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
|
@@ -19174,6 +19174,7 @@ function getUnderlineCssString({ type: type2 = "single", color = null, thickness
|
|
|
19174
19174
|
if (color) add("text-decoration-color", color);
|
|
19175
19175
|
return parts.join("; ");
|
|
19176
19176
|
}
|
|
19177
|
+
const INLINE_OVERRIDE_PROPERTIES = ["fontSize", "bold", "italic", "strike", "underline", "letterSpacing"];
|
|
19177
19178
|
const resolveRunProperties = (params2, inlineRpr, resolvedPpr, isListNumber = false, numberingDefinedInline = false) => {
|
|
19178
19179
|
const paragraphStyleId = resolvedPpr?.styleId;
|
|
19179
19180
|
const paragraphStyleProps = resolveStyleChain$1(params2, paragraphStyleId, translator$1N);
|
|
@@ -19210,6 +19211,11 @@ const resolveRunProperties = (params2, inlineRpr, resolvedPpr, isListNumber = fa
|
|
|
19210
19211
|
styleChain = [...styleChain, paragraphStyleProps, runStyleProps, inlineRpr];
|
|
19211
19212
|
}
|
|
19212
19213
|
const finalProps = combineProperties(styleChain, ["fontFamily", "color"]);
|
|
19214
|
+
for (const prop of INLINE_OVERRIDE_PROPERTIES) {
|
|
19215
|
+
if (inlineRpr?.[prop] != null) {
|
|
19216
|
+
finalProps[prop] = inlineRpr[prop];
|
|
19217
|
+
}
|
|
19218
|
+
}
|
|
19213
19219
|
return finalProps;
|
|
19214
19220
|
};
|
|
19215
19221
|
function resolveParagraphProperties(params2, inlineProps, insideTable = false, overrideInlineStyleId = false, tableStyleId = null) {
|
|
@@ -25017,8 +25023,8 @@ function handleImageNode$1(node, params2, isAnchor) {
|
|
|
25017
25023
|
horizontal: positionHValue,
|
|
25018
25024
|
top: positionVValue
|
|
25019
25025
|
};
|
|
25020
|
-
const useSimplePos = attributes["simplePos"] === "1" || attributes["simplePos"] === 1;
|
|
25021
|
-
const
|
|
25026
|
+
const useSimplePos = attributes["simplePos"] === "1" || attributes["simplePos"] === 1 || attributes["simplePos"] === true;
|
|
25027
|
+
const simplePosNode = node.elements.find((el) => el.name === "wp:simplePos");
|
|
25022
25028
|
const wrapNode = isAnchor ? node.elements.find(
|
|
25023
25029
|
(el) => ["wp:wrapNone", "wp:wrapSquare", "wp:wrapThrough", "wp:wrapTight", "wp:wrapTopAndBottom"].includes(el.name)
|
|
25024
25030
|
) : null;
|
|
@@ -25158,10 +25164,10 @@ function handleImageNode$1(node, params2, isAnchor) {
|
|
|
25158
25164
|
anchorData,
|
|
25159
25165
|
isAnchor,
|
|
25160
25166
|
transformData,
|
|
25161
|
-
...
|
|
25167
|
+
...useSimplePos && {
|
|
25162
25168
|
simplePos: {
|
|
25163
|
-
x:
|
|
25164
|
-
y:
|
|
25169
|
+
x: simplePosNode.attributes?.x,
|
|
25170
|
+
y: simplePosNode.attributes?.y
|
|
25165
25171
|
}
|
|
25166
25172
|
},
|
|
25167
25173
|
wrap: wrap2,
|
|
@@ -30919,12 +30925,13 @@ function translateShapeGroup(params2) {
|
|
|
30919
30925
|
function translateAnchorNode(params2) {
|
|
30920
30926
|
const { attrs } = params2.node;
|
|
30921
30927
|
const anchorElements = [];
|
|
30922
|
-
|
|
30928
|
+
const hasSimplePos = attrs.simplePos || attrs.originalAttributes?.simplePos;
|
|
30929
|
+
if (hasSimplePos) {
|
|
30923
30930
|
anchorElements.push({
|
|
30924
30931
|
name: "wp:simplePos",
|
|
30925
30932
|
attributes: {
|
|
30926
|
-
x: 0,
|
|
30927
|
-
y: 0
|
|
30933
|
+
x: attrs.simplePos?.x ?? 0,
|
|
30934
|
+
y: attrs.simplePos?.y ?? 0
|
|
30928
30935
|
}
|
|
30929
30936
|
});
|
|
30930
30937
|
}
|
|
@@ -30976,8 +30983,8 @@ function translateAnchorNode(params2) {
|
|
|
30976
30983
|
}
|
|
30977
30984
|
if (attrs.originalAttributes?.simplePos !== void 0) {
|
|
30978
30985
|
inlineAttrs.simplePos = attrs.originalAttributes.simplePos;
|
|
30979
|
-
} else if (
|
|
30980
|
-
inlineAttrs.simplePos =
|
|
30986
|
+
} else if (hasSimplePos) {
|
|
30987
|
+
inlineAttrs.simplePos = "1";
|
|
30981
30988
|
}
|
|
30982
30989
|
if (attrs.originalAttributes?.locked !== void 0) {
|
|
30983
30990
|
inlineAttrs.locked = attrs.originalAttributes.locked;
|
|
@@ -33742,7 +33749,7 @@ const handlePassthroughNode = (params2) => {
|
|
|
33742
33749
|
const { nodes = [] } = params2;
|
|
33743
33750
|
const node = nodes[0];
|
|
33744
33751
|
if (!node) return { nodes: [], consumed: 0 };
|
|
33745
|
-
if (registeredHandlers[node.name]) {
|
|
33752
|
+
if (registeredHandlers[node.name] || node.name === "w:commentReference") {
|
|
33746
33753
|
return { nodes: [], consumed: 0 };
|
|
33747
33754
|
}
|
|
33748
33755
|
const originalXml = carbonCopy(node) || {};
|
|
@@ -34042,7 +34049,11 @@ function importCommentData({ docx, editor, converter }) {
|
|
|
34042
34049
|
const generateCommentsWithExtendedData = ({ docx, comments }) => {
|
|
34043
34050
|
if (!comments?.length) return [];
|
|
34044
34051
|
const commentsExtended = docx["word/commentsExtended.xml"];
|
|
34045
|
-
if (!commentsExtended)
|
|
34052
|
+
if (!commentsExtended) {
|
|
34053
|
+
const commentRanges = extractCommentRangesFromDocument(docx);
|
|
34054
|
+
const commentsWithThreading = detectThreadingFromRanges(comments, commentRanges);
|
|
34055
|
+
return commentsWithThreading.map((comment) => ({ ...comment, isDone: comment.isDone ?? false }));
|
|
34056
|
+
}
|
|
34046
34057
|
const { elements: initialElements = [] } = commentsExtended;
|
|
34047
34058
|
if (!initialElements?.length) return comments.map((comment) => ({ ...comment, isDone: comment.isDone ?? false }));
|
|
34048
34059
|
const { elements = [] } = initialElements[0] ?? {};
|
|
@@ -34068,6 +34079,79 @@ const getExtendedDetails = (commentEx) => {
|
|
|
34068
34079
|
const paraIdParent = attributes["w15:paraIdParent"];
|
|
34069
34080
|
return { paraId, isDone, paraIdParent };
|
|
34070
34081
|
};
|
|
34082
|
+
const extractCommentRangesFromDocument = (docx) => {
|
|
34083
|
+
const documentXml = docx["word/document.xml"];
|
|
34084
|
+
if (!documentXml) {
|
|
34085
|
+
return [];
|
|
34086
|
+
}
|
|
34087
|
+
const pendingComments = [];
|
|
34088
|
+
const walkElements = (elements) => {
|
|
34089
|
+
if (!elements || !Array.isArray(elements)) return;
|
|
34090
|
+
elements.forEach((element) => {
|
|
34091
|
+
if (element.name === "w:commentRangeStart") {
|
|
34092
|
+
const commentId = element.attributes?.["w:id"];
|
|
34093
|
+
if (commentId !== void 0) {
|
|
34094
|
+
pendingComments.push({
|
|
34095
|
+
type: "start",
|
|
34096
|
+
commentId: String(commentId)
|
|
34097
|
+
});
|
|
34098
|
+
}
|
|
34099
|
+
} else if (element.name === "w:commentRangeEnd") {
|
|
34100
|
+
const commentId = element.attributes?.["w:id"];
|
|
34101
|
+
if (commentId !== void 0) {
|
|
34102
|
+
pendingComments.push({
|
|
34103
|
+
type: "end",
|
|
34104
|
+
commentId: String(commentId)
|
|
34105
|
+
});
|
|
34106
|
+
}
|
|
34107
|
+
}
|
|
34108
|
+
if (element.elements && Array.isArray(element.elements)) {
|
|
34109
|
+
walkElements(element.elements);
|
|
34110
|
+
}
|
|
34111
|
+
});
|
|
34112
|
+
};
|
|
34113
|
+
if (documentXml.elements && documentXml.elements.length > 0) {
|
|
34114
|
+
const body = documentXml.elements[0];
|
|
34115
|
+
if (body.elements) {
|
|
34116
|
+
walkElements(body.elements);
|
|
34117
|
+
}
|
|
34118
|
+
}
|
|
34119
|
+
return pendingComments;
|
|
34120
|
+
};
|
|
34121
|
+
const detectThreadingFromRanges = (comments, rangeEvents) => {
|
|
34122
|
+
if (!rangeEvents || rangeEvents.length === 0) {
|
|
34123
|
+
return comments;
|
|
34124
|
+
}
|
|
34125
|
+
const openRanges = [];
|
|
34126
|
+
const parentMap = /* @__PURE__ */ new Map();
|
|
34127
|
+
rangeEvents.forEach((event) => {
|
|
34128
|
+
if (event.type === "start") {
|
|
34129
|
+
if (openRanges.length > 0) {
|
|
34130
|
+
const parentCommentId = openRanges[openRanges.length - 1];
|
|
34131
|
+
parentMap.set(event.commentId, parentCommentId);
|
|
34132
|
+
}
|
|
34133
|
+
openRanges.push(event.commentId);
|
|
34134
|
+
} else if (event.type === "end") {
|
|
34135
|
+
const index2 = openRanges.lastIndexOf(event.commentId);
|
|
34136
|
+
if (index2 !== -1) {
|
|
34137
|
+
openRanges.splice(index2, 1);
|
|
34138
|
+
}
|
|
34139
|
+
}
|
|
34140
|
+
});
|
|
34141
|
+
return comments.map((comment) => {
|
|
34142
|
+
const parentCommentId = parentMap.get(comment.importedId);
|
|
34143
|
+
if (parentCommentId) {
|
|
34144
|
+
const parentComment = comments.find((c2) => c2.importedId === parentCommentId);
|
|
34145
|
+
if (parentComment) {
|
|
34146
|
+
return {
|
|
34147
|
+
...comment,
|
|
34148
|
+
parentCommentId: parentComment.commentId
|
|
34149
|
+
};
|
|
34150
|
+
}
|
|
34151
|
+
}
|
|
34152
|
+
return comment;
|
|
34153
|
+
});
|
|
34154
|
+
};
|
|
34071
34155
|
const RELATIONSHIP_TYPES = (
|
|
34072
34156
|
/** @type {const} */
|
|
34073
34157
|
{
|
|
@@ -35908,10 +35992,12 @@ const toIsoNoFractional = (unixMillis) => {
|
|
|
35908
35992
|
const updateCommentsXml = (commentDefs = [], commentsXml) => {
|
|
35909
35993
|
const newCommentsXml = carbonCopy(commentsXml);
|
|
35910
35994
|
commentDefs.forEach((commentDef) => {
|
|
35911
|
-
const
|
|
35995
|
+
const paraNode = commentDef.elements[0];
|
|
35996
|
+
if (!paraNode.attributes) paraNode.attributes = {};
|
|
35997
|
+
const elements = paraNode.elements;
|
|
35912
35998
|
elements.unshift(COMMENT_REF);
|
|
35913
35999
|
const paraId = commentDef.attributes["w15:paraId"];
|
|
35914
|
-
|
|
36000
|
+
paraNode.attributes["w14:paraId"] = paraId;
|
|
35915
36001
|
commentDef.attributes = {
|
|
35916
36002
|
"w:id": commentDef.attributes["w:id"],
|
|
35917
36003
|
"w:author": commentDef.attributes["w:author"],
|
|
@@ -36285,7 +36371,7 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
36285
36371
|
static getStoredSuperdocVersion(docx) {
|
|
36286
36372
|
return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
|
|
36287
36373
|
}
|
|
36288
|
-
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.
|
|
36374
|
+
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.19") {
|
|
36289
36375
|
return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
|
|
36290
36376
|
}
|
|
36291
36377
|
/**
|
|
@@ -36626,6 +36712,112 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
36626
36712
|
});
|
|
36627
36713
|
return { result, params: params2 };
|
|
36628
36714
|
}
|
|
36715
|
+
/**
|
|
36716
|
+
* Creates a default empty header for the specified variant.
|
|
36717
|
+
*
|
|
36718
|
+
* This method programmatically creates a new header section with an empty ProseMirror
|
|
36719
|
+
* document. The header is added to the converter's data structures and will be included
|
|
36720
|
+
* in subsequent DOCX exports.
|
|
36721
|
+
*
|
|
36722
|
+
* @param {('default' | 'first' | 'even' | 'odd')} variant - The header variant to create
|
|
36723
|
+
* @returns {string} The relationship ID of the created header
|
|
36724
|
+
*
|
|
36725
|
+
* @throws {Error} If variant is invalid or header already exists for this variant
|
|
36726
|
+
*
|
|
36727
|
+
* @example
|
|
36728
|
+
* ```javascript
|
|
36729
|
+
* const headerId = converter.createDefaultHeader('default');
|
|
36730
|
+
* // headerId: 'rId-header-default'
|
|
36731
|
+
* // converter.headers['rId-header-default'] contains empty PM doc
|
|
36732
|
+
* // converter.headerIds.default === 'rId-header-default'
|
|
36733
|
+
* ```
|
|
36734
|
+
*/
|
|
36735
|
+
createDefaultHeader(variant = "default") {
|
|
36736
|
+
if (typeof variant !== "string") {
|
|
36737
|
+
throw new TypeError(`variant must be a string, received ${typeof variant}`);
|
|
36738
|
+
}
|
|
36739
|
+
const validVariants = ["default", "first", "even", "odd"];
|
|
36740
|
+
if (!validVariants.includes(variant)) {
|
|
36741
|
+
throw new Error(`Invalid header variant: ${variant}. Must be one of: ${validVariants.join(", ")}`);
|
|
36742
|
+
}
|
|
36743
|
+
if (this.headerIds[variant]) {
|
|
36744
|
+
console.warn(`[SuperConverter] Header already exists for variant '${variant}': ${this.headerIds[variant]}`);
|
|
36745
|
+
return this.headerIds[variant];
|
|
36746
|
+
}
|
|
36747
|
+
const rId = `rId-header-${variant}`;
|
|
36748
|
+
const emptyDoc = {
|
|
36749
|
+
type: "doc",
|
|
36750
|
+
content: [
|
|
36751
|
+
{
|
|
36752
|
+
type: "paragraph",
|
|
36753
|
+
content: []
|
|
36754
|
+
}
|
|
36755
|
+
]
|
|
36756
|
+
};
|
|
36757
|
+
this.headers[rId] = emptyDoc;
|
|
36758
|
+
this.headerIds[variant] = rId;
|
|
36759
|
+
if (!this.headerIds.ids) {
|
|
36760
|
+
this.headerIds.ids = [];
|
|
36761
|
+
}
|
|
36762
|
+
if (!this.headerIds.ids.includes(rId)) {
|
|
36763
|
+
this.headerIds.ids.push(rId);
|
|
36764
|
+
}
|
|
36765
|
+
this.documentModified = true;
|
|
36766
|
+
return rId;
|
|
36767
|
+
}
|
|
36768
|
+
/**
|
|
36769
|
+
* Creates a default empty footer for the specified variant.
|
|
36770
|
+
*
|
|
36771
|
+
* This method programmatically creates a new footer section with an empty ProseMirror
|
|
36772
|
+
* document. The footer is added to the converter's data structures and will be included
|
|
36773
|
+
* in subsequent DOCX exports.
|
|
36774
|
+
*
|
|
36775
|
+
* @param {('default' | 'first' | 'even' | 'odd')} variant - The footer variant to create
|
|
36776
|
+
* @returns {string} The relationship ID of the created footer
|
|
36777
|
+
*
|
|
36778
|
+
* @throws {Error} If variant is invalid or footer already exists for this variant
|
|
36779
|
+
*
|
|
36780
|
+
* @example
|
|
36781
|
+
* ```javascript
|
|
36782
|
+
* const footerId = converter.createDefaultFooter('default');
|
|
36783
|
+
* // footerId: 'rId-footer-default'
|
|
36784
|
+
* // converter.footers['rId-footer-default'] contains empty PM doc
|
|
36785
|
+
* // converter.footerIds.default === 'rId-footer-default'
|
|
36786
|
+
* ```
|
|
36787
|
+
*/
|
|
36788
|
+
createDefaultFooter(variant = "default") {
|
|
36789
|
+
if (typeof variant !== "string") {
|
|
36790
|
+
throw new TypeError(`variant must be a string, received ${typeof variant}`);
|
|
36791
|
+
}
|
|
36792
|
+
const validVariants = ["default", "first", "even", "odd"];
|
|
36793
|
+
if (!validVariants.includes(variant)) {
|
|
36794
|
+
throw new Error(`Invalid footer variant: ${variant}. Must be one of: ${validVariants.join(", ")}`);
|
|
36795
|
+
}
|
|
36796
|
+
if (this.footerIds[variant]) {
|
|
36797
|
+
console.warn(`[SuperConverter] Footer already exists for variant '${variant}': ${this.footerIds[variant]}`);
|
|
36798
|
+
return this.footerIds[variant];
|
|
36799
|
+
}
|
|
36800
|
+
const rId = `rId-footer-${variant}`;
|
|
36801
|
+
const emptyDoc = {
|
|
36802
|
+
type: "doc",
|
|
36803
|
+
content: [
|
|
36804
|
+
{
|
|
36805
|
+
type: "paragraph",
|
|
36806
|
+
content: []
|
|
36807
|
+
}
|
|
36808
|
+
]
|
|
36809
|
+
};
|
|
36810
|
+
this.footers[rId] = emptyDoc;
|
|
36811
|
+
this.footerIds[variant] = rId;
|
|
36812
|
+
if (!this.footerIds.ids) {
|
|
36813
|
+
this.footerIds.ids = [];
|
|
36814
|
+
}
|
|
36815
|
+
if (!this.footerIds.ids.includes(rId)) {
|
|
36816
|
+
this.footerIds.ids.push(rId);
|
|
36817
|
+
}
|
|
36818
|
+
this.documentModified = true;
|
|
36819
|
+
return rId;
|
|
36820
|
+
}
|
|
36629
36821
|
// Deprecated methods for backward compatibility
|
|
36630
36822
|
static getStoredSuperdocId(docx) {
|
|
36631
36823
|
console.warn("getStoredSuperdocId is deprecated, use getDocumentGuid instead");
|
|
@@ -39485,7 +39677,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
|
|
|
39485
39677
|
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);
|
|
39486
39678
|
var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
|
|
39487
39679
|
var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
|
|
39488
|
-
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,
|
|
39680
|
+
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;
|
|
39489
39681
|
var GOOD_LEAF_SIZE = 200;
|
|
39490
39682
|
var RopeSequence = function RopeSequence2() {
|
|
39491
39683
|
};
|
|
@@ -50671,50 +50863,90 @@ const getCommentPositionsById = (commentId, doc2) => {
|
|
|
50671
50863
|
return positions;
|
|
50672
50864
|
};
|
|
50673
50865
|
const prepareCommentsForExport = (doc2, tr, schema, comments = []) => {
|
|
50866
|
+
const commentMap = /* @__PURE__ */ new Map();
|
|
50867
|
+
comments.forEach((c2) => {
|
|
50868
|
+
commentMap.set(c2.commentId, c2);
|
|
50869
|
+
});
|
|
50870
|
+
new Set(comments.filter((c2) => c2.parentCommentId).map((c2) => c2.parentCommentId));
|
|
50674
50871
|
const startNodes = [];
|
|
50675
50872
|
const endNodes = [];
|
|
50676
50873
|
const seen = /* @__PURE__ */ new Set();
|
|
50677
50874
|
doc2.descendants((node, pos) => {
|
|
50678
|
-
const commentMarks = node.marks?.filter((mark) => mark.type.name === CommentMarkName);
|
|
50875
|
+
const commentMarks = node.marks?.filter((mark) => mark.type.name === CommentMarkName) || [];
|
|
50679
50876
|
commentMarks.forEach((commentMark) => {
|
|
50680
|
-
|
|
50681
|
-
|
|
50682
|
-
|
|
50683
|
-
|
|
50684
|
-
|
|
50685
|
-
|
|
50686
|
-
|
|
50687
|
-
|
|
50877
|
+
const { attrs = {} } = commentMark;
|
|
50878
|
+
const { commentId } = attrs;
|
|
50879
|
+
if (commentId === "pending") return;
|
|
50880
|
+
if (seen.has(commentId)) return;
|
|
50881
|
+
seen.add(commentId);
|
|
50882
|
+
const comment = commentMap.get(commentId);
|
|
50883
|
+
const parentCommentId = comment?.parentCommentId;
|
|
50884
|
+
const commentStartNodeAttrs = getPreparedComment(commentMark.attrs);
|
|
50885
|
+
const startNode = schema.nodes.commentRangeStart.create(commentStartNodeAttrs);
|
|
50886
|
+
startNodes.push({
|
|
50887
|
+
pos,
|
|
50888
|
+
node: startNode,
|
|
50889
|
+
commentId,
|
|
50890
|
+
parentCommentId
|
|
50891
|
+
});
|
|
50892
|
+
const endNode = schema.nodes.commentRangeEnd.create(commentStartNodeAttrs);
|
|
50893
|
+
endNodes.push({
|
|
50894
|
+
pos: pos + node.nodeSize,
|
|
50895
|
+
node: endNode,
|
|
50896
|
+
commentId,
|
|
50897
|
+
parentCommentId
|
|
50898
|
+
});
|
|
50899
|
+
const childComments = comments.filter((c2) => c2.parentCommentId === commentId).sort((a, b2) => a.createdTime - b2.createdTime);
|
|
50900
|
+
childComments.forEach((c2) => {
|
|
50901
|
+
if (seen.has(c2.commentId)) return;
|
|
50902
|
+
seen.add(c2.commentId);
|
|
50903
|
+
const childMark = getPreparedComment({
|
|
50904
|
+
commentId: c2.commentId,
|
|
50905
|
+
internal: c2.isInternal
|
|
50906
|
+
});
|
|
50907
|
+
const childStartNode = schema.nodes.commentRangeStart.create(childMark);
|
|
50688
50908
|
startNodes.push({
|
|
50689
50909
|
pos,
|
|
50690
|
-
node:
|
|
50910
|
+
node: childStartNode,
|
|
50911
|
+
commentId: c2.commentId,
|
|
50912
|
+
parentCommentId: c2.parentCommentId
|
|
50691
50913
|
});
|
|
50692
|
-
const
|
|
50914
|
+
const childEndNode = schema.nodes.commentRangeEnd.create(childMark);
|
|
50693
50915
|
endNodes.push({
|
|
50694
50916
|
pos: pos + node.nodeSize,
|
|
50695
|
-
node:
|
|
50917
|
+
node: childEndNode,
|
|
50918
|
+
commentId: c2.commentId,
|
|
50919
|
+
parentCommentId: c2.parentCommentId
|
|
50696
50920
|
});
|
|
50697
|
-
|
|
50698
|
-
if (parentId) {
|
|
50699
|
-
const childComments = comments.filter((c2) => c2.parentCommentId === parentId).sort((a, b2) => a.createdTime - b2.createdTime);
|
|
50700
|
-
childComments.forEach((c2) => {
|
|
50701
|
-
const childMark = getPreparedComment(c2);
|
|
50702
|
-
const childStartNode = schema.nodes.commentRangeStart.create(childMark);
|
|
50703
|
-
seen.add(c2.commentId);
|
|
50704
|
-
startNodes.push({
|
|
50705
|
-
pos,
|
|
50706
|
-
node: childStartNode
|
|
50707
|
-
});
|
|
50708
|
-
const childEndNode = schema.nodes.commentRangeEnd.create(childMark);
|
|
50709
|
-
endNodes.push({
|
|
50710
|
-
pos: pos + node.nodeSize,
|
|
50711
|
-
node: childEndNode
|
|
50712
|
-
});
|
|
50713
|
-
});
|
|
50714
|
-
}
|
|
50715
|
-
}
|
|
50921
|
+
});
|
|
50716
50922
|
});
|
|
50717
50923
|
});
|
|
50924
|
+
startNodes.sort((a, b2) => {
|
|
50925
|
+
if (a.pos !== b2.pos) return a.pos - b2.pos;
|
|
50926
|
+
const aIsParentOfB = a.commentId === b2.parentCommentId;
|
|
50927
|
+
const bIsParentOfA = b2.commentId === a.parentCommentId;
|
|
50928
|
+
if (aIsParentOfB) return -1;
|
|
50929
|
+
if (bIsParentOfA) return 1;
|
|
50930
|
+
if (a.parentCommentId && a.parentCommentId === b2.parentCommentId) {
|
|
50931
|
+
const aComment = commentMap.get(a.commentId);
|
|
50932
|
+
const bComment = commentMap.get(b2.commentId);
|
|
50933
|
+
return (aComment?.createdTime || 0) - (bComment?.createdTime || 0);
|
|
50934
|
+
}
|
|
50935
|
+
return 0;
|
|
50936
|
+
});
|
|
50937
|
+
endNodes.sort((a, b2) => {
|
|
50938
|
+
if (a.pos !== b2.pos) return a.pos - b2.pos;
|
|
50939
|
+
const aIsParentOfB = a.commentId === b2.parentCommentId;
|
|
50940
|
+
const bIsParentOfA = b2.commentId === a.parentCommentId;
|
|
50941
|
+
if (aIsParentOfB) return -1;
|
|
50942
|
+
if (bIsParentOfA) return 1;
|
|
50943
|
+
if (a.parentCommentId && a.parentCommentId === b2.parentCommentId) {
|
|
50944
|
+
const aComment = commentMap.get(a.commentId);
|
|
50945
|
+
const bComment = commentMap.get(b2.commentId);
|
|
50946
|
+
return (aComment?.createdTime || 0) - (bComment?.createdTime || 0);
|
|
50947
|
+
}
|
|
50948
|
+
return 0;
|
|
50949
|
+
});
|
|
50718
50950
|
startNodes.forEach((n) => {
|
|
50719
50951
|
const { pos, node } = n;
|
|
50720
50952
|
const mappedPos = tr.mapping.map(pos);
|
|
@@ -53256,7 +53488,7 @@ const isHeadless = (editor) => {
|
|
|
53256
53488
|
const shouldSkipNodeView = (editor) => {
|
|
53257
53489
|
return isHeadless(editor);
|
|
53258
53490
|
};
|
|
53259
|
-
const summaryVersion = "1.0.0-beta.
|
|
53491
|
+
const summaryVersion = "1.0.0-beta.19";
|
|
53260
53492
|
const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
|
|
53261
53493
|
const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
|
|
53262
53494
|
function mapAttributes(attrs) {
|
|
@@ -54032,7 +54264,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
54032
54264
|
{ default: remarkStringify },
|
|
54033
54265
|
{ default: remarkGfm }
|
|
54034
54266
|
] = await Promise.all([
|
|
54035
|
-
import("./index-
|
|
54267
|
+
import("./index-CRpn1mWd-B4eH8Zok.es.js"),
|
|
54036
54268
|
import("./index-DRCvimau-Cw339678.es.js"),
|
|
54037
54269
|
import("./index-C_x_N6Uh-DJn8hIEt.es.js"),
|
|
54038
54270
|
import("./index-D_sWOSiG-DE96TaT5.es.js"),
|
|
@@ -54237,7 +54469,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
54237
54469
|
* Process collaboration migrations
|
|
54238
54470
|
*/
|
|
54239
54471
|
processCollaborationMigrations() {
|
|
54240
|
-
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.
|
|
54472
|
+
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.19");
|
|
54241
54473
|
if (!this.options.ydoc) return;
|
|
54242
54474
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
54243
54475
|
let docVersion = metaMap.get("version");
|
|
@@ -54939,6 +55171,15 @@ function extractColumns(elements) {
|
|
|
54939
55171
|
gap: gapInches * PX_PER_INCH$2
|
|
54940
55172
|
};
|
|
54941
55173
|
}
|
|
55174
|
+
function extractVerticalAlign(elements) {
|
|
55175
|
+
const vAlign = elements.find((el) => el?.name === "w:vAlign");
|
|
55176
|
+
if (!vAlign?.attributes) return void 0;
|
|
55177
|
+
const val = vAlign.attributes["w:val"];
|
|
55178
|
+
if (val === "top" || val === "center" || val === "bottom" || val === "both") {
|
|
55179
|
+
return val;
|
|
55180
|
+
}
|
|
55181
|
+
return void 0;
|
|
55182
|
+
}
|
|
54942
55183
|
function extractSectionData(para) {
|
|
54943
55184
|
const attrs = para.attrs ?? {};
|
|
54944
55185
|
let { headerPx, footerPx } = extractNormalizedMargins(attrs);
|
|
@@ -54955,7 +55196,20 @@ function extractSectionData(para) {
|
|
|
54955
55196
|
const footerRefs = extractHeaderFooterRefs(sectPrElements, "w:footerReference");
|
|
54956
55197
|
const numbering = extractPageNumbering(sectPrElements);
|
|
54957
55198
|
const columnsPx = extractColumns(sectPrElements);
|
|
54958
|
-
|
|
55199
|
+
const vAlign = extractVerticalAlign(sectPrElements);
|
|
55200
|
+
return {
|
|
55201
|
+
headerPx,
|
|
55202
|
+
footerPx,
|
|
55203
|
+
type: type2,
|
|
55204
|
+
pageSizePx,
|
|
55205
|
+
orientation,
|
|
55206
|
+
columnsPx,
|
|
55207
|
+
titlePg,
|
|
55208
|
+
headerRefs,
|
|
55209
|
+
footerRefs,
|
|
55210
|
+
numbering,
|
|
55211
|
+
vAlign
|
|
55212
|
+
};
|
|
54959
55213
|
}
|
|
54960
55214
|
function isSectPrElement(value) {
|
|
54961
55215
|
return typeof value === "object" && value !== null && value.type === "element" && value.name === "w:sectPr";
|
|
@@ -54992,7 +55246,8 @@ function createSectionBreakBlock(section, blockIdGen, extraAttrs) {
|
|
|
54992
55246
|
...section.columns && { columns: section.columns },
|
|
54993
55247
|
...section.numbering ? { numbering: section.numbering } : {},
|
|
54994
55248
|
...section.headerRefs && { headerRefs: section.headerRefs },
|
|
54995
|
-
...section.footerRefs && { footerRefs: section.footerRefs }
|
|
55249
|
+
...section.footerRefs && { footerRefs: section.footerRefs },
|
|
55250
|
+
...section.vAlign && { vAlign: section.vAlign }
|
|
54996
55251
|
};
|
|
54997
55252
|
return result;
|
|
54998
55253
|
}
|
|
@@ -55064,7 +55319,8 @@ function buildSectionRangesFromParagraphs(paragraphs, hasBodySectPr) {
|
|
|
55064
55319
|
titlePg: sectionData.titlePg ?? false,
|
|
55065
55320
|
headerRefs: sectionData.headerRefs,
|
|
55066
55321
|
footerRefs: sectionData.footerRefs,
|
|
55067
|
-
numbering: sectionData.numbering
|
|
55322
|
+
numbering: sectionData.numbering,
|
|
55323
|
+
vAlign: sectionData.vAlign
|
|
55068
55324
|
};
|
|
55069
55325
|
ranges.push(range2);
|
|
55070
55326
|
currentStart = item.index + 1;
|
|
@@ -55103,7 +55359,8 @@ function createFinalSectionFromBodySectPr(bodySectPr, currentStart, totalParagra
|
|
|
55103
55359
|
type: bodySectionData.type ?? DEFAULT_BODY_SECTION_TYPE,
|
|
55104
55360
|
titlePg: bodySectionData.titlePg ?? false,
|
|
55105
55361
|
headerRefs: bodySectionData.headerRefs,
|
|
55106
|
-
footerRefs: bodySectionData.footerRefs
|
|
55362
|
+
footerRefs: bodySectionData.footerRefs,
|
|
55363
|
+
vAlign: bodySectionData.vAlign
|
|
55107
55364
|
};
|
|
55108
55365
|
}
|
|
55109
55366
|
function createDefaultFinalSection(currentStart, totalParagraphs, sectionIndex) {
|
|
@@ -56766,8 +57023,9 @@ const normalizeOoxmlTabs = (tabs) => {
|
|
|
56766
57023
|
for (const entry of tabs) {
|
|
56767
57024
|
if (!entry || typeof entry !== "object") continue;
|
|
56768
57025
|
const rawEntry = entry;
|
|
56769
|
-
const
|
|
56770
|
-
const
|
|
57026
|
+
const isNestedTab = Boolean(rawEntry.tab && typeof rawEntry.tab === "object");
|
|
57027
|
+
const source = isNestedTab ? rawEntry.tab : rawEntry;
|
|
57028
|
+
const posTwips = resolveTabPosition(source, isNestedTab);
|
|
56771
57029
|
if (posTwips == null) continue;
|
|
56772
57030
|
const val = normalizeTabVal(source.val ?? source.align ?? source.alignment ?? source.type ?? source.tabType);
|
|
56773
57031
|
if (!val) continue;
|
|
@@ -56781,7 +57039,7 @@ const normalizeOoxmlTabs = (tabs) => {
|
|
|
56781
57039
|
}
|
|
56782
57040
|
return normalized.length > 0 ? normalized : void 0;
|
|
56783
57041
|
};
|
|
56784
|
-
const resolveTabPosition = (source) => {
|
|
57042
|
+
const resolveTabPosition = (source, treatPosAsTwips = false) => {
|
|
56785
57043
|
const originalPos = pickNumber(source.originalPos);
|
|
56786
57044
|
if (originalPos != null) {
|
|
56787
57045
|
return originalPos;
|
|
@@ -56790,6 +57048,9 @@ const resolveTabPosition = (source) => {
|
|
|
56790
57048
|
if (posValue == null) {
|
|
56791
57049
|
return void 0;
|
|
56792
57050
|
}
|
|
57051
|
+
if (treatPosAsTwips) {
|
|
57052
|
+
return posValue;
|
|
57053
|
+
}
|
|
56793
57054
|
if (posValue > TWIPS_THRESHOLD) {
|
|
56794
57055
|
return posValue;
|
|
56795
57056
|
} else {
|
|
@@ -58300,8 +58561,16 @@ const extractMarkerRun = (lvl) => {
|
|
|
58300
58561
|
}
|
|
58301
58562
|
const color = normalizeColor(getAttribute(findChild(rPr, "w:color"), "w:val"));
|
|
58302
58563
|
if (color) run2.color = color;
|
|
58303
|
-
|
|
58304
|
-
if (
|
|
58564
|
+
const boldEl = findChild(rPr, "w:b");
|
|
58565
|
+
if (boldEl) {
|
|
58566
|
+
const boldVal = getAttribute(boldEl, "w:val");
|
|
58567
|
+
if (boldVal == null || isTruthy(boldVal)) run2.bold = true;
|
|
58568
|
+
}
|
|
58569
|
+
const italicEl = findChild(rPr, "w:i");
|
|
58570
|
+
if (italicEl) {
|
|
58571
|
+
const italicVal = getAttribute(italicEl, "w:val");
|
|
58572
|
+
if (italicVal == null || isTruthy(italicVal)) run2.italic = true;
|
|
58573
|
+
}
|
|
58305
58574
|
const spacingTwips = parseNumberAttr(getAttribute(findChild(rPr, "w:spacing"), "w:val"));
|
|
58306
58575
|
if (spacingTwips != null && Number.isFinite(spacingTwips)) {
|
|
58307
58576
|
run2.letterSpacing = twipsToPx$1(spacingTwips);
|
|
@@ -58777,19 +59046,21 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
58777
59046
|
}
|
|
58778
59047
|
const tabObj = tab;
|
|
58779
59048
|
const val = typeof tabObj.tabType === "string" ? tabObj.tabType : typeof tabObj.val === "string" ? tabObj.val : void 0;
|
|
58780
|
-
const
|
|
59049
|
+
const originalPos = pickNumber(tabObj.originalPos);
|
|
59050
|
+
const pos = originalPos ?? pickNumber(tabObj.pos);
|
|
58781
59051
|
if (!val || pos == null) {
|
|
58782
59052
|
continue;
|
|
58783
59053
|
}
|
|
58784
59054
|
const normalized = { val, pos };
|
|
59055
|
+
if (originalPos != null && Number.isFinite(originalPos)) {
|
|
59056
|
+
normalized.originalPos = originalPos;
|
|
59057
|
+
} else {
|
|
59058
|
+
normalized.originalPos = pos;
|
|
59059
|
+
}
|
|
58785
59060
|
const leader = tabObj.leader;
|
|
58786
59061
|
if (typeof leader === "string" && leader.length > 0) {
|
|
58787
59062
|
normalized.leader = leader;
|
|
58788
59063
|
}
|
|
58789
|
-
const originalPos = pickNumber(tabObj.originalPos);
|
|
58790
|
-
if (originalPos != null && Number.isFinite(originalPos)) {
|
|
58791
|
-
normalized.originalPos = originalPos;
|
|
58792
|
-
}
|
|
58793
59064
|
unwrapped.push(normalized);
|
|
58794
59065
|
continue;
|
|
58795
59066
|
}
|
|
@@ -59631,11 +59902,11 @@ const applyLinkedStyleToRun = (run2, options) => {
|
|
|
59631
59902
|
if (!maps.length) return;
|
|
59632
59903
|
const finalStyles = Object.assign({}, ...maps);
|
|
59633
59904
|
const fontFamily2 = extractValue(finalStyles["font-family"]);
|
|
59634
|
-
if (typeof fontFamily2 === "string" && fontFamily2
|
|
59905
|
+
if (typeof fontFamily2 === "string" && fontFamily2) {
|
|
59635
59906
|
run2.fontFamily = fontFamily2;
|
|
59636
59907
|
}
|
|
59637
59908
|
const fontSize2 = toPxNumber(finalStyles["font-size"]);
|
|
59638
|
-
if (fontSize2 != null
|
|
59909
|
+
if (fontSize2 != null) {
|
|
59639
59910
|
run2.fontSize = fontSize2;
|
|
59640
59911
|
}
|
|
59641
59912
|
const letterSpacing = toPxNumber(finalStyles["letter-spacing"]);
|
|
@@ -59998,9 +60269,7 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
|
|
|
59998
60269
|
resolver: linkedStyleResolver,
|
|
59999
60270
|
paragraphStyleId,
|
|
60000
60271
|
inlineStyleId,
|
|
60001
|
-
runStyleId
|
|
60002
|
-
defaultFont,
|
|
60003
|
-
defaultSize
|
|
60272
|
+
runStyleId
|
|
60004
60273
|
});
|
|
60005
60274
|
};
|
|
60006
60275
|
const visitNode = (node, inheritedMarks = [], activeSdt, activeRunStyleId = null) => {
|
|
@@ -60010,7 +60279,8 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
|
|
|
60010
60279
|
positions,
|
|
60011
60280
|
defaultFont,
|
|
60012
60281
|
defaultSize,
|
|
60013
|
-
|
|
60282
|
+
[],
|
|
60283
|
+
// Empty marks - will be applied after linked styles
|
|
60014
60284
|
activeSdt,
|
|
60015
60285
|
hyperlinkConfig,
|
|
60016
60286
|
themeColors
|
|
@@ -60018,6 +60288,7 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
|
|
|
60018
60288
|
const inlineStyleId = getInlineStyleId(inheritedMarks);
|
|
60019
60289
|
applyRunStyles2(run2, inlineStyleId, activeRunStyleId);
|
|
60020
60290
|
applyBaseRunDefaults(run2, baseRunDefaults, defaultFont, defaultSize);
|
|
60291
|
+
applyMarksToRun(run2, [...node.marks ?? [], ...inheritedMarks ?? []], hyperlinkConfig, themeColors);
|
|
60021
60292
|
currentRuns.push(run2);
|
|
60022
60293
|
return;
|
|
60023
60294
|
}
|
|
@@ -61892,13 +62163,14 @@ function processFragment(fragmentEl, viewX, viewY) {
|
|
|
61892
62163
|
if (!Number.isFinite(lineStart) || !Number.isFinite(lineEnd)) {
|
|
61893
62164
|
return null;
|
|
61894
62165
|
}
|
|
61895
|
-
const spanEls = Array.from(lineEl.querySelectorAll("span"));
|
|
62166
|
+
const spanEls = Array.from(lineEl.querySelectorAll("span, a"));
|
|
61896
62167
|
log(
|
|
61897
|
-
"Spans in line:",
|
|
62168
|
+
"Spans/anchors in line:",
|
|
61898
62169
|
spanEls.map((el, i) => {
|
|
61899
62170
|
const rect = el.getBoundingClientRect();
|
|
61900
62171
|
return {
|
|
61901
62172
|
index: i,
|
|
62173
|
+
tag: el.tagName,
|
|
61902
62174
|
pmStart: el.dataset.pmStart,
|
|
61903
62175
|
pmEnd: el.dataset.pmEnd,
|
|
61904
62176
|
text: el.textContent?.substring(0, 20) + (el.textContent && el.textContent.length > 20 ? "..." : ""),
|
|
@@ -61918,32 +62190,33 @@ function processFragment(fragmentEl, viewX, viewY) {
|
|
|
61918
62190
|
if (viewX >= lastRect.right) {
|
|
61919
62191
|
return lineEnd;
|
|
61920
62192
|
}
|
|
61921
|
-
const
|
|
61922
|
-
if (!
|
|
62193
|
+
const targetEl = findSpanAtX(spanEls, viewX);
|
|
62194
|
+
if (!targetEl) {
|
|
61923
62195
|
return lineStart;
|
|
61924
62196
|
}
|
|
61925
|
-
const spanStart = Number(
|
|
61926
|
-
const spanEnd = Number(
|
|
61927
|
-
const targetRect =
|
|
61928
|
-
log("Target
|
|
62197
|
+
const spanStart = Number(targetEl.dataset.pmStart ?? "NaN");
|
|
62198
|
+
const spanEnd = Number(targetEl.dataset.pmEnd ?? "NaN");
|
|
62199
|
+
const targetRect = targetEl.getBoundingClientRect();
|
|
62200
|
+
log("Target element:", {
|
|
62201
|
+
tag: targetEl.tagName,
|
|
61929
62202
|
pmStart: spanStart,
|
|
61930
62203
|
pmEnd: spanEnd,
|
|
61931
|
-
text:
|
|
61932
|
-
visibility:
|
|
62204
|
+
text: targetEl.textContent?.substring(0, 30),
|
|
62205
|
+
visibility: targetEl.style.visibility,
|
|
61933
62206
|
rect: { left: targetRect.left, right: targetRect.right, width: targetRect.width }
|
|
61934
62207
|
});
|
|
61935
62208
|
if (!Number.isFinite(spanStart) || !Number.isFinite(spanEnd)) {
|
|
61936
62209
|
return null;
|
|
61937
62210
|
}
|
|
61938
|
-
const firstChild =
|
|
62211
|
+
const firstChild = targetEl.firstChild;
|
|
61939
62212
|
if (!firstChild || firstChild.nodeType !== Node.TEXT_NODE || !firstChild.textContent) {
|
|
61940
|
-
const
|
|
61941
|
-
const closerToLeft = Math.abs(viewX -
|
|
62213
|
+
const elRect = targetEl.getBoundingClientRect();
|
|
62214
|
+
const closerToLeft = Math.abs(viewX - elRect.left) <= Math.abs(viewX - elRect.right);
|
|
61942
62215
|
const snapPos = closerToLeft ? spanStart : spanEnd;
|
|
61943
62216
|
return snapPos;
|
|
61944
62217
|
}
|
|
61945
62218
|
const textNode = firstChild;
|
|
61946
|
-
const charIndex = findCharIndexAtX(textNode,
|
|
62219
|
+
const charIndex = findCharIndexAtX(textNode, targetEl, viewX);
|
|
61947
62220
|
const pos = spanStart + charIndex;
|
|
61948
62221
|
return pos;
|
|
61949
62222
|
}
|
|
@@ -61981,7 +62254,8 @@ function findSpanAtX(spanEls, viewX) {
|
|
|
61981
62254
|
const span = spanEls[i];
|
|
61982
62255
|
const rect = span.getBoundingClientRect();
|
|
61983
62256
|
if (viewX >= rect.left && viewX <= rect.right) {
|
|
61984
|
-
log("findSpanAtX: Found containing
|
|
62257
|
+
log("findSpanAtX: Found containing element at index", i, {
|
|
62258
|
+
tag: span.tagName,
|
|
61985
62259
|
pmStart: span.dataset.pmStart,
|
|
61986
62260
|
pmEnd: span.dataset.pmEnd,
|
|
61987
62261
|
rect: { left: rect.left, right: rect.right },
|
|
@@ -61993,16 +62267,17 @@ function findSpanAtX(spanEls, viewX) {
|
|
|
61993
62267
|
targetSpan = span;
|
|
61994
62268
|
}
|
|
61995
62269
|
}
|
|
61996
|
-
log("findSpanAtX: No containing
|
|
62270
|
+
log("findSpanAtX: No containing element, using nearest:", {
|
|
62271
|
+
tag: targetSpan.tagName,
|
|
61997
62272
|
pmStart: targetSpan.dataset.pmStart,
|
|
61998
62273
|
pmEnd: targetSpan.dataset.pmEnd,
|
|
61999
62274
|
viewX
|
|
62000
62275
|
});
|
|
62001
62276
|
return targetSpan;
|
|
62002
62277
|
}
|
|
62003
|
-
function findCharIndexAtX(textNode,
|
|
62278
|
+
function findCharIndexAtX(textNode, container, targetX) {
|
|
62004
62279
|
const text = textNode.textContent ?? "";
|
|
62005
|
-
const baseLeft =
|
|
62280
|
+
const baseLeft = container.getBoundingClientRect().left;
|
|
62006
62281
|
const range2 = document.createRange();
|
|
62007
62282
|
let lo = 0;
|
|
62008
62283
|
let hi = text.length;
|
|
@@ -62334,6 +62609,9 @@ function computeNextSectionPropsAtBreak(blocks) {
|
|
|
62334
62609
|
if (source.orientation) {
|
|
62335
62610
|
props.orientation = source.orientation;
|
|
62336
62611
|
}
|
|
62612
|
+
if (source.vAlign) {
|
|
62613
|
+
props.vAlign = source.vAlign;
|
|
62614
|
+
}
|
|
62337
62615
|
return props;
|
|
62338
62616
|
};
|
|
62339
62617
|
docxBreakIndexes.forEach((index2, ordinal) => {
|
|
@@ -63734,6 +64012,10 @@ function cloneBlockWithResolvedTokens(block, displayPageText, totalPagesStr) {
|
|
|
63734
64012
|
runs: clonedRuns
|
|
63735
64013
|
};
|
|
63736
64014
|
}
|
|
64015
|
+
const DEFAULT_PARAGRAPH_LINE_HEIGHT_PX = 20;
|
|
64016
|
+
function hasHeight(fragment) {
|
|
64017
|
+
return fragment.kind === "image" || fragment.kind === "drawing" || fragment.kind === "table";
|
|
64018
|
+
}
|
|
63737
64019
|
const DEFAULT_PAGE_SIZE$2 = { w: 612, h: 792 };
|
|
63738
64020
|
const DEFAULT_MARGINS$2 = { top: 72, right: 72, bottom: 72, left: 72 };
|
|
63739
64021
|
const COLUMN_EPSILON = 1e-4;
|
|
@@ -63828,6 +64110,8 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
63828
64110
|
let pendingColumns = null;
|
|
63829
64111
|
let activeOrientation = null;
|
|
63830
64112
|
let pendingOrientation = null;
|
|
64113
|
+
let activeVAlign = null;
|
|
64114
|
+
let pendingVAlign = null;
|
|
63831
64115
|
const floatManager = createFloatingObjectManager(
|
|
63832
64116
|
normalizeColumns(activeColumns, contentWidth),
|
|
63833
64117
|
{ left: margins.left, right: margins.right },
|
|
@@ -63933,6 +64217,9 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
63933
64217
|
if (activeOrientation) {
|
|
63934
64218
|
page.orientation = activeOrientation;
|
|
63935
64219
|
}
|
|
64220
|
+
if (activeVAlign && activeVAlign !== "top") {
|
|
64221
|
+
page.vAlign = activeVAlign;
|
|
64222
|
+
}
|
|
63936
64223
|
return page;
|
|
63937
64224
|
};
|
|
63938
64225
|
let pageCount = 0;
|
|
@@ -64011,6 +64298,10 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
64011
64298
|
activeSectionRefs = pendingSectionRefs;
|
|
64012
64299
|
pendingSectionRefs = null;
|
|
64013
64300
|
}
|
|
64301
|
+
if (pendingVAlign !== null) {
|
|
64302
|
+
activeVAlign = pendingVAlign;
|
|
64303
|
+
pendingVAlign = null;
|
|
64304
|
+
}
|
|
64014
64305
|
pageCount += 1;
|
|
64015
64306
|
return;
|
|
64016
64307
|
}
|
|
@@ -64147,7 +64438,8 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
64147
64438
|
margins: ahead.margins ? { ...effectiveBlock.margins ?? {}, ...ahead.margins } : effectiveBlock.margins ?? {},
|
|
64148
64439
|
pageSize: ahead.pageSize ?? effectiveBlock.pageSize,
|
|
64149
64440
|
columns: ahead.columns ?? effectiveBlock.columns,
|
|
64150
|
-
orientation: ahead.orientation ?? effectiveBlock.orientation
|
|
64441
|
+
orientation: ahead.orientation ?? effectiveBlock.orientation,
|
|
64442
|
+
vAlign: ahead.vAlign ?? effectiveBlock.vAlign
|
|
64151
64443
|
};
|
|
64152
64444
|
}
|
|
64153
64445
|
const sectionState = {
|
|
@@ -64200,6 +64492,15 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
64200
64492
|
pendingColumns = updatedState.pendingColumns;
|
|
64201
64493
|
activeOrientation = updatedState.activeOrientation;
|
|
64202
64494
|
pendingOrientation = updatedState.pendingOrientation;
|
|
64495
|
+
if (effectiveBlock.vAlign) {
|
|
64496
|
+
const isFirstSection = effectiveBlock.attrs?.isFirstSection && states.length === 0;
|
|
64497
|
+
if (isFirstSection) {
|
|
64498
|
+
activeVAlign = effectiveBlock.vAlign;
|
|
64499
|
+
pendingVAlign = null;
|
|
64500
|
+
} else {
|
|
64501
|
+
pendingVAlign = effectiveBlock.vAlign;
|
|
64502
|
+
}
|
|
64503
|
+
}
|
|
64203
64504
|
if (effectiveBlock.headerRefs || effectiveBlock.footerRefs) {
|
|
64204
64505
|
pendingSectionRefs = {
|
|
64205
64506
|
...effectiveBlock.headerRefs && { headerRefs: effectiveBlock.headerRefs },
|
|
@@ -64208,8 +64509,17 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
64208
64509
|
layoutLog(`[Layout] After scheduleSectionBreakCompat: Scheduled pendingSectionRefs:`, pendingSectionRefs);
|
|
64209
64510
|
}
|
|
64210
64511
|
if (breakInfo.forceMidPageRegion && block.columns) {
|
|
64211
|
-
|
|
64212
|
-
|
|
64512
|
+
let state2 = paginator.ensurePage();
|
|
64513
|
+
const columnIndexBefore = state2.columnIndex;
|
|
64514
|
+
const rawCount = block.columns.count;
|
|
64515
|
+
const validatedCount = typeof rawCount === "number" && Number.isFinite(rawCount) && rawCount > 0 ? Math.max(1, Math.floor(rawCount)) : 1;
|
|
64516
|
+
const rawGap = block.columns.gap;
|
|
64517
|
+
const validatedGap = typeof rawGap === "number" && Number.isFinite(rawGap) && rawGap >= 0 ? Math.max(0, rawGap) : 0;
|
|
64518
|
+
const newColumns = { count: validatedCount, gap: validatedGap };
|
|
64519
|
+
if (columnIndexBefore >= newColumns.count) {
|
|
64520
|
+
state2 = paginator.startNewPage();
|
|
64521
|
+
}
|
|
64522
|
+
startMidPageRegion(state2, newColumns);
|
|
64213
64523
|
}
|
|
64214
64524
|
if (breakInfo.forcePageBreak) {
|
|
64215
64525
|
let state2 = paginator.ensurePage();
|
|
@@ -64401,6 +64711,45 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
64401
64711
|
while (pages.length > 0 && pages[pages.length - 1].fragments.length === 0) {
|
|
64402
64712
|
pages.pop();
|
|
64403
64713
|
}
|
|
64714
|
+
for (const page of pages) {
|
|
64715
|
+
if (!page.vAlign || page.vAlign === "top") continue;
|
|
64716
|
+
if (page.fragments.length === 0) continue;
|
|
64717
|
+
const pageSizeForPage = page.size ?? pageSize;
|
|
64718
|
+
const contentTop = page.margins?.top ?? margins.top;
|
|
64719
|
+
const contentBottom = pageSizeForPage.h - (page.margins?.bottom ?? margins.bottom);
|
|
64720
|
+
const contentHeight = contentBottom - contentTop;
|
|
64721
|
+
let minY = Infinity;
|
|
64722
|
+
let maxY = -Infinity;
|
|
64723
|
+
for (const fragment of page.fragments) {
|
|
64724
|
+
if (fragment.y < minY) minY = fragment.y;
|
|
64725
|
+
let fragmentBottom = fragment.y;
|
|
64726
|
+
if (hasHeight(fragment)) {
|
|
64727
|
+
fragmentBottom += fragment.height;
|
|
64728
|
+
} else {
|
|
64729
|
+
const lineCount = fragment.toLine - fragment.fromLine;
|
|
64730
|
+
fragmentBottom += lineCount * DEFAULT_PARAGRAPH_LINE_HEIGHT_PX;
|
|
64731
|
+
}
|
|
64732
|
+
if (fragmentBottom > maxY) maxY = fragmentBottom;
|
|
64733
|
+
}
|
|
64734
|
+
const actualContentHeight = maxY - minY;
|
|
64735
|
+
const availableSpace = contentHeight - actualContentHeight;
|
|
64736
|
+
if (availableSpace <= 0) {
|
|
64737
|
+
continue;
|
|
64738
|
+
}
|
|
64739
|
+
let yOffset = 0;
|
|
64740
|
+
if (page.vAlign === "center") {
|
|
64741
|
+
yOffset = availableSpace / 2;
|
|
64742
|
+
} else if (page.vAlign === "bottom") {
|
|
64743
|
+
yOffset = availableSpace;
|
|
64744
|
+
} else if (page.vAlign === "both") {
|
|
64745
|
+
yOffset = availableSpace / 2;
|
|
64746
|
+
}
|
|
64747
|
+
if (yOffset > 0) {
|
|
64748
|
+
for (const fragment of page.fragments) {
|
|
64749
|
+
fragment.y += yOffset;
|
|
64750
|
+
}
|
|
64751
|
+
}
|
|
64752
|
+
}
|
|
64404
64753
|
return {
|
|
64405
64754
|
pageSize,
|
|
64406
64755
|
pages,
|
|
@@ -68828,14 +69177,25 @@ const PRINT_STYLES = `
|
|
|
68828
69177
|
}
|
|
68829
69178
|
`;
|
|
68830
69179
|
const LINK_AND_TOC_STYLES = `
|
|
68831
|
-
/* Reset browser default link styling - allow run colors to show through
|
|
69180
|
+
/* Reset browser default link styling - allow run colors to show through from inline styles
|
|
69181
|
+
*
|
|
69182
|
+
* Note: !important was removed from these rules to allow inline styles to take precedence.
|
|
69183
|
+
* This is necessary because OOXML hyperlink character styles apply colors via inline style
|
|
69184
|
+
* attributes on the run elements. The CSS cascade ensures that inline styles (applied via
|
|
69185
|
+
* element.style.color in applyRunStyles) override these class-based rules naturally.
|
|
69186
|
+
*
|
|
69187
|
+
* Implications:
|
|
69188
|
+
* - OOXML hyperlink character styles will correctly display their assigned colors
|
|
69189
|
+
* - Browser default link colors are still reset by these inherit rules
|
|
69190
|
+
* - Inline color styles from run objects override the inherit value as expected
|
|
69191
|
+
*/
|
|
68832
69192
|
.superdoc-link {
|
|
68833
|
-
color: inherit
|
|
68834
|
-
text-decoration: none
|
|
69193
|
+
color: inherit;
|
|
69194
|
+
text-decoration: none;
|
|
68835
69195
|
}
|
|
68836
69196
|
|
|
68837
69197
|
.superdoc-link:visited {
|
|
68838
|
-
color: inherit
|
|
69198
|
+
color: inherit;
|
|
68839
69199
|
}
|
|
68840
69200
|
|
|
68841
69201
|
.superdoc-link:hover {
|
|
@@ -70374,14 +70734,23 @@ const _DomPainter = class _DomPainter2 {
|
|
|
70374
70734
|
lines.forEach((line, index2) => {
|
|
70375
70735
|
const lineEl = this.renderLine(block, line, context);
|
|
70376
70736
|
const isListFirstLine = index2 === 0 && !fragment.continuesFromPrev && fragment.markerWidth && wordLayout?.marker;
|
|
70377
|
-
|
|
70378
|
-
|
|
70737
|
+
const hasExplicitSegmentPositioning = line.segments?.some((seg) => seg.x !== void 0);
|
|
70738
|
+
const isFirstLine = index2 === 0 && !fragment.continuesFromPrev;
|
|
70739
|
+
if (!isListFirstLine) {
|
|
70740
|
+
if (isFirstLine && hasExplicitSegmentPositioning && firstLineOffset !== 0) {
|
|
70741
|
+
const adjustedPadding = paraIndentLeft + firstLineOffset;
|
|
70742
|
+
lineEl.style.paddingLeft = `${adjustedPadding}px`;
|
|
70743
|
+
} else if (paraIndentLeft) {
|
|
70744
|
+
lineEl.style.paddingLeft = `${paraIndentLeft}px`;
|
|
70745
|
+
}
|
|
70379
70746
|
}
|
|
70380
70747
|
if (paraIndentRight) {
|
|
70381
70748
|
lineEl.style.paddingRight = `${paraIndentRight}px`;
|
|
70382
70749
|
}
|
|
70383
70750
|
if (!fragment.continuesFromPrev && index2 === 0 && firstLineOffset && !isListFirstLine) {
|
|
70384
|
-
|
|
70751
|
+
if (!hasExplicitSegmentPositioning) {
|
|
70752
|
+
lineEl.style.textIndent = `${firstLineOffset}px`;
|
|
70753
|
+
}
|
|
70385
70754
|
} else if (firstLineOffset && !isListFirstLine) {
|
|
70386
70755
|
lineEl.style.textIndent = "0px";
|
|
70387
70756
|
}
|
|
@@ -71275,6 +71644,24 @@ const _DomPainter = class _DomPainter2 {
|
|
|
71275
71644
|
}
|
|
71276
71645
|
elem.setAttribute("role", "link");
|
|
71277
71646
|
elem.setAttribute("tabindex", "0");
|
|
71647
|
+
elem.addEventListener("click", (event) => {
|
|
71648
|
+
event.preventDefault();
|
|
71649
|
+
event.stopPropagation();
|
|
71650
|
+
const linkClickEvent = new CustomEvent("superdoc-link-click", {
|
|
71651
|
+
bubbles: true,
|
|
71652
|
+
composed: true,
|
|
71653
|
+
detail: {
|
|
71654
|
+
href: linkData.href,
|
|
71655
|
+
target: linkData.target,
|
|
71656
|
+
rel: linkData.rel,
|
|
71657
|
+
tooltip: linkData.tooltip,
|
|
71658
|
+
element: elem,
|
|
71659
|
+
clientX: event.clientX,
|
|
71660
|
+
clientY: event.clientY
|
|
71661
|
+
}
|
|
71662
|
+
});
|
|
71663
|
+
elem.dispatchEvent(linkClickEvent);
|
|
71664
|
+
});
|
|
71278
71665
|
}
|
|
71279
71666
|
/**
|
|
71280
71667
|
* Render a single run as an HTML element (span or anchor).
|
|
@@ -71564,7 +71951,13 @@ const _DomPainter = class _DomPainter2 {
|
|
|
71564
71951
|
if (styleId) {
|
|
71565
71952
|
elem.setAttribute("styleid", styleId);
|
|
71566
71953
|
}
|
|
71954
|
+
const runSegments2 = segmentsByRun.get(runIndex);
|
|
71955
|
+
const segX = runSegments2 && runSegments2[0]?.x !== void 0 ? runSegments2[0].x : cumulativeX;
|
|
71956
|
+
const segWidth = (runSegments2 && runSegments2[0]?.width !== void 0 ? runSegments2[0].width : elem.offsetWidth) ?? 0;
|
|
71957
|
+
elem.style.position = "absolute";
|
|
71958
|
+
elem.style.left = `${segX}px`;
|
|
71567
71959
|
el.appendChild(elem);
|
|
71960
|
+
cumulativeX = segX + segWidth;
|
|
71568
71961
|
}
|
|
71569
71962
|
continue;
|
|
71570
71963
|
}
|
|
@@ -72106,7 +72499,7 @@ const deriveBlockVersion = (block) => {
|
|
|
72106
72499
|
}
|
|
72107
72500
|
return block.id;
|
|
72108
72501
|
};
|
|
72109
|
-
const applyRunStyles = (element, run2,
|
|
72502
|
+
const applyRunStyles = (element, run2, _isLink = false) => {
|
|
72110
72503
|
if (run2.kind === "tab" || run2.kind === "image" || run2.kind === "lineBreak" || run2.kind === "break") {
|
|
72111
72504
|
return;
|
|
72112
72505
|
}
|
|
@@ -72114,9 +72507,7 @@ const applyRunStyles = (element, run2, isLink = false) => {
|
|
|
72114
72507
|
element.style.fontSize = `${run2.fontSize}px`;
|
|
72115
72508
|
if (run2.bold) element.style.fontWeight = "bold";
|
|
72116
72509
|
if (run2.italic) element.style.fontStyle = "italic";
|
|
72117
|
-
if (
|
|
72118
|
-
if (run2.color) element.style.color = run2.color;
|
|
72119
|
-
}
|
|
72510
|
+
if (run2.color) element.style.color = run2.color;
|
|
72120
72511
|
if (run2.letterSpacing != null) {
|
|
72121
72512
|
element.style.letterSpacing = `${run2.letterSpacing}px`;
|
|
72122
72513
|
}
|
|
@@ -72664,28 +73055,44 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
72664
73055
|
}
|
|
72665
73056
|
return true;
|
|
72666
73057
|
};
|
|
72667
|
-
const
|
|
72668
|
-
if (!pendingTabAlignment || !currentLine) return;
|
|
73058
|
+
const alignPendingTabForWidth = (segmentWidth, beforeDecimalWidth) => {
|
|
73059
|
+
if (!pendingTabAlignment || !currentLine) return void 0;
|
|
73060
|
+
if (segmentWidth < 0) {
|
|
73061
|
+
segmentWidth = 0;
|
|
73062
|
+
}
|
|
72669
73063
|
const { target, val } = pendingTabAlignment;
|
|
72670
73064
|
let startX = currentLine.width;
|
|
73065
|
+
if (val === "decimal") {
|
|
73066
|
+
const beforeWidth = beforeDecimalWidth ?? 0;
|
|
73067
|
+
startX = Math.max(0, target - beforeWidth);
|
|
73068
|
+
} else if (val === "end") {
|
|
73069
|
+
startX = Math.max(0, target - segmentWidth);
|
|
73070
|
+
} else if (val === "center") {
|
|
73071
|
+
startX = Math.max(0, target - segmentWidth / 2);
|
|
73072
|
+
} else {
|
|
73073
|
+
startX = Math.max(0, target);
|
|
73074
|
+
}
|
|
73075
|
+
currentLine.width = roundValue(startX);
|
|
73076
|
+
lastAppliedTabAlign = { target, val };
|
|
73077
|
+
pendingTabAlignment = null;
|
|
73078
|
+
return startX;
|
|
73079
|
+
};
|
|
73080
|
+
const alignSegmentAtTab = (segmentText, font, runContext) => {
|
|
73081
|
+
if (!pendingTabAlignment || !currentLine) return void 0;
|
|
73082
|
+
const { val } = pendingTabAlignment;
|
|
73083
|
+
let segmentWidth = 0;
|
|
73084
|
+
let beforeDecimalWidth;
|
|
72671
73085
|
if (val === "decimal") {
|
|
72672
73086
|
const idx = segmentText.indexOf(decimalSeparator);
|
|
72673
73087
|
if (idx >= 0) {
|
|
72674
73088
|
const beforeText = segmentText.slice(0, idx);
|
|
72675
|
-
|
|
72676
|
-
startX = Math.max(0, target - beforeWidth);
|
|
72677
|
-
} else {
|
|
72678
|
-
startX = Math.max(0, target);
|
|
73089
|
+
beforeDecimalWidth = beforeText.length > 0 ? measureRunWidth(beforeText, font, ctx2, runContext) : 0;
|
|
72679
73090
|
}
|
|
73091
|
+
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext) : 0;
|
|
72680
73092
|
} else if (val === "end" || val === "center") {
|
|
72681
|
-
|
|
72682
|
-
startX = val === "end" ? Math.max(0, target - segWidth) : Math.max(0, target - segWidth / 2);
|
|
72683
|
-
} else if (val === "start" || val === "bar") {
|
|
72684
|
-
startX = Math.max(0, target);
|
|
73093
|
+
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext) : 0;
|
|
72685
73094
|
}
|
|
72686
|
-
|
|
72687
|
-
lastAppliedTabAlign = { target, val };
|
|
72688
|
-
pendingTabAlignment = null;
|
|
73095
|
+
return alignPendingTabForWidth(segmentWidth, beforeDecimalWidth);
|
|
72689
73096
|
};
|
|
72690
73097
|
const runsToProcess = [];
|
|
72691
73098
|
for (const run2 of block.runs) {
|
|
@@ -72834,6 +73241,10 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
72834
73241
|
const topSpace = run2.distTop ?? 0;
|
|
72835
73242
|
const bottomSpace = run2.distBottom ?? 0;
|
|
72836
73243
|
const imageHeight = run2.height + topSpace + bottomSpace;
|
|
73244
|
+
let imageStartX;
|
|
73245
|
+
if (pendingTabAlignment && currentLine) {
|
|
73246
|
+
imageStartX = alignPendingTabForWidth(imageWidth);
|
|
73247
|
+
}
|
|
72837
73248
|
if (!currentLine) {
|
|
72838
73249
|
currentLine = {
|
|
72839
73250
|
fromRun: runIndex,
|
|
@@ -72850,12 +73261,14 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
72850
73261
|
runIndex,
|
|
72851
73262
|
fromChar: 0,
|
|
72852
73263
|
toChar: 1,
|
|
72853
|
-
width: imageWidth
|
|
73264
|
+
width: imageWidth,
|
|
73265
|
+
...imageStartX !== void 0 ? { x: imageStartX } : {}
|
|
72854
73266
|
}
|
|
72855
73267
|
]
|
|
72856
73268
|
};
|
|
72857
73269
|
continue;
|
|
72858
73270
|
}
|
|
73271
|
+
const appliedTabAlign = lastAppliedTabAlign;
|
|
72859
73272
|
if (currentLine.width + imageWidth > currentLine.maxWidth && currentLine.width > 0) {
|
|
72860
73273
|
const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing);
|
|
72861
73274
|
const completedLine = {
|
|
@@ -72866,6 +73279,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
72866
73279
|
lines.push(completedLine);
|
|
72867
73280
|
tabStopCursor = 0;
|
|
72868
73281
|
pendingTabAlignment = null;
|
|
73282
|
+
lastAppliedTabAlign = null;
|
|
72869
73283
|
currentLine = {
|
|
72870
73284
|
fromRun: runIndex,
|
|
72871
73285
|
fromChar: 0,
|
|
@@ -72893,9 +73307,15 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
72893
73307
|
runIndex,
|
|
72894
73308
|
fromChar: 0,
|
|
72895
73309
|
toChar: 1,
|
|
72896
|
-
width: imageWidth
|
|
73310
|
+
width: imageWidth,
|
|
73311
|
+
...imageStartX !== void 0 ? { x: imageStartX } : {}
|
|
72897
73312
|
});
|
|
72898
73313
|
}
|
|
73314
|
+
const tabAlign = appliedTabAlign;
|
|
73315
|
+
if (tabAlign && currentLine && tabAlign.val === "end") {
|
|
73316
|
+
currentLine.width = roundValue(tabAlign.target);
|
|
73317
|
+
}
|
|
73318
|
+
lastAppliedTabAlign = null;
|
|
72899
73319
|
continue;
|
|
72900
73320
|
}
|
|
72901
73321
|
if (!("text" in run2) || !("fontSize" in run2)) {
|
|
@@ -72911,8 +73331,10 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
72911
73331
|
const words = segment.split(" ");
|
|
72912
73332
|
let segmentStartX;
|
|
72913
73333
|
if (currentLine && pendingTabAlignment) {
|
|
72914
|
-
alignSegmentAtTab(segment, font, run2);
|
|
72915
|
-
segmentStartX
|
|
73334
|
+
segmentStartX = alignSegmentAtTab(segment, font, run2);
|
|
73335
|
+
if (segmentStartX == null) {
|
|
73336
|
+
segmentStartX = currentLine.width;
|
|
73337
|
+
}
|
|
72916
73338
|
}
|
|
72917
73339
|
for (let wordIndex = 0; wordIndex < words.length; wordIndex++) {
|
|
72918
73340
|
const word = words[wordIndex];
|
|
@@ -73553,12 +73975,49 @@ const createHeaderFooterEditor = ({
|
|
|
73553
73975
|
editor,
|
|
73554
73976
|
data,
|
|
73555
73977
|
editorContainer,
|
|
73556
|
-
|
|
73978
|
+
editorHost,
|
|
73557
73979
|
sectionId,
|
|
73558
73980
|
type: type2,
|
|
73981
|
+
availableWidth,
|
|
73559
73982
|
availableHeight,
|
|
73560
|
-
currentPageNumber
|
|
73983
|
+
currentPageNumber,
|
|
73984
|
+
totalPageCount
|
|
73561
73985
|
}) => {
|
|
73986
|
+
if (!editor) {
|
|
73987
|
+
throw new TypeError("editor parameter is required");
|
|
73988
|
+
}
|
|
73989
|
+
if (!data) {
|
|
73990
|
+
throw new TypeError("data parameter is required");
|
|
73991
|
+
}
|
|
73992
|
+
if (!editorContainer) {
|
|
73993
|
+
throw new TypeError("editorContainer parameter is required");
|
|
73994
|
+
}
|
|
73995
|
+
if (!(editorContainer instanceof HTMLElement)) {
|
|
73996
|
+
throw new TypeError("editorContainer must be an HTMLElement");
|
|
73997
|
+
}
|
|
73998
|
+
if (editorHost !== void 0 && !(editorHost instanceof HTMLElement)) {
|
|
73999
|
+
throw new TypeError("editorHost must be an HTMLElement or undefined");
|
|
74000
|
+
}
|
|
74001
|
+
if (availableWidth !== void 0) {
|
|
74002
|
+
if (typeof availableWidth !== "number" || !Number.isFinite(availableWidth) || availableWidth <= 0) {
|
|
74003
|
+
throw new RangeError("availableWidth must be a positive number");
|
|
74004
|
+
}
|
|
74005
|
+
}
|
|
74006
|
+
if (availableHeight !== void 0) {
|
|
74007
|
+
if (typeof availableHeight !== "number" || !Number.isFinite(availableHeight) || availableHeight <= 0) {
|
|
74008
|
+
throw new RangeError("availableHeight must be a positive number");
|
|
74009
|
+
}
|
|
74010
|
+
}
|
|
74011
|
+
if (currentPageNumber !== void 0) {
|
|
74012
|
+
if (typeof currentPageNumber !== "number" || !Number.isInteger(currentPageNumber) || currentPageNumber < 1) {
|
|
74013
|
+
throw new RangeError("currentPageNumber must be a positive integer");
|
|
74014
|
+
}
|
|
74015
|
+
}
|
|
74016
|
+
if (totalPageCount !== void 0) {
|
|
74017
|
+
if (typeof totalPageCount !== "number" || !Number.isInteger(totalPageCount) || totalPageCount < 1) {
|
|
74018
|
+
throw new RangeError("totalPageCount must be a positive integer");
|
|
74019
|
+
}
|
|
74020
|
+
}
|
|
73562
74021
|
const parentStyles = editor.converter.getDocumentDefaultStyles();
|
|
73563
74022
|
const { fontSizePt, typeface, fontFamilyCss } = parentStyles;
|
|
73564
74023
|
const fontSizeInPixles = fontSizePt * 1.3333;
|
|
@@ -73572,21 +74031,24 @@ const createHeaderFooterEditor = ({
|
|
|
73572
74031
|
position: "absolute",
|
|
73573
74032
|
top: "0",
|
|
73574
74033
|
left: "0",
|
|
73575
|
-
width: "
|
|
74034
|
+
width: availableWidth ? `${availableWidth}px` : "100%",
|
|
74035
|
+
height: availableHeight ? `${availableHeight}px` : "auto",
|
|
73576
74036
|
maxWidth: "none",
|
|
73577
74037
|
fontFamily: fontFamilyCss || typeface,
|
|
73578
74038
|
fontSize: `${fontSizeInPixles}px`,
|
|
73579
|
-
lineHeight: `${lineHeight2}px
|
|
73580
|
-
|
|
73581
|
-
|
|
73582
|
-
|
|
73583
|
-
|
|
73584
|
-
|
|
73585
|
-
|
|
73586
|
-
|
|
73587
|
-
|
|
73588
|
-
}
|
|
73589
|
-
|
|
74039
|
+
lineHeight: `${lineHeight2}px`,
|
|
74040
|
+
overflow: "hidden",
|
|
74041
|
+
pointerEvents: "auto",
|
|
74042
|
+
// Critical: enables click interaction
|
|
74043
|
+
backgroundColor: "white"
|
|
74044
|
+
// Ensure editor has white background
|
|
74045
|
+
});
|
|
74046
|
+
if (editorHost) {
|
|
74047
|
+
editorHost.appendChild(editorContainer);
|
|
74048
|
+
} else {
|
|
74049
|
+
console.warn("[createHeaderFooterEditor] No editorHost provided, falling back to document.body");
|
|
74050
|
+
document.body.appendChild(editorContainer);
|
|
74051
|
+
}
|
|
73590
74052
|
const headerFooterEditor = new Editor({
|
|
73591
74053
|
role: editor.options.role,
|
|
73592
74054
|
loadFromSchema: true,
|
|
@@ -73604,9 +74066,12 @@ const createHeaderFooterEditor = ({
|
|
|
73604
74066
|
pagination: false,
|
|
73605
74067
|
// Explicitly disable pagination
|
|
73606
74068
|
annotations: true,
|
|
73607
|
-
currentPageNumber,
|
|
74069
|
+
currentPageNumber: currentPageNumber ?? 1,
|
|
74070
|
+
totalPageCount: totalPageCount ?? 1,
|
|
73608
74071
|
// Don't set parentEditor to avoid circular reference issues
|
|
73609
74072
|
// parentEditor: editor,
|
|
74073
|
+
// IMPORTANT: Start with editable: false to prevent triggering update cascades during creation.
|
|
74074
|
+
// PresentationEditor#enterHeaderFooterMode will call setEditable(true) when entering edit mode.
|
|
73610
74075
|
editable: false,
|
|
73611
74076
|
documentMode: "viewing",
|
|
73612
74077
|
onCreate: (evt) => setEditorToolbar(evt, editor),
|
|
@@ -73636,18 +74101,23 @@ const createHeaderFooterEditor = ({
|
|
|
73636
74101
|
const onHeaderFooterDataUpdate = async ({ editor, transaction }, mainEditor, sectionId, type2) => {
|
|
73637
74102
|
if (!type2 || !sectionId) return;
|
|
73638
74103
|
const updatedData = editor.getUpdatedJson();
|
|
73639
|
-
mainEditor.converter[`${type2}Editors`]
|
|
73640
|
-
|
|
74104
|
+
const editorsList = mainEditor.converter[`${type2}Editors`];
|
|
74105
|
+
if (Array.isArray(editorsList)) {
|
|
74106
|
+
editorsList.forEach((item) => {
|
|
74107
|
+
if (item.id === sectionId) {
|
|
74108
|
+
item.editor.setOptions({
|
|
74109
|
+
media: editor.options.media,
|
|
74110
|
+
mediaFiles: editor.options.mediaFiles
|
|
74111
|
+
});
|
|
74112
|
+
if (item.editor !== editor) {
|
|
74113
|
+
item.editor.replaceContent(updatedData);
|
|
74114
|
+
}
|
|
74115
|
+
}
|
|
73641
74116
|
item.editor.setOptions({
|
|
73642
|
-
|
|
73643
|
-
mediaFiles: editor.options.mediaFiles
|
|
74117
|
+
lastSelection: transaction?.selection
|
|
73644
74118
|
});
|
|
73645
|
-
item.editor.replaceContent(updatedData);
|
|
73646
|
-
}
|
|
73647
|
-
item.editor.setOptions({
|
|
73648
|
-
lastSelection: transaction?.selection
|
|
73649
74119
|
});
|
|
73650
|
-
}
|
|
74120
|
+
}
|
|
73651
74121
|
mainEditor.converter[`${type2}s`][sectionId] = updatedData;
|
|
73652
74122
|
mainEditor.setOptions({ isHeaderFooterChanged: editor.docChanged });
|
|
73653
74123
|
await updateYdocDocxData(mainEditor);
|
|
@@ -73728,13 +74198,69 @@ class HeaderFooterEditorManager extends EventEmitter$1 {
|
|
|
73728
74198
|
* Handles concurrent calls for the same descriptor by tracking pending creations
|
|
73729
74199
|
* and returning the same promise to all callers.
|
|
73730
74200
|
*
|
|
73731
|
-
* @param descriptor - The header or footer descriptor
|
|
74201
|
+
* @param descriptor - The header or footer descriptor. Must have a valid id property.
|
|
74202
|
+
* @param options - Optional configuration for editor creation
|
|
74203
|
+
* @param options.editorHost - The HTMLElement to mount the editor in. If provided, must be a valid HTMLElement.
|
|
74204
|
+
* @param options.availableWidth - The width of the editing region in pixels. Must be a positive number if provided.
|
|
74205
|
+
* @param options.availableHeight - The height of the editing region in pixels. Must be a positive number if provided.
|
|
74206
|
+
* @param options.currentPageNumber - The current page number for PAGE field resolution. Must be a positive integer if provided.
|
|
74207
|
+
* @param options.totalPageCount - The total page count for NUMPAGES field resolution. Must be a positive integer if provided.
|
|
73732
74208
|
* @returns The editor instance, or null if creation failed
|
|
73733
74209
|
*
|
|
73734
|
-
* @throws Never throws - errors are logged and emitted as events
|
|
74210
|
+
* @throws Never throws - errors are logged and emitted as events. Invalid parameters return null with error logged.
|
|
73735
74211
|
*/
|
|
73736
|
-
async ensureEditor(descriptor) {
|
|
74212
|
+
async ensureEditor(descriptor, options) {
|
|
73737
74213
|
if (!descriptor?.id) return null;
|
|
74214
|
+
if (options) {
|
|
74215
|
+
if (options.editorHost !== void 0 && !(options.editorHost instanceof HTMLElement)) {
|
|
74216
|
+
console.error("[HeaderFooterEditorManager] editorHost must be an HTMLElement");
|
|
74217
|
+
this.emit("error", {
|
|
74218
|
+
descriptor,
|
|
74219
|
+
error: new TypeError("editorHost must be an HTMLElement")
|
|
74220
|
+
});
|
|
74221
|
+
return null;
|
|
74222
|
+
}
|
|
74223
|
+
if (options.availableWidth !== void 0) {
|
|
74224
|
+
if (typeof options.availableWidth !== "number" || !Number.isFinite(options.availableWidth) || options.availableWidth <= 0) {
|
|
74225
|
+
console.error("[HeaderFooterEditorManager] availableWidth must be a positive number");
|
|
74226
|
+
this.emit("error", {
|
|
74227
|
+
descriptor,
|
|
74228
|
+
error: new TypeError("availableWidth must be a positive number")
|
|
74229
|
+
});
|
|
74230
|
+
return null;
|
|
74231
|
+
}
|
|
74232
|
+
}
|
|
74233
|
+
if (options.availableHeight !== void 0) {
|
|
74234
|
+
if (typeof options.availableHeight !== "number" || !Number.isFinite(options.availableHeight) || options.availableHeight <= 0) {
|
|
74235
|
+
console.error("[HeaderFooterEditorManager] availableHeight must be a positive number");
|
|
74236
|
+
this.emit("error", {
|
|
74237
|
+
descriptor,
|
|
74238
|
+
error: new TypeError("availableHeight must be a positive number")
|
|
74239
|
+
});
|
|
74240
|
+
return null;
|
|
74241
|
+
}
|
|
74242
|
+
}
|
|
74243
|
+
if (options.currentPageNumber !== void 0) {
|
|
74244
|
+
if (typeof options.currentPageNumber !== "number" || !Number.isInteger(options.currentPageNumber) || options.currentPageNumber < 1) {
|
|
74245
|
+
console.error("[HeaderFooterEditorManager] currentPageNumber must be a positive integer");
|
|
74246
|
+
this.emit("error", {
|
|
74247
|
+
descriptor,
|
|
74248
|
+
error: new TypeError("currentPageNumber must be a positive integer")
|
|
74249
|
+
});
|
|
74250
|
+
return null;
|
|
74251
|
+
}
|
|
74252
|
+
}
|
|
74253
|
+
if (options.totalPageCount !== void 0) {
|
|
74254
|
+
if (typeof options.totalPageCount !== "number" || !Number.isInteger(options.totalPageCount) || options.totalPageCount < 1) {
|
|
74255
|
+
console.error("[HeaderFooterEditorManager] totalPageCount must be a positive integer");
|
|
74256
|
+
this.emit("error", {
|
|
74257
|
+
descriptor,
|
|
74258
|
+
error: new TypeError("totalPageCount must be a positive integer")
|
|
74259
|
+
});
|
|
74260
|
+
return null;
|
|
74261
|
+
}
|
|
74262
|
+
}
|
|
74263
|
+
}
|
|
73738
74264
|
const existing = __privateGet$1(this, _editorEntries).get(descriptor.id);
|
|
73739
74265
|
if (existing) {
|
|
73740
74266
|
__privateSet(this, _cacheHits, __privateGet$1(this, _cacheHits) + 1);
|
|
@@ -73743,6 +74269,29 @@ class HeaderFooterEditorManager extends EventEmitter$1 {
|
|
|
73743
74269
|
console.error("[HeaderFooterEditorManager] Editor initialization failed:", error);
|
|
73744
74270
|
this.emit("error", { descriptor, error });
|
|
73745
74271
|
});
|
|
74272
|
+
if (existing.container && options?.editorHost) {
|
|
74273
|
+
if (existing.container.parentElement !== options.editorHost) {
|
|
74274
|
+
options.editorHost.appendChild(existing.container);
|
|
74275
|
+
}
|
|
74276
|
+
}
|
|
74277
|
+
if (existing.editor && options) {
|
|
74278
|
+
const updateOptions = {};
|
|
74279
|
+
if (options.currentPageNumber !== void 0) {
|
|
74280
|
+
updateOptions.currentPageNumber = options.currentPageNumber;
|
|
74281
|
+
}
|
|
74282
|
+
if (options.totalPageCount !== void 0) {
|
|
74283
|
+
updateOptions.totalPageCount = options.totalPageCount;
|
|
74284
|
+
}
|
|
74285
|
+
if (options.availableWidth !== void 0) {
|
|
74286
|
+
updateOptions.availableWidth = options.availableWidth;
|
|
74287
|
+
}
|
|
74288
|
+
if (options.availableHeight !== void 0) {
|
|
74289
|
+
updateOptions.availableHeight = options.availableHeight;
|
|
74290
|
+
}
|
|
74291
|
+
if (Object.keys(updateOptions).length > 0) {
|
|
74292
|
+
existing.editor.setOptions(updateOptions);
|
|
74293
|
+
}
|
|
74294
|
+
}
|
|
73746
74295
|
return existing.editor;
|
|
73747
74296
|
}
|
|
73748
74297
|
const pending = __privateGet$1(this, _pendingCreations).get(descriptor.id);
|
|
@@ -73752,7 +74301,7 @@ class HeaderFooterEditorManager extends EventEmitter$1 {
|
|
|
73752
74301
|
__privateSet(this, _cacheMisses, __privateGet$1(this, _cacheMisses) + 1);
|
|
73753
74302
|
const creationPromise = (async () => {
|
|
73754
74303
|
try {
|
|
73755
|
-
const entry = await __privateMethod$1(this, _HeaderFooterEditorManager_instances, createEditor_fn).call(this, descriptor);
|
|
74304
|
+
const entry = await __privateMethod$1(this, _HeaderFooterEditorManager_instances, createEditor_fn).call(this, descriptor, options);
|
|
73756
74305
|
if (!entry) return null;
|
|
73757
74306
|
__privateGet$1(this, _editorEntries).set(descriptor.id, entry);
|
|
73758
74307
|
__privateMethod$1(this, _HeaderFooterEditorManager_instances, updateAccessOrder_fn).call(this, descriptor.id);
|
|
@@ -74060,7 +74609,7 @@ teardownEditors_fn = function() {
|
|
|
74060
74609
|
});
|
|
74061
74610
|
__privateGet$1(this, _editorEntries).clear();
|
|
74062
74611
|
};
|
|
74063
|
-
createEditor_fn = async function(descriptor) {
|
|
74612
|
+
createEditor_fn = async function(descriptor, options) {
|
|
74064
74613
|
const json = this.getDocumentJson(descriptor);
|
|
74065
74614
|
if (!json) return null;
|
|
74066
74615
|
let editor;
|
|
@@ -74071,12 +74620,13 @@ createEditor_fn = async function(descriptor) {
|
|
|
74071
74620
|
editor: __privateGet$1(this, _editor2),
|
|
74072
74621
|
data: json,
|
|
74073
74622
|
editorContainer: container,
|
|
74074
|
-
|
|
74623
|
+
editorHost: options?.editorHost,
|
|
74075
74624
|
sectionId: descriptor.id,
|
|
74076
74625
|
type: descriptor.kind,
|
|
74077
|
-
|
|
74078
|
-
|
|
74079
|
-
|
|
74626
|
+
availableWidth: options?.availableWidth,
|
|
74627
|
+
availableHeight: options?.availableHeight ?? DEFAULT_HEADER_FOOTER_HEIGHT,
|
|
74628
|
+
currentPageNumber: options?.currentPageNumber ?? 1,
|
|
74629
|
+
totalPageCount: options?.totalPageCount ?? 1
|
|
74080
74630
|
});
|
|
74081
74631
|
} catch (error) {
|
|
74082
74632
|
console.error("[HeaderFooterEditorManager] Editor creation failed:", error);
|
|
@@ -74350,6 +74900,312 @@ getConverterContext_fn = function() {
|
|
|
74350
74900
|
}
|
|
74351
74901
|
return Object.keys(context).length > 0 ? context : void 0;
|
|
74352
74902
|
};
|
|
74903
|
+
const EDITOR_HOST_Z_INDEX = "10";
|
|
74904
|
+
const BORDER_LINE_Z_INDEX = "15";
|
|
74905
|
+
const BORDER_LINE_COLOR = "#4472c4";
|
|
74906
|
+
const BORDER_LINE_HEIGHT = "1px";
|
|
74907
|
+
class EditorOverlayManager {
|
|
74908
|
+
/**
|
|
74909
|
+
* Creates a new EditorOverlayManager instance.
|
|
74910
|
+
*
|
|
74911
|
+
* @param painterHost - The host element containing painted pages. Must be an HTMLElement connected to the DOM.
|
|
74912
|
+
* @param visibleHost - The visible host element for overlay positioning. Must be an HTMLElement connected to the DOM.
|
|
74913
|
+
* @param selectionOverlay - The selection overlay element (optional). If provided, must be an HTMLElement.
|
|
74914
|
+
*
|
|
74915
|
+
* @throws {TypeError} If painterHost is not an HTMLElement
|
|
74916
|
+
* @throws {TypeError} If visibleHost is not an HTMLElement
|
|
74917
|
+
* @throws {TypeError} If selectionOverlay is provided but is not an HTMLElement
|
|
74918
|
+
* @throws {Error} If painterHost is not connected to the DOM
|
|
74919
|
+
* @throws {Error} If visibleHost is not connected to the DOM
|
|
74920
|
+
*/
|
|
74921
|
+
constructor(painterHost, visibleHost, selectionOverlay = null) {
|
|
74922
|
+
__privateAdd$1(this, _EditorOverlayManager_instances);
|
|
74923
|
+
__privateAdd$1(this, _selectionOverlay);
|
|
74924
|
+
__privateAdd$1(this, _activeEditorHost, null);
|
|
74925
|
+
__privateAdd$1(this, _activeDecorationContainer, null);
|
|
74926
|
+
__privateAdd$1(this, _activeRegion, null);
|
|
74927
|
+
__privateAdd$1(this, _borderLine, null);
|
|
74928
|
+
if (!(painterHost instanceof HTMLElement)) {
|
|
74929
|
+
throw new TypeError("painterHost must be an HTMLElement");
|
|
74930
|
+
}
|
|
74931
|
+
if (!(visibleHost instanceof HTMLElement)) {
|
|
74932
|
+
throw new TypeError("visibleHost must be an HTMLElement");
|
|
74933
|
+
}
|
|
74934
|
+
if (selectionOverlay !== null && !(selectionOverlay instanceof HTMLElement)) {
|
|
74935
|
+
throw new TypeError("selectionOverlay must be an HTMLElement or null");
|
|
74936
|
+
}
|
|
74937
|
+
if (!painterHost.isConnected) {
|
|
74938
|
+
throw new Error("painterHost must be connected to the DOM");
|
|
74939
|
+
}
|
|
74940
|
+
if (!visibleHost.isConnected) {
|
|
74941
|
+
throw new Error("visibleHost must be connected to the DOM");
|
|
74942
|
+
}
|
|
74943
|
+
__privateSet(this, _selectionOverlay, selectionOverlay);
|
|
74944
|
+
}
|
|
74945
|
+
/**
|
|
74946
|
+
* Sets the callback to be invoked when the dimming overlay is clicked.
|
|
74947
|
+
* This allows PresentationEditor to exit header/footer mode when the user
|
|
74948
|
+
* clicks outside the editing region.
|
|
74949
|
+
*
|
|
74950
|
+
* @param callback - Function to call when dimming overlay is clicked
|
|
74951
|
+
*/
|
|
74952
|
+
setOnDimmingClick(_callback) {
|
|
74953
|
+
}
|
|
74954
|
+
/**
|
|
74955
|
+
* Gets the currently active editor host element.
|
|
74956
|
+
* This is useful for checking if a click target is inside the active editing area.
|
|
74957
|
+
*
|
|
74958
|
+
* @returns The active editor host element, or null if not in editing mode
|
|
74959
|
+
*/
|
|
74960
|
+
getActiveEditorHost() {
|
|
74961
|
+
return __privateGet$1(this, _activeEditorHost);
|
|
74962
|
+
}
|
|
74963
|
+
/**
|
|
74964
|
+
* Shows the editing overlay for a header/footer region.
|
|
74965
|
+
*
|
|
74966
|
+
* This method:
|
|
74967
|
+
* 1. Creates or retrieves the editor host element as a sibling to the decoration container
|
|
74968
|
+
* 2. Positions the editor host to match the decoration container bounds
|
|
74969
|
+
* 3. Hides the static decoration content
|
|
74970
|
+
* 4. Shows the dimming overlay over body content
|
|
74971
|
+
* 5. Returns the editor host element for mounting the ProseMirror editor
|
|
74972
|
+
*
|
|
74973
|
+
* @param pageElement - The page DOM element containing the region
|
|
74974
|
+
* @param region - The header/footer region to edit
|
|
74975
|
+
* @param zoom - Current zoom level (for positioning calculations)
|
|
74976
|
+
* @returns Result object with success status and editor host element
|
|
74977
|
+
*
|
|
74978
|
+
* @example
|
|
74979
|
+
* ```typescript
|
|
74980
|
+
* const result = overlayManager.showEditingOverlay(pageElement, region, 1.0);
|
|
74981
|
+
* if (result.success && result.editorHost) {
|
|
74982
|
+
* // Mount ProseMirror editor in result.editorHost
|
|
74983
|
+
* }
|
|
74984
|
+
* ```
|
|
74985
|
+
*/
|
|
74986
|
+
showEditingOverlay(pageElement, region, zoom) {
|
|
74987
|
+
try {
|
|
74988
|
+
const decorationContainer = __privateMethod$1(this, _EditorOverlayManager_instances, findDecorationContainer_fn).call(this, pageElement, region.kind);
|
|
74989
|
+
if (!decorationContainer) {
|
|
74990
|
+
return {
|
|
74991
|
+
success: false,
|
|
74992
|
+
reason: `Decoration container not found for ${region.kind} on page ${region.pageIndex}`
|
|
74993
|
+
};
|
|
74994
|
+
}
|
|
74995
|
+
const editorHost = __privateMethod$1(this, _EditorOverlayManager_instances, ensureEditorHost_fn).call(this, pageElement, region.kind);
|
|
74996
|
+
if (!editorHost) {
|
|
74997
|
+
return {
|
|
74998
|
+
success: false,
|
|
74999
|
+
reason: `Failed to create editor host for ${region.kind}`
|
|
75000
|
+
};
|
|
75001
|
+
}
|
|
75002
|
+
__privateMethod$1(this, _EditorOverlayManager_instances, positionEditorHost_fn).call(this, editorHost, region, decorationContainer, zoom);
|
|
75003
|
+
decorationContainer.style.visibility = "hidden";
|
|
75004
|
+
editorHost.style.visibility = "visible";
|
|
75005
|
+
editorHost.style.zIndex = EDITOR_HOST_Z_INDEX;
|
|
75006
|
+
if (region.kind === "footer") {
|
|
75007
|
+
const contentOffset = editorHost.dataset.contentOffset;
|
|
75008
|
+
if (contentOffset) {
|
|
75009
|
+
const editorContainer = editorHost.querySelector(".super-editor");
|
|
75010
|
+
if (editorContainer instanceof HTMLElement) {
|
|
75011
|
+
editorContainer.style.top = `${contentOffset}px`;
|
|
75012
|
+
}
|
|
75013
|
+
}
|
|
75014
|
+
}
|
|
75015
|
+
__privateMethod$1(this, _EditorOverlayManager_instances, showHeaderFooterBorder_fn).call(this, pageElement, region, decorationContainer);
|
|
75016
|
+
__privateSet(this, _activeEditorHost, editorHost);
|
|
75017
|
+
__privateSet(this, _activeDecorationContainer, decorationContainer);
|
|
75018
|
+
__privateSet(this, _activeRegion, region);
|
|
75019
|
+
return {
|
|
75020
|
+
success: true,
|
|
75021
|
+
editorHost
|
|
75022
|
+
};
|
|
75023
|
+
} catch (error) {
|
|
75024
|
+
if (__privateGet$1(this, _activeDecorationContainer)) {
|
|
75025
|
+
__privateGet$1(this, _activeDecorationContainer).style.visibility = "visible";
|
|
75026
|
+
}
|
|
75027
|
+
if (__privateGet$1(this, _activeEditorHost)) {
|
|
75028
|
+
__privateGet$1(this, _activeEditorHost).style.visibility = "hidden";
|
|
75029
|
+
}
|
|
75030
|
+
__privateMethod$1(this, _EditorOverlayManager_instances, hideHeaderFooterBorder_fn).call(this);
|
|
75031
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
75032
|
+
console.error("[EditorOverlayManager] Failed to show editing overlay:", error);
|
|
75033
|
+
return {
|
|
75034
|
+
success: false,
|
|
75035
|
+
reason: `DOM manipulation error: ${errorMessage}`
|
|
75036
|
+
};
|
|
75037
|
+
}
|
|
75038
|
+
}
|
|
75039
|
+
/**
|
|
75040
|
+
* Hides the editing overlay and restores normal view.
|
|
75041
|
+
*
|
|
75042
|
+
* This method:
|
|
75043
|
+
* 1. Shows the static decoration content
|
|
75044
|
+
* 2. Hides the editor host (but doesn't destroy it for reuse)
|
|
75045
|
+
* 3. Removes the dimming overlay
|
|
75046
|
+
*
|
|
75047
|
+
* @example
|
|
75048
|
+
* ```typescript
|
|
75049
|
+
* overlayManager.hideEditingOverlay();
|
|
75050
|
+
* // Static decoration is now visible, editor is hidden
|
|
75051
|
+
* ```
|
|
75052
|
+
*/
|
|
75053
|
+
hideEditingOverlay() {
|
|
75054
|
+
if (__privateGet$1(this, _activeDecorationContainer)) {
|
|
75055
|
+
__privateGet$1(this, _activeDecorationContainer).style.visibility = "visible";
|
|
75056
|
+
}
|
|
75057
|
+
if (__privateGet$1(this, _activeEditorHost)) {
|
|
75058
|
+
__privateGet$1(this, _activeEditorHost).style.visibility = "hidden";
|
|
75059
|
+
__privateGet$1(this, _activeEditorHost).style.zIndex = "";
|
|
75060
|
+
if (__privateGet$1(this, _activeRegion)?.kind === "footer") {
|
|
75061
|
+
const editorContainer = __privateGet$1(this, _activeEditorHost).querySelector(".super-editor");
|
|
75062
|
+
if (editorContainer instanceof HTMLElement) {
|
|
75063
|
+
editorContainer.style.top = "0";
|
|
75064
|
+
}
|
|
75065
|
+
}
|
|
75066
|
+
}
|
|
75067
|
+
__privateMethod$1(this, _EditorOverlayManager_instances, hideHeaderFooterBorder_fn).call(this);
|
|
75068
|
+
__privateSet(this, _activeEditorHost, null);
|
|
75069
|
+
__privateSet(this, _activeDecorationContainer, null);
|
|
75070
|
+
__privateSet(this, _activeRegion, null);
|
|
75071
|
+
}
|
|
75072
|
+
/**
|
|
75073
|
+
* Hides the layout selection overlay to prevent double caret rendering.
|
|
75074
|
+
*
|
|
75075
|
+
* Called when entering header/footer editing mode to ensure only the
|
|
75076
|
+
* ProseMirror editor's caret is visible, not both the PM caret and the
|
|
75077
|
+
* layout engine's selection overlay.
|
|
75078
|
+
*
|
|
75079
|
+
* @example
|
|
75080
|
+
* ```typescript
|
|
75081
|
+
* overlayManager.hideSelectionOverlay();
|
|
75082
|
+
* // Selection overlay is now hidden
|
|
75083
|
+
* ```
|
|
75084
|
+
*/
|
|
75085
|
+
hideSelectionOverlay() {
|
|
75086
|
+
if (__privateGet$1(this, _selectionOverlay)) {
|
|
75087
|
+
__privateGet$1(this, _selectionOverlay).style.visibility = "hidden";
|
|
75088
|
+
}
|
|
75089
|
+
}
|
|
75090
|
+
/**
|
|
75091
|
+
* Shows the layout selection overlay.
|
|
75092
|
+
*
|
|
75093
|
+
* Called when exiting header/footer editing mode to restore the
|
|
75094
|
+
* normal selection overlay rendering for body content.
|
|
75095
|
+
*
|
|
75096
|
+
* @example
|
|
75097
|
+
* ```typescript
|
|
75098
|
+
* overlayManager.showSelectionOverlay();
|
|
75099
|
+
* // Selection overlay is now visible
|
|
75100
|
+
* ```
|
|
75101
|
+
*/
|
|
75102
|
+
showSelectionOverlay() {
|
|
75103
|
+
if (__privateGet$1(this, _selectionOverlay)) {
|
|
75104
|
+
__privateGet$1(this, _selectionOverlay).style.visibility = "visible";
|
|
75105
|
+
}
|
|
75106
|
+
}
|
|
75107
|
+
/**
|
|
75108
|
+
* Destroys the overlay manager and cleans up all resources.
|
|
75109
|
+
*
|
|
75110
|
+
* Clears all references.
|
|
75111
|
+
* Editor host elements are left in the DOM as they're children of page elements
|
|
75112
|
+
* that will be cleaned up by the virtualization system.
|
|
75113
|
+
*/
|
|
75114
|
+
destroy() {
|
|
75115
|
+
__privateMethod$1(this, _EditorOverlayManager_instances, hideHeaderFooterBorder_fn).call(this);
|
|
75116
|
+
__privateSet(this, _activeEditorHost, null);
|
|
75117
|
+
__privateSet(this, _activeDecorationContainer, null);
|
|
75118
|
+
__privateSet(this, _activeRegion, null);
|
|
75119
|
+
__privateSet(this, _selectionOverlay, null);
|
|
75120
|
+
}
|
|
75121
|
+
}
|
|
75122
|
+
_selectionOverlay = /* @__PURE__ */ new WeakMap();
|
|
75123
|
+
_activeEditorHost = /* @__PURE__ */ new WeakMap();
|
|
75124
|
+
_activeDecorationContainer = /* @__PURE__ */ new WeakMap();
|
|
75125
|
+
_activeRegion = /* @__PURE__ */ new WeakMap();
|
|
75126
|
+
_borderLine = /* @__PURE__ */ new WeakMap();
|
|
75127
|
+
_EditorOverlayManager_instances = /* @__PURE__ */ new WeakSet();
|
|
75128
|
+
findDecorationContainer_fn = function(pageElement, kind) {
|
|
75129
|
+
const className = kind === "header" ? "superdoc-page-header" : "superdoc-page-footer";
|
|
75130
|
+
return pageElement.querySelector(`.${className}`);
|
|
75131
|
+
};
|
|
75132
|
+
ensureEditorHost_fn = function(pageElement, kind) {
|
|
75133
|
+
const className = kind === "header" ? "superdoc-header-editor-host" : "superdoc-footer-editor-host";
|
|
75134
|
+
let editorHost = pageElement.querySelector(`.${className}`);
|
|
75135
|
+
if (!editorHost) {
|
|
75136
|
+
editorHost = document.createElement("div");
|
|
75137
|
+
editorHost.className = className;
|
|
75138
|
+
Object.assign(editorHost.style, {
|
|
75139
|
+
position: "absolute",
|
|
75140
|
+
pointerEvents: "auto",
|
|
75141
|
+
// Critical: enables click interaction
|
|
75142
|
+
visibility: "hidden",
|
|
75143
|
+
// Hidden by default, shown during editing
|
|
75144
|
+
overflow: "hidden",
|
|
75145
|
+
boxSizing: "border-box"
|
|
75146
|
+
});
|
|
75147
|
+
const decorationContainer = __privateMethod$1(this, _EditorOverlayManager_instances, findDecorationContainer_fn).call(this, pageElement, kind);
|
|
75148
|
+
if (!decorationContainer) {
|
|
75149
|
+
console.error(`[EditorOverlayManager] Decoration container not found for ${kind}`);
|
|
75150
|
+
return null;
|
|
75151
|
+
}
|
|
75152
|
+
decorationContainer.parentNode?.insertBefore(editorHost, decorationContainer.nextSibling);
|
|
75153
|
+
}
|
|
75154
|
+
return editorHost;
|
|
75155
|
+
};
|
|
75156
|
+
positionEditorHost_fn = function(editorHost, region, decorationContainer, _zoom) {
|
|
75157
|
+
const decorationRect = decorationContainer.getBoundingClientRect();
|
|
75158
|
+
const pageElement = editorHost.parentElement;
|
|
75159
|
+
if (!pageElement) {
|
|
75160
|
+
console.error("[EditorOverlayManager] Editor host has no parent element");
|
|
75161
|
+
return;
|
|
75162
|
+
}
|
|
75163
|
+
const pageRect = pageElement.getBoundingClientRect();
|
|
75164
|
+
const top2 = decorationRect.top - pageRect.top;
|
|
75165
|
+
const left2 = decorationRect.left - pageRect.left;
|
|
75166
|
+
const width = decorationRect.width;
|
|
75167
|
+
const height = decorationRect.height;
|
|
75168
|
+
Object.assign(editorHost.style, {
|
|
75169
|
+
top: `${top2}px`,
|
|
75170
|
+
left: `${left2}px`,
|
|
75171
|
+
width: `${width}px`,
|
|
75172
|
+
height: `${height}px`
|
|
75173
|
+
});
|
|
75174
|
+
if (region.kind === "footer") {
|
|
75175
|
+
const fragment = decorationContainer.querySelector(".superdoc-fragment");
|
|
75176
|
+
if (fragment instanceof HTMLElement) {
|
|
75177
|
+
const fragmentTop = parseFloat(fragment.style.top) || 0;
|
|
75178
|
+
editorHost.dataset.contentOffset = String(fragmentTop);
|
|
75179
|
+
}
|
|
75180
|
+
}
|
|
75181
|
+
};
|
|
75182
|
+
showHeaderFooterBorder_fn = function(pageElement, region, decorationContainer) {
|
|
75183
|
+
__privateMethod$1(this, _EditorOverlayManager_instances, hideHeaderFooterBorder_fn).call(this);
|
|
75184
|
+
__privateSet(this, _borderLine, document.createElement("div"));
|
|
75185
|
+
__privateGet$1(this, _borderLine).className = "superdoc-header-footer-border";
|
|
75186
|
+
const decorationRect = decorationContainer.getBoundingClientRect();
|
|
75187
|
+
const pageRect = pageElement.getBoundingClientRect();
|
|
75188
|
+
const isHeader = region.kind === "header";
|
|
75189
|
+
const topPosition = isHeader ? decorationRect.bottom - pageRect.top : decorationRect.top - pageRect.top;
|
|
75190
|
+
Object.assign(__privateGet$1(this, _borderLine).style, {
|
|
75191
|
+
position: "absolute",
|
|
75192
|
+
left: "0",
|
|
75193
|
+
right: "0",
|
|
75194
|
+
top: `${topPosition}px`,
|
|
75195
|
+
height: BORDER_LINE_HEIGHT,
|
|
75196
|
+
backgroundColor: BORDER_LINE_COLOR,
|
|
75197
|
+
// MS Word blue
|
|
75198
|
+
zIndex: BORDER_LINE_Z_INDEX,
|
|
75199
|
+
pointerEvents: "none"
|
|
75200
|
+
});
|
|
75201
|
+
pageElement.appendChild(__privateGet$1(this, _borderLine));
|
|
75202
|
+
};
|
|
75203
|
+
hideHeaderFooterBorder_fn = function() {
|
|
75204
|
+
if (__privateGet$1(this, _borderLine)) {
|
|
75205
|
+
__privateGet$1(this, _borderLine).remove();
|
|
75206
|
+
__privateSet(this, _borderLine, null);
|
|
75207
|
+
}
|
|
75208
|
+
};
|
|
74353
75209
|
const uiSurfaces = /* @__PURE__ */ new WeakSet();
|
|
74354
75210
|
function isInRegisteredSurface(event) {
|
|
74355
75211
|
const path = typeof event.composedPath === "function" ? event.composedPath() : [];
|
|
@@ -74388,7 +75244,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
74388
75244
|
__privateAdd$1(this, _visibleHost);
|
|
74389
75245
|
__privateAdd$1(this, _viewportHost);
|
|
74390
75246
|
__privateAdd$1(this, _painterHost);
|
|
74391
|
-
__privateAdd$1(this,
|
|
75247
|
+
__privateAdd$1(this, _selectionOverlay2);
|
|
74392
75248
|
__privateAdd$1(this, _hiddenHost);
|
|
74393
75249
|
__privateAdd$1(this, _layoutOptions);
|
|
74394
75250
|
__privateAdd$1(this, _layoutState, { blocks: [], measures: [], layout: null });
|
|
@@ -74423,6 +75279,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
74423
75279
|
__privateAdd$1(this, _footerRegions, /* @__PURE__ */ new Map());
|
|
74424
75280
|
__privateAdd$1(this, _session, { mode: "body" });
|
|
74425
75281
|
__privateAdd$1(this, _activeHeaderFooterEditor, null);
|
|
75282
|
+
__privateAdd$1(this, _overlayManager, null);
|
|
74426
75283
|
__privateAdd$1(this, _hoverOverlay, null);
|
|
74427
75284
|
__privateAdd$1(this, _hoverTooltip, null);
|
|
74428
75285
|
__privateAdd$1(this, _modeBanner, null);
|
|
@@ -74477,6 +75334,11 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
74477
75334
|
const x2 = (event.clientX - rect.left + scrollLeft) / zoom;
|
|
74478
75335
|
const y2 = (event.clientY - rect.top + scrollTop) / zoom;
|
|
74479
75336
|
if (__privateGet$1(this, _session).mode !== "body") {
|
|
75337
|
+
const activeEditorHost = __privateGet$1(this, _overlayManager)?.getActiveEditorHost?.();
|
|
75338
|
+
const clickedInsideEditorHost = activeEditorHost && (activeEditorHost.contains(event.target) || activeEditorHost === event.target);
|
|
75339
|
+
if (clickedInsideEditorHost) {
|
|
75340
|
+
return;
|
|
75341
|
+
}
|
|
74480
75342
|
const headerFooterRegion2 = __privateMethod$1(this, _PresentationEditor_instances, hitTestHeaderFooterRegion_fn).call(this, x2, y2);
|
|
74481
75343
|
if (!headerFooterRegion2) {
|
|
74482
75344
|
__privateMethod$1(this, _PresentationEditor_instances, exitHeaderFooterMode_fn).call(this);
|
|
@@ -74631,6 +75493,11 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
74631
75493
|
if (region) {
|
|
74632
75494
|
event.preventDefault();
|
|
74633
75495
|
event.stopPropagation();
|
|
75496
|
+
const descriptor = __privateMethod$1(this, _PresentationEditor_instances, resolveDescriptorForRegion_fn).call(this, region);
|
|
75497
|
+
if (!descriptor && __privateGet$1(this, _headerFooterManager)) {
|
|
75498
|
+
__privateMethod$1(this, _PresentationEditor_instances, createDefaultHeaderFooter_fn).call(this, region);
|
|
75499
|
+
__privateGet$1(this, _headerFooterManager).refresh();
|
|
75500
|
+
}
|
|
74634
75501
|
__privateMethod$1(this, _PresentationEditor_instances, activateHeaderFooterRegion_fn).call(this, region);
|
|
74635
75502
|
} else if (__privateGet$1(this, _session).mode !== "body") {
|
|
74636
75503
|
__privateMethod$1(this, _PresentationEditor_instances, exitHeaderFooterMode_fn).call(this);
|
|
@@ -74699,13 +75566,13 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
74699
75566
|
__privateGet$1(this, _painterHost).className = "presentation-editor__pages";
|
|
74700
75567
|
__privateGet$1(this, _painterHost).style.transformOrigin = "top left";
|
|
74701
75568
|
__privateGet$1(this, _viewportHost).appendChild(__privateGet$1(this, _painterHost));
|
|
74702
|
-
__privateSet(this,
|
|
74703
|
-
__privateGet$1(this,
|
|
74704
|
-
__privateGet$1(this,
|
|
74705
|
-
__privateGet$1(this,
|
|
74706
|
-
__privateGet$1(this,
|
|
74707
|
-
__privateGet$1(this,
|
|
74708
|
-
__privateGet$1(this,
|
|
75569
|
+
__privateSet(this, _selectionOverlay2, doc2.createElement("div"));
|
|
75570
|
+
__privateGet$1(this, _selectionOverlay2).className = "presentation-editor__selection-overlay";
|
|
75571
|
+
__privateGet$1(this, _selectionOverlay2).id = `presentation-overlay-${options.documentId || "default"}`;
|
|
75572
|
+
__privateGet$1(this, _selectionOverlay2).style.position = "absolute";
|
|
75573
|
+
__privateGet$1(this, _selectionOverlay2).style.inset = "0";
|
|
75574
|
+
__privateGet$1(this, _selectionOverlay2).style.pointerEvents = "none";
|
|
75575
|
+
__privateGet$1(this, _selectionOverlay2).style.zIndex = "10";
|
|
74709
75576
|
__privateSet(this, _remoteCursorOverlay, doc2.createElement("div"));
|
|
74710
75577
|
__privateGet$1(this, _remoteCursorOverlay).className = "presentation-editor__selection-layer--remote";
|
|
74711
75578
|
__privateGet$1(this, _remoteCursorOverlay).style.position = "absolute";
|
|
@@ -74716,9 +75583,9 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
74716
75583
|
__privateGet$1(this, _localSelectionLayer).style.position = "absolute";
|
|
74717
75584
|
__privateGet$1(this, _localSelectionLayer).style.inset = "0";
|
|
74718
75585
|
__privateGet$1(this, _localSelectionLayer).style.pointerEvents = "none";
|
|
74719
|
-
__privateGet$1(this,
|
|
74720
|
-
__privateGet$1(this,
|
|
74721
|
-
__privateGet$1(this, _viewportHost).appendChild(__privateGet$1(this,
|
|
75586
|
+
__privateGet$1(this, _selectionOverlay2).appendChild(__privateGet$1(this, _remoteCursorOverlay));
|
|
75587
|
+
__privateGet$1(this, _selectionOverlay2).appendChild(__privateGet$1(this, _localSelectionLayer));
|
|
75588
|
+
__privateGet$1(this, _viewportHost).appendChild(__privateGet$1(this, _selectionOverlay2));
|
|
74722
75589
|
__privateSet(this, _hoverOverlay, doc2.createElement("div"));
|
|
74723
75590
|
__privateGet$1(this, _hoverOverlay).className = "presentation-editor__hover-overlay";
|
|
74724
75591
|
Object.assign(__privateGet$1(this, _hoverOverlay).style, {
|
|
@@ -74729,7 +75596,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
74729
75596
|
display: "none",
|
|
74730
75597
|
zIndex: "11"
|
|
74731
75598
|
});
|
|
74732
|
-
__privateGet$1(this,
|
|
75599
|
+
__privateGet$1(this, _selectionOverlay2).appendChild(__privateGet$1(this, _hoverOverlay));
|
|
74733
75600
|
__privateSet(this, _hoverTooltip, doc2.createElement("div"));
|
|
74734
75601
|
__privateGet$1(this, _hoverTooltip).className = "presentation-editor__hover-tooltip";
|
|
74735
75602
|
Object.assign(__privateGet$1(this, _hoverTooltip).style, {
|
|
@@ -74744,7 +75611,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
74744
75611
|
zIndex: "12",
|
|
74745
75612
|
whiteSpace: "nowrap"
|
|
74746
75613
|
});
|
|
74747
|
-
__privateGet$1(this,
|
|
75614
|
+
__privateGet$1(this, _selectionOverlay2).appendChild(__privateGet$1(this, _hoverTooltip));
|
|
74748
75615
|
__privateSet(this, _modeBanner, doc2.createElement("div"));
|
|
74749
75616
|
__privateGet$1(this, _modeBanner).className = "presentation-editor__mode-banner";
|
|
74750
75617
|
Object.assign(__privateGet$1(this, _modeBanner).style, {
|
|
@@ -74962,7 +75829,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
74962
75829
|
* ```
|
|
74963
75830
|
*/
|
|
74964
75831
|
get overlayElement() {
|
|
74965
|
-
return __privateGet$1(this,
|
|
75832
|
+
return __privateGet$1(this, _selectionOverlay2) ?? null;
|
|
74966
75833
|
}
|
|
74967
75834
|
/**
|
|
74968
75835
|
* Set the document mode and update editor editability.
|
|
@@ -75132,12 +75999,12 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
75132
75999
|
* @returns Array of rects, each containing pageIndex and position data (left, top, right, bottom, width, height)
|
|
75133
76000
|
*/
|
|
75134
76001
|
getRangeRects(from2, to, relativeTo) {
|
|
75135
|
-
if (!__privateGet$1(this,
|
|
76002
|
+
if (!__privateGet$1(this, _selectionOverlay2)) return [];
|
|
75136
76003
|
if (!Number.isFinite(from2) || !Number.isFinite(to)) return [];
|
|
75137
76004
|
const start2 = Math.min(from2, to);
|
|
75138
76005
|
const end2 = Math.max(from2, to);
|
|
75139
76006
|
const zoom = __privateGet$1(this, _layoutOptions).zoom ?? 1;
|
|
75140
|
-
const overlayRect = __privateGet$1(this,
|
|
76007
|
+
const overlayRect = __privateGet$1(this, _selectionOverlay2).getBoundingClientRect();
|
|
75141
76008
|
const relativeRect = relativeTo?.getBoundingClientRect() ?? null;
|
|
75142
76009
|
const layoutRectSource = () => {
|
|
75143
76010
|
if (__privateGet$1(this, _session).mode !== "body") {
|
|
@@ -75398,7 +76265,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
75398
76265
|
return null;
|
|
75399
76266
|
}
|
|
75400
76267
|
const rect2 = rects2[0];
|
|
75401
|
-
const overlayRect = __privateGet$1(this,
|
|
76268
|
+
const overlayRect = __privateGet$1(this, _selectionOverlay2)?.getBoundingClientRect();
|
|
75402
76269
|
if (!overlayRect) {
|
|
75403
76270
|
return null;
|
|
75404
76271
|
}
|
|
@@ -75568,7 +76435,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
75568
76435
|
__privateSet(this, _session, { mode: "body" });
|
|
75569
76436
|
__privateSet(this, _activeHeaderFooterEditor, null);
|
|
75570
76437
|
__privateSet(this, _domPainter, null);
|
|
75571
|
-
__privateGet$1(this,
|
|
76438
|
+
__privateGet$1(this, _selectionOverlay2)?.remove();
|
|
75572
76439
|
__privateGet$1(this, _painterHost)?.remove();
|
|
75573
76440
|
__privateGet$1(this, _hiddenHost)?.remove();
|
|
75574
76441
|
__privateSet(this, _hoverOverlay, null);
|
|
@@ -75590,7 +76457,7 @@ _editor3 = /* @__PURE__ */ new WeakMap();
|
|
|
75590
76457
|
_visibleHost = /* @__PURE__ */ new WeakMap();
|
|
75591
76458
|
_viewportHost = /* @__PURE__ */ new WeakMap();
|
|
75592
76459
|
_painterHost = /* @__PURE__ */ new WeakMap();
|
|
75593
|
-
|
|
76460
|
+
_selectionOverlay2 = /* @__PURE__ */ new WeakMap();
|
|
75594
76461
|
_hiddenHost = /* @__PURE__ */ new WeakMap();
|
|
75595
76462
|
_layoutOptions = /* @__PURE__ */ new WeakMap();
|
|
75596
76463
|
_layoutState = /* @__PURE__ */ new WeakMap();
|
|
@@ -75625,6 +76492,7 @@ _headerRegions = /* @__PURE__ */ new WeakMap();
|
|
|
75625
76492
|
_footerRegions = /* @__PURE__ */ new WeakMap();
|
|
75626
76493
|
_session = /* @__PURE__ */ new WeakMap();
|
|
75627
76494
|
_activeHeaderFooterEditor = /* @__PURE__ */ new WeakMap();
|
|
76495
|
+
_overlayManager = /* @__PURE__ */ new WeakMap();
|
|
75628
76496
|
_hoverOverlay = /* @__PURE__ */ new WeakMap();
|
|
75629
76497
|
_hoverTooltip = /* @__PURE__ */ new WeakMap();
|
|
75630
76498
|
_modeBanner = /* @__PURE__ */ new WeakMap();
|
|
@@ -75990,9 +76858,14 @@ initHeaderFooterRegistry_fn = function() {
|
|
|
75990
76858
|
__privateSet(this, _headerFooterManagerCleanups, []);
|
|
75991
76859
|
__privateGet$1(this, _headerFooterAdapter)?.clear();
|
|
75992
76860
|
__privateGet$1(this, _headerFooterManager)?.destroy();
|
|
76861
|
+
__privateGet$1(this, _overlayManager)?.destroy();
|
|
75993
76862
|
__privateSet(this, _session, { mode: "body" });
|
|
75994
76863
|
__privateSet(this, _activeHeaderFooterEditor, null);
|
|
75995
76864
|
__privateGet$1(this, _inputBridge)?.notifyTargetChanged();
|
|
76865
|
+
__privateSet(this, _overlayManager, new EditorOverlayManager(__privateGet$1(this, _painterHost), __privateGet$1(this, _visibleHost), __privateGet$1(this, _selectionOverlay2)));
|
|
76866
|
+
__privateGet$1(this, _overlayManager).setOnDimmingClick(() => {
|
|
76867
|
+
__privateMethod$1(this, _PresentationEditor_instances, exitHeaderFooterMode_fn).call(this);
|
|
76868
|
+
});
|
|
75996
76869
|
const converter = __privateGet$1(this, _editor3).converter;
|
|
75997
76870
|
__privateSet(this, _headerFooterIdentifier, extractIdentifierFromConverter(converter));
|
|
75998
76871
|
__privateSet(this, _headerFooterManager, new HeaderFooterEditorManager(__privateGet$1(this, _editor3)));
|
|
@@ -76341,6 +77214,9 @@ scheduleSelectionUpdate_fn = function() {
|
|
|
76341
77214
|
});
|
|
76342
77215
|
};
|
|
76343
77216
|
updateSelection_fn = function() {
|
|
77217
|
+
if (__privateGet$1(this, _session).mode !== "body") {
|
|
77218
|
+
return;
|
|
77219
|
+
}
|
|
76344
77220
|
if (!__privateGet$1(this, _localSelectionLayer)) {
|
|
76345
77221
|
return;
|
|
76346
77222
|
}
|
|
@@ -76350,22 +77226,6 @@ updateSelection_fn = function() {
|
|
|
76350
77226
|
if (!selection) {
|
|
76351
77227
|
return;
|
|
76352
77228
|
}
|
|
76353
|
-
if (__privateGet$1(this, _session).mode !== "body") {
|
|
76354
|
-
if (!layout) {
|
|
76355
|
-
return;
|
|
76356
|
-
}
|
|
76357
|
-
if (selection.from === selection.to) {
|
|
76358
|
-
const caretLayout = __privateMethod$1(this, _PresentationEditor_instances, computeHeaderFooterCaretRect_fn).call(this, selection.from);
|
|
76359
|
-
if (!caretLayout) {
|
|
76360
|
-
return;
|
|
76361
|
-
}
|
|
76362
|
-
__privateMethod$1(this, _PresentationEditor_instances, renderCaretOverlay_fn).call(this, caretLayout);
|
|
76363
|
-
return;
|
|
76364
|
-
}
|
|
76365
|
-
const rects2 = __privateMethod$1(this, _PresentationEditor_instances, computeHeaderFooterSelectionRects_fn).call(this, selection.from, selection.to);
|
|
76366
|
-
__privateMethod$1(this, _PresentationEditor_instances, renderSelectionRects_fn).call(this, rects2);
|
|
76367
|
-
return;
|
|
76368
|
-
}
|
|
76369
77229
|
if (!layout) {
|
|
76370
77230
|
return;
|
|
76371
77231
|
}
|
|
@@ -76600,46 +77460,168 @@ activateHeaderFooterRegion_fn = function(region) {
|
|
|
76600
77460
|
void __privateMethod$1(this, _PresentationEditor_instances, enterHeaderFooterMode_fn).call(this, region);
|
|
76601
77461
|
};
|
|
76602
77462
|
enterHeaderFooterMode_fn = async function(region) {
|
|
76603
|
-
|
|
76604
|
-
|
|
76605
|
-
|
|
76606
|
-
|
|
76607
|
-
|
|
76608
|
-
|
|
76609
|
-
|
|
76610
|
-
|
|
76611
|
-
|
|
76612
|
-
|
|
76613
|
-
|
|
76614
|
-
|
|
76615
|
-
|
|
76616
|
-
|
|
76617
|
-
|
|
76618
|
-
|
|
76619
|
-
|
|
76620
|
-
|
|
77463
|
+
try {
|
|
77464
|
+
if (!__privateGet$1(this, _headerFooterManager) || !__privateGet$1(this, _overlayManager)) {
|
|
77465
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
77466
|
+
return;
|
|
77467
|
+
}
|
|
77468
|
+
const descriptor = __privateMethod$1(this, _PresentationEditor_instances, resolveDescriptorForRegion_fn).call(this, region);
|
|
77469
|
+
if (!descriptor) {
|
|
77470
|
+
console.warn("[PresentationEditor] No descriptor found for region:", region);
|
|
77471
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
77472
|
+
return;
|
|
77473
|
+
}
|
|
77474
|
+
if (!descriptor.id) {
|
|
77475
|
+
console.warn("[PresentationEditor] Descriptor missing id:", descriptor);
|
|
77476
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
77477
|
+
return;
|
|
77478
|
+
}
|
|
77479
|
+
let pageElement = __privateMethod$1(this, _PresentationEditor_instances, getPageElement_fn).call(this, region.pageIndex);
|
|
77480
|
+
if (!pageElement) {
|
|
77481
|
+
try {
|
|
77482
|
+
__privateMethod$1(this, _PresentationEditor_instances, scrollPageIntoView_fn).call(this, region.pageIndex);
|
|
77483
|
+
const mounted = await __privateMethod$1(this, _PresentationEditor_instances, waitForPageMount_fn).call(this, region.pageIndex, { timeout: 2e3 });
|
|
77484
|
+
if (!mounted) {
|
|
77485
|
+
console.error("[PresentationEditor] Failed to mount page for header/footer editing");
|
|
77486
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
77487
|
+
this.emit("error", {
|
|
77488
|
+
error: new Error("Failed to mount page for editing"),
|
|
77489
|
+
context: "enterHeaderFooterMode"
|
|
77490
|
+
});
|
|
77491
|
+
return;
|
|
77492
|
+
}
|
|
77493
|
+
pageElement = __privateMethod$1(this, _PresentationEditor_instances, getPageElement_fn).call(this, region.pageIndex);
|
|
77494
|
+
} catch (scrollError) {
|
|
77495
|
+
console.error("[PresentationEditor] Error mounting page:", scrollError);
|
|
77496
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
77497
|
+
this.emit("error", {
|
|
77498
|
+
error: scrollError,
|
|
77499
|
+
context: "enterHeaderFooterMode.pageMount"
|
|
77500
|
+
});
|
|
77501
|
+
return;
|
|
77502
|
+
}
|
|
77503
|
+
}
|
|
77504
|
+
if (!pageElement) {
|
|
77505
|
+
console.error("[PresentationEditor] Page element not found after mount attempt");
|
|
77506
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
77507
|
+
this.emit("error", {
|
|
77508
|
+
error: new Error("Page element not found after mount"),
|
|
77509
|
+
context: "enterHeaderFooterMode"
|
|
77510
|
+
});
|
|
77511
|
+
return;
|
|
77512
|
+
}
|
|
77513
|
+
const { success, editorHost, reason } = __privateGet$1(this, _overlayManager).showEditingOverlay(
|
|
77514
|
+
pageElement,
|
|
77515
|
+
region,
|
|
77516
|
+
__privateGet$1(this, _layoutOptions).zoom ?? 1
|
|
77517
|
+
);
|
|
77518
|
+
if (!success || !editorHost) {
|
|
77519
|
+
console.error("[PresentationEditor] Failed to create editor host:", reason);
|
|
77520
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
77521
|
+
this.emit("error", {
|
|
77522
|
+
error: new Error(`Failed to create editor host: ${reason}`),
|
|
77523
|
+
context: "enterHeaderFooterMode.showOverlay"
|
|
77524
|
+
});
|
|
77525
|
+
return;
|
|
77526
|
+
}
|
|
77527
|
+
const layout = __privateGet$1(this, _layoutState).layout;
|
|
77528
|
+
let editor;
|
|
77529
|
+
try {
|
|
77530
|
+
editor = await __privateGet$1(this, _headerFooterManager).ensureEditor(descriptor, {
|
|
77531
|
+
editorHost,
|
|
77532
|
+
availableWidth: region.width,
|
|
77533
|
+
availableHeight: region.height,
|
|
77534
|
+
currentPageNumber: region.pageNumber,
|
|
77535
|
+
totalPageCount: layout?.pages?.length ?? 1
|
|
77536
|
+
});
|
|
77537
|
+
} catch (editorError) {
|
|
77538
|
+
console.error("[PresentationEditor] Error creating editor:", editorError);
|
|
77539
|
+
__privateGet$1(this, _overlayManager).hideEditingOverlay();
|
|
77540
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
77541
|
+
this.emit("error", {
|
|
77542
|
+
error: editorError,
|
|
77543
|
+
context: "enterHeaderFooterMode.ensureEditor"
|
|
77544
|
+
});
|
|
77545
|
+
return;
|
|
77546
|
+
}
|
|
77547
|
+
if (!editor) {
|
|
77548
|
+
console.warn("[PresentationEditor] Failed to ensure editor for descriptor:", descriptor);
|
|
77549
|
+
__privateGet$1(this, _overlayManager).hideEditingOverlay();
|
|
77550
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
77551
|
+
this.emit("error", {
|
|
77552
|
+
error: new Error("Failed to create editor instance"),
|
|
77553
|
+
context: "enterHeaderFooterMode.ensureEditor"
|
|
77554
|
+
});
|
|
77555
|
+
return;
|
|
77556
|
+
}
|
|
77557
|
+
try {
|
|
77558
|
+
editor.setEditable(true);
|
|
77559
|
+
editor.setOptions({ documentMode: "editing" });
|
|
77560
|
+
try {
|
|
77561
|
+
const doc2 = editor.state?.doc;
|
|
77562
|
+
if (doc2) {
|
|
77563
|
+
const endPos = doc2.content.size - 1;
|
|
77564
|
+
editor.commands?.setTextSelection?.(Math.max(1, endPos));
|
|
77565
|
+
}
|
|
77566
|
+
} catch (cursorError) {
|
|
77567
|
+
console.warn("[PresentationEditor] Could not set cursor to end:", cursorError);
|
|
77568
|
+
}
|
|
77569
|
+
} catch (editableError) {
|
|
77570
|
+
console.error("[PresentationEditor] Error setting editor editable:", editableError);
|
|
77571
|
+
__privateGet$1(this, _overlayManager).hideEditingOverlay();
|
|
77572
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
77573
|
+
this.emit("error", {
|
|
77574
|
+
error: editableError,
|
|
77575
|
+
context: "enterHeaderFooterMode.setEditable"
|
|
77576
|
+
});
|
|
77577
|
+
return;
|
|
77578
|
+
}
|
|
77579
|
+
__privateGet$1(this, _overlayManager).hideSelectionOverlay();
|
|
77580
|
+
__privateSet(this, _activeHeaderFooterEditor, editor);
|
|
77581
|
+
__privateSet(this, _session, {
|
|
77582
|
+
mode: region.kind,
|
|
77583
|
+
kind: region.kind,
|
|
77584
|
+
headerId: descriptor.id,
|
|
77585
|
+
sectionType: descriptor.variant ?? region.sectionType ?? null,
|
|
77586
|
+
pageIndex: region.pageIndex,
|
|
77587
|
+
pageNumber: region.pageNumber
|
|
77588
|
+
});
|
|
76621
77589
|
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
76622
|
-
|
|
77590
|
+
try {
|
|
77591
|
+
editor.view?.focus();
|
|
77592
|
+
} catch (focusError) {
|
|
77593
|
+
console.warn("[PresentationEditor] Could not focus editor:", focusError);
|
|
77594
|
+
}
|
|
77595
|
+
__privateMethod$1(this, _PresentationEditor_instances, emitHeaderFooterModeChanged_fn).call(this);
|
|
77596
|
+
__privateMethod$1(this, _PresentationEditor_instances, emitHeaderFooterEditingContext_fn).call(this, editor);
|
|
77597
|
+
__privateGet$1(this, _inputBridge)?.notifyTargetChanged();
|
|
77598
|
+
} catch (error) {
|
|
77599
|
+
console.error("[PresentationEditor] Unexpected error in enterHeaderFooterMode:", error);
|
|
77600
|
+
try {
|
|
77601
|
+
__privateGet$1(this, _overlayManager)?.hideEditingOverlay();
|
|
77602
|
+
__privateGet$1(this, _overlayManager)?.showSelectionOverlay();
|
|
77603
|
+
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
77604
|
+
__privateSet(this, _activeHeaderFooterEditor, null);
|
|
77605
|
+
__privateSet(this, _session, { mode: "body" });
|
|
77606
|
+
} catch (cleanupError) {
|
|
77607
|
+
console.error("[PresentationEditor] Error during cleanup:", cleanupError);
|
|
77608
|
+
}
|
|
77609
|
+
this.emit("error", {
|
|
77610
|
+
error,
|
|
77611
|
+
context: "enterHeaderFooterMode"
|
|
77612
|
+
});
|
|
76623
77613
|
}
|
|
76624
|
-
__privateSet(this, _activeHeaderFooterEditor, editor);
|
|
76625
|
-
__privateSet(this, _session, {
|
|
76626
|
-
mode: region.kind,
|
|
76627
|
-
kind: region.kind,
|
|
76628
|
-
headerId: descriptor.id,
|
|
76629
|
-
sectionType: descriptor.variant ?? region.sectionType ?? null,
|
|
76630
|
-
pageIndex: region.pageIndex,
|
|
76631
|
-
pageNumber: region.pageNumber
|
|
76632
|
-
});
|
|
76633
|
-
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
76634
|
-
__privateMethod$1(this, _PresentationEditor_instances, emitHeaderFooterModeChanged_fn).call(this);
|
|
76635
|
-
__privateMethod$1(this, _PresentationEditor_instances, emitHeaderFooterEditingContext_fn).call(this, editor);
|
|
76636
|
-
__privateGet$1(this, _inputBridge)?.notifyTargetChanged();
|
|
76637
|
-
editor.view?.focus();
|
|
76638
77614
|
};
|
|
76639
77615
|
exitHeaderFooterMode_fn = function() {
|
|
76640
77616
|
if (__privateGet$1(this, _session).mode === "body") return;
|
|
76641
|
-
|
|
77617
|
+
if (__privateGet$1(this, _activeHeaderFooterEditor)) {
|
|
77618
|
+
__privateGet$1(this, _activeHeaderFooterEditor).setEditable(false);
|
|
77619
|
+
__privateGet$1(this, _activeHeaderFooterEditor).setOptions({ documentMode: "viewing" });
|
|
77620
|
+
}
|
|
77621
|
+
__privateGet$1(this, _overlayManager)?.hideEditingOverlay();
|
|
77622
|
+
__privateGet$1(this, _overlayManager)?.showSelectionOverlay();
|
|
76642
77623
|
__privateSet(this, _activeHeaderFooterEditor, null);
|
|
77624
|
+
__privateSet(this, _session, { mode: "body" });
|
|
76643
77625
|
__privateMethod$1(this, _PresentationEditor_instances, emitHeaderFooterModeChanged_fn).call(this);
|
|
76644
77626
|
__privateMethod$1(this, _PresentationEditor_instances, emitHeaderFooterEditingContext_fn).call(this, __privateGet$1(this, _editor3));
|
|
76645
77627
|
__privateGet$1(this, _inputBridge)?.notifyTargetChanged();
|
|
@@ -76735,6 +77717,75 @@ resolveDescriptorForRegion_fn = function(region) {
|
|
|
76735
77717
|
}
|
|
76736
77718
|
return descriptors[0];
|
|
76737
77719
|
};
|
|
77720
|
+
createDefaultHeaderFooter_fn = function(region) {
|
|
77721
|
+
const converter = __privateGet$1(this, _editor3).converter;
|
|
77722
|
+
if (!converter) {
|
|
77723
|
+
console.error("[PresentationEditor] Converter not available for creating header/footer");
|
|
77724
|
+
return;
|
|
77725
|
+
}
|
|
77726
|
+
const variant = region.sectionType ?? "default";
|
|
77727
|
+
try {
|
|
77728
|
+
if (region.kind === "header") {
|
|
77729
|
+
if (typeof converter.createDefaultHeader === "function") {
|
|
77730
|
+
const headerId = converter.createDefaultHeader(variant);
|
|
77731
|
+
console.log(`[PresentationEditor] Created default header: ${headerId}`);
|
|
77732
|
+
} else {
|
|
77733
|
+
console.error("[PresentationEditor] converter.createDefaultHeader is not a function");
|
|
77734
|
+
}
|
|
77735
|
+
} else if (region.kind === "footer") {
|
|
77736
|
+
if (typeof converter.createDefaultFooter === "function") {
|
|
77737
|
+
const footerId = converter.createDefaultFooter(variant);
|
|
77738
|
+
console.log(`[PresentationEditor] Created default footer: ${footerId}`);
|
|
77739
|
+
} else {
|
|
77740
|
+
console.error("[PresentationEditor] converter.createDefaultFooter is not a function");
|
|
77741
|
+
}
|
|
77742
|
+
}
|
|
77743
|
+
} catch (error) {
|
|
77744
|
+
console.error("[PresentationEditor] Failed to create default header/footer:", error);
|
|
77745
|
+
}
|
|
77746
|
+
};
|
|
77747
|
+
getPageElement_fn = function(pageIndex) {
|
|
77748
|
+
if (!__privateGet$1(this, _painterHost)) return null;
|
|
77749
|
+
const pageElements = __privateGet$1(this, _painterHost).querySelectorAll("[data-page-index]");
|
|
77750
|
+
for (let i = 0; i < pageElements.length; i++) {
|
|
77751
|
+
const el = pageElements[i];
|
|
77752
|
+
const dataPageIndex = el.getAttribute("data-page-index");
|
|
77753
|
+
if (dataPageIndex && parseInt(dataPageIndex, 10) === pageIndex) {
|
|
77754
|
+
return el;
|
|
77755
|
+
}
|
|
77756
|
+
}
|
|
77757
|
+
return null;
|
|
77758
|
+
};
|
|
77759
|
+
scrollPageIntoView_fn = function(pageIndex) {
|
|
77760
|
+
const layout = __privateGet$1(this, _layoutState).layout;
|
|
77761
|
+
if (!layout) return;
|
|
77762
|
+
const pageHeight = layout.pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
|
|
77763
|
+
const virtualGap = __privateGet$1(this, _layoutOptions).virtualization?.gap ?? 0;
|
|
77764
|
+
const yPosition = pageIndex * (pageHeight + virtualGap);
|
|
77765
|
+
if (__privateGet$1(this, _visibleHost)) {
|
|
77766
|
+
__privateGet$1(this, _visibleHost).scrollTop = yPosition;
|
|
77767
|
+
}
|
|
77768
|
+
};
|
|
77769
|
+
waitForPageMount_fn = async function(pageIndex, options = {}) {
|
|
77770
|
+
const timeout2 = options.timeout ?? 2e3;
|
|
77771
|
+
const startTime = performance.now();
|
|
77772
|
+
return new Promise((resolve) => {
|
|
77773
|
+
const checkPage = () => {
|
|
77774
|
+
const pageElement = __privateMethod$1(this, _PresentationEditor_instances, getPageElement_fn).call(this, pageIndex);
|
|
77775
|
+
if (pageElement) {
|
|
77776
|
+
resolve(true);
|
|
77777
|
+
return;
|
|
77778
|
+
}
|
|
77779
|
+
const elapsed = performance.now() - startTime;
|
|
77780
|
+
if (elapsed >= timeout2) {
|
|
77781
|
+
resolve(false);
|
|
77782
|
+
return;
|
|
77783
|
+
}
|
|
77784
|
+
requestAnimationFrame(checkPage);
|
|
77785
|
+
};
|
|
77786
|
+
checkPage();
|
|
77787
|
+
});
|
|
77788
|
+
};
|
|
76738
77789
|
getBodyPageHeight_fn = function() {
|
|
76739
77790
|
return __privateGet$1(this, _layoutState).layout?.pageSize?.h ?? __privateGet$1(this, _layoutOptions).pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
|
|
76740
77791
|
};
|
|
@@ -76788,7 +77839,7 @@ renderHoverRegion_fn = function(region) {
|
|
|
76788
77839
|
__privateGet$1(this, _hoverOverlay).style.top = `${coords.y}px`;
|
|
76789
77840
|
__privateGet$1(this, _hoverOverlay).style.width = `${region.width * zoom}px`;
|
|
76790
77841
|
__privateGet$1(this, _hoverOverlay).style.height = `${region.height * zoom}px`;
|
|
76791
|
-
const tooltipText = `Double-click to edit ${region.kind === "header" ? "
|
|
77842
|
+
const tooltipText = `Double-click to edit ${region.kind === "header" ? "header" : "footer"}`;
|
|
76792
77843
|
__privateGet$1(this, _hoverTooltip).textContent = tooltipText;
|
|
76793
77844
|
__privateGet$1(this, _hoverTooltip).style.display = "block";
|
|
76794
77845
|
__privateGet$1(this, _hoverTooltip).style.left = `${coords.x}px`;
|
|
@@ -76894,33 +77945,6 @@ computeHeaderFooterSelectionRects_fn = function(from2, to) {
|
|
|
76894
77945
|
};
|
|
76895
77946
|
});
|
|
76896
77947
|
};
|
|
76897
|
-
computeHeaderFooterCaretRect_fn = function(pos) {
|
|
76898
|
-
const context = __privateMethod$1(this, _PresentationEditor_instances, getHeaderFooterContext_fn).call(this);
|
|
76899
|
-
if (!context) return null;
|
|
76900
|
-
const hit = getFragmentAtPosition(context.layout, context.blocks, context.measures, pos);
|
|
76901
|
-
if (!hit) return null;
|
|
76902
|
-
const block = hit.block;
|
|
76903
|
-
const measure = hit.measure;
|
|
76904
|
-
if (!block || block.kind !== "paragraph" || measure?.kind !== "paragraph" || hit.fragment.kind !== "para")
|
|
76905
|
-
return null;
|
|
76906
|
-
const lineInfo = __privateMethod$1(this, _PresentationEditor_instances, findLineContainingPos_fn).call(this, block, measure, hit.fragment.fromLine, hit.fragment.toLine, pos);
|
|
76907
|
-
if (!lineInfo) return null;
|
|
76908
|
-
const { line, index: index2 } = lineInfo;
|
|
76909
|
-
const range2 = computeLinePmRange$1(block, line);
|
|
76910
|
-
if (range2.pmStart == null || range2.pmEnd == null) return null;
|
|
76911
|
-
const pmCharsInLine = Math.max(1, range2.pmEnd - range2.pmStart);
|
|
76912
|
-
const pmOffset = Math.max(0, Math.min(pmCharsInLine, pos - range2.pmStart));
|
|
76913
|
-
const localX = hit.fragment.x + measureCharacterX(block, line, pmOffset);
|
|
76914
|
-
const lineOffset = __privateMethod$1(this, _PresentationEditor_instances, lineHeightBeforeIndex_fn).call(this, measure.lines, hit.fragment.fromLine, index2);
|
|
76915
|
-
const headerPageHeight = context.layout.pageSize?.h ?? context.region.height ?? 1;
|
|
76916
|
-
const headerLocalY = hit.pageIndex * headerPageHeight + (hit.fragment.y + lineOffset);
|
|
76917
|
-
return {
|
|
76918
|
-
pageIndex: context.region.pageIndex,
|
|
76919
|
-
x: context.region.localX + localX,
|
|
76920
|
-
y: context.region.localY + headerLocalY,
|
|
76921
|
-
height: line.lineHeight
|
|
76922
|
-
};
|
|
76923
|
-
};
|
|
76924
77948
|
syncTrackedChangesPreferences_fn = function() {
|
|
76925
77949
|
const mode = __privateMethod$1(this, _PresentationEditor_instances, deriveTrackedChangesMode_fn).call(this);
|
|
76926
77950
|
const enabled = __privateMethod$1(this, _PresentationEditor_instances, deriveTrackedChangesEnabled_fn).call(this);
|
|
@@ -77027,7 +78051,7 @@ convertPageLocalToOverlayCoords_fn = function(pageIndex, pageLocalX, pageLocalY)
|
|
|
77027
78051
|
return null;
|
|
77028
78052
|
}
|
|
77029
78053
|
const pageRect = pageEl.getBoundingClientRect();
|
|
77030
|
-
const overlayRect = __privateGet$1(this,
|
|
78054
|
+
const overlayRect = __privateGet$1(this, _selectionOverlay2).getBoundingClientRect();
|
|
77031
78055
|
const zoom = __privateGet$1(this, _layoutOptions).zoom ?? 1;
|
|
77032
78056
|
return {
|
|
77033
78057
|
x: pageRect.left - overlayRect.left + pageLocalX * zoom,
|
|
@@ -81897,22 +82921,53 @@ function calculateTabLayout(request, measurement, view) {
|
|
|
81897
82921
|
tabs
|
|
81898
82922
|
};
|
|
81899
82923
|
}
|
|
82924
|
+
const MAX_WALK_DEPTH = 50;
|
|
81900
82925
|
function applyLayoutResult(result, paragraph, paragraphPos) {
|
|
81901
82926
|
const decorations = [];
|
|
81902
82927
|
let tabIndex = 0;
|
|
81903
|
-
|
|
81904
|
-
if (
|
|
81905
|
-
|
|
81906
|
-
|
|
81907
|
-
|
|
81908
|
-
if (!
|
|
81909
|
-
|
|
81910
|
-
|
|
81911
|
-
|
|
81912
|
-
|
|
81913
|
-
|
|
81914
|
-
|
|
81915
|
-
|
|
82928
|
+
const walk = (node, pos, depth = 0) => {
|
|
82929
|
+
if (depth > MAX_WALK_DEPTH) {
|
|
82930
|
+
console.error(`applyLayoutResult: Maximum recursion depth (${MAX_WALK_DEPTH}) exceeded`);
|
|
82931
|
+
return;
|
|
82932
|
+
}
|
|
82933
|
+
if (!node?.type?.name) {
|
|
82934
|
+
console.error("applyLayoutResult: Node missing type.name", { node, pos, depth });
|
|
82935
|
+
return;
|
|
82936
|
+
}
|
|
82937
|
+
if (typeof node.nodeSize !== "number" || node.nodeSize < 0 || !Number.isFinite(node.nodeSize)) {
|
|
82938
|
+
console.error("applyLayoutResult: Invalid nodeSize", { nodeSize: node.nodeSize, nodeName: node.type.name, pos });
|
|
82939
|
+
return;
|
|
82940
|
+
}
|
|
82941
|
+
if (node.type.name === "tab") {
|
|
82942
|
+
const tabId = tabIdForIndex(result.paragraphId, tabIndex++);
|
|
82943
|
+
const layout = result.tabs[tabId];
|
|
82944
|
+
if (layout) {
|
|
82945
|
+
let style2 = `width: ${layout.width}px;`;
|
|
82946
|
+
if (layout.height) style2 += ` height: ${layout.height};`;
|
|
82947
|
+
if (layout.leader && leaderStyles[layout.leader]) {
|
|
82948
|
+
style2 += ` ${leaderStyles[layout.leader]}`;
|
|
82949
|
+
}
|
|
82950
|
+
decorations.push(Decoration.node(pos, pos + node.nodeSize, { style: style2 }));
|
|
82951
|
+
}
|
|
82952
|
+
return;
|
|
82953
|
+
}
|
|
82954
|
+
try {
|
|
82955
|
+
let offset2 = 0;
|
|
82956
|
+
node.forEach((child) => {
|
|
82957
|
+
const childPos = pos + 1 + offset2;
|
|
82958
|
+
walk(child, childPos, depth + 1);
|
|
82959
|
+
offset2 += child.nodeSize;
|
|
82960
|
+
});
|
|
82961
|
+
} catch (error) {
|
|
82962
|
+
console.error("applyLayoutResult: Error during recursion", {
|
|
82963
|
+
error,
|
|
82964
|
+
nodeName: node.type.name,
|
|
82965
|
+
pos,
|
|
82966
|
+
depth
|
|
82967
|
+
});
|
|
82968
|
+
}
|
|
82969
|
+
};
|
|
82970
|
+
walk(paragraph, paragraphPos);
|
|
81916
82971
|
return decorations;
|
|
81917
82972
|
}
|
|
81918
82973
|
function collectFollowingText(spans, startIndex) {
|
|
@@ -82460,8 +83515,8 @@ const createColGroup = (node, cellMinWidth2, overrideCol, overrideValue) => {
|
|
|
82460
83515
|
colgroupValues
|
|
82461
83516
|
};
|
|
82462
83517
|
};
|
|
82463
|
-
|
|
82464
|
-
|
|
83518
|
+
let readFromCache;
|
|
83519
|
+
let addToCache;
|
|
82465
83520
|
if (typeof WeakMap != "undefined") {
|
|
82466
83521
|
let cache2 = /* @__PURE__ */ new WeakMap();
|
|
82467
83522
|
readFromCache = (key2) => cache2.get(key2);
|
|
@@ -82474,8 +83529,7 @@ if (typeof WeakMap != "undefined") {
|
|
|
82474
83529
|
const cacheSize = 10;
|
|
82475
83530
|
let cachePos = 0;
|
|
82476
83531
|
readFromCache = (key2) => {
|
|
82477
|
-
for (let i = 0; i < cache2.length; i += 2)
|
|
82478
|
-
if (cache2[i] == key2) return cache2[i + 1];
|
|
83532
|
+
for (let i = 0; i < cache2.length; i += 2) if (cache2[i] == key2) return cache2[i + 1];
|
|
82479
83533
|
};
|
|
82480
83534
|
addToCache = (key2, value) => {
|
|
82481
83535
|
if (cachePos == cacheSize) cachePos = 0;
|
|
@@ -82490,7 +83544,6 @@ var TableMap = class {
|
|
|
82490
83544
|
this.map = map22;
|
|
82491
83545
|
this.problems = problems;
|
|
82492
83546
|
}
|
|
82493
|
-
// Find the dimensions of the cell at the given position.
|
|
82494
83547
|
findCell(pos) {
|
|
82495
83548
|
for (let i = 0; i < this.map.length; i++) {
|
|
82496
83549
|
const curPos = this.map[i];
|
|
@@ -82499,27 +83552,21 @@ var TableMap = class {
|
|
|
82499
83552
|
const top2 = i / this.width | 0;
|
|
82500
83553
|
let right2 = left2 + 1;
|
|
82501
83554
|
let bottom2 = top2 + 1;
|
|
82502
|
-
for (let j2 = 1; right2 < this.width && this.map[i + j2] == curPos; j2++)
|
|
82503
|
-
|
|
82504
|
-
|
|
82505
|
-
|
|
82506
|
-
|
|
82507
|
-
|
|
82508
|
-
|
|
83555
|
+
for (let j2 = 1; right2 < this.width && this.map[i + j2] == curPos; j2++) right2++;
|
|
83556
|
+
for (let j2 = 1; bottom2 < this.height && this.map[i + this.width * j2] == curPos; j2++) bottom2++;
|
|
83557
|
+
return {
|
|
83558
|
+
left: left2,
|
|
83559
|
+
top: top2,
|
|
83560
|
+
right: right2,
|
|
83561
|
+
bottom: bottom2
|
|
83562
|
+
};
|
|
82509
83563
|
}
|
|
82510
83564
|
throw new RangeError(`No cell with offset ${pos} found`);
|
|
82511
83565
|
}
|
|
82512
|
-
// Find the left side of the cell at the given position.
|
|
82513
83566
|
colCount(pos) {
|
|
82514
|
-
for (let i = 0; i < this.map.length; i++)
|
|
82515
|
-
if (this.map[i] == pos) {
|
|
82516
|
-
return i % this.width;
|
|
82517
|
-
}
|
|
82518
|
-
}
|
|
83567
|
+
for (let i = 0; i < this.map.length; i++) if (this.map[i] == pos) return i % this.width;
|
|
82519
83568
|
throw new RangeError(`No cell with offset ${pos} found`);
|
|
82520
83569
|
}
|
|
82521
|
-
// Find the next cell in the given direction, starting from the cell
|
|
82522
|
-
// at `pos`, if any.
|
|
82523
83570
|
nextCell(pos, axis, dir) {
|
|
82524
83571
|
const { left: left2, right: right2, top: top2, bottom: bottom2 } = this.findCell(pos);
|
|
82525
83572
|
if (axis == "horiz") {
|
|
@@ -82530,20 +83577,9 @@ var TableMap = class {
|
|
|
82530
83577
|
return this.map[left2 + this.width * (dir < 0 ? top2 - 1 : bottom2)];
|
|
82531
83578
|
}
|
|
82532
83579
|
}
|
|
82533
|
-
// Get the rectangle spanning the two given cells.
|
|
82534
83580
|
rectBetween(a, b2) {
|
|
82535
|
-
const {
|
|
82536
|
-
|
|
82537
|
-
right: rightA,
|
|
82538
|
-
top: topA,
|
|
82539
|
-
bottom: bottomA
|
|
82540
|
-
} = this.findCell(a);
|
|
82541
|
-
const {
|
|
82542
|
-
left: leftB,
|
|
82543
|
-
right: rightB,
|
|
82544
|
-
top: topB,
|
|
82545
|
-
bottom: bottomB
|
|
82546
|
-
} = this.findCell(b2);
|
|
83581
|
+
const { left: leftA, right: rightA, top: topA, bottom: bottomA } = this.findCell(a);
|
|
83582
|
+
const { left: leftB, right: rightB, top: topB, bottom: bottomB } = this.findCell(b2);
|
|
82547
83583
|
return {
|
|
82548
83584
|
left: Math.min(leftA, leftB),
|
|
82549
83585
|
top: Math.min(topA, topB),
|
|
@@ -82551,27 +83587,19 @@ var TableMap = class {
|
|
|
82551
83587
|
bottom: Math.max(bottomA, bottomB)
|
|
82552
83588
|
};
|
|
82553
83589
|
}
|
|
82554
|
-
// Return the position of all cells that have the top left corner in
|
|
82555
|
-
// the given rectangle.
|
|
82556
83590
|
cellsInRect(rect) {
|
|
82557
83591
|
const result = [];
|
|
82558
83592
|
const seen = {};
|
|
82559
|
-
for (let row = rect.top; row < rect.bottom; row++) {
|
|
82560
|
-
|
|
82561
|
-
|
|
82562
|
-
|
|
82563
|
-
|
|
82564
|
-
|
|
82565
|
-
|
|
82566
|
-
continue;
|
|
82567
|
-
}
|
|
82568
|
-
result.push(pos);
|
|
82569
|
-
}
|
|
83593
|
+
for (let row = rect.top; row < rect.bottom; row++) for (let col = rect.left; col < rect.right; col++) {
|
|
83594
|
+
const index2 = row * this.width + col;
|
|
83595
|
+
const pos = this.map[index2];
|
|
83596
|
+
if (seen[pos]) continue;
|
|
83597
|
+
seen[pos] = true;
|
|
83598
|
+
if (col == rect.left && col && this.map[index2 - 1] == pos || row == rect.top && row && this.map[index2 - this.width] == pos) continue;
|
|
83599
|
+
result.push(pos);
|
|
82570
83600
|
}
|
|
82571
83601
|
return result;
|
|
82572
83602
|
}
|
|
82573
|
-
// Return the position at which the cell at the given row and column
|
|
82574
|
-
// starts, or would start, if a cell started there.
|
|
82575
83603
|
positionAt(row, col, table) {
|
|
82576
83604
|
for (let i = 0, rowStart = 0; ; i++) {
|
|
82577
83605
|
const rowEnd = rowStart + table.child(i).nodeSize;
|
|
@@ -82584,14 +83612,12 @@ var TableMap = class {
|
|
|
82584
83612
|
rowStart = rowEnd;
|
|
82585
83613
|
}
|
|
82586
83614
|
}
|
|
82587
|
-
// Find the table map for the given table node.
|
|
82588
83615
|
static get(table) {
|
|
82589
83616
|
return readFromCache(table) || addToCache(table, computeMap(table));
|
|
82590
83617
|
}
|
|
82591
83618
|
};
|
|
82592
83619
|
function computeMap(table) {
|
|
82593
|
-
if (table.type.spec.tableRole != "table")
|
|
82594
|
-
throw new RangeError("Not a table node: " + table.type.name);
|
|
83620
|
+
if (table.type.spec.tableRole != "table") throw new RangeError("Not a table node: " + table.type.name);
|
|
82595
83621
|
const width = findWidth(table), height = table.childCount;
|
|
82596
83622
|
const map22 = [];
|
|
82597
83623
|
let mapPos = 0;
|
|
@@ -82618,22 +83644,19 @@ function computeMap(table) {
|
|
|
82618
83644
|
const start2 = mapPos + h2 * width;
|
|
82619
83645
|
for (let w2 = 0; w2 < colspan; w2++) {
|
|
82620
83646
|
if (map22[start2 + w2] == 0) map22[start2 + w2] = pos;
|
|
82621
|
-
else
|
|
82622
|
-
|
|
82623
|
-
|
|
82624
|
-
|
|
82625
|
-
|
|
82626
|
-
|
|
82627
|
-
});
|
|
83647
|
+
else (problems || (problems = [])).push({
|
|
83648
|
+
type: "collision",
|
|
83649
|
+
row,
|
|
83650
|
+
pos,
|
|
83651
|
+
n: colspan - w2
|
|
83652
|
+
});
|
|
82628
83653
|
const colW = colwidth && colwidth[w2];
|
|
82629
83654
|
if (colW) {
|
|
82630
83655
|
const widthIndex = (start2 + w2) % width * 2, prev = colWidths[widthIndex];
|
|
82631
83656
|
if (prev == null || prev != colW && colWidths[widthIndex + 1] == 1) {
|
|
82632
83657
|
colWidths[widthIndex] = colW;
|
|
82633
83658
|
colWidths[widthIndex + 1] = 1;
|
|
82634
|
-
} else if (prev == colW)
|
|
82635
|
-
colWidths[widthIndex + 1]++;
|
|
82636
|
-
}
|
|
83659
|
+
} else if (prev == colW) colWidths[widthIndex + 1]++;
|
|
82637
83660
|
}
|
|
82638
83661
|
}
|
|
82639
83662
|
}
|
|
@@ -82643,16 +83666,17 @@ function computeMap(table) {
|
|
|
82643
83666
|
const expectedPos = (row + 1) * width;
|
|
82644
83667
|
let missing = 0;
|
|
82645
83668
|
while (mapPos < expectedPos) if (map22[mapPos++] == 0) missing++;
|
|
82646
|
-
if (missing)
|
|
82647
|
-
|
|
83669
|
+
if (missing) (problems || (problems = [])).push({
|
|
83670
|
+
type: "missing",
|
|
83671
|
+
row,
|
|
83672
|
+
n: missing
|
|
83673
|
+
});
|
|
82648
83674
|
pos++;
|
|
82649
83675
|
}
|
|
82650
|
-
if (width === 0 || height === 0)
|
|
82651
|
-
(problems || (problems = [])).push({ type: "zero_sized" });
|
|
83676
|
+
if (width === 0 || height === 0) (problems || (problems = [])).push({ type: "zero_sized" });
|
|
82652
83677
|
const tableMap = new TableMap(width, height, map22, problems);
|
|
82653
83678
|
let badWidths = false;
|
|
82654
|
-
for (let i = 0; !badWidths && i < colWidths.length; i += 2)
|
|
82655
|
-
if (colWidths[i] != null && colWidths[i + 1] < height) badWidths = true;
|
|
83679
|
+
for (let i = 0; !badWidths && i < colWidths.length; i += 2) if (colWidths[i] != null && colWidths[i + 1] < height) badWidths = true;
|
|
82656
83680
|
if (badWidths) findBadColWidths(tableMap, colWidths, table);
|
|
82657
83681
|
return tableMap;
|
|
82658
83682
|
}
|
|
@@ -82662,14 +83686,13 @@ function findWidth(table) {
|
|
|
82662
83686
|
for (let row = 0; row < table.childCount; row++) {
|
|
82663
83687
|
const rowNode = table.child(row);
|
|
82664
83688
|
let rowWidth = 0;
|
|
82665
|
-
if (hasRowSpan)
|
|
82666
|
-
|
|
82667
|
-
|
|
82668
|
-
|
|
82669
|
-
|
|
82670
|
-
if (j2 + cell.attrs.rowspan > row) rowWidth += cell.attrs.colspan;
|
|
82671
|
-
}
|
|
83689
|
+
if (hasRowSpan) for (let j2 = 0; j2 < row; j2++) {
|
|
83690
|
+
const prevRow = table.child(j2);
|
|
83691
|
+
for (let i = 0; i < prevRow.childCount; i++) {
|
|
83692
|
+
const cell = prevRow.child(i);
|
|
83693
|
+
if (j2 + cell.attrs.rowspan > row) rowWidth += cell.attrs.colspan;
|
|
82672
83694
|
}
|
|
83695
|
+
}
|
|
82673
83696
|
for (let i = 0; i < rowNode.childCount; i++) {
|
|
82674
83697
|
const cell = rowNode.child(i);
|
|
82675
83698
|
rowWidth += cell.attrs.colspan;
|
|
@@ -82688,23 +83711,18 @@ function findBadColWidths(map22, colWidths, table) {
|
|
|
82688
83711
|
if (seen[pos]) continue;
|
|
82689
83712
|
seen[pos] = true;
|
|
82690
83713
|
const node = table.nodeAt(pos);
|
|
82691
|
-
if (!node) {
|
|
82692
|
-
throw new RangeError(`No cell with offset ${pos} found`);
|
|
82693
|
-
}
|
|
83714
|
+
if (!node) throw new RangeError(`No cell with offset ${pos} found`);
|
|
82694
83715
|
let updated = null;
|
|
82695
83716
|
const attrs = node.attrs;
|
|
82696
83717
|
for (let j2 = 0; j2 < attrs.colspan; j2++) {
|
|
82697
|
-
const
|
|
82698
|
-
|
|
82699
|
-
|
|
82700
|
-
|
|
82701
|
-
|
|
82702
|
-
|
|
82703
|
-
|
|
82704
|
-
|
|
82705
|
-
pos,
|
|
82706
|
-
colwidth: updated
|
|
82707
|
-
});
|
|
83718
|
+
const colWidth = colWidths[(i + j2) % map22.width * 2];
|
|
83719
|
+
if (colWidth != null && (!attrs.colwidth || attrs.colwidth[j2] != colWidth)) (updated || (updated = freshColWidth(attrs)))[j2] = colWidth;
|
|
83720
|
+
}
|
|
83721
|
+
if (updated) map22.problems.unshift({
|
|
83722
|
+
type: "colwidth mismatch",
|
|
83723
|
+
pos,
|
|
83724
|
+
colwidth: updated
|
|
83725
|
+
});
|
|
82708
83726
|
}
|
|
82709
83727
|
}
|
|
82710
83728
|
function freshColWidth(attrs) {
|
|
@@ -82724,11 +83742,9 @@ function tableNodeTypes(schema) {
|
|
|
82724
83742
|
}
|
|
82725
83743
|
return result;
|
|
82726
83744
|
}
|
|
82727
|
-
|
|
83745
|
+
const tableEditingKey = new PluginKey("selectingCells");
|
|
82728
83746
|
function cellAround$1($pos) {
|
|
82729
|
-
for (let d2 = $pos.depth - 1; d2 > 0; d2--)
|
|
82730
|
-
if ($pos.node(d2).type.spec.tableRole == "row")
|
|
82731
|
-
return $pos.node(0).resolve($pos.before(d2 + 1));
|
|
83747
|
+
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));
|
|
82732
83748
|
return null;
|
|
82733
83749
|
}
|
|
82734
83750
|
function cellWrapping$1($pos) {
|
|
@@ -82740,21 +83756,15 @@ function cellWrapping$1($pos) {
|
|
|
82740
83756
|
}
|
|
82741
83757
|
function isInTable(state2) {
|
|
82742
83758
|
const $head = state2.selection.$head;
|
|
82743
|
-
for (let d2 = $head.depth; d2 > 0; d2--)
|
|
82744
|
-
if ($head.node(d2).type.spec.tableRole == "row") return true;
|
|
83759
|
+
for (let d2 = $head.depth; d2 > 0; d2--) if ($head.node(d2).type.spec.tableRole == "row") return true;
|
|
82745
83760
|
return false;
|
|
82746
83761
|
}
|
|
82747
83762
|
function selectionCell(state2) {
|
|
82748
83763
|
const sel = state2.selection;
|
|
82749
|
-
if ("$anchorCell" in sel && sel.$anchorCell)
|
|
82750
|
-
|
|
82751
|
-
} else if ("node" in sel && sel.node && sel.node.type.spec.tableRole == "cell") {
|
|
82752
|
-
return sel.$anchor;
|
|
82753
|
-
}
|
|
83764
|
+
if ("$anchorCell" in sel && sel.$anchorCell) return sel.$anchorCell.pos > sel.$headCell.pos ? sel.$anchorCell : sel.$headCell;
|
|
83765
|
+
else if ("node" in sel && sel.node && sel.node.type.spec.tableRole == "cell") return sel.$anchor;
|
|
82754
83766
|
const $cell = cellAround$1(sel.$head) || cellNear(sel.$head);
|
|
82755
|
-
if ($cell)
|
|
82756
|
-
return $cell;
|
|
82757
|
-
}
|
|
83767
|
+
if ($cell) return $cell;
|
|
82758
83768
|
throw new RangeError(`No cell found around position ${sel.head}`);
|
|
82759
83769
|
}
|
|
82760
83770
|
function cellNear($pos) {
|
|
@@ -82764,8 +83774,7 @@ function cellNear($pos) {
|
|
|
82764
83774
|
}
|
|
82765
83775
|
for (let before = $pos.nodeBefore, pos = $pos.pos; before; before = before.lastChild, pos--) {
|
|
82766
83776
|
const role = before.type.spec.tableRole;
|
|
82767
|
-
if (role == "cell" || role == "header_cell")
|
|
82768
|
-
return $pos.doc.resolve(pos - before.nodeSize);
|
|
83777
|
+
if (role == "cell" || role == "header_cell") return $pos.doc.resolve(pos - before.nodeSize);
|
|
82769
83778
|
}
|
|
82770
83779
|
}
|
|
82771
83780
|
function pointsAtCell($pos) {
|
|
@@ -82785,7 +83794,10 @@ function nextCell($pos, axis, dir) {
|
|
|
82785
83794
|
return moved == null ? null : $pos.node(0).resolve(tableStart + moved);
|
|
82786
83795
|
}
|
|
82787
83796
|
function removeColSpan(attrs, pos, n = 1) {
|
|
82788
|
-
const result = {
|
|
83797
|
+
const result = {
|
|
83798
|
+
...attrs,
|
|
83799
|
+
colspan: attrs.colspan - n
|
|
83800
|
+
};
|
|
82789
83801
|
if (result.colwidth) {
|
|
82790
83802
|
result.colwidth = result.colwidth.slice();
|
|
82791
83803
|
result.colwidth.splice(pos, n);
|
|
@@ -82794,7 +83806,10 @@ function removeColSpan(attrs, pos, n = 1) {
|
|
|
82794
83806
|
return result;
|
|
82795
83807
|
}
|
|
82796
83808
|
function addColSpan(attrs, pos, n = 1) {
|
|
82797
|
-
const result = {
|
|
83809
|
+
const result = {
|
|
83810
|
+
...attrs,
|
|
83811
|
+
colspan: attrs.colspan + n
|
|
83812
|
+
};
|
|
82798
83813
|
if (result.colwidth) {
|
|
82799
83814
|
result.colwidth = result.colwidth.slice();
|
|
82800
83815
|
for (let i = 0; i < n; i++) result.colwidth.splice(pos, 0, 0);
|
|
@@ -82803,37 +83818,23 @@ function addColSpan(attrs, pos, n = 1) {
|
|
|
82803
83818
|
}
|
|
82804
83819
|
function columnIsHeader(map22, table, col) {
|
|
82805
83820
|
const headerCell = tableNodeTypes(table.type.schema).header_cell;
|
|
82806
|
-
for (let row = 0; row < map22.height; row++)
|
|
82807
|
-
if (table.nodeAt(map22.map[col + row * map22.width]).type != headerCell)
|
|
82808
|
-
return false;
|
|
83821
|
+
for (let row = 0; row < map22.height; row++) if (table.nodeAt(map22.map[col + row * map22.width]).type != headerCell) return false;
|
|
82809
83822
|
return true;
|
|
82810
83823
|
}
|
|
82811
|
-
var CellSelection = class
|
|
82812
|
-
// A table selection is identified by its anchor and head cells. The
|
|
82813
|
-
// positions given to this constructor should point _before_ two
|
|
82814
|
-
// cells in the same table. They may be the same, to select a single
|
|
82815
|
-
// cell.
|
|
83824
|
+
var CellSelection = class CellSelection2 extends Selection {
|
|
82816
83825
|
constructor($anchorCell, $headCell = $anchorCell) {
|
|
82817
83826
|
const table = $anchorCell.node(-1);
|
|
82818
83827
|
const map22 = TableMap.get(table);
|
|
82819
83828
|
const tableStart = $anchorCell.start(-1);
|
|
82820
|
-
const rect = map22.rectBetween(
|
|
82821
|
-
$anchorCell.pos - tableStart,
|
|
82822
|
-
$headCell.pos - tableStart
|
|
82823
|
-
);
|
|
83829
|
+
const rect = map22.rectBetween($anchorCell.pos - tableStart, $headCell.pos - tableStart);
|
|
82824
83830
|
const doc2 = $anchorCell.node(0);
|
|
82825
83831
|
const cells = map22.cellsInRect(rect).filter((p) => p != $headCell.pos - tableStart);
|
|
82826
83832
|
cells.unshift($headCell.pos - tableStart);
|
|
82827
83833
|
const ranges = cells.map((pos) => {
|
|
82828
83834
|
const cell = table.nodeAt(pos);
|
|
82829
|
-
if (!cell) {
|
|
82830
|
-
throw RangeError(`No cell with offset ${pos} found`);
|
|
82831
|
-
}
|
|
83835
|
+
if (!cell) throw new RangeError(`No cell with offset ${pos} found`);
|
|
82832
83836
|
const from2 = tableStart + pos + 1;
|
|
82833
|
-
return new SelectionRange(
|
|
82834
|
-
doc2.resolve(from2),
|
|
82835
|
-
doc2.resolve(from2 + cell.content.size)
|
|
82836
|
-
);
|
|
83837
|
+
return new SelectionRange(doc2.resolve(from2), doc2.resolve(from2 + cell.content.size));
|
|
82837
83838
|
});
|
|
82838
83839
|
super(ranges[0].$from, ranges[0].$to, ranges);
|
|
82839
83840
|
this.$anchorCell = $anchorCell;
|
|
@@ -82844,24 +83845,17 @@ var CellSelection = class _CellSelection extends Selection {
|
|
|
82844
83845
|
const $headCell = doc2.resolve(mapping.map(this.$headCell.pos));
|
|
82845
83846
|
if (pointsAtCell($anchorCell) && pointsAtCell($headCell) && inSameTable($anchorCell, $headCell)) {
|
|
82846
83847
|
const tableChanged = this.$anchorCell.node(-1) != $anchorCell.node(-1);
|
|
82847
|
-
if (tableChanged && this.isRowSelection())
|
|
82848
|
-
|
|
82849
|
-
else
|
|
82850
|
-
return _CellSelection.colSelection($anchorCell, $headCell);
|
|
82851
|
-
else return new _CellSelection($anchorCell, $headCell);
|
|
83848
|
+
if (tableChanged && this.isRowSelection()) return CellSelection2.rowSelection($anchorCell, $headCell);
|
|
83849
|
+
else if (tableChanged && this.isColSelection()) return CellSelection2.colSelection($anchorCell, $headCell);
|
|
83850
|
+
else return new CellSelection2($anchorCell, $headCell);
|
|
82852
83851
|
}
|
|
82853
83852
|
return TextSelection$1.between($anchorCell, $headCell);
|
|
82854
83853
|
}
|
|
82855
|
-
// Returns a rectangular slice of table rows containing the selected
|
|
82856
|
-
// cells.
|
|
82857
83854
|
content() {
|
|
82858
83855
|
const table = this.$anchorCell.node(-1);
|
|
82859
83856
|
const map22 = TableMap.get(table);
|
|
82860
83857
|
const tableStart = this.$anchorCell.start(-1);
|
|
82861
|
-
const rect = map22.rectBetween(
|
|
82862
|
-
this.$anchorCell.pos - tableStart,
|
|
82863
|
-
this.$headCell.pos - tableStart
|
|
82864
|
-
);
|
|
83858
|
+
const rect = map22.rectBetween(this.$anchorCell.pos - tableStart, this.$headCell.pos - tableStart);
|
|
82865
83859
|
const seen = {};
|
|
82866
83860
|
const rows = [];
|
|
82867
83861
|
for (let row = rect.top; row < rect.bottom; row++) {
|
|
@@ -82872,44 +83866,25 @@ var CellSelection = class _CellSelection extends Selection {
|
|
|
82872
83866
|
seen[pos] = true;
|
|
82873
83867
|
const cellRect = map22.findCell(pos);
|
|
82874
83868
|
let cell = table.nodeAt(pos);
|
|
82875
|
-
if (!cell) {
|
|
82876
|
-
throw RangeError(`No cell with offset ${pos} found`);
|
|
82877
|
-
}
|
|
83869
|
+
if (!cell) throw new RangeError(`No cell with offset ${pos} found`);
|
|
82878
83870
|
const extraLeft = rect.left - cellRect.left;
|
|
82879
83871
|
const extraRight = cellRect.right - rect.right;
|
|
82880
83872
|
if (extraLeft > 0 || extraRight > 0) {
|
|
82881
83873
|
let attrs = cell.attrs;
|
|
82882
|
-
if (extraLeft > 0)
|
|
82883
|
-
|
|
82884
|
-
}
|
|
82885
|
-
if (extraRight > 0) {
|
|
82886
|
-
attrs = removeColSpan(
|
|
82887
|
-
attrs,
|
|
82888
|
-
attrs.colspan - extraRight,
|
|
82889
|
-
extraRight
|
|
82890
|
-
);
|
|
82891
|
-
}
|
|
83874
|
+
if (extraLeft > 0) attrs = removeColSpan(attrs, 0, extraLeft);
|
|
83875
|
+
if (extraRight > 0) attrs = removeColSpan(attrs, attrs.colspan - extraRight, extraRight);
|
|
82892
83876
|
if (cellRect.left < rect.left) {
|
|
82893
83877
|
cell = cell.type.createAndFill(attrs);
|
|
82894
|
-
if (!cell) {
|
|
82895
|
-
|
|
82896
|
-
`Could not create cell with attrs ${JSON.stringify(attrs)}`
|
|
82897
|
-
);
|
|
82898
|
-
}
|
|
82899
|
-
} else {
|
|
82900
|
-
cell = cell.type.create(attrs, cell.content);
|
|
82901
|
-
}
|
|
83878
|
+
if (!cell) throw new RangeError(`Could not create cell with attrs ${JSON.stringify(attrs)}`);
|
|
83879
|
+
} else cell = cell.type.create(attrs, cell.content);
|
|
82902
83880
|
}
|
|
82903
83881
|
if (cellRect.top < rect.top || cellRect.bottom > rect.bottom) {
|
|
82904
83882
|
const attrs = {
|
|
82905
83883
|
...cell.attrs,
|
|
82906
83884
|
rowspan: Math.min(cellRect.bottom, rect.bottom) - Math.max(cellRect.top, rect.top)
|
|
82907
83885
|
};
|
|
82908
|
-
if (cellRect.top < rect.top)
|
|
82909
|
-
|
|
82910
|
-
} else {
|
|
82911
|
-
cell = cell.type.create(attrs, cell.content);
|
|
82912
|
-
}
|
|
83886
|
+
if (cellRect.top < rect.top) cell = cell.type.createAndFill(attrs);
|
|
83887
|
+
else cell = cell.type.create(attrs, cell.content);
|
|
82913
83888
|
}
|
|
82914
83889
|
rowContent.push(cell);
|
|
82915
83890
|
}
|
|
@@ -82922,16 +83897,9 @@ var CellSelection = class _CellSelection extends Selection {
|
|
|
82922
83897
|
const mapFrom = tr.steps.length, ranges = this.ranges;
|
|
82923
83898
|
for (let i = 0; i < ranges.length; i++) {
|
|
82924
83899
|
const { $from, $to } = ranges[i], mapping = tr.mapping.slice(mapFrom);
|
|
82925
|
-
tr.replace(
|
|
82926
|
-
mapping.map($from.pos),
|
|
82927
|
-
mapping.map($to.pos),
|
|
82928
|
-
i ? Slice.empty : content
|
|
82929
|
-
);
|
|
83900
|
+
tr.replace(mapping.map($from.pos), mapping.map($to.pos), i ? Slice.empty : content);
|
|
82930
83901
|
}
|
|
82931
|
-
const sel = Selection.findFrom(
|
|
82932
|
-
tr.doc.resolve(tr.mapping.slice(mapFrom).map(this.to)),
|
|
82933
|
-
-1
|
|
82934
|
-
);
|
|
83902
|
+
const sel = Selection.findFrom(tr.doc.resolve(tr.mapping.slice(mapFrom).map(this.to)), -1);
|
|
82935
83903
|
if (sel) tr.setSelection(sel);
|
|
82936
83904
|
}
|
|
82937
83905
|
replaceWith(tr, node) {
|
|
@@ -82941,18 +83909,9 @@ var CellSelection = class _CellSelection extends Selection {
|
|
|
82941
83909
|
const table = this.$anchorCell.node(-1);
|
|
82942
83910
|
const map22 = TableMap.get(table);
|
|
82943
83911
|
const tableStart = this.$anchorCell.start(-1);
|
|
82944
|
-
const cells = map22.cellsInRect(
|
|
82945
|
-
|
|
82946
|
-
this.$anchorCell.pos - tableStart,
|
|
82947
|
-
this.$headCell.pos - tableStart
|
|
82948
|
-
)
|
|
82949
|
-
);
|
|
82950
|
-
for (let i = 0; i < cells.length; i++) {
|
|
82951
|
-
f2(table.nodeAt(cells[i]), tableStart + cells[i]);
|
|
82952
|
-
}
|
|
83912
|
+
const cells = map22.cellsInRect(map22.rectBetween(this.$anchorCell.pos - tableStart, this.$headCell.pos - tableStart));
|
|
83913
|
+
for (let i = 0; i < cells.length; i++) f2(table.nodeAt(cells[i]), tableStart + cells[i]);
|
|
82953
83914
|
}
|
|
82954
|
-
// True if this selection goes all the way from the top to the
|
|
82955
|
-
// bottom of the table.
|
|
82956
83915
|
isColSelection() {
|
|
82957
83916
|
const anchorTop = this.$anchorCell.index(-1);
|
|
82958
83917
|
const headTop = this.$headCell.index(-1);
|
|
@@ -82961,8 +83920,6 @@ var CellSelection = class _CellSelection extends Selection {
|
|
|
82961
83920
|
const headBottom = headTop + this.$headCell.nodeAfter.attrs.rowspan;
|
|
82962
83921
|
return Math.max(anchorBottom, headBottom) == this.$headCell.node(-1).childCount;
|
|
82963
83922
|
}
|
|
82964
|
-
// Returns the smallest column selection that covers the given anchor
|
|
82965
|
-
// and head cell.
|
|
82966
83923
|
static colSelection($anchorCell, $headCell = $anchorCell) {
|
|
82967
83924
|
const table = $anchorCell.node(-1);
|
|
82968
83925
|
const map22 = TableMap.get(table);
|
|
@@ -82971,24 +83928,14 @@ var CellSelection = class _CellSelection extends Selection {
|
|
|
82971
83928
|
const headRect = map22.findCell($headCell.pos - tableStart);
|
|
82972
83929
|
const doc2 = $anchorCell.node(0);
|
|
82973
83930
|
if (anchorRect.top <= headRect.top) {
|
|
82974
|
-
if (anchorRect.top > 0)
|
|
82975
|
-
|
|
82976
|
-
if (headRect.bottom < map22.height)
|
|
82977
|
-
$headCell = doc2.resolve(
|
|
82978
|
-
tableStart + map22.map[map22.width * (map22.height - 1) + headRect.right - 1]
|
|
82979
|
-
);
|
|
83931
|
+
if (anchorRect.top > 0) $anchorCell = doc2.resolve(tableStart + map22.map[anchorRect.left]);
|
|
83932
|
+
if (headRect.bottom < map22.height) $headCell = doc2.resolve(tableStart + map22.map[map22.width * (map22.height - 1) + headRect.right - 1]);
|
|
82980
83933
|
} else {
|
|
82981
|
-
if (headRect.top > 0)
|
|
82982
|
-
|
|
82983
|
-
if (anchorRect.bottom < map22.height)
|
|
82984
|
-
$anchorCell = doc2.resolve(
|
|
82985
|
-
tableStart + map22.map[map22.width * (map22.height - 1) + anchorRect.right - 1]
|
|
82986
|
-
);
|
|
83934
|
+
if (headRect.top > 0) $headCell = doc2.resolve(tableStart + map22.map[headRect.left]);
|
|
83935
|
+
if (anchorRect.bottom < map22.height) $anchorCell = doc2.resolve(tableStart + map22.map[map22.width * (map22.height - 1) + anchorRect.right - 1]);
|
|
82987
83936
|
}
|
|
82988
|
-
return new
|
|
83937
|
+
return new CellSelection2($anchorCell, $headCell);
|
|
82989
83938
|
}
|
|
82990
|
-
// True if this selection goes all the way from the left to the
|
|
82991
|
-
// right of the table.
|
|
82992
83939
|
isRowSelection() {
|
|
82993
83940
|
const table = this.$anchorCell.node(-1);
|
|
82994
83941
|
const map22 = TableMap.get(table);
|
|
@@ -83001,10 +83948,8 @@ var CellSelection = class _CellSelection extends Selection {
|
|
|
83001
83948
|
return Math.max(anchorRight, headRight) == map22.width;
|
|
83002
83949
|
}
|
|
83003
83950
|
eq(other) {
|
|
83004
|
-
return other instanceof
|
|
83951
|
+
return other instanceof CellSelection2 && other.$anchorCell.pos == this.$anchorCell.pos && other.$headCell.pos == this.$headCell.pos;
|
|
83005
83952
|
}
|
|
83006
|
-
// Returns the smallest row selection that covers the given anchor
|
|
83007
|
-
// and head cell.
|
|
83008
83953
|
static rowSelection($anchorCell, $headCell = $anchorCell) {
|
|
83009
83954
|
const table = $anchorCell.node(-1);
|
|
83010
83955
|
const map22 = TableMap.get(table);
|
|
@@ -83013,23 +83958,13 @@ var CellSelection = class _CellSelection extends Selection {
|
|
|
83013
83958
|
const headRect = map22.findCell($headCell.pos - tableStart);
|
|
83014
83959
|
const doc2 = $anchorCell.node(0);
|
|
83015
83960
|
if (anchorRect.left <= headRect.left) {
|
|
83016
|
-
if (anchorRect.left > 0)
|
|
83017
|
-
|
|
83018
|
-
tableStart + map22.map[anchorRect.top * map22.width]
|
|
83019
|
-
);
|
|
83020
|
-
if (headRect.right < map22.width)
|
|
83021
|
-
$headCell = doc2.resolve(
|
|
83022
|
-
tableStart + map22.map[map22.width * (headRect.top + 1) - 1]
|
|
83023
|
-
);
|
|
83961
|
+
if (anchorRect.left > 0) $anchorCell = doc2.resolve(tableStart + map22.map[anchorRect.top * map22.width]);
|
|
83962
|
+
if (headRect.right < map22.width) $headCell = doc2.resolve(tableStart + map22.map[map22.width * (headRect.top + 1) - 1]);
|
|
83024
83963
|
} else {
|
|
83025
|
-
if (headRect.left > 0)
|
|
83026
|
-
|
|
83027
|
-
if (anchorRect.right < map22.width)
|
|
83028
|
-
$anchorCell = doc2.resolve(
|
|
83029
|
-
tableStart + map22.map[map22.width * (anchorRect.top + 1) - 1]
|
|
83030
|
-
);
|
|
83964
|
+
if (headRect.left > 0) $headCell = doc2.resolve(tableStart + map22.map[headRect.top * map22.width]);
|
|
83965
|
+
if (anchorRect.right < map22.width) $anchorCell = doc2.resolve(tableStart + map22.map[map22.width * (anchorRect.top + 1) - 1]);
|
|
83031
83966
|
}
|
|
83032
|
-
return new
|
|
83967
|
+
return new CellSelection2($anchorCell, $headCell);
|
|
83033
83968
|
}
|
|
83034
83969
|
toJSON() {
|
|
83035
83970
|
return {
|
|
@@ -83039,10 +83974,10 @@ var CellSelection = class _CellSelection extends Selection {
|
|
|
83039
83974
|
};
|
|
83040
83975
|
}
|
|
83041
83976
|
static fromJSON(doc2, json) {
|
|
83042
|
-
return new
|
|
83977
|
+
return new CellSelection2(doc2.resolve(json.anchor), doc2.resolve(json.head));
|
|
83043
83978
|
}
|
|
83044
83979
|
static create(doc2, anchorCell, headCell = anchorCell) {
|
|
83045
|
-
return new
|
|
83980
|
+
return new CellSelection2(doc2.resolve(anchorCell), doc2.resolve(headCell));
|
|
83046
83981
|
}
|
|
83047
83982
|
getBookmark() {
|
|
83048
83983
|
return new CellBookmark(this.$anchorCell.pos, this.$headCell.pos);
|
|
@@ -83050,18 +83985,17 @@ var CellSelection = class _CellSelection extends Selection {
|
|
|
83050
83985
|
};
|
|
83051
83986
|
CellSelection.prototype.visible = false;
|
|
83052
83987
|
Selection.jsonID("cell", CellSelection);
|
|
83053
|
-
var CellBookmark = class
|
|
83988
|
+
var CellBookmark = class CellBookmark2 {
|
|
83054
83989
|
constructor(anchor, head) {
|
|
83055
83990
|
this.anchor = anchor;
|
|
83056
83991
|
this.head = head;
|
|
83057
83992
|
}
|
|
83058
83993
|
map(mapping) {
|
|
83059
|
-
return new
|
|
83994
|
+
return new CellBookmark2(mapping.map(this.anchor), mapping.map(this.head));
|
|
83060
83995
|
}
|
|
83061
83996
|
resolve(doc2) {
|
|
83062
83997
|
const $anchorCell = doc2.resolve(this.anchor), $headCell = doc2.resolve(this.head);
|
|
83063
|
-
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))
|
|
83064
|
-
return new CellSelection($anchorCell, $headCell);
|
|
83998
|
+
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);
|
|
83065
83999
|
else return Selection.near($headCell, 1);
|
|
83066
84000
|
}
|
|
83067
84001
|
};
|
|
@@ -83069,9 +84003,7 @@ function drawCellSelection(state2) {
|
|
|
83069
84003
|
if (!(state2.selection instanceof CellSelection)) return null;
|
|
83070
84004
|
const cells = [];
|
|
83071
84005
|
state2.selection.forEachCell((node, pos) => {
|
|
83072
|
-
cells.push(
|
|
83073
|
-
Decoration.node(pos, pos + node.nodeSize, { class: "selectedCell" })
|
|
83074
|
-
);
|
|
84006
|
+
cells.push(Decoration.node(pos, pos + node.nodeSize, { class: "selectedCell" }));
|
|
83075
84007
|
});
|
|
83076
84008
|
return DecorationSet.create(state2.doc, cells);
|
|
83077
84009
|
}
|
|
@@ -83080,10 +84012,8 @@ function isCellBoundarySelection({ $from, $to }) {
|
|
|
83080
84012
|
let afterFrom = $from.pos;
|
|
83081
84013
|
let beforeTo = $to.pos;
|
|
83082
84014
|
let depth = $from.depth;
|
|
83083
|
-
for (; depth >= 0; depth--, afterFrom++)
|
|
83084
|
-
|
|
83085
|
-
for (let d2 = $to.depth; d2 >= 0; d2--, beforeTo--)
|
|
83086
|
-
if ($to.before(d2 + 1) > $to.start(d2)) break;
|
|
84015
|
+
for (; depth >= 0; depth--, afterFrom++) if ($from.after(depth + 1) < $from.end(depth)) break;
|
|
84016
|
+
for (let d2 = $to.depth; d2 >= 0; d2--, beforeTo--) if ($to.before(d2 + 1) > $to.start(d2)) break;
|
|
83087
84017
|
return afterFrom == beforeTo && /row|table/.test($from.node(depth).type.spec.tableRole);
|
|
83088
84018
|
}
|
|
83089
84019
|
function isTextSelectionAcrossCells({ $from, $to }) {
|
|
@@ -83111,9 +84041,8 @@ function normalizeSelection(state2, tr, allowTableNodeSelection) {
|
|
|
83111
84041
|
let normalize2;
|
|
83112
84042
|
let role;
|
|
83113
84043
|
if (sel instanceof NodeSelection && (role = sel.node.type.spec.tableRole)) {
|
|
83114
|
-
if (role == "cell" || role == "header_cell")
|
|
83115
|
-
|
|
83116
|
-
} else if (role == "row") {
|
|
84044
|
+
if (role == "cell" || role == "header_cell") normalize2 = CellSelection.create(doc2, sel.from);
|
|
84045
|
+
else if (role == "row") {
|
|
83117
84046
|
const $cell = doc2.resolve(sel.from + 1);
|
|
83118
84047
|
normalize2 = CellSelection.rowSelection($cell, $cell);
|
|
83119
84048
|
} else if (!allowTableNodeSelection) {
|
|
@@ -83122,29 +84051,23 @@ function normalizeSelection(state2, tr, allowTableNodeSelection) {
|
|
|
83122
84051
|
const lastCell = start2 + map22.map[map22.width * map22.height - 1];
|
|
83123
84052
|
normalize2 = CellSelection.create(doc2, start2 + 1, lastCell);
|
|
83124
84053
|
}
|
|
83125
|
-
} else if (sel instanceof TextSelection$1 && isCellBoundarySelection(sel))
|
|
83126
|
-
|
|
83127
|
-
} else if (sel instanceof TextSelection$1 && isTextSelectionAcrossCells(sel)) {
|
|
83128
|
-
normalize2 = TextSelection$1.create(doc2, sel.$from.start(), sel.$from.end());
|
|
83129
|
-
}
|
|
84054
|
+
} else if (sel instanceof TextSelection$1 && isCellBoundarySelection(sel)) normalize2 = TextSelection$1.create(doc2, sel.from);
|
|
84055
|
+
else if (sel instanceof TextSelection$1 && isTextSelectionAcrossCells(sel)) normalize2 = TextSelection$1.create(doc2, sel.$from.start(), sel.$from.end());
|
|
83130
84056
|
if (normalize2) (tr || (tr = state2.tr)).setSelection(normalize2);
|
|
83131
84057
|
return tr;
|
|
83132
84058
|
}
|
|
83133
|
-
|
|
84059
|
+
const fixTablesKey = new PluginKey("fix-tables");
|
|
83134
84060
|
function changedDescendants(old, cur, offset2, f2) {
|
|
83135
84061
|
const oldSize = old.childCount, curSize = cur.childCount;
|
|
83136
84062
|
outer: for (let i = 0, j2 = 0; i < curSize; i++) {
|
|
83137
84063
|
const child = cur.child(i);
|
|
83138
|
-
for (let scan = j2, e = Math.min(oldSize, i + 3); scan < e; scan++) {
|
|
83139
|
-
|
|
83140
|
-
|
|
83141
|
-
|
|
83142
|
-
continue outer;
|
|
83143
|
-
}
|
|
84064
|
+
for (let scan = j2, e = Math.min(oldSize, i + 3); scan < e; scan++) if (old.child(scan) == child) {
|
|
84065
|
+
j2 = scan + 1;
|
|
84066
|
+
offset2 += child.nodeSize;
|
|
84067
|
+
continue outer;
|
|
83144
84068
|
}
|
|
83145
84069
|
f2(child, offset2);
|
|
83146
|
-
if (j2 < oldSize && old.child(j2).sameMarkup(child))
|
|
83147
|
-
changedDescendants(old.child(j2), child, offset2 + 1, f2);
|
|
84070
|
+
if (j2 < oldSize && old.child(j2).sameMarkup(child)) changedDescendants(old.child(j2), child, offset2 + 1, f2);
|
|
83148
84071
|
else child.nodesBetween(0, child.content.size, f2, offset2 + 1);
|
|
83149
84072
|
offset2 += child.nodeSize;
|
|
83150
84073
|
}
|
|
@@ -83152,12 +84075,10 @@ function changedDescendants(old, cur, offset2, f2) {
|
|
|
83152
84075
|
function fixTables(state2, oldState) {
|
|
83153
84076
|
let tr;
|
|
83154
84077
|
const check = (node, pos) => {
|
|
83155
|
-
if (node.type.spec.tableRole == "table")
|
|
83156
|
-
tr = fixTable(state2, node, pos, tr);
|
|
84078
|
+
if (node.type.spec.tableRole == "table") tr = fixTable(state2, node, pos, tr);
|
|
83157
84079
|
};
|
|
83158
84080
|
if (!oldState) state2.doc.descendants(check);
|
|
83159
|
-
else if (oldState.doc != state2.doc)
|
|
83160
|
-
changedDescendants(oldState.doc, state2.doc, 0, check);
|
|
84081
|
+
else if (oldState.doc != state2.doc) changedDescendants(oldState.doc, state2.doc, 0, check);
|
|
83161
84082
|
return tr;
|
|
83162
84083
|
}
|
|
83163
84084
|
function fixTable(state2, table, tablePos, tr) {
|
|
@@ -83173,14 +84094,9 @@ function fixTable(state2, table, tablePos, tr) {
|
|
|
83173
84094
|
if (!cell) continue;
|
|
83174
84095
|
const attrs = cell.attrs;
|
|
83175
84096
|
for (let j2 = 0; j2 < attrs.rowspan; j2++) mustAdd[prob.row + j2] += prob.n;
|
|
83176
|
-
tr.setNodeMarkup(
|
|
83177
|
-
|
|
83178
|
-
|
|
83179
|
-
removeColSpan(attrs, attrs.colspan - prob.n, prob.n)
|
|
83180
|
-
);
|
|
83181
|
-
} else if (prob.type == "missing") {
|
|
83182
|
-
mustAdd[prob.row] += prob.n;
|
|
83183
|
-
} else if (prob.type == "overlong_rowspan") {
|
|
84097
|
+
tr.setNodeMarkup(tr.mapping.map(tablePos + 1 + prob.pos), null, removeColSpan(attrs, attrs.colspan - prob.n, prob.n));
|
|
84098
|
+
} else if (prob.type == "missing") mustAdd[prob.row] += prob.n;
|
|
84099
|
+
else if (prob.type == "overlong_rowspan") {
|
|
83184
84100
|
const cell = table.nodeAt(prob.pos);
|
|
83185
84101
|
if (!cell) continue;
|
|
83186
84102
|
tr.setNodeMarkup(tr.mapping.map(tablePos + 1 + prob.pos), null, {
|
|
@@ -83200,20 +84116,17 @@ function fixTable(state2, table, tablePos, tr) {
|
|
|
83200
84116
|
}
|
|
83201
84117
|
}
|
|
83202
84118
|
let first2, last;
|
|
83203
|
-
for (let i = 0; i < mustAdd.length; i++)
|
|
83204
|
-
if (
|
|
83205
|
-
|
|
83206
|
-
|
|
83207
|
-
}
|
|
84119
|
+
for (let i = 0; i < mustAdd.length; i++) if (mustAdd[i]) {
|
|
84120
|
+
if (first2 == null) first2 = i;
|
|
84121
|
+
last = i;
|
|
84122
|
+
}
|
|
83208
84123
|
for (let i = 0, pos = tablePos + 1; i < map22.height; i++) {
|
|
83209
84124
|
const row = table.child(i);
|
|
83210
84125
|
const end2 = pos + row.nodeSize;
|
|
83211
84126
|
const add = mustAdd[i];
|
|
83212
84127
|
if (add > 0) {
|
|
83213
84128
|
let role = "cell";
|
|
83214
|
-
if (row.firstChild)
|
|
83215
|
-
role = row.firstChild.type.spec.tableRole;
|
|
83216
|
-
}
|
|
84129
|
+
if (row.firstChild) role = row.firstChild.type.spec.tableRole;
|
|
83217
84130
|
const nodes = [];
|
|
83218
84131
|
for (let j2 = 0; j2 < add; j2++) {
|
|
83219
84132
|
const node = tableNodeTypes(state2.schema)[role].createAndFill();
|
|
@@ -83232,27 +84145,22 @@ function selectedRect(state2) {
|
|
|
83232
84145
|
const table = $pos.node(-1);
|
|
83233
84146
|
const tableStart = $pos.start(-1);
|
|
83234
84147
|
const map22 = TableMap.get(table);
|
|
83235
|
-
|
|
83236
|
-
sel.$anchorCell.pos - tableStart,
|
|
83237
|
-
|
|
83238
|
-
|
|
83239
|
-
|
|
84148
|
+
return {
|
|
84149
|
+
...sel instanceof CellSelection ? map22.rectBetween(sel.$anchorCell.pos - tableStart, sel.$headCell.pos - tableStart) : map22.findCell($pos.pos - tableStart),
|
|
84150
|
+
tableStart,
|
|
84151
|
+
map: map22,
|
|
84152
|
+
table
|
|
84153
|
+
};
|
|
83240
84154
|
}
|
|
83241
84155
|
function addColumn(tr, { map: map22, tableStart, table }, col) {
|
|
83242
84156
|
let refColumn = col > 0 ? -1 : 0;
|
|
83243
|
-
if (columnIsHeader(map22, table, col + refColumn))
|
|
83244
|
-
refColumn = col == 0 || col == map22.width ? null : 0;
|
|
83245
|
-
}
|
|
84157
|
+
if (columnIsHeader(map22, table, col + refColumn)) refColumn = col == 0 || col == map22.width ? null : 0;
|
|
83246
84158
|
for (let row = 0; row < map22.height; row++) {
|
|
83247
84159
|
const index2 = row * map22.width + col;
|
|
83248
84160
|
if (col > 0 && col < map22.width && map22.map[index2 - 1] == map22.map[index2]) {
|
|
83249
84161
|
const pos = map22.map[index2];
|
|
83250
84162
|
const cell = table.nodeAt(pos);
|
|
83251
|
-
tr.setNodeMarkup(
|
|
83252
|
-
tr.mapping.map(tableStart + pos),
|
|
83253
|
-
null,
|
|
83254
|
-
addColSpan(cell.attrs, col - map22.colCount(pos))
|
|
83255
|
-
);
|
|
84163
|
+
tr.setNodeMarkup(tr.mapping.map(tableStart + pos), null, addColSpan(cell.attrs, col - map22.colCount(pos)));
|
|
83256
84164
|
row += cell.attrs.rowspan - 1;
|
|
83257
84165
|
} else {
|
|
83258
84166
|
const type2 = refColumn == null ? tableNodeTypes(table.type.schema).cell : table.nodeAt(map22.map[index2 + refColumn]).type;
|
|
@@ -83285,13 +84193,8 @@ function removeColumn(tr, { map: map22, table, tableStart }, col) {
|
|
|
83285
84193
|
const pos = map22.map[index2];
|
|
83286
84194
|
const cell = table.nodeAt(pos);
|
|
83287
84195
|
const attrs = cell.attrs;
|
|
83288
|
-
if (col > 0 && map22.map[index2 - 1] == pos || col < map22.width - 1 && map22.map[index2 + 1] == pos)
|
|
83289
|
-
|
|
83290
|
-
tr.mapping.slice(mapStart).map(tableStart + pos),
|
|
83291
|
-
null,
|
|
83292
|
-
removeColSpan(attrs, col - map22.colCount(pos))
|
|
83293
|
-
);
|
|
83294
|
-
} else {
|
|
84196
|
+
if (col > 0 && map22.map[index2 - 1] == pos || col < map22.width - 1 && map22.map[index2 + 1] == pos) tr.setNodeMarkup(tr.mapping.slice(mapStart).map(tableStart + pos), null, removeColSpan(attrs, col - map22.colCount(pos)));
|
|
84197
|
+
else {
|
|
83295
84198
|
const start2 = tr.mapping.slice(mapStart).map(tableStart + pos);
|
|
83296
84199
|
tr.delete(start2, start2 + cell.nodeSize);
|
|
83297
84200
|
}
|
|
@@ -83308,9 +84211,7 @@ function deleteColumn(state2, dispatch) {
|
|
|
83308
84211
|
removeColumn(tr, rect, i);
|
|
83309
84212
|
if (i == rect.left) break;
|
|
83310
84213
|
const table = rect.tableStart ? tr.doc.nodeAt(rect.tableStart - 1) : tr.doc;
|
|
83311
|
-
if (!table)
|
|
83312
|
-
throw RangeError("No table found");
|
|
83313
|
-
}
|
|
84214
|
+
if (!table) throw new RangeError("No table found");
|
|
83314
84215
|
rect.table = table;
|
|
83315
84216
|
rect.map = TableMap.get(table);
|
|
83316
84217
|
}
|
|
@@ -83319,35 +84220,30 @@ function deleteColumn(state2, dispatch) {
|
|
|
83319
84220
|
return true;
|
|
83320
84221
|
}
|
|
83321
84222
|
function rowIsHeader(map22, table, row) {
|
|
83322
|
-
var
|
|
84223
|
+
var _table$nodeAt;
|
|
83323
84224
|
const headerCell = tableNodeTypes(table.type.schema).header_cell;
|
|
83324
|
-
for (let col = 0; col < map22.width; col++)
|
|
83325
|
-
if (((_a2 = table.nodeAt(map22.map[col + row * map22.width])) == null ? void 0 : _a2.type) != headerCell)
|
|
83326
|
-
return false;
|
|
84225
|
+
for (let col = 0; col < map22.width; col++) if (((_table$nodeAt = table.nodeAt(map22.map[col + row * map22.width])) === null || _table$nodeAt === void 0 ? void 0 : _table$nodeAt.type) != headerCell) return false;
|
|
83327
84226
|
return true;
|
|
83328
84227
|
}
|
|
83329
84228
|
function addRow(tr, { map: map22, tableStart, table }, row) {
|
|
83330
|
-
var _a2;
|
|
83331
84229
|
let rowPos = tableStart;
|
|
83332
84230
|
for (let i = 0; i < row; i++) rowPos += table.child(i).nodeSize;
|
|
83333
84231
|
const cells = [];
|
|
83334
84232
|
let refRow = row > 0 ? -1 : 0;
|
|
83335
|
-
if (rowIsHeader(map22, table, row + refRow))
|
|
83336
|
-
|
|
83337
|
-
|
|
83338
|
-
|
|
83339
|
-
|
|
83340
|
-
|
|
83341
|
-
|
|
83342
|
-
|
|
83343
|
-
|
|
83344
|
-
|
|
83345
|
-
|
|
83346
|
-
|
|
83347
|
-
|
|
83348
|
-
|
|
83349
|
-
if (node) cells.push(node);
|
|
83350
|
-
}
|
|
84233
|
+
if (rowIsHeader(map22, table, row + refRow)) refRow = row == 0 || row == map22.height ? null : 0;
|
|
84234
|
+
for (let col = 0, index2 = map22.width * row; col < map22.width; col++, index2++) if (row > 0 && row < map22.height && map22.map[index2] == map22.map[index2 - map22.width]) {
|
|
84235
|
+
const pos = map22.map[index2];
|
|
84236
|
+
const attrs = table.nodeAt(pos).attrs;
|
|
84237
|
+
tr.setNodeMarkup(tableStart + pos, null, {
|
|
84238
|
+
...attrs,
|
|
84239
|
+
rowspan: attrs.rowspan + 1
|
|
84240
|
+
});
|
|
84241
|
+
col += attrs.colspan - 1;
|
|
84242
|
+
} else {
|
|
84243
|
+
var _table$nodeAt2;
|
|
84244
|
+
const type2 = refRow == null ? tableNodeTypes(table.type.schema).cell : (_table$nodeAt2 = table.nodeAt(map22.map[index2 + refRow * map22.width])) === null || _table$nodeAt2 === void 0 ? void 0 : _table$nodeAt2.type;
|
|
84245
|
+
const node = type2 === null || type2 === void 0 ? void 0 : type2.createAndFill();
|
|
84246
|
+
if (node) cells.push(node);
|
|
83351
84247
|
}
|
|
83352
84248
|
tr.insert(rowPos, tableNodeTypes(table.type.schema).row.create(null, cells));
|
|
83353
84249
|
return tr;
|
|
@@ -83389,10 +84285,10 @@ function removeRow(tr, { map: map22, table, tableStart }, row) {
|
|
|
83389
84285
|
} else if (row < map22.height && pos == map22.map[index2 + map22.width]) {
|
|
83390
84286
|
const cell = table.nodeAt(pos);
|
|
83391
84287
|
const attrs = cell.attrs;
|
|
83392
|
-
const copy2 = cell.type.create(
|
|
83393
|
-
|
|
83394
|
-
cell.
|
|
83395
|
-
);
|
|
84288
|
+
const copy2 = cell.type.create({
|
|
84289
|
+
...attrs,
|
|
84290
|
+
rowspan: cell.attrs.rowspan - 1
|
|
84291
|
+
}, cell.content);
|
|
83396
84292
|
const newPos = map22.positionAt(row + 1, col, table);
|
|
83397
84293
|
tr.insert(tr.mapping.slice(mapFrom).map(tableStart + newPos), copy2);
|
|
83398
84294
|
col += attrs.colspan - 1;
|
|
@@ -83408,9 +84304,7 @@ function deleteRow(state2, dispatch) {
|
|
|
83408
84304
|
removeRow(tr, rect, i);
|
|
83409
84305
|
if (i == rect.top) break;
|
|
83410
84306
|
const table = rect.tableStart ? tr.doc.nodeAt(rect.tableStart - 1) : tr.doc;
|
|
83411
|
-
if (!table)
|
|
83412
|
-
throw RangeError("No table found");
|
|
83413
|
-
}
|
|
84307
|
+
if (!table) throw new RangeError("No table found");
|
|
83414
84308
|
rect.table = table;
|
|
83415
84309
|
rect.map = TableMap.get(rect.table);
|
|
83416
84310
|
}
|
|
@@ -83426,14 +84320,12 @@ function cellsOverlapRectangle({ width, height, map: map22 }, rect) {
|
|
|
83426
84320
|
let indexTop = rect.top * width + rect.left, indexLeft = indexTop;
|
|
83427
84321
|
let indexBottom = (rect.bottom - 1) * width + rect.left, indexRight = indexTop + (rect.right - rect.left - 1);
|
|
83428
84322
|
for (let i = rect.top; i < rect.bottom; i++) {
|
|
83429
|
-
if (rect.left > 0 && map22[indexLeft] == map22[indexLeft - 1] || rect.right < width && map22[indexRight] == map22[indexRight + 1])
|
|
83430
|
-
return true;
|
|
84323
|
+
if (rect.left > 0 && map22[indexLeft] == map22[indexLeft - 1] || rect.right < width && map22[indexRight] == map22[indexRight + 1]) return true;
|
|
83431
84324
|
indexLeft += width;
|
|
83432
84325
|
indexRight += width;
|
|
83433
84326
|
}
|
|
83434
84327
|
for (let i = rect.left; i < rect.right; i++) {
|
|
83435
|
-
if (rect.top > 0 && map22[indexTop] == map22[indexTop - width] || rect.bottom < height && map22[indexBottom] == map22[indexBottom + width])
|
|
83436
|
-
return true;
|
|
84328
|
+
if (rect.top > 0 && map22[indexTop] == map22[indexTop - width] || rect.bottom < height && map22[indexBottom] == map22[indexBottom + width]) return true;
|
|
83437
84329
|
indexTop++;
|
|
83438
84330
|
indexBottom++;
|
|
83439
84331
|
}
|
|
@@ -83441,8 +84333,7 @@ function cellsOverlapRectangle({ width, height, map: map22 }, rect) {
|
|
|
83441
84333
|
}
|
|
83442
84334
|
function mergeCells(state2, dispatch) {
|
|
83443
84335
|
const sel = state2.selection;
|
|
83444
|
-
if (!(sel instanceof CellSelection) || sel.$anchorCell.pos == sel.$headCell.pos)
|
|
83445
|
-
return false;
|
|
84336
|
+
if (!(sel instanceof CellSelection) || sel.$anchorCell.pos == sel.$headCell.pos) return false;
|
|
83446
84337
|
const rect = selectedRect(state2), { map: map22 } = rect;
|
|
83447
84338
|
if (cellsOverlapRectangle(map22, rect)) return false;
|
|
83448
84339
|
if (dispatch) {
|
|
@@ -83451,41 +84342,31 @@ function mergeCells(state2, dispatch) {
|
|
|
83451
84342
|
let content = Fragment.empty;
|
|
83452
84343
|
let mergedPos;
|
|
83453
84344
|
let mergedCell;
|
|
83454
|
-
for (let row = rect.top; row < rect.bottom; row++) {
|
|
83455
|
-
|
|
83456
|
-
|
|
83457
|
-
|
|
83458
|
-
|
|
83459
|
-
|
|
83460
|
-
|
|
83461
|
-
|
|
83462
|
-
|
|
83463
|
-
|
|
83464
|
-
|
|
83465
|
-
|
|
83466
|
-
tr.delete(mapped, mapped + cell.nodeSize);
|
|
83467
|
-
}
|
|
84345
|
+
for (let row = rect.top; row < rect.bottom; row++) for (let col = rect.left; col < rect.right; col++) {
|
|
84346
|
+
const cellPos = map22.map[row * map22.width + col];
|
|
84347
|
+
const cell = rect.table.nodeAt(cellPos);
|
|
84348
|
+
if (seen[cellPos] || !cell) continue;
|
|
84349
|
+
seen[cellPos] = true;
|
|
84350
|
+
if (mergedPos == null) {
|
|
84351
|
+
mergedPos = cellPos;
|
|
84352
|
+
mergedCell = cell;
|
|
84353
|
+
} else {
|
|
84354
|
+
if (!isEmpty(cell)) content = content.append(cell.content);
|
|
84355
|
+
const mapped = tr.mapping.map(cellPos + rect.tableStart);
|
|
84356
|
+
tr.delete(mapped, mapped + cell.nodeSize);
|
|
83468
84357
|
}
|
|
83469
84358
|
}
|
|
83470
|
-
if (mergedPos == null || mergedCell == null)
|
|
83471
|
-
return true;
|
|
83472
|
-
}
|
|
84359
|
+
if (mergedPos == null || mergedCell == null) return true;
|
|
83473
84360
|
tr.setNodeMarkup(mergedPos + rect.tableStart, null, {
|
|
83474
|
-
...addColSpan(
|
|
83475
|
-
mergedCell.attrs,
|
|
83476
|
-
mergedCell.attrs.colspan,
|
|
83477
|
-
rect.right - rect.left - mergedCell.attrs.colspan
|
|
83478
|
-
),
|
|
84361
|
+
...addColSpan(mergedCell.attrs, mergedCell.attrs.colspan, rect.right - rect.left - mergedCell.attrs.colspan),
|
|
83479
84362
|
rowspan: rect.bottom - rect.top
|
|
83480
84363
|
});
|
|
83481
|
-
if (content.size) {
|
|
84364
|
+
if (content.size > 0) {
|
|
83482
84365
|
const end2 = mergedPos + 1 + mergedCell.content.size;
|
|
83483
84366
|
const start2 = isEmpty(mergedCell) ? mergedPos + 1 : end2;
|
|
83484
84367
|
tr.replaceWith(start2 + rect.tableStart, end2 + rect.tableStart, content);
|
|
83485
84368
|
}
|
|
83486
|
-
tr.setSelection(
|
|
83487
|
-
new CellSelection(tr.doc.resolve(mergedPos + rect.tableStart))
|
|
83488
|
-
);
|
|
84369
|
+
tr.setSelection(new CellSelection(tr.doc.resolve(mergedPos + rect.tableStart)));
|
|
83489
84370
|
dispatch(tr);
|
|
83490
84371
|
}
|
|
83491
84372
|
return true;
|
|
@@ -83498,63 +84379,57 @@ function splitCell(state2, dispatch) {
|
|
|
83498
84379
|
}
|
|
83499
84380
|
function splitCellWithType(getCellType2) {
|
|
83500
84381
|
return (state2, dispatch) => {
|
|
83501
|
-
var _a2;
|
|
83502
84382
|
const sel = state2.selection;
|
|
83503
84383
|
let cellNode;
|
|
83504
84384
|
let cellPos;
|
|
83505
84385
|
if (!(sel instanceof CellSelection)) {
|
|
84386
|
+
var _cellAround;
|
|
83506
84387
|
cellNode = cellWrapping$1(sel.$from);
|
|
83507
84388
|
if (!cellNode) return false;
|
|
83508
|
-
cellPos = (
|
|
84389
|
+
cellPos = (_cellAround = cellAround$1(sel.$from)) === null || _cellAround === void 0 ? void 0 : _cellAround.pos;
|
|
83509
84390
|
} else {
|
|
83510
84391
|
if (sel.$anchorCell.pos != sel.$headCell.pos) return false;
|
|
83511
84392
|
cellNode = sel.$anchorCell.nodeAfter;
|
|
83512
84393
|
cellPos = sel.$anchorCell.pos;
|
|
83513
84394
|
}
|
|
83514
|
-
if (cellNode == null || cellPos == null)
|
|
83515
|
-
|
|
83516
|
-
}
|
|
83517
|
-
if (cellNode.attrs.colspan == 1 && cellNode.attrs.rowspan == 1) {
|
|
83518
|
-
return false;
|
|
83519
|
-
}
|
|
84395
|
+
if (cellNode == null || cellPos == null) return false;
|
|
84396
|
+
if (cellNode.attrs.colspan == 1 && cellNode.attrs.rowspan == 1) return false;
|
|
83520
84397
|
if (dispatch) {
|
|
83521
84398
|
let baseAttrs = cellNode.attrs;
|
|
83522
84399
|
const attrs = [];
|
|
83523
84400
|
const colwidth = baseAttrs.colwidth;
|
|
83524
|
-
if (baseAttrs.rowspan > 1) baseAttrs = {
|
|
83525
|
-
|
|
84401
|
+
if (baseAttrs.rowspan > 1) baseAttrs = {
|
|
84402
|
+
...baseAttrs,
|
|
84403
|
+
rowspan: 1
|
|
84404
|
+
};
|
|
84405
|
+
if (baseAttrs.colspan > 1) baseAttrs = {
|
|
84406
|
+
...baseAttrs,
|
|
84407
|
+
colspan: 1
|
|
84408
|
+
};
|
|
83526
84409
|
const rect = selectedRect(state2), tr = state2.tr;
|
|
83527
|
-
for (let i = 0; i < rect.right - rect.left; i++)
|
|
83528
|
-
|
|
83529
|
-
|
|
83530
|
-
|
|
83531
|
-
colwidth: colwidth && colwidth[i] ? [colwidth[i]] : null
|
|
83532
|
-
} : baseAttrs
|
|
83533
|
-
);
|
|
84410
|
+
for (let i = 0; i < rect.right - rect.left; i++) attrs.push(colwidth ? {
|
|
84411
|
+
...baseAttrs,
|
|
84412
|
+
colwidth: colwidth && colwidth[i] ? [colwidth[i]] : null
|
|
84413
|
+
} : baseAttrs);
|
|
83534
84414
|
let lastCell;
|
|
83535
84415
|
for (let row = rect.top; row < rect.bottom; row++) {
|
|
83536
84416
|
let pos = rect.map.positionAt(row, rect.left, rect.table);
|
|
83537
84417
|
if (row == rect.top) pos += cellNode.nodeSize;
|
|
83538
84418
|
for (let col = rect.left, i = 0; col < rect.right; col++, i++) {
|
|
83539
84419
|
if (col == rect.left && row == rect.top) continue;
|
|
83540
|
-
tr.insert(
|
|
83541
|
-
|
|
83542
|
-
|
|
83543
|
-
|
|
83544
|
-
|
|
83545
|
-
|
|
83546
|
-
|
|
83547
|
-
|
|
83548
|
-
|
|
83549
|
-
|
|
83550
|
-
|
|
83551
|
-
|
|
83552
|
-
|
|
83553
|
-
new CellSelection(
|
|
83554
|
-
tr.doc.resolve(sel.$anchorCell.pos),
|
|
83555
|
-
lastCell ? tr.doc.resolve(lastCell) : void 0
|
|
83556
|
-
)
|
|
83557
|
-
);
|
|
84420
|
+
tr.insert(lastCell = tr.mapping.map(pos + rect.tableStart, 1), getCellType2({
|
|
84421
|
+
node: cellNode,
|
|
84422
|
+
row,
|
|
84423
|
+
col
|
|
84424
|
+
}).createAndFill(attrs[i]));
|
|
84425
|
+
}
|
|
84426
|
+
}
|
|
84427
|
+
tr.setNodeMarkup(cellPos, getCellType2({
|
|
84428
|
+
node: cellNode,
|
|
84429
|
+
row: rect.top,
|
|
84430
|
+
col: rect.left
|
|
84431
|
+
}), attrs[0]);
|
|
84432
|
+
if (sel instanceof CellSelection) tr.setSelection(new CellSelection(tr.doc.resolve(sel.$anchorCell.pos), lastCell ? tr.doc.resolve(lastCell) : void 0));
|
|
83558
84433
|
dispatch(tr);
|
|
83559
84434
|
}
|
|
83560
84435
|
return true;
|
|
@@ -83567,19 +84442,16 @@ function setCellAttr(name, value) {
|
|
|
83567
84442
|
if ($cell.nodeAfter.attrs[name] === value) return false;
|
|
83568
84443
|
if (dispatch) {
|
|
83569
84444
|
const tr = state2.tr;
|
|
83570
|
-
if (state2.selection instanceof CellSelection)
|
|
83571
|
-
|
|
83572
|
-
|
|
83573
|
-
tr.setNodeMarkup(pos, null, {
|
|
83574
|
-
...node.attrs,
|
|
83575
|
-
[name]: value
|
|
83576
|
-
});
|
|
83577
|
-
});
|
|
83578
|
-
else
|
|
83579
|
-
tr.setNodeMarkup($cell.pos, null, {
|
|
83580
|
-
...$cell.nodeAfter.attrs,
|
|
84445
|
+
if (state2.selection instanceof CellSelection) state2.selection.forEachCell((node, pos) => {
|
|
84446
|
+
if (node.attrs[name] !== value) tr.setNodeMarkup(pos, null, {
|
|
84447
|
+
...node.attrs,
|
|
83581
84448
|
[name]: value
|
|
83582
84449
|
});
|
|
84450
|
+
});
|
|
84451
|
+
else tr.setNodeMarkup($cell.pos, null, {
|
|
84452
|
+
...$cell.nodeAfter.attrs,
|
|
84453
|
+
[name]: value
|
|
84454
|
+
});
|
|
83583
84455
|
dispatch(tr);
|
|
83584
84456
|
}
|
|
83585
84457
|
return true;
|
|
@@ -83591,34 +84463,20 @@ function deprecated_toggleHeader(type2) {
|
|
|
83591
84463
|
if (dispatch) {
|
|
83592
84464
|
const types2 = tableNodeTypes(state2.schema);
|
|
83593
84465
|
const rect = selectedRect(state2), tr = state2.tr;
|
|
83594
|
-
const cells = rect.map.cellsInRect(
|
|
83595
|
-
|
|
83596
|
-
|
|
83597
|
-
|
|
83598
|
-
|
|
83599
|
-
|
|
83600
|
-
|
|
83601
|
-
|
|
83602
|
-
|
|
83603
|
-
|
|
83604
|
-
|
|
83605
|
-
} : rect
|
|
83606
|
-
);
|
|
84466
|
+
const cells = rect.map.cellsInRect(type2 == "column" ? {
|
|
84467
|
+
left: rect.left,
|
|
84468
|
+
top: 0,
|
|
84469
|
+
right: rect.right,
|
|
84470
|
+
bottom: rect.map.height
|
|
84471
|
+
} : type2 == "row" ? {
|
|
84472
|
+
left: 0,
|
|
84473
|
+
top: rect.top,
|
|
84474
|
+
right: rect.map.width,
|
|
84475
|
+
bottom: rect.bottom
|
|
84476
|
+
} : rect);
|
|
83607
84477
|
const nodes = cells.map((pos) => rect.table.nodeAt(pos));
|
|
83608
|
-
for (let i = 0; i < cells.length; i++)
|
|
83609
|
-
|
|
83610
|
-
tr.setNodeMarkup(
|
|
83611
|
-
rect.tableStart + cells[i],
|
|
83612
|
-
types2.cell,
|
|
83613
|
-
nodes[i].attrs
|
|
83614
|
-
);
|
|
83615
|
-
if (tr.steps.length == 0)
|
|
83616
|
-
for (let i = 0; i < cells.length; i++)
|
|
83617
|
-
tr.setNodeMarkup(
|
|
83618
|
-
rect.tableStart + cells[i],
|
|
83619
|
-
types2.header_cell,
|
|
83620
|
-
nodes[i].attrs
|
|
83621
|
-
);
|
|
84478
|
+
for (let i = 0; i < cells.length; i++) if (nodes[i].type == types2.header_cell) tr.setNodeMarkup(rect.tableStart + cells[i], types2.cell, nodes[i].attrs);
|
|
84479
|
+
if (tr.steps.length === 0) for (let i = 0; i < cells.length; i++) tr.setNodeMarkup(rect.tableStart + cells[i], types2.header_cell, nodes[i].attrs);
|
|
83622
84480
|
dispatch(tr);
|
|
83623
84481
|
}
|
|
83624
84482
|
return true;
|
|
@@ -83633,9 +84491,7 @@ function isHeaderEnabledByType(type2, rect, types2) {
|
|
|
83633
84491
|
});
|
|
83634
84492
|
for (let i = 0; i < cellPositions.length; i++) {
|
|
83635
84493
|
const cell = rect.table.nodeAt(cellPositions[i]);
|
|
83636
|
-
if (cell && cell.type !== types2.header_cell)
|
|
83637
|
-
return false;
|
|
83638
|
-
}
|
|
84494
|
+
if (cell && cell.type !== types2.header_cell) return false;
|
|
83639
84495
|
}
|
|
83640
84496
|
return true;
|
|
83641
84497
|
}
|
|
@@ -83648,13 +84504,8 @@ function toggleHeader(type2, options) {
|
|
|
83648
84504
|
const types2 = tableNodeTypes(state2.schema);
|
|
83649
84505
|
const rect = selectedRect(state2), tr = state2.tr;
|
|
83650
84506
|
const isHeaderRowEnabled = isHeaderEnabledByType("row", rect, types2);
|
|
83651
|
-
const isHeaderColumnEnabled = isHeaderEnabledByType(
|
|
83652
|
-
|
|
83653
|
-
rect,
|
|
83654
|
-
types2
|
|
83655
|
-
);
|
|
83656
|
-
const isHeaderEnabled = type2 === "column" ? isHeaderRowEnabled : type2 === "row" ? isHeaderColumnEnabled : false;
|
|
83657
|
-
const selectionStartsAt = isHeaderEnabled ? 1 : 0;
|
|
84507
|
+
const isHeaderColumnEnabled = isHeaderEnabledByType("column", rect, types2);
|
|
84508
|
+
const selectionStartsAt = (type2 === "column" ? isHeaderRowEnabled : type2 === "row" ? isHeaderColumnEnabled : false) ? 1 : 0;
|
|
83658
84509
|
const cellsRect = type2 == "column" ? {
|
|
83659
84510
|
left: 0,
|
|
83660
84511
|
top: selectionStartsAt,
|
|
@@ -83670,24 +84521,16 @@ function toggleHeader(type2, options) {
|
|
|
83670
84521
|
rect.map.cellsInRect(cellsRect).forEach((relativeCellPos) => {
|
|
83671
84522
|
const cellPos = relativeCellPos + rect.tableStart;
|
|
83672
84523
|
const cell = tr.doc.nodeAt(cellPos);
|
|
83673
|
-
if (cell)
|
|
83674
|
-
tr.setNodeMarkup(cellPos, newType, cell.attrs);
|
|
83675
|
-
}
|
|
84524
|
+
if (cell) tr.setNodeMarkup(cellPos, newType, cell.attrs);
|
|
83676
84525
|
});
|
|
83677
84526
|
dispatch(tr);
|
|
83678
84527
|
}
|
|
83679
84528
|
return true;
|
|
83680
84529
|
};
|
|
83681
84530
|
}
|
|
83682
|
-
toggleHeader("row", {
|
|
83683
|
-
|
|
83684
|
-
});
|
|
83685
|
-
toggleHeader("column", {
|
|
83686
|
-
useDeprecatedLogic: true
|
|
83687
|
-
});
|
|
83688
|
-
var toggleHeaderCell = toggleHeader("cell", {
|
|
83689
|
-
useDeprecatedLogic: true
|
|
83690
|
-
});
|
|
84531
|
+
toggleHeader("row", { useDeprecatedLogic: true });
|
|
84532
|
+
toggleHeader("column", { useDeprecatedLogic: true });
|
|
84533
|
+
const toggleHeaderCell = toggleHeader("cell", { useDeprecatedLogic: true });
|
|
83691
84534
|
function findNextCell($cell, dir) {
|
|
83692
84535
|
if (dir < 0) {
|
|
83693
84536
|
const before = $cell.nodeBefore;
|
|
@@ -83695,15 +84538,11 @@ function findNextCell($cell, dir) {
|
|
|
83695
84538
|
for (let row = $cell.index(-1) - 1, rowEnd = $cell.before(); row >= 0; row--) {
|
|
83696
84539
|
const rowNode = $cell.node(-1).child(row);
|
|
83697
84540
|
const lastChild = rowNode.lastChild;
|
|
83698
|
-
if (lastChild)
|
|
83699
|
-
return rowEnd - 1 - lastChild.nodeSize;
|
|
83700
|
-
}
|
|
84541
|
+
if (lastChild) return rowEnd - 1 - lastChild.nodeSize;
|
|
83701
84542
|
rowEnd -= rowNode.nodeSize;
|
|
83702
84543
|
}
|
|
83703
84544
|
} else {
|
|
83704
|
-
if ($cell.index() < $cell.parent.childCount - 1)
|
|
83705
|
-
return $cell.pos + $cell.nodeAfter.nodeSize;
|
|
83706
|
-
}
|
|
84545
|
+
if ($cell.index() < $cell.parent.childCount - 1) return $cell.pos + $cell.nodeAfter.nodeSize;
|
|
83707
84546
|
const table = $cell.node(-1);
|
|
83708
84547
|
for (let row = $cell.indexAfter(-1), rowStart = $cell.after(); row < table.childCount; row++) {
|
|
83709
84548
|
const rowNode = table.child(row);
|
|
@@ -83720,24 +84559,16 @@ function goToNextCell(direction) {
|
|
|
83720
84559
|
if (cell == null) return false;
|
|
83721
84560
|
if (dispatch) {
|
|
83722
84561
|
const $cell = state2.doc.resolve(cell);
|
|
83723
|
-
dispatch(
|
|
83724
|
-
state2.tr.setSelection(TextSelection$1.between($cell, moveCellForward($cell))).scrollIntoView()
|
|
83725
|
-
);
|
|
84562
|
+
dispatch(state2.tr.setSelection(TextSelection$1.between($cell, moveCellForward($cell))).scrollIntoView());
|
|
83726
84563
|
}
|
|
83727
84564
|
return true;
|
|
83728
84565
|
};
|
|
83729
84566
|
}
|
|
83730
84567
|
function deleteTable(state2, dispatch) {
|
|
83731
84568
|
const $pos = state2.selection.$anchor;
|
|
83732
|
-
for (let d2 = $pos.depth; d2 > 0; d2--) {
|
|
83733
|
-
|
|
83734
|
-
|
|
83735
|
-
if (dispatch)
|
|
83736
|
-
dispatch(
|
|
83737
|
-
state2.tr.delete($pos.before(d2), $pos.after(d2)).scrollIntoView()
|
|
83738
|
-
);
|
|
83739
|
-
return true;
|
|
83740
|
-
}
|
|
84569
|
+
for (let d2 = $pos.depth; d2 > 0; d2--) if ($pos.node(d2).type.spec.tableRole == "table") {
|
|
84570
|
+
if (dispatch) dispatch(state2.tr.delete($pos.before(d2), $pos.after(d2)).scrollIntoView());
|
|
84571
|
+
return true;
|
|
83741
84572
|
}
|
|
83742
84573
|
return false;
|
|
83743
84574
|
}
|
|
@@ -83748,19 +84579,14 @@ function deleteCellSelection(state2, dispatch) {
|
|
|
83748
84579
|
const tr = state2.tr;
|
|
83749
84580
|
const baseContent = tableNodeTypes(state2.schema).cell.createAndFill().content;
|
|
83750
84581
|
sel.forEachCell((cell, pos) => {
|
|
83751
|
-
if (!cell.content.eq(baseContent))
|
|
83752
|
-
tr.replace(
|
|
83753
|
-
tr.mapping.map(pos + 1),
|
|
83754
|
-
tr.mapping.map(pos + cell.nodeSize - 1),
|
|
83755
|
-
new Slice(baseContent, 0, 0)
|
|
83756
|
-
);
|
|
84582
|
+
if (!cell.content.eq(baseContent)) tr.replace(tr.mapping.map(pos + 1), tr.mapping.map(pos + cell.nodeSize - 1), new Slice(baseContent, 0, 0));
|
|
83757
84583
|
});
|
|
83758
84584
|
if (tr.docChanged) dispatch(tr);
|
|
83759
84585
|
}
|
|
83760
84586
|
return true;
|
|
83761
84587
|
}
|
|
83762
84588
|
function pastedCells(slice2) {
|
|
83763
|
-
if (
|
|
84589
|
+
if (slice2.size === 0) return null;
|
|
83764
84590
|
let { content, openStart, openEnd } = slice2;
|
|
83765
84591
|
while (content.childCount == 1 && (openStart > 0 && openEnd > 0 || content.child(0).type.spec.tableRole == "table")) {
|
|
83766
84592
|
openStart--;
|
|
@@ -83770,28 +84596,15 @@ function pastedCells(slice2) {
|
|
|
83770
84596
|
const first2 = content.child(0);
|
|
83771
84597
|
const role = first2.type.spec.tableRole;
|
|
83772
84598
|
const schema = first2.type.schema, rows = [];
|
|
83773
|
-
if (role == "row") {
|
|
83774
|
-
|
|
83775
|
-
|
|
83776
|
-
|
|
83777
|
-
|
|
83778
|
-
|
|
83779
|
-
|
|
83780
|
-
|
|
83781
|
-
|
|
83782
|
-
).content;
|
|
83783
|
-
rows.push(cells);
|
|
83784
|
-
}
|
|
83785
|
-
} else if (role == "cell" || role == "header_cell") {
|
|
83786
|
-
rows.push(
|
|
83787
|
-
openStart || openEnd ? fitSlice(
|
|
83788
|
-
tableNodeTypes(schema).row,
|
|
83789
|
-
new Slice(content, openStart, openEnd)
|
|
83790
|
-
).content : content
|
|
83791
|
-
);
|
|
83792
|
-
} else {
|
|
83793
|
-
return null;
|
|
83794
|
-
}
|
|
84599
|
+
if (role == "row") for (let i = 0; i < content.childCount; i++) {
|
|
84600
|
+
let cells = content.child(i).content;
|
|
84601
|
+
const left2 = i ? 0 : Math.max(0, openStart - 1);
|
|
84602
|
+
const right2 = i < content.childCount - 1 ? 0 : Math.max(0, openEnd - 1);
|
|
84603
|
+
if (left2 || right2) cells = fitSlice(tableNodeTypes(schema).row, new Slice(cells, left2, right2)).content;
|
|
84604
|
+
rows.push(cells);
|
|
84605
|
+
}
|
|
84606
|
+
else if (role == "cell" || role == "header_cell") rows.push(openStart || openEnd ? fitSlice(tableNodeTypes(schema).row, new Slice(content, openStart, openEnd)).content : content);
|
|
84607
|
+
else return null;
|
|
83795
84608
|
return ensureRectangular(schema, rows);
|
|
83796
84609
|
}
|
|
83797
84610
|
function ensureRectangular(schema, rows) {
|
|
@@ -83800,8 +84613,7 @@ function ensureRectangular(schema, rows) {
|
|
|
83800
84613
|
const row = rows[i];
|
|
83801
84614
|
for (let j2 = row.childCount - 1; j2 >= 0; j2--) {
|
|
83802
84615
|
const { rowspan, colspan } = row.child(j2).attrs;
|
|
83803
|
-
for (let r2 = i; r2 < i + rowspan; r2++)
|
|
83804
|
-
widths[r2] = (widths[r2] || 0) + colspan;
|
|
84616
|
+
for (let r2 = i; r2 < i + rowspan; r2++) widths[r2] = (widths[r2] || 0) + colspan;
|
|
83805
84617
|
}
|
|
83806
84618
|
}
|
|
83807
84619
|
let width = 0;
|
|
@@ -83811,18 +84623,19 @@ function ensureRectangular(schema, rows) {
|
|
|
83811
84623
|
if (widths[r2] < width) {
|
|
83812
84624
|
const empty2 = tableNodeTypes(schema).cell.createAndFill();
|
|
83813
84625
|
const cells = [];
|
|
83814
|
-
for (let i = widths[r2]; i < width; i++)
|
|
83815
|
-
cells.push(empty2);
|
|
83816
|
-
}
|
|
84626
|
+
for (let i = widths[r2]; i < width; i++) cells.push(empty2);
|
|
83817
84627
|
rows[r2] = rows[r2].append(Fragment.from(cells));
|
|
83818
84628
|
}
|
|
83819
84629
|
}
|
|
83820
|
-
return {
|
|
84630
|
+
return {
|
|
84631
|
+
height: rows.length,
|
|
84632
|
+
width,
|
|
84633
|
+
rows
|
|
84634
|
+
};
|
|
83821
84635
|
}
|
|
83822
84636
|
function fitSlice(nodeType, slice2) {
|
|
83823
84637
|
const node = nodeType.createAndFill();
|
|
83824
|
-
|
|
83825
|
-
return tr.doc;
|
|
84638
|
+
return new Transform(node).replace(0, node.content.size, slice2).doc;
|
|
83826
84639
|
}
|
|
83827
84640
|
function clipCells({ width, height, rows }, newWidth, newHeight) {
|
|
83828
84641
|
if (width != newWidth) {
|
|
@@ -83832,19 +84645,10 @@ function clipCells({ width, height, rows }, newWidth, newHeight) {
|
|
|
83832
84645
|
const frag = rows[row], cells = [];
|
|
83833
84646
|
for (let col = added[row] || 0, i = 0; col < newWidth; i++) {
|
|
83834
84647
|
let cell = frag.child(i % frag.childCount);
|
|
83835
|
-
if (col + cell.attrs.colspan > newWidth)
|
|
83836
|
-
cell = cell.type.createChecked(
|
|
83837
|
-
removeColSpan(
|
|
83838
|
-
cell.attrs,
|
|
83839
|
-
cell.attrs.colspan,
|
|
83840
|
-
col + cell.attrs.colspan - newWidth
|
|
83841
|
-
),
|
|
83842
|
-
cell.content
|
|
83843
|
-
);
|
|
84648
|
+
if (col + cell.attrs.colspan > newWidth) cell = cell.type.createChecked(removeColSpan(cell.attrs, cell.attrs.colspan, col + cell.attrs.colspan - newWidth), cell.content);
|
|
83844
84649
|
cells.push(cell);
|
|
83845
84650
|
col += cell.attrs.colspan;
|
|
83846
|
-
for (let j2 = 1; j2 < cell.attrs.rowspan; j2++)
|
|
83847
|
-
added[row + j2] = (added[row + j2] || 0) + cell.attrs.colspan;
|
|
84651
|
+
for (let j2 = 1; j2 < cell.attrs.rowspan; j2++) added[row + j2] = (added[row + j2] || 0) + cell.attrs.colspan;
|
|
83848
84652
|
}
|
|
83849
84653
|
newRows.push(Fragment.from(cells));
|
|
83850
84654
|
}
|
|
@@ -83857,14 +84661,10 @@ function clipCells({ width, height, rows }, newWidth, newHeight) {
|
|
|
83857
84661
|
const cells = [], source = rows[i % height];
|
|
83858
84662
|
for (let j2 = 0; j2 < source.childCount; j2++) {
|
|
83859
84663
|
let cell = source.child(j2);
|
|
83860
|
-
if (row + cell.attrs.rowspan > newHeight)
|
|
83861
|
-
cell
|
|
83862
|
-
|
|
83863
|
-
|
|
83864
|
-
rowspan: Math.max(1, newHeight - cell.attrs.rowspan)
|
|
83865
|
-
},
|
|
83866
|
-
cell.content
|
|
83867
|
-
);
|
|
84664
|
+
if (row + cell.attrs.rowspan > newHeight) cell = cell.type.create({
|
|
84665
|
+
...cell.attrs,
|
|
84666
|
+
rowspan: Math.max(1, newHeight - cell.attrs.rowspan)
|
|
84667
|
+
}, cell.content);
|
|
83868
84668
|
cells.push(cell);
|
|
83869
84669
|
}
|
|
83870
84670
|
newRows.push(Fragment.from(cells));
|
|
@@ -83872,33 +84672,32 @@ function clipCells({ width, height, rows }, newWidth, newHeight) {
|
|
|
83872
84672
|
rows = newRows;
|
|
83873
84673
|
height = newHeight;
|
|
83874
84674
|
}
|
|
83875
|
-
return {
|
|
84675
|
+
return {
|
|
84676
|
+
width,
|
|
84677
|
+
height,
|
|
84678
|
+
rows
|
|
84679
|
+
};
|
|
83876
84680
|
}
|
|
83877
84681
|
function growTable(tr, map22, table, start2, width, height, mapFrom) {
|
|
83878
84682
|
const schema = tr.doc.type.schema;
|
|
83879
84683
|
const types2 = tableNodeTypes(schema);
|
|
83880
84684
|
let empty2;
|
|
83881
84685
|
let emptyHead;
|
|
83882
|
-
if (width > map22.width) {
|
|
83883
|
-
|
|
83884
|
-
|
|
83885
|
-
|
|
83886
|
-
|
|
83887
|
-
|
|
83888
|
-
|
|
83889
|
-
|
|
83890
|
-
|
|
83891
|
-
for (let i = map22.width; i < width; i++) cells.push(add);
|
|
83892
|
-
tr.insert(tr.mapping.slice(mapFrom).map(rowEnd - 1 + start2), cells);
|
|
83893
|
-
}
|
|
84686
|
+
if (width > map22.width) for (let row = 0, rowEnd = 0; row < map22.height; row++) {
|
|
84687
|
+
const rowNode = table.child(row);
|
|
84688
|
+
rowEnd += rowNode.nodeSize;
|
|
84689
|
+
const cells = [];
|
|
84690
|
+
let add;
|
|
84691
|
+
if (rowNode.lastChild == null || rowNode.lastChild.type == types2.cell) add = empty2 || (empty2 = types2.cell.createAndFill());
|
|
84692
|
+
else add = emptyHead || (emptyHead = types2.header_cell.createAndFill());
|
|
84693
|
+
for (let i = map22.width; i < width; i++) cells.push(add);
|
|
84694
|
+
tr.insert(tr.mapping.slice(mapFrom).map(rowEnd - 1 + start2), cells);
|
|
83894
84695
|
}
|
|
83895
84696
|
if (height > map22.height) {
|
|
83896
84697
|
const cells = [];
|
|
83897
|
-
for (let i = 0,
|
|
83898
|
-
const header = i >= map22.width ? false : table.nodeAt(map22.map[
|
|
83899
|
-
cells.push(
|
|
83900
|
-
header ? emptyHead || (emptyHead = types2.header_cell.createAndFill()) : empty2 || (empty2 = types2.cell.createAndFill())
|
|
83901
|
-
);
|
|
84698
|
+
for (let i = 0, start$1 = (map22.height - 1) * map22.width; i < Math.max(map22.width, width); i++) {
|
|
84699
|
+
const header = i >= map22.width ? false : table.nodeAt(map22.map[start$1 + i]).type == types2.header_cell;
|
|
84700
|
+
cells.push(header ? emptyHead || (emptyHead = types2.header_cell.createAndFill()) : empty2 || (empty2 = types2.cell.createAndFill()));
|
|
83902
84701
|
}
|
|
83903
84702
|
const emptyRow = types2.row.create(null, Fragment.from(cells)), rows = [];
|
|
83904
84703
|
for (let i = map22.height; i < height; i++) rows.push(emptyRow);
|
|
@@ -83919,13 +84718,10 @@ function isolateHorizontal(tr, map22, table, start2, left2, right2, top2, mapFro
|
|
|
83919
84718
|
...cell.attrs,
|
|
83920
84719
|
rowspan: top2 - cellTop
|
|
83921
84720
|
});
|
|
83922
|
-
tr.insert(
|
|
83923
|
-
|
|
83924
|
-
cell.
|
|
83925
|
-
|
|
83926
|
-
rowspan: cellTop + cell.attrs.rowspan - top2
|
|
83927
|
-
})
|
|
83928
|
-
);
|
|
84721
|
+
tr.insert(tr.mapping.slice(mapFrom).map(map22.positionAt(top2, cellLeft, table)), cell.type.createAndFill({
|
|
84722
|
+
...cell.attrs,
|
|
84723
|
+
rowspan: cellTop + cell.attrs.rowspan - top2
|
|
84724
|
+
}));
|
|
83929
84725
|
col += cell.attrs.colspan - 1;
|
|
83930
84726
|
}
|
|
83931
84727
|
}
|
|
@@ -83941,21 +84737,8 @@ function isolateVertical(tr, map22, table, start2, top2, bottom2, left2, mapFrom
|
|
|
83941
84737
|
const cell = table.nodeAt(pos);
|
|
83942
84738
|
const cellLeft = map22.colCount(pos);
|
|
83943
84739
|
const updatePos = tr.mapping.slice(mapFrom).map(pos + start2);
|
|
83944
|
-
tr.setNodeMarkup(
|
|
83945
|
-
|
|
83946
|
-
null,
|
|
83947
|
-
removeColSpan(
|
|
83948
|
-
cell.attrs,
|
|
83949
|
-
left2 - cellLeft,
|
|
83950
|
-
cell.attrs.colspan - (left2 - cellLeft)
|
|
83951
|
-
)
|
|
83952
|
-
);
|
|
83953
|
-
tr.insert(
|
|
83954
|
-
updatePos + cell.nodeSize,
|
|
83955
|
-
cell.type.createAndFill(
|
|
83956
|
-
removeColSpan(cell.attrs, 0, left2 - cellLeft)
|
|
83957
|
-
)
|
|
83958
|
-
);
|
|
84740
|
+
tr.setNodeMarkup(updatePos, null, removeColSpan(cell.attrs, left2 - cellLeft, cell.attrs.colspan - (left2 - cellLeft)));
|
|
84741
|
+
tr.insert(updatePos + cell.nodeSize, cell.type.createAndFill(removeColSpan(cell.attrs, 0, left2 - cellLeft)));
|
|
83959
84742
|
row += cell.attrs.rowspan - 1;
|
|
83960
84743
|
}
|
|
83961
84744
|
}
|
|
@@ -83963,9 +84746,7 @@ function isolateVertical(tr, map22, table, start2, top2, bottom2, left2, mapFrom
|
|
|
83963
84746
|
}
|
|
83964
84747
|
function insertCells(state2, dispatch, tableStart, rect, cells) {
|
|
83965
84748
|
let table = tableStart ? state2.doc.nodeAt(tableStart - 1) : state2.doc;
|
|
83966
|
-
if (!table)
|
|
83967
|
-
throw new Error("No table found");
|
|
83968
|
-
}
|
|
84749
|
+
if (!table) throw new Error("No table found");
|
|
83969
84750
|
let map22 = TableMap.get(table);
|
|
83970
84751
|
const { top: top2, left: left2 } = rect;
|
|
83971
84752
|
const right2 = left2 + cells.width, bottom2 = top2 + cells.height;
|
|
@@ -83973,39 +84754,24 @@ function insertCells(state2, dispatch, tableStart, rect, cells) {
|
|
|
83973
84754
|
let mapFrom = 0;
|
|
83974
84755
|
function recomp() {
|
|
83975
84756
|
table = tableStart ? tr.doc.nodeAt(tableStart - 1) : tr.doc;
|
|
83976
|
-
if (!table)
|
|
83977
|
-
throw new Error("No table found");
|
|
83978
|
-
}
|
|
84757
|
+
if (!table) throw new Error("No table found");
|
|
83979
84758
|
map22 = TableMap.get(table);
|
|
83980
84759
|
mapFrom = tr.mapping.maps.length;
|
|
83981
84760
|
}
|
|
83982
84761
|
if (growTable(tr, map22, table, tableStart, right2, bottom2, mapFrom)) recomp();
|
|
83983
|
-
if (isolateHorizontal(tr, map22, table, tableStart, left2, right2, top2, mapFrom))
|
|
83984
|
-
|
|
83985
|
-
if (
|
|
83986
|
-
|
|
83987
|
-
if (isolateVertical(tr, map22, table, tableStart, top2, bottom2, left2, mapFrom))
|
|
83988
|
-
recomp();
|
|
83989
|
-
if (isolateVertical(tr, map22, table, tableStart, top2, bottom2, right2, mapFrom))
|
|
83990
|
-
recomp();
|
|
84762
|
+
if (isolateHorizontal(tr, map22, table, tableStart, left2, right2, top2, mapFrom)) recomp();
|
|
84763
|
+
if (isolateHorizontal(tr, map22, table, tableStart, left2, right2, bottom2, mapFrom)) recomp();
|
|
84764
|
+
if (isolateVertical(tr, map22, table, tableStart, top2, bottom2, left2, mapFrom)) recomp();
|
|
84765
|
+
if (isolateVertical(tr, map22, table, tableStart, top2, bottom2, right2, mapFrom)) recomp();
|
|
83991
84766
|
for (let row = top2; row < bottom2; row++) {
|
|
83992
84767
|
const from2 = map22.positionAt(row, left2, table), to = map22.positionAt(row, right2, table);
|
|
83993
|
-
tr.replace(
|
|
83994
|
-
tr.mapping.slice(mapFrom).map(from2 + tableStart),
|
|
83995
|
-
tr.mapping.slice(mapFrom).map(to + tableStart),
|
|
83996
|
-
new Slice(cells.rows[row - top2], 0, 0)
|
|
83997
|
-
);
|
|
84768
|
+
tr.replace(tr.mapping.slice(mapFrom).map(from2 + tableStart), tr.mapping.slice(mapFrom).map(to + tableStart), new Slice(cells.rows[row - top2], 0, 0));
|
|
83998
84769
|
}
|
|
83999
84770
|
recomp();
|
|
84000
|
-
tr.setSelection(
|
|
84001
|
-
new CellSelection(
|
|
84002
|
-
tr.doc.resolve(tableStart + map22.positionAt(top2, left2, table)),
|
|
84003
|
-
tr.doc.resolve(tableStart + map22.positionAt(bottom2 - 1, right2 - 1, table))
|
|
84004
|
-
)
|
|
84005
|
-
);
|
|
84771
|
+
tr.setSelection(new CellSelection(tr.doc.resolve(tableStart + map22.positionAt(top2, left2, table)), tr.doc.resolve(tableStart + map22.positionAt(bottom2 - 1, right2 - 1, table))));
|
|
84006
84772
|
dispatch(tr);
|
|
84007
84773
|
}
|
|
84008
|
-
|
|
84774
|
+
const handleKeyDown = keydownHandler({
|
|
84009
84775
|
ArrowLeft: arrow$2("horiz", -1),
|
|
84010
84776
|
ArrowRight: arrow$2("horiz", 1),
|
|
84011
84777
|
ArrowUp: arrow$2("vert", -1),
|
|
@@ -84028,29 +84794,17 @@ function arrow$2(axis, dir) {
|
|
|
84028
84794
|
return (state2, dispatch, view) => {
|
|
84029
84795
|
if (!view) return false;
|
|
84030
84796
|
const sel = state2.selection;
|
|
84031
|
-
if (sel instanceof CellSelection)
|
|
84032
|
-
return maybeSetSelection(
|
|
84033
|
-
state2,
|
|
84034
|
-
dispatch,
|
|
84035
|
-
Selection.near(sel.$headCell, dir)
|
|
84036
|
-
);
|
|
84037
|
-
}
|
|
84797
|
+
if (sel instanceof CellSelection) return maybeSetSelection(state2, dispatch, Selection.near(sel.$headCell, dir));
|
|
84038
84798
|
if (axis != "horiz" && !sel.empty) return false;
|
|
84039
84799
|
const end2 = atEndOfCell(view, axis, dir);
|
|
84040
84800
|
if (end2 == null) return false;
|
|
84041
|
-
if (axis == "horiz")
|
|
84042
|
-
|
|
84043
|
-
state2,
|
|
84044
|
-
dispatch,
|
|
84045
|
-
Selection.near(state2.doc.resolve(sel.head + dir), dir)
|
|
84046
|
-
);
|
|
84047
|
-
} else {
|
|
84801
|
+
if (axis == "horiz") return maybeSetSelection(state2, dispatch, Selection.near(state2.doc.resolve(sel.head + dir), dir));
|
|
84802
|
+
else {
|
|
84048
84803
|
const $cell = state2.doc.resolve(end2);
|
|
84049
84804
|
const $next = nextCell($cell, axis, dir);
|
|
84050
84805
|
let newSel;
|
|
84051
84806
|
if ($next) newSel = Selection.near($next, 1);
|
|
84052
|
-
else if (dir < 0)
|
|
84053
|
-
newSel = Selection.near(state2.doc.resolve($cell.before(-1)), -1);
|
|
84807
|
+
else if (dir < 0) newSel = Selection.near(state2.doc.resolve($cell.before(-1)), -1);
|
|
84054
84808
|
else newSel = Selection.near(state2.doc.resolve($cell.after(-1)), 1);
|
|
84055
84809
|
return maybeSetSelection(state2, dispatch, newSel);
|
|
84056
84810
|
}
|
|
@@ -84061,20 +84815,15 @@ function shiftArrow(axis, dir) {
|
|
|
84061
84815
|
if (!view) return false;
|
|
84062
84816
|
const sel = state2.selection;
|
|
84063
84817
|
let cellSel;
|
|
84064
|
-
if (sel instanceof CellSelection)
|
|
84065
|
-
|
|
84066
|
-
} else {
|
|
84818
|
+
if (sel instanceof CellSelection) cellSel = sel;
|
|
84819
|
+
else {
|
|
84067
84820
|
const end2 = atEndOfCell(view, axis, dir);
|
|
84068
84821
|
if (end2 == null) return false;
|
|
84069
84822
|
cellSel = new CellSelection(state2.doc.resolve(end2));
|
|
84070
84823
|
}
|
|
84071
84824
|
const $head = nextCell(cellSel.$headCell, axis, dir);
|
|
84072
84825
|
if (!$head) return false;
|
|
84073
|
-
return maybeSetSelection(
|
|
84074
|
-
state2,
|
|
84075
|
-
dispatch,
|
|
84076
|
-
new CellSelection(cellSel.$anchorCell, $head)
|
|
84077
|
-
);
|
|
84826
|
+
return maybeSetSelection(state2, dispatch, new CellSelection(cellSel.$anchorCell, $head));
|
|
84078
84827
|
};
|
|
84079
84828
|
}
|
|
84080
84829
|
function handleTripleClick(view, pos) {
|
|
@@ -84088,65 +84837,45 @@ function handlePaste(view, _2, slice2) {
|
|
|
84088
84837
|
let cells = pastedCells(slice2);
|
|
84089
84838
|
const sel = view.state.selection;
|
|
84090
84839
|
if (sel instanceof CellSelection) {
|
|
84091
|
-
if (!cells)
|
|
84092
|
-
|
|
84093
|
-
|
|
84094
|
-
|
|
84095
|
-
|
|
84096
|
-
Fragment.from(
|
|
84097
|
-
fitSlice(tableNodeTypes(view.state.schema).cell, slice2)
|
|
84098
|
-
)
|
|
84099
|
-
]
|
|
84100
|
-
};
|
|
84840
|
+
if (!cells) cells = {
|
|
84841
|
+
width: 1,
|
|
84842
|
+
height: 1,
|
|
84843
|
+
rows: [Fragment.from(fitSlice(tableNodeTypes(view.state.schema).cell, slice2))]
|
|
84844
|
+
};
|
|
84101
84845
|
const table = sel.$anchorCell.node(-1);
|
|
84102
84846
|
const start2 = sel.$anchorCell.start(-1);
|
|
84103
|
-
const rect = TableMap.get(table).rectBetween(
|
|
84104
|
-
sel.$anchorCell.pos - start2,
|
|
84105
|
-
sel.$headCell.pos - start2
|
|
84106
|
-
);
|
|
84847
|
+
const rect = TableMap.get(table).rectBetween(sel.$anchorCell.pos - start2, sel.$headCell.pos - start2);
|
|
84107
84848
|
cells = clipCells(cells, rect.right - rect.left, rect.bottom - rect.top);
|
|
84108
84849
|
insertCells(view.state, view.dispatch, start2, rect, cells);
|
|
84109
84850
|
return true;
|
|
84110
84851
|
} else if (cells) {
|
|
84111
84852
|
const $cell = selectionCell(view.state);
|
|
84112
84853
|
const start2 = $cell.start(-1);
|
|
84113
|
-
insertCells(
|
|
84114
|
-
view.state,
|
|
84115
|
-
view.dispatch,
|
|
84116
|
-
start2,
|
|
84117
|
-
TableMap.get($cell.node(-1)).findCell($cell.pos - start2),
|
|
84118
|
-
cells
|
|
84119
|
-
);
|
|
84854
|
+
insertCells(view.state, view.dispatch, start2, TableMap.get($cell.node(-1)).findCell($cell.pos - start2), cells);
|
|
84120
84855
|
return true;
|
|
84121
|
-
} else
|
|
84122
|
-
return false;
|
|
84123
|
-
}
|
|
84856
|
+
} else return false;
|
|
84124
84857
|
}
|
|
84125
84858
|
function handleMouseDown(view, startEvent) {
|
|
84126
|
-
var
|
|
84859
|
+
var _cellUnderMouse;
|
|
84127
84860
|
if (startEvent.ctrlKey || startEvent.metaKey) return;
|
|
84128
84861
|
const startDOMCell = domInCell(view, startEvent.target);
|
|
84129
84862
|
let $anchor;
|
|
84130
84863
|
if (startEvent.shiftKey && view.state.selection instanceof CellSelection) {
|
|
84131
84864
|
setCellSelection(view.state.selection.$anchorCell, startEvent);
|
|
84132
84865
|
startEvent.preventDefault();
|
|
84133
|
-
} else if (startEvent.shiftKey && startDOMCell && ($anchor = cellAround$1(view.state.selection.$anchor)) != null && ((
|
|
84866
|
+
} 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) {
|
|
84134
84867
|
setCellSelection($anchor, startEvent);
|
|
84135
84868
|
startEvent.preventDefault();
|
|
84136
|
-
} else if (!startDOMCell)
|
|
84137
|
-
|
|
84138
|
-
}
|
|
84139
|
-
function setCellSelection($anchor2, event) {
|
|
84869
|
+
} else if (!startDOMCell) return;
|
|
84870
|
+
function setCellSelection($anchor$1, event) {
|
|
84140
84871
|
let $head = cellUnderMouse(view, event);
|
|
84141
84872
|
const starting = tableEditingKey.getState(view.state) == null;
|
|
84142
|
-
if (!$head || !inSameTable($
|
|
84143
|
-
|
|
84144
|
-
|
|
84145
|
-
}
|
|
84146
|
-
const selection = new CellSelection($anchor2, $head);
|
|
84873
|
+
if (!$head || !inSameTable($anchor$1, $head)) if (starting) $head = $anchor$1;
|
|
84874
|
+
else return;
|
|
84875
|
+
const selection = new CellSelection($anchor$1, $head);
|
|
84147
84876
|
if (starting || !view.state.selection.eq(selection)) {
|
|
84148
84877
|
const tr = view.state.tr.setSelection(selection);
|
|
84149
|
-
if (starting) tr.setMeta(tableEditingKey, $
|
|
84878
|
+
if (starting) tr.setMeta(tableEditingKey, $anchor$1.pos);
|
|
84150
84879
|
view.dispatch(tr);
|
|
84151
84880
|
}
|
|
84152
84881
|
}
|
|
@@ -84154,20 +84883,18 @@ function handleMouseDown(view, startEvent) {
|
|
|
84154
84883
|
view.root.removeEventListener("mouseup", stop);
|
|
84155
84884
|
view.root.removeEventListener("dragstart", stop);
|
|
84156
84885
|
view.root.removeEventListener("mousemove", move2);
|
|
84157
|
-
if (tableEditingKey.getState(view.state) != null)
|
|
84158
|
-
view.dispatch(view.state.tr.setMeta(tableEditingKey, -1));
|
|
84886
|
+
if (tableEditingKey.getState(view.state) != null) view.dispatch(view.state.tr.setMeta(tableEditingKey, -1));
|
|
84159
84887
|
}
|
|
84160
84888
|
function move2(_event) {
|
|
84161
84889
|
const event = _event;
|
|
84162
84890
|
const anchor = tableEditingKey.getState(view.state);
|
|
84163
|
-
let $
|
|
84164
|
-
if (anchor != null)
|
|
84165
|
-
|
|
84166
|
-
|
|
84167
|
-
$
|
|
84168
|
-
if (!$anchor2) return stop();
|
|
84891
|
+
let $anchor$1;
|
|
84892
|
+
if (anchor != null) $anchor$1 = view.state.doc.resolve(anchor);
|
|
84893
|
+
else if (domInCell(view, event.target) != startDOMCell) {
|
|
84894
|
+
$anchor$1 = cellUnderMouse(view, startEvent);
|
|
84895
|
+
if (!$anchor$1) return stop();
|
|
84169
84896
|
}
|
|
84170
|
-
if ($
|
|
84897
|
+
if ($anchor$1) setCellSelection($anchor$1, event);
|
|
84171
84898
|
}
|
|
84172
84899
|
view.root.addEventListener("mouseup", stop);
|
|
84173
84900
|
view.root.addEventListener("dragstart", stop);
|
|
@@ -84177,8 +84904,8 @@ function atEndOfCell(view, axis, dir) {
|
|
|
84177
84904
|
if (!(view.state.selection instanceof TextSelection$1)) return null;
|
|
84178
84905
|
const { $head } = view.state.selection;
|
|
84179
84906
|
for (let d2 = $head.depth - 1; d2 >= 0; d2--) {
|
|
84180
|
-
const parent = $head.node(d2)
|
|
84181
|
-
if (
|
|
84907
|
+
const parent = $head.node(d2);
|
|
84908
|
+
if ((dir < 0 ? $head.index(d2) : $head.indexAfter(d2)) != (dir < 0 ? 0 : parent.childCount)) return null;
|
|
84182
84909
|
if (parent.type.spec.tableRole == "cell" || parent.type.spec.tableRole == "header_cell") {
|
|
84183
84910
|
const cellPos = $head.before(d2);
|
|
84184
84911
|
const dirStr = axis == "vert" ? dir > 0 ? "down" : "up" : dir > 0 ? "right" : "left";
|
|
@@ -84188,11 +84915,7 @@ function atEndOfCell(view, axis, dir) {
|
|
|
84188
84915
|
return null;
|
|
84189
84916
|
}
|
|
84190
84917
|
function domInCell(view, dom) {
|
|
84191
|
-
for (; dom && dom != view.dom; dom = dom.parentNode)
|
|
84192
|
-
if (dom.nodeName == "TD" || dom.nodeName == "TH") {
|
|
84193
|
-
return dom;
|
|
84194
|
-
}
|
|
84195
|
-
}
|
|
84918
|
+
for (; dom && dom != view.dom; dom = dom.parentNode) if (dom.nodeName == "TD" || dom.nodeName == "TH") return dom;
|
|
84196
84919
|
return null;
|
|
84197
84920
|
}
|
|
84198
84921
|
function cellUnderMouse(view, event) {
|
|
@@ -84201,7 +84924,8 @@ function cellUnderMouse(view, event) {
|
|
|
84201
84924
|
top: event.clientY
|
|
84202
84925
|
});
|
|
84203
84926
|
if (!mousePos) return null;
|
|
84204
|
-
|
|
84927
|
+
const pos = mousePos.inside >= 0 ? mousePos.inside : mousePos.pos;
|
|
84928
|
+
return cellAround$1(view.state.doc.resolve(pos));
|
|
84205
84929
|
}
|
|
84206
84930
|
var TableView = class {
|
|
84207
84931
|
constructor(node, defaultCellMinWidth) {
|
|
@@ -84210,10 +84934,7 @@ var TableView = class {
|
|
|
84210
84934
|
this.dom = document.createElement("div");
|
|
84211
84935
|
this.dom.className = "tableWrapper";
|
|
84212
84936
|
this.table = this.dom.appendChild(document.createElement("table"));
|
|
84213
|
-
this.table.style.setProperty(
|
|
84214
|
-
"--default-cell-min-width",
|
|
84215
|
-
`${defaultCellMinWidth}px`
|
|
84216
|
-
);
|
|
84937
|
+
this.table.style.setProperty("--default-cell-min-width", `${defaultCellMinWidth}px`);
|
|
84217
84938
|
this.colgroup = this.table.appendChild(document.createElement("colgroup"));
|
|
84218
84939
|
updateColumnsOnResize(node, this.colgroup, this.table, defaultCellMinWidth);
|
|
84219
84940
|
this.contentDOM = this.table.appendChild(document.createElement("tbody"));
|
|
@@ -84221,12 +84942,7 @@ var TableView = class {
|
|
|
84221
84942
|
update(node) {
|
|
84222
84943
|
if (node.type != this.node.type) return false;
|
|
84223
84944
|
this.node = node;
|
|
84224
|
-
updateColumnsOnResize(
|
|
84225
|
-
node,
|
|
84226
|
-
this.colgroup,
|
|
84227
|
-
this.table,
|
|
84228
|
-
this.defaultCellMinWidth
|
|
84229
|
-
);
|
|
84945
|
+
updateColumnsOnResize(node, this.colgroup, this.table, this.defaultCellMinWidth);
|
|
84230
84946
|
return true;
|
|
84231
84947
|
}
|
|
84232
84948
|
ignoreMutation(record) {
|
|
@@ -84234,7 +84950,6 @@ var TableView = class {
|
|
|
84234
84950
|
}
|
|
84235
84951
|
};
|
|
84236
84952
|
function updateColumnsOnResize(node, colgroup, table, defaultCellMinWidth, overrideCol, overrideValue) {
|
|
84237
|
-
var _a2;
|
|
84238
84953
|
let totalWidth = 0;
|
|
84239
84954
|
let fixedWidth = true;
|
|
84240
84955
|
let nextDOM = colgroup.firstChild;
|
|
@@ -84248,20 +84963,19 @@ function updateColumnsOnResize(node, colgroup, table, defaultCellMinWidth, overr
|
|
|
84248
84963
|
totalWidth += hasWidth || defaultCellMinWidth;
|
|
84249
84964
|
if (!hasWidth) fixedWidth = false;
|
|
84250
84965
|
if (!nextDOM) {
|
|
84251
|
-
const
|
|
84252
|
-
|
|
84253
|
-
colgroup.appendChild(
|
|
84966
|
+
const col$1 = document.createElement("col");
|
|
84967
|
+
col$1.style.width = cssWidth;
|
|
84968
|
+
colgroup.appendChild(col$1);
|
|
84254
84969
|
} else {
|
|
84255
|
-
if (nextDOM.style.width != cssWidth)
|
|
84256
|
-
nextDOM.style.width = cssWidth;
|
|
84257
|
-
}
|
|
84970
|
+
if (nextDOM.style.width != cssWidth) nextDOM.style.width = cssWidth;
|
|
84258
84971
|
nextDOM = nextDOM.nextSibling;
|
|
84259
84972
|
}
|
|
84260
84973
|
}
|
|
84261
84974
|
}
|
|
84262
84975
|
while (nextDOM) {
|
|
84976
|
+
var _nextDOM$parentNode;
|
|
84263
84977
|
const after = nextDOM.nextSibling;
|
|
84264
|
-
(
|
|
84978
|
+
(_nextDOM$parentNode = nextDOM.parentNode) === null || _nextDOM$parentNode === void 0 || _nextDOM$parentNode.removeChild(nextDOM);
|
|
84265
84979
|
nextDOM = after;
|
|
84266
84980
|
}
|
|
84267
84981
|
if (fixedWidth) {
|
|
@@ -84272,28 +84986,18 @@ function updateColumnsOnResize(node, colgroup, table, defaultCellMinWidth, overr
|
|
|
84272
84986
|
table.style.minWidth = totalWidth + "px";
|
|
84273
84987
|
}
|
|
84274
84988
|
}
|
|
84275
|
-
|
|
84276
|
-
|
|
84277
|
-
);
|
|
84278
|
-
function columnResizing({
|
|
84279
|
-
handleWidth = 5,
|
|
84280
|
-
cellMinWidth: cellMinWidth2 = 25,
|
|
84281
|
-
defaultCellMinWidth = 100,
|
|
84282
|
-
View = TableView,
|
|
84283
|
-
lastColumnResizable = true
|
|
84284
|
-
} = {}) {
|
|
84989
|
+
const columnResizingPluginKey = new PluginKey("tableColumnResizing");
|
|
84990
|
+
function columnResizing({ handleWidth = 5, cellMinWidth: cellMinWidth2 = 25, defaultCellMinWidth = 100, View = TableView, lastColumnResizable = true } = {}) {
|
|
84285
84991
|
const plugin2 = new Plugin({
|
|
84286
84992
|
key: columnResizingPluginKey,
|
|
84287
84993
|
state: {
|
|
84288
84994
|
init(_2, state2) {
|
|
84289
|
-
var
|
|
84290
|
-
const nodeViews = (
|
|
84995
|
+
var _plugin$spec;
|
|
84996
|
+
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;
|
|
84291
84997
|
const tableName = tableNodeTypes(state2.schema).table.name;
|
|
84292
|
-
if (View && nodeViews) {
|
|
84293
|
-
|
|
84294
|
-
|
|
84295
|
-
};
|
|
84296
|
-
}
|
|
84998
|
+
if (View && nodeViews) nodeViews[tableName] = (node, view) => {
|
|
84999
|
+
return new View(node, defaultCellMinWidth, view);
|
|
85000
|
+
};
|
|
84297
85001
|
return new ResizeState(-1, false);
|
|
84298
85002
|
},
|
|
84299
85003
|
apply(tr, prev) {
|
|
@@ -84313,21 +85017,19 @@ function columnResizing({
|
|
|
84313
85017
|
handleMouseLeave(view);
|
|
84314
85018
|
},
|
|
84315
85019
|
mousedown: (view, event) => {
|
|
84316
|
-
|
|
85020
|
+
handleMouseDown$1(view, event, cellMinWidth2, defaultCellMinWidth);
|
|
84317
85021
|
}
|
|
84318
85022
|
},
|
|
84319
85023
|
decorations: (state2) => {
|
|
84320
85024
|
const pluginState = columnResizingPluginKey.getState(state2);
|
|
84321
|
-
if (pluginState && pluginState.activeHandle > -1)
|
|
84322
|
-
return handleDecorations(state2, pluginState.activeHandle);
|
|
84323
|
-
}
|
|
85025
|
+
if (pluginState && pluginState.activeHandle > -1) return handleDecorations(state2, pluginState.activeHandle);
|
|
84324
85026
|
},
|
|
84325
85027
|
nodeViews: {}
|
|
84326
85028
|
}
|
|
84327
85029
|
});
|
|
84328
85030
|
return plugin2;
|
|
84329
85031
|
}
|
|
84330
|
-
var ResizeState = class
|
|
85032
|
+
var ResizeState = class ResizeState2 {
|
|
84331
85033
|
constructor(activeHandle, dragging) {
|
|
84332
85034
|
this.activeHandle = activeHandle;
|
|
84333
85035
|
this.dragging = dragging;
|
|
@@ -84335,16 +85037,12 @@ var ResizeState = class _ResizeState {
|
|
|
84335
85037
|
apply(tr) {
|
|
84336
85038
|
const state2 = this;
|
|
84337
85039
|
const action = tr.getMeta(columnResizingPluginKey);
|
|
84338
|
-
if (action && action.setHandle != null)
|
|
84339
|
-
|
|
84340
|
-
if (action && action.setDragging !== void 0)
|
|
84341
|
-
return new _ResizeState(state2.activeHandle, action.setDragging);
|
|
85040
|
+
if (action && action.setHandle != null) return new ResizeState2(action.setHandle, false);
|
|
85041
|
+
if (action && action.setDragging !== void 0) return new ResizeState2(state2.activeHandle, action.setDragging);
|
|
84342
85042
|
if (state2.activeHandle > -1 && tr.docChanged) {
|
|
84343
85043
|
let handle = tr.mapping.map(state2.activeHandle, -1);
|
|
84344
|
-
if (!pointsAtCell(tr.doc.resolve(handle)))
|
|
84345
|
-
|
|
84346
|
-
}
|
|
84347
|
-
return new _ResizeState(handle, state2.dragging);
|
|
85044
|
+
if (!pointsAtCell(tr.doc.resolve(handle))) handle = -1;
|
|
85045
|
+
return new ResizeState2(handle, state2.dragging);
|
|
84348
85046
|
}
|
|
84349
85047
|
return state2;
|
|
84350
85048
|
}
|
|
@@ -84358,10 +85056,8 @@ function handleMouseMove(view, event, handleWidth, lastColumnResizable) {
|
|
|
84358
85056
|
let cell = -1;
|
|
84359
85057
|
if (target) {
|
|
84360
85058
|
const { left: left2, right: right2 } = target.getBoundingClientRect();
|
|
84361
|
-
if (event.clientX - left2 <= handleWidth)
|
|
84362
|
-
|
|
84363
|
-
else if (right2 - event.clientX <= handleWidth)
|
|
84364
|
-
cell = edgeCell(view, event, "right", handleWidth);
|
|
85059
|
+
if (event.clientX - left2 <= handleWidth) cell = edgeCell(view, event, "left", handleWidth);
|
|
85060
|
+
else if (right2 - event.clientX <= handleWidth) cell = edgeCell(view, event, "right", handleWidth);
|
|
84365
85061
|
}
|
|
84366
85062
|
if (cell != pluginState.activeHandle) {
|
|
84367
85063
|
if (!lastColumnResizable && cell !== -1) {
|
|
@@ -84369,10 +85065,7 @@ function handleMouseMove(view, event, handleWidth, lastColumnResizable) {
|
|
|
84369
85065
|
const table = $cell.node(-1);
|
|
84370
85066
|
const map22 = TableMap.get(table);
|
|
84371
85067
|
const tableStart = $cell.start(-1);
|
|
84372
|
-
|
|
84373
|
-
if (col == map22.width - 1) {
|
|
84374
|
-
return;
|
|
84375
|
-
}
|
|
85068
|
+
if (map22.colCount($cell.pos - tableStart) + $cell.nodeAfter.attrs.colspan - 1 == map22.width - 1) return;
|
|
84376
85069
|
}
|
|
84377
85070
|
updateHandle(view, cell);
|
|
84378
85071
|
}
|
|
@@ -84381,58 +85074,39 @@ function handleMouseMove(view, event, handleWidth, lastColumnResizable) {
|
|
|
84381
85074
|
function handleMouseLeave(view) {
|
|
84382
85075
|
if (!view.editable) return;
|
|
84383
85076
|
const pluginState = columnResizingPluginKey.getState(view.state);
|
|
84384
|
-
if (pluginState && pluginState.activeHandle > -1 && !pluginState.dragging)
|
|
84385
|
-
updateHandle(view, -1);
|
|
85077
|
+
if (pluginState && pluginState.activeHandle > -1 && !pluginState.dragging) updateHandle(view, -1);
|
|
84386
85078
|
}
|
|
84387
|
-
function
|
|
84388
|
-
var
|
|
85079
|
+
function handleMouseDown$1(view, event, cellMinWidth2, defaultCellMinWidth) {
|
|
85080
|
+
var _view$dom$ownerDocume;
|
|
84389
85081
|
if (!view.editable) return false;
|
|
84390
|
-
const win = (
|
|
85082
|
+
const win = (_view$dom$ownerDocume = view.dom.ownerDocument.defaultView) !== null && _view$dom$ownerDocume !== void 0 ? _view$dom$ownerDocume : window;
|
|
84391
85083
|
const pluginState = columnResizingPluginKey.getState(view.state);
|
|
84392
|
-
if (!pluginState || pluginState.activeHandle == -1 || pluginState.dragging)
|
|
84393
|
-
return false;
|
|
85084
|
+
if (!pluginState || pluginState.activeHandle == -1 || pluginState.dragging) return false;
|
|
84394
85085
|
const cell = view.state.doc.nodeAt(pluginState.activeHandle);
|
|
84395
85086
|
const width = currentColWidth(view, pluginState.activeHandle, cell.attrs);
|
|
84396
|
-
view.dispatch(
|
|
84397
|
-
|
|
84398
|
-
|
|
84399
|
-
|
|
84400
|
-
)
|
|
84401
|
-
function finish(event2) {
|
|
85087
|
+
view.dispatch(view.state.tr.setMeta(columnResizingPluginKey, { setDragging: {
|
|
85088
|
+
startX: event.clientX,
|
|
85089
|
+
startWidth: width
|
|
85090
|
+
} }));
|
|
85091
|
+
function finish(event$1) {
|
|
84402
85092
|
win.removeEventListener("mouseup", finish);
|
|
84403
85093
|
win.removeEventListener("mousemove", move2);
|
|
84404
|
-
const
|
|
84405
|
-
if (
|
|
84406
|
-
updateColumnWidth(
|
|
84407
|
-
|
|
84408
|
-
pluginState2.activeHandle,
|
|
84409
|
-
draggedWidth(pluginState2.dragging, event2, cellMinWidth2)
|
|
84410
|
-
);
|
|
84411
|
-
view.dispatch(
|
|
84412
|
-
view.state.tr.setMeta(columnResizingPluginKey, { setDragging: null })
|
|
84413
|
-
);
|
|
85094
|
+
const pluginState$1 = columnResizingPluginKey.getState(view.state);
|
|
85095
|
+
if (pluginState$1 === null || pluginState$1 === void 0 ? void 0 : pluginState$1.dragging) {
|
|
85096
|
+
updateColumnWidth(view, pluginState$1.activeHandle, draggedWidth(pluginState$1.dragging, event$1, cellMinWidth2));
|
|
85097
|
+
view.dispatch(view.state.tr.setMeta(columnResizingPluginKey, { setDragging: null }));
|
|
84414
85098
|
}
|
|
84415
85099
|
}
|
|
84416
|
-
function move2(
|
|
84417
|
-
if (!
|
|
84418
|
-
const
|
|
84419
|
-
if (!
|
|
84420
|
-
if (
|
|
84421
|
-
const dragged = draggedWidth(
|
|
84422
|
-
displayColumnWidth(
|
|
84423
|
-
view,
|
|
84424
|
-
pluginState2.activeHandle,
|
|
84425
|
-
dragged,
|
|
84426
|
-
defaultCellMinWidth
|
|
84427
|
-
);
|
|
85100
|
+
function move2(event$1) {
|
|
85101
|
+
if (!event$1.which) return finish(event$1);
|
|
85102
|
+
const pluginState$1 = columnResizingPluginKey.getState(view.state);
|
|
85103
|
+
if (!pluginState$1) return;
|
|
85104
|
+
if (pluginState$1.dragging) {
|
|
85105
|
+
const dragged = draggedWidth(pluginState$1.dragging, event$1, cellMinWidth2);
|
|
85106
|
+
displayColumnWidth(view, pluginState$1.activeHandle, dragged, defaultCellMinWidth);
|
|
84428
85107
|
}
|
|
84429
85108
|
}
|
|
84430
|
-
displayColumnWidth(
|
|
84431
|
-
view,
|
|
84432
|
-
pluginState.activeHandle,
|
|
84433
|
-
width,
|
|
84434
|
-
defaultCellMinWidth
|
|
84435
|
-
);
|
|
85109
|
+
displayColumnWidth(view, pluginState.activeHandle, width, defaultCellMinWidth);
|
|
84436
85110
|
win.addEventListener("mouseup", finish);
|
|
84437
85111
|
win.addEventListener("mousemove", move2);
|
|
84438
85112
|
event.preventDefault();
|
|
@@ -84442,20 +85116,17 @@ function currentColWidth(view, cellPos, { colspan, colwidth }) {
|
|
|
84442
85116
|
const width = colwidth && colwidth[colwidth.length - 1];
|
|
84443
85117
|
if (width) return width;
|
|
84444
85118
|
const dom = view.domAtPos(cellPos);
|
|
84445
|
-
|
|
84446
|
-
let domWidth = node.offsetWidth, parts = colspan;
|
|
85119
|
+
let domWidth = dom.node.childNodes[dom.offset].offsetWidth, parts = colspan;
|
|
84447
85120
|
if (colwidth) {
|
|
84448
|
-
for (let i = 0; i < colspan; i++)
|
|
84449
|
-
|
|
84450
|
-
|
|
84451
|
-
|
|
84452
|
-
}
|
|
85121
|
+
for (let i = 0; i < colspan; i++) if (colwidth[i]) {
|
|
85122
|
+
domWidth -= colwidth[i];
|
|
85123
|
+
parts--;
|
|
85124
|
+
}
|
|
84453
85125
|
}
|
|
84454
85126
|
return domWidth / parts;
|
|
84455
85127
|
}
|
|
84456
85128
|
function domCellAround(target) {
|
|
84457
|
-
while (target && target.nodeName != "TD" && target.nodeName != "TH")
|
|
84458
|
-
target = target.classList && target.classList.contains("ProseMirror") ? null : target.parentNode;
|
|
85129
|
+
while (target && target.nodeName != "TD" && target.nodeName != "TH") target = target.classList && target.classList.contains("ProseMirror") ? null : target.parentNode;
|
|
84459
85130
|
return target;
|
|
84460
85131
|
}
|
|
84461
85132
|
function edgeCell(view, event, side, handleWidth) {
|
|
@@ -84478,9 +85149,7 @@ function draggedWidth(dragging, event, resizeMinWidth) {
|
|
|
84478
85149
|
return Math.max(resizeMinWidth, dragging.startWidth + offset2);
|
|
84479
85150
|
}
|
|
84480
85151
|
function updateHandle(view, value) {
|
|
84481
|
-
view.dispatch(
|
|
84482
|
-
view.state.tr.setMeta(columnResizingPluginKey, { setHandle: value })
|
|
84483
|
-
);
|
|
85152
|
+
view.dispatch(view.state.tr.setMeta(columnResizingPluginKey, { setHandle: value }));
|
|
84484
85153
|
}
|
|
84485
85154
|
function updateColumnWidth(view, cell, width) {
|
|
84486
85155
|
const $cell = view.state.doc.resolve(cell);
|
|
@@ -84496,7 +85165,10 @@ function updateColumnWidth(view, cell, width) {
|
|
|
84496
85165
|
if (attrs.colwidth && attrs.colwidth[index2] == width) continue;
|
|
84497
85166
|
const colwidth = attrs.colwidth ? attrs.colwidth.slice() : zeroes(attrs.colspan);
|
|
84498
85167
|
colwidth[index2] = width;
|
|
84499
|
-
tr.setNodeMarkup(start2 + pos, null, {
|
|
85168
|
+
tr.setNodeMarkup(start2 + pos, null, {
|
|
85169
|
+
...attrs,
|
|
85170
|
+
colwidth
|
|
85171
|
+
});
|
|
84500
85172
|
}
|
|
84501
85173
|
if (tr.docChanged) view.dispatch(tr);
|
|
84502
85174
|
}
|
|
@@ -84505,64 +85177,38 @@ function displayColumnWidth(view, cell, width, defaultCellMinWidth) {
|
|
|
84505
85177
|
const table = $cell.node(-1), start2 = $cell.start(-1);
|
|
84506
85178
|
const col = TableMap.get(table).colCount($cell.pos - start2) + $cell.nodeAfter.attrs.colspan - 1;
|
|
84507
85179
|
let dom = view.domAtPos($cell.start(-1)).node;
|
|
84508
|
-
while (dom && dom.nodeName != "TABLE")
|
|
84509
|
-
dom = dom.parentNode;
|
|
84510
|
-
}
|
|
85180
|
+
while (dom && dom.nodeName != "TABLE") dom = dom.parentNode;
|
|
84511
85181
|
if (!dom) return;
|
|
84512
|
-
updateColumnsOnResize(
|
|
84513
|
-
table,
|
|
84514
|
-
dom.firstChild,
|
|
84515
|
-
dom,
|
|
84516
|
-
defaultCellMinWidth,
|
|
84517
|
-
col,
|
|
84518
|
-
width
|
|
84519
|
-
);
|
|
85182
|
+
updateColumnsOnResize(table, dom.firstChild, dom, defaultCellMinWidth, col, width);
|
|
84520
85183
|
}
|
|
84521
85184
|
function zeroes(n) {
|
|
84522
85185
|
return Array(n).fill(0);
|
|
84523
85186
|
}
|
|
84524
85187
|
function handleDecorations(state2, cell) {
|
|
84525
|
-
var _a2;
|
|
84526
85188
|
const decorations = [];
|
|
84527
85189
|
const $cell = state2.doc.resolve(cell);
|
|
84528
85190
|
const table = $cell.node(-1);
|
|
84529
|
-
if (!table)
|
|
84530
|
-
return DecorationSet.empty;
|
|
84531
|
-
}
|
|
85191
|
+
if (!table) return DecorationSet.empty;
|
|
84532
85192
|
const map22 = TableMap.get(table);
|
|
84533
85193
|
const start2 = $cell.start(-1);
|
|
84534
85194
|
const col = map22.colCount($cell.pos - start2) + $cell.nodeAfter.attrs.colspan - 1;
|
|
84535
85195
|
for (let row = 0; row < map22.height; row++) {
|
|
84536
85196
|
const index2 = col + row * map22.width;
|
|
84537
85197
|
if ((col == map22.width - 1 || map22.map[index2] != map22.map[index2 + 1]) && (row == 0 || map22.map[index2] != map22.map[index2 - map22.width])) {
|
|
85198
|
+
var _columnResizingPlugin;
|
|
84538
85199
|
const cellPos = map22.map[index2];
|
|
84539
85200
|
const pos = start2 + cellPos + table.nodeAt(cellPos).nodeSize - 1;
|
|
84540
85201
|
const dom = document.createElement("div");
|
|
84541
85202
|
dom.className = "column-resize-handle";
|
|
84542
|
-
if ((
|
|
84543
|
-
decorations.push(
|
|
84544
|
-
Decoration.node(
|
|
84545
|
-
start2 + cellPos,
|
|
84546
|
-
start2 + cellPos + table.nodeAt(cellPos).nodeSize,
|
|
84547
|
-
{
|
|
84548
|
-
class: "column-resize-dragging"
|
|
84549
|
-
}
|
|
84550
|
-
)
|
|
84551
|
-
);
|
|
84552
|
-
}
|
|
85203
|
+
if ((_columnResizingPlugin = columnResizingPluginKey.getState(state2)) === null || _columnResizingPlugin === void 0 ? void 0 : _columnResizingPlugin.dragging) decorations.push(Decoration.node(start2 + cellPos, start2 + cellPos + table.nodeAt(cellPos).nodeSize, { class: "column-resize-dragging" }));
|
|
84553
85204
|
decorations.push(Decoration.widget(pos, dom));
|
|
84554
85205
|
}
|
|
84555
85206
|
}
|
|
84556
85207
|
return DecorationSet.create(state2.doc, decorations);
|
|
84557
85208
|
}
|
|
84558
|
-
function tableEditing({
|
|
84559
|
-
allowTableNodeSelection = false
|
|
84560
|
-
} = {}) {
|
|
85209
|
+
function tableEditing({ allowTableNodeSelection = false } = {}) {
|
|
84561
85210
|
return new Plugin({
|
|
84562
85211
|
key: tableEditingKey,
|
|
84563
|
-
// This piece of state is used to remember when a mouse-drag
|
|
84564
|
-
// cell-selection is happening, so that it can continue even as
|
|
84565
|
-
// transactions (which might move its anchor cell) come in.
|
|
84566
85212
|
state: {
|
|
84567
85213
|
init() {
|
|
84568
85214
|
return null;
|
|
@@ -84577,9 +85223,7 @@ function tableEditing({
|
|
|
84577
85223
|
},
|
|
84578
85224
|
props: {
|
|
84579
85225
|
decorations: drawCellSelection,
|
|
84580
|
-
handleDOMEvents: {
|
|
84581
|
-
mousedown: handleMouseDown
|
|
84582
|
-
},
|
|
85226
|
+
handleDOMEvents: { mousedown: handleMouseDown },
|
|
84583
85227
|
createSelectionBetween(view) {
|
|
84584
85228
|
return tableEditingKey.getState(view.state) != null ? view.state.selection : null;
|
|
84585
85229
|
},
|
|
@@ -84588,11 +85232,7 @@ function tableEditing({
|
|
|
84588
85232
|
handlePaste
|
|
84589
85233
|
},
|
|
84590
85234
|
appendTransaction(_2, oldState, state2) {
|
|
84591
|
-
return normalizeSelection(
|
|
84592
|
-
state2,
|
|
84593
|
-
fixTables(state2, oldState),
|
|
84594
|
-
allowTableNodeSelection
|
|
84595
|
-
);
|
|
85235
|
+
return normalizeSelection(state2, fixTables(state2, oldState), allowTableNodeSelection);
|
|
84596
85236
|
}
|
|
84597
85237
|
});
|
|
84598
85238
|
}
|
|
@@ -95667,7 +96307,7 @@ const _hoisted_2$c = { key: 0 };
|
|
|
95667
96307
|
const _hoisted_3$a = { key: 0 };
|
|
95668
96308
|
const _hoisted_4$6 = { key: 1 };
|
|
95669
96309
|
const _hoisted_5$5 = { key: 1 };
|
|
95670
|
-
const _sfc_main$
|
|
96310
|
+
const _sfc_main$k = {
|
|
95671
96311
|
__name: "Mentions",
|
|
95672
96312
|
props: {
|
|
95673
96313
|
users: {
|
|
@@ -95750,7 +96390,7 @@ const _sfc_main$j = {
|
|
|
95750
96390
|
};
|
|
95751
96391
|
}
|
|
95752
96392
|
};
|
|
95753
|
-
const Mentions = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
96393
|
+
const Mentions = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["__scopeId", "data-v-bcae18cf"]]);
|
|
95754
96394
|
const popoverPluginKey = new PluginKey("popoverPlugin");
|
|
95755
96395
|
const PopoverPlugin = Extension.create({
|
|
95756
96396
|
name: "popoverPlugin",
|
|
@@ -106902,7 +107542,7 @@ const _sfc_main$1$1 = {
|
|
|
106902
107542
|
}
|
|
106903
107543
|
};
|
|
106904
107544
|
const ButtonGroup = /* @__PURE__ */ _export_sfc(_sfc_main$1$1, [["__scopeId", "data-v-c80a1e51"]]);
|
|
106905
|
-
const _sfc_main$
|
|
107545
|
+
const _sfc_main$j = {
|
|
106906
107546
|
__name: "Toolbar",
|
|
106907
107547
|
emits: ["command", "toggle", "select"],
|
|
106908
107548
|
setup(__props, { emit: __emit }) {
|
|
@@ -106984,7 +107624,7 @@ const _sfc_main$i = {
|
|
|
106984
107624
|
};
|
|
106985
107625
|
}
|
|
106986
107626
|
};
|
|
106987
|
-
const Toolbar = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
107627
|
+
const Toolbar = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["__scopeId", "data-v-3f5ec271"]]);
|
|
106988
107628
|
const DEFAULT_API_ENDPOINT = "https://sd-dev-express-gateway-i6xtm.ondigitalocean.app/insights";
|
|
106989
107629
|
const SYSTEM_PROMPT = "You are an expert copywriter and you are immersed in a document editor. You are to provide document related text responses based on the user prompts. Only write what is asked for. Do not provide explanations. Try to keep placeholders as short as possible. Do not output your prompt. Your instructions are: ";
|
|
106990
107630
|
async function baseInsightsFetch(payload, options = {}) {
|
|
@@ -107225,7 +107865,7 @@ const _hoisted_2$a = ["innerHTML"];
|
|
|
107225
107865
|
const _hoisted_3$8 = ["placeholder"];
|
|
107226
107866
|
const _hoisted_4$4 = { class: "ai-loader" };
|
|
107227
107867
|
const _hoisted_5$3 = ["innerHTML"];
|
|
107228
|
-
const _sfc_main$
|
|
107868
|
+
const _sfc_main$i = {
|
|
107229
107869
|
__name: "AIWriter",
|
|
107230
107870
|
props: {
|
|
107231
107871
|
selectedText: {
|
|
@@ -107501,7 +108141,7 @@ const _sfc_main$h = {
|
|
|
107501
108141
|
};
|
|
107502
108142
|
}
|
|
107503
108143
|
};
|
|
107504
|
-
const AIWriter = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
108144
|
+
const AIWriter = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["__scopeId", "data-v-d869be75"]]);
|
|
107505
108145
|
async function createZip(blobs, fileNames) {
|
|
107506
108146
|
const zip = new JSZip();
|
|
107507
108147
|
blobs.forEach((blob, index2) => {
|
|
@@ -107815,7 +108455,7 @@ const useToolbarItem = (options) => {
|
|
|
107815
108455
|
};
|
|
107816
108456
|
};
|
|
107817
108457
|
const _hoisted_1$f = ["onClick", "innerHTML", "aria-label", "onKeydown"];
|
|
107818
|
-
const _sfc_main$
|
|
108458
|
+
const _sfc_main$h = {
|
|
107819
108459
|
__name: "AlignmentButtons",
|
|
107820
108460
|
emits: ["select"],
|
|
107821
108461
|
setup(__props, { emit: __emit }) {
|
|
@@ -107906,14 +108546,14 @@ const _sfc_main$g = {
|
|
|
107906
108546
|
};
|
|
107907
108547
|
}
|
|
107908
108548
|
};
|
|
107909
|
-
const AlignmentButtons = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
108549
|
+
const AlignmentButtons = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["__scopeId", "data-v-d84f57b6"]]);
|
|
107910
108550
|
const _hoisted_1$e = ["onClick", "onKeydown"];
|
|
107911
108551
|
const _hoisted_2$9 = { class: "document-mode-column icon-column" };
|
|
107912
108552
|
const _hoisted_3$7 = ["innerHTML"];
|
|
107913
108553
|
const _hoisted_4$3 = { class: "document-mode-column text-column" };
|
|
107914
108554
|
const _hoisted_5$2 = { class: "document-mode-type" };
|
|
107915
108555
|
const _hoisted_6$1 = { class: "document-mode-description" };
|
|
107916
|
-
const _sfc_main$
|
|
108556
|
+
const _sfc_main$g = {
|
|
107917
108557
|
__name: "DocumentMode",
|
|
107918
108558
|
props: {
|
|
107919
108559
|
options: {
|
|
@@ -107993,14 +108633,14 @@ const _sfc_main$f = {
|
|
|
107993
108633
|
};
|
|
107994
108634
|
}
|
|
107995
108635
|
};
|
|
107996
|
-
const DocumentMode = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
108636
|
+
const DocumentMode = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["__scopeId", "data-v-8730b752"]]);
|
|
107997
108637
|
const _hoisted_1$d = {
|
|
107998
108638
|
key: 0,
|
|
107999
108639
|
class: "linked-style-buttons",
|
|
108000
108640
|
"data-editor-ui-surface": ""
|
|
108001
108641
|
};
|
|
108002
108642
|
const _hoisted_2$8 = ["onClick", "onKeydown", "aria-label"];
|
|
108003
|
-
const _sfc_main$
|
|
108643
|
+
const _sfc_main$f = {
|
|
108004
108644
|
__name: "LinkedStyle",
|
|
108005
108645
|
props: {
|
|
108006
108646
|
editor: {
|
|
@@ -108076,7 +108716,7 @@ const _sfc_main$e = {
|
|
|
108076
108716
|
};
|
|
108077
108717
|
}
|
|
108078
108718
|
};
|
|
108079
|
-
const LinkedStyle = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
108719
|
+
const LinkedStyle = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["__scopeId", "data-v-ecb78965"]]);
|
|
108080
108720
|
const _hoisted_1$c = {
|
|
108081
108721
|
key: 0,
|
|
108082
108722
|
class: "link-title"
|
|
@@ -108105,7 +108745,7 @@ const _hoisted_13 = {
|
|
|
108105
108745
|
key: 4,
|
|
108106
108746
|
class: "input-row go-to-anchor clickable"
|
|
108107
108747
|
};
|
|
108108
|
-
const _sfc_main$
|
|
108748
|
+
const _sfc_main$e = {
|
|
108109
108749
|
__name: "LinkInput",
|
|
108110
108750
|
props: {
|
|
108111
108751
|
showInput: {
|
|
@@ -108311,12 +108951,12 @@ const _sfc_main$d = {
|
|
|
108311
108951
|
};
|
|
108312
108952
|
}
|
|
108313
108953
|
};
|
|
108314
|
-
const LinkInput = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
108954
|
+
const LinkInput = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["__scopeId", "data-v-ba50627b"]]);
|
|
108315
108955
|
const _hoisted_1$b = ["aria-label", "onClick", "onKeydown"];
|
|
108316
108956
|
const _hoisted_2$6 = ["innerHTML"];
|
|
108317
108957
|
const _hoisted_3$5 = ["innerHTML"];
|
|
108318
108958
|
const ROW_SIZE$1 = 7;
|
|
108319
|
-
const _sfc_main$
|
|
108959
|
+
const _sfc_main$d = {
|
|
108320
108960
|
__name: "IconGridRow",
|
|
108321
108961
|
props: {
|
|
108322
108962
|
icons: {
|
|
@@ -108449,12 +109089,12 @@ const _sfc_main$c = {
|
|
|
108449
109089
|
};
|
|
108450
109090
|
}
|
|
108451
109091
|
};
|
|
108452
|
-
const IconGridRow = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
109092
|
+
const IconGridRow = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__scopeId", "data-v-0f479b6c"]]);
|
|
108453
109093
|
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';
|
|
108454
109094
|
const _hoisted_1$a = { class: "options-grid-wrap" };
|
|
108455
109095
|
const _hoisted_2$5 = ["innerHTML"];
|
|
108456
109096
|
const _hoisted_3$4 = { class: "option-grid-ctn" };
|
|
108457
|
-
const _sfc_main$
|
|
109097
|
+
const _sfc_main$c = {
|
|
108458
109098
|
__name: "IconGrid",
|
|
108459
109099
|
props: {
|
|
108460
109100
|
icons: {
|
|
@@ -108514,7 +109154,7 @@ const _sfc_main$b = {
|
|
|
108514
109154
|
};
|
|
108515
109155
|
}
|
|
108516
109156
|
};
|
|
108517
|
-
const IconGrid = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
109157
|
+
const IconGrid = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-3d19fedf"]]);
|
|
108518
109158
|
const closeDropdown$1 = (dropdown) => {
|
|
108519
109159
|
dropdown.expand.value = false;
|
|
108520
109160
|
};
|
|
@@ -108626,7 +109266,7 @@ const getAvailableColorOptions = () => {
|
|
|
108626
109266
|
const _hoisted_1$9 = ["data-cols", "data-rows", "onKeydown", "onClick"];
|
|
108627
109267
|
const _hoisted_2$4 = ["aria-valuetext"];
|
|
108628
109268
|
const ROW_SIZE = 5;
|
|
108629
|
-
const _sfc_main$
|
|
109269
|
+
const _sfc_main$b = {
|
|
108630
109270
|
__name: "TableGrid",
|
|
108631
109271
|
emits: ["select", "clickoutside"],
|
|
108632
109272
|
setup(__props, { emit: __emit }) {
|
|
@@ -108755,13 +109395,13 @@ const _sfc_main$a = {
|
|
|
108755
109395
|
};
|
|
108756
109396
|
}
|
|
108757
109397
|
};
|
|
108758
|
-
const TableGrid = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
109398
|
+
const TableGrid = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["__scopeId", "data-v-92e8d5fb"]]);
|
|
108759
109399
|
const _hoisted_1$8 = { class: "toolbar-table-actions" };
|
|
108760
109400
|
const _hoisted_2$3 = ["onClick", "data-item", "ariaLabel"];
|
|
108761
109401
|
const _hoisted_3$3 = { class: "toolbar-table-actions__icon" };
|
|
108762
109402
|
const _hoisted_4$1 = ["innerHTML"];
|
|
108763
109403
|
const _hoisted_5 = { class: "toolbar-table-actions__label" };
|
|
108764
|
-
const _sfc_main$
|
|
109404
|
+
const _sfc_main$a = {
|
|
108765
109405
|
__name: "TableActions",
|
|
108766
109406
|
props: {
|
|
108767
109407
|
options: {
|
|
@@ -108797,7 +109437,7 @@ const _sfc_main$9 = {
|
|
|
108797
109437
|
};
|
|
108798
109438
|
}
|
|
108799
109439
|
};
|
|
108800
|
-
const TableActions = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
109440
|
+
const TableActions = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-990b9a25"]]);
|
|
108801
109441
|
function getScrollableParent(element) {
|
|
108802
109442
|
let currentElement = element;
|
|
108803
109443
|
while (currentElement) {
|
|
@@ -108824,7 +109464,7 @@ const checkIconSvg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 5
|
|
|
108824
109464
|
const _hoisted_1$7 = { class: "search-input-ctn" };
|
|
108825
109465
|
const _hoisted_2$2 = { class: "row" };
|
|
108826
109466
|
const _hoisted_3$2 = ["onKeydown"];
|
|
108827
|
-
const _sfc_main$
|
|
109467
|
+
const _sfc_main$9 = {
|
|
108828
109468
|
__name: "SearchInput",
|
|
108829
109469
|
props: {
|
|
108830
109470
|
searchRef: {
|
|
@@ -108863,7 +109503,7 @@ const _sfc_main$8 = {
|
|
|
108863
109503
|
};
|
|
108864
109504
|
}
|
|
108865
109505
|
};
|
|
108866
|
-
const SearchInput = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
109506
|
+
const SearchInput = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-957cbcf2"]]);
|
|
108867
109507
|
const TOOLBAR_FONTS = [
|
|
108868
109508
|
{
|
|
108869
109509
|
label: "Georgia",
|
|
@@ -111638,7 +112278,7 @@ const _hoisted_2$1 = {
|
|
|
111638
112278
|
};
|
|
111639
112279
|
const _hoisted_3$1 = ["onClick"];
|
|
111640
112280
|
const _hoisted_4 = ["innerHTML"];
|
|
111641
|
-
const _sfc_main$
|
|
112281
|
+
const _sfc_main$8 = {
|
|
111642
112282
|
__name: "SlashMenu",
|
|
111643
112283
|
props: {
|
|
111644
112284
|
editor: {
|
|
@@ -111990,7 +112630,7 @@ const _sfc_main$7 = {
|
|
|
111990
112630
|
}
|
|
111991
112631
|
};
|
|
111992
112632
|
const _hoisted_1$5 = ["accept"];
|
|
111993
|
-
const _sfc_main$
|
|
112633
|
+
const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
111994
112634
|
__name: "BasicUpload",
|
|
111995
112635
|
props: {
|
|
111996
112636
|
accept: { default: ".docx, .pdf, .html, .md" }
|
|
@@ -112019,7 +112659,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
112019
112659
|
const _hoisted_1$4 = { class: "numbering" };
|
|
112020
112660
|
const MIN_WIDTH = 200;
|
|
112021
112661
|
const alignment = "flex-end";
|
|
112022
|
-
const _sfc_main$
|
|
112662
|
+
const _sfc_main$6 = {
|
|
112023
112663
|
__name: "Ruler",
|
|
112024
112664
|
props: {
|
|
112025
112665
|
orientation: {
|
|
@@ -112110,7 +112750,7 @@ const _sfc_main$5 = {
|
|
|
112110
112750
|
minHeight: `${editorBounds.height}px`
|
|
112111
112751
|
};
|
|
112112
112752
|
});
|
|
112113
|
-
const
|
|
112753
|
+
const handleMouseDown2 = (event) => {
|
|
112114
112754
|
isDragging.value = true;
|
|
112115
112755
|
setRulerHandleActive();
|
|
112116
112756
|
const itemId = event.currentTarget.id;
|
|
@@ -112185,13 +112825,13 @@ const _sfc_main$5 = {
|
|
|
112185
112825
|
createBaseVNode("div", {
|
|
112186
112826
|
class: "margin-handle handle-left",
|
|
112187
112827
|
id: "left-margin-handle",
|
|
112188
|
-
onMousedown:
|
|
112828
|
+
onMousedown: handleMouseDown2,
|
|
112189
112829
|
style: normalizeStyle(getHandlePosition.value("left"))
|
|
112190
112830
|
}, null, 36),
|
|
112191
112831
|
createBaseVNode("div", {
|
|
112192
112832
|
class: "margin-handle handle-right",
|
|
112193
112833
|
id: "right-margin-handle",
|
|
112194
|
-
onMousedown:
|
|
112834
|
+
onMousedown: handleMouseDown2,
|
|
112195
112835
|
style: normalizeStyle(getHandlePosition.value("right"))
|
|
112196
112836
|
}, null, 36),
|
|
112197
112837
|
showVerticalIndicator.value ? (openBlock(), createElementBlock("div", {
|
|
@@ -112224,8 +112864,8 @@ const _sfc_main$5 = {
|
|
|
112224
112864
|
};
|
|
112225
112865
|
}
|
|
112226
112866
|
};
|
|
112227
|
-
const Ruler = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
112228
|
-
const _sfc_main$
|
|
112867
|
+
const Ruler = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-79f9a944"]]);
|
|
112868
|
+
const _sfc_main$5 = {
|
|
112229
112869
|
__name: "GenericPopover",
|
|
112230
112870
|
props: {
|
|
112231
112871
|
editor: { type: Object, required: true },
|
|
@@ -112253,22 +112893,22 @@ const _sfc_main$4 = {
|
|
|
112253
112893
|
() => props.visible,
|
|
112254
112894
|
(val) => {
|
|
112255
112895
|
if (val) {
|
|
112256
|
-
document.addEventListener("
|
|
112896
|
+
document.addEventListener("pointerdown", handleClickOutside2);
|
|
112257
112897
|
document.addEventListener("keydown", handleEscape);
|
|
112258
112898
|
} else {
|
|
112259
|
-
document.removeEventListener("
|
|
112899
|
+
document.removeEventListener("pointerdown", handleClickOutside2);
|
|
112260
112900
|
document.removeEventListener("keydown", handleEscape);
|
|
112261
112901
|
}
|
|
112262
112902
|
}
|
|
112263
112903
|
);
|
|
112264
112904
|
onMounted(() => {
|
|
112265
112905
|
if (props.visible) {
|
|
112266
|
-
document.addEventListener("
|
|
112906
|
+
document.addEventListener("pointerdown", handleClickOutside2);
|
|
112267
112907
|
document.addEventListener("keydown", handleEscape);
|
|
112268
112908
|
}
|
|
112269
112909
|
});
|
|
112270
112910
|
onBeforeUnmount(() => {
|
|
112271
|
-
document.removeEventListener("
|
|
112911
|
+
document.removeEventListener("pointerdown", handleClickOutside2);
|
|
112272
112912
|
document.removeEventListener("keydown", handleEscape);
|
|
112273
112913
|
});
|
|
112274
112914
|
const derivedStyles = computed(() => ({
|
|
@@ -112283,7 +112923,7 @@ const _sfc_main$4 = {
|
|
|
112283
112923
|
style: normalizeStyle(derivedStyles.value),
|
|
112284
112924
|
ref_key: "popover",
|
|
112285
112925
|
ref: popover,
|
|
112286
|
-
|
|
112926
|
+
onPointerdown: _cache[0] || (_cache[0] = withModifiers(() => {
|
|
112287
112927
|
}, ["stop"])),
|
|
112288
112928
|
onClick: _cache[1] || (_cache[1] = withModifiers(() => {
|
|
112289
112929
|
}, ["stop"]))
|
|
@@ -112293,7 +112933,7 @@ const _sfc_main$4 = {
|
|
|
112293
112933
|
};
|
|
112294
112934
|
}
|
|
112295
112935
|
};
|
|
112296
|
-
const GenericPopover = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
112936
|
+
const GenericPopover = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-157855b5"]]);
|
|
112297
112937
|
const _hoisted_1$3 = ["data-boundary-index", "data-boundary-type", "onMousedown"];
|
|
112298
112938
|
const RESIZE_HANDLE_WIDTH_PX = 9;
|
|
112299
112939
|
const RESIZE_HANDLE_OFFSET_PX = 4;
|
|
@@ -112301,7 +112941,7 @@ const DRAG_OVERLAY_EXTENSION_PX = 1e3;
|
|
|
112301
112941
|
const MIN_DRAG_OVERLAY_WIDTH_PX = 2e3;
|
|
112302
112942
|
const THROTTLE_INTERVAL_MS = 16;
|
|
112303
112943
|
const MIN_RESIZE_DELTA_PX = 1;
|
|
112304
|
-
const _sfc_main$
|
|
112944
|
+
const _sfc_main$4 = {
|
|
112305
112945
|
__name: "TableResizeOverlay",
|
|
112306
112946
|
props: {
|
|
112307
112947
|
/** Editor instance for dispatching transactions */
|
|
@@ -112825,7 +113465,7 @@ const _sfc_main$3 = {
|
|
|
112825
113465
|
};
|
|
112826
113466
|
}
|
|
112827
113467
|
};
|
|
112828
|
-
const TableResizeOverlay = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
113468
|
+
const TableResizeOverlay = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-2fdf7836"]]);
|
|
112829
113469
|
const _hoisted_1$2 = ["data-handle-position", "onMousedown"];
|
|
112830
113470
|
const OVERLAY_EXPANSION_PX = 2e3;
|
|
112831
113471
|
const RESIZE_HANDLE_SIZE_PX = 12;
|
|
@@ -112834,7 +113474,7 @@ const DIMENSION_CHANGE_THRESHOLD_PX = 1;
|
|
|
112834
113474
|
const Z_INDEX_OVERLAY = 10;
|
|
112835
113475
|
const Z_INDEX_HANDLE = 15;
|
|
112836
113476
|
const Z_INDEX_GUIDELINE = 20;
|
|
112837
|
-
const _sfc_main$
|
|
113477
|
+
const _sfc_main$3 = {
|
|
112838
113478
|
__name: "ImageResizeOverlay",
|
|
112839
113479
|
props: {
|
|
112840
113480
|
/** Editor instance for dispatching transactions */
|
|
@@ -113258,7 +113898,81 @@ const _sfc_main$2 = {
|
|
|
113258
113898
|
};
|
|
113259
113899
|
}
|
|
113260
113900
|
};
|
|
113261
|
-
const ImageResizeOverlay = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
113901
|
+
const ImageResizeOverlay = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-e66ec7bb"]]);
|
|
113902
|
+
const _sfc_main$2 = {
|
|
113903
|
+
__name: "LinkClickHandler",
|
|
113904
|
+
props: {
|
|
113905
|
+
editor: {
|
|
113906
|
+
type: Object,
|
|
113907
|
+
required: true
|
|
113908
|
+
},
|
|
113909
|
+
openPopover: {
|
|
113910
|
+
type: Function,
|
|
113911
|
+
required: true
|
|
113912
|
+
},
|
|
113913
|
+
closePopover: {
|
|
113914
|
+
type: Function,
|
|
113915
|
+
required: true
|
|
113916
|
+
},
|
|
113917
|
+
popoverVisible: {
|
|
113918
|
+
type: Boolean,
|
|
113919
|
+
default: false
|
|
113920
|
+
}
|
|
113921
|
+
},
|
|
113922
|
+
setup(__props) {
|
|
113923
|
+
const props = __props;
|
|
113924
|
+
const handleLinkClick = (event) => {
|
|
113925
|
+
if (props.popoverVisible) {
|
|
113926
|
+
props.closePopover();
|
|
113927
|
+
return;
|
|
113928
|
+
}
|
|
113929
|
+
if (!props.editor || !props.editor.state) {
|
|
113930
|
+
return;
|
|
113931
|
+
}
|
|
113932
|
+
const surface = getEditorSurfaceElement(props.editor);
|
|
113933
|
+
if (!surface) {
|
|
113934
|
+
return;
|
|
113935
|
+
}
|
|
113936
|
+
moveCursorToMouseEvent(event.detail, props.editor);
|
|
113937
|
+
setTimeout(() => {
|
|
113938
|
+
const currentState = props.editor.state;
|
|
113939
|
+
const hasLink = selectionHasNodeOrMark(currentState, "link", { requireEnds: true });
|
|
113940
|
+
if (hasLink) {
|
|
113941
|
+
const surfaceRect = surface.getBoundingClientRect();
|
|
113942
|
+
if (!surfaceRect) return;
|
|
113943
|
+
props.openPopover(
|
|
113944
|
+
markRaw(LinkInput),
|
|
113945
|
+
{
|
|
113946
|
+
showInput: true,
|
|
113947
|
+
editor: props.editor,
|
|
113948
|
+
closePopover: props.closePopover
|
|
113949
|
+
},
|
|
113950
|
+
{
|
|
113951
|
+
left: `${event.detail.clientX - surfaceRect.left}px`,
|
|
113952
|
+
top: `${event.detail.clientY - surfaceRect.top + 15}px`
|
|
113953
|
+
}
|
|
113954
|
+
);
|
|
113955
|
+
}
|
|
113956
|
+
}, 10);
|
|
113957
|
+
};
|
|
113958
|
+
let surfaceElement = null;
|
|
113959
|
+
onMounted(() => {
|
|
113960
|
+
if (!props.editor) return;
|
|
113961
|
+
surfaceElement = getEditorSurfaceElement(props.editor);
|
|
113962
|
+
if (surfaceElement) {
|
|
113963
|
+
surfaceElement.addEventListener("superdoc-link-click", handleLinkClick);
|
|
113964
|
+
}
|
|
113965
|
+
});
|
|
113966
|
+
onBeforeUnmount(() => {
|
|
113967
|
+
if (surfaceElement) {
|
|
113968
|
+
surfaceElement.removeEventListener("superdoc-link-click", handleLinkClick);
|
|
113969
|
+
}
|
|
113970
|
+
});
|
|
113971
|
+
return (_ctx, _cache) => {
|
|
113972
|
+
return null;
|
|
113973
|
+
};
|
|
113974
|
+
}
|
|
113975
|
+
};
|
|
113262
113976
|
function adjustPaginationBreaks(editorElem, editor) {
|
|
113263
113977
|
if (!editorElem.value || !editor?.value?.options?.scale || isHeadless(editor)) return;
|
|
113264
113978
|
const zoom = editor.value.options.scale;
|
|
@@ -113600,21 +114314,28 @@ const _sfc_main$1 = {
|
|
|
113600
114314
|
class: "editor-element super-editor__element",
|
|
113601
114315
|
role: "presentation"
|
|
113602
114316
|
}, null, 512),
|
|
113603
|
-
!contextMenuDisabled.value && editorReady.value && activeEditor.value ? (openBlock(), createBlock(_sfc_main$
|
|
114317
|
+
!contextMenuDisabled.value && editorReady.value && activeEditor.value ? (openBlock(), createBlock(_sfc_main$8, {
|
|
113604
114318
|
key: 0,
|
|
113605
114319
|
editor: activeEditor.value,
|
|
113606
114320
|
popoverControls,
|
|
113607
114321
|
openPopover,
|
|
113608
114322
|
closePopover
|
|
113609
114323
|
}, null, 8, ["editor", "popoverControls"])) : createCommentVNode("", true),
|
|
113610
|
-
editorReady.value && activeEditor.value ? (openBlock(), createBlock(
|
|
114324
|
+
editorReady.value && activeEditor.value ? (openBlock(), createBlock(_sfc_main$2, {
|
|
113611
114325
|
key: 1,
|
|
113612
114326
|
editor: activeEditor.value,
|
|
114327
|
+
openPopover,
|
|
114328
|
+
closePopover,
|
|
114329
|
+
popoverVisible: popoverControls.visible
|
|
114330
|
+
}, null, 8, ["editor", "popoverVisible"])) : createCommentVNode("", true),
|
|
114331
|
+
editorReady.value && activeEditor.value ? (openBlock(), createBlock(TableResizeOverlay, {
|
|
114332
|
+
key: 2,
|
|
114333
|
+
editor: activeEditor.value,
|
|
113613
114334
|
visible: tableResizeState.visible,
|
|
113614
114335
|
tableElement: tableResizeState.tableElement
|
|
113615
114336
|
}, null, 8, ["editor", "visible", "tableElement"])) : createCommentVNode("", true),
|
|
113616
114337
|
editorReady.value && activeEditor.value ? (openBlock(), createBlock(ImageResizeOverlay, {
|
|
113617
|
-
key:
|
|
114338
|
+
key: 3,
|
|
113618
114339
|
editor: activeEditor.value,
|
|
113619
114340
|
visible: imageResizeState.visible,
|
|
113620
114341
|
imageElement: imageResizeState.imageElement
|
|
@@ -113681,7 +114402,7 @@ const _sfc_main$1 = {
|
|
|
113681
114402
|
};
|
|
113682
114403
|
}
|
|
113683
114404
|
};
|
|
113684
|
-
const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
114405
|
+
const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-08b32c3d"]]);
|
|
113685
114406
|
const _hoisted_1 = ["innerHTML"];
|
|
113686
114407
|
const _sfc_main = {
|
|
113687
114408
|
__name: "SuperInput",
|
|
@@ -113792,10 +114513,10 @@ export {
|
|
|
113792
114513
|
PresentationEditor as P,
|
|
113793
114514
|
SectionHelpers as S,
|
|
113794
114515
|
Toolbar as T,
|
|
113795
|
-
_sfc_main$
|
|
114516
|
+
_sfc_main$7 as _,
|
|
113796
114517
|
AnnotatorHelpers as a,
|
|
113797
114518
|
Extensions as b,
|
|
113798
|
-
_sfc_main$
|
|
114519
|
+
_sfc_main$8 as c,
|
|
113799
114520
|
SuperConverter as d,
|
|
113800
114521
|
SuperEditor as e,
|
|
113801
114522
|
SuperInput as f,
|