slate-angular 17.1.2 → 17.2.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/esm2022/components/editable/editable.component.mjs +2 -3
- package/esm2022/components/element/default-element.component.mjs +2 -4
- package/esm2022/components/element/element.component.mjs +2 -4
- package/esm2022/components/text/default-text.component.mjs +2 -4
- package/esm2022/components/text/void-text.component.mjs +2 -4
- package/esm2022/module.mjs +3 -9
- package/esm2022/plugins/angular-editor.mjs +1 -1
- package/esm2022/plugins/with-angular.mjs +15 -22
- package/esm2022/public-api.mjs +1 -3
- package/esm2022/types/clipboard.mjs +2 -0
- package/esm2022/types/index.mjs +2 -1
- package/esm2022/utils/clipboard/clipboard.mjs +77 -0
- package/esm2022/utils/clipboard/common.mjs +32 -0
- package/esm2022/utils/clipboard/data-transfer.mjs +44 -0
- package/esm2022/utils/clipboard/index.mjs +5 -0
- package/esm2022/utils/clipboard/navigator-clipboard.mjs +56 -0
- package/esm2022/utils/dom.mjs +5 -23
- package/esm2022/utils/index.mjs +2 -1
- package/esm2022/utils/weak-maps.mjs +2 -1
- package/esm2022/view/base.mjs +5 -3
- package/esm2022/view/render/list-render.mjs +22 -15
- package/esm2022/view/render/utils.mjs +1 -6
- package/fesm2022/slate-angular.mjs +251 -139
- package/fesm2022/slate-angular.mjs.map +1 -1
- package/module.d.ts +5 -7
- package/package.json +1 -1
- package/plugins/angular-editor.d.ts +7 -6
- package/public-api.d.ts +0 -2
- package/types/clipboard.d.ts +8 -0
- package/types/index.d.ts +1 -0
- package/utils/clipboard/clipboard.d.ts +12 -0
- package/utils/clipboard/common.d.ts +6 -0
- package/utils/clipboard/data-transfer.d.ts +5 -0
- package/utils/clipboard/index.d.ts +4 -0
- package/utils/clipboard/navigator-clipboard.d.ts +4 -0
- package/utils/dom.d.ts +2 -6
- package/utils/index.d.ts +1 -0
- package/utils/weak-maps.d.ts +1 -0
- package/view/render/list-render.d.ts +5 -3
- package/view/render/utils.d.ts +1 -2
- package/components/children/children.component.d.ts +0 -11
- package/components/leaves/leaves.component.d.ts +0 -12
- package/esm2022/components/children/children.component.mjs +0 -23
- package/esm2022/components/leaves/leaves.component.mjs +0 -25
- package/esm2022/view/container.mjs +0 -22
- package/view/container.d.ts +0 -18
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Editor, Range, Element, Transforms, Path, Text as Text$1, Node } from 'slate';
|
|
2
2
|
import { isKeyHotkey } from 'is-hotkey';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
|
-
import { TemplateRef, Component, ChangeDetectionStrategy, ViewChild,
|
|
4
|
+
import { TemplateRef, Component, ChangeDetectionStrategy, ViewChild, InjectionToken, ComponentRef, IterableDiffers, Directive, Input, HostBinding, inject, ViewContainerRef, forwardRef, ElementRef, Inject, NgModule } from '@angular/core';
|
|
5
5
|
import { direction } from 'direction';
|
|
6
6
|
import scrollIntoView from 'scroll-into-view-if-needed';
|
|
7
7
|
import { Subject } from 'rxjs';
|
|
8
8
|
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
9
9
|
import { HistoryEditor } from 'slate-history';
|
|
10
|
-
import {
|
|
10
|
+
import { CommonModule } from '@angular/common';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Two weak maps that allow us rebuild a path given a node. They are populated
|
|
@@ -47,6 +47,7 @@ const PLACEHOLDER_SYMBOL = Symbol('placeholder');
|
|
|
47
47
|
* Weak map for associating the html element with the component.
|
|
48
48
|
*/
|
|
49
49
|
const ELEMENT_TO_COMPONENT = new WeakMap();
|
|
50
|
+
const EDITOR_TO_AFTER_VIEW_INIT_QUEUE = new WeakMap();
|
|
50
51
|
|
|
51
52
|
/**
|
|
52
53
|
* Types.
|
|
@@ -202,33 +203,15 @@ const getPlainText = (domNode) => {
|
|
|
202
203
|
}
|
|
203
204
|
return text;
|
|
204
205
|
};
|
|
206
|
+
const SlateFragmentAttributeKey = 'data-slate-angular-fragment';
|
|
205
207
|
/**
|
|
206
|
-
* Get x-slate-fragment attribute from data-slate-fragment
|
|
208
|
+
* Get x-slate-fragment attribute from data-slate-angular-fragment
|
|
207
209
|
*/
|
|
208
|
-
const catchSlateFragment = /data-slate-fragment="(.+?)"/m;
|
|
209
|
-
const getSlateFragmentAttribute = (
|
|
210
|
-
const htmlData = dataTransfer.getData('text/html');
|
|
210
|
+
const catchSlateFragment = /data-slate-angular-fragment="(.+?)"/m;
|
|
211
|
+
const getSlateFragmentAttribute = (htmlData) => {
|
|
211
212
|
const [, fragment] = htmlData.match(catchSlateFragment) || [];
|
|
212
213
|
return fragment;
|
|
213
214
|
};
|
|
214
|
-
/**
|
|
215
|
-
* Get the x-slate-fragment attribute that exist in text/html data
|
|
216
|
-
* and append it to the DataTransfer object
|
|
217
|
-
*/
|
|
218
|
-
const getClipboardData = (dataTransfer, clipboardFormatKey = 'x-slate-fragment') => {
|
|
219
|
-
if (!dataTransfer.getData(`application/${clipboardFormatKey}`)) {
|
|
220
|
-
const fragment = getSlateFragmentAttribute(dataTransfer);
|
|
221
|
-
if (fragment) {
|
|
222
|
-
const clipboardData = new DataTransfer();
|
|
223
|
-
dataTransfer.types.forEach(type => {
|
|
224
|
-
clipboardData.setData(type, dataTransfer.getData(type));
|
|
225
|
-
});
|
|
226
|
-
clipboardData.setData(`application/${clipboardFormatKey}`, fragment);
|
|
227
|
-
return clipboardData;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
return dataTransfer;
|
|
231
|
-
};
|
|
232
215
|
|
|
233
216
|
/**
|
|
234
217
|
* An auto-incrementing identifier for keys.
|
|
@@ -1072,6 +1055,208 @@ const createThrottleRAF = () => {
|
|
|
1072
1055
|
return throttleRAF;
|
|
1073
1056
|
};
|
|
1074
1057
|
|
|
1058
|
+
const setDataTransferClipboard = (dataTransfer, htmlText) => {
|
|
1059
|
+
dataTransfer?.setData(`text/html`, htmlText);
|
|
1060
|
+
};
|
|
1061
|
+
const setDataTransferClipboardText = (data, text) => {
|
|
1062
|
+
data?.setData(`text/plain`, text);
|
|
1063
|
+
};
|
|
1064
|
+
const getDataTransferClipboard = (data) => {
|
|
1065
|
+
const html = data?.getData(`text/html`);
|
|
1066
|
+
if (html) {
|
|
1067
|
+
const htmlClipboardData = getClipboardFromHTMLText(html);
|
|
1068
|
+
if (htmlClipboardData) {
|
|
1069
|
+
return htmlClipboardData;
|
|
1070
|
+
}
|
|
1071
|
+
const textData = getDataTransferClipboardText(data);
|
|
1072
|
+
if (textData) {
|
|
1073
|
+
return {
|
|
1074
|
+
html,
|
|
1075
|
+
...textData
|
|
1076
|
+
};
|
|
1077
|
+
}
|
|
1078
|
+
else {
|
|
1079
|
+
return { html };
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
else {
|
|
1083
|
+
const textData = getDataTransferClipboardText(data);
|
|
1084
|
+
return textData;
|
|
1085
|
+
}
|
|
1086
|
+
};
|
|
1087
|
+
const getDataTransferClipboardText = (data) => {
|
|
1088
|
+
if (!data) {
|
|
1089
|
+
return null;
|
|
1090
|
+
}
|
|
1091
|
+
const text = data?.getData(`text/plain`);
|
|
1092
|
+
if (text) {
|
|
1093
|
+
const htmlClipboardData = getClipboardFromHTMLText(text);
|
|
1094
|
+
if (htmlClipboardData) {
|
|
1095
|
+
return htmlClipboardData;
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
return { text };
|
|
1099
|
+
};
|
|
1100
|
+
|
|
1101
|
+
const isClipboardReadSupported = () => {
|
|
1102
|
+
return 'clipboard' in navigator && 'read' in navigator.clipboard;
|
|
1103
|
+
};
|
|
1104
|
+
const isClipboardWriteSupported = () => {
|
|
1105
|
+
return 'clipboard' in navigator && 'write' in navigator.clipboard;
|
|
1106
|
+
};
|
|
1107
|
+
const isClipboardWriteTextSupported = () => {
|
|
1108
|
+
return 'clipboard' in navigator && 'writeText' in navigator.clipboard;
|
|
1109
|
+
};
|
|
1110
|
+
const isClipboardFile = (item) => {
|
|
1111
|
+
return item.types.find(i => i.match(/^image\//));
|
|
1112
|
+
};
|
|
1113
|
+
const stripHtml = (html) => {
|
|
1114
|
+
// See <https://github.com/developit/preact-markup/blob/4788b8d61b4e24f83688710746ee36e7464f7bbc/src/parse-markup.js#L60-L69>
|
|
1115
|
+
const doc = document.implementation.createHTMLDocument('');
|
|
1116
|
+
doc.documentElement.innerHTML = html.trim();
|
|
1117
|
+
return doc.body.textContent || doc.body.innerText || '';
|
|
1118
|
+
};
|
|
1119
|
+
const blobAsString = (blob) => {
|
|
1120
|
+
return new Promise((resolve, reject) => {
|
|
1121
|
+
const reader = new FileReader();
|
|
1122
|
+
reader.addEventListener('loadend', () => {
|
|
1123
|
+
const text = reader.result;
|
|
1124
|
+
resolve(text);
|
|
1125
|
+
});
|
|
1126
|
+
reader.addEventListener('error', () => {
|
|
1127
|
+
reject(reader.error);
|
|
1128
|
+
});
|
|
1129
|
+
reader.readAsText(blob);
|
|
1130
|
+
});
|
|
1131
|
+
};
|
|
1132
|
+
|
|
1133
|
+
const setNavigatorClipboard = async (htmlText, data, text = '') => {
|
|
1134
|
+
let textClipboard = text;
|
|
1135
|
+
if (isClipboardWriteSupported()) {
|
|
1136
|
+
await navigator.clipboard.write([
|
|
1137
|
+
new ClipboardItem({
|
|
1138
|
+
'text/html': new Blob([htmlText], {
|
|
1139
|
+
type: 'text/html'
|
|
1140
|
+
}),
|
|
1141
|
+
'text/plain': new Blob([JSON.stringify(textClipboard ?? data)], { type: 'text/plain' })
|
|
1142
|
+
})
|
|
1143
|
+
]);
|
|
1144
|
+
}
|
|
1145
|
+
};
|
|
1146
|
+
const getNavigatorClipboard = async () => {
|
|
1147
|
+
if (!isClipboardReadSupported()) {
|
|
1148
|
+
return null;
|
|
1149
|
+
}
|
|
1150
|
+
const clipboardItems = await navigator.clipboard.read();
|
|
1151
|
+
let clipboardData = {};
|
|
1152
|
+
if (Array.isArray(clipboardItems) && clipboardItems[0] instanceof ClipboardItem) {
|
|
1153
|
+
for (const item of clipboardItems) {
|
|
1154
|
+
if (isClipboardFile(item)) {
|
|
1155
|
+
const clipboardFiles = item.types.filter(type => type.match(/^image\//));
|
|
1156
|
+
const fileBlobs = await Promise.all(clipboardFiles.map(type => item.getType(type)));
|
|
1157
|
+
const urls = fileBlobs.filter(Boolean).map(blob => URL.createObjectURL(blob));
|
|
1158
|
+
const files = await Promise.all(urls.map(async (url) => {
|
|
1159
|
+
const blob = await (await fetch(url)).blob();
|
|
1160
|
+
return new File([blob], 'file', { type: blob.type });
|
|
1161
|
+
}));
|
|
1162
|
+
return {
|
|
1163
|
+
files
|
|
1164
|
+
};
|
|
1165
|
+
}
|
|
1166
|
+
if (item.types.includes('text/html')) {
|
|
1167
|
+
const htmlContent = await blobAsString(await item.getType('text/html'));
|
|
1168
|
+
const htmlClipboardData = getClipboardFromHTMLText(htmlContent);
|
|
1169
|
+
if (htmlClipboardData) {
|
|
1170
|
+
return htmlClipboardData;
|
|
1171
|
+
}
|
|
1172
|
+
if (htmlContent && htmlContent.trim()) {
|
|
1173
|
+
clipboardData = { html: htmlContent };
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
if (item.types.includes('text/plain')) {
|
|
1177
|
+
const textContent = await blobAsString(await item.getType('text/plain'));
|
|
1178
|
+
clipboardData = {
|
|
1179
|
+
text: stripHtml(textContent)
|
|
1180
|
+
};
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
return clipboardData;
|
|
1185
|
+
};
|
|
1186
|
+
|
|
1187
|
+
const buildHTMLText = (wrapper, attach, data) => {
|
|
1188
|
+
const stringObj = JSON.stringify(data);
|
|
1189
|
+
const encoded = window.btoa(encodeURIComponent(stringObj));
|
|
1190
|
+
attach.setAttribute(SlateFragmentAttributeKey, encoded);
|
|
1191
|
+
return wrapper.innerHTML;
|
|
1192
|
+
};
|
|
1193
|
+
const getClipboardFromHTMLText = (html) => {
|
|
1194
|
+
const fragmentAttribute = getSlateFragmentAttribute(html);
|
|
1195
|
+
if (fragmentAttribute) {
|
|
1196
|
+
try {
|
|
1197
|
+
const decoded = decodeURIComponent(window.atob(fragmentAttribute));
|
|
1198
|
+
const result = JSON.parse(decoded);
|
|
1199
|
+
if (result && Array.isArray(result) && result.length > 0) {
|
|
1200
|
+
return {
|
|
1201
|
+
elements: result
|
|
1202
|
+
};
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
catch (error) {
|
|
1206
|
+
console.error(error);
|
|
1207
|
+
return null;
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
return null;
|
|
1211
|
+
};
|
|
1212
|
+
const createClipboardData = (html, elements, text, files) => {
|
|
1213
|
+
const data = { elements, text, html, files };
|
|
1214
|
+
return data;
|
|
1215
|
+
};
|
|
1216
|
+
const getClipboardData = async (dataTransfer) => {
|
|
1217
|
+
let clipboardData = null;
|
|
1218
|
+
if (dataTransfer) {
|
|
1219
|
+
if (dataTransfer.files.length) {
|
|
1220
|
+
return { files: Array.from(dataTransfer.files) };
|
|
1221
|
+
}
|
|
1222
|
+
clipboardData = getDataTransferClipboard(dataTransfer);
|
|
1223
|
+
return clipboardData;
|
|
1224
|
+
}
|
|
1225
|
+
if (isClipboardReadSupported()) {
|
|
1226
|
+
return await getNavigatorClipboard();
|
|
1227
|
+
}
|
|
1228
|
+
return clipboardData;
|
|
1229
|
+
};
|
|
1230
|
+
/**
|
|
1231
|
+
* @param wrapper get wrapper.innerHTML string which will be written in clipboard
|
|
1232
|
+
* @param attach attach must be child element of wrapper which will be attached json data
|
|
1233
|
+
* @returns void
|
|
1234
|
+
*/
|
|
1235
|
+
const setClipboardData = async (clipboardData, wrapper, attach, dataTransfer) => {
|
|
1236
|
+
if (!clipboardData) {
|
|
1237
|
+
return;
|
|
1238
|
+
}
|
|
1239
|
+
const { elements, text } = clipboardData;
|
|
1240
|
+
if (isClipboardWriteSupported()) {
|
|
1241
|
+
const htmlText = buildHTMLText(wrapper, attach, elements);
|
|
1242
|
+
// TODO
|
|
1243
|
+
// maybe fail to write when copy some cell in table
|
|
1244
|
+
return await setNavigatorClipboard(htmlText, elements, text);
|
|
1245
|
+
}
|
|
1246
|
+
if (dataTransfer) {
|
|
1247
|
+
const htmlText = buildHTMLText(wrapper, attach, elements);
|
|
1248
|
+
setDataTransferClipboard(dataTransfer, htmlText);
|
|
1249
|
+
setDataTransferClipboardText(dataTransfer, text);
|
|
1250
|
+
return;
|
|
1251
|
+
}
|
|
1252
|
+
// Compatible with situations where navigator.clipboard.write is not supported and dataTransfer is empty
|
|
1253
|
+
// Such as contextmenu copy in Firefox.
|
|
1254
|
+
if (isClipboardWriteTextSupported()) {
|
|
1255
|
+
const htmlText = buildHTMLText(wrapper, attach, elements);
|
|
1256
|
+
return await navigator.clipboard.writeText(htmlText);
|
|
1257
|
+
}
|
|
1258
|
+
};
|
|
1259
|
+
|
|
1075
1260
|
/**
|
|
1076
1261
|
* Utilities for single-line deletion
|
|
1077
1262
|
*/
|
|
@@ -1194,7 +1379,7 @@ const withAngular = (editor, clipboardFormatKey = 'x-slate-fragment') => {
|
|
|
1194
1379
|
}
|
|
1195
1380
|
onChange();
|
|
1196
1381
|
};
|
|
1197
|
-
e.setFragmentData = (
|
|
1382
|
+
e.setFragmentData = (dataTransfer, originEvent) => {
|
|
1198
1383
|
const { selection } = e;
|
|
1199
1384
|
if (!selection) {
|
|
1200
1385
|
return;
|
|
@@ -1253,19 +1438,13 @@ const withAngular = (editor, clipboardFormatKey = 'x-slate-fragment') => {
|
|
|
1253
1438
|
attach = span;
|
|
1254
1439
|
}
|
|
1255
1440
|
const fragment = e.getFragment();
|
|
1256
|
-
const stringObj = JSON.stringify(fragment);
|
|
1257
|
-
const encoded = window.btoa(encodeURIComponent(stringObj));
|
|
1258
|
-
attach.setAttribute('data-slate-fragment', encoded);
|
|
1259
|
-
data.setData(`application/${clipboardFormatKey}`, encoded);
|
|
1260
1441
|
// Add the content to a <div> so that we can get its inner HTML.
|
|
1261
1442
|
const div = contents.ownerDocument.createElement('div');
|
|
1262
1443
|
div.appendChild(contents);
|
|
1263
1444
|
div.setAttribute('hidden', 'true');
|
|
1264
1445
|
contents.ownerDocument.body.appendChild(div);
|
|
1265
|
-
|
|
1266
|
-
data.setData('text/plain', getPlainText(div));
|
|
1446
|
+
setClipboardData({ text: getPlainText(div), elements: fragment }, div, attach, dataTransfer);
|
|
1267
1447
|
contents.ownerDocument.body.removeChild(div);
|
|
1268
|
-
return data;
|
|
1269
1448
|
};
|
|
1270
1449
|
e.deleteCutData = () => {
|
|
1271
1450
|
const { selection } = editor;
|
|
@@ -1281,28 +1460,26 @@ const withAngular = (editor, clipboardFormatKey = 'x-slate-fragment') => {
|
|
|
1281
1460
|
}
|
|
1282
1461
|
}
|
|
1283
1462
|
};
|
|
1284
|
-
e.insertData = (data) => {
|
|
1285
|
-
if (!e.insertFragmentData(data)) {
|
|
1463
|
+
e.insertData = async (data) => {
|
|
1464
|
+
if (!(await e.insertFragmentData(data))) {
|
|
1286
1465
|
e.insertTextData(data);
|
|
1287
1466
|
}
|
|
1288
1467
|
};
|
|
1289
|
-
e.insertFragmentData = (data) => {
|
|
1468
|
+
e.insertFragmentData = async (data) => {
|
|
1290
1469
|
/**
|
|
1291
1470
|
* Checking copied fragment from application/x-slate-fragment or data-slate-fragment
|
|
1292
1471
|
*/
|
|
1293
|
-
const
|
|
1294
|
-
if (
|
|
1295
|
-
|
|
1296
|
-
const parsed = JSON.parse(decoded);
|
|
1297
|
-
e.insertFragment(parsed);
|
|
1472
|
+
const clipboardData = await getClipboardData(data);
|
|
1473
|
+
if (clipboardData && clipboardData.elements) {
|
|
1474
|
+
e.insertFragment(clipboardData.elements);
|
|
1298
1475
|
return true;
|
|
1299
1476
|
}
|
|
1300
1477
|
return false;
|
|
1301
1478
|
};
|
|
1302
|
-
e.insertTextData = (data) => {
|
|
1303
|
-
const
|
|
1304
|
-
if (text) {
|
|
1305
|
-
const lines = text.split(/\r\n|\r|\n/);
|
|
1479
|
+
e.insertTextData = async (data) => {
|
|
1480
|
+
const clipboardData = await getClipboardData(data);
|
|
1481
|
+
if (clipboardData && clipboardData.text) {
|
|
1482
|
+
const lines = clipboardData.text.split(/\r\n|\r|\n/);
|
|
1306
1483
|
let split = false;
|
|
1307
1484
|
for (const line of lines) {
|
|
1308
1485
|
if (split) {
|
|
@@ -1728,46 +1905,6 @@ function restoreDom(editor, execute) {
|
|
|
1728
1905
|
}, 0);
|
|
1729
1906
|
}
|
|
1730
1907
|
|
|
1731
|
-
/**
|
|
1732
|
-
* @deprecated
|
|
1733
|
-
* the special container for angular template
|
|
1734
|
-
* Add the rootNodes of each child component to the parentElement
|
|
1735
|
-
* Remove useless DOM elements, eg: comment...
|
|
1736
|
-
*/
|
|
1737
|
-
class ViewContainer {
|
|
1738
|
-
constructor(elementRef, differs) {
|
|
1739
|
-
this.elementRef = elementRef;
|
|
1740
|
-
this.differs = differs;
|
|
1741
|
-
}
|
|
1742
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: ViewContainer, deps: [{ token: i0.ElementRef }, { token: i0.IterableDiffers }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1743
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.4", type: ViewContainer, inputs: { viewContext: "viewContext" }, ngImport: i0 }); }
|
|
1744
|
-
}
|
|
1745
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: ViewContainer, decorators: [{
|
|
1746
|
-
type: Directive
|
|
1747
|
-
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.IterableDiffers }], propDecorators: { viewContext: [{
|
|
1748
|
-
type: Input
|
|
1749
|
-
}] } });
|
|
1750
|
-
|
|
1751
|
-
class SlateChildren extends ViewContainer {
|
|
1752
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateChildren, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
1753
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.4", type: SlateChildren, isStandalone: true, selector: "slate-children", inputs: { children: "children", context: "context", viewContext: "viewContext" }, usesInheritance: true, ngImport: i0, template: ``, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
1754
|
-
}
|
|
1755
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateChildren, decorators: [{
|
|
1756
|
-
type: Component,
|
|
1757
|
-
args: [{
|
|
1758
|
-
selector: 'slate-children',
|
|
1759
|
-
template: ``,
|
|
1760
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1761
|
-
standalone: true
|
|
1762
|
-
}]
|
|
1763
|
-
}], propDecorators: { children: [{
|
|
1764
|
-
type: Input
|
|
1765
|
-
}], context: [{
|
|
1766
|
-
type: Input
|
|
1767
|
-
}], viewContext: [{
|
|
1768
|
-
type: Input
|
|
1769
|
-
}] } });
|
|
1770
|
-
|
|
1771
1908
|
const SLATE_DEFAULT_ELEMENT_COMPONENT_TOKEN = new InjectionToken('slate-default-element-token');
|
|
1772
1909
|
|
|
1773
1910
|
const SLATE_DEFAULT_TEXT_COMPONENT_TOKEN = new InjectionToken('slate-default-text-token');
|
|
@@ -1837,11 +1974,6 @@ function createEmbeddedViewOrComponent(viewType, context, viewContext, viewConta
|
|
|
1837
1974
|
return componentRef;
|
|
1838
1975
|
}
|
|
1839
1976
|
}
|
|
1840
|
-
function executeAfterViewInit(view) {
|
|
1841
|
-
if (view instanceof ComponentRef && view.instance.afterViewInit) {
|
|
1842
|
-
view.instance.afterViewInit();
|
|
1843
|
-
}
|
|
1844
|
-
}
|
|
1845
1977
|
function updateContext(view, newContext, viewContext) {
|
|
1846
1978
|
if (view instanceof ComponentRef) {
|
|
1847
1979
|
view.instance.context = newContext;
|
|
@@ -1937,7 +2069,7 @@ class ListRender {
|
|
|
1937
2069
|
this.getOutletParent = getOutletParent;
|
|
1938
2070
|
this.getOutletElement = getOutletElement;
|
|
1939
2071
|
this.views = [];
|
|
1940
|
-
|
|
2072
|
+
// private addedViews: (EmbeddedViewRef<any> | ComponentRef<any>)[] = [];
|
|
1941
2073
|
this.blockCards = [];
|
|
1942
2074
|
this.contexts = [];
|
|
1943
2075
|
this.viewTypes = [];
|
|
@@ -1956,7 +2088,6 @@ class ListRender {
|
|
|
1956
2088
|
const view = createEmbeddedViewOrComponent(viewType, context, this.viewContext, this.viewContainerRef);
|
|
1957
2089
|
const blockCard = createBlockCard(descendant, view, this.viewContainerRef, this.viewContext);
|
|
1958
2090
|
this.views.push(view);
|
|
1959
|
-
this.addedViews.push(view);
|
|
1960
2091
|
this.contexts.push(context);
|
|
1961
2092
|
this.viewTypes.push(viewType);
|
|
1962
2093
|
this.blockCards.push(blockCard);
|
|
@@ -1966,7 +2097,7 @@ class ListRender {
|
|
|
1966
2097
|
this.differ = newDiffers.find(children).create(trackBy$1(this.viewContext));
|
|
1967
2098
|
this.differ.diff(children);
|
|
1968
2099
|
if (parent === this.viewContext.editor) {
|
|
1969
|
-
this.
|
|
2100
|
+
executeAfterViewInit(this.viewContext.editor);
|
|
1970
2101
|
}
|
|
1971
2102
|
}
|
|
1972
2103
|
update(children, parent, childrenContext) {
|
|
@@ -1999,7 +2130,6 @@ class ListRender {
|
|
|
1999
2130
|
blockCard = createBlockCard(record.item, view, this.viewContainerRef, this.viewContext);
|
|
2000
2131
|
newContexts.push(context);
|
|
2001
2132
|
newViews.push(view);
|
|
2002
|
-
this.addedViews.push(view);
|
|
2003
2133
|
newBlockCards.push(blockCard);
|
|
2004
2134
|
mountOnItemChange(record.currentIndex, record.item, newViews, newBlockCards, outletParent, firstRootNode, this.viewContext);
|
|
2005
2135
|
}
|
|
@@ -2010,7 +2140,6 @@ class ListRender {
|
|
|
2010
2140
|
const previousBlockCard = this.blockCards[record.previousIndex];
|
|
2011
2141
|
if (previousViewType !== viewType) {
|
|
2012
2142
|
view = createEmbeddedViewOrComponent(viewType, context, this.viewContext, this.viewContainerRef);
|
|
2013
|
-
this.addedViews.push(view);
|
|
2014
2143
|
blockCard = createBlockCard(record.item, view, this.viewContainerRef, this.viewContext);
|
|
2015
2144
|
const firstRootNode = getRootNodes(previousView, previousBlockCard)[0];
|
|
2016
2145
|
const newRootNodes = getRootNodes(view, blockCard);
|
|
@@ -2054,7 +2183,7 @@ class ListRender {
|
|
|
2054
2183
|
this.children = children;
|
|
2055
2184
|
this.blockCards = newBlockCards;
|
|
2056
2185
|
if (parent === this.viewContext.editor) {
|
|
2057
|
-
this.
|
|
2186
|
+
executeAfterViewInit(this.viewContext.editor);
|
|
2058
2187
|
}
|
|
2059
2188
|
}
|
|
2060
2189
|
else {
|
|
@@ -2075,12 +2204,6 @@ class ListRender {
|
|
|
2075
2204
|
this.contexts = newContexts;
|
|
2076
2205
|
}
|
|
2077
2206
|
}
|
|
2078
|
-
afterViewInit() {
|
|
2079
|
-
this.addedViews.forEach(view => {
|
|
2080
|
-
executeAfterViewInit(view);
|
|
2081
|
-
});
|
|
2082
|
-
this.addedViews = [];
|
|
2083
|
-
}
|
|
2084
2207
|
destroy() {
|
|
2085
2208
|
this.children.forEach((element, index) => {
|
|
2086
2209
|
if (this.views[index]) {
|
|
@@ -2213,6 +2336,22 @@ function memoizedTextContext(prev, next) {
|
|
|
2213
2336
|
next.text === prev.text &&
|
|
2214
2337
|
isDecoratorRangeListEqual(next.decorations, prev.decorations));
|
|
2215
2338
|
}
|
|
2339
|
+
function addAfterViewInitQueue(editor, afterViewInitCallback) {
|
|
2340
|
+
const queue = getAfterViewInitQueue(editor);
|
|
2341
|
+
queue.push(afterViewInitCallback);
|
|
2342
|
+
EDITOR_TO_AFTER_VIEW_INIT_QUEUE.set(editor, queue);
|
|
2343
|
+
}
|
|
2344
|
+
function getAfterViewInitQueue(editor) {
|
|
2345
|
+
return EDITOR_TO_AFTER_VIEW_INIT_QUEUE.get(editor) || [];
|
|
2346
|
+
}
|
|
2347
|
+
function clearAfterViewInitQueue(editor) {
|
|
2348
|
+
EDITOR_TO_AFTER_VIEW_INIT_QUEUE.set(editor, []);
|
|
2349
|
+
}
|
|
2350
|
+
function executeAfterViewInit(editor) {
|
|
2351
|
+
const queue = getAfterViewInitQueue(editor);
|
|
2352
|
+
queue.forEach(callback => callback());
|
|
2353
|
+
clearAfterViewInitQueue(editor);
|
|
2354
|
+
}
|
|
2216
2355
|
|
|
2217
2356
|
class LeavesRender {
|
|
2218
2357
|
constructor(viewContext, viewContainerRef, getOutletParent, getOutletElement) {
|
|
@@ -2492,12 +2631,14 @@ class BaseElementComponent extends BaseComponent {
|
|
|
2492
2631
|
if (this.editor.isExpanded(this.element)) {
|
|
2493
2632
|
this.listRender.initialize(this.children, this.element, this.childrenContext);
|
|
2494
2633
|
}
|
|
2634
|
+
addAfterViewInitQueue(this.editor, () => {
|
|
2635
|
+
this.afterViewInit();
|
|
2636
|
+
});
|
|
2495
2637
|
}
|
|
2496
2638
|
afterViewInit() {
|
|
2497
2639
|
if (this._context.contentEditable !== undefined) {
|
|
2498
2640
|
this.nativeElement.setAttribute('contenteditable', this._context.contentEditable + '');
|
|
2499
2641
|
}
|
|
2500
|
-
this.listRender.afterViewInit();
|
|
2501
2642
|
}
|
|
2502
2643
|
updateWeakMap() {
|
|
2503
2644
|
NODE_TO_ELEMENT.set(this.element, this.nativeElement);
|
|
@@ -2601,27 +2742,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImpor
|
|
|
2601
2742
|
args: [SlateChildrenOutlet, { static: true }]
|
|
2602
2743
|
}] } });
|
|
2603
2744
|
|
|
2604
|
-
class SlateLeaves extends ViewContainer {
|
|
2605
|
-
constructor() {
|
|
2606
|
-
super(...arguments);
|
|
2607
|
-
this.initialized = false;
|
|
2608
|
-
}
|
|
2609
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateLeaves, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
2610
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.4", type: SlateLeaves, isStandalone: true, selector: "slate-leaves", inputs: { context: "context" }, usesInheritance: true, ngImport: i0, template: ``, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
2611
|
-
}
|
|
2612
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateLeaves, decorators: [{
|
|
2613
|
-
type: Component,
|
|
2614
|
-
args: [{
|
|
2615
|
-
selector: 'slate-leaves',
|
|
2616
|
-
template: ``,
|
|
2617
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2618
|
-
standalone: true,
|
|
2619
|
-
imports: [NgFor]
|
|
2620
|
-
}]
|
|
2621
|
-
}], propDecorators: { context: [{
|
|
2622
|
-
type: Input
|
|
2623
|
-
}] } });
|
|
2624
|
-
|
|
2625
2745
|
class SlateVoidText extends BaseTextComponent {
|
|
2626
2746
|
ngOnInit() {
|
|
2627
2747
|
super.ngOnInit();
|
|
@@ -2645,8 +2765,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImpor
|
|
|
2645
2765
|
class: 'slate-spacer',
|
|
2646
2766
|
'data-slate-node': 'text'
|
|
2647
2767
|
},
|
|
2648
|
-
standalone: true
|
|
2649
|
-
imports: [SlateLeaves]
|
|
2768
|
+
standalone: true
|
|
2650
2769
|
}]
|
|
2651
2770
|
}] });
|
|
2652
2771
|
|
|
@@ -2663,8 +2782,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImpor
|
|
|
2663
2782
|
host: {
|
|
2664
2783
|
'data-slate-node': 'text'
|
|
2665
2784
|
},
|
|
2666
|
-
standalone: true
|
|
2667
|
-
imports: [SlateLeaves]
|
|
2785
|
+
standalone: true
|
|
2668
2786
|
}]
|
|
2669
2787
|
}] });
|
|
2670
2788
|
|
|
@@ -2678,8 +2796,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImpor
|
|
|
2678
2796
|
selector: 'div[slateDefaultElement]',
|
|
2679
2797
|
template: ``,
|
|
2680
2798
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2681
|
-
standalone: true
|
|
2682
|
-
imports: [SlateChildren]
|
|
2799
|
+
standalone: true
|
|
2683
2800
|
}]
|
|
2684
2801
|
}] });
|
|
2685
2802
|
|
|
@@ -4075,7 +4192,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImpor
|
|
|
4075
4192
|
provide: SLATE_DEFAULT_LEAF_COMPONENT_TOKEN,
|
|
4076
4193
|
useValue: SlateDefaultLeaf
|
|
4077
4194
|
}
|
|
4078
|
-
], standalone: true, imports: [
|
|
4195
|
+
], standalone: true, imports: [SlateStringTemplate], template: "<slate-string-template #templateComponent></slate-string-template>\n" }]
|
|
4079
4196
|
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }, { type: i0.Injector }, { type: undefined, decorators: [{
|
|
4080
4197
|
type: Inject,
|
|
4081
4198
|
args: [SLATE_DEFAULT_ELEMENT_COMPONENT_TOKEN]
|
|
@@ -4241,8 +4358,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImpor
|
|
|
4241
4358
|
selector: '[slateElement]',
|
|
4242
4359
|
template: '<ng-content></ng-content>',
|
|
4243
4360
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
4244
|
-
standalone: true
|
|
4245
|
-
imports: [SlateChildren]
|
|
4361
|
+
standalone: true
|
|
4246
4362
|
}]
|
|
4247
4363
|
}] });
|
|
4248
4364
|
|
|
@@ -4256,12 +4372,10 @@ class SlateModule {
|
|
|
4256
4372
|
SlateDefaultText,
|
|
4257
4373
|
SlateString,
|
|
4258
4374
|
SlateStringTemplate,
|
|
4259
|
-
SlateChildren,
|
|
4260
4375
|
SlateBlockCard,
|
|
4261
|
-
SlateLeaves,
|
|
4262
4376
|
SlateDefaultLeaf,
|
|
4263
4377
|
SlateDefaultString,
|
|
4264
|
-
SlateChildrenOutlet], exports: [SlateEditable,
|
|
4378
|
+
SlateChildrenOutlet], exports: [SlateEditable, SlateChildrenOutlet, SlateElement, SlateString, SlateDefaultString] }); }
|
|
4265
4379
|
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateModule, providers: [
|
|
4266
4380
|
{
|
|
4267
4381
|
provide: SLATE_DEFAULT_ELEMENT_COMPONENT_TOKEN,
|
|
@@ -4281,14 +4395,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImpor
|
|
|
4281
4395
|
SlateDefaultText,
|
|
4282
4396
|
SlateString,
|
|
4283
4397
|
SlateStringTemplate,
|
|
4284
|
-
SlateChildren,
|
|
4285
4398
|
SlateBlockCard,
|
|
4286
|
-
SlateLeaves,
|
|
4287
4399
|
SlateDefaultLeaf,
|
|
4288
4400
|
SlateDefaultString,
|
|
4289
4401
|
SlateChildrenOutlet
|
|
4290
4402
|
],
|
|
4291
|
-
exports: [SlateEditable,
|
|
4403
|
+
exports: [SlateEditable, SlateChildrenOutlet, SlateElement, SlateString, SlateDefaultString],
|
|
4292
4404
|
providers: [
|
|
4293
4405
|
{
|
|
4294
4406
|
provide: SLATE_DEFAULT_ELEMENT_COMPONENT_TOKEN,
|
|
@@ -4306,5 +4418,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImpor
|
|
|
4306
4418
|
* Generated bundle index. Do not edit.
|
|
4307
4419
|
*/
|
|
4308
4420
|
|
|
4309
|
-
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,
|
|
4421
|
+
export { AngularEditor, BaseComponent, BaseElementComponent, BaseLeafComponent, BaseTextComponent, DOMComment, DOMElement, DOMNode, DOMRange, DOMSelection, DOMStaticRange, DOMText, EDITOR_TO_AFTER_VIEW_INIT_QUEUE, 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, SlateChildrenOutlet, SlateDefaultString, SlateEditable, SlateElement, SlateErrorCode, SlateFragmentAttributeKey, SlateModule, SlateString, blobAsString, buildHTMLText, check, createClipboardData, createThrottleRAF, defaultScrollSelectionIntoView, getCardTargetAttribute, getClipboardData, getClipboardFromHTMLText, getDataTransferClipboard, getDataTransferClipboardText, getDefaultView, getEditableChild, getEditableChildAndIndex, getNavigatorClipboard, getPlainText, getSlateFragmentAttribute, hasAfterContextChange, hasBeforeContextChange, hasBlockCard, hasBlockCardWithNode, hasEditableTarget, hasShadowRoot, hotkeys, isCardCenterByTargetAttr, isCardLeft, isCardLeftByTargetAttr, isCardRightByTargetAttr, isClipboardFile, isClipboardReadSupported, isClipboardWriteSupported, isClipboardWriteTextSupported, isComponentType, isDOMComment, isDOMElement, isDOMNode, isDOMSelection, isDOMText, isDecoratorRangeListEqual, isEmpty, isPlainTextOnlyPaste, isTemplateRef, isValid, normalize, normalizeDOMPoint, setClipboardData, setDataTransferClipboard, setDataTransferClipboardText, setNavigatorClipboard, shallowCompare, stripHtml, withAngular };
|
|
4310
4422
|
//# sourceMappingURL=slate-angular.mjs.map
|