Skip to content

Commit

Permalink
fix(core): use context selection calc isCollapsed and resolve editor …
Browse files Browse the repository at this point in the history
…is undefined error
  • Loading branch information
pubuzhixing8 committed Aug 23, 2022
1 parent 9d0dae0 commit cbc2b33
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/funny-jars-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"slate-angular": minor
---

use context selection calc isCollapsed and resolve editor is undefined error
4 changes: 2 additions & 2 deletions packages/src/view/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ export class BaseElementComponent<T extends Element = Element, K extends Angular
}

get isCollapsed() {
return this.selection && Range.isCollapsed(this.editor.selection);
return this.selection && Range.isCollapsed(this.selection);
}

get isCollapsedAndNonReadonly() {
return this.selection && Range.isCollapsed(this.editor.selection) && !this.readonly;
return this.selection && Range.isCollapsed(this.selection) && !this.readonly;
}

get readonly() {
Expand Down
2 changes: 1 addition & 1 deletion packages/src/view/container-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ export abstract class ViewContainerItem<T = SlateElementContext | SlateTextConte
}
if (isComponentType(this.viewType)) {
const componentRef = this.viewContainerRef.createComponent(this.viewType);
componentRef.instance.context = context;
componentRef.instance.viewContext = this.viewContext;
componentRef.instance.context = context;
this.componentRef = componentRef;
}
}
Expand Down

0 comments on commit cbc2b33

Please sign in to comment.