@harbour-enterprises/superdoc 0.25.0-next.3 → 0.25.0-next.5
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-DDL0V0l5.cjs → PdfViewer-8kRpbCwn.cjs} +1 -1
- package/dist/chunks/{PdfViewer-Y13XRanw.es.js → PdfViewer-DVToyLl3.es.js} +1 -1
- package/dist/chunks/{index-Bo5YCvD5.cjs → index-DisCF1vr.cjs} +2 -2
- package/dist/chunks/{index-DKNVSdr6.es.js → index-STsumey2.es.js} +2 -2
- package/dist/chunks/{super-editor.es-Ct2sXbNV.cjs → super-editor.es-QqtfiJGc.cjs} +255 -245
- package/dist/chunks/{super-editor.es-CYtLh0Ob.es.js → super-editor.es-rBPknGqQ.es.js} +255 -245
- 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-DOkexB95.js} +89 -72
- package/dist/super-editor/chunks/{docx-zipper-CceGxV02.js → docx-zipper-Ci5JbfjE.js} +1 -1
- package/dist/super-editor/chunks/{editor-CoX24lXQ.js → editor-BOoGDORN.js} +171 -187
- package/dist/super-editor/chunks/{toolbar-BTw9-jfX.js → toolbar-DPI_cCm_.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/index.d.ts +8 -2
- package/dist/super-editor/super-editor.es.js +16 -12
- 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 +255 -245
- 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;
|
|
@@ -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);
|
|
@@ -53518,9 +53537,6 @@ init_fn = function() {
|
|
|
53518
53537
|
this.emit("beforeCreate", { editor: this });
|
|
53519
53538
|
this.on("contentError", this.options.onContentError);
|
|
53520
53539
|
this.mount(this.options.element);
|
|
53521
|
-
if (!this.options.isHeadless) {
|
|
53522
|
-
__privateMethod$1(this, _Editor_instances, checkFonts_fn).call(this);
|
|
53523
|
-
}
|
|
53524
53540
|
this.on("create", this.options.onCreate);
|
|
53525
53541
|
this.on("update", this.options.onUpdate);
|
|
53526
53542
|
this.on("selectionUpdate", this.options.onSelectionUpdate);
|
|
@@ -53542,8 +53558,12 @@ init_fn = function() {
|
|
|
53542
53558
|
if (!this.options.isHeadless) {
|
|
53543
53559
|
this.initializeCollaborationData();
|
|
53544
53560
|
this.initDefaultStyles();
|
|
53561
|
+
__privateMethod$1(this, _Editor_instances, checkFonts_fn).call(this);
|
|
53545
53562
|
}
|
|
53546
|
-
|
|
53563
|
+
const shouldMigrateListsOnInit = Boolean(
|
|
53564
|
+
this.options.markdown || this.options.html || this.options.loadFromSchema || this.options.jsonOverride || this.options.mode === "html" || this.options.mode === "text"
|
|
53565
|
+
);
|
|
53566
|
+
if (shouldMigrateListsOnInit) {
|
|
53547
53567
|
this.migrateListsToV2();
|
|
53548
53568
|
}
|
|
53549
53569
|
this.setDocumentMode(this.options.documentMode);
|
|
@@ -53684,52 +53704,18 @@ checkFonts_fn = async function() {
|
|
|
53684
53704
|
if (this.options.isHeadless) {
|
|
53685
53705
|
return;
|
|
53686
53706
|
}
|
|
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
53707
|
try {
|
|
53708
|
-
const
|
|
53709
|
-
const
|
|
53710
|
-
const unsupportedFonts = __privateMethod$1(this, _Editor_instances, determineUnsupportedFontsWithLocalFonts_fn).call(this, fontsUsedInDocument, uniqueLocalFonts);
|
|
53708
|
+
const fontsUsedInDocument = this.converter.getDocumentFonts();
|
|
53709
|
+
const unsupportedFonts = __privateMethod$1(this, _Editor_instances, determineUnsupportedFonts_fn).call(this, fontsUsedInDocument);
|
|
53711
53710
|
this.emit("fonts-resolved", {
|
|
53712
53711
|
documentFonts: fontsUsedInDocument,
|
|
53713
53712
|
unsupportedFonts
|
|
53714
53713
|
});
|
|
53715
53714
|
} 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
|
-
});
|
|
53715
|
+
console.warn("[SuperDoc] Could not determine document fonts and unsupported fonts");
|
|
53722
53716
|
}
|
|
53723
53717
|
};
|
|
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) {
|
|
53718
|
+
determineUnsupportedFonts_fn = function(fonts) {
|
|
53733
53719
|
const unsupportedFonts = fonts.filter((font) => {
|
|
53734
53720
|
const canRender = canRenderFont(font);
|
|
53735
53721
|
const isFontImported = this.fontsImported.includes(font);
|
|
@@ -53817,6 +53803,9 @@ onCollaborationReady_fn = function({ editor, ydoc }) {
|
|
|
53817
53803
|
if (this.options.collaborationIsReady) return;
|
|
53818
53804
|
console.debug("🔗 [super-editor] Collaboration ready");
|
|
53819
53805
|
__privateMethod$1(this, _Editor_instances, validateDocumentInit_fn).call(this);
|
|
53806
|
+
if (this.options.ydoc) {
|
|
53807
|
+
this.migrateListsToV2();
|
|
53808
|
+
}
|
|
53820
53809
|
this.options.onCollaborationReady({ editor, ydoc });
|
|
53821
53810
|
this.options.collaborationIsReady = true;
|
|
53822
53811
|
this.options.initialState = this.state;
|
|
@@ -64788,58 +64777,6 @@ const registerImages = async (foundImages, editor, view) => {
|
|
|
64788
64777
|
}
|
|
64789
64778
|
});
|
|
64790
64779
|
};
|
|
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
64780
|
const ImagePositionPluginKey = new PluginKey("ImagePosition");
|
|
64844
64781
|
const ImagePositionPlugin = ({ editor }) => {
|
|
64845
64782
|
const { view } = editor;
|
|
@@ -64852,8 +64789,9 @@ const ImagePositionPlugin = ({ editor }) => {
|
|
|
64852
64789
|
return DecorationSet.empty;
|
|
64853
64790
|
},
|
|
64854
64791
|
apply(tr, oldDecorationSet, oldState, newState) {
|
|
64855
|
-
if (!tr.docChanged) return oldDecorationSet;
|
|
64792
|
+
if (!tr.docChanged && !shouldUpdate) return oldDecorationSet;
|
|
64856
64793
|
const decorations = getImagePositionDecorations(newState, view);
|
|
64794
|
+
shouldUpdate = false;
|
|
64857
64795
|
return DecorationSet.create(newState.doc, decorations);
|
|
64858
64796
|
}
|
|
64859
64797
|
},
|
|
@@ -64862,7 +64800,6 @@ const ImagePositionPlugin = ({ editor }) => {
|
|
|
64862
64800
|
update: (view2, lastState) => {
|
|
64863
64801
|
const pagination = PaginationPluginKey.getState(lastState);
|
|
64864
64802
|
if (shouldUpdate) {
|
|
64865
|
-
shouldUpdate = false;
|
|
64866
64803
|
const decorations = getImagePositionDecorations(lastState, view2);
|
|
64867
64804
|
const updateTransaction = view2.state.tr.setMeta(ImagePositionPluginKey, { decorations });
|
|
64868
64805
|
view2.dispatch(updateTransaction);
|
|
@@ -64888,41 +64825,35 @@ const getImagePositionDecorations = (state2, view) => {
|
|
|
64888
64825
|
let className = "";
|
|
64889
64826
|
const { vRelativeFrom, alignH } = node.attrs.anchorData;
|
|
64890
64827
|
const { size: size2, padding } = node.attrs;
|
|
64891
|
-
const { marginOffset } = getNormalizedImageAttrs(node.attrs);
|
|
64892
64828
|
const pageBreak = findPreviousDomNodeWithClass(view, pos, "pagination-break-wrapper");
|
|
64893
|
-
if (pageBreak) {
|
|
64894
|
-
|
|
64895
|
-
|
|
64896
|
-
|
|
64897
|
-
|
|
64898
|
-
|
|
64899
|
-
|
|
64900
|
-
|
|
64901
|
-
|
|
64902
|
-
|
|
64903
|
-
|
|
64829
|
+
if (pageBreak && vRelativeFrom === "margin" && alignH) {
|
|
64830
|
+
const topPos = pageBreak?.offsetTop + pageBreak?.offsetHeight;
|
|
64831
|
+
let horizontalAlignment = `${alignH}: 0;`;
|
|
64832
|
+
if (alignH === "center") horizontalAlignment = "left: 50%; transform: translateX(-50%);";
|
|
64833
|
+
style2 += vRelativeFrom === "margin" ? `position: absolute; top: ${topPos}px; ${horizontalAlignment}` : "";
|
|
64834
|
+
const nextPos = view.posAtDOM(pageBreak, 1);
|
|
64835
|
+
if (nextPos < 0) {
|
|
64836
|
+
const $pos = view.state.doc.resolve(pos);
|
|
64837
|
+
decorations.push(
|
|
64838
|
+
Decoration.node(pos - 1, pos + $pos.parent.nodeSize - 1, {
|
|
64839
|
+
style: `height: ${size2.height + parseInt(padding.top) + parseInt(padding.bottom)}px`
|
|
64840
|
+
})
|
|
64841
|
+
);
|
|
64904
64842
|
}
|
|
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" }));
|
|
64843
|
+
const imageBlock = document.createElement("div");
|
|
64844
|
+
imageBlock.className = "anchor-image-placeholder";
|
|
64845
|
+
imageBlock.style.float = alignH === "left" || alignH === "right" ? alignH : "none";
|
|
64846
|
+
let paddingHorizontal;
|
|
64847
|
+
if (alignH === "center") {
|
|
64848
|
+
paddingHorizontal = (parseInt(padding.left) || 0) + (parseInt(padding.right) || 0);
|
|
64849
|
+
} else {
|
|
64850
|
+
paddingHorizontal = parseInt(padding[alignH]) || 0;
|
|
64923
64851
|
}
|
|
64852
|
+
imageBlock.style.width = size2.width + paddingHorizontal + "px";
|
|
64853
|
+
imageBlock.style.height = size2.height + parseInt(padding.top) + parseInt(padding.bottom) + "px";
|
|
64854
|
+
decorations.push(Decoration.widget(nextPos, imageBlock, { key: "stable-key" }));
|
|
64855
|
+
decorations.push(Decoration.inline(pos, pos + node.nodeSize, { style: style2, class: className }));
|
|
64924
64856
|
}
|
|
64925
|
-
decorations.push(Decoration.inline(pos, pos + node.nodeSize, { style: style2, class: className }));
|
|
64926
64857
|
}
|
|
64927
64858
|
});
|
|
64928
64859
|
return decorations;
|
|
@@ -64947,6 +64878,58 @@ const findPreviousDomNodeWithClass = (view, pos, className) => {
|
|
|
64947
64878
|
}
|
|
64948
64879
|
return null;
|
|
64949
64880
|
};
|
|
64881
|
+
const normalizeWrap = (attrs = {}) => {
|
|
64882
|
+
const wrap2 = attrs.wrap;
|
|
64883
|
+
if (wrap2?.type && wrap2.type !== "Inline") {
|
|
64884
|
+
return {
|
|
64885
|
+
type: wrap2.type,
|
|
64886
|
+
attrs: wrap2.attrs ?? {}
|
|
64887
|
+
};
|
|
64888
|
+
}
|
|
64889
|
+
if (wrap2?.type === "Inline" && Object.keys(wrap2.attrs ?? {}).length) {
|
|
64890
|
+
return {
|
|
64891
|
+
type: "Inline",
|
|
64892
|
+
attrs: wrap2.attrs
|
|
64893
|
+
};
|
|
64894
|
+
}
|
|
64895
|
+
if (!wrap2 && attrs.wrapText) {
|
|
64896
|
+
return {
|
|
64897
|
+
type: "Square",
|
|
64898
|
+
attrs: {
|
|
64899
|
+
wrapText: attrs.wrapText
|
|
64900
|
+
}
|
|
64901
|
+
};
|
|
64902
|
+
}
|
|
64903
|
+
if (!wrap2 && attrs.wrapTopAndBottom) {
|
|
64904
|
+
return {
|
|
64905
|
+
type: "TopAndBottom",
|
|
64906
|
+
attrs: {}
|
|
64907
|
+
};
|
|
64908
|
+
}
|
|
64909
|
+
if (wrap2?.type === "Inline") {
|
|
64910
|
+
return {
|
|
64911
|
+
type: "Inline",
|
|
64912
|
+
attrs: wrap2.attrs ?? {}
|
|
64913
|
+
};
|
|
64914
|
+
}
|
|
64915
|
+
return {
|
|
64916
|
+
type: "Inline",
|
|
64917
|
+
attrs: {}
|
|
64918
|
+
};
|
|
64919
|
+
};
|
|
64920
|
+
const normalizeMarginOffset = (marginOffset = {}) => {
|
|
64921
|
+
const { left: left2, horizontal, ...rest } = marginOffset;
|
|
64922
|
+
return {
|
|
64923
|
+
...rest,
|
|
64924
|
+
horizontal: horizontal ?? left2
|
|
64925
|
+
};
|
|
64926
|
+
};
|
|
64927
|
+
const getNormalizedImageAttrs = (attrs = {}) => {
|
|
64928
|
+
return {
|
|
64929
|
+
wrap: normalizeWrap(attrs),
|
|
64930
|
+
marginOffset: normalizeMarginOffset(attrs.marginOffset ?? {})
|
|
64931
|
+
};
|
|
64932
|
+
};
|
|
64950
64933
|
const getRotationMargins = (w2, h2, angleDegrees) => {
|
|
64951
64934
|
const rad = angleDegrees * (Math.PI / 180);
|
|
64952
64935
|
const cos = Math.abs(Math.cos(rad));
|
|
@@ -65155,27 +65138,15 @@ const Image = Node$1.create({
|
|
|
65155
65138
|
style2 += "float: right;";
|
|
65156
65139
|
floatRight = true;
|
|
65157
65140
|
} 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
|
-
}
|
|
65141
|
+
const pageStylesData2 = getDataFromPageStyles({
|
|
65142
|
+
editor: this.editor,
|
|
65143
|
+
marginOffset,
|
|
65144
|
+
size: size2,
|
|
65145
|
+
attrs
|
|
65146
|
+
});
|
|
65147
|
+
style2 += pageStylesData2.style;
|
|
65148
|
+
floatRight = pageStylesData2.floatRight;
|
|
65149
|
+
baseHorizontal = pageStylesData2.baseHorizontal;
|
|
65179
65150
|
}
|
|
65180
65151
|
if (attrs.distTop) margin.top += attrs.distTop;
|
|
65181
65152
|
if (attrs.distBottom) margin.bottom += attrs.distBottom;
|
|
@@ -65185,27 +65156,15 @@ const Image = Node$1.create({
|
|
|
65185
65156
|
case "Through":
|
|
65186
65157
|
case "Tight":
|
|
65187
65158
|
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
|
-
}
|
|
65159
|
+
const pageStylesData = getDataFromPageStyles({
|
|
65160
|
+
editor: this.editor,
|
|
65161
|
+
marginOffset,
|
|
65162
|
+
size: size2,
|
|
65163
|
+
attrs
|
|
65164
|
+
});
|
|
65165
|
+
style2 += pageStylesData.style;
|
|
65166
|
+
floatRight = pageStylesData.floatRight;
|
|
65167
|
+
baseHorizontal = pageStylesData.baseHorizontal;
|
|
65209
65168
|
if (attrs.distTop) margin.top += attrs.distTop;
|
|
65210
65169
|
if (attrs.distBottom) margin.bottom += attrs.distBottom;
|
|
65211
65170
|
if (attrs.distLeft) margin.left += attrs.distLeft;
|
|
@@ -65242,6 +65201,22 @@ const Image = Node$1.create({
|
|
|
65242
65201
|
}
|
|
65243
65202
|
const hasAnchorData = Boolean(anchorData);
|
|
65244
65203
|
const hasMarginOffsets = marginOffset?.horizontal != null || marginOffset?.top != null;
|
|
65204
|
+
if (hasAnchorData) {
|
|
65205
|
+
switch (anchorData.hRelativeFrom) {
|
|
65206
|
+
case "page":
|
|
65207
|
+
const pageStyles = this.editor?.converter?.pageStyles || this.editor?.options.parentEditor?.converter?.pageStyles;
|
|
65208
|
+
margin.left -= inchesToPixels(pageStyles?.pageMargins?.left) || 0;
|
|
65209
|
+
break;
|
|
65210
|
+
case "margin":
|
|
65211
|
+
if (anchorData.alignH === "center") {
|
|
65212
|
+
style2 += "position: absolute; left: 50%; transform: translateX(-50%);";
|
|
65213
|
+
}
|
|
65214
|
+
if (anchorData.alignH === "left" || anchorData.alignH === "right") {
|
|
65215
|
+
style2 += `position: absolute; ${anchorData.alignH}: 0;`;
|
|
65216
|
+
}
|
|
65217
|
+
break;
|
|
65218
|
+
}
|
|
65219
|
+
}
|
|
65245
65220
|
if (hasAnchorData || hasMarginOffsets) {
|
|
65246
65221
|
const relativeFromPageV = anchorData?.vRelativeFrom === "page";
|
|
65247
65222
|
const maxMarginV = 500;
|
|
@@ -65390,6 +65365,37 @@ const Image = Node$1.create({
|
|
|
65390
65365
|
return [ImageRegistrationPlugin({ editor: this.editor }), ImagePositionPlugin({ editor: this.editor })];
|
|
65391
65366
|
}
|
|
65392
65367
|
});
|
|
65368
|
+
const getDataFromPageStyles = ({ editor, marginOffset, size: size2, attrs }) => {
|
|
65369
|
+
let style2 = "";
|
|
65370
|
+
let floatRight = false;
|
|
65371
|
+
let baseHorizontal = marginOffset?.horizontal || 0;
|
|
65372
|
+
const pageStyles = editor?.converter?.pageStyles || editor?.options.parentEditor?.converter?.pageStyles;
|
|
65373
|
+
if (pageStyles?.pageSize && pageStyles?.pageMargins && size2.width) {
|
|
65374
|
+
const pageWidth = inchesToPixels(pageStyles.pageSize.width);
|
|
65375
|
+
const leftMargin = inchesToPixels(pageStyles.pageMargins.left);
|
|
65376
|
+
const rightMargin = inchesToPixels(pageStyles.pageMargins.right);
|
|
65377
|
+
const contentWidth = pageWidth - leftMargin - rightMargin;
|
|
65378
|
+
const imageWidth = size2.width + (attrs.distLeft || 0) + (attrs.distRight || 0);
|
|
65379
|
+
const leftSpace = marginOffset.horizontal;
|
|
65380
|
+
const rightSpace = contentWidth - leftSpace - imageWidth;
|
|
65381
|
+
if (rightSpace < 0) {
|
|
65382
|
+
style2 += "float: left;";
|
|
65383
|
+
} else if (rightSpace > leftSpace) {
|
|
65384
|
+
style2 += "float: left;";
|
|
65385
|
+
} else {
|
|
65386
|
+
style2 += "float: right;";
|
|
65387
|
+
floatRight = true;
|
|
65388
|
+
baseHorizontal = rightSpace;
|
|
65389
|
+
}
|
|
65390
|
+
} else {
|
|
65391
|
+
style2 += "float: left;";
|
|
65392
|
+
}
|
|
65393
|
+
return {
|
|
65394
|
+
style: style2,
|
|
65395
|
+
floatRight,
|
|
65396
|
+
baseHorizontal
|
|
65397
|
+
};
|
|
65398
|
+
};
|
|
65393
65399
|
const ACCEPT_IMAGE_TYPES = [".jpg", ".jpeg", ".png", "image/jpeg", "image/png"];
|
|
65394
65400
|
const getFileOpener = () => {
|
|
65395
65401
|
let fileInput = document.createElement("input");
|
|
@@ -72832,7 +72838,7 @@ const nodeResizer = (nodeNames = ["image"], editor) => {
|
|
|
72832
72838
|
return oldState;
|
|
72833
72839
|
}
|
|
72834
72840
|
if (typeof document === "undefined" || editor.options.isHeadless) return oldState;
|
|
72835
|
-
if (editor.options.documentMode === "viewing" || !editor.isEditable) {
|
|
72841
|
+
if (!editor.options.isHeaderOrFooter && (editor.options.documentMode === "viewing" || !editor.isEditable)) {
|
|
72836
72842
|
return DecorationSet.empty;
|
|
72837
72843
|
}
|
|
72838
72844
|
const { selection } = newState;
|
|
@@ -88974,8 +88980,12 @@ const Extensions = {
|
|
|
88974
88980
|
Node: Node$1,
|
|
88975
88981
|
Attribute: Attribute2,
|
|
88976
88982
|
Extension,
|
|
88983
|
+
Mark: Mark2,
|
|
88984
|
+
//
|
|
88977
88985
|
Plugin,
|
|
88978
|
-
|
|
88986
|
+
PluginKey,
|
|
88987
|
+
Decoration,
|
|
88988
|
+
DecorationSet
|
|
88979
88989
|
};
|
|
88980
88990
|
export {
|
|
88981
88991
|
AIWriter as A,
|