slate-angular 14.1.3 → 15.1.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/components/block-card/block-card.component.d.ts +2 -2
  2. package/components/block-card/block-card.component.scss +3 -2
  3. package/components/children/children.component.d.ts +5 -5
  4. package/components/descendant/descendant.component.d.ts +6 -6
  5. package/components/editable/editable.component.d.ts +1 -1
  6. package/components/element/default-element.component.d.ts +1 -1
  7. package/components/element/default-element.component.token.d.ts +3 -3
  8. package/components/element/element.component.d.ts +1 -1
  9. package/components/leaf/default-leaf.component.d.ts +3 -3
  10. package/components/leaf/leaf.component.d.ts +6 -6
  11. package/components/leaves/leaves.component.d.ts +5 -5
  12. package/components/string/default-string.component.d.ts +13 -0
  13. package/components/string/string.component.d.ts +3 -2
  14. package/components/string/template.component.d.ts +1 -2
  15. package/components/text/default-text.component.d.ts +1 -1
  16. package/components/text/void-text.component.d.ts +1 -1
  17. package/esm2020/components/block-card/block-card.component.mjs +10 -10
  18. package/esm2020/components/children/children.component.mjs +24 -21
  19. package/esm2020/components/descendant/descendant.component.mjs +27 -25
  20. package/esm2020/components/editable/editable.component.mjs +135 -55
  21. package/esm2020/components/element/default-element.component.mjs +4 -4
  22. package/esm2020/components/element/default-element.component.token.mjs +2 -2
  23. package/esm2020/components/element/element.component.mjs +4 -4
  24. package/esm2020/components/leaf/default-leaf.component.mjs +7 -7
  25. package/esm2020/components/leaf/leaf.component.mjs +9 -9
  26. package/esm2020/components/leaves/leaves.component.mjs +18 -16
  27. package/esm2020/components/string/default-string.component.mjs +31 -0
  28. package/esm2020/components/string/string.component.mjs +10 -6
  29. package/esm2020/components/string/template.component.mjs +10 -10
  30. package/esm2020/components/text/default-text.component.mjs +4 -4
  31. package/esm2020/components/text/void-text.component.mjs +6 -6
  32. package/esm2020/custom-event/BeforeInputEventPlugin.mjs +1 -1
  33. package/esm2020/custom-event/before-input-polyfill.mjs +2 -2
  34. package/esm2020/module.mjs +25 -10
  35. package/esm2020/plugins/angular-editor.mjs +33 -50
  36. package/esm2020/plugins/with-angular.mjs +11 -8
  37. package/esm2020/public-api.mjs +2 -1
  38. package/esm2020/types/error.mjs +1 -1
  39. package/esm2020/types/feature.mjs +1 -1
  40. package/esm2020/types/view.mjs +1 -1
  41. package/esm2020/utils/block-card.mjs +1 -1
  42. package/esm2020/utils/dom.mjs +4 -8
  43. package/esm2020/utils/environment.mjs +5 -9
  44. package/esm2020/utils/global-normalize.mjs +5 -8
  45. package/esm2020/utils/hotkeys.mjs +1 -1
  46. package/esm2020/utils/index.mjs +1 -1
  47. package/esm2020/utils/lines.mjs +1 -1
  48. package/esm2020/utils/range-list.mjs +1 -1
  49. package/esm2020/utils/restore-dom.mjs +33 -0
  50. package/esm2020/utils/view.mjs +2 -2
  51. package/esm2020/utils/weak-maps.mjs +1 -1
  52. package/esm2020/view/base.mjs +20 -20
  53. package/esm2020/view/before-context-change.mjs +1 -1
  54. package/esm2020/view/container-item.mjs +20 -14
  55. package/esm2020/view/container.mjs +8 -8
  56. package/esm2020/view/context.mjs +1 -1
  57. package/fesm2015/slate-angular.mjs +402 -256
  58. package/fesm2015/slate-angular.mjs.map +1 -1
  59. package/fesm2020/slate-angular.mjs +402 -257
  60. package/fesm2020/slate-angular.mjs.map +1 -1
  61. package/module.d.ts +3 -2
  62. package/package.json +5 -5
  63. package/plugins/angular-editor.d.ts +4 -4
  64. package/public-api.d.ts +1 -0
  65. package/styles/index.scss +3 -4
  66. package/types/error.d.ts +1 -1
  67. package/types/feature.d.ts +1 -1
  68. package/types/index.d.ts +1 -1
  69. package/types/view.d.ts +2 -2
  70. package/utils/block-card.d.ts +1 -1
  71. package/utils/dom.d.ts +4 -4
  72. package/utils/global-normalize.d.ts +1 -1
  73. package/utils/restore-dom.d.ts +2 -0
  74. package/utils/view.d.ts +2 -2
  75. package/view/base.d.ts +8 -8
  76. package/view/container-item.d.ts +6 -6
  77. package/view/container.d.ts +4 -4
  78. package/view/context.d.ts +5 -5
