slate-angular 15.0.0 → 15.1.0-next.1
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.
- package/components/block-card/block-card.component.d.ts +1 -1
- package/components/block-card/block-card.component.scss +3 -2
- package/components/children/children.component.d.ts +4 -4
- package/components/descendant/descendant.component.d.ts +5 -5
- package/components/element/default-element.component.token.d.ts +3 -3
- package/components/leaf/default-leaf.component.d.ts +2 -2
- package/components/leaf/leaf.component.d.ts +5 -5
- package/components/leaves/leaves.component.d.ts +4 -4
- package/components/string/default-string.component.d.ts +13 -0
- package/components/string/string.component.d.ts +2 -1
- package/components/string/template.component.d.ts +0 -1
- package/esm2020/components/block-card/block-card.component.mjs +5 -5
- package/esm2020/components/children/children.component.mjs +22 -19
- package/esm2020/components/descendant/descendant.component.mjs +19 -17
- package/esm2020/components/editable/editable.component.mjs +138 -48
- package/esm2020/components/element/default-element.component.mjs +1 -1
- package/esm2020/components/element/default-element.component.token.mjs +2 -2
- package/esm2020/components/element/element.component.mjs +1 -1
- package/esm2020/components/leaf/default-leaf.component.mjs +5 -5
- package/esm2020/components/leaf/leaf.component.mjs +6 -6
- package/esm2020/components/leaves/leaves.component.mjs +15 -13
- package/esm2020/components/string/default-string.component.mjs +31 -0
- package/esm2020/components/string/string.component.mjs +7 -3
- package/esm2020/components/string/template.component.mjs +8 -8
- package/esm2020/components/text/default-text.component.mjs +1 -1
- package/esm2020/components/text/void-text.component.mjs +3 -3
- package/esm2020/custom-event/BeforeInputEventPlugin.mjs +1 -1
- package/esm2020/custom-event/before-input-polyfill.mjs +2 -2
- package/esm2020/module.mjs +21 -6
- package/esm2020/plugins/angular-editor.mjs +33 -50
- package/esm2020/plugins/with-angular.mjs +11 -8
- package/esm2020/public-api.mjs +2 -1
- package/esm2020/types/error.mjs +1 -1
- package/esm2020/types/feature.mjs +1 -1
- package/esm2020/types/view.mjs +1 -1
- package/esm2020/utils/block-card.mjs +1 -1
- package/esm2020/utils/dom.mjs +4 -8
- package/esm2020/utils/environment.mjs +5 -9
- package/esm2020/utils/global-normalize.mjs +5 -8
- package/esm2020/utils/hotkeys.mjs +1 -1
- package/esm2020/utils/index.mjs +1 -1
- package/esm2020/utils/lines.mjs +1 -1
- package/esm2020/utils/range-list.mjs +1 -1
- package/esm2020/utils/restore-dom.mjs +33 -0
- package/esm2020/utils/view.mjs +2 -2
- package/esm2020/utils/weak-maps.mjs +1 -1
- package/esm2020/view/base.mjs +4 -4
- package/esm2020/view/before-context-change.mjs +1 -1
- package/esm2020/view/container-item.mjs +13 -7
- package/esm2020/view/container.mjs +6 -6
- package/esm2020/view/context.mjs +1 -1
- package/fesm2015/slate-angular.mjs +337 -182
- package/fesm2015/slate-angular.mjs.map +1 -1
- package/fesm2020/slate-angular.mjs +337 -183
- package/fesm2020/slate-angular.mjs.map +1 -1
- package/module.d.ts +3 -2
- package/package.json +1 -1
- package/plugins/angular-editor.d.ts +4 -4
- package/public-api.d.ts +1 -0
- package/styles/index.scss +3 -4
- package/types/error.d.ts +1 -1
- package/types/feature.d.ts +1 -1
- package/types/view.d.ts +1 -1
- package/utils/block-card.d.ts +1 -1
- package/utils/dom.d.ts +3 -3
- package/utils/global-normalize.d.ts +1 -1
- package/utils/restore-dom.d.ts +2 -0
- package/utils/view.d.ts +2 -2
- package/view/base.d.ts +4 -4
- package/view/container-item.d.ts +5 -5
- package/view/container.d.ts +4 -4
- package/view/context.d.ts +5 -5
|
@@ -65,7 +65,7 @@ var DOMStaticRange = globalThis.StaticRange;
|
|
|
65
65
|
* Returns the host window of a DOM node
|
|
66
66
|
*/
|
|
67
67
|
const getDefaultView = (value) => {
|
|
68
|
-
return (
|
|
68
|
+
return (value && value.ownerDocument && value.ownerDocument.defaultView) || null;
|
|
69
69
|
};
|
|
70
70
|
/**
|
|
71
71
|
* Check if a DOM node is a comment node.
|
|
@@ -103,9 +103,7 @@ const isDOMText = (value) => {
|
|
|
103
103
|
* Checks whether a paste event is a plaintext-only event.
|
|
104
104
|
*/
|
|
105
105
|
const isPlainTextOnlyPaste = (event) => {
|
|
106
|
-
return (event.clipboardData
|
|
107
|
-
event.clipboardData.getData('text/plain') !== '' &&
|
|
108
|
-
event.clipboardData.types.length === 1);
|
|
106
|
+
return event.clipboardData && event.clipboardData.getData('text/plain') !== '' && event.clipboardData.types.length === 1;
|
|
109
107
|
};
|
|
110
108
|
/**
|
|
111
109
|
* Normalize a DOM point so that it always refers to a text node.
|
|
@@ -117,7 +115,6 @@ const normalizeDOMPoint = (domPoint) => {
|
|
|
117
115
|
if (isDOMElement(node) && node.childNodes.length) {
|
|
118
116
|
let isLast = offset === node.childNodes.length;
|
|
119
117
|
let index = isLast ? offset - 1 : offset;
|
|
120
|
-
;
|
|
121
118
|
[node, index] = getEditableChildAndIndex(node, index, isLast ? 'backward' : 'forward');
|
|
122
119
|
// If the editable child found is in front of input offset, we instead seek to its end
|
|
123
120
|
isLast = index < offset;
|
|
@@ -128,8 +125,7 @@ const normalizeDOMPoint = (domPoint) => {
|
|
|
128
125
|
node = getEditableChild(node, i, isLast ? 'backward' : 'forward');
|
|
129
126
|
}
|
|
130
127
|
// Determine the new offset inside the text node.
|
|
131
|
-
offset =
|
|
132
|
-
isLast && node.textContent != null ? node.textContent.length : 0;
|
|
128
|
+
offset = isLast && node.textContent != null ? node.textContent.length : 0;
|
|
133
129
|
}
|
|
134
130
|
// Return the node and offset.
|
|
135
131
|
return [node, offset];
|
|
@@ -254,13 +250,10 @@ const IS_IOS = typeof navigator !== 'undefined' &&
|
|
|
254
250
|
!window.MSStream;
|
|
255
251
|
const IS_APPLE = typeof navigator !== 'undefined' && /Mac OS X/.test(navigator.userAgent);
|
|
256
252
|
const IS_ANDROID = typeof navigator !== 'undefined' && /Android/.test(navigator.userAgent);
|
|
257
|
-
const IS_FIREFOX = typeof navigator !== 'undefined' &&
|
|
258
|
-
|
|
259
|
-
const IS_SAFARI = typeof navigator !== 'undefined' &&
|
|
260
|
-
/Version\/[\d\.]+.*Safari/.test(navigator.userAgent);
|
|
253
|
+
const IS_FIREFOX = typeof navigator !== 'undefined' && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
|
|
254
|
+
const IS_SAFARI = typeof navigator !== 'undefined' && /Version\/[\d\.]+.*Safari/.test(navigator.userAgent);
|
|
261
255
|
// "modern" Edge was released at 79.x
|
|
262
|
-
const IS_EDGE_LEGACY = typeof navigator !== 'undefined' &&
|
|
263
|
-
/Edge?\/(?:[0-6][0-9]|[0-7][0-8])(?:\.)/i.test(navigator.userAgent);
|
|
256
|
+
const IS_EDGE_LEGACY = typeof navigator !== 'undefined' && /Edge?\/(?:[0-6][0-9]|[0-7][0-8])(?:\.)/i.test(navigator.userAgent);
|
|
264
257
|
const IS_CHROME = typeof navigator !== 'undefined' && /Chrome/i.test(navigator.userAgent);
|
|
265
258
|
// Native beforeInput events don't work well with react on Chrome 75 and older, Chrome 76+ can use beforeInput
|
|
266
259
|
const IS_CHROME_LEGACY = typeof navigator !== 'undefined' &&
|
|
@@ -268,8 +261,7 @@ const IS_CHROME_LEGACY = typeof navigator !== 'undefined' &&
|
|
|
268
261
|
// Exclude Chrome version greater than 3 bits,Chrome releases v100 on 2022.03.29
|
|
269
262
|
!/Chrome?\/(?:\d{3,})/i.test(navigator.userAgent);
|
|
270
263
|
// Firefox did not support `beforeInput` until `v87`.
|
|
271
|
-
const IS_FIREFOX_LEGACY = typeof navigator !== 'undefined' &&
|
|
272
|
-
/^(?!.*Seamonkey)(?=.*Firefox\/(?:[0-7][0-9]|[0-8][0-6])(?:\.)).*/i.test(navigator.userAgent);
|
|
264
|
+
const IS_FIREFOX_LEGACY = typeof navigator !== 'undefined' && /^(?!.*Seamonkey)(?=.*Firefox\/(?:[0-7][0-9]|[0-8][0-6])(?:\.)).*/i.test(navigator.userAgent);
|
|
273
265
|
// qq browser
|
|
274
266
|
const IS_QQBROWSER = typeof navigator !== 'undefined' && /.*QQBrowser/.test(navigator.userAgent);
|
|
275
267
|
// UC mobile browser
|
|
@@ -372,8 +364,7 @@ const AngularEditor = {
|
|
|
372
364
|
findDocumentOrShadowRoot(editor) {
|
|
373
365
|
const el = AngularEditor.toDOMNode(editor, editor);
|
|
374
366
|
const root = el.getRootNode();
|
|
375
|
-
if ((root instanceof Document || root instanceof ShadowRoot) &&
|
|
376
|
-
root.getSelection != null) {
|
|
367
|
+
if ((root instanceof Document || root instanceof ShadowRoot) && root.getSelection != null) {
|
|
377
368
|
return root;
|
|
378
369
|
}
|
|
379
370
|
return el.ownerDocument;
|
|
@@ -402,7 +393,10 @@ const AngularEditor = {
|
|
|
402
393
|
return false;
|
|
403
394
|
}
|
|
404
395
|
const [start, end] = Range.edges(selection);
|
|
405
|
-
const endBlock = Editor.above(editor, {
|
|
396
|
+
const endBlock = Editor.above(editor, {
|
|
397
|
+
at: end,
|
|
398
|
+
match: node => Editor.isBlock(editor, node)
|
|
399
|
+
});
|
|
406
400
|
return Editor.isStart(editor, end, endBlock[1]);
|
|
407
401
|
},
|
|
408
402
|
/**
|
|
@@ -463,9 +457,8 @@ const AngularEditor = {
|
|
|
463
457
|
if (!targetEl) {
|
|
464
458
|
return false;
|
|
465
459
|
}
|
|
466
|
-
return targetEl.closest(`[data-slate-editor]`) === editorEl &&
|
|
467
|
-
(!editable || targetEl.isContentEditable ||
|
|
468
|
-
!!targetEl.getAttribute('data-slate-zero-width'));
|
|
460
|
+
return (targetEl.closest(`[data-slate-editor]`) === editorEl &&
|
|
461
|
+
(!editable || targetEl.isContentEditable || !!targetEl.getAttribute('data-slate-zero-width')));
|
|
469
462
|
},
|
|
470
463
|
/**
|
|
471
464
|
* Insert data from a `DataTransfer` into the editor.
|
|
@@ -474,8 +467,8 @@ const AngularEditor = {
|
|
|
474
467
|
editor.insertData(data);
|
|
475
468
|
},
|
|
476
469
|
/**
|
|
477
|
-
|
|
478
|
-
|
|
470
|
+
* Insert fragment data from a `DataTransfer` into the editor.
|
|
471
|
+
*/
|
|
479
472
|
insertFragmentData(editor, data) {
|
|
480
473
|
return editor.insertFragmentData(data);
|
|
481
474
|
},
|
|
@@ -492,8 +485,8 @@ const AngularEditor = {
|
|
|
492
485
|
editor.onKeydown(data);
|
|
493
486
|
},
|
|
494
487
|
/**
|
|
495
|
-
|
|
496
|
-
|
|
488
|
+
* onClick hook.
|
|
489
|
+
*/
|
|
497
490
|
onClick(editor, data) {
|
|
498
491
|
editor.onClick(data);
|
|
499
492
|
},
|
|
@@ -510,9 +503,7 @@ const AngularEditor = {
|
|
|
510
503
|
* Find the native DOM element from a Slate node.
|
|
511
504
|
*/
|
|
512
505
|
toDOMNode(editor, node) {
|
|
513
|
-
const domNode = Editor.isEditor(node)
|
|
514
|
-
? EDITOR_TO_ELEMENT.get(editor)
|
|
515
|
-
: NODE_TO_ELEMENT.get(node);
|
|
506
|
+
const domNode = Editor.isEditor(node) ? EDITOR_TO_ELEMENT.get(editor) : NODE_TO_ELEMENT.get(node);
|
|
516
507
|
if (!domNode) {
|
|
517
508
|
throw new Error(`Cannot resolve a DOM node from Slate node: ${JSON.stringify(node)}`);
|
|
518
509
|
}
|
|
@@ -588,13 +579,9 @@ const AngularEditor = {
|
|
|
588
579
|
// A slate Point at zero-width Leaf always has an offset of 0 but a native DOM selection at
|
|
589
580
|
// zero-width node has an offset of 1 so we have to check if we are in a zero-width node and
|
|
590
581
|
// adjust the offset accordingly.
|
|
591
|
-
const startEl = (isDOMElement(startNode)
|
|
592
|
-
? startNode
|
|
593
|
-
: startNode.parentElement);
|
|
582
|
+
const startEl = (isDOMElement(startNode) ? startNode : startNode.parentElement);
|
|
594
583
|
const isStartAtZeroWidth = !!startEl.getAttribute('data-slate-zero-width');
|
|
595
|
-
const endEl = (isDOMElement(endNode)
|
|
596
|
-
? endNode
|
|
597
|
-
: endNode.parentElement);
|
|
584
|
+
const endEl = (isDOMElement(endNode) ? endNode : endNode.parentElement);
|
|
598
585
|
const isEndAtZeroWidth = !!endEl.getAttribute('data-slate-zero-width');
|
|
599
586
|
domRange.setStart(startNode, isStartAtZeroWidth ? 1 : startOffset);
|
|
600
587
|
domRange.setEnd(endNode, isEndAtZeroWidth ? 1 : endOffset);
|
|
@@ -632,9 +619,7 @@ const AngularEditor = {
|
|
|
632
619
|
// coordinates are closest to.
|
|
633
620
|
if (Editor.isVoid(editor, node)) {
|
|
634
621
|
const rect = target.getBoundingClientRect();
|
|
635
|
-
const isPrev = editor.isInline(node)
|
|
636
|
-
? x - rect.left < rect.left + rect.width - x
|
|
637
|
-
: y - rect.top < rect.top + rect.height - y;
|
|
622
|
+
const isPrev = editor.isInline(node) ? x - rect.left < rect.left + rect.width - x : y - rect.top < rect.top + rect.height - y;
|
|
638
623
|
const edge = Editor.point(editor, path, {
|
|
639
624
|
edge: isPrev ? 'start' : 'end'
|
|
640
625
|
});
|
|
@@ -693,15 +678,11 @@ const AngularEditor = {
|
|
|
693
678
|
// forward
|
|
694
679
|
// and to the end of previous node
|
|
695
680
|
if (isCardLeftByTargetAttr(cardTargetAttr) && !isBackward) {
|
|
696
|
-
const endPath = blockPath[blockPath.length - 1] <= 0
|
|
697
|
-
? blockPath
|
|
698
|
-
: Path.previous(blockPath);
|
|
681
|
+
const endPath = blockPath[blockPath.length - 1] <= 0 ? blockPath : Path.previous(blockPath);
|
|
699
682
|
return Editor.end(editor, endPath);
|
|
700
683
|
}
|
|
701
684
|
// to the of current node
|
|
702
|
-
if ((isCardCenterByTargetAttr(cardTargetAttr) ||
|
|
703
|
-
isCardRightByTargetAttr(cardTargetAttr)) &&
|
|
704
|
-
!isBackward) {
|
|
685
|
+
if ((isCardCenterByTargetAttr(cardTargetAttr) || isCardRightByTargetAttr(cardTargetAttr)) && !isBackward) {
|
|
705
686
|
return Editor.end(editor, blockPath);
|
|
706
687
|
}
|
|
707
688
|
// backward
|
|
@@ -710,9 +691,7 @@ const AngularEditor = {
|
|
|
710
691
|
return Editor.start(editor, Path.next(blockPath));
|
|
711
692
|
}
|
|
712
693
|
// and to the start of current node
|
|
713
|
-
if ((isCardCenterByTargetAttr(cardTargetAttr) ||
|
|
714
|
-
isCardLeftByTargetAttr(cardTargetAttr)) &&
|
|
715
|
-
isBackward) {
|
|
694
|
+
if ((isCardCenterByTargetAttr(cardTargetAttr) || isCardLeftByTargetAttr(cardTargetAttr)) && isBackward) {
|
|
716
695
|
return Editor.start(editor, blockPath);
|
|
717
696
|
}
|
|
718
697
|
}
|
|
@@ -731,7 +710,7 @@ const AngularEditor = {
|
|
|
731
710
|
const contents = range.cloneContents();
|
|
732
711
|
const removals = [
|
|
733
712
|
...Array.prototype.slice.call(contents.querySelectorAll('[data-slate-zero-width]')),
|
|
734
|
-
...Array.prototype.slice.call(contents.querySelectorAll('[contenteditable=false]'))
|
|
713
|
+
...Array.prototype.slice.call(contents.querySelectorAll('[contenteditable=false]'))
|
|
735
714
|
];
|
|
736
715
|
removals.forEach(el => {
|
|
737
716
|
el.parentNode.removeChild(el);
|
|
@@ -758,9 +737,7 @@ const AngularEditor = {
|
|
|
758
737
|
// composition the ASCII characters will be prepended to the zero-width
|
|
759
738
|
// space, so subtract 1 from the offset to account for the zero-width
|
|
760
739
|
// space character.
|
|
761
|
-
if (domNode &&
|
|
762
|
-
offset === domNode.textContent.length &&
|
|
763
|
-
(parentNode && parentNode.hasAttribute('data-slate-zero-width'))) {
|
|
740
|
+
if (domNode && offset === domNode.textContent.length && parentNode && parentNode.hasAttribute('data-slate-zero-width')) {
|
|
764
741
|
offset--;
|
|
765
742
|
}
|
|
766
743
|
}
|
|
@@ -795,9 +772,7 @@ const AngularEditor = {
|
|
|
795
772
|
// (2020/08/08)
|
|
796
773
|
// https://bugs.chromium.org/p/chromium/issues/detail?id=447523
|
|
797
774
|
if (IS_CHROME && hasShadowRoot()) {
|
|
798
|
-
isCollapsed =
|
|
799
|
-
domRange.anchorNode === domRange.focusNode &&
|
|
800
|
-
domRange.anchorOffset === domRange.focusOffset;
|
|
775
|
+
isCollapsed = domRange.anchorNode === domRange.focusNode && domRange.anchorOffset === domRange.focusOffset;
|
|
801
776
|
}
|
|
802
777
|
else {
|
|
803
778
|
isCollapsed = domRange.isCollapsed;
|
|
@@ -822,22 +797,19 @@ const AngularEditor = {
|
|
|
822
797
|
return Element.isElement(node) && !editor.isInline(node) && Editor.hasInlines(editor, node);
|
|
823
798
|
},
|
|
824
799
|
isBlockCardLeftCursor(editor) {
|
|
825
|
-
return editor.selection.anchor.offset === FAKE_LEFT_BLOCK_CARD_OFFSET && editor.selection.focus.offset === FAKE_LEFT_BLOCK_CARD_OFFSET;
|
|
800
|
+
return (editor.selection.anchor.offset === FAKE_LEFT_BLOCK_CARD_OFFSET && editor.selection.focus.offset === FAKE_LEFT_BLOCK_CARD_OFFSET);
|
|
826
801
|
},
|
|
827
802
|
isBlockCardRightCursor(editor) {
|
|
828
|
-
return editor.selection.anchor.offset === FAKE_RIGHT_BLOCK_CARD_OFFSET &&
|
|
803
|
+
return (editor.selection.anchor.offset === FAKE_RIGHT_BLOCK_CARD_OFFSET &&
|
|
804
|
+
editor.selection.focus.offset === FAKE_RIGHT_BLOCK_CARD_OFFSET);
|
|
829
805
|
},
|
|
830
806
|
getCardCursorNode(editor, blockCardNode, options) {
|
|
831
807
|
const blockCardElement = AngularEditor.toDOMNode(editor, blockCardNode);
|
|
832
808
|
const cardCenter = blockCardElement.parentElement;
|
|
833
|
-
return options.direction === 'left'
|
|
834
|
-
? cardCenter.previousElementSibling
|
|
835
|
-
: cardCenter.nextElementSibling;
|
|
809
|
+
return options.direction === 'left' ? cardCenter.previousElementSibling : cardCenter.nextElementSibling;
|
|
836
810
|
},
|
|
837
811
|
toSlateCardEntry(editor, node) {
|
|
838
|
-
const element = node.parentElement
|
|
839
|
-
.closest('.slate-block-card')?.querySelector('[card-target="card-center"]')
|
|
840
|
-
.firstElementChild;
|
|
812
|
+
const element = node.parentElement.closest('.slate-block-card')?.querySelector('[card-target="card-center"]').firstElementChild;
|
|
841
813
|
const slateNode = AngularEditor.toSlateNode(editor, element);
|
|
842
814
|
const path = AngularEditor.findPath(editor, slateNode);
|
|
843
815
|
return [slateNode, path];
|
|
@@ -861,13 +833,16 @@ const AngularEditor = {
|
|
|
861
833
|
* @param options
|
|
862
834
|
*/
|
|
863
835
|
moveBlockCardCursor(editor, path, options) {
|
|
864
|
-
const cursor = {
|
|
836
|
+
const cursor = {
|
|
837
|
+
path,
|
|
838
|
+
offset: options.direction === 'left' ? FAKE_LEFT_BLOCK_CARD_OFFSET : FAKE_RIGHT_BLOCK_CARD_OFFSET
|
|
839
|
+
};
|
|
865
840
|
Transforms.select(editor, { anchor: cursor, focus: cursor });
|
|
866
841
|
},
|
|
867
842
|
hasRange(editor, range) {
|
|
868
843
|
const { anchor, focus } = range;
|
|
869
|
-
return
|
|
870
|
-
}
|
|
844
|
+
return Editor.hasPath(editor, anchor.path) && Editor.hasPath(editor, focus.path);
|
|
845
|
+
}
|
|
871
846
|
};
|
|
872
847
|
|
|
873
848
|
/**
|
|
@@ -999,16 +974,13 @@ const isDecoratorRangeListEqual = (list, another) => {
|
|
|
999
974
|
return true;
|
|
1000
975
|
};
|
|
1001
976
|
|
|
1002
|
-
const isValid = (value) => (Element.isElement(value) &&
|
|
1003
|
-
value.children.length > 0 &&
|
|
1004
|
-
value.children.every((child) => isValid(child))) ||
|
|
977
|
+
const isValid = (value) => (Element.isElement(value) && value.children.length > 0 && value.children.every(child => isValid(child))) ||
|
|
1005
978
|
Text$1.isText(value);
|
|
1006
979
|
const check = (document) => {
|
|
1007
|
-
return document.every(
|
|
1008
|
-
;
|
|
980
|
+
return document.every(value => Element.isElement(value) && isValid(value));
|
|
1009
981
|
};
|
|
1010
982
|
function normalize(document) {
|
|
1011
|
-
return document.filter(
|
|
983
|
+
return document.filter(value => Element.isElement(value) && isValid(value));
|
|
1012
984
|
}
|
|
1013
985
|
|
|
1014
986
|
/**
|
|
@@ -1065,7 +1037,7 @@ const withAngular = (editor, clipboardFormatKey = 'x-slate-fragment') => {
|
|
|
1065
1037
|
if (editor.selection && Range.isCollapsed(editor.selection)) {
|
|
1066
1038
|
const parentBlockEntry = Editor.above(editor, {
|
|
1067
1039
|
match: n => Editor.isBlock(editor, n),
|
|
1068
|
-
at: editor.selection
|
|
1040
|
+
at: editor.selection
|
|
1069
1041
|
});
|
|
1070
1042
|
if (parentBlockEntry) {
|
|
1071
1043
|
const [, parentBlockPath] = parentBlockEntry;
|
|
@@ -1094,7 +1066,7 @@ const withAngular = (editor, clipboardFormatKey = 'x-slate-fragment') => {
|
|
|
1094
1066
|
case 'merge_node':
|
|
1095
1067
|
case 'split_node': {
|
|
1096
1068
|
for (const [node, path] of Editor.levels(e, {
|
|
1097
|
-
at: Path.parent(op.path)
|
|
1069
|
+
at: Path.parent(op.path)
|
|
1098
1070
|
})) {
|
|
1099
1071
|
const key = AngularEditor.findKey(e, node);
|
|
1100
1072
|
matches.push([path, key]);
|
|
@@ -1103,11 +1075,15 @@ const withAngular = (editor, clipboardFormatKey = 'x-slate-fragment') => {
|
|
|
1103
1075
|
}
|
|
1104
1076
|
case 'move_node': {
|
|
1105
1077
|
const commonPath = Path.common(Path.parent(op.path), Path.parent(op.newPath));
|
|
1106
|
-
for (const [node, path] of Editor.levels(e, {
|
|
1078
|
+
for (const [node, path] of Editor.levels(e, {
|
|
1079
|
+
at: Path.parent(op.path)
|
|
1080
|
+
})) {
|
|
1107
1081
|
const key = AngularEditor.findKey(e, node);
|
|
1108
1082
|
matches.push([Editor.pathRef(editor, path), key]);
|
|
1109
1083
|
}
|
|
1110
|
-
for (const [node, path] of Editor.levels(e, {
|
|
1084
|
+
for (const [node, path] of Editor.levels(e, {
|
|
1085
|
+
at: Path.parent(op.newPath)
|
|
1086
|
+
})) {
|
|
1111
1087
|
if (path.length > commonPath.length) {
|
|
1112
1088
|
const key = AngularEditor.findKey(e, node);
|
|
1113
1089
|
matches.push([Editor.pathRef(editor, path), key]);
|
|
@@ -1225,8 +1201,7 @@ const withAngular = (editor, clipboardFormatKey = 'x-slate-fragment') => {
|
|
|
1225
1201
|
/**
|
|
1226
1202
|
* Checking copied fragment from application/x-slate-fragment or data-slate-fragment
|
|
1227
1203
|
*/
|
|
1228
|
-
const fragment = data.getData(`application/${clipboardFormatKey}`) ||
|
|
1229
|
-
getSlateFragmentAttribute(data);
|
|
1204
|
+
const fragment = data.getData(`application/${clipboardFormatKey}`) || getSlateFragmentAttribute(data);
|
|
1230
1205
|
if (fragment) {
|
|
1231
1206
|
const decoded = decodeURIComponent(window.atob(fragment));
|
|
1232
1207
|
const parsed = JSON.parse(decoded);
|
|
@@ -1253,7 +1228,7 @@ const withAngular = (editor, clipboardFormatKey = 'x-slate-fragment') => {
|
|
|
1253
1228
|
};
|
|
1254
1229
|
e.onKeydown = () => { };
|
|
1255
1230
|
e.onClick = () => { };
|
|
1256
|
-
e.isBlockCard =
|
|
1231
|
+
e.isBlockCard = element => false;
|
|
1257
1232
|
e.onError = (errorData) => {
|
|
1258
1233
|
if (errorData.nativeError) {
|
|
1259
1234
|
console.error(errorData.nativeError);
|
|
@@ -1597,7 +1572,7 @@ const BEFORE_INPUT_EVENTS = [
|
|
|
1597
1572
|
{ name: 'keypress', handler: null, isTriggerBeforeInput: true },
|
|
1598
1573
|
{ name: 'keyup', handler: 'onKeyUp', isTriggerBeforeInput: true },
|
|
1599
1574
|
{ name: 'mousedown', handler: 'onMouseDown', isTriggerBeforeInput: true },
|
|
1600
|
-
{ name: 'textInput', handler: null, isTriggerBeforeInput: true }
|
|
1575
|
+
{ name: 'textInput', handler: null, isTriggerBeforeInput: true }
|
|
1601
1576
|
// { name: 'paste', handler: 'onPaste', isTriggerBeforeInput: true }
|
|
1602
1577
|
];
|
|
1603
1578
|
|
|
@@ -1613,17 +1588,46 @@ var SlateErrorCode;
|
|
|
1613
1588
|
SlateErrorCode[SlateErrorCode["InvalidValueError"] = 4100] = "InvalidValueError";
|
|
1614
1589
|
})(SlateErrorCode || (SlateErrorCode = {}));
|
|
1615
1590
|
|
|
1591
|
+
function restoreDom(editor, execute) {
|
|
1592
|
+
const editable = EDITOR_TO_ELEMENT.get(editor);
|
|
1593
|
+
let observer = new MutationObserver(mutations => {
|
|
1594
|
+
mutations.reverse().forEach(mutation => {
|
|
1595
|
+
if (mutation.type === 'characterData') {
|
|
1596
|
+
// We don't want to restore the DOM for characterData mutations
|
|
1597
|
+
// because this interrupts the composition.
|
|
1598
|
+
return;
|
|
1599
|
+
}
|
|
1600
|
+
mutation.removedNodes.forEach(node => {
|
|
1601
|
+
mutation.target.insertBefore(node, mutation.nextSibling);
|
|
1602
|
+
});
|
|
1603
|
+
mutation.addedNodes.forEach(node => {
|
|
1604
|
+
mutation.target.removeChild(node);
|
|
1605
|
+
});
|
|
1606
|
+
});
|
|
1607
|
+
disconnect();
|
|
1608
|
+
execute();
|
|
1609
|
+
});
|
|
1610
|
+
const disconnect = () => {
|
|
1611
|
+
observer.disconnect();
|
|
1612
|
+
observer = null;
|
|
1613
|
+
};
|
|
1614
|
+
observer.observe(editable, { subtree: true, childList: true, characterData: true, characterDataOldValue: true });
|
|
1615
|
+
setTimeout(() => {
|
|
1616
|
+
if (observer) {
|
|
1617
|
+
disconnect();
|
|
1618
|
+
execute();
|
|
1619
|
+
}
|
|
1620
|
+
}, 0);
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1616
1623
|
class SlateStringTemplateComponent {
|
|
1617
1624
|
}
|
|
1618
1625
|
SlateStringTemplateComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: SlateStringTemplateComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1619
|
-
SlateStringTemplateComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: SlateStringTemplateComponent, selector: "slate-string-template", viewQueries: [{ propertyName: "
|
|
1626
|
+
SlateStringTemplateComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: SlateStringTemplateComponent, selector: "slate-string-template", viewQueries: [{ propertyName: "compatStringTemplate", first: true, predicate: ["compatStringTemplate"], descendants: true, read: TemplateRef, static: true }, { propertyName: "emptyStringTemplate", first: true, predicate: ["emptyStringTemplate"], descendants: true, read: TemplateRef, static: true }, { propertyName: "emptyTextTemplate", first: true, predicate: ["emptyTextTemplate"], descendants: true, read: TemplateRef, static: true }, { propertyName: "lineBreakEmptyStringTemplate", first: true, predicate: ["lineBreakEmptyStringTemplate"], descendants: true, read: TemplateRef, static: true }], ngImport: i0, template: "<ng-template #compatStringTemplate let-context=\"context\" let-viewContext=\"viewContext\">\n <!-- Compatible with Chinese input in Chrome with \\n -->\n <span editable-text data-slate-string=\"true\"\n >{{ context.text }}<span data-slate-zero-width>{{ '\\uFEFF' }}</span></span\n >\n</ng-template>\n<ng-template #emptyStringTemplate let-context=\"context\" let-viewContext=\"viewContext\">\n <span editable-text data-slate-zero-width=\"z\" attr.data-slate-length=\"{{ context.elementStringLength }}\">{{ '\\uFEFF' }}</span>\n</ng-template>\n<ng-template #emptyTextTemplate let-context=\"context\" let-viewContext=\"viewContext\">\n <span editable-text data-slate-zero-width=\"z\" data-slate-length=\"0\">{{ '\\uFEFF' }}</span>\n</ng-template>\n<ng-template #lineBreakEmptyStringTemplate let-context=\"context\" let-viewContext=\"viewContext\">\n <span editable-text data-slate-zero-width=\"n\" attr.data-slate-length=\"{{ context.elementStringLength }}\">{{ '\\uFEFF' }}<br /></span>\n</ng-template>\n", changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1620
1627
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: SlateStringTemplateComponent, decorators: [{
|
|
1621
1628
|
type: Component,
|
|
1622
|
-
args: [{ selector: 'slate-string-template', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-template #
|
|
1623
|
-
}], propDecorators: {
|
|
1624
|
-
type: ViewChild,
|
|
1625
|
-
args: ['stringTemplate', { read: TemplateRef, static: true }]
|
|
1626
|
-
}], compatStringTemplate: [{
|
|
1629
|
+
args: [{ selector: 'slate-string-template', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-template #compatStringTemplate let-context=\"context\" let-viewContext=\"viewContext\">\n <!-- Compatible with Chinese input in Chrome with \\n -->\n <span editable-text data-slate-string=\"true\"\n >{{ context.text }}<span data-slate-zero-width>{{ '\\uFEFF' }}</span></span\n >\n</ng-template>\n<ng-template #emptyStringTemplate let-context=\"context\" let-viewContext=\"viewContext\">\n <span editable-text data-slate-zero-width=\"z\" attr.data-slate-length=\"{{ context.elementStringLength }}\">{{ '\\uFEFF' }}</span>\n</ng-template>\n<ng-template #emptyTextTemplate let-context=\"context\" let-viewContext=\"viewContext\">\n <span editable-text data-slate-zero-width=\"z\" data-slate-length=\"0\">{{ '\\uFEFF' }}</span>\n</ng-template>\n<ng-template #lineBreakEmptyStringTemplate let-context=\"context\" let-viewContext=\"viewContext\">\n <span editable-text data-slate-zero-width=\"n\" attr.data-slate-length=\"{{ context.elementStringLength }}\">{{ '\\uFEFF' }}<br /></span>\n</ng-template>\n" }]
|
|
1630
|
+
}], propDecorators: { compatStringTemplate: [{
|
|
1627
1631
|
type: ViewChild,
|
|
1628
1632
|
args: ['compatStringTemplate', { read: TemplateRef, static: true }]
|
|
1629
1633
|
}], emptyStringTemplate: [{
|
|
@@ -1634,7 +1638,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
|
|
|
1634
1638
|
args: ['emptyTextTemplate', { read: TemplateRef, static: true }]
|
|
1635
1639
|
}], lineBreakEmptyStringTemplate: [{
|
|
1636
1640
|
type: ViewChild,
|
|
1637
|
-
args: ['lineBreakEmptyStringTemplate', {
|
|
1641
|
+
args: ['lineBreakEmptyStringTemplate', {
|
|
1642
|
+
read: TemplateRef,
|
|
1643
|
+
static: true
|
|
1644
|
+
}]
|
|
1638
1645
|
}] } });
|
|
1639
1646
|
|
|
1640
1647
|
class SlateBlockCardComponent {
|
|
@@ -1652,17 +1659,17 @@ class SlateBlockCardComponent {
|
|
|
1652
1659
|
this.nativeElement.classList.add(`slate-block-card`);
|
|
1653
1660
|
}
|
|
1654
1661
|
append() {
|
|
1655
|
-
this.centerRootNodes.forEach(
|
|
1662
|
+
this.centerRootNodes.forEach(rootNode => !this.centerContainerElement.contains(rootNode) && this.centerContainerElement.appendChild(rootNode));
|
|
1656
1663
|
}
|
|
1657
1664
|
initializeCenter(rootNodes) {
|
|
1658
1665
|
this.centerRootNodes = rootNodes;
|
|
1659
1666
|
}
|
|
1660
1667
|
}
|
|
1661
1668
|
SlateBlockCardComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: SlateBlockCardComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
1662
|
-
SlateBlockCardComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: SlateBlockCardComponent, selector: "slate-block-card, [slateBlockCard]", viewQueries: [{ propertyName: "centerContianer", first: true, predicate: ["centerContianer"], descendants: true, static: true }], ngImport: i0, template: "<span card-target=\"card-left\" class=\"card-left\">{{
|
|
1669
|
+
SlateBlockCardComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: SlateBlockCardComponent, selector: "slate-block-card, [slateBlockCard]", viewQueries: [{ propertyName: "centerContianer", first: true, predicate: ["centerContianer"], descendants: true, static: true }], ngImport: i0, template: "<span card-target=\"card-left\" class=\"card-left\">{{ '\\uFEFF' }}</span>\n<div card-target=\"card-center\" #centerContianer></div>\n<span card-target=\"card-right\" class=\"card-right\">{{ '\\uFEFF' }}</span>\n" });
|
|
1663
1670
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: SlateBlockCardComponent, decorators: [{
|
|
1664
1671
|
type: Component,
|
|
1665
|
-
args: [{ selector: 'slate-block-card, [slateBlockCard]', template: "<span card-target=\"card-left\" class=\"card-left\">{{
|
|
1672
|
+
args: [{ selector: 'slate-block-card, [slateBlockCard]', template: "<span card-target=\"card-left\" class=\"card-left\">{{ '\\uFEFF' }}</span>\n<div card-target=\"card-center\" #centerContianer></div>\n<span card-target=\"card-right\" class=\"card-right\">{{ '\\uFEFF' }}</span>\n" }]
|
|
1666
1673
|
}], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { centerContianer: [{
|
|
1667
1674
|
type: ViewChild,
|
|
1668
1675
|
args: ['centerContianer', { static: true }]
|
|
@@ -1679,7 +1686,7 @@ class ViewContainerItem {
|
|
|
1679
1686
|
}
|
|
1680
1687
|
getRootNodes() {
|
|
1681
1688
|
if (this.embeddedViewRef) {
|
|
1682
|
-
return this.embeddedViewRef.rootNodes.filter(
|
|
1689
|
+
return this.embeddedViewRef.rootNodes.filter(rootNode => isDOMElement(rootNode));
|
|
1683
1690
|
}
|
|
1684
1691
|
if (this.componentRef) {
|
|
1685
1692
|
return [this.componentRef.instance.nativeElement];
|
|
@@ -1705,7 +1712,10 @@ class ViewContainerItem {
|
|
|
1705
1712
|
this.viewType = this.getViewType();
|
|
1706
1713
|
const context = this.getContext();
|
|
1707
1714
|
if (isTemplateRef(this.viewType)) {
|
|
1708
|
-
this.embeddedViewContext = {
|
|
1715
|
+
this.embeddedViewContext = {
|
|
1716
|
+
context,
|
|
1717
|
+
viewContext: this.viewContext
|
|
1718
|
+
};
|
|
1709
1719
|
const embeddedViewRef = this.viewContainerRef.createEmbeddedView(this.viewType, this.embeddedViewContext);
|
|
1710
1720
|
this.embeddedViewRef = embeddedViewRef;
|
|
1711
1721
|
}
|
|
@@ -1737,9 +1747,12 @@ class ViewContainerItem {
|
|
|
1737
1747
|
this.viewType = viewType;
|
|
1738
1748
|
const firstRootNode = this.rootNodes[0];
|
|
1739
1749
|
if (isTemplateRef(this.viewType)) {
|
|
1740
|
-
this.embeddedViewContext = {
|
|
1750
|
+
this.embeddedViewContext = {
|
|
1751
|
+
context,
|
|
1752
|
+
viewContext: this.viewContext
|
|
1753
|
+
};
|
|
1741
1754
|
const embeddedViewRef = this.viewContainerRef.createEmbeddedView(this.viewType, this.embeddedViewContext);
|
|
1742
|
-
firstRootNode.replaceWith(...embeddedViewRef.rootNodes.filter(
|
|
1755
|
+
firstRootNode.replaceWith(...embeddedViewRef.rootNodes.filter(rootNode => isDOMElement(rootNode)));
|
|
1743
1756
|
this.destroyView();
|
|
1744
1757
|
this.embeddedViewRef = embeddedViewRef;
|
|
1745
1758
|
}
|
|
@@ -1987,7 +2000,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
|
|
|
1987
2000
|
}] });
|
|
1988
2001
|
|
|
1989
2002
|
/**
|
|
1990
|
-
* the
|
|
2003
|
+
* the special container for angular template
|
|
1991
2004
|
* Add the rootNodes of each child component to the parentElement
|
|
1992
2005
|
* Remove useless DOM elements, eg: comment...
|
|
1993
2006
|
*/
|
|
@@ -2007,7 +2020,7 @@ class ViewContainer {
|
|
|
2007
2020
|
parentElement.insertBefore(this.createFragment(), this.elementRef.nativeElement);
|
|
2008
2021
|
this.elementRef.nativeElement.remove();
|
|
2009
2022
|
}
|
|
2010
|
-
this.childrenComponent.changes.subscribe(
|
|
2023
|
+
this.childrenComponent.changes.subscribe(value => {
|
|
2011
2024
|
const iterableChanges = differ.diff(this.childrenComponent);
|
|
2012
2025
|
if (iterableChanges) {
|
|
2013
2026
|
iterableChanges.forEachOperation((record, previousIndex, currentIndex) => {
|
|
@@ -2060,7 +2073,7 @@ class ViewContainer {
|
|
|
2060
2073
|
// insert afterend of previous component end
|
|
2061
2074
|
let previousRootNode = this.getPreviousRootNode(record.currentIndex);
|
|
2062
2075
|
if (previousRootNode) {
|
|
2063
|
-
record.item.rootNodes.forEach(
|
|
2076
|
+
record.item.rootNodes.forEach(rootNode => {
|
|
2064
2077
|
previousRootNode.insertAdjacentElement('afterend', rootNode);
|
|
2065
2078
|
previousRootNode = rootNode;
|
|
2066
2079
|
});
|
|
@@ -2085,6 +2098,34 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
|
|
|
2085
2098
|
type: Input
|
|
2086
2099
|
}] } });
|
|
2087
2100
|
|
|
2101
|
+
class SlateDefaultStringComponent extends BaseComponent {
|
|
2102
|
+
constructor(elementRef, cdr) {
|
|
2103
|
+
super(elementRef, cdr);
|
|
2104
|
+
this.elementRef = elementRef;
|
|
2105
|
+
this.cdr = cdr;
|
|
2106
|
+
}
|
|
2107
|
+
onContextChange() {
|
|
2108
|
+
// Avoid breaking some browser default behaviors, such as spellCheck, android composition input state
|
|
2109
|
+
if (this.nativeElement.textContent !== this.context.text) {
|
|
2110
|
+
this.nativeElement.textContent = this.context.text;
|
|
2111
|
+
}
|
|
2112
|
+
}
|
|
2113
|
+
ngOnInit() {
|
|
2114
|
+
this.nativeElement.setAttribute('editable-text', '');
|
|
2115
|
+
this.nativeElement.setAttribute('data-slate-string', 'true');
|
|
2116
|
+
}
|
|
2117
|
+
}
|
|
2118
|
+
SlateDefaultStringComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: SlateDefaultStringComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
2119
|
+
SlateDefaultStringComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: SlateDefaultStringComponent, selector: "span[slateDefaultString]", usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2120
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: SlateDefaultStringComponent, decorators: [{
|
|
2121
|
+
type: Component,
|
|
2122
|
+
args: [{
|
|
2123
|
+
selector: 'span[slateDefaultString]',
|
|
2124
|
+
template: '',
|
|
2125
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
2126
|
+
}]
|
|
2127
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }]; } });
|
|
2128
|
+
|
|
2088
2129
|
class SlateStringComponent extends ViewContainerItem {
|
|
2089
2130
|
constructor(elementRef, viewContainerRef) {
|
|
2090
2131
|
super(viewContainerRef);
|
|
@@ -2131,10 +2172,13 @@ class SlateStringComponent extends ViewContainerItem {
|
|
|
2131
2172
|
if (this.context.isLast && this.context.leaf.text.slice(-1) === '\n') {
|
|
2132
2173
|
return this.viewContext.templateComponent.compatStringTemplate;
|
|
2133
2174
|
}
|
|
2134
|
-
return
|
|
2175
|
+
return SlateDefaultStringComponent;
|
|
2135
2176
|
}
|
|
2136
2177
|
getContext() {
|
|
2137
|
-
return {
|
|
2178
|
+
return {
|
|
2179
|
+
text: this.context.leaf.text,
|
|
2180
|
+
elementStringLength: Node.string(this.context.parent).length
|
|
2181
|
+
};
|
|
2138
2182
|
}
|
|
2139
2183
|
memoizedContext(prev, next) {
|
|
2140
2184
|
return false;
|
|
@@ -2164,12 +2208,12 @@ class SlateDefaultLeafComponent extends BaseLeafComponent {
|
|
|
2164
2208
|
}
|
|
2165
2209
|
}
|
|
2166
2210
|
SlateDefaultLeafComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: SlateDefaultLeafComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
2167
|
-
SlateDefaultLeafComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: SlateDefaultLeafComponent, selector: "span[slateDefaultLeaf]", host: { attributes: { "data-slate-leaf": "true" } }, usesInheritance: true, ngImport: i0, template: `<span slateString [context]="context" [viewContext]="viewContext"><span>`, isInline: true, dependencies: [{ kind: "component", type: SlateStringComponent, selector: "span[slateString]", inputs: ["context"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2211
|
+
SlateDefaultLeafComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: SlateDefaultLeafComponent, selector: "span[slateDefaultLeaf]", host: { attributes: { "data-slate-leaf": "true" } }, usesInheritance: true, ngImport: i0, template: `<span slateString [context]="context" [viewContext]="viewContext"><span></span></span>`, isInline: true, dependencies: [{ kind: "component", type: SlateStringComponent, selector: "span[slateString]", inputs: ["context"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2168
2212
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: SlateDefaultLeafComponent, decorators: [{
|
|
2169
2213
|
type: Component,
|
|
2170
2214
|
args: [{
|
|
2171
2215
|
selector: 'span[slateDefaultLeaf]',
|
|
2172
|
-
template: `<span slateString [context]="context" [viewContext]="viewContext"><span>`,
|
|
2216
|
+
template: `<span slateString [context]="context" [viewContext]="viewContext"><span></span></span>`,
|
|
2173
2217
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2174
2218
|
host: {
|
|
2175
2219
|
'data-slate-leaf': 'true'
|
|
@@ -2185,7 +2229,7 @@ class SlateLeafComponent extends ViewContainerItem {
|
|
|
2185
2229
|
return this.context;
|
|
2186
2230
|
}
|
|
2187
2231
|
getViewType() {
|
|
2188
|
-
return this.viewContext.renderLeaf && this.viewContext.renderLeaf(this.context.leaf) || SlateDefaultLeafComponent;
|
|
2232
|
+
return (this.viewContext.renderLeaf && this.viewContext.renderLeaf(this.context.leaf)) || SlateDefaultLeafComponent;
|
|
2189
2233
|
}
|
|
2190
2234
|
memoizedContext(prev, next) {
|
|
2191
2235
|
return false;
|
|
@@ -2204,7 +2248,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
|
|
|
2204
2248
|
args: [{
|
|
2205
2249
|
selector: 'slate-leaf',
|
|
2206
2250
|
template: '',
|
|
2207
|
-
changeDetection: ChangeDetectionStrategy.OnPush
|
|
2251
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
2208
2252
|
}]
|
|
2209
2253
|
}], propDecorators: { context: [{
|
|
2210
2254
|
type: Input
|
|
@@ -2249,19 +2293,21 @@ class SlateLeavesComponent extends ViewContainer {
|
|
|
2249
2293
|
}
|
|
2250
2294
|
SlateLeavesComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: SlateLeavesComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
2251
2295
|
SlateLeavesComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: SlateLeavesComponent, selector: "slate-leaves", inputs: { context: "context" }, viewQueries: [{ propertyName: "childrenComponent", predicate: SlateLeafComponent, descendants: true, read: SlateLeafComponent }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: `<slate-leaf
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2296
|
+
[context]="context"
|
|
2297
|
+
[viewContext]="viewContext"
|
|
2298
|
+
[viewContext]="viewContext"
|
|
2299
|
+
*ngFor="let context of leafContexts; trackBy: trackBy"
|
|
2300
|
+
></slate-leaf>`, isInline: true, dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: SlateLeafComponent, selector: "slate-leaf", inputs: ["context"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2256
2301
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: SlateLeavesComponent, decorators: [{
|
|
2257
2302
|
type: Component,
|
|
2258
2303
|
args: [{
|
|
2259
2304
|
selector: 'slate-leaves',
|
|
2260
2305
|
template: `<slate-leaf
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2306
|
+
[context]="context"
|
|
2307
|
+
[viewContext]="viewContext"
|
|
2308
|
+
[viewContext]="viewContext"
|
|
2309
|
+
*ngFor="let context of leafContexts; trackBy: trackBy"
|
|
2310
|
+
></slate-leaf>`,
|
|
2265
2311
|
changeDetection: ChangeDetectionStrategy.OnPush
|
|
2266
2312
|
}]
|
|
2267
2313
|
}], propDecorators: { context: [{
|
|
@@ -2309,8 +2355,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
|
|
|
2309
2355
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2310
2356
|
host: {
|
|
2311
2357
|
'[attr.contenteditable]': 'isLeafBlock',
|
|
2312
|
-
'data-slate-spacer':
|
|
2313
|
-
|
|
2358
|
+
'data-slate-spacer': 'true',
|
|
2359
|
+
class: 'slate-spacer',
|
|
2314
2360
|
'data-slate-node': 'text'
|
|
2315
2361
|
}
|
|
2316
2362
|
}]
|
|
@@ -2392,7 +2438,10 @@ class SlateDescendantComponent extends ViewContainerItem {
|
|
|
2392
2438
|
return { selection: sel, decorations: ds };
|
|
2393
2439
|
}
|
|
2394
2440
|
catch (error) {
|
|
2395
|
-
this.viewContext.editor.onError({
|
|
2441
|
+
this.viewContext.editor.onError({
|
|
2442
|
+
code: SlateErrorCode.GetStartPointError,
|
|
2443
|
+
nativeError: error
|
|
2444
|
+
});
|
|
2396
2445
|
return { selection: null, decorations: [] };
|
|
2397
2446
|
}
|
|
2398
2447
|
}
|
|
@@ -2439,7 +2488,9 @@ class SlateDescendantComponent extends ViewContainerItem {
|
|
|
2439
2488
|
}
|
|
2440
2489
|
else {
|
|
2441
2490
|
const isVoid = this.viewContext.editor.isVoid(this.context.parent);
|
|
2442
|
-
return isVoid
|
|
2491
|
+
return isVoid
|
|
2492
|
+
? SlateVoidTextComponent
|
|
2493
|
+
: (this.viewContext.renderText && this.viewContext.renderText(this.descendant)) || SlateDefaultTextComponent;
|
|
2443
2494
|
}
|
|
2444
2495
|
}
|
|
2445
2496
|
memoizedElementContext(prev, next) {
|
|
@@ -2447,10 +2498,7 @@ class SlateDescendantComponent extends ViewContainerItem {
|
|
|
2447
2498
|
(!this.viewContext.isStrictDecorate || prev.decorate === next.decorate) &&
|
|
2448
2499
|
prev.readonly === next.readonly &&
|
|
2449
2500
|
isDecoratorRangeListEqual(prev.decorations, next.decorations) &&
|
|
2450
|
-
(prev.selection === next.selection ||
|
|
2451
|
-
(!!prev.selection &&
|
|
2452
|
-
!!next.selection &&
|
|
2453
|
-
Range.equals(prev.selection, next.selection))));
|
|
2501
|
+
(prev.selection === next.selection || (!!prev.selection && !!next.selection && Range.equals(prev.selection, next.selection))));
|
|
2454
2502
|
}
|
|
2455
2503
|
memoizedTextContext(prev, next) {
|
|
2456
2504
|
return (next.parent === prev.parent &&
|
|
@@ -2496,26 +2544,29 @@ class SlateChildrenComponent extends ViewContainer {
|
|
|
2496
2544
|
return this.viewContext.trackBy(node) || AngularEditor.findKey(this.viewContext.editor, node);
|
|
2497
2545
|
};
|
|
2498
2546
|
}
|
|
2499
|
-
ngOnInit() {
|
|
2500
|
-
}
|
|
2547
|
+
ngOnInit() { }
|
|
2501
2548
|
}
|
|
2502
2549
|
SlateChildrenComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: SlateChildrenComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
2503
|
-
SlateChildrenComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: SlateChildrenComponent, selector: "slate-children", inputs: { children: "children", context: "context", viewContext: "viewContext" }, viewQueries: [{ propertyName: "childrenComponent", predicate: SlateDescendantComponent, descendants: true, read: SlateDescendantComponent }], usesInheritance: true, ngImport: i0, template: `<slate-descendant
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2550
|
+
SlateChildrenComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: SlateChildrenComponent, selector: "slate-children", inputs: { children: "children", context: "context", viewContext: "viewContext" }, viewQueries: [{ propertyName: "childrenComponent", predicate: SlateDescendantComponent, descendants: true, read: SlateDescendantComponent }], usesInheritance: true, ngImport: i0, template: `<slate-descendant
|
|
2551
|
+
[descendant]="descendant"
|
|
2552
|
+
[context]="context"
|
|
2553
|
+
[viewContext]="viewContext"
|
|
2554
|
+
[viewContext]="viewContext"
|
|
2555
|
+
[index]="index"
|
|
2556
|
+
*ngFor="let descendant of children; let index = index; trackBy: trackBy"
|
|
2557
|
+
></slate-descendant>`, isInline: true, dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: SlateDescendantComponent, selector: "slate-descendant", inputs: ["descendant", "context", "viewContext", "index"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2509
2558
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: SlateChildrenComponent, decorators: [{
|
|
2510
2559
|
type: Component,
|
|
2511
2560
|
args: [{
|
|
2512
2561
|
selector: 'slate-children',
|
|
2513
|
-
template: `<slate-descendant
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2562
|
+
template: `<slate-descendant
|
|
2563
|
+
[descendant]="descendant"
|
|
2564
|
+
[context]="context"
|
|
2565
|
+
[viewContext]="viewContext"
|
|
2566
|
+
[viewContext]="viewContext"
|
|
2567
|
+
[index]="index"
|
|
2568
|
+
*ngFor="let descendant of children; let index = index; trackBy: trackBy"
|
|
2569
|
+
></slate-descendant>`,
|
|
2519
2570
|
changeDetection: ChangeDetectionStrategy.OnPush
|
|
2520
2571
|
}]
|
|
2521
2572
|
}], propDecorators: { children: [{
|
|
@@ -2584,7 +2635,7 @@ class SlateEditableComponent {
|
|
|
2584
2635
|
// remove unused DOM, just keep templateComponent instance
|
|
2585
2636
|
this.templateElementRef.nativeElement.remove();
|
|
2586
2637
|
// add browser class
|
|
2587
|
-
let browserClass = IS_FIREFOX ? 'firefox' :
|
|
2638
|
+
let browserClass = IS_FIREFOX ? 'firefox' : IS_SAFARI ? 'safari' : '';
|
|
2588
2639
|
browserClass && this.elementRef.nativeElement.classList.add(browserClass);
|
|
2589
2640
|
}
|
|
2590
2641
|
ngOnChanges(simpleChanges) {
|
|
@@ -2661,7 +2712,7 @@ class SlateEditableComponent {
|
|
|
2661
2712
|
const root = AngularEditor.findDocumentOrShadowRoot(this.editor);
|
|
2662
2713
|
const { activeElement } = root;
|
|
2663
2714
|
const domSelection = root.getSelection();
|
|
2664
|
-
if (this.isComposing || !domSelection || !AngularEditor.isFocused(this.editor)) {
|
|
2715
|
+
if ((this.isComposing && !IS_ANDROID) || !domSelection || !AngularEditor.isFocused(this.editor)) {
|
|
2665
2716
|
return;
|
|
2666
2717
|
}
|
|
2667
2718
|
const hasDomSelection = domSelection.type !== 'None';
|
|
@@ -2725,17 +2776,19 @@ class SlateEditableComponent {
|
|
|
2725
2776
|
});
|
|
2726
2777
|
}
|
|
2727
2778
|
catch (error) {
|
|
2728
|
-
this.editor.onError({
|
|
2779
|
+
this.editor.onError({
|
|
2780
|
+
code: SlateErrorCode.ToNativeSelectionError,
|
|
2781
|
+
nativeError: error
|
|
2782
|
+
});
|
|
2783
|
+
this.isUpdatingSelection = false;
|
|
2729
2784
|
}
|
|
2730
2785
|
}
|
|
2731
2786
|
onChange() {
|
|
2732
2787
|
this.forceFlush();
|
|
2733
2788
|
this.onChangeCallback(this.editor.children);
|
|
2734
2789
|
}
|
|
2735
|
-
ngAfterViewChecked() {
|
|
2736
|
-
}
|
|
2737
|
-
ngDoCheck() {
|
|
2738
|
-
}
|
|
2790
|
+
ngAfterViewChecked() { }
|
|
2791
|
+
ngDoCheck() { }
|
|
2739
2792
|
forceFlush() {
|
|
2740
2793
|
this.detectContext();
|
|
2741
2794
|
this.cdr.detectChanges();
|
|
@@ -2755,7 +2808,7 @@ class SlateEditableComponent {
|
|
|
2755
2808
|
const textDOMNode = AngularEditor.toDOMNode(this.editor, textNode);
|
|
2756
2809
|
let textContent = '';
|
|
2757
2810
|
// skip decorate text
|
|
2758
|
-
textDOMNode.querySelectorAll('[editable-text]').forEach(
|
|
2811
|
+
textDOMNode.querySelectorAll('[editable-text]').forEach(stringDOMNode => {
|
|
2759
2812
|
let text = stringDOMNode.textContent;
|
|
2760
2813
|
const zeroChar = '\uFEFF';
|
|
2761
2814
|
// remove zero with char
|
|
@@ -2813,17 +2866,14 @@ class SlateEditableComponent {
|
|
|
2813
2866
|
if (this.placeholderDecorate) {
|
|
2814
2867
|
return this.placeholderDecorate(editor) || [];
|
|
2815
2868
|
}
|
|
2816
|
-
if (this.placeholder &&
|
|
2817
|
-
editor.children.length === 1 &&
|
|
2818
|
-
Array.from(Node.texts(editor)).length === 1 &&
|
|
2819
|
-
Node.string(editor) === '') {
|
|
2869
|
+
if (this.placeholder && editor.children.length === 1 && Array.from(Node.texts(editor)).length === 1 && Node.string(editor) === '') {
|
|
2820
2870
|
const start = Editor.start(editor, []);
|
|
2821
2871
|
return [
|
|
2822
2872
|
{
|
|
2823
2873
|
placeholder: this.placeholder,
|
|
2824
2874
|
anchor: start,
|
|
2825
|
-
focus: start
|
|
2826
|
-
}
|
|
2875
|
+
focus: start
|
|
2876
|
+
}
|
|
2827
2877
|
];
|
|
2828
2878
|
}
|
|
2829
2879
|
else {
|
|
@@ -2832,9 +2882,7 @@ class SlateEditableComponent {
|
|
|
2832
2882
|
}
|
|
2833
2883
|
generateDecorations() {
|
|
2834
2884
|
const decorations = this.decorate([this.editor, []]);
|
|
2835
|
-
const placeholderDecorations = this.isComposing
|
|
2836
|
-
? []
|
|
2837
|
-
: this.composePlaceholderDecorate(this.editor);
|
|
2885
|
+
const placeholderDecorations = this.isComposing ? [] : this.composePlaceholderDecorate(this.editor);
|
|
2838
2886
|
decorations.push(...placeholderDecorations);
|
|
2839
2887
|
return decorations;
|
|
2840
2888
|
}
|
|
@@ -2849,7 +2897,7 @@ class SlateEditableComponent {
|
|
|
2849
2897
|
}));
|
|
2850
2898
|
}
|
|
2851
2899
|
toSlateSelection() {
|
|
2852
|
-
if (!this.isComposing && !this.isUpdatingSelection && !this.isDraggingInternally) {
|
|
2900
|
+
if ((!this.isComposing || IS_ANDROID) && !this.isUpdatingSelection && !this.isDraggingInternally) {
|
|
2853
2901
|
try {
|
|
2854
2902
|
const root = AngularEditor.findDocumentOrShadowRoot(this.editor);
|
|
2855
2903
|
const { activeElement } = root;
|
|
@@ -2885,7 +2933,10 @@ class SlateEditableComponent {
|
|
|
2885
2933
|
}
|
|
2886
2934
|
}
|
|
2887
2935
|
catch (error) {
|
|
2888
|
-
this.editor.onError({
|
|
2936
|
+
this.editor.onError({
|
|
2937
|
+
code: SlateErrorCode.ToSlateSelectionError,
|
|
2938
|
+
nativeError: error
|
|
2939
|
+
});
|
|
2889
2940
|
}
|
|
2890
2941
|
}
|
|
2891
2942
|
}
|
|
@@ -2893,11 +2944,70 @@ class SlateEditableComponent {
|
|
|
2893
2944
|
const editor = this.editor;
|
|
2894
2945
|
const root = AngularEditor.findDocumentOrShadowRoot(this.editor);
|
|
2895
2946
|
const { activeElement } = root;
|
|
2896
|
-
|
|
2947
|
+
const { selection } = editor;
|
|
2948
|
+
const { inputType: type } = event;
|
|
2949
|
+
const data = event.dataTransfer || event.data || undefined;
|
|
2950
|
+
if (IS_ANDROID) {
|
|
2951
|
+
let targetRange = null;
|
|
2952
|
+
let [nativeTargetRange] = event.getTargetRanges();
|
|
2953
|
+
if (nativeTargetRange) {
|
|
2954
|
+
targetRange = AngularEditor.toSlateRange(editor, nativeTargetRange);
|
|
2955
|
+
}
|
|
2956
|
+
// COMPAT: SelectionChange event is fired after the action is performed, so we
|
|
2957
|
+
// have to manually get the selection here to ensure it's up-to-date.
|
|
2958
|
+
const window = AngularEditor.getWindow(editor);
|
|
2959
|
+
const domSelection = window.getSelection();
|
|
2960
|
+
if (!targetRange && domSelection) {
|
|
2961
|
+
targetRange = AngularEditor.toSlateRange(editor, domSelection);
|
|
2962
|
+
}
|
|
2963
|
+
targetRange = targetRange ?? editor.selection;
|
|
2964
|
+
if (type === 'insertCompositionText') {
|
|
2965
|
+
if (data && data.toString().includes('\n')) {
|
|
2966
|
+
restoreDom(editor, () => {
|
|
2967
|
+
Editor.insertBreak(editor);
|
|
2968
|
+
});
|
|
2969
|
+
}
|
|
2970
|
+
else {
|
|
2971
|
+
if (targetRange) {
|
|
2972
|
+
if (data) {
|
|
2973
|
+
restoreDom(editor, () => {
|
|
2974
|
+
Transforms.insertText(editor, data.toString(), { at: targetRange });
|
|
2975
|
+
});
|
|
2976
|
+
}
|
|
2977
|
+
else {
|
|
2978
|
+
restoreDom(editor, () => {
|
|
2979
|
+
Transforms.delete(editor, { at: targetRange });
|
|
2980
|
+
});
|
|
2981
|
+
}
|
|
2982
|
+
}
|
|
2983
|
+
}
|
|
2984
|
+
return;
|
|
2985
|
+
}
|
|
2986
|
+
if (type === 'deleteContentBackward') {
|
|
2987
|
+
// gboard can not prevent default action, so must use restoreDom,
|
|
2988
|
+
// sougou Keyboard can prevent default action(only in Chinese input mode).
|
|
2989
|
+
// In order to avoid weird action in Sougou Keyboard, use resotreDom only range's isCollapsed is false (recognize gboard)
|
|
2990
|
+
if (!Range.isCollapsed(targetRange)) {
|
|
2991
|
+
restoreDom(editor, () => {
|
|
2992
|
+
Transforms.delete(editor, { at: targetRange });
|
|
2993
|
+
});
|
|
2994
|
+
return;
|
|
2995
|
+
}
|
|
2996
|
+
}
|
|
2997
|
+
if (type === 'insertText') {
|
|
2998
|
+
restoreDom(editor, () => {
|
|
2999
|
+
if (typeof data === 'string') {
|
|
3000
|
+
Editor.insertText(editor, data);
|
|
3001
|
+
}
|
|
3002
|
+
});
|
|
3003
|
+
return;
|
|
3004
|
+
}
|
|
3005
|
+
}
|
|
3006
|
+
if (!this.readonly &&
|
|
3007
|
+
hasEditableTarget(editor, event.target) &&
|
|
3008
|
+
!isTargetInsideVoid(editor, activeElement) &&
|
|
3009
|
+
!this.isDOMEventHandled(event, this.beforeInput)) {
|
|
2897
3010
|
try {
|
|
2898
|
-
const { selection } = editor;
|
|
2899
|
-
const { inputType: type } = event;
|
|
2900
|
-
const data = event.dataTransfer || event.data || undefined;
|
|
2901
3011
|
event.preventDefault();
|
|
2902
3012
|
// COMPAT: If the selection is expanded, even if the command seems like
|
|
2903
3013
|
// a delete forward/backward command it should delete the selection.
|
|
@@ -2985,7 +3095,10 @@ class SlateEditableComponent {
|
|
|
2985
3095
|
}
|
|
2986
3096
|
}
|
|
2987
3097
|
catch (error) {
|
|
2988
|
-
this.editor.onError({
|
|
3098
|
+
this.editor.onError({
|
|
3099
|
+
code: SlateErrorCode.OnDOMBeforeInputError,
|
|
3100
|
+
nativeError: error
|
|
3101
|
+
});
|
|
2989
3102
|
}
|
|
2990
3103
|
}
|
|
2991
3104
|
}
|
|
@@ -3055,7 +3168,7 @@ class SlateEditableComponent {
|
|
|
3055
3168
|
// aren't correct and never fire the "insertFromComposition"
|
|
3056
3169
|
// type that we need. So instead, insert whenever a composition
|
|
3057
3170
|
// ends since it will already have been committed to the DOM.
|
|
3058
|
-
if (this.isComposing === true && !IS_SAFARI && event.data) {
|
|
3171
|
+
if (this.isComposing === true && !IS_SAFARI && !IS_ANDROID && event.data) {
|
|
3059
3172
|
preventInsertFromComposition(event, this.editor);
|
|
3060
3173
|
Editor.insertText(this.editor, event.data);
|
|
3061
3174
|
}
|
|
@@ -3114,8 +3227,7 @@ class SlateEditableComponent {
|
|
|
3114
3227
|
if (!this.readonly && hasTarget(this.editor, event.target) && !this.isDOMEventHandled(event, this.dragStart)) {
|
|
3115
3228
|
const node = AngularEditor.toSlateNode(this.editor, event.target);
|
|
3116
3229
|
const path = AngularEditor.findPath(this.editor, node);
|
|
3117
|
-
const voidMatch = Editor.isVoid(this.editor, node) ||
|
|
3118
|
-
Editor.void(this.editor, { at: path, voids: true });
|
|
3230
|
+
const voidMatch = Editor.isVoid(this.editor, node) || Editor.void(this.editor, { at: path, voids: true });
|
|
3119
3231
|
// If starting a drag on a void node, make sure it is selected
|
|
3120
3232
|
// so that it shows up in the selection's fragment.
|
|
3121
3233
|
if (voidMatch) {
|
|
@@ -3139,7 +3251,7 @@ class SlateEditableComponent {
|
|
|
3139
3251
|
if (this.isDraggingInternally) {
|
|
3140
3252
|
if (draggedRange) {
|
|
3141
3253
|
Transforms.delete(editor, {
|
|
3142
|
-
at: draggedRange
|
|
3254
|
+
at: draggedRange
|
|
3143
3255
|
});
|
|
3144
3256
|
}
|
|
3145
3257
|
this.isDraggingInternally = false;
|
|
@@ -3153,7 +3265,10 @@ class SlateEditableComponent {
|
|
|
3153
3265
|
}
|
|
3154
3266
|
}
|
|
3155
3267
|
onDOMDragEnd(event) {
|
|
3156
|
-
if (!this.readonly &&
|
|
3268
|
+
if (!this.readonly &&
|
|
3269
|
+
this.isDraggingInternally &&
|
|
3270
|
+
hasTarget(this.editor, event.target) &&
|
|
3271
|
+
!this.isDOMEventHandled(event, this.dragEnd)) {
|
|
3157
3272
|
this.isDraggingInternally = false;
|
|
3158
3273
|
}
|
|
3159
3274
|
}
|
|
@@ -3294,7 +3409,9 @@ class SlateEditableComponent {
|
|
|
3294
3409
|
if (hotkeys.isDeleteBackward(nativeEvent)) {
|
|
3295
3410
|
event.preventDefault();
|
|
3296
3411
|
if (selection && Range.isExpanded(selection)) {
|
|
3297
|
-
Editor.deleteFragment(editor, {
|
|
3412
|
+
Editor.deleteFragment(editor, {
|
|
3413
|
+
direction: 'backward'
|
|
3414
|
+
});
|
|
3298
3415
|
}
|
|
3299
3416
|
else {
|
|
3300
3417
|
Editor.deleteBackward(editor);
|
|
@@ -3304,7 +3421,9 @@ class SlateEditableComponent {
|
|
|
3304
3421
|
if (hotkeys.isDeleteForward(nativeEvent)) {
|
|
3305
3422
|
event.preventDefault();
|
|
3306
3423
|
if (selection && Range.isExpanded(selection)) {
|
|
3307
|
-
Editor.deleteFragment(editor, {
|
|
3424
|
+
Editor.deleteFragment(editor, {
|
|
3425
|
+
direction: 'forward'
|
|
3426
|
+
});
|
|
3308
3427
|
}
|
|
3309
3428
|
else {
|
|
3310
3429
|
Editor.deleteForward(editor);
|
|
@@ -3314,7 +3433,9 @@ class SlateEditableComponent {
|
|
|
3314
3433
|
if (hotkeys.isDeleteLineBackward(nativeEvent)) {
|
|
3315
3434
|
event.preventDefault();
|
|
3316
3435
|
if (selection && Range.isExpanded(selection)) {
|
|
3317
|
-
Editor.deleteFragment(editor, {
|
|
3436
|
+
Editor.deleteFragment(editor, {
|
|
3437
|
+
direction: 'backward'
|
|
3438
|
+
});
|
|
3318
3439
|
}
|
|
3319
3440
|
else {
|
|
3320
3441
|
Editor.deleteBackward(editor, { unit: 'line' });
|
|
@@ -3324,7 +3445,9 @@ class SlateEditableComponent {
|
|
|
3324
3445
|
if (hotkeys.isDeleteLineForward(nativeEvent)) {
|
|
3325
3446
|
event.preventDefault();
|
|
3326
3447
|
if (selection && Range.isExpanded(selection)) {
|
|
3327
|
-
Editor.deleteFragment(editor, {
|
|
3448
|
+
Editor.deleteFragment(editor, {
|
|
3449
|
+
direction: 'forward'
|
|
3450
|
+
});
|
|
3328
3451
|
}
|
|
3329
3452
|
else {
|
|
3330
3453
|
Editor.deleteForward(editor, { unit: 'line' });
|
|
@@ -3334,7 +3457,9 @@ class SlateEditableComponent {
|
|
|
3334
3457
|
if (hotkeys.isDeleteWordBackward(nativeEvent)) {
|
|
3335
3458
|
event.preventDefault();
|
|
3336
3459
|
if (selection && Range.isExpanded(selection)) {
|
|
3337
|
-
Editor.deleteFragment(editor, {
|
|
3460
|
+
Editor.deleteFragment(editor, {
|
|
3461
|
+
direction: 'backward'
|
|
3462
|
+
});
|
|
3338
3463
|
}
|
|
3339
3464
|
else {
|
|
3340
3465
|
Editor.deleteBackward(editor, { unit: 'word' });
|
|
@@ -3344,7 +3469,9 @@ class SlateEditableComponent {
|
|
|
3344
3469
|
if (hotkeys.isDeleteWordForward(nativeEvent)) {
|
|
3345
3470
|
event.preventDefault();
|
|
3346
3471
|
if (selection && Range.isExpanded(selection)) {
|
|
3347
|
-
Editor.deleteFragment(editor, {
|
|
3472
|
+
Editor.deleteFragment(editor, {
|
|
3473
|
+
direction: 'forward'
|
|
3474
|
+
});
|
|
3348
3475
|
}
|
|
3349
3476
|
else {
|
|
3350
3477
|
Editor.deleteForward(editor, { unit: 'word' });
|
|
@@ -3357,15 +3484,16 @@ class SlateEditableComponent {
|
|
|
3357
3484
|
// COMPAT: Chrome and Safari support `beforeinput` event but do not fire
|
|
3358
3485
|
// an event when deleting backwards in a selected void inline node
|
|
3359
3486
|
if (selection &&
|
|
3360
|
-
(hotkeys.isDeleteBackward(nativeEvent) ||
|
|
3361
|
-
hotkeys.isDeleteForward(nativeEvent)) &&
|
|
3487
|
+
(hotkeys.isDeleteBackward(nativeEvent) || hotkeys.isDeleteForward(nativeEvent)) &&
|
|
3362
3488
|
Range.isCollapsed(selection)) {
|
|
3363
3489
|
const currentNode = Node.parent(editor, selection.anchor.path);
|
|
3364
3490
|
if (Element.isElement(currentNode) &&
|
|
3365
3491
|
Editor.isVoid(editor, currentNode) &&
|
|
3366
3492
|
Editor.isInline(editor, currentNode)) {
|
|
3367
3493
|
event.preventDefault();
|
|
3368
|
-
Editor.deleteBackward(editor, {
|
|
3494
|
+
Editor.deleteBackward(editor, {
|
|
3495
|
+
unit: 'block'
|
|
3496
|
+
});
|
|
3369
3497
|
return;
|
|
3370
3498
|
}
|
|
3371
3499
|
}
|
|
@@ -3373,7 +3501,10 @@ class SlateEditableComponent {
|
|
|
3373
3501
|
}
|
|
3374
3502
|
}
|
|
3375
3503
|
catch (error) {
|
|
3376
|
-
this.editor.onError({
|
|
3504
|
+
this.editor.onError({
|
|
3505
|
+
code: SlateErrorCode.OnDOMKeydownError,
|
|
3506
|
+
nativeError: error
|
|
3507
|
+
});
|
|
3377
3508
|
}
|
|
3378
3509
|
}
|
|
3379
3510
|
}
|
|
@@ -3411,7 +3542,10 @@ class SlateEditableComponent {
|
|
|
3411
3542
|
}
|
|
3412
3543
|
}
|
|
3413
3544
|
catch (error) {
|
|
3414
|
-
this.editor.onError({
|
|
3545
|
+
this.editor.onError({
|
|
3546
|
+
code: SlateErrorCode.ToNativeSelectionError,
|
|
3547
|
+
nativeError: error
|
|
3548
|
+
});
|
|
3415
3549
|
}
|
|
3416
3550
|
}
|
|
3417
3551
|
}
|
|
@@ -3433,11 +3567,13 @@ class SlateEditableComponent {
|
|
|
3433
3567
|
}
|
|
3434
3568
|
}
|
|
3435
3569
|
SlateEditableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: SlateEditableComponent, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Component });
|
|
3436
|
-
SlateEditableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: SlateEditableComponent, selector: "slate-editable", inputs: { editor: "editor", renderElement: "renderElement", renderLeaf: "renderLeaf", renderText: "renderText", decorate: "decorate", placeholderDecorate: "placeholderDecorate", isStrictDecorate: "isStrictDecorate", trackBy: "trackBy", readonly: "readonly", placeholder: "placeholder", beforeInput: "beforeInput", blur: "blur", click: "click", compositionEnd: "compositionEnd", compositionStart: "compositionStart", copy: "copy", cut: "cut", dragOver: "dragOver", dragStart: "dragStart", dragEnd: "dragEnd", drop: "drop", focus: "focus", keydown: "keydown", paste: "paste", spellCheck: "spellCheck", autoCorrect: "autoCorrect", autoCapitalize: "autoCapitalize" }, host: { properties: { "attr.contenteditable": "readonly ? undefined : true", "attr.role": "readonly ? undefined : 'textbox'", "attr.spellCheck": "!hasBeforeInputSupport ? false : spellCheck", "attr.autoCorrect": "!hasBeforeInputSupport ? 'false' : autoCorrect", "attr.autoCapitalize": "!hasBeforeInputSupport ? 'false' : autoCapitalize", "attr.data-slate-editor": "this.dataSlateEditor", "attr.data-slate-node": "this.dataSlateNode", "attr.data-gramm": "this.dataGramm" }, classAttribute: "slate-editable-container" }, providers: [
|
|
3570
|
+
SlateEditableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: SlateEditableComponent, selector: "slate-editable", inputs: { editor: "editor", renderElement: "renderElement", renderLeaf: "renderLeaf", renderText: "renderText", decorate: "decorate", placeholderDecorate: "placeholderDecorate", isStrictDecorate: "isStrictDecorate", trackBy: "trackBy", readonly: "readonly", placeholder: "placeholder", beforeInput: "beforeInput", blur: "blur", click: "click", compositionEnd: "compositionEnd", compositionStart: "compositionStart", copy: "copy", cut: "cut", dragOver: "dragOver", dragStart: "dragStart", dragEnd: "dragEnd", drop: "drop", focus: "focus", keydown: "keydown", paste: "paste", spellCheck: "spellCheck", autoCorrect: "autoCorrect", autoCapitalize: "autoCapitalize" }, host: { properties: { "attr.contenteditable": "readonly ? undefined : true", "attr.role": "readonly ? undefined : 'textbox'", "attr.spellCheck": "!hasBeforeInputSupport ? false : spellCheck", "attr.autoCorrect": "!hasBeforeInputSupport ? 'false' : autoCorrect", "attr.autoCapitalize": "!hasBeforeInputSupport ? 'false' : autoCapitalize", "attr.data-slate-editor": "this.dataSlateEditor", "attr.data-slate-node": "this.dataSlateNode", "attr.data-gramm": "this.dataGramm" }, classAttribute: "slate-editable-container" }, providers: [
|
|
3571
|
+
{
|
|
3437
3572
|
provide: NG_VALUE_ACCESSOR,
|
|
3438
3573
|
useExisting: forwardRef(() => SlateEditableComponent),
|
|
3439
3574
|
multi: true
|
|
3440
|
-
}
|
|
3575
|
+
}
|
|
3576
|
+
], viewQueries: [{ propertyName: "templateComponent", first: true, predicate: ["templateComponent"], descendants: true, static: true }, { propertyName: "templateElementRef", first: true, predicate: ["templateComponent"], descendants: true, read: ElementRef, static: true }], usesOnChanges: true, ngImport: i0, template: "<slate-children [children]=\"editor.children\" [context]=\"context\" [viewContext]=\"viewContext\"></slate-children>\n<slate-string-template #templateComponent></slate-string-template>\n", dependencies: [{ kind: "component", type: SlateStringTemplateComponent, selector: "slate-string-template" }, { kind: "component", type: SlateChildrenComponent, selector: "slate-children", inputs: ["children", "context", "viewContext"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
3441
3577
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: SlateEditableComponent, decorators: [{
|
|
3442
3578
|
type: Component,
|
|
3443
3579
|
args: [{ selector: 'slate-editable', host: {
|
|
@@ -3447,11 +3583,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
|
|
|
3447
3583
|
'[attr.spellCheck]': `!hasBeforeInputSupport ? false : spellCheck`,
|
|
3448
3584
|
'[attr.autoCorrect]': `!hasBeforeInputSupport ? 'false' : autoCorrect`,
|
|
3449
3585
|
'[attr.autoCapitalize]': `!hasBeforeInputSupport ? 'false' : autoCapitalize`
|
|
3450
|
-
}, changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
3586
|
+
}, changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
3587
|
+
{
|
|
3451
3588
|
provide: NG_VALUE_ACCESSOR,
|
|
3452
3589
|
useExisting: forwardRef(() => SlateEditableComponent),
|
|
3453
3590
|
multi: true
|
|
3454
|
-
}
|
|
3591
|
+
}
|
|
3592
|
+
], template: "<slate-children [children]=\"editor.children\" [context]=\"context\" [viewContext]=\"viewContext\"></slate-children>\n<slate-string-template #templateComponent></slate-string-template>\n" }]
|
|
3455
3593
|
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }, { type: i0.Injector }]; }, propDecorators: { editor: [{
|
|
3456
3594
|
type: Input
|
|
3457
3595
|
}], renderElement: [{
|
|
@@ -3555,8 +3693,10 @@ const isTargetInsideVoid = (editor, target) => {
|
|
|
3555
3693
|
return Editor.isVoid(editor, slateNode);
|
|
3556
3694
|
};
|
|
3557
3695
|
const hasStringTarget = (domSelection) => {
|
|
3558
|
-
return (domSelection.anchorNode.parentElement.hasAttribute('data-slate-string') ||
|
|
3559
|
-
|
|
3696
|
+
return ((domSelection.anchorNode.parentElement.hasAttribute('data-slate-string') ||
|
|
3697
|
+
domSelection.anchorNode.parentElement.hasAttribute('data-slate-zero-width')) &&
|
|
3698
|
+
(domSelection.focusNode.parentElement.hasAttribute('data-slate-string') ||
|
|
3699
|
+
domSelection.focusNode.parentElement.hasAttribute('data-slate-zero-width')));
|
|
3560
3700
|
};
|
|
3561
3701
|
/**
|
|
3562
3702
|
* remove default insert from composition
|
|
@@ -3618,12 +3758,18 @@ SlateModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "1
|
|
|
3618
3758
|
SlateBlockCardComponent,
|
|
3619
3759
|
SlateLeafComponent,
|
|
3620
3760
|
SlateLeavesComponent,
|
|
3621
|
-
SlateDefaultLeafComponent
|
|
3761
|
+
SlateDefaultLeafComponent,
|
|
3762
|
+
SlateDefaultStringComponent], imports: [CommonModule], exports: [SlateEditableComponent,
|
|
3763
|
+
SlateChildrenComponent,
|
|
3764
|
+
SlateElementComponent,
|
|
3765
|
+
SlateLeavesComponent,
|
|
3766
|
+
SlateStringComponent,
|
|
3767
|
+
SlateDefaultStringComponent] });
|
|
3622
3768
|
SlateModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: SlateModule, providers: [
|
|
3623
3769
|
{
|
|
3624
3770
|
provide: SLATE_DEFAULT_ELEMENT_COMPONENT_TOKEN,
|
|
3625
3771
|
useValue: SlateDefaultElementComponent
|
|
3626
|
-
}
|
|
3772
|
+
}
|
|
3627
3773
|
], imports: [CommonModule] });
|
|
3628
3774
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: SlateModule, decorators: [{
|
|
3629
3775
|
type: NgModule,
|
|
@@ -3641,15 +3787,23 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
|
|
|
3641
3787
|
SlateBlockCardComponent,
|
|
3642
3788
|
SlateLeafComponent,
|
|
3643
3789
|
SlateLeavesComponent,
|
|
3644
|
-
SlateDefaultLeafComponent
|
|
3790
|
+
SlateDefaultLeafComponent,
|
|
3791
|
+
SlateDefaultStringComponent
|
|
3645
3792
|
],
|
|
3646
3793
|
imports: [CommonModule],
|
|
3647
|
-
exports: [
|
|
3794
|
+
exports: [
|
|
3795
|
+
SlateEditableComponent,
|
|
3796
|
+
SlateChildrenComponent,
|
|
3797
|
+
SlateElementComponent,
|
|
3798
|
+
SlateLeavesComponent,
|
|
3799
|
+
SlateStringComponent,
|
|
3800
|
+
SlateDefaultStringComponent
|
|
3801
|
+
],
|
|
3648
3802
|
providers: [
|
|
3649
3803
|
{
|
|
3650
3804
|
provide: SLATE_DEFAULT_ELEMENT_COMPONENT_TOKEN,
|
|
3651
3805
|
useValue: SlateDefaultElementComponent
|
|
3652
|
-
}
|
|
3806
|
+
}
|
|
3653
3807
|
]
|
|
3654
3808
|
}]
|
|
3655
3809
|
}] });
|
|
@@ -3662,5 +3816,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
|
|
|
3662
3816
|
* Generated bundle index. Do not edit.
|
|
3663
3817
|
*/
|
|
3664
3818
|
|
|
3665
|
-
export { AngularEditor, BaseComponent, BaseElementComponent, BaseLeafComponent, BaseTextComponent, DOMComment, DOMElement, DOMNode, DOMRange, DOMSelection, DOMStaticRange, DOMText, EDITOR_TO_ELEMENT, EDITOR_TO_ON_CHANGE, EDITOR_TO_PLACEHOLDER, EDITOR_TO_WINDOW, ELEMENT_TO_COMPONENT, ELEMENT_TO_NODE, FAKE_LEFT_BLOCK_CARD_OFFSET, FAKE_RIGHT_BLOCK_CARD_OFFSET, HAS_BEFORE_INPUT_SUPPORT, IS_ANDROID, IS_APPLE, IS_CHROME, IS_CHROME_LEGACY, IS_CLICKING, IS_DRAGGING, IS_EDGE_LEGACY, IS_FIREFOX, IS_FIREFOX_LEGACY, IS_FOCUSED, IS_IOS, IS_QQBROWSER, IS_READONLY, IS_SAFARI, IS_UC_MOBILE, IS_WECHATBROWSER, KEY_TO_ELEMENT, Key, NODE_TO_ELEMENT, NODE_TO_INDEX, NODE_TO_KEY, NODE_TO_PARENT, PLACEHOLDER_SYMBOL, SlateChildrenComponent, SlateEditableComponent, SlateElementComponent, SlateErrorCode, SlateLeavesComponent, SlateModule, SlateStringComponent, check, getCardTargetAttribute, getClipboardData, getDefaultView, getEditableChild, getEditableChildAndIndex, getPlainText, getSlateFragmentAttribute, hasBeforeContextChange, hasBlockCard, hasBlockCardWithNode, hasShadowRoot, hotkeys, isCardCenterByTargetAttr, isCardLeft, isCardLeftByTargetAttr, isCardRightByTargetAttr, isComponentType, isDOMComment, isDOMElement, isDOMNode, isDOMSelection, isDOMText, isDecoratorRangeListEqual, isPlainTextOnlyPaste, isTemplateRef, isValid, normalize, normalizeDOMPoint, shallowCompare, withAngular };
|
|
3819
|
+
export { AngularEditor, BaseComponent, BaseElementComponent, BaseLeafComponent, BaseTextComponent, DOMComment, DOMElement, DOMNode, DOMRange, DOMSelection, DOMStaticRange, DOMText, EDITOR_TO_ELEMENT, EDITOR_TO_ON_CHANGE, EDITOR_TO_PLACEHOLDER, EDITOR_TO_WINDOW, ELEMENT_TO_COMPONENT, ELEMENT_TO_NODE, FAKE_LEFT_BLOCK_CARD_OFFSET, FAKE_RIGHT_BLOCK_CARD_OFFSET, HAS_BEFORE_INPUT_SUPPORT, IS_ANDROID, IS_APPLE, IS_CHROME, IS_CHROME_LEGACY, IS_CLICKING, IS_DRAGGING, IS_EDGE_LEGACY, IS_FIREFOX, IS_FIREFOX_LEGACY, IS_FOCUSED, IS_IOS, IS_QQBROWSER, IS_READONLY, IS_SAFARI, IS_UC_MOBILE, IS_WECHATBROWSER, KEY_TO_ELEMENT, Key, NODE_TO_ELEMENT, NODE_TO_INDEX, NODE_TO_KEY, NODE_TO_PARENT, PLACEHOLDER_SYMBOL, SlateChildrenComponent, SlateDefaultStringComponent, SlateEditableComponent, SlateElementComponent, SlateErrorCode, SlateLeavesComponent, SlateModule, SlateStringComponent, check, getCardTargetAttribute, getClipboardData, getDefaultView, getEditableChild, getEditableChildAndIndex, getPlainText, getSlateFragmentAttribute, hasBeforeContextChange, hasBlockCard, hasBlockCardWithNode, hasShadowRoot, hotkeys, isCardCenterByTargetAttr, isCardLeft, isCardLeftByTargetAttr, isCardRightByTargetAttr, isComponentType, isDOMComment, isDOMElement, isDOMNode, isDOMSelection, isDOMText, isDecoratorRangeListEqual, isPlainTextOnlyPaste, isTemplateRef, isValid, normalize, normalizeDOMPoint, shallowCompare, withAngular };
|
|
3666
3820
|
//# sourceMappingURL=slate-angular.mjs.map
|