superdoc 1.0.0-beta.17 → 1.0.0-beta.19
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-BIlJaTm7.cjs → PdfViewer-BLFV17De.cjs} +1 -1
- package/dist/chunks/{PdfViewer-cvzMUtBh.es.js → PdfViewer-D_4g-jsZ.es.js} +1 -1
- package/dist/chunks/{index-VCeRjVPO-FBgR9qxX.es.js → index-CRpn1mWd-B4eH8Zok.es.js} +1 -1
- package/dist/chunks/{index-VCeRjVPO-DjkejB6t.cjs → index-CRpn1mWd-BUbbd3Jq.cjs} +1 -1
- package/dist/chunks/{index-CrIfBvBN.es.js → index-NPXppXmC.es.js} +8 -4
- package/dist/chunks/{index-DDx90Dl3.cjs → index-k02voMEs.cjs} +8 -4
- package/dist/chunks/{super-editor.es-00SpI-wK.es.js → super-editor.es-CHU4dmes.es.js} +1844 -1123
- package/dist/chunks/{super-editor.es-Mlj7AGyt.cjs → super-editor.es-C_Gk8cDd.cjs} +1843 -1122
- package/dist/packages/superdoc/src/components/CommentsLayer/use-comment.d.ts.map +1 -1
- package/dist/packages/superdoc/src/stores/comments-store.d.ts.map +1 -1
- package/dist/style.css +7 -7
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-B9zUZjYT.js → converter-Cu26_LdN.js} +207 -15
- package/dist/super-editor/chunks/{docx-zipper-r5KdE_SA.js → docx-zipper-C8lozSFd.js} +1 -1
- package/dist/super-editor/chunks/{editor-D2k2BwSG.js → editor-BXC2Hzba.js} +1574 -1062
- package/dist/super-editor/chunks/{index-VCeRjVPO.js → index-CRpn1mWd.js} +1 -1
- package/dist/super-editor/chunks/{toolbar-8o_LgoiW.js → toolbar-BglLOe8y.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/style.css +7 -7
- package/dist/super-editor/super-editor.es.js +126 -45
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +3 -3
- 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 +1842 -1117
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -19191,6 +19191,7 @@ function getUnderlineCssString({ type: type2 = "single", color = null, thickness
|
|
|
19191
19191
|
if (color) add("text-decoration-color", color);
|
|
19192
19192
|
return parts.join("; ");
|
|
19193
19193
|
}
|
|
19194
|
+
const INLINE_OVERRIDE_PROPERTIES = ["fontSize", "bold", "italic", "strike", "underline", "letterSpacing"];
|
|
19194
19195
|
const resolveRunProperties = (params2, inlineRpr, resolvedPpr, isListNumber = false, numberingDefinedInline = false) => {
|
|
19195
19196
|
const paragraphStyleId = resolvedPpr?.styleId;
|
|
19196
19197
|
const paragraphStyleProps = resolveStyleChain$1(params2, paragraphStyleId, translator$1N);
|
|
@@ -19227,6 +19228,11 @@ const resolveRunProperties = (params2, inlineRpr, resolvedPpr, isListNumber = fa
|
|
|
19227
19228
|
styleChain = [...styleChain, paragraphStyleProps, runStyleProps, inlineRpr];
|
|
19228
19229
|
}
|
|
19229
19230
|
const finalProps = combineProperties(styleChain, ["fontFamily", "color"]);
|
|
19231
|
+
for (const prop of INLINE_OVERRIDE_PROPERTIES) {
|
|
19232
|
+
if (inlineRpr?.[prop] != null) {
|
|
19233
|
+
finalProps[prop] = inlineRpr[prop];
|
|
19234
|
+
}
|
|
19235
|
+
}
|
|
19230
19236
|
return finalProps;
|
|
19231
19237
|
};
|
|
19232
19238
|
function resolveParagraphProperties(params2, inlineProps, insideTable = false, overrideInlineStyleId = false, tableStyleId = null) {
|
|
@@ -25034,8 +25040,8 @@ function handleImageNode$1(node, params2, isAnchor) {
|
|
|
25034
25040
|
horizontal: positionHValue,
|
|
25035
25041
|
top: positionVValue
|
|
25036
25042
|
};
|
|
25037
|
-
const useSimplePos = attributes["simplePos"] === "1" || attributes["simplePos"] === 1;
|
|
25038
|
-
const
|
|
25043
|
+
const useSimplePos = attributes["simplePos"] === "1" || attributes["simplePos"] === 1 || attributes["simplePos"] === true;
|
|
25044
|
+
const simplePosNode = node.elements.find((el) => el.name === "wp:simplePos");
|
|
25039
25045
|
const wrapNode = isAnchor ? node.elements.find(
|
|
25040
25046
|
(el) => ["wp:wrapNone", "wp:wrapSquare", "wp:wrapThrough", "wp:wrapTight", "wp:wrapTopAndBottom"].includes(el.name)
|
|
25041
25047
|
) : null;
|
|
@@ -25175,10 +25181,10 @@ function handleImageNode$1(node, params2, isAnchor) {
|
|
|
25175
25181
|
anchorData,
|
|
25176
25182
|
isAnchor,
|
|
25177
25183
|
transformData,
|
|
25178
|
-
...
|
|
25184
|
+
...useSimplePos && {
|
|
25179
25185
|
simplePos: {
|
|
25180
|
-
x:
|
|
25181
|
-
y:
|
|
25186
|
+
x: simplePosNode.attributes?.x,
|
|
25187
|
+
y: simplePosNode.attributes?.y
|
|
25182
25188
|
}
|
|
25183
25189
|
},
|
|
25184
25190
|
wrap: wrap2,
|
|
@@ -30936,12 +30942,13 @@ function translateShapeGroup(params2) {
|
|
|
30936
30942
|
function translateAnchorNode(params2) {
|
|
30937
30943
|
const { attrs } = params2.node;
|
|
30938
30944
|
const anchorElements = [];
|
|
30939
|
-
|
|
30945
|
+
const hasSimplePos = attrs.simplePos || attrs.originalAttributes?.simplePos;
|
|
30946
|
+
if (hasSimplePos) {
|
|
30940
30947
|
anchorElements.push({
|
|
30941
30948
|
name: "wp:simplePos",
|
|
30942
30949
|
attributes: {
|
|
30943
|
-
x: 0,
|
|
30944
|
-
y: 0
|
|
30950
|
+
x: attrs.simplePos?.x ?? 0,
|
|
30951
|
+
y: attrs.simplePos?.y ?? 0
|
|
30945
30952
|
}
|
|
30946
30953
|
});
|
|
30947
30954
|
}
|
|
@@ -30993,8 +31000,8 @@ function translateAnchorNode(params2) {
|
|
|
30993
31000
|
}
|
|
30994
31001
|
if (attrs.originalAttributes?.simplePos !== void 0) {
|
|
30995
31002
|
inlineAttrs.simplePos = attrs.originalAttributes.simplePos;
|
|
30996
|
-
} else if (
|
|
30997
|
-
inlineAttrs.simplePos =
|
|
31003
|
+
} else if (hasSimplePos) {
|
|
31004
|
+
inlineAttrs.simplePos = "1";
|
|
30998
31005
|
}
|
|
30999
31006
|
if (attrs.originalAttributes?.locked !== void 0) {
|
|
31000
31007
|
inlineAttrs.locked = attrs.originalAttributes.locked;
|
|
@@ -33759,7 +33766,7 @@ const handlePassthroughNode = (params2) => {
|
|
|
33759
33766
|
const { nodes = [] } = params2;
|
|
33760
33767
|
const node = nodes[0];
|
|
33761
33768
|
if (!node) return { nodes: [], consumed: 0 };
|
|
33762
|
-
if (registeredHandlers[node.name]) {
|
|
33769
|
+
if (registeredHandlers[node.name] || node.name === "w:commentReference") {
|
|
33763
33770
|
return { nodes: [], consumed: 0 };
|
|
33764
33771
|
}
|
|
33765
33772
|
const originalXml = carbonCopy(node) || {};
|
|
@@ -34059,7 +34066,11 @@ function importCommentData({ docx, editor, converter }) {
|
|
|
34059
34066
|
const generateCommentsWithExtendedData = ({ docx, comments }) => {
|
|
34060
34067
|
if (!comments?.length) return [];
|
|
34061
34068
|
const commentsExtended = docx["word/commentsExtended.xml"];
|
|
34062
|
-
if (!commentsExtended)
|
|
34069
|
+
if (!commentsExtended) {
|
|
34070
|
+
const commentRanges = extractCommentRangesFromDocument(docx);
|
|
34071
|
+
const commentsWithThreading = detectThreadingFromRanges(comments, commentRanges);
|
|
34072
|
+
return commentsWithThreading.map((comment) => ({ ...comment, isDone: comment.isDone ?? false }));
|
|
34073
|
+
}
|
|
34063
34074
|
const { elements: initialElements = [] } = commentsExtended;
|
|
34064
34075
|
if (!initialElements?.length) return comments.map((comment) => ({ ...comment, isDone: comment.isDone ?? false }));
|
|
34065
34076
|
const { elements = [] } = initialElements[0] ?? {};
|
|
@@ -34085,6 +34096,79 @@ const getExtendedDetails = (commentEx) => {
|
|
|
34085
34096
|
const paraIdParent = attributes["w15:paraIdParent"];
|
|
34086
34097
|
return { paraId, isDone, paraIdParent };
|
|
34087
34098
|
};
|
|
34099
|
+
const extractCommentRangesFromDocument = (docx) => {
|
|
34100
|
+
const documentXml = docx["word/document.xml"];
|
|
34101
|
+
if (!documentXml) {
|
|
34102
|
+
return [];
|
|
34103
|
+
}
|
|
34104
|
+
const pendingComments = [];
|
|
34105
|
+
const walkElements = (elements) => {
|
|
34106
|
+
if (!elements || !Array.isArray(elements)) return;
|
|
34107
|
+
elements.forEach((element) => {
|
|
34108
|
+
if (element.name === "w:commentRangeStart") {
|
|
34109
|
+
const commentId = element.attributes?.["w:id"];
|
|
34110
|
+
if (commentId !== void 0) {
|
|
34111
|
+
pendingComments.push({
|
|
34112
|
+
type: "start",
|
|
34113
|
+
commentId: String(commentId)
|
|
34114
|
+
});
|
|
34115
|
+
}
|
|
34116
|
+
} else if (element.name === "w:commentRangeEnd") {
|
|
34117
|
+
const commentId = element.attributes?.["w:id"];
|
|
34118
|
+
if (commentId !== void 0) {
|
|
34119
|
+
pendingComments.push({
|
|
34120
|
+
type: "end",
|
|
34121
|
+
commentId: String(commentId)
|
|
34122
|
+
});
|
|
34123
|
+
}
|
|
34124
|
+
}
|
|
34125
|
+
if (element.elements && Array.isArray(element.elements)) {
|
|
34126
|
+
walkElements(element.elements);
|
|
34127
|
+
}
|
|
34128
|
+
});
|
|
34129
|
+
};
|
|
34130
|
+
if (documentXml.elements && documentXml.elements.length > 0) {
|
|
34131
|
+
const body = documentXml.elements[0];
|
|
34132
|
+
if (body.elements) {
|
|
34133
|
+
walkElements(body.elements);
|
|
34134
|
+
}
|
|
34135
|
+
}
|
|
34136
|
+
return pendingComments;
|
|
34137
|
+
};
|
|
34138
|
+
const detectThreadingFromRanges = (comments, rangeEvents) => {
|
|
34139
|
+
if (!rangeEvents || rangeEvents.length === 0) {
|
|
34140
|
+
return comments;
|
|
34141
|
+
}
|
|
34142
|
+
const openRanges = [];
|
|
34143
|
+
const parentMap = /* @__PURE__ */ new Map();
|
|
34144
|
+
rangeEvents.forEach((event) => {
|
|
34145
|
+
if (event.type === "start") {
|
|
34146
|
+
if (openRanges.length > 0) {
|
|
34147
|
+
const parentCommentId = openRanges[openRanges.length - 1];
|
|
34148
|
+
parentMap.set(event.commentId, parentCommentId);
|
|
34149
|
+
}
|
|
34150
|
+
openRanges.push(event.commentId);
|
|
34151
|
+
} else if (event.type === "end") {
|
|
34152
|
+
const index2 = openRanges.lastIndexOf(event.commentId);
|
|
34153
|
+
if (index2 !== -1) {
|
|
34154
|
+
openRanges.splice(index2, 1);
|
|
34155
|
+
}
|
|
34156
|
+
}
|
|
34157
|
+
});
|
|
34158
|
+
return comments.map((comment) => {
|
|
34159
|
+
const parentCommentId = parentMap.get(comment.importedId);
|
|
34160
|
+
if (parentCommentId) {
|
|
34161
|
+
const parentComment = comments.find((c2) => c2.importedId === parentCommentId);
|
|
34162
|
+
if (parentComment) {
|
|
34163
|
+
return {
|
|
34164
|
+
...comment,
|
|
34165
|
+
parentCommentId: parentComment.commentId
|
|
34166
|
+
};
|
|
34167
|
+
}
|
|
34168
|
+
}
|
|
34169
|
+
return comment;
|
|
34170
|
+
});
|
|
34171
|
+
};
|
|
34088
34172
|
const RELATIONSHIP_TYPES = (
|
|
34089
34173
|
/** @type {const} */
|
|
34090
34174
|
{
|
|
@@ -35925,10 +36009,12 @@ const toIsoNoFractional = (unixMillis) => {
|
|
|
35925
36009
|
const updateCommentsXml = (commentDefs = [], commentsXml) => {
|
|
35926
36010
|
const newCommentsXml = carbonCopy(commentsXml);
|
|
35927
36011
|
commentDefs.forEach((commentDef) => {
|
|
35928
|
-
const
|
|
36012
|
+
const paraNode = commentDef.elements[0];
|
|
36013
|
+
if (!paraNode.attributes) paraNode.attributes = {};
|
|
36014
|
+
const elements = paraNode.elements;
|
|
35929
36015
|
elements.unshift(COMMENT_REF);
|
|
35930
36016
|
const paraId = commentDef.attributes["w15:paraId"];
|
|
35931
|
-
|
|
36017
|
+
paraNode.attributes["w14:paraId"] = paraId;
|
|
35932
36018
|
commentDef.attributes = {
|
|
35933
36019
|
"w:id": commentDef.attributes["w:id"],
|
|
35934
36020
|
"w:author": commentDef.attributes["w:author"],
|
|
@@ -36302,7 +36388,7 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
36302
36388
|
static getStoredSuperdocVersion(docx) {
|
|
36303
36389
|
return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
|
|
36304
36390
|
}
|
|
36305
|
-
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.
|
|
36391
|
+
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.19") {
|
|
36306
36392
|
return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
|
|
36307
36393
|
}
|
|
36308
36394
|
/**
|
|
@@ -36643,6 +36729,112 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
36643
36729
|
});
|
|
36644
36730
|
return { result, params: params2 };
|
|
36645
36731
|
}
|
|
36732
|
+
/**
|
|
36733
|
+
* Creates a default empty header for the specified variant.
|
|
36734
|
+
*
|
|
36735
|
+
* This method programmatically creates a new header section with an empty ProseMirror
|
|
36736
|
+
* document. The header is added to the converter's data structures and will be included
|
|
36737
|
+
* in subsequent DOCX exports.
|
|
36738
|
+
*
|
|
36739
|
+
* @param {('default' | 'first' | 'even' | 'odd')} variant - The header variant to create
|
|
36740
|
+
* @returns {string} The relationship ID of the created header
|
|
36741
|
+
*
|
|
36742
|
+
* @throws {Error} If variant is invalid or header already exists for this variant
|
|
36743
|
+
*
|
|
36744
|
+
* @example
|
|
36745
|
+
* ```javascript
|
|
36746
|
+
* const headerId = converter.createDefaultHeader('default');
|
|
36747
|
+
* // headerId: 'rId-header-default'
|
|
36748
|
+
* // converter.headers['rId-header-default'] contains empty PM doc
|
|
36749
|
+
* // converter.headerIds.default === 'rId-header-default'
|
|
36750
|
+
* ```
|
|
36751
|
+
*/
|
|
36752
|
+
createDefaultHeader(variant = "default") {
|
|
36753
|
+
if (typeof variant !== "string") {
|
|
36754
|
+
throw new TypeError(`variant must be a string, received ${typeof variant}`);
|
|
36755
|
+
}
|
|
36756
|
+
const validVariants = ["default", "first", "even", "odd"];
|
|
36757
|
+
if (!validVariants.includes(variant)) {
|
|
36758
|
+
throw new Error(`Invalid header variant: ${variant}. Must be one of: ${validVariants.join(", ")}`);
|
|
36759
|
+
}
|
|
36760
|
+
if (this.headerIds[variant]) {
|
|
36761
|
+
console.warn(`[SuperConverter] Header already exists for variant '${variant}': ${this.headerIds[variant]}`);
|
|
36762
|
+
return this.headerIds[variant];
|
|
36763
|
+
}
|
|
36764
|
+
const rId = `rId-header-${variant}`;
|
|
36765
|
+
const emptyDoc = {
|
|
36766
|
+
type: "doc",
|
|
36767
|
+
content: [
|
|
36768
|
+
{
|
|
36769
|
+
type: "paragraph",
|
|
36770
|
+
content: []
|
|
36771
|
+
}
|
|
36772
|
+
]
|
|
36773
|
+
};
|
|
36774
|
+
this.headers[rId] = emptyDoc;
|
|
36775
|
+
this.headerIds[variant] = rId;
|
|
36776
|
+
if (!this.headerIds.ids) {
|
|
36777
|
+
this.headerIds.ids = [];
|
|
36778
|
+
}
|
|
36779
|
+
if (!this.headerIds.ids.includes(rId)) {
|
|
36780
|
+
this.headerIds.ids.push(rId);
|
|
36781
|
+
}
|
|
36782
|
+
this.documentModified = true;
|
|
36783
|
+
return rId;
|
|
36784
|
+
}
|
|
36785
|
+
/**
|
|
36786
|
+
* Creates a default empty footer for the specified variant.
|
|
36787
|
+
*
|
|
36788
|
+
* This method programmatically creates a new footer section with an empty ProseMirror
|
|
36789
|
+
* document. The footer is added to the converter's data structures and will be included
|
|
36790
|
+
* in subsequent DOCX exports.
|
|
36791
|
+
*
|
|
36792
|
+
* @param {('default' | 'first' | 'even' | 'odd')} variant - The footer variant to create
|
|
36793
|
+
* @returns {string} The relationship ID of the created footer
|
|
36794
|
+
*
|
|
36795
|
+
* @throws {Error} If variant is invalid or footer already exists for this variant
|
|
36796
|
+
*
|
|
36797
|
+
* @example
|
|
36798
|
+
* ```javascript
|
|
36799
|
+
* const footerId = converter.createDefaultFooter('default');
|
|
36800
|
+
* // footerId: 'rId-footer-default'
|
|
36801
|
+
* // converter.footers['rId-footer-default'] contains empty PM doc
|
|
36802
|
+
* // converter.footerIds.default === 'rId-footer-default'
|
|
36803
|
+
* ```
|
|
36804
|
+
*/
|
|
36805
|
+
createDefaultFooter(variant = "default") {
|
|
36806
|
+
if (typeof variant !== "string") {
|
|
36807
|
+
throw new TypeError(`variant must be a string, received ${typeof variant}`);
|
|
36808
|
+
}
|
|
36809
|
+
const validVariants = ["default", "first", "even", "odd"];
|
|
36810
|
+
if (!validVariants.includes(variant)) {
|
|
36811
|
+
throw new Error(`Invalid footer variant: ${variant}. Must be one of: ${validVariants.join(", ")}`);
|
|
36812
|
+
}
|
|
36813
|
+
if (this.footerIds[variant]) {
|
|
36814
|
+
console.warn(`[SuperConverter] Footer already exists for variant '${variant}': ${this.footerIds[variant]}`);
|
|
36815
|
+
return this.footerIds[variant];
|
|
36816
|
+
}
|
|
36817
|
+
const rId = `rId-footer-${variant}`;
|
|
36818
|
+
const emptyDoc = {
|
|
36819
|
+
type: "doc",
|
|
36820
|
+
content: [
|
|
36821
|
+
{
|
|
36822
|
+
type: "paragraph",
|
|
36823
|
+
content: []
|
|
36824
|
+
}
|
|
36825
|
+
]
|
|
36826
|
+
};
|
|
36827
|
+
this.footers[rId] = emptyDoc;
|
|
36828
|
+
this.footerIds[variant] = rId;
|
|
36829
|
+
if (!this.footerIds.ids) {
|
|
36830
|
+
this.footerIds.ids = [];
|
|
36831
|
+
}
|
|
36832
|
+
if (!this.footerIds.ids.includes(rId)) {
|
|
36833
|
+
this.footerIds.ids.push(rId);
|
|
36834
|
+
}
|
|
36835
|
+
this.documentModified = true;
|
|
36836
|
+
return rId;
|
|
36837
|
+
}
|
|
36646
36838
|
// Deprecated methods for backward compatibility
|
|
36647
36839
|
static getStoredSuperdocId(docx) {
|
|
36648
36840
|
console.warn("getStoredSuperdocId is deprecated, use getDocumentGuid instead");
|
|
@@ -39502,7 +39694,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
|
|
|
39502
39694
|
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);
|
|
39503
39695
|
var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
|
|
39504
39696
|
var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
|
|
39505
|
-
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, dispatchWithFallback_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, getPluginKeyName_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, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _map, _editor2, _descriptors, _collections, _editorEntries, _maxCachedEditors, _editorAccessOrder, _pendingCreations, _cacheHits, _cacheMisses, _evictions, _HeaderFooterEditorManager_instances, hasConverter_fn, extractCollections_fn, collectDescriptors_fn, teardownMissingEditors_fn, teardownEditors_fn, createEditor_fn, createEditorContainer_fn, registerConverterEditor_fn, unregisterConverterEditor_fn, updateAccessOrder_fn, enforceCacheSizeLimit_fn, _manager, _mediaFiles, _blockCache, _HeaderFooterLayoutAdapter_instances, getBlocks_fn, getConverterContext_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost,
|
|
39697
|
+
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, dispatchWithFallback_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, getPluginKeyName_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, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _map, _editor2, _descriptors, _collections, _editorEntries, _maxCachedEditors, _editorAccessOrder, _pendingCreations, _cacheHits, _cacheMisses, _evictions, _HeaderFooterEditorManager_instances, hasConverter_fn, extractCollections_fn, collectDescriptors_fn, teardownMissingEditors_fn, teardownEditors_fn, createEditor_fn, createEditorContainer_fn, registerConverterEditor_fn, unregisterConverterEditor_fn, updateAccessOrder_fn, enforceCacheSizeLimit_fn, _manager, _mediaFiles, _blockCache, _HeaderFooterLayoutAdapter_instances, getBlocks_fn, getConverterContext_fn, _selectionOverlay, _activeEditorHost, _activeDecorationContainer, _activeRegion, _borderLine, _EditorOverlayManager_instances, findDecorationContainer_fn, ensureEditorHost_fn, positionEditorHost_fn, showHeaderFooterBorder_fn, hideHeaderFooterBorder_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost, _selectionOverlay2, _hiddenHost, _layoutOptions, _layoutState, _domPainter, _layoutError, _layoutErrorState, _errorBanner, _errorBannerMessage, _telemetryEmitter, _renderScheduled, _pendingDocChange, _isRerendering, _selectionUpdateScheduled, _remoteCursorUpdateScheduled, _rafHandle, _editorListeners, _sectionMetadata, _documentMode, _inputBridge, _trackedChangesMode, _trackedChangesEnabled, _trackedChangesOverrides, _headerFooterManager, _headerFooterAdapter, _headerFooterIdentifier, _headerLayoutResults, _footerLayoutResults, _headerDecorationProvider, _footerDecorationProvider, _headerFooterManagerCleanups, _headerRegions, _footerRegions, _session, _activeHeaderFooterEditor, _overlayManager, _hoverOverlay, _hoverTooltip, _modeBanner, _ariaLiveRegion, _hoverRegion, _clickCount, _lastClickTime, _lastClickPosition, _lastSelectedImageBlockId, _remoteCursorState, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _remoteCursorRafHandle, _scrollTimeout, _PresentationEditor_instances, aggregateLayoutBounds_fn, safeCleanup_fn, setupEditorListeners_fn, setupCollaborationCursors_fn, normalizeAwarenessStates_fn, getFallbackColor_fn, getValidatedColor_fn, scheduleRemoteCursorUpdate_fn, scheduleRemoteCursorReRender_fn, updateRemoteCursors_fn, renderRemoteCursors_fn, renderRemoteCaret_fn, renderRemoteCursorLabel_fn, renderRemoteSelection_fn, setupPointerHandlers_fn, setupInputBridge_fn, initHeaderFooterRegistry_fn, _handlePointerDown, getFirstTextPosition_fn, registerPointerClick_fn, selectWordAt_fn, selectParagraphAt_fn, isWordCharacter_fn, _handlePointerMove, _handlePointerLeave, _handleDoubleClick, _handleKeyDown, focusHeaderFooterShortcut_fn, scheduleRerender_fn, flushRerenderQueue_fn, rerender_fn, ensurePainter_fn, scheduleSelectionUpdate_fn, updateSelection_fn, resolveLayoutOptions_fn, buildHeaderFooterInput_fn, computeHeaderFooterConstraints_fn, updateDecorationProviders_fn, createDecorationProvider_fn, findHeaderFooterPageForPageNumber_fn, computeDecorationBox_fn, rebuildHeaderFooterRegions_fn, hitTestHeaderFooterRegion_fn, pointInRegion_fn, activateHeaderFooterRegion_fn, enterHeaderFooterMode_fn, exitHeaderFooterMode_fn, getActiveDomTarget_fn, emitHeaderFooterModeChanged_fn, emitHeaderFooterEditingContext_fn, updateAwarenessSession_fn, updateModeBanner_fn, announce_fn, validateHeaderFooterEditPermission_fn, emitHeaderFooterEditBlocked_fn, resolveDescriptorForRegion_fn, createDefaultHeaderFooter_fn, getPageElement_fn, scrollPageIntoView_fn, waitForPageMount_fn, getBodyPageHeight_fn, getHeaderFooterPageHeight_fn, renderSelectionRects_fn, renderHoverRegion_fn, clearHoverRegion_fn, renderCaretOverlay_fn, getHeaderFooterContext_fn, computeHeaderFooterSelectionRects_fn, syncTrackedChangesPreferences_fn, deriveTrackedChangesMode_fn, deriveTrackedChangesEnabled_fn, getTrackChangesPluginState_fn, computeDefaultLayoutDefaults_fn, parseColumns_fn, inchesToPx_fn, applyZoom_fn, createLayoutMetrics_fn, convertPageLocalToOverlayCoords_fn, normalizeClientPoint_fn, computeCaretLayoutRect_fn, computeCaretLayoutRectFromDOM_fn, computeTableCaretLayoutRect_fn, findLineContainingPos_fn, lineHeightBeforeIndex_fn, getCurrentPageIndex_fn, findRegionForPage_fn, handleLayoutError_fn, decorateError_fn, showLayoutErrorBanner_fn, dismissErrorBanner_fn, createHiddenHost_fn, _windowRoot, _layoutSurfaces, _getTargetDom, _onTargetChanged, _listeners, _currentTarget, _destroyed, _useWindowFallback, _PresentationInputBridge_instances, addListener_fn, dispatchToTarget_fn, forwardKeyboardEvent_fn, forwardTextEvent_fn, forwardCompositionEvent_fn, forwardContextMenu_fn, isEventOnActiveTarget_fn, shouldSkipSurface_fn, isInLayoutSurface_fn, getListenerTargets_fn, isPlainCharacterKey_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ParagraphNodeView_instances, checkShouldUpdate_fn, updateHTMLAttributes_fn, updateDOMStyles_fn, resolveNeighborParagraphProperties_fn, updateListStyles_fn, initList_fn, checkIsList_fn, createMarker_fn, createSeparator_fn, calculateTabSeparatorStyle_fn, calculateMarkerStyle_fn, removeList_fn, getParagraphContext_fn, scheduleAnimation_fn, cancelScheduledAnimation_fn, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn, _VectorShapeView_instances, ensureParentPositioned_fn, _ShapeGroupView_instances, ensureParentPositioned_fn2;
|
|
39506
39698
|
var GOOD_LEAF_SIZE = 200;
|
|
39507
39699
|
var RopeSequence = function RopeSequence2() {
|
|
39508
39700
|
};
|
|
@@ -50688,50 +50880,90 @@ const getCommentPositionsById = (commentId, doc2) => {
|
|
|
50688
50880
|
return positions;
|
|
50689
50881
|
};
|
|
50690
50882
|
const prepareCommentsForExport = (doc2, tr, schema, comments = []) => {
|
|
50883
|
+
const commentMap = /* @__PURE__ */ new Map();
|
|
50884
|
+
comments.forEach((c2) => {
|
|
50885
|
+
commentMap.set(c2.commentId, c2);
|
|
50886
|
+
});
|
|
50887
|
+
new Set(comments.filter((c2) => c2.parentCommentId).map((c2) => c2.parentCommentId));
|
|
50691
50888
|
const startNodes = [];
|
|
50692
50889
|
const endNodes = [];
|
|
50693
50890
|
const seen = /* @__PURE__ */ new Set();
|
|
50694
50891
|
doc2.descendants((node, pos) => {
|
|
50695
|
-
const commentMarks = node.marks?.filter((mark) => mark.type.name === CommentMarkName);
|
|
50892
|
+
const commentMarks = node.marks?.filter((mark) => mark.type.name === CommentMarkName) || [];
|
|
50696
50893
|
commentMarks.forEach((commentMark) => {
|
|
50697
|
-
|
|
50698
|
-
|
|
50699
|
-
|
|
50700
|
-
|
|
50701
|
-
|
|
50702
|
-
|
|
50703
|
-
|
|
50704
|
-
|
|
50894
|
+
const { attrs = {} } = commentMark;
|
|
50895
|
+
const { commentId } = attrs;
|
|
50896
|
+
if (commentId === "pending") return;
|
|
50897
|
+
if (seen.has(commentId)) return;
|
|
50898
|
+
seen.add(commentId);
|
|
50899
|
+
const comment = commentMap.get(commentId);
|
|
50900
|
+
const parentCommentId = comment?.parentCommentId;
|
|
50901
|
+
const commentStartNodeAttrs = getPreparedComment(commentMark.attrs);
|
|
50902
|
+
const startNode = schema.nodes.commentRangeStart.create(commentStartNodeAttrs);
|
|
50903
|
+
startNodes.push({
|
|
50904
|
+
pos,
|
|
50905
|
+
node: startNode,
|
|
50906
|
+
commentId,
|
|
50907
|
+
parentCommentId
|
|
50908
|
+
});
|
|
50909
|
+
const endNode = schema.nodes.commentRangeEnd.create(commentStartNodeAttrs);
|
|
50910
|
+
endNodes.push({
|
|
50911
|
+
pos: pos + node.nodeSize,
|
|
50912
|
+
node: endNode,
|
|
50913
|
+
commentId,
|
|
50914
|
+
parentCommentId
|
|
50915
|
+
});
|
|
50916
|
+
const childComments = comments.filter((c2) => c2.parentCommentId === commentId).sort((a, b2) => a.createdTime - b2.createdTime);
|
|
50917
|
+
childComments.forEach((c2) => {
|
|
50918
|
+
if (seen.has(c2.commentId)) return;
|
|
50919
|
+
seen.add(c2.commentId);
|
|
50920
|
+
const childMark = getPreparedComment({
|
|
50921
|
+
commentId: c2.commentId,
|
|
50922
|
+
internal: c2.isInternal
|
|
50923
|
+
});
|
|
50924
|
+
const childStartNode = schema.nodes.commentRangeStart.create(childMark);
|
|
50705
50925
|
startNodes.push({
|
|
50706
50926
|
pos,
|
|
50707
|
-
node:
|
|
50927
|
+
node: childStartNode,
|
|
50928
|
+
commentId: c2.commentId,
|
|
50929
|
+
parentCommentId: c2.parentCommentId
|
|
50708
50930
|
});
|
|
50709
|
-
const
|
|
50931
|
+
const childEndNode = schema.nodes.commentRangeEnd.create(childMark);
|
|
50710
50932
|
endNodes.push({
|
|
50711
50933
|
pos: pos + node.nodeSize,
|
|
50712
|
-
node:
|
|
50934
|
+
node: childEndNode,
|
|
50935
|
+
commentId: c2.commentId,
|
|
50936
|
+
parentCommentId: c2.parentCommentId
|
|
50713
50937
|
});
|
|
50714
|
-
|
|
50715
|
-
if (parentId) {
|
|
50716
|
-
const childComments = comments.filter((c2) => c2.parentCommentId === parentId).sort((a, b2) => a.createdTime - b2.createdTime);
|
|
50717
|
-
childComments.forEach((c2) => {
|
|
50718
|
-
const childMark = getPreparedComment(c2);
|
|
50719
|
-
const childStartNode = schema.nodes.commentRangeStart.create(childMark);
|
|
50720
|
-
seen.add(c2.commentId);
|
|
50721
|
-
startNodes.push({
|
|
50722
|
-
pos,
|
|
50723
|
-
node: childStartNode
|
|
50724
|
-
});
|
|
50725
|
-
const childEndNode = schema.nodes.commentRangeEnd.create(childMark);
|
|
50726
|
-
endNodes.push({
|
|
50727
|
-
pos: pos + node.nodeSize,
|
|
50728
|
-
node: childEndNode
|
|
50729
|
-
});
|
|
50730
|
-
});
|
|
50731
|
-
}
|
|
50732
|
-
}
|
|
50938
|
+
});
|
|
50733
50939
|
});
|
|
50734
50940
|
});
|
|
50941
|
+
startNodes.sort((a, b2) => {
|
|
50942
|
+
if (a.pos !== b2.pos) return a.pos - b2.pos;
|
|
50943
|
+
const aIsParentOfB = a.commentId === b2.parentCommentId;
|
|
50944
|
+
const bIsParentOfA = b2.commentId === a.parentCommentId;
|
|
50945
|
+
if (aIsParentOfB) return -1;
|
|
50946
|
+
if (bIsParentOfA) return 1;
|
|
50947
|
+
if (a.parentCommentId && a.parentCommentId === b2.parentCommentId) {
|
|
50948
|
+
const aComment = commentMap.get(a.commentId);
|
|
50949
|
+
const bComment = commentMap.get(b2.commentId);
|
|
50950
|
+
return (aComment?.createdTime || 0) - (bComment?.createdTime || 0);
|
|
50951
|
+
}
|
|
50952
|
+
return 0;
|
|
50953
|
+
});
|
|
50954
|
+
endNodes.sort((a, b2) => {
|
|
50955
|
+
if (a.pos !== b2.pos) return a.pos - b2.pos;
|
|
50956
|
+
const aIsParentOfB = a.commentId === b2.parentCommentId;
|
|
50957
|
+
const bIsParentOfA = b2.commentId === a.parentCommentId;
|
|
50958
|
+
if (aIsParentOfB) return -1;
|
|
50959
|
+
if (bIsParentOfA) return 1;
|
|
50960
|
+
if (a.parentCommentId && a.parentCommentId === b2.parentCommentId) {
|
|
50961
|
+
const aComment = commentMap.get(a.commentId);
|
|
50962
|
+
const bComment = commentMap.get(b2.commentId);
|
|
50963
|
+
return (aComment?.createdTime || 0) - (bComment?.createdTime || 0);
|
|
50964
|
+
}
|
|
50965
|
+
return 0;
|
|
50966
|
+
});
|
|
50735
50967
|
startNodes.forEach((n) => {
|
|
50736
50968
|
const { pos, node } = n;
|
|
50737
50969
|
const mappedPos = tr.mapping.map(pos);
|
|
@@ -53273,7 +53505,7 @@ const isHeadless = (editor) => {
|
|
|
53273
53505
|
const shouldSkipNodeView = (editor) => {
|
|
53274
53506
|
return isHeadless(editor);
|
|
53275
53507
|
};
|
|
53276
|
-
const summaryVersion = "1.0.0-beta.
|
|
53508
|
+
const summaryVersion = "1.0.0-beta.19";
|
|
53277
53509
|
const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
|
|
53278
53510
|
const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
|
|
53279
53511
|
function mapAttributes(attrs) {
|
|
@@ -54049,7 +54281,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
54049
54281
|
{ default: remarkStringify },
|
|
54050
54282
|
{ default: remarkGfm }
|
|
54051
54283
|
] = await Promise.all([
|
|
54052
|
-
Promise.resolve().then(() => require("./index-
|
|
54284
|
+
Promise.resolve().then(() => require("./index-CRpn1mWd-BUbbd3Jq.cjs")),
|
|
54053
54285
|
Promise.resolve().then(() => require("./index-DRCvimau-H4Ck3S9a.cjs")),
|
|
54054
54286
|
Promise.resolve().then(() => require("./index-C_x_N6Uh-Db3CUJMX.cjs")),
|
|
54055
54287
|
Promise.resolve().then(() => require("./index-D_sWOSiG-BtDZzJ6I.cjs")),
|
|
@@ -54254,7 +54486,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
54254
54486
|
* Process collaboration migrations
|
|
54255
54487
|
*/
|
|
54256
54488
|
processCollaborationMigrations() {
|
|
54257
|
-
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.
|
|
54489
|
+
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.19");
|
|
54258
54490
|
if (!this.options.ydoc) return;
|
|
54259
54491
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
54260
54492
|
let docVersion = metaMap.get("version");
|
|
@@ -54956,6 +55188,15 @@ function extractColumns(elements) {
|
|
|
54956
55188
|
gap: gapInches * PX_PER_INCH$2
|
|
54957
55189
|
};
|
|
54958
55190
|
}
|
|
55191
|
+
function extractVerticalAlign(elements) {
|
|
55192
|
+
const vAlign = elements.find((el) => el?.name === "w:vAlign");
|
|
55193
|
+
if (!vAlign?.attributes) return void 0;
|
|
55194
|
+
const val = vAlign.attributes["w:val"];
|
|
55195
|
+
if (val === "top" || val === "center" || val === "bottom" || val === "both") {
|
|
55196
|
+
return val;
|
|
55197
|
+
}
|
|
55198
|
+
return void 0;
|
|
55199
|
+
}
|
|
54959
55200
|
function extractSectionData(para) {
|
|
54960
55201
|
const attrs = para.attrs ?? {};
|
|
54961
55202
|
let { headerPx, footerPx } = extractNormalizedMargins(attrs);
|
|
@@ -54972,7 +55213,20 @@ function extractSectionData(para) {
|
|
|
54972
55213
|
const footerRefs = extractHeaderFooterRefs(sectPrElements, "w:footerReference");
|
|
54973
55214
|
const numbering = extractPageNumbering(sectPrElements);
|
|
54974
55215
|
const columnsPx = extractColumns(sectPrElements);
|
|
54975
|
-
|
|
55216
|
+
const vAlign = extractVerticalAlign(sectPrElements);
|
|
55217
|
+
return {
|
|
55218
|
+
headerPx,
|
|
55219
|
+
footerPx,
|
|
55220
|
+
type: type2,
|
|
55221
|
+
pageSizePx,
|
|
55222
|
+
orientation,
|
|
55223
|
+
columnsPx,
|
|
55224
|
+
titlePg,
|
|
55225
|
+
headerRefs,
|
|
55226
|
+
footerRefs,
|
|
55227
|
+
numbering,
|
|
55228
|
+
vAlign
|
|
55229
|
+
};
|
|
54976
55230
|
}
|
|
54977
55231
|
function isSectPrElement(value) {
|
|
54978
55232
|
return typeof value === "object" && value !== null && value.type === "element" && value.name === "w:sectPr";
|
|
@@ -55009,7 +55263,8 @@ function createSectionBreakBlock(section, blockIdGen, extraAttrs) {
|
|
|
55009
55263
|
...section.columns && { columns: section.columns },
|
|
55010
55264
|
...section.numbering ? { numbering: section.numbering } : {},
|
|
55011
55265
|
...section.headerRefs && { headerRefs: section.headerRefs },
|
|
55012
|
-
...section.footerRefs && { footerRefs: section.footerRefs }
|
|
55266
|
+
...section.footerRefs && { footerRefs: section.footerRefs },
|
|
55267
|
+
...section.vAlign && { vAlign: section.vAlign }
|
|
55013
55268
|
};
|
|
55014
55269
|
return result;
|
|
55015
55270
|
}
|
|
@@ -55081,7 +55336,8 @@ function buildSectionRangesFromParagraphs(paragraphs, hasBodySectPr) {
|
|
|
55081
55336
|
titlePg: sectionData.titlePg ?? false,
|
|
55082
55337
|
headerRefs: sectionData.headerRefs,
|
|
55083
55338
|
footerRefs: sectionData.footerRefs,
|
|
55084
|
-
numbering: sectionData.numbering
|
|
55339
|
+
numbering: sectionData.numbering,
|
|
55340
|
+
vAlign: sectionData.vAlign
|
|
55085
55341
|
};
|
|
55086
55342
|
ranges.push(range2);
|
|
55087
55343
|
currentStart = item.index + 1;
|
|
@@ -55120,7 +55376,8 @@ function createFinalSectionFromBodySectPr(bodySectPr, currentStart, totalParagra
|
|
|
55120
55376
|
type: bodySectionData.type ?? DEFAULT_BODY_SECTION_TYPE,
|
|
55121
55377
|
titlePg: bodySectionData.titlePg ?? false,
|
|
55122
55378
|
headerRefs: bodySectionData.headerRefs,
|
|
55123
|
-
footerRefs: bodySectionData.footerRefs
|
|
55379
|
+
footerRefs: bodySectionData.footerRefs,
|
|
55380
|
+
vAlign: bodySectionData.vAlign
|
|
55124
55381
|
};
|
|
55125
55382
|
}
|
|
55126
55383
|
function createDefaultFinalSection(currentStart, totalParagraphs, sectionIndex) {
|
|
@@ -56783,8 +57040,9 @@ const normalizeOoxmlTabs = (tabs) => {
|
|
|
56783
57040
|
for (const entry of tabs) {
|
|
56784
57041
|
if (!entry || typeof entry !== "object") continue;
|
|
56785
57042
|
const rawEntry = entry;
|
|
56786
|
-
const
|
|
56787
|
-
const
|
|
57043
|
+
const isNestedTab = Boolean(rawEntry.tab && typeof rawEntry.tab === "object");
|
|
57044
|
+
const source = isNestedTab ? rawEntry.tab : rawEntry;
|
|
57045
|
+
const posTwips = resolveTabPosition(source, isNestedTab);
|
|
56788
57046
|
if (posTwips == null) continue;
|
|
56789
57047
|
const val = normalizeTabVal(source.val ?? source.align ?? source.alignment ?? source.type ?? source.tabType);
|
|
56790
57048
|
if (!val) continue;
|
|
@@ -56798,7 +57056,7 @@ const normalizeOoxmlTabs = (tabs) => {
|
|
|
56798
57056
|
}
|
|
56799
57057
|
return normalized.length > 0 ? normalized : void 0;
|
|
56800
57058
|
};
|
|
56801
|
-
const resolveTabPosition = (source) => {
|
|
57059
|
+
const resolveTabPosition = (source, treatPosAsTwips = false) => {
|
|
56802
57060
|
const originalPos = pickNumber(source.originalPos);
|
|
56803
57061
|
if (originalPos != null) {
|
|
56804
57062
|
return originalPos;
|
|
@@ -56807,6 +57065,9 @@ const resolveTabPosition = (source) => {
|
|
|
56807
57065
|
if (posValue == null) {
|
|
56808
57066
|
return void 0;
|
|
56809
57067
|
}
|
|
57068
|
+
if (treatPosAsTwips) {
|
|
57069
|
+
return posValue;
|
|
57070
|
+
}
|
|
56810
57071
|
if (posValue > TWIPS_THRESHOLD) {
|
|
56811
57072
|
return posValue;
|
|
56812
57073
|
} else {
|
|
@@ -58317,8 +58578,16 @@ const extractMarkerRun = (lvl) => {
|
|
|
58317
58578
|
}
|
|
58318
58579
|
const color = normalizeColor(getAttribute(findChild(rPr, "w:color"), "w:val"));
|
|
58319
58580
|
if (color) run2.color = color;
|
|
58320
|
-
|
|
58321
|
-
if (
|
|
58581
|
+
const boldEl = findChild(rPr, "w:b");
|
|
58582
|
+
if (boldEl) {
|
|
58583
|
+
const boldVal = getAttribute(boldEl, "w:val");
|
|
58584
|
+
if (boldVal == null || isTruthy(boldVal)) run2.bold = true;
|
|
58585
|
+
}
|
|
58586
|
+
const italicEl = findChild(rPr, "w:i");
|
|
58587
|
+
if (italicEl) {
|
|
58588
|
+
const italicVal = getAttribute(italicEl, "w:val");
|
|
58589
|
+
if (italicVal == null || isTruthy(italicVal)) run2.italic = true;
|
|
58590
|
+
}
|
|
58322
58591
|
const spacingTwips = parseNumberAttr(getAttribute(findChild(rPr, "w:spacing"), "w:val"));
|
|
58323
58592
|
if (spacingTwips != null && Number.isFinite(spacingTwips)) {
|
|
58324
58593
|
run2.letterSpacing = twipsToPx$1(spacingTwips);
|
|
@@ -58794,19 +59063,21 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
58794
59063
|
}
|
|
58795
59064
|
const tabObj = tab;
|
|
58796
59065
|
const val = typeof tabObj.tabType === "string" ? tabObj.tabType : typeof tabObj.val === "string" ? tabObj.val : void 0;
|
|
58797
|
-
const
|
|
59066
|
+
const originalPos = pickNumber(tabObj.originalPos);
|
|
59067
|
+
const pos = originalPos ?? pickNumber(tabObj.pos);
|
|
58798
59068
|
if (!val || pos == null) {
|
|
58799
59069
|
continue;
|
|
58800
59070
|
}
|
|
58801
59071
|
const normalized = { val, pos };
|
|
59072
|
+
if (originalPos != null && Number.isFinite(originalPos)) {
|
|
59073
|
+
normalized.originalPos = originalPos;
|
|
59074
|
+
} else {
|
|
59075
|
+
normalized.originalPos = pos;
|
|
59076
|
+
}
|
|
58802
59077
|
const leader = tabObj.leader;
|
|
58803
59078
|
if (typeof leader === "string" && leader.length > 0) {
|
|
58804
59079
|
normalized.leader = leader;
|
|
58805
59080
|
}
|
|
58806
|
-
const originalPos = pickNumber(tabObj.originalPos);
|
|
58807
|
-
if (originalPos != null && Number.isFinite(originalPos)) {
|
|
58808
|
-
normalized.originalPos = originalPos;
|
|
58809
|
-
}
|
|
58810
59081
|
unwrapped.push(normalized);
|
|
58811
59082
|
continue;
|
|
58812
59083
|
}
|
|
@@ -59648,11 +59919,11 @@ const applyLinkedStyleToRun = (run2, options) => {
|
|
|
59648
59919
|
if (!maps.length) return;
|
|
59649
59920
|
const finalStyles = Object.assign({}, ...maps);
|
|
59650
59921
|
const fontFamily2 = extractValue(finalStyles["font-family"]);
|
|
59651
|
-
if (typeof fontFamily2 === "string" && fontFamily2
|
|
59922
|
+
if (typeof fontFamily2 === "string" && fontFamily2) {
|
|
59652
59923
|
run2.fontFamily = fontFamily2;
|
|
59653
59924
|
}
|
|
59654
59925
|
const fontSize2 = toPxNumber(finalStyles["font-size"]);
|
|
59655
|
-
if (fontSize2 != null
|
|
59926
|
+
if (fontSize2 != null) {
|
|
59656
59927
|
run2.fontSize = fontSize2;
|
|
59657
59928
|
}
|
|
59658
59929
|
const letterSpacing = toPxNumber(finalStyles["letter-spacing"]);
|
|
@@ -60015,9 +60286,7 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
|
|
|
60015
60286
|
resolver: linkedStyleResolver,
|
|
60016
60287
|
paragraphStyleId,
|
|
60017
60288
|
inlineStyleId,
|
|
60018
|
-
runStyleId
|
|
60019
|
-
defaultFont,
|
|
60020
|
-
defaultSize
|
|
60289
|
+
runStyleId
|
|
60021
60290
|
});
|
|
60022
60291
|
};
|
|
60023
60292
|
const visitNode = (node, inheritedMarks = [], activeSdt, activeRunStyleId = null) => {
|
|
@@ -60027,7 +60296,8 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
|
|
|
60027
60296
|
positions,
|
|
60028
60297
|
defaultFont,
|
|
60029
60298
|
defaultSize,
|
|
60030
|
-
|
|
60299
|
+
[],
|
|
60300
|
+
// Empty marks - will be applied after linked styles
|
|
60031
60301
|
activeSdt,
|
|
60032
60302
|
hyperlinkConfig,
|
|
60033
60303
|
themeColors
|
|
@@ -60035,6 +60305,7 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
|
|
|
60035
60305
|
const inlineStyleId = getInlineStyleId(inheritedMarks);
|
|
60036
60306
|
applyRunStyles2(run2, inlineStyleId, activeRunStyleId);
|
|
60037
60307
|
applyBaseRunDefaults(run2, baseRunDefaults, defaultFont, defaultSize);
|
|
60308
|
+
applyMarksToRun(run2, [...node.marks ?? [], ...inheritedMarks ?? []], hyperlinkConfig, themeColors);
|
|
60038
60309
|
currentRuns.push(run2);
|
|
60039
60310
|
return;
|
|
60040
60311
|
}
|
|
@@ -61909,13 +62180,14 @@ function processFragment(fragmentEl, viewX, viewY) {
|
|
|
61909
62180
|
if (!Number.isFinite(lineStart) || !Number.isFinite(lineEnd)) {
|
|
61910
62181
|
return null;
|
|
61911
62182
|
}
|
|
61912
|
-
const spanEls = Array.from(lineEl.querySelectorAll("span"));
|
|
62183
|
+
const spanEls = Array.from(lineEl.querySelectorAll("span, a"));
|
|
61913
62184
|
log(
|
|
61914
|
-
"Spans in line:",
|
|
62185
|
+
"Spans/anchors in line:",
|
|
61915
62186
|
spanEls.map((el, i) => {
|
|
61916
62187
|
const rect = el.getBoundingClientRect();
|
|
61917
62188
|
return {
|
|
61918
62189
|
index: i,
|
|
62190
|
+
tag: el.tagName,
|
|
61919
62191
|
pmStart: el.dataset.pmStart,
|
|
61920
62192
|
pmEnd: el.dataset.pmEnd,
|
|
61921
62193
|
text: el.textContent?.substring(0, 20) + (el.textContent && el.textContent.length > 20 ? "..." : ""),
|
|
@@ -61935,32 +62207,33 @@ function processFragment(fragmentEl, viewX, viewY) {
|
|
|
61935
62207
|
if (viewX >= lastRect.right) {
|
|
61936
62208
|
return lineEnd;
|
|
61937
62209
|
}
|
|
61938
|
-
const
|
|
61939
|
-
if (!
|
|
62210
|
+
const targetEl = findSpanAtX(spanEls, viewX);
|
|
62211
|
+
if (!targetEl) {
|
|
61940
62212
|
return lineStart;
|
|
61941
62213
|
}
|
|
61942
|
-
const spanStart = Number(
|
|
61943
|
-
const spanEnd = Number(
|
|
61944
|
-
const targetRect =
|
|
61945
|
-
log("Target
|
|
62214
|
+
const spanStart = Number(targetEl.dataset.pmStart ?? "NaN");
|
|
62215
|
+
const spanEnd = Number(targetEl.dataset.pmEnd ?? "NaN");
|
|
62216
|
+
const targetRect = targetEl.getBoundingClientRect();
|
|
62217
|
+
log("Target element:", {
|
|
62218
|
+
tag: targetEl.tagName,
|
|
61946
62219
|
pmStart: spanStart,
|
|
61947
62220
|
pmEnd: spanEnd,
|
|
61948
|
-
text:
|
|
61949
|
-
visibility:
|
|
62221
|
+
text: targetEl.textContent?.substring(0, 30),
|
|
62222
|
+
visibility: targetEl.style.visibility,
|
|
61950
62223
|
rect: { left: targetRect.left, right: targetRect.right, width: targetRect.width }
|
|
61951
62224
|
});
|
|
61952
62225
|
if (!Number.isFinite(spanStart) || !Number.isFinite(spanEnd)) {
|
|
61953
62226
|
return null;
|
|
61954
62227
|
}
|
|
61955
|
-
const firstChild =
|
|
62228
|
+
const firstChild = targetEl.firstChild;
|
|
61956
62229
|
if (!firstChild || firstChild.nodeType !== Node.TEXT_NODE || !firstChild.textContent) {
|
|
61957
|
-
const
|
|
61958
|
-
const closerToLeft = Math.abs(viewX -
|
|
62230
|
+
const elRect = targetEl.getBoundingClientRect();
|
|
62231
|
+
const closerToLeft = Math.abs(viewX - elRect.left) <= Math.abs(viewX - elRect.right);
|
|
61959
62232
|
const snapPos = closerToLeft ? spanStart : spanEnd;
|
|
61960
62233
|
return snapPos;
|
|
61961
62234
|
}
|
|
61962
62235
|
const textNode = firstChild;
|
|
61963
|
-
const charIndex = findCharIndexAtX(textNode,
|
|
62236
|
+
const charIndex = findCharIndexAtX(textNode, targetEl, viewX);
|
|
61964
62237
|
const pos = spanStart + charIndex;
|
|
61965
62238
|
return pos;
|
|
61966
62239
|
}
|
|
@@ -61998,7 +62271,8 @@ function findSpanAtX(spanEls, viewX) {
|
|
|
61998
62271
|
const span = spanEls[i];
|
|
61999
62272
|
const rect = span.getBoundingClientRect();
|
|
62000
62273
|
if (viewX >= rect.left && viewX <= rect.right) {
|
|
62001
|
-
log("findSpanAtX: Found containing
|
|
62274
|
+
log("findSpanAtX: Found containing element at index", i, {
|
|
62275
|
+
tag: span.tagName,
|
|
62002
62276
|
pmStart: span.dataset.pmStart,
|
|
62003
62277
|
pmEnd: span.dataset.pmEnd,
|
|
62004
62278
|
rect: { left: rect.left, right: rect.right },
|
|
@@ -62010,16 +62284,17 @@ function findSpanAtX(spanEls, viewX) {
|
|
|
62010
62284
|
targetSpan = span;
|
|
62011
62285
|
}
|
|
62012
62286
|
}
|
|
62013
|
-
log("findSpanAtX: No containing
|
|
62287
|
+
log("findSpanAtX: No containing element, using nearest:", {
|
|
62288
|
+
tag: targetSpan.tagName,
|
|
62014
62289
|
pmStart: targetSpan.dataset.pmStart,
|
|
62015
62290
|
pmEnd: targetSpan.dataset.pmEnd,
|
|
62016
62291
|
viewX
|
|
62017
62292
|
});
|
|
62018
62293
|
return targetSpan;
|
|
62019
62294
|
}
|
|
62020
|
-
function findCharIndexAtX(textNode,
|
|
62295
|
+
function findCharIndexAtX(textNode, container, targetX) {
|
|
62021
62296
|
const text = textNode.textContent ?? "";
|
|
62022
|
-
const baseLeft =
|
|
62297
|
+
const baseLeft = container.getBoundingClientRect().left;
|
|
62023
62298
|
const range2 = document.createRange();
|
|
62024
62299
|
let lo = 0;
|
|
62025
62300
|
let hi = text.length;
|
|
@@ -62351,6 +62626,9 @@ function computeNextSectionPropsAtBreak(blocks) {
|
|
|
62351
62626
|
if (source.orientation) {
|
|
62352
62627
|
props.orientation = source.orientation;
|
|
62353
62628
|
}
|
|
62629
|
+
if (source.vAlign) {
|
|
62630
|
+
props.vAlign = source.vAlign;
|
|
62631
|
+
}
|
|
62354
62632
|
return props;
|
|
62355
62633
|
};
|
|
62356
62634
|
docxBreakIndexes.forEach((index2, ordinal) => {
|
|
@@ -63751,6 +64029,10 @@ function cloneBlockWithResolvedTokens(block, displayPageText, totalPagesStr) {
|
|
|
63751
64029
|
runs: clonedRuns
|
|
63752
64030
|
};
|
|
63753
64031
|
}
|
|
64032
|
+
const DEFAULT_PARAGRAPH_LINE_HEIGHT_PX = 20;
|
|
64033
|
+
function hasHeight(fragment) {
|
|
64034
|
+
return fragment.kind === "image" || fragment.kind === "drawing" || fragment.kind === "table";
|
|
64035
|
+
}
|
|
63754
64036
|
const DEFAULT_PAGE_SIZE$2 = { w: 612, h: 792 };
|
|
63755
64037
|
const DEFAULT_MARGINS$2 = { top: 72, right: 72, bottom: 72, left: 72 };
|
|
63756
64038
|
const COLUMN_EPSILON = 1e-4;
|
|
@@ -63845,6 +64127,8 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
63845
64127
|
let pendingColumns = null;
|
|
63846
64128
|
let activeOrientation = null;
|
|
63847
64129
|
let pendingOrientation = null;
|
|
64130
|
+
let activeVAlign = null;
|
|
64131
|
+
let pendingVAlign = null;
|
|
63848
64132
|
const floatManager = createFloatingObjectManager(
|
|
63849
64133
|
normalizeColumns(activeColumns, contentWidth),
|
|
63850
64134
|
{ left: margins.left, right: margins.right },
|
|
@@ -63950,6 +64234,9 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
63950
64234
|
if (activeOrientation) {
|
|
63951
64235
|
page.orientation = activeOrientation;
|
|
63952
64236
|
}
|
|
64237
|
+
if (activeVAlign && activeVAlign !== "top") {
|
|
64238
|
+
page.vAlign = activeVAlign;
|
|
64239
|
+
}
|
|
63953
64240
|
return page;
|
|
63954
64241
|
};
|
|
63955
64242
|
let pageCount = 0;
|
|
@@ -64028,6 +64315,10 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
64028
64315
|
activeSectionRefs = pendingSectionRefs;
|
|
64029
64316
|
pendingSectionRefs = null;
|
|
64030
64317
|
}
|
|
64318
|
+
if (pendingVAlign !== null) {
|
|
64319
|
+
activeVAlign = pendingVAlign;
|
|
64320
|
+
pendingVAlign = null;
|
|
64321
|
+
}
|
|
64031
64322
|
pageCount += 1;
|
|
64032
64323
|
return;
|
|
64033
64324
|
}
|
|
@@ -64164,7 +64455,8 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
64164
64455
|
margins: ahead.margins ? { ...effectiveBlock.margins ?? {}, ...ahead.margins } : effectiveBlock.margins ?? {},
|
|
64165
64456
|
pageSize: ahead.pageSize ?? effectiveBlock.pageSize,
|
|
64166
64457
|
columns: ahead.columns ?? effectiveBlock.columns,
|
|
64167
|
-
orientation: ahead.orientation ?? effectiveBlock.orientation
|
|
64458
|
+
orientation: ahead.orientation ?? effectiveBlock.orientation,
|
|
64459
|
+
vAlign: ahead.vAlign ?? effectiveBlock.vAlign
|
|
64168
64460
|
};
|
|
64169
64461
|
}
|
|
64170
64462
|
const sectionState = {
|
|
@@ -64217,6 +64509,15 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
64217
64509
|
pendingColumns = updatedState.pendingColumns;
|
|
64218
64510
|
activeOrientation = updatedState.activeOrientation;
|
|
64219
64511
|
pendingOrientation = updatedState.pendingOrientation;
|
|
64512
|
+
if (effectiveBlock.vAlign) {
|
|
64513
|
+
const isFirstSection = effectiveBlock.attrs?.isFirstSection && states.length === 0;
|
|
64514
|
+
if (isFirstSection) {
|
|
64515
|
+
activeVAlign = effectiveBlock.vAlign;
|
|
64516
|
+
pendingVAlign = null;
|
|
64517
|
+
} else {
|
|
64518
|
+
pendingVAlign = effectiveBlock.vAlign;
|
|
64519
|
+
}
|
|
64520
|
+
}
|
|
64220
64521
|
if (effectiveBlock.headerRefs || effectiveBlock.footerRefs) {
|
|
64221
64522
|
pendingSectionRefs = {
|
|
64222
64523
|
...effectiveBlock.headerRefs && { headerRefs: effectiveBlock.headerRefs },
|
|
@@ -64225,8 +64526,17 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
64225
64526
|
layoutLog(`[Layout] After scheduleSectionBreakCompat: Scheduled pendingSectionRefs:`, pendingSectionRefs);
|
|
64226
64527
|
}
|
|
64227
64528
|
if (breakInfo.forceMidPageRegion && block.columns) {
|
|
64228
|
-
|
|
64229
|
-
|
|
64529
|
+
let state2 = paginator.ensurePage();
|
|
64530
|
+
const columnIndexBefore = state2.columnIndex;
|
|
64531
|
+
const rawCount = block.columns.count;
|
|
64532
|
+
const validatedCount = typeof rawCount === "number" && Number.isFinite(rawCount) && rawCount > 0 ? Math.max(1, Math.floor(rawCount)) : 1;
|
|
64533
|
+
const rawGap = block.columns.gap;
|
|
64534
|
+
const validatedGap = typeof rawGap === "number" && Number.isFinite(rawGap) && rawGap >= 0 ? Math.max(0, rawGap) : 0;
|
|
64535
|
+
const newColumns = { count: validatedCount, gap: validatedGap };
|
|
64536
|
+
if (columnIndexBefore >= newColumns.count) {
|
|
64537
|
+
state2 = paginator.startNewPage();
|
|
64538
|
+
}
|
|
64539
|
+
startMidPageRegion(state2, newColumns);
|
|
64230
64540
|
}
|
|
64231
64541
|
if (breakInfo.forcePageBreak) {
|
|
64232
64542
|
let state2 = paginator.ensurePage();
|
|
@@ -64418,6 +64728,45 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
64418
64728
|
while (pages.length > 0 && pages[pages.length - 1].fragments.length === 0) {
|
|
64419
64729
|
pages.pop();
|
|
64420
64730
|
}
|
|
64731
|
+
for (const page of pages) {
|
|
64732
|
+
if (!page.vAlign || page.vAlign === "top") continue;
|
|
64733
|
+
if (page.fragments.length === 0) continue;
|
|
64734
|
+
const pageSizeForPage = page.size ?? pageSize;
|
|
64735
|
+
const contentTop = page.margins?.top ?? margins.top;
|
|
64736
|
+
const contentBottom = pageSizeForPage.h - (page.margins?.bottom ?? margins.bottom);
|
|
64737
|
+
const contentHeight = contentBottom - contentTop;
|
|
64738
|
+
let minY = Infinity;
|
|
64739
|
+
let maxY = -Infinity;
|
|
64740
|
+
for (const fragment of page.fragments) {
|
|
64741
|
+
if (fragment.y < minY) minY = fragment.y;
|
|
64742
|
+
let fragmentBottom = fragment.y;
|
|
64743
|
+
if (hasHeight(fragment)) {
|
|
64744
|
+
fragmentBottom += fragment.height;
|
|
64745
|
+
} else {
|
|
64746
|
+
const lineCount = fragment.toLine - fragment.fromLine;
|
|
64747
|
+
fragmentBottom += lineCount * DEFAULT_PARAGRAPH_LINE_HEIGHT_PX;
|
|
64748
|
+
}
|
|
64749
|
+
if (fragmentBottom > maxY) maxY = fragmentBottom;
|
|
64750
|
+
}
|
|
64751
|
+
const actualContentHeight = maxY - minY;
|
|
64752
|
+
const availableSpace = contentHeight - actualContentHeight;
|
|
64753
|
+
if (availableSpace <= 0) {
|
|
64754
|
+
continue;
|
|
64755
|
+
}
|
|
64756
|
+
let yOffset = 0;
|
|
64757
|
+
if (page.vAlign === "center") {
|
|
64758
|
+
yOffset = availableSpace / 2;
|
|
64759
|
+
} else if (page.vAlign === "bottom") {
|
|
64760
|
+
yOffset = availableSpace;
|
|
64761
|
+
} else if (page.vAlign === "both") {
|
|
64762
|
+
yOffset = availableSpace / 2;
|
|
64763
|
+
}
|
|
64764
|
+
if (yOffset > 0) {
|
|
64765
|
+
for (const fragment of page.fragments) {
|
|
64766
|
+
fragment.y += yOffset;
|
|
64767
|
+
}
|
|
64768
|
+
}
|
|
64769
|
+
}
|
|
64421
64770
|
return {
|
|
64422
64771
|
pageSize,
|
|
64423
64772
|
pages,
|
|
@@ -68845,14 +69194,25 @@ const PRINT_STYLES = `
|
|
|
68845
69194
|
}
|
|
68846
69195
|
`;
|
|
68847
69196
|
const LINK_AND_TOC_STYLES = `
|
|
68848
|
-
/* Reset browser default link styling - allow run colors to show through
|
|
69197
|
+
/* Reset browser default link styling - allow run colors to show through from inline styles
|
|
69198
|
+
*
|
|
69199
|
+
* Note: !important was removed from these rules to allow inline styles to take precedence.
|
|
69200
|
+
* This is necessary because OOXML hyperlink character styles apply colors via inline style
|
|
69201
|
+
* attributes on the run elements. The CSS cascade ensures that inline styles (applied via
|
|
69202
|
+
* element.style.color in applyRunStyles) override these class-based rules naturally.
|
|
69203
|
+
*
|
|
69204
|
+
* Implications:
|
|
69205
|
+
* - OOXML hyperlink character styles will correctly display their assigned colors
|
|
69206
|
+
* - Browser default link colors are still reset by these inherit rules
|
|
69207
|
+
* - Inline color styles from run objects override the inherit value as expected
|
|
69208
|
+
*/
|
|
68849
69209
|
.superdoc-link {
|
|
68850
|
-
color: inherit
|
|
68851
|
-
text-decoration: none
|
|
69210
|
+
color: inherit;
|
|
69211
|
+
text-decoration: none;
|
|
68852
69212
|
}
|
|
68853
69213
|
|
|
68854
69214
|
.superdoc-link:visited {
|
|
68855
|
-
color: inherit
|
|
69215
|
+
color: inherit;
|
|
68856
69216
|
}
|
|
68857
69217
|
|
|
68858
69218
|
.superdoc-link:hover {
|
|
@@ -70391,14 +70751,23 @@ const _DomPainter = class _DomPainter2 {
|
|
|
70391
70751
|
lines.forEach((line, index2) => {
|
|
70392
70752
|
const lineEl = this.renderLine(block, line, context);
|
|
70393
70753
|
const isListFirstLine = index2 === 0 && !fragment.continuesFromPrev && fragment.markerWidth && wordLayout?.marker;
|
|
70394
|
-
|
|
70395
|
-
|
|
70754
|
+
const hasExplicitSegmentPositioning = line.segments?.some((seg) => seg.x !== void 0);
|
|
70755
|
+
const isFirstLine = index2 === 0 && !fragment.continuesFromPrev;
|
|
70756
|
+
if (!isListFirstLine) {
|
|
70757
|
+
if (isFirstLine && hasExplicitSegmentPositioning && firstLineOffset !== 0) {
|
|
70758
|
+
const adjustedPadding = paraIndentLeft + firstLineOffset;
|
|
70759
|
+
lineEl.style.paddingLeft = `${adjustedPadding}px`;
|
|
70760
|
+
} else if (paraIndentLeft) {
|
|
70761
|
+
lineEl.style.paddingLeft = `${paraIndentLeft}px`;
|
|
70762
|
+
}
|
|
70396
70763
|
}
|
|
70397
70764
|
if (paraIndentRight) {
|
|
70398
70765
|
lineEl.style.paddingRight = `${paraIndentRight}px`;
|
|
70399
70766
|
}
|
|
70400
70767
|
if (!fragment.continuesFromPrev && index2 === 0 && firstLineOffset && !isListFirstLine) {
|
|
70401
|
-
|
|
70768
|
+
if (!hasExplicitSegmentPositioning) {
|
|
70769
|
+
lineEl.style.textIndent = `${firstLineOffset}px`;
|
|
70770
|
+
}
|
|
70402
70771
|
} else if (firstLineOffset && !isListFirstLine) {
|
|
70403
70772
|
lineEl.style.textIndent = "0px";
|
|
70404
70773
|
}
|
|
@@ -71292,6 +71661,24 @@ const _DomPainter = class _DomPainter2 {
|
|
|
71292
71661
|
}
|
|
71293
71662
|
elem.setAttribute("role", "link");
|
|
71294
71663
|
elem.setAttribute("tabindex", "0");
|
|
71664
|
+
elem.addEventListener("click", (event) => {
|
|
71665
|
+
event.preventDefault();
|
|
71666
|
+
event.stopPropagation();
|
|
71667
|
+
const linkClickEvent = new CustomEvent("superdoc-link-click", {
|
|
71668
|
+
bubbles: true,
|
|
71669
|
+
composed: true,
|
|
71670
|
+
detail: {
|
|
71671
|
+
href: linkData.href,
|
|
71672
|
+
target: linkData.target,
|
|
71673
|
+
rel: linkData.rel,
|
|
71674
|
+
tooltip: linkData.tooltip,
|
|
71675
|
+
element: elem,
|
|
71676
|
+
clientX: event.clientX,
|
|
71677
|
+
clientY: event.clientY
|
|
71678
|
+
}
|
|
71679
|
+
});
|
|
71680
|
+
elem.dispatchEvent(linkClickEvent);
|
|
71681
|
+
});
|
|
71295
71682
|
}
|
|
71296
71683
|
/**
|
|
71297
71684
|
* Render a single run as an HTML element (span or anchor).
|
|
@@ -71581,7 +71968,13 @@ const _DomPainter = class _DomPainter2 {
|
|
|
71581
71968
|
if (styleId) {
|
|
71582
71969
|
elem.setAttribute("styleid", styleId);
|
|
71583
71970
|
}
|
|
71971
|
+
const runSegments2 = segmentsByRun.get(runIndex);
|
|
71972
|
+
const segX = runSegments2 && runSegments2[0]?.x !== void 0 ? runSegments2[0].x : cumulativeX;
|
|
71973
|
+
const segWidth = (runSegments2 && runSegments2[0]?.width !== void 0 ? runSegments2[0].width : elem.offsetWidth) ?? 0;
|
|
71974
|
+
elem.style.position = "absolute";
|
|
71975
|
+
elem.style.left = `${segX}px`;
|
|
71584
71976
|
el.appendChild(elem);
|
|
71977
|
+
cumulativeX = segX + segWidth;
|
|
71585
71978
|
}
|
|
71586
71979
|
continue;
|
|
71587
71980
|
}
|
|
@@ -72123,7 +72516,7 @@ const deriveBlockVersion = (block) => {
|
|
|
72123
72516
|
}
|
|
72124
72517
|
return block.id;
|
|
72125
72518
|
};
|
|
72126
|
-
const applyRunStyles = (element, run2,
|
|
72519
|
+
const applyRunStyles = (element, run2, _isLink = false) => {
|
|
72127
72520
|
if (run2.kind === "tab" || run2.kind === "image" || run2.kind === "lineBreak" || run2.kind === "break") {
|
|
72128
72521
|
return;
|
|
72129
72522
|
}
|
|
@@ -72131,9 +72524,7 @@ const applyRunStyles = (element, run2, isLink = false) => {
|
|
|
72131
72524
|
element.style.fontSize = `${run2.fontSize}px`;
|
|
72132
72525
|
if (run2.bold) element.style.fontWeight = "bold";
|
|
72133
72526
|
if (run2.italic) element.style.fontStyle = "italic";
|
|
72134
|
-
if (
|
|
72135
|
-
if (run2.color) element.style.color = run2.color;
|
|
72136
|
-
}
|
|
72527
|
+
if (run2.color) element.style.color = run2.color;
|
|
72137
72528
|
if (run2.letterSpacing != null) {
|
|
72138
72529
|
element.style.letterSpacing = `${run2.letterSpacing}px`;
|
|
72139
72530
|
}
|
|
@@ -72681,28 +73072,44 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
72681
73072
|
}
|
|
72682
73073
|
return true;
|
|
72683
73074
|
};
|
|
72684
|
-
const
|
|
72685
|
-
if (!pendingTabAlignment || !currentLine) return;
|
|
73075
|
+
const alignPendingTabForWidth = (segmentWidth, beforeDecimalWidth) => {
|
|
73076
|
+
if (!pendingTabAlignment || !currentLine) return void 0;
|
|
73077
|
+
if (segmentWidth < 0) {
|
|
73078
|
+
segmentWidth = 0;
|
|
73079
|
+
}
|
|
72686
73080
|
const { target, val } = pendingTabAlignment;
|
|
72687
73081
|
let startX = currentLine.width;
|
|
73082
|
+
if (val === "decimal") {
|
|
73083
|
+
const beforeWidth = beforeDecimalWidth ?? 0;
|
|
73084
|
+
startX = Math.max(0, target - beforeWidth);
|
|
73085
|
+
} else if (val === "end") {
|
|
73086
|
+
startX = Math.max(0, target - segmentWidth);
|
|
73087
|
+
} else if (val === "center") {
|
|
73088
|
+
startX = Math.max(0, target - segmentWidth / 2);
|
|
73089
|
+
} else {
|
|
73090
|
+
startX = Math.max(0, target);
|
|
73091
|
+
}
|
|
73092
|
+
currentLine.width = roundValue(startX);
|
|
73093
|
+
lastAppliedTabAlign = { target, val };
|
|
73094
|
+
pendingTabAlignment = null;
|
|
73095
|
+
return startX;
|
|
73096
|
+
};
|
|
73097
|
+
const alignSegmentAtTab = (segmentText, font, runContext) => {
|
|
73098
|
+
if (!pendingTabAlignment || !currentLine) return void 0;
|
|
73099
|
+
const { val } = pendingTabAlignment;
|
|
73100
|
+
let segmentWidth = 0;
|
|
73101
|
+
let beforeDecimalWidth;
|
|
72688
73102
|
if (val === "decimal") {
|
|
72689
73103
|
const idx = segmentText.indexOf(decimalSeparator);
|
|
72690
73104
|
if (idx >= 0) {
|
|
72691
73105
|
const beforeText = segmentText.slice(0, idx);
|
|
72692
|
-
|
|
72693
|
-
startX = Math.max(0, target - beforeWidth);
|
|
72694
|
-
} else {
|
|
72695
|
-
startX = Math.max(0, target);
|
|
73106
|
+
beforeDecimalWidth = beforeText.length > 0 ? measureRunWidth(beforeText, font, ctx2, runContext) : 0;
|
|
72696
73107
|
}
|
|
73108
|
+
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext) : 0;
|
|
72697
73109
|
} else if (val === "end" || val === "center") {
|
|
72698
|
-
|
|
72699
|
-
startX = val === "end" ? Math.max(0, target - segWidth) : Math.max(0, target - segWidth / 2);
|
|
72700
|
-
} else if (val === "start" || val === "bar") {
|
|
72701
|
-
startX = Math.max(0, target);
|
|
73110
|
+
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext) : 0;
|
|
72702
73111
|
}
|
|
72703
|
-
|
|
72704
|
-
lastAppliedTabAlign = { target, val };
|
|
72705
|
-
pendingTabAlignment = null;
|
|
73112
|
+
return alignPendingTabForWidth(segmentWidth, beforeDecimalWidth);
|
|
72706
73113
|
};
|
|
72707
73114
|
const runsToProcess = [];
|
|
72708
73115
|
for (const run2 of block.runs) {
|
|
@@ -72851,6 +73258,10 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
72851
73258
|
const topSpace = run2.distTop ?? 0;
|
|
72852
73259
|
const bottomSpace = run2.distBottom ?? 0;
|
|
72853
73260
|
const imageHeight = run2.height + topSpace + bottomSpace;
|
|
73261
|
+
let imageStartX;
|
|
73262
|
+
if (pendingTabAlignment && currentLine) {
|
|
73263
|
+
imageStartX = alignPendingTabForWidth(imageWidth);
|
|
73264
|
+
}
|
|
72854
73265
|
if (!currentLine) {
|
|
72855
73266
|
currentLine = {
|
|
72856
73267
|
fromRun: runIndex,
|
|
@@ -72867,12 +73278,14 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
72867
73278
|
runIndex,
|
|
72868
73279
|
fromChar: 0,
|
|
72869
73280
|
toChar: 1,
|
|
72870
|
-
width: imageWidth
|
|
73281
|
+
width: imageWidth,
|
|
73282
|
+
...imageStartX !== void 0 ? { x: imageStartX } : {}
|
|
72871
73283
|
}
|
|
72872
73284
|
]
|
|
72873
73285
|
};
|
|
72874
73286
|
continue;
|
|
72875
73287
|
}
|
|
73288
|
+
const appliedTabAlign = lastAppliedTabAlign;
|
|
72876
73289
|
if (currentLine.width + imageWidth > currentLine.maxWidth && currentLine.width > 0) {
|
|
72877
73290
|
const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing);
|
|
72878
73291
|
const completedLine = {
|
|
@@ -72883,6 +73296,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
72883
73296
|
lines.push(completedLine);
|
|
72884
73297
|
tabStopCursor = 0;
|
|
72885
73298
|
pendingTabAlignment = null;
|
|
73299
|
+
lastAppliedTabAlign = null;
|
|
72886
73300
|
currentLine = {
|
|
72887
73301
|
fromRun: runIndex,
|
|
72888
73302
|
fromChar: 0,
|
|
@@ -72910,9 +73324,15 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
72910
73324
|
runIndex,
|
|
72911
73325
|
fromChar: 0,
|
|
72912
73326
|
toChar: 1,
|
|
72913
|
-
width: imageWidth
|
|
73327
|
+
width: imageWidth,
|
|
73328
|
+
...imageStartX !== void 0 ? { x: imageStartX } : {}
|
|
72914
73329
|
});
|
|
72915
73330
|
}
|
|
73331
|
+
const tabAlign = appliedTabAlign;
|
|
73332
|
+
if (tabAlign && currentLine && tabAlign.val === "end") {
|
|
73333
|
+
currentLine.width = roundValue(tabAlign.target);
|
|
73334
|
+
}
|
|
73335
|
+
lastAppliedTabAlign = null;
|
|
72916
73336
|
continue;
|
|
72917
73337
|
}
|
|
72918
73338
|
if (!("text" in run2) || !("fontSize" in run2)) {
|
|
@@ -72928,8 +73348,10 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
72928
73348
|
const words = segment.split(" ");
|
|
72929
73349
|
let segmentStartX;
|
|
72930
73350
|
if (currentLine && pendingTabAlignment) {
|
|
72931
|
-
alignSegmentAtTab(segment, font, run2);
|
|
72932
|
-
segmentStartX
|
|
73351
|
+
segmentStartX = alignSegmentAtTab(segment, font, run2);
|
|
73352
|
+
if (segmentStartX == null) {
|
|
73353
|
+
segmentStartX = currentLine.width;
|
|
73354
|
+
}
|
|
72933
73355
|
}
|
|
72934
73356
|
for (let wordIndex = 0; wordIndex < words.length; wordIndex++) {
|
|
72935
73357
|
const word = words[wordIndex];
|
|
@@ -73570,12 +73992,49 @@ const createHeaderFooterEditor = ({
|
|
|
73570
73992
|
editor,
|
|
73571
73993
|
data,
|
|
73572
73994
|
editorContainer,
|
|
73573
|
-
|
|
73995
|
+
editorHost,
|
|
73574
73996
|
sectionId,
|
|
73575
73997
|
type: type2,
|
|
73998
|
+
availableWidth,
|
|
73576
73999
|
availableHeight,
|
|
73577
|
-
currentPageNumber
|
|
74000
|
+
currentPageNumber,
|
|
74001
|
+
totalPageCount
|
|
73578
74002
|
}) => {
|
|
74003
|
+
if (!editor) {
|
|
74004
|
+
throw new TypeError("editor parameter is required");
|
|
74005
|
+
}
|
|
74006
|
+
if (!data) {
|
|
74007
|
+
throw new TypeError("data parameter is required");
|
|
74008
|
+
}
|
|
74009
|
+
if (!editorContainer) {
|
|
74010
|
+
throw new TypeError("editorContainer parameter is required");
|
|
74011
|
+
}
|
|
74012
|
+
if (!(editorContainer instanceof HTMLElement)) {
|
|
74013
|
+
throw new TypeError("editorContainer must be an HTMLElement");
|
|
74014
|
+
}
|
|
74015
|
+
if (editorHost !== void 0 && !(editorHost instanceof HTMLElement)) {
|
|
74016
|
+
throw new TypeError("editorHost must be an HTMLElement or undefined");
|
|
74017
|
+
}
|
|
74018
|
+
if (availableWidth !== void 0) {
|
|
74019
|
+
if (typeof availableWidth !== "number" || !Number.isFinite(availableWidth) || availableWidth <= 0) {
|
|
74020
|
+
throw new RangeError("availableWidth must be a positive number");
|
|
74021
|
+
}
|
|
74022
|
+
}
|
|
74023
|
+
if (availableHeight !== void 0) {
|
|
74024
|
+
if (typeof availableHeight !== "number" || !Number.isFinite(availableHeight) || availableHeight <= 0) {
|
|
74025
|
+
throw new RangeError("availableHeight must be a positive number");
|
|
74026
|
+
}
|
|
74027
|
+
}
|
|
74028
|
+
if (currentPageNumber !== void 0) {
|
|
74029
|
+
if (typeof currentPageNumber !== "number" || !Number.isInteger(currentPageNumber) || currentPageNumber < 1) {
|
|
74030
|
+
throw new RangeError("currentPageNumber must be a positive integer");
|
|
74031
|
+
}
|
|
74032
|
+
}
|
|
74033
|
+
if (totalPageCount !== void 0) {
|
|
74034
|
+
if (typeof totalPageCount !== "number" || !Number.isInteger(totalPageCount) || totalPageCount < 1) {
|
|
74035
|
+
throw new RangeError("totalPageCount must be a positive integer");
|
|
74036
|
+
}
|
|
74037
|
+
}
|
|
73579
74038
|
const parentStyles = editor.converter.getDocumentDefaultStyles();
|
|
73580
74039
|
const { fontSizePt, typeface, fontFamilyCss } = parentStyles;
|
|
73581
74040
|
const fontSizeInPixles = fontSizePt * 1.3333;
|
|
@@ -73589,21 +74048,24 @@ const createHeaderFooterEditor = ({
|
|
|
73589
74048
|
position: "absolute",
|
|
73590
74049
|
top: "0",
|
|
73591
74050
|
left: "0",
|
|
73592
|
-
width: "
|
|
74051
|
+
width: availableWidth ? `${availableWidth}px` : "100%",
|
|
74052
|
+
height: availableHeight ? `${availableHeight}px` : "auto",
|
|
73593
74053
|
maxWidth: "none",
|
|
73594
74054
|
fontFamily: fontFamilyCss || typeface,
|
|
73595
74055
|
fontSize: `${fontSizeInPixles}px`,
|
|
73596
|
-
lineHeight: `${lineHeight2}px
|
|
73597
|
-
|
|
73598
|
-
|
|
73599
|
-
|
|
73600
|
-
|
|
73601
|
-
|
|
73602
|
-
|
|
73603
|
-
|
|
73604
|
-
|
|
73605
|
-
}
|
|
73606
|
-
|
|
74056
|
+
lineHeight: `${lineHeight2}px`,
|
|
74057
|
+
overflow: "hidden",
|
|
74058
|
+
pointerEvents: "auto",
|
|
74059
|
+
// Critical: enables click interaction
|
|
74060
|
+
backgroundColor: "white"
|
|
74061
|
+
// Ensure editor has white background
|
|
74062
|
+
});
|
|
74063
|
+
if (editorHost) {
|
|
74064
|
+
editorHost.appendChild(editorContainer);
|
|
74065
|
+
} else {
|
|
74066
|
+
console.warn("[createHeaderFooterEditor] No editorHost provided, falling back to document.body");
|
|
74067
|
+
document.body.appendChild(editorContainer);
|
|
74068
|
+
}
|
|
73607
74069
|
const headerFooterEditor = new Editor({
|
|
73608
74070
|
role: editor.options.role,
|
|
73609
74071
|
loadFromSchema: true,
|
|
@@ -73621,9 +74083,12 @@ const createHeaderFooterEditor = ({
|
|
|
73621
74083
|
pagination: false,
|
|
73622
74084
|
// Explicitly disable pagination
|
|
73623
74085
|
annotations: true,
|
|
73624
|
-
currentPageNumber,
|
|
74086
|
+
currentPageNumber: currentPageNumber ?? 1,
|
|
74087
|
+
totalPageCount: totalPageCount ?? 1,
|
|
73625
74088
|
// Don't set parentEditor to avoid circular reference issues
|
|
73626
74089
|
// parentEditor: editor,
|
|
74090
|
+
// IMPORTANT: Start with editable: false to prevent triggering update cascades during creation.
|
|
74091
|
+
// PresentationEditor#enterHeaderFooterMode will call setEditable(true) when entering edit mode.
|
|
73627
74092
|
editable: false,
|
|
73628
74093
|
documentMode: "viewing",
|
|
73629
74094
|
onCreate: (evt) => setEditorToolbar(evt, editor),
|
|
@@ -73653,18 +74118,23 @@ const createHeaderFooterEditor = ({
|
|
|
73653
74118
|
const onHeaderFooterDataUpdate = async ({ editor, transaction }, mainEditor, sectionId, type2) => {
|
|
73654
74119
|
if (!type2 || !sectionId) return;
|
|
73655
74120
|
const updatedData = editor.getUpdatedJson();
|
|
73656
|
-
mainEditor.converter[`${type2}Editors`]
|
|
73657
|
-
|
|
74121
|
+
const editorsList = mainEditor.converter[`${type2}Editors`];
|
|
74122
|
+
if (Array.isArray(editorsList)) {
|
|
74123
|
+
editorsList.forEach((item) => {
|
|
74124
|
+
if (item.id === sectionId) {
|
|
74125
|
+
item.editor.setOptions({
|
|
74126
|
+
media: editor.options.media,
|
|
74127
|
+
mediaFiles: editor.options.mediaFiles
|
|
74128
|
+
});
|
|
74129
|
+
if (item.editor !== editor) {
|
|
74130
|
+
item.editor.replaceContent(updatedData);
|
|
74131
|
+
}
|
|
74132
|
+
}
|
|
73658
74133
|
item.editor.setOptions({
|
|
73659
|
-
|
|
73660
|
-
mediaFiles: editor.options.mediaFiles
|
|
74134
|
+
lastSelection: transaction?.selection
|
|
73661
74135
|
});
|
|
73662
|
-
item.editor.replaceContent(updatedData);
|
|
73663
|
-
}
|
|
73664
|
-
item.editor.setOptions({
|
|
73665
|
-
lastSelection: transaction?.selection
|
|
73666
74136
|
});
|
|
73667
|
-
}
|
|
74137
|
+
}
|
|
73668
74138
|
mainEditor.converter[`${type2}s`][sectionId] = updatedData;
|
|
73669
74139
|
mainEditor.setOptions({ isHeaderFooterChanged: editor.docChanged });
|
|
73670
74140
|
await updateYdocDocxData(mainEditor);
|
|
@@ -73745,13 +74215,69 @@ class HeaderFooterEditorManager extends EventEmitter$1 {
|
|
|
73745
74215
|
* Handles concurrent calls for the same descriptor by tracking pending creations
|
|
73746
74216
|
* and returning the same promise to all callers.
|
|
73747
74217
|
*
|
|
73748
|
-
* @param descriptor - The header or footer descriptor
|
|
74218
|
+
* @param descriptor - The header or footer descriptor. Must have a valid id property.
|
|
74219
|
+
* @param options - Optional configuration for editor creation
|
|
74220
|
+
* @param options.editorHost - The HTMLElement to mount the editor in. If provided, must be a valid HTMLElement.
|
|
74221
|
+
* @param options.availableWidth - The width of the editing region in pixels. Must be a positive number if provided.
|
|
74222
|
+
* @param options.availableHeight - The height of the editing region in pixels. Must be a positive number if provided.
|
|
74223
|
+
* @param options.currentPageNumber - The current page number for PAGE field resolution. Must be a positive integer if provided.
|
|
74224
|
+
* @param options.totalPageCount - The total page count for NUMPAGES field resolution. Must be a positive integer if provided.
|
|
73749
74225
|
* @returns The editor instance, or null if creation failed
|
|
73750
74226
|
*
|
|
73751
|
-
* @throws Never throws - errors are logged and emitted as events
|
|
74227
|
+
* @throws Never throws - errors are logged and emitted as events. Invalid parameters return null with error logged.
|
|
73752
74228
|
*/
|
|
73753
|
-
async ensureEditor(descriptor) {
|
|
74229
|
+
async ensureEditor(descriptor, options) {
|
|
73754
74230
|
if (!descriptor?.id) return null;
|
|
74231
|
+
if (options) {
|
|
74232
|
+
if (options.editorHost !== void 0 && !(options.editorHost instanceof HTMLElement)) {
|
|
74233
|
+
console.error("[HeaderFooterEditorManager] editorHost must be an HTMLElement");
|
|
74234
|
+
this.emit("error", {
|
|
74235
|
+
descriptor,
|
|
74236
|
+
error: new TypeError("editorHost must be an HTMLElement")
|
|
74237
|
+
});
|
|
74238
|
+
return null;
|
|
74239
|
+
}
|
|
74240
|
+
if (options.availableWidth !== void 0) {
|
|
74241
|
+
if (typeof options.availableWidth !== "number" || !Number.isFinite(options.availableWidth) || options.availableWidth <= 0) {
|
|
74242
|
+
console.error("[HeaderFooterEditorManager] availableWidth must be a positive number");
|
|
74243
|
+
this.emit("error", {
|
|
74244
|
+
descriptor,
|
|
74245
|
+
error: new TypeError("availableWidth must be a positive number")
|
|
74246
|
+
});
|
|
74247
|
+
return null;
|
|
74248
|
+
}
|
|
74249
|
+
}
|
|
74250
|
+
if (options.availableHeight !== void 0) {
|
|
74251
|
+
if (typeof options.availableHeight !== "number" || !Number.isFinite(options.availableHeight) || options.availableHeight <= 0) {
|
|
74252
|
+
console.error("[HeaderFooterEditorManager] availableHeight must be a positive number");
|
|
74253
|
+
this.emit("error", {
|
|
74254
|
+
descriptor,
|
|
74255
|
+
error: new TypeError("availableHeight must be a positive number")
|
|
74256
|
+
});
|
|
74257
|
+
return null;
|
|
74258
|
+
}
|
|
74259
|
+
}
|
|
74260
|
+
if (options.currentPageNumber !== void 0) {
|
|
74261
|
+
if (typeof options.currentPageNumber !== "number" || !Number.isInteger(options.currentPageNumber) || options.currentPageNumber < 1) {
|
|
74262
|
+
console.error("[HeaderFooterEditorManager] currentPageNumber must be a positive integer");
|
|
74263
|
+
this.emit("error", {
|
|
74264
|
+
descriptor,
|
|
74265
|
+
error: new TypeError("currentPageNumber must be a positive integer")
|
|
74266
|
+
});
|
|
74267
|
+
return null;
|
|
74268
|
+
}
|
|
74269
|
+
}
|
|
74270
|
+
if (options.totalPageCount !== void 0) {
|
|
74271
|
+
if (typeof options.totalPageCount !== "number" || !Number.isInteger(options.totalPageCount) || options.totalPageCount < 1) {
|
|
74272
|
+
console.error("[HeaderFooterEditorManager] totalPageCount must be a positive integer");
|
|
74273
|
+
this.emit("error", {
|
|
74274
|
+
descriptor,
|
|
74275
|
+
error: new TypeError("totalPageCount must be a positive integer")
|
|
74276
|
+
});
|
|
74277
|
+
return null;
|
|
74278
|
+
}
|
|
74279
|
+
}
|
|
74280
|
+
}
|
|
73755
74281
|
const existing = __privateGet$1(this, _editorEntries).get(descriptor.id);
|
|
73756
74282
|
if (existing) {
|
|
73757
74283
|
__privateSet(this, _cacheHits, __privateGet$1(this, _cacheHits) + 1);
|
|
@@ -73760,6 +74286,29 @@ class HeaderFooterEditorManager extends EventEmitter$1 {
|
|
|
73760
74286
|
console.error("[HeaderFooterEditorManager] Editor initialization failed:", error);
|
|
73761
74287
|
this.emit("error", { descriptor, error });
|
|
73762
74288
|
});
|
|
74289
|
+
if (existing.container && options?.editorHost) {
|
|
74290
|
+
if (existing.container.parentElement !== options.editorHost) {
|
|
74291
|
+
options.editorHost.appendChild(existing.container);
|
|
74292
|
+
}
|
|
74293
|
+
}
|
|
74294
|
+
if (existing.editor && options) {
|
|
74295
|
+
const updateOptions = {};
|
|
74296
|
+
if (options.currentPageNumber !== void 0) {
|
|
74297
|
+
updateOptions.currentPageNumber = options.currentPageNumber;
|
|
74298
|
+
}
|
|
74299
|
+
if (options.totalPageCount !== void 0) {
|
|
74300
|
+
updateOptions.totalPageCount = options.totalPageCount;
|
|
74301
|
+
}
|
|
74302
|
+
if (options.availableWidth !== void 0) {
|
|
74303
|
+
updateOptions.availableWidth = options.availableWidth;
|
|
74304
|
+
}
|
|
74305
|
+
if (options.availableHeight !== void 0) {
|
|
74306
|
+
updateOptions.availableHeight = options.availableHeight;
|
|
74307
|
+
}
|
|
74308
|
+
if (Object.keys(updateOptions).length > 0) {
|
|
74309
|
+
existing.editor.setOptions(updateOptions);
|
|
74310
|
+
}
|
|
74311
|
+
}
|
|
73763
74312
|
return existing.editor;
|
|
73764
74313
|
}
|
|
73765
74314
|
const pending = __privateGet$1(this, _pendingCreations).get(descriptor.id);
|
|
@@ -73769,7 +74318,7 @@ class HeaderFooterEditorManager extends EventEmitter$1 {
|
|
|
73769
74318
|
__privateSet(this, _cacheMisses, __privateGet$1(this, _cacheMisses) + 1);
|
|
73770
74319
|
const creationPromise = (async () => {
|
|
73771
74320
|
try {
|
|
73772
|
-
const entry = await __privateMethod$1(this, _HeaderFooterEditorManager_instances, createEditor_fn).call(this, descriptor);
|
|
74321
|
+
const entry = await __privateMethod$1(this, _HeaderFooterEditorManager_instances, createEditor_fn).call(this, descriptor, options);
|
|
73773
74322
|
if (!entry) return null;
|
|
73774
74323
|
__privateGet$1(this, _editorEntries).set(descriptor.id, entry);
|
|
73775
74324
|
__privateMethod$1(this, _HeaderFooterEditorManager_instances, updateAccessOrder_fn).call(this, descriptor.id);
|
|
@@ -74077,7 +74626,7 @@ teardownEditors_fn = function() {
|
|
|
74077
74626
|
});
|
|
74078
74627
|
__privateGet$1(this, _editorEntries).clear();
|
|
74079
74628
|
};
|
|
74080
|
-
createEditor_fn = async function(descriptor) {
|
|
74629
|
+
createEditor_fn = async function(descriptor, options) {
|
|
74081
74630
|
const json = this.getDocumentJson(descriptor);
|
|
74082
74631
|
if (!json) return null;
|
|
74083
74632
|
let editor;
|
|
@@ -74088,12 +74637,13 @@ createEditor_fn = async function(descriptor) {
|
|
|
74088
74637
|
editor: __privateGet$1(this, _editor2),
|
|
74089
74638
|
data: json,
|
|
74090
74639
|
editorContainer: container,
|
|
74091
|
-
|
|
74640
|
+
editorHost: options?.editorHost,
|
|
74092
74641
|
sectionId: descriptor.id,
|
|
74093
74642
|
type: descriptor.kind,
|
|
74094
|
-
|
|
74095
|
-
|
|
74096
|
-
|
|
74643
|
+
availableWidth: options?.availableWidth,
|
|
74644
|
+
availableHeight: options?.availableHeight ?? DEFAULT_HEADER_FOOTER_HEIGHT,
|
|
74645
|
+
currentPageNumber: options?.currentPageNumber ?? 1,
|
|
74646
|
+
totalPageCount: options?.totalPageCount ?? 1
|
|
74097
74647
|
});
|
|
74098
74648
|
} catch (error) {
|
|
74099
74649
|
console.error("[HeaderFooterEditorManager] Editor creation failed:", error);
|
|
@@ -74367,6 +74917,312 @@ getConverterContext_fn = function() {
|
|
|
74367
74917
|
}
|
|
74368
74918
|
return Object.keys(context).length > 0 ? context : void 0;
|
|
74369
74919
|
};
|
|
74920
|
+
const EDITOR_HOST_Z_INDEX = "10";
|
|
74921
|
+
const BORDER_LINE_Z_INDEX = "15";
|
|
74922
|
+
const BORDER_LINE_COLOR = "#4472c4";
|
|
74923
|
+
const BORDER_LINE_HEIGHT = "1px";
|
|
74924
|
+
class EditorOverlayManager {
|
|
74925
|
+
/**
|
|
74926
|
+
* Creates a new EditorOverlayManager instance.
|
|
74927
|
+
*
|
|
74928
|
+
* @param painterHost - The host element containing painted pages. Must be an HTMLElement connected to the DOM.
|
|
74929
|
+
* @param visibleHost - The visible host element for overlay positioning. Must be an HTMLElement connected to the DOM.
|
|
74930
|
+
* @param selectionOverlay - The selection overlay element (optional). If provided, must be an HTMLElement.
|
|
74931
|
+
*
|
|
74932
|
+
* @throws {TypeError} If painterHost is not an HTMLElement
|
|
74933
|
+
* @throws {TypeError} If visibleHost is not an HTMLElement
|
|
74934
|
+
* @throws {TypeError} If selectionOverlay is provided but is not an HTMLElement
|
|
74935
|
+
* @throws {Error} If painterHost is not connected to the DOM
|
|
74936
|
+
* @throws {Error} If visibleHost is not connected to the DOM
|
|
74937
|
+
*/
|
|
74938
|
+
constructor(painterHost, visibleHost, selectionOverlay = null) {
|
|
74939
|
+
__privateAdd$1(this, _EditorOverlayManager_instances);
|
|
74940
|
+
__privateAdd$1(this, _selectionOverlay);
|
|
74941
|
+
__privateAdd$1(this, _activeEditorHost, null);
|
|
74942
|
+
__privateAdd$1(this, _activeDecorationContainer, null);
|
|
74943
|
+
__privateAdd$1(this, _activeRegion, null);
|
|
74944
|
+
__privateAdd$1(this, _borderLine, null);
|
|
74945
|
+
if (!(painterHost instanceof HTMLElement)) {
|
|
74946
|
+
throw new TypeError("painterHost must be an HTMLElement");
|
|
74947
|
+
}
|
|
74948
|
+
if (!(visibleHost instanceof HTMLElement)) {
|
|
74949
|
+
throw new TypeError("visibleHost must be an HTMLElement");
|
|
74950
|
+
}
|
|
74951
|
+
if (selectionOverlay !== null && !(selectionOverlay instanceof HTMLElement)) {
|
|
74952
|
+
throw new TypeError("selectionOverlay must be an HTMLElement or null");
|
|
74953
|
+
}
|
|
74954
|
+
if (!painterHost.isConnected) {
|
|
74955
|
+
throw new Error("painterHost must be connected to the DOM");
|
|
74956
|
+
}
|
|
74957
|
+
if (!visibleHost.isConnected) {
|
|
74958
|
+
throw new Error("visibleHost must be connected to the DOM");
|
|
74959
|
+
}
|
|
74960
|
+
__privateSet(this, _selectionOverlay, selectionOverlay);
|
|
74961
|
+
}
|
|
74962
|
+
/**
|
|
74963
|
+
* Sets the callback to be invoked when the dimming overlay is clicked.
|
|
74964
|
+
* This allows PresentationEditor to exit header/footer mode when the user
|
|
74965
|
+
* clicks outside the editing region.
|
|
74966
|
+
*
|
|
74967
|
+
* @param callback - Function to call when dimming overlay is clicked
|
|
74968
|
+
*/
|
|
74969
|
+
setOnDimmingClick(_callback) {
|
|
74970
|
+
}
|
|
74971
|
+
/**
|
|
74972
|
+
* Gets the currently active editor host element.
|
|
74973
|
+
* This is useful for checking if a click target is inside the active editing area.
|
|
74974
|
+
*
|
|
74975
|
+
* @returns The active editor host element, or null if not in editing mode
|
|
74976
|
+
*/
|
|
74977
|
+
getActiveEditorHost() {
|
|
74978
|
+
return __privateGet$1(this, _activeEditorHost);
|
|
74979
|
+
}
|
|
74980
|
+
/**
|
|
74981
|
+
* Shows the editing overlay for a header/footer region.
|
|
74982
|
+
*
|
|
74983
|
+
* This method:
|
|
74984
|
+
* 1. Creates or retrieves the editor host element as a sibling to the decoration container
|
|
74985
|
+
* 2. Positions the editor host to match the decoration container bounds
|
|
74986
|
+
* 3. Hides the static decoration content
|
|
74987
|
+
* 4. Shows the dimming overlay over body content
|
|
74988
|
+
* 5. Returns the editor host element for mounting the ProseMirror editor
|
|
74989
|
+
*
|
|
74990
|
+
* @param pageElement - The page DOM element containing the region
|
|
74991
|
+
* @param region - The header/footer region to edit
|
|
74992
|
+
* @param zoom - Current zoom level (for positioning calculations)
|
|
74993
|
+
* @returns Result object with success status and editor host element
|
|
74994
|
+
*
|
|
74995
|
+
* @example
|
|
74996
|
+
* ```typescript
|
|
74997
|
+
* const result = overlayManager.showEditingOverlay(pageElement, region, 1.0);
|
|
74998
|
+
* if (result.success && result.editorHost) {
|
|
74999
|
+
* // Mount ProseMirror editor in result.editorHost
|
|
75000
|
+
* }
|
|
75001
|
+
* ```
|
|
75002
|
+
*/
|
|
75003
|
+
showEditingOverlay(pageElement, region, zoom) {
|
|
75004
|
+
try {
|
|
75005
|
+
const decorationContainer = __privateMethod$1(this, _EditorOverlayManager_instances, findDecorationContainer_fn).call(this, pageElement, region.kind);
|
|
75006
|
+
if (!decorationContainer) {
|
|
75007
|
+
return {
|
|
75008
|
+
success: false,
|
|
75009
|
+
reason: `Decoration container not found for ${region.kind} on page ${region.pageIndex}`
|
|
75010
|
+
};
|
|
75011
|
+
}
|
|
75012
|
+
const editorHost = __privateMethod$1(this, _EditorOverlayManager_instances, ensureEditorHost_fn).call(this, pageElement, region.kind);
|
|
75013
|
+
if (!editorHost) {
|
|
75014
|
+
return {
|
|
75015
|
+
success: false,
|
|
75016
|
+
reason: `Failed to create editor host for ${region.kind}`
|
|
75017
|
+
};
|
|
75018
|
+
}
|
|
75019
|
+
__privateMethod$1(this, _EditorOverlayManager_instances, positionEditorHost_fn).call(this, editorHost, region, decorationContainer, zoom);
|
|
75020
|
+
decorationContainer.style.visibility = "hidden";
|
|
75021
|
+
editorHost.style.visibility = "visible";
|
|
75022
|
+
editorHost.style.zIndex = EDITOR_HOST_Z_INDEX;
|
|
75023
|
+
if (region.kind === "footer") {
|
|
75024
|
+
const contentOffset = editorHost.dataset.contentOffset;
|
|
75025
|
+
if (contentOffset) {
|
|
75026
|
+
const editorContainer = editorHost.querySelector(".super-editor");
|
|
75027
|
+
if (editorContainer instanceof HTMLElement) {
|
|
75028
|
+
editorContainer.style.top = `${contentOffset}px`;
|
|
75029
|
+
}
|
|
75030
|
+
}
|
|
75031
|
+
}
|
|
75032
|
+
__privateMethod$1(this, _EditorOverlayManager_instances, showHeaderFooterBorder_fn).call(this, pageElement, region, decorationContainer);
|
|
75033
|
+
__privateSet(this, _activeEditorHost, editorHost);
|
|
75034
|
+
__privateSet(this, _activeDecorationContainer, decorationContainer);
|
|
75035
|
+
__privateSet(this, _activeRegion, region);
|
|
75036
|
+
return {
|
|
75037
|
+
success: true,
|
|
75038
|
+
editorHost
|
|
75039
|
+
};
|
|
75040
|
+
} catch (error) {
|
|
75041
|
+
if (__privateGet$1(this, _activeDecorationContainer)) {
|
|
75042
|
+
__privateGet$1(this, _activeDecorationContainer).style.visibility = "visible";
|
|
75043
|
+
}
|
|
75044
|
+
if (__privateGet$1(this, _activeEditorHost)) {
|
|
75045
|
+
__privateGet$1(this, _activeEditorHost).style.visibility = "hidden";
|
|
75046
|
+
}
|
|
75047
|
+
__privateMethod$1(this, _EditorOverlayManager_instances, hideHeaderFooterBorder_fn).call(this);
|
|
75048
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
75049
|
+
console.error("[EditorOverlayManager] Failed to show editing overlay:", error);
|
|
75050
|
+
return {
|
|
75051
|
+
success: false,
|
|
75052
|
+
reason: `DOM manipulation error: ${errorMessage}`
|
|
75053
|
+
};
|
|
75054
|
+
}
|
|
75055
|
+
}
|
|
75056
|
+
/**
|
|
75057
|
+
* Hides the editing overlay and restores normal view.
|
|
75058
|
+
*
|
|
75059
|
+
* This method:
|
|
75060
|
+
* 1. Shows the static decoration content
|
|
75061
|
+
* 2. Hides the editor host (but doesn't destroy it for reuse)
|
|
75062
|
+
* 3. Removes the dimming overlay
|
|
75063
|
+
*
|
|
75064
|
+
* @example
|
|
75065
|
+
* ```typescript
|
|
75066
|
+
* overlayManager.hideEditingOverlay();
|
|
75067
|
+
* // Static decoration is now visible, editor is hidden
|
|
75068
|
+
* ```
|
|
75069
|
+
*/
|
|
75070
|
+
hideEditingOverlay() {
|
|
75071
|
+
if (__privateGet$1(this, _activeDecorationContainer)) {
|
|
75072
|
+
__privateGet$1(this, _activeDecorationContainer).style.visibility = "visible";
|
|
75073
|
+
}
|
|
75074
|
+
if (__privateGet$1(this, _activeEditorHost)) {
|
|
75075
|
+
__privateGet$1(this, _activeEditorHost).style.visibility = "hidden";
|
|
75076
|
+
__privateGet$1(this, _activeEditorHost).style.zIndex = "";
|
|
75077
|
+
if (__privateGet$1(this, _activeRegion)?.kind === "footer") {
|
|
75078
|
+
const editorContainer = __privateGet$1(this, _activeEditorHost).querySelector(".super-editor");
|
|
75079
|
+
if (editorContainer instanceof HTMLElement) {
|
|
75080
|
+
editorContainer.style.top = "0";
|
|
75081
|
+
}
|
|
75082
|
+
}
|
|
75083
|
+
}
|
|
75084
|
+
__privateMethod$1(this, _EditorOverlayManager_instances, hideHeaderFooterBorder_fn).call(this);
|
|
75085
|
+
__privateSet(this, _activeEditorHost, null);
|
|
75086
|
+
__privateSet(this, _activeDecorationContainer, null);
|
|
75087
|
+
__privateSet(this, _activeRegion, null);
|
|
75088
|
+
}
|
|
75089
|
+
/**
|
|
75090
|
+
* Hides the layout selection overlay to prevent double caret rendering.
|
|
75091
|
+
*
|
|
75092
|
+
* Called when entering header/footer editing mode to ensure only the
|
|
75093
|
+
* ProseMirror editor's caret is visible, not both the PM caret and the
|
|
75094
|
+
* layout engine's selection overlay.
|
|
75095
|
+
*
|
|
75096
|
+
* @example
|
|
75097
|
+
* ```typescript
|
|
75098
|
+
* overlayManager.hideSelectionOverlay();
|
|
75099
|
+
* // Selection overlay is now hidden
|
|
75100
|
+
* ```
|
|
75101
|
+
*/
|
|
75102
|
+
hideSelectionOverlay() {
|
|
75103
|
+
if (__privateGet$1(this, _selectionOverlay)) {
|
|
75104
|
+
__privateGet$1(this, _selectionOverlay).style.visibility = "hidden";
|
|
75105
|
+
}
|
|
75106
|
+
}
|
|
75107
|
+
/**
|
|
75108
|
+
* Shows the layout selection overlay.
|
|
75109
|
+
*
|
|
75110
|
+
* Called when exiting header/footer editing mode to restore the
|
|
75111
|
+
* normal selection overlay rendering for body content.
|
|
75112
|
+
*
|
|
75113
|
+
* @example
|
|
75114
|
+
* ```typescript
|
|
75115
|
+
* overlayManager.showSelectionOverlay();
|
|
75116
|
+
* // Selection overlay is now visible
|
|
75117
|
+
* ```
|
|
75118
|
+
*/
|
|
75119
|
+
showSelectionOverlay() {
|
|
75120
|
+
if (__privateGet$1(this, _selectionOverlay)) {
|
|
75121
|
+
__privateGet$1(this, _selectionOverlay).style.visibility = "visible";
|
|
75122
|
+
}
|
|
75123
|
+
}
|
|
75124
|
+
/**
|
|
75125
|
+
* Destroys the overlay manager and cleans up all resources.
|
|
75126
|
+
*
|
|
75127
|
+
* Clears all references.
|
|
75128
|
+
* Editor host elements are left in the DOM as they're children of page elements
|
|
75129
|
+
* that will be cleaned up by the virtualization system.
|
|
75130
|
+
*/
|
|
75131
|
+
destroy() {
|
|
75132
|
+
__privateMethod$1(this, _EditorOverlayManager_instances, hideHeaderFooterBorder_fn).call(this);
|
|
75133
|
+
__privateSet(this, _activeEditorHost, null);
|
|
75134
|
+
__privateSet(this, _activeDecorationContainer, null);
|
|
75135
|
+
__privateSet(this, _activeRegion, null);
|
|
75136
|
+
__privateSet(this, _selectionOverlay, null);
|
|
75137
|
+
}
|
|
75138
|
+
}
|
|
75139
|
+
_selectionOverlay = /* @__PURE__ */ new WeakMap();
|
|
75140
|
+
_activeEditorHost = /* @__PURE__ */ new WeakMap();
|
|
75141
|
+
_activeDecorationContainer = /* @__PURE__ */ new WeakMap();
|
|
75142
|
+
_activeRegion = /* @__PURE__ */ new WeakMap();
|
|
75143
|
+
_borderLine = /* @__PURE__ */ new WeakMap();
|
|
75144
|
+
_EditorOverlayManager_instances = /* @__PURE__ */ new WeakSet();
|
|
75145
|
+
findDecorationContainer_fn = function(pageElement, kind) {
|
|
75146
|
+
const className = kind === "header" ? "superdoc-page-header" : "superdoc-page-footer";
|
|
75147
|
+
return pageElement.querySelector(`.${className}`);
|
|
75148
|
+
};
|
|
75149
|
+
ensureEditorHost_fn = function(pageElement, kind) {
|
|
75150
|
+
const className = kind === "header" ? "superdoc-header-editor-host" : "superdoc-footer-editor-host";
|
|
75151
|
+
let editorHost = pageElement.querySelector(`.${className}`);
|
|
75152
|
+
if (!editorHost) {
|
|
75153
|
+
editorHost = document.createElement("div");
|
|
75154
|
+
editorHost.className = className;
|
|
75155
|
+
Object.assign(editorHost.style, {
|
|
75156
|
+
position: "absolute",
|
|
75157
|
+
pointerEvents: "auto",
|
|
75158
|
+
// Critical: enables click interaction
|
|
75159
|
+
visibility: "hidden",
|
|
75160
|
+
// Hidden by default, shown during editing
|
|
75161
|
+
overflow: "hidden",
|
|
75162
|
+
boxSizing: "border-box"
|
|
75163
|
+
});
|
|
75164
|
+
const decorationContainer = __privateMethod$1(this, _EditorOverlayManager_instances, findDecorationContainer_fn).call(this, pageElement, kind);
|
|
75165
|
+
if (!decorationContainer) {
|
|
75166
|
+
console.error(`[EditorOverlayManager] Decoration container not found for ${kind}`);
|
|
75167
|
+
return null;
|
|
75168
|
+
}
|
|
75169
|
+
decorationContainer.parentNode?.insertBefore(editorHost, decorationContainer.nextSibling);
|
|
75170
|
+
}
|
|
75171
|
+
return editorHost;
|
|
75172
|
+
};
|
|
75173
|
+
positionEditorHost_fn = function(editorHost, region, decorationContainer, _zoom) {
|
|
75174
|
+
const decorationRect = decorationContainer.getBoundingClientRect();
|
|
75175
|
+
const pageElement = editorHost.parentElement;
|
|
75176
|
+
if (!pageElement) {
|
|
75177
|
+
console.error("[EditorOverlayManager] Editor host has no parent element");
|
|
75178
|
+
return;
|
|
75179
|
+
}
|
|
75180
|
+
const pageRect = pageElement.getBoundingClientRect();
|
|
75181
|
+
const top2 = decorationRect.top - pageRect.top;
|
|
75182
|
+
const left2 = decorationRect.left - pageRect.left;
|
|
75183
|
+
const width = decorationRect.width;
|
|
75184
|
+
const height = decorationRect.height;
|
|
75185
|
+
Object.assign(editorHost.style, {
|
|
75186
|
+
top: `${top2}px`,
|
|
75187
|
+
left: `${left2}px`,
|
|
75188
|
+
width: `${width}px`,
|
|
75189
|
+
height: `${height}px`
|
|
75190
|
+
});
|
|
75191
|
+
if (region.kind === "footer") {
|
|
75192
|
+
const fragment = decorationContainer.querySelector(".superdoc-fragment");
|
|
75193
|
+
if (fragment instanceof HTMLElement) {
|
|
75194
|
+
const fragmentTop = parseFloat(fragment.style.top) || 0;
|
|
75195
|
+
editorHost.dataset.contentOffset = String(fragmentTop);
|
|
75196
|
+
}
|
|
75197
|
+
}
|
|
75198
|
+
};
|
|
75199
|
+
showHeaderFooterBorder_fn = function(pageElement, region, decorationContainer) {
|
|
75200
|
+
__privateMethod$1(this, _EditorOverlayManager_instances, hideHeaderFooterBorder_fn).call(this);
|
|
75201
|
+
__privateSet(this, _borderLine, document.createElement("div"));
|
|
75202
|
+
__privateGet$1(this, _borderLine).className = "superdoc-header-footer-border";
|
|
75203
|
+
const decorationRect = decorationContainer.getBoundingClientRect();
|
|
75204
|
+
const pageRect = pageElement.getBoundingClientRect();
|
|
75205
|
+
const isHeader = region.kind === "header";
|
|
75206
|
+
const topPosition = isHeader ? decorationRect.bottom - pageRect.top : decorationRect.top - pageRect.top;
|
|
75207
|
+
Object.assign(__privateGet$1(this, _borderLine).style, {
|
|
75208
|
+
position: "absolute",
|
|
75209
|
+
left: "0",
|
|
75210
|
+
right: "0",
|
|
75211
|
+
top: `${topPosition}px`,
|
|
75212
|
+
height: BORDER_LINE_HEIGHT,
|
|
75213
|
+
backgroundColor: BORDER_LINE_COLOR,
|
|
75214
|
+
// MS Word blue
|
|
75215
|
+
zIndex: BORDER_LINE_Z_INDEX,
|
|
75216
|
+
pointerEvents: "none"
|
|
75217
|
+
});
|
|
75218
|
+
pageElement.appendChild(__privateGet$1(this, _borderLine));
|
|
75219
|
+
};
|
|
75220
|
+
hideHeaderFooterBorder_fn = function() {
|
|
75221
|
+
if (__privateGet$1(this, _borderLine)) {
|
|
75222
|
+
__privateGet$1(this, _borderLine).remove();
|
|
75223
|
+
__privateSet(this, _borderLine, null);
|
|
75224
|
+
}
|
|
75225
|
+
};
|
|
74370
75226
|
const uiSurfaces = /* @__PURE__ */ new WeakSet();
|
|
74371
75227
|
function isInRegisteredSurface(event) {
|
|
74372
75228
|
const path = typeof event.composedPath === "function" ? event.composedPath() : [];
|
|
@@ -74405,7 +75261,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
74405
75261
|
__privateAdd$1(this, _visibleHost);
|
|
74406
75262
|
__privateAdd$1(this, _viewportHost);
|
|
74407
75263
|
__privateAdd$1(this, _painterHost);
|
|
74408
|
-
__privateAdd$1(this,
|
|
75264
|
+
__privateAdd$1(this, _selectionOverlay2);
|
|
74409
75265
|
__privateAdd$1(this, _hiddenHost);
|
|
74410
75266
|
__privateAdd$1(this, _layoutOptions);
|
|
74411
75267
|
__privateAdd$1(this, _layoutState, { blocks: [], measures: [], layout: null });
|
|
@@ -74440,6 +75296,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
74440
75296
|
__privateAdd$1(this, _footerRegions, /* @__PURE__ */ new Map());
|
|
74441
75297
|
__privateAdd$1(this, _session, { mode: "body" });
|
|
74442
75298
|
__privateAdd$1(this, _activeHeaderFooterEditor, null);
|
|
75299
|
+
__privateAdd$1(this, _overlayManager, null);
|
|
74443
75300
|
__privateAdd$1(this, _hoverOverlay, null);
|
|
74444
75301
|
__privateAdd$1(this, _hoverTooltip, null);
|
|
74445
75302
|
__privateAdd$1(this, _modeBanner, null);
|
|
@@ -74494,6 +75351,11 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
74494
75351
|
const x2 = (event.clientX - rect.left + scrollLeft) / zoom;
|
|
74495
75352
|
const y2 = (event.clientY - rect.top + scrollTop) / zoom;
|
|
74496
75353
|
if (__privateGet$1(this, _session).mode !== "body") {
|
|
75354
|
+
const activeEditorHost = __privateGet$1(this, _overlayManager)?.getActiveEditorHost?.();
|
|
75355
|
+
const clickedInsideEditorHost = activeEditorHost && (activeEditorHost.contains(event.target) || activeEditorHost === event.target);
|
|
75356
|
+
if (clickedInsideEditorHost) {
|
|
75357
|
+
return;
|
|
75358
|
+
}
|
|
74497
75359
|
const headerFooterRegion2 = __privateMethod$1(this, _PresentationEditor_instances, hitTestHeaderFooterRegion_fn).call(this, x2, y2);
|
|
74498
75360
|
if (!headerFooterRegion2) {
|
|
74499
75361
|
__privateMethod$1(this, _PresentationEditor_instances, exitHeaderFooterMode_fn).call(this);
|
|
@@ -74648,6 +75510,11 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
74648
75510
|
if (region) {
|
|
74649
75511
|
event.preventDefault();
|
|
74650
75512
|
event.stopPropagation();
|
|
75513
|
+
const descriptor = __privateMethod$1(this, _PresentationEditor_instances, resolveDescriptorForRegion_fn).call(this, region);
|
|
75514
|
+
if (!descriptor && __privateGet$1(this, _headerFooterManager)) {
|
|
75515
|
+
__privateMethod$1(this, _PresentationEditor_instances, createDefaultHeaderFooter_fn).call(this, region);
|
|
75516
|
+
__privateGet$1(this, _headerFooterManager).refresh();
|
|
75517
|
+
}
|
|
74651
75518
|
__privateMethod$1(this, _PresentationEditor_instances, activateHeaderFooterRegion_fn).call(this, region);
|
|
74652
75519
|
} else if (__privateGet$1(this, _session).mode !== "body") {
|
|
74653
75520
|
__privateMethod$1(this, _PresentationEditor_instances, exitHeaderFooterMode_fn).call(this);
|
|
@@ -74716,13 +75583,13 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
74716
75583
|
__privateGet$1(this, _painterHost).className = "presentation-editor__pages";
|
|
74717
75584
|
__privateGet$1(this, _painterHost).style.transformOrigin = "top left";
|
|
74718
75585
|
__privateGet$1(this, _viewportHost).appendChild(__privateGet$1(this, _painterHost));
|
|
74719
|
-
__privateSet(this,
|
|
74720
|
-
__privateGet$1(this,
|
|
74721
|
-
__privateGet$1(this,
|
|
74722
|
-
__privateGet$1(this,
|
|
74723
|
-
__privateGet$1(this,
|
|
74724
|
-
__privateGet$1(this,
|
|
74725
|
-
__privateGet$1(this,
|
|
75586
|
+
__privateSet(this, _selectionOverlay2, doc2.createElement("div"));
|
|
75587
|
+
__privateGet$1(this, _selectionOverlay2).className = "presentation-editor__selection-overlay";
|
|
75588
|
+
__privateGet$1(this, _selectionOverlay2).id = `presentation-overlay-${options.documentId || "default"}`;
|
|
75589
|
+
__privateGet$1(this, _selectionOverlay2).style.position = "absolute";
|
|
75590
|
+
__privateGet$1(this, _selectionOverlay2).style.inset = "0";
|
|
75591
|
+
__privateGet$1(this, _selectionOverlay2).style.pointerEvents = "none";
|
|
75592
|
+
__privateGet$1(this, _selectionOverlay2).style.zIndex = "10";
|
|
74726
75593
|
__privateSet(this, _remoteCursorOverlay, doc2.createElement("div"));
|
|
74727
75594
|
__privateGet$1(this, _remoteCursorOverlay).className = "presentation-editor__selection-layer--remote";
|
|
74728
75595
|
__privateGet$1(this, _remoteCursorOverlay).style.position = "absolute";
|
|
@@ -74733,9 +75600,9 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
74733
75600
|
__privateGet$1(this, _localSelectionLayer).style.position = "absolute";
|
|
74734
75601
|
__privateGet$1(this, _localSelectionLayer).style.inset = "0";
|
|
74735
75602
|
__privateGet$1(this, _localSelectionLayer).style.pointerEvents = "none";
|
|
74736
|
-
__privateGet$1(this,
|
|
74737
|
-
__privateGet$1(this,
|
|
74738
|
-
__privateGet$1(this, _viewportHost).appendChild(__privateGet$1(this,
|
|
75603
|
+
__privateGet$1(this, _selectionOverlay2).appendChild(__privateGet$1(this, _remoteCursorOverlay));
|
|
75604
|
+
__privateGet$1(this, _selectionOverlay2).appendChild(__privateGet$1(this, _localSelectionLayer));
|
|
75605
|
+
__privateGet$1(this, _viewportHost).appendChild(__privateGet$1(this, _selectionOverlay2));
|
|
74739
75606
|
__privateSet(this, _hoverOverlay, doc2.createElement("div"));
|
|
74740
75607
|
__privateGet$1(this, _hoverOverlay).className = "presentation-editor__hover-overlay";
|
|
74741
75608
|
Object.assign(__privateGet$1(this, _hoverOverlay).style, {
|
|
@@ -74746,7 +75613,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
74746
75613
|
display: "none",
|
|
74747
75614
|
zIndex: "11"
|
|
74748
75615
|
});
|
|
74749
|
-
__privateGet$1(this,
|
|
75616
|
+
__privateGet$1(this, _selectionOverlay2).appendChild(__privateGet$1(this, _hoverOverlay));
|
|
74750
75617
|
__privateSet(this, _hoverTooltip, doc2.createElement("div"));
|
|
74751
75618
|
__privateGet$1(this, _hoverTooltip).className = "presentation-editor__hover-tooltip";
|
|
74752
75619
|
Object.assign(__privateGet$1(this, _hoverTooltip).style, {
|
|
@@ -74761,7 +75628,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
74761
75628
|
zIndex: "12",
|
|
74762
75629
|
whiteSpace: "nowrap"
|
|
74763
75630
|
});
|
|
74764
|
-
__privateGet$1(this,
|
|
75631
|
+
__privateGet$1(this, _selectionOverlay2).appendChild(__privateGet$1(this, _hoverTooltip));
|
|
74765
75632
|
__privateSet(this, _modeBanner, doc2.createElement("div"));
|
|
74766
75633
|
__privateGet$1(this, _modeBanner).className = "presentation-editor__mode-banner";
|
|
74767
75634
|
Object.assign(__privateGet$1(this, _modeBanner).style, {
|
|
@@ -74979,7 +75846,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
74979
75846
|
* ```
|
|
74980
75847
|
*/
|
|
74981
75848
|
get overlayElement() {
|
|
74982
|
-
return __privateGet$1(this,
|
|
75849
|
+
return __privateGet$1(this, _selectionOverlay2) ?? null;
|
|
74983
75850
|
}
|
|
74984
75851
|
/**
|
|
74985
75852
|
* Set the document mode and update editor editability.
|
|
@@ -75149,12 +76016,12 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
75149
76016
|
* @returns Array of rects, each containing pageIndex and position data (left, top, right, bottom, width, height)
|
|
75150
76017
|
*/
|
|
75151
76018
|
getRangeRects(from2, to, relativeTo) {
|
|
75152
|
-
if (!__privateGet$1(this,
|
|
76019
|
+
if (!__privateGet$1(this, _selectionOverlay2)) return [];
|
|
75153
76020
|
if (!Number.isFinite(from2) || !Number.isFinite(to)) return [];
|
|
75154
76021
|
const start2 = Math.min(from2, to);
|
|
75155
76022
|
const end2 = Math.max(from2, to);
|
|
75156
76023
|
const zoom = __privateGet$1(this, _layoutOptions).zoom ?? 1;
|
|
75157
|
-
const overlayRect = __privateGet$1(this,
|
|
76024
|
+
const overlayRect = __privateGet$1(this, _selectionOverlay2).getBoundingClientRect();
|
|
75158
76025
|
const relativeRect = relativeTo?.getBoundingClientRect() ?? null;
|
|
75159
76026
|
const layoutRectSource = () => {
|
|
75160
76027
|
if (__privateGet$1(this, _session).mode !== "body") {
|
|
@@ -75415,7 +76282,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
75415
76282
|
return null;
|
|
75416
76283
|
}
|
|
75417
76284
|
const rect2 = rects2[0];
|
|
75418
|
-
const overlayRect = __privateGet$1(this,
|
|
76285
|
+
const overlayRect = __privateGet$1(this, _selectionOverlay2)?.getBoundingClientRect();
|
|
75419
76286
|
if (!overlayRect) {
|
|
75420
76287
|
return null;
|
|
75421
76288
|
}
|
|
@@ -75585,7 +76452,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
75585
76452
|
__privateSet(this, _session, { mode: "body" });
|
|
75586
76453
|
__privateSet(this, _activeHeaderFooterEditor, null);
|
|
75587
76454
|
__privateSet(this, _domPainter, null);
|
|
75588
|
-
__privateGet$1(this,
|
|
76455
|
+
__privateGet$1(this, _selectionOverlay2)?.remove();
|
|
75589
76456
|
__privateGet$1(this, _painterHost)?.remove();
|
|
75590
76457
|
__privateGet$1(this, _hiddenHost)?.remove();
|
|
75591
76458
|
__privateSet(this, _hoverOverlay, null);
|
|
@@ -75607,7 +76474,7 @@ _editor3 = /* @__PURE__ */ new WeakMap();
|
|
|
75607
76474
|
_visibleHost = /* @__PURE__ */ new WeakMap();
|
|
75608
76475
|
_viewportHost = /* @__PURE__ */ new WeakMap();
|
|
75609
76476
|
_painterHost = /* @__PURE__ */ new WeakMap();
|
|
75610
|
-
|
|
76477
|
+
_selectionOverlay2 = /* @__PURE__ */ new WeakMap();
|
|
75611
76478
|
_hiddenHost = /* @__PURE__ */ new WeakMap();
|
|
75612
76479
|
_layoutOptions = /* @__PURE__ */ new WeakMap();
|
|
75613
76480
|
_layoutState = /* @__PURE__ */ new WeakMap();
|
|
@@ -75642,6 +76509,7 @@ _headerRegions = /* @__PURE__ */ new WeakMap();
|
|
|
75642
76509
|
_footerRegions = /* @__PURE__ */ new WeakMap();
|
|
75643
76510
|
_session = /* @__PURE__ */ new WeakMap();
|
|
75644
76511
|
_activeHeaderFooterEditor = /* @__PURE__ */ new WeakMap();
|
|
76512
|
+
_overlayManager = /* @__PURE__ */ new WeakMap();
|
|
75645
76513
|
_hoverOverlay = /* @__PURE__ */ new WeakMap();
|
|
75646
76514
|
_hoverTooltip = /* @__PURE__ */ new WeakMap();
|
|
75647
76515
|
_modeBanner = /* @__PURE__ */ new WeakMap();
|
|
@@ -76007,9 +76875,14 @@ initHeaderFooterRegistry_fn = function() {
|
|
|
76007
76875
|
__privateSet(this, _headerFooterManagerCleanups, []);
|
|
76008
76876
|
__privateGet$1(this, _headerFooterAdapter)?.clear();
|
|
76009
76877
|
__privateGet$1(this, _headerFooterManager)?.destroy();
|
|
76878
|
+
__privateGet$1(this, _overlayManager)?.destroy();
|
|
76010
76879
|
__privateSet(this, _session, { mode: "body" });
|
|
76011
76880
|
__privateSet(this, _activeHeaderFooterEditor, null);
|
|
76012
76881
|
__privateGet$1(this, _inputBridge)?.notifyTargetChanged();
|
|
76882
|
+
__privateSet(this, _overlayManager, new EditorOverlayManager(__privateGet$1(this, _painterHost), __privateGet$1(this, _visibleHost), __privateGet$1(this, _selectionOverlay2)));
|
|
76883
|
+
__privateGet$1(this, _overlayManager).setOnDimmingClick(() => {
|
|
76884
|
+
__privateMethod$1(this, _PresentationEditor_instances, exitHeaderFooterMode_fn).call(this);
|
|
76885
|
+
});
|
|
76013
76886
|
const converter = __privateGet$1(this, _editor3).converter;
|
|
76014
76887
|
__privateSet(this, _headerFooterIdentifier, extractIdentifierFromConverter(converter));
|
|
76015
76888
|
__privateSet(this, _headerFooterManager, new HeaderFooterEditorManager(__privateGet$1(this, _editor3)));
|
|
@@ -76358,6 +77231,9 @@ scheduleSelectionUpdate_fn = function() {
|
|
|
76358
77231
|
});
|
|
76359
77232
|
};
|
|
76360
77233
|
updateSelection_fn = function() {
|
|
77234
|
+
if (__privateGet$1(this, _session).mode !== "body") {
|
|
77235
|
+
return;
|
|
77236
|
+
}
|
|
76361
77237
|
if (!__privateGet$1(this, _localSelectionLayer)) {
|
|
76362
77238
|
return;
|
|
76363
77239
|
}
|
|
@@ -76367,22 +77243,6 @@ updateSelection_fn = function() {
|
|
|
76367
77243
|
if (!selection) {
|
|
76368
77244
|
return;
|
|
76369
77245
|
}
|
|
76370
|
-
if (__privateGet$1(this, _session).mode !== "body") {
|
|
76371
|
-
if (!layout) {
|
|
76372
|
-
return;
|
|
76373
|
-
}
|
|
76374
|
-
if (selection.from === selection.to) {
|
|
76375
|
-
const caretLayout = __privateMethod$1(this, _PresentationEditor_instances, computeHeaderFooterCaretRect_fn).call(this, selection.from);
|
|
76376
|
-
if (!caretLayout) {
|
|
76377
|
-
return;
|
|
76378
|
-
}
|
|
76379
|
-
__privateMethod$1(this, _PresentationEditor_instances, renderCaretOverlay_fn).call(this, caretLayout);
|
|
76380
|
-
return;
|
|
76381
|
-
}
|
|
76382
|
-
const rects2 = __privateMethod$1(this, _PresentationEditor_instances, computeHeaderFooterSelectionRects_fn).call(this, selection.from, selection.to);
|
|
76383
|
-
__privateMethod$1(this, _PresentationEditor_instances, renderSelectionRects_fn).call(this, rects2);
|
|
76384
|
-
return;
|
|
76385
|
-
}
|
|
76386
77246
|
if (!layout) {
|
|
76387
77247
|
return;
|
|
76388
77248
|
}
|
|
@@ -76617,46 +77477,168 @@ activateHeaderFooterRegion_fn = function(region) {
|
|
|
76617
77477
|
void __privateMethod$1(this, _PresentationEditor_instances, enterHeaderFooterMode_fn).call(this, region);
|
|
76618
77478
|
};
|
|
76619
77479
|
enterHeaderFooterMode_fn = async function(region) {
|
|
76620
|
-
|
|
76621
|
-
|
|
76622
|
-
|
|
76623
|
-
|
|
76624
|
-
|
|
76625
|
-
|
|
76626
|
-
|
|
76627
|
-
|
|
76628
|
-
|
|
76629
|
-
|
|
76630
|
-
|
|
76631
|
-
|
|
76632
|
-
|
|
76633
|
-
|
|
76634
|
-
|
|
76635
|
-
|
|
76636
|
-
|
|
76637
|
-
|
|
77480
|
+
try {
|
|
77481
|
+
if (!__privateGet$1(this, _headerFooterManager) || !__privateGet$1(this, _overlayManager)) {
|
|
77482
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
77483
|
+
return;
|
|
77484
|
+
}
|
|
77485
|
+
const descriptor = __privateMethod$1(this, _PresentationEditor_instances, resolveDescriptorForRegion_fn).call(this, region);
|
|
77486
|
+
if (!descriptor) {
|
|
77487
|
+
console.warn("[PresentationEditor] No descriptor found for region:", region);
|
|
77488
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
77489
|
+
return;
|
|
77490
|
+
}
|
|
77491
|
+
if (!descriptor.id) {
|
|
77492
|
+
console.warn("[PresentationEditor] Descriptor missing id:", descriptor);
|
|
77493
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
77494
|
+
return;
|
|
77495
|
+
}
|
|
77496
|
+
let pageElement = __privateMethod$1(this, _PresentationEditor_instances, getPageElement_fn).call(this, region.pageIndex);
|
|
77497
|
+
if (!pageElement) {
|
|
77498
|
+
try {
|
|
77499
|
+
__privateMethod$1(this, _PresentationEditor_instances, scrollPageIntoView_fn).call(this, region.pageIndex);
|
|
77500
|
+
const mounted = await __privateMethod$1(this, _PresentationEditor_instances, waitForPageMount_fn).call(this, region.pageIndex, { timeout: 2e3 });
|
|
77501
|
+
if (!mounted) {
|
|
77502
|
+
console.error("[PresentationEditor] Failed to mount page for header/footer editing");
|
|
77503
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
77504
|
+
this.emit("error", {
|
|
77505
|
+
error: new Error("Failed to mount page for editing"),
|
|
77506
|
+
context: "enterHeaderFooterMode"
|
|
77507
|
+
});
|
|
77508
|
+
return;
|
|
77509
|
+
}
|
|
77510
|
+
pageElement = __privateMethod$1(this, _PresentationEditor_instances, getPageElement_fn).call(this, region.pageIndex);
|
|
77511
|
+
} catch (scrollError) {
|
|
77512
|
+
console.error("[PresentationEditor] Error mounting page:", scrollError);
|
|
77513
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
77514
|
+
this.emit("error", {
|
|
77515
|
+
error: scrollError,
|
|
77516
|
+
context: "enterHeaderFooterMode.pageMount"
|
|
77517
|
+
});
|
|
77518
|
+
return;
|
|
77519
|
+
}
|
|
77520
|
+
}
|
|
77521
|
+
if (!pageElement) {
|
|
77522
|
+
console.error("[PresentationEditor] Page element not found after mount attempt");
|
|
77523
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
77524
|
+
this.emit("error", {
|
|
77525
|
+
error: new Error("Page element not found after mount"),
|
|
77526
|
+
context: "enterHeaderFooterMode"
|
|
77527
|
+
});
|
|
77528
|
+
return;
|
|
77529
|
+
}
|
|
77530
|
+
const { success, editorHost, reason } = __privateGet$1(this, _overlayManager).showEditingOverlay(
|
|
77531
|
+
pageElement,
|
|
77532
|
+
region,
|
|
77533
|
+
__privateGet$1(this, _layoutOptions).zoom ?? 1
|
|
77534
|
+
);
|
|
77535
|
+
if (!success || !editorHost) {
|
|
77536
|
+
console.error("[PresentationEditor] Failed to create editor host:", reason);
|
|
77537
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
77538
|
+
this.emit("error", {
|
|
77539
|
+
error: new Error(`Failed to create editor host: ${reason}`),
|
|
77540
|
+
context: "enterHeaderFooterMode.showOverlay"
|
|
77541
|
+
});
|
|
77542
|
+
return;
|
|
77543
|
+
}
|
|
77544
|
+
const layout = __privateGet$1(this, _layoutState).layout;
|
|
77545
|
+
let editor;
|
|
77546
|
+
try {
|
|
77547
|
+
editor = await __privateGet$1(this, _headerFooterManager).ensureEditor(descriptor, {
|
|
77548
|
+
editorHost,
|
|
77549
|
+
availableWidth: region.width,
|
|
77550
|
+
availableHeight: region.height,
|
|
77551
|
+
currentPageNumber: region.pageNumber,
|
|
77552
|
+
totalPageCount: layout?.pages?.length ?? 1
|
|
77553
|
+
});
|
|
77554
|
+
} catch (editorError) {
|
|
77555
|
+
console.error("[PresentationEditor] Error creating editor:", editorError);
|
|
77556
|
+
__privateGet$1(this, _overlayManager).hideEditingOverlay();
|
|
77557
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
77558
|
+
this.emit("error", {
|
|
77559
|
+
error: editorError,
|
|
77560
|
+
context: "enterHeaderFooterMode.ensureEditor"
|
|
77561
|
+
});
|
|
77562
|
+
return;
|
|
77563
|
+
}
|
|
77564
|
+
if (!editor) {
|
|
77565
|
+
console.warn("[PresentationEditor] Failed to ensure editor for descriptor:", descriptor);
|
|
77566
|
+
__privateGet$1(this, _overlayManager).hideEditingOverlay();
|
|
77567
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
77568
|
+
this.emit("error", {
|
|
77569
|
+
error: new Error("Failed to create editor instance"),
|
|
77570
|
+
context: "enterHeaderFooterMode.ensureEditor"
|
|
77571
|
+
});
|
|
77572
|
+
return;
|
|
77573
|
+
}
|
|
77574
|
+
try {
|
|
77575
|
+
editor.setEditable(true);
|
|
77576
|
+
editor.setOptions({ documentMode: "editing" });
|
|
77577
|
+
try {
|
|
77578
|
+
const doc2 = editor.state?.doc;
|
|
77579
|
+
if (doc2) {
|
|
77580
|
+
const endPos = doc2.content.size - 1;
|
|
77581
|
+
editor.commands?.setTextSelection?.(Math.max(1, endPos));
|
|
77582
|
+
}
|
|
77583
|
+
} catch (cursorError) {
|
|
77584
|
+
console.warn("[PresentationEditor] Could not set cursor to end:", cursorError);
|
|
77585
|
+
}
|
|
77586
|
+
} catch (editableError) {
|
|
77587
|
+
console.error("[PresentationEditor] Error setting editor editable:", editableError);
|
|
77588
|
+
__privateGet$1(this, _overlayManager).hideEditingOverlay();
|
|
77589
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
77590
|
+
this.emit("error", {
|
|
77591
|
+
error: editableError,
|
|
77592
|
+
context: "enterHeaderFooterMode.setEditable"
|
|
77593
|
+
});
|
|
77594
|
+
return;
|
|
77595
|
+
}
|
|
77596
|
+
__privateGet$1(this, _overlayManager).hideSelectionOverlay();
|
|
77597
|
+
__privateSet(this, _activeHeaderFooterEditor, editor);
|
|
77598
|
+
__privateSet(this, _session, {
|
|
77599
|
+
mode: region.kind,
|
|
77600
|
+
kind: region.kind,
|
|
77601
|
+
headerId: descriptor.id,
|
|
77602
|
+
sectionType: descriptor.variant ?? region.sectionType ?? null,
|
|
77603
|
+
pageIndex: region.pageIndex,
|
|
77604
|
+
pageNumber: region.pageNumber
|
|
77605
|
+
});
|
|
76638
77606
|
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
76639
|
-
|
|
77607
|
+
try {
|
|
77608
|
+
editor.view?.focus();
|
|
77609
|
+
} catch (focusError) {
|
|
77610
|
+
console.warn("[PresentationEditor] Could not focus editor:", focusError);
|
|
77611
|
+
}
|
|
77612
|
+
__privateMethod$1(this, _PresentationEditor_instances, emitHeaderFooterModeChanged_fn).call(this);
|
|
77613
|
+
__privateMethod$1(this, _PresentationEditor_instances, emitHeaderFooterEditingContext_fn).call(this, editor);
|
|
77614
|
+
__privateGet$1(this, _inputBridge)?.notifyTargetChanged();
|
|
77615
|
+
} catch (error) {
|
|
77616
|
+
console.error("[PresentationEditor] Unexpected error in enterHeaderFooterMode:", error);
|
|
77617
|
+
try {
|
|
77618
|
+
__privateGet$1(this, _overlayManager)?.hideEditingOverlay();
|
|
77619
|
+
__privateGet$1(this, _overlayManager)?.showSelectionOverlay();
|
|
77620
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
77621
|
+
__privateSet(this, _activeHeaderFooterEditor, null);
|
|
77622
|
+
__privateSet(this, _session, { mode: "body" });
|
|
77623
|
+
} catch (cleanupError) {
|
|
77624
|
+
console.error("[PresentationEditor] Error during cleanup:", cleanupError);
|
|
77625
|
+
}
|
|
77626
|
+
this.emit("error", {
|
|
77627
|
+
error,
|
|
77628
|
+
context: "enterHeaderFooterMode"
|
|
77629
|
+
});
|
|
76640
77630
|
}
|
|
76641
|
-
__privateSet(this, _activeHeaderFooterEditor, editor);
|
|
76642
|
-
__privateSet(this, _session, {
|
|
76643
|
-
mode: region.kind,
|
|
76644
|
-
kind: region.kind,
|
|
76645
|
-
headerId: descriptor.id,
|
|
76646
|
-
sectionType: descriptor.variant ?? region.sectionType ?? null,
|
|
76647
|
-
pageIndex: region.pageIndex,
|
|
76648
|
-
pageNumber: region.pageNumber
|
|
76649
|
-
});
|
|
76650
|
-
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
76651
|
-
__privateMethod$1(this, _PresentationEditor_instances, emitHeaderFooterModeChanged_fn).call(this);
|
|
76652
|
-
__privateMethod$1(this, _PresentationEditor_instances, emitHeaderFooterEditingContext_fn).call(this, editor);
|
|
76653
|
-
__privateGet$1(this, _inputBridge)?.notifyTargetChanged();
|
|
76654
|
-
editor.view?.focus();
|
|
76655
77631
|
};
|
|
76656
77632
|
exitHeaderFooterMode_fn = function() {
|
|
76657
77633
|
if (__privateGet$1(this, _session).mode === "body") return;
|
|
76658
|
-
|
|
77634
|
+
if (__privateGet$1(this, _activeHeaderFooterEditor)) {
|
|
77635
|
+
__privateGet$1(this, _activeHeaderFooterEditor).setEditable(false);
|
|
77636
|
+
__privateGet$1(this, _activeHeaderFooterEditor).setOptions({ documentMode: "viewing" });
|
|
77637
|
+
}
|
|
77638
|
+
__privateGet$1(this, _overlayManager)?.hideEditingOverlay();
|
|
77639
|
+
__privateGet$1(this, _overlayManager)?.showSelectionOverlay();
|
|
76659
77640
|
__privateSet(this, _activeHeaderFooterEditor, null);
|
|
77641
|
+
__privateSet(this, _session, { mode: "body" });
|
|
76660
77642
|
__privateMethod$1(this, _PresentationEditor_instances, emitHeaderFooterModeChanged_fn).call(this);
|
|
76661
77643
|
__privateMethod$1(this, _PresentationEditor_instances, emitHeaderFooterEditingContext_fn).call(this, __privateGet$1(this, _editor3));
|
|
76662
77644
|
__privateGet$1(this, _inputBridge)?.notifyTargetChanged();
|
|
@@ -76752,6 +77734,75 @@ resolveDescriptorForRegion_fn = function(region) {
|
|
|
76752
77734
|
}
|
|
76753
77735
|
return descriptors[0];
|
|
76754
77736
|
};
|
|
77737
|
+
createDefaultHeaderFooter_fn = function(region) {
|
|
77738
|
+
const converter = __privateGet$1(this, _editor3).converter;
|
|
77739
|
+
if (!converter) {
|
|
77740
|
+
console.error("[PresentationEditor] Converter not available for creating header/footer");
|
|
77741
|
+
return;
|
|
77742
|
+
}
|
|
77743
|
+
const variant = region.sectionType ?? "default";
|
|
77744
|
+
try {
|
|
77745
|
+
if (region.kind === "header") {
|
|
77746
|
+
if (typeof converter.createDefaultHeader === "function") {
|
|
77747
|
+
const headerId = converter.createDefaultHeader(variant);
|
|
77748
|
+
console.log(`[PresentationEditor] Created default header: ${headerId}`);
|
|
77749
|
+
} else {
|
|
77750
|
+
console.error("[PresentationEditor] converter.createDefaultHeader is not a function");
|
|
77751
|
+
}
|
|
77752
|
+
} else if (region.kind === "footer") {
|
|
77753
|
+
if (typeof converter.createDefaultFooter === "function") {
|
|
77754
|
+
const footerId = converter.createDefaultFooter(variant);
|
|
77755
|
+
console.log(`[PresentationEditor] Created default footer: ${footerId}`);
|
|
77756
|
+
} else {
|
|
77757
|
+
console.error("[PresentationEditor] converter.createDefaultFooter is not a function");
|
|
77758
|
+
}
|
|
77759
|
+
}
|
|
77760
|
+
} catch (error) {
|
|
77761
|
+
console.error("[PresentationEditor] Failed to create default header/footer:", error);
|
|
77762
|
+
}
|
|
77763
|
+
};
|
|
77764
|
+
getPageElement_fn = function(pageIndex) {
|
|
77765
|
+
if (!__privateGet$1(this, _painterHost)) return null;
|
|
77766
|
+
const pageElements = __privateGet$1(this, _painterHost).querySelectorAll("[data-page-index]");
|
|
77767
|
+
for (let i = 0; i < pageElements.length; i++) {
|
|
77768
|
+
const el = pageElements[i];
|
|
77769
|
+
const dataPageIndex = el.getAttribute("data-page-index");
|
|
77770
|
+
if (dataPageIndex && parseInt(dataPageIndex, 10) === pageIndex) {
|
|
77771
|
+
return el;
|
|
77772
|
+
}
|
|
77773
|
+
}
|
|
77774
|
+
return null;
|
|
77775
|
+
};
|
|
77776
|
+
scrollPageIntoView_fn = function(pageIndex) {
|
|
77777
|
+
const layout = __privateGet$1(this, _layoutState).layout;
|
|
77778
|
+
if (!layout) return;
|
|
77779
|
+
const pageHeight = layout.pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
|
|
77780
|
+
const virtualGap = __privateGet$1(this, _layoutOptions).virtualization?.gap ?? 0;
|
|
77781
|
+
const yPosition = pageIndex * (pageHeight + virtualGap);
|
|
77782
|
+
if (__privateGet$1(this, _visibleHost)) {
|
|
77783
|
+
__privateGet$1(this, _visibleHost).scrollTop = yPosition;
|
|
77784
|
+
}
|
|
77785
|
+
};
|
|
77786
|
+
waitForPageMount_fn = async function(pageIndex, options = {}) {
|
|
77787
|
+
const timeout2 = options.timeout ?? 2e3;
|
|
77788
|
+
const startTime = performance.now();
|
|
77789
|
+
return new Promise((resolve) => {
|
|
77790
|
+
const checkPage = () => {
|
|
77791
|
+
const pageElement = __privateMethod$1(this, _PresentationEditor_instances, getPageElement_fn).call(this, pageIndex);
|
|
77792
|
+
if (pageElement) {
|
|
77793
|
+
resolve(true);
|
|
77794
|
+
return;
|
|
77795
|
+
}
|
|
77796
|
+
const elapsed = performance.now() - startTime;
|
|
77797
|
+
if (elapsed >= timeout2) {
|
|
77798
|
+
resolve(false);
|
|
77799
|
+
return;
|
|
77800
|
+
}
|
|
77801
|
+
requestAnimationFrame(checkPage);
|
|
77802
|
+
};
|
|
77803
|
+
checkPage();
|
|
77804
|
+
});
|
|
77805
|
+
};
|
|
76755
77806
|
getBodyPageHeight_fn = function() {
|
|
76756
77807
|
return __privateGet$1(this, _layoutState).layout?.pageSize?.h ?? __privateGet$1(this, _layoutOptions).pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
|
|
76757
77808
|
};
|
|
@@ -76805,7 +77856,7 @@ renderHoverRegion_fn = function(region) {
|
|
|
76805
77856
|
__privateGet$1(this, _hoverOverlay).style.top = `${coords.y}px`;
|
|
76806
77857
|
__privateGet$1(this, _hoverOverlay).style.width = `${region.width * zoom}px`;
|
|
76807
77858
|
__privateGet$1(this, _hoverOverlay).style.height = `${region.height * zoom}px`;
|
|
76808
|
-
const tooltipText = `Double-click to edit ${region.kind === "header" ? "
|
|
77859
|
+
const tooltipText = `Double-click to edit ${region.kind === "header" ? "header" : "footer"}`;
|
|
76809
77860
|
__privateGet$1(this, _hoverTooltip).textContent = tooltipText;
|
|
76810
77861
|
__privateGet$1(this, _hoverTooltip).style.display = "block";
|
|
76811
77862
|
__privateGet$1(this, _hoverTooltip).style.left = `${coords.x}px`;
|
|
@@ -76911,33 +77962,6 @@ computeHeaderFooterSelectionRects_fn = function(from2, to) {
|
|
|
76911
77962
|
};
|
|
76912
77963
|
});
|
|
76913
77964
|
};
|
|
76914
|
-
computeHeaderFooterCaretRect_fn = function(pos) {
|
|
76915
|
-
const context = __privateMethod$1(this, _PresentationEditor_instances, getHeaderFooterContext_fn).call(this);
|
|
76916
|
-
if (!context) return null;
|
|
76917
|
-
const hit = getFragmentAtPosition(context.layout, context.blocks, context.measures, pos);
|
|
76918
|
-
if (!hit) return null;
|
|
76919
|
-
const block = hit.block;
|
|
76920
|
-
const measure = hit.measure;
|
|
76921
|
-
if (!block || block.kind !== "paragraph" || measure?.kind !== "paragraph" || hit.fragment.kind !== "para")
|
|
76922
|
-
return null;
|
|
76923
|
-
const lineInfo = __privateMethod$1(this, _PresentationEditor_instances, findLineContainingPos_fn).call(this, block, measure, hit.fragment.fromLine, hit.fragment.toLine, pos);
|
|
76924
|
-
if (!lineInfo) return null;
|
|
76925
|
-
const { line, index: index2 } = lineInfo;
|
|
76926
|
-
const range2 = computeLinePmRange$1(block, line);
|
|
76927
|
-
if (range2.pmStart == null || range2.pmEnd == null) return null;
|
|
76928
|
-
const pmCharsInLine = Math.max(1, range2.pmEnd - range2.pmStart);
|
|
76929
|
-
const pmOffset = Math.max(0, Math.min(pmCharsInLine, pos - range2.pmStart));
|
|
76930
|
-
const localX = hit.fragment.x + measureCharacterX(block, line, pmOffset);
|
|
76931
|
-
const lineOffset = __privateMethod$1(this, _PresentationEditor_instances, lineHeightBeforeIndex_fn).call(this, measure.lines, hit.fragment.fromLine, index2);
|
|
76932
|
-
const headerPageHeight = context.layout.pageSize?.h ?? context.region.height ?? 1;
|
|
76933
|
-
const headerLocalY = hit.pageIndex * headerPageHeight + (hit.fragment.y + lineOffset);
|
|
76934
|
-
return {
|
|
76935
|
-
pageIndex: context.region.pageIndex,
|
|
76936
|
-
x: context.region.localX + localX,
|
|
76937
|
-
y: context.region.localY + headerLocalY,
|
|
76938
|
-
height: line.lineHeight
|
|
76939
|
-
};
|
|
76940
|
-
};
|
|
76941
77965
|
syncTrackedChangesPreferences_fn = function() {
|
|
76942
77966
|
const mode = __privateMethod$1(this, _PresentationEditor_instances, deriveTrackedChangesMode_fn).call(this);
|
|
76943
77967
|
const enabled = __privateMethod$1(this, _PresentationEditor_instances, deriveTrackedChangesEnabled_fn).call(this);
|
|
@@ -77044,7 +78068,7 @@ convertPageLocalToOverlayCoords_fn = function(pageIndex, pageLocalX, pageLocalY)
|
|
|
77044
78068
|
return null;
|
|
77045
78069
|
}
|
|
77046
78070
|
const pageRect = pageEl.getBoundingClientRect();
|
|
77047
|
-
const overlayRect = __privateGet$1(this,
|
|
78071
|
+
const overlayRect = __privateGet$1(this, _selectionOverlay2).getBoundingClientRect();
|
|
77048
78072
|
const zoom = __privateGet$1(this, _layoutOptions).zoom ?? 1;
|
|
77049
78073
|
return {
|
|
77050
78074
|
x: pageRect.left - overlayRect.left + pageLocalX * zoom,
|
|
@@ -81914,22 +82938,53 @@ function calculateTabLayout(request, measurement, view) {
|
|
|
81914
82938
|
tabs
|
|
81915
82939
|
};
|
|
81916
82940
|
}
|
|
82941
|
+
const MAX_WALK_DEPTH = 50;
|
|
81917
82942
|
function applyLayoutResult(result, paragraph, paragraphPos) {
|
|
81918
82943
|
const decorations = [];
|
|
81919
82944
|
let tabIndex = 0;
|
|
81920
|
-
|
|
81921
|
-
if (
|
|
81922
|
-
|
|
81923
|
-
|
|
81924
|
-
|
|
81925
|
-
if (!
|
|
81926
|
-
|
|
81927
|
-
|
|
81928
|
-
|
|
81929
|
-
|
|
81930
|
-
|
|
81931
|
-
|
|
81932
|
-
|
|
82945
|
+
const walk = (node, pos, depth = 0) => {
|
|
82946
|
+
if (depth > MAX_WALK_DEPTH) {
|
|
82947
|
+
console.error(`applyLayoutResult: Maximum recursion depth (${MAX_WALK_DEPTH}) exceeded`);
|
|
82948
|
+
return;
|
|
82949
|
+
}
|
|
82950
|
+
if (!node?.type?.name) {
|
|
82951
|
+
console.error("applyLayoutResult: Node missing type.name", { node, pos, depth });
|
|
82952
|
+
return;
|
|
82953
|
+
}
|
|
82954
|
+
if (typeof node.nodeSize !== "number" || node.nodeSize < 0 || !Number.isFinite(node.nodeSize)) {
|
|
82955
|
+
console.error("applyLayoutResult: Invalid nodeSize", { nodeSize: node.nodeSize, nodeName: node.type.name, pos });
|
|
82956
|
+
return;
|
|
82957
|
+
}
|
|
82958
|
+
if (node.type.name === "tab") {
|
|
82959
|
+
const tabId = tabIdForIndex(result.paragraphId, tabIndex++);
|
|
82960
|
+
const layout = result.tabs[tabId];
|
|
82961
|
+
if (layout) {
|
|
82962
|
+
let style2 = `width: ${layout.width}px;`;
|
|
82963
|
+
if (layout.height) style2 += ` height: ${layout.height};`;
|
|
82964
|
+
if (layout.leader && leaderStyles[layout.leader]) {
|
|
82965
|
+
style2 += ` ${leaderStyles[layout.leader]}`;
|
|
82966
|
+
}
|
|
82967
|
+
decorations.push(Decoration.node(pos, pos + node.nodeSize, { style: style2 }));
|
|
82968
|
+
}
|
|
82969
|
+
return;
|
|
82970
|
+
}
|
|
82971
|
+
try {
|
|
82972
|
+
let offset2 = 0;
|
|
82973
|
+
node.forEach((child) => {
|
|
82974
|
+
const childPos = pos + 1 + offset2;
|
|
82975
|
+
walk(child, childPos, depth + 1);
|
|
82976
|
+
offset2 += child.nodeSize;
|
|
82977
|
+
});
|
|
82978
|
+
} catch (error) {
|
|
82979
|
+
console.error("applyLayoutResult: Error during recursion", {
|
|
82980
|
+
error,
|
|
82981
|
+
nodeName: node.type.name,
|
|
82982
|
+
pos,
|
|
82983
|
+
depth
|
|
82984
|
+
});
|
|
82985
|
+
}
|
|
82986
|
+
};
|
|
82987
|
+
walk(paragraph, paragraphPos);
|
|
81933
82988
|
return decorations;
|
|
81934
82989
|
}
|
|
81935
82990
|
function collectFollowingText(spans, startIndex) {
|
|
@@ -82477,8 +83532,8 @@ const createColGroup = (node, cellMinWidth2, overrideCol, overrideValue) => {
|
|
|
82477
83532
|
colgroupValues
|
|
82478
83533
|
};
|
|
82479
83534
|
};
|
|
82480
|
-
|
|
82481
|
-
|
|
83535
|
+
let readFromCache;
|
|
83536
|
+
let addToCache;
|
|
82482
83537
|
if (typeof WeakMap != "undefined") {
|
|
82483
83538
|
let cache2 = /* @__PURE__ */ new WeakMap();
|
|
82484
83539
|
readFromCache = (key2) => cache2.get(key2);
|
|
@@ -82491,8 +83546,7 @@ if (typeof WeakMap != "undefined") {
|
|
|
82491
83546
|
const cacheSize = 10;
|
|
82492
83547
|
let cachePos = 0;
|
|
82493
83548
|
readFromCache = (key2) => {
|
|
82494
|
-
for (let i = 0; i < cache2.length; i += 2)
|
|
82495
|
-
if (cache2[i] == key2) return cache2[i + 1];
|
|
83549
|
+
for (let i = 0; i < cache2.length; i += 2) if (cache2[i] == key2) return cache2[i + 1];
|
|
82496
83550
|
};
|
|
82497
83551
|
addToCache = (key2, value) => {
|
|
82498
83552
|
if (cachePos == cacheSize) cachePos = 0;
|
|
@@ -82507,7 +83561,6 @@ var TableMap = class {
|
|
|
82507
83561
|
this.map = map22;
|
|
82508
83562
|
this.problems = problems;
|
|
82509
83563
|
}
|
|
82510
|
-
// Find the dimensions of the cell at the given position.
|
|
82511
83564
|
findCell(pos) {
|
|
82512
83565
|
for (let i = 0; i < this.map.length; i++) {
|
|
82513
83566
|
const curPos = this.map[i];
|
|
@@ -82516,27 +83569,21 @@ var TableMap = class {
|
|
|
82516
83569
|
const top2 = i / this.width | 0;
|
|
82517
83570
|
let right2 = left2 + 1;
|
|
82518
83571
|
let bottom2 = top2 + 1;
|
|
82519
|
-
for (let j2 = 1; right2 < this.width && this.map[i + j2] == curPos; j2++)
|
|
82520
|
-
|
|
82521
|
-
|
|
82522
|
-
|
|
82523
|
-
|
|
82524
|
-
|
|
82525
|
-
|
|
83572
|
+
for (let j2 = 1; right2 < this.width && this.map[i + j2] == curPos; j2++) right2++;
|
|
83573
|
+
for (let j2 = 1; bottom2 < this.height && this.map[i + this.width * j2] == curPos; j2++) bottom2++;
|
|
83574
|
+
return {
|
|
83575
|
+
left: left2,
|
|
83576
|
+
top: top2,
|
|
83577
|
+
right: right2,
|
|
83578
|
+
bottom: bottom2
|
|
83579
|
+
};
|
|
82526
83580
|
}
|
|
82527
83581
|
throw new RangeError(`No cell with offset ${pos} found`);
|
|
82528
83582
|
}
|
|
82529
|
-
// Find the left side of the cell at the given position.
|
|
82530
83583
|
colCount(pos) {
|
|
82531
|
-
for (let i = 0; i < this.map.length; i++)
|
|
82532
|
-
if (this.map[i] == pos) {
|
|
82533
|
-
return i % this.width;
|
|
82534
|
-
}
|
|
82535
|
-
}
|
|
83584
|
+
for (let i = 0; i < this.map.length; i++) if (this.map[i] == pos) return i % this.width;
|
|
82536
83585
|
throw new RangeError(`No cell with offset ${pos} found`);
|
|
82537
83586
|
}
|
|
82538
|
-
// Find the next cell in the given direction, starting from the cell
|
|
82539
|
-
// at `pos`, if any.
|
|
82540
83587
|
nextCell(pos, axis, dir) {
|
|
82541
83588
|
const { left: left2, right: right2, top: top2, bottom: bottom2 } = this.findCell(pos);
|
|
82542
83589
|
if (axis == "horiz") {
|
|
@@ -82547,20 +83594,9 @@ var TableMap = class {
|
|
|
82547
83594
|
return this.map[left2 + this.width * (dir < 0 ? top2 - 1 : bottom2)];
|
|
82548
83595
|
}
|
|
82549
83596
|
}
|
|
82550
|
-
// Get the rectangle spanning the two given cells.
|
|
82551
83597
|
rectBetween(a, b2) {
|
|
82552
|
-
const {
|
|
82553
|
-
|
|
82554
|
-
right: rightA,
|
|
82555
|
-
top: topA,
|
|
82556
|
-
bottom: bottomA
|
|
82557
|
-
} = this.findCell(a);
|
|
82558
|
-
const {
|
|
82559
|
-
left: leftB,
|
|
82560
|
-
right: rightB,
|
|
82561
|
-
top: topB,
|
|
82562
|
-
bottom: bottomB
|
|
82563
|
-
} = this.findCell(b2);
|
|
83598
|
+
const { left: leftA, right: rightA, top: topA, bottom: bottomA } = this.findCell(a);
|
|
83599
|
+
const { left: leftB, right: rightB, top: topB, bottom: bottomB } = this.findCell(b2);
|
|
82564
83600
|
return {
|
|
82565
83601
|
left: Math.min(leftA, leftB),
|
|
82566
83602
|
top: Math.min(topA, topB),
|
|
@@ -82568,27 +83604,19 @@ var TableMap = class {
|
|
|
82568
83604
|
bottom: Math.max(bottomA, bottomB)
|
|
82569
83605
|
};
|
|
82570
83606
|
}
|
|
82571
|
-
// Return the position of all cells that have the top left corner in
|
|
82572
|
-
// the given rectangle.
|
|
82573
83607
|
cellsInRect(rect) {
|
|
82574
83608
|
const result = [];
|
|
82575
83609
|
const seen = {};
|
|
82576
|
-
for (let row = rect.top; row < rect.bottom; row++) {
|
|
82577
|
-
|
|
82578
|
-
|
|
82579
|
-
|
|
82580
|
-
|
|
82581
|
-
|
|
82582
|
-
|
|
82583
|
-
continue;
|
|
82584
|
-
}
|
|
82585
|
-
result.push(pos);
|
|
82586
|
-
}
|
|
83610
|
+
for (let row = rect.top; row < rect.bottom; row++) for (let col = rect.left; col < rect.right; col++) {
|
|
83611
|
+
const index2 = row * this.width + col;
|
|
83612
|
+
const pos = this.map[index2];
|
|
83613
|
+
if (seen[pos]) continue;
|
|
83614
|
+
seen[pos] = true;
|
|
83615
|
+
if (col == rect.left && col && this.map[index2 - 1] == pos || row == rect.top && row && this.map[index2 - this.width] == pos) continue;
|
|
83616
|
+
result.push(pos);
|
|
82587
83617
|
}
|
|
82588
83618
|
return result;
|
|
82589
83619
|
}
|
|
82590
|
-
// Return the position at which the cell at the given row and column
|
|
82591
|
-
// starts, or would start, if a cell started there.
|
|
82592
83620
|
positionAt(row, col, table) {
|
|
82593
83621
|
for (let i = 0, rowStart = 0; ; i++) {
|
|
82594
83622
|
const rowEnd = rowStart + table.child(i).nodeSize;
|
|
@@ -82601,14 +83629,12 @@ var TableMap = class {
|
|
|
82601
83629
|
rowStart = rowEnd;
|
|
82602
83630
|
}
|
|
82603
83631
|
}
|
|
82604
|
-
// Find the table map for the given table node.
|
|
82605
83632
|
static get(table) {
|
|
82606
83633
|
return readFromCache(table) || addToCache(table, computeMap(table));
|
|
82607
83634
|
}
|
|
82608
83635
|
};
|
|
82609
83636
|
function computeMap(table) {
|
|
82610
|
-
if (table.type.spec.tableRole != "table")
|
|
82611
|
-
throw new RangeError("Not a table node: " + table.type.name);
|
|
83637
|
+
if (table.type.spec.tableRole != "table") throw new RangeError("Not a table node: " + table.type.name);
|
|
82612
83638
|
const width = findWidth(table), height = table.childCount;
|
|
82613
83639
|
const map22 = [];
|
|
82614
83640
|
let mapPos = 0;
|
|
@@ -82635,22 +83661,19 @@ function computeMap(table) {
|
|
|
82635
83661
|
const start2 = mapPos + h * width;
|
|
82636
83662
|
for (let w2 = 0; w2 < colspan; w2++) {
|
|
82637
83663
|
if (map22[start2 + w2] == 0) map22[start2 + w2] = pos;
|
|
82638
|
-
else
|
|
82639
|
-
|
|
82640
|
-
|
|
82641
|
-
|
|
82642
|
-
|
|
82643
|
-
|
|
82644
|
-
});
|
|
83664
|
+
else (problems || (problems = [])).push({
|
|
83665
|
+
type: "collision",
|
|
83666
|
+
row,
|
|
83667
|
+
pos,
|
|
83668
|
+
n: colspan - w2
|
|
83669
|
+
});
|
|
82645
83670
|
const colW = colwidth && colwidth[w2];
|
|
82646
83671
|
if (colW) {
|
|
82647
83672
|
const widthIndex = (start2 + w2) % width * 2, prev = colWidths[widthIndex];
|
|
82648
83673
|
if (prev == null || prev != colW && colWidths[widthIndex + 1] == 1) {
|
|
82649
83674
|
colWidths[widthIndex] = colW;
|
|
82650
83675
|
colWidths[widthIndex + 1] = 1;
|
|
82651
|
-
} else if (prev == colW)
|
|
82652
|
-
colWidths[widthIndex + 1]++;
|
|
82653
|
-
}
|
|
83676
|
+
} else if (prev == colW) colWidths[widthIndex + 1]++;
|
|
82654
83677
|
}
|
|
82655
83678
|
}
|
|
82656
83679
|
}
|
|
@@ -82660,16 +83683,17 @@ function computeMap(table) {
|
|
|
82660
83683
|
const expectedPos = (row + 1) * width;
|
|
82661
83684
|
let missing = 0;
|
|
82662
83685
|
while (mapPos < expectedPos) if (map22[mapPos++] == 0) missing++;
|
|
82663
|
-
if (missing)
|
|
82664
|
-
|
|
83686
|
+
if (missing) (problems || (problems = [])).push({
|
|
83687
|
+
type: "missing",
|
|
83688
|
+
row,
|
|
83689
|
+
n: missing
|
|
83690
|
+
});
|
|
82665
83691
|
pos++;
|
|
82666
83692
|
}
|
|
82667
|
-
if (width === 0 || height === 0)
|
|
82668
|
-
(problems || (problems = [])).push({ type: "zero_sized" });
|
|
83693
|
+
if (width === 0 || height === 0) (problems || (problems = [])).push({ type: "zero_sized" });
|
|
82669
83694
|
const tableMap = new TableMap(width, height, map22, problems);
|
|
82670
83695
|
let badWidths = false;
|
|
82671
|
-
for (let i = 0; !badWidths && i < colWidths.length; i += 2)
|
|
82672
|
-
if (colWidths[i] != null && colWidths[i + 1] < height) badWidths = true;
|
|
83696
|
+
for (let i = 0; !badWidths && i < colWidths.length; i += 2) if (colWidths[i] != null && colWidths[i + 1] < height) badWidths = true;
|
|
82673
83697
|
if (badWidths) findBadColWidths(tableMap, colWidths, table);
|
|
82674
83698
|
return tableMap;
|
|
82675
83699
|
}
|
|
@@ -82679,14 +83703,13 @@ function findWidth(table) {
|
|
|
82679
83703
|
for (let row = 0; row < table.childCount; row++) {
|
|
82680
83704
|
const rowNode = table.child(row);
|
|
82681
83705
|
let rowWidth = 0;
|
|
82682
|
-
if (hasRowSpan)
|
|
82683
|
-
|
|
82684
|
-
|
|
82685
|
-
|
|
82686
|
-
|
|
82687
|
-
if (j2 + cell.attrs.rowspan > row) rowWidth += cell.attrs.colspan;
|
|
82688
|
-
}
|
|
83706
|
+
if (hasRowSpan) for (let j2 = 0; j2 < row; j2++) {
|
|
83707
|
+
const prevRow = table.child(j2);
|
|
83708
|
+
for (let i = 0; i < prevRow.childCount; i++) {
|
|
83709
|
+
const cell = prevRow.child(i);
|
|
83710
|
+
if (j2 + cell.attrs.rowspan > row) rowWidth += cell.attrs.colspan;
|
|
82689
83711
|
}
|
|
83712
|
+
}
|
|
82690
83713
|
for (let i = 0; i < rowNode.childCount; i++) {
|
|
82691
83714
|
const cell = rowNode.child(i);
|
|
82692
83715
|
rowWidth += cell.attrs.colspan;
|
|
@@ -82705,23 +83728,18 @@ function findBadColWidths(map22, colWidths, table) {
|
|
|
82705
83728
|
if (seen[pos]) continue;
|
|
82706
83729
|
seen[pos] = true;
|
|
82707
83730
|
const node = table.nodeAt(pos);
|
|
82708
|
-
if (!node) {
|
|
82709
|
-
throw new RangeError(`No cell with offset ${pos} found`);
|
|
82710
|
-
}
|
|
83731
|
+
if (!node) throw new RangeError(`No cell with offset ${pos} found`);
|
|
82711
83732
|
let updated = null;
|
|
82712
83733
|
const attrs = node.attrs;
|
|
82713
83734
|
for (let j2 = 0; j2 < attrs.colspan; j2++) {
|
|
82714
|
-
const
|
|
82715
|
-
|
|
82716
|
-
|
|
82717
|
-
|
|
82718
|
-
|
|
82719
|
-
|
|
82720
|
-
|
|
82721
|
-
|
|
82722
|
-
pos,
|
|
82723
|
-
colwidth: updated
|
|
82724
|
-
});
|
|
83735
|
+
const colWidth = colWidths[(i + j2) % map22.width * 2];
|
|
83736
|
+
if (colWidth != null && (!attrs.colwidth || attrs.colwidth[j2] != colWidth)) (updated || (updated = freshColWidth(attrs)))[j2] = colWidth;
|
|
83737
|
+
}
|
|
83738
|
+
if (updated) map22.problems.unshift({
|
|
83739
|
+
type: "colwidth mismatch",
|
|
83740
|
+
pos,
|
|
83741
|
+
colwidth: updated
|
|
83742
|
+
});
|
|
82725
83743
|
}
|
|
82726
83744
|
}
|
|
82727
83745
|
function freshColWidth(attrs) {
|
|
@@ -82741,11 +83759,9 @@ function tableNodeTypes(schema) {
|
|
|
82741
83759
|
}
|
|
82742
83760
|
return result;
|
|
82743
83761
|
}
|
|
82744
|
-
|
|
83762
|
+
const tableEditingKey = new PluginKey("selectingCells");
|
|
82745
83763
|
function cellAround$1($pos) {
|
|
82746
|
-
for (let d2 = $pos.depth - 1; d2 > 0; d2--)
|
|
82747
|
-
if ($pos.node(d2).type.spec.tableRole == "row")
|
|
82748
|
-
return $pos.node(0).resolve($pos.before(d2 + 1));
|
|
83764
|
+
for (let d2 = $pos.depth - 1; d2 > 0; d2--) if ($pos.node(d2).type.spec.tableRole == "row") return $pos.node(0).resolve($pos.before(d2 + 1));
|
|
82749
83765
|
return null;
|
|
82750
83766
|
}
|
|
82751
83767
|
function cellWrapping$1($pos) {
|
|
@@ -82757,21 +83773,15 @@ function cellWrapping$1($pos) {
|
|
|
82757
83773
|
}
|
|
82758
83774
|
function isInTable(state2) {
|
|
82759
83775
|
const $head = state2.selection.$head;
|
|
82760
|
-
for (let d2 = $head.depth; d2 > 0; d2--)
|
|
82761
|
-
if ($head.node(d2).type.spec.tableRole == "row") return true;
|
|
83776
|
+
for (let d2 = $head.depth; d2 > 0; d2--) if ($head.node(d2).type.spec.tableRole == "row") return true;
|
|
82762
83777
|
return false;
|
|
82763
83778
|
}
|
|
82764
83779
|
function selectionCell(state2) {
|
|
82765
83780
|
const sel = state2.selection;
|
|
82766
|
-
if ("$anchorCell" in sel && sel.$anchorCell)
|
|
82767
|
-
|
|
82768
|
-
} else if ("node" in sel && sel.node && sel.node.type.spec.tableRole == "cell") {
|
|
82769
|
-
return sel.$anchor;
|
|
82770
|
-
}
|
|
83781
|
+
if ("$anchorCell" in sel && sel.$anchorCell) return sel.$anchorCell.pos > sel.$headCell.pos ? sel.$anchorCell : sel.$headCell;
|
|
83782
|
+
else if ("node" in sel && sel.node && sel.node.type.spec.tableRole == "cell") return sel.$anchor;
|
|
82771
83783
|
const $cell = cellAround$1(sel.$head) || cellNear(sel.$head);
|
|
82772
|
-
if ($cell)
|
|
82773
|
-
return $cell;
|
|
82774
|
-
}
|
|
83784
|
+
if ($cell) return $cell;
|
|
82775
83785
|
throw new RangeError(`No cell found around position ${sel.head}`);
|
|
82776
83786
|
}
|
|
82777
83787
|
function cellNear($pos) {
|
|
@@ -82781,8 +83791,7 @@ function cellNear($pos) {
|
|
|
82781
83791
|
}
|
|
82782
83792
|
for (let before = $pos.nodeBefore, pos = $pos.pos; before; before = before.lastChild, pos--) {
|
|
82783
83793
|
const role = before.type.spec.tableRole;
|
|
82784
|
-
if (role == "cell" || role == "header_cell")
|
|
82785
|
-
return $pos.doc.resolve(pos - before.nodeSize);
|
|
83794
|
+
if (role == "cell" || role == "header_cell") return $pos.doc.resolve(pos - before.nodeSize);
|
|
82786
83795
|
}
|
|
82787
83796
|
}
|
|
82788
83797
|
function pointsAtCell($pos) {
|
|
@@ -82802,7 +83811,10 @@ function nextCell($pos, axis, dir) {
|
|
|
82802
83811
|
return moved == null ? null : $pos.node(0).resolve(tableStart + moved);
|
|
82803
83812
|
}
|
|
82804
83813
|
function removeColSpan(attrs, pos, n = 1) {
|
|
82805
|
-
const result = {
|
|
83814
|
+
const result = {
|
|
83815
|
+
...attrs,
|
|
83816
|
+
colspan: attrs.colspan - n
|
|
83817
|
+
};
|
|
82806
83818
|
if (result.colwidth) {
|
|
82807
83819
|
result.colwidth = result.colwidth.slice();
|
|
82808
83820
|
result.colwidth.splice(pos, n);
|
|
@@ -82811,7 +83823,10 @@ function removeColSpan(attrs, pos, n = 1) {
|
|
|
82811
83823
|
return result;
|
|
82812
83824
|
}
|
|
82813
83825
|
function addColSpan(attrs, pos, n = 1) {
|
|
82814
|
-
const result = {
|
|
83826
|
+
const result = {
|
|
83827
|
+
...attrs,
|
|
83828
|
+
colspan: attrs.colspan + n
|
|
83829
|
+
};
|
|
82815
83830
|
if (result.colwidth) {
|
|
82816
83831
|
result.colwidth = result.colwidth.slice();
|
|
82817
83832
|
for (let i = 0; i < n; i++) result.colwidth.splice(pos, 0, 0);
|
|
@@ -82820,37 +83835,23 @@ function addColSpan(attrs, pos, n = 1) {
|
|
|
82820
83835
|
}
|
|
82821
83836
|
function columnIsHeader(map22, table, col) {
|
|
82822
83837
|
const headerCell = tableNodeTypes(table.type.schema).header_cell;
|
|
82823
|
-
for (let row = 0; row < map22.height; row++)
|
|
82824
|
-
if (table.nodeAt(map22.map[col + row * map22.width]).type != headerCell)
|
|
82825
|
-
return false;
|
|
83838
|
+
for (let row = 0; row < map22.height; row++) if (table.nodeAt(map22.map[col + row * map22.width]).type != headerCell) return false;
|
|
82826
83839
|
return true;
|
|
82827
83840
|
}
|
|
82828
|
-
var CellSelection = class
|
|
82829
|
-
// A table selection is identified by its anchor and head cells. The
|
|
82830
|
-
// positions given to this constructor should point _before_ two
|
|
82831
|
-
// cells in the same table. They may be the same, to select a single
|
|
82832
|
-
// cell.
|
|
83841
|
+
var CellSelection = class CellSelection2 extends Selection {
|
|
82833
83842
|
constructor($anchorCell, $headCell = $anchorCell) {
|
|
82834
83843
|
const table = $anchorCell.node(-1);
|
|
82835
83844
|
const map22 = TableMap.get(table);
|
|
82836
83845
|
const tableStart = $anchorCell.start(-1);
|
|
82837
|
-
const rect = map22.rectBetween(
|
|
82838
|
-
$anchorCell.pos - tableStart,
|
|
82839
|
-
$headCell.pos - tableStart
|
|
82840
|
-
);
|
|
83846
|
+
const rect = map22.rectBetween($anchorCell.pos - tableStart, $headCell.pos - tableStart);
|
|
82841
83847
|
const doc2 = $anchorCell.node(0);
|
|
82842
83848
|
const cells = map22.cellsInRect(rect).filter((p) => p != $headCell.pos - tableStart);
|
|
82843
83849
|
cells.unshift($headCell.pos - tableStart);
|
|
82844
83850
|
const ranges = cells.map((pos) => {
|
|
82845
83851
|
const cell = table.nodeAt(pos);
|
|
82846
|
-
if (!cell) {
|
|
82847
|
-
throw RangeError(`No cell with offset ${pos} found`);
|
|
82848
|
-
}
|
|
83852
|
+
if (!cell) throw new RangeError(`No cell with offset ${pos} found`);
|
|
82849
83853
|
const from2 = tableStart + pos + 1;
|
|
82850
|
-
return new SelectionRange(
|
|
82851
|
-
doc2.resolve(from2),
|
|
82852
|
-
doc2.resolve(from2 + cell.content.size)
|
|
82853
|
-
);
|
|
83854
|
+
return new SelectionRange(doc2.resolve(from2), doc2.resolve(from2 + cell.content.size));
|
|
82854
83855
|
});
|
|
82855
83856
|
super(ranges[0].$from, ranges[0].$to, ranges);
|
|
82856
83857
|
this.$anchorCell = $anchorCell;
|
|
@@ -82861,24 +83862,17 @@ var CellSelection = class _CellSelection extends Selection {
|
|
|
82861
83862
|
const $headCell = doc2.resolve(mapping.map(this.$headCell.pos));
|
|
82862
83863
|
if (pointsAtCell($anchorCell) && pointsAtCell($headCell) && inSameTable($anchorCell, $headCell)) {
|
|
82863
83864
|
const tableChanged = this.$anchorCell.node(-1) != $anchorCell.node(-1);
|
|
82864
|
-
if (tableChanged && this.isRowSelection())
|
|
82865
|
-
|
|
82866
|
-
else
|
|
82867
|
-
return _CellSelection.colSelection($anchorCell, $headCell);
|
|
82868
|
-
else return new _CellSelection($anchorCell, $headCell);
|
|
83865
|
+
if (tableChanged && this.isRowSelection()) return CellSelection2.rowSelection($anchorCell, $headCell);
|
|
83866
|
+
else if (tableChanged && this.isColSelection()) return CellSelection2.colSelection($anchorCell, $headCell);
|
|
83867
|
+
else return new CellSelection2($anchorCell, $headCell);
|
|
82869
83868
|
}
|
|
82870
83869
|
return TextSelection$1.between($anchorCell, $headCell);
|
|
82871
83870
|
}
|
|
82872
|
-
// Returns a rectangular slice of table rows containing the selected
|
|
82873
|
-
// cells.
|
|
82874
83871
|
content() {
|
|
82875
83872
|
const table = this.$anchorCell.node(-1);
|
|
82876
83873
|
const map22 = TableMap.get(table);
|
|
82877
83874
|
const tableStart = this.$anchorCell.start(-1);
|
|
82878
|
-
const rect = map22.rectBetween(
|
|
82879
|
-
this.$anchorCell.pos - tableStart,
|
|
82880
|
-
this.$headCell.pos - tableStart
|
|
82881
|
-
);
|
|
83875
|
+
const rect = map22.rectBetween(this.$anchorCell.pos - tableStart, this.$headCell.pos - tableStart);
|
|
82882
83876
|
const seen = {};
|
|
82883
83877
|
const rows = [];
|
|
82884
83878
|
for (let row = rect.top; row < rect.bottom; row++) {
|
|
@@ -82889,44 +83883,25 @@ var CellSelection = class _CellSelection extends Selection {
|
|
|
82889
83883
|
seen[pos] = true;
|
|
82890
83884
|
const cellRect = map22.findCell(pos);
|
|
82891
83885
|
let cell = table.nodeAt(pos);
|
|
82892
|
-
if (!cell) {
|
|
82893
|
-
throw RangeError(`No cell with offset ${pos} found`);
|
|
82894
|
-
}
|
|
83886
|
+
if (!cell) throw new RangeError(`No cell with offset ${pos} found`);
|
|
82895
83887
|
const extraLeft = rect.left - cellRect.left;
|
|
82896
83888
|
const extraRight = cellRect.right - rect.right;
|
|
82897
83889
|
if (extraLeft > 0 || extraRight > 0) {
|
|
82898
83890
|
let attrs = cell.attrs;
|
|
82899
|
-
if (extraLeft > 0)
|
|
82900
|
-
|
|
82901
|
-
}
|
|
82902
|
-
if (extraRight > 0) {
|
|
82903
|
-
attrs = removeColSpan(
|
|
82904
|
-
attrs,
|
|
82905
|
-
attrs.colspan - extraRight,
|
|
82906
|
-
extraRight
|
|
82907
|
-
);
|
|
82908
|
-
}
|
|
83891
|
+
if (extraLeft > 0) attrs = removeColSpan(attrs, 0, extraLeft);
|
|
83892
|
+
if (extraRight > 0) attrs = removeColSpan(attrs, attrs.colspan - extraRight, extraRight);
|
|
82909
83893
|
if (cellRect.left < rect.left) {
|
|
82910
83894
|
cell = cell.type.createAndFill(attrs);
|
|
82911
|
-
if (!cell) {
|
|
82912
|
-
|
|
82913
|
-
`Could not create cell with attrs ${JSON.stringify(attrs)}`
|
|
82914
|
-
);
|
|
82915
|
-
}
|
|
82916
|
-
} else {
|
|
82917
|
-
cell = cell.type.create(attrs, cell.content);
|
|
82918
|
-
}
|
|
83895
|
+
if (!cell) throw new RangeError(`Could not create cell with attrs ${JSON.stringify(attrs)}`);
|
|
83896
|
+
} else cell = cell.type.create(attrs, cell.content);
|
|
82919
83897
|
}
|
|
82920
83898
|
if (cellRect.top < rect.top || cellRect.bottom > rect.bottom) {
|
|
82921
83899
|
const attrs = {
|
|
82922
83900
|
...cell.attrs,
|
|
82923
83901
|
rowspan: Math.min(cellRect.bottom, rect.bottom) - Math.max(cellRect.top, rect.top)
|
|
82924
83902
|
};
|
|
82925
|
-
if (cellRect.top < rect.top)
|
|
82926
|
-
|
|
82927
|
-
} else {
|
|
82928
|
-
cell = cell.type.create(attrs, cell.content);
|
|
82929
|
-
}
|
|
83903
|
+
if (cellRect.top < rect.top) cell = cell.type.createAndFill(attrs);
|
|
83904
|
+
else cell = cell.type.create(attrs, cell.content);
|
|
82930
83905
|
}
|
|
82931
83906
|
rowContent.push(cell);
|
|
82932
83907
|
}
|
|
@@ -82939,16 +83914,9 @@ var CellSelection = class _CellSelection extends Selection {
|
|
|
82939
83914
|
const mapFrom = tr.steps.length, ranges = this.ranges;
|
|
82940
83915
|
for (let i = 0; i < ranges.length; i++) {
|
|
82941
83916
|
const { $from, $to } = ranges[i], mapping = tr.mapping.slice(mapFrom);
|
|
82942
|
-
tr.replace(
|
|
82943
|
-
mapping.map($from.pos),
|
|
82944
|
-
mapping.map($to.pos),
|
|
82945
|
-
i ? Slice.empty : content
|
|
82946
|
-
);
|
|
83917
|
+
tr.replace(mapping.map($from.pos), mapping.map($to.pos), i ? Slice.empty : content);
|
|
82947
83918
|
}
|
|
82948
|
-
const sel = Selection.findFrom(
|
|
82949
|
-
tr.doc.resolve(tr.mapping.slice(mapFrom).map(this.to)),
|
|
82950
|
-
-1
|
|
82951
|
-
);
|
|
83919
|
+
const sel = Selection.findFrom(tr.doc.resolve(tr.mapping.slice(mapFrom).map(this.to)), -1);
|
|
82952
83920
|
if (sel) tr.setSelection(sel);
|
|
82953
83921
|
}
|
|
82954
83922
|
replaceWith(tr, node) {
|
|
@@ -82958,18 +83926,9 @@ var CellSelection = class _CellSelection extends Selection {
|
|
|
82958
83926
|
const table = this.$anchorCell.node(-1);
|
|
82959
83927
|
const map22 = TableMap.get(table);
|
|
82960
83928
|
const tableStart = this.$anchorCell.start(-1);
|
|
82961
|
-
const cells = map22.cellsInRect(
|
|
82962
|
-
|
|
82963
|
-
this.$anchorCell.pos - tableStart,
|
|
82964
|
-
this.$headCell.pos - tableStart
|
|
82965
|
-
)
|
|
82966
|
-
);
|
|
82967
|
-
for (let i = 0; i < cells.length; i++) {
|
|
82968
|
-
f2(table.nodeAt(cells[i]), tableStart + cells[i]);
|
|
82969
|
-
}
|
|
83929
|
+
const cells = map22.cellsInRect(map22.rectBetween(this.$anchorCell.pos - tableStart, this.$headCell.pos - tableStart));
|
|
83930
|
+
for (let i = 0; i < cells.length; i++) f2(table.nodeAt(cells[i]), tableStart + cells[i]);
|
|
82970
83931
|
}
|
|
82971
|
-
// True if this selection goes all the way from the top to the
|
|
82972
|
-
// bottom of the table.
|
|
82973
83932
|
isColSelection() {
|
|
82974
83933
|
const anchorTop = this.$anchorCell.index(-1);
|
|
82975
83934
|
const headTop = this.$headCell.index(-1);
|
|
@@ -82978,8 +83937,6 @@ var CellSelection = class _CellSelection extends Selection {
|
|
|
82978
83937
|
const headBottom = headTop + this.$headCell.nodeAfter.attrs.rowspan;
|
|
82979
83938
|
return Math.max(anchorBottom, headBottom) == this.$headCell.node(-1).childCount;
|
|
82980
83939
|
}
|
|
82981
|
-
// Returns the smallest column selection that covers the given anchor
|
|
82982
|
-
// and head cell.
|
|
82983
83940
|
static colSelection($anchorCell, $headCell = $anchorCell) {
|
|
82984
83941
|
const table = $anchorCell.node(-1);
|
|
82985
83942
|
const map22 = TableMap.get(table);
|
|
@@ -82988,24 +83945,14 @@ var CellSelection = class _CellSelection extends Selection {
|
|
|
82988
83945
|
const headRect = map22.findCell($headCell.pos - tableStart);
|
|
82989
83946
|
const doc2 = $anchorCell.node(0);
|
|
82990
83947
|
if (anchorRect.top <= headRect.top) {
|
|
82991
|
-
if (anchorRect.top > 0)
|
|
82992
|
-
|
|
82993
|
-
if (headRect.bottom < map22.height)
|
|
82994
|
-
$headCell = doc2.resolve(
|
|
82995
|
-
tableStart + map22.map[map22.width * (map22.height - 1) + headRect.right - 1]
|
|
82996
|
-
);
|
|
83948
|
+
if (anchorRect.top > 0) $anchorCell = doc2.resolve(tableStart + map22.map[anchorRect.left]);
|
|
83949
|
+
if (headRect.bottom < map22.height) $headCell = doc2.resolve(tableStart + map22.map[map22.width * (map22.height - 1) + headRect.right - 1]);
|
|
82997
83950
|
} else {
|
|
82998
|
-
if (headRect.top > 0)
|
|
82999
|
-
|
|
83000
|
-
if (anchorRect.bottom < map22.height)
|
|
83001
|
-
$anchorCell = doc2.resolve(
|
|
83002
|
-
tableStart + map22.map[map22.width * (map22.height - 1) + anchorRect.right - 1]
|
|
83003
|
-
);
|
|
83951
|
+
if (headRect.top > 0) $headCell = doc2.resolve(tableStart + map22.map[headRect.left]);
|
|
83952
|
+
if (anchorRect.bottom < map22.height) $anchorCell = doc2.resolve(tableStart + map22.map[map22.width * (map22.height - 1) + anchorRect.right - 1]);
|
|
83004
83953
|
}
|
|
83005
|
-
return new
|
|
83954
|
+
return new CellSelection2($anchorCell, $headCell);
|
|
83006
83955
|
}
|
|
83007
|
-
// True if this selection goes all the way from the left to the
|
|
83008
|
-
// right of the table.
|
|
83009
83956
|
isRowSelection() {
|
|
83010
83957
|
const table = this.$anchorCell.node(-1);
|
|
83011
83958
|
const map22 = TableMap.get(table);
|
|
@@ -83018,10 +83965,8 @@ var CellSelection = class _CellSelection extends Selection {
|
|
|
83018
83965
|
return Math.max(anchorRight, headRight) == map22.width;
|
|
83019
83966
|
}
|
|
83020
83967
|
eq(other) {
|
|
83021
|
-
return other instanceof
|
|
83968
|
+
return other instanceof CellSelection2 && other.$anchorCell.pos == this.$anchorCell.pos && other.$headCell.pos == this.$headCell.pos;
|
|
83022
83969
|
}
|
|
83023
|
-
// Returns the smallest row selection that covers the given anchor
|
|
83024
|
-
// and head cell.
|
|
83025
83970
|
static rowSelection($anchorCell, $headCell = $anchorCell) {
|
|
83026
83971
|
const table = $anchorCell.node(-1);
|
|
83027
83972
|
const map22 = TableMap.get(table);
|
|
@@ -83030,23 +83975,13 @@ var CellSelection = class _CellSelection extends Selection {
|
|
|
83030
83975
|
const headRect = map22.findCell($headCell.pos - tableStart);
|
|
83031
83976
|
const doc2 = $anchorCell.node(0);
|
|
83032
83977
|
if (anchorRect.left <= headRect.left) {
|
|
83033
|
-
if (anchorRect.left > 0)
|
|
83034
|
-
|
|
83035
|
-
tableStart + map22.map[anchorRect.top * map22.width]
|
|
83036
|
-
);
|
|
83037
|
-
if (headRect.right < map22.width)
|
|
83038
|
-
$headCell = doc2.resolve(
|
|
83039
|
-
tableStart + map22.map[map22.width * (headRect.top + 1) - 1]
|
|
83040
|
-
);
|
|
83978
|
+
if (anchorRect.left > 0) $anchorCell = doc2.resolve(tableStart + map22.map[anchorRect.top * map22.width]);
|
|
83979
|
+
if (headRect.right < map22.width) $headCell = doc2.resolve(tableStart + map22.map[map22.width * (headRect.top + 1) - 1]);
|
|
83041
83980
|
} else {
|
|
83042
|
-
if (headRect.left > 0)
|
|
83043
|
-
|
|
83044
|
-
if (anchorRect.right < map22.width)
|
|
83045
|
-
$anchorCell = doc2.resolve(
|
|
83046
|
-
tableStart + map22.map[map22.width * (anchorRect.top + 1) - 1]
|
|
83047
|
-
);
|
|
83981
|
+
if (headRect.left > 0) $headCell = doc2.resolve(tableStart + map22.map[headRect.top * map22.width]);
|
|
83982
|
+
if (anchorRect.right < map22.width) $anchorCell = doc2.resolve(tableStart + map22.map[map22.width * (anchorRect.top + 1) - 1]);
|
|
83048
83983
|
}
|
|
83049
|
-
return new
|
|
83984
|
+
return new CellSelection2($anchorCell, $headCell);
|
|
83050
83985
|
}
|
|
83051
83986
|
toJSON() {
|
|
83052
83987
|
return {
|
|
@@ -83056,10 +83991,10 @@ var CellSelection = class _CellSelection extends Selection {
|
|
|
83056
83991
|
};
|
|
83057
83992
|
}
|
|
83058
83993
|
static fromJSON(doc2, json) {
|
|
83059
|
-
return new
|
|
83994
|
+
return new CellSelection2(doc2.resolve(json.anchor), doc2.resolve(json.head));
|
|
83060
83995
|
}
|
|
83061
83996
|
static create(doc2, anchorCell, headCell = anchorCell) {
|
|
83062
|
-
return new
|
|
83997
|
+
return new CellSelection2(doc2.resolve(anchorCell), doc2.resolve(headCell));
|
|
83063
83998
|
}
|
|
83064
83999
|
getBookmark() {
|
|
83065
84000
|
return new CellBookmark(this.$anchorCell.pos, this.$headCell.pos);
|
|
@@ -83067,18 +84002,17 @@ var CellSelection = class _CellSelection extends Selection {
|
|
|
83067
84002
|
};
|
|
83068
84003
|
CellSelection.prototype.visible = false;
|
|
83069
84004
|
Selection.jsonID("cell", CellSelection);
|
|
83070
|
-
var CellBookmark = class
|
|
84005
|
+
var CellBookmark = class CellBookmark2 {
|
|
83071
84006
|
constructor(anchor, head) {
|
|
83072
84007
|
this.anchor = anchor;
|
|
83073
84008
|
this.head = head;
|
|
83074
84009
|
}
|
|
83075
84010
|
map(mapping) {
|
|
83076
|
-
return new
|
|
84011
|
+
return new CellBookmark2(mapping.map(this.anchor), mapping.map(this.head));
|
|
83077
84012
|
}
|
|
83078
84013
|
resolve(doc2) {
|
|
83079
84014
|
const $anchorCell = doc2.resolve(this.anchor), $headCell = doc2.resolve(this.head);
|
|
83080
|
-
if ($anchorCell.parent.type.spec.tableRole == "row" && $headCell.parent.type.spec.tableRole == "row" && $anchorCell.index() < $anchorCell.parent.childCount && $headCell.index() < $headCell.parent.childCount && inSameTable($anchorCell, $headCell))
|
|
83081
|
-
return new CellSelection($anchorCell, $headCell);
|
|
84015
|
+
if ($anchorCell.parent.type.spec.tableRole == "row" && $headCell.parent.type.spec.tableRole == "row" && $anchorCell.index() < $anchorCell.parent.childCount && $headCell.index() < $headCell.parent.childCount && inSameTable($anchorCell, $headCell)) return new CellSelection($anchorCell, $headCell);
|
|
83082
84016
|
else return Selection.near($headCell, 1);
|
|
83083
84017
|
}
|
|
83084
84018
|
};
|
|
@@ -83086,9 +84020,7 @@ function drawCellSelection(state2) {
|
|
|
83086
84020
|
if (!(state2.selection instanceof CellSelection)) return null;
|
|
83087
84021
|
const cells = [];
|
|
83088
84022
|
state2.selection.forEachCell((node, pos) => {
|
|
83089
|
-
cells.push(
|
|
83090
|
-
Decoration.node(pos, pos + node.nodeSize, { class: "selectedCell" })
|
|
83091
|
-
);
|
|
84023
|
+
cells.push(Decoration.node(pos, pos + node.nodeSize, { class: "selectedCell" }));
|
|
83092
84024
|
});
|
|
83093
84025
|
return DecorationSet.create(state2.doc, cells);
|
|
83094
84026
|
}
|
|
@@ -83097,10 +84029,8 @@ function isCellBoundarySelection({ $from, $to }) {
|
|
|
83097
84029
|
let afterFrom = $from.pos;
|
|
83098
84030
|
let beforeTo = $to.pos;
|
|
83099
84031
|
let depth = $from.depth;
|
|
83100
|
-
for (; depth >= 0; depth--, afterFrom++)
|
|
83101
|
-
|
|
83102
|
-
for (let d2 = $to.depth; d2 >= 0; d2--, beforeTo--)
|
|
83103
|
-
if ($to.before(d2 + 1) > $to.start(d2)) break;
|
|
84032
|
+
for (; depth >= 0; depth--, afterFrom++) if ($from.after(depth + 1) < $from.end(depth)) break;
|
|
84033
|
+
for (let d2 = $to.depth; d2 >= 0; d2--, beforeTo--) if ($to.before(d2 + 1) > $to.start(d2)) break;
|
|
83104
84034
|
return afterFrom == beforeTo && /row|table/.test($from.node(depth).type.spec.tableRole);
|
|
83105
84035
|
}
|
|
83106
84036
|
function isTextSelectionAcrossCells({ $from, $to }) {
|
|
@@ -83128,9 +84058,8 @@ function normalizeSelection(state2, tr, allowTableNodeSelection) {
|
|
|
83128
84058
|
let normalize2;
|
|
83129
84059
|
let role;
|
|
83130
84060
|
if (sel instanceof NodeSelection && (role = sel.node.type.spec.tableRole)) {
|
|
83131
|
-
if (role == "cell" || role == "header_cell")
|
|
83132
|
-
|
|
83133
|
-
} else if (role == "row") {
|
|
84061
|
+
if (role == "cell" || role == "header_cell") normalize2 = CellSelection.create(doc2, sel.from);
|
|
84062
|
+
else if (role == "row") {
|
|
83134
84063
|
const $cell = doc2.resolve(sel.from + 1);
|
|
83135
84064
|
normalize2 = CellSelection.rowSelection($cell, $cell);
|
|
83136
84065
|
} else if (!allowTableNodeSelection) {
|
|
@@ -83139,29 +84068,23 @@ function normalizeSelection(state2, tr, allowTableNodeSelection) {
|
|
|
83139
84068
|
const lastCell = start2 + map22.map[map22.width * map22.height - 1];
|
|
83140
84069
|
normalize2 = CellSelection.create(doc2, start2 + 1, lastCell);
|
|
83141
84070
|
}
|
|
83142
|
-
} else if (sel instanceof TextSelection$1 && isCellBoundarySelection(sel))
|
|
83143
|
-
|
|
83144
|
-
} else if (sel instanceof TextSelection$1 && isTextSelectionAcrossCells(sel)) {
|
|
83145
|
-
normalize2 = TextSelection$1.create(doc2, sel.$from.start(), sel.$from.end());
|
|
83146
|
-
}
|
|
84071
|
+
} else if (sel instanceof TextSelection$1 && isCellBoundarySelection(sel)) normalize2 = TextSelection$1.create(doc2, sel.from);
|
|
84072
|
+
else if (sel instanceof TextSelection$1 && isTextSelectionAcrossCells(sel)) normalize2 = TextSelection$1.create(doc2, sel.$from.start(), sel.$from.end());
|
|
83147
84073
|
if (normalize2) (tr || (tr = state2.tr)).setSelection(normalize2);
|
|
83148
84074
|
return tr;
|
|
83149
84075
|
}
|
|
83150
|
-
|
|
84076
|
+
const fixTablesKey = new PluginKey("fix-tables");
|
|
83151
84077
|
function changedDescendants(old, cur, offset2, f2) {
|
|
83152
84078
|
const oldSize = old.childCount, curSize = cur.childCount;
|
|
83153
84079
|
outer: for (let i = 0, j2 = 0; i < curSize; i++) {
|
|
83154
84080
|
const child = cur.child(i);
|
|
83155
|
-
for (let scan = j2, e = Math.min(oldSize, i + 3); scan < e; scan++) {
|
|
83156
|
-
|
|
83157
|
-
|
|
83158
|
-
|
|
83159
|
-
continue outer;
|
|
83160
|
-
}
|
|
84081
|
+
for (let scan = j2, e = Math.min(oldSize, i + 3); scan < e; scan++) if (old.child(scan) == child) {
|
|
84082
|
+
j2 = scan + 1;
|
|
84083
|
+
offset2 += child.nodeSize;
|
|
84084
|
+
continue outer;
|
|
83161
84085
|
}
|
|
83162
84086
|
f2(child, offset2);
|
|
83163
|
-
if (j2 < oldSize && old.child(j2).sameMarkup(child))
|
|
83164
|
-
changedDescendants(old.child(j2), child, offset2 + 1, f2);
|
|
84087
|
+
if (j2 < oldSize && old.child(j2).sameMarkup(child)) changedDescendants(old.child(j2), child, offset2 + 1, f2);
|
|
83165
84088
|
else child.nodesBetween(0, child.content.size, f2, offset2 + 1);
|
|
83166
84089
|
offset2 += child.nodeSize;
|
|
83167
84090
|
}
|
|
@@ -83169,12 +84092,10 @@ function changedDescendants(old, cur, offset2, f2) {
|
|
|
83169
84092
|
function fixTables(state2, oldState) {
|
|
83170
84093
|
let tr;
|
|
83171
84094
|
const check = (node, pos) => {
|
|
83172
|
-
if (node.type.spec.tableRole == "table")
|
|
83173
|
-
tr = fixTable(state2, node, pos, tr);
|
|
84095
|
+
if (node.type.spec.tableRole == "table") tr = fixTable(state2, node, pos, tr);
|
|
83174
84096
|
};
|
|
83175
84097
|
if (!oldState) state2.doc.descendants(check);
|
|
83176
|
-
else if (oldState.doc != state2.doc)
|
|
83177
|
-
changedDescendants(oldState.doc, state2.doc, 0, check);
|
|
84098
|
+
else if (oldState.doc != state2.doc) changedDescendants(oldState.doc, state2.doc, 0, check);
|
|
83178
84099
|
return tr;
|
|
83179
84100
|
}
|
|
83180
84101
|
function fixTable(state2, table, tablePos, tr) {
|
|
@@ -83190,14 +84111,9 @@ function fixTable(state2, table, tablePos, tr) {
|
|
|
83190
84111
|
if (!cell) continue;
|
|
83191
84112
|
const attrs = cell.attrs;
|
|
83192
84113
|
for (let j2 = 0; j2 < attrs.rowspan; j2++) mustAdd[prob.row + j2] += prob.n;
|
|
83193
|
-
tr.setNodeMarkup(
|
|
83194
|
-
|
|
83195
|
-
|
|
83196
|
-
removeColSpan(attrs, attrs.colspan - prob.n, prob.n)
|
|
83197
|
-
);
|
|
83198
|
-
} else if (prob.type == "missing") {
|
|
83199
|
-
mustAdd[prob.row] += prob.n;
|
|
83200
|
-
} else if (prob.type == "overlong_rowspan") {
|
|
84114
|
+
tr.setNodeMarkup(tr.mapping.map(tablePos + 1 + prob.pos), null, removeColSpan(attrs, attrs.colspan - prob.n, prob.n));
|
|
84115
|
+
} else if (prob.type == "missing") mustAdd[prob.row] += prob.n;
|
|
84116
|
+
else if (prob.type == "overlong_rowspan") {
|
|
83201
84117
|
const cell = table.nodeAt(prob.pos);
|
|
83202
84118
|
if (!cell) continue;
|
|
83203
84119
|
tr.setNodeMarkup(tr.mapping.map(tablePos + 1 + prob.pos), null, {
|
|
@@ -83217,20 +84133,17 @@ function fixTable(state2, table, tablePos, tr) {
|
|
|
83217
84133
|
}
|
|
83218
84134
|
}
|
|
83219
84135
|
let first2, last;
|
|
83220
|
-
for (let i = 0; i < mustAdd.length; i++)
|
|
83221
|
-
if (
|
|
83222
|
-
|
|
83223
|
-
|
|
83224
|
-
}
|
|
84136
|
+
for (let i = 0; i < mustAdd.length; i++) if (mustAdd[i]) {
|
|
84137
|
+
if (first2 == null) first2 = i;
|
|
84138
|
+
last = i;
|
|
84139
|
+
}
|
|
83225
84140
|
for (let i = 0, pos = tablePos + 1; i < map22.height; i++) {
|
|
83226
84141
|
const row = table.child(i);
|
|
83227
84142
|
const end2 = pos + row.nodeSize;
|
|
83228
84143
|
const add = mustAdd[i];
|
|
83229
84144
|
if (add > 0) {
|
|
83230
84145
|
let role = "cell";
|
|
83231
|
-
if (row.firstChild)
|
|
83232
|
-
role = row.firstChild.type.spec.tableRole;
|
|
83233
|
-
}
|
|
84146
|
+
if (row.firstChild) role = row.firstChild.type.spec.tableRole;
|
|
83234
84147
|
const nodes = [];
|
|
83235
84148
|
for (let j2 = 0; j2 < add; j2++) {
|
|
83236
84149
|
const node = tableNodeTypes(state2.schema)[role].createAndFill();
|
|
@@ -83249,27 +84162,22 @@ function selectedRect(state2) {
|
|
|
83249
84162
|
const table = $pos.node(-1);
|
|
83250
84163
|
const tableStart = $pos.start(-1);
|
|
83251
84164
|
const map22 = TableMap.get(table);
|
|
83252
|
-
|
|
83253
|
-
sel.$anchorCell.pos - tableStart,
|
|
83254
|
-
|
|
83255
|
-
|
|
83256
|
-
|
|
84165
|
+
return {
|
|
84166
|
+
...sel instanceof CellSelection ? map22.rectBetween(sel.$anchorCell.pos - tableStart, sel.$headCell.pos - tableStart) : map22.findCell($pos.pos - tableStart),
|
|
84167
|
+
tableStart,
|
|
84168
|
+
map: map22,
|
|
84169
|
+
table
|
|
84170
|
+
};
|
|
83257
84171
|
}
|
|
83258
84172
|
function addColumn(tr, { map: map22, tableStart, table }, col) {
|
|
83259
84173
|
let refColumn = col > 0 ? -1 : 0;
|
|
83260
|
-
if (columnIsHeader(map22, table, col + refColumn))
|
|
83261
|
-
refColumn = col == 0 || col == map22.width ? null : 0;
|
|
83262
|
-
}
|
|
84174
|
+
if (columnIsHeader(map22, table, col + refColumn)) refColumn = col == 0 || col == map22.width ? null : 0;
|
|
83263
84175
|
for (let row = 0; row < map22.height; row++) {
|
|
83264
84176
|
const index2 = row * map22.width + col;
|
|
83265
84177
|
if (col > 0 && col < map22.width && map22.map[index2 - 1] == map22.map[index2]) {
|
|
83266
84178
|
const pos = map22.map[index2];
|
|
83267
84179
|
const cell = table.nodeAt(pos);
|
|
83268
|
-
tr.setNodeMarkup(
|
|
83269
|
-
tr.mapping.map(tableStart + pos),
|
|
83270
|
-
null,
|
|
83271
|
-
addColSpan(cell.attrs, col - map22.colCount(pos))
|
|
83272
|
-
);
|
|
84180
|
+
tr.setNodeMarkup(tr.mapping.map(tableStart + pos), null, addColSpan(cell.attrs, col - map22.colCount(pos)));
|
|
83273
84181
|
row += cell.attrs.rowspan - 1;
|
|
83274
84182
|
} else {
|
|
83275
84183
|
const type2 = refColumn == null ? tableNodeTypes(table.type.schema).cell : table.nodeAt(map22.map[index2 + refColumn]).type;
|
|
@@ -83302,13 +84210,8 @@ function removeColumn(tr, { map: map22, table, tableStart }, col) {
|
|
|
83302
84210
|
const pos = map22.map[index2];
|
|
83303
84211
|
const cell = table.nodeAt(pos);
|
|
83304
84212
|
const attrs = cell.attrs;
|
|
83305
|
-
if (col > 0 && map22.map[index2 - 1] == pos || col < map22.width - 1 && map22.map[index2 + 1] == pos)
|
|
83306
|
-
|
|
83307
|
-
tr.mapping.slice(mapStart).map(tableStart + pos),
|
|
83308
|
-
null,
|
|
83309
|
-
removeColSpan(attrs, col - map22.colCount(pos))
|
|
83310
|
-
);
|
|
83311
|
-
} else {
|
|
84213
|
+
if (col > 0 && map22.map[index2 - 1] == pos || col < map22.width - 1 && map22.map[index2 + 1] == pos) tr.setNodeMarkup(tr.mapping.slice(mapStart).map(tableStart + pos), null, removeColSpan(attrs, col - map22.colCount(pos)));
|
|
84214
|
+
else {
|
|
83312
84215
|
const start2 = tr.mapping.slice(mapStart).map(tableStart + pos);
|
|
83313
84216
|
tr.delete(start2, start2 + cell.nodeSize);
|
|
83314
84217
|
}
|
|
@@ -83325,9 +84228,7 @@ function deleteColumn(state2, dispatch) {
|
|
|
83325
84228
|
removeColumn(tr, rect, i);
|
|
83326
84229
|
if (i == rect.left) break;
|
|
83327
84230
|
const table = rect.tableStart ? tr.doc.nodeAt(rect.tableStart - 1) : tr.doc;
|
|
83328
|
-
if (!table)
|
|
83329
|
-
throw RangeError("No table found");
|
|
83330
|
-
}
|
|
84231
|
+
if (!table) throw new RangeError("No table found");
|
|
83331
84232
|
rect.table = table;
|
|
83332
84233
|
rect.map = TableMap.get(table);
|
|
83333
84234
|
}
|
|
@@ -83336,35 +84237,30 @@ function deleteColumn(state2, dispatch) {
|
|
|
83336
84237
|
return true;
|
|
83337
84238
|
}
|
|
83338
84239
|
function rowIsHeader(map22, table, row) {
|
|
83339
|
-
var
|
|
84240
|
+
var _table$nodeAt;
|
|
83340
84241
|
const headerCell = tableNodeTypes(table.type.schema).header_cell;
|
|
83341
|
-
for (let col = 0; col < map22.width; col++)
|
|
83342
|
-
if (((_a2 = table.nodeAt(map22.map[col + row * map22.width])) == null ? void 0 : _a2.type) != headerCell)
|
|
83343
|
-
return false;
|
|
84242
|
+
for (let col = 0; col < map22.width; col++) if (((_table$nodeAt = table.nodeAt(map22.map[col + row * map22.width])) === null || _table$nodeAt === void 0 ? void 0 : _table$nodeAt.type) != headerCell) return false;
|
|
83344
84243
|
return true;
|
|
83345
84244
|
}
|
|
83346
84245
|
function addRow(tr, { map: map22, tableStart, table }, row) {
|
|
83347
|
-
var _a2;
|
|
83348
84246
|
let rowPos = tableStart;
|
|
83349
84247
|
for (let i = 0; i < row; i++) rowPos += table.child(i).nodeSize;
|
|
83350
84248
|
const cells = [];
|
|
83351
84249
|
let refRow = row > 0 ? -1 : 0;
|
|
83352
|
-
if (rowIsHeader(map22, table, row + refRow))
|
|
83353
|
-
|
|
83354
|
-
|
|
83355
|
-
|
|
83356
|
-
|
|
83357
|
-
|
|
83358
|
-
|
|
83359
|
-
|
|
83360
|
-
|
|
83361
|
-
|
|
83362
|
-
|
|
83363
|
-
|
|
83364
|
-
|
|
83365
|
-
|
|
83366
|
-
if (node) cells.push(node);
|
|
83367
|
-
}
|
|
84250
|
+
if (rowIsHeader(map22, table, row + refRow)) refRow = row == 0 || row == map22.height ? null : 0;
|
|
84251
|
+
for (let col = 0, index2 = map22.width * row; col < map22.width; col++, index2++) if (row > 0 && row < map22.height && map22.map[index2] == map22.map[index2 - map22.width]) {
|
|
84252
|
+
const pos = map22.map[index2];
|
|
84253
|
+
const attrs = table.nodeAt(pos).attrs;
|
|
84254
|
+
tr.setNodeMarkup(tableStart + pos, null, {
|
|
84255
|
+
...attrs,
|
|
84256
|
+
rowspan: attrs.rowspan + 1
|
|
84257
|
+
});
|
|
84258
|
+
col += attrs.colspan - 1;
|
|
84259
|
+
} else {
|
|
84260
|
+
var _table$nodeAt2;
|
|
84261
|
+
const type2 = refRow == null ? tableNodeTypes(table.type.schema).cell : (_table$nodeAt2 = table.nodeAt(map22.map[index2 + refRow * map22.width])) === null || _table$nodeAt2 === void 0 ? void 0 : _table$nodeAt2.type;
|
|
84262
|
+
const node = type2 === null || type2 === void 0 ? void 0 : type2.createAndFill();
|
|
84263
|
+
if (node) cells.push(node);
|
|
83368
84264
|
}
|
|
83369
84265
|
tr.insert(rowPos, tableNodeTypes(table.type.schema).row.create(null, cells));
|
|
83370
84266
|
return tr;
|
|
@@ -83406,10 +84302,10 @@ function removeRow(tr, { map: map22, table, tableStart }, row) {
|
|
|
83406
84302
|
} else if (row < map22.height && pos == map22.map[index2 + map22.width]) {
|
|
83407
84303
|
const cell = table.nodeAt(pos);
|
|
83408
84304
|
const attrs = cell.attrs;
|
|
83409
|
-
const copy2 = cell.type.create(
|
|
83410
|
-
|
|
83411
|
-
cell.
|
|
83412
|
-
);
|
|
84305
|
+
const copy2 = cell.type.create({
|
|
84306
|
+
...attrs,
|
|
84307
|
+
rowspan: cell.attrs.rowspan - 1
|
|
84308
|
+
}, cell.content);
|
|
83413
84309
|
const newPos = map22.positionAt(row + 1, col, table);
|
|
83414
84310
|
tr.insert(tr.mapping.slice(mapFrom).map(tableStart + newPos), copy2);
|
|
83415
84311
|
col += attrs.colspan - 1;
|
|
@@ -83425,9 +84321,7 @@ function deleteRow(state2, dispatch) {
|
|
|
83425
84321
|
removeRow(tr, rect, i);
|
|
83426
84322
|
if (i == rect.top) break;
|
|
83427
84323
|
const table = rect.tableStart ? tr.doc.nodeAt(rect.tableStart - 1) : tr.doc;
|
|
83428
|
-
if (!table)
|
|
83429
|
-
throw RangeError("No table found");
|
|
83430
|
-
}
|
|
84324
|
+
if (!table) throw new RangeError("No table found");
|
|
83431
84325
|
rect.table = table;
|
|
83432
84326
|
rect.map = TableMap.get(rect.table);
|
|
83433
84327
|
}
|
|
@@ -83443,14 +84337,12 @@ function cellsOverlapRectangle({ width, height, map: map22 }, rect) {
|
|
|
83443
84337
|
let indexTop = rect.top * width + rect.left, indexLeft = indexTop;
|
|
83444
84338
|
let indexBottom = (rect.bottom - 1) * width + rect.left, indexRight = indexTop + (rect.right - rect.left - 1);
|
|
83445
84339
|
for (let i = rect.top; i < rect.bottom; i++) {
|
|
83446
|
-
if (rect.left > 0 && map22[indexLeft] == map22[indexLeft - 1] || rect.right < width && map22[indexRight] == map22[indexRight + 1])
|
|
83447
|
-
return true;
|
|
84340
|
+
if (rect.left > 0 && map22[indexLeft] == map22[indexLeft - 1] || rect.right < width && map22[indexRight] == map22[indexRight + 1]) return true;
|
|
83448
84341
|
indexLeft += width;
|
|
83449
84342
|
indexRight += width;
|
|
83450
84343
|
}
|
|
83451
84344
|
for (let i = rect.left; i < rect.right; i++) {
|
|
83452
|
-
if (rect.top > 0 && map22[indexTop] == map22[indexTop - width] || rect.bottom < height && map22[indexBottom] == map22[indexBottom + width])
|
|
83453
|
-
return true;
|
|
84345
|
+
if (rect.top > 0 && map22[indexTop] == map22[indexTop - width] || rect.bottom < height && map22[indexBottom] == map22[indexBottom + width]) return true;
|
|
83454
84346
|
indexTop++;
|
|
83455
84347
|
indexBottom++;
|
|
83456
84348
|
}
|
|
@@ -83458,8 +84350,7 @@ function cellsOverlapRectangle({ width, height, map: map22 }, rect) {
|
|
|
83458
84350
|
}
|
|
83459
84351
|
function mergeCells(state2, dispatch) {
|
|
83460
84352
|
const sel = state2.selection;
|
|
83461
|
-
if (!(sel instanceof CellSelection) || sel.$anchorCell.pos == sel.$headCell.pos)
|
|
83462
|
-
return false;
|
|
84353
|
+
if (!(sel instanceof CellSelection) || sel.$anchorCell.pos == sel.$headCell.pos) return false;
|
|
83463
84354
|
const rect = selectedRect(state2), { map: map22 } = rect;
|
|
83464
84355
|
if (cellsOverlapRectangle(map22, rect)) return false;
|
|
83465
84356
|
if (dispatch) {
|
|
@@ -83468,41 +84359,31 @@ function mergeCells(state2, dispatch) {
|
|
|
83468
84359
|
let content = Fragment.empty;
|
|
83469
84360
|
let mergedPos;
|
|
83470
84361
|
let mergedCell;
|
|
83471
|
-
for (let row = rect.top; row < rect.bottom; row++) {
|
|
83472
|
-
|
|
83473
|
-
|
|
83474
|
-
|
|
83475
|
-
|
|
83476
|
-
|
|
83477
|
-
|
|
83478
|
-
|
|
83479
|
-
|
|
83480
|
-
|
|
83481
|
-
|
|
83482
|
-
|
|
83483
|
-
tr.delete(mapped, mapped + cell.nodeSize);
|
|
83484
|
-
}
|
|
84362
|
+
for (let row = rect.top; row < rect.bottom; row++) for (let col = rect.left; col < rect.right; col++) {
|
|
84363
|
+
const cellPos = map22.map[row * map22.width + col];
|
|
84364
|
+
const cell = rect.table.nodeAt(cellPos);
|
|
84365
|
+
if (seen[cellPos] || !cell) continue;
|
|
84366
|
+
seen[cellPos] = true;
|
|
84367
|
+
if (mergedPos == null) {
|
|
84368
|
+
mergedPos = cellPos;
|
|
84369
|
+
mergedCell = cell;
|
|
84370
|
+
} else {
|
|
84371
|
+
if (!isEmpty(cell)) content = content.append(cell.content);
|
|
84372
|
+
const mapped = tr.mapping.map(cellPos + rect.tableStart);
|
|
84373
|
+
tr.delete(mapped, mapped + cell.nodeSize);
|
|
83485
84374
|
}
|
|
83486
84375
|
}
|
|
83487
|
-
if (mergedPos == null || mergedCell == null)
|
|
83488
|
-
return true;
|
|
83489
|
-
}
|
|
84376
|
+
if (mergedPos == null || mergedCell == null) return true;
|
|
83490
84377
|
tr.setNodeMarkup(mergedPos + rect.tableStart, null, {
|
|
83491
|
-
...addColSpan(
|
|
83492
|
-
mergedCell.attrs,
|
|
83493
|
-
mergedCell.attrs.colspan,
|
|
83494
|
-
rect.right - rect.left - mergedCell.attrs.colspan
|
|
83495
|
-
),
|
|
84378
|
+
...addColSpan(mergedCell.attrs, mergedCell.attrs.colspan, rect.right - rect.left - mergedCell.attrs.colspan),
|
|
83496
84379
|
rowspan: rect.bottom - rect.top
|
|
83497
84380
|
});
|
|
83498
|
-
if (content.size) {
|
|
84381
|
+
if (content.size > 0) {
|
|
83499
84382
|
const end2 = mergedPos + 1 + mergedCell.content.size;
|
|
83500
84383
|
const start2 = isEmpty(mergedCell) ? mergedPos + 1 : end2;
|
|
83501
84384
|
tr.replaceWith(start2 + rect.tableStart, end2 + rect.tableStart, content);
|
|
83502
84385
|
}
|
|
83503
|
-
tr.setSelection(
|
|
83504
|
-
new CellSelection(tr.doc.resolve(mergedPos + rect.tableStart))
|
|
83505
|
-
);
|
|
84386
|
+
tr.setSelection(new CellSelection(tr.doc.resolve(mergedPos + rect.tableStart)));
|
|
83506
84387
|
dispatch(tr);
|
|
83507
84388
|
}
|
|
83508
84389
|
return true;
|
|
@@ -83515,63 +84396,57 @@ function splitCell(state2, dispatch) {
|
|
|
83515
84396
|
}
|
|
83516
84397
|
function splitCellWithType(getCellType2) {
|
|
83517
84398
|
return (state2, dispatch) => {
|
|
83518
|
-
var _a2;
|
|
83519
84399
|
const sel = state2.selection;
|
|
83520
84400
|
let cellNode;
|
|
83521
84401
|
let cellPos;
|
|
83522
84402
|
if (!(sel instanceof CellSelection)) {
|
|
84403
|
+
var _cellAround;
|
|
83523
84404
|
cellNode = cellWrapping$1(sel.$from);
|
|
83524
84405
|
if (!cellNode) return false;
|
|
83525
|
-
cellPos = (
|
|
84406
|
+
cellPos = (_cellAround = cellAround$1(sel.$from)) === null || _cellAround === void 0 ? void 0 : _cellAround.pos;
|
|
83526
84407
|
} else {
|
|
83527
84408
|
if (sel.$anchorCell.pos != sel.$headCell.pos) return false;
|
|
83528
84409
|
cellNode = sel.$anchorCell.nodeAfter;
|
|
83529
84410
|
cellPos = sel.$anchorCell.pos;
|
|
83530
84411
|
}
|
|
83531
|
-
if (cellNode == null || cellPos == null)
|
|
83532
|
-
|
|
83533
|
-
}
|
|
83534
|
-
if (cellNode.attrs.colspan == 1 && cellNode.attrs.rowspan == 1) {
|
|
83535
|
-
return false;
|
|
83536
|
-
}
|
|
84412
|
+
if (cellNode == null || cellPos == null) return false;
|
|
84413
|
+
if (cellNode.attrs.colspan == 1 && cellNode.attrs.rowspan == 1) return false;
|
|
83537
84414
|
if (dispatch) {
|
|
83538
84415
|
let baseAttrs = cellNode.attrs;
|
|
83539
84416
|
const attrs = [];
|
|
83540
84417
|
const colwidth = baseAttrs.colwidth;
|
|
83541
|
-
if (baseAttrs.rowspan > 1) baseAttrs = {
|
|
83542
|
-
|
|
84418
|
+
if (baseAttrs.rowspan > 1) baseAttrs = {
|
|
84419
|
+
...baseAttrs,
|
|
84420
|
+
rowspan: 1
|
|
84421
|
+
};
|
|
84422
|
+
if (baseAttrs.colspan > 1) baseAttrs = {
|
|
84423
|
+
...baseAttrs,
|
|
84424
|
+
colspan: 1
|
|
84425
|
+
};
|
|
83543
84426
|
const rect = selectedRect(state2), tr = state2.tr;
|
|
83544
|
-
for (let i = 0; i < rect.right - rect.left; i++)
|
|
83545
|
-
|
|
83546
|
-
|
|
83547
|
-
|
|
83548
|
-
colwidth: colwidth && colwidth[i] ? [colwidth[i]] : null
|
|
83549
|
-
} : baseAttrs
|
|
83550
|
-
);
|
|
84427
|
+
for (let i = 0; i < rect.right - rect.left; i++) attrs.push(colwidth ? {
|
|
84428
|
+
...baseAttrs,
|
|
84429
|
+
colwidth: colwidth && colwidth[i] ? [colwidth[i]] : null
|
|
84430
|
+
} : baseAttrs);
|
|
83551
84431
|
let lastCell;
|
|
83552
84432
|
for (let row = rect.top; row < rect.bottom; row++) {
|
|
83553
84433
|
let pos = rect.map.positionAt(row, rect.left, rect.table);
|
|
83554
84434
|
if (row == rect.top) pos += cellNode.nodeSize;
|
|
83555
84435
|
for (let col = rect.left, i = 0; col < rect.right; col++, i++) {
|
|
83556
84436
|
if (col == rect.left && row == rect.top) continue;
|
|
83557
|
-
tr.insert(
|
|
83558
|
-
|
|
83559
|
-
|
|
83560
|
-
|
|
83561
|
-
|
|
83562
|
-
|
|
83563
|
-
|
|
83564
|
-
|
|
83565
|
-
|
|
83566
|
-
|
|
83567
|
-
|
|
83568
|
-
|
|
83569
|
-
|
|
83570
|
-
new CellSelection(
|
|
83571
|
-
tr.doc.resolve(sel.$anchorCell.pos),
|
|
83572
|
-
lastCell ? tr.doc.resolve(lastCell) : void 0
|
|
83573
|
-
)
|
|
83574
|
-
);
|
|
84437
|
+
tr.insert(lastCell = tr.mapping.map(pos + rect.tableStart, 1), getCellType2({
|
|
84438
|
+
node: cellNode,
|
|
84439
|
+
row,
|
|
84440
|
+
col
|
|
84441
|
+
}).createAndFill(attrs[i]));
|
|
84442
|
+
}
|
|
84443
|
+
}
|
|
84444
|
+
tr.setNodeMarkup(cellPos, getCellType2({
|
|
84445
|
+
node: cellNode,
|
|
84446
|
+
row: rect.top,
|
|
84447
|
+
col: rect.left
|
|
84448
|
+
}), attrs[0]);
|
|
84449
|
+
if (sel instanceof CellSelection) tr.setSelection(new CellSelection(tr.doc.resolve(sel.$anchorCell.pos), lastCell ? tr.doc.resolve(lastCell) : void 0));
|
|
83575
84450
|
dispatch(tr);
|
|
83576
84451
|
}
|
|
83577
84452
|
return true;
|
|
@@ -83584,19 +84459,16 @@ function setCellAttr(name, value) {
|
|
|
83584
84459
|
if ($cell.nodeAfter.attrs[name] === value) return false;
|
|
83585
84460
|
if (dispatch) {
|
|
83586
84461
|
const tr = state2.tr;
|
|
83587
|
-
if (state2.selection instanceof CellSelection)
|
|
83588
|
-
|
|
83589
|
-
|
|
83590
|
-
tr.setNodeMarkup(pos, null, {
|
|
83591
|
-
...node.attrs,
|
|
83592
|
-
[name]: value
|
|
83593
|
-
});
|
|
83594
|
-
});
|
|
83595
|
-
else
|
|
83596
|
-
tr.setNodeMarkup($cell.pos, null, {
|
|
83597
|
-
...$cell.nodeAfter.attrs,
|
|
84462
|
+
if (state2.selection instanceof CellSelection) state2.selection.forEachCell((node, pos) => {
|
|
84463
|
+
if (node.attrs[name] !== value) tr.setNodeMarkup(pos, null, {
|
|
84464
|
+
...node.attrs,
|
|
83598
84465
|
[name]: value
|
|
83599
84466
|
});
|
|
84467
|
+
});
|
|
84468
|
+
else tr.setNodeMarkup($cell.pos, null, {
|
|
84469
|
+
...$cell.nodeAfter.attrs,
|
|
84470
|
+
[name]: value
|
|
84471
|
+
});
|
|
83600
84472
|
dispatch(tr);
|
|
83601
84473
|
}
|
|
83602
84474
|
return true;
|
|
@@ -83608,34 +84480,20 @@ function deprecated_toggleHeader(type2) {
|
|
|
83608
84480
|
if (dispatch) {
|
|
83609
84481
|
const types2 = tableNodeTypes(state2.schema);
|
|
83610
84482
|
const rect = selectedRect(state2), tr = state2.tr;
|
|
83611
|
-
const cells = rect.map.cellsInRect(
|
|
83612
|
-
|
|
83613
|
-
|
|
83614
|
-
|
|
83615
|
-
|
|
83616
|
-
|
|
83617
|
-
|
|
83618
|
-
|
|
83619
|
-
|
|
83620
|
-
|
|
83621
|
-
|
|
83622
|
-
} : rect
|
|
83623
|
-
);
|
|
84483
|
+
const cells = rect.map.cellsInRect(type2 == "column" ? {
|
|
84484
|
+
left: rect.left,
|
|
84485
|
+
top: 0,
|
|
84486
|
+
right: rect.right,
|
|
84487
|
+
bottom: rect.map.height
|
|
84488
|
+
} : type2 == "row" ? {
|
|
84489
|
+
left: 0,
|
|
84490
|
+
top: rect.top,
|
|
84491
|
+
right: rect.map.width,
|
|
84492
|
+
bottom: rect.bottom
|
|
84493
|
+
} : rect);
|
|
83624
84494
|
const nodes = cells.map((pos) => rect.table.nodeAt(pos));
|
|
83625
|
-
for (let i = 0; i < cells.length; i++)
|
|
83626
|
-
|
|
83627
|
-
tr.setNodeMarkup(
|
|
83628
|
-
rect.tableStart + cells[i],
|
|
83629
|
-
types2.cell,
|
|
83630
|
-
nodes[i].attrs
|
|
83631
|
-
);
|
|
83632
|
-
if (tr.steps.length == 0)
|
|
83633
|
-
for (let i = 0; i < cells.length; i++)
|
|
83634
|
-
tr.setNodeMarkup(
|
|
83635
|
-
rect.tableStart + cells[i],
|
|
83636
|
-
types2.header_cell,
|
|
83637
|
-
nodes[i].attrs
|
|
83638
|
-
);
|
|
84495
|
+
for (let i = 0; i < cells.length; i++) if (nodes[i].type == types2.header_cell) tr.setNodeMarkup(rect.tableStart + cells[i], types2.cell, nodes[i].attrs);
|
|
84496
|
+
if (tr.steps.length === 0) for (let i = 0; i < cells.length; i++) tr.setNodeMarkup(rect.tableStart + cells[i], types2.header_cell, nodes[i].attrs);
|
|
83639
84497
|
dispatch(tr);
|
|
83640
84498
|
}
|
|
83641
84499
|
return true;
|
|
@@ -83650,9 +84508,7 @@ function isHeaderEnabledByType(type2, rect, types2) {
|
|
|
83650
84508
|
});
|
|
83651
84509
|
for (let i = 0; i < cellPositions.length; i++) {
|
|
83652
84510
|
const cell = rect.table.nodeAt(cellPositions[i]);
|
|
83653
|
-
if (cell && cell.type !== types2.header_cell)
|
|
83654
|
-
return false;
|
|
83655
|
-
}
|
|
84511
|
+
if (cell && cell.type !== types2.header_cell) return false;
|
|
83656
84512
|
}
|
|
83657
84513
|
return true;
|
|
83658
84514
|
}
|
|
@@ -83665,13 +84521,8 @@ function toggleHeader(type2, options) {
|
|
|
83665
84521
|
const types2 = tableNodeTypes(state2.schema);
|
|
83666
84522
|
const rect = selectedRect(state2), tr = state2.tr;
|
|
83667
84523
|
const isHeaderRowEnabled = isHeaderEnabledByType("row", rect, types2);
|
|
83668
|
-
const isHeaderColumnEnabled = isHeaderEnabledByType(
|
|
83669
|
-
|
|
83670
|
-
rect,
|
|
83671
|
-
types2
|
|
83672
|
-
);
|
|
83673
|
-
const isHeaderEnabled = type2 === "column" ? isHeaderRowEnabled : type2 === "row" ? isHeaderColumnEnabled : false;
|
|
83674
|
-
const selectionStartsAt = isHeaderEnabled ? 1 : 0;
|
|
84524
|
+
const isHeaderColumnEnabled = isHeaderEnabledByType("column", rect, types2);
|
|
84525
|
+
const selectionStartsAt = (type2 === "column" ? isHeaderRowEnabled : type2 === "row" ? isHeaderColumnEnabled : false) ? 1 : 0;
|
|
83675
84526
|
const cellsRect = type2 == "column" ? {
|
|
83676
84527
|
left: 0,
|
|
83677
84528
|
top: selectionStartsAt,
|
|
@@ -83687,24 +84538,16 @@ function toggleHeader(type2, options) {
|
|
|
83687
84538
|
rect.map.cellsInRect(cellsRect).forEach((relativeCellPos) => {
|
|
83688
84539
|
const cellPos = relativeCellPos + rect.tableStart;
|
|
83689
84540
|
const cell = tr.doc.nodeAt(cellPos);
|
|
83690
|
-
if (cell)
|
|
83691
|
-
tr.setNodeMarkup(cellPos, newType, cell.attrs);
|
|
83692
|
-
}
|
|
84541
|
+
if (cell) tr.setNodeMarkup(cellPos, newType, cell.attrs);
|
|
83693
84542
|
});
|
|
83694
84543
|
dispatch(tr);
|
|
83695
84544
|
}
|
|
83696
84545
|
return true;
|
|
83697
84546
|
};
|
|
83698
84547
|
}
|
|
83699
|
-
toggleHeader("row", {
|
|
83700
|
-
|
|
83701
|
-
});
|
|
83702
|
-
toggleHeader("column", {
|
|
83703
|
-
useDeprecatedLogic: true
|
|
83704
|
-
});
|
|
83705
|
-
var toggleHeaderCell = toggleHeader("cell", {
|
|
83706
|
-
useDeprecatedLogic: true
|
|
83707
|
-
});
|
|
84548
|
+
toggleHeader("row", { useDeprecatedLogic: true });
|
|
84549
|
+
toggleHeader("column", { useDeprecatedLogic: true });
|
|
84550
|
+
const toggleHeaderCell = toggleHeader("cell", { useDeprecatedLogic: true });
|
|
83708
84551
|
function findNextCell($cell, dir) {
|
|
83709
84552
|
if (dir < 0) {
|
|
83710
84553
|
const before = $cell.nodeBefore;
|
|
@@ -83712,15 +84555,11 @@ function findNextCell($cell, dir) {
|
|
|
83712
84555
|
for (let row = $cell.index(-1) - 1, rowEnd = $cell.before(); row >= 0; row--) {
|
|
83713
84556
|
const rowNode = $cell.node(-1).child(row);
|
|
83714
84557
|
const lastChild = rowNode.lastChild;
|
|
83715
|
-
if (lastChild)
|
|
83716
|
-
return rowEnd - 1 - lastChild.nodeSize;
|
|
83717
|
-
}
|
|
84558
|
+
if (lastChild) return rowEnd - 1 - lastChild.nodeSize;
|
|
83718
84559
|
rowEnd -= rowNode.nodeSize;
|
|
83719
84560
|
}
|
|
83720
84561
|
} else {
|
|
83721
|
-
if ($cell.index() < $cell.parent.childCount - 1)
|
|
83722
|
-
return $cell.pos + $cell.nodeAfter.nodeSize;
|
|
83723
|
-
}
|
|
84562
|
+
if ($cell.index() < $cell.parent.childCount - 1) return $cell.pos + $cell.nodeAfter.nodeSize;
|
|
83724
84563
|
const table = $cell.node(-1);
|
|
83725
84564
|
for (let row = $cell.indexAfter(-1), rowStart = $cell.after(); row < table.childCount; row++) {
|
|
83726
84565
|
const rowNode = table.child(row);
|
|
@@ -83737,24 +84576,16 @@ function goToNextCell(direction) {
|
|
|
83737
84576
|
if (cell == null) return false;
|
|
83738
84577
|
if (dispatch) {
|
|
83739
84578
|
const $cell = state2.doc.resolve(cell);
|
|
83740
|
-
dispatch(
|
|
83741
|
-
state2.tr.setSelection(TextSelection$1.between($cell, moveCellForward($cell))).scrollIntoView()
|
|
83742
|
-
);
|
|
84579
|
+
dispatch(state2.tr.setSelection(TextSelection$1.between($cell, moveCellForward($cell))).scrollIntoView());
|
|
83743
84580
|
}
|
|
83744
84581
|
return true;
|
|
83745
84582
|
};
|
|
83746
84583
|
}
|
|
83747
84584
|
function deleteTable(state2, dispatch) {
|
|
83748
84585
|
const $pos = state2.selection.$anchor;
|
|
83749
|
-
for (let d2 = $pos.depth; d2 > 0; d2--) {
|
|
83750
|
-
|
|
83751
|
-
|
|
83752
|
-
if (dispatch)
|
|
83753
|
-
dispatch(
|
|
83754
|
-
state2.tr.delete($pos.before(d2), $pos.after(d2)).scrollIntoView()
|
|
83755
|
-
);
|
|
83756
|
-
return true;
|
|
83757
|
-
}
|
|
84586
|
+
for (let d2 = $pos.depth; d2 > 0; d2--) if ($pos.node(d2).type.spec.tableRole == "table") {
|
|
84587
|
+
if (dispatch) dispatch(state2.tr.delete($pos.before(d2), $pos.after(d2)).scrollIntoView());
|
|
84588
|
+
return true;
|
|
83758
84589
|
}
|
|
83759
84590
|
return false;
|
|
83760
84591
|
}
|
|
@@ -83765,19 +84596,14 @@ function deleteCellSelection(state2, dispatch) {
|
|
|
83765
84596
|
const tr = state2.tr;
|
|
83766
84597
|
const baseContent = tableNodeTypes(state2.schema).cell.createAndFill().content;
|
|
83767
84598
|
sel.forEachCell((cell, pos) => {
|
|
83768
|
-
if (!cell.content.eq(baseContent))
|
|
83769
|
-
tr.replace(
|
|
83770
|
-
tr.mapping.map(pos + 1),
|
|
83771
|
-
tr.mapping.map(pos + cell.nodeSize - 1),
|
|
83772
|
-
new Slice(baseContent, 0, 0)
|
|
83773
|
-
);
|
|
84599
|
+
if (!cell.content.eq(baseContent)) tr.replace(tr.mapping.map(pos + 1), tr.mapping.map(pos + cell.nodeSize - 1), new Slice(baseContent, 0, 0));
|
|
83774
84600
|
});
|
|
83775
84601
|
if (tr.docChanged) dispatch(tr);
|
|
83776
84602
|
}
|
|
83777
84603
|
return true;
|
|
83778
84604
|
}
|
|
83779
84605
|
function pastedCells(slice2) {
|
|
83780
|
-
if (
|
|
84606
|
+
if (slice2.size === 0) return null;
|
|
83781
84607
|
let { content, openStart, openEnd } = slice2;
|
|
83782
84608
|
while (content.childCount == 1 && (openStart > 0 && openEnd > 0 || content.child(0).type.spec.tableRole == "table")) {
|
|
83783
84609
|
openStart--;
|
|
@@ -83787,28 +84613,15 @@ function pastedCells(slice2) {
|
|
|
83787
84613
|
const first2 = content.child(0);
|
|
83788
84614
|
const role = first2.type.spec.tableRole;
|
|
83789
84615
|
const schema = first2.type.schema, rows = [];
|
|
83790
|
-
if (role == "row") {
|
|
83791
|
-
|
|
83792
|
-
|
|
83793
|
-
|
|
83794
|
-
|
|
83795
|
-
|
|
83796
|
-
|
|
83797
|
-
|
|
83798
|
-
|
|
83799
|
-
).content;
|
|
83800
|
-
rows.push(cells);
|
|
83801
|
-
}
|
|
83802
|
-
} else if (role == "cell" || role == "header_cell") {
|
|
83803
|
-
rows.push(
|
|
83804
|
-
openStart || openEnd ? fitSlice(
|
|
83805
|
-
tableNodeTypes(schema).row,
|
|
83806
|
-
new Slice(content, openStart, openEnd)
|
|
83807
|
-
).content : content
|
|
83808
|
-
);
|
|
83809
|
-
} else {
|
|
83810
|
-
return null;
|
|
83811
|
-
}
|
|
84616
|
+
if (role == "row") for (let i = 0; i < content.childCount; i++) {
|
|
84617
|
+
let cells = content.child(i).content;
|
|
84618
|
+
const left2 = i ? 0 : Math.max(0, openStart - 1);
|
|
84619
|
+
const right2 = i < content.childCount - 1 ? 0 : Math.max(0, openEnd - 1);
|
|
84620
|
+
if (left2 || right2) cells = fitSlice(tableNodeTypes(schema).row, new Slice(cells, left2, right2)).content;
|
|
84621
|
+
rows.push(cells);
|
|
84622
|
+
}
|
|
84623
|
+
else if (role == "cell" || role == "header_cell") rows.push(openStart || openEnd ? fitSlice(tableNodeTypes(schema).row, new Slice(content, openStart, openEnd)).content : content);
|
|
84624
|
+
else return null;
|
|
83812
84625
|
return ensureRectangular(schema, rows);
|
|
83813
84626
|
}
|
|
83814
84627
|
function ensureRectangular(schema, rows) {
|
|
@@ -83817,8 +84630,7 @@ function ensureRectangular(schema, rows) {
|
|
|
83817
84630
|
const row = rows[i];
|
|
83818
84631
|
for (let j2 = row.childCount - 1; j2 >= 0; j2--) {
|
|
83819
84632
|
const { rowspan, colspan } = row.child(j2).attrs;
|
|
83820
|
-
for (let r2 = i; r2 < i + rowspan; r2++)
|
|
83821
|
-
widths[r2] = (widths[r2] || 0) + colspan;
|
|
84633
|
+
for (let r2 = i; r2 < i + rowspan; r2++) widths[r2] = (widths[r2] || 0) + colspan;
|
|
83822
84634
|
}
|
|
83823
84635
|
}
|
|
83824
84636
|
let width = 0;
|
|
@@ -83828,18 +84640,19 @@ function ensureRectangular(schema, rows) {
|
|
|
83828
84640
|
if (widths[r2] < width) {
|
|
83829
84641
|
const empty2 = tableNodeTypes(schema).cell.createAndFill();
|
|
83830
84642
|
const cells = [];
|
|
83831
|
-
for (let i = widths[r2]; i < width; i++)
|
|
83832
|
-
cells.push(empty2);
|
|
83833
|
-
}
|
|
84643
|
+
for (let i = widths[r2]; i < width; i++) cells.push(empty2);
|
|
83834
84644
|
rows[r2] = rows[r2].append(Fragment.from(cells));
|
|
83835
84645
|
}
|
|
83836
84646
|
}
|
|
83837
|
-
return {
|
|
84647
|
+
return {
|
|
84648
|
+
height: rows.length,
|
|
84649
|
+
width,
|
|
84650
|
+
rows
|
|
84651
|
+
};
|
|
83838
84652
|
}
|
|
83839
84653
|
function fitSlice(nodeType, slice2) {
|
|
83840
84654
|
const node = nodeType.createAndFill();
|
|
83841
|
-
|
|
83842
|
-
return tr.doc;
|
|
84655
|
+
return new Transform(node).replace(0, node.content.size, slice2).doc;
|
|
83843
84656
|
}
|
|
83844
84657
|
function clipCells({ width, height, rows }, newWidth, newHeight) {
|
|
83845
84658
|
if (width != newWidth) {
|
|
@@ -83849,19 +84662,10 @@ function clipCells({ width, height, rows }, newWidth, newHeight) {
|
|
|
83849
84662
|
const frag = rows[row], cells = [];
|
|
83850
84663
|
for (let col = added[row] || 0, i = 0; col < newWidth; i++) {
|
|
83851
84664
|
let cell = frag.child(i % frag.childCount);
|
|
83852
|
-
if (col + cell.attrs.colspan > newWidth)
|
|
83853
|
-
cell = cell.type.createChecked(
|
|
83854
|
-
removeColSpan(
|
|
83855
|
-
cell.attrs,
|
|
83856
|
-
cell.attrs.colspan,
|
|
83857
|
-
col + cell.attrs.colspan - newWidth
|
|
83858
|
-
),
|
|
83859
|
-
cell.content
|
|
83860
|
-
);
|
|
84665
|
+
if (col + cell.attrs.colspan > newWidth) cell = cell.type.createChecked(removeColSpan(cell.attrs, cell.attrs.colspan, col + cell.attrs.colspan - newWidth), cell.content);
|
|
83861
84666
|
cells.push(cell);
|
|
83862
84667
|
col += cell.attrs.colspan;
|
|
83863
|
-
for (let j2 = 1; j2 < cell.attrs.rowspan; j2++)
|
|
83864
|
-
added[row + j2] = (added[row + j2] || 0) + cell.attrs.colspan;
|
|
84668
|
+
for (let j2 = 1; j2 < cell.attrs.rowspan; j2++) added[row + j2] = (added[row + j2] || 0) + cell.attrs.colspan;
|
|
83865
84669
|
}
|
|
83866
84670
|
newRows.push(Fragment.from(cells));
|
|
83867
84671
|
}
|
|
@@ -83874,14 +84678,10 @@ function clipCells({ width, height, rows }, newWidth, newHeight) {
|
|
|
83874
84678
|
const cells = [], source = rows[i % height];
|
|
83875
84679
|
for (let j2 = 0; j2 < source.childCount; j2++) {
|
|
83876
84680
|
let cell = source.child(j2);
|
|
83877
|
-
if (row + cell.attrs.rowspan > newHeight)
|
|
83878
|
-
cell
|
|
83879
|
-
|
|
83880
|
-
|
|
83881
|
-
rowspan: Math.max(1, newHeight - cell.attrs.rowspan)
|
|
83882
|
-
},
|
|
83883
|
-
cell.content
|
|
83884
|
-
);
|
|
84681
|
+
if (row + cell.attrs.rowspan > newHeight) cell = cell.type.create({
|
|
84682
|
+
...cell.attrs,
|
|
84683
|
+
rowspan: Math.max(1, newHeight - cell.attrs.rowspan)
|
|
84684
|
+
}, cell.content);
|
|
83885
84685
|
cells.push(cell);
|
|
83886
84686
|
}
|
|
83887
84687
|
newRows.push(Fragment.from(cells));
|
|
@@ -83889,33 +84689,32 @@ function clipCells({ width, height, rows }, newWidth, newHeight) {
|
|
|
83889
84689
|
rows = newRows;
|
|
83890
84690
|
height = newHeight;
|
|
83891
84691
|
}
|
|
83892
|
-
return {
|
|
84692
|
+
return {
|
|
84693
|
+
width,
|
|
84694
|
+
height,
|
|
84695
|
+
rows
|
|
84696
|
+
};
|
|
83893
84697
|
}
|
|
83894
84698
|
function growTable(tr, map22, table, start2, width, height, mapFrom) {
|
|
83895
84699
|
const schema = tr.doc.type.schema;
|
|
83896
84700
|
const types2 = tableNodeTypes(schema);
|
|
83897
84701
|
let empty2;
|
|
83898
84702
|
let emptyHead;
|
|
83899
|
-
if (width > map22.width) {
|
|
83900
|
-
|
|
83901
|
-
|
|
83902
|
-
|
|
83903
|
-
|
|
83904
|
-
|
|
83905
|
-
|
|
83906
|
-
|
|
83907
|
-
|
|
83908
|
-
for (let i = map22.width; i < width; i++) cells.push(add);
|
|
83909
|
-
tr.insert(tr.mapping.slice(mapFrom).map(rowEnd - 1 + start2), cells);
|
|
83910
|
-
}
|
|
84703
|
+
if (width > map22.width) for (let row = 0, rowEnd = 0; row < map22.height; row++) {
|
|
84704
|
+
const rowNode = table.child(row);
|
|
84705
|
+
rowEnd += rowNode.nodeSize;
|
|
84706
|
+
const cells = [];
|
|
84707
|
+
let add;
|
|
84708
|
+
if (rowNode.lastChild == null || rowNode.lastChild.type == types2.cell) add = empty2 || (empty2 = types2.cell.createAndFill());
|
|
84709
|
+
else add = emptyHead || (emptyHead = types2.header_cell.createAndFill());
|
|
84710
|
+
for (let i = map22.width; i < width; i++) cells.push(add);
|
|
84711
|
+
tr.insert(tr.mapping.slice(mapFrom).map(rowEnd - 1 + start2), cells);
|
|
83911
84712
|
}
|
|
83912
84713
|
if (height > map22.height) {
|
|
83913
84714
|
const cells = [];
|
|
83914
|
-
for (let i = 0,
|
|
83915
|
-
const header = i >= map22.width ? false : table.nodeAt(map22.map[
|
|
83916
|
-
cells.push(
|
|
83917
|
-
header ? emptyHead || (emptyHead = types2.header_cell.createAndFill()) : empty2 || (empty2 = types2.cell.createAndFill())
|
|
83918
|
-
);
|
|
84715
|
+
for (let i = 0, start$1 = (map22.height - 1) * map22.width; i < Math.max(map22.width, width); i++) {
|
|
84716
|
+
const header = i >= map22.width ? false : table.nodeAt(map22.map[start$1 + i]).type == types2.header_cell;
|
|
84717
|
+
cells.push(header ? emptyHead || (emptyHead = types2.header_cell.createAndFill()) : empty2 || (empty2 = types2.cell.createAndFill()));
|
|
83919
84718
|
}
|
|
83920
84719
|
const emptyRow = types2.row.create(null, Fragment.from(cells)), rows = [];
|
|
83921
84720
|
for (let i = map22.height; i < height; i++) rows.push(emptyRow);
|
|
@@ -83936,13 +84735,10 @@ function isolateHorizontal(tr, map22, table, start2, left2, right2, top2, mapFro
|
|
|
83936
84735
|
...cell.attrs,
|
|
83937
84736
|
rowspan: top2 - cellTop
|
|
83938
84737
|
});
|
|
83939
|
-
tr.insert(
|
|
83940
|
-
|
|
83941
|
-
cell.
|
|
83942
|
-
|
|
83943
|
-
rowspan: cellTop + cell.attrs.rowspan - top2
|
|
83944
|
-
})
|
|
83945
|
-
);
|
|
84738
|
+
tr.insert(tr.mapping.slice(mapFrom).map(map22.positionAt(top2, cellLeft, table)), cell.type.createAndFill({
|
|
84739
|
+
...cell.attrs,
|
|
84740
|
+
rowspan: cellTop + cell.attrs.rowspan - top2
|
|
84741
|
+
}));
|
|
83946
84742
|
col += cell.attrs.colspan - 1;
|
|
83947
84743
|
}
|
|
83948
84744
|
}
|
|
@@ -83958,21 +84754,8 @@ function isolateVertical(tr, map22, table, start2, top2, bottom2, left2, mapFrom
|
|
|
83958
84754
|
const cell = table.nodeAt(pos);
|
|
83959
84755
|
const cellLeft = map22.colCount(pos);
|
|
83960
84756
|
const updatePos = tr.mapping.slice(mapFrom).map(pos + start2);
|
|
83961
|
-
tr.setNodeMarkup(
|
|
83962
|
-
|
|
83963
|
-
null,
|
|
83964
|
-
removeColSpan(
|
|
83965
|
-
cell.attrs,
|
|
83966
|
-
left2 - cellLeft,
|
|
83967
|
-
cell.attrs.colspan - (left2 - cellLeft)
|
|
83968
|
-
)
|
|
83969
|
-
);
|
|
83970
|
-
tr.insert(
|
|
83971
|
-
updatePos + cell.nodeSize,
|
|
83972
|
-
cell.type.createAndFill(
|
|
83973
|
-
removeColSpan(cell.attrs, 0, left2 - cellLeft)
|
|
83974
|
-
)
|
|
83975
|
-
);
|
|
84757
|
+
tr.setNodeMarkup(updatePos, null, removeColSpan(cell.attrs, left2 - cellLeft, cell.attrs.colspan - (left2 - cellLeft)));
|
|
84758
|
+
tr.insert(updatePos + cell.nodeSize, cell.type.createAndFill(removeColSpan(cell.attrs, 0, left2 - cellLeft)));
|
|
83976
84759
|
row += cell.attrs.rowspan - 1;
|
|
83977
84760
|
}
|
|
83978
84761
|
}
|
|
@@ -83980,9 +84763,7 @@ function isolateVertical(tr, map22, table, start2, top2, bottom2, left2, mapFrom
|
|
|
83980
84763
|
}
|
|
83981
84764
|
function insertCells(state2, dispatch, tableStart, rect, cells) {
|
|
83982
84765
|
let table = tableStart ? state2.doc.nodeAt(tableStart - 1) : state2.doc;
|
|
83983
|
-
if (!table)
|
|
83984
|
-
throw new Error("No table found");
|
|
83985
|
-
}
|
|
84766
|
+
if (!table) throw new Error("No table found");
|
|
83986
84767
|
let map22 = TableMap.get(table);
|
|
83987
84768
|
const { top: top2, left: left2 } = rect;
|
|
83988
84769
|
const right2 = left2 + cells.width, bottom2 = top2 + cells.height;
|
|
@@ -83990,39 +84771,24 @@ function insertCells(state2, dispatch, tableStart, rect, cells) {
|
|
|
83990
84771
|
let mapFrom = 0;
|
|
83991
84772
|
function recomp() {
|
|
83992
84773
|
table = tableStart ? tr.doc.nodeAt(tableStart - 1) : tr.doc;
|
|
83993
|
-
if (!table)
|
|
83994
|
-
throw new Error("No table found");
|
|
83995
|
-
}
|
|
84774
|
+
if (!table) throw new Error("No table found");
|
|
83996
84775
|
map22 = TableMap.get(table);
|
|
83997
84776
|
mapFrom = tr.mapping.maps.length;
|
|
83998
84777
|
}
|
|
83999
84778
|
if (growTable(tr, map22, table, tableStart, right2, bottom2, mapFrom)) recomp();
|
|
84000
|
-
if (isolateHorizontal(tr, map22, table, tableStart, left2, right2, top2, mapFrom))
|
|
84001
|
-
|
|
84002
|
-
if (
|
|
84003
|
-
|
|
84004
|
-
if (isolateVertical(tr, map22, table, tableStart, top2, bottom2, left2, mapFrom))
|
|
84005
|
-
recomp();
|
|
84006
|
-
if (isolateVertical(tr, map22, table, tableStart, top2, bottom2, right2, mapFrom))
|
|
84007
|
-
recomp();
|
|
84779
|
+
if (isolateHorizontal(tr, map22, table, tableStart, left2, right2, top2, mapFrom)) recomp();
|
|
84780
|
+
if (isolateHorizontal(tr, map22, table, tableStart, left2, right2, bottom2, mapFrom)) recomp();
|
|
84781
|
+
if (isolateVertical(tr, map22, table, tableStart, top2, bottom2, left2, mapFrom)) recomp();
|
|
84782
|
+
if (isolateVertical(tr, map22, table, tableStart, top2, bottom2, right2, mapFrom)) recomp();
|
|
84008
84783
|
for (let row = top2; row < bottom2; row++) {
|
|
84009
84784
|
const from2 = map22.positionAt(row, left2, table), to = map22.positionAt(row, right2, table);
|
|
84010
|
-
tr.replace(
|
|
84011
|
-
tr.mapping.slice(mapFrom).map(from2 + tableStart),
|
|
84012
|
-
tr.mapping.slice(mapFrom).map(to + tableStart),
|
|
84013
|
-
new Slice(cells.rows[row - top2], 0, 0)
|
|
84014
|
-
);
|
|
84785
|
+
tr.replace(tr.mapping.slice(mapFrom).map(from2 + tableStart), tr.mapping.slice(mapFrom).map(to + tableStart), new Slice(cells.rows[row - top2], 0, 0));
|
|
84015
84786
|
}
|
|
84016
84787
|
recomp();
|
|
84017
|
-
tr.setSelection(
|
|
84018
|
-
new CellSelection(
|
|
84019
|
-
tr.doc.resolve(tableStart + map22.positionAt(top2, left2, table)),
|
|
84020
|
-
tr.doc.resolve(tableStart + map22.positionAt(bottom2 - 1, right2 - 1, table))
|
|
84021
|
-
)
|
|
84022
|
-
);
|
|
84788
|
+
tr.setSelection(new CellSelection(tr.doc.resolve(tableStart + map22.positionAt(top2, left2, table)), tr.doc.resolve(tableStart + map22.positionAt(bottom2 - 1, right2 - 1, table))));
|
|
84023
84789
|
dispatch(tr);
|
|
84024
84790
|
}
|
|
84025
|
-
|
|
84791
|
+
const handleKeyDown = keydownHandler({
|
|
84026
84792
|
ArrowLeft: arrow$2("horiz", -1),
|
|
84027
84793
|
ArrowRight: arrow$2("horiz", 1),
|
|
84028
84794
|
ArrowUp: arrow$2("vert", -1),
|
|
@@ -84045,29 +84811,17 @@ function arrow$2(axis, dir) {
|
|
|
84045
84811
|
return (state2, dispatch, view) => {
|
|
84046
84812
|
if (!view) return false;
|
|
84047
84813
|
const sel = state2.selection;
|
|
84048
|
-
if (sel instanceof CellSelection)
|
|
84049
|
-
return maybeSetSelection(
|
|
84050
|
-
state2,
|
|
84051
|
-
dispatch,
|
|
84052
|
-
Selection.near(sel.$headCell, dir)
|
|
84053
|
-
);
|
|
84054
|
-
}
|
|
84814
|
+
if (sel instanceof CellSelection) return maybeSetSelection(state2, dispatch, Selection.near(sel.$headCell, dir));
|
|
84055
84815
|
if (axis != "horiz" && !sel.empty) return false;
|
|
84056
84816
|
const end2 = atEndOfCell(view, axis, dir);
|
|
84057
84817
|
if (end2 == null) return false;
|
|
84058
|
-
if (axis == "horiz")
|
|
84059
|
-
|
|
84060
|
-
state2,
|
|
84061
|
-
dispatch,
|
|
84062
|
-
Selection.near(state2.doc.resolve(sel.head + dir), dir)
|
|
84063
|
-
);
|
|
84064
|
-
} else {
|
|
84818
|
+
if (axis == "horiz") return maybeSetSelection(state2, dispatch, Selection.near(state2.doc.resolve(sel.head + dir), dir));
|
|
84819
|
+
else {
|
|
84065
84820
|
const $cell = state2.doc.resolve(end2);
|
|
84066
84821
|
const $next = nextCell($cell, axis, dir);
|
|
84067
84822
|
let newSel;
|
|
84068
84823
|
if ($next) newSel = Selection.near($next, 1);
|
|
84069
|
-
else if (dir < 0)
|
|
84070
|
-
newSel = Selection.near(state2.doc.resolve($cell.before(-1)), -1);
|
|
84824
|
+
else if (dir < 0) newSel = Selection.near(state2.doc.resolve($cell.before(-1)), -1);
|
|
84071
84825
|
else newSel = Selection.near(state2.doc.resolve($cell.after(-1)), 1);
|
|
84072
84826
|
return maybeSetSelection(state2, dispatch, newSel);
|
|
84073
84827
|
}
|
|
@@ -84078,20 +84832,15 @@ function shiftArrow(axis, dir) {
|
|
|
84078
84832
|
if (!view) return false;
|
|
84079
84833
|
const sel = state2.selection;
|
|
84080
84834
|
let cellSel;
|
|
84081
|
-
if (sel instanceof CellSelection)
|
|
84082
|
-
|
|
84083
|
-
} else {
|
|
84835
|
+
if (sel instanceof CellSelection) cellSel = sel;
|
|
84836
|
+
else {
|
|
84084
84837
|
const end2 = atEndOfCell(view, axis, dir);
|
|
84085
84838
|
if (end2 == null) return false;
|
|
84086
84839
|
cellSel = new CellSelection(state2.doc.resolve(end2));
|
|
84087
84840
|
}
|
|
84088
84841
|
const $head = nextCell(cellSel.$headCell, axis, dir);
|
|
84089
84842
|
if (!$head) return false;
|
|
84090
|
-
return maybeSetSelection(
|
|
84091
|
-
state2,
|
|
84092
|
-
dispatch,
|
|
84093
|
-
new CellSelection(cellSel.$anchorCell, $head)
|
|
84094
|
-
);
|
|
84843
|
+
return maybeSetSelection(state2, dispatch, new CellSelection(cellSel.$anchorCell, $head));
|
|
84095
84844
|
};
|
|
84096
84845
|
}
|
|
84097
84846
|
function handleTripleClick(view, pos) {
|
|
@@ -84105,65 +84854,45 @@ function handlePaste(view, _2, slice2) {
|
|
|
84105
84854
|
let cells = pastedCells(slice2);
|
|
84106
84855
|
const sel = view.state.selection;
|
|
84107
84856
|
if (sel instanceof CellSelection) {
|
|
84108
|
-
if (!cells)
|
|
84109
|
-
|
|
84110
|
-
|
|
84111
|
-
|
|
84112
|
-
|
|
84113
|
-
Fragment.from(
|
|
84114
|
-
fitSlice(tableNodeTypes(view.state.schema).cell, slice2)
|
|
84115
|
-
)
|
|
84116
|
-
]
|
|
84117
|
-
};
|
|
84857
|
+
if (!cells) cells = {
|
|
84858
|
+
width: 1,
|
|
84859
|
+
height: 1,
|
|
84860
|
+
rows: [Fragment.from(fitSlice(tableNodeTypes(view.state.schema).cell, slice2))]
|
|
84861
|
+
};
|
|
84118
84862
|
const table = sel.$anchorCell.node(-1);
|
|
84119
84863
|
const start2 = sel.$anchorCell.start(-1);
|
|
84120
|
-
const rect = TableMap.get(table).rectBetween(
|
|
84121
|
-
sel.$anchorCell.pos - start2,
|
|
84122
|
-
sel.$headCell.pos - start2
|
|
84123
|
-
);
|
|
84864
|
+
const rect = TableMap.get(table).rectBetween(sel.$anchorCell.pos - start2, sel.$headCell.pos - start2);
|
|
84124
84865
|
cells = clipCells(cells, rect.right - rect.left, rect.bottom - rect.top);
|
|
84125
84866
|
insertCells(view.state, view.dispatch, start2, rect, cells);
|
|
84126
84867
|
return true;
|
|
84127
84868
|
} else if (cells) {
|
|
84128
84869
|
const $cell = selectionCell(view.state);
|
|
84129
84870
|
const start2 = $cell.start(-1);
|
|
84130
|
-
insertCells(
|
|
84131
|
-
view.state,
|
|
84132
|
-
view.dispatch,
|
|
84133
|
-
start2,
|
|
84134
|
-
TableMap.get($cell.node(-1)).findCell($cell.pos - start2),
|
|
84135
|
-
cells
|
|
84136
|
-
);
|
|
84871
|
+
insertCells(view.state, view.dispatch, start2, TableMap.get($cell.node(-1)).findCell($cell.pos - start2), cells);
|
|
84137
84872
|
return true;
|
|
84138
|
-
} else
|
|
84139
|
-
return false;
|
|
84140
|
-
}
|
|
84873
|
+
} else return false;
|
|
84141
84874
|
}
|
|
84142
84875
|
function handleMouseDown(view, startEvent) {
|
|
84143
|
-
var
|
|
84876
|
+
var _cellUnderMouse;
|
|
84144
84877
|
if (startEvent.ctrlKey || startEvent.metaKey) return;
|
|
84145
84878
|
const startDOMCell = domInCell(view, startEvent.target);
|
|
84146
84879
|
let $anchor;
|
|
84147
84880
|
if (startEvent.shiftKey && view.state.selection instanceof CellSelection) {
|
|
84148
84881
|
setCellSelection(view.state.selection.$anchorCell, startEvent);
|
|
84149
84882
|
startEvent.preventDefault();
|
|
84150
|
-
} else if (startEvent.shiftKey && startDOMCell && ($anchor = cellAround$1(view.state.selection.$anchor)) != null && ((
|
|
84883
|
+
} else if (startEvent.shiftKey && startDOMCell && ($anchor = cellAround$1(view.state.selection.$anchor)) != null && ((_cellUnderMouse = cellUnderMouse(view, startEvent)) === null || _cellUnderMouse === void 0 ? void 0 : _cellUnderMouse.pos) != $anchor.pos) {
|
|
84151
84884
|
setCellSelection($anchor, startEvent);
|
|
84152
84885
|
startEvent.preventDefault();
|
|
84153
|
-
} else if (!startDOMCell)
|
|
84154
|
-
|
|
84155
|
-
}
|
|
84156
|
-
function setCellSelection($anchor2, event) {
|
|
84886
|
+
} else if (!startDOMCell) return;
|
|
84887
|
+
function setCellSelection($anchor$1, event) {
|
|
84157
84888
|
let $head = cellUnderMouse(view, event);
|
|
84158
84889
|
const starting = tableEditingKey.getState(view.state) == null;
|
|
84159
|
-
if (!$head || !inSameTable($
|
|
84160
|
-
|
|
84161
|
-
|
|
84162
|
-
}
|
|
84163
|
-
const selection = new CellSelection($anchor2, $head);
|
|
84890
|
+
if (!$head || !inSameTable($anchor$1, $head)) if (starting) $head = $anchor$1;
|
|
84891
|
+
else return;
|
|
84892
|
+
const selection = new CellSelection($anchor$1, $head);
|
|
84164
84893
|
if (starting || !view.state.selection.eq(selection)) {
|
|
84165
84894
|
const tr = view.state.tr.setSelection(selection);
|
|
84166
|
-
if (starting) tr.setMeta(tableEditingKey, $
|
|
84895
|
+
if (starting) tr.setMeta(tableEditingKey, $anchor$1.pos);
|
|
84167
84896
|
view.dispatch(tr);
|
|
84168
84897
|
}
|
|
84169
84898
|
}
|
|
@@ -84171,20 +84900,18 @@ function handleMouseDown(view, startEvent) {
|
|
|
84171
84900
|
view.root.removeEventListener("mouseup", stop);
|
|
84172
84901
|
view.root.removeEventListener("dragstart", stop);
|
|
84173
84902
|
view.root.removeEventListener("mousemove", move2);
|
|
84174
|
-
if (tableEditingKey.getState(view.state) != null)
|
|
84175
|
-
view.dispatch(view.state.tr.setMeta(tableEditingKey, -1));
|
|
84903
|
+
if (tableEditingKey.getState(view.state) != null) view.dispatch(view.state.tr.setMeta(tableEditingKey, -1));
|
|
84176
84904
|
}
|
|
84177
84905
|
function move2(_event) {
|
|
84178
84906
|
const event = _event;
|
|
84179
84907
|
const anchor = tableEditingKey.getState(view.state);
|
|
84180
|
-
let $
|
|
84181
|
-
if (anchor != null)
|
|
84182
|
-
|
|
84183
|
-
|
|
84184
|
-
$
|
|
84185
|
-
if (!$anchor2) return stop();
|
|
84908
|
+
let $anchor$1;
|
|
84909
|
+
if (anchor != null) $anchor$1 = view.state.doc.resolve(anchor);
|
|
84910
|
+
else if (domInCell(view, event.target) != startDOMCell) {
|
|
84911
|
+
$anchor$1 = cellUnderMouse(view, startEvent);
|
|
84912
|
+
if (!$anchor$1) return stop();
|
|
84186
84913
|
}
|
|
84187
|
-
if ($
|
|
84914
|
+
if ($anchor$1) setCellSelection($anchor$1, event);
|
|
84188
84915
|
}
|
|
84189
84916
|
view.root.addEventListener("mouseup", stop);
|
|
84190
84917
|
view.root.addEventListener("dragstart", stop);
|
|
@@ -84194,8 +84921,8 @@ function atEndOfCell(view, axis, dir) {
|
|
|
84194
84921
|
if (!(view.state.selection instanceof TextSelection$1)) return null;
|
|
84195
84922
|
const { $head } = view.state.selection;
|
|
84196
84923
|
for (let d2 = $head.depth - 1; d2 >= 0; d2--) {
|
|
84197
|
-
const parent = $head.node(d2)
|
|
84198
|
-
if (
|
|
84924
|
+
const parent = $head.node(d2);
|
|
84925
|
+
if ((dir < 0 ? $head.index(d2) : $head.indexAfter(d2)) != (dir < 0 ? 0 : parent.childCount)) return null;
|
|
84199
84926
|
if (parent.type.spec.tableRole == "cell" || parent.type.spec.tableRole == "header_cell") {
|
|
84200
84927
|
const cellPos = $head.before(d2);
|
|
84201
84928
|
const dirStr = axis == "vert" ? dir > 0 ? "down" : "up" : dir > 0 ? "right" : "left";
|
|
@@ -84205,11 +84932,7 @@ function atEndOfCell(view, axis, dir) {
|
|
|
84205
84932
|
return null;
|
|
84206
84933
|
}
|
|
84207
84934
|
function domInCell(view, dom) {
|
|
84208
|
-
for (; dom && dom != view.dom; dom = dom.parentNode)
|
|
84209
|
-
if (dom.nodeName == "TD" || dom.nodeName == "TH") {
|
|
84210
|
-
return dom;
|
|
84211
|
-
}
|
|
84212
|
-
}
|
|
84935
|
+
for (; dom && dom != view.dom; dom = dom.parentNode) if (dom.nodeName == "TD" || dom.nodeName == "TH") return dom;
|
|
84213
84936
|
return null;
|
|
84214
84937
|
}
|
|
84215
84938
|
function cellUnderMouse(view, event) {
|
|
@@ -84218,7 +84941,8 @@ function cellUnderMouse(view, event) {
|
|
|
84218
84941
|
top: event.clientY
|
|
84219
84942
|
});
|
|
84220
84943
|
if (!mousePos) return null;
|
|
84221
|
-
|
|
84944
|
+
const pos = mousePos.inside >= 0 ? mousePos.inside : mousePos.pos;
|
|
84945
|
+
return cellAround$1(view.state.doc.resolve(pos));
|
|
84222
84946
|
}
|
|
84223
84947
|
var TableView = class {
|
|
84224
84948
|
constructor(node, defaultCellMinWidth) {
|
|
@@ -84227,10 +84951,7 @@ var TableView = class {
|
|
|
84227
84951
|
this.dom = document.createElement("div");
|
|
84228
84952
|
this.dom.className = "tableWrapper";
|
|
84229
84953
|
this.table = this.dom.appendChild(document.createElement("table"));
|
|
84230
|
-
this.table.style.setProperty(
|
|
84231
|
-
"--default-cell-min-width",
|
|
84232
|
-
`${defaultCellMinWidth}px`
|
|
84233
|
-
);
|
|
84954
|
+
this.table.style.setProperty("--default-cell-min-width", `${defaultCellMinWidth}px`);
|
|
84234
84955
|
this.colgroup = this.table.appendChild(document.createElement("colgroup"));
|
|
84235
84956
|
updateColumnsOnResize(node, this.colgroup, this.table, defaultCellMinWidth);
|
|
84236
84957
|
this.contentDOM = this.table.appendChild(document.createElement("tbody"));
|
|
@@ -84238,12 +84959,7 @@ var TableView = class {
|
|
|
84238
84959
|
update(node) {
|
|
84239
84960
|
if (node.type != this.node.type) return false;
|
|
84240
84961
|
this.node = node;
|
|
84241
|
-
updateColumnsOnResize(
|
|
84242
|
-
node,
|
|
84243
|
-
this.colgroup,
|
|
84244
|
-
this.table,
|
|
84245
|
-
this.defaultCellMinWidth
|
|
84246
|
-
);
|
|
84962
|
+
updateColumnsOnResize(node, this.colgroup, this.table, this.defaultCellMinWidth);
|
|
84247
84963
|
return true;
|
|
84248
84964
|
}
|
|
84249
84965
|
ignoreMutation(record) {
|
|
@@ -84251,7 +84967,6 @@ var TableView = class {
|
|
|
84251
84967
|
}
|
|
84252
84968
|
};
|
|
84253
84969
|
function updateColumnsOnResize(node, colgroup, table, defaultCellMinWidth, overrideCol, overrideValue) {
|
|
84254
|
-
var _a2;
|
|
84255
84970
|
let totalWidth = 0;
|
|
84256
84971
|
let fixedWidth = true;
|
|
84257
84972
|
let nextDOM = colgroup.firstChild;
|
|
@@ -84265,20 +84980,19 @@ function updateColumnsOnResize(node, colgroup, table, defaultCellMinWidth, overr
|
|
|
84265
84980
|
totalWidth += hasWidth || defaultCellMinWidth;
|
|
84266
84981
|
if (!hasWidth) fixedWidth = false;
|
|
84267
84982
|
if (!nextDOM) {
|
|
84268
|
-
const
|
|
84269
|
-
|
|
84270
|
-
colgroup.appendChild(
|
|
84983
|
+
const col$1 = document.createElement("col");
|
|
84984
|
+
col$1.style.width = cssWidth;
|
|
84985
|
+
colgroup.appendChild(col$1);
|
|
84271
84986
|
} else {
|
|
84272
|
-
if (nextDOM.style.width != cssWidth)
|
|
84273
|
-
nextDOM.style.width = cssWidth;
|
|
84274
|
-
}
|
|
84987
|
+
if (nextDOM.style.width != cssWidth) nextDOM.style.width = cssWidth;
|
|
84275
84988
|
nextDOM = nextDOM.nextSibling;
|
|
84276
84989
|
}
|
|
84277
84990
|
}
|
|
84278
84991
|
}
|
|
84279
84992
|
while (nextDOM) {
|
|
84993
|
+
var _nextDOM$parentNode;
|
|
84280
84994
|
const after = nextDOM.nextSibling;
|
|
84281
|
-
(
|
|
84995
|
+
(_nextDOM$parentNode = nextDOM.parentNode) === null || _nextDOM$parentNode === void 0 || _nextDOM$parentNode.removeChild(nextDOM);
|
|
84282
84996
|
nextDOM = after;
|
|
84283
84997
|
}
|
|
84284
84998
|
if (fixedWidth) {
|
|
@@ -84289,28 +85003,18 @@ function updateColumnsOnResize(node, colgroup, table, defaultCellMinWidth, overr
|
|
|
84289
85003
|
table.style.minWidth = totalWidth + "px";
|
|
84290
85004
|
}
|
|
84291
85005
|
}
|
|
84292
|
-
|
|
84293
|
-
|
|
84294
|
-
);
|
|
84295
|
-
function columnResizing({
|
|
84296
|
-
handleWidth = 5,
|
|
84297
|
-
cellMinWidth: cellMinWidth2 = 25,
|
|
84298
|
-
defaultCellMinWidth = 100,
|
|
84299
|
-
View = TableView,
|
|
84300
|
-
lastColumnResizable = true
|
|
84301
|
-
} = {}) {
|
|
85006
|
+
const columnResizingPluginKey = new PluginKey("tableColumnResizing");
|
|
85007
|
+
function columnResizing({ handleWidth = 5, cellMinWidth: cellMinWidth2 = 25, defaultCellMinWidth = 100, View = TableView, lastColumnResizable = true } = {}) {
|
|
84302
85008
|
const plugin2 = new Plugin({
|
|
84303
85009
|
key: columnResizingPluginKey,
|
|
84304
85010
|
state: {
|
|
84305
85011
|
init(_2, state2) {
|
|
84306
|
-
var
|
|
84307
|
-
const nodeViews = (
|
|
85012
|
+
var _plugin$spec;
|
|
85013
|
+
const nodeViews = (_plugin$spec = plugin2.spec) === null || _plugin$spec === void 0 || (_plugin$spec = _plugin$spec.props) === null || _plugin$spec === void 0 ? void 0 : _plugin$spec.nodeViews;
|
|
84308
85014
|
const tableName = tableNodeTypes(state2.schema).table.name;
|
|
84309
|
-
if (View && nodeViews) {
|
|
84310
|
-
|
|
84311
|
-
|
|
84312
|
-
};
|
|
84313
|
-
}
|
|
85015
|
+
if (View && nodeViews) nodeViews[tableName] = (node, view) => {
|
|
85016
|
+
return new View(node, defaultCellMinWidth, view);
|
|
85017
|
+
};
|
|
84314
85018
|
return new ResizeState(-1, false);
|
|
84315
85019
|
},
|
|
84316
85020
|
apply(tr, prev) {
|
|
@@ -84330,21 +85034,19 @@ function columnResizing({
|
|
|
84330
85034
|
handleMouseLeave(view);
|
|
84331
85035
|
},
|
|
84332
85036
|
mousedown: (view, event) => {
|
|
84333
|
-
|
|
85037
|
+
handleMouseDown$1(view, event, cellMinWidth2, defaultCellMinWidth);
|
|
84334
85038
|
}
|
|
84335
85039
|
},
|
|
84336
85040
|
decorations: (state2) => {
|
|
84337
85041
|
const pluginState = columnResizingPluginKey.getState(state2);
|
|
84338
|
-
if (pluginState && pluginState.activeHandle > -1)
|
|
84339
|
-
return handleDecorations(state2, pluginState.activeHandle);
|
|
84340
|
-
}
|
|
85042
|
+
if (pluginState && pluginState.activeHandle > -1) return handleDecorations(state2, pluginState.activeHandle);
|
|
84341
85043
|
},
|
|
84342
85044
|
nodeViews: {}
|
|
84343
85045
|
}
|
|
84344
85046
|
});
|
|
84345
85047
|
return plugin2;
|
|
84346
85048
|
}
|
|
84347
|
-
var ResizeState = class
|
|
85049
|
+
var ResizeState = class ResizeState2 {
|
|
84348
85050
|
constructor(activeHandle, dragging) {
|
|
84349
85051
|
this.activeHandle = activeHandle;
|
|
84350
85052
|
this.dragging = dragging;
|
|
@@ -84352,16 +85054,12 @@ var ResizeState = class _ResizeState {
|
|
|
84352
85054
|
apply(tr) {
|
|
84353
85055
|
const state2 = this;
|
|
84354
85056
|
const action = tr.getMeta(columnResizingPluginKey);
|
|
84355
|
-
if (action && action.setHandle != null)
|
|
84356
|
-
|
|
84357
|
-
if (action && action.setDragging !== void 0)
|
|
84358
|
-
return new _ResizeState(state2.activeHandle, action.setDragging);
|
|
85057
|
+
if (action && action.setHandle != null) return new ResizeState2(action.setHandle, false);
|
|
85058
|
+
if (action && action.setDragging !== void 0) return new ResizeState2(state2.activeHandle, action.setDragging);
|
|
84359
85059
|
if (state2.activeHandle > -1 && tr.docChanged) {
|
|
84360
85060
|
let handle = tr.mapping.map(state2.activeHandle, -1);
|
|
84361
|
-
if (!pointsAtCell(tr.doc.resolve(handle)))
|
|
84362
|
-
|
|
84363
|
-
}
|
|
84364
|
-
return new _ResizeState(handle, state2.dragging);
|
|
85061
|
+
if (!pointsAtCell(tr.doc.resolve(handle))) handle = -1;
|
|
85062
|
+
return new ResizeState2(handle, state2.dragging);
|
|
84365
85063
|
}
|
|
84366
85064
|
return state2;
|
|
84367
85065
|
}
|
|
@@ -84375,10 +85073,8 @@ function handleMouseMove(view, event, handleWidth, lastColumnResizable) {
|
|
|
84375
85073
|
let cell = -1;
|
|
84376
85074
|
if (target) {
|
|
84377
85075
|
const { left: left2, right: right2 } = target.getBoundingClientRect();
|
|
84378
|
-
if (event.clientX - left2 <= handleWidth)
|
|
84379
|
-
|
|
84380
|
-
else if (right2 - event.clientX <= handleWidth)
|
|
84381
|
-
cell = edgeCell(view, event, "right", handleWidth);
|
|
85076
|
+
if (event.clientX - left2 <= handleWidth) cell = edgeCell(view, event, "left", handleWidth);
|
|
85077
|
+
else if (right2 - event.clientX <= handleWidth) cell = edgeCell(view, event, "right", handleWidth);
|
|
84382
85078
|
}
|
|
84383
85079
|
if (cell != pluginState.activeHandle) {
|
|
84384
85080
|
if (!lastColumnResizable && cell !== -1) {
|
|
@@ -84386,10 +85082,7 @@ function handleMouseMove(view, event, handleWidth, lastColumnResizable) {
|
|
|
84386
85082
|
const table = $cell.node(-1);
|
|
84387
85083
|
const map22 = TableMap.get(table);
|
|
84388
85084
|
const tableStart = $cell.start(-1);
|
|
84389
|
-
|
|
84390
|
-
if (col == map22.width - 1) {
|
|
84391
|
-
return;
|
|
84392
|
-
}
|
|
85085
|
+
if (map22.colCount($cell.pos - tableStart) + $cell.nodeAfter.attrs.colspan - 1 == map22.width - 1) return;
|
|
84393
85086
|
}
|
|
84394
85087
|
updateHandle(view, cell);
|
|
84395
85088
|
}
|
|
@@ -84398,58 +85091,39 @@ function handleMouseMove(view, event, handleWidth, lastColumnResizable) {
|
|
|
84398
85091
|
function handleMouseLeave(view) {
|
|
84399
85092
|
if (!view.editable) return;
|
|
84400
85093
|
const pluginState = columnResizingPluginKey.getState(view.state);
|
|
84401
|
-
if (pluginState && pluginState.activeHandle > -1 && !pluginState.dragging)
|
|
84402
|
-
updateHandle(view, -1);
|
|
85094
|
+
if (pluginState && pluginState.activeHandle > -1 && !pluginState.dragging) updateHandle(view, -1);
|
|
84403
85095
|
}
|
|
84404
|
-
function
|
|
84405
|
-
var
|
|
85096
|
+
function handleMouseDown$1(view, event, cellMinWidth2, defaultCellMinWidth) {
|
|
85097
|
+
var _view$dom$ownerDocume;
|
|
84406
85098
|
if (!view.editable) return false;
|
|
84407
|
-
const win = (
|
|
85099
|
+
const win = (_view$dom$ownerDocume = view.dom.ownerDocument.defaultView) !== null && _view$dom$ownerDocume !== void 0 ? _view$dom$ownerDocume : window;
|
|
84408
85100
|
const pluginState = columnResizingPluginKey.getState(view.state);
|
|
84409
|
-
if (!pluginState || pluginState.activeHandle == -1 || pluginState.dragging)
|
|
84410
|
-
return false;
|
|
85101
|
+
if (!pluginState || pluginState.activeHandle == -1 || pluginState.dragging) return false;
|
|
84411
85102
|
const cell = view.state.doc.nodeAt(pluginState.activeHandle);
|
|
84412
85103
|
const width = currentColWidth(view, pluginState.activeHandle, cell.attrs);
|
|
84413
|
-
view.dispatch(
|
|
84414
|
-
|
|
84415
|
-
|
|
84416
|
-
|
|
84417
|
-
)
|
|
84418
|
-
function finish(event2) {
|
|
85104
|
+
view.dispatch(view.state.tr.setMeta(columnResizingPluginKey, { setDragging: {
|
|
85105
|
+
startX: event.clientX,
|
|
85106
|
+
startWidth: width
|
|
85107
|
+
} }));
|
|
85108
|
+
function finish(event$1) {
|
|
84419
85109
|
win.removeEventListener("mouseup", finish);
|
|
84420
85110
|
win.removeEventListener("mousemove", move2);
|
|
84421
|
-
const
|
|
84422
|
-
if (
|
|
84423
|
-
updateColumnWidth(
|
|
84424
|
-
|
|
84425
|
-
pluginState2.activeHandle,
|
|
84426
|
-
draggedWidth(pluginState2.dragging, event2, cellMinWidth2)
|
|
84427
|
-
);
|
|
84428
|
-
view.dispatch(
|
|
84429
|
-
view.state.tr.setMeta(columnResizingPluginKey, { setDragging: null })
|
|
84430
|
-
);
|
|
85111
|
+
const pluginState$1 = columnResizingPluginKey.getState(view.state);
|
|
85112
|
+
if (pluginState$1 === null || pluginState$1 === void 0 ? void 0 : pluginState$1.dragging) {
|
|
85113
|
+
updateColumnWidth(view, pluginState$1.activeHandle, draggedWidth(pluginState$1.dragging, event$1, cellMinWidth2));
|
|
85114
|
+
view.dispatch(view.state.tr.setMeta(columnResizingPluginKey, { setDragging: null }));
|
|
84431
85115
|
}
|
|
84432
85116
|
}
|
|
84433
|
-
function move2(
|
|
84434
|
-
if (!
|
|
84435
|
-
const
|
|
84436
|
-
if (!
|
|
84437
|
-
if (
|
|
84438
|
-
const dragged = draggedWidth(
|
|
84439
|
-
displayColumnWidth(
|
|
84440
|
-
view,
|
|
84441
|
-
pluginState2.activeHandle,
|
|
84442
|
-
dragged,
|
|
84443
|
-
defaultCellMinWidth
|
|
84444
|
-
);
|
|
85117
|
+
function move2(event$1) {
|
|
85118
|
+
if (!event$1.which) return finish(event$1);
|
|
85119
|
+
const pluginState$1 = columnResizingPluginKey.getState(view.state);
|
|
85120
|
+
if (!pluginState$1) return;
|
|
85121
|
+
if (pluginState$1.dragging) {
|
|
85122
|
+
const dragged = draggedWidth(pluginState$1.dragging, event$1, cellMinWidth2);
|
|
85123
|
+
displayColumnWidth(view, pluginState$1.activeHandle, dragged, defaultCellMinWidth);
|
|
84445
85124
|
}
|
|
84446
85125
|
}
|
|
84447
|
-
displayColumnWidth(
|
|
84448
|
-
view,
|
|
84449
|
-
pluginState.activeHandle,
|
|
84450
|
-
width,
|
|
84451
|
-
defaultCellMinWidth
|
|
84452
|
-
);
|
|
85126
|
+
displayColumnWidth(view, pluginState.activeHandle, width, defaultCellMinWidth);
|
|
84453
85127
|
win.addEventListener("mouseup", finish);
|
|
84454
85128
|
win.addEventListener("mousemove", move2);
|
|
84455
85129
|
event.preventDefault();
|
|
@@ -84459,20 +85133,17 @@ function currentColWidth(view, cellPos, { colspan, colwidth }) {
|
|
|
84459
85133
|
const width = colwidth && colwidth[colwidth.length - 1];
|
|
84460
85134
|
if (width) return width;
|
|
84461
85135
|
const dom = view.domAtPos(cellPos);
|
|
84462
|
-
|
|
84463
|
-
let domWidth = node.offsetWidth, parts = colspan;
|
|
85136
|
+
let domWidth = dom.node.childNodes[dom.offset].offsetWidth, parts = colspan;
|
|
84464
85137
|
if (colwidth) {
|
|
84465
|
-
for (let i = 0; i < colspan; i++)
|
|
84466
|
-
|
|
84467
|
-
|
|
84468
|
-
|
|
84469
|
-
}
|
|
85138
|
+
for (let i = 0; i < colspan; i++) if (colwidth[i]) {
|
|
85139
|
+
domWidth -= colwidth[i];
|
|
85140
|
+
parts--;
|
|
85141
|
+
}
|
|
84470
85142
|
}
|
|
84471
85143
|
return domWidth / parts;
|
|
84472
85144
|
}
|
|
84473
85145
|
function domCellAround(target) {
|
|
84474
|
-
while (target && target.nodeName != "TD" && target.nodeName != "TH")
|
|
84475
|
-
target = target.classList && target.classList.contains("ProseMirror") ? null : target.parentNode;
|
|
85146
|
+
while (target && target.nodeName != "TD" && target.nodeName != "TH") target = target.classList && target.classList.contains("ProseMirror") ? null : target.parentNode;
|
|
84476
85147
|
return target;
|
|
84477
85148
|
}
|
|
84478
85149
|
function edgeCell(view, event, side, handleWidth) {
|
|
@@ -84495,9 +85166,7 @@ function draggedWidth(dragging, event, resizeMinWidth) {
|
|
|
84495
85166
|
return Math.max(resizeMinWidth, dragging.startWidth + offset2);
|
|
84496
85167
|
}
|
|
84497
85168
|
function updateHandle(view, value) {
|
|
84498
|
-
view.dispatch(
|
|
84499
|
-
view.state.tr.setMeta(columnResizingPluginKey, { setHandle: value })
|
|
84500
|
-
);
|
|
85169
|
+
view.dispatch(view.state.tr.setMeta(columnResizingPluginKey, { setHandle: value }));
|
|
84501
85170
|
}
|
|
84502
85171
|
function updateColumnWidth(view, cell, width) {
|
|
84503
85172
|
const $cell = view.state.doc.resolve(cell);
|
|
@@ -84513,7 +85182,10 @@ function updateColumnWidth(view, cell, width) {
|
|
|
84513
85182
|
if (attrs.colwidth && attrs.colwidth[index2] == width) continue;
|
|
84514
85183
|
const colwidth = attrs.colwidth ? attrs.colwidth.slice() : zeroes(attrs.colspan);
|
|
84515
85184
|
colwidth[index2] = width;
|
|
84516
|
-
tr.setNodeMarkup(start2 + pos, null, {
|
|
85185
|
+
tr.setNodeMarkup(start2 + pos, null, {
|
|
85186
|
+
...attrs,
|
|
85187
|
+
colwidth
|
|
85188
|
+
});
|
|
84517
85189
|
}
|
|
84518
85190
|
if (tr.docChanged) view.dispatch(tr);
|
|
84519
85191
|
}
|
|
@@ -84522,64 +85194,38 @@ function displayColumnWidth(view, cell, width, defaultCellMinWidth) {
|
|
|
84522
85194
|
const table = $cell.node(-1), start2 = $cell.start(-1);
|
|
84523
85195
|
const col = TableMap.get(table).colCount($cell.pos - start2) + $cell.nodeAfter.attrs.colspan - 1;
|
|
84524
85196
|
let dom = view.domAtPos($cell.start(-1)).node;
|
|
84525
|
-
while (dom && dom.nodeName != "TABLE")
|
|
84526
|
-
dom = dom.parentNode;
|
|
84527
|
-
}
|
|
85197
|
+
while (dom && dom.nodeName != "TABLE") dom = dom.parentNode;
|
|
84528
85198
|
if (!dom) return;
|
|
84529
|
-
updateColumnsOnResize(
|
|
84530
|
-
table,
|
|
84531
|
-
dom.firstChild,
|
|
84532
|
-
dom,
|
|
84533
|
-
defaultCellMinWidth,
|
|
84534
|
-
col,
|
|
84535
|
-
width
|
|
84536
|
-
);
|
|
85199
|
+
updateColumnsOnResize(table, dom.firstChild, dom, defaultCellMinWidth, col, width);
|
|
84537
85200
|
}
|
|
84538
85201
|
function zeroes(n) {
|
|
84539
85202
|
return Array(n).fill(0);
|
|
84540
85203
|
}
|
|
84541
85204
|
function handleDecorations(state2, cell) {
|
|
84542
|
-
var _a2;
|
|
84543
85205
|
const decorations = [];
|
|
84544
85206
|
const $cell = state2.doc.resolve(cell);
|
|
84545
85207
|
const table = $cell.node(-1);
|
|
84546
|
-
if (!table)
|
|
84547
|
-
return DecorationSet.empty;
|
|
84548
|
-
}
|
|
85208
|
+
if (!table) return DecorationSet.empty;
|
|
84549
85209
|
const map22 = TableMap.get(table);
|
|
84550
85210
|
const start2 = $cell.start(-1);
|
|
84551
85211
|
const col = map22.colCount($cell.pos - start2) + $cell.nodeAfter.attrs.colspan - 1;
|
|
84552
85212
|
for (let row = 0; row < map22.height; row++) {
|
|
84553
85213
|
const index2 = col + row * map22.width;
|
|
84554
85214
|
if ((col == map22.width - 1 || map22.map[index2] != map22.map[index2 + 1]) && (row == 0 || map22.map[index2] != map22.map[index2 - map22.width])) {
|
|
85215
|
+
var _columnResizingPlugin;
|
|
84555
85216
|
const cellPos = map22.map[index2];
|
|
84556
85217
|
const pos = start2 + cellPos + table.nodeAt(cellPos).nodeSize - 1;
|
|
84557
85218
|
const dom = document.createElement("div");
|
|
84558
85219
|
dom.className = "column-resize-handle";
|
|
84559
|
-
if ((
|
|
84560
|
-
decorations.push(
|
|
84561
|
-
Decoration.node(
|
|
84562
|
-
start2 + cellPos,
|
|
84563
|
-
start2 + cellPos + table.nodeAt(cellPos).nodeSize,
|
|
84564
|
-
{
|
|
84565
|
-
class: "column-resize-dragging"
|
|
84566
|
-
}
|
|
84567
|
-
)
|
|
84568
|
-
);
|
|
84569
|
-
}
|
|
85220
|
+
if ((_columnResizingPlugin = columnResizingPluginKey.getState(state2)) === null || _columnResizingPlugin === void 0 ? void 0 : _columnResizingPlugin.dragging) decorations.push(Decoration.node(start2 + cellPos, start2 + cellPos + table.nodeAt(cellPos).nodeSize, { class: "column-resize-dragging" }));
|
|
84570
85221
|
decorations.push(Decoration.widget(pos, dom));
|
|
84571
85222
|
}
|
|
84572
85223
|
}
|
|
84573
85224
|
return DecorationSet.create(state2.doc, decorations);
|
|
84574
85225
|
}
|
|
84575
|
-
function tableEditing({
|
|
84576
|
-
allowTableNodeSelection = false
|
|
84577
|
-
} = {}) {
|
|
85226
|
+
function tableEditing({ allowTableNodeSelection = false } = {}) {
|
|
84578
85227
|
return new Plugin({
|
|
84579
85228
|
key: tableEditingKey,
|
|
84580
|
-
// This piece of state is used to remember when a mouse-drag
|
|
84581
|
-
// cell-selection is happening, so that it can continue even as
|
|
84582
|
-
// transactions (which might move its anchor cell) come in.
|
|
84583
85229
|
state: {
|
|
84584
85230
|
init() {
|
|
84585
85231
|
return null;
|
|
@@ -84594,9 +85240,7 @@ function tableEditing({
|
|
|
84594
85240
|
},
|
|
84595
85241
|
props: {
|
|
84596
85242
|
decorations: drawCellSelection,
|
|
84597
|
-
handleDOMEvents: {
|
|
84598
|
-
mousedown: handleMouseDown
|
|
84599
|
-
},
|
|
85243
|
+
handleDOMEvents: { mousedown: handleMouseDown },
|
|
84600
85244
|
createSelectionBetween(view) {
|
|
84601
85245
|
return tableEditingKey.getState(view.state) != null ? view.state.selection : null;
|
|
84602
85246
|
},
|
|
@@ -84605,11 +85249,7 @@ function tableEditing({
|
|
|
84605
85249
|
handlePaste
|
|
84606
85250
|
},
|
|
84607
85251
|
appendTransaction(_2, oldState, state2) {
|
|
84608
|
-
return normalizeSelection(
|
|
84609
|
-
state2,
|
|
84610
|
-
fixTables(state2, oldState),
|
|
84611
|
-
allowTableNodeSelection
|
|
84612
|
-
);
|
|
85252
|
+
return normalizeSelection(state2, fixTables(state2, oldState), allowTableNodeSelection);
|
|
84613
85253
|
}
|
|
84614
85254
|
});
|
|
84615
85255
|
}
|
|
@@ -95684,7 +96324,7 @@ const _hoisted_2$c = { key: 0 };
|
|
|
95684
96324
|
const _hoisted_3$a = { key: 0 };
|
|
95685
96325
|
const _hoisted_4$6 = { key: 1 };
|
|
95686
96326
|
const _hoisted_5$5 = { key: 1 };
|
|
95687
|
-
const _sfc_main$
|
|
96327
|
+
const _sfc_main$k = {
|
|
95688
96328
|
__name: "Mentions",
|
|
95689
96329
|
props: {
|
|
95690
96330
|
users: {
|
|
@@ -95767,7 +96407,7 @@ const _sfc_main$j = {
|
|
|
95767
96407
|
};
|
|
95768
96408
|
}
|
|
95769
96409
|
};
|
|
95770
|
-
const Mentions = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
96410
|
+
const Mentions = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["__scopeId", "data-v-bcae18cf"]]);
|
|
95771
96411
|
const popoverPluginKey = new PluginKey("popoverPlugin");
|
|
95772
96412
|
const PopoverPlugin = Extension.create({
|
|
95773
96413
|
name: "popoverPlugin",
|
|
@@ -106919,7 +107559,7 @@ const _sfc_main$1$1 = {
|
|
|
106919
107559
|
}
|
|
106920
107560
|
};
|
|
106921
107561
|
const ButtonGroup = /* @__PURE__ */ _export_sfc(_sfc_main$1$1, [["__scopeId", "data-v-c80a1e51"]]);
|
|
106922
|
-
const _sfc_main$
|
|
107562
|
+
const _sfc_main$j = {
|
|
106923
107563
|
__name: "Toolbar",
|
|
106924
107564
|
emits: ["command", "toggle", "select"],
|
|
106925
107565
|
setup(__props, { emit: __emit }) {
|
|
@@ -107001,7 +107641,7 @@ const _sfc_main$i = {
|
|
|
107001
107641
|
};
|
|
107002
107642
|
}
|
|
107003
107643
|
};
|
|
107004
|
-
const Toolbar = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
107644
|
+
const Toolbar = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["__scopeId", "data-v-3f5ec271"]]);
|
|
107005
107645
|
const DEFAULT_API_ENDPOINT = "https://sd-dev-express-gateway-i6xtm.ondigitalocean.app/insights";
|
|
107006
107646
|
const SYSTEM_PROMPT = "You are an expert copywriter and you are immersed in a document editor. You are to provide document related text responses based on the user prompts. Only write what is asked for. Do not provide explanations. Try to keep placeholders as short as possible. Do not output your prompt. Your instructions are: ";
|
|
107007
107647
|
async function baseInsightsFetch(payload, options = {}) {
|
|
@@ -107242,7 +107882,7 @@ const _hoisted_2$a = ["innerHTML"];
|
|
|
107242
107882
|
const _hoisted_3$8 = ["placeholder"];
|
|
107243
107883
|
const _hoisted_4$4 = { class: "ai-loader" };
|
|
107244
107884
|
const _hoisted_5$3 = ["innerHTML"];
|
|
107245
|
-
const _sfc_main$
|
|
107885
|
+
const _sfc_main$i = {
|
|
107246
107886
|
__name: "AIWriter",
|
|
107247
107887
|
props: {
|
|
107248
107888
|
selectedText: {
|
|
@@ -107518,7 +108158,7 @@ const _sfc_main$h = {
|
|
|
107518
108158
|
};
|
|
107519
108159
|
}
|
|
107520
108160
|
};
|
|
107521
|
-
const AIWriter = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
108161
|
+
const AIWriter = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["__scopeId", "data-v-d869be75"]]);
|
|
107522
108162
|
async function createZip(blobs, fileNames) {
|
|
107523
108163
|
const zip = new JSZip();
|
|
107524
108164
|
blobs.forEach((blob, index2) => {
|
|
@@ -107832,7 +108472,7 @@ const useToolbarItem = (options) => {
|
|
|
107832
108472
|
};
|
|
107833
108473
|
};
|
|
107834
108474
|
const _hoisted_1$f = ["onClick", "innerHTML", "aria-label", "onKeydown"];
|
|
107835
|
-
const _sfc_main$
|
|
108475
|
+
const _sfc_main$h = {
|
|
107836
108476
|
__name: "AlignmentButtons",
|
|
107837
108477
|
emits: ["select"],
|
|
107838
108478
|
setup(__props, { emit: __emit }) {
|
|
@@ -107923,14 +108563,14 @@ const _sfc_main$g = {
|
|
|
107923
108563
|
};
|
|
107924
108564
|
}
|
|
107925
108565
|
};
|
|
107926
|
-
const AlignmentButtons = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
108566
|
+
const AlignmentButtons = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["__scopeId", "data-v-d84f57b6"]]);
|
|
107927
108567
|
const _hoisted_1$e = ["onClick", "onKeydown"];
|
|
107928
108568
|
const _hoisted_2$9 = { class: "document-mode-column icon-column" };
|
|
107929
108569
|
const _hoisted_3$7 = ["innerHTML"];
|
|
107930
108570
|
const _hoisted_4$3 = { class: "document-mode-column text-column" };
|
|
107931
108571
|
const _hoisted_5$2 = { class: "document-mode-type" };
|
|
107932
108572
|
const _hoisted_6$1 = { class: "document-mode-description" };
|
|
107933
|
-
const _sfc_main$
|
|
108573
|
+
const _sfc_main$g = {
|
|
107934
108574
|
__name: "DocumentMode",
|
|
107935
108575
|
props: {
|
|
107936
108576
|
options: {
|
|
@@ -108010,14 +108650,14 @@ const _sfc_main$f = {
|
|
|
108010
108650
|
};
|
|
108011
108651
|
}
|
|
108012
108652
|
};
|
|
108013
|
-
const DocumentMode = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
108653
|
+
const DocumentMode = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["__scopeId", "data-v-8730b752"]]);
|
|
108014
108654
|
const _hoisted_1$d = {
|
|
108015
108655
|
key: 0,
|
|
108016
108656
|
class: "linked-style-buttons",
|
|
108017
108657
|
"data-editor-ui-surface": ""
|
|
108018
108658
|
};
|
|
108019
108659
|
const _hoisted_2$8 = ["onClick", "onKeydown", "aria-label"];
|
|
108020
|
-
const _sfc_main$
|
|
108660
|
+
const _sfc_main$f = {
|
|
108021
108661
|
__name: "LinkedStyle",
|
|
108022
108662
|
props: {
|
|
108023
108663
|
editor: {
|
|
@@ -108093,7 +108733,7 @@ const _sfc_main$e = {
|
|
|
108093
108733
|
};
|
|
108094
108734
|
}
|
|
108095
108735
|
};
|
|
108096
|
-
const LinkedStyle = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
108736
|
+
const LinkedStyle = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["__scopeId", "data-v-ecb78965"]]);
|
|
108097
108737
|
const _hoisted_1$c = {
|
|
108098
108738
|
key: 0,
|
|
108099
108739
|
class: "link-title"
|
|
@@ -108122,7 +108762,7 @@ const _hoisted_13 = {
|
|
|
108122
108762
|
key: 4,
|
|
108123
108763
|
class: "input-row go-to-anchor clickable"
|
|
108124
108764
|
};
|
|
108125
|
-
const _sfc_main$
|
|
108765
|
+
const _sfc_main$e = {
|
|
108126
108766
|
__name: "LinkInput",
|
|
108127
108767
|
props: {
|
|
108128
108768
|
showInput: {
|
|
@@ -108328,12 +108968,12 @@ const _sfc_main$d = {
|
|
|
108328
108968
|
};
|
|
108329
108969
|
}
|
|
108330
108970
|
};
|
|
108331
|
-
const LinkInput = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
108971
|
+
const LinkInput = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["__scopeId", "data-v-ba50627b"]]);
|
|
108332
108972
|
const _hoisted_1$b = ["aria-label", "onClick", "onKeydown"];
|
|
108333
108973
|
const _hoisted_2$6 = ["innerHTML"];
|
|
108334
108974
|
const _hoisted_3$5 = ["innerHTML"];
|
|
108335
108975
|
const ROW_SIZE$1 = 7;
|
|
108336
|
-
const _sfc_main$
|
|
108976
|
+
const _sfc_main$d = {
|
|
108337
108977
|
__name: "IconGridRow",
|
|
108338
108978
|
props: {
|
|
108339
108979
|
icons: {
|
|
@@ -108466,12 +109106,12 @@ const _sfc_main$c = {
|
|
|
108466
109106
|
};
|
|
108467
109107
|
}
|
|
108468
109108
|
};
|
|
108469
|
-
const IconGridRow = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
109109
|
+
const IconGridRow = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__scopeId", "data-v-0f479b6c"]]);
|
|
108470
109110
|
const DropIcon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M320 512c53.2 0 101.4-21.6 136.1-56.6l-298.3-235C140 257.1 128 292.3 128 320c0 106 86 192 192 192zM505.2 370.7c4.4-16.2 6.8-33.1 6.8-50.7c0-91.2-130.2-262.3-166.6-308.3C339.4 4.2 330.5 0 320.9 0l-1.8 0c-9.6 0-18.5 4.2-24.5 11.7C277.8 33 240.7 81.3 205.8 136L38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L505.2 370.7zM224 336c0 44.2 35.8 80 80 80c8.8 0 16 7.2 16 16s-7.2 16-16 16c-61.9 0-112-50.1-112-112c0-8.8 7.2-16 16-16s16 7.2 16 16z"/></svg>\n';
|
|
108471
109111
|
const _hoisted_1$a = { class: "options-grid-wrap" };
|
|
108472
109112
|
const _hoisted_2$5 = ["innerHTML"];
|
|
108473
109113
|
const _hoisted_3$4 = { class: "option-grid-ctn" };
|
|
108474
|
-
const _sfc_main$
|
|
109114
|
+
const _sfc_main$c = {
|
|
108475
109115
|
__name: "IconGrid",
|
|
108476
109116
|
props: {
|
|
108477
109117
|
icons: {
|
|
@@ -108531,7 +109171,7 @@ const _sfc_main$b = {
|
|
|
108531
109171
|
};
|
|
108532
109172
|
}
|
|
108533
109173
|
};
|
|
108534
|
-
const IconGrid = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
109174
|
+
const IconGrid = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-3d19fedf"]]);
|
|
108535
109175
|
const closeDropdown$1 = (dropdown) => {
|
|
108536
109176
|
dropdown.expand.value = false;
|
|
108537
109177
|
};
|
|
@@ -108643,7 +109283,7 @@ const getAvailableColorOptions = () => {
|
|
|
108643
109283
|
const _hoisted_1$9 = ["data-cols", "data-rows", "onKeydown", "onClick"];
|
|
108644
109284
|
const _hoisted_2$4 = ["aria-valuetext"];
|
|
108645
109285
|
const ROW_SIZE = 5;
|
|
108646
|
-
const _sfc_main$
|
|
109286
|
+
const _sfc_main$b = {
|
|
108647
109287
|
__name: "TableGrid",
|
|
108648
109288
|
emits: ["select", "clickoutside"],
|
|
108649
109289
|
setup(__props, { emit: __emit }) {
|
|
@@ -108772,13 +109412,13 @@ const _sfc_main$a = {
|
|
|
108772
109412
|
};
|
|
108773
109413
|
}
|
|
108774
109414
|
};
|
|
108775
|
-
const TableGrid = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
109415
|
+
const TableGrid = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["__scopeId", "data-v-92e8d5fb"]]);
|
|
108776
109416
|
const _hoisted_1$8 = { class: "toolbar-table-actions" };
|
|
108777
109417
|
const _hoisted_2$3 = ["onClick", "data-item", "ariaLabel"];
|
|
108778
109418
|
const _hoisted_3$3 = { class: "toolbar-table-actions__icon" };
|
|
108779
109419
|
const _hoisted_4$1 = ["innerHTML"];
|
|
108780
109420
|
const _hoisted_5 = { class: "toolbar-table-actions__label" };
|
|
108781
|
-
const _sfc_main$
|
|
109421
|
+
const _sfc_main$a = {
|
|
108782
109422
|
__name: "TableActions",
|
|
108783
109423
|
props: {
|
|
108784
109424
|
options: {
|
|
@@ -108814,7 +109454,7 @@ const _sfc_main$9 = {
|
|
|
108814
109454
|
};
|
|
108815
109455
|
}
|
|
108816
109456
|
};
|
|
108817
|
-
const TableActions = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
109457
|
+
const TableActions = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-990b9a25"]]);
|
|
108818
109458
|
function getScrollableParent(element) {
|
|
108819
109459
|
let currentElement = element;
|
|
108820
109460
|
while (currentElement) {
|
|
@@ -108841,7 +109481,7 @@ const checkIconSvg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 5
|
|
|
108841
109481
|
const _hoisted_1$7 = { class: "search-input-ctn" };
|
|
108842
109482
|
const _hoisted_2$2 = { class: "row" };
|
|
108843
109483
|
const _hoisted_3$2 = ["onKeydown"];
|
|
108844
|
-
const _sfc_main$
|
|
109484
|
+
const _sfc_main$9 = {
|
|
108845
109485
|
__name: "SearchInput",
|
|
108846
109486
|
props: {
|
|
108847
109487
|
searchRef: {
|
|
@@ -108880,7 +109520,7 @@ const _sfc_main$8 = {
|
|
|
108880
109520
|
};
|
|
108881
109521
|
}
|
|
108882
109522
|
};
|
|
108883
|
-
const SearchInput = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
109523
|
+
const SearchInput = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-957cbcf2"]]);
|
|
108884
109524
|
const TOOLBAR_FONTS = [
|
|
108885
109525
|
{
|
|
108886
109526
|
label: "Georgia",
|
|
@@ -111655,7 +112295,7 @@ const _hoisted_2$1 = {
|
|
|
111655
112295
|
};
|
|
111656
112296
|
const _hoisted_3$1 = ["onClick"];
|
|
111657
112297
|
const _hoisted_4 = ["innerHTML"];
|
|
111658
|
-
const _sfc_main$
|
|
112298
|
+
const _sfc_main$8 = {
|
|
111659
112299
|
__name: "SlashMenu",
|
|
111660
112300
|
props: {
|
|
111661
112301
|
editor: {
|
|
@@ -112007,7 +112647,7 @@ const _sfc_main$7 = {
|
|
|
112007
112647
|
}
|
|
112008
112648
|
};
|
|
112009
112649
|
const _hoisted_1$5 = ["accept"];
|
|
112010
|
-
const _sfc_main$
|
|
112650
|
+
const _sfc_main$7 = /* @__PURE__ */ vue.defineComponent({
|
|
112011
112651
|
__name: "BasicUpload",
|
|
112012
112652
|
props: {
|
|
112013
112653
|
accept: { default: ".docx, .pdf, .html, .md" }
|
|
@@ -112036,7 +112676,7 @@ const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
|
|
|
112036
112676
|
const _hoisted_1$4 = { class: "numbering" };
|
|
112037
112677
|
const MIN_WIDTH = 200;
|
|
112038
112678
|
const alignment = "flex-end";
|
|
112039
|
-
const _sfc_main$
|
|
112679
|
+
const _sfc_main$6 = {
|
|
112040
112680
|
__name: "Ruler",
|
|
112041
112681
|
props: {
|
|
112042
112682
|
orientation: {
|
|
@@ -112127,7 +112767,7 @@ const _sfc_main$5 = {
|
|
|
112127
112767
|
minHeight: `${editorBounds.height}px`
|
|
112128
112768
|
};
|
|
112129
112769
|
});
|
|
112130
|
-
const
|
|
112770
|
+
const handleMouseDown2 = (event) => {
|
|
112131
112771
|
isDragging.value = true;
|
|
112132
112772
|
setRulerHandleActive();
|
|
112133
112773
|
const itemId = event.currentTarget.id;
|
|
@@ -112202,13 +112842,13 @@ const _sfc_main$5 = {
|
|
|
112202
112842
|
vue.createBaseVNode("div", {
|
|
112203
112843
|
class: "margin-handle handle-left",
|
|
112204
112844
|
id: "left-margin-handle",
|
|
112205
|
-
onMousedown:
|
|
112845
|
+
onMousedown: handleMouseDown2,
|
|
112206
112846
|
style: vue.normalizeStyle(getHandlePosition.value("left"))
|
|
112207
112847
|
}, null, 36),
|
|
112208
112848
|
vue.createBaseVNode("div", {
|
|
112209
112849
|
class: "margin-handle handle-right",
|
|
112210
112850
|
id: "right-margin-handle",
|
|
112211
|
-
onMousedown:
|
|
112851
|
+
onMousedown: handleMouseDown2,
|
|
112212
112852
|
style: vue.normalizeStyle(getHandlePosition.value("right"))
|
|
112213
112853
|
}, null, 36),
|
|
112214
112854
|
showVerticalIndicator.value ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
@@ -112241,8 +112881,8 @@ const _sfc_main$5 = {
|
|
|
112241
112881
|
};
|
|
112242
112882
|
}
|
|
112243
112883
|
};
|
|
112244
|
-
const Ruler = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
112245
|
-
const _sfc_main$
|
|
112884
|
+
const Ruler = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-79f9a944"]]);
|
|
112885
|
+
const _sfc_main$5 = {
|
|
112246
112886
|
__name: "GenericPopover",
|
|
112247
112887
|
props: {
|
|
112248
112888
|
editor: { type: Object, required: true },
|
|
@@ -112270,22 +112910,22 @@ const _sfc_main$4 = {
|
|
|
112270
112910
|
() => props.visible,
|
|
112271
112911
|
(val) => {
|
|
112272
112912
|
if (val) {
|
|
112273
|
-
document.addEventListener("
|
|
112913
|
+
document.addEventListener("pointerdown", handleClickOutside2);
|
|
112274
112914
|
document.addEventListener("keydown", handleEscape);
|
|
112275
112915
|
} else {
|
|
112276
|
-
document.removeEventListener("
|
|
112916
|
+
document.removeEventListener("pointerdown", handleClickOutside2);
|
|
112277
112917
|
document.removeEventListener("keydown", handleEscape);
|
|
112278
112918
|
}
|
|
112279
112919
|
}
|
|
112280
112920
|
);
|
|
112281
112921
|
vue.onMounted(() => {
|
|
112282
112922
|
if (props.visible) {
|
|
112283
|
-
document.addEventListener("
|
|
112923
|
+
document.addEventListener("pointerdown", handleClickOutside2);
|
|
112284
112924
|
document.addEventListener("keydown", handleEscape);
|
|
112285
112925
|
}
|
|
112286
112926
|
});
|
|
112287
112927
|
vue.onBeforeUnmount(() => {
|
|
112288
|
-
document.removeEventListener("
|
|
112928
|
+
document.removeEventListener("pointerdown", handleClickOutside2);
|
|
112289
112929
|
document.removeEventListener("keydown", handleEscape);
|
|
112290
112930
|
});
|
|
112291
112931
|
const derivedStyles = vue.computed(() => ({
|
|
@@ -112300,7 +112940,7 @@ const _sfc_main$4 = {
|
|
|
112300
112940
|
style: vue.normalizeStyle(derivedStyles.value),
|
|
112301
112941
|
ref_key: "popover",
|
|
112302
112942
|
ref: popover,
|
|
112303
|
-
|
|
112943
|
+
onPointerdown: _cache[0] || (_cache[0] = vue.withModifiers(() => {
|
|
112304
112944
|
}, ["stop"])),
|
|
112305
112945
|
onClick: _cache[1] || (_cache[1] = vue.withModifiers(() => {
|
|
112306
112946
|
}, ["stop"]))
|
|
@@ -112310,7 +112950,7 @@ const _sfc_main$4 = {
|
|
|
112310
112950
|
};
|
|
112311
112951
|
}
|
|
112312
112952
|
};
|
|
112313
|
-
const GenericPopover = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
112953
|
+
const GenericPopover = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-157855b5"]]);
|
|
112314
112954
|
const _hoisted_1$3 = ["data-boundary-index", "data-boundary-type", "onMousedown"];
|
|
112315
112955
|
const RESIZE_HANDLE_WIDTH_PX = 9;
|
|
112316
112956
|
const RESIZE_HANDLE_OFFSET_PX = 4;
|
|
@@ -112318,7 +112958,7 @@ const DRAG_OVERLAY_EXTENSION_PX = 1e3;
|
|
|
112318
112958
|
const MIN_DRAG_OVERLAY_WIDTH_PX = 2e3;
|
|
112319
112959
|
const THROTTLE_INTERVAL_MS = 16;
|
|
112320
112960
|
const MIN_RESIZE_DELTA_PX = 1;
|
|
112321
|
-
const _sfc_main$
|
|
112961
|
+
const _sfc_main$4 = {
|
|
112322
112962
|
__name: "TableResizeOverlay",
|
|
112323
112963
|
props: {
|
|
112324
112964
|
/** Editor instance for dispatching transactions */
|
|
@@ -112842,7 +113482,7 @@ const _sfc_main$3 = {
|
|
|
112842
113482
|
};
|
|
112843
113483
|
}
|
|
112844
113484
|
};
|
|
112845
|
-
const TableResizeOverlay = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
113485
|
+
const TableResizeOverlay = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-2fdf7836"]]);
|
|
112846
113486
|
const _hoisted_1$2 = ["data-handle-position", "onMousedown"];
|
|
112847
113487
|
const OVERLAY_EXPANSION_PX = 2e3;
|
|
112848
113488
|
const RESIZE_HANDLE_SIZE_PX = 12;
|
|
@@ -112851,7 +113491,7 @@ const DIMENSION_CHANGE_THRESHOLD_PX = 1;
|
|
|
112851
113491
|
const Z_INDEX_OVERLAY = 10;
|
|
112852
113492
|
const Z_INDEX_HANDLE = 15;
|
|
112853
113493
|
const Z_INDEX_GUIDELINE = 20;
|
|
112854
|
-
const _sfc_main$
|
|
113494
|
+
const _sfc_main$3 = {
|
|
112855
113495
|
__name: "ImageResizeOverlay",
|
|
112856
113496
|
props: {
|
|
112857
113497
|
/** Editor instance for dispatching transactions */
|
|
@@ -113275,7 +113915,81 @@ const _sfc_main$2 = {
|
|
|
113275
113915
|
};
|
|
113276
113916
|
}
|
|
113277
113917
|
};
|
|
113278
|
-
const ImageResizeOverlay = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
113918
|
+
const ImageResizeOverlay = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-e66ec7bb"]]);
|
|
113919
|
+
const _sfc_main$2 = {
|
|
113920
|
+
__name: "LinkClickHandler",
|
|
113921
|
+
props: {
|
|
113922
|
+
editor: {
|
|
113923
|
+
type: Object,
|
|
113924
|
+
required: true
|
|
113925
|
+
},
|
|
113926
|
+
openPopover: {
|
|
113927
|
+
type: Function,
|
|
113928
|
+
required: true
|
|
113929
|
+
},
|
|
113930
|
+
closePopover: {
|
|
113931
|
+
type: Function,
|
|
113932
|
+
required: true
|
|
113933
|
+
},
|
|
113934
|
+
popoverVisible: {
|
|
113935
|
+
type: Boolean,
|
|
113936
|
+
default: false
|
|
113937
|
+
}
|
|
113938
|
+
},
|
|
113939
|
+
setup(__props) {
|
|
113940
|
+
const props = __props;
|
|
113941
|
+
const handleLinkClick = (event) => {
|
|
113942
|
+
if (props.popoverVisible) {
|
|
113943
|
+
props.closePopover();
|
|
113944
|
+
return;
|
|
113945
|
+
}
|
|
113946
|
+
if (!props.editor || !props.editor.state) {
|
|
113947
|
+
return;
|
|
113948
|
+
}
|
|
113949
|
+
const surface = getEditorSurfaceElement(props.editor);
|
|
113950
|
+
if (!surface) {
|
|
113951
|
+
return;
|
|
113952
|
+
}
|
|
113953
|
+
moveCursorToMouseEvent(event.detail, props.editor);
|
|
113954
|
+
setTimeout(() => {
|
|
113955
|
+
const currentState = props.editor.state;
|
|
113956
|
+
const hasLink = selectionHasNodeOrMark(currentState, "link", { requireEnds: true });
|
|
113957
|
+
if (hasLink) {
|
|
113958
|
+
const surfaceRect = surface.getBoundingClientRect();
|
|
113959
|
+
if (!surfaceRect) return;
|
|
113960
|
+
props.openPopover(
|
|
113961
|
+
vue.markRaw(LinkInput),
|
|
113962
|
+
{
|
|
113963
|
+
showInput: true,
|
|
113964
|
+
editor: props.editor,
|
|
113965
|
+
closePopover: props.closePopover
|
|
113966
|
+
},
|
|
113967
|
+
{
|
|
113968
|
+
left: `${event.detail.clientX - surfaceRect.left}px`,
|
|
113969
|
+
top: `${event.detail.clientY - surfaceRect.top + 15}px`
|
|
113970
|
+
}
|
|
113971
|
+
);
|
|
113972
|
+
}
|
|
113973
|
+
}, 10);
|
|
113974
|
+
};
|
|
113975
|
+
let surfaceElement = null;
|
|
113976
|
+
vue.onMounted(() => {
|
|
113977
|
+
if (!props.editor) return;
|
|
113978
|
+
surfaceElement = getEditorSurfaceElement(props.editor);
|
|
113979
|
+
if (surfaceElement) {
|
|
113980
|
+
surfaceElement.addEventListener("superdoc-link-click", handleLinkClick);
|
|
113981
|
+
}
|
|
113982
|
+
});
|
|
113983
|
+
vue.onBeforeUnmount(() => {
|
|
113984
|
+
if (surfaceElement) {
|
|
113985
|
+
surfaceElement.removeEventListener("superdoc-link-click", handleLinkClick);
|
|
113986
|
+
}
|
|
113987
|
+
});
|
|
113988
|
+
return (_ctx, _cache) => {
|
|
113989
|
+
return null;
|
|
113990
|
+
};
|
|
113991
|
+
}
|
|
113992
|
+
};
|
|
113279
113993
|
function adjustPaginationBreaks(editorElem, editor) {
|
|
113280
113994
|
if (!editorElem.value || !editor?.value?.options?.scale || isHeadless(editor)) return;
|
|
113281
113995
|
const zoom = editor.value.options.scale;
|
|
@@ -113617,21 +114331,28 @@ const _sfc_main$1 = {
|
|
|
113617
114331
|
class: "editor-element super-editor__element",
|
|
113618
114332
|
role: "presentation"
|
|
113619
114333
|
}, null, 512),
|
|
113620
|
-
!contextMenuDisabled.value && editorReady.value && activeEditor.value ? (vue.openBlock(), vue.createBlock(_sfc_main$
|
|
114334
|
+
!contextMenuDisabled.value && editorReady.value && activeEditor.value ? (vue.openBlock(), vue.createBlock(_sfc_main$8, {
|
|
113621
114335
|
key: 0,
|
|
113622
114336
|
editor: activeEditor.value,
|
|
113623
114337
|
popoverControls,
|
|
113624
114338
|
openPopover,
|
|
113625
114339
|
closePopover
|
|
113626
114340
|
}, null, 8, ["editor", "popoverControls"])) : vue.createCommentVNode("", true),
|
|
113627
|
-
editorReady.value && activeEditor.value ? (vue.openBlock(), vue.createBlock(
|
|
114341
|
+
editorReady.value && activeEditor.value ? (vue.openBlock(), vue.createBlock(_sfc_main$2, {
|
|
113628
114342
|
key: 1,
|
|
113629
114343
|
editor: activeEditor.value,
|
|
114344
|
+
openPopover,
|
|
114345
|
+
closePopover,
|
|
114346
|
+
popoverVisible: popoverControls.visible
|
|
114347
|
+
}, null, 8, ["editor", "popoverVisible"])) : vue.createCommentVNode("", true),
|
|
114348
|
+
editorReady.value && activeEditor.value ? (vue.openBlock(), vue.createBlock(TableResizeOverlay, {
|
|
114349
|
+
key: 2,
|
|
114350
|
+
editor: activeEditor.value,
|
|
113630
114351
|
visible: tableResizeState.visible,
|
|
113631
114352
|
tableElement: tableResizeState.tableElement
|
|
113632
114353
|
}, null, 8, ["editor", "visible", "tableElement"])) : vue.createCommentVNode("", true),
|
|
113633
114354
|
editorReady.value && activeEditor.value ? (vue.openBlock(), vue.createBlock(ImageResizeOverlay, {
|
|
113634
|
-
key:
|
|
114355
|
+
key: 3,
|
|
113635
114356
|
editor: activeEditor.value,
|
|
113636
114357
|
visible: imageResizeState.visible,
|
|
113637
114358
|
imageElement: imageResizeState.imageElement
|
|
@@ -113698,7 +114419,7 @@ const _sfc_main$1 = {
|
|
|
113698
114419
|
};
|
|
113699
114420
|
}
|
|
113700
114421
|
};
|
|
113701
|
-
const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
114422
|
+
const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-08b32c3d"]]);
|
|
113702
114423
|
const _hoisted_1 = ["innerHTML"];
|
|
113703
114424
|
const _sfc_main = {
|
|
113704
114425
|
__name: "SuperInput",
|
|
@@ -113815,8 +114536,8 @@ exports.SuperInput = SuperInput;
|
|
|
113815
114536
|
exports.SuperToolbar = SuperToolbar;
|
|
113816
114537
|
exports.Toolbar = Toolbar;
|
|
113817
114538
|
exports.TrackChangesBasePluginKey = TrackChangesBasePluginKey;
|
|
113818
|
-
exports._sfc_main$6 = _sfc_main$6;
|
|
113819
114539
|
exports._sfc_main$7 = _sfc_main$7;
|
|
114540
|
+
exports._sfc_main$8 = _sfc_main$8;
|
|
113820
114541
|
exports.createZip = createZip;
|
|
113821
114542
|
exports.getActiveFormatting = getActiveFormatting;
|
|
113822
114543
|
exports.getAllowedImageDimensions = getAllowedImageDimensions;
|