@harbour-enterprises/superdoc 0.13.2-rev9 → 0.13.2
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/dist/chunks/{eventemitter3-KKY27oz-.es.js → eventemitter3-BrspJk8q.es.js} +1 -1
- package/dist/chunks/{eventemitter3-CHxWXmuK.cjs → eventemitter3-DfVviFzP.cjs} +1 -1
- package/dist/chunks/{index-CweAXNfB.cjs → index-B4J7wgs6.cjs} +2 -2
- package/dist/chunks/{index-kOMfCfBT.cjs → index-Cdsq63Xq.cjs} +4 -4
- package/dist/chunks/{index-DS3W0eVB.es.js → index-Diu6UKHt.es.js} +4 -4
- package/dist/chunks/{index-BqLFjUHn.es.js → index-Hr3Um-Bg.es.js} +2 -2
- package/dist/chunks/{jszip-9bCX1h2W.cjs → jszip-BTAcmbVg.cjs} +1 -1
- package/dist/chunks/{jszip-Cl3s9njw.es.js → jszip-DckFs3A7.es.js} +1 -1
- package/dist/chunks/{super-editor.es-TaswSSDL.cjs → super-editor.es-BM89AzsN.cjs} +811 -1088
- package/dist/chunks/{super-editor.es-BE0HKCoV.es.js → super-editor.es-BNyzbCw0.es.js} +811 -1088
- package/dist/chunks/{url-B8LY3nwf.cjs → url-BIzg4y2i.cjs} +2 -2
- package/dist/chunks/{url-Bq00tGvm.es.js → url-CHayXMZH.es.js} +2 -2
- package/dist/chunks/{vue-BBJVqxjL.es.js → vue-Bi1uWinj.es.js} +3 -10
- package/dist/chunks/{vue-BBjMeYfo.cjs → vue-HIY1g7dm.cjs} +3 -10
- package/dist/chunks/{xml-js-BuAdLsHD.cjs → xml-js-BjqmFOSP.cjs} +102 -81
- package/dist/chunks/{xml-js-1F0lia4t.es.js → xml-js-CfClL-1b.es.js} +102 -81
- package/dist/style.css +1 -2
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-BvRopd2F.js → converter-CsK9KCaL.js} +55 -637
- package/dist/super-editor/chunks/{docx-zipper-CZ8M74hv.js → docx-zipper-6iKmmME2.js} +1 -1
- package/dist/super-editor/chunks/{editor-D1rD0fdS.js → editor-Cxb-Zwyu.js} +685 -387
- package/dist/super-editor/chunks/{toolbar-CvP4K1yD.js → toolbar-QHIHaeEf.js} +3 -2
- package/dist/super-editor/converter.es.js +2 -2
- package/dist/super-editor/core/Editor.d.ts +0 -7
- package/dist/super-editor/core/Editor.d.ts.map +1 -1
- package/dist/super-editor/core/InputRule.d.ts +0 -7
- package/dist/super-editor/core/InputRule.d.ts.map +1 -1
- package/dist/super-editor/core/helpers/annotator.d.ts +0 -4
- package/dist/super-editor/core/helpers/annotator.d.ts.map +1 -1
- package/dist/super-editor/core/super-converter/exporter.d.ts.map +1 -1
- package/dist/super-editor/docx-zipper.es.js +2 -2
- package/dist/super-editor/editor.es.js +3 -3
- package/dist/super-editor/extensions/field-annotation/field-annotation.d.ts.map +1 -1
- package/dist/super-editor/extensions/field-annotation/fieldAnnotationHelpers/findRemovedFieldAnnotations.d.ts.map +1 -1
- package/dist/super-editor/extensions/image/imageHelpers/startImageUpload.d.ts.map +1 -1
- package/dist/super-editor/extensions/line-break/line-break.d.ts.map +1 -1
- package/dist/super-editor/extensions/noderesizer/noderesizer.d.ts.map +1 -1
- package/dist/super-editor/extensions/pagination/pagination-helpers.d.ts +1 -6
- package/dist/super-editor/extensions/pagination/pagination-helpers.d.ts.map +1 -1
- package/dist/super-editor/extensions/pagination/pagination.d.ts.map +1 -1
- package/dist/super-editor/extensions/paragraph/paragraph.d.ts.map +1 -1
- package/dist/super-editor/file-zipper.es.js +1 -1
- package/dist/super-editor/style.css +1 -2
- package/dist/super-editor/super-editor.es.js +7 -7
- package/dist/super-editor/tests/e2e/test-app/vite.config.d.ts +1 -1
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +2 -2
- package/dist/super-editor.es.js +2 -2
- package/dist/superdoc.cjs +9 -8
- package/dist/superdoc.es.js +10 -9
- package/dist/superdoc.umd.js +815 -1098
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/super-editor/core/helpers/setImageNodeSelection.d.ts +0 -2
- package/dist/super-editor/core/helpers/setImageNodeSelection.d.ts.map +0 -1
- package/dist/super-editor/tests/e2e/test-app/dist/assets/index-BTMvkUyI.d.ts +0 -3
- package/dist/super-editor/tests/e2e/test-app/dist/assets/index-BTMvkUyI.d.ts.map +0 -1
|
@@ -9,12 +9,12 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
|
|
|
9
9
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
10
10
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
11
11
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
12
|
-
var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _commandService, _css, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, insertNewFileData_fn, registerPluginByNameIfNotExists_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, createSchema_fn, generatePmData_fn, createDocFromHTML_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn,
|
|
12
|
+
var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _commandService, _css, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, insertNewFileData_fn, registerPluginByNameIfNotExists_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, createSchema_fn, generatePmData_fn, createDocFromHTML_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn;
|
|
13
13
|
import * as Y from "yjs";
|
|
14
14
|
import { UndoManager, Item as Item$1, ContentType, Text as Text$1, XmlElement, encodeStateAsUpdate } from "yjs";
|
|
15
|
-
import { P as PluginKey, a as Plugin, M as Mapping, c as callOrGet, i as isEmptyObject, S as Schema$1, T as TextSelection, b as canSplit, l as liftTarget, A as AllSelection, d as canJoin, j as joinPoint, N as NodeSelection, r as replaceStep$1, e as Selection, F as Fragment, R as ReplaceAroundStep
|
|
15
|
+
import { P as PluginKey, a as Plugin, M as Mapping, c as callOrGet, i as isEmptyObject, S as Schema$1, T as TextSelection, b as canSplit, l as liftTarget, A as AllSelection, d as canJoin, j as joinPoint, N as NodeSelection, r as replaceStep$1, e as Selection, F as Fragment, R as ReplaceAroundStep, f as Slice, o as objectIncludes, g as deleteProps, D as DOMParser$1, h as ReplaceStep, k as NodeRange, m as findWrapping, n as isMacOS, p as isIOS, q as generateDocxRandomId, s as minMax, t as generateRandom32BitHex, u as DOMSerializer, v as Mark$1, w as dropPoint, x as process$1, B as Buffer2, y as isRegExp, z as TrackDeleteMarkName, C as TrackInsertMarkName, E as v4, G as TrackFormatMarkName, H as comments_module_events, I as AddMarkStep, J as RemoveMarkStep, K as twipsToLines, L as pixelsToTwips, O as SuperConverter, Q as EditorState, U as hasSomeParentWithClass, V as parseSizeUnit, W as getLineHeightValueString, X as toKebabCase, Y as kebabCase, Z as getColStyleDeclaration, _ as SelectionRange, $ as Transform, a0 as createColGroup } from "./converter-CsK9KCaL.js";
|
|
16
16
|
import { ref, computed, createElementBlock, openBlock, withModifiers, Fragment as Fragment$1, renderList, normalizeClass, createCommentVNode, toDisplayString, createElementVNode, createApp } from "vue";
|
|
17
|
-
import { D as DocxZipper } from "./docx-zipper-
|
|
17
|
+
import { D as DocxZipper } from "./docx-zipper-6iKmmME2.js";
|
|
18
18
|
function getMarksFromSelection(state) {
|
|
19
19
|
const { from: from2, to, empty: empty2 } = state.selection;
|
|
20
20
|
const marks = [];
|
|
@@ -1203,6 +1203,164 @@ createMarksSchema_fn = function(markExtensions, attributes, editor) {
|
|
|
1203
1203
|
};
|
|
1204
1204
|
__privateAdd(_Schema, _Schema_static);
|
|
1205
1205
|
let Schema = _Schema;
|
|
1206
|
+
function chainableEditorState(transaction, state) {
|
|
1207
|
+
let { selection, doc: doc2, storedMarks } = transaction;
|
|
1208
|
+
return {
|
|
1209
|
+
...state,
|
|
1210
|
+
apply: state.apply.bind(state),
|
|
1211
|
+
applyTransaction: state.applyTransaction.bind(state),
|
|
1212
|
+
plugins: state.plugins,
|
|
1213
|
+
schema: state.schema,
|
|
1214
|
+
reconfigure: state.reconfigure.bind(state),
|
|
1215
|
+
toJSON: state.toJSON.bind(state),
|
|
1216
|
+
get storedMarks() {
|
|
1217
|
+
return storedMarks;
|
|
1218
|
+
},
|
|
1219
|
+
get selection() {
|
|
1220
|
+
return selection;
|
|
1221
|
+
},
|
|
1222
|
+
get doc() {
|
|
1223
|
+
return doc2;
|
|
1224
|
+
},
|
|
1225
|
+
get tr() {
|
|
1226
|
+
selection = transaction.selection;
|
|
1227
|
+
doc2 = transaction.doc;
|
|
1228
|
+
storedMarks = transaction.storedMarks;
|
|
1229
|
+
return transaction;
|
|
1230
|
+
}
|
|
1231
|
+
};
|
|
1232
|
+
}
|
|
1233
|
+
class CommandService {
|
|
1234
|
+
constructor(props) {
|
|
1235
|
+
__publicField(this, "editor");
|
|
1236
|
+
__publicField(this, "rawCommands");
|
|
1237
|
+
this.editor = props.editor;
|
|
1238
|
+
this.rawCommands = this.editor.extensionService.commands;
|
|
1239
|
+
}
|
|
1240
|
+
/**
|
|
1241
|
+
* Static method for creating a service.
|
|
1242
|
+
* @param args Arguments for the constructor.
|
|
1243
|
+
*/
|
|
1244
|
+
static create(...args) {
|
|
1245
|
+
return new CommandService(...args);
|
|
1246
|
+
}
|
|
1247
|
+
/**
|
|
1248
|
+
* Get editor state.
|
|
1249
|
+
*/
|
|
1250
|
+
get state() {
|
|
1251
|
+
return this.editor.state;
|
|
1252
|
+
}
|
|
1253
|
+
/**
|
|
1254
|
+
* Get all commands with wrapped command method.
|
|
1255
|
+
*/
|
|
1256
|
+
get commands() {
|
|
1257
|
+
const { editor, state } = this;
|
|
1258
|
+
const { view } = editor;
|
|
1259
|
+
const { tr } = state;
|
|
1260
|
+
const props = this.createProps(tr);
|
|
1261
|
+
const entries = Object.entries(this.rawCommands).map(([name, command2]) => {
|
|
1262
|
+
const method = (...args) => {
|
|
1263
|
+
const fn2 = command2(...args)(props);
|
|
1264
|
+
if (!tr.getMeta("preventDispatch")) {
|
|
1265
|
+
view.dispatch(tr);
|
|
1266
|
+
}
|
|
1267
|
+
return fn2;
|
|
1268
|
+
};
|
|
1269
|
+
return [name, method];
|
|
1270
|
+
});
|
|
1271
|
+
return Object.fromEntries(entries);
|
|
1272
|
+
}
|
|
1273
|
+
/**
|
|
1274
|
+
* Create a chain of commands to call multiple commands at once.
|
|
1275
|
+
*/
|
|
1276
|
+
get chain() {
|
|
1277
|
+
return () => this.createChain();
|
|
1278
|
+
}
|
|
1279
|
+
/**
|
|
1280
|
+
* Check if a command or a chain of commands can be executed. Without executing it.
|
|
1281
|
+
*/
|
|
1282
|
+
get can() {
|
|
1283
|
+
return () => this.createCan();
|
|
1284
|
+
}
|
|
1285
|
+
/**
|
|
1286
|
+
* Creates a chain of commands.
|
|
1287
|
+
* @param startTr Start transaction.
|
|
1288
|
+
* @param shouldDispatch Should dispatch or not.
|
|
1289
|
+
*/
|
|
1290
|
+
createChain(startTr, shouldDispatch = true) {
|
|
1291
|
+
const { editor, state, rawCommands } = this;
|
|
1292
|
+
const { view } = editor;
|
|
1293
|
+
const callbacks = [];
|
|
1294
|
+
const hasStartTr = !!startTr;
|
|
1295
|
+
const tr = startTr || state.tr;
|
|
1296
|
+
const run2 = () => {
|
|
1297
|
+
if (!hasStartTr && shouldDispatch && !tr.getMeta("preventDispatch")) {
|
|
1298
|
+
view.dispatch(tr);
|
|
1299
|
+
}
|
|
1300
|
+
return callbacks.every((cb) => cb === true);
|
|
1301
|
+
};
|
|
1302
|
+
const entries = Object.entries(rawCommands).map(([name, command2]) => {
|
|
1303
|
+
const chainedCommand = (...args) => {
|
|
1304
|
+
const props = this.createProps(tr, shouldDispatch);
|
|
1305
|
+
const callback = command2(...args)(props);
|
|
1306
|
+
callbacks.push(callback);
|
|
1307
|
+
return chain;
|
|
1308
|
+
};
|
|
1309
|
+
return [name, chainedCommand];
|
|
1310
|
+
});
|
|
1311
|
+
const chain = {
|
|
1312
|
+
...Object.fromEntries(entries),
|
|
1313
|
+
run: run2
|
|
1314
|
+
};
|
|
1315
|
+
return chain;
|
|
1316
|
+
}
|
|
1317
|
+
/**
|
|
1318
|
+
* Creates a can check for commands.
|
|
1319
|
+
* @param startTr Start transaction.
|
|
1320
|
+
*/
|
|
1321
|
+
createCan(startTr) {
|
|
1322
|
+
const { rawCommands, state } = this;
|
|
1323
|
+
const dispatch = false;
|
|
1324
|
+
const tr = startTr || state.tr;
|
|
1325
|
+
const props = this.createProps(tr, dispatch);
|
|
1326
|
+
const commands2 = Object.fromEntries(
|
|
1327
|
+
Object.entries(rawCommands).map(([name, command2]) => {
|
|
1328
|
+
return [name, (...args) => command2(...args)({ ...props, dispatch: void 0 })];
|
|
1329
|
+
})
|
|
1330
|
+
);
|
|
1331
|
+
return {
|
|
1332
|
+
...commands2,
|
|
1333
|
+
chain: () => this.createChain(tr, dispatch)
|
|
1334
|
+
};
|
|
1335
|
+
}
|
|
1336
|
+
/**
|
|
1337
|
+
* Creates default props for the command method.
|
|
1338
|
+
* @param {*} tr Transaction.
|
|
1339
|
+
* @param {*} shouldDispatch Check if should dispatch.
|
|
1340
|
+
* @returns Object with props.
|
|
1341
|
+
*/
|
|
1342
|
+
createProps(tr, shouldDispatch = true) {
|
|
1343
|
+
const { editor, state, rawCommands } = this;
|
|
1344
|
+
const { view } = editor;
|
|
1345
|
+
const props = {
|
|
1346
|
+
tr,
|
|
1347
|
+
editor,
|
|
1348
|
+
view,
|
|
1349
|
+
state: chainableEditorState(tr, state),
|
|
1350
|
+
dispatch: shouldDispatch ? () => void 0 : void 0,
|
|
1351
|
+
chain: () => this.createChain(tr, shouldDispatch),
|
|
1352
|
+
can: () => this.createCan(tr),
|
|
1353
|
+
get commands() {
|
|
1354
|
+
return Object.fromEntries(
|
|
1355
|
+
Object.entries(rawCommands).map(([name, command2]) => {
|
|
1356
|
+
return [name, (...args) => command2(...args)(props)];
|
|
1357
|
+
})
|
|
1358
|
+
);
|
|
1359
|
+
}
|
|
1360
|
+
};
|
|
1361
|
+
return props;
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1206
1364
|
const first = (commands2) => (props) => {
|
|
1207
1365
|
const items = typeof commands2 === "function" ? commands2(props) : commands2;
|
|
1208
1366
|
for (let i = 0; i < items.length; i += 1) {
|
|
@@ -1564,7 +1722,7 @@ function deleteBarrier(state, $cut, dispatch, dir) {
|
|
|
1564
1722
|
for (let i = conn.length - 1; i >= 0; i--)
|
|
1565
1723
|
wrap = Fragment.from(conn[i].create(null, wrap));
|
|
1566
1724
|
wrap = Fragment.from(before.copy(wrap));
|
|
1567
|
-
let tr = state.tr.step(new ReplaceAroundStep
|
|
1725
|
+
let tr = state.tr.step(new ReplaceAroundStep($cut.pos - 1, end2, $cut.pos, end2, new Slice(wrap, 1, 0), conn.length, true));
|
|
1568
1726
|
let $joinAt = tr.doc.resolve(end2 + 2 * conn.length);
|
|
1569
1727
|
if ($joinAt.nodeAfter && $joinAt.nodeAfter.type == before.type && canJoin(tr.doc, $joinAt.pos))
|
|
1570
1728
|
tr.join($joinAt.pos);
|
|
@@ -1595,7 +1753,7 @@ function deleteBarrier(state, $cut, dispatch, dir) {
|
|
|
1595
1753
|
let end2 = Fragment.empty;
|
|
1596
1754
|
for (let i = wrap.length - 1; i >= 0; i--)
|
|
1597
1755
|
end2 = Fragment.from(wrap[i].copy(end2));
|
|
1598
|
-
let tr = state.tr.step(new ReplaceAroundStep
|
|
1756
|
+
let tr = state.tr.step(new ReplaceAroundStep($cut.pos - wrap.length, $cut.pos + after.nodeSize, $cut.pos + afterDepth, $cut.pos + after.nodeSize - afterDepth, new Slice(end2, wrap.length, 0), 0, true));
|
|
1599
1757
|
dispatch(tr.scrollIntoView());
|
|
1600
1758
|
}
|
|
1601
1759
|
return true;
|
|
@@ -2168,7 +2326,7 @@ function selectionToInsertionEnd(tr, startLen, bias) {
|
|
|
2168
2326
|
return;
|
|
2169
2327
|
}
|
|
2170
2328
|
const step = tr.steps[last];
|
|
2171
|
-
if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep
|
|
2329
|
+
if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep)) {
|
|
2172
2330
|
return;
|
|
2173
2331
|
}
|
|
2174
2332
|
const map2 = tr.mapping.maps[last];
|
|
@@ -2314,7 +2472,7 @@ function doWrapInList(tr, range, wrappers, joinBefore, listType) {
|
|
|
2314
2472
|
let content = Fragment.empty;
|
|
2315
2473
|
for (let i = wrappers.length - 1; i >= 0; i--)
|
|
2316
2474
|
content = Fragment.from(wrappers[i].type.create(wrappers[i].attrs, content));
|
|
2317
|
-
tr.step(new ReplaceAroundStep
|
|
2475
|
+
tr.step(new ReplaceAroundStep(range.start - (joinBefore ? 2 : 0), range.end, range.start, range.end, new Slice(content, 0, 0), wrappers.length, true));
|
|
2318
2476
|
let found = 0;
|
|
2319
2477
|
for (let i = 0; i < wrappers.length; i++)
|
|
2320
2478
|
if (wrappers[i].type == listType)
|
|
@@ -2347,7 +2505,7 @@ function liftListItem$1(itemType) {
|
|
|
2347
2505
|
function liftToOuterList(state, dispatch, itemType, range) {
|
|
2348
2506
|
let tr = state.tr, end2 = range.end, endOfList = range.$to.end(range.depth);
|
|
2349
2507
|
if (end2 < endOfList) {
|
|
2350
|
-
tr.step(new ReplaceAroundStep
|
|
2508
|
+
tr.step(new ReplaceAroundStep(end2 - 1, endOfList, end2, endOfList, new Slice(Fragment.from(itemType.create(null, range.parent.copy())), 1, 0), 1, true));
|
|
2351
2509
|
range = new NodeRange(tr.doc.resolve(range.$from.pos), tr.doc.resolve(endOfList), range.depth);
|
|
2352
2510
|
}
|
|
2353
2511
|
const target = liftTarget(range);
|
|
@@ -2374,7 +2532,7 @@ function liftOutOfList(state, dispatch, range) {
|
|
|
2374
2532
|
if (!parent.canReplace(indexBefore + (atStart ? 0 : 1), indexBefore + 1, item.content.append(atEnd ? Fragment.empty : Fragment.from(list))))
|
|
2375
2533
|
return false;
|
|
2376
2534
|
let start2 = $start.pos, end2 = start2 + item.nodeSize;
|
|
2377
|
-
tr.step(new ReplaceAroundStep
|
|
2535
|
+
tr.step(new ReplaceAroundStep(start2 - (atStart ? 1 : 0), end2 + (atEnd ? 1 : 0), start2 + 1, end2 - 1, new Slice((atStart ? Fragment.empty : Fragment.from(list.copy(Fragment.empty))).append(atEnd ? Fragment.empty : Fragment.from(list.copy(Fragment.empty))), atStart ? 0 : 1, atEnd ? 0 : 1), atStart ? 0 : 1));
|
|
2378
2536
|
dispatch(tr.scrollIntoView());
|
|
2379
2537
|
return true;
|
|
2380
2538
|
}
|
|
@@ -2395,7 +2553,7 @@ function sinkListItem$1(itemType) {
|
|
|
2395
2553
|
let inner = Fragment.from(nestedBefore ? itemType.create() : null);
|
|
2396
2554
|
let slice2 = new Slice(Fragment.from(itemType.create(null, Fragment.from(parent.type.create(null, inner)))), nestedBefore ? 3 : 1, 0);
|
|
2397
2555
|
let before = range.start, after = range.end;
|
|
2398
|
-
dispatch(state.tr.step(new ReplaceAroundStep
|
|
2556
|
+
dispatch(state.tr.step(new ReplaceAroundStep(before - (nestedBefore ? 3 : 1), after, before, after, slice2, 1, true)).scrollIntoView());
|
|
2399
2557
|
}
|
|
2400
2558
|
return true;
|
|
2401
2559
|
};
|
|
@@ -9988,8 +10146,7 @@ const restoreRelativeSelection = (tr, relSel, binding) => {
|
|
|
9988
10146
|
binding.mapping
|
|
9989
10147
|
);
|
|
9990
10148
|
if (anchor !== null && head !== null) {
|
|
9991
|
-
|
|
9992
|
-
tr.setSelection(sel);
|
|
10149
|
+
tr.setSelection(TextSelection.between(tr.doc.resolve(anchor), tr.doc.resolve(head)));
|
|
9993
10150
|
}
|
|
9994
10151
|
}
|
|
9995
10152
|
}
|
|
@@ -10770,7 +10927,7 @@ const setMeta = (view, key, value) => {
|
|
|
10770
10927
|
};
|
|
10771
10928
|
const absolutePositionToRelativePosition = (pos, type, mapping) => {
|
|
10772
10929
|
if (pos === 0) {
|
|
10773
|
-
return Y.createRelativePositionFromTypeIndex(type, 0,
|
|
10930
|
+
return Y.createRelativePositionFromTypeIndex(type, 0, -1);
|
|
10774
10931
|
}
|
|
10775
10932
|
let n = type._first === null ? null : (
|
|
10776
10933
|
/** @type {Y.ContentType} */
|
|
@@ -10779,7 +10936,7 @@ const absolutePositionToRelativePosition = (pos, type, mapping) => {
|
|
|
10779
10936
|
while (n !== null && type !== n) {
|
|
10780
10937
|
if (n instanceof Y.XmlText) {
|
|
10781
10938
|
if (n._length >= pos) {
|
|
10782
|
-
return Y.createRelativePositionFromTypeIndex(n, pos,
|
|
10939
|
+
return Y.createRelativePositionFromTypeIndex(n, pos, -1);
|
|
10783
10940
|
} else {
|
|
10784
10941
|
pos -= n._length;
|
|
10785
10942
|
}
|
|
@@ -10843,7 +11000,7 @@ const absolutePositionToRelativePosition = (pos, type, mapping) => {
|
|
|
10843
11000
|
return createRelativePosition(n._item.parent, n._item);
|
|
10844
11001
|
}
|
|
10845
11002
|
}
|
|
10846
|
-
return Y.createRelativePositionFromTypeIndex(type, type._length,
|
|
11003
|
+
return Y.createRelativePositionFromTypeIndex(type, type._length, -1);
|
|
10847
11004
|
};
|
|
10848
11005
|
const createRelativePosition = (type, item) => {
|
|
10849
11006
|
let typeid = null;
|
|
@@ -11440,6 +11597,409 @@ function isExtensionRulesEnabled(extension, enabled) {
|
|
|
11440
11597
|
}
|
|
11441
11598
|
return enabled;
|
|
11442
11599
|
}
|
|
11600
|
+
function getHTMLFromFragment(fragment, schema) {
|
|
11601
|
+
const documentFragment = DOMSerializer.fromSchema(schema).serializeFragment(fragment);
|
|
11602
|
+
const temporaryDocument = document.implementation.createHTMLDocument();
|
|
11603
|
+
const container = temporaryDocument.createElement("div");
|
|
11604
|
+
container.appendChild(documentFragment);
|
|
11605
|
+
return container.innerHTML;
|
|
11606
|
+
}
|
|
11607
|
+
const getTextContentFromNodes = ($from, maxMatch = 500) => {
|
|
11608
|
+
let textBefore = "";
|
|
11609
|
+
const sliceEndPos = $from.parentOffset;
|
|
11610
|
+
$from.parent.nodesBetween(
|
|
11611
|
+
Math.max(0, sliceEndPos - maxMatch),
|
|
11612
|
+
sliceEndPos,
|
|
11613
|
+
(node, pos, parent, index2) => {
|
|
11614
|
+
const chunk = node.type.spec.toText?.({
|
|
11615
|
+
node,
|
|
11616
|
+
pos,
|
|
11617
|
+
parent,
|
|
11618
|
+
index: index2
|
|
11619
|
+
}) || node.textContent || "%leaf%";
|
|
11620
|
+
textBefore += node.isAtom && !node.isText ? chunk : chunk.slice(0, Math.max(0, sliceEndPos - pos));
|
|
11621
|
+
}
|
|
11622
|
+
);
|
|
11623
|
+
return textBefore;
|
|
11624
|
+
};
|
|
11625
|
+
const handleDocxPaste = (html, editor, view, plugin) => {
|
|
11626
|
+
const { converter } = editor;
|
|
11627
|
+
if (!converter || !converter.convertedXml) return handleHtmlPaste(html, editor, view, plugin);
|
|
11628
|
+
let cleanedHtml = convertEmToPt(html);
|
|
11629
|
+
cleanedHtml = cleanHtmlUnnecessaryTags(cleanedHtml);
|
|
11630
|
+
const tempDiv = document.createElement("div");
|
|
11631
|
+
tempDiv.innerHTML = cleanedHtml;
|
|
11632
|
+
const paragraphs = tempDiv.querySelectorAll("p");
|
|
11633
|
+
paragraphs.forEach((p) => {
|
|
11634
|
+
const innerHTML3 = p.innerHTML;
|
|
11635
|
+
if (!innerHTML3.includes("<!--[if !supportLists]")) return;
|
|
11636
|
+
const styleAttr = p.getAttribute("style") || "";
|
|
11637
|
+
const msoListMatch = styleAttr.match(/mso-list:\s*l(\d+)\s+level(\d+)/);
|
|
11638
|
+
if (msoListMatch) {
|
|
11639
|
+
const [, abstractId, level] = msoListMatch;
|
|
11640
|
+
const listNumId = getListNumIdFromAbstract(abstractId, editor);
|
|
11641
|
+
if (!listNumId) return;
|
|
11642
|
+
const abstractDefinition = getListAbstractDefinition(abstractId, editor);
|
|
11643
|
+
const { lvlText, start: start2, numFmt } = getLevelDefinition(abstractDefinition, level - 1);
|
|
11644
|
+
p.setAttribute("data-num-id", listNumId);
|
|
11645
|
+
p.setAttribute("data-list-level", level - 1);
|
|
11646
|
+
p.setAttribute("data-start", start2);
|
|
11647
|
+
p.setAttribute("data-lvl-text", lvlText);
|
|
11648
|
+
p.setAttribute("data-num-fmt", numFmt);
|
|
11649
|
+
}
|
|
11650
|
+
extractAndRemoveConditionalPrefix(p);
|
|
11651
|
+
});
|
|
11652
|
+
transformWordLists(tempDiv);
|
|
11653
|
+
const doc2 = DOMParser$1.fromSchema(editor.schema).parse(tempDiv);
|
|
11654
|
+
tempDiv.remove();
|
|
11655
|
+
const { dispatch } = editor.view;
|
|
11656
|
+
if (!dispatch) return false;
|
|
11657
|
+
dispatch(view.state.tr.replaceSelectionWith(doc2, true));
|
|
11658
|
+
return true;
|
|
11659
|
+
};
|
|
11660
|
+
const getLevelDefinition = (abstractDefinition, level) => {
|
|
11661
|
+
if (!abstractDefinition || !abstractDefinition.elements) return null;
|
|
11662
|
+
const levelElement = abstractDefinition.elements.find((el) => {
|
|
11663
|
+
return el.name === "w:lvl" && el.attributes?.["w:ilvl"] == level;
|
|
11664
|
+
});
|
|
11665
|
+
if (!levelElement) return null;
|
|
11666
|
+
const { elements } = levelElement;
|
|
11667
|
+
const lvlText = elements.find((el) => el.name === "w:lvlText")?.attributes?.["w:val"];
|
|
11668
|
+
const start2 = elements.find((el) => el.name === "w:start")?.attributes?.["w:val"];
|
|
11669
|
+
const numFmt = elements.find((el) => el.name === "w:numFmt")?.attributes?.["w:val"];
|
|
11670
|
+
return { lvlText, start: start2, numFmt, elements };
|
|
11671
|
+
};
|
|
11672
|
+
const getListNumIdFromAbstract = (abstractId, editor) => {
|
|
11673
|
+
const { definitions } = editor?.converter?.numbering;
|
|
11674
|
+
if (!definitions) return null;
|
|
11675
|
+
const matchedDefinition = Object.values(definitions).find((def) => {
|
|
11676
|
+
return def.elements.some((el) => el.name === "w:abstractNumId" && el.attributes?.["w:val"] == abstractId);
|
|
11677
|
+
});
|
|
11678
|
+
return matchedDefinition?.attributes?.["w:numId"];
|
|
11679
|
+
};
|
|
11680
|
+
const getListAbstractDefinition = (abstractId, editor) => {
|
|
11681
|
+
const { abstracts = {} } = editor?.converter?.numbering;
|
|
11682
|
+
return abstracts[abstractId] || null;
|
|
11683
|
+
};
|
|
11684
|
+
const transformWordLists = (container) => {
|
|
11685
|
+
const paragraphs = Array.from(container.querySelectorAll("p[data-num-id]"));
|
|
11686
|
+
const listMap = /* @__PURE__ */ new Map();
|
|
11687
|
+
const listLevels = {};
|
|
11688
|
+
for (const p of paragraphs) {
|
|
11689
|
+
const listId = p.getAttribute("data-num-id");
|
|
11690
|
+
const level = parseInt(p.getAttribute("data-list-level"));
|
|
11691
|
+
const numFmt = p.getAttribute("data-num-fmt");
|
|
11692
|
+
const start2 = p.getAttribute("data-start");
|
|
11693
|
+
const lvlText = p.getAttribute("data-lvl-text");
|
|
11694
|
+
if (!listMap.has(listId)) listMap.set(listId, []);
|
|
11695
|
+
listMap.get(listId).push({ p, level, numFmt, start: start2, lvlText });
|
|
11696
|
+
}
|
|
11697
|
+
for (const [id, items] of listMap.entries()) {
|
|
11698
|
+
if (!listLevels[id]) {
|
|
11699
|
+
listLevels[id] = {
|
|
11700
|
+
stack: [],
|
|
11701
|
+
counts: {},
|
|
11702
|
+
prevLevel: null
|
|
11703
|
+
};
|
|
11704
|
+
}
|
|
11705
|
+
const parentStack = [];
|
|
11706
|
+
items.forEach(({ p, level, numFmt, start: start2, lvlText }, index2) => {
|
|
11707
|
+
const listLevel = generateListNestingPath(listLevels, id, level);
|
|
11708
|
+
const li = document.createElement("li");
|
|
11709
|
+
li.innerHTML = p.innerHTML;
|
|
11710
|
+
li.setAttribute("data-list-level", JSON.stringify(listLevel));
|
|
11711
|
+
li.setAttribute("data-num-id", id);
|
|
11712
|
+
li.setAttribute("data-lvl-text", lvlText);
|
|
11713
|
+
li.setAttribute("data-num-fmt", numFmt);
|
|
11714
|
+
if (p.hasAttribute("data-font-family")) {
|
|
11715
|
+
li.setAttribute("data-font-family", p.getAttribute("data-font-family"));
|
|
11716
|
+
}
|
|
11717
|
+
if (p.hasAttribute("data-font-size")) {
|
|
11718
|
+
li.setAttribute("data-font-size", p.getAttribute("data-font-size"));
|
|
11719
|
+
}
|
|
11720
|
+
const parentNode2 = p.parentNode;
|
|
11721
|
+
let listForLevel = parentStack[level];
|
|
11722
|
+
if (!listForLevel) {
|
|
11723
|
+
const newList = document.createElement("ol");
|
|
11724
|
+
newList.setAttribute("data-list-id", id);
|
|
11725
|
+
newList.level = level;
|
|
11726
|
+
if (level > 0) {
|
|
11727
|
+
const parentLi = parentStack[level - 1]?.querySelector("li:last-child");
|
|
11728
|
+
if (parentLi) parentLi.appendChild(newList);
|
|
11729
|
+
} else {
|
|
11730
|
+
parentNode2.insertBefore(newList, p);
|
|
11731
|
+
}
|
|
11732
|
+
parentStack[level] = newList;
|
|
11733
|
+
parentStack.length = level + 1;
|
|
11734
|
+
listForLevel = newList;
|
|
11735
|
+
}
|
|
11736
|
+
listForLevel.appendChild(li);
|
|
11737
|
+
p.remove();
|
|
11738
|
+
});
|
|
11739
|
+
}
|
|
11740
|
+
};
|
|
11741
|
+
function generateListNestingPath(listLevels, listId, currentLevel) {
|
|
11742
|
+
const levelState = listLevels[listId];
|
|
11743
|
+
if (!levelState.stack) levelState.stack = [];
|
|
11744
|
+
if (levelState.prevLevel === void 0) levelState.prevLevel = null;
|
|
11745
|
+
if (levelState.prevLevel === null) {
|
|
11746
|
+
levelState.stack = Array(currentLevel).fill(1).concat(1);
|
|
11747
|
+
} else {
|
|
11748
|
+
if (currentLevel > levelState.prevLevel) {
|
|
11749
|
+
levelState.stack.push(1);
|
|
11750
|
+
} else if (currentLevel === levelState.prevLevel) {
|
|
11751
|
+
levelState.stack[levelState.stack.length - 1]++;
|
|
11752
|
+
} else {
|
|
11753
|
+
levelState.stack = levelState.stack.slice(0, currentLevel + 1);
|
|
11754
|
+
levelState.stack[currentLevel] = (levelState.stack[currentLevel] || 1) + 1;
|
|
11755
|
+
}
|
|
11756
|
+
}
|
|
11757
|
+
levelState.prevLevel = currentLevel;
|
|
11758
|
+
return [...levelState.stack];
|
|
11759
|
+
}
|
|
11760
|
+
function extractAndRemoveConditionalPrefix(p) {
|
|
11761
|
+
const nodes = Array.from(p.childNodes);
|
|
11762
|
+
let fontFamily = null;
|
|
11763
|
+
let fontSize = null;
|
|
11764
|
+
let start2 = -1, end2 = -1;
|
|
11765
|
+
nodes.forEach((node, index2) => {
|
|
11766
|
+
if (node.nodeType === Node.COMMENT_NODE && node.nodeValue.includes("[if !supportLists]")) {
|
|
11767
|
+
start2 = index2;
|
|
11768
|
+
}
|
|
11769
|
+
if (start2 !== -1 && node.nodeType === Node.COMMENT_NODE && node.nodeValue.includes("[endif]")) {
|
|
11770
|
+
end2 = index2;
|
|
11771
|
+
}
|
|
11772
|
+
});
|
|
11773
|
+
if (start2 !== -1 && end2 !== -1) {
|
|
11774
|
+
for (let i = start2 + 1; i < end2; i++) {
|
|
11775
|
+
const node = nodes[i];
|
|
11776
|
+
if (node.nodeType === Node.ELEMENT_NODE && node.style) {
|
|
11777
|
+
fontFamily = fontFamily || node.style.fontFamily;
|
|
11778
|
+
fontSize = fontSize || node.style.fontSize;
|
|
11779
|
+
}
|
|
11780
|
+
}
|
|
11781
|
+
for (let i = end2; i >= start2; i--) {
|
|
11782
|
+
p.removeChild(p.childNodes[i]);
|
|
11783
|
+
}
|
|
11784
|
+
if (fontFamily) p.setAttribute("data-font-family", fontFamily);
|
|
11785
|
+
if (fontSize) p.setAttribute("data-font-size", fontSize);
|
|
11786
|
+
}
|
|
11787
|
+
}
|
|
11788
|
+
class InputRule {
|
|
11789
|
+
constructor(config) {
|
|
11790
|
+
__publicField(this, "match");
|
|
11791
|
+
__publicField(this, "handler");
|
|
11792
|
+
this.match = config.match;
|
|
11793
|
+
this.handler = config.handler;
|
|
11794
|
+
}
|
|
11795
|
+
}
|
|
11796
|
+
const inputRuleMatcherHandler = (text, match) => {
|
|
11797
|
+
if (isRegExp(match)) {
|
|
11798
|
+
return match.exec(text);
|
|
11799
|
+
}
|
|
11800
|
+
const inputRuleMatch = match(text);
|
|
11801
|
+
if (!inputRuleMatch) {
|
|
11802
|
+
return null;
|
|
11803
|
+
}
|
|
11804
|
+
const result = [inputRuleMatch.text];
|
|
11805
|
+
result.index = inputRuleMatch.index;
|
|
11806
|
+
result.input = text;
|
|
11807
|
+
result.data = inputRuleMatch.data;
|
|
11808
|
+
if (inputRuleMatch.replaceWith) {
|
|
11809
|
+
if (!inputRuleMatch.text.includes(inputRuleMatch.replaceWith)) {
|
|
11810
|
+
console.warn(
|
|
11811
|
+
'[super-editor warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'
|
|
11812
|
+
);
|
|
11813
|
+
}
|
|
11814
|
+
result.push(inputRuleMatch.replaceWith);
|
|
11815
|
+
}
|
|
11816
|
+
return result;
|
|
11817
|
+
};
|
|
11818
|
+
const run = (config) => {
|
|
11819
|
+
const {
|
|
11820
|
+
editor,
|
|
11821
|
+
from: from2,
|
|
11822
|
+
to,
|
|
11823
|
+
text,
|
|
11824
|
+
rules,
|
|
11825
|
+
plugin
|
|
11826
|
+
} = config;
|
|
11827
|
+
const { view } = editor;
|
|
11828
|
+
if (view.composing) {
|
|
11829
|
+
return false;
|
|
11830
|
+
}
|
|
11831
|
+
const $from = view.state.doc.resolve(from2);
|
|
11832
|
+
if ($from.parent.type.spec.code || !!($from.nodeBefore || $from.nodeAfter)?.marks.find((mark) => mark.type.spec.code)) {
|
|
11833
|
+
return false;
|
|
11834
|
+
}
|
|
11835
|
+
let matched = false;
|
|
11836
|
+
const textBefore = getTextContentFromNodes($from) + text;
|
|
11837
|
+
rules.forEach((rule) => {
|
|
11838
|
+
if (matched) {
|
|
11839
|
+
return;
|
|
11840
|
+
}
|
|
11841
|
+
const match = inputRuleMatcherHandler(textBefore, rule.match);
|
|
11842
|
+
if (!match) {
|
|
11843
|
+
return;
|
|
11844
|
+
}
|
|
11845
|
+
const tr = view.state.tr;
|
|
11846
|
+
const state = chainableEditorState(tr, view.state);
|
|
11847
|
+
const range = {
|
|
11848
|
+
from: from2 - (match[0].length - text.length),
|
|
11849
|
+
to
|
|
11850
|
+
};
|
|
11851
|
+
const { commands: commands2, chain, can } = new CommandService({
|
|
11852
|
+
editor,
|
|
11853
|
+
state
|
|
11854
|
+
});
|
|
11855
|
+
const handler = rule.handler({
|
|
11856
|
+
state,
|
|
11857
|
+
range,
|
|
11858
|
+
match,
|
|
11859
|
+
commands: commands2,
|
|
11860
|
+
chain,
|
|
11861
|
+
can
|
|
11862
|
+
});
|
|
11863
|
+
if (handler === null || !tr.steps.length) {
|
|
11864
|
+
return;
|
|
11865
|
+
}
|
|
11866
|
+
tr.setMeta(plugin, {
|
|
11867
|
+
transform: tr,
|
|
11868
|
+
from: from2,
|
|
11869
|
+
to,
|
|
11870
|
+
text
|
|
11871
|
+
});
|
|
11872
|
+
view.dispatch(tr);
|
|
11873
|
+
matched = true;
|
|
11874
|
+
});
|
|
11875
|
+
return matched;
|
|
11876
|
+
};
|
|
11877
|
+
const inputRulesPlugin = ({ editor, rules }) => {
|
|
11878
|
+
const plugin = new Plugin({
|
|
11879
|
+
key: new PluginKey("inputRulesPlugin"),
|
|
11880
|
+
state: {
|
|
11881
|
+
init() {
|
|
11882
|
+
return null;
|
|
11883
|
+
},
|
|
11884
|
+
apply(tr, prev, state) {
|
|
11885
|
+
const stored = tr.getMeta(plugin);
|
|
11886
|
+
if (stored) {
|
|
11887
|
+
return stored;
|
|
11888
|
+
}
|
|
11889
|
+
const simulatedInputMeta = tr.getMeta("applyInputRules");
|
|
11890
|
+
const isSimulatedInput = !!simulatedInputMeta;
|
|
11891
|
+
if (isSimulatedInput) {
|
|
11892
|
+
setTimeout(() => {
|
|
11893
|
+
let { text } = simulatedInputMeta;
|
|
11894
|
+
if (typeof text !== "string") {
|
|
11895
|
+
text = getHTMLFromFragment(Fragment.from(text), state.schema);
|
|
11896
|
+
}
|
|
11897
|
+
const { from: from2 } = simulatedInputMeta;
|
|
11898
|
+
const to = from2 + text.length;
|
|
11899
|
+
run({
|
|
11900
|
+
editor,
|
|
11901
|
+
from: from2,
|
|
11902
|
+
to,
|
|
11903
|
+
text,
|
|
11904
|
+
rules,
|
|
11905
|
+
plugin
|
|
11906
|
+
});
|
|
11907
|
+
});
|
|
11908
|
+
}
|
|
11909
|
+
return tr.selectionSet || tr.docChanged ? null : prev;
|
|
11910
|
+
}
|
|
11911
|
+
},
|
|
11912
|
+
props: {
|
|
11913
|
+
handleTextInput(view, from2, to, text) {
|
|
11914
|
+
return run({
|
|
11915
|
+
editor,
|
|
11916
|
+
from: from2,
|
|
11917
|
+
to,
|
|
11918
|
+
text,
|
|
11919
|
+
rules,
|
|
11920
|
+
plugin
|
|
11921
|
+
});
|
|
11922
|
+
},
|
|
11923
|
+
// add support for input rules to trigger on enter
|
|
11924
|
+
// this is useful for example for code blocks
|
|
11925
|
+
handleKeyDown(view, event) {
|
|
11926
|
+
if (event.key !== "Enter") {
|
|
11927
|
+
return false;
|
|
11928
|
+
}
|
|
11929
|
+
const { $cursor } = view.state.selection;
|
|
11930
|
+
if ($cursor) {
|
|
11931
|
+
return run({
|
|
11932
|
+
editor,
|
|
11933
|
+
from: $cursor.pos,
|
|
11934
|
+
to: $cursor.pos,
|
|
11935
|
+
text: "\n",
|
|
11936
|
+
rules,
|
|
11937
|
+
plugin
|
|
11938
|
+
});
|
|
11939
|
+
}
|
|
11940
|
+
return false;
|
|
11941
|
+
},
|
|
11942
|
+
// Paste handler
|
|
11943
|
+
handlePaste(view, event, slice2) {
|
|
11944
|
+
const clipboard = event.clipboardData;
|
|
11945
|
+
const html = clipboard.getData("text/html");
|
|
11946
|
+
clipboard.getData("text/plain");
|
|
11947
|
+
const fieldAnnotationContent = slice2.content.content.filter((item) => item.type.name === "fieldAnnotation");
|
|
11948
|
+
if (fieldAnnotationContent.length) {
|
|
11949
|
+
return false;
|
|
11950
|
+
}
|
|
11951
|
+
let source;
|
|
11952
|
+
if (!html) {
|
|
11953
|
+
source = "plain-text";
|
|
11954
|
+
} else if (isWordHtml(html)) {
|
|
11955
|
+
source = "word-html";
|
|
11956
|
+
} else {
|
|
11957
|
+
source = "browser-html";
|
|
11958
|
+
}
|
|
11959
|
+
switch (source) {
|
|
11960
|
+
case "plain-text":
|
|
11961
|
+
break;
|
|
11962
|
+
case "word-html":
|
|
11963
|
+
if (editor.options.mode === "docx") {
|
|
11964
|
+
return handleDocxPaste(html, editor, view, plugin);
|
|
11965
|
+
}
|
|
11966
|
+
case "browser-html":
|
|
11967
|
+
return handleHtmlPaste$1(html, editor);
|
|
11968
|
+
}
|
|
11969
|
+
return false;
|
|
11970
|
+
}
|
|
11971
|
+
},
|
|
11972
|
+
isInputRules: true
|
|
11973
|
+
});
|
|
11974
|
+
return plugin;
|
|
11975
|
+
};
|
|
11976
|
+
function isWordHtml(html) {
|
|
11977
|
+
return /class=["']?Mso|xmlns:o=["']?urn:schemas-microsoft-com|<!--\[if gte mso|<meta[^>]+name=["']?Generator["']?[^>]+Word/i.test(html);
|
|
11978
|
+
}
|
|
11979
|
+
const handleHtmlPaste$1 = (html, editor, plugin) => {
|
|
11980
|
+
const cleanedHtml = convertEmToPt(html);
|
|
11981
|
+
const tempDiv = document.createElement("div");
|
|
11982
|
+
tempDiv.innerHTML = cleanedHtml;
|
|
11983
|
+
const doc2 = DOMParser$1.fromSchema(editor.schema).parse(tempDiv);
|
|
11984
|
+
tempDiv.remove();
|
|
11985
|
+
const { dispatch } = editor.view;
|
|
11986
|
+
if (!dispatch) return false;
|
|
11987
|
+
dispatch(editor.view.state.tr.replaceSelectionWith(doc2, true));
|
|
11988
|
+
return true;
|
|
11989
|
+
};
|
|
11990
|
+
const convertEmToPt = (html) => {
|
|
11991
|
+
return html.replace(
|
|
11992
|
+
/font-size\s*:\s*([\d.]+)em/gi,
|
|
11993
|
+
(_, emValue) => {
|
|
11994
|
+
const em = parseFloat(emValue);
|
|
11995
|
+
const pt = Math.round(em * 12 * 100) / 100;
|
|
11996
|
+
return `font-size: ${pt}pt`;
|
|
11997
|
+
}
|
|
11998
|
+
);
|
|
11999
|
+
};
|
|
12000
|
+
function cleanHtmlUnnecessaryTags(html) {
|
|
12001
|
+
return html.replace(/<o:p>.*?<\/o:p>/gi, "").replace(/ /gi, " ").replace(/<span[^>]*>\s*<\/span>/gi, "").replace(/<p[^>]*>\s*<\/p>/gi, "").trim();
|
|
12002
|
+
}
|
|
11443
12003
|
const _ExtensionService = class _ExtensionService {
|
|
11444
12004
|
constructor(extensions, userExtensions, editor) {
|
|
11445
12005
|
__privateAdd(this, _ExtensionService_instances);
|
|
@@ -12287,7 +12847,6 @@ const createHeaderFooterEditor = ({
|
|
|
12287
12847
|
mediaFiles: editor.storage.image.media,
|
|
12288
12848
|
fonts: editor.options.fonts,
|
|
12289
12849
|
isHeaderOrFooter: true,
|
|
12290
|
-
isHeadless: editor.options.isHeadless,
|
|
12291
12850
|
annotations: true,
|
|
12292
12851
|
currentPageNumber,
|
|
12293
12852
|
parentEditor: editor,
|
|
@@ -12295,15 +12854,13 @@ const createHeaderFooterEditor = ({
|
|
|
12295
12854
|
onBlur: (evt) => onHeaderFooterDataUpdate(evt, editor, sectionId, type)
|
|
12296
12855
|
});
|
|
12297
12856
|
const pm = editorContainer.querySelector(".ProseMirror");
|
|
12298
|
-
|
|
12299
|
-
|
|
12300
|
-
|
|
12301
|
-
|
|
12302
|
-
|
|
12303
|
-
|
|
12304
|
-
|
|
12305
|
-
pm.setAttribute("aria-label", `${type} content area. Double click to start typing.`);
|
|
12306
|
-
}
|
|
12857
|
+
pm.style.maxHeight = "100%";
|
|
12858
|
+
pm.style.minHeight = "100%";
|
|
12859
|
+
pm.style.outline = "none";
|
|
12860
|
+
pm.style.border = "none";
|
|
12861
|
+
pm.setAttribute("role", "textbox");
|
|
12862
|
+
pm.setAttribute("aria-multiline", true);
|
|
12863
|
+
pm.setAttribute("aria-label", `${type} content area. Double click to start typing.`);
|
|
12307
12864
|
return headerFooterEditor;
|
|
12308
12865
|
};
|
|
12309
12866
|
const broadcastEditorEvents = (editor, sectionEditor) => {
|
|
@@ -12322,16 +12879,14 @@ const broadcastEditorEvents = (editor, sectionEditor) => {
|
|
|
12322
12879
|
});
|
|
12323
12880
|
});
|
|
12324
12881
|
};
|
|
12325
|
-
const toggleHeaderFooterEditMode = (
|
|
12882
|
+
const toggleHeaderFooterEditMode = (editor, focusedSectionEditor, isEditMode) => {
|
|
12326
12883
|
editor.converter.headerEditors.forEach((item) => {
|
|
12327
12884
|
item.editor.setEditable(isEditMode, false);
|
|
12328
12885
|
item.editor.view.dom.setAttribute("aria-readonly", !isEditMode);
|
|
12329
|
-
item.editor.view.dom.setAttribute("documentmode", documentMode);
|
|
12330
12886
|
});
|
|
12331
12887
|
editor.converter.footerEditors.forEach((item) => {
|
|
12332
12888
|
item.editor.setEditable(isEditMode, false);
|
|
12333
12889
|
item.editor.view.dom.setAttribute("aria-readonly", !isEditMode);
|
|
12334
|
-
item.editor.view.dom.setAttribute("documentmode", documentMode);
|
|
12335
12890
|
});
|
|
12336
12891
|
if (isEditMode) {
|
|
12337
12892
|
const pm = document.querySelector(".ProseMirror");
|
|
@@ -13412,19 +13967,6 @@ const deleteHeaderFooterFieldAnnotations = ({ editor, fieldIdOrArray }) => {
|
|
|
13412
13967
|
);
|
|
13413
13968
|
});
|
|
13414
13969
|
};
|
|
13415
|
-
const resetHeaderFooterFieldAnnotations = ({ editor }) => {
|
|
13416
|
-
if (!editor) return;
|
|
13417
|
-
const sectionEditors = getAllHeaderFooterEditors(editor);
|
|
13418
|
-
sectionEditors.forEach(({ editor: sectionEditor, sectionId, type }) => {
|
|
13419
|
-
sectionEditor.commands.resetFieldAnnotations();
|
|
13420
|
-
onHeaderFooterDataUpdate(
|
|
13421
|
-
{ editor: sectionEditor },
|
|
13422
|
-
editor,
|
|
13423
|
-
sectionId,
|
|
13424
|
-
type
|
|
13425
|
-
);
|
|
13426
|
-
});
|
|
13427
|
-
};
|
|
13428
13970
|
const cleanUpListsWithAnnotations = (fieldsToDelete = [], editor) => {
|
|
13429
13971
|
if (!Array.isArray(fieldsToDelete)) fieldsToDelete = [fieldsToDelete];
|
|
13430
13972
|
const { doc: doc2 } = editor.state;
|
|
@@ -13495,7 +14037,6 @@ const AnnotatorHelpers = {
|
|
|
13495
14037
|
getAllHeaderFooterEditors,
|
|
13496
14038
|
updateHeaderFooterFieldAnnotations,
|
|
13497
14039
|
deleteHeaderFooterFieldAnnotations,
|
|
13498
|
-
resetHeaderFooterFieldAnnotations,
|
|
13499
14040
|
cleanUpListsWithAnnotations
|
|
13500
14041
|
};
|
|
13501
14042
|
const CollaborationPluginKey = new PluginKey("collaboration");
|
|
@@ -13675,16 +14216,6 @@ const setWordSelection = (view, pos) => {
|
|
|
13675
14216
|
const tr = state.tr.setSelection(TextSelection.create(state.doc, word.from, word.to));
|
|
13676
14217
|
dispatch(tr);
|
|
13677
14218
|
};
|
|
13678
|
-
const setImageNodeSelection = (view, pos) => {
|
|
13679
|
-
const { doc: doc2 } = view.state;
|
|
13680
|
-
const node = doc2.nodeAt(pos);
|
|
13681
|
-
if (node && node.type.name === "image") {
|
|
13682
|
-
const tr = view.state.tr.setSelection(NodeSelection.create(doc2, pos));
|
|
13683
|
-
view.dispatch(tr);
|
|
13684
|
-
return true;
|
|
13685
|
-
}
|
|
13686
|
-
return false;
|
|
13687
|
-
};
|
|
13688
14219
|
const _Editor = class _Editor extends EventEmitter {
|
|
13689
14220
|
/**
|
|
13690
14221
|
* Create a new Editor instance
|
|
@@ -13811,19 +14342,6 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
13811
14342
|
this.setHighContrastMode = setHighContrastMode;
|
|
13812
14343
|
initMode();
|
|
13813
14344
|
}
|
|
13814
|
-
mount(el) {
|
|
13815
|
-
__privateMethod(this, _Editor_instances, createView_fn).call(this, el);
|
|
13816
|
-
window.setTimeout(() => {
|
|
13817
|
-
if (this.isDestroyed) return;
|
|
13818
|
-
this.emit("create", { editor: this });
|
|
13819
|
-
}, 0);
|
|
13820
|
-
}
|
|
13821
|
-
unmount() {
|
|
13822
|
-
if (this.view) {
|
|
13823
|
-
this.view.destroy();
|
|
13824
|
-
}
|
|
13825
|
-
this.view = null;
|
|
13826
|
-
}
|
|
13827
14345
|
/**
|
|
13828
14346
|
* Set the toolbar for this editor
|
|
13829
14347
|
* @param {Object} toolbar - The toolbar instance
|
|
@@ -13872,7 +14390,7 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
13872
14390
|
* @returns {boolean}
|
|
13873
14391
|
*/
|
|
13874
14392
|
get isDestroyed() {
|
|
13875
|
-
return this.view
|
|
14393
|
+
return this.view.isDestroyed;
|
|
13876
14394
|
}
|
|
13877
14395
|
/**
|
|
13878
14396
|
* Get the editor element
|
|
@@ -13915,12 +14433,7 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
13915
14433
|
this.commands.toggleTrackChangesShowOriginal();
|
|
13916
14434
|
this.setEditable(false, false);
|
|
13917
14435
|
this.setOptions({ documentMode: "viewing" });
|
|
13918
|
-
toggleHeaderFooterEditMode(
|
|
13919
|
-
editor: this,
|
|
13920
|
-
focusedSectionEditor: null,
|
|
13921
|
-
isEditMode: false,
|
|
13922
|
-
documentMode: cleanedMode
|
|
13923
|
-
});
|
|
14436
|
+
toggleHeaderFooterEditMode(this, null, false);
|
|
13924
14437
|
} else if (cleanedMode === "suggesting") {
|
|
13925
14438
|
__privateMethod(this, _Editor_instances, registerPluginByNameIfNotExists_fn).call(this, "TrackChangesBase");
|
|
13926
14439
|
this.commands.disableTrackChangesShowOriginal();
|
|
@@ -13933,12 +14446,7 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
13933
14446
|
this.commands.disableTrackChanges();
|
|
13934
14447
|
this.setEditable(true, false);
|
|
13935
14448
|
this.setOptions({ documentMode: "editing" });
|
|
13936
|
-
toggleHeaderFooterEditMode(
|
|
13937
|
-
editor: this,
|
|
13938
|
-
focusedSectionEditor: null,
|
|
13939
|
-
isEditMode: false,
|
|
13940
|
-
documentMode: cleanedMode
|
|
13941
|
-
});
|
|
14449
|
+
toggleHeaderFooterEditMode(this, null, false);
|
|
13942
14450
|
}
|
|
13943
14451
|
}
|
|
13944
14452
|
/**
|
|
@@ -14115,26 +14623,29 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14115
14623
|
};
|
|
14116
14624
|
}
|
|
14117
14625
|
/**
|
|
14118
|
-
|
|
14119
|
-
|
|
14120
|
-
|
|
14626
|
+
* Initialize default styles for the editor container and ProseMirror.
|
|
14627
|
+
* Get page size and margins from the converter.
|
|
14628
|
+
* Set document default font and font size.
|
|
14629
|
+
*
|
|
14630
|
+
* @param {HTMLElement} [element=this.element] - The DOM element to apply styles to
|
|
14631
|
+
* @returns {void}
|
|
14632
|
+
*/
|
|
14633
|
+
initDefaultStyles(element = this.element) {
|
|
14634
|
+
if (this.options.isHeadless || this.options.suppressDefaultDocxStyles) return;
|
|
14635
|
+
const proseMirror = element?.querySelector(".ProseMirror");
|
|
14121
14636
|
const { pageSize, pageMargins } = this.converter.pageStyles ?? {};
|
|
14122
|
-
if (!proseMirror || !
|
|
14637
|
+
if (!proseMirror || !pageSize || !pageMargins) {
|
|
14123
14638
|
return;
|
|
14124
14639
|
}
|
|
14125
14640
|
proseMirror.setAttribute("role", "document");
|
|
14126
14641
|
proseMirror.setAttribute("aria-multiline", true);
|
|
14127
14642
|
proseMirror.setAttribute("aria-label", "Main content area, start typing to enter text.");
|
|
14128
14643
|
proseMirror.setAttribute("aria-description", "");
|
|
14129
|
-
|
|
14130
|
-
|
|
14131
|
-
|
|
14132
|
-
|
|
14133
|
-
|
|
14134
|
-
if (pageMargins) {
|
|
14135
|
-
element.style.paddingLeft = pageMargins.left + "in";
|
|
14136
|
-
element.style.paddingRight = pageMargins.right + "in";
|
|
14137
|
-
}
|
|
14644
|
+
element.style.width = pageSize.width + "in";
|
|
14645
|
+
element.style.minWidth = pageSize.width + "in";
|
|
14646
|
+
element.style.minHeight = pageSize.height + "in";
|
|
14647
|
+
element.style.paddingLeft = pageMargins.left + "in";
|
|
14648
|
+
element.style.paddingRight = pageMargins.right + "in";
|
|
14138
14649
|
element.style.boxSizing = "border-box";
|
|
14139
14650
|
element.style.isolation = "isolate";
|
|
14140
14651
|
proseMirror.style.outline = "none";
|
|
@@ -14155,19 +14666,6 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14155
14666
|
proseMirror.style.paddingTop = "1in";
|
|
14156
14667
|
proseMirror.style.paddingBottom = "1in";
|
|
14157
14668
|
}
|
|
14158
|
-
}
|
|
14159
|
-
/**
|
|
14160
|
-
* Initialize default styles for the editor container and ProseMirror.
|
|
14161
|
-
* Get page size and margins from the converter.
|
|
14162
|
-
* Set document default font and font size.
|
|
14163
|
-
*
|
|
14164
|
-
* @param {HTMLElement} [element=this.element] - The DOM element to apply styles to
|
|
14165
|
-
* @returns {void}
|
|
14166
|
-
*/
|
|
14167
|
-
initDefaultStyles(element = this.element) {
|
|
14168
|
-
if (this.options.isHeadless || this.options.suppressDefaultDocxStyles) return;
|
|
14169
|
-
const proseMirror = element?.querySelector(".ProseMirror");
|
|
14170
|
-
this.updateEditorStyles(element, proseMirror);
|
|
14171
14669
|
this.initMobileStyles(element);
|
|
14172
14670
|
}
|
|
14173
14671
|
/**
|
|
@@ -14379,25 +14877,10 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14379
14877
|
*/
|
|
14380
14878
|
destroy() {
|
|
14381
14879
|
this.emit("destroy");
|
|
14382
|
-
this.
|
|
14383
|
-
this.destroyHeaderFooterEditors();
|
|
14880
|
+
if (this.view) this.view.destroy();
|
|
14384
14881
|
__privateMethod(this, _Editor_instances, endCollaboration_fn).call(this);
|
|
14385
14882
|
this.removeAllListeners();
|
|
14386
14883
|
}
|
|
14387
|
-
destroyHeaderFooterEditors() {
|
|
14388
|
-
try {
|
|
14389
|
-
const editors = [
|
|
14390
|
-
...this.converter.headerEditors,
|
|
14391
|
-
...this.converter.footerEditors
|
|
14392
|
-
];
|
|
14393
|
-
for (let editorData of editors) {
|
|
14394
|
-
editorData.editor.destroy();
|
|
14395
|
-
}
|
|
14396
|
-
this.converter.headerEditors.length = 0;
|
|
14397
|
-
this.converter.footerEditors.length = 0;
|
|
14398
|
-
} catch (error) {
|
|
14399
|
-
}
|
|
14400
|
-
}
|
|
14401
14884
|
/**
|
|
14402
14885
|
* Check if migrations are needed for the data
|
|
14403
14886
|
* @static
|
|
@@ -14415,7 +14898,7 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14415
14898
|
* @returns {Object | void} Migration results
|
|
14416
14899
|
*/
|
|
14417
14900
|
processCollaborationMigrations() {
|
|
14418
|
-
console.debug("[checkVersionMigrations] Current editor version", "0.13.2
|
|
14901
|
+
console.debug("[checkVersionMigrations] Current editor version", "0.13.2");
|
|
14419
14902
|
if (!this.options.ydoc) return;
|
|
14420
14903
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
14421
14904
|
let docVersion = metaMap.get("version");
|
|
@@ -14459,7 +14942,6 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14459
14942
|
__privateMethod(this, _Editor_instances, initMedia_fn).call(this);
|
|
14460
14943
|
this.initDefaultStyles();
|
|
14461
14944
|
if (this.options.ydoc && this.options.collaborationProvider) {
|
|
14462
|
-
updateYdocDocxData(this);
|
|
14463
14945
|
this.initializeCollaborationData(true);
|
|
14464
14946
|
} else {
|
|
14465
14947
|
__privateMethod(this, _Editor_instances, insertNewFileData_fn).call(this);
|
|
@@ -14623,7 +15105,7 @@ init_fn = function(options) {
|
|
|
14623
15105
|
this.emit("beforeCreate", { editor: this });
|
|
14624
15106
|
this.on("contentError", this.options.onContentError);
|
|
14625
15107
|
this.on("exception", this.options.onException);
|
|
14626
|
-
this.
|
|
15108
|
+
__privateMethod(this, _Editor_instances, createView_fn).call(this);
|
|
14627
15109
|
this.initDefaultStyles();
|
|
14628
15110
|
this.setDocumentMode(options.documentMode);
|
|
14629
15111
|
if (this.options.isHeadless) return;
|
|
@@ -14647,6 +15129,10 @@ init_fn = function(options) {
|
|
|
14647
15129
|
__privateMethod(this, _Editor_instances, initPagination_fn).call(this);
|
|
14648
15130
|
__privateMethod(this, _Editor_instances, initComments_fn).call(this);
|
|
14649
15131
|
}
|
|
15132
|
+
window.setTimeout(() => {
|
|
15133
|
+
if (this.isDestroyed) return;
|
|
15134
|
+
this.emit("create", { editor: this });
|
|
15135
|
+
}, 0);
|
|
14650
15136
|
};
|
|
14651
15137
|
/**
|
|
14652
15138
|
* Initialize the editor in rich text mode
|
|
@@ -14664,7 +15150,7 @@ initRichText_fn = function(options) {
|
|
|
14664
15150
|
this.on("beforeCreate", this.options.onBeforeCreate);
|
|
14665
15151
|
this.emit("beforeCreate", { editor: this });
|
|
14666
15152
|
this.on("contentError", this.options.onContentError);
|
|
14667
|
-
this.
|
|
15153
|
+
__privateMethod(this, _Editor_instances, createView_fn).call(this);
|
|
14668
15154
|
this.on("create", this.options.onCreate);
|
|
14669
15155
|
this.on("update", this.options.onUpdate);
|
|
14670
15156
|
this.on("selectionUpdate", this.options.onSelectionUpdate);
|
|
@@ -14675,6 +15161,10 @@ initRichText_fn = function(options) {
|
|
|
14675
15161
|
this.on("commentsLoaded", this.options.onCommentsLoaded);
|
|
14676
15162
|
this.on("commentClick", this.options.onCommentClicked);
|
|
14677
15163
|
this.on("locked", this.options.onDocumentLocked);
|
|
15164
|
+
window.setTimeout(() => {
|
|
15165
|
+
if (this.isDestroyed) return;
|
|
15166
|
+
this.emit("create", { editor: this });
|
|
15167
|
+
}, 0);
|
|
14678
15168
|
};
|
|
14679
15169
|
/**
|
|
14680
15170
|
*
|
|
@@ -14873,15 +15363,14 @@ createDocFromHTML_fn = function(content) {
|
|
|
14873
15363
|
* @private
|
|
14874
15364
|
* @returns {void}
|
|
14875
15365
|
*/
|
|
14876
|
-
createView_fn = function(
|
|
15366
|
+
createView_fn = function() {
|
|
14877
15367
|
let doc2 = __privateMethod(this, _Editor_instances, generatePmData_fn).call(this);
|
|
14878
15368
|
const state = { schema: this.schema };
|
|
14879
15369
|
if (!this.options.ydoc) state.doc = doc2;
|
|
14880
|
-
this.view = new EditorView(element, {
|
|
15370
|
+
this.view = new EditorView(this.options.element, {
|
|
14881
15371
|
...this.options.editorProps,
|
|
14882
15372
|
dispatchTransaction: __privateMethod(this, _Editor_instances, dispatchTransaction_fn).bind(this),
|
|
14883
15373
|
state: EditorState.create(state),
|
|
14884
|
-
handleClick: __privateMethod(this, _Editor_instances, handleNodeSelection_fn).bind(this),
|
|
14885
15374
|
handleDoubleClick: async (view, pos, event) => {
|
|
14886
15375
|
if (this.options.documentMode !== "editing") return;
|
|
14887
15376
|
const isHeader = hasSomeParentWithClass(event.target, "pagination-section-header");
|
|
@@ -14895,12 +15384,7 @@ createView_fn = function(element) {
|
|
|
14895
15384
|
event.stopPropagation();
|
|
14896
15385
|
if (!this.options.editable) {
|
|
14897
15386
|
this.setEditable(true, false);
|
|
14898
|
-
toggleHeaderFooterEditMode(
|
|
14899
|
-
editor: this,
|
|
14900
|
-
focusedSectionEditor: null,
|
|
14901
|
-
isEditMode: false,
|
|
14902
|
-
documentMode: this.options.documentMode
|
|
14903
|
-
});
|
|
15387
|
+
toggleHeaderFooterEditMode(this, null, false);
|
|
14904
15388
|
const pm = document.querySelector(".ProseMirror");
|
|
14905
15389
|
pm.classList.remove("header-footer-edit");
|
|
14906
15390
|
pm.setAttribute("aria-readonly", false);
|
|
@@ -14913,6 +15397,8 @@ createView_fn = function(element) {
|
|
|
14913
15397
|
});
|
|
14914
15398
|
this.view.updateState(newState);
|
|
14915
15399
|
this.createNodeViews();
|
|
15400
|
+
const dom = this.view.dom;
|
|
15401
|
+
dom.editor = this;
|
|
14916
15402
|
this.options.telemetry?.sendReport();
|
|
14917
15403
|
};
|
|
14918
15404
|
/**
|
|
@@ -14954,9 +15440,7 @@ initComments_fn = function() {
|
|
|
14954
15440
|
}, 50);
|
|
14955
15441
|
};
|
|
14956
15442
|
initPagination_fn = async function() {
|
|
14957
|
-
if (this.options.isHeadless || !this.extensionService
|
|
14958
|
-
return;
|
|
14959
|
-
}
|
|
15443
|
+
if (this.options.isHeadless || !this.extensionService) return;
|
|
14960
15444
|
const pagination = this.options.extensions.find((e) => e.name === "pagination");
|
|
14961
15445
|
if (pagination && this.options.pagination) {
|
|
14962
15446
|
console.debug("🔗 [super-editor] Initializing pagination");
|
|
@@ -14973,7 +15457,7 @@ initPagination_fn = async function() {
|
|
|
14973
15457
|
* @param {Object} transaction - ProseMirror transaction
|
|
14974
15458
|
*/
|
|
14975
15459
|
dispatchTransaction_fn = function(transaction) {
|
|
14976
|
-
if (this.isDestroyed) return;
|
|
15460
|
+
if (this.view.isDestroyed) return;
|
|
14977
15461
|
let state;
|
|
14978
15462
|
try {
|
|
14979
15463
|
const trackChangesState = TrackChangesBasePluginKey.getState(this.view.state);
|
|
@@ -15025,14 +15509,6 @@ dispatchTransaction_fn = function(transaction) {
|
|
|
15025
15509
|
transaction
|
|
15026
15510
|
});
|
|
15027
15511
|
};
|
|
15028
|
-
/**
|
|
15029
|
-
* Handles image node selection for header/footer editor
|
|
15030
|
-
*/
|
|
15031
|
-
handleNodeSelection_fn = function(view, pos) {
|
|
15032
|
-
if (this.options.isHeaderOrFooter) {
|
|
15033
|
-
return setImageNodeSelection(view, pos);
|
|
15034
|
-
}
|
|
15035
|
-
};
|
|
15036
15512
|
/**
|
|
15037
15513
|
* Perform any post conversion pre prosemirror import processing.
|
|
15038
15514
|
* Comments are processed here.
|
|
@@ -17393,7 +17869,7 @@ const Paragraph = Node$1.create({
|
|
|
17393
17869
|
},
|
|
17394
17870
|
addPmPlugins() {
|
|
17395
17871
|
const { view } = this.editor;
|
|
17396
|
-
new Plugin({
|
|
17872
|
+
const dropcapPlugin = new Plugin({
|
|
17397
17873
|
name: "dropcapPlugin",
|
|
17398
17874
|
key: new PluginKey("dropcapPlugin"),
|
|
17399
17875
|
state: {
|
|
@@ -17413,7 +17889,7 @@ const Paragraph = Node$1.create({
|
|
|
17413
17889
|
}
|
|
17414
17890
|
}
|
|
17415
17891
|
});
|
|
17416
|
-
return [];
|
|
17892
|
+
return [dropcapPlugin];
|
|
17417
17893
|
}
|
|
17418
17894
|
});
|
|
17419
17895
|
const getDropcapDecorations = (state, view) => {
|
|
@@ -17766,16 +18242,7 @@ const HardBreak = Node$1.create({
|
|
|
17766
18242
|
};
|
|
17767
18243
|
},
|
|
17768
18244
|
parseDOM() {
|
|
17769
|
-
return [{
|
|
17770
|
-
tag: 'span[linebreaktype="page"]',
|
|
17771
|
-
getAttrs: (dom) => {
|
|
17772
|
-
if (!(dom instanceof HTMLElement)) return false;
|
|
17773
|
-
return {
|
|
17774
|
-
pageBreakSource: dom.getAttribute("pagebreaksource") || null,
|
|
17775
|
-
pageBreakType: dom.getAttribute("linebreaktype") || null
|
|
17776
|
-
};
|
|
17777
|
-
}
|
|
17778
|
-
}];
|
|
18245
|
+
return [{ tag: "span" }];
|
|
17779
18246
|
},
|
|
17780
18247
|
renderDOM({ htmlAttributes }) {
|
|
17781
18248
|
return ["span", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
|
|
@@ -20772,8 +21239,6 @@ function findRemovedFieldAnnotations(tr) {
|
|
|
20772
21239
|
if (!tr.steps.length || tr.meta && !Object.keys(tr.meta).every((meta) => ["inputType", "uiEvent", "paste"].includes(meta)) || ["historyUndo", "historyRedo"].includes(tr.getMeta("inputType")) || ["drop"].includes(tr.getMeta("uiEvent")) || tr.getMeta("fieldAnnotationUpdate") === true) {
|
|
20773
21240
|
return removedNodes;
|
|
20774
21241
|
}
|
|
20775
|
-
const hasDeletion = transactionDeletedAnything(tr);
|
|
20776
|
-
if (!hasDeletion) return removedNodes;
|
|
20777
21242
|
tr.steps.forEach((step, stepIndex) => {
|
|
20778
21243
|
if (step instanceof ReplaceStep && step.from !== step.to) {
|
|
20779
21244
|
let mapping = tr.mapping.maps[stepIndex];
|
|
@@ -20790,14 +21255,6 @@ function findRemovedFieldAnnotations(tr) {
|
|
|
20790
21255
|
});
|
|
20791
21256
|
return removedNodes;
|
|
20792
21257
|
}
|
|
20793
|
-
function transactionDeletedAnything(tr) {
|
|
20794
|
-
return tr.steps.some((step) => {
|
|
20795
|
-
if (step instanceof ReplaceStep || step instanceof ReplaceAroundStep) {
|
|
20796
|
-
return step.from !== step.to;
|
|
20797
|
-
}
|
|
20798
|
-
return false;
|
|
20799
|
-
});
|
|
20800
|
-
}
|
|
20801
21258
|
function trackFieldAnnotationsDeletion(editor, tr) {
|
|
20802
21259
|
let removedAnnotations = [];
|
|
20803
21260
|
try {
|
|
@@ -21193,18 +21650,8 @@ const FieldAnnotation = Node$1.create({
|
|
|
21193
21650
|
};
|
|
21194
21651
|
}
|
|
21195
21652
|
},
|
|
21196
|
-
defaultDisplayLabel: {
|
|
21197
|
-
default: "",
|
|
21198
|
-
parseDOM: (elem) => elem.getAttribute("data-default-display-label"),
|
|
21199
|
-
renderDOM: (attrs) => {
|
|
21200
|
-
if (!attrs.defaultDisplayLabel) return {};
|
|
21201
|
-
return {
|
|
21202
|
-
"data-default-display-label": attrs.defaultDisplayLabel
|
|
21203
|
-
};
|
|
21204
|
-
}
|
|
21205
|
-
},
|
|
21206
21653
|
displayLabel: {
|
|
21207
|
-
default: "",
|
|
21654
|
+
default: "Text field",
|
|
21208
21655
|
parseDOM: (elem) => elem.getAttribute("data-display-label"),
|
|
21209
21656
|
renderDOM: (attrs) => {
|
|
21210
21657
|
if (!attrs.displayLabel) return {};
|
|
@@ -21520,7 +21967,6 @@ const FieldAnnotation = Node$1.create({
|
|
|
21520
21967
|
return renderer();
|
|
21521
21968
|
},
|
|
21522
21969
|
addCommands() {
|
|
21523
|
-
const annotationTypes = this.options.types;
|
|
21524
21970
|
return {
|
|
21525
21971
|
/**
|
|
21526
21972
|
* Add field annotation.
|
|
@@ -21542,12 +21988,7 @@ const FieldAnnotation = Node$1.create({
|
|
|
21542
21988
|
let currentMarks = $pos.marks();
|
|
21543
21989
|
currentMarks = currentMarks.length ? [...currentMarks] : null;
|
|
21544
21990
|
let formatAttrs = getFormatAttrsFromMarks(currentMarks);
|
|
21545
|
-
let
|
|
21546
|
-
let node = schema.nodes[this.name].create({
|
|
21547
|
-
...attrs,
|
|
21548
|
-
...formatAttrs,
|
|
21549
|
-
defaultDisplayLabel
|
|
21550
|
-
}, null, null);
|
|
21991
|
+
let node = schema.nodes[this.name].create({ ...attrs, ...formatAttrs }, null, null);
|
|
21551
21992
|
state.tr.insert(newPos, node).setSelection(Selection.near(tr.doc.resolve(newPos + node.nodeSize)));
|
|
21552
21993
|
if (editorFocus) {
|
|
21553
21994
|
this.editor.view.focus();
|
|
@@ -21555,9 +21996,9 @@ const FieldAnnotation = Node$1.create({
|
|
|
21555
21996
|
}
|
|
21556
21997
|
return true;
|
|
21557
21998
|
},
|
|
21558
|
-
addFieldAnnotationAtSelection: (attrs = {}, editorFocus = false) => ({ state, commands: commands2 }) => {
|
|
21999
|
+
addFieldAnnotationAtSelection: (attrs = {}, editorFocus = false) => ({ editor, dispatch, state, tr, commands: commands2 }) => {
|
|
21559
22000
|
const { from: from2 } = state.selection;
|
|
21560
|
-
|
|
22001
|
+
commands2.addFieldAnnotation(from2, attrs, editorFocus);
|
|
21561
22002
|
},
|
|
21562
22003
|
/**
|
|
21563
22004
|
* Replace field annotation.
|
|
@@ -21567,113 +22008,24 @@ const FieldAnnotation = Node$1.create({
|
|
|
21567
22008
|
* from: 20,
|
|
21568
22009
|
* to: 45,
|
|
21569
22010
|
* attrs: {
|
|
21570
|
-
*
|
|
21571
|
-
*
|
|
22011
|
+
* fieldType: 'TEXTINPUT'
|
|
22012
|
+
* fieldColor: '#980043'
|
|
21572
22013
|
* }
|
|
21573
22014
|
* ])
|
|
21574
22015
|
*/
|
|
21575
|
-
replaceWithFieldAnnotation: (fieldsArray) => ({ editor, dispatch, tr }) => {
|
|
22016
|
+
replaceWithFieldAnnotation: (fieldsArray) => ({ editor, dispatch, state, tr }) => {
|
|
21576
22017
|
if (!dispatch) return true;
|
|
22018
|
+
tr.setMeta("fieldAnnotationReplace", true);
|
|
21577
22019
|
fieldsArray.forEach((annotation) => {
|
|
21578
22020
|
let { from: from2, to, attrs } = annotation;
|
|
21579
22021
|
let { schema } = editor;
|
|
21580
22022
|
let newPosFrom = tr.mapping.map(from2);
|
|
21581
22023
|
let newPosTo = tr.mapping.map(to);
|
|
21582
|
-
let
|
|
21583
|
-
let node = schema.nodes[this.name].create({
|
|
21584
|
-
...attrs,
|
|
21585
|
-
defaultDisplayLabel
|
|
21586
|
-
}, null, null);
|
|
22024
|
+
let node = schema.nodes[this.name].create({ ...attrs }, null, null);
|
|
21587
22025
|
tr.replaceWith(newPosFrom, newPosTo, node);
|
|
21588
22026
|
});
|
|
21589
22027
|
return true;
|
|
21590
22028
|
},
|
|
21591
|
-
/**
|
|
21592
|
-
* Replace annotations with a label (as text node) in selection.
|
|
21593
|
-
* @param options Additional options.
|
|
21594
|
-
* @example
|
|
21595
|
-
* editor.commands.replaceFieldAnnotationsWithLabelInSelection()
|
|
21596
|
-
*/
|
|
21597
|
-
replaceFieldAnnotationsWithLabelInSelection: (options = {}) => ({ commands: commands2 }) => {
|
|
21598
|
-
return commands2.replaceFieldAnnotationsWithLabel(null, {
|
|
21599
|
-
...options,
|
|
21600
|
-
isInSelection: true
|
|
21601
|
-
});
|
|
21602
|
-
},
|
|
21603
|
-
/**
|
|
21604
|
-
* Replace annotations with a label (as text node).
|
|
21605
|
-
* @param fieldIdOrArray The field ID or array of field IDs.
|
|
21606
|
-
* @param options.isInSelection Find in selection instead of field IDs.
|
|
21607
|
-
* @param options.addToHistory Add to history or not.
|
|
21608
|
-
* @param options.types Annotation types to replace.
|
|
21609
|
-
* @example
|
|
21610
|
-
* editor.commands.replaceFieldAnnotationsWithLabel(['1', '2'])
|
|
21611
|
-
*/
|
|
21612
|
-
replaceFieldAnnotationsWithLabel: (fieldIdOrArray, {
|
|
21613
|
-
isInSelection = false,
|
|
21614
|
-
addToHistory = false,
|
|
21615
|
-
types = annotationTypes
|
|
21616
|
-
} = {}) => ({ dispatch, state, tr }) => {
|
|
21617
|
-
let { from: from2, to } = state.selection;
|
|
21618
|
-
let annotations = isInSelection ? findFieldAnnotationsBetween(from2, to, state.doc) : findFieldAnnotationsByFieldId(fieldIdOrArray, state);
|
|
21619
|
-
annotations = types.length ? annotations.filter(({ node }) => types.includes(node.attrs.type)) : annotations;
|
|
21620
|
-
if (!annotations.length) {
|
|
21621
|
-
return true;
|
|
21622
|
-
}
|
|
21623
|
-
if (!addToHistory) {
|
|
21624
|
-
tr.setMeta("addToHistory", false);
|
|
21625
|
-
}
|
|
21626
|
-
if (dispatch) {
|
|
21627
|
-
annotations.forEach((annotation) => {
|
|
21628
|
-
let { pos, node } = annotation;
|
|
21629
|
-
let newPosFrom = tr.mapping.map(pos);
|
|
21630
|
-
let newPosTo = tr.mapping.map(pos + node.nodeSize);
|
|
21631
|
-
let currentNode = tr.doc.nodeAt(newPosFrom);
|
|
21632
|
-
let nodeEqual = node.attrs.fieldId === currentNode?.attrs?.fieldId;
|
|
21633
|
-
let $newPosFrom = tr.doc.resolve(newPosFrom);
|
|
21634
|
-
let currentMarks = $newPosFrom.marks();
|
|
21635
|
-
currentMarks = currentMarks.length ? [...currentMarks] : null;
|
|
21636
|
-
if (nodeEqual) {
|
|
21637
|
-
let label = node.attrs.displayLabel || " ";
|
|
21638
|
-
let textNode = state.schema.text(label, currentMarks);
|
|
21639
|
-
tr.replaceWith(newPosFrom, newPosTo, textNode);
|
|
21640
|
-
}
|
|
21641
|
-
});
|
|
21642
|
-
}
|
|
21643
|
-
return true;
|
|
21644
|
-
},
|
|
21645
|
-
/**
|
|
21646
|
-
* Resets all annotations to default values.
|
|
21647
|
-
* @example
|
|
21648
|
-
* editor.commands.resetFieldAnnotations()
|
|
21649
|
-
*/
|
|
21650
|
-
resetFieldAnnotations: () => ({ dispatch, state, tr }) => {
|
|
21651
|
-
let annotations = getAllFieldAnnotations(state);
|
|
21652
|
-
if (!annotations.length) {
|
|
21653
|
-
return true;
|
|
21654
|
-
}
|
|
21655
|
-
tr.setMeta("fieldAnnotationUpdate", true);
|
|
21656
|
-
if (dispatch) {
|
|
21657
|
-
annotations.forEach(({ pos, node }) => {
|
|
21658
|
-
let newPos = tr.mapping.map(pos);
|
|
21659
|
-
let currentNode = tr.doc.nodeAt(newPos);
|
|
21660
|
-
let nodeEqual = node.attrs.fieldId === currentNode?.attrs?.fieldId;
|
|
21661
|
-
if (nodeEqual) {
|
|
21662
|
-
let displayLabel = node.attrs.defaultDisplayLabel || node.attrs.displayLabel || "";
|
|
21663
|
-
tr.setNodeMarkup(newPos, void 0, {
|
|
21664
|
-
...node.attrs,
|
|
21665
|
-
// reset displayLabel to default.
|
|
21666
|
-
displayLabel,
|
|
21667
|
-
// reset attrs for specific types.
|
|
21668
|
-
imageSrc: null,
|
|
21669
|
-
rawHtml: null,
|
|
21670
|
-
linkUrl: null
|
|
21671
|
-
});
|
|
21672
|
-
}
|
|
21673
|
-
});
|
|
21674
|
-
}
|
|
21675
|
-
return true;
|
|
21676
|
-
},
|
|
21677
22029
|
/**
|
|
21678
22030
|
* Update annotations associated with a field.
|
|
21679
22031
|
* @param fieldIdOrArray The field ID or array of field IDs.
|
|
@@ -22428,16 +22780,12 @@ const startImageUpload = async ({ editor, view, file }) => {
|
|
|
22428
22780
|
}
|
|
22429
22781
|
let id = {};
|
|
22430
22782
|
let { tr, schema } = view.state;
|
|
22431
|
-
|
|
22432
|
-
if (editor.options.isHeaderOrFooter) {
|
|
22433
|
-
selection = editor.options.lastSelection;
|
|
22434
|
-
}
|
|
22435
|
-
if (!selection.empty && !editor.options.isHeaderOrFooter) {
|
|
22783
|
+
if (!tr.selection.empty) {
|
|
22436
22784
|
tr.deleteSelection();
|
|
22437
22785
|
}
|
|
22438
22786
|
let imageMeta = {
|
|
22439
22787
|
type: "add",
|
|
22440
|
-
pos: selection.from,
|
|
22788
|
+
pos: tr.selection.from,
|
|
22441
22789
|
id
|
|
22442
22790
|
};
|
|
22443
22791
|
tr.setMeta(ImagePlaceholderPluginKey, imageMeta);
|
|
@@ -27686,8 +28034,7 @@ const Pagination = Extension.create({
|
|
|
27686
28034
|
addStorage() {
|
|
27687
28035
|
return {
|
|
27688
28036
|
height: 0,
|
|
27689
|
-
sectionData: null
|
|
27690
|
-
headerFooterEditors: /* @__PURE__ */ new Map()
|
|
28037
|
+
sectionData: null
|
|
27691
28038
|
};
|
|
27692
28039
|
},
|
|
27693
28040
|
addCommands() {
|
|
@@ -27730,14 +28077,13 @@ const Pagination = Extension.create({
|
|
|
27730
28077
|
shouldUpdate = true;
|
|
27731
28078
|
shouldInitialize = meta.isReadyToInit;
|
|
27732
28079
|
}
|
|
27733
|
-
const syncMeta = tr.getMeta("y-sync$");
|
|
27734
|
-
if (syncMeta && syncMeta.isChangeOrigin) {
|
|
27735
|
-
return { ...oldState };
|
|
27736
|
-
}
|
|
27737
28080
|
const imagePluginTransaction = tr.getMeta(ImagePlaceholderPluginKey);
|
|
27738
28081
|
if (imagePluginTransaction) {
|
|
27739
28082
|
if (imagePluginTransaction.type === "remove") {
|
|
27740
|
-
|
|
28083
|
+
const imagePos = imagePluginTransaction.pos;
|
|
28084
|
+
const domImage = editor.view.domAtPos(imagePos).node.querySelector("img");
|
|
28085
|
+
if (domImage.complete) onImageLoad(editor);
|
|
28086
|
+
else domImage.onload = () => onImageLoad(editor);
|
|
27741
28087
|
}
|
|
27742
28088
|
return { ...oldState };
|
|
27743
28089
|
}
|
|
@@ -27764,7 +28110,6 @@ const Pagination = Extension.create({
|
|
|
27764
28110
|
if (isForceUpdate) shouldUpdate = true;
|
|
27765
28111
|
return {
|
|
27766
28112
|
...oldState,
|
|
27767
|
-
decorations: meta?.decorations?.map(tr.mapping, tr.doc) || DecorationSet.empty,
|
|
27768
28113
|
isReadyToInit: shouldInitialize
|
|
27769
28114
|
};
|
|
27770
28115
|
}
|
|
@@ -27793,10 +28138,6 @@ const Pagination = Extension.create({
|
|
|
27793
28138
|
},
|
|
27794
28139
|
onDestroy() {
|
|
27795
28140
|
cleanupFloatingSeparators();
|
|
27796
|
-
const { headerFooterEditors } = this.editor.storage.pagination;
|
|
27797
|
-
if (headerFooterEditors) {
|
|
27798
|
-
headerFooterEditors.clear();
|
|
27799
|
-
}
|
|
27800
28141
|
}
|
|
27801
28142
|
});
|
|
27802
28143
|
const getHeaderFooterId = (currentPageNumber, sectionType, editor, node = null) => {
|
|
@@ -27857,7 +28198,6 @@ const performUpdate = (editor, view, previousDecorations) => {
|
|
|
27857
28198
|
const calculatePageBreaks = (view, editor, sectionData) => {
|
|
27858
28199
|
if (!editor.converter) return DecorationSet.empty;
|
|
27859
28200
|
const pageSize = editor.converter.pageStyles?.pageSize;
|
|
27860
|
-
if (!pageSize) return DecorationSet.empty;
|
|
27861
28201
|
const { width, height } = pageSize;
|
|
27862
28202
|
if (!width || !height) return DecorationSet.empty;
|
|
27863
28203
|
const ignorePlugins = [CollaborationPluginKey, PaginationPluginKey];
|
|
@@ -27896,13 +28236,11 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
|
|
|
27896
28236
|
let pageHeightThreshold = pageHeight;
|
|
27897
28237
|
let footer = null, header = null;
|
|
27898
28238
|
const firstHeaderId = getHeaderFooterId(currentPageNumber, "headerIds", editor);
|
|
27899
|
-
const
|
|
27900
|
-
const firstHeader = createHeader(pageMargins, pageSize, sectionData, firstHeaderId, editor, currentPageNumber, isFirstHeader);
|
|
28239
|
+
const firstHeader = createHeader(pageMargins, pageSize, sectionData, firstHeaderId, editor, currentPageNumber);
|
|
27901
28240
|
const pageBreak = createPageBreak({ editor, header: firstHeader, isFirstHeader: true });
|
|
27902
28241
|
decorations.push(Decoration.widget(0, pageBreak, { key: "stable-key" }));
|
|
27903
28242
|
const lastFooterId = getHeaderFooterId(currentPageNumber, "footerIds", editor);
|
|
27904
|
-
const
|
|
27905
|
-
const lastFooter = createFooter(pageMargins, pageSize, sectionData, lastFooterId, editor, currentPageNumber, isLastFooter);
|
|
28243
|
+
const lastFooter = createFooter(pageMargins, pageSize, sectionData, lastFooterId, editor, currentPageNumber);
|
|
27906
28244
|
pageHeightThreshold -= firstHeader.headerHeight + lastFooter.footerHeight;
|
|
27907
28245
|
let coords = view?.coordsAtPos(doc2.content.size);
|
|
27908
28246
|
if (!coords) return [];
|
|
@@ -27921,8 +28259,7 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
|
|
|
27921
28259
|
if (currentPageNumber === 1) {
|
|
27922
28260
|
const headerId2 = getHeaderFooterId(currentPageNumber, "headerIds", editor, currentNode);
|
|
27923
28261
|
decorations.pop();
|
|
27924
|
-
const
|
|
27925
|
-
const newFirstHeader = createHeader(pageMargins, pageSize, sectionData, headerId2, editor, currentPageNumber, isFirstHeader2);
|
|
28262
|
+
const newFirstHeader = createHeader(pageMargins, pageSize, sectionData, headerId2, editor, currentPageNumber - 1);
|
|
27926
28263
|
const pageBreak2 = createPageBreak({ editor, header: newFirstHeader, isFirstHeader: true });
|
|
27927
28264
|
decorations.push(Decoration.widget(0, pageBreak2, { key: "stable-key" }));
|
|
27928
28265
|
}
|
|
@@ -27996,15 +28333,15 @@ function createFinalPagePadding(bufferHeight) {
|
|
|
27996
28333
|
div2.style.height = bufferHeight + "px";
|
|
27997
28334
|
return { nodeHeight: bufferHeight, node: div2 };
|
|
27998
28335
|
}
|
|
27999
|
-
function createHeader(pageMargins, pageSize, sectionData, headerId, editor, currentPageNumber
|
|
28000
|
-
const headerDef = sectionData
|
|
28336
|
+
function createHeader(pageMargins, pageSize, sectionData, headerId, editor, currentPageNumber) {
|
|
28337
|
+
const headerDef = sectionData.headers?.[headerId];
|
|
28001
28338
|
const minHeaderHeight = pageMargins.top * 96;
|
|
28002
28339
|
const headerMargin = pageMargins.header * 96;
|
|
28003
28340
|
const hasHeaderOffset = headerDef?.height > minHeaderHeight - headerMargin;
|
|
28004
28341
|
const headerOffset = hasHeaderOffset ? headerMargin : 0;
|
|
28005
28342
|
const headerHeight = Math.max(headerDef?.height || 0, minHeaderHeight) + headerOffset;
|
|
28006
28343
|
const availableHeight = headerHeight - headerMargin;
|
|
28007
|
-
|
|
28344
|
+
const editorContainer = document.createElement("div");
|
|
28008
28345
|
if (!headerId && !editor?.converter?.headerIds?.["default"]) {
|
|
28009
28346
|
headerId = "rId" + generateDocxRandomId();
|
|
28010
28347
|
editor.converter.headerIds["default"] = headerId;
|
|
@@ -28016,31 +28353,23 @@ function createHeader(pageMargins, pageSize, sectionData, headerId, editor, curr
|
|
|
28016
28353
|
};
|
|
28017
28354
|
}
|
|
28018
28355
|
const data = editor.converter.headers[headerId];
|
|
28019
|
-
const
|
|
28020
|
-
|
|
28021
|
-
|
|
28022
|
-
|
|
28023
|
-
|
|
28024
|
-
|
|
28025
|
-
|
|
28026
|
-
|
|
28027
|
-
|
|
28028
|
-
|
|
28029
|
-
|
|
28030
|
-
|
|
28031
|
-
|
|
28032
|
-
|
|
28033
|
-
sectionId: headerId,
|
|
28034
|
-
type: "header",
|
|
28035
|
-
availableHeight,
|
|
28036
|
-
currentPageNumber
|
|
28037
|
-
});
|
|
28038
|
-
editor.converter.headerEditors.push({ id: headerId, editor: editorSection });
|
|
28039
|
-
headerFooterEditors.set(editorKey, { editor: editorSection });
|
|
28040
|
-
broadcastEditorEvents(editor, editorSection);
|
|
28041
|
-
}
|
|
28356
|
+
const editorSection = createHeaderFooterEditor({
|
|
28357
|
+
editor,
|
|
28358
|
+
data,
|
|
28359
|
+
editorContainer,
|
|
28360
|
+
appendToBody: false,
|
|
28361
|
+
sectionId: headerId,
|
|
28362
|
+
type: "header",
|
|
28363
|
+
availableHeight,
|
|
28364
|
+
currentPageNumber
|
|
28365
|
+
});
|
|
28366
|
+
editor.converter.headerEditors.push({
|
|
28367
|
+
id: headerId,
|
|
28368
|
+
editor: editorSection
|
|
28369
|
+
});
|
|
28042
28370
|
editorSection.setEditable(false, false);
|
|
28043
|
-
|
|
28371
|
+
broadcastEditorEvents(editor, editorSection);
|
|
28372
|
+
editorContainer.className = "pagination-section-header";
|
|
28044
28373
|
editorContainer.style.paddingTop = headerMargin + "px";
|
|
28045
28374
|
editorContainer.style.paddingLeft = pageMargins.left * 96 + "px";
|
|
28046
28375
|
editorContainer.style.paddingRight = pageMargins.right * 96 + "px";
|
|
@@ -28053,12 +28382,12 @@ function createHeader(pageMargins, pageSize, sectionData, headerId, editor, curr
|
|
|
28053
28382
|
headerHeight
|
|
28054
28383
|
};
|
|
28055
28384
|
}
|
|
28056
|
-
function createFooter(pageMargins, pageSize, sectionData, footerId, editor, currentPageNumber
|
|
28057
|
-
const footerDef = sectionData
|
|
28385
|
+
function createFooter(pageMargins, pageSize, sectionData, footerId, editor, currentPageNumber) {
|
|
28386
|
+
const footerDef = sectionData.footers?.[footerId];
|
|
28058
28387
|
const minFooterHeight = pageMargins.bottom * 96;
|
|
28059
28388
|
const footerPaddingFromEdge = pageMargins.footer * 96;
|
|
28060
28389
|
const footerHeight = Math.max(footerDef?.height || 0, minFooterHeight - footerPaddingFromEdge);
|
|
28061
|
-
|
|
28390
|
+
const editorContainer = document.createElement("div");
|
|
28062
28391
|
if (!footerId && !editor.converter.footerIds["default"]) {
|
|
28063
28392
|
footerId = "rId" + generateDocxRandomId();
|
|
28064
28393
|
editor.converter.footerIds["default"] = footerId;
|
|
@@ -28070,31 +28399,23 @@ function createFooter(pageMargins, pageSize, sectionData, footerId, editor, curr
|
|
|
28070
28399
|
};
|
|
28071
28400
|
}
|
|
28072
28401
|
const data = editor.converter.footers[footerId];
|
|
28073
|
-
const
|
|
28074
|
-
|
|
28075
|
-
|
|
28076
|
-
|
|
28077
|
-
|
|
28078
|
-
|
|
28079
|
-
|
|
28080
|
-
|
|
28081
|
-
|
|
28082
|
-
|
|
28083
|
-
|
|
28084
|
-
|
|
28085
|
-
|
|
28086
|
-
|
|
28087
|
-
sectionId: footerId,
|
|
28088
|
-
type: "footer",
|
|
28089
|
-
availableHeight: footerHeight,
|
|
28090
|
-
currentPageNumber
|
|
28091
|
-
});
|
|
28092
|
-
editor.converter.footerEditors.push({ id: footerId, editor: editorSection });
|
|
28093
|
-
headerFooterEditors.set(editorKey, { editor: editorSection });
|
|
28094
|
-
broadcastEditorEvents(editor, editorSection);
|
|
28095
|
-
}
|
|
28402
|
+
const editorSection = createHeaderFooterEditor({
|
|
28403
|
+
editor,
|
|
28404
|
+
data,
|
|
28405
|
+
editorContainer,
|
|
28406
|
+
appendToBody: false,
|
|
28407
|
+
sectionId: footerId,
|
|
28408
|
+
type: "footer",
|
|
28409
|
+
availableHeight: footerHeight,
|
|
28410
|
+
currentPageNumber
|
|
28411
|
+
});
|
|
28412
|
+
editor.converter.footerEditors.push({
|
|
28413
|
+
id: footerId,
|
|
28414
|
+
editor: editorSection
|
|
28415
|
+
});
|
|
28096
28416
|
editorSection.setEditable(false, false);
|
|
28097
|
-
|
|
28417
|
+
broadcastEditorEvents(editor, editorSection);
|
|
28418
|
+
editorContainer.className = "pagination-section-footer";
|
|
28098
28419
|
editorContainer.style.height = footerHeight + "px";
|
|
28099
28420
|
editorContainer.style.marginBottom = footerPaddingFromEdge + "px";
|
|
28100
28421
|
editorContainer.style.paddingLeft = pageMargins.left * 96 + "px";
|
|
@@ -28107,28 +28428,10 @@ function createFooter(pageMargins, pageSize, sectionData, footerId, editor, curr
|
|
|
28107
28428
|
footerHeight: footerHeight + footerPaddingFromEdge
|
|
28108
28429
|
};
|
|
28109
28430
|
}
|
|
28110
|
-
const getHeaderFooterEditorKey = ({
|
|
28111
|
-
pageNumber,
|
|
28112
|
-
isHeader,
|
|
28113
|
-
isFooter,
|
|
28114
|
-
isFirstHeader = false,
|
|
28115
|
-
isLastFooter = false
|
|
28116
|
-
}) => {
|
|
28117
|
-
if (isFirstHeader) return `first-header-${pageNumber}`;
|
|
28118
|
-
if (isLastFooter) return `last-footer-${pageNumber}`;
|
|
28119
|
-
if (isHeader) return `header-${pageNumber}`;
|
|
28120
|
-
if (isFooter) return `footer-${pageNumber}`;
|
|
28121
|
-
return void 0;
|
|
28122
|
-
};
|
|
28123
28431
|
const onHeaderFooterDblClick = (editor, currentFocusedSectionEditor) => {
|
|
28124
28432
|
if (editor.options.documentMode !== "editing") return;
|
|
28125
28433
|
editor.setEditable(false, false);
|
|
28126
|
-
toggleHeaderFooterEditMode(
|
|
28127
|
-
editor,
|
|
28128
|
-
focusedSectionEditor: currentFocusedSectionEditor,
|
|
28129
|
-
isEditMode: true,
|
|
28130
|
-
documentMode: editor.options.documentMode
|
|
28131
|
-
});
|
|
28434
|
+
toggleHeaderFooterEditMode(editor, currentFocusedSectionEditor, true);
|
|
28132
28435
|
};
|
|
28133
28436
|
function createPageBreak({ editor, header, footer, footerBottom = null, isFirstHeader, isLastFooter, isInTable: isInTable2 = false }) {
|
|
28134
28437
|
const { pageSize, pageMargins } = editor.converter.pageStyles;
|
|
@@ -28683,7 +28986,7 @@ const Search = Extension.create({
|
|
|
28683
28986
|
}
|
|
28684
28987
|
});
|
|
28685
28988
|
const NodeResizerKey = new PluginKey("node-resizer");
|
|
28686
|
-
const nodeResizer = (nodeNames = ["image"]
|
|
28989
|
+
const nodeResizer = (nodeNames = ["image"]) => {
|
|
28687
28990
|
let resizeState = {
|
|
28688
28991
|
dragging: false,
|
|
28689
28992
|
startX: 0,
|
|
@@ -28708,13 +29011,8 @@ const nodeResizer = (nodeNames = ["image"], editor) => {
|
|
|
28708
29011
|
if (tr.getMeta(NodeResizerKey)) {
|
|
28709
29012
|
return oldState;
|
|
28710
29013
|
}
|
|
28711
|
-
if (typeof document === "undefined" || editor.options.isHeadless) return oldState;
|
|
28712
|
-
const { selection } = newState;
|
|
28713
|
-
const node = selection.node;
|
|
28714
|
-
if (!node || !nodeNames.includes(node.type.name)) {
|
|
28715
|
-
return DecorationSet.empty;
|
|
28716
|
-
}
|
|
28717
29014
|
const decorations = [];
|
|
29015
|
+
const { selection } = newState;
|
|
28718
29016
|
if (nodeNames.includes(selection.node?.type.name)) {
|
|
28719
29017
|
decorations.push(
|
|
28720
29018
|
Decoration.node(selection.from, selection.to, {
|
|
@@ -28917,7 +29215,7 @@ const nodeResizer = (nodeNames = ["image"], editor) => {
|
|
|
28917
29215
|
const NodeResizer = Extension.create({
|
|
28918
29216
|
name: "nodeResizer",
|
|
28919
29217
|
addPmPlugins() {
|
|
28920
|
-
return [nodeResizer(["image"]
|
|
29218
|
+
return [nodeResizer(["image"])];
|
|
28921
29219
|
}
|
|
28922
29220
|
});
|
|
28923
29221
|
const getRichTextExtensions = () => {
|