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
package/dist/superdoc.umd.js
CHANGED
|
@@ -19192,6 +19192,7 @@
|
|
|
19192
19192
|
if (color2) add("text-decoration-color", color2);
|
|
19193
19193
|
return parts.join("; ");
|
|
19194
19194
|
}
|
|
19195
|
+
const INLINE_OVERRIDE_PROPERTIES = ["fontSize", "bold", "italic", "strike", "underline", "letterSpacing"];
|
|
19195
19196
|
const resolveRunProperties = (params2, inlineRpr, resolvedPpr, isListNumber = false, numberingDefinedInline = false) => {
|
|
19196
19197
|
const paragraphStyleId = resolvedPpr?.styleId;
|
|
19197
19198
|
const paragraphStyleProps = resolveStyleChain$1(params2, paragraphStyleId, translator$1N);
|
|
@@ -19228,6 +19229,11 @@
|
|
|
19228
19229
|
styleChain = [...styleChain, paragraphStyleProps, runStyleProps, inlineRpr];
|
|
19229
19230
|
}
|
|
19230
19231
|
const finalProps = combineProperties(styleChain, ["fontFamily", "color"]);
|
|
19232
|
+
for (const prop of INLINE_OVERRIDE_PROPERTIES) {
|
|
19233
|
+
if (inlineRpr?.[prop] != null) {
|
|
19234
|
+
finalProps[prop] = inlineRpr[prop];
|
|
19235
|
+
}
|
|
19236
|
+
}
|
|
19231
19237
|
return finalProps;
|
|
19232
19238
|
};
|
|
19233
19239
|
function resolveParagraphProperties(params2, inlineProps, insideTable = false, overrideInlineStyleId = false, tableStyleId = null) {
|
|
@@ -25035,8 +25041,8 @@
|
|
|
25035
25041
|
horizontal: positionHValue,
|
|
25036
25042
|
top: positionVValue
|
|
25037
25043
|
};
|
|
25038
|
-
const useSimplePos = attributes["simplePos"] === "1" || attributes["simplePos"] === 1;
|
|
25039
|
-
const
|
|
25044
|
+
const useSimplePos = attributes["simplePos"] === "1" || attributes["simplePos"] === 1 || attributes["simplePos"] === true;
|
|
25045
|
+
const simplePosNode = node2.elements.find((el) => el.name === "wp:simplePos");
|
|
25040
25046
|
const wrapNode = isAnchor ? node2.elements.find(
|
|
25041
25047
|
(el) => ["wp:wrapNone", "wp:wrapSquare", "wp:wrapThrough", "wp:wrapTight", "wp:wrapTopAndBottom"].includes(el.name)
|
|
25042
25048
|
) : null;
|
|
@@ -25176,10 +25182,10 @@
|
|
|
25176
25182
|
anchorData,
|
|
25177
25183
|
isAnchor,
|
|
25178
25184
|
transformData,
|
|
25179
|
-
...
|
|
25185
|
+
...useSimplePos && {
|
|
25180
25186
|
simplePos: {
|
|
25181
|
-
x:
|
|
25182
|
-
y:
|
|
25187
|
+
x: simplePosNode.attributes?.x,
|
|
25188
|
+
y: simplePosNode.attributes?.y
|
|
25183
25189
|
}
|
|
25184
25190
|
},
|
|
25185
25191
|
wrap: wrap2,
|
|
@@ -30937,12 +30943,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
30937
30943
|
function translateAnchorNode(params2) {
|
|
30938
30944
|
const { attrs } = params2.node;
|
|
30939
30945
|
const anchorElements = [];
|
|
30940
|
-
|
|
30946
|
+
const hasSimplePos = attrs.simplePos || attrs.originalAttributes?.simplePos;
|
|
30947
|
+
if (hasSimplePos) {
|
|
30941
30948
|
anchorElements.push({
|
|
30942
30949
|
name: "wp:simplePos",
|
|
30943
30950
|
attributes: {
|
|
30944
|
-
x: 0,
|
|
30945
|
-
y: 0
|
|
30951
|
+
x: attrs.simplePos?.x ?? 0,
|
|
30952
|
+
y: attrs.simplePos?.y ?? 0
|
|
30946
30953
|
}
|
|
30947
30954
|
});
|
|
30948
30955
|
}
|
|
@@ -30994,8 +31001,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
30994
31001
|
}
|
|
30995
31002
|
if (attrs.originalAttributes?.simplePos !== void 0) {
|
|
30996
31003
|
inlineAttrs.simplePos = attrs.originalAttributes.simplePos;
|
|
30997
|
-
} else if (
|
|
30998
|
-
inlineAttrs.simplePos =
|
|
31004
|
+
} else if (hasSimplePos) {
|
|
31005
|
+
inlineAttrs.simplePos = "1";
|
|
30999
31006
|
}
|
|
31000
31007
|
if (attrs.originalAttributes?.locked !== void 0) {
|
|
31001
31008
|
inlineAttrs.locked = attrs.originalAttributes.locked;
|
|
@@ -33760,7 +33767,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
33760
33767
|
const { nodes = [] } = params2;
|
|
33761
33768
|
const node2 = nodes[0];
|
|
33762
33769
|
if (!node2) return { nodes: [], consumed: 0 };
|
|
33763
|
-
if (registeredHandlers[node2.name]) {
|
|
33770
|
+
if (registeredHandlers[node2.name] || node2.name === "w:commentReference") {
|
|
33764
33771
|
return { nodes: [], consumed: 0 };
|
|
33765
33772
|
}
|
|
33766
33773
|
const originalXml = carbonCopy(node2) || {};
|
|
@@ -34060,7 +34067,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
34060
34067
|
const generateCommentsWithExtendedData = ({ docx, comments }) => {
|
|
34061
34068
|
if (!comments?.length) return [];
|
|
34062
34069
|
const commentsExtended = docx["word/commentsExtended.xml"];
|
|
34063
|
-
if (!commentsExtended)
|
|
34070
|
+
if (!commentsExtended) {
|
|
34071
|
+
const commentRanges = extractCommentRangesFromDocument(docx);
|
|
34072
|
+
const commentsWithThreading = detectThreadingFromRanges(comments, commentRanges);
|
|
34073
|
+
return commentsWithThreading.map((comment2) => ({ ...comment2, isDone: comment2.isDone ?? false }));
|
|
34074
|
+
}
|
|
34064
34075
|
const { elements: initialElements = [] } = commentsExtended;
|
|
34065
34076
|
if (!initialElements?.length) return comments.map((comment2) => ({ ...comment2, isDone: comment2.isDone ?? false }));
|
|
34066
34077
|
const { elements = [] } = initialElements[0] ?? {};
|
|
@@ -34086,6 +34097,79 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
34086
34097
|
const paraIdParent = attributes["w15:paraIdParent"];
|
|
34087
34098
|
return { paraId, isDone, paraIdParent };
|
|
34088
34099
|
};
|
|
34100
|
+
const extractCommentRangesFromDocument = (docx) => {
|
|
34101
|
+
const documentXml = docx["word/document.xml"];
|
|
34102
|
+
if (!documentXml) {
|
|
34103
|
+
return [];
|
|
34104
|
+
}
|
|
34105
|
+
const pendingComments = [];
|
|
34106
|
+
const walkElements = (elements) => {
|
|
34107
|
+
if (!elements || !Array.isArray(elements)) return;
|
|
34108
|
+
elements.forEach((element2) => {
|
|
34109
|
+
if (element2.name === "w:commentRangeStart") {
|
|
34110
|
+
const commentId = element2.attributes?.["w:id"];
|
|
34111
|
+
if (commentId !== void 0) {
|
|
34112
|
+
pendingComments.push({
|
|
34113
|
+
type: "start",
|
|
34114
|
+
commentId: String(commentId)
|
|
34115
|
+
});
|
|
34116
|
+
}
|
|
34117
|
+
} else if (element2.name === "w:commentRangeEnd") {
|
|
34118
|
+
const commentId = element2.attributes?.["w:id"];
|
|
34119
|
+
if (commentId !== void 0) {
|
|
34120
|
+
pendingComments.push({
|
|
34121
|
+
type: "end",
|
|
34122
|
+
commentId: String(commentId)
|
|
34123
|
+
});
|
|
34124
|
+
}
|
|
34125
|
+
}
|
|
34126
|
+
if (element2.elements && Array.isArray(element2.elements)) {
|
|
34127
|
+
walkElements(element2.elements);
|
|
34128
|
+
}
|
|
34129
|
+
});
|
|
34130
|
+
};
|
|
34131
|
+
if (documentXml.elements && documentXml.elements.length > 0) {
|
|
34132
|
+
const body = documentXml.elements[0];
|
|
34133
|
+
if (body.elements) {
|
|
34134
|
+
walkElements(body.elements);
|
|
34135
|
+
}
|
|
34136
|
+
}
|
|
34137
|
+
return pendingComments;
|
|
34138
|
+
};
|
|
34139
|
+
const detectThreadingFromRanges = (comments, rangeEvents) => {
|
|
34140
|
+
if (!rangeEvents || rangeEvents.length === 0) {
|
|
34141
|
+
return comments;
|
|
34142
|
+
}
|
|
34143
|
+
const openRanges = [];
|
|
34144
|
+
const parentMap = /* @__PURE__ */ new Map();
|
|
34145
|
+
rangeEvents.forEach((event) => {
|
|
34146
|
+
if (event.type === "start") {
|
|
34147
|
+
if (openRanges.length > 0) {
|
|
34148
|
+
const parentCommentId = openRanges[openRanges.length - 1];
|
|
34149
|
+
parentMap.set(event.commentId, parentCommentId);
|
|
34150
|
+
}
|
|
34151
|
+
openRanges.push(event.commentId);
|
|
34152
|
+
} else if (event.type === "end") {
|
|
34153
|
+
const index2 = openRanges.lastIndexOf(event.commentId);
|
|
34154
|
+
if (index2 !== -1) {
|
|
34155
|
+
openRanges.splice(index2, 1);
|
|
34156
|
+
}
|
|
34157
|
+
}
|
|
34158
|
+
});
|
|
34159
|
+
return comments.map((comment2) => {
|
|
34160
|
+
const parentCommentId = parentMap.get(comment2.importedId);
|
|
34161
|
+
if (parentCommentId) {
|
|
34162
|
+
const parentComment = comments.find((c2) => c2.importedId === parentCommentId);
|
|
34163
|
+
if (parentComment) {
|
|
34164
|
+
return {
|
|
34165
|
+
...comment2,
|
|
34166
|
+
parentCommentId: parentComment.commentId
|
|
34167
|
+
};
|
|
34168
|
+
}
|
|
34169
|
+
}
|
|
34170
|
+
return comment2;
|
|
34171
|
+
});
|
|
34172
|
+
};
|
|
34089
34173
|
const RELATIONSHIP_TYPES = (
|
|
34090
34174
|
/** @type {const} */
|
|
34091
34175
|
{
|
|
@@ -35926,10 +36010,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
35926
36010
|
const updateCommentsXml = (commentDefs = [], commentsXml) => {
|
|
35927
36011
|
const newCommentsXml = carbonCopy(commentsXml);
|
|
35928
36012
|
commentDefs.forEach((commentDef) => {
|
|
35929
|
-
const
|
|
36013
|
+
const paraNode = commentDef.elements[0];
|
|
36014
|
+
if (!paraNode.attributes) paraNode.attributes = {};
|
|
36015
|
+
const elements = paraNode.elements;
|
|
35930
36016
|
elements.unshift(COMMENT_REF);
|
|
35931
36017
|
const paraId = commentDef.attributes["w15:paraId"];
|
|
35932
|
-
|
|
36018
|
+
paraNode.attributes["w14:paraId"] = paraId;
|
|
35933
36019
|
commentDef.attributes = {
|
|
35934
36020
|
"w:id": commentDef.attributes["w:id"],
|
|
35935
36021
|
"w:author": commentDef.attributes["w:author"],
|
|
@@ -36303,7 +36389,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36303
36389
|
static getStoredSuperdocVersion(docx) {
|
|
36304
36390
|
return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
|
|
36305
36391
|
}
|
|
36306
|
-
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.
|
|
36392
|
+
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.19") {
|
|
36307
36393
|
return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
|
|
36308
36394
|
}
|
|
36309
36395
|
/**
|
|
@@ -36644,6 +36730,112 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36644
36730
|
});
|
|
36645
36731
|
return { result, params: params2 };
|
|
36646
36732
|
}
|
|
36733
|
+
/**
|
|
36734
|
+
* Creates a default empty header for the specified variant.
|
|
36735
|
+
*
|
|
36736
|
+
* This method programmatically creates a new header section with an empty ProseMirror
|
|
36737
|
+
* document. The header is added to the converter's data structures and will be included
|
|
36738
|
+
* in subsequent DOCX exports.
|
|
36739
|
+
*
|
|
36740
|
+
* @param {('default' | 'first' | 'even' | 'odd')} variant - The header variant to create
|
|
36741
|
+
* @returns {string} The relationship ID of the created header
|
|
36742
|
+
*
|
|
36743
|
+
* @throws {Error} If variant is invalid or header already exists for this variant
|
|
36744
|
+
*
|
|
36745
|
+
* @example
|
|
36746
|
+
* ```javascript
|
|
36747
|
+
* const headerId = converter.createDefaultHeader('default');
|
|
36748
|
+
* // headerId: 'rId-header-default'
|
|
36749
|
+
* // converter.headers['rId-header-default'] contains empty PM doc
|
|
36750
|
+
* // converter.headerIds.default === 'rId-header-default'
|
|
36751
|
+
* ```
|
|
36752
|
+
*/
|
|
36753
|
+
createDefaultHeader(variant = "default") {
|
|
36754
|
+
if (typeof variant !== "string") {
|
|
36755
|
+
throw new TypeError(`variant must be a string, received ${typeof variant}`);
|
|
36756
|
+
}
|
|
36757
|
+
const validVariants = ["default", "first", "even", "odd"];
|
|
36758
|
+
if (!validVariants.includes(variant)) {
|
|
36759
|
+
throw new Error(`Invalid header variant: ${variant}. Must be one of: ${validVariants.join(", ")}`);
|
|
36760
|
+
}
|
|
36761
|
+
if (this.headerIds[variant]) {
|
|
36762
|
+
console.warn(`[SuperConverter] Header already exists for variant '${variant}': ${this.headerIds[variant]}`);
|
|
36763
|
+
return this.headerIds[variant];
|
|
36764
|
+
}
|
|
36765
|
+
const rId = `rId-header-${variant}`;
|
|
36766
|
+
const emptyDoc = {
|
|
36767
|
+
type: "doc",
|
|
36768
|
+
content: [
|
|
36769
|
+
{
|
|
36770
|
+
type: "paragraph",
|
|
36771
|
+
content: []
|
|
36772
|
+
}
|
|
36773
|
+
]
|
|
36774
|
+
};
|
|
36775
|
+
this.headers[rId] = emptyDoc;
|
|
36776
|
+
this.headerIds[variant] = rId;
|
|
36777
|
+
if (!this.headerIds.ids) {
|
|
36778
|
+
this.headerIds.ids = [];
|
|
36779
|
+
}
|
|
36780
|
+
if (!this.headerIds.ids.includes(rId)) {
|
|
36781
|
+
this.headerIds.ids.push(rId);
|
|
36782
|
+
}
|
|
36783
|
+
this.documentModified = true;
|
|
36784
|
+
return rId;
|
|
36785
|
+
}
|
|
36786
|
+
/**
|
|
36787
|
+
* Creates a default empty footer for the specified variant.
|
|
36788
|
+
*
|
|
36789
|
+
* This method programmatically creates a new footer section with an empty ProseMirror
|
|
36790
|
+
* document. The footer is added to the converter's data structures and will be included
|
|
36791
|
+
* in subsequent DOCX exports.
|
|
36792
|
+
*
|
|
36793
|
+
* @param {('default' | 'first' | 'even' | 'odd')} variant - The footer variant to create
|
|
36794
|
+
* @returns {string} The relationship ID of the created footer
|
|
36795
|
+
*
|
|
36796
|
+
* @throws {Error} If variant is invalid or footer already exists for this variant
|
|
36797
|
+
*
|
|
36798
|
+
* @example
|
|
36799
|
+
* ```javascript
|
|
36800
|
+
* const footerId = converter.createDefaultFooter('default');
|
|
36801
|
+
* // footerId: 'rId-footer-default'
|
|
36802
|
+
* // converter.footers['rId-footer-default'] contains empty PM doc
|
|
36803
|
+
* // converter.footerIds.default === 'rId-footer-default'
|
|
36804
|
+
* ```
|
|
36805
|
+
*/
|
|
36806
|
+
createDefaultFooter(variant = "default") {
|
|
36807
|
+
if (typeof variant !== "string") {
|
|
36808
|
+
throw new TypeError(`variant must be a string, received ${typeof variant}`);
|
|
36809
|
+
}
|
|
36810
|
+
const validVariants = ["default", "first", "even", "odd"];
|
|
36811
|
+
if (!validVariants.includes(variant)) {
|
|
36812
|
+
throw new Error(`Invalid footer variant: ${variant}. Must be one of: ${validVariants.join(", ")}`);
|
|
36813
|
+
}
|
|
36814
|
+
if (this.footerIds[variant]) {
|
|
36815
|
+
console.warn(`[SuperConverter] Footer already exists for variant '${variant}': ${this.footerIds[variant]}`);
|
|
36816
|
+
return this.footerIds[variant];
|
|
36817
|
+
}
|
|
36818
|
+
const rId = `rId-footer-${variant}`;
|
|
36819
|
+
const emptyDoc = {
|
|
36820
|
+
type: "doc",
|
|
36821
|
+
content: [
|
|
36822
|
+
{
|
|
36823
|
+
type: "paragraph",
|
|
36824
|
+
content: []
|
|
36825
|
+
}
|
|
36826
|
+
]
|
|
36827
|
+
};
|
|
36828
|
+
this.footers[rId] = emptyDoc;
|
|
36829
|
+
this.footerIds[variant] = rId;
|
|
36830
|
+
if (!this.footerIds.ids) {
|
|
36831
|
+
this.footerIds.ids = [];
|
|
36832
|
+
}
|
|
36833
|
+
if (!this.footerIds.ids.includes(rId)) {
|
|
36834
|
+
this.footerIds.ids.push(rId);
|
|
36835
|
+
}
|
|
36836
|
+
this.documentModified = true;
|
|
36837
|
+
return rId;
|
|
36838
|
+
}
|
|
36647
36839
|
// Deprecated methods for backward compatibility
|
|
36648
36840
|
static getStoredSuperdocId(docx) {
|
|
36649
36841
|
console.warn("getStoredSuperdocId is deprecated, use getDocumentGuid instead");
|
|
@@ -47360,7 +47552,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
47360
47552
|
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);
|
|
47361
47553
|
var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
|
|
47362
47554
|
var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
|
|
47363
|
-
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,
|
|
47555
|
+
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;
|
|
47364
47556
|
var GOOD_LEAF_SIZE = 200;
|
|
47365
47557
|
var RopeSequence = function RopeSequence2() {
|
|
47366
47558
|
};
|
|
@@ -58546,50 +58738,90 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
58546
58738
|
return positions;
|
|
58547
58739
|
};
|
|
58548
58740
|
const prepareCommentsForExport = (doc2, tr, schema, comments = []) => {
|
|
58741
|
+
const commentMap = /* @__PURE__ */ new Map();
|
|
58742
|
+
comments.forEach((c2) => {
|
|
58743
|
+
commentMap.set(c2.commentId, c2);
|
|
58744
|
+
});
|
|
58745
|
+
new Set(comments.filter((c2) => c2.parentCommentId).map((c2) => c2.parentCommentId));
|
|
58549
58746
|
const startNodes = [];
|
|
58550
58747
|
const endNodes = [];
|
|
58551
58748
|
const seen = /* @__PURE__ */ new Set();
|
|
58552
58749
|
doc2.descendants((node2, pos) => {
|
|
58553
|
-
const commentMarks = node2.marks?.filter((mark2) => mark2.type.name === CommentMarkName);
|
|
58750
|
+
const commentMarks = node2.marks?.filter((mark2) => mark2.type.name === CommentMarkName) || [];
|
|
58554
58751
|
commentMarks.forEach((commentMark) => {
|
|
58555
|
-
|
|
58556
|
-
|
|
58557
|
-
|
|
58558
|
-
|
|
58559
|
-
|
|
58560
|
-
|
|
58561
|
-
|
|
58562
|
-
|
|
58752
|
+
const { attrs = {} } = commentMark;
|
|
58753
|
+
const { commentId } = attrs;
|
|
58754
|
+
if (commentId === "pending") return;
|
|
58755
|
+
if (seen.has(commentId)) return;
|
|
58756
|
+
seen.add(commentId);
|
|
58757
|
+
const comment2 = commentMap.get(commentId);
|
|
58758
|
+
const parentCommentId = comment2?.parentCommentId;
|
|
58759
|
+
const commentStartNodeAttrs = getPreparedComment(commentMark.attrs);
|
|
58760
|
+
const startNode = schema.nodes.commentRangeStart.create(commentStartNodeAttrs);
|
|
58761
|
+
startNodes.push({
|
|
58762
|
+
pos,
|
|
58763
|
+
node: startNode,
|
|
58764
|
+
commentId,
|
|
58765
|
+
parentCommentId
|
|
58766
|
+
});
|
|
58767
|
+
const endNode = schema.nodes.commentRangeEnd.create(commentStartNodeAttrs);
|
|
58768
|
+
endNodes.push({
|
|
58769
|
+
pos: pos + node2.nodeSize,
|
|
58770
|
+
node: endNode,
|
|
58771
|
+
commentId,
|
|
58772
|
+
parentCommentId
|
|
58773
|
+
});
|
|
58774
|
+
const childComments = comments.filter((c2) => c2.parentCommentId === commentId).sort((a2, b2) => a2.createdTime - b2.createdTime);
|
|
58775
|
+
childComments.forEach((c2) => {
|
|
58776
|
+
if (seen.has(c2.commentId)) return;
|
|
58777
|
+
seen.add(c2.commentId);
|
|
58778
|
+
const childMark = getPreparedComment({
|
|
58779
|
+
commentId: c2.commentId,
|
|
58780
|
+
internal: c2.isInternal
|
|
58781
|
+
});
|
|
58782
|
+
const childStartNode = schema.nodes.commentRangeStart.create(childMark);
|
|
58563
58783
|
startNodes.push({
|
|
58564
58784
|
pos,
|
|
58565
|
-
node:
|
|
58785
|
+
node: childStartNode,
|
|
58786
|
+
commentId: c2.commentId,
|
|
58787
|
+
parentCommentId: c2.parentCommentId
|
|
58566
58788
|
});
|
|
58567
|
-
const
|
|
58789
|
+
const childEndNode = schema.nodes.commentRangeEnd.create(childMark);
|
|
58568
58790
|
endNodes.push({
|
|
58569
58791
|
pos: pos + node2.nodeSize,
|
|
58570
|
-
node:
|
|
58792
|
+
node: childEndNode,
|
|
58793
|
+
commentId: c2.commentId,
|
|
58794
|
+
parentCommentId: c2.parentCommentId
|
|
58571
58795
|
});
|
|
58572
|
-
|
|
58573
|
-
if (parentId) {
|
|
58574
|
-
const childComments = comments.filter((c2) => c2.parentCommentId === parentId).sort((a2, b2) => a2.createdTime - b2.createdTime);
|
|
58575
|
-
childComments.forEach((c2) => {
|
|
58576
|
-
const childMark = getPreparedComment(c2);
|
|
58577
|
-
const childStartNode = schema.nodes.commentRangeStart.create(childMark);
|
|
58578
|
-
seen.add(c2.commentId);
|
|
58579
|
-
startNodes.push({
|
|
58580
|
-
pos,
|
|
58581
|
-
node: childStartNode
|
|
58582
|
-
});
|
|
58583
|
-
const childEndNode = schema.nodes.commentRangeEnd.create(childMark);
|
|
58584
|
-
endNodes.push({
|
|
58585
|
-
pos: pos + node2.nodeSize,
|
|
58586
|
-
node: childEndNode
|
|
58587
|
-
});
|
|
58588
|
-
});
|
|
58589
|
-
}
|
|
58590
|
-
}
|
|
58796
|
+
});
|
|
58591
58797
|
});
|
|
58592
58798
|
});
|
|
58799
|
+
startNodes.sort((a2, b2) => {
|
|
58800
|
+
if (a2.pos !== b2.pos) return a2.pos - b2.pos;
|
|
58801
|
+
const aIsParentOfB = a2.commentId === b2.parentCommentId;
|
|
58802
|
+
const bIsParentOfA = b2.commentId === a2.parentCommentId;
|
|
58803
|
+
if (aIsParentOfB) return -1;
|
|
58804
|
+
if (bIsParentOfA) return 1;
|
|
58805
|
+
if (a2.parentCommentId && a2.parentCommentId === b2.parentCommentId) {
|
|
58806
|
+
const aComment = commentMap.get(a2.commentId);
|
|
58807
|
+
const bComment = commentMap.get(b2.commentId);
|
|
58808
|
+
return (aComment?.createdTime || 0) - (bComment?.createdTime || 0);
|
|
58809
|
+
}
|
|
58810
|
+
return 0;
|
|
58811
|
+
});
|
|
58812
|
+
endNodes.sort((a2, b2) => {
|
|
58813
|
+
if (a2.pos !== b2.pos) return a2.pos - b2.pos;
|
|
58814
|
+
const aIsParentOfB = a2.commentId === b2.parentCommentId;
|
|
58815
|
+
const bIsParentOfA = b2.commentId === a2.parentCommentId;
|
|
58816
|
+
if (aIsParentOfB) return -1;
|
|
58817
|
+
if (bIsParentOfA) return 1;
|
|
58818
|
+
if (a2.parentCommentId && a2.parentCommentId === b2.parentCommentId) {
|
|
58819
|
+
const aComment = commentMap.get(a2.commentId);
|
|
58820
|
+
const bComment = commentMap.get(b2.commentId);
|
|
58821
|
+
return (aComment?.createdTime || 0) - (bComment?.createdTime || 0);
|
|
58822
|
+
}
|
|
58823
|
+
return 0;
|
|
58824
|
+
});
|
|
58593
58825
|
startNodes.forEach((n) => {
|
|
58594
58826
|
const { pos, node: node2 } = n;
|
|
58595
58827
|
const mappedPos = tr.mapping.map(pos);
|
|
@@ -61131,7 +61363,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
61131
61363
|
const shouldSkipNodeView = (editor) => {
|
|
61132
61364
|
return isHeadless(editor);
|
|
61133
61365
|
};
|
|
61134
|
-
const summaryVersion = "1.0.0-beta.
|
|
61366
|
+
const summaryVersion = "1.0.0-beta.19";
|
|
61135
61367
|
const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
|
|
61136
61368
|
const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
|
|
61137
61369
|
function mapAttributes(attrs) {
|
|
@@ -61907,7 +62139,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
61907
62139
|
{ default: remarkStringify2 },
|
|
61908
62140
|
{ default: remarkGfm2 }
|
|
61909
62141
|
] = await Promise.all([
|
|
61910
|
-
Promise.resolve().then(() =>
|
|
62142
|
+
Promise.resolve().then(() => indexCRpn1mWd),
|
|
61911
62143
|
Promise.resolve().then(() => indexDRCvimau),
|
|
61912
62144
|
Promise.resolve().then(() => indexC_x_N6Uh),
|
|
61913
62145
|
Promise.resolve().then(() => indexD_sWOSiG),
|
|
@@ -62112,7 +62344,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
62112
62344
|
* Process collaboration migrations
|
|
62113
62345
|
*/
|
|
62114
62346
|
processCollaborationMigrations() {
|
|
62115
|
-
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.
|
|
62347
|
+
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.19");
|
|
62116
62348
|
if (!this.options.ydoc) return;
|
|
62117
62349
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
62118
62350
|
let docVersion = metaMap.get("version");
|
|
@@ -62814,6 +63046,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
62814
63046
|
gap: gapInches * PX_PER_INCH$2
|
|
62815
63047
|
};
|
|
62816
63048
|
}
|
|
63049
|
+
function extractVerticalAlign(elements) {
|
|
63050
|
+
const vAlign = elements.find((el) => el?.name === "w:vAlign");
|
|
63051
|
+
if (!vAlign?.attributes) return void 0;
|
|
63052
|
+
const val = vAlign.attributes["w:val"];
|
|
63053
|
+
if (val === "top" || val === "center" || val === "bottom" || val === "both") {
|
|
63054
|
+
return val;
|
|
63055
|
+
}
|
|
63056
|
+
return void 0;
|
|
63057
|
+
}
|
|
62817
63058
|
function extractSectionData(para) {
|
|
62818
63059
|
const attrs = para.attrs ?? {};
|
|
62819
63060
|
let { headerPx, footerPx } = extractNormalizedMargins(attrs);
|
|
@@ -62830,7 +63071,20 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
62830
63071
|
const footerRefs = extractHeaderFooterRefs(sectPrElements, "w:footerReference");
|
|
62831
63072
|
const numbering = extractPageNumbering(sectPrElements);
|
|
62832
63073
|
const columnsPx = extractColumns(sectPrElements);
|
|
62833
|
-
|
|
63074
|
+
const vAlign = extractVerticalAlign(sectPrElements);
|
|
63075
|
+
return {
|
|
63076
|
+
headerPx,
|
|
63077
|
+
footerPx,
|
|
63078
|
+
type: type2,
|
|
63079
|
+
pageSizePx,
|
|
63080
|
+
orientation,
|
|
63081
|
+
columnsPx,
|
|
63082
|
+
titlePg,
|
|
63083
|
+
headerRefs,
|
|
63084
|
+
footerRefs,
|
|
63085
|
+
numbering,
|
|
63086
|
+
vAlign
|
|
63087
|
+
};
|
|
62834
63088
|
}
|
|
62835
63089
|
function isSectPrElement(value) {
|
|
62836
63090
|
return typeof value === "object" && value !== null && value.type === "element" && value.name === "w:sectPr";
|
|
@@ -62867,7 +63121,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
62867
63121
|
...section.columns && { columns: section.columns },
|
|
62868
63122
|
...section.numbering ? { numbering: section.numbering } : {},
|
|
62869
63123
|
...section.headerRefs && { headerRefs: section.headerRefs },
|
|
62870
|
-
...section.footerRefs && { footerRefs: section.footerRefs }
|
|
63124
|
+
...section.footerRefs && { footerRefs: section.footerRefs },
|
|
63125
|
+
...section.vAlign && { vAlign: section.vAlign }
|
|
62871
63126
|
};
|
|
62872
63127
|
return result;
|
|
62873
63128
|
}
|
|
@@ -62939,7 +63194,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
62939
63194
|
titlePg: sectionData.titlePg ?? false,
|
|
62940
63195
|
headerRefs: sectionData.headerRefs,
|
|
62941
63196
|
footerRefs: sectionData.footerRefs,
|
|
62942
|
-
numbering: sectionData.numbering
|
|
63197
|
+
numbering: sectionData.numbering,
|
|
63198
|
+
vAlign: sectionData.vAlign
|
|
62943
63199
|
};
|
|
62944
63200
|
ranges.push(range2);
|
|
62945
63201
|
currentStart = item.index + 1;
|
|
@@ -62978,7 +63234,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
62978
63234
|
type: bodySectionData.type ?? DEFAULT_BODY_SECTION_TYPE,
|
|
62979
63235
|
titlePg: bodySectionData.titlePg ?? false,
|
|
62980
63236
|
headerRefs: bodySectionData.headerRefs,
|
|
62981
|
-
footerRefs: bodySectionData.footerRefs
|
|
63237
|
+
footerRefs: bodySectionData.footerRefs,
|
|
63238
|
+
vAlign: bodySectionData.vAlign
|
|
62982
63239
|
};
|
|
62983
63240
|
}
|
|
62984
63241
|
function createDefaultFinalSection(currentStart, totalParagraphs, sectionIndex) {
|
|
@@ -64641,8 +64898,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
64641
64898
|
for (const entry of tabs) {
|
|
64642
64899
|
if (!entry || typeof entry !== "object") continue;
|
|
64643
64900
|
const rawEntry = entry;
|
|
64644
|
-
const
|
|
64645
|
-
const
|
|
64901
|
+
const isNestedTab = Boolean(rawEntry.tab && typeof rawEntry.tab === "object");
|
|
64902
|
+
const source = isNestedTab ? rawEntry.tab : rawEntry;
|
|
64903
|
+
const posTwips = resolveTabPosition(source, isNestedTab);
|
|
64646
64904
|
if (posTwips == null) continue;
|
|
64647
64905
|
const val = normalizeTabVal(source.val ?? source.align ?? source.alignment ?? source.type ?? source.tabType);
|
|
64648
64906
|
if (!val) continue;
|
|
@@ -64656,7 +64914,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
64656
64914
|
}
|
|
64657
64915
|
return normalized.length > 0 ? normalized : void 0;
|
|
64658
64916
|
};
|
|
64659
|
-
const resolveTabPosition = (source) => {
|
|
64917
|
+
const resolveTabPosition = (source, treatPosAsTwips = false) => {
|
|
64660
64918
|
const originalPos = pickNumber(source.originalPos);
|
|
64661
64919
|
if (originalPos != null) {
|
|
64662
64920
|
return originalPos;
|
|
@@ -64665,6 +64923,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
64665
64923
|
if (posValue == null) {
|
|
64666
64924
|
return void 0;
|
|
64667
64925
|
}
|
|
64926
|
+
if (treatPosAsTwips) {
|
|
64927
|
+
return posValue;
|
|
64928
|
+
}
|
|
64668
64929
|
if (posValue > TWIPS_THRESHOLD) {
|
|
64669
64930
|
return posValue;
|
|
64670
64931
|
} else {
|
|
@@ -66175,8 +66436,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
66175
66436
|
}
|
|
66176
66437
|
const color2 = normalizeColor(getAttribute(findChild(rPr, "w:color"), "w:val"));
|
|
66177
66438
|
if (color2) run2.color = color2;
|
|
66178
|
-
|
|
66179
|
-
if (
|
|
66439
|
+
const boldEl = findChild(rPr, "w:b");
|
|
66440
|
+
if (boldEl) {
|
|
66441
|
+
const boldVal = getAttribute(boldEl, "w:val");
|
|
66442
|
+
if (boldVal == null || isTruthy(boldVal)) run2.bold = true;
|
|
66443
|
+
}
|
|
66444
|
+
const italicEl = findChild(rPr, "w:i");
|
|
66445
|
+
if (italicEl) {
|
|
66446
|
+
const italicVal = getAttribute(italicEl, "w:val");
|
|
66447
|
+
if (italicVal == null || isTruthy(italicVal)) run2.italic = true;
|
|
66448
|
+
}
|
|
66180
66449
|
const spacingTwips = parseNumberAttr(getAttribute(findChild(rPr, "w:spacing"), "w:val"));
|
|
66181
66450
|
if (spacingTwips != null && Number.isFinite(spacingTwips)) {
|
|
66182
66451
|
run2.letterSpacing = twipsToPx$1(spacingTwips);
|
|
@@ -66652,19 +66921,21 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
66652
66921
|
}
|
|
66653
66922
|
const tabObj = tab;
|
|
66654
66923
|
const val = typeof tabObj.tabType === "string" ? tabObj.tabType : typeof tabObj.val === "string" ? tabObj.val : void 0;
|
|
66655
|
-
const
|
|
66924
|
+
const originalPos = pickNumber(tabObj.originalPos);
|
|
66925
|
+
const pos = originalPos ?? pickNumber(tabObj.pos);
|
|
66656
66926
|
if (!val || pos == null) {
|
|
66657
66927
|
continue;
|
|
66658
66928
|
}
|
|
66659
66929
|
const normalized = { val, pos };
|
|
66930
|
+
if (originalPos != null && Number.isFinite(originalPos)) {
|
|
66931
|
+
normalized.originalPos = originalPos;
|
|
66932
|
+
} else {
|
|
66933
|
+
normalized.originalPos = pos;
|
|
66934
|
+
}
|
|
66660
66935
|
const leader = tabObj.leader;
|
|
66661
66936
|
if (typeof leader === "string" && leader.length > 0) {
|
|
66662
66937
|
normalized.leader = leader;
|
|
66663
66938
|
}
|
|
66664
|
-
const originalPos = pickNumber(tabObj.originalPos);
|
|
66665
|
-
if (originalPos != null && Number.isFinite(originalPos)) {
|
|
66666
|
-
normalized.originalPos = originalPos;
|
|
66667
|
-
}
|
|
66668
66939
|
unwrapped.push(normalized);
|
|
66669
66940
|
continue;
|
|
66670
66941
|
}
|
|
@@ -67506,11 +67777,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
67506
67777
|
if (!maps.length) return;
|
|
67507
67778
|
const finalStyles = Object.assign({}, ...maps);
|
|
67508
67779
|
const fontFamily2 = extractValue(finalStyles["font-family"]);
|
|
67509
|
-
if (typeof fontFamily2 === "string" && fontFamily2
|
|
67780
|
+
if (typeof fontFamily2 === "string" && fontFamily2) {
|
|
67510
67781
|
run2.fontFamily = fontFamily2;
|
|
67511
67782
|
}
|
|
67512
67783
|
const fontSize2 = toPxNumber(finalStyles["font-size"]);
|
|
67513
|
-
if (fontSize2 != null
|
|
67784
|
+
if (fontSize2 != null) {
|
|
67514
67785
|
run2.fontSize = fontSize2;
|
|
67515
67786
|
}
|
|
67516
67787
|
const letterSpacing = toPxNumber(finalStyles["letter-spacing"]);
|
|
@@ -67873,9 +68144,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
67873
68144
|
resolver: linkedStyleResolver,
|
|
67874
68145
|
paragraphStyleId,
|
|
67875
68146
|
inlineStyleId,
|
|
67876
|
-
runStyleId
|
|
67877
|
-
defaultFont,
|
|
67878
|
-
defaultSize
|
|
68147
|
+
runStyleId
|
|
67879
68148
|
});
|
|
67880
68149
|
};
|
|
67881
68150
|
const visitNode = (node2, inheritedMarks = [], activeSdt, activeRunStyleId = null) => {
|
|
@@ -67885,7 +68154,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
67885
68154
|
positions,
|
|
67886
68155
|
defaultFont,
|
|
67887
68156
|
defaultSize,
|
|
67888
|
-
|
|
68157
|
+
[],
|
|
68158
|
+
// Empty marks - will be applied after linked styles
|
|
67889
68159
|
activeSdt,
|
|
67890
68160
|
hyperlinkConfig,
|
|
67891
68161
|
themeColors
|
|
@@ -67893,6 +68163,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
67893
68163
|
const inlineStyleId = getInlineStyleId(inheritedMarks);
|
|
67894
68164
|
applyRunStyles2(run2, inlineStyleId, activeRunStyleId);
|
|
67895
68165
|
applyBaseRunDefaults(run2, baseRunDefaults, defaultFont, defaultSize);
|
|
68166
|
+
applyMarksToRun(run2, [...node2.marks ?? [], ...inheritedMarks ?? []], hyperlinkConfig, themeColors);
|
|
67896
68167
|
currentRuns.push(run2);
|
|
67897
68168
|
return;
|
|
67898
68169
|
}
|
|
@@ -69767,13 +70038,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
69767
70038
|
if (!Number.isFinite(lineStart) || !Number.isFinite(lineEnd)) {
|
|
69768
70039
|
return null;
|
|
69769
70040
|
}
|
|
69770
|
-
const spanEls = Array.from(lineEl.querySelectorAll("span"));
|
|
70041
|
+
const spanEls = Array.from(lineEl.querySelectorAll("span, a"));
|
|
69771
70042
|
log(
|
|
69772
|
-
"Spans in line:",
|
|
70043
|
+
"Spans/anchors in line:",
|
|
69773
70044
|
spanEls.map((el, i2) => {
|
|
69774
70045
|
const rect = el.getBoundingClientRect();
|
|
69775
70046
|
return {
|
|
69776
70047
|
index: i2,
|
|
70048
|
+
tag: el.tagName,
|
|
69777
70049
|
pmStart: el.dataset.pmStart,
|
|
69778
70050
|
pmEnd: el.dataset.pmEnd,
|
|
69779
70051
|
text: el.textContent?.substring(0, 20) + (el.textContent && el.textContent.length > 20 ? "..." : ""),
|
|
@@ -69793,32 +70065,33 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
69793
70065
|
if (viewX >= lastRect.right) {
|
|
69794
70066
|
return lineEnd;
|
|
69795
70067
|
}
|
|
69796
|
-
const
|
|
69797
|
-
if (!
|
|
70068
|
+
const targetEl = findSpanAtX(spanEls, viewX);
|
|
70069
|
+
if (!targetEl) {
|
|
69798
70070
|
return lineStart;
|
|
69799
70071
|
}
|
|
69800
|
-
const spanStart = Number(
|
|
69801
|
-
const spanEnd = Number(
|
|
69802
|
-
const targetRect =
|
|
69803
|
-
log("Target
|
|
70072
|
+
const spanStart = Number(targetEl.dataset.pmStart ?? "NaN");
|
|
70073
|
+
const spanEnd = Number(targetEl.dataset.pmEnd ?? "NaN");
|
|
70074
|
+
const targetRect = targetEl.getBoundingClientRect();
|
|
70075
|
+
log("Target element:", {
|
|
70076
|
+
tag: targetEl.tagName,
|
|
69804
70077
|
pmStart: spanStart,
|
|
69805
70078
|
pmEnd: spanEnd,
|
|
69806
|
-
text:
|
|
69807
|
-
visibility:
|
|
70079
|
+
text: targetEl.textContent?.substring(0, 30),
|
|
70080
|
+
visibility: targetEl.style.visibility,
|
|
69808
70081
|
rect: { left: targetRect.left, right: targetRect.right, width: targetRect.width }
|
|
69809
70082
|
});
|
|
69810
70083
|
if (!Number.isFinite(spanStart) || !Number.isFinite(spanEnd)) {
|
|
69811
70084
|
return null;
|
|
69812
70085
|
}
|
|
69813
|
-
const firstChild =
|
|
70086
|
+
const firstChild = targetEl.firstChild;
|
|
69814
70087
|
if (!firstChild || firstChild.nodeType !== Node.TEXT_NODE || !firstChild.textContent) {
|
|
69815
|
-
const
|
|
69816
|
-
const closerToLeft = Math.abs(viewX -
|
|
70088
|
+
const elRect = targetEl.getBoundingClientRect();
|
|
70089
|
+
const closerToLeft = Math.abs(viewX - elRect.left) <= Math.abs(viewX - elRect.right);
|
|
69817
70090
|
const snapPos = closerToLeft ? spanStart : spanEnd;
|
|
69818
70091
|
return snapPos;
|
|
69819
70092
|
}
|
|
69820
70093
|
const textNode = firstChild;
|
|
69821
|
-
const charIndex = findCharIndexAtX(textNode,
|
|
70094
|
+
const charIndex = findCharIndexAtX(textNode, targetEl, viewX);
|
|
69822
70095
|
const pos = spanStart + charIndex;
|
|
69823
70096
|
return pos;
|
|
69824
70097
|
}
|
|
@@ -69856,7 +70129,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
69856
70129
|
const span = spanEls[i2];
|
|
69857
70130
|
const rect = span.getBoundingClientRect();
|
|
69858
70131
|
if (viewX >= rect.left && viewX <= rect.right) {
|
|
69859
|
-
log("findSpanAtX: Found containing
|
|
70132
|
+
log("findSpanAtX: Found containing element at index", i2, {
|
|
70133
|
+
tag: span.tagName,
|
|
69860
70134
|
pmStart: span.dataset.pmStart,
|
|
69861
70135
|
pmEnd: span.dataset.pmEnd,
|
|
69862
70136
|
rect: { left: rect.left, right: rect.right },
|
|
@@ -69868,16 +70142,17 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
69868
70142
|
targetSpan = span;
|
|
69869
70143
|
}
|
|
69870
70144
|
}
|
|
69871
|
-
log("findSpanAtX: No containing
|
|
70145
|
+
log("findSpanAtX: No containing element, using nearest:", {
|
|
70146
|
+
tag: targetSpan.tagName,
|
|
69872
70147
|
pmStart: targetSpan.dataset.pmStart,
|
|
69873
70148
|
pmEnd: targetSpan.dataset.pmEnd,
|
|
69874
70149
|
viewX
|
|
69875
70150
|
});
|
|
69876
70151
|
return targetSpan;
|
|
69877
70152
|
}
|
|
69878
|
-
function findCharIndexAtX(textNode,
|
|
70153
|
+
function findCharIndexAtX(textNode, container, targetX) {
|
|
69879
70154
|
const text2 = textNode.textContent ?? "";
|
|
69880
|
-
const baseLeft =
|
|
70155
|
+
const baseLeft = container.getBoundingClientRect().left;
|
|
69881
70156
|
const range2 = document.createRange();
|
|
69882
70157
|
let lo = 0;
|
|
69883
70158
|
let hi = text2.length;
|
|
@@ -70209,6 +70484,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
70209
70484
|
if (source.orientation) {
|
|
70210
70485
|
props.orientation = source.orientation;
|
|
70211
70486
|
}
|
|
70487
|
+
if (source.vAlign) {
|
|
70488
|
+
props.vAlign = source.vAlign;
|
|
70489
|
+
}
|
|
70212
70490
|
return props;
|
|
70213
70491
|
};
|
|
70214
70492
|
docxBreakIndexes.forEach((index2, ordinal) => {
|
|
@@ -71609,6 +71887,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
71609
71887
|
runs: clonedRuns
|
|
71610
71888
|
};
|
|
71611
71889
|
}
|
|
71890
|
+
const DEFAULT_PARAGRAPH_LINE_HEIGHT_PX = 20;
|
|
71891
|
+
function hasHeight(fragment) {
|
|
71892
|
+
return fragment.kind === "image" || fragment.kind === "drawing" || fragment.kind === "table";
|
|
71893
|
+
}
|
|
71612
71894
|
const DEFAULT_PAGE_SIZE$2 = { w: 612, h: 792 };
|
|
71613
71895
|
const DEFAULT_MARGINS$2 = { top: 72, right: 72, bottom: 72, left: 72 };
|
|
71614
71896
|
const COLUMN_EPSILON = 1e-4;
|
|
@@ -71703,6 +71985,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
71703
71985
|
let pendingColumns = null;
|
|
71704
71986
|
let activeOrientation = null;
|
|
71705
71987
|
let pendingOrientation = null;
|
|
71988
|
+
let activeVAlign = null;
|
|
71989
|
+
let pendingVAlign = null;
|
|
71706
71990
|
const floatManager = createFloatingObjectManager(
|
|
71707
71991
|
normalizeColumns(activeColumns, contentWidth),
|
|
71708
71992
|
{ left: margins.left, right: margins.right },
|
|
@@ -71808,6 +72092,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
71808
72092
|
if (activeOrientation) {
|
|
71809
72093
|
page.orientation = activeOrientation;
|
|
71810
72094
|
}
|
|
72095
|
+
if (activeVAlign && activeVAlign !== "top") {
|
|
72096
|
+
page.vAlign = activeVAlign;
|
|
72097
|
+
}
|
|
71811
72098
|
return page;
|
|
71812
72099
|
};
|
|
71813
72100
|
let pageCount = 0;
|
|
@@ -71886,6 +72173,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
71886
72173
|
activeSectionRefs = pendingSectionRefs;
|
|
71887
72174
|
pendingSectionRefs = null;
|
|
71888
72175
|
}
|
|
72176
|
+
if (pendingVAlign !== null) {
|
|
72177
|
+
activeVAlign = pendingVAlign;
|
|
72178
|
+
pendingVAlign = null;
|
|
72179
|
+
}
|
|
71889
72180
|
pageCount += 1;
|
|
71890
72181
|
return;
|
|
71891
72182
|
}
|
|
@@ -72022,7 +72313,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
72022
72313
|
margins: ahead.margins ? { ...effectiveBlock.margins ?? {}, ...ahead.margins } : effectiveBlock.margins ?? {},
|
|
72023
72314
|
pageSize: ahead.pageSize ?? effectiveBlock.pageSize,
|
|
72024
72315
|
columns: ahead.columns ?? effectiveBlock.columns,
|
|
72025
|
-
orientation: ahead.orientation ?? effectiveBlock.orientation
|
|
72316
|
+
orientation: ahead.orientation ?? effectiveBlock.orientation,
|
|
72317
|
+
vAlign: ahead.vAlign ?? effectiveBlock.vAlign
|
|
72026
72318
|
};
|
|
72027
72319
|
}
|
|
72028
72320
|
const sectionState = {
|
|
@@ -72075,6 +72367,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
72075
72367
|
pendingColumns = updatedState.pendingColumns;
|
|
72076
72368
|
activeOrientation = updatedState.activeOrientation;
|
|
72077
72369
|
pendingOrientation = updatedState.pendingOrientation;
|
|
72370
|
+
if (effectiveBlock.vAlign) {
|
|
72371
|
+
const isFirstSection = effectiveBlock.attrs?.isFirstSection && states.length === 0;
|
|
72372
|
+
if (isFirstSection) {
|
|
72373
|
+
activeVAlign = effectiveBlock.vAlign;
|
|
72374
|
+
pendingVAlign = null;
|
|
72375
|
+
} else {
|
|
72376
|
+
pendingVAlign = effectiveBlock.vAlign;
|
|
72377
|
+
}
|
|
72378
|
+
}
|
|
72078
72379
|
if (effectiveBlock.headerRefs || effectiveBlock.footerRefs) {
|
|
72079
72380
|
pendingSectionRefs = {
|
|
72080
72381
|
...effectiveBlock.headerRefs && { headerRefs: effectiveBlock.headerRefs },
|
|
@@ -72083,8 +72384,17 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
72083
72384
|
layoutLog(`[Layout] After scheduleSectionBreakCompat: Scheduled pendingSectionRefs:`, pendingSectionRefs);
|
|
72084
72385
|
}
|
|
72085
72386
|
if (breakInfo.forceMidPageRegion && block.columns) {
|
|
72086
|
-
|
|
72087
|
-
|
|
72387
|
+
let state2 = paginator.ensurePage();
|
|
72388
|
+
const columnIndexBefore = state2.columnIndex;
|
|
72389
|
+
const rawCount = block.columns.count;
|
|
72390
|
+
const validatedCount = typeof rawCount === "number" && Number.isFinite(rawCount) && rawCount > 0 ? Math.max(1, Math.floor(rawCount)) : 1;
|
|
72391
|
+
const rawGap = block.columns.gap;
|
|
72392
|
+
const validatedGap = typeof rawGap === "number" && Number.isFinite(rawGap) && rawGap >= 0 ? Math.max(0, rawGap) : 0;
|
|
72393
|
+
const newColumns = { count: validatedCount, gap: validatedGap };
|
|
72394
|
+
if (columnIndexBefore >= newColumns.count) {
|
|
72395
|
+
state2 = paginator.startNewPage();
|
|
72396
|
+
}
|
|
72397
|
+
startMidPageRegion(state2, newColumns);
|
|
72088
72398
|
}
|
|
72089
72399
|
if (breakInfo.forcePageBreak) {
|
|
72090
72400
|
let state2 = paginator.ensurePage();
|
|
@@ -72276,6 +72586,45 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
72276
72586
|
while (pages.length > 0 && pages[pages.length - 1].fragments.length === 0) {
|
|
72277
72587
|
pages.pop();
|
|
72278
72588
|
}
|
|
72589
|
+
for (const page of pages) {
|
|
72590
|
+
if (!page.vAlign || page.vAlign === "top") continue;
|
|
72591
|
+
if (page.fragments.length === 0) continue;
|
|
72592
|
+
const pageSizeForPage = page.size ?? pageSize;
|
|
72593
|
+
const contentTop = page.margins?.top ?? margins.top;
|
|
72594
|
+
const contentBottom = pageSizeForPage.h - (page.margins?.bottom ?? margins.bottom);
|
|
72595
|
+
const contentHeight = contentBottom - contentTop;
|
|
72596
|
+
let minY = Infinity;
|
|
72597
|
+
let maxY = -Infinity;
|
|
72598
|
+
for (const fragment of page.fragments) {
|
|
72599
|
+
if (fragment.y < minY) minY = fragment.y;
|
|
72600
|
+
let fragmentBottom = fragment.y;
|
|
72601
|
+
if (hasHeight(fragment)) {
|
|
72602
|
+
fragmentBottom += fragment.height;
|
|
72603
|
+
} else {
|
|
72604
|
+
const lineCount = fragment.toLine - fragment.fromLine;
|
|
72605
|
+
fragmentBottom += lineCount * DEFAULT_PARAGRAPH_LINE_HEIGHT_PX;
|
|
72606
|
+
}
|
|
72607
|
+
if (fragmentBottom > maxY) maxY = fragmentBottom;
|
|
72608
|
+
}
|
|
72609
|
+
const actualContentHeight = maxY - minY;
|
|
72610
|
+
const availableSpace = contentHeight - actualContentHeight;
|
|
72611
|
+
if (availableSpace <= 0) {
|
|
72612
|
+
continue;
|
|
72613
|
+
}
|
|
72614
|
+
let yOffset = 0;
|
|
72615
|
+
if (page.vAlign === "center") {
|
|
72616
|
+
yOffset = availableSpace / 2;
|
|
72617
|
+
} else if (page.vAlign === "bottom") {
|
|
72618
|
+
yOffset = availableSpace;
|
|
72619
|
+
} else if (page.vAlign === "both") {
|
|
72620
|
+
yOffset = availableSpace / 2;
|
|
72621
|
+
}
|
|
72622
|
+
if (yOffset > 0) {
|
|
72623
|
+
for (const fragment of page.fragments) {
|
|
72624
|
+
fragment.y += yOffset;
|
|
72625
|
+
}
|
|
72626
|
+
}
|
|
72627
|
+
}
|
|
72279
72628
|
return {
|
|
72280
72629
|
pageSize,
|
|
72281
72630
|
pages,
|
|
@@ -76703,14 +77052,25 @@ ${l}
|
|
|
76703
77052
|
}
|
|
76704
77053
|
`;
|
|
76705
77054
|
const LINK_AND_TOC_STYLES = `
|
|
76706
|
-
/* Reset browser default link styling - allow run colors to show through
|
|
77055
|
+
/* Reset browser default link styling - allow run colors to show through from inline styles
|
|
77056
|
+
*
|
|
77057
|
+
* Note: !important was removed from these rules to allow inline styles to take precedence.
|
|
77058
|
+
* This is necessary because OOXML hyperlink character styles apply colors via inline style
|
|
77059
|
+
* attributes on the run elements. The CSS cascade ensures that inline styles (applied via
|
|
77060
|
+
* element.style.color in applyRunStyles) override these class-based rules naturally.
|
|
77061
|
+
*
|
|
77062
|
+
* Implications:
|
|
77063
|
+
* - OOXML hyperlink character styles will correctly display their assigned colors
|
|
77064
|
+
* - Browser default link colors are still reset by these inherit rules
|
|
77065
|
+
* - Inline color styles from run objects override the inherit value as expected
|
|
77066
|
+
*/
|
|
76707
77067
|
.superdoc-link {
|
|
76708
|
-
color: inherit
|
|
76709
|
-
text-decoration: none
|
|
77068
|
+
color: inherit;
|
|
77069
|
+
text-decoration: none;
|
|
76710
77070
|
}
|
|
76711
77071
|
|
|
76712
77072
|
.superdoc-link:visited {
|
|
76713
|
-
color: inherit
|
|
77073
|
+
color: inherit;
|
|
76714
77074
|
}
|
|
76715
77075
|
|
|
76716
77076
|
.superdoc-link:hover {
|
|
@@ -78249,14 +78609,23 @@ ${l}
|
|
|
78249
78609
|
lines.forEach((line, index2) => {
|
|
78250
78610
|
const lineEl = this.renderLine(block, line, context);
|
|
78251
78611
|
const isListFirstLine = index2 === 0 && !fragment.continuesFromPrev && fragment.markerWidth && wordLayout?.marker;
|
|
78252
|
-
|
|
78253
|
-
|
|
78612
|
+
const hasExplicitSegmentPositioning = line.segments?.some((seg) => seg.x !== void 0);
|
|
78613
|
+
const isFirstLine = index2 === 0 && !fragment.continuesFromPrev;
|
|
78614
|
+
if (!isListFirstLine) {
|
|
78615
|
+
if (isFirstLine && hasExplicitSegmentPositioning && firstLineOffset !== 0) {
|
|
78616
|
+
const adjustedPadding = paraIndentLeft + firstLineOffset;
|
|
78617
|
+
lineEl.style.paddingLeft = `${adjustedPadding}px`;
|
|
78618
|
+
} else if (paraIndentLeft) {
|
|
78619
|
+
lineEl.style.paddingLeft = `${paraIndentLeft}px`;
|
|
78620
|
+
}
|
|
78254
78621
|
}
|
|
78255
78622
|
if (paraIndentRight) {
|
|
78256
78623
|
lineEl.style.paddingRight = `${paraIndentRight}px`;
|
|
78257
78624
|
}
|
|
78258
78625
|
if (!fragment.continuesFromPrev && index2 === 0 && firstLineOffset && !isListFirstLine) {
|
|
78259
|
-
|
|
78626
|
+
if (!hasExplicitSegmentPositioning) {
|
|
78627
|
+
lineEl.style.textIndent = `${firstLineOffset}px`;
|
|
78628
|
+
}
|
|
78260
78629
|
} else if (firstLineOffset && !isListFirstLine) {
|
|
78261
78630
|
lineEl.style.textIndent = "0px";
|
|
78262
78631
|
}
|
|
@@ -79150,6 +79519,24 @@ ${l}
|
|
|
79150
79519
|
}
|
|
79151
79520
|
elem.setAttribute("role", "link");
|
|
79152
79521
|
elem.setAttribute("tabindex", "0");
|
|
79522
|
+
elem.addEventListener("click", (event) => {
|
|
79523
|
+
event.preventDefault();
|
|
79524
|
+
event.stopPropagation();
|
|
79525
|
+
const linkClickEvent = new CustomEvent("superdoc-link-click", {
|
|
79526
|
+
bubbles: true,
|
|
79527
|
+
composed: true,
|
|
79528
|
+
detail: {
|
|
79529
|
+
href: linkData.href,
|
|
79530
|
+
target: linkData.target,
|
|
79531
|
+
rel: linkData.rel,
|
|
79532
|
+
tooltip: linkData.tooltip,
|
|
79533
|
+
element: elem,
|
|
79534
|
+
clientX: event.clientX,
|
|
79535
|
+
clientY: event.clientY
|
|
79536
|
+
}
|
|
79537
|
+
});
|
|
79538
|
+
elem.dispatchEvent(linkClickEvent);
|
|
79539
|
+
});
|
|
79153
79540
|
}
|
|
79154
79541
|
/**
|
|
79155
79542
|
* Render a single run as an HTML element (span or anchor).
|
|
@@ -79439,7 +79826,13 @@ ${l}
|
|
|
79439
79826
|
if (styleId) {
|
|
79440
79827
|
elem.setAttribute("styleid", styleId);
|
|
79441
79828
|
}
|
|
79829
|
+
const runSegments2 = segmentsByRun.get(runIndex);
|
|
79830
|
+
const segX = runSegments2 && runSegments2[0]?.x !== void 0 ? runSegments2[0].x : cumulativeX;
|
|
79831
|
+
const segWidth = (runSegments2 && runSegments2[0]?.width !== void 0 ? runSegments2[0].width : elem.offsetWidth) ?? 0;
|
|
79832
|
+
elem.style.position = "absolute";
|
|
79833
|
+
elem.style.left = `${segX}px`;
|
|
79442
79834
|
el.appendChild(elem);
|
|
79835
|
+
cumulativeX = segX + segWidth;
|
|
79443
79836
|
}
|
|
79444
79837
|
continue;
|
|
79445
79838
|
}
|
|
@@ -79981,7 +80374,7 @@ ${l}
|
|
|
79981
80374
|
}
|
|
79982
80375
|
return block.id;
|
|
79983
80376
|
};
|
|
79984
|
-
const applyRunStyles = (element2, run2,
|
|
80377
|
+
const applyRunStyles = (element2, run2, _isLink = false) => {
|
|
79985
80378
|
if (run2.kind === "tab" || run2.kind === "image" || run2.kind === "lineBreak" || run2.kind === "break") {
|
|
79986
80379
|
return;
|
|
79987
80380
|
}
|
|
@@ -79989,9 +80382,7 @@ ${l}
|
|
|
79989
80382
|
element2.style.fontSize = `${run2.fontSize}px`;
|
|
79990
80383
|
if (run2.bold) element2.style.fontWeight = "bold";
|
|
79991
80384
|
if (run2.italic) element2.style.fontStyle = "italic";
|
|
79992
|
-
if (
|
|
79993
|
-
if (run2.color) element2.style.color = run2.color;
|
|
79994
|
-
}
|
|
80385
|
+
if (run2.color) element2.style.color = run2.color;
|
|
79995
80386
|
if (run2.letterSpacing != null) {
|
|
79996
80387
|
element2.style.letterSpacing = `${run2.letterSpacing}px`;
|
|
79997
80388
|
}
|
|
@@ -80539,28 +80930,44 @@ ${l}
|
|
|
80539
80930
|
}
|
|
80540
80931
|
return true;
|
|
80541
80932
|
};
|
|
80542
|
-
const
|
|
80543
|
-
if (!pendingTabAlignment || !currentLine) return;
|
|
80933
|
+
const alignPendingTabForWidth = (segmentWidth, beforeDecimalWidth) => {
|
|
80934
|
+
if (!pendingTabAlignment || !currentLine) return void 0;
|
|
80935
|
+
if (segmentWidth < 0) {
|
|
80936
|
+
segmentWidth = 0;
|
|
80937
|
+
}
|
|
80544
80938
|
const { target, val } = pendingTabAlignment;
|
|
80545
80939
|
let startX = currentLine.width;
|
|
80940
|
+
if (val === "decimal") {
|
|
80941
|
+
const beforeWidth = beforeDecimalWidth ?? 0;
|
|
80942
|
+
startX = Math.max(0, target - beforeWidth);
|
|
80943
|
+
} else if (val === "end") {
|
|
80944
|
+
startX = Math.max(0, target - segmentWidth);
|
|
80945
|
+
} else if (val === "center") {
|
|
80946
|
+
startX = Math.max(0, target - segmentWidth / 2);
|
|
80947
|
+
} else {
|
|
80948
|
+
startX = Math.max(0, target);
|
|
80949
|
+
}
|
|
80950
|
+
currentLine.width = roundValue(startX);
|
|
80951
|
+
lastAppliedTabAlign = { target, val };
|
|
80952
|
+
pendingTabAlignment = null;
|
|
80953
|
+
return startX;
|
|
80954
|
+
};
|
|
80955
|
+
const alignSegmentAtTab = (segmentText, font, runContext) => {
|
|
80956
|
+
if (!pendingTabAlignment || !currentLine) return void 0;
|
|
80957
|
+
const { val } = pendingTabAlignment;
|
|
80958
|
+
let segmentWidth = 0;
|
|
80959
|
+
let beforeDecimalWidth;
|
|
80546
80960
|
if (val === "decimal") {
|
|
80547
80961
|
const idx = segmentText.indexOf(decimalSeparator);
|
|
80548
80962
|
if (idx >= 0) {
|
|
80549
80963
|
const beforeText = segmentText.slice(0, idx);
|
|
80550
|
-
|
|
80551
|
-
startX = Math.max(0, target - beforeWidth);
|
|
80552
|
-
} else {
|
|
80553
|
-
startX = Math.max(0, target);
|
|
80964
|
+
beforeDecimalWidth = beforeText.length > 0 ? measureRunWidth(beforeText, font, ctx2, runContext) : 0;
|
|
80554
80965
|
}
|
|
80966
|
+
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext) : 0;
|
|
80555
80967
|
} else if (val === "end" || val === "center") {
|
|
80556
|
-
|
|
80557
|
-
startX = val === "end" ? Math.max(0, target - segWidth) : Math.max(0, target - segWidth / 2);
|
|
80558
|
-
} else if (val === "start" || val === "bar") {
|
|
80559
|
-
startX = Math.max(0, target);
|
|
80968
|
+
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext) : 0;
|
|
80560
80969
|
}
|
|
80561
|
-
|
|
80562
|
-
lastAppliedTabAlign = { target, val };
|
|
80563
|
-
pendingTabAlignment = null;
|
|
80970
|
+
return alignPendingTabForWidth(segmentWidth, beforeDecimalWidth);
|
|
80564
80971
|
};
|
|
80565
80972
|
const runsToProcess = [];
|
|
80566
80973
|
for (const run2 of block.runs) {
|
|
@@ -80709,6 +81116,10 @@ ${l}
|
|
|
80709
81116
|
const topSpace = run2.distTop ?? 0;
|
|
80710
81117
|
const bottomSpace = run2.distBottom ?? 0;
|
|
80711
81118
|
const imageHeight = run2.height + topSpace + bottomSpace;
|
|
81119
|
+
let imageStartX;
|
|
81120
|
+
if (pendingTabAlignment && currentLine) {
|
|
81121
|
+
imageStartX = alignPendingTabForWidth(imageWidth);
|
|
81122
|
+
}
|
|
80712
81123
|
if (!currentLine) {
|
|
80713
81124
|
currentLine = {
|
|
80714
81125
|
fromRun: runIndex,
|
|
@@ -80725,12 +81136,14 @@ ${l}
|
|
|
80725
81136
|
runIndex,
|
|
80726
81137
|
fromChar: 0,
|
|
80727
81138
|
toChar: 1,
|
|
80728
|
-
width: imageWidth
|
|
81139
|
+
width: imageWidth,
|
|
81140
|
+
...imageStartX !== void 0 ? { x: imageStartX } : {}
|
|
80729
81141
|
}
|
|
80730
81142
|
]
|
|
80731
81143
|
};
|
|
80732
81144
|
continue;
|
|
80733
81145
|
}
|
|
81146
|
+
const appliedTabAlign = lastAppliedTabAlign;
|
|
80734
81147
|
if (currentLine.width + imageWidth > currentLine.maxWidth && currentLine.width > 0) {
|
|
80735
81148
|
const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing);
|
|
80736
81149
|
const completedLine = {
|
|
@@ -80741,6 +81154,7 @@ ${l}
|
|
|
80741
81154
|
lines.push(completedLine);
|
|
80742
81155
|
tabStopCursor = 0;
|
|
80743
81156
|
pendingTabAlignment = null;
|
|
81157
|
+
lastAppliedTabAlign = null;
|
|
80744
81158
|
currentLine = {
|
|
80745
81159
|
fromRun: runIndex,
|
|
80746
81160
|
fromChar: 0,
|
|
@@ -80768,9 +81182,15 @@ ${l}
|
|
|
80768
81182
|
runIndex,
|
|
80769
81183
|
fromChar: 0,
|
|
80770
81184
|
toChar: 1,
|
|
80771
|
-
width: imageWidth
|
|
81185
|
+
width: imageWidth,
|
|
81186
|
+
...imageStartX !== void 0 ? { x: imageStartX } : {}
|
|
80772
81187
|
});
|
|
80773
81188
|
}
|
|
81189
|
+
const tabAlign = appliedTabAlign;
|
|
81190
|
+
if (tabAlign && currentLine && tabAlign.val === "end") {
|
|
81191
|
+
currentLine.width = roundValue(tabAlign.target);
|
|
81192
|
+
}
|
|
81193
|
+
lastAppliedTabAlign = null;
|
|
80774
81194
|
continue;
|
|
80775
81195
|
}
|
|
80776
81196
|
if (!("text" in run2) || !("fontSize" in run2)) {
|
|
@@ -80786,8 +81206,10 @@ ${l}
|
|
|
80786
81206
|
const words = segment.split(" ");
|
|
80787
81207
|
let segmentStartX;
|
|
80788
81208
|
if (currentLine && pendingTabAlignment) {
|
|
80789
|
-
alignSegmentAtTab(segment, font, run2);
|
|
80790
|
-
segmentStartX
|
|
81209
|
+
segmentStartX = alignSegmentAtTab(segment, font, run2);
|
|
81210
|
+
if (segmentStartX == null) {
|
|
81211
|
+
segmentStartX = currentLine.width;
|
|
81212
|
+
}
|
|
80791
81213
|
}
|
|
80792
81214
|
for (let wordIndex = 0; wordIndex < words.length; wordIndex++) {
|
|
80793
81215
|
const word = words[wordIndex];
|
|
@@ -81428,12 +81850,49 @@ ${l}
|
|
|
81428
81850
|
editor,
|
|
81429
81851
|
data,
|
|
81430
81852
|
editorContainer,
|
|
81431
|
-
|
|
81853
|
+
editorHost,
|
|
81432
81854
|
sectionId,
|
|
81433
81855
|
type: type2,
|
|
81856
|
+
availableWidth,
|
|
81434
81857
|
availableHeight,
|
|
81435
|
-
currentPageNumber
|
|
81858
|
+
currentPageNumber,
|
|
81859
|
+
totalPageCount
|
|
81436
81860
|
}) => {
|
|
81861
|
+
if (!editor) {
|
|
81862
|
+
throw new TypeError("editor parameter is required");
|
|
81863
|
+
}
|
|
81864
|
+
if (!data) {
|
|
81865
|
+
throw new TypeError("data parameter is required");
|
|
81866
|
+
}
|
|
81867
|
+
if (!editorContainer) {
|
|
81868
|
+
throw new TypeError("editorContainer parameter is required");
|
|
81869
|
+
}
|
|
81870
|
+
if (!(editorContainer instanceof HTMLElement)) {
|
|
81871
|
+
throw new TypeError("editorContainer must be an HTMLElement");
|
|
81872
|
+
}
|
|
81873
|
+
if (editorHost !== void 0 && !(editorHost instanceof HTMLElement)) {
|
|
81874
|
+
throw new TypeError("editorHost must be an HTMLElement or undefined");
|
|
81875
|
+
}
|
|
81876
|
+
if (availableWidth !== void 0) {
|
|
81877
|
+
if (typeof availableWidth !== "number" || !Number.isFinite(availableWidth) || availableWidth <= 0) {
|
|
81878
|
+
throw new RangeError("availableWidth must be a positive number");
|
|
81879
|
+
}
|
|
81880
|
+
}
|
|
81881
|
+
if (availableHeight !== void 0) {
|
|
81882
|
+
if (typeof availableHeight !== "number" || !Number.isFinite(availableHeight) || availableHeight <= 0) {
|
|
81883
|
+
throw new RangeError("availableHeight must be a positive number");
|
|
81884
|
+
}
|
|
81885
|
+
}
|
|
81886
|
+
if (currentPageNumber !== void 0) {
|
|
81887
|
+
if (typeof currentPageNumber !== "number" || !Number.isInteger(currentPageNumber) || currentPageNumber < 1) {
|
|
81888
|
+
throw new RangeError("currentPageNumber must be a positive integer");
|
|
81889
|
+
}
|
|
81890
|
+
}
|
|
81891
|
+
if (totalPageCount !== void 0) {
|
|
81892
|
+
if (typeof totalPageCount !== "number" || !Number.isInteger(totalPageCount) || totalPageCount < 1) {
|
|
81893
|
+
throw new RangeError("totalPageCount must be a positive integer");
|
|
81894
|
+
}
|
|
81895
|
+
}
|
|
81437
81896
|
const parentStyles = editor.converter.getDocumentDefaultStyles();
|
|
81438
81897
|
const { fontSizePt, typeface, fontFamilyCss } = parentStyles;
|
|
81439
81898
|
const fontSizeInPixles = fontSizePt * 1.3333;
|
|
@@ -81447,21 +81906,24 @@ ${l}
|
|
|
81447
81906
|
position: "absolute",
|
|
81448
81907
|
top: "0",
|
|
81449
81908
|
left: "0",
|
|
81450
|
-
width: "
|
|
81909
|
+
width: availableWidth ? `${availableWidth}px` : "100%",
|
|
81910
|
+
height: availableHeight ? `${availableHeight}px` : "auto",
|
|
81451
81911
|
maxWidth: "none",
|
|
81452
81912
|
fontFamily: fontFamilyCss || typeface,
|
|
81453
81913
|
fontSize: `${fontSizeInPixles}px`,
|
|
81454
|
-
lineHeight: `${lineHeight2}px
|
|
81455
|
-
|
|
81456
|
-
|
|
81457
|
-
|
|
81458
|
-
|
|
81459
|
-
|
|
81460
|
-
|
|
81461
|
-
|
|
81462
|
-
|
|
81463
|
-
}
|
|
81464
|
-
|
|
81914
|
+
lineHeight: `${lineHeight2}px`,
|
|
81915
|
+
overflow: "hidden",
|
|
81916
|
+
pointerEvents: "auto",
|
|
81917
|
+
// Critical: enables click interaction
|
|
81918
|
+
backgroundColor: "white"
|
|
81919
|
+
// Ensure editor has white background
|
|
81920
|
+
});
|
|
81921
|
+
if (editorHost) {
|
|
81922
|
+
editorHost.appendChild(editorContainer);
|
|
81923
|
+
} else {
|
|
81924
|
+
console.warn("[createHeaderFooterEditor] No editorHost provided, falling back to document.body");
|
|
81925
|
+
document.body.appendChild(editorContainer);
|
|
81926
|
+
}
|
|
81465
81927
|
const headerFooterEditor = new Editor({
|
|
81466
81928
|
role: editor.options.role,
|
|
81467
81929
|
loadFromSchema: true,
|
|
@@ -81479,9 +81941,12 @@ ${l}
|
|
|
81479
81941
|
pagination: false,
|
|
81480
81942
|
// Explicitly disable pagination
|
|
81481
81943
|
annotations: true,
|
|
81482
|
-
currentPageNumber,
|
|
81944
|
+
currentPageNumber: currentPageNumber ?? 1,
|
|
81945
|
+
totalPageCount: totalPageCount ?? 1,
|
|
81483
81946
|
// Don't set parentEditor to avoid circular reference issues
|
|
81484
81947
|
// parentEditor: editor,
|
|
81948
|
+
// IMPORTANT: Start with editable: false to prevent triggering update cascades during creation.
|
|
81949
|
+
// PresentationEditor#enterHeaderFooterMode will call setEditable(true) when entering edit mode.
|
|
81485
81950
|
editable: false,
|
|
81486
81951
|
documentMode: "viewing",
|
|
81487
81952
|
onCreate: (evt) => setEditorToolbar(evt, editor),
|
|
@@ -81511,18 +81976,23 @@ ${l}
|
|
|
81511
81976
|
const onHeaderFooterDataUpdate = async ({ editor, transaction }, mainEditor, sectionId, type2) => {
|
|
81512
81977
|
if (!type2 || !sectionId) return;
|
|
81513
81978
|
const updatedData = editor.getUpdatedJson();
|
|
81514
|
-
mainEditor.converter[`${type2}Editors`]
|
|
81515
|
-
|
|
81979
|
+
const editorsList = mainEditor.converter[`${type2}Editors`];
|
|
81980
|
+
if (Array.isArray(editorsList)) {
|
|
81981
|
+
editorsList.forEach((item) => {
|
|
81982
|
+
if (item.id === sectionId) {
|
|
81983
|
+
item.editor.setOptions({
|
|
81984
|
+
media: editor.options.media,
|
|
81985
|
+
mediaFiles: editor.options.mediaFiles
|
|
81986
|
+
});
|
|
81987
|
+
if (item.editor !== editor) {
|
|
81988
|
+
item.editor.replaceContent(updatedData);
|
|
81989
|
+
}
|
|
81990
|
+
}
|
|
81516
81991
|
item.editor.setOptions({
|
|
81517
|
-
|
|
81518
|
-
mediaFiles: editor.options.mediaFiles
|
|
81992
|
+
lastSelection: transaction?.selection
|
|
81519
81993
|
});
|
|
81520
|
-
item.editor.replaceContent(updatedData);
|
|
81521
|
-
}
|
|
81522
|
-
item.editor.setOptions({
|
|
81523
|
-
lastSelection: transaction?.selection
|
|
81524
81994
|
});
|
|
81525
|
-
}
|
|
81995
|
+
}
|
|
81526
81996
|
mainEditor.converter[`${type2}s`][sectionId] = updatedData;
|
|
81527
81997
|
mainEditor.setOptions({ isHeaderFooterChanged: editor.docChanged });
|
|
81528
81998
|
await updateYdocDocxData(mainEditor);
|
|
@@ -81603,13 +82073,69 @@ ${l}
|
|
|
81603
82073
|
* Handles concurrent calls for the same descriptor by tracking pending creations
|
|
81604
82074
|
* and returning the same promise to all callers.
|
|
81605
82075
|
*
|
|
81606
|
-
* @param descriptor - The header or footer descriptor
|
|
82076
|
+
* @param descriptor - The header or footer descriptor. Must have a valid id property.
|
|
82077
|
+
* @param options - Optional configuration for editor creation
|
|
82078
|
+
* @param options.editorHost - The HTMLElement to mount the editor in. If provided, must be a valid HTMLElement.
|
|
82079
|
+
* @param options.availableWidth - The width of the editing region in pixels. Must be a positive number if provided.
|
|
82080
|
+
* @param options.availableHeight - The height of the editing region in pixels. Must be a positive number if provided.
|
|
82081
|
+
* @param options.currentPageNumber - The current page number for PAGE field resolution. Must be a positive integer if provided.
|
|
82082
|
+
* @param options.totalPageCount - The total page count for NUMPAGES field resolution. Must be a positive integer if provided.
|
|
81607
82083
|
* @returns The editor instance, or null if creation failed
|
|
81608
82084
|
*
|
|
81609
|
-
* @throws Never throws - errors are logged and emitted as events
|
|
82085
|
+
* @throws Never throws - errors are logged and emitted as events. Invalid parameters return null with error logged.
|
|
81610
82086
|
*/
|
|
81611
|
-
async ensureEditor(descriptor) {
|
|
82087
|
+
async ensureEditor(descriptor, options) {
|
|
81612
82088
|
if (!descriptor?.id) return null;
|
|
82089
|
+
if (options) {
|
|
82090
|
+
if (options.editorHost !== void 0 && !(options.editorHost instanceof HTMLElement)) {
|
|
82091
|
+
console.error("[HeaderFooterEditorManager] editorHost must be an HTMLElement");
|
|
82092
|
+
this.emit("error", {
|
|
82093
|
+
descriptor,
|
|
82094
|
+
error: new TypeError("editorHost must be an HTMLElement")
|
|
82095
|
+
});
|
|
82096
|
+
return null;
|
|
82097
|
+
}
|
|
82098
|
+
if (options.availableWidth !== void 0) {
|
|
82099
|
+
if (typeof options.availableWidth !== "number" || !Number.isFinite(options.availableWidth) || options.availableWidth <= 0) {
|
|
82100
|
+
console.error("[HeaderFooterEditorManager] availableWidth must be a positive number");
|
|
82101
|
+
this.emit("error", {
|
|
82102
|
+
descriptor,
|
|
82103
|
+
error: new TypeError("availableWidth must be a positive number")
|
|
82104
|
+
});
|
|
82105
|
+
return null;
|
|
82106
|
+
}
|
|
82107
|
+
}
|
|
82108
|
+
if (options.availableHeight !== void 0) {
|
|
82109
|
+
if (typeof options.availableHeight !== "number" || !Number.isFinite(options.availableHeight) || options.availableHeight <= 0) {
|
|
82110
|
+
console.error("[HeaderFooterEditorManager] availableHeight must be a positive number");
|
|
82111
|
+
this.emit("error", {
|
|
82112
|
+
descriptor,
|
|
82113
|
+
error: new TypeError("availableHeight must be a positive number")
|
|
82114
|
+
});
|
|
82115
|
+
return null;
|
|
82116
|
+
}
|
|
82117
|
+
}
|
|
82118
|
+
if (options.currentPageNumber !== void 0) {
|
|
82119
|
+
if (typeof options.currentPageNumber !== "number" || !Number.isInteger(options.currentPageNumber) || options.currentPageNumber < 1) {
|
|
82120
|
+
console.error("[HeaderFooterEditorManager] currentPageNumber must be a positive integer");
|
|
82121
|
+
this.emit("error", {
|
|
82122
|
+
descriptor,
|
|
82123
|
+
error: new TypeError("currentPageNumber must be a positive integer")
|
|
82124
|
+
});
|
|
82125
|
+
return null;
|
|
82126
|
+
}
|
|
82127
|
+
}
|
|
82128
|
+
if (options.totalPageCount !== void 0) {
|
|
82129
|
+
if (typeof options.totalPageCount !== "number" || !Number.isInteger(options.totalPageCount) || options.totalPageCount < 1) {
|
|
82130
|
+
console.error("[HeaderFooterEditorManager] totalPageCount must be a positive integer");
|
|
82131
|
+
this.emit("error", {
|
|
82132
|
+
descriptor,
|
|
82133
|
+
error: new TypeError("totalPageCount must be a positive integer")
|
|
82134
|
+
});
|
|
82135
|
+
return null;
|
|
82136
|
+
}
|
|
82137
|
+
}
|
|
82138
|
+
}
|
|
81613
82139
|
const existing = __privateGet$1(this, _editorEntries).get(descriptor.id);
|
|
81614
82140
|
if (existing) {
|
|
81615
82141
|
__privateSet(this, _cacheHits, __privateGet$1(this, _cacheHits) + 1);
|
|
@@ -81618,6 +82144,29 @@ ${l}
|
|
|
81618
82144
|
console.error("[HeaderFooterEditorManager] Editor initialization failed:", error);
|
|
81619
82145
|
this.emit("error", { descriptor, error });
|
|
81620
82146
|
});
|
|
82147
|
+
if (existing.container && options?.editorHost) {
|
|
82148
|
+
if (existing.container.parentElement !== options.editorHost) {
|
|
82149
|
+
options.editorHost.appendChild(existing.container);
|
|
82150
|
+
}
|
|
82151
|
+
}
|
|
82152
|
+
if (existing.editor && options) {
|
|
82153
|
+
const updateOptions = {};
|
|
82154
|
+
if (options.currentPageNumber !== void 0) {
|
|
82155
|
+
updateOptions.currentPageNumber = options.currentPageNumber;
|
|
82156
|
+
}
|
|
82157
|
+
if (options.totalPageCount !== void 0) {
|
|
82158
|
+
updateOptions.totalPageCount = options.totalPageCount;
|
|
82159
|
+
}
|
|
82160
|
+
if (options.availableWidth !== void 0) {
|
|
82161
|
+
updateOptions.availableWidth = options.availableWidth;
|
|
82162
|
+
}
|
|
82163
|
+
if (options.availableHeight !== void 0) {
|
|
82164
|
+
updateOptions.availableHeight = options.availableHeight;
|
|
82165
|
+
}
|
|
82166
|
+
if (Object.keys(updateOptions).length > 0) {
|
|
82167
|
+
existing.editor.setOptions(updateOptions);
|
|
82168
|
+
}
|
|
82169
|
+
}
|
|
81621
82170
|
return existing.editor;
|
|
81622
82171
|
}
|
|
81623
82172
|
const pending = __privateGet$1(this, _pendingCreations).get(descriptor.id);
|
|
@@ -81627,7 +82176,7 @@ ${l}
|
|
|
81627
82176
|
__privateSet(this, _cacheMisses, __privateGet$1(this, _cacheMisses) + 1);
|
|
81628
82177
|
const creationPromise = (async () => {
|
|
81629
82178
|
try {
|
|
81630
|
-
const entry = await __privateMethod$1(this, _HeaderFooterEditorManager_instances, createEditor_fn).call(this, descriptor);
|
|
82179
|
+
const entry = await __privateMethod$1(this, _HeaderFooterEditorManager_instances, createEditor_fn).call(this, descriptor, options);
|
|
81631
82180
|
if (!entry) return null;
|
|
81632
82181
|
__privateGet$1(this, _editorEntries).set(descriptor.id, entry);
|
|
81633
82182
|
__privateMethod$1(this, _HeaderFooterEditorManager_instances, updateAccessOrder_fn).call(this, descriptor.id);
|
|
@@ -81935,7 +82484,7 @@ ${l}
|
|
|
81935
82484
|
});
|
|
81936
82485
|
__privateGet$1(this, _editorEntries).clear();
|
|
81937
82486
|
};
|
|
81938
|
-
createEditor_fn = async function(descriptor) {
|
|
82487
|
+
createEditor_fn = async function(descriptor, options) {
|
|
81939
82488
|
const json = this.getDocumentJson(descriptor);
|
|
81940
82489
|
if (!json) return null;
|
|
81941
82490
|
let editor;
|
|
@@ -81946,12 +82495,13 @@ ${l}
|
|
|
81946
82495
|
editor: __privateGet$1(this, _editor2),
|
|
81947
82496
|
data: json,
|
|
81948
82497
|
editorContainer: container,
|
|
81949
|
-
|
|
82498
|
+
editorHost: options?.editorHost,
|
|
81950
82499
|
sectionId: descriptor.id,
|
|
81951
82500
|
type: descriptor.kind,
|
|
81952
|
-
|
|
81953
|
-
|
|
81954
|
-
|
|
82501
|
+
availableWidth: options?.availableWidth,
|
|
82502
|
+
availableHeight: options?.availableHeight ?? DEFAULT_HEADER_FOOTER_HEIGHT,
|
|
82503
|
+
currentPageNumber: options?.currentPageNumber ?? 1,
|
|
82504
|
+
totalPageCount: options?.totalPageCount ?? 1
|
|
81955
82505
|
});
|
|
81956
82506
|
} catch (error) {
|
|
81957
82507
|
console.error("[HeaderFooterEditorManager] Editor creation failed:", error);
|
|
@@ -82225,6 +82775,312 @@ ${l}
|
|
|
82225
82775
|
}
|
|
82226
82776
|
return Object.keys(context).length > 0 ? context : void 0;
|
|
82227
82777
|
};
|
|
82778
|
+
const EDITOR_HOST_Z_INDEX = "10";
|
|
82779
|
+
const BORDER_LINE_Z_INDEX = "15";
|
|
82780
|
+
const BORDER_LINE_COLOR = "#4472c4";
|
|
82781
|
+
const BORDER_LINE_HEIGHT = "1px";
|
|
82782
|
+
class EditorOverlayManager {
|
|
82783
|
+
/**
|
|
82784
|
+
* Creates a new EditorOverlayManager instance.
|
|
82785
|
+
*
|
|
82786
|
+
* @param painterHost - The host element containing painted pages. Must be an HTMLElement connected to the DOM.
|
|
82787
|
+
* @param visibleHost - The visible host element for overlay positioning. Must be an HTMLElement connected to the DOM.
|
|
82788
|
+
* @param selectionOverlay - The selection overlay element (optional). If provided, must be an HTMLElement.
|
|
82789
|
+
*
|
|
82790
|
+
* @throws {TypeError} If painterHost is not an HTMLElement
|
|
82791
|
+
* @throws {TypeError} If visibleHost is not an HTMLElement
|
|
82792
|
+
* @throws {TypeError} If selectionOverlay is provided but is not an HTMLElement
|
|
82793
|
+
* @throws {Error} If painterHost is not connected to the DOM
|
|
82794
|
+
* @throws {Error} If visibleHost is not connected to the DOM
|
|
82795
|
+
*/
|
|
82796
|
+
constructor(painterHost, visibleHost, selectionOverlay = null) {
|
|
82797
|
+
__privateAdd$1(this, _EditorOverlayManager_instances);
|
|
82798
|
+
__privateAdd$1(this, _selectionOverlay);
|
|
82799
|
+
__privateAdd$1(this, _activeEditorHost, null);
|
|
82800
|
+
__privateAdd$1(this, _activeDecorationContainer, null);
|
|
82801
|
+
__privateAdd$1(this, _activeRegion, null);
|
|
82802
|
+
__privateAdd$1(this, _borderLine, null);
|
|
82803
|
+
if (!(painterHost instanceof HTMLElement)) {
|
|
82804
|
+
throw new TypeError("painterHost must be an HTMLElement");
|
|
82805
|
+
}
|
|
82806
|
+
if (!(visibleHost instanceof HTMLElement)) {
|
|
82807
|
+
throw new TypeError("visibleHost must be an HTMLElement");
|
|
82808
|
+
}
|
|
82809
|
+
if (selectionOverlay !== null && !(selectionOverlay instanceof HTMLElement)) {
|
|
82810
|
+
throw new TypeError("selectionOverlay must be an HTMLElement or null");
|
|
82811
|
+
}
|
|
82812
|
+
if (!painterHost.isConnected) {
|
|
82813
|
+
throw new Error("painterHost must be connected to the DOM");
|
|
82814
|
+
}
|
|
82815
|
+
if (!visibleHost.isConnected) {
|
|
82816
|
+
throw new Error("visibleHost must be connected to the DOM");
|
|
82817
|
+
}
|
|
82818
|
+
__privateSet(this, _selectionOverlay, selectionOverlay);
|
|
82819
|
+
}
|
|
82820
|
+
/**
|
|
82821
|
+
* Sets the callback to be invoked when the dimming overlay is clicked.
|
|
82822
|
+
* This allows PresentationEditor to exit header/footer mode when the user
|
|
82823
|
+
* clicks outside the editing region.
|
|
82824
|
+
*
|
|
82825
|
+
* @param callback - Function to call when dimming overlay is clicked
|
|
82826
|
+
*/
|
|
82827
|
+
setOnDimmingClick(_callback) {
|
|
82828
|
+
}
|
|
82829
|
+
/**
|
|
82830
|
+
* Gets the currently active editor host element.
|
|
82831
|
+
* This is useful for checking if a click target is inside the active editing area.
|
|
82832
|
+
*
|
|
82833
|
+
* @returns The active editor host element, or null if not in editing mode
|
|
82834
|
+
*/
|
|
82835
|
+
getActiveEditorHost() {
|
|
82836
|
+
return __privateGet$1(this, _activeEditorHost);
|
|
82837
|
+
}
|
|
82838
|
+
/**
|
|
82839
|
+
* Shows the editing overlay for a header/footer region.
|
|
82840
|
+
*
|
|
82841
|
+
* This method:
|
|
82842
|
+
* 1. Creates or retrieves the editor host element as a sibling to the decoration container
|
|
82843
|
+
* 2. Positions the editor host to match the decoration container bounds
|
|
82844
|
+
* 3. Hides the static decoration content
|
|
82845
|
+
* 4. Shows the dimming overlay over body content
|
|
82846
|
+
* 5. Returns the editor host element for mounting the ProseMirror editor
|
|
82847
|
+
*
|
|
82848
|
+
* @param pageElement - The page DOM element containing the region
|
|
82849
|
+
* @param region - The header/footer region to edit
|
|
82850
|
+
* @param zoom - Current zoom level (for positioning calculations)
|
|
82851
|
+
* @returns Result object with success status and editor host element
|
|
82852
|
+
*
|
|
82853
|
+
* @example
|
|
82854
|
+
* ```typescript
|
|
82855
|
+
* const result = overlayManager.showEditingOverlay(pageElement, region, 1.0);
|
|
82856
|
+
* if (result.success && result.editorHost) {
|
|
82857
|
+
* // Mount ProseMirror editor in result.editorHost
|
|
82858
|
+
* }
|
|
82859
|
+
* ```
|
|
82860
|
+
*/
|
|
82861
|
+
showEditingOverlay(pageElement, region, zoom) {
|
|
82862
|
+
try {
|
|
82863
|
+
const decorationContainer = __privateMethod$1(this, _EditorOverlayManager_instances, findDecorationContainer_fn).call(this, pageElement, region.kind);
|
|
82864
|
+
if (!decorationContainer) {
|
|
82865
|
+
return {
|
|
82866
|
+
success: false,
|
|
82867
|
+
reason: `Decoration container not found for ${region.kind} on page ${region.pageIndex}`
|
|
82868
|
+
};
|
|
82869
|
+
}
|
|
82870
|
+
const editorHost = __privateMethod$1(this, _EditorOverlayManager_instances, ensureEditorHost_fn).call(this, pageElement, region.kind);
|
|
82871
|
+
if (!editorHost) {
|
|
82872
|
+
return {
|
|
82873
|
+
success: false,
|
|
82874
|
+
reason: `Failed to create editor host for ${region.kind}`
|
|
82875
|
+
};
|
|
82876
|
+
}
|
|
82877
|
+
__privateMethod$1(this, _EditorOverlayManager_instances, positionEditorHost_fn).call(this, editorHost, region, decorationContainer, zoom);
|
|
82878
|
+
decorationContainer.style.visibility = "hidden";
|
|
82879
|
+
editorHost.style.visibility = "visible";
|
|
82880
|
+
editorHost.style.zIndex = EDITOR_HOST_Z_INDEX;
|
|
82881
|
+
if (region.kind === "footer") {
|
|
82882
|
+
const contentOffset = editorHost.dataset.contentOffset;
|
|
82883
|
+
if (contentOffset) {
|
|
82884
|
+
const editorContainer = editorHost.querySelector(".super-editor");
|
|
82885
|
+
if (editorContainer instanceof HTMLElement) {
|
|
82886
|
+
editorContainer.style.top = `${contentOffset}px`;
|
|
82887
|
+
}
|
|
82888
|
+
}
|
|
82889
|
+
}
|
|
82890
|
+
__privateMethod$1(this, _EditorOverlayManager_instances, showHeaderFooterBorder_fn).call(this, pageElement, region, decorationContainer);
|
|
82891
|
+
__privateSet(this, _activeEditorHost, editorHost);
|
|
82892
|
+
__privateSet(this, _activeDecorationContainer, decorationContainer);
|
|
82893
|
+
__privateSet(this, _activeRegion, region);
|
|
82894
|
+
return {
|
|
82895
|
+
success: true,
|
|
82896
|
+
editorHost
|
|
82897
|
+
};
|
|
82898
|
+
} catch (error) {
|
|
82899
|
+
if (__privateGet$1(this, _activeDecorationContainer)) {
|
|
82900
|
+
__privateGet$1(this, _activeDecorationContainer).style.visibility = "visible";
|
|
82901
|
+
}
|
|
82902
|
+
if (__privateGet$1(this, _activeEditorHost)) {
|
|
82903
|
+
__privateGet$1(this, _activeEditorHost).style.visibility = "hidden";
|
|
82904
|
+
}
|
|
82905
|
+
__privateMethod$1(this, _EditorOverlayManager_instances, hideHeaderFooterBorder_fn).call(this);
|
|
82906
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
82907
|
+
console.error("[EditorOverlayManager] Failed to show editing overlay:", error);
|
|
82908
|
+
return {
|
|
82909
|
+
success: false,
|
|
82910
|
+
reason: `DOM manipulation error: ${errorMessage}`
|
|
82911
|
+
};
|
|
82912
|
+
}
|
|
82913
|
+
}
|
|
82914
|
+
/**
|
|
82915
|
+
* Hides the editing overlay and restores normal view.
|
|
82916
|
+
*
|
|
82917
|
+
* This method:
|
|
82918
|
+
* 1. Shows the static decoration content
|
|
82919
|
+
* 2. Hides the editor host (but doesn't destroy it for reuse)
|
|
82920
|
+
* 3. Removes the dimming overlay
|
|
82921
|
+
*
|
|
82922
|
+
* @example
|
|
82923
|
+
* ```typescript
|
|
82924
|
+
* overlayManager.hideEditingOverlay();
|
|
82925
|
+
* // Static decoration is now visible, editor is hidden
|
|
82926
|
+
* ```
|
|
82927
|
+
*/
|
|
82928
|
+
hideEditingOverlay() {
|
|
82929
|
+
if (__privateGet$1(this, _activeDecorationContainer)) {
|
|
82930
|
+
__privateGet$1(this, _activeDecorationContainer).style.visibility = "visible";
|
|
82931
|
+
}
|
|
82932
|
+
if (__privateGet$1(this, _activeEditorHost)) {
|
|
82933
|
+
__privateGet$1(this, _activeEditorHost).style.visibility = "hidden";
|
|
82934
|
+
__privateGet$1(this, _activeEditorHost).style.zIndex = "";
|
|
82935
|
+
if (__privateGet$1(this, _activeRegion)?.kind === "footer") {
|
|
82936
|
+
const editorContainer = __privateGet$1(this, _activeEditorHost).querySelector(".super-editor");
|
|
82937
|
+
if (editorContainer instanceof HTMLElement) {
|
|
82938
|
+
editorContainer.style.top = "0";
|
|
82939
|
+
}
|
|
82940
|
+
}
|
|
82941
|
+
}
|
|
82942
|
+
__privateMethod$1(this, _EditorOverlayManager_instances, hideHeaderFooterBorder_fn).call(this);
|
|
82943
|
+
__privateSet(this, _activeEditorHost, null);
|
|
82944
|
+
__privateSet(this, _activeDecorationContainer, null);
|
|
82945
|
+
__privateSet(this, _activeRegion, null);
|
|
82946
|
+
}
|
|
82947
|
+
/**
|
|
82948
|
+
* Hides the layout selection overlay to prevent double caret rendering.
|
|
82949
|
+
*
|
|
82950
|
+
* Called when entering header/footer editing mode to ensure only the
|
|
82951
|
+
* ProseMirror editor's caret is visible, not both the PM caret and the
|
|
82952
|
+
* layout engine's selection overlay.
|
|
82953
|
+
*
|
|
82954
|
+
* @example
|
|
82955
|
+
* ```typescript
|
|
82956
|
+
* overlayManager.hideSelectionOverlay();
|
|
82957
|
+
* // Selection overlay is now hidden
|
|
82958
|
+
* ```
|
|
82959
|
+
*/
|
|
82960
|
+
hideSelectionOverlay() {
|
|
82961
|
+
if (__privateGet$1(this, _selectionOverlay)) {
|
|
82962
|
+
__privateGet$1(this, _selectionOverlay).style.visibility = "hidden";
|
|
82963
|
+
}
|
|
82964
|
+
}
|
|
82965
|
+
/**
|
|
82966
|
+
* Shows the layout selection overlay.
|
|
82967
|
+
*
|
|
82968
|
+
* Called when exiting header/footer editing mode to restore the
|
|
82969
|
+
* normal selection overlay rendering for body content.
|
|
82970
|
+
*
|
|
82971
|
+
* @example
|
|
82972
|
+
* ```typescript
|
|
82973
|
+
* overlayManager.showSelectionOverlay();
|
|
82974
|
+
* // Selection overlay is now visible
|
|
82975
|
+
* ```
|
|
82976
|
+
*/
|
|
82977
|
+
showSelectionOverlay() {
|
|
82978
|
+
if (__privateGet$1(this, _selectionOverlay)) {
|
|
82979
|
+
__privateGet$1(this, _selectionOverlay).style.visibility = "visible";
|
|
82980
|
+
}
|
|
82981
|
+
}
|
|
82982
|
+
/**
|
|
82983
|
+
* Destroys the overlay manager and cleans up all resources.
|
|
82984
|
+
*
|
|
82985
|
+
* Clears all references.
|
|
82986
|
+
* Editor host elements are left in the DOM as they're children of page elements
|
|
82987
|
+
* that will be cleaned up by the virtualization system.
|
|
82988
|
+
*/
|
|
82989
|
+
destroy() {
|
|
82990
|
+
__privateMethod$1(this, _EditorOverlayManager_instances, hideHeaderFooterBorder_fn).call(this);
|
|
82991
|
+
__privateSet(this, _activeEditorHost, null);
|
|
82992
|
+
__privateSet(this, _activeDecorationContainer, null);
|
|
82993
|
+
__privateSet(this, _activeRegion, null);
|
|
82994
|
+
__privateSet(this, _selectionOverlay, null);
|
|
82995
|
+
}
|
|
82996
|
+
}
|
|
82997
|
+
_selectionOverlay = /* @__PURE__ */ new WeakMap();
|
|
82998
|
+
_activeEditorHost = /* @__PURE__ */ new WeakMap();
|
|
82999
|
+
_activeDecorationContainer = /* @__PURE__ */ new WeakMap();
|
|
83000
|
+
_activeRegion = /* @__PURE__ */ new WeakMap();
|
|
83001
|
+
_borderLine = /* @__PURE__ */ new WeakMap();
|
|
83002
|
+
_EditorOverlayManager_instances = /* @__PURE__ */ new WeakSet();
|
|
83003
|
+
findDecorationContainer_fn = function(pageElement, kind) {
|
|
83004
|
+
const className = kind === "header" ? "superdoc-page-header" : "superdoc-page-footer";
|
|
83005
|
+
return pageElement.querySelector(`.${className}`);
|
|
83006
|
+
};
|
|
83007
|
+
ensureEditorHost_fn = function(pageElement, kind) {
|
|
83008
|
+
const className = kind === "header" ? "superdoc-header-editor-host" : "superdoc-footer-editor-host";
|
|
83009
|
+
let editorHost = pageElement.querySelector(`.${className}`);
|
|
83010
|
+
if (!editorHost) {
|
|
83011
|
+
editorHost = document.createElement("div");
|
|
83012
|
+
editorHost.className = className;
|
|
83013
|
+
Object.assign(editorHost.style, {
|
|
83014
|
+
position: "absolute",
|
|
83015
|
+
pointerEvents: "auto",
|
|
83016
|
+
// Critical: enables click interaction
|
|
83017
|
+
visibility: "hidden",
|
|
83018
|
+
// Hidden by default, shown during editing
|
|
83019
|
+
overflow: "hidden",
|
|
83020
|
+
boxSizing: "border-box"
|
|
83021
|
+
});
|
|
83022
|
+
const decorationContainer = __privateMethod$1(this, _EditorOverlayManager_instances, findDecorationContainer_fn).call(this, pageElement, kind);
|
|
83023
|
+
if (!decorationContainer) {
|
|
83024
|
+
console.error(`[EditorOverlayManager] Decoration container not found for ${kind}`);
|
|
83025
|
+
return null;
|
|
83026
|
+
}
|
|
83027
|
+
decorationContainer.parentNode?.insertBefore(editorHost, decorationContainer.nextSibling);
|
|
83028
|
+
}
|
|
83029
|
+
return editorHost;
|
|
83030
|
+
};
|
|
83031
|
+
positionEditorHost_fn = function(editorHost, region, decorationContainer, _zoom) {
|
|
83032
|
+
const decorationRect = decorationContainer.getBoundingClientRect();
|
|
83033
|
+
const pageElement = editorHost.parentElement;
|
|
83034
|
+
if (!pageElement) {
|
|
83035
|
+
console.error("[EditorOverlayManager] Editor host has no parent element");
|
|
83036
|
+
return;
|
|
83037
|
+
}
|
|
83038
|
+
const pageRect = pageElement.getBoundingClientRect();
|
|
83039
|
+
const top2 = decorationRect.top - pageRect.top;
|
|
83040
|
+
const left2 = decorationRect.left - pageRect.left;
|
|
83041
|
+
const width = decorationRect.width;
|
|
83042
|
+
const height = decorationRect.height;
|
|
83043
|
+
Object.assign(editorHost.style, {
|
|
83044
|
+
top: `${top2}px`,
|
|
83045
|
+
left: `${left2}px`,
|
|
83046
|
+
width: `${width}px`,
|
|
83047
|
+
height: `${height}px`
|
|
83048
|
+
});
|
|
83049
|
+
if (region.kind === "footer") {
|
|
83050
|
+
const fragment = decorationContainer.querySelector(".superdoc-fragment");
|
|
83051
|
+
if (fragment instanceof HTMLElement) {
|
|
83052
|
+
const fragmentTop = parseFloat(fragment.style.top) || 0;
|
|
83053
|
+
editorHost.dataset.contentOffset = String(fragmentTop);
|
|
83054
|
+
}
|
|
83055
|
+
}
|
|
83056
|
+
};
|
|
83057
|
+
showHeaderFooterBorder_fn = function(pageElement, region, decorationContainer) {
|
|
83058
|
+
__privateMethod$1(this, _EditorOverlayManager_instances, hideHeaderFooterBorder_fn).call(this);
|
|
83059
|
+
__privateSet(this, _borderLine, document.createElement("div"));
|
|
83060
|
+
__privateGet$1(this, _borderLine).className = "superdoc-header-footer-border";
|
|
83061
|
+
const decorationRect = decorationContainer.getBoundingClientRect();
|
|
83062
|
+
const pageRect = pageElement.getBoundingClientRect();
|
|
83063
|
+
const isHeader = region.kind === "header";
|
|
83064
|
+
const topPosition = isHeader ? decorationRect.bottom - pageRect.top : decorationRect.top - pageRect.top;
|
|
83065
|
+
Object.assign(__privateGet$1(this, _borderLine).style, {
|
|
83066
|
+
position: "absolute",
|
|
83067
|
+
left: "0",
|
|
83068
|
+
right: "0",
|
|
83069
|
+
top: `${topPosition}px`,
|
|
83070
|
+
height: BORDER_LINE_HEIGHT,
|
|
83071
|
+
backgroundColor: BORDER_LINE_COLOR,
|
|
83072
|
+
// MS Word blue
|
|
83073
|
+
zIndex: BORDER_LINE_Z_INDEX,
|
|
83074
|
+
pointerEvents: "none"
|
|
83075
|
+
});
|
|
83076
|
+
pageElement.appendChild(__privateGet$1(this, _borderLine));
|
|
83077
|
+
};
|
|
83078
|
+
hideHeaderFooterBorder_fn = function() {
|
|
83079
|
+
if (__privateGet$1(this, _borderLine)) {
|
|
83080
|
+
__privateGet$1(this, _borderLine).remove();
|
|
83081
|
+
__privateSet(this, _borderLine, null);
|
|
83082
|
+
}
|
|
83083
|
+
};
|
|
82228
83084
|
const uiSurfaces = /* @__PURE__ */ new WeakSet();
|
|
82229
83085
|
function isInRegisteredSurface(event) {
|
|
82230
83086
|
const path2 = typeof event.composedPath === "function" ? event.composedPath() : [];
|
|
@@ -82263,7 +83119,7 @@ ${l}
|
|
|
82263
83119
|
__privateAdd$1(this, _visibleHost);
|
|
82264
83120
|
__privateAdd$1(this, _viewportHost);
|
|
82265
83121
|
__privateAdd$1(this, _painterHost);
|
|
82266
|
-
__privateAdd$1(this,
|
|
83122
|
+
__privateAdd$1(this, _selectionOverlay2);
|
|
82267
83123
|
__privateAdd$1(this, _hiddenHost);
|
|
82268
83124
|
__privateAdd$1(this, _layoutOptions);
|
|
82269
83125
|
__privateAdd$1(this, _layoutState, { blocks: [], measures: [], layout: null });
|
|
@@ -82298,6 +83154,7 @@ ${l}
|
|
|
82298
83154
|
__privateAdd$1(this, _footerRegions, /* @__PURE__ */ new Map());
|
|
82299
83155
|
__privateAdd$1(this, _session, { mode: "body" });
|
|
82300
83156
|
__privateAdd$1(this, _activeHeaderFooterEditor, null);
|
|
83157
|
+
__privateAdd$1(this, _overlayManager, null);
|
|
82301
83158
|
__privateAdd$1(this, _hoverOverlay, null);
|
|
82302
83159
|
__privateAdd$1(this, _hoverTooltip, null);
|
|
82303
83160
|
__privateAdd$1(this, _modeBanner, null);
|
|
@@ -82352,6 +83209,11 @@ ${l}
|
|
|
82352
83209
|
const x2 = (event.clientX - rect.left + scrollLeft) / zoom;
|
|
82353
83210
|
const y2 = (event.clientY - rect.top + scrollTop) / zoom;
|
|
82354
83211
|
if (__privateGet$1(this, _session).mode !== "body") {
|
|
83212
|
+
const activeEditorHost = __privateGet$1(this, _overlayManager)?.getActiveEditorHost?.();
|
|
83213
|
+
const clickedInsideEditorHost = activeEditorHost && (activeEditorHost.contains(event.target) || activeEditorHost === event.target);
|
|
83214
|
+
if (clickedInsideEditorHost) {
|
|
83215
|
+
return;
|
|
83216
|
+
}
|
|
82355
83217
|
const headerFooterRegion2 = __privateMethod$1(this, _PresentationEditor_instances, hitTestHeaderFooterRegion_fn).call(this, x2, y2);
|
|
82356
83218
|
if (!headerFooterRegion2) {
|
|
82357
83219
|
__privateMethod$1(this, _PresentationEditor_instances, exitHeaderFooterMode_fn).call(this);
|
|
@@ -82506,6 +83368,11 @@ ${l}
|
|
|
82506
83368
|
if (region) {
|
|
82507
83369
|
event.preventDefault();
|
|
82508
83370
|
event.stopPropagation();
|
|
83371
|
+
const descriptor = __privateMethod$1(this, _PresentationEditor_instances, resolveDescriptorForRegion_fn).call(this, region);
|
|
83372
|
+
if (!descriptor && __privateGet$1(this, _headerFooterManager)) {
|
|
83373
|
+
__privateMethod$1(this, _PresentationEditor_instances, createDefaultHeaderFooter_fn).call(this, region);
|
|
83374
|
+
__privateGet$1(this, _headerFooterManager).refresh();
|
|
83375
|
+
}
|
|
82509
83376
|
__privateMethod$1(this, _PresentationEditor_instances, activateHeaderFooterRegion_fn).call(this, region);
|
|
82510
83377
|
} else if (__privateGet$1(this, _session).mode !== "body") {
|
|
82511
83378
|
__privateMethod$1(this, _PresentationEditor_instances, exitHeaderFooterMode_fn).call(this);
|
|
@@ -82574,13 +83441,13 @@ ${l}
|
|
|
82574
83441
|
__privateGet$1(this, _painterHost).className = "presentation-editor__pages";
|
|
82575
83442
|
__privateGet$1(this, _painterHost).style.transformOrigin = "top left";
|
|
82576
83443
|
__privateGet$1(this, _viewportHost).appendChild(__privateGet$1(this, _painterHost));
|
|
82577
|
-
__privateSet(this,
|
|
82578
|
-
__privateGet$1(this,
|
|
82579
|
-
__privateGet$1(this,
|
|
82580
|
-
__privateGet$1(this,
|
|
82581
|
-
__privateGet$1(this,
|
|
82582
|
-
__privateGet$1(this,
|
|
82583
|
-
__privateGet$1(this,
|
|
83444
|
+
__privateSet(this, _selectionOverlay2, doc2.createElement("div"));
|
|
83445
|
+
__privateGet$1(this, _selectionOverlay2).className = "presentation-editor__selection-overlay";
|
|
83446
|
+
__privateGet$1(this, _selectionOverlay2).id = `presentation-overlay-${options.documentId || "default"}`;
|
|
83447
|
+
__privateGet$1(this, _selectionOverlay2).style.position = "absolute";
|
|
83448
|
+
__privateGet$1(this, _selectionOverlay2).style.inset = "0";
|
|
83449
|
+
__privateGet$1(this, _selectionOverlay2).style.pointerEvents = "none";
|
|
83450
|
+
__privateGet$1(this, _selectionOverlay2).style.zIndex = "10";
|
|
82584
83451
|
__privateSet(this, _remoteCursorOverlay, doc2.createElement("div"));
|
|
82585
83452
|
__privateGet$1(this, _remoteCursorOverlay).className = "presentation-editor__selection-layer--remote";
|
|
82586
83453
|
__privateGet$1(this, _remoteCursorOverlay).style.position = "absolute";
|
|
@@ -82591,9 +83458,9 @@ ${l}
|
|
|
82591
83458
|
__privateGet$1(this, _localSelectionLayer).style.position = "absolute";
|
|
82592
83459
|
__privateGet$1(this, _localSelectionLayer).style.inset = "0";
|
|
82593
83460
|
__privateGet$1(this, _localSelectionLayer).style.pointerEvents = "none";
|
|
82594
|
-
__privateGet$1(this,
|
|
82595
|
-
__privateGet$1(this,
|
|
82596
|
-
__privateGet$1(this, _viewportHost).appendChild(__privateGet$1(this,
|
|
83461
|
+
__privateGet$1(this, _selectionOverlay2).appendChild(__privateGet$1(this, _remoteCursorOverlay));
|
|
83462
|
+
__privateGet$1(this, _selectionOverlay2).appendChild(__privateGet$1(this, _localSelectionLayer));
|
|
83463
|
+
__privateGet$1(this, _viewportHost).appendChild(__privateGet$1(this, _selectionOverlay2));
|
|
82597
83464
|
__privateSet(this, _hoverOverlay, doc2.createElement("div"));
|
|
82598
83465
|
__privateGet$1(this, _hoverOverlay).className = "presentation-editor__hover-overlay";
|
|
82599
83466
|
Object.assign(__privateGet$1(this, _hoverOverlay).style, {
|
|
@@ -82604,7 +83471,7 @@ ${l}
|
|
|
82604
83471
|
display: "none",
|
|
82605
83472
|
zIndex: "11"
|
|
82606
83473
|
});
|
|
82607
|
-
__privateGet$1(this,
|
|
83474
|
+
__privateGet$1(this, _selectionOverlay2).appendChild(__privateGet$1(this, _hoverOverlay));
|
|
82608
83475
|
__privateSet(this, _hoverTooltip, doc2.createElement("div"));
|
|
82609
83476
|
__privateGet$1(this, _hoverTooltip).className = "presentation-editor__hover-tooltip";
|
|
82610
83477
|
Object.assign(__privateGet$1(this, _hoverTooltip).style, {
|
|
@@ -82619,7 +83486,7 @@ ${l}
|
|
|
82619
83486
|
zIndex: "12",
|
|
82620
83487
|
whiteSpace: "nowrap"
|
|
82621
83488
|
});
|
|
82622
|
-
__privateGet$1(this,
|
|
83489
|
+
__privateGet$1(this, _selectionOverlay2).appendChild(__privateGet$1(this, _hoverTooltip));
|
|
82623
83490
|
__privateSet(this, _modeBanner, doc2.createElement("div"));
|
|
82624
83491
|
__privateGet$1(this, _modeBanner).className = "presentation-editor__mode-banner";
|
|
82625
83492
|
Object.assign(__privateGet$1(this, _modeBanner).style, {
|
|
@@ -82837,7 +83704,7 @@ ${l}
|
|
|
82837
83704
|
* ```
|
|
82838
83705
|
*/
|
|
82839
83706
|
get overlayElement() {
|
|
82840
|
-
return __privateGet$1(this,
|
|
83707
|
+
return __privateGet$1(this, _selectionOverlay2) ?? null;
|
|
82841
83708
|
}
|
|
82842
83709
|
/**
|
|
82843
83710
|
* Set the document mode and update editor editability.
|
|
@@ -83007,12 +83874,12 @@ ${l}
|
|
|
83007
83874
|
* @returns Array of rects, each containing pageIndex and position data (left, top, right, bottom, width, height)
|
|
83008
83875
|
*/
|
|
83009
83876
|
getRangeRects(from2, to, relativeTo) {
|
|
83010
|
-
if (!__privateGet$1(this,
|
|
83877
|
+
if (!__privateGet$1(this, _selectionOverlay2)) return [];
|
|
83011
83878
|
if (!Number.isFinite(from2) || !Number.isFinite(to)) return [];
|
|
83012
83879
|
const start2 = Math.min(from2, to);
|
|
83013
83880
|
const end2 = Math.max(from2, to);
|
|
83014
83881
|
const zoom = __privateGet$1(this, _layoutOptions).zoom ?? 1;
|
|
83015
|
-
const overlayRect = __privateGet$1(this,
|
|
83882
|
+
const overlayRect = __privateGet$1(this, _selectionOverlay2).getBoundingClientRect();
|
|
83016
83883
|
const relativeRect = relativeTo?.getBoundingClientRect() ?? null;
|
|
83017
83884
|
const layoutRectSource = () => {
|
|
83018
83885
|
if (__privateGet$1(this, _session).mode !== "body") {
|
|
@@ -83273,7 +84140,7 @@ ${l}
|
|
|
83273
84140
|
return null;
|
|
83274
84141
|
}
|
|
83275
84142
|
const rect2 = rects2[0];
|
|
83276
|
-
const overlayRect = __privateGet$1(this,
|
|
84143
|
+
const overlayRect = __privateGet$1(this, _selectionOverlay2)?.getBoundingClientRect();
|
|
83277
84144
|
if (!overlayRect) {
|
|
83278
84145
|
return null;
|
|
83279
84146
|
}
|
|
@@ -83443,7 +84310,7 @@ ${l}
|
|
|
83443
84310
|
__privateSet(this, _session, { mode: "body" });
|
|
83444
84311
|
__privateSet(this, _activeHeaderFooterEditor, null);
|
|
83445
84312
|
__privateSet(this, _domPainter, null);
|
|
83446
|
-
__privateGet$1(this,
|
|
84313
|
+
__privateGet$1(this, _selectionOverlay2)?.remove();
|
|
83447
84314
|
__privateGet$1(this, _painterHost)?.remove();
|
|
83448
84315
|
__privateGet$1(this, _hiddenHost)?.remove();
|
|
83449
84316
|
__privateSet(this, _hoverOverlay, null);
|
|
@@ -83465,7 +84332,7 @@ ${l}
|
|
|
83465
84332
|
_visibleHost = /* @__PURE__ */ new WeakMap();
|
|
83466
84333
|
_viewportHost = /* @__PURE__ */ new WeakMap();
|
|
83467
84334
|
_painterHost = /* @__PURE__ */ new WeakMap();
|
|
83468
|
-
|
|
84335
|
+
_selectionOverlay2 = /* @__PURE__ */ new WeakMap();
|
|
83469
84336
|
_hiddenHost = /* @__PURE__ */ new WeakMap();
|
|
83470
84337
|
_layoutOptions = /* @__PURE__ */ new WeakMap();
|
|
83471
84338
|
_layoutState = /* @__PURE__ */ new WeakMap();
|
|
@@ -83500,6 +84367,7 @@ ${l}
|
|
|
83500
84367
|
_footerRegions = /* @__PURE__ */ new WeakMap();
|
|
83501
84368
|
_session = /* @__PURE__ */ new WeakMap();
|
|
83502
84369
|
_activeHeaderFooterEditor = /* @__PURE__ */ new WeakMap();
|
|
84370
|
+
_overlayManager = /* @__PURE__ */ new WeakMap();
|
|
83503
84371
|
_hoverOverlay = /* @__PURE__ */ new WeakMap();
|
|
83504
84372
|
_hoverTooltip = /* @__PURE__ */ new WeakMap();
|
|
83505
84373
|
_modeBanner = /* @__PURE__ */ new WeakMap();
|
|
@@ -83865,9 +84733,14 @@ ${l}
|
|
|
83865
84733
|
__privateSet(this, _headerFooterManagerCleanups, []);
|
|
83866
84734
|
__privateGet$1(this, _headerFooterAdapter)?.clear();
|
|
83867
84735
|
__privateGet$1(this, _headerFooterManager)?.destroy();
|
|
84736
|
+
__privateGet$1(this, _overlayManager)?.destroy();
|
|
83868
84737
|
__privateSet(this, _session, { mode: "body" });
|
|
83869
84738
|
__privateSet(this, _activeHeaderFooterEditor, null);
|
|
83870
84739
|
__privateGet$1(this, _inputBridge)?.notifyTargetChanged();
|
|
84740
|
+
__privateSet(this, _overlayManager, new EditorOverlayManager(__privateGet$1(this, _painterHost), __privateGet$1(this, _visibleHost), __privateGet$1(this, _selectionOverlay2)));
|
|
84741
|
+
__privateGet$1(this, _overlayManager).setOnDimmingClick(() => {
|
|
84742
|
+
__privateMethod$1(this, _PresentationEditor_instances, exitHeaderFooterMode_fn).call(this);
|
|
84743
|
+
});
|
|
83871
84744
|
const converter = __privateGet$1(this, _editor3).converter;
|
|
83872
84745
|
__privateSet(this, _headerFooterIdentifier, extractIdentifierFromConverter(converter));
|
|
83873
84746
|
__privateSet(this, _headerFooterManager, new HeaderFooterEditorManager(__privateGet$1(this, _editor3)));
|
|
@@ -84216,6 +85089,9 @@ ${l}
|
|
|
84216
85089
|
});
|
|
84217
85090
|
};
|
|
84218
85091
|
updateSelection_fn = function() {
|
|
85092
|
+
if (__privateGet$1(this, _session).mode !== "body") {
|
|
85093
|
+
return;
|
|
85094
|
+
}
|
|
84219
85095
|
if (!__privateGet$1(this, _localSelectionLayer)) {
|
|
84220
85096
|
return;
|
|
84221
85097
|
}
|
|
@@ -84225,22 +85101,6 @@ ${l}
|
|
|
84225
85101
|
if (!selection) {
|
|
84226
85102
|
return;
|
|
84227
85103
|
}
|
|
84228
|
-
if (__privateGet$1(this, _session).mode !== "body") {
|
|
84229
|
-
if (!layout) {
|
|
84230
|
-
return;
|
|
84231
|
-
}
|
|
84232
|
-
if (selection.from === selection.to) {
|
|
84233
|
-
const caretLayout = __privateMethod$1(this, _PresentationEditor_instances, computeHeaderFooterCaretRect_fn).call(this, selection.from);
|
|
84234
|
-
if (!caretLayout) {
|
|
84235
|
-
return;
|
|
84236
|
-
}
|
|
84237
|
-
__privateMethod$1(this, _PresentationEditor_instances, renderCaretOverlay_fn).call(this, caretLayout);
|
|
84238
|
-
return;
|
|
84239
|
-
}
|
|
84240
|
-
const rects2 = __privateMethod$1(this, _PresentationEditor_instances, computeHeaderFooterSelectionRects_fn).call(this, selection.from, selection.to);
|
|
84241
|
-
__privateMethod$1(this, _PresentationEditor_instances, renderSelectionRects_fn).call(this, rects2);
|
|
84242
|
-
return;
|
|
84243
|
-
}
|
|
84244
85104
|
if (!layout) {
|
|
84245
85105
|
return;
|
|
84246
85106
|
}
|
|
@@ -84475,46 +85335,168 @@ ${l}
|
|
|
84475
85335
|
void __privateMethod$1(this, _PresentationEditor_instances, enterHeaderFooterMode_fn).call(this, region);
|
|
84476
85336
|
};
|
|
84477
85337
|
enterHeaderFooterMode_fn = async function(region) {
|
|
84478
|
-
|
|
84479
|
-
|
|
84480
|
-
|
|
84481
|
-
|
|
84482
|
-
|
|
84483
|
-
|
|
84484
|
-
|
|
84485
|
-
|
|
84486
|
-
|
|
84487
|
-
|
|
84488
|
-
|
|
84489
|
-
|
|
84490
|
-
|
|
84491
|
-
|
|
84492
|
-
|
|
84493
|
-
|
|
84494
|
-
|
|
84495
|
-
|
|
85338
|
+
try {
|
|
85339
|
+
if (!__privateGet$1(this, _headerFooterManager) || !__privateGet$1(this, _overlayManager)) {
|
|
85340
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
85341
|
+
return;
|
|
85342
|
+
}
|
|
85343
|
+
const descriptor = __privateMethod$1(this, _PresentationEditor_instances, resolveDescriptorForRegion_fn).call(this, region);
|
|
85344
|
+
if (!descriptor) {
|
|
85345
|
+
console.warn("[PresentationEditor] No descriptor found for region:", region);
|
|
85346
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
85347
|
+
return;
|
|
85348
|
+
}
|
|
85349
|
+
if (!descriptor.id) {
|
|
85350
|
+
console.warn("[PresentationEditor] Descriptor missing id:", descriptor);
|
|
85351
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
85352
|
+
return;
|
|
85353
|
+
}
|
|
85354
|
+
let pageElement = __privateMethod$1(this, _PresentationEditor_instances, getPageElement_fn).call(this, region.pageIndex);
|
|
85355
|
+
if (!pageElement) {
|
|
85356
|
+
try {
|
|
85357
|
+
__privateMethod$1(this, _PresentationEditor_instances, scrollPageIntoView_fn).call(this, region.pageIndex);
|
|
85358
|
+
const mounted = await __privateMethod$1(this, _PresentationEditor_instances, waitForPageMount_fn).call(this, region.pageIndex, { timeout: 2e3 });
|
|
85359
|
+
if (!mounted) {
|
|
85360
|
+
console.error("[PresentationEditor] Failed to mount page for header/footer editing");
|
|
85361
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
85362
|
+
this.emit("error", {
|
|
85363
|
+
error: new Error("Failed to mount page for editing"),
|
|
85364
|
+
context: "enterHeaderFooterMode"
|
|
85365
|
+
});
|
|
85366
|
+
return;
|
|
85367
|
+
}
|
|
85368
|
+
pageElement = __privateMethod$1(this, _PresentationEditor_instances, getPageElement_fn).call(this, region.pageIndex);
|
|
85369
|
+
} catch (scrollError) {
|
|
85370
|
+
console.error("[PresentationEditor] Error mounting page:", scrollError);
|
|
85371
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
85372
|
+
this.emit("error", {
|
|
85373
|
+
error: scrollError,
|
|
85374
|
+
context: "enterHeaderFooterMode.pageMount"
|
|
85375
|
+
});
|
|
85376
|
+
return;
|
|
85377
|
+
}
|
|
85378
|
+
}
|
|
85379
|
+
if (!pageElement) {
|
|
85380
|
+
console.error("[PresentationEditor] Page element not found after mount attempt");
|
|
85381
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
85382
|
+
this.emit("error", {
|
|
85383
|
+
error: new Error("Page element not found after mount"),
|
|
85384
|
+
context: "enterHeaderFooterMode"
|
|
85385
|
+
});
|
|
85386
|
+
return;
|
|
85387
|
+
}
|
|
85388
|
+
const { success, editorHost, reason } = __privateGet$1(this, _overlayManager).showEditingOverlay(
|
|
85389
|
+
pageElement,
|
|
85390
|
+
region,
|
|
85391
|
+
__privateGet$1(this, _layoutOptions).zoom ?? 1
|
|
85392
|
+
);
|
|
85393
|
+
if (!success || !editorHost) {
|
|
85394
|
+
console.error("[PresentationEditor] Failed to create editor host:", reason);
|
|
85395
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
85396
|
+
this.emit("error", {
|
|
85397
|
+
error: new Error(`Failed to create editor host: ${reason}`),
|
|
85398
|
+
context: "enterHeaderFooterMode.showOverlay"
|
|
85399
|
+
});
|
|
85400
|
+
return;
|
|
85401
|
+
}
|
|
85402
|
+
const layout = __privateGet$1(this, _layoutState).layout;
|
|
85403
|
+
let editor;
|
|
85404
|
+
try {
|
|
85405
|
+
editor = await __privateGet$1(this, _headerFooterManager).ensureEditor(descriptor, {
|
|
85406
|
+
editorHost,
|
|
85407
|
+
availableWidth: region.width,
|
|
85408
|
+
availableHeight: region.height,
|
|
85409
|
+
currentPageNumber: region.pageNumber,
|
|
85410
|
+
totalPageCount: layout?.pages?.length ?? 1
|
|
85411
|
+
});
|
|
85412
|
+
} catch (editorError) {
|
|
85413
|
+
console.error("[PresentationEditor] Error creating editor:", editorError);
|
|
85414
|
+
__privateGet$1(this, _overlayManager).hideEditingOverlay();
|
|
85415
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
85416
|
+
this.emit("error", {
|
|
85417
|
+
error: editorError,
|
|
85418
|
+
context: "enterHeaderFooterMode.ensureEditor"
|
|
85419
|
+
});
|
|
85420
|
+
return;
|
|
85421
|
+
}
|
|
85422
|
+
if (!editor) {
|
|
85423
|
+
console.warn("[PresentationEditor] Failed to ensure editor for descriptor:", descriptor);
|
|
85424
|
+
__privateGet$1(this, _overlayManager).hideEditingOverlay();
|
|
85425
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
85426
|
+
this.emit("error", {
|
|
85427
|
+
error: new Error("Failed to create editor instance"),
|
|
85428
|
+
context: "enterHeaderFooterMode.ensureEditor"
|
|
85429
|
+
});
|
|
85430
|
+
return;
|
|
85431
|
+
}
|
|
85432
|
+
try {
|
|
85433
|
+
editor.setEditable(true);
|
|
85434
|
+
editor.setOptions({ documentMode: "editing" });
|
|
85435
|
+
try {
|
|
85436
|
+
const doc2 = editor.state?.doc;
|
|
85437
|
+
if (doc2) {
|
|
85438
|
+
const endPos = doc2.content.size - 1;
|
|
85439
|
+
editor.commands?.setTextSelection?.(Math.max(1, endPos));
|
|
85440
|
+
}
|
|
85441
|
+
} catch (cursorError) {
|
|
85442
|
+
console.warn("[PresentationEditor] Could not set cursor to end:", cursorError);
|
|
85443
|
+
}
|
|
85444
|
+
} catch (editableError) {
|
|
85445
|
+
console.error("[PresentationEditor] Error setting editor editable:", editableError);
|
|
85446
|
+
__privateGet$1(this, _overlayManager).hideEditingOverlay();
|
|
85447
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
85448
|
+
this.emit("error", {
|
|
85449
|
+
error: editableError,
|
|
85450
|
+
context: "enterHeaderFooterMode.setEditable"
|
|
85451
|
+
});
|
|
85452
|
+
return;
|
|
85453
|
+
}
|
|
85454
|
+
__privateGet$1(this, _overlayManager).hideSelectionOverlay();
|
|
85455
|
+
__privateSet(this, _activeHeaderFooterEditor, editor);
|
|
85456
|
+
__privateSet(this, _session, {
|
|
85457
|
+
mode: region.kind,
|
|
85458
|
+
kind: region.kind,
|
|
85459
|
+
headerId: descriptor.id,
|
|
85460
|
+
sectionType: descriptor.variant ?? region.sectionType ?? null,
|
|
85461
|
+
pageIndex: region.pageIndex,
|
|
85462
|
+
pageNumber: region.pageNumber
|
|
85463
|
+
});
|
|
84496
85464
|
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
84497
|
-
|
|
85465
|
+
try {
|
|
85466
|
+
editor.view?.focus();
|
|
85467
|
+
} catch (focusError) {
|
|
85468
|
+
console.warn("[PresentationEditor] Could not focus editor:", focusError);
|
|
85469
|
+
}
|
|
85470
|
+
__privateMethod$1(this, _PresentationEditor_instances, emitHeaderFooterModeChanged_fn).call(this);
|
|
85471
|
+
__privateMethod$1(this, _PresentationEditor_instances, emitHeaderFooterEditingContext_fn).call(this, editor);
|
|
85472
|
+
__privateGet$1(this, _inputBridge)?.notifyTargetChanged();
|
|
85473
|
+
} catch (error) {
|
|
85474
|
+
console.error("[PresentationEditor] Unexpected error in enterHeaderFooterMode:", error);
|
|
85475
|
+
try {
|
|
85476
|
+
__privateGet$1(this, _overlayManager)?.hideEditingOverlay();
|
|
85477
|
+
__privateGet$1(this, _overlayManager)?.showSelectionOverlay();
|
|
85478
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
85479
|
+
__privateSet(this, _activeHeaderFooterEditor, null);
|
|
85480
|
+
__privateSet(this, _session, { mode: "body" });
|
|
85481
|
+
} catch (cleanupError) {
|
|
85482
|
+
console.error("[PresentationEditor] Error during cleanup:", cleanupError);
|
|
85483
|
+
}
|
|
85484
|
+
this.emit("error", {
|
|
85485
|
+
error,
|
|
85486
|
+
context: "enterHeaderFooterMode"
|
|
85487
|
+
});
|
|
84498
85488
|
}
|
|
84499
|
-
__privateSet(this, _activeHeaderFooterEditor, editor);
|
|
84500
|
-
__privateSet(this, _session, {
|
|
84501
|
-
mode: region.kind,
|
|
84502
|
-
kind: region.kind,
|
|
84503
|
-
headerId: descriptor.id,
|
|
84504
|
-
sectionType: descriptor.variant ?? region.sectionType ?? null,
|
|
84505
|
-
pageIndex: region.pageIndex,
|
|
84506
|
-
pageNumber: region.pageNumber
|
|
84507
|
-
});
|
|
84508
|
-
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
84509
|
-
__privateMethod$1(this, _PresentationEditor_instances, emitHeaderFooterModeChanged_fn).call(this);
|
|
84510
|
-
__privateMethod$1(this, _PresentationEditor_instances, emitHeaderFooterEditingContext_fn).call(this, editor);
|
|
84511
|
-
__privateGet$1(this, _inputBridge)?.notifyTargetChanged();
|
|
84512
|
-
editor.view?.focus();
|
|
84513
85489
|
};
|
|
84514
85490
|
exitHeaderFooterMode_fn = function() {
|
|
84515
85491
|
if (__privateGet$1(this, _session).mode === "body") return;
|
|
84516
|
-
|
|
85492
|
+
if (__privateGet$1(this, _activeHeaderFooterEditor)) {
|
|
85493
|
+
__privateGet$1(this, _activeHeaderFooterEditor).setEditable(false);
|
|
85494
|
+
__privateGet$1(this, _activeHeaderFooterEditor).setOptions({ documentMode: "viewing" });
|
|
85495
|
+
}
|
|
85496
|
+
__privateGet$1(this, _overlayManager)?.hideEditingOverlay();
|
|
85497
|
+
__privateGet$1(this, _overlayManager)?.showSelectionOverlay();
|
|
84517
85498
|
__privateSet(this, _activeHeaderFooterEditor, null);
|
|
85499
|
+
__privateSet(this, _session, { mode: "body" });
|
|
84518
85500
|
__privateMethod$1(this, _PresentationEditor_instances, emitHeaderFooterModeChanged_fn).call(this);
|
|
84519
85501
|
__privateMethod$1(this, _PresentationEditor_instances, emitHeaderFooterEditingContext_fn).call(this, __privateGet$1(this, _editor3));
|
|
84520
85502
|
__privateGet$1(this, _inputBridge)?.notifyTargetChanged();
|
|
@@ -84610,6 +85592,75 @@ ${l}
|
|
|
84610
85592
|
}
|
|
84611
85593
|
return descriptors[0];
|
|
84612
85594
|
};
|
|
85595
|
+
createDefaultHeaderFooter_fn = function(region) {
|
|
85596
|
+
const converter = __privateGet$1(this, _editor3).converter;
|
|
85597
|
+
if (!converter) {
|
|
85598
|
+
console.error("[PresentationEditor] Converter not available for creating header/footer");
|
|
85599
|
+
return;
|
|
85600
|
+
}
|
|
85601
|
+
const variant = region.sectionType ?? "default";
|
|
85602
|
+
try {
|
|
85603
|
+
if (region.kind === "header") {
|
|
85604
|
+
if (typeof converter.createDefaultHeader === "function") {
|
|
85605
|
+
const headerId = converter.createDefaultHeader(variant);
|
|
85606
|
+
console.log(`[PresentationEditor] Created default header: ${headerId}`);
|
|
85607
|
+
} else {
|
|
85608
|
+
console.error("[PresentationEditor] converter.createDefaultHeader is not a function");
|
|
85609
|
+
}
|
|
85610
|
+
} else if (region.kind === "footer") {
|
|
85611
|
+
if (typeof converter.createDefaultFooter === "function") {
|
|
85612
|
+
const footerId = converter.createDefaultFooter(variant);
|
|
85613
|
+
console.log(`[PresentationEditor] Created default footer: ${footerId}`);
|
|
85614
|
+
} else {
|
|
85615
|
+
console.error("[PresentationEditor] converter.createDefaultFooter is not a function");
|
|
85616
|
+
}
|
|
85617
|
+
}
|
|
85618
|
+
} catch (error) {
|
|
85619
|
+
console.error("[PresentationEditor] Failed to create default header/footer:", error);
|
|
85620
|
+
}
|
|
85621
|
+
};
|
|
85622
|
+
getPageElement_fn = function(pageIndex) {
|
|
85623
|
+
if (!__privateGet$1(this, _painterHost)) return null;
|
|
85624
|
+
const pageElements = __privateGet$1(this, _painterHost).querySelectorAll("[data-page-index]");
|
|
85625
|
+
for (let i2 = 0; i2 < pageElements.length; i2++) {
|
|
85626
|
+
const el = pageElements[i2];
|
|
85627
|
+
const dataPageIndex = el.getAttribute("data-page-index");
|
|
85628
|
+
if (dataPageIndex && parseInt(dataPageIndex, 10) === pageIndex) {
|
|
85629
|
+
return el;
|
|
85630
|
+
}
|
|
85631
|
+
}
|
|
85632
|
+
return null;
|
|
85633
|
+
};
|
|
85634
|
+
scrollPageIntoView_fn = function(pageIndex) {
|
|
85635
|
+
const layout = __privateGet$1(this, _layoutState).layout;
|
|
85636
|
+
if (!layout) return;
|
|
85637
|
+
const pageHeight = layout.pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
|
|
85638
|
+
const virtualGap = __privateGet$1(this, _layoutOptions).virtualization?.gap ?? 0;
|
|
85639
|
+
const yPosition = pageIndex * (pageHeight + virtualGap);
|
|
85640
|
+
if (__privateGet$1(this, _visibleHost)) {
|
|
85641
|
+
__privateGet$1(this, _visibleHost).scrollTop = yPosition;
|
|
85642
|
+
}
|
|
85643
|
+
};
|
|
85644
|
+
waitForPageMount_fn = async function(pageIndex, options = {}) {
|
|
85645
|
+
const timeout2 = options.timeout ?? 2e3;
|
|
85646
|
+
const startTime = performance.now();
|
|
85647
|
+
return new Promise((resolve2) => {
|
|
85648
|
+
const checkPage = () => {
|
|
85649
|
+
const pageElement = __privateMethod$1(this, _PresentationEditor_instances, getPageElement_fn).call(this, pageIndex);
|
|
85650
|
+
if (pageElement) {
|
|
85651
|
+
resolve2(true);
|
|
85652
|
+
return;
|
|
85653
|
+
}
|
|
85654
|
+
const elapsed = performance.now() - startTime;
|
|
85655
|
+
if (elapsed >= timeout2) {
|
|
85656
|
+
resolve2(false);
|
|
85657
|
+
return;
|
|
85658
|
+
}
|
|
85659
|
+
requestAnimationFrame(checkPage);
|
|
85660
|
+
};
|
|
85661
|
+
checkPage();
|
|
85662
|
+
});
|
|
85663
|
+
};
|
|
84613
85664
|
getBodyPageHeight_fn = function() {
|
|
84614
85665
|
return __privateGet$1(this, _layoutState).layout?.pageSize?.h ?? __privateGet$1(this, _layoutOptions).pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
|
|
84615
85666
|
};
|
|
@@ -84663,7 +85714,7 @@ ${l}
|
|
|
84663
85714
|
__privateGet$1(this, _hoverOverlay).style.top = `${coords.y}px`;
|
|
84664
85715
|
__privateGet$1(this, _hoverOverlay).style.width = `${region.width * zoom}px`;
|
|
84665
85716
|
__privateGet$1(this, _hoverOverlay).style.height = `${region.height * zoom}px`;
|
|
84666
|
-
const tooltipText = `Double-click to edit ${region.kind === "header" ? "
|
|
85717
|
+
const tooltipText = `Double-click to edit ${region.kind === "header" ? "header" : "footer"}`;
|
|
84667
85718
|
__privateGet$1(this, _hoverTooltip).textContent = tooltipText;
|
|
84668
85719
|
__privateGet$1(this, _hoverTooltip).style.display = "block";
|
|
84669
85720
|
__privateGet$1(this, _hoverTooltip).style.left = `${coords.x}px`;
|
|
@@ -84769,33 +85820,6 @@ ${l}
|
|
|
84769
85820
|
};
|
|
84770
85821
|
});
|
|
84771
85822
|
};
|
|
84772
|
-
computeHeaderFooterCaretRect_fn = function(pos) {
|
|
84773
|
-
const context = __privateMethod$1(this, _PresentationEditor_instances, getHeaderFooterContext_fn).call(this);
|
|
84774
|
-
if (!context) return null;
|
|
84775
|
-
const hit = getFragmentAtPosition(context.layout, context.blocks, context.measures, pos);
|
|
84776
|
-
if (!hit) return null;
|
|
84777
|
-
const block = hit.block;
|
|
84778
|
-
const measure = hit.measure;
|
|
84779
|
-
if (!block || block.kind !== "paragraph" || measure?.kind !== "paragraph" || hit.fragment.kind !== "para")
|
|
84780
|
-
return null;
|
|
84781
|
-
const lineInfo = __privateMethod$1(this, _PresentationEditor_instances, findLineContainingPos_fn).call(this, block, measure, hit.fragment.fromLine, hit.fragment.toLine, pos);
|
|
84782
|
-
if (!lineInfo) return null;
|
|
84783
|
-
const { line, index: index2 } = lineInfo;
|
|
84784
|
-
const range2 = computeLinePmRange$1(block, line);
|
|
84785
|
-
if (range2.pmStart == null || range2.pmEnd == null) return null;
|
|
84786
|
-
const pmCharsInLine = Math.max(1, range2.pmEnd - range2.pmStart);
|
|
84787
|
-
const pmOffset = Math.max(0, Math.min(pmCharsInLine, pos - range2.pmStart));
|
|
84788
|
-
const localX = hit.fragment.x + measureCharacterX(block, line, pmOffset);
|
|
84789
|
-
const lineOffset = __privateMethod$1(this, _PresentationEditor_instances, lineHeightBeforeIndex_fn).call(this, measure.lines, hit.fragment.fromLine, index2);
|
|
84790
|
-
const headerPageHeight = context.layout.pageSize?.h ?? context.region.height ?? 1;
|
|
84791
|
-
const headerLocalY = hit.pageIndex * headerPageHeight + (hit.fragment.y + lineOffset);
|
|
84792
|
-
return {
|
|
84793
|
-
pageIndex: context.region.pageIndex,
|
|
84794
|
-
x: context.region.localX + localX,
|
|
84795
|
-
y: context.region.localY + headerLocalY,
|
|
84796
|
-
height: line.lineHeight
|
|
84797
|
-
};
|
|
84798
|
-
};
|
|
84799
85823
|
syncTrackedChangesPreferences_fn = function() {
|
|
84800
85824
|
const mode = __privateMethod$1(this, _PresentationEditor_instances, deriveTrackedChangesMode_fn).call(this);
|
|
84801
85825
|
const enabled = __privateMethod$1(this, _PresentationEditor_instances, deriveTrackedChangesEnabled_fn).call(this);
|
|
@@ -84902,7 +85926,7 @@ ${l}
|
|
|
84902
85926
|
return null;
|
|
84903
85927
|
}
|
|
84904
85928
|
const pageRect = pageEl.getBoundingClientRect();
|
|
84905
|
-
const overlayRect = __privateGet$1(this,
|
|
85929
|
+
const overlayRect = __privateGet$1(this, _selectionOverlay2).getBoundingClientRect();
|
|
84906
85930
|
const zoom = __privateGet$1(this, _layoutOptions).zoom ?? 1;
|
|
84907
85931
|
return {
|
|
84908
85932
|
x: pageRect.left - overlayRect.left + pageLocalX * zoom,
|
|
@@ -89772,22 +90796,53 @@ ${l}
|
|
|
89772
90796
|
tabs
|
|
89773
90797
|
};
|
|
89774
90798
|
}
|
|
90799
|
+
const MAX_WALK_DEPTH = 50;
|
|
89775
90800
|
function applyLayoutResult(result, paragraph2, paragraphPos) {
|
|
89776
90801
|
const decorations = [];
|
|
89777
90802
|
let tabIndex = 0;
|
|
89778
|
-
|
|
89779
|
-
if (
|
|
89780
|
-
|
|
89781
|
-
|
|
89782
|
-
|
|
89783
|
-
if (!
|
|
89784
|
-
|
|
89785
|
-
|
|
89786
|
-
|
|
89787
|
-
|
|
89788
|
-
|
|
89789
|
-
|
|
89790
|
-
|
|
90803
|
+
const walk = (node2, pos, depth = 0) => {
|
|
90804
|
+
if (depth > MAX_WALK_DEPTH) {
|
|
90805
|
+
console.error(`applyLayoutResult: Maximum recursion depth (${MAX_WALK_DEPTH}) exceeded`);
|
|
90806
|
+
return;
|
|
90807
|
+
}
|
|
90808
|
+
if (!node2?.type?.name) {
|
|
90809
|
+
console.error("applyLayoutResult: Node missing type.name", { node: node2, pos, depth });
|
|
90810
|
+
return;
|
|
90811
|
+
}
|
|
90812
|
+
if (typeof node2.nodeSize !== "number" || node2.nodeSize < 0 || !Number.isFinite(node2.nodeSize)) {
|
|
90813
|
+
console.error("applyLayoutResult: Invalid nodeSize", { nodeSize: node2.nodeSize, nodeName: node2.type.name, pos });
|
|
90814
|
+
return;
|
|
90815
|
+
}
|
|
90816
|
+
if (node2.type.name === "tab") {
|
|
90817
|
+
const tabId = tabIdForIndex(result.paragraphId, tabIndex++);
|
|
90818
|
+
const layout = result.tabs[tabId];
|
|
90819
|
+
if (layout) {
|
|
90820
|
+
let style2 = `width: ${layout.width}px;`;
|
|
90821
|
+
if (layout.height) style2 += ` height: ${layout.height};`;
|
|
90822
|
+
if (layout.leader && leaderStyles[layout.leader]) {
|
|
90823
|
+
style2 += ` ${leaderStyles[layout.leader]}`;
|
|
90824
|
+
}
|
|
90825
|
+
decorations.push(Decoration.node(pos, pos + node2.nodeSize, { style: style2 }));
|
|
90826
|
+
}
|
|
90827
|
+
return;
|
|
90828
|
+
}
|
|
90829
|
+
try {
|
|
90830
|
+
let offset2 = 0;
|
|
90831
|
+
node2.forEach((child) => {
|
|
90832
|
+
const childPos = pos + 1 + offset2;
|
|
90833
|
+
walk(child, childPos, depth + 1);
|
|
90834
|
+
offset2 += child.nodeSize;
|
|
90835
|
+
});
|
|
90836
|
+
} catch (error) {
|
|
90837
|
+
console.error("applyLayoutResult: Error during recursion", {
|
|
90838
|
+
error,
|
|
90839
|
+
nodeName: node2.type.name,
|
|
90840
|
+
pos,
|
|
90841
|
+
depth
|
|
90842
|
+
});
|
|
90843
|
+
}
|
|
90844
|
+
};
|
|
90845
|
+
walk(paragraph2, paragraphPos);
|
|
89791
90846
|
return decorations;
|
|
89792
90847
|
}
|
|
89793
90848
|
function collectFollowingText(spans, startIndex) {
|
|
@@ -90335,8 +91390,8 @@ ${l}
|
|
|
90335
91390
|
colgroupValues
|
|
90336
91391
|
};
|
|
90337
91392
|
};
|
|
90338
|
-
|
|
90339
|
-
|
|
91393
|
+
let readFromCache;
|
|
91394
|
+
let addToCache;
|
|
90340
91395
|
if (typeof WeakMap != "undefined") {
|
|
90341
91396
|
let cache2 = /* @__PURE__ */ new WeakMap();
|
|
90342
91397
|
readFromCache = (key2) => cache2.get(key2);
|
|
@@ -90349,8 +91404,7 @@ ${l}
|
|
|
90349
91404
|
const cacheSize = 10;
|
|
90350
91405
|
let cachePos = 0;
|
|
90351
91406
|
readFromCache = (key2) => {
|
|
90352
|
-
for (let i2 = 0; i2 < cache2.length; i2 += 2)
|
|
90353
|
-
if (cache2[i2] == key2) return cache2[i2 + 1];
|
|
91407
|
+
for (let i2 = 0; i2 < cache2.length; i2 += 2) if (cache2[i2] == key2) return cache2[i2 + 1];
|
|
90354
91408
|
};
|
|
90355
91409
|
addToCache = (key2, value) => {
|
|
90356
91410
|
if (cachePos == cacheSize) cachePos = 0;
|
|
@@ -90365,7 +91419,6 @@ ${l}
|
|
|
90365
91419
|
this.map = map2;
|
|
90366
91420
|
this.problems = problems;
|
|
90367
91421
|
}
|
|
90368
|
-
// Find the dimensions of the cell at the given position.
|
|
90369
91422
|
findCell(pos) {
|
|
90370
91423
|
for (let i2 = 0; i2 < this.map.length; i2++) {
|
|
90371
91424
|
const curPos = this.map[i2];
|
|
@@ -90374,27 +91427,21 @@ ${l}
|
|
|
90374
91427
|
const top2 = i2 / this.width | 0;
|
|
90375
91428
|
let right2 = left2 + 1;
|
|
90376
91429
|
let bottom2 = top2 + 1;
|
|
90377
|
-
for (let j2 = 1; right2 < this.width && this.map[i2 + j2] == curPos; j2++)
|
|
90378
|
-
|
|
90379
|
-
|
|
90380
|
-
|
|
90381
|
-
|
|
90382
|
-
|
|
90383
|
-
|
|
91430
|
+
for (let j2 = 1; right2 < this.width && this.map[i2 + j2] == curPos; j2++) right2++;
|
|
91431
|
+
for (let j2 = 1; bottom2 < this.height && this.map[i2 + this.width * j2] == curPos; j2++) bottom2++;
|
|
91432
|
+
return {
|
|
91433
|
+
left: left2,
|
|
91434
|
+
top: top2,
|
|
91435
|
+
right: right2,
|
|
91436
|
+
bottom: bottom2
|
|
91437
|
+
};
|
|
90384
91438
|
}
|
|
90385
91439
|
throw new RangeError(`No cell with offset ${pos} found`);
|
|
90386
91440
|
}
|
|
90387
|
-
// Find the left side of the cell at the given position.
|
|
90388
91441
|
colCount(pos) {
|
|
90389
|
-
for (let i2 = 0; i2 < this.map.length; i2++)
|
|
90390
|
-
if (this.map[i2] == pos) {
|
|
90391
|
-
return i2 % this.width;
|
|
90392
|
-
}
|
|
90393
|
-
}
|
|
91442
|
+
for (let i2 = 0; i2 < this.map.length; i2++) if (this.map[i2] == pos) return i2 % this.width;
|
|
90394
91443
|
throw new RangeError(`No cell with offset ${pos} found`);
|
|
90395
91444
|
}
|
|
90396
|
-
// Find the next cell in the given direction, starting from the cell
|
|
90397
|
-
// at `pos`, if any.
|
|
90398
91445
|
nextCell(pos, axis, dir) {
|
|
90399
91446
|
const { left: left2, right: right2, top: top2, bottom: bottom2 } = this.findCell(pos);
|
|
90400
91447
|
if (axis == "horiz") {
|
|
@@ -90405,20 +91452,9 @@ ${l}
|
|
|
90405
91452
|
return this.map[left2 + this.width * (dir < 0 ? top2 - 1 : bottom2)];
|
|
90406
91453
|
}
|
|
90407
91454
|
}
|
|
90408
|
-
// Get the rectangle spanning the two given cells.
|
|
90409
91455
|
rectBetween(a2, b2) {
|
|
90410
|
-
const {
|
|
90411
|
-
|
|
90412
|
-
right: rightA,
|
|
90413
|
-
top: topA,
|
|
90414
|
-
bottom: bottomA
|
|
90415
|
-
} = this.findCell(a2);
|
|
90416
|
-
const {
|
|
90417
|
-
left: leftB,
|
|
90418
|
-
right: rightB,
|
|
90419
|
-
top: topB,
|
|
90420
|
-
bottom: bottomB
|
|
90421
|
-
} = this.findCell(b2);
|
|
91456
|
+
const { left: leftA, right: rightA, top: topA, bottom: bottomA } = this.findCell(a2);
|
|
91457
|
+
const { left: leftB, right: rightB, top: topB, bottom: bottomB } = this.findCell(b2);
|
|
90422
91458
|
return {
|
|
90423
91459
|
left: Math.min(leftA, leftB),
|
|
90424
91460
|
top: Math.min(topA, topB),
|
|
@@ -90426,27 +91462,19 @@ ${l}
|
|
|
90426
91462
|
bottom: Math.max(bottomA, bottomB)
|
|
90427
91463
|
};
|
|
90428
91464
|
}
|
|
90429
|
-
// Return the position of all cells that have the top left corner in
|
|
90430
|
-
// the given rectangle.
|
|
90431
91465
|
cellsInRect(rect) {
|
|
90432
91466
|
const result = [];
|
|
90433
91467
|
const seen = {};
|
|
90434
|
-
for (let row2 = rect.top; row2 < rect.bottom; row2++) {
|
|
90435
|
-
|
|
90436
|
-
|
|
90437
|
-
|
|
90438
|
-
|
|
90439
|
-
|
|
90440
|
-
|
|
90441
|
-
continue;
|
|
90442
|
-
}
|
|
90443
|
-
result.push(pos);
|
|
90444
|
-
}
|
|
91468
|
+
for (let row2 = rect.top; row2 < rect.bottom; row2++) for (let col = rect.left; col < rect.right; col++) {
|
|
91469
|
+
const index2 = row2 * this.width + col;
|
|
91470
|
+
const pos = this.map[index2];
|
|
91471
|
+
if (seen[pos]) continue;
|
|
91472
|
+
seen[pos] = true;
|
|
91473
|
+
if (col == rect.left && col && this.map[index2 - 1] == pos || row2 == rect.top && row2 && this.map[index2 - this.width] == pos) continue;
|
|
91474
|
+
result.push(pos);
|
|
90445
91475
|
}
|
|
90446
91476
|
return result;
|
|
90447
91477
|
}
|
|
90448
|
-
// Return the position at which the cell at the given row and column
|
|
90449
|
-
// starts, or would start, if a cell started there.
|
|
90450
91478
|
positionAt(row2, col, table2) {
|
|
90451
91479
|
for (let i2 = 0, rowStart = 0; ; i2++) {
|
|
90452
91480
|
const rowEnd = rowStart + table2.child(i2).nodeSize;
|
|
@@ -90459,14 +91487,12 @@ ${l}
|
|
|
90459
91487
|
rowStart = rowEnd;
|
|
90460
91488
|
}
|
|
90461
91489
|
}
|
|
90462
|
-
// Find the table map for the given table node.
|
|
90463
91490
|
static get(table2) {
|
|
90464
91491
|
return readFromCache(table2) || addToCache(table2, computeMap(table2));
|
|
90465
91492
|
}
|
|
90466
91493
|
};
|
|
90467
91494
|
function computeMap(table2) {
|
|
90468
|
-
if (table2.type.spec.tableRole != "table")
|
|
90469
|
-
throw new RangeError("Not a table node: " + table2.type.name);
|
|
91495
|
+
if (table2.type.spec.tableRole != "table") throw new RangeError("Not a table node: " + table2.type.name);
|
|
90470
91496
|
const width = findWidth(table2), height = table2.childCount;
|
|
90471
91497
|
const map2 = [];
|
|
90472
91498
|
let mapPos = 0;
|
|
@@ -90493,22 +91519,19 @@ ${l}
|
|
|
90493
91519
|
const start2 = mapPos + h2 * width;
|
|
90494
91520
|
for (let w2 = 0; w2 < colspan; w2++) {
|
|
90495
91521
|
if (map2[start2 + w2] == 0) map2[start2 + w2] = pos;
|
|
90496
|
-
else
|
|
90497
|
-
|
|
90498
|
-
|
|
90499
|
-
|
|
90500
|
-
|
|
90501
|
-
|
|
90502
|
-
});
|
|
91522
|
+
else (problems || (problems = [])).push({
|
|
91523
|
+
type: "collision",
|
|
91524
|
+
row: row2,
|
|
91525
|
+
pos,
|
|
91526
|
+
n: colspan - w2
|
|
91527
|
+
});
|
|
90503
91528
|
const colW = colwidth && colwidth[w2];
|
|
90504
91529
|
if (colW) {
|
|
90505
91530
|
const widthIndex = (start2 + w2) % width * 2, prev = colWidths[widthIndex];
|
|
90506
91531
|
if (prev == null || prev != colW && colWidths[widthIndex + 1] == 1) {
|
|
90507
91532
|
colWidths[widthIndex] = colW;
|
|
90508
91533
|
colWidths[widthIndex + 1] = 1;
|
|
90509
|
-
} else if (prev == colW)
|
|
90510
|
-
colWidths[widthIndex + 1]++;
|
|
90511
|
-
}
|
|
91534
|
+
} else if (prev == colW) colWidths[widthIndex + 1]++;
|
|
90512
91535
|
}
|
|
90513
91536
|
}
|
|
90514
91537
|
}
|
|
@@ -90518,16 +91541,17 @@ ${l}
|
|
|
90518
91541
|
const expectedPos = (row2 + 1) * width;
|
|
90519
91542
|
let missing = 0;
|
|
90520
91543
|
while (mapPos < expectedPos) if (map2[mapPos++] == 0) missing++;
|
|
90521
|
-
if (missing)
|
|
90522
|
-
|
|
91544
|
+
if (missing) (problems || (problems = [])).push({
|
|
91545
|
+
type: "missing",
|
|
91546
|
+
row: row2,
|
|
91547
|
+
n: missing
|
|
91548
|
+
});
|
|
90523
91549
|
pos++;
|
|
90524
91550
|
}
|
|
90525
|
-
if (width === 0 || height === 0)
|
|
90526
|
-
(problems || (problems = [])).push({ type: "zero_sized" });
|
|
91551
|
+
if (width === 0 || height === 0) (problems || (problems = [])).push({ type: "zero_sized" });
|
|
90527
91552
|
const tableMap = new TableMap(width, height, map2, problems);
|
|
90528
91553
|
let badWidths = false;
|
|
90529
|
-
for (let i2 = 0; !badWidths && i2 < colWidths.length; i2 += 2)
|
|
90530
|
-
if (colWidths[i2] != null && colWidths[i2 + 1] < height) badWidths = true;
|
|
91554
|
+
for (let i2 = 0; !badWidths && i2 < colWidths.length; i2 += 2) if (colWidths[i2] != null && colWidths[i2 + 1] < height) badWidths = true;
|
|
90531
91555
|
if (badWidths) findBadColWidths(tableMap, colWidths, table2);
|
|
90532
91556
|
return tableMap;
|
|
90533
91557
|
}
|
|
@@ -90537,14 +91561,13 @@ ${l}
|
|
|
90537
91561
|
for (let row2 = 0; row2 < table2.childCount; row2++) {
|
|
90538
91562
|
const rowNode = table2.child(row2);
|
|
90539
91563
|
let rowWidth = 0;
|
|
90540
|
-
if (hasRowSpan)
|
|
90541
|
-
|
|
90542
|
-
|
|
90543
|
-
|
|
90544
|
-
|
|
90545
|
-
if (j2 + cell2.attrs.rowspan > row2) rowWidth += cell2.attrs.colspan;
|
|
90546
|
-
}
|
|
91564
|
+
if (hasRowSpan) for (let j2 = 0; j2 < row2; j2++) {
|
|
91565
|
+
const prevRow = table2.child(j2);
|
|
91566
|
+
for (let i2 = 0; i2 < prevRow.childCount; i2++) {
|
|
91567
|
+
const cell2 = prevRow.child(i2);
|
|
91568
|
+
if (j2 + cell2.attrs.rowspan > row2) rowWidth += cell2.attrs.colspan;
|
|
90547
91569
|
}
|
|
91570
|
+
}
|
|
90548
91571
|
for (let i2 = 0; i2 < rowNode.childCount; i2++) {
|
|
90549
91572
|
const cell2 = rowNode.child(i2);
|
|
90550
91573
|
rowWidth += cell2.attrs.colspan;
|
|
@@ -90563,23 +91586,18 @@ ${l}
|
|
|
90563
91586
|
if (seen[pos]) continue;
|
|
90564
91587
|
seen[pos] = true;
|
|
90565
91588
|
const node2 = table2.nodeAt(pos);
|
|
90566
|
-
if (!node2) {
|
|
90567
|
-
throw new RangeError(`No cell with offset ${pos} found`);
|
|
90568
|
-
}
|
|
91589
|
+
if (!node2) throw new RangeError(`No cell with offset ${pos} found`);
|
|
90569
91590
|
let updated = null;
|
|
90570
91591
|
const attrs = node2.attrs;
|
|
90571
91592
|
for (let j2 = 0; j2 < attrs.colspan; j2++) {
|
|
90572
|
-
const
|
|
90573
|
-
|
|
90574
|
-
|
|
90575
|
-
|
|
90576
|
-
|
|
90577
|
-
|
|
90578
|
-
|
|
90579
|
-
|
|
90580
|
-
pos,
|
|
90581
|
-
colwidth: updated
|
|
90582
|
-
});
|
|
91593
|
+
const colWidth = colWidths[(i2 + j2) % map2.width * 2];
|
|
91594
|
+
if (colWidth != null && (!attrs.colwidth || attrs.colwidth[j2] != colWidth)) (updated || (updated = freshColWidth(attrs)))[j2] = colWidth;
|
|
91595
|
+
}
|
|
91596
|
+
if (updated) map2.problems.unshift({
|
|
91597
|
+
type: "colwidth mismatch",
|
|
91598
|
+
pos,
|
|
91599
|
+
colwidth: updated
|
|
91600
|
+
});
|
|
90583
91601
|
}
|
|
90584
91602
|
}
|
|
90585
91603
|
function freshColWidth(attrs) {
|
|
@@ -90599,11 +91617,9 @@ ${l}
|
|
|
90599
91617
|
}
|
|
90600
91618
|
return result;
|
|
90601
91619
|
}
|
|
90602
|
-
|
|
91620
|
+
const tableEditingKey = new PluginKey("selectingCells");
|
|
90603
91621
|
function cellAround$1($pos) {
|
|
90604
|
-
for (let d2 = $pos.depth - 1; d2 > 0; d2--)
|
|
90605
|
-
if ($pos.node(d2).type.spec.tableRole == "row")
|
|
90606
|
-
return $pos.node(0).resolve($pos.before(d2 + 1));
|
|
91622
|
+
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));
|
|
90607
91623
|
return null;
|
|
90608
91624
|
}
|
|
90609
91625
|
function cellWrapping$1($pos) {
|
|
@@ -90615,21 +91631,15 @@ ${l}
|
|
|
90615
91631
|
}
|
|
90616
91632
|
function isInTable(state2) {
|
|
90617
91633
|
const $head = state2.selection.$head;
|
|
90618
|
-
for (let d2 = $head.depth; d2 > 0; d2--)
|
|
90619
|
-
if ($head.node(d2).type.spec.tableRole == "row") return true;
|
|
91634
|
+
for (let d2 = $head.depth; d2 > 0; d2--) if ($head.node(d2).type.spec.tableRole == "row") return true;
|
|
90620
91635
|
return false;
|
|
90621
91636
|
}
|
|
90622
91637
|
function selectionCell(state2) {
|
|
90623
91638
|
const sel = state2.selection;
|
|
90624
|
-
if ("$anchorCell" in sel && sel.$anchorCell)
|
|
90625
|
-
|
|
90626
|
-
} else if ("node" in sel && sel.node && sel.node.type.spec.tableRole == "cell") {
|
|
90627
|
-
return sel.$anchor;
|
|
90628
|
-
}
|
|
91639
|
+
if ("$anchorCell" in sel && sel.$anchorCell) return sel.$anchorCell.pos > sel.$headCell.pos ? sel.$anchorCell : sel.$headCell;
|
|
91640
|
+
else if ("node" in sel && sel.node && sel.node.type.spec.tableRole == "cell") return sel.$anchor;
|
|
90629
91641
|
const $cell = cellAround$1(sel.$head) || cellNear(sel.$head);
|
|
90630
|
-
if ($cell)
|
|
90631
|
-
return $cell;
|
|
90632
|
-
}
|
|
91642
|
+
if ($cell) return $cell;
|
|
90633
91643
|
throw new RangeError(`No cell found around position ${sel.head}`);
|
|
90634
91644
|
}
|
|
90635
91645
|
function cellNear($pos) {
|
|
@@ -90639,8 +91649,7 @@ ${l}
|
|
|
90639
91649
|
}
|
|
90640
91650
|
for (let before = $pos.nodeBefore, pos = $pos.pos; before; before = before.lastChild, pos--) {
|
|
90641
91651
|
const role = before.type.spec.tableRole;
|
|
90642
|
-
if (role == "cell" || role == "header_cell")
|
|
90643
|
-
return $pos.doc.resolve(pos - before.nodeSize);
|
|
91652
|
+
if (role == "cell" || role == "header_cell") return $pos.doc.resolve(pos - before.nodeSize);
|
|
90644
91653
|
}
|
|
90645
91654
|
}
|
|
90646
91655
|
function pointsAtCell($pos) {
|
|
@@ -90660,7 +91669,10 @@ ${l}
|
|
|
90660
91669
|
return moved == null ? null : $pos.node(0).resolve(tableStart + moved);
|
|
90661
91670
|
}
|
|
90662
91671
|
function removeColSpan(attrs, pos, n = 1) {
|
|
90663
|
-
const result = {
|
|
91672
|
+
const result = {
|
|
91673
|
+
...attrs,
|
|
91674
|
+
colspan: attrs.colspan - n
|
|
91675
|
+
};
|
|
90664
91676
|
if (result.colwidth) {
|
|
90665
91677
|
result.colwidth = result.colwidth.slice();
|
|
90666
91678
|
result.colwidth.splice(pos, n);
|
|
@@ -90669,7 +91681,10 @@ ${l}
|
|
|
90669
91681
|
return result;
|
|
90670
91682
|
}
|
|
90671
91683
|
function addColSpan(attrs, pos, n = 1) {
|
|
90672
|
-
const result = {
|
|
91684
|
+
const result = {
|
|
91685
|
+
...attrs,
|
|
91686
|
+
colspan: attrs.colspan + n
|
|
91687
|
+
};
|
|
90673
91688
|
if (result.colwidth) {
|
|
90674
91689
|
result.colwidth = result.colwidth.slice();
|
|
90675
91690
|
for (let i2 = 0; i2 < n; i2++) result.colwidth.splice(pos, 0, 0);
|
|
@@ -90678,37 +91693,23 @@ ${l}
|
|
|
90678
91693
|
}
|
|
90679
91694
|
function columnIsHeader(map2, table2, col) {
|
|
90680
91695
|
const headerCell = tableNodeTypes(table2.type.schema).header_cell;
|
|
90681
|
-
for (let row2 = 0; row2 < map2.height; row2++)
|
|
90682
|
-
if (table2.nodeAt(map2.map[col + row2 * map2.width]).type != headerCell)
|
|
90683
|
-
return false;
|
|
91696
|
+
for (let row2 = 0; row2 < map2.height; row2++) if (table2.nodeAt(map2.map[col + row2 * map2.width]).type != headerCell) return false;
|
|
90684
91697
|
return true;
|
|
90685
91698
|
}
|
|
90686
|
-
var CellSelection = class
|
|
90687
|
-
// A table selection is identified by its anchor and head cells. The
|
|
90688
|
-
// positions given to this constructor should point _before_ two
|
|
90689
|
-
// cells in the same table. They may be the same, to select a single
|
|
90690
|
-
// cell.
|
|
91699
|
+
var CellSelection = class CellSelection2 extends Selection {
|
|
90691
91700
|
constructor($anchorCell, $headCell = $anchorCell) {
|
|
90692
91701
|
const table2 = $anchorCell.node(-1);
|
|
90693
91702
|
const map2 = TableMap.get(table2);
|
|
90694
91703
|
const tableStart = $anchorCell.start(-1);
|
|
90695
|
-
const rect = map2.rectBetween(
|
|
90696
|
-
$anchorCell.pos - tableStart,
|
|
90697
|
-
$headCell.pos - tableStart
|
|
90698
|
-
);
|
|
91704
|
+
const rect = map2.rectBetween($anchorCell.pos - tableStart, $headCell.pos - tableStart);
|
|
90699
91705
|
const doc2 = $anchorCell.node(0);
|
|
90700
91706
|
const cells = map2.cellsInRect(rect).filter((p2) => p2 != $headCell.pos - tableStart);
|
|
90701
91707
|
cells.unshift($headCell.pos - tableStart);
|
|
90702
91708
|
const ranges = cells.map((pos) => {
|
|
90703
91709
|
const cell2 = table2.nodeAt(pos);
|
|
90704
|
-
if (!cell2) {
|
|
90705
|
-
throw RangeError(`No cell with offset ${pos} found`);
|
|
90706
|
-
}
|
|
91710
|
+
if (!cell2) throw new RangeError(`No cell with offset ${pos} found`);
|
|
90707
91711
|
const from2 = tableStart + pos + 1;
|
|
90708
|
-
return new SelectionRange(
|
|
90709
|
-
doc2.resolve(from2),
|
|
90710
|
-
doc2.resolve(from2 + cell2.content.size)
|
|
90711
|
-
);
|
|
91712
|
+
return new SelectionRange(doc2.resolve(from2), doc2.resolve(from2 + cell2.content.size));
|
|
90712
91713
|
});
|
|
90713
91714
|
super(ranges[0].$from, ranges[0].$to, ranges);
|
|
90714
91715
|
this.$anchorCell = $anchorCell;
|
|
@@ -90719,24 +91720,17 @@ ${l}
|
|
|
90719
91720
|
const $headCell = doc2.resolve(mapping.map(this.$headCell.pos));
|
|
90720
91721
|
if (pointsAtCell($anchorCell) && pointsAtCell($headCell) && inSameTable($anchorCell, $headCell)) {
|
|
90721
91722
|
const tableChanged = this.$anchorCell.node(-1) != $anchorCell.node(-1);
|
|
90722
|
-
if (tableChanged && this.isRowSelection())
|
|
90723
|
-
|
|
90724
|
-
else
|
|
90725
|
-
return _CellSelection.colSelection($anchorCell, $headCell);
|
|
90726
|
-
else return new _CellSelection($anchorCell, $headCell);
|
|
91723
|
+
if (tableChanged && this.isRowSelection()) return CellSelection2.rowSelection($anchorCell, $headCell);
|
|
91724
|
+
else if (tableChanged && this.isColSelection()) return CellSelection2.colSelection($anchorCell, $headCell);
|
|
91725
|
+
else return new CellSelection2($anchorCell, $headCell);
|
|
90727
91726
|
}
|
|
90728
91727
|
return TextSelection$1.between($anchorCell, $headCell);
|
|
90729
91728
|
}
|
|
90730
|
-
// Returns a rectangular slice of table rows containing the selected
|
|
90731
|
-
// cells.
|
|
90732
91729
|
content() {
|
|
90733
91730
|
const table2 = this.$anchorCell.node(-1);
|
|
90734
91731
|
const map2 = TableMap.get(table2);
|
|
90735
91732
|
const tableStart = this.$anchorCell.start(-1);
|
|
90736
|
-
const rect = map2.rectBetween(
|
|
90737
|
-
this.$anchorCell.pos - tableStart,
|
|
90738
|
-
this.$headCell.pos - tableStart
|
|
90739
|
-
);
|
|
91733
|
+
const rect = map2.rectBetween(this.$anchorCell.pos - tableStart, this.$headCell.pos - tableStart);
|
|
90740
91734
|
const seen = {};
|
|
90741
91735
|
const rows = [];
|
|
90742
91736
|
for (let row2 = rect.top; row2 < rect.bottom; row2++) {
|
|
@@ -90747,44 +91741,25 @@ ${l}
|
|
|
90747
91741
|
seen[pos] = true;
|
|
90748
91742
|
const cellRect = map2.findCell(pos);
|
|
90749
91743
|
let cell2 = table2.nodeAt(pos);
|
|
90750
|
-
if (!cell2) {
|
|
90751
|
-
throw RangeError(`No cell with offset ${pos} found`);
|
|
90752
|
-
}
|
|
91744
|
+
if (!cell2) throw new RangeError(`No cell with offset ${pos} found`);
|
|
90753
91745
|
const extraLeft = rect.left - cellRect.left;
|
|
90754
91746
|
const extraRight = cellRect.right - rect.right;
|
|
90755
91747
|
if (extraLeft > 0 || extraRight > 0) {
|
|
90756
91748
|
let attrs = cell2.attrs;
|
|
90757
|
-
if (extraLeft > 0)
|
|
90758
|
-
|
|
90759
|
-
}
|
|
90760
|
-
if (extraRight > 0) {
|
|
90761
|
-
attrs = removeColSpan(
|
|
90762
|
-
attrs,
|
|
90763
|
-
attrs.colspan - extraRight,
|
|
90764
|
-
extraRight
|
|
90765
|
-
);
|
|
90766
|
-
}
|
|
91749
|
+
if (extraLeft > 0) attrs = removeColSpan(attrs, 0, extraLeft);
|
|
91750
|
+
if (extraRight > 0) attrs = removeColSpan(attrs, attrs.colspan - extraRight, extraRight);
|
|
90767
91751
|
if (cellRect.left < rect.left) {
|
|
90768
91752
|
cell2 = cell2.type.createAndFill(attrs);
|
|
90769
|
-
if (!cell2) {
|
|
90770
|
-
|
|
90771
|
-
`Could not create cell with attrs ${JSON.stringify(attrs)}`
|
|
90772
|
-
);
|
|
90773
|
-
}
|
|
90774
|
-
} else {
|
|
90775
|
-
cell2 = cell2.type.create(attrs, cell2.content);
|
|
90776
|
-
}
|
|
91753
|
+
if (!cell2) throw new RangeError(`Could not create cell with attrs ${JSON.stringify(attrs)}`);
|
|
91754
|
+
} else cell2 = cell2.type.create(attrs, cell2.content);
|
|
90777
91755
|
}
|
|
90778
91756
|
if (cellRect.top < rect.top || cellRect.bottom > rect.bottom) {
|
|
90779
91757
|
const attrs = {
|
|
90780
91758
|
...cell2.attrs,
|
|
90781
91759
|
rowspan: Math.min(cellRect.bottom, rect.bottom) - Math.max(cellRect.top, rect.top)
|
|
90782
91760
|
};
|
|
90783
|
-
if (cellRect.top < rect.top)
|
|
90784
|
-
|
|
90785
|
-
} else {
|
|
90786
|
-
cell2 = cell2.type.create(attrs, cell2.content);
|
|
90787
|
-
}
|
|
91761
|
+
if (cellRect.top < rect.top) cell2 = cell2.type.createAndFill(attrs);
|
|
91762
|
+
else cell2 = cell2.type.create(attrs, cell2.content);
|
|
90788
91763
|
}
|
|
90789
91764
|
rowContent.push(cell2);
|
|
90790
91765
|
}
|
|
@@ -90797,16 +91772,9 @@ ${l}
|
|
|
90797
91772
|
const mapFrom = tr.steps.length, ranges = this.ranges;
|
|
90798
91773
|
for (let i2 = 0; i2 < ranges.length; i2++) {
|
|
90799
91774
|
const { $from, $to } = ranges[i2], mapping = tr.mapping.slice(mapFrom);
|
|
90800
|
-
tr.replace(
|
|
90801
|
-
mapping.map($from.pos),
|
|
90802
|
-
mapping.map($to.pos),
|
|
90803
|
-
i2 ? Slice.empty : content2
|
|
90804
|
-
);
|
|
91775
|
+
tr.replace(mapping.map($from.pos), mapping.map($to.pos), i2 ? Slice.empty : content2);
|
|
90805
91776
|
}
|
|
90806
|
-
const sel = Selection.findFrom(
|
|
90807
|
-
tr.doc.resolve(tr.mapping.slice(mapFrom).map(this.to)),
|
|
90808
|
-
-1
|
|
90809
|
-
);
|
|
91777
|
+
const sel = Selection.findFrom(tr.doc.resolve(tr.mapping.slice(mapFrom).map(this.to)), -1);
|
|
90810
91778
|
if (sel) tr.setSelection(sel);
|
|
90811
91779
|
}
|
|
90812
91780
|
replaceWith(tr, node2) {
|
|
@@ -90816,18 +91784,9 @@ ${l}
|
|
|
90816
91784
|
const table2 = this.$anchorCell.node(-1);
|
|
90817
91785
|
const map2 = TableMap.get(table2);
|
|
90818
91786
|
const tableStart = this.$anchorCell.start(-1);
|
|
90819
|
-
const cells = map2.cellsInRect(
|
|
90820
|
-
|
|
90821
|
-
this.$anchorCell.pos - tableStart,
|
|
90822
|
-
this.$headCell.pos - tableStart
|
|
90823
|
-
)
|
|
90824
|
-
);
|
|
90825
|
-
for (let i2 = 0; i2 < cells.length; i2++) {
|
|
90826
|
-
f2(table2.nodeAt(cells[i2]), tableStart + cells[i2]);
|
|
90827
|
-
}
|
|
91787
|
+
const cells = map2.cellsInRect(map2.rectBetween(this.$anchorCell.pos - tableStart, this.$headCell.pos - tableStart));
|
|
91788
|
+
for (let i2 = 0; i2 < cells.length; i2++) f2(table2.nodeAt(cells[i2]), tableStart + cells[i2]);
|
|
90828
91789
|
}
|
|
90829
|
-
// True if this selection goes all the way from the top to the
|
|
90830
|
-
// bottom of the table.
|
|
90831
91790
|
isColSelection() {
|
|
90832
91791
|
const anchorTop = this.$anchorCell.index(-1);
|
|
90833
91792
|
const headTop = this.$headCell.index(-1);
|
|
@@ -90836,8 +91795,6 @@ ${l}
|
|
|
90836
91795
|
const headBottom = headTop + this.$headCell.nodeAfter.attrs.rowspan;
|
|
90837
91796
|
return Math.max(anchorBottom, headBottom) == this.$headCell.node(-1).childCount;
|
|
90838
91797
|
}
|
|
90839
|
-
// Returns the smallest column selection that covers the given anchor
|
|
90840
|
-
// and head cell.
|
|
90841
91798
|
static colSelection($anchorCell, $headCell = $anchorCell) {
|
|
90842
91799
|
const table2 = $anchorCell.node(-1);
|
|
90843
91800
|
const map2 = TableMap.get(table2);
|
|
@@ -90846,24 +91803,14 @@ ${l}
|
|
|
90846
91803
|
const headRect = map2.findCell($headCell.pos - tableStart);
|
|
90847
91804
|
const doc2 = $anchorCell.node(0);
|
|
90848
91805
|
if (anchorRect.top <= headRect.top) {
|
|
90849
|
-
if (anchorRect.top > 0)
|
|
90850
|
-
|
|
90851
|
-
if (headRect.bottom < map2.height)
|
|
90852
|
-
$headCell = doc2.resolve(
|
|
90853
|
-
tableStart + map2.map[map2.width * (map2.height - 1) + headRect.right - 1]
|
|
90854
|
-
);
|
|
91806
|
+
if (anchorRect.top > 0) $anchorCell = doc2.resolve(tableStart + map2.map[anchorRect.left]);
|
|
91807
|
+
if (headRect.bottom < map2.height) $headCell = doc2.resolve(tableStart + map2.map[map2.width * (map2.height - 1) + headRect.right - 1]);
|
|
90855
91808
|
} else {
|
|
90856
|
-
if (headRect.top > 0)
|
|
90857
|
-
|
|
90858
|
-
if (anchorRect.bottom < map2.height)
|
|
90859
|
-
$anchorCell = doc2.resolve(
|
|
90860
|
-
tableStart + map2.map[map2.width * (map2.height - 1) + anchorRect.right - 1]
|
|
90861
|
-
);
|
|
91809
|
+
if (headRect.top > 0) $headCell = doc2.resolve(tableStart + map2.map[headRect.left]);
|
|
91810
|
+
if (anchorRect.bottom < map2.height) $anchorCell = doc2.resolve(tableStart + map2.map[map2.width * (map2.height - 1) + anchorRect.right - 1]);
|
|
90862
91811
|
}
|
|
90863
|
-
return new
|
|
91812
|
+
return new CellSelection2($anchorCell, $headCell);
|
|
90864
91813
|
}
|
|
90865
|
-
// True if this selection goes all the way from the left to the
|
|
90866
|
-
// right of the table.
|
|
90867
91814
|
isRowSelection() {
|
|
90868
91815
|
const table2 = this.$anchorCell.node(-1);
|
|
90869
91816
|
const map2 = TableMap.get(table2);
|
|
@@ -90876,10 +91823,8 @@ ${l}
|
|
|
90876
91823
|
return Math.max(anchorRight, headRight) == map2.width;
|
|
90877
91824
|
}
|
|
90878
91825
|
eq(other) {
|
|
90879
|
-
return other instanceof
|
|
91826
|
+
return other instanceof CellSelection2 && other.$anchorCell.pos == this.$anchorCell.pos && other.$headCell.pos == this.$headCell.pos;
|
|
90880
91827
|
}
|
|
90881
|
-
// Returns the smallest row selection that covers the given anchor
|
|
90882
|
-
// and head cell.
|
|
90883
91828
|
static rowSelection($anchorCell, $headCell = $anchorCell) {
|
|
90884
91829
|
const table2 = $anchorCell.node(-1);
|
|
90885
91830
|
const map2 = TableMap.get(table2);
|
|
@@ -90888,23 +91833,13 @@ ${l}
|
|
|
90888
91833
|
const headRect = map2.findCell($headCell.pos - tableStart);
|
|
90889
91834
|
const doc2 = $anchorCell.node(0);
|
|
90890
91835
|
if (anchorRect.left <= headRect.left) {
|
|
90891
|
-
if (anchorRect.left > 0)
|
|
90892
|
-
|
|
90893
|
-
tableStart + map2.map[anchorRect.top * map2.width]
|
|
90894
|
-
);
|
|
90895
|
-
if (headRect.right < map2.width)
|
|
90896
|
-
$headCell = doc2.resolve(
|
|
90897
|
-
tableStart + map2.map[map2.width * (headRect.top + 1) - 1]
|
|
90898
|
-
);
|
|
91836
|
+
if (anchorRect.left > 0) $anchorCell = doc2.resolve(tableStart + map2.map[anchorRect.top * map2.width]);
|
|
91837
|
+
if (headRect.right < map2.width) $headCell = doc2.resolve(tableStart + map2.map[map2.width * (headRect.top + 1) - 1]);
|
|
90899
91838
|
} else {
|
|
90900
|
-
if (headRect.left > 0)
|
|
90901
|
-
|
|
90902
|
-
if (anchorRect.right < map2.width)
|
|
90903
|
-
$anchorCell = doc2.resolve(
|
|
90904
|
-
tableStart + map2.map[map2.width * (anchorRect.top + 1) - 1]
|
|
90905
|
-
);
|
|
91839
|
+
if (headRect.left > 0) $headCell = doc2.resolve(tableStart + map2.map[headRect.top * map2.width]);
|
|
91840
|
+
if (anchorRect.right < map2.width) $anchorCell = doc2.resolve(tableStart + map2.map[map2.width * (anchorRect.top + 1) - 1]);
|
|
90906
91841
|
}
|
|
90907
|
-
return new
|
|
91842
|
+
return new CellSelection2($anchorCell, $headCell);
|
|
90908
91843
|
}
|
|
90909
91844
|
toJSON() {
|
|
90910
91845
|
return {
|
|
@@ -90914,10 +91849,10 @@ ${l}
|
|
|
90914
91849
|
};
|
|
90915
91850
|
}
|
|
90916
91851
|
static fromJSON(doc2, json) {
|
|
90917
|
-
return new
|
|
91852
|
+
return new CellSelection2(doc2.resolve(json.anchor), doc2.resolve(json.head));
|
|
90918
91853
|
}
|
|
90919
91854
|
static create(doc2, anchorCell, headCell = anchorCell) {
|
|
90920
|
-
return new
|
|
91855
|
+
return new CellSelection2(doc2.resolve(anchorCell), doc2.resolve(headCell));
|
|
90921
91856
|
}
|
|
90922
91857
|
getBookmark() {
|
|
90923
91858
|
return new CellBookmark(this.$anchorCell.pos, this.$headCell.pos);
|
|
@@ -90925,18 +91860,17 @@ ${l}
|
|
|
90925
91860
|
};
|
|
90926
91861
|
CellSelection.prototype.visible = false;
|
|
90927
91862
|
Selection.jsonID("cell", CellSelection);
|
|
90928
|
-
var CellBookmark = class
|
|
91863
|
+
var CellBookmark = class CellBookmark2 {
|
|
90929
91864
|
constructor(anchor, head) {
|
|
90930
91865
|
this.anchor = anchor;
|
|
90931
91866
|
this.head = head;
|
|
90932
91867
|
}
|
|
90933
91868
|
map(mapping) {
|
|
90934
|
-
return new
|
|
91869
|
+
return new CellBookmark2(mapping.map(this.anchor), mapping.map(this.head));
|
|
90935
91870
|
}
|
|
90936
91871
|
resolve(doc2) {
|
|
90937
91872
|
const $anchorCell = doc2.resolve(this.anchor), $headCell = doc2.resolve(this.head);
|
|
90938
|
-
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))
|
|
90939
|
-
return new CellSelection($anchorCell, $headCell);
|
|
91873
|
+
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);
|
|
90940
91874
|
else return Selection.near($headCell, 1);
|
|
90941
91875
|
}
|
|
90942
91876
|
};
|
|
@@ -90944,9 +91878,7 @@ ${l}
|
|
|
90944
91878
|
if (!(state2.selection instanceof CellSelection)) return null;
|
|
90945
91879
|
const cells = [];
|
|
90946
91880
|
state2.selection.forEachCell((node2, pos) => {
|
|
90947
|
-
cells.push(
|
|
90948
|
-
Decoration.node(pos, pos + node2.nodeSize, { class: "selectedCell" })
|
|
90949
|
-
);
|
|
91881
|
+
cells.push(Decoration.node(pos, pos + node2.nodeSize, { class: "selectedCell" }));
|
|
90950
91882
|
});
|
|
90951
91883
|
return DecorationSet.create(state2.doc, cells);
|
|
90952
91884
|
}
|
|
@@ -90955,10 +91887,8 @@ ${l}
|
|
|
90955
91887
|
let afterFrom = $from.pos;
|
|
90956
91888
|
let beforeTo = $to.pos;
|
|
90957
91889
|
let depth = $from.depth;
|
|
90958
|
-
for (; depth >= 0; depth--, afterFrom++)
|
|
90959
|
-
|
|
90960
|
-
for (let d2 = $to.depth; d2 >= 0; d2--, beforeTo--)
|
|
90961
|
-
if ($to.before(d2 + 1) > $to.start(d2)) break;
|
|
91890
|
+
for (; depth >= 0; depth--, afterFrom++) if ($from.after(depth + 1) < $from.end(depth)) break;
|
|
91891
|
+
for (let d2 = $to.depth; d2 >= 0; d2--, beforeTo--) if ($to.before(d2 + 1) > $to.start(d2)) break;
|
|
90962
91892
|
return afterFrom == beforeTo && /row|table/.test($from.node(depth).type.spec.tableRole);
|
|
90963
91893
|
}
|
|
90964
91894
|
function isTextSelectionAcrossCells({ $from, $to }) {
|
|
@@ -90986,9 +91916,8 @@ ${l}
|
|
|
90986
91916
|
let normalize2;
|
|
90987
91917
|
let role;
|
|
90988
91918
|
if (sel instanceof NodeSelection && (role = sel.node.type.spec.tableRole)) {
|
|
90989
|
-
if (role == "cell" || role == "header_cell")
|
|
90990
|
-
|
|
90991
|
-
} else if (role == "row") {
|
|
91919
|
+
if (role == "cell" || role == "header_cell") normalize2 = CellSelection.create(doc2, sel.from);
|
|
91920
|
+
else if (role == "row") {
|
|
90992
91921
|
const $cell = doc2.resolve(sel.from + 1);
|
|
90993
91922
|
normalize2 = CellSelection.rowSelection($cell, $cell);
|
|
90994
91923
|
} else if (!allowTableNodeSelection) {
|
|
@@ -90997,29 +91926,23 @@ ${l}
|
|
|
90997
91926
|
const lastCell = start2 + map2.map[map2.width * map2.height - 1];
|
|
90998
91927
|
normalize2 = CellSelection.create(doc2, start2 + 1, lastCell);
|
|
90999
91928
|
}
|
|
91000
|
-
} else if (sel instanceof TextSelection$1 && isCellBoundarySelection(sel))
|
|
91001
|
-
|
|
91002
|
-
} else if (sel instanceof TextSelection$1 && isTextSelectionAcrossCells(sel)) {
|
|
91003
|
-
normalize2 = TextSelection$1.create(doc2, sel.$from.start(), sel.$from.end());
|
|
91004
|
-
}
|
|
91929
|
+
} else if (sel instanceof TextSelection$1 && isCellBoundarySelection(sel)) normalize2 = TextSelection$1.create(doc2, sel.from);
|
|
91930
|
+
else if (sel instanceof TextSelection$1 && isTextSelectionAcrossCells(sel)) normalize2 = TextSelection$1.create(doc2, sel.$from.start(), sel.$from.end());
|
|
91005
91931
|
if (normalize2) (tr || (tr = state2.tr)).setSelection(normalize2);
|
|
91006
91932
|
return tr;
|
|
91007
91933
|
}
|
|
91008
|
-
|
|
91934
|
+
const fixTablesKey = new PluginKey("fix-tables");
|
|
91009
91935
|
function changedDescendants(old, cur, offset2, f2) {
|
|
91010
91936
|
const oldSize = old.childCount, curSize = cur.childCount;
|
|
91011
91937
|
outer: for (let i2 = 0, j2 = 0; i2 < curSize; i2++) {
|
|
91012
91938
|
const child = cur.child(i2);
|
|
91013
|
-
for (let scan = j2, e = Math.min(oldSize, i2 + 3); scan < e; scan++) {
|
|
91014
|
-
|
|
91015
|
-
|
|
91016
|
-
|
|
91017
|
-
continue outer;
|
|
91018
|
-
}
|
|
91939
|
+
for (let scan = j2, e = Math.min(oldSize, i2 + 3); scan < e; scan++) if (old.child(scan) == child) {
|
|
91940
|
+
j2 = scan + 1;
|
|
91941
|
+
offset2 += child.nodeSize;
|
|
91942
|
+
continue outer;
|
|
91019
91943
|
}
|
|
91020
91944
|
f2(child, offset2);
|
|
91021
|
-
if (j2 < oldSize && old.child(j2).sameMarkup(child))
|
|
91022
|
-
changedDescendants(old.child(j2), child, offset2 + 1, f2);
|
|
91945
|
+
if (j2 < oldSize && old.child(j2).sameMarkup(child)) changedDescendants(old.child(j2), child, offset2 + 1, f2);
|
|
91023
91946
|
else child.nodesBetween(0, child.content.size, f2, offset2 + 1);
|
|
91024
91947
|
offset2 += child.nodeSize;
|
|
91025
91948
|
}
|
|
@@ -91027,12 +91950,10 @@ ${l}
|
|
|
91027
91950
|
function fixTables(state2, oldState) {
|
|
91028
91951
|
let tr;
|
|
91029
91952
|
const check = (node2, pos) => {
|
|
91030
|
-
if (node2.type.spec.tableRole == "table")
|
|
91031
|
-
tr = fixTable(state2, node2, pos, tr);
|
|
91953
|
+
if (node2.type.spec.tableRole == "table") tr = fixTable(state2, node2, pos, tr);
|
|
91032
91954
|
};
|
|
91033
91955
|
if (!oldState) state2.doc.descendants(check);
|
|
91034
|
-
else if (oldState.doc != state2.doc)
|
|
91035
|
-
changedDescendants(oldState.doc, state2.doc, 0, check);
|
|
91956
|
+
else if (oldState.doc != state2.doc) changedDescendants(oldState.doc, state2.doc, 0, check);
|
|
91036
91957
|
return tr;
|
|
91037
91958
|
}
|
|
91038
91959
|
function fixTable(state2, table2, tablePos, tr) {
|
|
@@ -91048,14 +91969,9 @@ ${l}
|
|
|
91048
91969
|
if (!cell2) continue;
|
|
91049
91970
|
const attrs = cell2.attrs;
|
|
91050
91971
|
for (let j2 = 0; j2 < attrs.rowspan; j2++) mustAdd[prob.row + j2] += prob.n;
|
|
91051
|
-
tr.setNodeMarkup(
|
|
91052
|
-
|
|
91053
|
-
|
|
91054
|
-
removeColSpan(attrs, attrs.colspan - prob.n, prob.n)
|
|
91055
|
-
);
|
|
91056
|
-
} else if (prob.type == "missing") {
|
|
91057
|
-
mustAdd[prob.row] += prob.n;
|
|
91058
|
-
} else if (prob.type == "overlong_rowspan") {
|
|
91972
|
+
tr.setNodeMarkup(tr.mapping.map(tablePos + 1 + prob.pos), null, removeColSpan(attrs, attrs.colspan - prob.n, prob.n));
|
|
91973
|
+
} else if (prob.type == "missing") mustAdd[prob.row] += prob.n;
|
|
91974
|
+
else if (prob.type == "overlong_rowspan") {
|
|
91059
91975
|
const cell2 = table2.nodeAt(prob.pos);
|
|
91060
91976
|
if (!cell2) continue;
|
|
91061
91977
|
tr.setNodeMarkup(tr.mapping.map(tablePos + 1 + prob.pos), null, {
|
|
@@ -91075,20 +91991,17 @@ ${l}
|
|
|
91075
91991
|
}
|
|
91076
91992
|
}
|
|
91077
91993
|
let first2, last;
|
|
91078
|
-
for (let i2 = 0; i2 < mustAdd.length; i2++)
|
|
91079
|
-
if (
|
|
91080
|
-
|
|
91081
|
-
|
|
91082
|
-
}
|
|
91994
|
+
for (let i2 = 0; i2 < mustAdd.length; i2++) if (mustAdd[i2]) {
|
|
91995
|
+
if (first2 == null) first2 = i2;
|
|
91996
|
+
last = i2;
|
|
91997
|
+
}
|
|
91083
91998
|
for (let i2 = 0, pos = tablePos + 1; i2 < map2.height; i2++) {
|
|
91084
91999
|
const row2 = table2.child(i2);
|
|
91085
92000
|
const end2 = pos + row2.nodeSize;
|
|
91086
92001
|
const add = mustAdd[i2];
|
|
91087
92002
|
if (add > 0) {
|
|
91088
92003
|
let role = "cell";
|
|
91089
|
-
if (row2.firstChild)
|
|
91090
|
-
role = row2.firstChild.type.spec.tableRole;
|
|
91091
|
-
}
|
|
92004
|
+
if (row2.firstChild) role = row2.firstChild.type.spec.tableRole;
|
|
91092
92005
|
const nodes = [];
|
|
91093
92006
|
for (let j2 = 0; j2 < add; j2++) {
|
|
91094
92007
|
const node2 = tableNodeTypes(state2.schema)[role].createAndFill();
|
|
@@ -91107,27 +92020,22 @@ ${l}
|
|
|
91107
92020
|
const table2 = $pos.node(-1);
|
|
91108
92021
|
const tableStart = $pos.start(-1);
|
|
91109
92022
|
const map2 = TableMap.get(table2);
|
|
91110
|
-
|
|
91111
|
-
sel.$anchorCell.pos - tableStart,
|
|
91112
|
-
|
|
91113
|
-
|
|
91114
|
-
|
|
92023
|
+
return {
|
|
92024
|
+
...sel instanceof CellSelection ? map2.rectBetween(sel.$anchorCell.pos - tableStart, sel.$headCell.pos - tableStart) : map2.findCell($pos.pos - tableStart),
|
|
92025
|
+
tableStart,
|
|
92026
|
+
map: map2,
|
|
92027
|
+
table: table2
|
|
92028
|
+
};
|
|
91115
92029
|
}
|
|
91116
92030
|
function addColumn(tr, { map: map2, tableStart, table: table2 }, col) {
|
|
91117
92031
|
let refColumn = col > 0 ? -1 : 0;
|
|
91118
|
-
if (columnIsHeader(map2, table2, col + refColumn))
|
|
91119
|
-
refColumn = col == 0 || col == map2.width ? null : 0;
|
|
91120
|
-
}
|
|
92032
|
+
if (columnIsHeader(map2, table2, col + refColumn)) refColumn = col == 0 || col == map2.width ? null : 0;
|
|
91121
92033
|
for (let row2 = 0; row2 < map2.height; row2++) {
|
|
91122
92034
|
const index2 = row2 * map2.width + col;
|
|
91123
92035
|
if (col > 0 && col < map2.width && map2.map[index2 - 1] == map2.map[index2]) {
|
|
91124
92036
|
const pos = map2.map[index2];
|
|
91125
92037
|
const cell2 = table2.nodeAt(pos);
|
|
91126
|
-
tr.setNodeMarkup(
|
|
91127
|
-
tr.mapping.map(tableStart + pos),
|
|
91128
|
-
null,
|
|
91129
|
-
addColSpan(cell2.attrs, col - map2.colCount(pos))
|
|
91130
|
-
);
|
|
92038
|
+
tr.setNodeMarkup(tr.mapping.map(tableStart + pos), null, addColSpan(cell2.attrs, col - map2.colCount(pos)));
|
|
91131
92039
|
row2 += cell2.attrs.rowspan - 1;
|
|
91132
92040
|
} else {
|
|
91133
92041
|
const type2 = refColumn == null ? tableNodeTypes(table2.type.schema).cell : table2.nodeAt(map2.map[index2 + refColumn]).type;
|
|
@@ -91160,13 +92068,8 @@ ${l}
|
|
|
91160
92068
|
const pos = map2.map[index2];
|
|
91161
92069
|
const cell2 = table2.nodeAt(pos);
|
|
91162
92070
|
const attrs = cell2.attrs;
|
|
91163
|
-
if (col > 0 && map2.map[index2 - 1] == pos || col < map2.width - 1 && map2.map[index2 + 1] == pos)
|
|
91164
|
-
|
|
91165
|
-
tr.mapping.slice(mapStart).map(tableStart + pos),
|
|
91166
|
-
null,
|
|
91167
|
-
removeColSpan(attrs, col - map2.colCount(pos))
|
|
91168
|
-
);
|
|
91169
|
-
} else {
|
|
92071
|
+
if (col > 0 && map2.map[index2 - 1] == pos || col < map2.width - 1 && map2.map[index2 + 1] == pos) tr.setNodeMarkup(tr.mapping.slice(mapStart).map(tableStart + pos), null, removeColSpan(attrs, col - map2.colCount(pos)));
|
|
92072
|
+
else {
|
|
91170
92073
|
const start2 = tr.mapping.slice(mapStart).map(tableStart + pos);
|
|
91171
92074
|
tr.delete(start2, start2 + cell2.nodeSize);
|
|
91172
92075
|
}
|
|
@@ -91183,9 +92086,7 @@ ${l}
|
|
|
91183
92086
|
removeColumn(tr, rect, i2);
|
|
91184
92087
|
if (i2 == rect.left) break;
|
|
91185
92088
|
const table2 = rect.tableStart ? tr.doc.nodeAt(rect.tableStart - 1) : tr.doc;
|
|
91186
|
-
if (!table2)
|
|
91187
|
-
throw RangeError("No table found");
|
|
91188
|
-
}
|
|
92089
|
+
if (!table2) throw new RangeError("No table found");
|
|
91189
92090
|
rect.table = table2;
|
|
91190
92091
|
rect.map = TableMap.get(table2);
|
|
91191
92092
|
}
|
|
@@ -91194,35 +92095,30 @@ ${l}
|
|
|
91194
92095
|
return true;
|
|
91195
92096
|
}
|
|
91196
92097
|
function rowIsHeader(map2, table2, row2) {
|
|
91197
|
-
var
|
|
92098
|
+
var _table$nodeAt;
|
|
91198
92099
|
const headerCell = tableNodeTypes(table2.type.schema).header_cell;
|
|
91199
|
-
for (let col = 0; col < map2.width; col++)
|
|
91200
|
-
if (((_a2 = table2.nodeAt(map2.map[col + row2 * map2.width])) == null ? void 0 : _a2.type) != headerCell)
|
|
91201
|
-
return false;
|
|
92100
|
+
for (let col = 0; col < map2.width; col++) if (((_table$nodeAt = table2.nodeAt(map2.map[col + row2 * map2.width])) === null || _table$nodeAt === void 0 ? void 0 : _table$nodeAt.type) != headerCell) return false;
|
|
91202
92101
|
return true;
|
|
91203
92102
|
}
|
|
91204
92103
|
function addRow(tr, { map: map2, tableStart, table: table2 }, row2) {
|
|
91205
|
-
var _a2;
|
|
91206
92104
|
let rowPos = tableStart;
|
|
91207
92105
|
for (let i2 = 0; i2 < row2; i2++) rowPos += table2.child(i2).nodeSize;
|
|
91208
92106
|
const cells = [];
|
|
91209
92107
|
let refRow = row2 > 0 ? -1 : 0;
|
|
91210
|
-
if (rowIsHeader(map2, table2, row2 + refRow))
|
|
91211
|
-
|
|
91212
|
-
|
|
91213
|
-
|
|
91214
|
-
|
|
91215
|
-
|
|
91216
|
-
|
|
91217
|
-
|
|
91218
|
-
|
|
91219
|
-
|
|
91220
|
-
|
|
91221
|
-
|
|
91222
|
-
|
|
91223
|
-
|
|
91224
|
-
if (node2) cells.push(node2);
|
|
91225
|
-
}
|
|
92108
|
+
if (rowIsHeader(map2, table2, row2 + refRow)) refRow = row2 == 0 || row2 == map2.height ? null : 0;
|
|
92109
|
+
for (let col = 0, index2 = map2.width * row2; col < map2.width; col++, index2++) if (row2 > 0 && row2 < map2.height && map2.map[index2] == map2.map[index2 - map2.width]) {
|
|
92110
|
+
const pos = map2.map[index2];
|
|
92111
|
+
const attrs = table2.nodeAt(pos).attrs;
|
|
92112
|
+
tr.setNodeMarkup(tableStart + pos, null, {
|
|
92113
|
+
...attrs,
|
|
92114
|
+
rowspan: attrs.rowspan + 1
|
|
92115
|
+
});
|
|
92116
|
+
col += attrs.colspan - 1;
|
|
92117
|
+
} else {
|
|
92118
|
+
var _table$nodeAt2;
|
|
92119
|
+
const type2 = refRow == null ? tableNodeTypes(table2.type.schema).cell : (_table$nodeAt2 = table2.nodeAt(map2.map[index2 + refRow * map2.width])) === null || _table$nodeAt2 === void 0 ? void 0 : _table$nodeAt2.type;
|
|
92120
|
+
const node2 = type2 === null || type2 === void 0 ? void 0 : type2.createAndFill();
|
|
92121
|
+
if (node2) cells.push(node2);
|
|
91226
92122
|
}
|
|
91227
92123
|
tr.insert(rowPos, tableNodeTypes(table2.type.schema).row.create(null, cells));
|
|
91228
92124
|
return tr;
|
|
@@ -91264,10 +92160,10 @@ ${l}
|
|
|
91264
92160
|
} else if (row2 < map2.height && pos == map2.map[index2 + map2.width]) {
|
|
91265
92161
|
const cell2 = table2.nodeAt(pos);
|
|
91266
92162
|
const attrs = cell2.attrs;
|
|
91267
|
-
const copy2 = cell2.type.create(
|
|
91268
|
-
|
|
91269
|
-
cell2.
|
|
91270
|
-
);
|
|
92163
|
+
const copy2 = cell2.type.create({
|
|
92164
|
+
...attrs,
|
|
92165
|
+
rowspan: cell2.attrs.rowspan - 1
|
|
92166
|
+
}, cell2.content);
|
|
91271
92167
|
const newPos = map2.positionAt(row2 + 1, col, table2);
|
|
91272
92168
|
tr.insert(tr.mapping.slice(mapFrom).map(tableStart + newPos), copy2);
|
|
91273
92169
|
col += attrs.colspan - 1;
|
|
@@ -91283,9 +92179,7 @@ ${l}
|
|
|
91283
92179
|
removeRow(tr, rect, i2);
|
|
91284
92180
|
if (i2 == rect.top) break;
|
|
91285
92181
|
const table2 = rect.tableStart ? tr.doc.nodeAt(rect.tableStart - 1) : tr.doc;
|
|
91286
|
-
if (!table2)
|
|
91287
|
-
throw RangeError("No table found");
|
|
91288
|
-
}
|
|
92182
|
+
if (!table2) throw new RangeError("No table found");
|
|
91289
92183
|
rect.table = table2;
|
|
91290
92184
|
rect.map = TableMap.get(rect.table);
|
|
91291
92185
|
}
|
|
@@ -91301,14 +92195,12 @@ ${l}
|
|
|
91301
92195
|
let indexTop = rect.top * width + rect.left, indexLeft = indexTop;
|
|
91302
92196
|
let indexBottom = (rect.bottom - 1) * width + rect.left, indexRight = indexTop + (rect.right - rect.left - 1);
|
|
91303
92197
|
for (let i2 = rect.top; i2 < rect.bottom; i2++) {
|
|
91304
|
-
if (rect.left > 0 && map2[indexLeft] == map2[indexLeft - 1] || rect.right < width && map2[indexRight] == map2[indexRight + 1])
|
|
91305
|
-
return true;
|
|
92198
|
+
if (rect.left > 0 && map2[indexLeft] == map2[indexLeft - 1] || rect.right < width && map2[indexRight] == map2[indexRight + 1]) return true;
|
|
91306
92199
|
indexLeft += width;
|
|
91307
92200
|
indexRight += width;
|
|
91308
92201
|
}
|
|
91309
92202
|
for (let i2 = rect.left; i2 < rect.right; i2++) {
|
|
91310
|
-
if (rect.top > 0 && map2[indexTop] == map2[indexTop - width] || rect.bottom < height && map2[indexBottom] == map2[indexBottom + width])
|
|
91311
|
-
return true;
|
|
92203
|
+
if (rect.top > 0 && map2[indexTop] == map2[indexTop - width] || rect.bottom < height && map2[indexBottom] == map2[indexBottom + width]) return true;
|
|
91312
92204
|
indexTop++;
|
|
91313
92205
|
indexBottom++;
|
|
91314
92206
|
}
|
|
@@ -91316,8 +92208,7 @@ ${l}
|
|
|
91316
92208
|
}
|
|
91317
92209
|
function mergeCells(state2, dispatch) {
|
|
91318
92210
|
const sel = state2.selection;
|
|
91319
|
-
if (!(sel instanceof CellSelection) || sel.$anchorCell.pos == sel.$headCell.pos)
|
|
91320
|
-
return false;
|
|
92211
|
+
if (!(sel instanceof CellSelection) || sel.$anchorCell.pos == sel.$headCell.pos) return false;
|
|
91321
92212
|
const rect = selectedRect(state2), { map: map2 } = rect;
|
|
91322
92213
|
if (cellsOverlapRectangle(map2, rect)) return false;
|
|
91323
92214
|
if (dispatch) {
|
|
@@ -91326,41 +92217,31 @@ ${l}
|
|
|
91326
92217
|
let content2 = Fragment$1.empty;
|
|
91327
92218
|
let mergedPos;
|
|
91328
92219
|
let mergedCell;
|
|
91329
|
-
for (let row2 = rect.top; row2 < rect.bottom; row2++) {
|
|
91330
|
-
|
|
91331
|
-
|
|
91332
|
-
|
|
91333
|
-
|
|
91334
|
-
|
|
91335
|
-
|
|
91336
|
-
|
|
91337
|
-
|
|
91338
|
-
|
|
91339
|
-
|
|
91340
|
-
|
|
91341
|
-
tr.delete(mapped, mapped + cell2.nodeSize);
|
|
91342
|
-
}
|
|
92220
|
+
for (let row2 = rect.top; row2 < rect.bottom; row2++) for (let col = rect.left; col < rect.right; col++) {
|
|
92221
|
+
const cellPos = map2.map[row2 * map2.width + col];
|
|
92222
|
+
const cell2 = rect.table.nodeAt(cellPos);
|
|
92223
|
+
if (seen[cellPos] || !cell2) continue;
|
|
92224
|
+
seen[cellPos] = true;
|
|
92225
|
+
if (mergedPos == null) {
|
|
92226
|
+
mergedPos = cellPos;
|
|
92227
|
+
mergedCell = cell2;
|
|
92228
|
+
} else {
|
|
92229
|
+
if (!isEmpty(cell2)) content2 = content2.append(cell2.content);
|
|
92230
|
+
const mapped = tr.mapping.map(cellPos + rect.tableStart);
|
|
92231
|
+
tr.delete(mapped, mapped + cell2.nodeSize);
|
|
91343
92232
|
}
|
|
91344
92233
|
}
|
|
91345
|
-
if (mergedPos == null || mergedCell == null)
|
|
91346
|
-
return true;
|
|
91347
|
-
}
|
|
92234
|
+
if (mergedPos == null || mergedCell == null) return true;
|
|
91348
92235
|
tr.setNodeMarkup(mergedPos + rect.tableStart, null, {
|
|
91349
|
-
...addColSpan(
|
|
91350
|
-
mergedCell.attrs,
|
|
91351
|
-
mergedCell.attrs.colspan,
|
|
91352
|
-
rect.right - rect.left - mergedCell.attrs.colspan
|
|
91353
|
-
),
|
|
92236
|
+
...addColSpan(mergedCell.attrs, mergedCell.attrs.colspan, rect.right - rect.left - mergedCell.attrs.colspan),
|
|
91354
92237
|
rowspan: rect.bottom - rect.top
|
|
91355
92238
|
});
|
|
91356
|
-
if (content2.size) {
|
|
92239
|
+
if (content2.size > 0) {
|
|
91357
92240
|
const end2 = mergedPos + 1 + mergedCell.content.size;
|
|
91358
92241
|
const start2 = isEmpty(mergedCell) ? mergedPos + 1 : end2;
|
|
91359
92242
|
tr.replaceWith(start2 + rect.tableStart, end2 + rect.tableStart, content2);
|
|
91360
92243
|
}
|
|
91361
|
-
tr.setSelection(
|
|
91362
|
-
new CellSelection(tr.doc.resolve(mergedPos + rect.tableStart))
|
|
91363
|
-
);
|
|
92244
|
+
tr.setSelection(new CellSelection(tr.doc.resolve(mergedPos + rect.tableStart)));
|
|
91364
92245
|
dispatch(tr);
|
|
91365
92246
|
}
|
|
91366
92247
|
return true;
|
|
@@ -91373,63 +92254,57 @@ ${l}
|
|
|
91373
92254
|
}
|
|
91374
92255
|
function splitCellWithType(getCellType2) {
|
|
91375
92256
|
return (state2, dispatch) => {
|
|
91376
|
-
var _a2;
|
|
91377
92257
|
const sel = state2.selection;
|
|
91378
92258
|
let cellNode;
|
|
91379
92259
|
let cellPos;
|
|
91380
92260
|
if (!(sel instanceof CellSelection)) {
|
|
92261
|
+
var _cellAround;
|
|
91381
92262
|
cellNode = cellWrapping$1(sel.$from);
|
|
91382
92263
|
if (!cellNode) return false;
|
|
91383
|
-
cellPos = (
|
|
92264
|
+
cellPos = (_cellAround = cellAround$1(sel.$from)) === null || _cellAround === void 0 ? void 0 : _cellAround.pos;
|
|
91384
92265
|
} else {
|
|
91385
92266
|
if (sel.$anchorCell.pos != sel.$headCell.pos) return false;
|
|
91386
92267
|
cellNode = sel.$anchorCell.nodeAfter;
|
|
91387
92268
|
cellPos = sel.$anchorCell.pos;
|
|
91388
92269
|
}
|
|
91389
|
-
if (cellNode == null || cellPos == null)
|
|
91390
|
-
|
|
91391
|
-
}
|
|
91392
|
-
if (cellNode.attrs.colspan == 1 && cellNode.attrs.rowspan == 1) {
|
|
91393
|
-
return false;
|
|
91394
|
-
}
|
|
92270
|
+
if (cellNode == null || cellPos == null) return false;
|
|
92271
|
+
if (cellNode.attrs.colspan == 1 && cellNode.attrs.rowspan == 1) return false;
|
|
91395
92272
|
if (dispatch) {
|
|
91396
92273
|
let baseAttrs = cellNode.attrs;
|
|
91397
92274
|
const attrs = [];
|
|
91398
92275
|
const colwidth = baseAttrs.colwidth;
|
|
91399
|
-
if (baseAttrs.rowspan > 1) baseAttrs = {
|
|
91400
|
-
|
|
92276
|
+
if (baseAttrs.rowspan > 1) baseAttrs = {
|
|
92277
|
+
...baseAttrs,
|
|
92278
|
+
rowspan: 1
|
|
92279
|
+
};
|
|
92280
|
+
if (baseAttrs.colspan > 1) baseAttrs = {
|
|
92281
|
+
...baseAttrs,
|
|
92282
|
+
colspan: 1
|
|
92283
|
+
};
|
|
91401
92284
|
const rect = selectedRect(state2), tr = state2.tr;
|
|
91402
|
-
for (let i2 = 0; i2 < rect.right - rect.left; i2++)
|
|
91403
|
-
|
|
91404
|
-
|
|
91405
|
-
|
|
91406
|
-
colwidth: colwidth && colwidth[i2] ? [colwidth[i2]] : null
|
|
91407
|
-
} : baseAttrs
|
|
91408
|
-
);
|
|
92285
|
+
for (let i2 = 0; i2 < rect.right - rect.left; i2++) attrs.push(colwidth ? {
|
|
92286
|
+
...baseAttrs,
|
|
92287
|
+
colwidth: colwidth && colwidth[i2] ? [colwidth[i2]] : null
|
|
92288
|
+
} : baseAttrs);
|
|
91409
92289
|
let lastCell;
|
|
91410
92290
|
for (let row2 = rect.top; row2 < rect.bottom; row2++) {
|
|
91411
92291
|
let pos = rect.map.positionAt(row2, rect.left, rect.table);
|
|
91412
92292
|
if (row2 == rect.top) pos += cellNode.nodeSize;
|
|
91413
92293
|
for (let col = rect.left, i2 = 0; col < rect.right; col++, i2++) {
|
|
91414
92294
|
if (col == rect.left && row2 == rect.top) continue;
|
|
91415
|
-
tr.insert(
|
|
91416
|
-
|
|
91417
|
-
|
|
91418
|
-
|
|
91419
|
-
|
|
91420
|
-
|
|
91421
|
-
|
|
91422
|
-
|
|
91423
|
-
|
|
91424
|
-
|
|
91425
|
-
|
|
91426
|
-
|
|
91427
|
-
|
|
91428
|
-
new CellSelection(
|
|
91429
|
-
tr.doc.resolve(sel.$anchorCell.pos),
|
|
91430
|
-
lastCell ? tr.doc.resolve(lastCell) : void 0
|
|
91431
|
-
)
|
|
91432
|
-
);
|
|
92295
|
+
tr.insert(lastCell = tr.mapping.map(pos + rect.tableStart, 1), getCellType2({
|
|
92296
|
+
node: cellNode,
|
|
92297
|
+
row: row2,
|
|
92298
|
+
col
|
|
92299
|
+
}).createAndFill(attrs[i2]));
|
|
92300
|
+
}
|
|
92301
|
+
}
|
|
92302
|
+
tr.setNodeMarkup(cellPos, getCellType2({
|
|
92303
|
+
node: cellNode,
|
|
92304
|
+
row: rect.top,
|
|
92305
|
+
col: rect.left
|
|
92306
|
+
}), attrs[0]);
|
|
92307
|
+
if (sel instanceof CellSelection) tr.setSelection(new CellSelection(tr.doc.resolve(sel.$anchorCell.pos), lastCell ? tr.doc.resolve(lastCell) : void 0));
|
|
91433
92308
|
dispatch(tr);
|
|
91434
92309
|
}
|
|
91435
92310
|
return true;
|
|
@@ -91442,19 +92317,16 @@ ${l}
|
|
|
91442
92317
|
if ($cell.nodeAfter.attrs[name] === value) return false;
|
|
91443
92318
|
if (dispatch) {
|
|
91444
92319
|
const tr = state2.tr;
|
|
91445
|
-
if (state2.selection instanceof CellSelection)
|
|
91446
|
-
|
|
91447
|
-
|
|
91448
|
-
tr.setNodeMarkup(pos, null, {
|
|
91449
|
-
...node2.attrs,
|
|
91450
|
-
[name]: value
|
|
91451
|
-
});
|
|
91452
|
-
});
|
|
91453
|
-
else
|
|
91454
|
-
tr.setNodeMarkup($cell.pos, null, {
|
|
91455
|
-
...$cell.nodeAfter.attrs,
|
|
92320
|
+
if (state2.selection instanceof CellSelection) state2.selection.forEachCell((node2, pos) => {
|
|
92321
|
+
if (node2.attrs[name] !== value) tr.setNodeMarkup(pos, null, {
|
|
92322
|
+
...node2.attrs,
|
|
91456
92323
|
[name]: value
|
|
91457
92324
|
});
|
|
92325
|
+
});
|
|
92326
|
+
else tr.setNodeMarkup($cell.pos, null, {
|
|
92327
|
+
...$cell.nodeAfter.attrs,
|
|
92328
|
+
[name]: value
|
|
92329
|
+
});
|
|
91458
92330
|
dispatch(tr);
|
|
91459
92331
|
}
|
|
91460
92332
|
return true;
|
|
@@ -91466,34 +92338,20 @@ ${l}
|
|
|
91466
92338
|
if (dispatch) {
|
|
91467
92339
|
const types2 = tableNodeTypes(state2.schema);
|
|
91468
92340
|
const rect = selectedRect(state2), tr = state2.tr;
|
|
91469
|
-
const cells = rect.map.cellsInRect(
|
|
91470
|
-
|
|
91471
|
-
|
|
91472
|
-
|
|
91473
|
-
|
|
91474
|
-
|
|
91475
|
-
|
|
91476
|
-
|
|
91477
|
-
|
|
91478
|
-
|
|
91479
|
-
|
|
91480
|
-
} : rect
|
|
91481
|
-
);
|
|
92341
|
+
const cells = rect.map.cellsInRect(type2 == "column" ? {
|
|
92342
|
+
left: rect.left,
|
|
92343
|
+
top: 0,
|
|
92344
|
+
right: rect.right,
|
|
92345
|
+
bottom: rect.map.height
|
|
92346
|
+
} : type2 == "row" ? {
|
|
92347
|
+
left: 0,
|
|
92348
|
+
top: rect.top,
|
|
92349
|
+
right: rect.map.width,
|
|
92350
|
+
bottom: rect.bottom
|
|
92351
|
+
} : rect);
|
|
91482
92352
|
const nodes = cells.map((pos) => rect.table.nodeAt(pos));
|
|
91483
|
-
for (let i2 = 0; i2 < cells.length; i2++)
|
|
91484
|
-
|
|
91485
|
-
tr.setNodeMarkup(
|
|
91486
|
-
rect.tableStart + cells[i2],
|
|
91487
|
-
types2.cell,
|
|
91488
|
-
nodes[i2].attrs
|
|
91489
|
-
);
|
|
91490
|
-
if (tr.steps.length == 0)
|
|
91491
|
-
for (let i2 = 0; i2 < cells.length; i2++)
|
|
91492
|
-
tr.setNodeMarkup(
|
|
91493
|
-
rect.tableStart + cells[i2],
|
|
91494
|
-
types2.header_cell,
|
|
91495
|
-
nodes[i2].attrs
|
|
91496
|
-
);
|
|
92353
|
+
for (let i2 = 0; i2 < cells.length; i2++) if (nodes[i2].type == types2.header_cell) tr.setNodeMarkup(rect.tableStart + cells[i2], types2.cell, nodes[i2].attrs);
|
|
92354
|
+
if (tr.steps.length === 0) for (let i2 = 0; i2 < cells.length; i2++) tr.setNodeMarkup(rect.tableStart + cells[i2], types2.header_cell, nodes[i2].attrs);
|
|
91497
92355
|
dispatch(tr);
|
|
91498
92356
|
}
|
|
91499
92357
|
return true;
|
|
@@ -91508,9 +92366,7 @@ ${l}
|
|
|
91508
92366
|
});
|
|
91509
92367
|
for (let i2 = 0; i2 < cellPositions.length; i2++) {
|
|
91510
92368
|
const cell2 = rect.table.nodeAt(cellPositions[i2]);
|
|
91511
|
-
if (cell2 && cell2.type !== types2.header_cell)
|
|
91512
|
-
return false;
|
|
91513
|
-
}
|
|
92369
|
+
if (cell2 && cell2.type !== types2.header_cell) return false;
|
|
91514
92370
|
}
|
|
91515
92371
|
return true;
|
|
91516
92372
|
}
|
|
@@ -91523,13 +92379,8 @@ ${l}
|
|
|
91523
92379
|
const types2 = tableNodeTypes(state2.schema);
|
|
91524
92380
|
const rect = selectedRect(state2), tr = state2.tr;
|
|
91525
92381
|
const isHeaderRowEnabled = isHeaderEnabledByType("row", rect, types2);
|
|
91526
|
-
const isHeaderColumnEnabled = isHeaderEnabledByType(
|
|
91527
|
-
|
|
91528
|
-
rect,
|
|
91529
|
-
types2
|
|
91530
|
-
);
|
|
91531
|
-
const isHeaderEnabled = type2 === "column" ? isHeaderRowEnabled : type2 === "row" ? isHeaderColumnEnabled : false;
|
|
91532
|
-
const selectionStartsAt = isHeaderEnabled ? 1 : 0;
|
|
92382
|
+
const isHeaderColumnEnabled = isHeaderEnabledByType("column", rect, types2);
|
|
92383
|
+
const selectionStartsAt = (type2 === "column" ? isHeaderRowEnabled : type2 === "row" ? isHeaderColumnEnabled : false) ? 1 : 0;
|
|
91533
92384
|
const cellsRect = type2 == "column" ? {
|
|
91534
92385
|
left: 0,
|
|
91535
92386
|
top: selectionStartsAt,
|
|
@@ -91545,24 +92396,16 @@ ${l}
|
|
|
91545
92396
|
rect.map.cellsInRect(cellsRect).forEach((relativeCellPos) => {
|
|
91546
92397
|
const cellPos = relativeCellPos + rect.tableStart;
|
|
91547
92398
|
const cell2 = tr.doc.nodeAt(cellPos);
|
|
91548
|
-
if (cell2)
|
|
91549
|
-
tr.setNodeMarkup(cellPos, newType, cell2.attrs);
|
|
91550
|
-
}
|
|
92399
|
+
if (cell2) tr.setNodeMarkup(cellPos, newType, cell2.attrs);
|
|
91551
92400
|
});
|
|
91552
92401
|
dispatch(tr);
|
|
91553
92402
|
}
|
|
91554
92403
|
return true;
|
|
91555
92404
|
};
|
|
91556
92405
|
}
|
|
91557
|
-
toggleHeader("row", {
|
|
91558
|
-
|
|
91559
|
-
});
|
|
91560
|
-
toggleHeader("column", {
|
|
91561
|
-
useDeprecatedLogic: true
|
|
91562
|
-
});
|
|
91563
|
-
var toggleHeaderCell = toggleHeader("cell", {
|
|
91564
|
-
useDeprecatedLogic: true
|
|
91565
|
-
});
|
|
92406
|
+
toggleHeader("row", { useDeprecatedLogic: true });
|
|
92407
|
+
toggleHeader("column", { useDeprecatedLogic: true });
|
|
92408
|
+
const toggleHeaderCell = toggleHeader("cell", { useDeprecatedLogic: true });
|
|
91566
92409
|
function findNextCell($cell, dir) {
|
|
91567
92410
|
if (dir < 0) {
|
|
91568
92411
|
const before = $cell.nodeBefore;
|
|
@@ -91570,15 +92413,11 @@ ${l}
|
|
|
91570
92413
|
for (let row2 = $cell.index(-1) - 1, rowEnd = $cell.before(); row2 >= 0; row2--) {
|
|
91571
92414
|
const rowNode = $cell.node(-1).child(row2);
|
|
91572
92415
|
const lastChild = rowNode.lastChild;
|
|
91573
|
-
if (lastChild)
|
|
91574
|
-
return rowEnd - 1 - lastChild.nodeSize;
|
|
91575
|
-
}
|
|
92416
|
+
if (lastChild) return rowEnd - 1 - lastChild.nodeSize;
|
|
91576
92417
|
rowEnd -= rowNode.nodeSize;
|
|
91577
92418
|
}
|
|
91578
92419
|
} else {
|
|
91579
|
-
if ($cell.index() < $cell.parent.childCount - 1)
|
|
91580
|
-
return $cell.pos + $cell.nodeAfter.nodeSize;
|
|
91581
|
-
}
|
|
92420
|
+
if ($cell.index() < $cell.parent.childCount - 1) return $cell.pos + $cell.nodeAfter.nodeSize;
|
|
91582
92421
|
const table2 = $cell.node(-1);
|
|
91583
92422
|
for (let row2 = $cell.indexAfter(-1), rowStart = $cell.after(); row2 < table2.childCount; row2++) {
|
|
91584
92423
|
const rowNode = table2.child(row2);
|
|
@@ -91595,24 +92434,16 @@ ${l}
|
|
|
91595
92434
|
if (cell2 == null) return false;
|
|
91596
92435
|
if (dispatch) {
|
|
91597
92436
|
const $cell = state2.doc.resolve(cell2);
|
|
91598
|
-
dispatch(
|
|
91599
|
-
state2.tr.setSelection(TextSelection$1.between($cell, moveCellForward($cell))).scrollIntoView()
|
|
91600
|
-
);
|
|
92437
|
+
dispatch(state2.tr.setSelection(TextSelection$1.between($cell, moveCellForward($cell))).scrollIntoView());
|
|
91601
92438
|
}
|
|
91602
92439
|
return true;
|
|
91603
92440
|
};
|
|
91604
92441
|
}
|
|
91605
92442
|
function deleteTable(state2, dispatch) {
|
|
91606
92443
|
const $pos = state2.selection.$anchor;
|
|
91607
|
-
for (let d2 = $pos.depth; d2 > 0; d2--) {
|
|
91608
|
-
|
|
91609
|
-
|
|
91610
|
-
if (dispatch)
|
|
91611
|
-
dispatch(
|
|
91612
|
-
state2.tr.delete($pos.before(d2), $pos.after(d2)).scrollIntoView()
|
|
91613
|
-
);
|
|
91614
|
-
return true;
|
|
91615
|
-
}
|
|
92444
|
+
for (let d2 = $pos.depth; d2 > 0; d2--) if ($pos.node(d2).type.spec.tableRole == "table") {
|
|
92445
|
+
if (dispatch) dispatch(state2.tr.delete($pos.before(d2), $pos.after(d2)).scrollIntoView());
|
|
92446
|
+
return true;
|
|
91616
92447
|
}
|
|
91617
92448
|
return false;
|
|
91618
92449
|
}
|
|
@@ -91623,19 +92454,14 @@ ${l}
|
|
|
91623
92454
|
const tr = state2.tr;
|
|
91624
92455
|
const baseContent = tableNodeTypes(state2.schema).cell.createAndFill().content;
|
|
91625
92456
|
sel.forEachCell((cell2, pos) => {
|
|
91626
|
-
if (!cell2.content.eq(baseContent))
|
|
91627
|
-
tr.replace(
|
|
91628
|
-
tr.mapping.map(pos + 1),
|
|
91629
|
-
tr.mapping.map(pos + cell2.nodeSize - 1),
|
|
91630
|
-
new Slice(baseContent, 0, 0)
|
|
91631
|
-
);
|
|
92457
|
+
if (!cell2.content.eq(baseContent)) tr.replace(tr.mapping.map(pos + 1), tr.mapping.map(pos + cell2.nodeSize - 1), new Slice(baseContent, 0, 0));
|
|
91632
92458
|
});
|
|
91633
92459
|
if (tr.docChanged) dispatch(tr);
|
|
91634
92460
|
}
|
|
91635
92461
|
return true;
|
|
91636
92462
|
}
|
|
91637
92463
|
function pastedCells(slice2) {
|
|
91638
|
-
if (
|
|
92464
|
+
if (slice2.size === 0) return null;
|
|
91639
92465
|
let { content: content2, openStart, openEnd } = slice2;
|
|
91640
92466
|
while (content2.childCount == 1 && (openStart > 0 && openEnd > 0 || content2.child(0).type.spec.tableRole == "table")) {
|
|
91641
92467
|
openStart--;
|
|
@@ -91645,28 +92471,15 @@ ${l}
|
|
|
91645
92471
|
const first2 = content2.child(0);
|
|
91646
92472
|
const role = first2.type.spec.tableRole;
|
|
91647
92473
|
const schema = first2.type.schema, rows = [];
|
|
91648
|
-
if (role == "row") {
|
|
91649
|
-
|
|
91650
|
-
|
|
91651
|
-
|
|
91652
|
-
|
|
91653
|
-
|
|
91654
|
-
|
|
91655
|
-
|
|
91656
|
-
|
|
91657
|
-
).content;
|
|
91658
|
-
rows.push(cells);
|
|
91659
|
-
}
|
|
91660
|
-
} else if (role == "cell" || role == "header_cell") {
|
|
91661
|
-
rows.push(
|
|
91662
|
-
openStart || openEnd ? fitSlice(
|
|
91663
|
-
tableNodeTypes(schema).row,
|
|
91664
|
-
new Slice(content2, openStart, openEnd)
|
|
91665
|
-
).content : content2
|
|
91666
|
-
);
|
|
91667
|
-
} else {
|
|
91668
|
-
return null;
|
|
91669
|
-
}
|
|
92474
|
+
if (role == "row") for (let i2 = 0; i2 < content2.childCount; i2++) {
|
|
92475
|
+
let cells = content2.child(i2).content;
|
|
92476
|
+
const left2 = i2 ? 0 : Math.max(0, openStart - 1);
|
|
92477
|
+
const right2 = i2 < content2.childCount - 1 ? 0 : Math.max(0, openEnd - 1);
|
|
92478
|
+
if (left2 || right2) cells = fitSlice(tableNodeTypes(schema).row, new Slice(cells, left2, right2)).content;
|
|
92479
|
+
rows.push(cells);
|
|
92480
|
+
}
|
|
92481
|
+
else if (role == "cell" || role == "header_cell") rows.push(openStart || openEnd ? fitSlice(tableNodeTypes(schema).row, new Slice(content2, openStart, openEnd)).content : content2);
|
|
92482
|
+
else return null;
|
|
91670
92483
|
return ensureRectangular(schema, rows);
|
|
91671
92484
|
}
|
|
91672
92485
|
function ensureRectangular(schema, rows) {
|
|
@@ -91675,8 +92488,7 @@ ${l}
|
|
|
91675
92488
|
const row2 = rows[i2];
|
|
91676
92489
|
for (let j2 = row2.childCount - 1; j2 >= 0; j2--) {
|
|
91677
92490
|
const { rowspan, colspan } = row2.child(j2).attrs;
|
|
91678
|
-
for (let r2 = i2; r2 < i2 + rowspan; r2++)
|
|
91679
|
-
widths[r2] = (widths[r2] || 0) + colspan;
|
|
92491
|
+
for (let r2 = i2; r2 < i2 + rowspan; r2++) widths[r2] = (widths[r2] || 0) + colspan;
|
|
91680
92492
|
}
|
|
91681
92493
|
}
|
|
91682
92494
|
let width = 0;
|
|
@@ -91686,18 +92498,19 @@ ${l}
|
|
|
91686
92498
|
if (widths[r2] < width) {
|
|
91687
92499
|
const empty2 = tableNodeTypes(schema).cell.createAndFill();
|
|
91688
92500
|
const cells = [];
|
|
91689
|
-
for (let i2 = widths[r2]; i2 < width; i2++)
|
|
91690
|
-
cells.push(empty2);
|
|
91691
|
-
}
|
|
92501
|
+
for (let i2 = widths[r2]; i2 < width; i2++) cells.push(empty2);
|
|
91692
92502
|
rows[r2] = rows[r2].append(Fragment$1.from(cells));
|
|
91693
92503
|
}
|
|
91694
92504
|
}
|
|
91695
|
-
return {
|
|
92505
|
+
return {
|
|
92506
|
+
height: rows.length,
|
|
92507
|
+
width,
|
|
92508
|
+
rows
|
|
92509
|
+
};
|
|
91696
92510
|
}
|
|
91697
92511
|
function fitSlice(nodeType, slice2) {
|
|
91698
92512
|
const node2 = nodeType.createAndFill();
|
|
91699
|
-
|
|
91700
|
-
return tr.doc;
|
|
92513
|
+
return new Transform(node2).replace(0, node2.content.size, slice2).doc;
|
|
91701
92514
|
}
|
|
91702
92515
|
function clipCells({ width, height, rows }, newWidth, newHeight) {
|
|
91703
92516
|
if (width != newWidth) {
|
|
@@ -91707,19 +92520,10 @@ ${l}
|
|
|
91707
92520
|
const frag = rows[row2], cells = [];
|
|
91708
92521
|
for (let col = added[row2] || 0, i2 = 0; col < newWidth; i2++) {
|
|
91709
92522
|
let cell2 = frag.child(i2 % frag.childCount);
|
|
91710
|
-
if (col + cell2.attrs.colspan > newWidth)
|
|
91711
|
-
cell2 = cell2.type.createChecked(
|
|
91712
|
-
removeColSpan(
|
|
91713
|
-
cell2.attrs,
|
|
91714
|
-
cell2.attrs.colspan,
|
|
91715
|
-
col + cell2.attrs.colspan - newWidth
|
|
91716
|
-
),
|
|
91717
|
-
cell2.content
|
|
91718
|
-
);
|
|
92523
|
+
if (col + cell2.attrs.colspan > newWidth) cell2 = cell2.type.createChecked(removeColSpan(cell2.attrs, cell2.attrs.colspan, col + cell2.attrs.colspan - newWidth), cell2.content);
|
|
91719
92524
|
cells.push(cell2);
|
|
91720
92525
|
col += cell2.attrs.colspan;
|
|
91721
|
-
for (let j2 = 1; j2 < cell2.attrs.rowspan; j2++)
|
|
91722
|
-
added[row2 + j2] = (added[row2 + j2] || 0) + cell2.attrs.colspan;
|
|
92526
|
+
for (let j2 = 1; j2 < cell2.attrs.rowspan; j2++) added[row2 + j2] = (added[row2 + j2] || 0) + cell2.attrs.colspan;
|
|
91723
92527
|
}
|
|
91724
92528
|
newRows.push(Fragment$1.from(cells));
|
|
91725
92529
|
}
|
|
@@ -91732,14 +92536,10 @@ ${l}
|
|
|
91732
92536
|
const cells = [], source = rows[i2 % height];
|
|
91733
92537
|
for (let j2 = 0; j2 < source.childCount; j2++) {
|
|
91734
92538
|
let cell2 = source.child(j2);
|
|
91735
|
-
if (row2 + cell2.attrs.rowspan > newHeight)
|
|
91736
|
-
cell2
|
|
91737
|
-
|
|
91738
|
-
|
|
91739
|
-
rowspan: Math.max(1, newHeight - cell2.attrs.rowspan)
|
|
91740
|
-
},
|
|
91741
|
-
cell2.content
|
|
91742
|
-
);
|
|
92539
|
+
if (row2 + cell2.attrs.rowspan > newHeight) cell2 = cell2.type.create({
|
|
92540
|
+
...cell2.attrs,
|
|
92541
|
+
rowspan: Math.max(1, newHeight - cell2.attrs.rowspan)
|
|
92542
|
+
}, cell2.content);
|
|
91743
92543
|
cells.push(cell2);
|
|
91744
92544
|
}
|
|
91745
92545
|
newRows.push(Fragment$1.from(cells));
|
|
@@ -91747,33 +92547,32 @@ ${l}
|
|
|
91747
92547
|
rows = newRows;
|
|
91748
92548
|
height = newHeight;
|
|
91749
92549
|
}
|
|
91750
|
-
return {
|
|
92550
|
+
return {
|
|
92551
|
+
width,
|
|
92552
|
+
height,
|
|
92553
|
+
rows
|
|
92554
|
+
};
|
|
91751
92555
|
}
|
|
91752
92556
|
function growTable(tr, map2, table2, start2, width, height, mapFrom) {
|
|
91753
92557
|
const schema = tr.doc.type.schema;
|
|
91754
92558
|
const types2 = tableNodeTypes(schema);
|
|
91755
92559
|
let empty2;
|
|
91756
92560
|
let emptyHead;
|
|
91757
|
-
if (width > map2.width) {
|
|
91758
|
-
|
|
91759
|
-
|
|
91760
|
-
|
|
91761
|
-
|
|
91762
|
-
|
|
91763
|
-
|
|
91764
|
-
|
|
91765
|
-
|
|
91766
|
-
for (let i2 = map2.width; i2 < width; i2++) cells.push(add);
|
|
91767
|
-
tr.insert(tr.mapping.slice(mapFrom).map(rowEnd - 1 + start2), cells);
|
|
91768
|
-
}
|
|
92561
|
+
if (width > map2.width) for (let row2 = 0, rowEnd = 0; row2 < map2.height; row2++) {
|
|
92562
|
+
const rowNode = table2.child(row2);
|
|
92563
|
+
rowEnd += rowNode.nodeSize;
|
|
92564
|
+
const cells = [];
|
|
92565
|
+
let add;
|
|
92566
|
+
if (rowNode.lastChild == null || rowNode.lastChild.type == types2.cell) add = empty2 || (empty2 = types2.cell.createAndFill());
|
|
92567
|
+
else add = emptyHead || (emptyHead = types2.header_cell.createAndFill());
|
|
92568
|
+
for (let i2 = map2.width; i2 < width; i2++) cells.push(add);
|
|
92569
|
+
tr.insert(tr.mapping.slice(mapFrom).map(rowEnd - 1 + start2), cells);
|
|
91769
92570
|
}
|
|
91770
92571
|
if (height > map2.height) {
|
|
91771
92572
|
const cells = [];
|
|
91772
|
-
for (let i2 = 0,
|
|
91773
|
-
const header = i2 >= map2.width ? false : table2.nodeAt(map2.map[
|
|
91774
|
-
cells.push(
|
|
91775
|
-
header ? emptyHead || (emptyHead = types2.header_cell.createAndFill()) : empty2 || (empty2 = types2.cell.createAndFill())
|
|
91776
|
-
);
|
|
92573
|
+
for (let i2 = 0, start$1 = (map2.height - 1) * map2.width; i2 < Math.max(map2.width, width); i2++) {
|
|
92574
|
+
const header = i2 >= map2.width ? false : table2.nodeAt(map2.map[start$1 + i2]).type == types2.header_cell;
|
|
92575
|
+
cells.push(header ? emptyHead || (emptyHead = types2.header_cell.createAndFill()) : empty2 || (empty2 = types2.cell.createAndFill()));
|
|
91777
92576
|
}
|
|
91778
92577
|
const emptyRow = types2.row.create(null, Fragment$1.from(cells)), rows = [];
|
|
91779
92578
|
for (let i2 = map2.height; i2 < height; i2++) rows.push(emptyRow);
|
|
@@ -91794,13 +92593,10 @@ ${l}
|
|
|
91794
92593
|
...cell2.attrs,
|
|
91795
92594
|
rowspan: top2 - cellTop
|
|
91796
92595
|
});
|
|
91797
|
-
tr.insert(
|
|
91798
|
-
|
|
91799
|
-
cell2.
|
|
91800
|
-
|
|
91801
|
-
rowspan: cellTop + cell2.attrs.rowspan - top2
|
|
91802
|
-
})
|
|
91803
|
-
);
|
|
92596
|
+
tr.insert(tr.mapping.slice(mapFrom).map(map2.positionAt(top2, cellLeft, table2)), cell2.type.createAndFill({
|
|
92597
|
+
...cell2.attrs,
|
|
92598
|
+
rowspan: cellTop + cell2.attrs.rowspan - top2
|
|
92599
|
+
}));
|
|
91804
92600
|
col += cell2.attrs.colspan - 1;
|
|
91805
92601
|
}
|
|
91806
92602
|
}
|
|
@@ -91816,21 +92612,8 @@ ${l}
|
|
|
91816
92612
|
const cell2 = table2.nodeAt(pos);
|
|
91817
92613
|
const cellLeft = map2.colCount(pos);
|
|
91818
92614
|
const updatePos = tr.mapping.slice(mapFrom).map(pos + start2);
|
|
91819
|
-
tr.setNodeMarkup(
|
|
91820
|
-
|
|
91821
|
-
null,
|
|
91822
|
-
removeColSpan(
|
|
91823
|
-
cell2.attrs,
|
|
91824
|
-
left2 - cellLeft,
|
|
91825
|
-
cell2.attrs.colspan - (left2 - cellLeft)
|
|
91826
|
-
)
|
|
91827
|
-
);
|
|
91828
|
-
tr.insert(
|
|
91829
|
-
updatePos + cell2.nodeSize,
|
|
91830
|
-
cell2.type.createAndFill(
|
|
91831
|
-
removeColSpan(cell2.attrs, 0, left2 - cellLeft)
|
|
91832
|
-
)
|
|
91833
|
-
);
|
|
92615
|
+
tr.setNodeMarkup(updatePos, null, removeColSpan(cell2.attrs, left2 - cellLeft, cell2.attrs.colspan - (left2 - cellLeft)));
|
|
92616
|
+
tr.insert(updatePos + cell2.nodeSize, cell2.type.createAndFill(removeColSpan(cell2.attrs, 0, left2 - cellLeft)));
|
|
91834
92617
|
row2 += cell2.attrs.rowspan - 1;
|
|
91835
92618
|
}
|
|
91836
92619
|
}
|
|
@@ -91838,9 +92621,7 @@ ${l}
|
|
|
91838
92621
|
}
|
|
91839
92622
|
function insertCells(state2, dispatch, tableStart, rect, cells) {
|
|
91840
92623
|
let table2 = tableStart ? state2.doc.nodeAt(tableStart - 1) : state2.doc;
|
|
91841
|
-
if (!table2)
|
|
91842
|
-
throw new Error("No table found");
|
|
91843
|
-
}
|
|
92624
|
+
if (!table2) throw new Error("No table found");
|
|
91844
92625
|
let map2 = TableMap.get(table2);
|
|
91845
92626
|
const { top: top2, left: left2 } = rect;
|
|
91846
92627
|
const right2 = left2 + cells.width, bottom2 = top2 + cells.height;
|
|
@@ -91848,39 +92629,24 @@ ${l}
|
|
|
91848
92629
|
let mapFrom = 0;
|
|
91849
92630
|
function recomp() {
|
|
91850
92631
|
table2 = tableStart ? tr.doc.nodeAt(tableStart - 1) : tr.doc;
|
|
91851
|
-
if (!table2)
|
|
91852
|
-
throw new Error("No table found");
|
|
91853
|
-
}
|
|
92632
|
+
if (!table2) throw new Error("No table found");
|
|
91854
92633
|
map2 = TableMap.get(table2);
|
|
91855
92634
|
mapFrom = tr.mapping.maps.length;
|
|
91856
92635
|
}
|
|
91857
92636
|
if (growTable(tr, map2, table2, tableStart, right2, bottom2, mapFrom)) recomp();
|
|
91858
|
-
if (isolateHorizontal(tr, map2, table2, tableStart, left2, right2, top2, mapFrom))
|
|
91859
|
-
|
|
91860
|
-
if (
|
|
91861
|
-
|
|
91862
|
-
if (isolateVertical(tr, map2, table2, tableStart, top2, bottom2, left2, mapFrom))
|
|
91863
|
-
recomp();
|
|
91864
|
-
if (isolateVertical(tr, map2, table2, tableStart, top2, bottom2, right2, mapFrom))
|
|
91865
|
-
recomp();
|
|
92637
|
+
if (isolateHorizontal(tr, map2, table2, tableStart, left2, right2, top2, mapFrom)) recomp();
|
|
92638
|
+
if (isolateHorizontal(tr, map2, table2, tableStart, left2, right2, bottom2, mapFrom)) recomp();
|
|
92639
|
+
if (isolateVertical(tr, map2, table2, tableStart, top2, bottom2, left2, mapFrom)) recomp();
|
|
92640
|
+
if (isolateVertical(tr, map2, table2, tableStart, top2, bottom2, right2, mapFrom)) recomp();
|
|
91866
92641
|
for (let row2 = top2; row2 < bottom2; row2++) {
|
|
91867
92642
|
const from2 = map2.positionAt(row2, left2, table2), to = map2.positionAt(row2, right2, table2);
|
|
91868
|
-
tr.replace(
|
|
91869
|
-
tr.mapping.slice(mapFrom).map(from2 + tableStart),
|
|
91870
|
-
tr.mapping.slice(mapFrom).map(to + tableStart),
|
|
91871
|
-
new Slice(cells.rows[row2 - top2], 0, 0)
|
|
91872
|
-
);
|
|
92643
|
+
tr.replace(tr.mapping.slice(mapFrom).map(from2 + tableStart), tr.mapping.slice(mapFrom).map(to + tableStart), new Slice(cells.rows[row2 - top2], 0, 0));
|
|
91873
92644
|
}
|
|
91874
92645
|
recomp();
|
|
91875
|
-
tr.setSelection(
|
|
91876
|
-
new CellSelection(
|
|
91877
|
-
tr.doc.resolve(tableStart + map2.positionAt(top2, left2, table2)),
|
|
91878
|
-
tr.doc.resolve(tableStart + map2.positionAt(bottom2 - 1, right2 - 1, table2))
|
|
91879
|
-
)
|
|
91880
|
-
);
|
|
92646
|
+
tr.setSelection(new CellSelection(tr.doc.resolve(tableStart + map2.positionAt(top2, left2, table2)), tr.doc.resolve(tableStart + map2.positionAt(bottom2 - 1, right2 - 1, table2))));
|
|
91881
92647
|
dispatch(tr);
|
|
91882
92648
|
}
|
|
91883
|
-
|
|
92649
|
+
const handleKeyDown = keydownHandler({
|
|
91884
92650
|
ArrowLeft: arrow$2("horiz", -1),
|
|
91885
92651
|
ArrowRight: arrow$2("horiz", 1),
|
|
91886
92652
|
ArrowUp: arrow$2("vert", -1),
|
|
@@ -91903,29 +92669,17 @@ ${l}
|
|
|
91903
92669
|
return (state2, dispatch, view) => {
|
|
91904
92670
|
if (!view) return false;
|
|
91905
92671
|
const sel = state2.selection;
|
|
91906
|
-
if (sel instanceof CellSelection)
|
|
91907
|
-
return maybeSetSelection(
|
|
91908
|
-
state2,
|
|
91909
|
-
dispatch,
|
|
91910
|
-
Selection.near(sel.$headCell, dir)
|
|
91911
|
-
);
|
|
91912
|
-
}
|
|
92672
|
+
if (sel instanceof CellSelection) return maybeSetSelection(state2, dispatch, Selection.near(sel.$headCell, dir));
|
|
91913
92673
|
if (axis != "horiz" && !sel.empty) return false;
|
|
91914
92674
|
const end2 = atEndOfCell(view, axis, dir);
|
|
91915
92675
|
if (end2 == null) return false;
|
|
91916
|
-
if (axis == "horiz")
|
|
91917
|
-
|
|
91918
|
-
state2,
|
|
91919
|
-
dispatch,
|
|
91920
|
-
Selection.near(state2.doc.resolve(sel.head + dir), dir)
|
|
91921
|
-
);
|
|
91922
|
-
} else {
|
|
92676
|
+
if (axis == "horiz") return maybeSetSelection(state2, dispatch, Selection.near(state2.doc.resolve(sel.head + dir), dir));
|
|
92677
|
+
else {
|
|
91923
92678
|
const $cell = state2.doc.resolve(end2);
|
|
91924
92679
|
const $next = nextCell($cell, axis, dir);
|
|
91925
92680
|
let newSel;
|
|
91926
92681
|
if ($next) newSel = Selection.near($next, 1);
|
|
91927
|
-
else if (dir < 0)
|
|
91928
|
-
newSel = Selection.near(state2.doc.resolve($cell.before(-1)), -1);
|
|
92682
|
+
else if (dir < 0) newSel = Selection.near(state2.doc.resolve($cell.before(-1)), -1);
|
|
91929
92683
|
else newSel = Selection.near(state2.doc.resolve($cell.after(-1)), 1);
|
|
91930
92684
|
return maybeSetSelection(state2, dispatch, newSel);
|
|
91931
92685
|
}
|
|
@@ -91936,20 +92690,15 @@ ${l}
|
|
|
91936
92690
|
if (!view) return false;
|
|
91937
92691
|
const sel = state2.selection;
|
|
91938
92692
|
let cellSel;
|
|
91939
|
-
if (sel instanceof CellSelection)
|
|
91940
|
-
|
|
91941
|
-
} else {
|
|
92693
|
+
if (sel instanceof CellSelection) cellSel = sel;
|
|
92694
|
+
else {
|
|
91942
92695
|
const end2 = atEndOfCell(view, axis, dir);
|
|
91943
92696
|
if (end2 == null) return false;
|
|
91944
92697
|
cellSel = new CellSelection(state2.doc.resolve(end2));
|
|
91945
92698
|
}
|
|
91946
92699
|
const $head = nextCell(cellSel.$headCell, axis, dir);
|
|
91947
92700
|
if (!$head) return false;
|
|
91948
|
-
return maybeSetSelection(
|
|
91949
|
-
state2,
|
|
91950
|
-
dispatch,
|
|
91951
|
-
new CellSelection(cellSel.$anchorCell, $head)
|
|
91952
|
-
);
|
|
92701
|
+
return maybeSetSelection(state2, dispatch, new CellSelection(cellSel.$anchorCell, $head));
|
|
91953
92702
|
};
|
|
91954
92703
|
}
|
|
91955
92704
|
function handleTripleClick(view, pos) {
|
|
@@ -91963,65 +92712,45 @@ ${l}
|
|
|
91963
92712
|
let cells = pastedCells(slice2);
|
|
91964
92713
|
const sel = view.state.selection;
|
|
91965
92714
|
if (sel instanceof CellSelection) {
|
|
91966
|
-
if (!cells)
|
|
91967
|
-
|
|
91968
|
-
|
|
91969
|
-
|
|
91970
|
-
|
|
91971
|
-
Fragment$1.from(
|
|
91972
|
-
fitSlice(tableNodeTypes(view.state.schema).cell, slice2)
|
|
91973
|
-
)
|
|
91974
|
-
]
|
|
91975
|
-
};
|
|
92715
|
+
if (!cells) cells = {
|
|
92716
|
+
width: 1,
|
|
92717
|
+
height: 1,
|
|
92718
|
+
rows: [Fragment$1.from(fitSlice(tableNodeTypes(view.state.schema).cell, slice2))]
|
|
92719
|
+
};
|
|
91976
92720
|
const table2 = sel.$anchorCell.node(-1);
|
|
91977
92721
|
const start2 = sel.$anchorCell.start(-1);
|
|
91978
|
-
const rect = TableMap.get(table2).rectBetween(
|
|
91979
|
-
sel.$anchorCell.pos - start2,
|
|
91980
|
-
sel.$headCell.pos - start2
|
|
91981
|
-
);
|
|
92722
|
+
const rect = TableMap.get(table2).rectBetween(sel.$anchorCell.pos - start2, sel.$headCell.pos - start2);
|
|
91982
92723
|
cells = clipCells(cells, rect.right - rect.left, rect.bottom - rect.top);
|
|
91983
92724
|
insertCells(view.state, view.dispatch, start2, rect, cells);
|
|
91984
92725
|
return true;
|
|
91985
92726
|
} else if (cells) {
|
|
91986
92727
|
const $cell = selectionCell(view.state);
|
|
91987
92728
|
const start2 = $cell.start(-1);
|
|
91988
|
-
insertCells(
|
|
91989
|
-
view.state,
|
|
91990
|
-
view.dispatch,
|
|
91991
|
-
start2,
|
|
91992
|
-
TableMap.get($cell.node(-1)).findCell($cell.pos - start2),
|
|
91993
|
-
cells
|
|
91994
|
-
);
|
|
92729
|
+
insertCells(view.state, view.dispatch, start2, TableMap.get($cell.node(-1)).findCell($cell.pos - start2), cells);
|
|
91995
92730
|
return true;
|
|
91996
|
-
} else
|
|
91997
|
-
return false;
|
|
91998
|
-
}
|
|
92731
|
+
} else return false;
|
|
91999
92732
|
}
|
|
92000
92733
|
function handleMouseDown(view, startEvent) {
|
|
92001
|
-
var
|
|
92734
|
+
var _cellUnderMouse;
|
|
92002
92735
|
if (startEvent.ctrlKey || startEvent.metaKey) return;
|
|
92003
92736
|
const startDOMCell = domInCell(view, startEvent.target);
|
|
92004
92737
|
let $anchor;
|
|
92005
92738
|
if (startEvent.shiftKey && view.state.selection instanceof CellSelection) {
|
|
92006
92739
|
setCellSelection(view.state.selection.$anchorCell, startEvent);
|
|
92007
92740
|
startEvent.preventDefault();
|
|
92008
|
-
} else if (startEvent.shiftKey && startDOMCell && ($anchor = cellAround$1(view.state.selection.$anchor)) != null && ((
|
|
92741
|
+
} 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) {
|
|
92009
92742
|
setCellSelection($anchor, startEvent);
|
|
92010
92743
|
startEvent.preventDefault();
|
|
92011
|
-
} else if (!startDOMCell)
|
|
92012
|
-
|
|
92013
|
-
}
|
|
92014
|
-
function setCellSelection($anchor2, event) {
|
|
92744
|
+
} else if (!startDOMCell) return;
|
|
92745
|
+
function setCellSelection($anchor$1, event) {
|
|
92015
92746
|
let $head = cellUnderMouse(view, event);
|
|
92016
92747
|
const starting = tableEditingKey.getState(view.state) == null;
|
|
92017
|
-
if (!$head || !inSameTable($
|
|
92018
|
-
|
|
92019
|
-
|
|
92020
|
-
}
|
|
92021
|
-
const selection = new CellSelection($anchor2, $head);
|
|
92748
|
+
if (!$head || !inSameTable($anchor$1, $head)) if (starting) $head = $anchor$1;
|
|
92749
|
+
else return;
|
|
92750
|
+
const selection = new CellSelection($anchor$1, $head);
|
|
92022
92751
|
if (starting || !view.state.selection.eq(selection)) {
|
|
92023
92752
|
const tr = view.state.tr.setSelection(selection);
|
|
92024
|
-
if (starting) tr.setMeta(tableEditingKey, $
|
|
92753
|
+
if (starting) tr.setMeta(tableEditingKey, $anchor$1.pos);
|
|
92025
92754
|
view.dispatch(tr);
|
|
92026
92755
|
}
|
|
92027
92756
|
}
|
|
@@ -92029,20 +92758,18 @@ ${l}
|
|
|
92029
92758
|
view.root.removeEventListener("mouseup", stop);
|
|
92030
92759
|
view.root.removeEventListener("dragstart", stop);
|
|
92031
92760
|
view.root.removeEventListener("mousemove", move2);
|
|
92032
|
-
if (tableEditingKey.getState(view.state) != null)
|
|
92033
|
-
view.dispatch(view.state.tr.setMeta(tableEditingKey, -1));
|
|
92761
|
+
if (tableEditingKey.getState(view.state) != null) view.dispatch(view.state.tr.setMeta(tableEditingKey, -1));
|
|
92034
92762
|
}
|
|
92035
92763
|
function move2(_event) {
|
|
92036
92764
|
const event = _event;
|
|
92037
92765
|
const anchor = tableEditingKey.getState(view.state);
|
|
92038
|
-
let $
|
|
92039
|
-
if (anchor != null)
|
|
92040
|
-
|
|
92041
|
-
|
|
92042
|
-
$
|
|
92043
|
-
if (!$anchor2) return stop();
|
|
92766
|
+
let $anchor$1;
|
|
92767
|
+
if (anchor != null) $anchor$1 = view.state.doc.resolve(anchor);
|
|
92768
|
+
else if (domInCell(view, event.target) != startDOMCell) {
|
|
92769
|
+
$anchor$1 = cellUnderMouse(view, startEvent);
|
|
92770
|
+
if (!$anchor$1) return stop();
|
|
92044
92771
|
}
|
|
92045
|
-
if ($
|
|
92772
|
+
if ($anchor$1) setCellSelection($anchor$1, event);
|
|
92046
92773
|
}
|
|
92047
92774
|
view.root.addEventListener("mouseup", stop);
|
|
92048
92775
|
view.root.addEventListener("dragstart", stop);
|
|
@@ -92052,8 +92779,8 @@ ${l}
|
|
|
92052
92779
|
if (!(view.state.selection instanceof TextSelection$1)) return null;
|
|
92053
92780
|
const { $head } = view.state.selection;
|
|
92054
92781
|
for (let d2 = $head.depth - 1; d2 >= 0; d2--) {
|
|
92055
|
-
const parent = $head.node(d2)
|
|
92056
|
-
if (
|
|
92782
|
+
const parent = $head.node(d2);
|
|
92783
|
+
if ((dir < 0 ? $head.index(d2) : $head.indexAfter(d2)) != (dir < 0 ? 0 : parent.childCount)) return null;
|
|
92057
92784
|
if (parent.type.spec.tableRole == "cell" || parent.type.spec.tableRole == "header_cell") {
|
|
92058
92785
|
const cellPos = $head.before(d2);
|
|
92059
92786
|
const dirStr = axis == "vert" ? dir > 0 ? "down" : "up" : dir > 0 ? "right" : "left";
|
|
@@ -92063,11 +92790,7 @@ ${l}
|
|
|
92063
92790
|
return null;
|
|
92064
92791
|
}
|
|
92065
92792
|
function domInCell(view, dom) {
|
|
92066
|
-
for (; dom && dom != view.dom; dom = dom.parentNode)
|
|
92067
|
-
if (dom.nodeName == "TD" || dom.nodeName == "TH") {
|
|
92068
|
-
return dom;
|
|
92069
|
-
}
|
|
92070
|
-
}
|
|
92793
|
+
for (; dom && dom != view.dom; dom = dom.parentNode) if (dom.nodeName == "TD" || dom.nodeName == "TH") return dom;
|
|
92071
92794
|
return null;
|
|
92072
92795
|
}
|
|
92073
92796
|
function cellUnderMouse(view, event) {
|
|
@@ -92076,7 +92799,8 @@ ${l}
|
|
|
92076
92799
|
top: event.clientY
|
|
92077
92800
|
});
|
|
92078
92801
|
if (!mousePos) return null;
|
|
92079
|
-
|
|
92802
|
+
const pos = mousePos.inside >= 0 ? mousePos.inside : mousePos.pos;
|
|
92803
|
+
return cellAround$1(view.state.doc.resolve(pos));
|
|
92080
92804
|
}
|
|
92081
92805
|
var TableView = class {
|
|
92082
92806
|
constructor(node2, defaultCellMinWidth) {
|
|
@@ -92085,10 +92809,7 @@ ${l}
|
|
|
92085
92809
|
this.dom = document.createElement("div");
|
|
92086
92810
|
this.dom.className = "tableWrapper";
|
|
92087
92811
|
this.table = this.dom.appendChild(document.createElement("table"));
|
|
92088
|
-
this.table.style.setProperty(
|
|
92089
|
-
"--default-cell-min-width",
|
|
92090
|
-
`${defaultCellMinWidth}px`
|
|
92091
|
-
);
|
|
92812
|
+
this.table.style.setProperty("--default-cell-min-width", `${defaultCellMinWidth}px`);
|
|
92092
92813
|
this.colgroup = this.table.appendChild(document.createElement("colgroup"));
|
|
92093
92814
|
updateColumnsOnResize(node2, this.colgroup, this.table, defaultCellMinWidth);
|
|
92094
92815
|
this.contentDOM = this.table.appendChild(document.createElement("tbody"));
|
|
@@ -92096,12 +92817,7 @@ ${l}
|
|
|
92096
92817
|
update(node2) {
|
|
92097
92818
|
if (node2.type != this.node.type) return false;
|
|
92098
92819
|
this.node = node2;
|
|
92099
|
-
updateColumnsOnResize(
|
|
92100
|
-
node2,
|
|
92101
|
-
this.colgroup,
|
|
92102
|
-
this.table,
|
|
92103
|
-
this.defaultCellMinWidth
|
|
92104
|
-
);
|
|
92820
|
+
updateColumnsOnResize(node2, this.colgroup, this.table, this.defaultCellMinWidth);
|
|
92105
92821
|
return true;
|
|
92106
92822
|
}
|
|
92107
92823
|
ignoreMutation(record) {
|
|
@@ -92109,7 +92825,6 @@ ${l}
|
|
|
92109
92825
|
}
|
|
92110
92826
|
};
|
|
92111
92827
|
function updateColumnsOnResize(node2, colgroup, table2, defaultCellMinWidth, overrideCol, overrideValue) {
|
|
92112
|
-
var _a2;
|
|
92113
92828
|
let totalWidth = 0;
|
|
92114
92829
|
let fixedWidth = true;
|
|
92115
92830
|
let nextDOM = colgroup.firstChild;
|
|
@@ -92123,20 +92838,19 @@ ${l}
|
|
|
92123
92838
|
totalWidth += hasWidth || defaultCellMinWidth;
|
|
92124
92839
|
if (!hasWidth) fixedWidth = false;
|
|
92125
92840
|
if (!nextDOM) {
|
|
92126
|
-
const
|
|
92127
|
-
|
|
92128
|
-
colgroup.appendChild(
|
|
92841
|
+
const col$1 = document.createElement("col");
|
|
92842
|
+
col$1.style.width = cssWidth;
|
|
92843
|
+
colgroup.appendChild(col$1);
|
|
92129
92844
|
} else {
|
|
92130
|
-
if (nextDOM.style.width != cssWidth)
|
|
92131
|
-
nextDOM.style.width = cssWidth;
|
|
92132
|
-
}
|
|
92845
|
+
if (nextDOM.style.width != cssWidth) nextDOM.style.width = cssWidth;
|
|
92133
92846
|
nextDOM = nextDOM.nextSibling;
|
|
92134
92847
|
}
|
|
92135
92848
|
}
|
|
92136
92849
|
}
|
|
92137
92850
|
while (nextDOM) {
|
|
92851
|
+
var _nextDOM$parentNode;
|
|
92138
92852
|
const after = nextDOM.nextSibling;
|
|
92139
|
-
(
|
|
92853
|
+
(_nextDOM$parentNode = nextDOM.parentNode) === null || _nextDOM$parentNode === void 0 || _nextDOM$parentNode.removeChild(nextDOM);
|
|
92140
92854
|
nextDOM = after;
|
|
92141
92855
|
}
|
|
92142
92856
|
if (fixedWidth) {
|
|
@@ -92147,28 +92861,18 @@ ${l}
|
|
|
92147
92861
|
table2.style.minWidth = totalWidth + "px";
|
|
92148
92862
|
}
|
|
92149
92863
|
}
|
|
92150
|
-
|
|
92151
|
-
|
|
92152
|
-
);
|
|
92153
|
-
function columnResizing({
|
|
92154
|
-
handleWidth = 5,
|
|
92155
|
-
cellMinWidth: cellMinWidth2 = 25,
|
|
92156
|
-
defaultCellMinWidth = 100,
|
|
92157
|
-
View = TableView,
|
|
92158
|
-
lastColumnResizable = true
|
|
92159
|
-
} = {}) {
|
|
92864
|
+
const columnResizingPluginKey = new PluginKey("tableColumnResizing");
|
|
92865
|
+
function columnResizing({ handleWidth = 5, cellMinWidth: cellMinWidth2 = 25, defaultCellMinWidth = 100, View = TableView, lastColumnResizable = true } = {}) {
|
|
92160
92866
|
const plugin2 = new Plugin({
|
|
92161
92867
|
key: columnResizingPluginKey,
|
|
92162
92868
|
state: {
|
|
92163
92869
|
init(_2, state2) {
|
|
92164
|
-
var
|
|
92165
|
-
const nodeViews = (
|
|
92870
|
+
var _plugin$spec;
|
|
92871
|
+
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;
|
|
92166
92872
|
const tableName = tableNodeTypes(state2.schema).table.name;
|
|
92167
|
-
if (View && nodeViews) {
|
|
92168
|
-
|
|
92169
|
-
|
|
92170
|
-
};
|
|
92171
|
-
}
|
|
92873
|
+
if (View && nodeViews) nodeViews[tableName] = (node2, view) => {
|
|
92874
|
+
return new View(node2, defaultCellMinWidth, view);
|
|
92875
|
+
};
|
|
92172
92876
|
return new ResizeState(-1, false);
|
|
92173
92877
|
},
|
|
92174
92878
|
apply(tr, prev) {
|
|
@@ -92188,21 +92892,19 @@ ${l}
|
|
|
92188
92892
|
handleMouseLeave(view);
|
|
92189
92893
|
},
|
|
92190
92894
|
mousedown: (view, event) => {
|
|
92191
|
-
|
|
92895
|
+
handleMouseDown$1(view, event, cellMinWidth2, defaultCellMinWidth);
|
|
92192
92896
|
}
|
|
92193
92897
|
},
|
|
92194
92898
|
decorations: (state2) => {
|
|
92195
92899
|
const pluginState = columnResizingPluginKey.getState(state2);
|
|
92196
|
-
if (pluginState && pluginState.activeHandle > -1)
|
|
92197
|
-
return handleDecorations(state2, pluginState.activeHandle);
|
|
92198
|
-
}
|
|
92900
|
+
if (pluginState && pluginState.activeHandle > -1) return handleDecorations(state2, pluginState.activeHandle);
|
|
92199
92901
|
},
|
|
92200
92902
|
nodeViews: {}
|
|
92201
92903
|
}
|
|
92202
92904
|
});
|
|
92203
92905
|
return plugin2;
|
|
92204
92906
|
}
|
|
92205
|
-
var ResizeState = class
|
|
92907
|
+
var ResizeState = class ResizeState2 {
|
|
92206
92908
|
constructor(activeHandle, dragging) {
|
|
92207
92909
|
this.activeHandle = activeHandle;
|
|
92208
92910
|
this.dragging = dragging;
|
|
@@ -92210,16 +92912,12 @@ ${l}
|
|
|
92210
92912
|
apply(tr) {
|
|
92211
92913
|
const state2 = this;
|
|
92212
92914
|
const action = tr.getMeta(columnResizingPluginKey);
|
|
92213
|
-
if (action && action.setHandle != null)
|
|
92214
|
-
|
|
92215
|
-
if (action && action.setDragging !== void 0)
|
|
92216
|
-
return new _ResizeState(state2.activeHandle, action.setDragging);
|
|
92915
|
+
if (action && action.setHandle != null) return new ResizeState2(action.setHandle, false);
|
|
92916
|
+
if (action && action.setDragging !== void 0) return new ResizeState2(state2.activeHandle, action.setDragging);
|
|
92217
92917
|
if (state2.activeHandle > -1 && tr.docChanged) {
|
|
92218
92918
|
let handle2 = tr.mapping.map(state2.activeHandle, -1);
|
|
92219
|
-
if (!pointsAtCell(tr.doc.resolve(handle2)))
|
|
92220
|
-
|
|
92221
|
-
}
|
|
92222
|
-
return new _ResizeState(handle2, state2.dragging);
|
|
92919
|
+
if (!pointsAtCell(tr.doc.resolve(handle2))) handle2 = -1;
|
|
92920
|
+
return new ResizeState2(handle2, state2.dragging);
|
|
92223
92921
|
}
|
|
92224
92922
|
return state2;
|
|
92225
92923
|
}
|
|
@@ -92233,10 +92931,8 @@ ${l}
|
|
|
92233
92931
|
let cell2 = -1;
|
|
92234
92932
|
if (target) {
|
|
92235
92933
|
const { left: left2, right: right2 } = target.getBoundingClientRect();
|
|
92236
|
-
if (event.clientX - left2 <= handleWidth)
|
|
92237
|
-
|
|
92238
|
-
else if (right2 - event.clientX <= handleWidth)
|
|
92239
|
-
cell2 = edgeCell(view, event, "right", handleWidth);
|
|
92934
|
+
if (event.clientX - left2 <= handleWidth) cell2 = edgeCell(view, event, "left", handleWidth);
|
|
92935
|
+
else if (right2 - event.clientX <= handleWidth) cell2 = edgeCell(view, event, "right", handleWidth);
|
|
92240
92936
|
}
|
|
92241
92937
|
if (cell2 != pluginState.activeHandle) {
|
|
92242
92938
|
if (!lastColumnResizable && cell2 !== -1) {
|
|
@@ -92244,10 +92940,7 @@ ${l}
|
|
|
92244
92940
|
const table2 = $cell.node(-1);
|
|
92245
92941
|
const map2 = TableMap.get(table2);
|
|
92246
92942
|
const tableStart = $cell.start(-1);
|
|
92247
|
-
|
|
92248
|
-
if (col == map2.width - 1) {
|
|
92249
|
-
return;
|
|
92250
|
-
}
|
|
92943
|
+
if (map2.colCount($cell.pos - tableStart) + $cell.nodeAfter.attrs.colspan - 1 == map2.width - 1) return;
|
|
92251
92944
|
}
|
|
92252
92945
|
updateHandle(view, cell2);
|
|
92253
92946
|
}
|
|
@@ -92256,58 +92949,39 @@ ${l}
|
|
|
92256
92949
|
function handleMouseLeave(view) {
|
|
92257
92950
|
if (!view.editable) return;
|
|
92258
92951
|
const pluginState = columnResizingPluginKey.getState(view.state);
|
|
92259
|
-
if (pluginState && pluginState.activeHandle > -1 && !pluginState.dragging)
|
|
92260
|
-
updateHandle(view, -1);
|
|
92952
|
+
if (pluginState && pluginState.activeHandle > -1 && !pluginState.dragging) updateHandle(view, -1);
|
|
92261
92953
|
}
|
|
92262
|
-
function
|
|
92263
|
-
var
|
|
92954
|
+
function handleMouseDown$1(view, event, cellMinWidth2, defaultCellMinWidth) {
|
|
92955
|
+
var _view$dom$ownerDocume;
|
|
92264
92956
|
if (!view.editable) return false;
|
|
92265
|
-
const win = (
|
|
92957
|
+
const win = (_view$dom$ownerDocume = view.dom.ownerDocument.defaultView) !== null && _view$dom$ownerDocume !== void 0 ? _view$dom$ownerDocume : window;
|
|
92266
92958
|
const pluginState = columnResizingPluginKey.getState(view.state);
|
|
92267
|
-
if (!pluginState || pluginState.activeHandle == -1 || pluginState.dragging)
|
|
92268
|
-
return false;
|
|
92959
|
+
if (!pluginState || pluginState.activeHandle == -1 || pluginState.dragging) return false;
|
|
92269
92960
|
const cell2 = view.state.doc.nodeAt(pluginState.activeHandle);
|
|
92270
92961
|
const width = currentColWidth(view, pluginState.activeHandle, cell2.attrs);
|
|
92271
|
-
view.dispatch(
|
|
92272
|
-
|
|
92273
|
-
|
|
92274
|
-
|
|
92275
|
-
)
|
|
92276
|
-
function finish(event2) {
|
|
92962
|
+
view.dispatch(view.state.tr.setMeta(columnResizingPluginKey, { setDragging: {
|
|
92963
|
+
startX: event.clientX,
|
|
92964
|
+
startWidth: width
|
|
92965
|
+
} }));
|
|
92966
|
+
function finish(event$1) {
|
|
92277
92967
|
win.removeEventListener("mouseup", finish);
|
|
92278
92968
|
win.removeEventListener("mousemove", move2);
|
|
92279
|
-
const
|
|
92280
|
-
if (
|
|
92281
|
-
updateColumnWidth(
|
|
92282
|
-
|
|
92283
|
-
pluginState2.activeHandle,
|
|
92284
|
-
draggedWidth(pluginState2.dragging, event2, cellMinWidth2)
|
|
92285
|
-
);
|
|
92286
|
-
view.dispatch(
|
|
92287
|
-
view.state.tr.setMeta(columnResizingPluginKey, { setDragging: null })
|
|
92288
|
-
);
|
|
92969
|
+
const pluginState$1 = columnResizingPluginKey.getState(view.state);
|
|
92970
|
+
if (pluginState$1 === null || pluginState$1 === void 0 ? void 0 : pluginState$1.dragging) {
|
|
92971
|
+
updateColumnWidth(view, pluginState$1.activeHandle, draggedWidth(pluginState$1.dragging, event$1, cellMinWidth2));
|
|
92972
|
+
view.dispatch(view.state.tr.setMeta(columnResizingPluginKey, { setDragging: null }));
|
|
92289
92973
|
}
|
|
92290
92974
|
}
|
|
92291
|
-
function move2(
|
|
92292
|
-
if (!
|
|
92293
|
-
const
|
|
92294
|
-
if (!
|
|
92295
|
-
if (
|
|
92296
|
-
const dragged = draggedWidth(
|
|
92297
|
-
displayColumnWidth(
|
|
92298
|
-
view,
|
|
92299
|
-
pluginState2.activeHandle,
|
|
92300
|
-
dragged,
|
|
92301
|
-
defaultCellMinWidth
|
|
92302
|
-
);
|
|
92975
|
+
function move2(event$1) {
|
|
92976
|
+
if (!event$1.which) return finish(event$1);
|
|
92977
|
+
const pluginState$1 = columnResizingPluginKey.getState(view.state);
|
|
92978
|
+
if (!pluginState$1) return;
|
|
92979
|
+
if (pluginState$1.dragging) {
|
|
92980
|
+
const dragged = draggedWidth(pluginState$1.dragging, event$1, cellMinWidth2);
|
|
92981
|
+
displayColumnWidth(view, pluginState$1.activeHandle, dragged, defaultCellMinWidth);
|
|
92303
92982
|
}
|
|
92304
92983
|
}
|
|
92305
|
-
displayColumnWidth(
|
|
92306
|
-
view,
|
|
92307
|
-
pluginState.activeHandle,
|
|
92308
|
-
width,
|
|
92309
|
-
defaultCellMinWidth
|
|
92310
|
-
);
|
|
92984
|
+
displayColumnWidth(view, pluginState.activeHandle, width, defaultCellMinWidth);
|
|
92311
92985
|
win.addEventListener("mouseup", finish);
|
|
92312
92986
|
win.addEventListener("mousemove", move2);
|
|
92313
92987
|
event.preventDefault();
|
|
@@ -92317,20 +92991,17 @@ ${l}
|
|
|
92317
92991
|
const width = colwidth && colwidth[colwidth.length - 1];
|
|
92318
92992
|
if (width) return width;
|
|
92319
92993
|
const dom = view.domAtPos(cellPos);
|
|
92320
|
-
|
|
92321
|
-
let domWidth = node2.offsetWidth, parts = colspan;
|
|
92994
|
+
let domWidth = dom.node.childNodes[dom.offset].offsetWidth, parts = colspan;
|
|
92322
92995
|
if (colwidth) {
|
|
92323
|
-
for (let i2 = 0; i2 < colspan; i2++)
|
|
92324
|
-
|
|
92325
|
-
|
|
92326
|
-
|
|
92327
|
-
}
|
|
92996
|
+
for (let i2 = 0; i2 < colspan; i2++) if (colwidth[i2]) {
|
|
92997
|
+
domWidth -= colwidth[i2];
|
|
92998
|
+
parts--;
|
|
92999
|
+
}
|
|
92328
93000
|
}
|
|
92329
93001
|
return domWidth / parts;
|
|
92330
93002
|
}
|
|
92331
93003
|
function domCellAround(target) {
|
|
92332
|
-
while (target && target.nodeName != "TD" && target.nodeName != "TH")
|
|
92333
|
-
target = target.classList && target.classList.contains("ProseMirror") ? null : target.parentNode;
|
|
93004
|
+
while (target && target.nodeName != "TD" && target.nodeName != "TH") target = target.classList && target.classList.contains("ProseMirror") ? null : target.parentNode;
|
|
92334
93005
|
return target;
|
|
92335
93006
|
}
|
|
92336
93007
|
function edgeCell(view, event, side, handleWidth) {
|
|
@@ -92353,9 +93024,7 @@ ${l}
|
|
|
92353
93024
|
return Math.max(resizeMinWidth, dragging.startWidth + offset2);
|
|
92354
93025
|
}
|
|
92355
93026
|
function updateHandle(view, value) {
|
|
92356
|
-
view.dispatch(
|
|
92357
|
-
view.state.tr.setMeta(columnResizingPluginKey, { setHandle: value })
|
|
92358
|
-
);
|
|
93027
|
+
view.dispatch(view.state.tr.setMeta(columnResizingPluginKey, { setHandle: value }));
|
|
92359
93028
|
}
|
|
92360
93029
|
function updateColumnWidth(view, cell2, width) {
|
|
92361
93030
|
const $cell = view.state.doc.resolve(cell2);
|
|
@@ -92371,7 +93040,10 @@ ${l}
|
|
|
92371
93040
|
if (attrs.colwidth && attrs.colwidth[index2] == width) continue;
|
|
92372
93041
|
const colwidth = attrs.colwidth ? attrs.colwidth.slice() : zeroes(attrs.colspan);
|
|
92373
93042
|
colwidth[index2] = width;
|
|
92374
|
-
tr.setNodeMarkup(start2 + pos, null, {
|
|
93043
|
+
tr.setNodeMarkup(start2 + pos, null, {
|
|
93044
|
+
...attrs,
|
|
93045
|
+
colwidth
|
|
93046
|
+
});
|
|
92375
93047
|
}
|
|
92376
93048
|
if (tr.docChanged) view.dispatch(tr);
|
|
92377
93049
|
}
|
|
@@ -92380,64 +93052,38 @@ ${l}
|
|
|
92380
93052
|
const table2 = $cell.node(-1), start2 = $cell.start(-1);
|
|
92381
93053
|
const col = TableMap.get(table2).colCount($cell.pos - start2) + $cell.nodeAfter.attrs.colspan - 1;
|
|
92382
93054
|
let dom = view.domAtPos($cell.start(-1)).node;
|
|
92383
|
-
while (dom && dom.nodeName != "TABLE")
|
|
92384
|
-
dom = dom.parentNode;
|
|
92385
|
-
}
|
|
93055
|
+
while (dom && dom.nodeName != "TABLE") dom = dom.parentNode;
|
|
92386
93056
|
if (!dom) return;
|
|
92387
|
-
updateColumnsOnResize(
|
|
92388
|
-
table2,
|
|
92389
|
-
dom.firstChild,
|
|
92390
|
-
dom,
|
|
92391
|
-
defaultCellMinWidth,
|
|
92392
|
-
col,
|
|
92393
|
-
width
|
|
92394
|
-
);
|
|
93057
|
+
updateColumnsOnResize(table2, dom.firstChild, dom, defaultCellMinWidth, col, width);
|
|
92395
93058
|
}
|
|
92396
93059
|
function zeroes(n) {
|
|
92397
93060
|
return Array(n).fill(0);
|
|
92398
93061
|
}
|
|
92399
93062
|
function handleDecorations(state2, cell2) {
|
|
92400
|
-
var _a2;
|
|
92401
93063
|
const decorations = [];
|
|
92402
93064
|
const $cell = state2.doc.resolve(cell2);
|
|
92403
93065
|
const table2 = $cell.node(-1);
|
|
92404
|
-
if (!table2)
|
|
92405
|
-
return DecorationSet.empty;
|
|
92406
|
-
}
|
|
93066
|
+
if (!table2) return DecorationSet.empty;
|
|
92407
93067
|
const map2 = TableMap.get(table2);
|
|
92408
93068
|
const start2 = $cell.start(-1);
|
|
92409
93069
|
const col = map2.colCount($cell.pos - start2) + $cell.nodeAfter.attrs.colspan - 1;
|
|
92410
93070
|
for (let row2 = 0; row2 < map2.height; row2++) {
|
|
92411
93071
|
const index2 = col + row2 * map2.width;
|
|
92412
93072
|
if ((col == map2.width - 1 || map2.map[index2] != map2.map[index2 + 1]) && (row2 == 0 || map2.map[index2] != map2.map[index2 - map2.width])) {
|
|
93073
|
+
var _columnResizingPlugin;
|
|
92413
93074
|
const cellPos = map2.map[index2];
|
|
92414
93075
|
const pos = start2 + cellPos + table2.nodeAt(cellPos).nodeSize - 1;
|
|
92415
93076
|
const dom = document.createElement("div");
|
|
92416
93077
|
dom.className = "column-resize-handle";
|
|
92417
|
-
if ((
|
|
92418
|
-
decorations.push(
|
|
92419
|
-
Decoration.node(
|
|
92420
|
-
start2 + cellPos,
|
|
92421
|
-
start2 + cellPos + table2.nodeAt(cellPos).nodeSize,
|
|
92422
|
-
{
|
|
92423
|
-
class: "column-resize-dragging"
|
|
92424
|
-
}
|
|
92425
|
-
)
|
|
92426
|
-
);
|
|
92427
|
-
}
|
|
93078
|
+
if ((_columnResizingPlugin = columnResizingPluginKey.getState(state2)) === null || _columnResizingPlugin === void 0 ? void 0 : _columnResizingPlugin.dragging) decorations.push(Decoration.node(start2 + cellPos, start2 + cellPos + table2.nodeAt(cellPos).nodeSize, { class: "column-resize-dragging" }));
|
|
92428
93079
|
decorations.push(Decoration.widget(pos, dom));
|
|
92429
93080
|
}
|
|
92430
93081
|
}
|
|
92431
93082
|
return DecorationSet.create(state2.doc, decorations);
|
|
92432
93083
|
}
|
|
92433
|
-
function tableEditing({
|
|
92434
|
-
allowTableNodeSelection = false
|
|
92435
|
-
} = {}) {
|
|
93084
|
+
function tableEditing({ allowTableNodeSelection = false } = {}) {
|
|
92436
93085
|
return new Plugin({
|
|
92437
93086
|
key: tableEditingKey,
|
|
92438
|
-
// This piece of state is used to remember when a mouse-drag
|
|
92439
|
-
// cell-selection is happening, so that it can continue even as
|
|
92440
|
-
// transactions (which might move its anchor cell) come in.
|
|
92441
93087
|
state: {
|
|
92442
93088
|
init() {
|
|
92443
93089
|
return null;
|
|
@@ -92452,9 +93098,7 @@ ${l}
|
|
|
92452
93098
|
},
|
|
92453
93099
|
props: {
|
|
92454
93100
|
decorations: drawCellSelection,
|
|
92455
|
-
handleDOMEvents: {
|
|
92456
|
-
mousedown: handleMouseDown
|
|
92457
|
-
},
|
|
93101
|
+
handleDOMEvents: { mousedown: handleMouseDown },
|
|
92458
93102
|
createSelectionBetween(view) {
|
|
92459
93103
|
return tableEditingKey.getState(view.state) != null ? view.state.selection : null;
|
|
92460
93104
|
},
|
|
@@ -92463,11 +93107,7 @@ ${l}
|
|
|
92463
93107
|
handlePaste
|
|
92464
93108
|
},
|
|
92465
93109
|
appendTransaction(_2, oldState, state2) {
|
|
92466
|
-
return normalizeSelection(
|
|
92467
|
-
state2,
|
|
92468
|
-
fixTables(state2, oldState),
|
|
92469
|
-
allowTableNodeSelection
|
|
92470
|
-
);
|
|
93110
|
+
return normalizeSelection(state2, fixTables(state2, oldState), allowTableNodeSelection);
|
|
92471
93111
|
}
|
|
92472
93112
|
});
|
|
92473
93113
|
}
|
|
@@ -115690,7 +116330,7 @@ ${style2}
|
|
|
115690
116330
|
};
|
|
115691
116331
|
};
|
|
115692
116332
|
const _hoisted_1$f$1 = ["onClick", "innerHTML", "aria-label", "onKeydown"];
|
|
115693
|
-
const _sfc_main$
|
|
116333
|
+
const _sfc_main$h$1 = {
|
|
115694
116334
|
__name: "AlignmentButtons",
|
|
115695
116335
|
emits: ["select"],
|
|
115696
116336
|
setup(__props, { emit: __emit }) {
|
|
@@ -115781,14 +116421,14 @@ ${style2}
|
|
|
115781
116421
|
};
|
|
115782
116422
|
}
|
|
115783
116423
|
};
|
|
115784
|
-
const AlignmentButtons = /* @__PURE__ */ _export_sfc$1(_sfc_main$
|
|
116424
|
+
const AlignmentButtons = /* @__PURE__ */ _export_sfc$1(_sfc_main$h$1, [["__scopeId", "data-v-d84f57b6"]]);
|
|
115785
116425
|
const _hoisted_1$e$1 = ["onClick", "onKeydown"];
|
|
115786
116426
|
const _hoisted_2$9$1 = { class: "document-mode-column icon-column" };
|
|
115787
116427
|
const _hoisted_3$7$1 = ["innerHTML"];
|
|
115788
116428
|
const _hoisted_4$3$1 = { class: "document-mode-column text-column" };
|
|
115789
116429
|
const _hoisted_5$2$1 = { class: "document-mode-type" };
|
|
115790
116430
|
const _hoisted_6$1$1 = { class: "document-mode-description" };
|
|
115791
|
-
const _sfc_main$
|
|
116431
|
+
const _sfc_main$g$1 = {
|
|
115792
116432
|
__name: "DocumentMode",
|
|
115793
116433
|
props: {
|
|
115794
116434
|
options: {
|
|
@@ -115868,14 +116508,14 @@ ${style2}
|
|
|
115868
116508
|
};
|
|
115869
116509
|
}
|
|
115870
116510
|
};
|
|
115871
|
-
const DocumentMode = /* @__PURE__ */ _export_sfc$1(_sfc_main$
|
|
116511
|
+
const DocumentMode = /* @__PURE__ */ _export_sfc$1(_sfc_main$g$1, [["__scopeId", "data-v-8730b752"]]);
|
|
115872
116512
|
const _hoisted_1$d$1 = {
|
|
115873
116513
|
key: 0,
|
|
115874
116514
|
class: "linked-style-buttons",
|
|
115875
116515
|
"data-editor-ui-surface": ""
|
|
115876
116516
|
};
|
|
115877
116517
|
const _hoisted_2$8$1 = ["onClick", "onKeydown", "aria-label"];
|
|
115878
|
-
const _sfc_main$
|
|
116518
|
+
const _sfc_main$f$1 = {
|
|
115879
116519
|
__name: "LinkedStyle",
|
|
115880
116520
|
props: {
|
|
115881
116521
|
editor: {
|
|
@@ -115951,7 +116591,7 @@ ${style2}
|
|
|
115951
116591
|
};
|
|
115952
116592
|
}
|
|
115953
116593
|
};
|
|
115954
|
-
const LinkedStyle = /* @__PURE__ */ _export_sfc$1(_sfc_main$
|
|
116594
|
+
const LinkedStyle = /* @__PURE__ */ _export_sfc$1(_sfc_main$f$1, [["__scopeId", "data-v-ecb78965"]]);
|
|
115955
116595
|
const _hoisted_1$c$1 = {
|
|
115956
116596
|
key: 0,
|
|
115957
116597
|
class: "link-title"
|
|
@@ -115980,7 +116620,7 @@ ${style2}
|
|
|
115980
116620
|
key: 4,
|
|
115981
116621
|
class: "input-row go-to-anchor clickable"
|
|
115982
116622
|
};
|
|
115983
|
-
const _sfc_main$
|
|
116623
|
+
const _sfc_main$e$1 = {
|
|
115984
116624
|
__name: "LinkInput",
|
|
115985
116625
|
props: {
|
|
115986
116626
|
showInput: {
|
|
@@ -116186,12 +116826,12 @@ ${style2}
|
|
|
116186
116826
|
};
|
|
116187
116827
|
}
|
|
116188
116828
|
};
|
|
116189
|
-
const LinkInput = /* @__PURE__ */ _export_sfc$1(_sfc_main$
|
|
116829
|
+
const LinkInput = /* @__PURE__ */ _export_sfc$1(_sfc_main$e$1, [["__scopeId", "data-v-ba50627b"]]);
|
|
116190
116830
|
const _hoisted_1$b$1 = ["aria-label", "onClick", "onKeydown"];
|
|
116191
116831
|
const _hoisted_2$6$1 = ["innerHTML"];
|
|
116192
116832
|
const _hoisted_3$5$1 = ["innerHTML"];
|
|
116193
116833
|
const ROW_SIZE$1 = 7;
|
|
116194
|
-
const _sfc_main$
|
|
116834
|
+
const _sfc_main$d$1 = {
|
|
116195
116835
|
__name: "IconGridRow",
|
|
116196
116836
|
props: {
|
|
116197
116837
|
icons: {
|
|
@@ -116324,12 +116964,12 @@ ${style2}
|
|
|
116324
116964
|
};
|
|
116325
116965
|
}
|
|
116326
116966
|
};
|
|
116327
|
-
const IconGridRow = /* @__PURE__ */ _export_sfc$1(_sfc_main$
|
|
116967
|
+
const IconGridRow = /* @__PURE__ */ _export_sfc$1(_sfc_main$d$1, [["__scopeId", "data-v-0f479b6c"]]);
|
|
116328
116968
|
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';
|
|
116329
116969
|
const _hoisted_1$a$1 = { class: "options-grid-wrap" };
|
|
116330
116970
|
const _hoisted_2$5$1 = ["innerHTML"];
|
|
116331
116971
|
const _hoisted_3$4$1 = { class: "option-grid-ctn" };
|
|
116332
|
-
const _sfc_main$
|
|
116972
|
+
const _sfc_main$c$1 = {
|
|
116333
116973
|
__name: "IconGrid",
|
|
116334
116974
|
props: {
|
|
116335
116975
|
icons: {
|
|
@@ -116389,7 +117029,7 @@ ${style2}
|
|
|
116389
117029
|
};
|
|
116390
117030
|
}
|
|
116391
117031
|
};
|
|
116392
|
-
const IconGrid = /* @__PURE__ */ _export_sfc$1(_sfc_main$
|
|
117032
|
+
const IconGrid = /* @__PURE__ */ _export_sfc$1(_sfc_main$c$1, [["__scopeId", "data-v-3d19fedf"]]);
|
|
116393
117033
|
const closeDropdown$1 = (dropdown) => {
|
|
116394
117034
|
dropdown.expand.value = false;
|
|
116395
117035
|
};
|
|
@@ -116501,7 +117141,7 @@ ${style2}
|
|
|
116501
117141
|
const _hoisted_1$9$1 = ["data-cols", "data-rows", "onKeydown", "onClick"];
|
|
116502
117142
|
const _hoisted_2$4$1 = ["aria-valuetext"];
|
|
116503
117143
|
const ROW_SIZE = 5;
|
|
116504
|
-
const _sfc_main$
|
|
117144
|
+
const _sfc_main$b$1 = {
|
|
116505
117145
|
__name: "TableGrid",
|
|
116506
117146
|
emits: ["select", "clickoutside"],
|
|
116507
117147
|
setup(__props, { emit: __emit }) {
|
|
@@ -116630,13 +117270,13 @@ ${style2}
|
|
|
116630
117270
|
};
|
|
116631
117271
|
}
|
|
116632
117272
|
};
|
|
116633
|
-
const TableGrid = /* @__PURE__ */ _export_sfc$1(_sfc_main$
|
|
117273
|
+
const TableGrid = /* @__PURE__ */ _export_sfc$1(_sfc_main$b$1, [["__scopeId", "data-v-92e8d5fb"]]);
|
|
116634
117274
|
const _hoisted_1$8$1 = { class: "toolbar-table-actions" };
|
|
116635
117275
|
const _hoisted_2$3$1 = ["onClick", "data-item", "ariaLabel"];
|
|
116636
117276
|
const _hoisted_3$3$1 = { class: "toolbar-table-actions__icon" };
|
|
116637
117277
|
const _hoisted_4$1$1 = ["innerHTML"];
|
|
116638
117278
|
const _hoisted_5$3 = { class: "toolbar-table-actions__label" };
|
|
116639
|
-
const _sfc_main$
|
|
117279
|
+
const _sfc_main$a$1 = {
|
|
116640
117280
|
__name: "TableActions",
|
|
116641
117281
|
props: {
|
|
116642
117282
|
options: {
|
|
@@ -116672,7 +117312,7 @@ ${style2}
|
|
|
116672
117312
|
};
|
|
116673
117313
|
}
|
|
116674
117314
|
};
|
|
116675
|
-
const TableActions = /* @__PURE__ */ _export_sfc$1(_sfc_main$
|
|
117315
|
+
const TableActions = /* @__PURE__ */ _export_sfc$1(_sfc_main$a$1, [["__scopeId", "data-v-990b9a25"]]);
|
|
116676
117316
|
function getScrollableParent(element2) {
|
|
116677
117317
|
let currentElement = element2;
|
|
116678
117318
|
while (currentElement) {
|
|
@@ -116699,7 +117339,7 @@ ${style2}
|
|
|
116699
117339
|
const _hoisted_1$7$1 = { class: "search-input-ctn" };
|
|
116700
117340
|
const _hoisted_2$2$1 = { class: "row" };
|
|
116701
117341
|
const _hoisted_3$2$1 = ["onKeydown"];
|
|
116702
|
-
const _sfc_main$
|
|
117342
|
+
const _sfc_main$9$1 = {
|
|
116703
117343
|
__name: "SearchInput",
|
|
116704
117344
|
props: {
|
|
116705
117345
|
searchRef: {
|
|
@@ -116738,7 +117378,7 @@ ${style2}
|
|
|
116738
117378
|
};
|
|
116739
117379
|
}
|
|
116740
117380
|
};
|
|
116741
|
-
const SearchInput = /* @__PURE__ */ _export_sfc$1(_sfc_main$
|
|
117381
|
+
const SearchInput = /* @__PURE__ */ _export_sfc$1(_sfc_main$9$1, [["__scopeId", "data-v-957cbcf2"]]);
|
|
116742
117382
|
const TOOLBAR_FONTS = [
|
|
116743
117383
|
{
|
|
116744
117384
|
label: "Georgia",
|
|
@@ -119513,7 +120153,7 @@ ${style2}
|
|
|
119513
120153
|
};
|
|
119514
120154
|
const _hoisted_3$1$1 = ["onClick"];
|
|
119515
120155
|
const _hoisted_4$5 = ["innerHTML"];
|
|
119516
|
-
const _sfc_main$
|
|
120156
|
+
const _sfc_main$8$1 = {
|
|
119517
120157
|
__name: "SlashMenu",
|
|
119518
120158
|
props: {
|
|
119519
120159
|
editor: {
|
|
@@ -119867,7 +120507,7 @@ ${style2}
|
|
|
119867
120507
|
const _hoisted_1$4$1 = { class: "numbering" };
|
|
119868
120508
|
const MIN_WIDTH = 200;
|
|
119869
120509
|
const alignment = "flex-end";
|
|
119870
|
-
const _sfc_main$
|
|
120510
|
+
const _sfc_main$6$1 = {
|
|
119871
120511
|
__name: "Ruler",
|
|
119872
120512
|
props: {
|
|
119873
120513
|
orientation: {
|
|
@@ -119958,7 +120598,7 @@ ${style2}
|
|
|
119958
120598
|
minHeight: `${editorBounds.height}px`
|
|
119959
120599
|
};
|
|
119960
120600
|
});
|
|
119961
|
-
const
|
|
120601
|
+
const handleMouseDown2 = (event) => {
|
|
119962
120602
|
isDragging.value = true;
|
|
119963
120603
|
setRulerHandleActive();
|
|
119964
120604
|
const itemId = event.currentTarget.id;
|
|
@@ -120033,13 +120673,13 @@ ${style2}
|
|
|
120033
120673
|
createBaseVNode("div", {
|
|
120034
120674
|
class: "margin-handle handle-left",
|
|
120035
120675
|
id: "left-margin-handle",
|
|
120036
|
-
onMousedown:
|
|
120676
|
+
onMousedown: handleMouseDown2,
|
|
120037
120677
|
style: normalizeStyle(getHandlePosition.value("left"))
|
|
120038
120678
|
}, null, 36),
|
|
120039
120679
|
createBaseVNode("div", {
|
|
120040
120680
|
class: "margin-handle handle-right",
|
|
120041
120681
|
id: "right-margin-handle",
|
|
120042
|
-
onMousedown:
|
|
120682
|
+
onMousedown: handleMouseDown2,
|
|
120043
120683
|
style: normalizeStyle(getHandlePosition.value("right"))
|
|
120044
120684
|
}, null, 36),
|
|
120045
120685
|
showVerticalIndicator.value ? (openBlock(), createElementBlock("div", {
|
|
@@ -120072,8 +120712,8 @@ ${style2}
|
|
|
120072
120712
|
};
|
|
120073
120713
|
}
|
|
120074
120714
|
};
|
|
120075
|
-
const Ruler = /* @__PURE__ */ _export_sfc$1(_sfc_main$
|
|
120076
|
-
const _sfc_main$
|
|
120715
|
+
const Ruler = /* @__PURE__ */ _export_sfc$1(_sfc_main$6$1, [["__scopeId", "data-v-79f9a944"]]);
|
|
120716
|
+
const _sfc_main$5$1 = {
|
|
120077
120717
|
__name: "GenericPopover",
|
|
120078
120718
|
props: {
|
|
120079
120719
|
editor: { type: Object, required: true },
|
|
@@ -120101,22 +120741,22 @@ ${style2}
|
|
|
120101
120741
|
() => props.visible,
|
|
120102
120742
|
(val) => {
|
|
120103
120743
|
if (val) {
|
|
120104
|
-
document.addEventListener("
|
|
120744
|
+
document.addEventListener("pointerdown", handleClickOutside2);
|
|
120105
120745
|
document.addEventListener("keydown", handleEscape);
|
|
120106
120746
|
} else {
|
|
120107
|
-
document.removeEventListener("
|
|
120747
|
+
document.removeEventListener("pointerdown", handleClickOutside2);
|
|
120108
120748
|
document.removeEventListener("keydown", handleEscape);
|
|
120109
120749
|
}
|
|
120110
120750
|
}
|
|
120111
120751
|
);
|
|
120112
120752
|
onMounted(() => {
|
|
120113
120753
|
if (props.visible) {
|
|
120114
|
-
document.addEventListener("
|
|
120754
|
+
document.addEventListener("pointerdown", handleClickOutside2);
|
|
120115
120755
|
document.addEventListener("keydown", handleEscape);
|
|
120116
120756
|
}
|
|
120117
120757
|
});
|
|
120118
120758
|
onBeforeUnmount(() => {
|
|
120119
|
-
document.removeEventListener("
|
|
120759
|
+
document.removeEventListener("pointerdown", handleClickOutside2);
|
|
120120
120760
|
document.removeEventListener("keydown", handleEscape);
|
|
120121
120761
|
});
|
|
120122
120762
|
const derivedStyles = computed(() => ({
|
|
@@ -120131,7 +120771,7 @@ ${style2}
|
|
|
120131
120771
|
style: normalizeStyle(derivedStyles.value),
|
|
120132
120772
|
ref_key: "popover",
|
|
120133
120773
|
ref: popover,
|
|
120134
|
-
|
|
120774
|
+
onPointerdown: _cache[0] || (_cache[0] = withModifiers(() => {
|
|
120135
120775
|
}, ["stop"])),
|
|
120136
120776
|
onClick: _cache[1] || (_cache[1] = withModifiers(() => {
|
|
120137
120777
|
}, ["stop"]))
|
|
@@ -120141,7 +120781,7 @@ ${style2}
|
|
|
120141
120781
|
};
|
|
120142
120782
|
}
|
|
120143
120783
|
};
|
|
120144
|
-
const GenericPopover = /* @__PURE__ */ _export_sfc$1(_sfc_main$
|
|
120784
|
+
const GenericPopover = /* @__PURE__ */ _export_sfc$1(_sfc_main$5$1, [["__scopeId", "data-v-157855b5"]]);
|
|
120145
120785
|
const _hoisted_1$3$1 = ["data-boundary-index", "data-boundary-type", "onMousedown"];
|
|
120146
120786
|
const RESIZE_HANDLE_WIDTH_PX = 9;
|
|
120147
120787
|
const RESIZE_HANDLE_OFFSET_PX = 4;
|
|
@@ -120149,7 +120789,7 @@ ${style2}
|
|
|
120149
120789
|
const MIN_DRAG_OVERLAY_WIDTH_PX = 2e3;
|
|
120150
120790
|
const THROTTLE_INTERVAL_MS = 16;
|
|
120151
120791
|
const MIN_RESIZE_DELTA_PX = 1;
|
|
120152
|
-
const _sfc_main$
|
|
120792
|
+
const _sfc_main$4$1 = {
|
|
120153
120793
|
__name: "TableResizeOverlay",
|
|
120154
120794
|
props: {
|
|
120155
120795
|
/** Editor instance for dispatching transactions */
|
|
@@ -120673,7 +121313,7 @@ ${style2}
|
|
|
120673
121313
|
};
|
|
120674
121314
|
}
|
|
120675
121315
|
};
|
|
120676
|
-
const TableResizeOverlay = /* @__PURE__ */ _export_sfc$1(_sfc_main$
|
|
121316
|
+
const TableResizeOverlay = /* @__PURE__ */ _export_sfc$1(_sfc_main$4$1, [["__scopeId", "data-v-2fdf7836"]]);
|
|
120677
121317
|
const _hoisted_1$2$1 = ["data-handle-position", "onMousedown"];
|
|
120678
121318
|
const OVERLAY_EXPANSION_PX = 2e3;
|
|
120679
121319
|
const RESIZE_HANDLE_SIZE_PX = 12;
|
|
@@ -120682,7 +121322,7 @@ ${style2}
|
|
|
120682
121322
|
const Z_INDEX_OVERLAY = 10;
|
|
120683
121323
|
const Z_INDEX_HANDLE = 15;
|
|
120684
121324
|
const Z_INDEX_GUIDELINE = 20;
|
|
120685
|
-
const _sfc_main$
|
|
121325
|
+
const _sfc_main$3$1 = {
|
|
120686
121326
|
__name: "ImageResizeOverlay",
|
|
120687
121327
|
props: {
|
|
120688
121328
|
/** Editor instance for dispatching transactions */
|
|
@@ -121106,7 +121746,81 @@ ${style2}
|
|
|
121106
121746
|
};
|
|
121107
121747
|
}
|
|
121108
121748
|
};
|
|
121109
|
-
const ImageResizeOverlay = /* @__PURE__ */ _export_sfc$1(_sfc_main$
|
|
121749
|
+
const ImageResizeOverlay = /* @__PURE__ */ _export_sfc$1(_sfc_main$3$1, [["__scopeId", "data-v-e66ec7bb"]]);
|
|
121750
|
+
const _sfc_main$2$1 = {
|
|
121751
|
+
__name: "LinkClickHandler",
|
|
121752
|
+
props: {
|
|
121753
|
+
editor: {
|
|
121754
|
+
type: Object,
|
|
121755
|
+
required: true
|
|
121756
|
+
},
|
|
121757
|
+
openPopover: {
|
|
121758
|
+
type: Function,
|
|
121759
|
+
required: true
|
|
121760
|
+
},
|
|
121761
|
+
closePopover: {
|
|
121762
|
+
type: Function,
|
|
121763
|
+
required: true
|
|
121764
|
+
},
|
|
121765
|
+
popoverVisible: {
|
|
121766
|
+
type: Boolean,
|
|
121767
|
+
default: false
|
|
121768
|
+
}
|
|
121769
|
+
},
|
|
121770
|
+
setup(__props) {
|
|
121771
|
+
const props = __props;
|
|
121772
|
+
const handleLinkClick = (event) => {
|
|
121773
|
+
if (props.popoverVisible) {
|
|
121774
|
+
props.closePopover();
|
|
121775
|
+
return;
|
|
121776
|
+
}
|
|
121777
|
+
if (!props.editor || !props.editor.state) {
|
|
121778
|
+
return;
|
|
121779
|
+
}
|
|
121780
|
+
const surface = getEditorSurfaceElement(props.editor);
|
|
121781
|
+
if (!surface) {
|
|
121782
|
+
return;
|
|
121783
|
+
}
|
|
121784
|
+
moveCursorToMouseEvent(event.detail, props.editor);
|
|
121785
|
+
setTimeout(() => {
|
|
121786
|
+
const currentState = props.editor.state;
|
|
121787
|
+
const hasLink = selectionHasNodeOrMark(currentState, "link", { requireEnds: true });
|
|
121788
|
+
if (hasLink) {
|
|
121789
|
+
const surfaceRect = surface.getBoundingClientRect();
|
|
121790
|
+
if (!surfaceRect) return;
|
|
121791
|
+
props.openPopover(
|
|
121792
|
+
markRaw(LinkInput),
|
|
121793
|
+
{
|
|
121794
|
+
showInput: true,
|
|
121795
|
+
editor: props.editor,
|
|
121796
|
+
closePopover: props.closePopover
|
|
121797
|
+
},
|
|
121798
|
+
{
|
|
121799
|
+
left: `${event.detail.clientX - surfaceRect.left}px`,
|
|
121800
|
+
top: `${event.detail.clientY - surfaceRect.top + 15}px`
|
|
121801
|
+
}
|
|
121802
|
+
);
|
|
121803
|
+
}
|
|
121804
|
+
}, 10);
|
|
121805
|
+
};
|
|
121806
|
+
let surfaceElement = null;
|
|
121807
|
+
onMounted(() => {
|
|
121808
|
+
if (!props.editor) return;
|
|
121809
|
+
surfaceElement = getEditorSurfaceElement(props.editor);
|
|
121810
|
+
if (surfaceElement) {
|
|
121811
|
+
surfaceElement.addEventListener("superdoc-link-click", handleLinkClick);
|
|
121812
|
+
}
|
|
121813
|
+
});
|
|
121814
|
+
onBeforeUnmount(() => {
|
|
121815
|
+
if (surfaceElement) {
|
|
121816
|
+
surfaceElement.removeEventListener("superdoc-link-click", handleLinkClick);
|
|
121817
|
+
}
|
|
121818
|
+
});
|
|
121819
|
+
return (_ctx, _cache) => {
|
|
121820
|
+
return null;
|
|
121821
|
+
};
|
|
121822
|
+
}
|
|
121823
|
+
};
|
|
121110
121824
|
function adjustPaginationBreaks(editorElem, editor) {
|
|
121111
121825
|
if (!editorElem.value || !editor?.value?.options?.scale || isHeadless(editor)) return;
|
|
121112
121826
|
const zoom = editor.value.options.scale;
|
|
@@ -121448,21 +122162,28 @@ ${style2}
|
|
|
121448
122162
|
class: "editor-element super-editor__element",
|
|
121449
122163
|
role: "presentation"
|
|
121450
122164
|
}, null, 512),
|
|
121451
|
-
!contextMenuDisabled.value && editorReady.value && activeEditor.value ? (openBlock(), createBlock(_sfc_main$
|
|
122165
|
+
!contextMenuDisabled.value && editorReady.value && activeEditor.value ? (openBlock(), createBlock(_sfc_main$8$1, {
|
|
121452
122166
|
key: 0,
|
|
121453
122167
|
editor: activeEditor.value,
|
|
121454
122168
|
popoverControls,
|
|
121455
122169
|
openPopover,
|
|
121456
122170
|
closePopover
|
|
121457
122171
|
}, null, 8, ["editor", "popoverControls"])) : createCommentVNode("", true),
|
|
121458
|
-
editorReady.value && activeEditor.value ? (openBlock(), createBlock(
|
|
122172
|
+
editorReady.value && activeEditor.value ? (openBlock(), createBlock(_sfc_main$2$1, {
|
|
121459
122173
|
key: 1,
|
|
121460
122174
|
editor: activeEditor.value,
|
|
122175
|
+
openPopover,
|
|
122176
|
+
closePopover,
|
|
122177
|
+
popoverVisible: popoverControls.visible
|
|
122178
|
+
}, null, 8, ["editor", "popoverVisible"])) : createCommentVNode("", true),
|
|
122179
|
+
editorReady.value && activeEditor.value ? (openBlock(), createBlock(TableResizeOverlay, {
|
|
122180
|
+
key: 2,
|
|
122181
|
+
editor: activeEditor.value,
|
|
121461
122182
|
visible: tableResizeState.visible,
|
|
121462
122183
|
tableElement: tableResizeState.tableElement
|
|
121463
122184
|
}, null, 8, ["editor", "visible", "tableElement"])) : createCommentVNode("", true),
|
|
121464
122185
|
editorReady.value && activeEditor.value ? (openBlock(), createBlock(ImageResizeOverlay, {
|
|
121465
|
-
key:
|
|
122186
|
+
key: 3,
|
|
121466
122187
|
editor: activeEditor.value,
|
|
121467
122188
|
visible: imageResizeState.visible,
|
|
121468
122189
|
imageElement: imageResizeState.imageElement
|
|
@@ -121529,7 +122250,7 @@ ${style2}
|
|
|
121529
122250
|
};
|
|
121530
122251
|
}
|
|
121531
122252
|
};
|
|
121532
|
-
const SuperEditor = /* @__PURE__ */ _export_sfc$1(_sfc_main$1$1, [["__scopeId", "data-v-
|
|
122253
|
+
const SuperEditor = /* @__PURE__ */ _export_sfc$1(_sfc_main$1$1, [["__scopeId", "data-v-08b32c3d"]]);
|
|
121533
122254
|
const _hoisted_1$h = ["innerHTML"];
|
|
121534
122255
|
const _sfc_main$i = {
|
|
121535
122256
|
__name: "SuperInput",
|
|
@@ -123906,6 +124627,7 @@ ${reason}`);
|
|
|
123906
124627
|
const creatorImage = params2.creatorImage;
|
|
123907
124628
|
const createdTime = params2.createdTime || Date.now();
|
|
123908
124629
|
const importedAuthor = ref(params2.importedAuthor || null);
|
|
124630
|
+
const docxCommentJSON = params2.docxCommentJSON || null;
|
|
123909
124631
|
const commentText = ref(params2.commentText || "");
|
|
123910
124632
|
const selection = params2.selection ? useSelection(params2.selection) : useSelection({
|
|
123911
124633
|
documentId: fileId,
|
|
@@ -124020,6 +124742,7 @@ ${reason}`);
|
|
|
124020
124742
|
creatorImage,
|
|
124021
124743
|
createdTime,
|
|
124022
124744
|
importedAuthor: importedAuthor.value,
|
|
124745
|
+
docxCommentJSON,
|
|
124023
124746
|
isInternal: isInternal.value,
|
|
124024
124747
|
commentText: commentText.value,
|
|
124025
124748
|
selection: selection ? selection.getValues() : null,
|
|
@@ -124058,6 +124781,7 @@ ${reason}`);
|
|
|
124058
124781
|
resolvedByEmail,
|
|
124059
124782
|
resolvedByName,
|
|
124060
124783
|
importedAuthor,
|
|
124784
|
+
docxCommentJSON,
|
|
124061
124785
|
// Actions
|
|
124062
124786
|
setText,
|
|
124063
124787
|
getValues,
|
|
@@ -124639,6 +125363,7 @@ ${reason}`);
|
|
|
124639
125363
|
const newComment = useComment({
|
|
124640
125364
|
fileId: documentId,
|
|
124641
125365
|
fileType: document2.type,
|
|
125366
|
+
docxCommentJSON: comment2.textJson,
|
|
124642
125367
|
commentId: comment2.commentId,
|
|
124643
125368
|
isInternal: false,
|
|
124644
125369
|
parentCommentId: comment2.parentCommentId,
|
|
@@ -124699,7 +125424,7 @@ ${reason}`);
|
|
|
124699
125424
|
commentsList.value.forEach((comment2) => {
|
|
124700
125425
|
const values = comment2.getValues();
|
|
124701
125426
|
const richText = values.commentText;
|
|
124702
|
-
const schema = convertHtmlToSchema(richText);
|
|
125427
|
+
const schema = values.docxCommentJSON || convertHtmlToSchema(richText);
|
|
124703
125428
|
processedComments.push({
|
|
124704
125429
|
...values,
|
|
124705
125430
|
commentJSON: schema
|
|
@@ -138672,7 +139397,7 @@ ${style2}
|
|
|
138672
139397
|
this.config.colors = shuffleArray(this.config.colors);
|
|
138673
139398
|
this.userColorMap = /* @__PURE__ */ new Map();
|
|
138674
139399
|
this.colorIndex = 0;
|
|
138675
|
-
this.version = "1.0.0-beta.
|
|
139400
|
+
this.version = "1.0.0-beta.19";
|
|
138676
139401
|
this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
|
|
138677
139402
|
this.superdocId = config2.superdocId || v4();
|
|
138678
139403
|
this.colors = this.config.colors;
|
|
@@ -141115,7 +141840,7 @@ ${style2}
|
|
|
141115
141840
|
value && typeof value === "object" && "byteLength" in value && "byteOffset" in value
|
|
141116
141841
|
);
|
|
141117
141842
|
}
|
|
141118
|
-
const
|
|
141843
|
+
const indexCRpn1mWd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
141119
141844
|
__proto__: null,
|
|
141120
141845
|
unified
|
|
141121
141846
|
}, Symbol.toStringTag, { value: "Module" }));
|