package/module.d.ts CHANGED
@@ -12,9 +12,10 @@ import * as i10 from "./components/block-card/block-card.component";
12
12
  import * as i11 from "./components/leaf/leaf.component";
13
13
  import * as i12 from "./components/leaves/leaves.component";
14
14
  import * as i13 from "./components/leaf/default-leaf.component";
15
- import * as i14 from "@angular/common";
15
+ import * as i14 from "./components/string/default-string.component";
16
+ import * as i15 from "@angular/common";
16
17
  export declare class SlateModule {
17
18
  static ɵfac: i0.ɵɵFactoryDeclaration<SlateModule, never>;
18
- static ɵmod: i0.ɵɵNgModuleDeclaration<SlateModule, [typeof i1.SlateEditableComponent, typeof i2.SlateDefaultElementComponent, typeof i3.SlateElementComponent, typeof i4.SlateVoidTextComponent, typeof i5.SlateDefaultTextComponent, typeof i6.SlateStringComponent, typeof i7.SlateStringTemplateComponent, typeof i8.SlateDescendantComponent, typeof i9.SlateChildrenComponent, typeof i10.SlateBlockCardComponent, typeof i11.SlateLeafComponent, typeof i12.SlateLeavesComponent, typeof i13.SlateDefaultLeafComponent], [typeof i14.CommonModule], [typeof i1.SlateEditableComponent, typeof i9.SlateChildrenComponent, typeof i3.SlateElementComponent, typeof i12.SlateLeavesComponent, typeof i6.SlateStringComponent]>;
19
+ static ɵmod: i0.ɵɵNgModuleDeclaration<SlateModule, [typeof i1.SlateEditableComponent, typeof i2.SlateDefaultElementComponent, typeof i3.SlateElementComponent, typeof i4.SlateVoidTextComponent, typeof i5.SlateDefaultTextComponent, typeof i6.SlateStringComponent, typeof i7.SlateStringTemplateComponent, typeof i8.SlateDescendantComponent, typeof i9.SlateChildrenComponent, typeof i10.SlateBlockCardComponent, typeof i11.SlateLeafComponent, typeof i12.SlateLeavesComponent, typeof i13.SlateDefaultLeafComponent, typeof i14.SlateDefaultStringComponent], [typeof i15.CommonModule], [typeof i1.SlateEditableComponent, typeof i9.SlateChildrenComponent, typeof i3.SlateElementComponent, typeof i12.SlateLeavesComponent, typeof i6.SlateStringComponent, typeof i14.SlateDefaultStringComponent]>;
19
20
  static ɵinj: i0.ɵɵInjectorDeclaration<SlateModule>;
20
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slate-angular",
3
- "version": "14.1.3",
3
+ "version": "15.1.0-next.0",
4
4
  "description": "Angular view layer for Slate",
5
5
  "author": "pubuzhixing <pubuzhixing@gmail.com>",
6
6
  "homepage": "https://github.com/worktile/slate-angular#readme",
@@ -12,6 +12,9 @@
12
12
  "direction": "^1.0.3",
13
13
  "is-hotkey": "^0.1.6"
14
14
  },
