Skip to content

Commit

Permalink
fix(core): add emptyTextTemplate #WIK-4475
Browse files Browse the repository at this point in the history
  • Loading branch information
huanhuanwa committed Aug 3, 2021
1 parent 01dcce7 commit 7160bca
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/src/components/string/string.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class SlateStringComponent extends ViewContainerItem<SlateStringContext>
// node, so we render a zero-width space so that the selection can be
// inserted next to it still.
if (this.context.leaf.text === '') {
return this.viewContext.templateComponent.emptyStringTemplate;
return this.viewContext.templateComponent.emptyTextTemplate;
}

// COMPAT: Browsers will collapse trailing new lines at the end of blocks,
Expand Down
3 changes: 3 additions & 0 deletions packages/src/components/string/template.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<ng-template #emptyStringTemplate let-context="context" let-viewContext="viewContext">
<span data-slate-zero-width="z" attr.data-slate-length="{{ context.elementStringLength }}">{{ '\uFEFF' }}</span>
</ng-template>
<ng-template #emptyTextTemplate let-context="context" let-viewContext="viewContext">
<span data-slate-zero-width="z" data-slate-length="0">{{ '\uFEFF' }}</span>
</ng-template>
<ng-template #lineBreakEmptyStringTemplate let-context="context" let-viewContext="viewContext">
<span data-slate-zero-width="n" attr.data-slate-length="{{ context.elementStringLength }}">{{ '\uFEFF'
}}<br /></span>
Expand Down
3 changes: 3 additions & 0 deletions packages/src/components/string/template.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export class SlateStringTemplateComponent {
@ViewChild('emptyStringTemplate', { read: TemplateRef, static: true })
emptyStringTemplate: TemplateRef<any>;

@ViewChild('emptyTextTemplate', { read: TemplateRef, static: true })
emptyTextTemplate: TemplateRef<any>;

@ViewChild('lineBreakEmptyStringTemplate', { read: TemplateRef, static: true })
lineBreakEmptyStringTemplate: TemplateRef<any>;
}

0 comments on commit 7160bca

Please sign in to comment.