@harbour-enterprises/superdoc 0.25.0 → 0.26.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{PdfViewer-Y13XRanw.es.js → PdfViewer-BKHHNbny.es.js} +1 -1
- package/dist/chunks/{PdfViewer-DDL0V0l5.cjs → PdfViewer-BdAhZa5N.cjs} +1 -1
- package/dist/chunks/{index-Bo5YCvD5.cjs → index-CAVKoWDJ.cjs} +3 -3
- package/dist/chunks/{index-DKNVSdr6.es.js → index-ClUzozbw.es.js} +3 -3
- package/dist/chunks/{super-editor.es-CYtLh0Ob.es.js → super-editor.es-BewiNPbf.es.js} +475 -249
- package/dist/chunks/{super-editor.es-Ct2sXbNV.cjs → super-editor.es-DZb1VLxX.cjs} +475 -249
- package/dist/core/types/index.d.ts.map +1 -1
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-gSy6s2VK.js → converter-khE-H7hH.js} +90 -73
- package/dist/super-editor/chunks/{docx-zipper-CceGxV02.js → docx-zipper-KoUEtzIj.js} +1 -1
- package/dist/super-editor/chunks/{editor-CoX24lXQ.js → editor-CeTu_f0L.js} +388 -188
- package/dist/super-editor/chunks/{toolbar-BTw9-jfX.js → toolbar-D1RxvV5u.js} +2 -2
- package/dist/super-editor/converter.es.js +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/file-zipper.es.js +1 -1
- package/dist/super-editor/super-editor/src/core/Editor.d.ts +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/mc/altermateContent/alternate-content-translator.d.ts +11 -0
- package/dist/super-editor/super-editor/src/extensions/structured-content/structured-content-commands.d.ts +25 -0
- package/dist/super-editor/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentTablesById.d.ts +10 -0
- package/dist/super-editor/super-editor/src/extensions/structured-content/structuredContentHelpers/index.d.ts +1 -0
- package/dist/super-editor/super-editor/src/extensions/table/table.d.ts +84 -0
- package/dist/super-editor/super-editor/src/extensions/table/tableHelpers/appendRows.d.ts +139 -0
- package/dist/super-editor/super-editor/src/index.d.ts +8 -2
- package/dist/super-editor/super-editor.es.js +18 -14
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +1 -1
- package/dist/super-editor.es.js +1 -1
- package/dist/superdoc.cjs +2 -2
- package/dist/superdoc.es.js +2 -2
- package/dist/superdoc.umd.js +476 -250
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -32332,8 +32332,7 @@ const bookmarkEndNodeHandlerEntity = {
|
|
|
32332
32332
|
handlerName: "w:bookmarkEndTranslator",
|
|
32333
32333
|
handler: handleBookmarkEndNode
|
|
32334
32334
|
};
|
|
32335
|
-
const
|
|
32336
|
-
const SUPPORTED_REQUIRES = /* @__PURE__ */ new Set([
|
|
32335
|
+
const SUPPORTED_ALTERNATE_CONTENT_REQUIRES = /* @__PURE__ */ new Set([
|
|
32337
32336
|
"wps",
|
|
32338
32337
|
"wp14",
|
|
32339
32338
|
"w14",
|
|
@@ -32346,22 +32345,85 @@ const SUPPORTED_REQUIRES = /* @__PURE__ */ new Set([
|
|
|
32346
32345
|
"w16sdtfl",
|
|
32347
32346
|
"w16se"
|
|
32348
32347
|
]);
|
|
32348
|
+
const XML_NODE_NAME$1 = "mc:AlternateContent";
|
|
32349
|
+
const SD_NODE_NAME$1 = [];
|
|
32350
|
+
const validXmlAttributes$1 = [];
|
|
32351
|
+
function encode$1(params2) {
|
|
32352
|
+
const { nodeListHandler } = params2;
|
|
32353
|
+
const { node } = params2.extraParams;
|
|
32354
|
+
if (!node || !node.type) {
|
|
32355
|
+
return null;
|
|
32356
|
+
}
|
|
32357
|
+
const { branch, elements } = selectAlternateContentElements(node);
|
|
32358
|
+
if (!elements) {
|
|
32359
|
+
return null;
|
|
32360
|
+
}
|
|
32361
|
+
return nodeListHandler.handler({
|
|
32362
|
+
...params2,
|
|
32363
|
+
nodes: elements,
|
|
32364
|
+
path: buildPath(params2.path, node, branch)
|
|
32365
|
+
});
|
|
32366
|
+
}
|
|
32367
|
+
function decode$1(params2) {
|
|
32368
|
+
const { node } = params2;
|
|
32369
|
+
const { drawingContent } = node.attrs;
|
|
32370
|
+
const drawing = {
|
|
32371
|
+
name: "w:drawing",
|
|
32372
|
+
elements: [...drawingContent ? [...drawingContent.elements || []] : []]
|
|
32373
|
+
};
|
|
32374
|
+
const choice = {
|
|
32375
|
+
name: "mc:Choice",
|
|
32376
|
+
attributes: { Requires: "wps" },
|
|
32377
|
+
elements: [drawing]
|
|
32378
|
+
};
|
|
32379
|
+
return {
|
|
32380
|
+
name: "mc:AlternateContent",
|
|
32381
|
+
elements: [choice]
|
|
32382
|
+
};
|
|
32383
|
+
}
|
|
32384
|
+
const config$1 = {
|
|
32385
|
+
xmlName: XML_NODE_NAME$1,
|
|
32386
|
+
sdNodeOrKeyName: SD_NODE_NAME$1,
|
|
32387
|
+
type: NodeTranslator.translatorTypes.NODE,
|
|
32388
|
+
encode: encode$1,
|
|
32389
|
+
decode: decode$1,
|
|
32390
|
+
attributes: validXmlAttributes$1
|
|
32391
|
+
};
|
|
32392
|
+
function selectAlternateContentElements(node) {
|
|
32393
|
+
if (!node?.elements?.length) {
|
|
32394
|
+
return { branch: null, elements: null };
|
|
32395
|
+
}
|
|
32396
|
+
const choices = node.elements.filter((el) => el?.name === "mc:Choice");
|
|
32397
|
+
const fallback = node.elements.find((el) => el?.name === "mc:Fallback");
|
|
32398
|
+
const supportedChoice = choices.find((choice) => {
|
|
32399
|
+
const requiresAttr = choice?.attributes?.Requires || choice?.attributes?.requires;
|
|
32400
|
+
if (!requiresAttr) return false;
|
|
32401
|
+
return requiresAttr.split(/\s+/).filter(Boolean).some((namespace2) => SUPPORTED_ALTERNATE_CONTENT_REQUIRES.has(namespace2));
|
|
32402
|
+
});
|
|
32403
|
+
const branch = supportedChoice || fallback || choices[0] || null;
|
|
32404
|
+
const selectedElements = branch?.elements;
|
|
32405
|
+
if (!selectedElements) {
|
|
32406
|
+
return { branch, elements: null };
|
|
32407
|
+
}
|
|
32408
|
+
return {
|
|
32409
|
+
branch,
|
|
32410
|
+
elements: carbonCopy(selectedElements)
|
|
32411
|
+
};
|
|
32412
|
+
}
|
|
32413
|
+
const translator$1 = NodeTranslator.from(config$1);
|
|
32414
|
+
function buildPath(existingPath = [], node, branch) {
|
|
32415
|
+
const path = [...existingPath];
|
|
32416
|
+
if (node) path.push(node);
|
|
32417
|
+
if (branch) path.push(branch);
|
|
32418
|
+
return path;
|
|
32419
|
+
}
|
|
32420
|
+
const ALTERNATE_CONTENT_NODE = "mc:AlternateContent";
|
|
32349
32421
|
const skipHandlerResponse = { nodes: [], consumed: 0 };
|
|
32350
32422
|
const isAlternateContentNode = (node) => node?.name === ALTERNATE_CONTENT_NODE;
|
|
32351
|
-
const isSupportedChoice = (choice) => {
|
|
32352
|
-
if (!choice?.attributes) return false;
|
|
32353
|
-
const requires = choice.attributes.Requires || choice.attributes.requires;
|
|
32354
|
-
if (!requires) return false;
|
|
32355
|
-
return requires.split(/\s+/).filter(Boolean).some((namespace2) => SUPPORTED_REQUIRES.has(namespace2));
|
|
32356
|
-
};
|
|
32357
32423
|
const resolveAlternateContentElements = (alternateContent) => {
|
|
32358
|
-
|
|
32359
|
-
|
|
32360
|
-
|
|
32361
|
-
const supportedChoice = choices.find(isSupportedChoice);
|
|
32362
|
-
const selectedElements = supportedChoice?.elements || fallback?.elements || choices[0]?.elements;
|
|
32363
|
-
if (!selectedElements) return null;
|
|
32364
|
-
return carbonCopy(selectedElements);
|
|
32424
|
+
const { elements } = selectAlternateContentElements(alternateContent);
|
|
32425
|
+
if (!elements) return null;
|
|
32426
|
+
return elements;
|
|
32365
32427
|
};
|
|
32366
32428
|
const buildNodeWithoutAlternateContent = (node) => {
|
|
32367
32429
|
const { elements } = node || {};
|
|
@@ -32393,16 +32455,20 @@ const handleAlternateChoice = (params2) => {
|
|
|
32393
32455
|
}
|
|
32394
32456
|
const [currentNode] = nodes;
|
|
32395
32457
|
if (isAlternateContentNode(currentNode)) {
|
|
32396
|
-
const
|
|
32397
|
-
|
|
32398
|
-
|
|
32399
|
-
}
|
|
32400
|
-
const
|
|
32458
|
+
const nodeForTranslator = currentNode?.type ? currentNode : {
|
|
32459
|
+
...currentNode,
|
|
32460
|
+
type: "element"
|
|
32461
|
+
};
|
|
32462
|
+
const translated = translator$1.encode({
|
|
32401
32463
|
...params2,
|
|
32402
|
-
nodes:
|
|
32403
|
-
|
|
32464
|
+
nodes: [nodeForTranslator],
|
|
32465
|
+
extraParams: { ...params2.extraParams || {}, node: nodeForTranslator }
|
|
32404
32466
|
});
|
|
32405
|
-
|
|
32467
|
+
if (!translated) {
|
|
32468
|
+
return skipHandlerResponse;
|
|
32469
|
+
}
|
|
32470
|
+
const nodesArray = Array.isArray(translated) ? translated : [translated];
|
|
32471
|
+
return { nodes: nodesArray, consumed: 1 };
|
|
32406
32472
|
}
|
|
32407
32473
|
const sanitizedNode = buildNodeWithoutAlternateContent(currentNode);
|
|
32408
32474
|
if (!sanitizedNode) {
|
|
@@ -33700,55 +33766,6 @@ function translateShapeTextbox(params2) {
|
|
|
33700
33766
|
};
|
|
33701
33767
|
return textbox;
|
|
33702
33768
|
}
|
|
33703
|
-
const XML_NODE_NAME$1 = "mc:AlternateContent";
|
|
33704
|
-
const SD_NODE_NAME$1 = [];
|
|
33705
|
-
const validXmlAttributes$1 = [];
|
|
33706
|
-
function encode$1(params2) {
|
|
33707
|
-
const { nodeListHandler } = params2;
|
|
33708
|
-
const { node } = params2.extraParams;
|
|
33709
|
-
if (!node || !node.type) {
|
|
33710
|
-
return null;
|
|
33711
|
-
}
|
|
33712
|
-
const allowedNamespaces = ["wps", "wp14", "w14", "w15"];
|
|
33713
|
-
const wpsNode = node.elements.find(
|
|
33714
|
-
(el) => el.name === "mc:Choice" && allowedNamespaces.includes(el.attributes["Requires"])
|
|
33715
|
-
);
|
|
33716
|
-
if (!wpsNode) {
|
|
33717
|
-
return null;
|
|
33718
|
-
}
|
|
33719
|
-
const contents = wpsNode.elements;
|
|
33720
|
-
return nodeListHandler.handler({
|
|
33721
|
-
...params2,
|
|
33722
|
-
nodes: contents,
|
|
33723
|
-
path: [...params2.path || [], wpsNode]
|
|
33724
|
-
});
|
|
33725
|
-
}
|
|
33726
|
-
function decode$1(params2) {
|
|
33727
|
-
const { node } = params2;
|
|
33728
|
-
const { drawingContent } = node.attrs;
|
|
33729
|
-
const drawing = {
|
|
33730
|
-
name: "w:drawing",
|
|
33731
|
-
elements: [...drawingContent ? [...drawingContent.elements || []] : []]
|
|
33732
|
-
};
|
|
33733
|
-
const choice = {
|
|
33734
|
-
name: "mc:Choice",
|
|
33735
|
-
attributes: { Requires: "wps" },
|
|
33736
|
-
elements: [drawing]
|
|
33737
|
-
};
|
|
33738
|
-
return {
|
|
33739
|
-
name: "mc:AlternateContent",
|
|
33740
|
-
elements: [choice]
|
|
33741
|
-
};
|
|
33742
|
-
}
|
|
33743
|
-
const config$1 = {
|
|
33744
|
-
xmlName: XML_NODE_NAME$1,
|
|
33745
|
-
sdNodeOrKeyName: SD_NODE_NAME$1,
|
|
33746
|
-
type: NodeTranslator.translatorTypes.NODE,
|
|
33747
|
-
encode: encode$1,
|
|
33748
|
-
decode: decode$1,
|
|
33749
|
-
attributes: validXmlAttributes$1
|
|
33750
|
-
};
|
|
33751
|
-
const translator$1 = NodeTranslator.from(config$1);
|
|
33752
33769
|
function translateContentBlock(params2) {
|
|
33753
33770
|
const { node } = params2;
|
|
33754
33771
|
const { vmlAttributes, horizontalRule } = node.attrs;
|
|
@@ -35141,7 +35158,7 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
35141
35158
|
static getStoredSuperdocVersion(docx) {
|
|
35142
35159
|
return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
|
|
35143
35160
|
}
|
|
35144
|
-
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "0.
|
|
35161
|
+
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "0.25.0") {
|
|
35145
35162
|
return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
|
|
35146
35163
|
}
|
|
35147
35164
|
/**
|
|
@@ -38352,7 +38369,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
|
|
|
38352
38369
|
var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
38353
38370
|
var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
|
|
38354
38371
|
var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
|
|
38355
|
-
var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, registerPluginByNameIfNotExists_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, checkFonts_fn,
|
|
38372
|
+
var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, registerPluginByNameIfNotExists_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, checkFonts_fn, determineUnsupportedFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ListItemNodeView_instances, init_fn3, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn;
|
|
38356
38373
|
var GOOD_LEAF_SIZE = 200;
|
|
38357
38374
|
var RopeSequence = function RopeSequence2() {
|
|
38358
38375
|
};
|
|
@@ -52567,7 +52584,9 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
52567
52584
|
isHeaderFooterChanged: false,
|
|
52568
52585
|
isCustomXmlChanged: false,
|
|
52569
52586
|
focusTarget: null,
|
|
52570
|
-
permissionResolver: null
|
|
52587
|
+
permissionResolver: null,
|
|
52588
|
+
// header/footer editors may have parent(main) editor set
|
|
52589
|
+
parentEditor: null
|
|
52571
52590
|
});
|
|
52572
52591
|
__privateMethod$1(this, _Editor_instances, initContainerElement_fn).call(this, options);
|
|
52573
52592
|
__privateMethod$1(this, _Editor_instances, checkHeadless_fn).call(this, options);
|
|
@@ -53329,7 +53348,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
53329
53348
|
* @returns {Object | void} Migration results
|
|
53330
53349
|
*/
|
|
53331
53350
|
processCollaborationMigrations() {
|
|
53332
|
-
console.debug("[checkVersionMigrations] Current editor version", "0.
|
|
53351
|
+
console.debug("[checkVersionMigrations] Current editor version", "0.25.0");
|
|
53333
53352
|
if (!this.options.ydoc) return;
|
|
53334
53353
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
53335
53354
|
let docVersion = metaMap.get("version");
|
|
@@ -53535,9 +53554,6 @@ init_fn = function() {
|
|
|
53535
53554
|
this.emit("beforeCreate", { editor: this });
|
|
53536
53555
|
this.on("contentError", this.options.onContentError);
|
|
53537
53556
|
this.mount(this.options.element);
|
|
53538
|
-
if (!this.options.isHeadless) {
|
|
53539
|
-
__privateMethod$1(this, _Editor_instances, checkFonts_fn).call(this);
|
|
53540
|
-
}
|
|
53541
53557
|
this.on("create", this.options.onCreate);
|
|
53542
53558
|
this.on("update", this.options.onUpdate);
|
|
53543
53559
|
this.on("selectionUpdate", this.options.onSelectionUpdate);
|
|
@@ -53559,8 +53575,12 @@ init_fn = function() {
|
|
|
53559
53575
|
if (!this.options.isHeadless) {
|
|
53560
53576
|
this.initializeCollaborationData();
|
|
53561
53577
|
this.initDefaultStyles();
|
|
53578
|
+
__privateMethod$1(this, _Editor_instances, checkFonts_fn).call(this);
|
|
53562
53579
|
}
|
|
53563
|
-
|
|
53580
|
+
const shouldMigrateListsOnInit = Boolean(
|
|
53581
|
+
this.options.markdown || this.options.html || this.options.loadFromSchema || this.options.jsonOverride || this.options.mode === "html" || this.options.mode === "text"
|
|
53582
|
+
);
|
|
53583
|
+
if (shouldMigrateListsOnInit) {
|
|
53564
53584
|
this.migrateListsToV2();
|
|
53565
53585
|
}
|
|
53566
53586
|
this.setDocumentMode(this.options.documentMode);
|
|
@@ -53701,52 +53721,18 @@ checkFonts_fn = async function() {
|
|
|
53701
53721
|
if (this.options.isHeadless) {
|
|
53702
53722
|
return;
|
|
53703
53723
|
}
|
|
53704
|
-
const fontsUsedInDocument = this.converter.getDocumentFonts();
|
|
53705
|
-
if (!("queryLocalFonts" in window)) {
|
|
53706
|
-
console.warn("[SuperDoc] Could not get access to local fonts. Using fallback solution.");
|
|
53707
|
-
const unsupportedFonts = __privateMethod$1(this, _Editor_instances, determineUnsupportedFontsWithCanvas_fn).call(this, fontsUsedInDocument);
|
|
53708
|
-
this.emit("fonts-resolved", {
|
|
53709
|
-
documentFonts: fontsUsedInDocument,
|
|
53710
|
-
unsupportedFonts
|
|
53711
|
-
});
|
|
53712
|
-
return;
|
|
53713
|
-
}
|
|
53714
|
-
const localFontAccess = await navigator.permissions.query({ name: "local-fonts" });
|
|
53715
|
-
if (localFontAccess.state === "denied") {
|
|
53716
|
-
console.warn("[SuperDoc] Could not get access to local fonts. Using fallback solution.");
|
|
53717
|
-
const unsupportedFonts = __privateMethod$1(this, _Editor_instances, determineUnsupportedFontsWithCanvas_fn).call(this, fontsUsedInDocument);
|
|
53718
|
-
this.emit("fonts-resolved", {
|
|
53719
|
-
documentFonts: fontsUsedInDocument,
|
|
53720
|
-
unsupportedFonts
|
|
53721
|
-
});
|
|
53722
|
-
return;
|
|
53723
|
-
}
|
|
53724
53724
|
try {
|
|
53725
|
-
const
|
|
53726
|
-
const
|
|
53727
|
-
const unsupportedFonts = __privateMethod$1(this, _Editor_instances, determineUnsupportedFontsWithLocalFonts_fn).call(this, fontsUsedInDocument, uniqueLocalFonts);
|
|
53725
|
+
const fontsUsedInDocument = this.converter.getDocumentFonts();
|
|
53726
|
+
const unsupportedFonts = __privateMethod$1(this, _Editor_instances, determineUnsupportedFonts_fn).call(this, fontsUsedInDocument);
|
|
53728
53727
|
this.emit("fonts-resolved", {
|
|
53729
53728
|
documentFonts: fontsUsedInDocument,
|
|
53730
53729
|
unsupportedFonts
|
|
53731
53730
|
});
|
|
53732
53731
|
} catch {
|
|
53733
|
-
console.warn("[SuperDoc] Could not
|
|
53734
|
-
const unsupportedFonts = __privateMethod$1(this, _Editor_instances, determineUnsupportedFontsWithCanvas_fn).call(this, fontsUsedInDocument);
|
|
53735
|
-
this.emit("fonts-resolved", {
|
|
53736
|
-
documentFonts: fontsUsedInDocument,
|
|
53737
|
-
unsupportedFonts
|
|
53738
|
-
});
|
|
53732
|
+
console.warn("[SuperDoc] Could not determine document fonts and unsupported fonts");
|
|
53739
53733
|
}
|
|
53740
53734
|
};
|
|
53741
|
-
|
|
53742
|
-
const unsupportedFonts = fonts.filter((font) => {
|
|
53743
|
-
const isLocalFont = localFonts.includes(font);
|
|
53744
|
-
const isFontImported = this.fontsImported.includes(font);
|
|
53745
|
-
return !isLocalFont && !isFontImported;
|
|
53746
|
-
});
|
|
53747
|
-
return unsupportedFonts;
|
|
53748
|
-
};
|
|
53749
|
-
determineUnsupportedFontsWithCanvas_fn = function(fonts) {
|
|
53735
|
+
determineUnsupportedFonts_fn = function(fonts) {
|
|
53750
53736
|
const unsupportedFonts = fonts.filter((font) => {
|
|
53751
53737
|
const canRender = canRenderFont(font);
|
|
53752
53738
|
const isFontImported = this.fontsImported.includes(font);
|
|
@@ -53834,6 +53820,9 @@ onCollaborationReady_fn = function({ editor, ydoc }) {
|
|
|
53834
53820
|
if (this.options.collaborationIsReady) return;
|
|
53835
53821
|
console.debug("🔗 [super-editor] Collaboration ready");
|
|
53836
53822
|
__privateMethod$1(this, _Editor_instances, validateDocumentInit_fn).call(this);
|
|
53823
|
+
if (this.options.ydoc) {
|
|
53824
|
+
this.migrateListsToV2();
|
|
53825
|
+
}
|
|
53837
53826
|
this.options.onCollaborationReady({ editor, ydoc });
|
|
53838
53827
|
this.options.collaborationIsReady = true;
|
|
53839
53828
|
this.options.initialState = this.state;
|
|
@@ -55779,10 +55768,27 @@ function getStructuredContentBlockTags(state2) {
|
|
|
55779
55768
|
const result = findChildren$5(state2.doc, (node) => node.type.name === "structuredContentBlock");
|
|
55780
55769
|
return result;
|
|
55781
55770
|
}
|
|
55771
|
+
function getStructuredContentTablesById(id, state2) {
|
|
55772
|
+
if (!id || !state2) return [];
|
|
55773
|
+
const blocks = getStructuredContentTagsById(id, state2).filter(
|
|
55774
|
+
({ node }) => node.type.name === "structuredContentBlock"
|
|
55775
|
+
);
|
|
55776
|
+
if (!blocks.length) return [];
|
|
55777
|
+
const { pos: blockPos, node: blockNode } = blocks[0];
|
|
55778
|
+
const tablesInBlock = [];
|
|
55779
|
+
blockNode.descendants((child, relPos) => {
|
|
55780
|
+
if (child.type.name === "table") {
|
|
55781
|
+
const absPos = blockPos + 1 + relPos;
|
|
55782
|
+
tablesInBlock.push({ node: child, pos: absPos });
|
|
55783
|
+
}
|
|
55784
|
+
});
|
|
55785
|
+
return tablesInBlock;
|
|
55786
|
+
}
|
|
55782
55787
|
const structuredContentHelpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
55783
55788
|
__proto__: null,
|
|
55784
55789
|
getStructuredContentBlockTags,
|
|
55785
55790
|
getStructuredContentInlineTags,
|
|
55791
|
+
getStructuredContentTablesById,
|
|
55786
55792
|
getStructuredContentTags,
|
|
55787
55793
|
getStructuredContentTagsById
|
|
55788
55794
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
@@ -55979,6 +55985,36 @@ const StructuredContentCommands = Extension.create({
|
|
|
55979
55985
|
tr.replaceWith(posFrom, posTo, content);
|
|
55980
55986
|
}
|
|
55981
55987
|
return true;
|
|
55988
|
+
},
|
|
55989
|
+
/**
|
|
55990
|
+
* Append multiple rows to the end of a table inside a structured content block.
|
|
55991
|
+
* Each inner array represents the cell values for one new row.
|
|
55992
|
+
* @category Command
|
|
55993
|
+
* @param {StructuredContentTableAppendRowsOptions} options - Append configuration
|
|
55994
|
+
* @example
|
|
55995
|
+
* editor.commands.appendRowsToStructuredContentTable({
|
|
55996
|
+
* id: 'block-123',
|
|
55997
|
+
* tableIndex: 0,
|
|
55998
|
+
* rows: [['A', 'B'], ['C', 'D']],
|
|
55999
|
+
* copyRowStyle: true,
|
|
56000
|
+
* });
|
|
56001
|
+
*/
|
|
56002
|
+
appendRowsToStructuredContentTable: ({ id, tableIndex = 0, rows = [], copyRowStyle = false }) => ({ state: state2, commands: commands2, dispatch }) => {
|
|
56003
|
+
const normalized = normalizeRowsInput(rows);
|
|
56004
|
+
if (!normalized.length) return true;
|
|
56005
|
+
const tables = getStructuredContentTablesById(id, state2);
|
|
56006
|
+
if (!tables.length || tableIndex < 0 || tableIndex >= tables.length) return true;
|
|
56007
|
+
const { node: tableNode, pos: tablePos } = tables[tableIndex];
|
|
56008
|
+
if (dispatch) {
|
|
56009
|
+
return commands2.appendRowsWithContent({ tablePos, tableNode, valueRows: normalized, copyRowStyle });
|
|
56010
|
+
}
|
|
56011
|
+
return commands2.appendRowsWithContent({
|
|
56012
|
+
tablePos,
|
|
56013
|
+
tableNode,
|
|
56014
|
+
valueRows: normalized,
|
|
56015
|
+
copyRowStyle,
|
|
56016
|
+
dispatch: false
|
|
56017
|
+
});
|
|
55982
56018
|
}
|
|
55983
56019
|
};
|
|
55984
56020
|
},
|
|
@@ -55988,6 +56024,15 @@ const StructuredContentCommands = Extension.create({
|
|
|
55988
56024
|
};
|
|
55989
56025
|
}
|
|
55990
56026
|
});
|
|
56027
|
+
const normalizeRowsInput = (rowsOrValues) => {
|
|
56028
|
+
if (!Array.isArray(rowsOrValues) || !rowsOrValues.length) {
|
|
56029
|
+
return [];
|
|
56030
|
+
}
|
|
56031
|
+
if (Array.isArray(rowsOrValues[0])) {
|
|
56032
|
+
return rowsOrValues;
|
|
56033
|
+
}
|
|
56034
|
+
return [rowsOrValues];
|
|
56035
|
+
};
|
|
55991
56036
|
class DocumentSectionView {
|
|
55992
56037
|
constructor(node, getPos, decorations, editor) {
|
|
55993
56038
|
__privateAdd$1(this, _DocumentSectionView_instances);
|
|
@@ -61740,6 +61785,107 @@ function cellWrapping($pos) {
|
|
|
61740
61785
|
}
|
|
61741
61786
|
return null;
|
|
61742
61787
|
}
|
|
61788
|
+
function resolveTable(tr, tablePos, tableNode) {
|
|
61789
|
+
if (tableNode && tableNode.type && tableNode.type.name === "table") {
|
|
61790
|
+
return tableNode;
|
|
61791
|
+
}
|
|
61792
|
+
if (typeof tablePos === "number") {
|
|
61793
|
+
const current = tr.doc.nodeAt(tablePos);
|
|
61794
|
+
if (current && current.type.name === "table") {
|
|
61795
|
+
return current;
|
|
61796
|
+
}
|
|
61797
|
+
}
|
|
61798
|
+
return null;
|
|
61799
|
+
}
|
|
61800
|
+
function pickTemplateRowForAppend(tableNode, schema) {
|
|
61801
|
+
const RowType = schema.nodes.tableRow;
|
|
61802
|
+
const rows = [];
|
|
61803
|
+
tableNode.descendants((child) => {
|
|
61804
|
+
if (child.type === RowType) rows.push(child);
|
|
61805
|
+
});
|
|
61806
|
+
if (!rows.length) return null;
|
|
61807
|
+
for (let i = rows.length - 1; i >= 0; i--) {
|
|
61808
|
+
const r2 = rows[i];
|
|
61809
|
+
const hasBodyCell = r2.content?.content?.some((c2) => c2.type.name === "tableCell");
|
|
61810
|
+
if (hasBodyCell) return r2;
|
|
61811
|
+
}
|
|
61812
|
+
return rows[rows.length - 1];
|
|
61813
|
+
}
|
|
61814
|
+
function extractRowTemplateFormatting(cellNode, schema) {
|
|
61815
|
+
const ParagraphType = schema.nodes.paragraph;
|
|
61816
|
+
let blockType = ParagraphType;
|
|
61817
|
+
let blockAttrs = null;
|
|
61818
|
+
let textMarks = [];
|
|
61819
|
+
const blocks = cellNode?.content?.content || [];
|
|
61820
|
+
for (const block of blocks) {
|
|
61821
|
+
const isParagraphish = block.type === ParagraphType || block.type.name === "heading";
|
|
61822
|
+
if (isParagraphish) {
|
|
61823
|
+
blockType = block.type || ParagraphType;
|
|
61824
|
+
blockAttrs = block.attrs || null;
|
|
61825
|
+
}
|
|
61826
|
+
let foundText = null;
|
|
61827
|
+
block.descendants?.((n) => {
|
|
61828
|
+
if (!foundText && n.isText) foundText = n;
|
|
61829
|
+
});
|
|
61830
|
+
if (foundText) {
|
|
61831
|
+
textMarks = foundText.marks ? Array.from(foundText.marks) : [];
|
|
61832
|
+
break;
|
|
61833
|
+
}
|
|
61834
|
+
}
|
|
61835
|
+
if (!blockType || !blockType.validContent) blockType = ParagraphType;
|
|
61836
|
+
return { blockType, blockAttrs, textMarks };
|
|
61837
|
+
}
|
|
61838
|
+
function buildFormattedCellBlock(schema, value, { blockType, blockAttrs, textMarks }, copyRowStyle = false) {
|
|
61839
|
+
const text = typeof value === "string" ? value : value == null ? "" : String(value);
|
|
61840
|
+
const marks = copyRowStyle ? textMarks || [] : [];
|
|
61841
|
+
const textNode = schema.text(text, marks);
|
|
61842
|
+
const type2 = blockType || schema.nodes.paragraph;
|
|
61843
|
+
return type2.createAndFill(blockAttrs || null, textNode);
|
|
61844
|
+
}
|
|
61845
|
+
function buildRowFromTemplateRow({ schema, tableNode, templateRow, values, copyRowStyle = false }) {
|
|
61846
|
+
const RowType = schema.nodes.tableRow;
|
|
61847
|
+
const CellType = schema.nodes.tableCell;
|
|
61848
|
+
const HeaderType = schema.nodes.tableHeader;
|
|
61849
|
+
const map22 = TableMap.get(tableNode);
|
|
61850
|
+
const totalColumns = map22.width;
|
|
61851
|
+
const byColumns = Array.isArray(values) && values.length === totalColumns;
|
|
61852
|
+
const newCells = [];
|
|
61853
|
+
let columnCursor = 0;
|
|
61854
|
+
templateRow.content.content.forEach((cellNode, cellIndex) => {
|
|
61855
|
+
const isHeaderCell = cellNode.type === HeaderType;
|
|
61856
|
+
const targetCellType = isHeaderCell ? CellType : cellNode.type;
|
|
61857
|
+
const attrs = { ...cellNode.attrs };
|
|
61858
|
+
const formatting = extractRowTemplateFormatting(cellNode, schema);
|
|
61859
|
+
let cellValue = "";
|
|
61860
|
+
if (byColumns) {
|
|
61861
|
+
const span = Math.max(1, attrs.colspan || 1);
|
|
61862
|
+
cellValue = values[columnCursor] ?? "";
|
|
61863
|
+
columnCursor += span;
|
|
61864
|
+
} else {
|
|
61865
|
+
cellValue = Array.isArray(values) ? values[cellIndex] ?? "" : "";
|
|
61866
|
+
}
|
|
61867
|
+
const content = buildFormattedCellBlock(schema, cellValue, formatting, copyRowStyle);
|
|
61868
|
+
const newCell = targetCellType.createAndFill(attrs, content);
|
|
61869
|
+
if (newCell) newCells.push(newCell);
|
|
61870
|
+
});
|
|
61871
|
+
return RowType.createAndFill(null, newCells);
|
|
61872
|
+
}
|
|
61873
|
+
function insertRowsAtTableEnd({ tr, tablePos, tableNode, rows }) {
|
|
61874
|
+
if (!rows || !rows.length) return;
|
|
61875
|
+
const RowTypeName = "tableRow";
|
|
61876
|
+
let lastRowRelPos = 0;
|
|
61877
|
+
let lastRowNode = null;
|
|
61878
|
+
tableNode.descendants((child, relPos) => {
|
|
61879
|
+
if (child.type.name === RowTypeName) {
|
|
61880
|
+
lastRowRelPos = relPos;
|
|
61881
|
+
lastRowNode = child;
|
|
61882
|
+
}
|
|
61883
|
+
});
|
|
61884
|
+
if (!lastRowNode) return;
|
|
61885
|
+
const lastRowAbsEnd = tablePos + 1 + lastRowRelPos + lastRowNode.nodeSize;
|
|
61886
|
+
const frag = Fragment.fromArray(rows);
|
|
61887
|
+
tr.insert(lastRowAbsEnd, frag);
|
|
61888
|
+
}
|
|
61743
61889
|
const Table = Node$1.create({
|
|
61744
61890
|
name: "table",
|
|
61745
61891
|
content: "tableRow+",
|
|
@@ -61899,6 +62045,47 @@ const Table = Node$1.create({
|
|
|
61899
62045
|
},
|
|
61900
62046
|
addCommands() {
|
|
61901
62047
|
return {
|
|
62048
|
+
/**
|
|
62049
|
+
* Append multiple rows to the end of a table in a single transaction.
|
|
62050
|
+
* @category Command
|
|
62051
|
+
* @param {appendRowsWithContentOptions} options - Append configuration
|
|
62052
|
+
* @example
|
|
62053
|
+
* editor.commands.appendRowsWithContent({ tablePos, valueRows: [['A','B'], ['C','D']], copyRowStyle: true })
|
|
62054
|
+
*/
|
|
62055
|
+
appendRowsWithContent: ({ tablePos, tableNode, valueRows = [], copyRowStyle = false }) => ({ editor, chain }) => {
|
|
62056
|
+
if (typeof tablePos !== "number" && !tableNode || !Array.isArray(valueRows) || !valueRows.length) {
|
|
62057
|
+
return false;
|
|
62058
|
+
}
|
|
62059
|
+
return chain().command(({ tr, dispatch }) => {
|
|
62060
|
+
const workingTable = resolveTable(tr, tablePos, tableNode);
|
|
62061
|
+
if (!workingTable) return false;
|
|
62062
|
+
const templateRow = pickTemplateRowForAppend(workingTable, editor.schema);
|
|
62063
|
+
if (!templateRow) return false;
|
|
62064
|
+
const newRows = valueRows.map(
|
|
62065
|
+
(vals) => buildRowFromTemplateRow({
|
|
62066
|
+
schema: editor.schema,
|
|
62067
|
+
tableNode: workingTable,
|
|
62068
|
+
templateRow,
|
|
62069
|
+
values: vals,
|
|
62070
|
+
copyRowStyle
|
|
62071
|
+
})
|
|
62072
|
+
).filter(Boolean);
|
|
62073
|
+
if (!newRows.length) return false;
|
|
62074
|
+
let resolvedTablePos = tablePos;
|
|
62075
|
+
if (typeof resolvedTablePos !== "number" && workingTable) {
|
|
62076
|
+
const tables = editor.getNodesOfType("table");
|
|
62077
|
+
const match = workingTable ? tables.find((t) => t.node.eq(workingTable)) : tables[0];
|
|
62078
|
+
resolvedTablePos = match?.pos ?? null;
|
|
62079
|
+
}
|
|
62080
|
+
if (typeof resolvedTablePos !== "number") {
|
|
62081
|
+
return false;
|
|
62082
|
+
}
|
|
62083
|
+
if (dispatch) {
|
|
62084
|
+
insertRowsAtTableEnd({ tr, tablePos, tableNode: workingTable, rows: newRows });
|
|
62085
|
+
}
|
|
62086
|
+
return true;
|
|
62087
|
+
}).run();
|
|
62088
|
+
},
|
|
61902
62089
|
/**
|
|
61903
62090
|
* Insert a new table into the document
|
|
61904
62091
|
* @category Command
|
|
@@ -64805,58 +64992,6 @@ const registerImages = async (foundImages, editor, view) => {
|
|
|
64805
64992
|
}
|
|
64806
64993
|
});
|
|
64807
64994
|
};
|
|
64808
|
-
const normalizeWrap = (attrs = {}) => {
|
|
64809
|
-
const wrap2 = attrs.wrap;
|
|
64810
|
-
if (wrap2?.type && wrap2.type !== "Inline") {
|
|
64811
|
-
return {
|
|
64812
|
-
type: wrap2.type,
|
|
64813
|
-
attrs: wrap2.attrs ?? {}
|
|
64814
|
-
};
|
|
64815
|
-
}
|
|
64816
|
-
if (wrap2?.type === "Inline" && Object.keys(wrap2.attrs ?? {}).length) {
|
|
64817
|
-
return {
|
|
64818
|
-
type: "Inline",
|
|
64819
|
-
attrs: wrap2.attrs
|
|
64820
|
-
};
|
|
64821
|
-
}
|
|
64822
|
-
if (!wrap2 && attrs.wrapText) {
|
|
64823
|
-
return {
|
|
64824
|
-
type: "Square",
|
|
64825
|
-
attrs: {
|
|
64826
|
-
wrapText: attrs.wrapText
|
|
64827
|
-
}
|
|
64828
|
-
};
|
|
64829
|
-
}
|
|
64830
|
-
if (!wrap2 && attrs.wrapTopAndBottom) {
|
|
64831
|
-
return {
|
|
64832
|
-
type: "TopAndBottom",
|
|
64833
|
-
attrs: {}
|
|
64834
|
-
};
|
|
64835
|
-
}
|
|
64836
|
-
if (wrap2?.type === "Inline") {
|
|
64837
|
-
return {
|
|
64838
|
-
type: "Inline",
|
|
64839
|
-
attrs: wrap2.attrs ?? {}
|
|
64840
|
-
};
|
|
64841
|
-
}
|
|
64842
|
-
return {
|
|
64843
|
-
type: "Inline",
|
|
64844
|
-
attrs: {}
|
|
64845
|
-
};
|
|
64846
|
-
};
|
|
64847
|
-
const normalizeMarginOffset = (marginOffset = {}) => {
|
|
64848
|
-
const { left: left2, horizontal, ...rest } = marginOffset;
|
|
64849
|
-
return {
|
|
64850
|
-
...rest,
|
|
64851
|
-
horizontal: horizontal ?? left2
|
|
64852
|
-
};
|
|
64853
|
-
};
|
|
64854
|
-
const getNormalizedImageAttrs = (attrs = {}) => {
|
|
64855
|
-
return {
|
|
64856
|
-
wrap: normalizeWrap(attrs),
|
|
64857
|
-
marginOffset: normalizeMarginOffset(attrs.marginOffset ?? {})
|
|
64858
|
-
};
|
|
64859
|
-
};
|
|
64860
64995
|
const ImagePositionPluginKey = new PluginKey("ImagePosition");
|
|
64861
64996
|
const ImagePositionPlugin = ({ editor }) => {
|
|
64862
64997
|
const { view } = editor;
|
|
@@ -64869,8 +65004,9 @@ const ImagePositionPlugin = ({ editor }) => {
|
|
|
64869
65004
|
return DecorationSet.empty;
|
|
64870
65005
|
},
|
|
64871
65006
|
apply(tr, oldDecorationSet, oldState, newState) {
|
|
64872
|
-
if (!tr.docChanged) return oldDecorationSet;
|
|
65007
|
+
if (!tr.docChanged && !shouldUpdate) return oldDecorationSet;
|
|
64873
65008
|
const decorations = getImagePositionDecorations(newState, view);
|
|
65009
|
+
shouldUpdate = false;
|
|
64874
65010
|
return DecorationSet.create(newState.doc, decorations);
|
|
64875
65011
|
}
|
|
64876
65012
|
},
|
|
@@ -64879,7 +65015,6 @@ const ImagePositionPlugin = ({ editor }) => {
|
|
|
64879
65015
|
update: (view2, lastState) => {
|
|
64880
65016
|
const pagination = PaginationPluginKey.getState(lastState);
|
|
64881
65017
|
if (shouldUpdate) {
|
|
64882
|
-
shouldUpdate = false;
|
|
64883
65018
|
const decorations = getImagePositionDecorations(lastState, view2);
|
|
64884
65019
|
const updateTransaction = view2.state.tr.setMeta(ImagePositionPluginKey, { decorations });
|
|
64885
65020
|
view2.dispatch(updateTransaction);
|
|
@@ -64905,41 +65040,35 @@ const getImagePositionDecorations = (state2, view) => {
|
|
|
64905
65040
|
let className = "";
|
|
64906
65041
|
const { vRelativeFrom, alignH } = node.attrs.anchorData;
|
|
64907
65042
|
const { size: size2, padding } = node.attrs;
|
|
64908
|
-
const { marginOffset } = getNormalizedImageAttrs(node.attrs);
|
|
64909
65043
|
const pageBreak = findPreviousDomNodeWithClass(view, pos, "pagination-break-wrapper");
|
|
64910
|
-
if (pageBreak) {
|
|
64911
|
-
|
|
64912
|
-
|
|
64913
|
-
|
|
64914
|
-
|
|
64915
|
-
|
|
64916
|
-
|
|
64917
|
-
|
|
64918
|
-
|
|
64919
|
-
|
|
64920
|
-
|
|
65044
|
+
if (pageBreak && vRelativeFrom === "margin" && alignH) {
|
|
65045
|
+
const topPos = pageBreak?.offsetTop + pageBreak?.offsetHeight;
|
|
65046
|
+
let horizontalAlignment = `${alignH}: 0;`;
|
|
65047
|
+
if (alignH === "center") horizontalAlignment = "left: 50%; transform: translateX(-50%);";
|
|
65048
|
+
style2 += vRelativeFrom === "margin" ? `position: absolute; top: ${topPos}px; ${horizontalAlignment}` : "";
|
|
65049
|
+
const nextPos = view.posAtDOM(pageBreak, 1);
|
|
65050
|
+
if (nextPos < 0) {
|
|
65051
|
+
const $pos = view.state.doc.resolve(pos);
|
|
65052
|
+
decorations.push(
|
|
65053
|
+
Decoration.node(pos - 1, pos + $pos.parent.nodeSize - 1, {
|
|
65054
|
+
style: `height: ${size2.height + parseInt(padding.top) + parseInt(padding.bottom)}px`
|
|
65055
|
+
})
|
|
65056
|
+
);
|
|
64921
65057
|
}
|
|
64922
|
-
const
|
|
64923
|
-
|
|
64924
|
-
|
|
64925
|
-
|
|
64926
|
-
|
|
64927
|
-
|
|
64928
|
-
|
|
64929
|
-
|
|
64930
|
-
style: `height: ${size2.height + parseInt(padding.top) + parseInt(padding.bottom)}px`
|
|
64931
|
-
})
|
|
64932
|
-
);
|
|
64933
|
-
}
|
|
64934
|
-
const imageBlock = document.createElement("div");
|
|
64935
|
-
imageBlock.className = "anchor-image-placeholder";
|
|
64936
|
-
imageBlock.style.float = alignH;
|
|
64937
|
-
imageBlock.style.width = size2.width + parseInt(padding[alignH]) + "px";
|
|
64938
|
-
imageBlock.style.height = size2.height + parseInt(padding.top) + parseInt(padding.bottom) + "px";
|
|
64939
|
-
decorations.push(Decoration.widget(nextPos, imageBlock, { key: "stable-key" }));
|
|
65058
|
+
const imageBlock = document.createElement("div");
|
|
65059
|
+
imageBlock.className = "anchor-image-placeholder";
|
|
65060
|
+
imageBlock.style.float = alignH === "left" || alignH === "right" ? alignH : "none";
|
|
65061
|
+
let paddingHorizontal;
|
|
65062
|
+
if (alignH === "center") {
|
|
65063
|
+
paddingHorizontal = (parseInt(padding.left) || 0) + (parseInt(padding.right) || 0);
|
|
65064
|
+
} else {
|
|
65065
|
+
paddingHorizontal = parseInt(padding[alignH]) || 0;
|
|
64940
65066
|
}
|
|
65067
|
+
imageBlock.style.width = size2.width + paddingHorizontal + "px";
|
|
65068
|
+
imageBlock.style.height = size2.height + parseInt(padding.top) + parseInt(padding.bottom) + "px";
|
|
65069
|
+
decorations.push(Decoration.widget(nextPos, imageBlock, { key: "stable-key" }));
|
|
65070
|
+
decorations.push(Decoration.inline(pos, pos + node.nodeSize, { style: style2, class: className }));
|
|
64941
65071
|
}
|
|
64942
|
-
decorations.push(Decoration.inline(pos, pos + node.nodeSize, { style: style2, class: className }));
|
|
64943
65072
|
}
|
|
64944
65073
|
});
|
|
64945
65074
|
return decorations;
|
|
@@ -64964,6 +65093,58 @@ const findPreviousDomNodeWithClass = (view, pos, className) => {
|
|
|
64964
65093
|
}
|
|
64965
65094
|
return null;
|
|
64966
65095
|
};
|
|
65096
|
+
const normalizeWrap = (attrs = {}) => {
|
|
65097
|
+
const wrap2 = attrs.wrap;
|
|
65098
|
+
if (wrap2?.type && wrap2.type !== "Inline") {
|
|
65099
|
+
return {
|
|
65100
|
+
type: wrap2.type,
|
|
65101
|
+
attrs: wrap2.attrs ?? {}
|
|
65102
|
+
};
|
|
65103
|
+
}
|
|
65104
|
+
if (wrap2?.type === "Inline" && Object.keys(wrap2.attrs ?? {}).length) {
|
|
65105
|
+
return {
|
|
65106
|
+
type: "Inline",
|
|
65107
|
+
attrs: wrap2.attrs
|
|
65108
|
+
};
|
|
65109
|
+
}
|
|
65110
|
+
if (!wrap2 && attrs.wrapText) {
|
|
65111
|
+
return {
|
|
65112
|
+
type: "Square",
|
|
65113
|
+
attrs: {
|
|
65114
|
+
wrapText: attrs.wrapText
|
|
65115
|
+
}
|
|
65116
|
+
};
|
|
65117
|
+
}
|
|
65118
|
+
if (!wrap2 && attrs.wrapTopAndBottom) {
|
|
65119
|
+
return {
|
|
65120
|
+
type: "TopAndBottom",
|
|
65121
|
+
attrs: {}
|
|
65122
|
+
};
|
|
65123
|
+
}
|
|
65124
|
+
if (wrap2?.type === "Inline") {
|
|
65125
|
+
return {
|
|
65126
|
+
type: "Inline",
|
|
65127
|
+
attrs: wrap2.attrs ?? {}
|
|
65128
|
+
};
|
|
65129
|
+
}
|
|
65130
|
+
return {
|
|
65131
|
+
type: "Inline",
|
|
65132
|
+
attrs: {}
|
|
65133
|
+
};
|
|
65134
|
+
};
|
|
65135
|
+
const normalizeMarginOffset = (marginOffset = {}) => {
|
|
65136
|
+
const { left: left2, horizontal, ...rest } = marginOffset;
|
|
65137
|
+
return {
|
|
65138
|
+
...rest,
|
|
65139
|
+
horizontal: horizontal ?? left2
|
|
65140
|
+
};
|
|
65141
|
+
};
|
|
65142
|
+
const getNormalizedImageAttrs = (attrs = {}) => {
|
|
65143
|
+
return {
|
|
65144
|
+
wrap: normalizeWrap(attrs),
|
|
65145
|
+
marginOffset: normalizeMarginOffset(attrs.marginOffset ?? {})
|
|
65146
|
+
};
|
|
65147
|
+
};
|
|
64967
65148
|
const getRotationMargins = (w2, h2, angleDegrees) => {
|
|
64968
65149
|
const rad = angleDegrees * (Math.PI / 180);
|
|
64969
65150
|
const cos = Math.abs(Math.cos(rad));
|
|
@@ -65172,27 +65353,15 @@ const Image = Node$1.create({
|
|
|
65172
65353
|
style2 += "float: right;";
|
|
65173
65354
|
floatRight = true;
|
|
65174
65355
|
} else if (["largest", "bothSides"].includes(attrs.wrapText)) {
|
|
65175
|
-
const
|
|
65176
|
-
|
|
65177
|
-
|
|
65178
|
-
|
|
65179
|
-
|
|
65180
|
-
|
|
65181
|
-
|
|
65182
|
-
|
|
65183
|
-
|
|
65184
|
-
if (rightSpace < 0) {
|
|
65185
|
-
style2 += "float: left;";
|
|
65186
|
-
} else if (rightSpace > leftSpace) {
|
|
65187
|
-
style2 += "float: left;";
|
|
65188
|
-
} else {
|
|
65189
|
-
style2 += "float: right;";
|
|
65190
|
-
floatRight = true;
|
|
65191
|
-
baseHorizontal = rightSpace;
|
|
65192
|
-
}
|
|
65193
|
-
} else {
|
|
65194
|
-
style2 += "float: left;";
|
|
65195
|
-
}
|
|
65356
|
+
const pageStylesData2 = getDataFromPageStyles({
|
|
65357
|
+
editor: this.editor,
|
|
65358
|
+
marginOffset,
|
|
65359
|
+
size: size2,
|
|
65360
|
+
attrs
|
|
65361
|
+
});
|
|
65362
|
+
style2 += pageStylesData2.style;
|
|
65363
|
+
floatRight = pageStylesData2.floatRight;
|
|
65364
|
+
baseHorizontal = pageStylesData2.baseHorizontal;
|
|
65196
65365
|
}
|
|
65197
65366
|
if (attrs.distTop) margin.top += attrs.distTop;
|
|
65198
65367
|
if (attrs.distBottom) margin.bottom += attrs.distBottom;
|
|
@@ -65202,27 +65371,15 @@ const Image = Node$1.create({
|
|
|
65202
65371
|
case "Through":
|
|
65203
65372
|
case "Tight":
|
|
65204
65373
|
style2 += "clear: both;";
|
|
65205
|
-
const
|
|
65206
|
-
|
|
65207
|
-
|
|
65208
|
-
|
|
65209
|
-
|
|
65210
|
-
|
|
65211
|
-
|
|
65212
|
-
|
|
65213
|
-
|
|
65214
|
-
if (rightSpace < 0) {
|
|
65215
|
-
style2 += "float: left;";
|
|
65216
|
-
} else if (rightSpace > leftSpace) {
|
|
65217
|
-
style2 += "float: left;";
|
|
65218
|
-
} else {
|
|
65219
|
-
style2 += "float: right;";
|
|
65220
|
-
floatRight = true;
|
|
65221
|
-
baseHorizontal = rightSpace;
|
|
65222
|
-
}
|
|
65223
|
-
} else {
|
|
65224
|
-
style2 += "float: left;";
|
|
65225
|
-
}
|
|
65374
|
+
const pageStylesData = getDataFromPageStyles({
|
|
65375
|
+
editor: this.editor,
|
|
65376
|
+
marginOffset,
|
|
65377
|
+
size: size2,
|
|
65378
|
+
attrs
|
|
65379
|
+
});
|
|
65380
|
+
style2 += pageStylesData.style;
|
|
65381
|
+
floatRight = pageStylesData.floatRight;
|
|
65382
|
+
baseHorizontal = pageStylesData.baseHorizontal;
|
|
65226
65383
|
if (attrs.distTop) margin.top += attrs.distTop;
|
|
65227
65384
|
if (attrs.distBottom) margin.bottom += attrs.distBottom;
|
|
65228
65385
|
if (attrs.distLeft) margin.left += attrs.distLeft;
|
|
@@ -65259,6 +65416,22 @@ const Image = Node$1.create({
|
|
|
65259
65416
|
}
|
|
65260
65417
|
const hasAnchorData = Boolean(anchorData);
|
|
65261
65418
|
const hasMarginOffsets = marginOffset?.horizontal != null || marginOffset?.top != null;
|
|
65419
|
+
if (hasAnchorData) {
|
|
65420
|
+
switch (anchorData.hRelativeFrom) {
|
|
65421
|
+
case "page":
|
|
65422
|
+
const pageStyles = this.editor?.converter?.pageStyles || this.editor?.options.parentEditor?.converter?.pageStyles;
|
|
65423
|
+
margin.left -= inchesToPixels(pageStyles?.pageMargins?.left) || 0;
|
|
65424
|
+
break;
|
|
65425
|
+
case "margin":
|
|
65426
|
+
if (anchorData.alignH === "center") {
|
|
65427
|
+
style2 += "position: absolute; left: 50%; transform: translateX(-50%);";
|
|
65428
|
+
}
|
|
65429
|
+
if (anchorData.alignH === "left" || anchorData.alignH === "right") {
|
|
65430
|
+
style2 += `position: absolute; ${anchorData.alignH}: 0;`;
|
|
65431
|
+
}
|
|
65432
|
+
break;
|
|
65433
|
+
}
|
|
65434
|
+
}
|
|
65262
65435
|
if (hasAnchorData || hasMarginOffsets) {
|
|
65263
65436
|
const relativeFromPageV = anchorData?.vRelativeFrom === "page";
|
|
65264
65437
|
const maxMarginV = 500;
|
|
@@ -65407,6 +65580,37 @@ const Image = Node$1.create({
|
|
|
65407
65580
|
return [ImageRegistrationPlugin({ editor: this.editor }), ImagePositionPlugin({ editor: this.editor })];
|
|
65408
65581
|
}
|
|
65409
65582
|
});
|
|
65583
|
+
const getDataFromPageStyles = ({ editor, marginOffset, size: size2, attrs }) => {
|
|
65584
|
+
let style2 = "";
|
|
65585
|
+
let floatRight = false;
|
|
65586
|
+
let baseHorizontal = marginOffset?.horizontal || 0;
|
|
65587
|
+
const pageStyles = editor?.converter?.pageStyles || editor?.options.parentEditor?.converter?.pageStyles;
|
|
65588
|
+
if (pageStyles?.pageSize && pageStyles?.pageMargins && size2.width) {
|
|
65589
|
+
const pageWidth = inchesToPixels(pageStyles.pageSize.width);
|
|
65590
|
+
const leftMargin = inchesToPixels(pageStyles.pageMargins.left);
|
|
65591
|
+
const rightMargin = inchesToPixels(pageStyles.pageMargins.right);
|
|
65592
|
+
const contentWidth = pageWidth - leftMargin - rightMargin;
|
|
65593
|
+
const imageWidth = size2.width + (attrs.distLeft || 0) + (attrs.distRight || 0);
|
|
65594
|
+
const leftSpace = marginOffset.horizontal;
|
|
65595
|
+
const rightSpace = contentWidth - leftSpace - imageWidth;
|
|
65596
|
+
if (rightSpace < 0) {
|
|
65597
|
+
style2 += "float: left;";
|
|
65598
|
+
} else if (rightSpace > leftSpace) {
|
|
65599
|
+
style2 += "float: left;";
|
|
65600
|
+
} else {
|
|
65601
|
+
style2 += "float: right;";
|
|
65602
|
+
floatRight = true;
|
|
65603
|
+
baseHorizontal = rightSpace;
|
|
65604
|
+
}
|
|
65605
|
+
} else {
|
|
65606
|
+
style2 += "float: left;";
|
|
65607
|
+
}
|
|
65608
|
+
return {
|
|
65609
|
+
style: style2,
|
|
65610
|
+
floatRight,
|
|
65611
|
+
baseHorizontal
|
|
65612
|
+
};
|
|
65613
|
+
};
|
|
65410
65614
|
const ACCEPT_IMAGE_TYPES = [".jpg", ".jpeg", ".png", "image/jpeg", "image/png"];
|
|
65411
65615
|
const getFileOpener = () => {
|
|
65412
65616
|
let fileInput = document.createElement("input");
|
|
@@ -67528,6 +67732,15 @@ const TrackChanges = Extension.create({
|
|
|
67528
67732
|
const { from: from2, to } = state2.selection;
|
|
67529
67733
|
return commands2.acceptTrackedChangesBetween(from2, to);
|
|
67530
67734
|
},
|
|
67735
|
+
acceptTrackedChangeFromToolbar: () => ({ state: state2, commands: commands2 }) => {
|
|
67736
|
+
const commentsPluginState = CommentsPluginKey.getState(state2);
|
|
67737
|
+
const activeThreadId = commentsPluginState?.activeThreadId;
|
|
67738
|
+
if (activeThreadId && commentsPluginState?.trackedChanges?.[activeThreadId]) {
|
|
67739
|
+
return commands2.acceptTrackedChangeById(activeThreadId);
|
|
67740
|
+
} else {
|
|
67741
|
+
return commands2.acceptTrackedChangeBySelection();
|
|
67742
|
+
}
|
|
67743
|
+
},
|
|
67531
67744
|
acceptTrackedChangeById: (id) => ({ state: state2, tr, commands: commands2 }) => {
|
|
67532
67745
|
const toResolve = getChangesByIdToResolve(state2, id) || [];
|
|
67533
67746
|
return toResolve.map(({ from: from2, to }) => {
|
|
@@ -67556,6 +67769,15 @@ const TrackChanges = Extension.create({
|
|
|
67556
67769
|
const { from: from2, to } = state2.selection;
|
|
67557
67770
|
return commands2.rejectTrackedChangesBetween(from2, to);
|
|
67558
67771
|
},
|
|
67772
|
+
rejectTrackedChangeFromToolbar: () => ({ state: state2, commands: commands2 }) => {
|
|
67773
|
+
const commentsPluginState = CommentsPluginKey.getState(state2);
|
|
67774
|
+
const activeThreadId = commentsPluginState?.activeThreadId;
|
|
67775
|
+
if (activeThreadId && commentsPluginState?.trackedChanges?.[activeThreadId]) {
|
|
67776
|
+
return commands2.rejectTrackedChangeById(activeThreadId);
|
|
67777
|
+
} else {
|
|
67778
|
+
return commands2.rejectTrackedChangeOnSelection();
|
|
67779
|
+
}
|
|
67780
|
+
},
|
|
67559
67781
|
rejectAllTrackedChanges: () => ({ state: state2, commands: commands2 }) => {
|
|
67560
67782
|
const from2 = 0, to = state2.doc.content.size;
|
|
67561
67783
|
return commands2.rejectTrackedChangesBetween(from2, to);
|
|
@@ -72849,7 +73071,7 @@ const nodeResizer = (nodeNames = ["image"], editor) => {
|
|
|
72849
73071
|
return oldState;
|
|
72850
73072
|
}
|
|
72851
73073
|
if (typeof document === "undefined" || editor.options.isHeadless) return oldState;
|
|
72852
|
-
if (editor.options.documentMode === "viewing" || !editor.isEditable) {
|
|
73074
|
+
if (!editor.options.isHeaderOrFooter && (editor.options.documentMode === "viewing" || !editor.isEditable)) {
|
|
72853
73075
|
return DecorationSet.empty;
|
|
72854
73076
|
}
|
|
72855
73077
|
const { selection } = newState;
|
|
@@ -85958,7 +86180,7 @@ const makeDefaultItems = ({
|
|
|
85958
86180
|
disabled: false,
|
|
85959
86181
|
name: "acceptTrackedChangeBySelection",
|
|
85960
86182
|
tooltip: toolbarTexts2.trackChangesAccept,
|
|
85961
|
-
command: "
|
|
86183
|
+
command: "acceptTrackedChangeFromToolbar",
|
|
85962
86184
|
icon: toolbarIcons2.trackChangesAccept,
|
|
85963
86185
|
group: "left",
|
|
85964
86186
|
attributes: {
|
|
@@ -85970,7 +86192,7 @@ const makeDefaultItems = ({
|
|
|
85970
86192
|
disabled: false,
|
|
85971
86193
|
name: "rejectTrackedChangeOnSelection",
|
|
85972
86194
|
tooltip: toolbarTexts2.trackChangesReject,
|
|
85973
|
-
command: "
|
|
86195
|
+
command: "rejectTrackedChangeFromToolbar",
|
|
85974
86196
|
icon: toolbarIcons2.trackChangesReject,
|
|
85975
86197
|
group: "left",
|
|
85976
86198
|
attributes: {
|
|
@@ -88991,8 +89213,12 @@ const Extensions = {
|
|
|
88991
89213
|
Node: Node$1,
|
|
88992
89214
|
Attribute: Attribute2,
|
|
88993
89215
|
Extension,
|
|
89216
|
+
Mark: Mark2,
|
|
89217
|
+
//
|
|
88994
89218
|
Plugin,
|
|
88995
|
-
|
|
89219
|
+
PluginKey,
|
|
89220
|
+
Decoration,
|
|
89221
|
+
DecorationSet
|
|
88996
89222
|
};
|
|
88997
89223
|
exports.AIWriter = AIWriter;
|
|
88998
89224
|
exports.AnnotatorHelpers = AnnotatorHelpers;
|