15
+ "dependencies": {
16
+ "tslib": "^2.5.0"
17
+ },
15
18
  "exports": {
16
19
  ".": {
17
20
  "sass": "./styles/index.scss",
@@ -38,8 +41,5 @@
38
41
  "fesm2020": "fesm2020/slate-angular.mjs",
39
42
  "fesm2015": "fesm2015/slate-angular.mjs",
40
43
  "typings": "index.d.ts",
41
- "sideEffects": false,
42
- "dependencies": {
43
- "tslib": "^2.0.0"
44
- }
44
+ "sideEffects": false
45
45
  }
@@ -76,8 +76,8 @@ export declare const AngularEditor: {
76
76
  */
77
77
  insertData(editor: AngularEditor, data: DataTransfer): void;
78
78
  /**
79
- * Insert fragment data from a `DataTransfer` into the editor.
80
- */
79
+ * Insert fragment data from a `DataTransfer` into the editor.
80
+ */
81
81
  insertFragmentData(editor: AngularEditor, data: DataTransfer): boolean;
82
82
  /**
83
83
  * Insert text data from a `DataTransfer` into the editor.
@@ -88,8 +88,8 @@ export declare const AngularEditor: {
88
88
  */
89
89
  onKeydown(editor: AngularEditor, data: KeyboardEvent): void;
90
90
  /**
91
- * onClick hook.
92
- */
91
+ * onClick hook.
92
+ */
93
93
  onClick(editor: AngularEditor, data: MouseEvent): void;
94
94
  /**
95
95
  * Sets data from the currently selected fragment on a `DataTransfer`.
package/public-api.d.ts CHANGED
@@ -3,6 +3,7 @@ export * from './plugins/with-angular';
3
3
  export * from './components/editable/editable.component';
4
4
  export * from './components/element/element.component';
5
5
  export * from './components/string/string.component';
6
+ export * from './components/string/default-string.component';
6
7
  export * from './components/children/children.component';
7
8
  export * from './components/leaves/leaves.component';
8
9
  export * from './module';
package/styles/index.scss CHANGED
@@ -4,7 +4,7 @@
4
4
  outline: none;
5
5
  padding: 32px;
6
6
  white-space: break-spaces;
7
- & [contenteditable="true"] {
7
+ & [contenteditable='true'] {
8
8
  outline: none;
9
9
  }
10
10
  & [data-slate-placeholder] {
@@ -18,7 +18,7 @@
18
18
  text-decoration: none;
19
19
  top: 0;
20
20
  }
21
- & [data-slate-leaf="true"] {
21
+ & [data-slate-leaf='true'] {
22
22
  &.leaf-with-placeholder {
23
23
  position: relative;
24
24
  display: inline-block;
@@ -32,7 +32,6 @@
32
32
  .leaf-with-placeholder {
33
33
  display: inline-flex !important;
34
34
  }
35
-
36
35
  }
37
36
  }
38
37
 
@@ -41,4 +40,4 @@
41
40
  color: transparent;
42
41
  outline: none;
43
42
  position: absolute;
44
- }
43
+ }
package/types/error.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Descendant } from "slate";
1
+ import { Descendant } from 'slate';
2
2
  export declare enum SlateErrorCode {
3
3
  ToNativeSelectionError = 2100,
4
4
  ToSlateSelectionError = 2101,
@@ -1,4 +1,4 @@
1
- import { BaseRange } from "slate";
1
+ import { BaseRange } from 'slate';
2
2
  export interface SlatePlaceholder extends BaseRange {
3
3
  placeholder: string;
4
4
  }
package/types/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export * from './error';
2
2
  export * from './view';
3
3
  export * from './feature';
4
- export declare type SafeAny = any;
4
+ export type SafeAny = any;
package/types/view.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { TemplateRef } from "@angular/core";
1
+ import { TemplateRef } from '@angular/core';
2
2
  export interface ComponentType<T> {
3
3
  new (...args: any[]): T;
4
4
  }
5
- export declare type ViewType = TemplateRef<any> | ComponentType<any>;
5
+ export type ViewType = TemplateRef<any> | ComponentType<any>;
@@ -1,4 +1,4 @@
1
- import { DOMNode, DOMSelection } from "./dom";
1
+ import { DOMNode, DOMSelection } from './dom';
2
2
  export declare const FAKE_LEFT_BLOCK_CARD_OFFSET = -1;
3
3
  export declare const FAKE_RIGHT_BLOCK_CARD_OFFSET = -2;
4
4
  export declare function hasBlockCardWithNode(node: DOMNode): boolean;
package/utils/dom.d.ts CHANGED
@@ -11,12 +11,12 @@ import DOMStaticRange = globalThis.StaticRange;
11
11
  export { DOMNode, DOMComment, DOMElement, DOMText, DOMRange, DOMSelection, DOMStaticRange };
12
12
  declare global {
13
13
  interface Window {
14
- Selection: typeof Selection['constructor'];
15
- DataTransfer: typeof DataTransfer['constructor'];
16
- Node: typeof Node['constructor'];
14
+ Selection: (typeof Selection)['constructor'];
15
+ DataTransfer: (typeof DataTransfer)['constructor'];
16
+ Node: (typeof Node)['constructor'];
17
17
  }
18
18
  }
19
- export declare type DOMPoint = [Node, number];
19
+ export type DOMPoint = [Node, number];
20
20
  /**
21
21
  * Returns the host window of a DOM node
22
22
  */
@@ -1,4 +1,4 @@
1
- import { Descendant, Element } from "slate";
1
+ import { Descendant, Element } from 'slate';
2
2
  declare const isValid: (value: Descendant) => any;
3
3
  declare const check: (document: Element[]) => boolean;
4
4
  declare function normalize(document: Element[]): import("slate").BaseElement[];
@@ -0,0 +1,2 @@
1
+ import { Editor } from 'slate';
2
+ export declare function restoreDom(editor: Editor, execute: () => void): void;
package/utils/view.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { TemplateRef } from "@angular/core";
2
- import { ComponentType, ViewType } from "../types/view";
1
+ import { TemplateRef } from '@angular/core';
2
+ import { ComponentType, ViewType } from '../types/view';
3
3
  export declare function isTemplateRef<C>(value: ViewType): value is TemplateRef<C>;
4
4
  export declare function isComponentType<T>(value: ViewType): value is ComponentType<T>;
package/view/base.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { ChangeDetectorRef, ElementRef, OnDestroy, OnInit } from "@angular/core";
2
- import { AngularEditor } from "../plugins/angular-editor";
3
- import { SlateViewContext, SlateElementContext, SlateTextContext, SlateLeafContext } from "./context";
1
+ import { ChangeDetectorRef, ElementRef, OnDestroy, OnInit } from '@angular/core';
2
+ import { AngularEditor } from '../plugins/angular-editor';
3
+ import { SlateViewContext, SlateElementContext, SlateTextContext, SlateLeafContext } from './context';
4
4
  import { Descendant, Element, Range, Text } from 'slate';
5
- import { SlateChildrenContext } from "./context";
5
+ import { SlateChildrenContext } from './context';
6
6
  import * as i0 from "@angular/core";
7
7
  /**
8
8
  * base class for template
@@ -26,7 +26,7 @@ export declare abstract class BaseComponent<T = SlateTextContext | SlateLeafCont
26
26
  constructor(elementRef: ElementRef, cdr: ChangeDetectorRef);
27
27
  abstract onContextChange(): any;
28
28
  static ɵfac: i0.ɵɵFactoryDeclaration<BaseComponent<any, any>, never>;
29
- static ɵdir: i0.ɵɵDirectiveDeclaration<BaseComponent<any, any>, never, never, { "context": "context"; "viewContext": "viewContext"; }, {}, never, never, false>;
29
+ static ɵdir: i0.ɵɵDirectiveDeclaration<BaseComponent<any, any>, never, never, { "context": "context"; "viewContext": "viewContext"; }, {}, never, never, false, never>;
30
30
  }
31
31
  /**
32
32
  * base class for custom leaf component
@@ -44,7 +44,7 @@ export declare class BaseLeafComponent extends BaseComponent<SlateLeafContext> i
44
44
  updatePlaceholder(): void;
45
45
  destroyPlaceholder(): void;
46
46
  static ɵfac: i0.ɵɵFactoryDeclaration<BaseLeafComponent, never>;
47
- static ɵdir: i0.ɵɵDirectiveDeclaration<BaseLeafComponent, never, never, {}, {}, never, never, false>;
47
+ static ɵdir: i0.ɵɵDirectiveDeclaration<BaseLeafComponent, never, never, {}, {}, never, never, false, never>;
48
48
  }
49
49
  /**
50
50
  * base class for custom element component
@@ -65,7 +65,7 @@ export declare class BaseElementComponent<T extends Element = Element, K extends
65
65
  onContextChange(): void;
66
66
  getChildrenContext(): SlateChildrenContext;
67
67
  static ɵfac: i0.ɵɵFactoryDeclaration<BaseElementComponent<any, any>, never>;
68
- static ɵdir: i0.ɵɵDirectiveDeclaration<BaseElementComponent<any, any>, never, never, {}, {}, never, never, false>;
68
+ static ɵdir: i0.ɵɵDirectiveDeclaration<BaseElementComponent<any, any>, never, never, {}, {}, never, never, false, never>;
69
69
  }
70
70
  /**
71
71
  * base class for custom text component
@@ -78,5 +78,5 @@ export declare class BaseTextComponent extends BaseComponent<SlateTextContext> i
78
78
  ngOnDestroy(): void;
79
79
  onContextChange(): void;
80
80
  static ɵfac: i0.ɵɵFactoryDeclaration<BaseTextComponent, never>;
81
- static ɵdir: i0.ɵɵDirectiveDeclaration<BaseTextComponent, never, never, {}, {}, never, never, false>;
81
+ static ɵdir: i0.ɵɵDirectiveDeclaration<BaseTextComponent, never, never, {}, {}, never, never, false, never>;
82
82
  }
@@ -1,8 +1,8 @@
1
- import { ComponentRef, EmbeddedViewRef, ViewContainerRef } from "@angular/core";
2
- import { SlateBlockCardComponent } from "../components/block-card/block-card.component";
3
- import { ViewType } from "../types/view";
4
- import { BaseComponent, BaseEmbeddedView } from "./base";
5
- import { SlateElementContext, SlateLeafContext, SlateStringContext, SlateTextContext, SlateViewContext } from "./context";
1
+ import { ComponentRef, EmbeddedViewRef, ViewContainerRef } from '@angular/core';
2
+ import { SlateBlockCardComponent } from '../components/block-card/block-card.component';
3
+ import { ViewType } from '../types/view';
4
+ import { BaseComponent, BaseEmbeddedView } from './base';
5
+ import { SlateElementContext, SlateLeafContext, SlateStringContext, SlateTextContext, SlateViewContext } from './context';
6
6
  import * as i0 from "@angular/core";
7
7
  /**
8
8
  * Dynamically create/update components or templates
@@ -29,5 +29,5 @@ export declare abstract class ViewContainerItem<T = SlateElementContext | SlateT
29
29
  updateView(): void;
30
30
  appendBlockCardElement(): void;
31
31
  static ɵfac: i0.ɵɵFactoryDeclaration<ViewContainerItem<any, any>, never>;
32
- static ɵdir: i0.ɵɵDirectiveDeclaration<ViewContainerItem<any, any>, never, never, { "viewContext": "viewContext"; }, {}, never, never, false>;
32
+ static ɵdir: i0.ɵɵDirectiveDeclaration<ViewContainerItem<any, any>, never, never, { "viewContext": "viewContext"; }, {}, never, never, false, never>;
33
33
  }
@@ -1,6 +1,6 @@
1
- import { AfterViewInit, ElementRef, IterableChangeRecord, IterableDiffers, QueryList } from "@angular/core";
2
- import { SlateViewContext } from "./context";
3
- import { ViewContainerItem } from "./container-item";
1
+ import { AfterViewInit, ElementRef, IterableChangeRecord, IterableDiffers, QueryList } from '@angular/core';
2
+ import { SlateViewContext } from './context';
3
+ import { ViewContainerItem } from './container-item';
4
4
  import * as i0 from "@angular/core";
5
5
  /**
6
6
  * the sepcial container for angular template
@@ -18,5 +18,5 @@ export declare abstract class ViewContainer<T extends ViewContainerItem> impleme
18
18
  createFragment(): DocumentFragment;
19
19
  handleContainerItemChange(record: IterableChangeRecord<T>, parentElement: HTMLElement): void;
20
20
  static ɵfac: i0.ɵɵFactoryDeclaration<ViewContainer<any>, never>;
21
- static ɵdir: i0.ɵɵDirectiveDeclaration<ViewContainer<any>, never, never, { "viewContext": "viewContext"; }, {}, never, never, false>;
21
+ static ɵdir: i0.ɵɵDirectiveDeclaration<ViewContainer<any>, never, never, { "viewContext": "viewContext"; }, {}, never, never, false, never>;
22
22
  }
package/view/context.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { NodeEntry, Range, Element, Ancestor, Text } from "slate";
2
- import { SlateStringTemplateComponent } from "../components/string/template.component";
3
- import { AngularEditor } from "../plugins/angular-editor";
4
- import { ViewType } from "../types/view";
1
+ import { NodeEntry, Range, Element, Ancestor, Text } from 'slate';
2
+ import { SlateStringTemplateComponent } from '../components/string/template.component';
3
+ import { AngularEditor } from '../plugins/angular-editor';
4
+ import { ViewType } from '../types/view';
5
5
  export interface SlateViewContext<T extends AngularEditor = AngularEditor> {
6
6
  editor: T;
7
7
  templateComponent: SlateStringTemplateComponent;
@@ -43,7 +43,7 @@ export interface SlateElementAttributes {
43
43
  'data-slate-node': 'element';
44
44
  'data-slate-void'?: boolean;
45
45
  'data-slate-inline'?: boolean;
46
- 'contenteditable'?: boolean;
46
+ contenteditable?: boolean;
47
47
  'data-slate-key'?: string;
48
48
  dir?: 'rtl';
49
49
  }