Skip to content

Commit

Permalink
Merge pull request worktile#119 from worktile/isStrictDecorate
Browse files Browse the repository at this point in the history
feat(decorate): support isStrictDecorate
  • Loading branch information
huanhuanwa authored Sep 18, 2021
2 parents 80fa11d + 97271d8 commit 75b4317
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/src/components/descendant/descendant.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export class SlateDescendantComponent extends ViewContainerItem<SlateElementCont
memoizedElementContext(prev: SlateElementContext, next: SlateElementContext) {
return (
prev.element === next.element &&
prev.decorate === next.decorate &&
(!this.viewContext.isStrictDecorate || prev.decorate === next.decorate) &&
prev.readonly === next.readonly &&
isDecoratorRangeListEqual(prev.decorations, next.decorations) &&
(prev.selection === next.selection ||
Expand Down
6 changes: 4 additions & 2 deletions packages/src/components/editable/editable.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@ export class SlateEditableComponent implements OnInit, OnChanges, OnDestroy, Aft

@Input() decorate: (entry: NodeEntry) => Range[] = () => [];

@Input() isStrictDecorate: boolean = true;

@Input() trackBy: (node: Element) => any = () => null;

@Input()
readonly = false;
@Input() readonly = false;

//#region input event handler
@Input() beforeInput: (event: Event) => void;
Expand Down Expand Up @@ -395,6 +396,7 @@ export class SlateEditableComponent implements OnInit, OnChanges, OnDestroy, Aft
renderLeaf: this.renderLeaf,
renderText: this.renderText,
trackBy: this.trackBy,
isStrictDecorate: this.isStrictDecorate,
templateComponent: this.templateComponent
};
}
Expand Down
1 change: 1 addition & 0 deletions packages/src/view/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface SlateViewContext<T extends AngularEditor = AngularEditor> {
renderElement?: (element: Element) => ViewType;
renderLeaf?: (text: Text) => ViewType;
renderText?: (text: Text) => ViewType;
isStrictDecorate: boolean
}

export interface SlateChildrenContext {
Expand Down

0 comments on commit 75b4317

Please sign in to comment.