@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
|
@@ -9,12 +9,12 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
|
|
|
9
9
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
10
10
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
11
11
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
12
|
-
var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _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,
|
|
12
|
+
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;
|
|
13
13
|
import * as Y from "yjs";
|
|
14
14
|
import { UndoManager, Item as Item$1, ContentType, Text as Text$1, XmlElement, encodeStateAsUpdate } from "yjs";
|
|
15
|
-
import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as ReplaceStep, E as NodeRange, G as findWrapping, L as ListHelpers, H as findParentNode, I as isMacOS, J as isIOS, K as getSchemaTypeByName, O as inputRulesPlugin, Q as TrackDeleteMarkName, U as TrackInsertMarkName, V as v4, W as TrackFormatMarkName, X as comments_module_events, Y as findMark, Z as objectIncludes, _ as AddMarkStep, $ as RemoveMarkStep, a0 as twipsToLines, a1 as pixelsToTwips, a2 as helpers, a3 as posToDOMRect, a4 as CommandService, a5 as SuperConverter, a6 as createDocument, a7 as createDocFromMarkdown, a8 as createDocFromHTML, a9 as EditorState, aa as hasSomeParentWithClass, ab as isActive, ac as unflattenListsInHtml, ad as parseSizeUnit, ae as minMax, af as getLineHeightValueString, ag as updateDOMAttributes, ah as findChildren$5, ai as htmlHandler, aj as generateRandomSigned32BitIntStrId, ak as InputRule, al as kebabCase, am as findParentNodeClosestToPos, an as getListItemStyleDefinitions, ao as docxNumberigHelpers, ap as parseIndentElement, aq as combineIndents, ar as twipsToPixels, as as PIXELS_PER_INCH, at as SelectionRange, au as Transform, av as isInTable$1, aw as generateDocxRandomId, ax as insertNewRelationship, ay as inchesToPixels } from "./converter-
|
|
15
|
+
import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as ReplaceStep, E as NodeRange, G as findWrapping, L as ListHelpers, H as findParentNode, I as isMacOS, J as isIOS, K as getSchemaTypeByName, O as inputRulesPlugin, Q as TrackDeleteMarkName, U as TrackInsertMarkName, V as v4, W as TrackFormatMarkName, X as comments_module_events, Y as findMark, Z as objectIncludes, _ as AddMarkStep, $ as RemoveMarkStep, a0 as twipsToLines, a1 as pixelsToTwips, a2 as helpers, a3 as posToDOMRect, a4 as CommandService, a5 as SuperConverter, a6 as createDocument, a7 as createDocFromMarkdown, a8 as createDocFromHTML, a9 as EditorState, aa as hasSomeParentWithClass, ab as isActive, ac as unflattenListsInHtml, ad as parseSizeUnit, ae as minMax, af as getLineHeightValueString, ag as updateDOMAttributes, ah as findChildren$5, ai as htmlHandler, aj as generateRandomSigned32BitIntStrId, ak as InputRule, al as kebabCase, am as findParentNodeClosestToPos, an as getListItemStyleDefinitions, ao as docxNumberigHelpers, ap as parseIndentElement, aq as combineIndents, ar as twipsToPixels, as as PIXELS_PER_INCH, at as SelectionRange, au as Transform, av as isInTable$1, aw as generateDocxRandomId, ax as insertNewRelationship, ay as inchesToPixels } from "./converter-khE-H7hH.js";
|
|
16
16
|
import { ref, computed, createElementBlock, openBlock, withModifiers, Fragment as Fragment$1, renderList, normalizeClass, createCommentVNode, toDisplayString, createElementVNode, createApp } from "vue";
|
|
17
|
-
import { D as DocxZipper } from "./docx-zipper-
|
|
17
|
+
import { D as DocxZipper } from "./docx-zipper-KoUEtzIj.js";
|
|
18
18
|
var GOOD_LEAF_SIZE = 200;
|
|
19
19
|
var RopeSequence = function RopeSequence2() {
|
|
20
20
|
};
|
|
@@ -14294,7 +14294,9 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14294
14294
|
isHeaderFooterChanged: false,
|
|
14295
14295
|
isCustomXmlChanged: false,
|
|
14296
14296
|
focusTarget: null,
|
|
14297
|
-
permissionResolver: null
|
|
14297
|
+
permissionResolver: null,
|
|
14298
|
+
// header/footer editors may have parent(main) editor set
|
|
14299
|
+
parentEditor: null
|
|
14298
14300
|
});
|
|
14299
14301
|
__privateMethod(this, _Editor_instances, initContainerElement_fn).call(this, options);
|
|
14300
14302
|
__privateMethod(this, _Editor_instances, checkHeadless_fn).call(this, options);
|
|
@@ -15056,7 +15058,7 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
15056
15058
|
* @returns {Object | void} Migration results
|
|
15057
15059
|
*/
|
|
15058
15060
|
processCollaborationMigrations() {
|
|
15059
|
-
console.debug("[checkVersionMigrations] Current editor version", "0.
|
|
15061
|
+
console.debug("[checkVersionMigrations] Current editor version", "0.25.0");
|
|
15060
15062
|
if (!this.options.ydoc) return;
|
|
15061
15063
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
15062
15064
|
let docVersion = metaMap.get("version");
|
|
@@ -15271,9 +15273,6 @@ init_fn = function() {
|
|
|
15271
15273
|
this.emit("beforeCreate", { editor: this });
|
|
15272
15274
|
this.on("contentError", this.options.onContentError);
|
|
15273
15275
|
this.mount(this.options.element);
|
|
15274
|
-
if (!this.options.isHeadless) {
|
|
15275
|
-
__privateMethod(this, _Editor_instances, checkFonts_fn).call(this);
|
|
15276
|
-
}
|
|
15277
15276
|
this.on("create", this.options.onCreate);
|
|
15278
15277
|
this.on("update", this.options.onUpdate);
|
|
15279
15278
|
this.on("selectionUpdate", this.options.onSelectionUpdate);
|
|
@@ -15295,8 +15294,12 @@ init_fn = function() {
|
|
|
15295
15294
|
if (!this.options.isHeadless) {
|
|
15296
15295
|
this.initializeCollaborationData();
|
|
15297
15296
|
this.initDefaultStyles();
|
|
15297
|
+
__privateMethod(this, _Editor_instances, checkFonts_fn).call(this);
|
|
15298
15298
|
}
|
|
15299
|
-
|
|
15299
|
+
const shouldMigrateListsOnInit = Boolean(
|
|
15300
|
+
this.options.markdown || this.options.html || this.options.loadFromSchema || this.options.jsonOverride || this.options.mode === "html" || this.options.mode === "text"
|
|
15301
|
+
);
|
|
15302
|
+
if (shouldMigrateListsOnInit) {
|
|
15300
15303
|
this.migrateListsToV2();
|
|
15301
15304
|
}
|
|
15302
15305
|
this.setDocumentMode(this.options.documentMode);
|
|
@@ -15490,58 +15493,17 @@ checkFonts_fn = async function() {
|
|
|
15490
15493
|
if (this.options.isHeadless) {
|
|
15491
15494
|
return;
|
|
15492
15495
|
}
|
|
15493
|
-
const fontsUsedInDocument = this.converter.getDocumentFonts();
|
|
15494
|
-
if (!("queryLocalFonts" in window)) {
|
|
15495
|
-
console.warn("[SuperDoc] Could not get access to local fonts. Using fallback solution.");
|
|
15496
|
-
const unsupportedFonts = __privateMethod(this, _Editor_instances, determineUnsupportedFontsWithCanvas_fn).call(this, fontsUsedInDocument);
|
|
15497
|
-
this.emit("fonts-resolved", {
|
|
15498
|
-
documentFonts: fontsUsedInDocument,
|
|
15499
|
-
unsupportedFonts
|
|
15500
|
-
});
|
|
15501
|
-
return;
|
|
15502
|
-
}
|
|
15503
|
-
const localFontAccess = await navigator.permissions.query({ name: "local-fonts" });
|
|
15504
|
-
if (localFontAccess.state === "denied") {
|
|
15505
|
-
console.warn("[SuperDoc] Could not get access to local fonts. Using fallback solution.");
|
|
15506
|
-
const unsupportedFonts = __privateMethod(this, _Editor_instances, determineUnsupportedFontsWithCanvas_fn).call(this, fontsUsedInDocument);
|
|
15507
|
-
this.emit("fonts-resolved", {
|
|
15508
|
-
documentFonts: fontsUsedInDocument,
|
|
15509
|
-
unsupportedFonts
|
|
15510
|
-
});
|
|
15511
|
-
return;
|
|
15512
|
-
}
|
|
15513
15496
|
try {
|
|
15514
|
-
const
|
|
15515
|
-
const
|
|
15516
|
-
const unsupportedFonts = __privateMethod(this, _Editor_instances, determineUnsupportedFontsWithLocalFonts_fn).call(this, fontsUsedInDocument, uniqueLocalFonts);
|
|
15497
|
+
const fontsUsedInDocument = this.converter.getDocumentFonts();
|
|
15498
|
+
const unsupportedFonts = __privateMethod(this, _Editor_instances, determineUnsupportedFonts_fn).call(this, fontsUsedInDocument);
|
|
15517
15499
|
this.emit("fonts-resolved", {
|
|
15518
15500
|
documentFonts: fontsUsedInDocument,
|
|
15519
15501
|
unsupportedFonts
|
|
15520
15502
|
});
|
|
15521
15503
|
} catch {
|
|
15522
|
-
console.warn("[SuperDoc] Could not
|
|
15523
|
-
const unsupportedFonts = __privateMethod(this, _Editor_instances, determineUnsupportedFontsWithCanvas_fn).call(this, fontsUsedInDocument);
|
|
15524
|
-
this.emit("fonts-resolved", {
|
|
15525
|
-
documentFonts: fontsUsedInDocument,
|
|
15526
|
-
unsupportedFonts
|
|
15527
|
-
});
|
|
15504
|
+
console.warn("[SuperDoc] Could not determine document fonts and unsupported fonts");
|
|
15528
15505
|
}
|
|
15529
15506
|
};
|
|
15530
|
-
/**
|
|
15531
|
-
* Determines which fonts used in the document are not available locally nor imported.
|
|
15532
|
-
*
|
|
15533
|
-
* @param {string[]} fonts - Array of font family names used in the document.
|
|
15534
|
-
* @param {string[]} localFonts - Array of local font family names available on the system.
|
|
15535
|
-
* @returns {string[]} Array of font names that are unsupported.
|
|
15536
|
-
*/
|
|
15537
|
-
determineUnsupportedFontsWithLocalFonts_fn = function(fonts, localFonts) {
|
|
15538
|
-
const unsupportedFonts = fonts.filter((font) => {
|
|
15539
|
-
const isLocalFont = localFonts.includes(font);
|
|
15540
|
-
const isFontImported = this.fontsImported.includes(font);
|
|
15541
|
-
return !isLocalFont && !isFontImported;
|
|
15542
|
-
});
|
|
15543
|
-
return unsupportedFonts;
|
|
15544
|
-
};
|
|
15545
15507
|
/**
|
|
15546
15508
|
* Determines which fonts used in the document are not supported
|
|
15547
15509
|
* by attempting to render them on a canvas.
|
|
@@ -15551,7 +15513,7 @@ determineUnsupportedFontsWithLocalFonts_fn = function(fonts, localFonts) {
|
|
|
15551
15513
|
* @param {string[]} fonts - Array of font family names used in the document.
|
|
15552
15514
|
* @returns {string[]} Array of unsupported font family names.
|
|
15553
15515
|
*/
|
|
15554
|
-
|
|
15516
|
+
determineUnsupportedFonts_fn = function(fonts) {
|
|
15555
15517
|
const unsupportedFonts = fonts.filter((font) => {
|
|
15556
15518
|
const canRender = canRenderFont(font);
|
|
15557
15519
|
const isFontImported = this.fontsImported.includes(font);
|
|
@@ -15660,6 +15622,9 @@ onCollaborationReady_fn = function({ editor, ydoc }) {
|
|
|
15660
15622
|
if (this.options.collaborationIsReady) return;
|
|
15661
15623
|
console.debug("🔗 [super-editor] Collaboration ready");
|
|
15662
15624
|
__privateMethod(this, _Editor_instances, validateDocumentInit_fn).call(this);
|
|
15625
|
+
if (this.options.ydoc) {
|
|
15626
|
+
this.migrateListsToV2();
|
|
15627
|
+
}
|
|
15663
15628
|
this.options.onCollaborationReady({ editor, ydoc });
|
|
15664
15629
|
this.options.collaborationIsReady = true;
|
|
15665
15630
|
this.options.initialState = this.state;
|
|
@@ -17639,10 +17604,27 @@ function getStructuredContentBlockTags(state) {
|
|
|
17639
17604
|
const result = findChildren$5(state.doc, (node) => node.type.name === "structuredContentBlock");
|
|
17640
17605
|
return result;
|
|
17641
17606
|
}
|
|
17607
|
+
function getStructuredContentTablesById(id, state) {
|
|
17608
|
+
if (!id || !state) return [];
|
|
17609
|
+
const blocks = getStructuredContentTagsById(id, state).filter(
|
|
17610
|
+
({ node }) => node.type.name === "structuredContentBlock"
|
|
17611
|
+
);
|
|
17612
|
+
if (!blocks.length) return [];
|
|
17613
|
+
const { pos: blockPos, node: blockNode } = blocks[0];
|
|
17614
|
+
const tablesInBlock = [];
|
|
17615
|
+
blockNode.descendants((child, relPos) => {
|
|
17616
|
+
if (child.type.name === "table") {
|
|
17617
|
+
const absPos = blockPos + 1 + relPos;
|
|
17618
|
+
tablesInBlock.push({ node: child, pos: absPos });
|
|
17619
|
+
}
|
|
17620
|
+
});
|
|
17621
|
+
return tablesInBlock;
|
|
17622
|
+
}
|
|
17642
17623
|
const structuredContentHelpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
17643
17624
|
__proto__: null,
|
|
17644
17625
|
getStructuredContentBlockTags,
|
|
17645
17626
|
getStructuredContentInlineTags,
|
|
17627
|
+
getStructuredContentTablesById,
|
|
17646
17628
|
getStructuredContentTags,
|
|
17647
17629
|
getStructuredContentTagsById
|
|
17648
17630
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
@@ -17839,6 +17821,36 @@ const StructuredContentCommands = Extension.create({
|
|
|
17839
17821
|
tr.replaceWith(posFrom, posTo, content);
|
|
17840
17822
|
}
|
|
17841
17823
|
return true;
|
|
17824
|
+
},
|
|
17825
|
+
/**
|
|
17826
|
+
* Append multiple rows to the end of a table inside a structured content block.
|
|
17827
|
+
* Each inner array represents the cell values for one new row.
|
|
17828
|
+
* @category Command
|
|
17829
|
+
* @param {StructuredContentTableAppendRowsOptions} options - Append configuration
|
|
17830
|
+
* @example
|
|
17831
|
+
* editor.commands.appendRowsToStructuredContentTable({
|
|
17832
|
+
* id: 'block-123',
|
|
17833
|
+
* tableIndex: 0,
|
|
17834
|
+
* rows: [['A', 'B'], ['C', 'D']],
|
|
17835
|
+
* copyRowStyle: true,
|
|
17836
|
+
* });
|
|
17837
|
+
*/
|
|
17838
|
+
appendRowsToStructuredContentTable: ({ id, tableIndex = 0, rows = [], copyRowStyle = false }) => ({ state, commands: commands2, dispatch }) => {
|
|
17839
|
+
const normalized = normalizeRowsInput(rows);
|
|
17840
|
+
if (!normalized.length) return true;
|
|
17841
|
+
const tables = getStructuredContentTablesById(id, state);
|
|
17842
|
+
if (!tables.length || tableIndex < 0 || tableIndex >= tables.length) return true;
|
|
17843
|
+
const { node: tableNode, pos: tablePos } = tables[tableIndex];
|
|
17844
|
+
if (dispatch) {
|
|
17845
|
+
return commands2.appendRowsWithContent({ tablePos, tableNode, valueRows: normalized, copyRowStyle });
|
|
17846
|
+
}
|
|
17847
|
+
return commands2.appendRowsWithContent({
|
|
17848
|
+
tablePos,
|
|
17849
|
+
tableNode,
|
|
17850
|
+
valueRows: normalized,
|
|
17851
|
+
copyRowStyle,
|
|
17852
|
+
dispatch: false
|
|
17853
|
+
});
|
|
17842
17854
|
}
|
|
17843
17855
|
};
|
|
17844
17856
|
},
|
|
@@ -17848,6 +17860,15 @@ const StructuredContentCommands = Extension.create({
|
|
|
17848
17860
|
};
|
|
17849
17861
|
}
|
|
17850
17862
|
});
|
|
17863
|
+
const normalizeRowsInput = (rowsOrValues) => {
|
|
17864
|
+
if (!Array.isArray(rowsOrValues) || !rowsOrValues.length) {
|
|
17865
|
+
return [];
|
|
17866
|
+
}
|
|
17867
|
+
if (Array.isArray(rowsOrValues[0])) {
|
|
17868
|
+
return rowsOrValues;
|
|
17869
|
+
}
|
|
17870
|
+
return [rowsOrValues];
|
|
17871
|
+
};
|
|
17851
17872
|
class DocumentSectionView {
|
|
17852
17873
|
constructor(node, getPos, decorations, editor) {
|
|
17853
17874
|
__privateAdd(this, _DocumentSectionView_instances);
|
|
@@ -23600,6 +23621,107 @@ function cellWrapping($pos) {
|
|
|
23600
23621
|
}
|
|
23601
23622
|
return null;
|
|
23602
23623
|
}
|
|
23624
|
+
function resolveTable(tr, tablePos, tableNode) {
|
|
23625
|
+
if (tableNode && tableNode.type && tableNode.type.name === "table") {
|
|
23626
|
+
return tableNode;
|
|
23627
|
+
}
|
|
23628
|
+
if (typeof tablePos === "number") {
|
|
23629
|
+
const current = tr.doc.nodeAt(tablePos);
|
|
23630
|
+
if (current && current.type.name === "table") {
|
|
23631
|
+
return current;
|
|
23632
|
+
}
|
|
23633
|
+
}
|
|
23634
|
+
return null;
|
|
23635
|
+
}
|
|
23636
|
+
function pickTemplateRowForAppend(tableNode, schema) {
|
|
23637
|
+
const RowType = schema.nodes.tableRow;
|
|
23638
|
+
const rows = [];
|
|
23639
|
+
tableNode.descendants((child) => {
|
|
23640
|
+
if (child.type === RowType) rows.push(child);
|
|
23641
|
+
});
|
|
23642
|
+
if (!rows.length) return null;
|
|
23643
|
+
for (let i = rows.length - 1; i >= 0; i--) {
|
|
23644
|
+
const r2 = rows[i];
|
|
23645
|
+
const hasBodyCell = r2.content?.content?.some((c) => c.type.name === "tableCell");
|
|
23646
|
+
if (hasBodyCell) return r2;
|
|
23647
|
+
}
|
|
23648
|
+
return rows[rows.length - 1];
|
|
23649
|
+
}
|
|
23650
|
+
function extractRowTemplateFormatting(cellNode, schema) {
|
|
23651
|
+
const ParagraphType = schema.nodes.paragraph;
|
|
23652
|
+
let blockType = ParagraphType;
|
|
23653
|
+
let blockAttrs = null;
|
|
23654
|
+
let textMarks = [];
|
|
23655
|
+
const blocks = cellNode?.content?.content || [];
|
|
23656
|
+
for (const block of blocks) {
|
|
23657
|
+
const isParagraphish = block.type === ParagraphType || block.type.name === "heading";
|
|
23658
|
+
if (isParagraphish) {
|
|
23659
|
+
blockType = block.type || ParagraphType;
|
|
23660
|
+
blockAttrs = block.attrs || null;
|
|
23661
|
+
}
|
|
23662
|
+
let foundText = null;
|
|
23663
|
+
block.descendants?.((n) => {
|
|
23664
|
+
if (!foundText && n.isText) foundText = n;
|
|
23665
|
+
});
|
|
23666
|
+
if (foundText) {
|
|
23667
|
+
textMarks = foundText.marks ? Array.from(foundText.marks) : [];
|
|
23668
|
+
break;
|
|
23669
|
+
}
|
|
23670
|
+
}
|
|
23671
|
+
if (!blockType || !blockType.validContent) blockType = ParagraphType;
|
|
23672
|
+
return { blockType, blockAttrs, textMarks };
|
|
23673
|
+
}
|
|
23674
|
+
function buildFormattedCellBlock(schema, value, { blockType, blockAttrs, textMarks }, copyRowStyle = false) {
|
|
23675
|
+
const text = typeof value === "string" ? value : value == null ? "" : String(value);
|
|
23676
|
+
const marks = copyRowStyle ? textMarks || [] : [];
|
|
23677
|
+
const textNode = schema.text(text, marks);
|
|
23678
|
+
const type = blockType || schema.nodes.paragraph;
|
|
23679
|
+
return type.createAndFill(blockAttrs || null, textNode);
|
|
23680
|
+
}
|
|
23681
|
+
function buildRowFromTemplateRow({ schema, tableNode, templateRow, values, copyRowStyle = false }) {
|
|
23682
|
+
const RowType = schema.nodes.tableRow;
|
|
23683
|
+
const CellType = schema.nodes.tableCell;
|
|
23684
|
+
const HeaderType = schema.nodes.tableHeader;
|
|
23685
|
+
const map2 = TableMap.get(tableNode);
|
|
23686
|
+
const totalColumns = map2.width;
|
|
23687
|
+
const byColumns = Array.isArray(values) && values.length === totalColumns;
|
|
23688
|
+
const newCells = [];
|
|
23689
|
+
let columnCursor = 0;
|
|
23690
|
+
templateRow.content.content.forEach((cellNode, cellIndex) => {
|
|
23691
|
+
const isHeaderCell = cellNode.type === HeaderType;
|
|
23692
|
+
const targetCellType = isHeaderCell ? CellType : cellNode.type;
|
|
23693
|
+
const attrs = { ...cellNode.attrs };
|
|
23694
|
+
const formatting = extractRowTemplateFormatting(cellNode, schema);
|
|
23695
|
+
let cellValue = "";
|
|
23696
|
+
if (byColumns) {
|
|
23697
|
+
const span = Math.max(1, attrs.colspan || 1);
|
|
23698
|
+
cellValue = values[columnCursor] ?? "";
|
|
23699
|
+
columnCursor += span;
|
|
23700
|
+
} else {
|
|
23701
|
+
cellValue = Array.isArray(values) ? values[cellIndex] ?? "" : "";
|
|
23702
|
+
}
|
|
23703
|
+
const content = buildFormattedCellBlock(schema, cellValue, formatting, copyRowStyle);
|
|
23704
|
+
const newCell = targetCellType.createAndFill(attrs, content);
|
|
23705
|
+
if (newCell) newCells.push(newCell);
|
|
23706
|
+
});
|
|
23707
|
+
return RowType.createAndFill(null, newCells);
|
|
23708
|
+
}
|
|
23709
|
+
function insertRowsAtTableEnd({ tr, tablePos, tableNode, rows }) {
|
|
23710
|
+
if (!rows || !rows.length) return;
|
|
23711
|
+
const RowTypeName = "tableRow";
|
|
23712
|
+
let lastRowRelPos = 0;
|
|
23713
|
+
let lastRowNode = null;
|
|
23714
|
+
tableNode.descendants((child, relPos) => {
|
|
23715
|
+
if (child.type.name === RowTypeName) {
|
|
23716
|
+
lastRowRelPos = relPos;
|
|
23717
|
+
lastRowNode = child;
|
|
23718
|
+
}
|
|
23719
|
+
});
|
|
23720
|
+
if (!lastRowNode) return;
|
|
23721
|
+
const lastRowAbsEnd = tablePos + 1 + lastRowRelPos + lastRowNode.nodeSize;
|
|
23722
|
+
const frag = Fragment.fromArray(rows);
|
|
23723
|
+
tr.insert(lastRowAbsEnd, frag);
|
|
23724
|
+
}
|
|
23603
23725
|
const Table = Node$1.create({
|
|
23604
23726
|
name: "table",
|
|
23605
23727
|
content: "tableRow+",
|
|
@@ -23759,6 +23881,47 @@ const Table = Node$1.create({
|
|
|
23759
23881
|
},
|
|
23760
23882
|
addCommands() {
|
|
23761
23883
|
return {
|
|
23884
|
+
/**
|
|
23885
|
+
* Append multiple rows to the end of a table in a single transaction.
|
|
23886
|
+
* @category Command
|
|
23887
|
+
* @param {appendRowsWithContentOptions} options - Append configuration
|
|
23888
|
+
* @example
|
|
23889
|
+
* editor.commands.appendRowsWithContent({ tablePos, valueRows: [['A','B'], ['C','D']], copyRowStyle: true })
|
|
23890
|
+
*/
|
|
23891
|
+
appendRowsWithContent: ({ tablePos, tableNode, valueRows = [], copyRowStyle = false }) => ({ editor, chain }) => {
|
|
23892
|
+
if (typeof tablePos !== "number" && !tableNode || !Array.isArray(valueRows) || !valueRows.length) {
|
|
23893
|
+
return false;
|
|
23894
|
+
}
|
|
23895
|
+
return chain().command(({ tr, dispatch }) => {
|
|
23896
|
+
const workingTable = resolveTable(tr, tablePos, tableNode);
|
|
23897
|
+
if (!workingTable) return false;
|
|
23898
|
+
const templateRow = pickTemplateRowForAppend(workingTable, editor.schema);
|
|
23899
|
+
if (!templateRow) return false;
|
|
23900
|
+
const newRows = valueRows.map(
|
|
23901
|
+
(vals) => buildRowFromTemplateRow({
|
|
23902
|
+
schema: editor.schema,
|
|
23903
|
+
tableNode: workingTable,
|
|
23904
|
+
templateRow,
|
|
23905
|
+
values: vals,
|
|
23906
|
+
copyRowStyle
|
|
23907
|
+
})
|
|
23908
|
+
).filter(Boolean);
|
|
23909
|
+
if (!newRows.length) return false;
|
|
23910
|
+
let resolvedTablePos = tablePos;
|
|
23911
|
+
if (typeof resolvedTablePos !== "number" && workingTable) {
|
|
23912
|
+
const tables = editor.getNodesOfType("table");
|
|
23913
|
+
const match = workingTable ? tables.find((t) => t.node.eq(workingTable)) : tables[0];
|
|
23914
|
+
resolvedTablePos = match?.pos ?? null;
|
|
23915
|
+
}
|
|
23916
|
+
if (typeof resolvedTablePos !== "number") {
|
|
23917
|
+
return false;
|
|
23918
|
+
}
|
|
23919
|
+
if (dispatch) {
|
|
23920
|
+
insertRowsAtTableEnd({ tr, tablePos, tableNode: workingTable, rows: newRows });
|
|
23921
|
+
}
|
|
23922
|
+
return true;
|
|
23923
|
+
}).run();
|
|
23924
|
+
},
|
|
23762
23925
|
/**
|
|
23763
23926
|
* Insert a new table into the document
|
|
23764
23927
|
* @category Command
|
|
@@ -26665,58 +26828,6 @@ const registerImages = async (foundImages, editor, view) => {
|
|
|
26665
26828
|
}
|
|
26666
26829
|
});
|
|
26667
26830
|
};
|
|
26668
|
-
const normalizeWrap = (attrs = {}) => {
|
|
26669
|
-
const wrap = attrs.wrap;
|
|
26670
|
-
if (wrap?.type && wrap.type !== "Inline") {
|
|
26671
|
-
return {
|
|
26672
|
-
type: wrap.type,
|
|
26673
|
-
attrs: wrap.attrs ?? {}
|
|
26674
|
-
};
|
|
26675
|
-
}
|
|
26676
|
-
if (wrap?.type === "Inline" && Object.keys(wrap.attrs ?? {}).length) {
|
|
26677
|
-
return {
|
|
26678
|
-
type: "Inline",
|
|
26679
|
-
attrs: wrap.attrs
|
|
26680
|
-
};
|
|
26681
|
-
}
|
|
26682
|
-
if (!wrap && attrs.wrapText) {
|
|
26683
|
-
return {
|
|
26684
|
-
type: "Square",
|
|
26685
|
-
attrs: {
|
|
26686
|
-
wrapText: attrs.wrapText
|
|
26687
|
-
}
|
|
26688
|
-
};
|
|
26689
|
-
}
|
|
26690
|
-
if (!wrap && attrs.wrapTopAndBottom) {
|
|
26691
|
-
return {
|
|
26692
|
-
type: "TopAndBottom",
|
|
26693
|
-
attrs: {}
|
|
26694
|
-
};
|
|
26695
|
-
}
|
|
26696
|
-
if (wrap?.type === "Inline") {
|
|
26697
|
-
return {
|
|
26698
|
-
type: "Inline",
|
|
26699
|
-
attrs: wrap.attrs ?? {}
|
|
26700
|
-
};
|
|
26701
|
-
}
|
|
26702
|
-
return {
|
|
26703
|
-
type: "Inline",
|
|
26704
|
-
attrs: {}
|
|
26705
|
-
};
|
|
26706
|
-
};
|
|
26707
|
-
const normalizeMarginOffset = (marginOffset = {}) => {
|
|
26708
|
-
const { left: left2, horizontal, ...rest } = marginOffset;
|
|
26709
|
-
return {
|
|
26710
|
-
...rest,
|
|
26711
|
-
horizontal: horizontal ?? left2
|
|
26712
|
-
};
|
|
26713
|
-
};
|
|
26714
|
-
const getNormalizedImageAttrs = (attrs = {}) => {
|
|
26715
|
-
return {
|
|
26716
|
-
wrap: normalizeWrap(attrs),
|
|
26717
|
-
marginOffset: normalizeMarginOffset(attrs.marginOffset ?? {})
|
|
26718
|
-
};
|
|
26719
|
-
};
|
|
26720
26831
|
const ImagePositionPluginKey = new PluginKey("ImagePosition");
|
|
26721
26832
|
const ImagePositionPlugin = ({ editor }) => {
|
|
26722
26833
|
const { view } = editor;
|
|
@@ -26729,8 +26840,9 @@ const ImagePositionPlugin = ({ editor }) => {
|
|
|
26729
26840
|
return DecorationSet.empty;
|
|
26730
26841
|
},
|
|
26731
26842
|
apply(tr, oldDecorationSet, oldState, newState) {
|
|
26732
|
-
if (!tr.docChanged) return oldDecorationSet;
|
|
26843
|
+
if (!tr.docChanged && !shouldUpdate) return oldDecorationSet;
|
|
26733
26844
|
const decorations = getImagePositionDecorations(newState, view);
|
|
26845
|
+
shouldUpdate = false;
|
|
26734
26846
|
return DecorationSet.create(newState.doc, decorations);
|
|
26735
26847
|
}
|
|
26736
26848
|
},
|
|
@@ -26739,7 +26851,6 @@ const ImagePositionPlugin = ({ editor }) => {
|
|
|
26739
26851
|
update: (view2, lastState) => {
|
|
26740
26852
|
const pagination = PaginationPluginKey.getState(lastState);
|
|
26741
26853
|
if (shouldUpdate) {
|
|
26742
|
-
shouldUpdate = false;
|
|
26743
26854
|
const decorations = getImagePositionDecorations(lastState, view2);
|
|
26744
26855
|
const updateTransaction = view2.state.tr.setMeta(ImagePositionPluginKey, { decorations });
|
|
26745
26856
|
view2.dispatch(updateTransaction);
|
|
@@ -26765,41 +26876,35 @@ const getImagePositionDecorations = (state, view) => {
|
|
|
26765
26876
|
let className = "";
|
|
26766
26877
|
const { vRelativeFrom, alignH } = node.attrs.anchorData;
|
|
26767
26878
|
const { size, padding } = node.attrs;
|
|
26768
|
-
const { marginOffset } = getNormalizedImageAttrs(node.attrs);
|
|
26769
26879
|
const pageBreak = findPreviousDomNodeWithClass(view, pos, "pagination-break-wrapper");
|
|
26770
|
-
if (pageBreak) {
|
|
26771
|
-
|
|
26772
|
-
|
|
26773
|
-
|
|
26774
|
-
|
|
26775
|
-
|
|
26776
|
-
|
|
26777
|
-
|
|
26778
|
-
|
|
26779
|
-
|
|
26780
|
-
|
|
26880
|
+
if (pageBreak && vRelativeFrom === "margin" && alignH) {
|
|
26881
|
+
const topPos = pageBreak?.offsetTop + pageBreak?.offsetHeight;
|
|
26882
|
+
let horizontalAlignment = `${alignH}: 0;`;
|
|
26883
|
+
if (alignH === "center") horizontalAlignment = "left: 50%; transform: translateX(-50%);";
|
|
26884
|
+
style += vRelativeFrom === "margin" ? `position: absolute; top: ${topPos}px; ${horizontalAlignment}` : "";
|
|
26885
|
+
const nextPos = view.posAtDOM(pageBreak, 1);
|
|
26886
|
+
if (nextPos < 0) {
|
|
26887
|
+
const $pos = view.state.doc.resolve(pos);
|
|
26888
|
+
decorations.push(
|
|
26889
|
+
Decoration.node(pos - 1, pos + $pos.parent.nodeSize - 1, {
|
|
26890
|
+
style: `height: ${size.height + parseInt(padding.top) + parseInt(padding.bottom)}px`
|
|
26891
|
+
})
|
|
26892
|
+
);
|
|
26781
26893
|
}
|
|
26782
|
-
const
|
|
26783
|
-
|
|
26784
|
-
|
|
26785
|
-
|
|
26786
|
-
|
|
26787
|
-
|
|
26788
|
-
|
|
26789
|
-
|
|
26790
|
-
style: `height: ${size.height + parseInt(padding.top) + parseInt(padding.bottom)}px`
|
|
26791
|
-
})
|
|
26792
|
-
);
|
|
26793
|
-
}
|
|
26794
|
-
const imageBlock = document.createElement("div");
|
|
26795
|
-
imageBlock.className = "anchor-image-placeholder";
|
|
26796
|
-
imageBlock.style.float = alignH;
|
|
26797
|
-
imageBlock.style.width = size.width + parseInt(padding[alignH]) + "px";
|
|
26798
|
-
imageBlock.style.height = size.height + parseInt(padding.top) + parseInt(padding.bottom) + "px";
|
|
26799
|
-
decorations.push(Decoration.widget(nextPos, imageBlock, { key: "stable-key" }));
|
|
26894
|
+
const imageBlock = document.createElement("div");
|
|
26895
|
+
imageBlock.className = "anchor-image-placeholder";
|
|
26896
|
+
imageBlock.style.float = alignH === "left" || alignH === "right" ? alignH : "none";
|
|
26897
|
+
let paddingHorizontal;
|
|
26898
|
+
if (alignH === "center") {
|
|
26899
|
+
paddingHorizontal = (parseInt(padding.left) || 0) + (parseInt(padding.right) || 0);
|
|
26900
|
+
} else {
|
|
26901
|
+
paddingHorizontal = parseInt(padding[alignH]) || 0;
|
|
26800
26902
|
}
|
|
26903
|
+
imageBlock.style.width = size.width + paddingHorizontal + "px";
|
|
26904
|
+
imageBlock.style.height = size.height + parseInt(padding.top) + parseInt(padding.bottom) + "px";
|
|
26905
|
+
decorations.push(Decoration.widget(nextPos, imageBlock, { key: "stable-key" }));
|
|
26906
|
+
decorations.push(Decoration.inline(pos, pos + node.nodeSize, { style, class: className }));
|
|
26801
26907
|
}
|
|
26802
|
-
decorations.push(Decoration.inline(pos, pos + node.nodeSize, { style, class: className }));
|
|
26803
26908
|
}
|
|
26804
26909
|
});
|
|
26805
26910
|
return decorations;
|
|
@@ -26824,6 +26929,58 @@ const findPreviousDomNodeWithClass = (view, pos, className) => {
|
|
|
26824
26929
|
}
|
|
26825
26930
|
return null;
|
|
26826
26931
|
};
|
|
26932
|
+
const normalizeWrap = (attrs = {}) => {
|
|
26933
|
+
const wrap = attrs.wrap;
|
|
26934
|
+
if (wrap?.type && wrap.type !== "Inline") {
|
|
26935
|
+
return {
|
|
26936
|
+
type: wrap.type,
|
|
26937
|
+
attrs: wrap.attrs ?? {}
|
|
26938
|
+
};
|
|
26939
|
+
}
|
|
26940
|
+
if (wrap?.type === "Inline" && Object.keys(wrap.attrs ?? {}).length) {
|
|
26941
|
+
return {
|
|
26942
|
+
type: "Inline",
|
|
26943
|
+
attrs: wrap.attrs
|
|
26944
|
+
};
|
|
26945
|
+
}
|
|
26946
|
+
if (!wrap && attrs.wrapText) {
|
|
26947
|
+
return {
|
|
26948
|
+
type: "Square",
|
|
26949
|
+
attrs: {
|
|
26950
|
+
wrapText: attrs.wrapText
|
|
26951
|
+
}
|
|
26952
|
+
};
|
|
26953
|
+
}
|
|
26954
|
+
if (!wrap && attrs.wrapTopAndBottom) {
|
|
26955
|
+
return {
|
|
26956
|
+
type: "TopAndBottom",
|
|
26957
|
+
attrs: {}
|
|
26958
|
+
};
|
|
26959
|
+
}
|
|
26960
|
+
if (wrap?.type === "Inline") {
|
|
26961
|
+
return {
|
|
26962
|
+
type: "Inline",
|
|
26963
|
+
attrs: wrap.attrs ?? {}
|
|
26964
|
+
};
|
|
26965
|
+
}
|
|
26966
|
+
return {
|
|
26967
|
+
type: "Inline",
|
|
26968
|
+
attrs: {}
|
|
26969
|
+
};
|
|
26970
|
+
};
|
|
26971
|
+
const normalizeMarginOffset = (marginOffset = {}) => {
|
|
26972
|
+
const { left: left2, horizontal, ...rest } = marginOffset;
|
|
26973
|
+
return {
|
|
26974
|
+
...rest,
|
|
26975
|
+
horizontal: horizontal ?? left2
|
|
26976
|
+
};
|
|
26977
|
+
};
|
|
26978
|
+
const getNormalizedImageAttrs = (attrs = {}) => {
|
|
26979
|
+
return {
|
|
26980
|
+
wrap: normalizeWrap(attrs),
|
|
26981
|
+
marginOffset: normalizeMarginOffset(attrs.marginOffset ?? {})
|
|
26982
|
+
};
|
|
26983
|
+
};
|
|
26827
26984
|
const getRotationMargins = (w, h, angleDegrees) => {
|
|
26828
26985
|
const rad = angleDegrees * (Math.PI / 180);
|
|
26829
26986
|
const cos = Math.abs(Math.cos(rad));
|
|
@@ -27032,27 +27189,15 @@ const Image = Node$1.create({
|
|
|
27032
27189
|
style += "float: right;";
|
|
27033
27190
|
floatRight = true;
|
|
27034
27191
|
} else if (["largest", "bothSides"].includes(attrs.wrapText)) {
|
|
27035
|
-
const
|
|
27036
|
-
|
|
27037
|
-
|
|
27038
|
-
|
|
27039
|
-
|
|
27040
|
-
|
|
27041
|
-
|
|
27042
|
-
|
|
27043
|
-
|
|
27044
|
-
if (rightSpace < 0) {
|
|
27045
|
-
style += "float: left;";
|
|
27046
|
-
} else if (rightSpace > leftSpace) {
|
|
27047
|
-
style += "float: left;";
|
|
27048
|
-
} else {
|
|
27049
|
-
style += "float: right;";
|
|
27050
|
-
floatRight = true;
|
|
27051
|
-
baseHorizontal = rightSpace;
|
|
27052
|
-
}
|
|
27053
|
-
} else {
|
|
27054
|
-
style += "float: left;";
|
|
27055
|
-
}
|
|
27192
|
+
const pageStylesData2 = getDataFromPageStyles({
|
|
27193
|
+
editor: this.editor,
|
|
27194
|
+
marginOffset,
|
|
27195
|
+
size,
|
|
27196
|
+
attrs
|
|
27197
|
+
});
|
|
27198
|
+
style += pageStylesData2.style;
|
|
27199
|
+
floatRight = pageStylesData2.floatRight;
|
|
27200
|
+
baseHorizontal = pageStylesData2.baseHorizontal;
|
|
27056
27201
|
}
|
|
27057
27202
|
if (attrs.distTop) margin.top += attrs.distTop;
|
|
27058
27203
|
if (attrs.distBottom) margin.bottom += attrs.distBottom;
|
|
@@ -27062,27 +27207,15 @@ const Image = Node$1.create({
|
|
|
27062
27207
|
case "Through":
|
|
27063
27208
|
case "Tight":
|
|
27064
27209
|
style += "clear: both;";
|
|
27065
|
-
const
|
|
27066
|
-
|
|
27067
|
-
|
|
27068
|
-
|
|
27069
|
-
|
|
27070
|
-
|
|
27071
|
-
|
|
27072
|
-
|
|
27073
|
-
|
|
27074
|
-
if (rightSpace < 0) {
|
|
27075
|
-
style += "float: left;";
|
|
27076
|
-
} else if (rightSpace > leftSpace) {
|
|
27077
|
-
style += "float: left;";
|
|
27078
|
-
} else {
|
|
27079
|
-
style += "float: right;";
|
|
27080
|
-
floatRight = true;
|
|
27081
|
-
baseHorizontal = rightSpace;
|
|
27082
|
-
}
|
|
27083
|
-
} else {
|
|
27084
|
-
style += "float: left;";
|
|
27085
|
-
}
|
|
27210
|
+
const pageStylesData = getDataFromPageStyles({
|
|
27211
|
+
editor: this.editor,
|
|
27212
|
+
marginOffset,
|
|
27213
|
+
size,
|
|
27214
|
+
attrs
|
|
27215
|
+
});
|
|
27216
|
+
style += pageStylesData.style;
|
|
27217
|
+
floatRight = pageStylesData.floatRight;
|
|
27218
|
+
baseHorizontal = pageStylesData.baseHorizontal;
|
|
27086
27219
|
if (attrs.distTop) margin.top += attrs.distTop;
|
|
27087
27220
|
if (attrs.distBottom) margin.bottom += attrs.distBottom;
|
|
27088
27221
|
if (attrs.distLeft) margin.left += attrs.distLeft;
|
|
@@ -27119,6 +27252,22 @@ const Image = Node$1.create({
|
|
|
27119
27252
|
}
|
|
27120
27253
|
const hasAnchorData = Boolean(anchorData);
|
|
27121
27254
|
const hasMarginOffsets = marginOffset?.horizontal != null || marginOffset?.top != null;
|
|
27255
|
+
if (hasAnchorData) {
|
|
27256
|
+
switch (anchorData.hRelativeFrom) {
|
|
27257
|
+
case "page":
|
|
27258
|
+
const pageStyles = this.editor?.converter?.pageStyles || this.editor?.options.parentEditor?.converter?.pageStyles;
|
|
27259
|
+
margin.left -= inchesToPixels(pageStyles?.pageMargins?.left) || 0;
|
|
27260
|
+
break;
|
|
27261
|
+
case "margin":
|
|
27262
|
+
if (anchorData.alignH === "center") {
|
|
27263
|
+
style += "position: absolute; left: 50%; transform: translateX(-50%);";
|
|
27264
|
+
}
|
|
27265
|
+
if (anchorData.alignH === "left" || anchorData.alignH === "right") {
|
|
27266
|
+
style += `position: absolute; ${anchorData.alignH}: 0;`;
|
|
27267
|
+
}
|
|
27268
|
+
break;
|
|
27269
|
+
}
|
|
27270
|
+
}
|
|
27122
27271
|
if (hasAnchorData || hasMarginOffsets) {
|
|
27123
27272
|
const relativeFromPageV = anchorData?.vRelativeFrom === "page";
|
|
27124
27273
|
const maxMarginV = 500;
|
|
@@ -27267,6 +27416,37 @@ const Image = Node$1.create({
|
|
|
27267
27416
|
return [ImageRegistrationPlugin({ editor: this.editor }), ImagePositionPlugin({ editor: this.editor })];
|
|
27268
27417
|
}
|
|
27269
27418
|
});
|
|
27419
|
+
const getDataFromPageStyles = ({ editor, marginOffset, size, attrs }) => {
|
|
27420
|
+
let style = "";
|
|
27421
|
+
let floatRight = false;
|
|
27422
|
+
let baseHorizontal = marginOffset?.horizontal || 0;
|
|
27423
|
+
const pageStyles = editor?.converter?.pageStyles || editor?.options.parentEditor?.converter?.pageStyles;
|
|
27424
|
+
if (pageStyles?.pageSize && pageStyles?.pageMargins && size.width) {
|
|
27425
|
+
const pageWidth = inchesToPixels(pageStyles.pageSize.width);
|
|
27426
|
+
const leftMargin = inchesToPixels(pageStyles.pageMargins.left);
|
|
27427
|
+
const rightMargin = inchesToPixels(pageStyles.pageMargins.right);
|
|
27428
|
+
const contentWidth = pageWidth - leftMargin - rightMargin;
|
|
27429
|
+
const imageWidth = size.width + (attrs.distLeft || 0) + (attrs.distRight || 0);
|
|
27430
|
+
const leftSpace = marginOffset.horizontal;
|
|
27431
|
+
const rightSpace = contentWidth - leftSpace - imageWidth;
|
|
27432
|
+
if (rightSpace < 0) {
|
|
27433
|
+
style += "float: left;";
|
|
27434
|
+
} else if (rightSpace > leftSpace) {
|
|
27435
|
+
style += "float: left;";
|
|
27436
|
+
} else {
|
|
27437
|
+
style += "float: right;";
|
|
27438
|
+
floatRight = true;
|
|
27439
|
+
baseHorizontal = rightSpace;
|
|
27440
|
+
}
|
|
27441
|
+
} else {
|
|
27442
|
+
style += "float: left;";
|
|
27443
|
+
}
|
|
27444
|
+
return {
|
|
27445
|
+
style,
|
|
27446
|
+
floatRight,
|
|
27447
|
+
baseHorizontal
|
|
27448
|
+
};
|
|
27449
|
+
};
|
|
27270
27450
|
const ACCEPT_IMAGE_TYPES = [".jpg", ".jpeg", ".png", "image/jpeg", "image/png"];
|
|
27271
27451
|
const getFileOpener = () => {
|
|
27272
27452
|
let fileInput = document.createElement("input");
|
|
@@ -29388,6 +29568,15 @@ const TrackChanges = Extension.create({
|
|
|
29388
29568
|
const { from: from2, to } = state.selection;
|
|
29389
29569
|
return commands2.acceptTrackedChangesBetween(from2, to);
|
|
29390
29570
|
},
|
|
29571
|
+
acceptTrackedChangeFromToolbar: () => ({ state, commands: commands2 }) => {
|
|
29572
|
+
const commentsPluginState = CommentsPluginKey.getState(state);
|
|
29573
|
+
const activeThreadId = commentsPluginState?.activeThreadId;
|
|
29574
|
+
if (activeThreadId && commentsPluginState?.trackedChanges?.[activeThreadId]) {
|
|
29575
|
+
return commands2.acceptTrackedChangeById(activeThreadId);
|
|
29576
|
+
} else {
|
|
29577
|
+
return commands2.acceptTrackedChangeBySelection();
|
|
29578
|
+
}
|
|
29579
|
+
},
|
|
29391
29580
|
acceptTrackedChangeById: (id) => ({ state, tr, commands: commands2 }) => {
|
|
29392
29581
|
const toResolve = getChangesByIdToResolve(state, id) || [];
|
|
29393
29582
|
return toResolve.map(({ from: from2, to }) => {
|
|
@@ -29416,6 +29605,15 @@ const TrackChanges = Extension.create({
|
|
|
29416
29605
|
const { from: from2, to } = state.selection;
|
|
29417
29606
|
return commands2.rejectTrackedChangesBetween(from2, to);
|
|
29418
29607
|
},
|
|
29608
|
+
rejectTrackedChangeFromToolbar: () => ({ state, commands: commands2 }) => {
|
|
29609
|
+
const commentsPluginState = CommentsPluginKey.getState(state);
|
|
29610
|
+
const activeThreadId = commentsPluginState?.activeThreadId;
|
|
29611
|
+
if (activeThreadId && commentsPluginState?.trackedChanges?.[activeThreadId]) {
|
|
29612
|
+
return commands2.rejectTrackedChangeById(activeThreadId);
|
|
29613
|
+
} else {
|
|
29614
|
+
return commands2.rejectTrackedChangeOnSelection();
|
|
29615
|
+
}
|
|
29616
|
+
},
|
|
29419
29617
|
rejectAllTrackedChanges: () => ({ state, commands: commands2 }) => {
|
|
29420
29618
|
const from2 = 0, to = state.doc.content.size;
|
|
29421
29619
|
return commands2.rejectTrackedChangesBetween(from2, to);
|
|
@@ -34709,7 +34907,7 @@ const nodeResizer = (nodeNames = ["image"], editor) => {
|
|
|
34709
34907
|
return oldState;
|
|
34710
34908
|
}
|
|
34711
34909
|
if (typeof document === "undefined" || editor.options.isHeadless) return oldState;
|
|
34712
|
-
if (editor.options.documentMode === "viewing" || !editor.isEditable) {
|
|
34910
|
+
if (!editor.options.isHeaderOrFooter && (editor.options.documentMode === "viewing" || !editor.isEditable)) {
|
|
34713
34911
|
return DecorationSet.empty;
|
|
34714
34912
|
}
|
|
34715
34913
|
const { selection } = newState;
|
|
@@ -35059,6 +35257,7 @@ const getStarterExtensions = () => {
|
|
|
35059
35257
|
export {
|
|
35060
35258
|
Attribute as A,
|
|
35061
35259
|
CommentsPluginKey as C,
|
|
35260
|
+
DecorationSet as D,
|
|
35062
35261
|
Editor as E,
|
|
35063
35262
|
Mark as M,
|
|
35064
35263
|
Node$1 as N,
|
|
@@ -35079,14 +35278,15 @@ export {
|
|
|
35079
35278
|
collectTrackedChangesForContext as k,
|
|
35080
35279
|
getStarterExtensions as l,
|
|
35081
35280
|
getRichTextExtensions as m,
|
|
35082
|
-
|
|
35083
|
-
|
|
35084
|
-
index as p,
|
|
35085
|
-
|
|
35281
|
+
Decoration as n,
|
|
35282
|
+
Extension as o,
|
|
35283
|
+
index$1 as p,
|
|
35284
|
+
index as q,
|
|
35086
35285
|
replaceSelectionWithImagePlaceholder as r,
|
|
35087
35286
|
shouldBypassContextMenu as s,
|
|
35088
|
-
|
|
35287
|
+
AnnotatorHelpers as t,
|
|
35089
35288
|
useHighContrastMode as u,
|
|
35090
|
-
|
|
35289
|
+
SectionHelpers as v,
|
|
35290
|
+
getAllowedImageDimensions as w,
|
|
35091
35291
|
yUndoPluginKey as y
|
|
35092
35292
|
};
|