slate-angular 20.0.0 → 20.1.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.
- package/fesm2022/slate-angular.mjs +78 -71
- package/fesm2022/slate-angular.mjs.map +1 -1
- package/index.d.ts +16 -20
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import { Editor, Range, Element, Transforms, Text as Text$1, Node, Path } from '
|
|
|
2
2
|
import { EDITOR_TO_ELEMENT, NODE_TO_ELEMENT, DOMEditor, normalizeDOMPoint, isDOMSelection, IS_CHROME as IS_CHROME$1, hasShadowRoot, isDOMElement, NODE_TO_PARENT, NODE_TO_INDEX, IS_FOCUSED, isDOMNode, withDOM, NODE_TO_KEY, ELEMENT_TO_NODE, getDefaultView, EDITOR_TO_WINDOW, IS_READ_ONLY, EDITOR_TO_ON_CHANGE, TRIPLE_CLICK, isPlainTextOnlyPaste } from 'slate-dom';
|
|
3
3
|
import { isKeyHotkey } from 'is-hotkey';
|
|
4
4
|
import * as i0 from '@angular/core';
|
|
5
|
-
import { TemplateRef,
|
|
5
|
+
import { TemplateRef, ComponentRef, IterableDiffers, inject, ViewContainerRef, forwardRef, HostBinding, Input, ChangeDetectionStrategy, Component, NgModule, ElementRef, ChangeDetectorRef, Directive, ViewChild } from '@angular/core';
|
|
6
6
|
import { direction } from 'direction';
|
|
7
7
|
import scrollIntoView from 'scroll-into-view-if-needed';
|
|
8
8
|
import { Subject } from 'rxjs';
|
|
@@ -839,6 +839,9 @@ const getContentHeight = (element) => {
|
|
|
839
839
|
}
|
|
840
840
|
return Math.max(contentHeight, 0);
|
|
841
841
|
};
|
|
842
|
+
const getZeroTextNode = () => {
|
|
843
|
+
return document.createTextNode('\uFEFF');
|
|
844
|
+
};
|
|
842
845
|
|
|
843
846
|
const buildHTMLText = (wrapper, attach, data) => {
|
|
844
847
|
const stringObj = JSON.stringify(data);
|
|
@@ -1512,38 +1515,12 @@ function restoreDom(editor, execute) {
|
|
|
1512
1515
|
}, 0);
|
|
1513
1516
|
}
|
|
1514
1517
|
|
|
1515
|
-
class
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
}
|
|
1519
|
-
get centerContainerElement() {
|
|
1520
|
-
return this.centerContainer.nativeElement;
|
|
1521
|
-
}
|
|
1522
|
-
constructor(elementRef) {
|
|
1523
|
-
this.elementRef = elementRef;
|
|
1524
|
-
}
|
|
1525
|
-
ngOnInit() {
|
|
1526
|
-
this.nativeElement.classList.add(`slate-block-card`);
|
|
1527
|
-
}
|
|
1528
|
-
append() {
|
|
1529
|
-
this.centerRootNodes.forEach(rootNode => !this.centerContainerElement.contains(rootNode) && this.centerContainerElement.appendChild(rootNode));
|
|
1530
|
-
}
|
|
1531
|
-
initializeCenter(rootNodes) {
|
|
1532
|
-
this.centerRootNodes = rootNodes;
|
|
1533
|
-
this.append();
|
|
1518
|
+
class FlavourRef {
|
|
1519
|
+
destroy() {
|
|
1520
|
+
this.instance.onDestroy();
|
|
1534
1521
|
}
|
|
1535
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: SlateBlockCard, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1536
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.12", type: SlateBlockCard, isStandalone: true, selector: "slate-block-card, [slateBlockCard]", viewQueries: [{ propertyName: "centerContainer", first: true, predicate: ["centerContainer"], descendants: true, static: true }], ngImport: i0, template: "<span card-target=\"card-left\" class=\"card-left\">{{ '\\uFEFF' }}</span>\n<div card-target=\"card-center\" #centerContainer></div>\n<span card-target=\"card-right\" class=\"card-right\">{{ '\\uFEFF' }}</span>\n" }); }
|
|
1537
1522
|
}
|
|
1538
|
-
|
|
1539
|
-
type: Component,
|
|
1540
|
-
args: [{ selector: 'slate-block-card, [slateBlockCard]', standalone: true, template: "<span card-target=\"card-left\" class=\"card-left\">{{ '\\uFEFF' }}</span>\n<div card-target=\"card-center\" #centerContainer></div>\n<span card-target=\"card-right\" class=\"card-right\">{{ '\\uFEFF' }}</span>\n" }]
|
|
1541
|
-
}], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { centerContainer: [{
|
|
1542
|
-
type: ViewChild,
|
|
1543
|
-
args: ['centerContainer', { static: true }]
|
|
1544
|
-
}] } });
|
|
1545
|
-
|
|
1546
|
-
class FlavourRef {
|
|
1523
|
+
class BlockCardRef {
|
|
1547
1524
|
destroy() {
|
|
1548
1525
|
this.instance.onDestroy();
|
|
1549
1526
|
}
|
|
@@ -1995,7 +1972,7 @@ const createEmptyOrVoidStringNode = () => {
|
|
|
1995
1972
|
stringNode.setAttribute('data-slate-string', 'true');
|
|
1996
1973
|
stringNode.setAttribute('data-slate-zero-width', 'z');
|
|
1997
1974
|
stringNode.setAttribute('data-slate-length', '0');
|
|
1998
|
-
const zeroWidthSpace =
|
|
1975
|
+
const zeroWidthSpace = getZeroTextNode();
|
|
1999
1976
|
stringNode.appendChild(zeroWidthSpace);
|
|
2000
1977
|
stringNode.setAttribute('editable-text', '');
|
|
2001
1978
|
return stringNode;
|
|
@@ -2006,7 +1983,7 @@ const createCompatibleStringNode = (text) => {
|
|
|
2006
1983
|
stringNode.textContent = text;
|
|
2007
1984
|
stringNode.setAttribute('editable-text', '');
|
|
2008
1985
|
const zeroWidthSpan = document.createElement('span');
|
|
2009
|
-
const zeroWidthSpace =
|
|
1986
|
+
const zeroWidthSpace = getZeroTextNode();
|
|
2010
1987
|
zeroWidthSpan.setAttribute('data-slate-zero-width', '');
|
|
2011
1988
|
zeroWidthSpan.appendChild(zeroWidthSpace);
|
|
2012
1989
|
stringNode.appendChild(zeroWidthSpan);
|
|
@@ -2016,7 +1993,7 @@ const createLineBreakEmptyStringDOM = (elementStringLength) => {
|
|
|
2016
1993
|
const stringNode = document.createElement('span');
|
|
2017
1994
|
stringNode.setAttribute('data-slate-zero-width', 'n');
|
|
2018
1995
|
stringNode.setAttribute('data-slate-length', `${elementStringLength}`);
|
|
2019
|
-
const zeroWidthSpace =
|
|
1996
|
+
const zeroWidthSpace = getZeroTextNode();
|
|
2020
1997
|
stringNode.appendChild(zeroWidthSpace);
|
|
2021
1998
|
const brNode = document.createElement('br');
|
|
2022
1999
|
stringNode.appendChild(brNode);
|
|
@@ -2226,6 +2203,49 @@ const createText = (text) => {
|
|
|
2226
2203
|
return { nativeElement };
|
|
2227
2204
|
};
|
|
2228
2205
|
|
|
2206
|
+
const SLATE_BLOCK_CARD_CLASS_NAME = 'slate-block-card';
|
|
2207
|
+
class SlateBlockCard {
|
|
2208
|
+
onInit() {
|
|
2209
|
+
const nativeElement = document.createElement('div');
|
|
2210
|
+
nativeElement.classList.add(SLATE_BLOCK_CARD_CLASS_NAME);
|
|
2211
|
+
this.nativeElement = nativeElement;
|
|
2212
|
+
this.createContent();
|
|
2213
|
+
}
|
|
2214
|
+
createContent() {
|
|
2215
|
+
const leftCaret = document.createElement('span');
|
|
2216
|
+
leftCaret.setAttribute(`card-target`, 'card-left');
|
|
2217
|
+
leftCaret.classList.add('card-left');
|
|
2218
|
+
leftCaret.appendChild(getZeroTextNode());
|
|
2219
|
+
const rightCaret = document.createElement('span');
|
|
2220
|
+
rightCaret.setAttribute(`card-target`, 'card-right');
|
|
2221
|
+
rightCaret.classList.add('card-right');
|
|
2222
|
+
rightCaret.appendChild(getZeroTextNode());
|
|
2223
|
+
const center = document.createElement('div');
|
|
2224
|
+
center.setAttribute(`card-target`, 'card-center');
|
|
2225
|
+
this.nativeElement.appendChild(leftCaret);
|
|
2226
|
+
this.nativeElement.appendChild(center);
|
|
2227
|
+
this.nativeElement.appendChild(rightCaret);
|
|
2228
|
+
this.centerContainer = center;
|
|
2229
|
+
}
|
|
2230
|
+
append() {
|
|
2231
|
+
this.centerRootNodes.forEach(rootNode => !this.centerContainer.contains(rootNode) && this.centerContainer.appendChild(rootNode));
|
|
2232
|
+
}
|
|
2233
|
+
initializeCenter(rootNodes) {
|
|
2234
|
+
this.centerRootNodes = rootNodes;
|
|
2235
|
+
this.append();
|
|
2236
|
+
}
|
|
2237
|
+
onDestroy() {
|
|
2238
|
+
this.nativeElement.remove();
|
|
2239
|
+
}
|
|
2240
|
+
}
|
|
2241
|
+
const getBlockCardByNativeElement = (nativeElement) => {
|
|
2242
|
+
const blockCardElement = nativeElement?.parentElement?.parentElement;
|
|
2243
|
+
if (blockCardElement && blockCardElement.classList.contains(SLATE_BLOCK_CARD_CLASS_NAME)) {
|
|
2244
|
+
return blockCardElement;
|
|
2245
|
+
}
|
|
2246
|
+
return null;
|
|
2247
|
+
};
|
|
2248
|
+
|
|
2229
2249
|
class ListRender {
|
|
2230
2250
|
constructor(viewContext, viewContainerRef, getOutletParent, getOutletElement) {
|
|
2231
2251
|
this.viewContext = viewContext;
|
|
@@ -2249,7 +2269,7 @@ class ListRender {
|
|
|
2249
2269
|
const context = getContext(index, descendant, parentPath, childrenContext, this.viewContext);
|
|
2250
2270
|
const viewType = getViewType(descendant, parent, this.viewContext);
|
|
2251
2271
|
const view = createEmbeddedViewOrComponentOrFlavour(viewType, context, this.viewContext, this.viewContainerRef);
|
|
2252
|
-
const blockCard = createBlockCard(descendant, view, this.
|
|
2272
|
+
const blockCard = createBlockCard(descendant, view, this.viewContext);
|
|
2253
2273
|
this.views.push(view);
|
|
2254
2274
|
this.contexts.push(context);
|
|
2255
2275
|
this.viewTypes.push(viewType);
|
|
@@ -2290,7 +2310,7 @@ class ListRender {
|
|
|
2290
2310
|
let blockCard;
|
|
2291
2311
|
if (record.previousIndex === null) {
|
|
2292
2312
|
view = createEmbeddedViewOrComponentOrFlavour(viewType, context, this.viewContext, this.viewContainerRef);
|
|
2293
|
-
blockCard = createBlockCard(record.item, view, this.
|
|
2313
|
+
blockCard = createBlockCard(record.item, view, this.viewContext);
|
|
2294
2314
|
newContexts.push(context);
|
|
2295
2315
|
newViews.push(view);
|
|
2296
2316
|
newBlockCards.push(blockCard);
|
|
@@ -2303,7 +2323,7 @@ class ListRender {
|
|
|
2303
2323
|
const previousBlockCard = this.blockCards[record.previousIndex];
|
|
2304
2324
|
if (previousViewType !== viewType) {
|
|
2305
2325
|
view = createEmbeddedViewOrComponentOrFlavour(viewType, context, this.viewContext, this.viewContainerRef);
|
|
2306
|
-
blockCard = createBlockCard(record.item, view, this.
|
|
2326
|
+
blockCard = createBlockCard(record.item, view, this.viewContext);
|
|
2307
2327
|
const firstRootNode = getRootNodes(previousView, previousBlockCard)[0];
|
|
2308
2328
|
const newRootNodes = getRootNodes(view, blockCard);
|
|
2309
2329
|
firstRootNode.replaceWith(...newRootNodes);
|
|
@@ -2461,16 +2481,15 @@ function getViewType(item, parent, viewContext) {
|
|
|
2461
2481
|
return isVoid ? VoidTextFlavour : (viewContext.renderText && viewContext.renderText(item)) || DefaultTextFlavour;
|
|
2462
2482
|
}
|
|
2463
2483
|
}
|
|
2464
|
-
function createBlockCard(item, view,
|
|
2484
|
+
function createBlockCard(item, view, viewContext) {
|
|
2465
2485
|
const isBlockCard = viewContext.editor.isBlockCard(item);
|
|
2466
2486
|
if (isBlockCard) {
|
|
2467
2487
|
const rootNodes = getRootNodes(view);
|
|
2468
|
-
const
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
return blockCardComponentRef;
|
|
2488
|
+
const blockCardRef = new BlockCardRef();
|
|
2489
|
+
blockCardRef.instance = new SlateBlockCard();
|
|
2490
|
+
blockCardRef.instance.onInit();
|
|
2491
|
+
blockCardRef.instance.initializeCenter(rootNodes);
|
|
2492
|
+
return blockCardRef;
|
|
2474
2493
|
}
|
|
2475
2494
|
else {
|
|
2476
2495
|
return null;
|
|
@@ -3544,24 +3563,31 @@ class SlateEditable {
|
|
|
3544
3563
|
useExisting: forwardRef(() => SlateEditable),
|
|
3545
3564
|
multi: true
|
|
3546
3565
|
}
|
|
3547
|
-
], usesOnChanges: true, ngImport: i0, template:
|
|
3566
|
+
], usesOnChanges: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
3548
3567
|
}
|
|
3549
3568
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: SlateEditable, decorators: [{
|
|
3550
3569
|
type: Component,
|
|
3551
|
-
args: [{
|
|
3570
|
+
args: [{
|
|
3571
|
+
selector: 'slate-editable',
|
|
3572
|
+
host: {
|
|
3552
3573
|
class: 'slate-editable-container',
|
|
3553
3574
|
'[attr.contenteditable]': 'readonly ? undefined : true',
|
|
3554
3575
|
'[attr.role]': `readonly ? undefined : 'textbox'`,
|
|
3555
3576
|
'[attr.spellCheck]': `!hasBeforeInputSupport ? false : spellCheck`,
|
|
3556
3577
|
'[attr.autoCorrect]': `!hasBeforeInputSupport ? 'false' : autoCorrect`,
|
|
3557
3578
|
'[attr.autoCapitalize]': `!hasBeforeInputSupport ? 'false' : autoCapitalize`
|
|
3558
|
-
},
|
|
3579
|
+
},
|
|
3580
|
+
template: '',
|
|
3581
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
3582
|
+
providers: [
|
|
3559
3583
|
{
|
|
3560
3584
|
provide: NG_VALUE_ACCESSOR,
|
|
3561
3585
|
useExisting: forwardRef(() => SlateEditable),
|
|
3562
3586
|
multi: true
|
|
3563
3587
|
}
|
|
3564
|
-
],
|
|
3588
|
+
],
|
|
3589
|
+
imports: []
|
|
3590
|
+
}]
|
|
3565
3591
|
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }, { type: i0.Injector }], propDecorators: { editor: [{
|
|
3566
3592
|
type: Input
|
|
3567
3593
|
}], renderElement: [{
|
|
@@ -3709,35 +3735,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImpo
|
|
|
3709
3735
|
}]
|
|
3710
3736
|
}], ctorParameters: () => [{ type: i0.ElementRef }] });
|
|
3711
3737
|
|
|
3712
|
-
class SlateString {
|
|
3713
|
-
ngOnInit() { }
|
|
3714
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: SlateString, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
3715
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.12", type: SlateString, isStandalone: true, selector: "span[slateString]", inputs: { context: "context", viewContext: "viewContext" }, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
3716
|
-
}
|
|
3717
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: SlateString, decorators: [{
|
|
3718
|
-
type: Component,
|
|
3719
|
-
args: [{
|
|
3720
|
-
selector: 'span[slateString]',
|
|
3721
|
-
template: '',
|
|
3722
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
3723
|
-
standalone: true
|
|
3724
|
-
}]
|
|
3725
|
-
}], propDecorators: { context: [{
|
|
3726
|
-
type: Input
|
|
3727
|
-
}], viewContext: [{
|
|
3728
|
-
type: Input
|
|
3729
|
-
}] } });
|
|
3730
|
-
|
|
3731
3738
|
class SlateModule {
|
|
3732
3739
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: SlateModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
3733
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.12", ngImport: i0, type: SlateModule, imports: [CommonModule, SlateEditable,
|
|
3740
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.12", ngImport: i0, type: SlateModule, imports: [CommonModule, SlateEditable, SlateChildrenOutlet], exports: [SlateEditable, SlateChildrenOutlet] }); }
|
|
3734
3741
|
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: SlateModule, imports: [CommonModule] }); }
|
|
3735
3742
|
}
|
|
3736
3743
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: SlateModule, decorators: [{
|
|
3737
3744
|
type: NgModule,
|
|
3738
3745
|
args: [{
|
|
3739
|
-
imports: [CommonModule, SlateEditable,
|
|
3740
|
-
exports: [SlateEditable, SlateChildrenOutlet
|
|
3746
|
+
imports: [CommonModule, SlateEditable, SlateChildrenOutlet],
|
|
3747
|
+
exports: [SlateEditable, SlateChildrenOutlet],
|
|
3741
3748
|
providers: []
|
|
3742
3749
|
}]
|
|
3743
3750
|
}] });
|
|
@@ -4034,5 +4041,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImpo
|
|
|
4034
4041
|
* Generated bundle index. Do not edit.
|
|
4035
4042
|
*/
|
|
4036
4043
|
|
|
4037
|
-
export { AngularEditor, BaseComponent, BaseElementComponent, BaseElementFlavour, BaseFlavour, BaseLeafComponent, BaseLeafFlavour, BaseTextComponent, BaseTextFlavour, DefaultTextFlavour, EDITOR_TO_AFTER_VIEW_INIT_QUEUE, ELEMENT_TO_COMPONENT, FAKE_LEFT_BLOCK_CARD_OFFSET, FAKE_RIGHT_BLOCK_CARD_OFFSET, FlavourRef, HAS_BEFORE_INPUT_SUPPORT, IS_ANDROID, IS_APPLE, IS_CHROME, IS_CHROME_LEGACY, IS_EDGE_LEGACY, IS_FIREFOX, IS_FIREFOX_LEGACY, IS_IOS, IS_QQBROWSER, IS_SAFARI, IS_UC_MOBILE, IS_WECHATBROWSER, PLACEHOLDER_SYMBOL, SlateChildrenOutlet, SlateEditable, SlateErrorCode, SlateFragmentAttributeKey, SlateModule,
|
|
4044
|
+
export { AngularEditor, BaseComponent, BaseElementComponent, BaseElementFlavour, BaseFlavour, BaseLeafComponent, BaseLeafFlavour, BaseTextComponent, BaseTextFlavour, BlockCardRef, DefaultTextFlavour, EDITOR_TO_AFTER_VIEW_INIT_QUEUE, ELEMENT_TO_COMPONENT, FAKE_LEFT_BLOCK_CARD_OFFSET, FAKE_RIGHT_BLOCK_CARD_OFFSET, FlavourRef, HAS_BEFORE_INPUT_SUPPORT, IS_ANDROID, IS_APPLE, IS_CHROME, IS_CHROME_LEGACY, IS_EDGE_LEGACY, IS_FIREFOX, IS_FIREFOX_LEGACY, IS_IOS, IS_QQBROWSER, IS_SAFARI, IS_UC_MOBILE, IS_WECHATBROWSER, PLACEHOLDER_SYMBOL, SLATE_BLOCK_CARD_CLASS_NAME, SlateBlockCard, SlateChildrenOutlet, SlateEditable, SlateErrorCode, SlateFragmentAttributeKey, SlateModule, VoidTextFlavour, blobAsString, buildHTMLText, check, completeTable, createClipboardData, createText, createThrottleRAF, defaultScrollSelectionIntoView, fallbackCopyText, getBlockCardByNativeElement, getCardTargetAttribute, getClipboardData, getClipboardFromHTMLText, getContentHeight, getDataTransferClipboard, getDataTransferClipboardText, getNavigatorClipboard, getPlainText, getSelection, getSlateFragmentAttribute, getZeroTextNode, hasAfterContextChange, hasBeforeContextChange, hasBlockCard, hasBlockCardWithNode, hotkeys, isCardCenterByTargetAttr, isCardLeft, isCardLeftByTargetAttr, isCardRightByTargetAttr, isClipboardFile, isClipboardReadSupported, isClipboardWriteSupported, isClipboardWriteTextSupported, isComponentType, isDOMText, isDecoratorRangeListEqual, isFlavourType, isInvalidTable, isTemplateRef, isValid, normalize, setClipboardData, setDataTransferClipboard, setDataTransferClipboardText, setNavigatorClipboard, shallowCompare, stripHtml, withAngular };
|
|
4038
4045
|
//# sourceMappingURL=slate-angular.mjs.map
|