@harbour-enterprises/superdoc 0.25.0 → 0.26.0-next.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/{PdfViewer-Y13XRanw.es.js → PdfViewer-BUDqeNx7.es.js} +1 -1
- package/dist/chunks/{PdfViewer-DDL0V0l5.cjs → PdfViewer-Bk6eeTRu.cjs} +1 -1
- package/dist/chunks/{index-Bo5YCvD5.cjs → index-W-nB4woH.cjs} +19 -3
- package/dist/chunks/{index-DKNVSdr6.es.js → index-kTEBpqiG.es.js} +19 -3
- package/dist/chunks/{super-editor.es-Ct2sXbNV.cjs → super-editor.es-C74O3hXJ.cjs} +484 -253
- package/dist/chunks/{super-editor.es-CYtLh0Ob.es.js → super-editor.es-DznCuGcp.es.js} +484 -253
- package/dist/core/SuperDoc.d.ts.map +1 -1
- 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-wd9pvfTV.js} +421 -192
- package/dist/super-editor/chunks/{toolbar-BTw9-jfX.js → toolbar-CWJmT_bY.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 +501 -254
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -32315,8 +32315,7 @@ const bookmarkEndNodeHandlerEntity = {
|
|
|
32315
32315
|
handlerName: "w:bookmarkEndTranslator",
|
|
32316
32316
|
handler: handleBookmarkEndNode
|
|
32317
32317
|
};
|
|
32318
|
-
const
|
|
32319
|
-
const SUPPORTED_REQUIRES = /* @__PURE__ */ new Set([
|
|
32318
|
+
const SUPPORTED_ALTERNATE_CONTENT_REQUIRES = /* @__PURE__ */ new Set([
|
|
32320
32319
|
"wps",
|
|
32321
32320
|
"wp14",
|
|
32322
32321
|
"w14",
|
|
@@ -32329,22 +32328,85 @@ const SUPPORTED_REQUIRES = /* @__PURE__ */ new Set([
|
|
|
32329
32328
|
"w16sdtfl",
|
|
32330
32329
|
"w16se"
|
|
32331
32330
|
]);
|
|
32331
|
+
const XML_NODE_NAME$1 = "mc:AlternateContent";
|
|
32332
|
+
const SD_NODE_NAME$1 = [];
|
|
32333
|
+
const validXmlAttributes$1 = [];
|
|
32334
|
+
function encode$1(params2) {
|
|
32335
|
+
const { nodeListHandler } = params2;
|
|
32336
|
+
const { node } = params2.extraParams;
|
|
32337
|
+
if (!node || !node.type) {
|
|
32338
|
+
return null;
|
|
32339
|
+
}
|
|
32340
|
+
const { branch, elements } = selectAlternateContentElements(node);
|
|
32341
|
+
if (!elements) {
|
|
32342
|
+
return null;
|
|
32343
|
+
}
|
|
32344
|
+
return nodeListHandler.handler({
|
|
32345
|
+
...params2,
|
|
32346
|
+
nodes: elements,
|
|
32347
|
+
path: buildPath(params2.path, node, branch)
|
|
32348
|
+
});
|
|
32349
|
+
}
|
|
32350
|
+
function decode$1(params2) {
|
|
32351
|
+
const { node } = params2;
|
|
32352
|
+
const { drawingContent } = node.attrs;
|
|
32353
|
+
const drawing = {
|
|
32354
|
+
name: "w:drawing",
|
|
32355
|
+
elements: [...drawingContent ? [...drawingContent.elements || []] : []]
|
|
32356
|
+
};
|
|
32357
|
+
const choice = {
|
|
32358
|
+
name: "mc:Choice",
|
|
32359
|
+
attributes: { Requires: "wps" },
|
|
32360
|
+
elements: [drawing]
|
|
32361
|
+
};
|
|
32362
|
+
return {
|
|
32363
|
+
name: "mc:AlternateContent",
|
|
32364
|
+
elements: [choice]
|
|
32365
|
+
};
|
|
32366
|
+
}
|
|
32367
|
+
const config$1 = {
|
|
32368
|
+
xmlName: XML_NODE_NAME$1,
|
|
32369
|
+
sdNodeOrKeyName: SD_NODE_NAME$1,
|
|
32370
|
+
type: NodeTranslator.translatorTypes.NODE,
|
|
32371
|
+
encode: encode$1,
|
|
32372
|
+
decode: decode$1,
|
|
32373
|
+
attributes: validXmlAttributes$1
|
|
32374
|
+
};
|
|
32375
|
+
function selectAlternateContentElements(node) {
|
|
32376
|
+
if (!node?.elements?.length) {
|
|
32377
|
+
return { branch: null, elements: null };
|
|
32378
|
+
}
|
|
32379
|
+
const choices = node.elements.filter((el) => el?.name === "mc:Choice");
|
|
32380
|
+
const fallback = node.elements.find((el) => el?.name === "mc:Fallback");
|
|
32381
|
+
const supportedChoice = choices.find((choice) => {
|
|
32382
|
+
const requiresAttr = choice?.attributes?.Requires || choice?.attributes?.requires;
|
|
32383
|
+
if (!requiresAttr) return false;
|
|
32384
|
+
return requiresAttr.split(/\s+/).filter(Boolean).some((namespace2) => SUPPORTED_ALTERNATE_CONTENT_REQUIRES.has(namespace2));
|
|
32385
|
+
});
|
|
32386
|
+
const branch = supportedChoice || fallback || choices[0] || null;
|
|
32387
|
+
const selectedElements = branch?.elements;
|
|
32388
|
+
if (!selectedElements) {
|
|
32389
|
+
return { branch, elements: null };
|
|
32390
|
+
}
|
|
32391
|
+
return {
|
|
32392
|
+
branch,
|
|
32393
|
+
elements: carbonCopy(selectedElements)
|
|
32394
|
+
};
|
|
32395
|
+
}
|
|
32396
|
+
const translator$1 = NodeTranslator.from(config$1);
|
|
32397
|
+
function buildPath(existingPath = [], node, branch) {
|
|
32398
|
+
const path = [...existingPath];
|
|
32399
|
+
if (node) path.push(node);
|
|
32400
|
+
if (branch) path.push(branch);
|
|
32401
|
+
return path;
|
|
32402
|
+
}
|
|
32403
|
+
const ALTERNATE_CONTENT_NODE = "mc:AlternateContent";
|
|
32332
32404
|
const skipHandlerResponse = { nodes: [], consumed: 0 };
|
|
32333
32405
|
const isAlternateContentNode = (node) => node?.name === ALTERNATE_CONTENT_NODE;
|
|
32334
|
-
const isSupportedChoice = (choice) => {
|
|
32335
|
-
if (!choice?.attributes) return false;
|
|
32336
|
-
const requires = choice.attributes.Requires || choice.attributes.requires;
|
|
32337
|
-
if (!requires) return false;
|
|
32338
|
-
return requires.split(/\s+/).filter(Boolean).some((namespace2) => SUPPORTED_REQUIRES.has(namespace2));
|
|
32339
|
-
};
|
|
32340
32406
|
const resolveAlternateContentElements = (alternateContent) => {
|
|
32341
|
-
|
|
32342
|
-
|
|
32343
|
-
|
|
32344
|
-
const supportedChoice = choices.find(isSupportedChoice);
|
|
32345
|
-
const selectedElements = supportedChoice?.elements || fallback?.elements || choices[0]?.elements;
|
|
32346
|
-
if (!selectedElements) return null;
|
|
32347
|
-
return carbonCopy(selectedElements);
|
|
32407
|
+
const { elements } = selectAlternateContentElements(alternateContent);
|
|
32408
|
+
if (!elements) return null;
|
|
32409
|
+
return elements;
|
|
32348
32410
|
};
|
|
32349
32411
|
const buildNodeWithoutAlternateContent = (node) => {
|
|
32350
32412
|
const { elements } = node || {};
|
|
@@ -32376,16 +32438,20 @@ const handleAlternateChoice = (params2) => {
|
|
|
32376
32438
|
}
|
|
32377
32439
|
const [currentNode] = nodes;
|
|
32378
32440
|
if (isAlternateContentNode(currentNode)) {
|
|
32379
|
-
const
|
|
32380
|
-
|
|
32381
|
-
|
|
32382
|
-
}
|
|
32383
|
-
const
|
|
32441
|
+
const nodeForTranslator = currentNode?.type ? currentNode : {
|
|
32442
|
+
...currentNode,
|
|
32443
|
+
type: "element"
|
|
32444
|
+
};
|
|
32445
|
+
const translated = translator$1.encode({
|
|
32384
32446
|
...params2,
|
|
32385
|
-
nodes:
|
|
32386
|
-
|
|
32447
|
+
nodes: [nodeForTranslator],
|
|
32448
|
+
extraParams: { ...params2.extraParams || {}, node: nodeForTranslator }
|
|
32387
32449
|
});
|
|
32388
|
-
|
|
32450
|
+
if (!translated) {
|
|
32451
|
+
return skipHandlerResponse;
|
|
32452
|
+
}
|
|
32453
|
+
const nodesArray = Array.isArray(translated) ? translated : [translated];
|
|
32454
|
+
return { nodes: nodesArray, consumed: 1 };
|
|
32389
32455
|
}
|
|
32390
32456
|
const sanitizedNode = buildNodeWithoutAlternateContent(currentNode);
|
|
32391
32457
|
if (!sanitizedNode) {
|
|
@@ -33683,55 +33749,6 @@ function translateShapeTextbox(params2) {
|
|
|
33683
33749
|
};
|
|
33684
33750
|
return textbox;
|
|
33685
33751
|
}
|
|
33686
|
-
const XML_NODE_NAME$1 = "mc:AlternateContent";
|
|
33687
|
-
const SD_NODE_NAME$1 = [];
|
|
33688
|
-
const validXmlAttributes$1 = [];
|
|
33689
|
-
function encode$1(params2) {
|
|
33690
|
-
const { nodeListHandler } = params2;
|
|
33691
|
-
const { node } = params2.extraParams;
|
|
33692
|
-
if (!node || !node.type) {
|
|
33693
|
-
return null;
|
|
33694
|
-
}
|
|
33695
|
-
const allowedNamespaces = ["wps", "wp14", "w14", "w15"];
|
|
33696
|
-
const wpsNode = node.elements.find(
|
|
33697
|
-
(el) => el.name === "mc:Choice" && allowedNamespaces.includes(el.attributes["Requires"])
|
|
33698
|
-
);
|
|
33699
|
-
if (!wpsNode) {
|
|
33700
|
-
return null;
|
|
33701
|
-
}
|
|
33702
|
-
const contents = wpsNode.elements;
|
|
33703
|
-
return nodeListHandler.handler({
|
|
33704
|
-
...params2,
|
|
33705
|
-
nodes: contents,
|
|
33706
|
-
path: [...params2.path || [], wpsNode]
|
|
33707
|
-
});
|
|
33708
|
-
}
|
|
33709
|
-
function decode$1(params2) {
|
|
33710
|
-
const { node } = params2;
|
|
33711
|
-
const { drawingContent } = node.attrs;
|
|
33712
|
-
const drawing = {
|
|
33713
|
-
name: "w:drawing",
|
|
33714
|
-
elements: [...drawingContent ? [...drawingContent.elements || []] : []]
|
|
33715
|
-
};
|
|
33716
|
-
const choice = {
|
|
33717
|
-
name: "mc:Choice",
|
|
33718
|
-
attributes: { Requires: "wps" },
|
|
33719
|
-
elements: [drawing]
|
|
33720
|
-
};
|
|
33721
|
-
return {
|
|
33722
|
-
name: "mc:AlternateContent",
|
|
33723
|
-
elements: [choice]
|
|
33724
|
-
};
|
|
33725
|
-
}
|
|
33726
|
-
const config$1 = {
|
|
33727
|
-
xmlName: XML_NODE_NAME$1,
|
|
33728
|
-
sdNodeOrKeyName: SD_NODE_NAME$1,
|
|
33729
|
-
type: NodeTranslator.translatorTypes.NODE,
|
|
33730
|
-
encode: encode$1,
|
|
33731
|
-
decode: decode$1,
|
|
33732
|
-
attributes: validXmlAttributes$1
|
|
33733
|
-
};
|
|
33734
|
-
const translator$1 = NodeTranslator.from(config$1);
|
|
33735
33752
|
function translateContentBlock(params2) {
|
|
33736
33753
|
const { node } = params2;
|
|
33737
33754
|
const { vmlAttributes, horizontalRule } = node.attrs;
|
|
@@ -35124,7 +35141,7 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
35124
35141
|
static getStoredSuperdocVersion(docx) {
|
|
35125
35142
|
return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
|
|
35126
35143
|
}
|
|
35127
|
-
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "0.
|
|
35144
|
+
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "0.25.0") {
|
|
35128
35145
|
return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
|
|
35129
35146
|
}
|
|
35130
35147
|
/**
|
|
@@ -38335,7 +38352,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
|
|
|
38335
38352
|
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);
|
|
38336
38353
|
var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
|
|
38337
38354
|
var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
|
|
38338
|
-
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,
|
|
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, 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;
|
|
38339
38356
|
var GOOD_LEAF_SIZE = 200;
|
|
38340
38357
|
var RopeSequence = function RopeSequence2() {
|
|
38341
38358
|
};
|
|
@@ -52550,7 +52567,9 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
52550
52567
|
isHeaderFooterChanged: false,
|
|
52551
52568
|
isCustomXmlChanged: false,
|
|
52552
52569
|
focusTarget: null,
|
|
52553
|
-
permissionResolver: null
|
|
52570
|
+
permissionResolver: null,
|
|
52571
|
+
// header/footer editors may have parent(main) editor set
|
|
52572
|
+
parentEditor: null
|
|
52554
52573
|
});
|
|
52555
52574
|
__privateMethod$1(this, _Editor_instances, initContainerElement_fn).call(this, options);
|
|
52556
52575
|
__privateMethod$1(this, _Editor_instances, checkHeadless_fn).call(this, options);
|
|
@@ -52678,6 +52697,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
52678
52697
|
* @param {string} documentMode - The document mode ('editing', 'viewing', 'suggesting')
|
|
52679
52698
|
*/
|
|
52680
52699
|
setDocumentMode(documentMode) {
|
|
52700
|
+
if (this.options.isHeaderOrFooter || this.options.isChildEditor) return;
|
|
52681
52701
|
let cleanedMode = documentMode?.toLowerCase() || "editing";
|
|
52682
52702
|
if (!this.extensionService || !this.state) return;
|
|
52683
52703
|
const pm = this.view?.dom || this.options.element?.querySelector?.(".ProseMirror");
|
|
@@ -52693,7 +52713,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
52693
52713
|
isEditMode: false,
|
|
52694
52714
|
documentMode: cleanedMode
|
|
52695
52715
|
});
|
|
52696
|
-
if (
|
|
52716
|
+
if (pm) pm.classList.add("view-mode");
|
|
52697
52717
|
} else if (cleanedMode === "suggesting") {
|
|
52698
52718
|
__privateMethod$1(this, _Editor_instances, registerPluginByNameIfNotExists_fn).call(this, "TrackChangesBase");
|
|
52699
52719
|
this.commands.disableTrackChangesShowOriginal();
|
|
@@ -53312,7 +53332,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
53312
53332
|
* @returns {Object | void} Migration results
|
|
53313
53333
|
*/
|
|
53314
53334
|
processCollaborationMigrations() {
|
|
53315
|
-
console.debug("[checkVersionMigrations] Current editor version", "0.
|
|
53335
|
+
console.debug("[checkVersionMigrations] Current editor version", "0.25.0");
|
|
53316
53336
|
if (!this.options.ydoc) return;
|
|
53317
53337
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
53318
53338
|
let docVersion = metaMap.get("version");
|
|
@@ -53518,9 +53538,6 @@ init_fn = function() {
|
|
|
53518
53538
|
this.emit("beforeCreate", { editor: this });
|
|
53519
53539
|
this.on("contentError", this.options.onContentError);
|
|
53520
53540
|
this.mount(this.options.element);
|
|
53521
|
-
if (!this.options.isHeadless) {
|
|
53522
|
-
__privateMethod$1(this, _Editor_instances, checkFonts_fn).call(this);
|
|
53523
|
-
}
|
|
53524
53541
|
this.on("create", this.options.onCreate);
|
|
53525
53542
|
this.on("update", this.options.onUpdate);
|
|
53526
53543
|
this.on("selectionUpdate", this.options.onSelectionUpdate);
|
|
@@ -53542,8 +53559,12 @@ init_fn = function() {
|
|
|
53542
53559
|
if (!this.options.isHeadless) {
|
|
53543
53560
|
this.initializeCollaborationData();
|
|
53544
53561
|
this.initDefaultStyles();
|
|
53562
|
+
__privateMethod$1(this, _Editor_instances, checkFonts_fn).call(this);
|
|
53545
53563
|
}
|
|
53546
|
-
|
|
53564
|
+
const shouldMigrateListsOnInit = Boolean(
|
|
53565
|
+
this.options.markdown || this.options.html || this.options.loadFromSchema || this.options.jsonOverride || this.options.mode === "html" || this.options.mode === "text"
|
|
53566
|
+
);
|
|
53567
|
+
if (shouldMigrateListsOnInit) {
|
|
53547
53568
|
this.migrateListsToV2();
|
|
53548
53569
|
}
|
|
53549
53570
|
this.setDocumentMode(this.options.documentMode);
|
|
@@ -53684,52 +53705,18 @@ checkFonts_fn = async function() {
|
|
|
53684
53705
|
if (this.options.isHeadless) {
|
|
53685
53706
|
return;
|
|
53686
53707
|
}
|
|
53687
|
-
const fontsUsedInDocument = this.converter.getDocumentFonts();
|
|
53688
|
-
if (!("queryLocalFonts" in window)) {
|
|
53689
|
-
console.warn("[SuperDoc] Could not get access to local fonts. Using fallback solution.");
|
|
53690
|
-
const unsupportedFonts = __privateMethod$1(this, _Editor_instances, determineUnsupportedFontsWithCanvas_fn).call(this, fontsUsedInDocument);
|
|
53691
|
-
this.emit("fonts-resolved", {
|
|
53692
|
-
documentFonts: fontsUsedInDocument,
|
|
53693
|
-
unsupportedFonts
|
|
53694
|
-
});
|
|
53695
|
-
return;
|
|
53696
|
-
}
|
|
53697
|
-
const localFontAccess = await navigator.permissions.query({ name: "local-fonts" });
|
|
53698
|
-
if (localFontAccess.state === "denied") {
|
|
53699
|
-
console.warn("[SuperDoc] Could not get access to local fonts. Using fallback solution.");
|
|
53700
|
-
const unsupportedFonts = __privateMethod$1(this, _Editor_instances, determineUnsupportedFontsWithCanvas_fn).call(this, fontsUsedInDocument);
|
|
53701
|
-
this.emit("fonts-resolved", {
|
|
53702
|
-
documentFonts: fontsUsedInDocument,
|
|
53703
|
-
unsupportedFonts
|
|
53704
|
-
});
|
|
53705
|
-
return;
|
|
53706
|
-
}
|
|
53707
53708
|
try {
|
|
53708
|
-
const
|
|
53709
|
-
const
|
|
53710
|
-
const unsupportedFonts = __privateMethod$1(this, _Editor_instances, determineUnsupportedFontsWithLocalFonts_fn).call(this, fontsUsedInDocument, uniqueLocalFonts);
|
|
53709
|
+
const fontsUsedInDocument = this.converter.getDocumentFonts();
|
|
53710
|
+
const unsupportedFonts = __privateMethod$1(this, _Editor_instances, determineUnsupportedFonts_fn).call(this, fontsUsedInDocument);
|
|
53711
53711
|
this.emit("fonts-resolved", {
|
|
53712
53712
|
documentFonts: fontsUsedInDocument,
|
|
53713
53713
|
unsupportedFonts
|
|
53714
53714
|
});
|
|
53715
53715
|
} catch {
|
|
53716
|
-
console.warn("[SuperDoc] Could not
|
|
53717
|
-
const unsupportedFonts = __privateMethod$1(this, _Editor_instances, determineUnsupportedFontsWithCanvas_fn).call(this, fontsUsedInDocument);
|
|
53718
|
-
this.emit("fonts-resolved", {
|
|
53719
|
-
documentFonts: fontsUsedInDocument,
|
|
53720
|
-
unsupportedFonts
|
|
53721
|
-
});
|
|
53716
|
+
console.warn("[SuperDoc] Could not determine document fonts and unsupported fonts");
|
|
53722
53717
|
}
|
|
53723
53718
|
};
|
|
53724
|
-
|
|
53725
|
-
const unsupportedFonts = fonts.filter((font) => {
|
|
53726
|
-
const isLocalFont = localFonts.includes(font);
|
|
53727
|
-
const isFontImported = this.fontsImported.includes(font);
|
|
53728
|
-
return !isLocalFont && !isFontImported;
|
|
53729
|
-
});
|
|
53730
|
-
return unsupportedFonts;
|
|
53731
|
-
};
|
|
53732
|
-
determineUnsupportedFontsWithCanvas_fn = function(fonts) {
|
|
53719
|
+
determineUnsupportedFonts_fn = function(fonts) {
|
|
53733
53720
|
const unsupportedFonts = fonts.filter((font) => {
|
|
53734
53721
|
const canRender = canRenderFont(font);
|
|
53735
53722
|
const isFontImported = this.fontsImported.includes(font);
|
|
@@ -53817,6 +53804,9 @@ onCollaborationReady_fn = function({ editor, ydoc }) {
|
|
|
53817
53804
|
if (this.options.collaborationIsReady) return;
|
|
53818
53805
|
console.debug("🔗 [super-editor] Collaboration ready");
|
|
53819
53806
|
__privateMethod$1(this, _Editor_instances, validateDocumentInit_fn).call(this);
|
|
53807
|
+
if (this.options.ydoc) {
|
|
53808
|
+
this.migrateListsToV2();
|
|
53809
|
+
}
|
|
53820
53810
|
this.options.onCollaborationReady({ editor, ydoc });
|
|
53821
53811
|
this.options.collaborationIsReady = true;
|
|
53822
53812
|
this.options.initialState = this.state;
|
|
@@ -55762,10 +55752,27 @@ function getStructuredContentBlockTags(state2) {
|
|
|
55762
55752
|
const result = findChildren$5(state2.doc, (node) => node.type.name === "structuredContentBlock");
|
|
55763
55753
|
return result;
|
|
55764
55754
|
}
|
|
55755
|
+
function getStructuredContentTablesById(id, state2) {
|
|
55756
|
+
if (!id || !state2) return [];
|
|
55757
|
+
const blocks = getStructuredContentTagsById(id, state2).filter(
|
|
55758
|
+
({ node }) => node.type.name === "structuredContentBlock"
|
|
55759
|
+
);
|
|
55760
|
+
if (!blocks.length) return [];
|
|
55761
|
+
const { pos: blockPos, node: blockNode } = blocks[0];
|
|
55762
|
+
const tablesInBlock = [];
|
|
55763
|
+
blockNode.descendants((child, relPos) => {
|
|
55764
|
+
if (child.type.name === "table") {
|
|
55765
|
+
const absPos = blockPos + 1 + relPos;
|
|
55766
|
+
tablesInBlock.push({ node: child, pos: absPos });
|
|
55767
|
+
}
|
|
55768
|
+
});
|
|
55769
|
+
return tablesInBlock;
|
|
55770
|
+
}
|
|
55765
55771
|
const structuredContentHelpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
55766
55772
|
__proto__: null,
|
|
55767
55773
|
getStructuredContentBlockTags,
|
|
55768
55774
|
getStructuredContentInlineTags,
|
|
55775
|
+
getStructuredContentTablesById,
|
|
55769
55776
|
getStructuredContentTags,
|
|
55770
55777
|
getStructuredContentTagsById
|
|
55771
55778
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
@@ -55962,6 +55969,36 @@ const StructuredContentCommands = Extension.create({
|
|
|
55962
55969
|
tr.replaceWith(posFrom, posTo, content);
|
|
55963
55970
|
}
|
|
55964
55971
|
return true;
|
|
55972
|
+
},
|
|
55973
|
+
/**
|
|
55974
|
+
* Append multiple rows to the end of a table inside a structured content block.
|
|
55975
|
+
* Each inner array represents the cell values for one new row.
|
|
55976
|
+
* @category Command
|
|
55977
|
+
* @param {StructuredContentTableAppendRowsOptions} options - Append configuration
|
|
55978
|
+
* @example
|
|
55979
|
+
* editor.commands.appendRowsToStructuredContentTable({
|
|
55980
|
+
* id: 'block-123',
|
|
55981
|
+
* tableIndex: 0,
|
|
55982
|
+
* rows: [['A', 'B'], ['C', 'D']],
|
|
55983
|
+
* copyRowStyle: true,
|
|
55984
|
+
* });
|
|
55985
|
+
*/
|
|
55986
|
+
appendRowsToStructuredContentTable: ({ id, tableIndex = 0, rows = [], copyRowStyle = false }) => ({ state: state2, commands: commands2, dispatch }) => {
|
|
55987
|
+
const normalized = normalizeRowsInput(rows);
|
|
55988
|
+
if (!normalized.length) return true;
|
|
55989
|
+
const tables = getStructuredContentTablesById(id, state2);
|
|
55990
|
+
if (!tables.length || tableIndex < 0 || tableIndex >= tables.length) return true;
|
|
55991
|
+
const { node: tableNode, pos: tablePos } = tables[tableIndex];
|
|
55992
|
+
if (dispatch) {
|
|
55993
|
+
return commands2.appendRowsWithContent({ tablePos, tableNode, valueRows: normalized, copyRowStyle });
|
|
55994
|
+
}
|
|
55995
|
+
return commands2.appendRowsWithContent({
|
|
55996
|
+
tablePos,
|
|
55997
|
+
tableNode,
|
|
55998
|
+
valueRows: normalized,
|
|
55999
|
+
copyRowStyle,
|
|
56000
|
+
dispatch: false
|
|
56001
|
+
});
|
|
55965
56002
|
}
|
|
55966
56003
|
};
|
|
55967
56004
|
},
|
|
@@ -55971,6 +56008,15 @@ const StructuredContentCommands = Extension.create({
|
|
|
55971
56008
|
};
|
|
55972
56009
|
}
|
|
55973
56010
|
});
|
|
56011
|
+
const normalizeRowsInput = (rowsOrValues) => {
|
|
56012
|
+
if (!Array.isArray(rowsOrValues) || !rowsOrValues.length) {
|
|
56013
|
+
return [];
|
|
56014
|
+
}
|
|
56015
|
+
if (Array.isArray(rowsOrValues[0])) {
|
|
56016
|
+
return rowsOrValues;
|
|
56017
|
+
}
|
|
56018
|
+
return [rowsOrValues];
|
|
56019
|
+
};
|
|
55974
56020
|
class DocumentSectionView {
|
|
55975
56021
|
constructor(node, getPos, decorations, editor) {
|
|
55976
56022
|
__privateAdd$1(this, _DocumentSectionView_instances);
|
|
@@ -61723,6 +61769,107 @@ function cellWrapping($pos) {
|
|
|
61723
61769
|
}
|
|
61724
61770
|
return null;
|
|
61725
61771
|
}
|
|
61772
|
+
function resolveTable(tr, tablePos, tableNode) {
|
|
61773
|
+
if (tableNode && tableNode.type && tableNode.type.name === "table") {
|
|
61774
|
+
return tableNode;
|
|
61775
|
+
}
|
|
61776
|
+
if (typeof tablePos === "number") {
|
|
61777
|
+
const current = tr.doc.nodeAt(tablePos);
|
|
61778
|
+
if (current && current.type.name === "table") {
|
|
61779
|
+
return current;
|
|
61780
|
+
}
|
|
61781
|
+
}
|
|
61782
|
+
return null;
|
|
61783
|
+
}
|
|
61784
|
+
function pickTemplateRowForAppend(tableNode, schema) {
|
|
61785
|
+
const RowType = schema.nodes.tableRow;
|
|
61786
|
+
const rows = [];
|
|
61787
|
+
tableNode.descendants((child) => {
|
|
61788
|
+
if (child.type === RowType) rows.push(child);
|
|
61789
|
+
});
|
|
61790
|
+
if (!rows.length) return null;
|
|
61791
|
+
for (let i = rows.length - 1; i >= 0; i--) {
|
|
61792
|
+
const r2 = rows[i];
|
|
61793
|
+
const hasBodyCell = r2.content?.content?.some((c2) => c2.type.name === "tableCell");
|
|
61794
|
+
if (hasBodyCell) return r2;
|
|
61795
|
+
}
|
|
61796
|
+
return rows[rows.length - 1];
|
|
61797
|
+
}
|
|
61798
|
+
function extractRowTemplateFormatting(cellNode, schema) {
|
|
61799
|
+
const ParagraphType = schema.nodes.paragraph;
|
|
61800
|
+
let blockType = ParagraphType;
|
|
61801
|
+
let blockAttrs = null;
|
|
61802
|
+
let textMarks = [];
|
|
61803
|
+
const blocks = cellNode?.content?.content || [];
|
|
61804
|
+
for (const block of blocks) {
|
|
61805
|
+
const isParagraphish = block.type === ParagraphType || block.type.name === "heading";
|
|
61806
|
+
if (isParagraphish) {
|
|
61807
|
+
blockType = block.type || ParagraphType;
|
|
61808
|
+
blockAttrs = block.attrs || null;
|
|
61809
|
+
}
|
|
61810
|
+
let foundText = null;
|
|
61811
|
+
block.descendants?.((n) => {
|
|
61812
|
+
if (!foundText && n.isText) foundText = n;
|
|
61813
|
+
});
|
|
61814
|
+
if (foundText) {
|
|
61815
|
+
textMarks = foundText.marks ? Array.from(foundText.marks) : [];
|
|
61816
|
+
break;
|
|
61817
|
+
}
|
|
61818
|
+
}
|
|
61819
|
+
if (!blockType || !blockType.validContent) blockType = ParagraphType;
|
|
61820
|
+
return { blockType, blockAttrs, textMarks };
|
|
61821
|
+
}
|
|
61822
|
+
function buildFormattedCellBlock(schema, value, { blockType, blockAttrs, textMarks }, copyRowStyle = false) {
|
|
61823
|
+
const text = typeof value === "string" ? value : value == null ? "" : String(value);
|
|
61824
|
+
const marks = copyRowStyle ? textMarks || [] : [];
|
|
61825
|
+
const textNode = schema.text(text, marks);
|
|
61826
|
+
const type2 = blockType || schema.nodes.paragraph;
|
|
61827
|
+
return type2.createAndFill(blockAttrs || null, textNode);
|
|
61828
|
+
}
|
|
61829
|
+
function buildRowFromTemplateRow({ schema, tableNode, templateRow, values, copyRowStyle = false }) {
|
|
61830
|
+
const RowType = schema.nodes.tableRow;
|
|
61831
|
+
const CellType = schema.nodes.tableCell;
|
|
61832
|
+
const HeaderType = schema.nodes.tableHeader;
|
|
61833
|
+
const map22 = TableMap.get(tableNode);
|
|
61834
|
+
const totalColumns = map22.width;
|
|
61835
|
+
const byColumns = Array.isArray(values) && values.length === totalColumns;
|
|
61836
|
+
const newCells = [];
|
|
61837
|
+
let columnCursor = 0;
|
|
61838
|
+
templateRow.content.content.forEach((cellNode, cellIndex) => {
|
|
61839
|
+
const isHeaderCell = cellNode.type === HeaderType;
|
|
61840
|
+
const targetCellType = isHeaderCell ? CellType : cellNode.type;
|
|
61841
|
+
const attrs = { ...cellNode.attrs };
|
|
61842
|
+
const formatting = extractRowTemplateFormatting(cellNode, schema);
|
|
61843
|
+
let cellValue = "";
|
|
61844
|
+
if (byColumns) {
|
|
61845
|
+
const span = Math.max(1, attrs.colspan || 1);
|
|
61846
|
+
cellValue = values[columnCursor] ?? "";
|
|
61847
|
+
columnCursor += span;
|
|
61848
|
+
} else {
|
|
61849
|
+
cellValue = Array.isArray(values) ? values[cellIndex] ?? "" : "";
|
|
61850
|
+
}
|
|
61851
|
+
const content = buildFormattedCellBlock(schema, cellValue, formatting, copyRowStyle);
|
|
61852
|
+
const newCell = targetCellType.createAndFill(attrs, content);
|
|
61853
|
+
if (newCell) newCells.push(newCell);
|
|
61854
|
+
});
|
|
61855
|
+
return RowType.createAndFill(null, newCells);
|
|
61856
|
+
}
|
|
61857
|
+
function insertRowsAtTableEnd({ tr, tablePos, tableNode, rows }) {
|
|
61858
|
+
if (!rows || !rows.length) return;
|
|
61859
|
+
const RowTypeName = "tableRow";
|
|
61860
|
+
let lastRowRelPos = 0;
|
|
61861
|
+
let lastRowNode = null;
|
|
61862
|
+
tableNode.descendants((child, relPos) => {
|
|
61863
|
+
if (child.type.name === RowTypeName) {
|
|
61864
|
+
lastRowRelPos = relPos;
|
|
61865
|
+
lastRowNode = child;
|
|
61866
|
+
}
|
|
61867
|
+
});
|
|
61868
|
+
if (!lastRowNode) return;
|
|
61869
|
+
const lastRowAbsEnd = tablePos + 1 + lastRowRelPos + lastRowNode.nodeSize;
|
|
61870
|
+
const frag = Fragment.fromArray(rows);
|
|
61871
|
+
tr.insert(lastRowAbsEnd, frag);
|
|
61872
|
+
}
|
|
61726
61873
|
const Table = Node$1.create({
|
|
61727
61874
|
name: "table",
|
|
61728
61875
|
content: "tableRow+",
|
|
@@ -61882,6 +62029,47 @@ const Table = Node$1.create({
|
|
|
61882
62029
|
},
|
|
61883
62030
|
addCommands() {
|
|
61884
62031
|
return {
|
|
62032
|
+
/**
|
|
62033
|
+
* Append multiple rows to the end of a table in a single transaction.
|
|
62034
|
+
* @category Command
|
|
62035
|
+
* @param {appendRowsWithContentOptions} options - Append configuration
|
|
62036
|
+
* @example
|
|
62037
|
+
* editor.commands.appendRowsWithContent({ tablePos, valueRows: [['A','B'], ['C','D']], copyRowStyle: true })
|
|
62038
|
+
*/
|
|
62039
|
+
appendRowsWithContent: ({ tablePos, tableNode, valueRows = [], copyRowStyle = false }) => ({ editor, chain }) => {
|
|
62040
|
+
if (typeof tablePos !== "number" && !tableNode || !Array.isArray(valueRows) || !valueRows.length) {
|
|
62041
|
+
return false;
|
|
62042
|
+
}
|
|
62043
|
+
return chain().command(({ tr, dispatch }) => {
|
|
62044
|
+
const workingTable = resolveTable(tr, tablePos, tableNode);
|
|
62045
|
+
if (!workingTable) return false;
|
|
62046
|
+
const templateRow = pickTemplateRowForAppend(workingTable, editor.schema);
|
|
62047
|
+
if (!templateRow) return false;
|
|
62048
|
+
const newRows = valueRows.map(
|
|
62049
|
+
(vals) => buildRowFromTemplateRow({
|
|
62050
|
+
schema: editor.schema,
|
|
62051
|
+
tableNode: workingTable,
|
|
62052
|
+
templateRow,
|
|
62053
|
+
values: vals,
|
|
62054
|
+
copyRowStyle
|
|
62055
|
+
})
|
|
62056
|
+
).filter(Boolean);
|
|
62057
|
+
if (!newRows.length) return false;
|
|
62058
|
+
let resolvedTablePos = tablePos;
|
|
62059
|
+
if (typeof resolvedTablePos !== "number" && workingTable) {
|
|
62060
|
+
const tables = editor.getNodesOfType("table");
|
|
62061
|
+
const match = workingTable ? tables.find((t) => t.node.eq(workingTable)) : tables[0];
|
|
62062
|
+
resolvedTablePos = match?.pos ?? null;
|
|
62063
|
+
}
|
|
62064
|
+
if (typeof resolvedTablePos !== "number") {
|
|
62065
|
+
return false;
|
|
62066
|
+
}
|
|
62067
|
+
if (dispatch) {
|
|
62068
|
+
insertRowsAtTableEnd({ tr, tablePos, tableNode: workingTable, rows: newRows });
|
|
62069
|
+
}
|
|
62070
|
+
return true;
|
|
62071
|
+
}).run();
|
|
62072
|
+
},
|
|
61885
62073
|
/**
|
|
61886
62074
|
* Insert a new table into the document
|
|
61887
62075
|
* @category Command
|
|
@@ -64788,58 +64976,6 @@ const registerImages = async (foundImages, editor, view) => {
|
|
|
64788
64976
|
}
|
|
64789
64977
|
});
|
|
64790
64978
|
};
|
|
64791
|
-
const normalizeWrap = (attrs = {}) => {
|
|
64792
|
-
const wrap2 = attrs.wrap;
|
|
64793
|
-
if (wrap2?.type && wrap2.type !== "Inline") {
|
|
64794
|
-
return {
|
|
64795
|
-
type: wrap2.type,
|
|
64796
|
-
attrs: wrap2.attrs ?? {}
|
|
64797
|
-
};
|
|
64798
|
-
}
|
|
64799
|
-
if (wrap2?.type === "Inline" && Object.keys(wrap2.attrs ?? {}).length) {
|
|
64800
|
-
return {
|
|
64801
|
-
type: "Inline",
|
|
64802
|
-
attrs: wrap2.attrs
|
|
64803
|
-
};
|
|
64804
|
-
}
|
|
64805
|
-
if (!wrap2 && attrs.wrapText) {
|
|
64806
|
-
return {
|
|
64807
|
-
type: "Square",
|
|
64808
|
-
attrs: {
|
|
64809
|
-
wrapText: attrs.wrapText
|
|
64810
|
-
}
|
|
64811
|
-
};
|
|
64812
|
-
}
|
|
64813
|
-
if (!wrap2 && attrs.wrapTopAndBottom) {
|
|
64814
|
-
return {
|
|
64815
|
-
type: "TopAndBottom",
|
|
64816
|
-
attrs: {}
|
|
64817
|
-
};
|
|
64818
|
-
}
|
|
64819
|
-
if (wrap2?.type === "Inline") {
|
|
64820
|
-
return {
|
|
64821
|
-
type: "Inline",
|
|
64822
|
-
attrs: wrap2.attrs ?? {}
|
|
64823
|
-
};
|
|
64824
|
-
}
|
|
64825
|
-
return {
|
|
64826
|
-
type: "Inline",
|
|
64827
|
-
attrs: {}
|
|
64828
|
-
};
|
|
64829
|
-
};
|
|
64830
|
-
const normalizeMarginOffset = (marginOffset = {}) => {
|
|
64831
|
-
const { left: left2, horizontal, ...rest } = marginOffset;
|
|
64832
|
-
return {
|
|
64833
|
-
...rest,
|
|
64834
|
-
horizontal: horizontal ?? left2
|
|
64835
|
-
};
|
|
64836
|
-
};
|
|
64837
|
-
const getNormalizedImageAttrs = (attrs = {}) => {
|
|
64838
|
-
return {
|
|
64839
|
-
wrap: normalizeWrap(attrs),
|
|
64840
|
-
marginOffset: normalizeMarginOffset(attrs.marginOffset ?? {})
|
|
64841
|
-
};
|
|
64842
|
-
};
|
|
64843
64979
|
const ImagePositionPluginKey = new PluginKey("ImagePosition");
|
|
64844
64980
|
const ImagePositionPlugin = ({ editor }) => {
|
|
64845
64981
|
const { view } = editor;
|
|
@@ -64852,8 +64988,9 @@ const ImagePositionPlugin = ({ editor }) => {
|
|
|
64852
64988
|
return DecorationSet.empty;
|
|
64853
64989
|
},
|
|
64854
64990
|
apply(tr, oldDecorationSet, oldState, newState) {
|
|
64855
|
-
if (!tr.docChanged) return oldDecorationSet;
|
|
64991
|
+
if (!tr.docChanged && !shouldUpdate) return oldDecorationSet;
|
|
64856
64992
|
const decorations = getImagePositionDecorations(newState, view);
|
|
64993
|
+
shouldUpdate = false;
|
|
64857
64994
|
return DecorationSet.create(newState.doc, decorations);
|
|
64858
64995
|
}
|
|
64859
64996
|
},
|
|
@@ -64862,7 +64999,6 @@ const ImagePositionPlugin = ({ editor }) => {
|
|
|
64862
64999
|
update: (view2, lastState) => {
|
|
64863
65000
|
const pagination = PaginationPluginKey.getState(lastState);
|
|
64864
65001
|
if (shouldUpdate) {
|
|
64865
|
-
shouldUpdate = false;
|
|
64866
65002
|
const decorations = getImagePositionDecorations(lastState, view2);
|
|
64867
65003
|
const updateTransaction = view2.state.tr.setMeta(ImagePositionPluginKey, { decorations });
|
|
64868
65004
|
view2.dispatch(updateTransaction);
|
|
@@ -64888,41 +65024,35 @@ const getImagePositionDecorations = (state2, view) => {
|
|
|
64888
65024
|
let className = "";
|
|
64889
65025
|
const { vRelativeFrom, alignH } = node.attrs.anchorData;
|
|
64890
65026
|
const { size: size2, padding } = node.attrs;
|
|
64891
|
-
const { marginOffset } = getNormalizedImageAttrs(node.attrs);
|
|
64892
65027
|
const pageBreak = findPreviousDomNodeWithClass(view, pos, "pagination-break-wrapper");
|
|
64893
|
-
if (pageBreak) {
|
|
64894
|
-
|
|
64895
|
-
|
|
64896
|
-
|
|
64897
|
-
|
|
64898
|
-
|
|
64899
|
-
|
|
64900
|
-
|
|
64901
|
-
|
|
64902
|
-
|
|
64903
|
-
|
|
65028
|
+
if (pageBreak && vRelativeFrom === "margin" && alignH) {
|
|
65029
|
+
const topPos = pageBreak?.offsetTop + pageBreak?.offsetHeight;
|
|
65030
|
+
let horizontalAlignment = `${alignH}: 0;`;
|
|
65031
|
+
if (alignH === "center") horizontalAlignment = "left: 50%; transform: translateX(-50%);";
|
|
65032
|
+
style2 += vRelativeFrom === "margin" ? `position: absolute; top: ${topPos}px; ${horizontalAlignment}` : "";
|
|
65033
|
+
const nextPos = view.posAtDOM(pageBreak, 1);
|
|
65034
|
+
if (nextPos < 0) {
|
|
65035
|
+
const $pos = view.state.doc.resolve(pos);
|
|
65036
|
+
decorations.push(
|
|
65037
|
+
Decoration.node(pos - 1, pos + $pos.parent.nodeSize - 1, {
|
|
65038
|
+
style: `height: ${size2.height + parseInt(padding.top) + parseInt(padding.bottom)}px`
|
|
65039
|
+
})
|
|
65040
|
+
);
|
|
64904
65041
|
}
|
|
64905
|
-
const
|
|
64906
|
-
|
|
64907
|
-
|
|
64908
|
-
|
|
64909
|
-
|
|
64910
|
-
|
|
64911
|
-
|
|
64912
|
-
|
|
64913
|
-
style: `height: ${size2.height + parseInt(padding.top) + parseInt(padding.bottom)}px`
|
|
64914
|
-
})
|
|
64915
|
-
);
|
|
64916
|
-
}
|
|
64917
|
-
const imageBlock = document.createElement("div");
|
|
64918
|
-
imageBlock.className = "anchor-image-placeholder";
|
|
64919
|
-
imageBlock.style.float = alignH;
|
|
64920
|
-
imageBlock.style.width = size2.width + parseInt(padding[alignH]) + "px";
|
|
64921
|
-
imageBlock.style.height = size2.height + parseInt(padding.top) + parseInt(padding.bottom) + "px";
|
|
64922
|
-
decorations.push(Decoration.widget(nextPos, imageBlock, { key: "stable-key" }));
|
|
65042
|
+
const imageBlock = document.createElement("div");
|
|
65043
|
+
imageBlock.className = "anchor-image-placeholder";
|
|
65044
|
+
imageBlock.style.float = alignH === "left" || alignH === "right" ? alignH : "none";
|
|
65045
|
+
let paddingHorizontal;
|
|
65046
|
+
if (alignH === "center") {
|
|
65047
|
+
paddingHorizontal = (parseInt(padding.left) || 0) + (parseInt(padding.right) || 0);
|
|
65048
|
+
} else {
|
|
65049
|
+
paddingHorizontal = parseInt(padding[alignH]) || 0;
|
|
64923
65050
|
}
|
|
65051
|
+
imageBlock.style.width = size2.width + paddingHorizontal + "px";
|
|
65052
|
+
imageBlock.style.height = size2.height + parseInt(padding.top) + parseInt(padding.bottom) + "px";
|
|
65053
|
+
decorations.push(Decoration.widget(nextPos, imageBlock, { key: "stable-key" }));
|
|
65054
|
+
decorations.push(Decoration.inline(pos, pos + node.nodeSize, { style: style2, class: className }));
|
|
64924
65055
|
}
|
|
64925
|
-
decorations.push(Decoration.inline(pos, pos + node.nodeSize, { style: style2, class: className }));
|
|
64926
65056
|
}
|
|
64927
65057
|
});
|
|
64928
65058
|
return decorations;
|
|
@@ -64947,6 +65077,58 @@ const findPreviousDomNodeWithClass = (view, pos, className) => {
|
|
|
64947
65077
|
}
|
|
64948
65078
|
return null;
|
|
64949
65079
|
};
|
|
65080
|
+
const normalizeWrap = (attrs = {}) => {
|
|
65081
|
+
const wrap2 = attrs.wrap;
|
|
65082
|
+
if (wrap2?.type && wrap2.type !== "Inline") {
|
|
65083
|
+
return {
|
|
65084
|
+
type: wrap2.type,
|
|
65085
|
+
attrs: wrap2.attrs ?? {}
|
|
65086
|
+
};
|
|
65087
|
+
}
|
|
65088
|
+
if (wrap2?.type === "Inline" && Object.keys(wrap2.attrs ?? {}).length) {
|
|
65089
|
+
return {
|
|
65090
|
+
type: "Inline",
|
|
65091
|
+
attrs: wrap2.attrs
|
|
65092
|
+
};
|
|
65093
|
+
}
|
|
65094
|
+
if (!wrap2 && attrs.wrapText) {
|
|
65095
|
+
return {
|
|
65096
|
+
type: "Square",
|
|
65097
|
+
attrs: {
|
|
65098
|
+
wrapText: attrs.wrapText
|
|
65099
|
+
}
|
|
65100
|
+
};
|
|
65101
|
+
}
|
|
65102
|
+
if (!wrap2 && attrs.wrapTopAndBottom) {
|
|
65103
|
+
return {
|
|
65104
|
+
type: "TopAndBottom",
|
|
65105
|
+
attrs: {}
|
|
65106
|
+
};
|
|
65107
|
+
}
|
|
65108
|
+
if (wrap2?.type === "Inline") {
|
|
65109
|
+
return {
|
|
65110
|
+
type: "Inline",
|
|
65111
|
+
attrs: wrap2.attrs ?? {}
|
|
65112
|
+
};
|
|
65113
|
+
}
|
|
65114
|
+
return {
|
|
65115
|
+
type: "Inline",
|
|
65116
|
+
attrs: {}
|
|
65117
|
+
};
|
|
65118
|
+
};
|
|
65119
|
+
const normalizeMarginOffset = (marginOffset = {}) => {
|
|
65120
|
+
const { left: left2, horizontal, ...rest } = marginOffset;
|
|
65121
|
+
return {
|
|
65122
|
+
...rest,
|
|
65123
|
+
horizontal: horizontal ?? left2
|
|
65124
|
+
};
|
|
65125
|
+
};
|
|
65126
|
+
const getNormalizedImageAttrs = (attrs = {}) => {
|
|
65127
|
+
return {
|
|
65128
|
+
wrap: normalizeWrap(attrs),
|
|
65129
|
+
marginOffset: normalizeMarginOffset(attrs.marginOffset ?? {})
|
|
65130
|
+
};
|
|
65131
|
+
};
|
|
64950
65132
|
const getRotationMargins = (w2, h2, angleDegrees) => {
|
|
64951
65133
|
const rad = angleDegrees * (Math.PI / 180);
|
|
64952
65134
|
const cos = Math.abs(Math.cos(rad));
|
|
@@ -65155,27 +65337,15 @@ const Image = Node$1.create({
|
|
|
65155
65337
|
style2 += "float: right;";
|
|
65156
65338
|
floatRight = true;
|
|
65157
65339
|
} else if (["largest", "bothSides"].includes(attrs.wrapText)) {
|
|
65158
|
-
const
|
|
65159
|
-
|
|
65160
|
-
|
|
65161
|
-
|
|
65162
|
-
|
|
65163
|
-
|
|
65164
|
-
|
|
65165
|
-
|
|
65166
|
-
|
|
65167
|
-
if (rightSpace < 0) {
|
|
65168
|
-
style2 += "float: left;";
|
|
65169
|
-
} else if (rightSpace > leftSpace) {
|
|
65170
|
-
style2 += "float: left;";
|
|
65171
|
-
} else {
|
|
65172
|
-
style2 += "float: right;";
|
|
65173
|
-
floatRight = true;
|
|
65174
|
-
baseHorizontal = rightSpace;
|
|
65175
|
-
}
|
|
65176
|
-
} else {
|
|
65177
|
-
style2 += "float: left;";
|
|
65178
|
-
}
|
|
65340
|
+
const pageStylesData2 = getDataFromPageStyles({
|
|
65341
|
+
editor: this.editor,
|
|
65342
|
+
marginOffset,
|
|
65343
|
+
size: size2,
|
|
65344
|
+
attrs
|
|
65345
|
+
});
|
|
65346
|
+
style2 += pageStylesData2.style;
|
|
65347
|
+
floatRight = pageStylesData2.floatRight;
|
|
65348
|
+
baseHorizontal = pageStylesData2.baseHorizontal;
|
|
65179
65349
|
}
|
|
65180
65350
|
if (attrs.distTop) margin.top += attrs.distTop;
|
|
65181
65351
|
if (attrs.distBottom) margin.bottom += attrs.distBottom;
|
|
@@ -65185,27 +65355,15 @@ const Image = Node$1.create({
|
|
|
65185
65355
|
case "Through":
|
|
65186
65356
|
case "Tight":
|
|
65187
65357
|
style2 += "clear: both;";
|
|
65188
|
-
const
|
|
65189
|
-
|
|
65190
|
-
|
|
65191
|
-
|
|
65192
|
-
|
|
65193
|
-
|
|
65194
|
-
|
|
65195
|
-
|
|
65196
|
-
|
|
65197
|
-
if (rightSpace < 0) {
|
|
65198
|
-
style2 += "float: left;";
|
|
65199
|
-
} else if (rightSpace > leftSpace) {
|
|
65200
|
-
style2 += "float: left;";
|
|
65201
|
-
} else {
|
|
65202
|
-
style2 += "float: right;";
|
|
65203
|
-
floatRight = true;
|
|
65204
|
-
baseHorizontal = rightSpace;
|
|
65205
|
-
}
|
|
65206
|
-
} else {
|
|
65207
|
-
style2 += "float: left;";
|
|
65208
|
-
}
|
|
65358
|
+
const pageStylesData = getDataFromPageStyles({
|
|
65359
|
+
editor: this.editor,
|
|
65360
|
+
marginOffset,
|
|
65361
|
+
size: size2,
|
|
65362
|
+
attrs
|
|
65363
|
+
});
|
|
65364
|
+
style2 += pageStylesData.style;
|
|
65365
|
+
floatRight = pageStylesData.floatRight;
|
|
65366
|
+
baseHorizontal = pageStylesData.baseHorizontal;
|
|
65209
65367
|
if (attrs.distTop) margin.top += attrs.distTop;
|
|
65210
65368
|
if (attrs.distBottom) margin.bottom += attrs.distBottom;
|
|
65211
65369
|
if (attrs.distLeft) margin.left += attrs.distLeft;
|
|
@@ -65242,6 +65400,22 @@ const Image = Node$1.create({
|
|
|
65242
65400
|
}
|
|
65243
65401
|
const hasAnchorData = Boolean(anchorData);
|
|
65244
65402
|
const hasMarginOffsets = marginOffset?.horizontal != null || marginOffset?.top != null;
|
|
65403
|
+
if (hasAnchorData) {
|
|
65404
|
+
switch (anchorData.hRelativeFrom) {
|
|
65405
|
+
case "page":
|
|
65406
|
+
const pageStyles = this.editor?.converter?.pageStyles || this.editor?.options.parentEditor?.converter?.pageStyles;
|
|
65407
|
+
margin.left -= inchesToPixels(pageStyles?.pageMargins?.left) || 0;
|
|
65408
|
+
break;
|
|
65409
|
+
case "margin":
|
|
65410
|
+
if (anchorData.alignH === "center") {
|
|
65411
|
+
style2 += "position: absolute; left: 50%; transform: translateX(-50%);";
|
|
65412
|
+
}
|
|
65413
|
+
if (anchorData.alignH === "left" || anchorData.alignH === "right") {
|
|
65414
|
+
style2 += `position: absolute; ${anchorData.alignH}: 0;`;
|
|
65415
|
+
}
|
|
65416
|
+
break;
|
|
65417
|
+
}
|
|
65418
|
+
}
|
|
65245
65419
|
if (hasAnchorData || hasMarginOffsets) {
|
|
65246
65420
|
const relativeFromPageV = anchorData?.vRelativeFrom === "page";
|
|
65247
65421
|
const maxMarginV = 500;
|
|
@@ -65390,6 +65564,37 @@ const Image = Node$1.create({
|
|
|
65390
65564
|
return [ImageRegistrationPlugin({ editor: this.editor }), ImagePositionPlugin({ editor: this.editor })];
|
|
65391
65565
|
}
|
|
65392
65566
|
});
|
|
65567
|
+
const getDataFromPageStyles = ({ editor, marginOffset, size: size2, attrs }) => {
|
|
65568
|
+
let style2 = "";
|
|
65569
|
+
let floatRight = false;
|
|
65570
|
+
let baseHorizontal = marginOffset?.horizontal || 0;
|
|
65571
|
+
const pageStyles = editor?.converter?.pageStyles || editor?.options.parentEditor?.converter?.pageStyles;
|
|
65572
|
+
if (pageStyles?.pageSize && pageStyles?.pageMargins && size2.width) {
|
|
65573
|
+
const pageWidth = inchesToPixels(pageStyles.pageSize.width);
|
|
65574
|
+
const leftMargin = inchesToPixels(pageStyles.pageMargins.left);
|
|
65575
|
+
const rightMargin = inchesToPixels(pageStyles.pageMargins.right);
|
|
65576
|
+
const contentWidth = pageWidth - leftMargin - rightMargin;
|
|
65577
|
+
const imageWidth = size2.width + (attrs.distLeft || 0) + (attrs.distRight || 0);
|
|
65578
|
+
const leftSpace = marginOffset.horizontal;
|
|
65579
|
+
const rightSpace = contentWidth - leftSpace - imageWidth;
|
|
65580
|
+
if (rightSpace < 0) {
|
|
65581
|
+
style2 += "float: left;";
|
|
65582
|
+
} else if (rightSpace > leftSpace) {
|
|
65583
|
+
style2 += "float: left;";
|
|
65584
|
+
} else {
|
|
65585
|
+
style2 += "float: right;";
|
|
65586
|
+
floatRight = true;
|
|
65587
|
+
baseHorizontal = rightSpace;
|
|
65588
|
+
}
|
|
65589
|
+
} else {
|
|
65590
|
+
style2 += "float: left;";
|
|
65591
|
+
}
|
|
65592
|
+
return {
|
|
65593
|
+
style: style2,
|
|
65594
|
+
floatRight,
|
|
65595
|
+
baseHorizontal
|
|
65596
|
+
};
|
|
65597
|
+
};
|
|
65393
65598
|
const ACCEPT_IMAGE_TYPES = [".jpg", ".jpeg", ".png", "image/jpeg", "image/png"];
|
|
65394
65599
|
const getFileOpener = () => {
|
|
65395
65600
|
let fileInput = document.createElement("input");
|
|
@@ -67359,6 +67564,10 @@ const derivePermissionKey = ({ action, isOwn }) => {
|
|
|
67359
67564
|
if (!mapping) return null;
|
|
67360
67565
|
return isOwn ? mapping.own : mapping.other;
|
|
67361
67566
|
};
|
|
67567
|
+
const normalizeEmail = (value) => {
|
|
67568
|
+
if (typeof value !== "string") return "";
|
|
67569
|
+
return value.trim().toLowerCase();
|
|
67570
|
+
};
|
|
67362
67571
|
const resolveChanges = (editor) => {
|
|
67363
67572
|
if (!editor) return { role: "editor", isInternal: false, currentUser: null, resolver: null };
|
|
67364
67573
|
const role = editor.options?.role ?? "editor";
|
|
@@ -67371,10 +67580,10 @@ const isTrackedChangeActionAllowed = ({ editor, action, trackedChanges }) => {
|
|
|
67371
67580
|
if (!trackedChanges?.length) return true;
|
|
67372
67581
|
const { role, isInternal, currentUser, resolver } = resolveChanges(editor);
|
|
67373
67582
|
if (typeof resolver !== "function") return true;
|
|
67374
|
-
const currentEmail = currentUser?.email
|
|
67583
|
+
const currentEmail = normalizeEmail(currentUser?.email);
|
|
67375
67584
|
return trackedChanges.every((change) => {
|
|
67376
|
-
const authorEmail = change.attrs?.authorEmail
|
|
67377
|
-
const isOwn =
|
|
67585
|
+
const authorEmail = normalizeEmail(change.attrs?.authorEmail);
|
|
67586
|
+
const isOwn = !currentEmail || !authorEmail || currentEmail === authorEmail;
|
|
67378
67587
|
const permission = derivePermissionKey({ action, isOwn });
|
|
67379
67588
|
if (!permission) return true;
|
|
67380
67589
|
const payload = {
|
|
@@ -67511,6 +67720,15 @@ const TrackChanges = Extension.create({
|
|
|
67511
67720
|
const { from: from2, to } = state2.selection;
|
|
67512
67721
|
return commands2.acceptTrackedChangesBetween(from2, to);
|
|
67513
67722
|
},
|
|
67723
|
+
acceptTrackedChangeFromToolbar: () => ({ state: state2, commands: commands2 }) => {
|
|
67724
|
+
const commentsPluginState = CommentsPluginKey.getState(state2);
|
|
67725
|
+
const activeThreadId = commentsPluginState?.activeThreadId;
|
|
67726
|
+
if (activeThreadId && commentsPluginState?.trackedChanges?.[activeThreadId]) {
|
|
67727
|
+
return commands2.acceptTrackedChangeById(activeThreadId);
|
|
67728
|
+
} else {
|
|
67729
|
+
return commands2.acceptTrackedChangeBySelection();
|
|
67730
|
+
}
|
|
67731
|
+
},
|
|
67514
67732
|
acceptTrackedChangeById: (id) => ({ state: state2, tr, commands: commands2 }) => {
|
|
67515
67733
|
const toResolve = getChangesByIdToResolve(state2, id) || [];
|
|
67516
67734
|
return toResolve.map(({ from: from2, to }) => {
|
|
@@ -67539,6 +67757,15 @@ const TrackChanges = Extension.create({
|
|
|
67539
67757
|
const { from: from2, to } = state2.selection;
|
|
67540
67758
|
return commands2.rejectTrackedChangesBetween(from2, to);
|
|
67541
67759
|
},
|
|
67760
|
+
rejectTrackedChangeFromToolbar: () => ({ state: state2, commands: commands2 }) => {
|
|
67761
|
+
const commentsPluginState = CommentsPluginKey.getState(state2);
|
|
67762
|
+
const activeThreadId = commentsPluginState?.activeThreadId;
|
|
67763
|
+
if (activeThreadId && commentsPluginState?.trackedChanges?.[activeThreadId]) {
|
|
67764
|
+
return commands2.rejectTrackedChangeById(activeThreadId);
|
|
67765
|
+
} else {
|
|
67766
|
+
return commands2.rejectTrackedChangeOnSelection();
|
|
67767
|
+
}
|
|
67768
|
+
},
|
|
67542
67769
|
rejectAllTrackedChanges: () => ({ state: state2, commands: commands2 }) => {
|
|
67543
67770
|
const from2 = 0, to = state2.doc.content.size;
|
|
67544
67771
|
return commands2.rejectTrackedChangesBetween(from2, to);
|
|
@@ -72832,7 +73059,7 @@ const nodeResizer = (nodeNames = ["image"], editor) => {
|
|
|
72832
73059
|
return oldState;
|
|
72833
73060
|
}
|
|
72834
73061
|
if (typeof document === "undefined" || editor.options.isHeadless) return oldState;
|
|
72835
|
-
if (editor.options.documentMode === "viewing" || !editor.isEditable) {
|
|
73062
|
+
if (!editor.options.isHeaderOrFooter && (editor.options.documentMode === "viewing" || !editor.isEditable)) {
|
|
72836
73063
|
return DecorationSet.empty;
|
|
72837
73064
|
}
|
|
72838
73065
|
const { selection } = newState;
|
|
@@ -85941,7 +86168,7 @@ const makeDefaultItems = ({
|
|
|
85941
86168
|
disabled: false,
|
|
85942
86169
|
name: "acceptTrackedChangeBySelection",
|
|
85943
86170
|
tooltip: toolbarTexts2.trackChangesAccept,
|
|
85944
|
-
command: "
|
|
86171
|
+
command: "acceptTrackedChangeFromToolbar",
|
|
85945
86172
|
icon: toolbarIcons2.trackChangesAccept,
|
|
85946
86173
|
group: "left",
|
|
85947
86174
|
attributes: {
|
|
@@ -85953,7 +86180,7 @@ const makeDefaultItems = ({
|
|
|
85953
86180
|
disabled: false,
|
|
85954
86181
|
name: "rejectTrackedChangeOnSelection",
|
|
85955
86182
|
tooltip: toolbarTexts2.trackChangesReject,
|
|
85956
|
-
command: "
|
|
86183
|
+
command: "rejectTrackedChangeFromToolbar",
|
|
85957
86184
|
icon: toolbarIcons2.trackChangesReject,
|
|
85958
86185
|
group: "left",
|
|
85959
86186
|
attributes: {
|
|
@@ -88974,8 +89201,12 @@ const Extensions = {
|
|
|
88974
89201
|
Node: Node$1,
|
|
88975
89202
|
Attribute: Attribute2,
|
|
88976
89203
|
Extension,
|
|
89204
|
+
Mark: Mark2,
|
|
89205
|
+
//
|
|
88977
89206
|
Plugin,
|
|
88978
|
-
|
|
89207
|
+
PluginKey,
|
|
89208
|
+
Decoration,
|
|
89209
|
+
DecorationSet
|
|
88979
89210
|
};
|
|
88980
89211
|
export {
|
|
88981
89212
|
AIWriter as A,
|