@harbour-enterprises/superdoc 0.22.0-next.1 → 0.22.0-next.3
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-B3KmcDup.cjs → PdfViewer-CvFw8S_D.cjs} +1 -1
- package/dist/chunks/{PdfViewer-BpwMPbUj.es.js → PdfViewer-D95oFKMa.es.js} +1 -1
- package/dist/chunks/{index-BOf6E2I4.cjs → index-Ct4VrAay.cjs} +39 -19
- package/dist/chunks/{index-Cw4YywoD.es.js → index-DgH1cx2c.es.js} +39 -19
- package/dist/chunks/{super-editor.es-DHDx2fsy.cjs → super-editor.es-CIDcWgLs.cjs} +198 -76
- package/dist/chunks/{super-editor.es-vfoWxyZL.es.js → super-editor.es-WUoM0FI7.es.js} +198 -76
- package/dist/core/SuperDoc.d.ts +5 -0
- package/dist/core/SuperDoc.d.ts.map +1 -1
- package/dist/core/types/index.d.ts +4 -4
- package/dist/core/types/index.d.ts.map +1 -1
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-BcqEfCTg.js → converter-DBwwYo1I.js} +187 -63
- package/dist/super-editor/chunks/{docx-zipper-DZ9ph0iQ.js → docx-zipper-BCI-3XE9.js} +1 -1
- package/dist/super-editor/chunks/{editor-BC2sSIVa.js → editor-W3rw5KHF.js} +13 -6
- package/dist/super-editor/chunks/{toolbar-DNTo5DDf.js → toolbar-CFfRuTi3.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/src/core/super-converter/SuperConverter.d.ts +1 -13
- package/dist/super-editor/src/extensions/custom-selection/custom-selection.d.ts +0 -1
- package/dist/super-editor/src/utils/contextmenu-helpers.d.ts +24 -0
- package/dist/super-editor/super-editor.es.js +7 -15
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +1 -1
- package/dist/super-editor.es.js +1 -1
- package/dist/superdoc.cjs +2 -2
- package/dist/superdoc.es.js +2 -2
- package/dist/superdoc.umd.js +235 -93
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/super-editor/src/components/slash-menu/contextmenu-helpers.d.ts +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const vue = require("./vue-DWle4Cai.cjs");
|
|
4
|
-
const superdoc = require("./index-
|
|
4
|
+
const superdoc = require("./index-Ct4VrAay.cjs");
|
|
5
5
|
function self(vars) {
|
|
6
6
|
const {
|
|
7
7
|
opacityDisabled,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { m as defineComponent, B as h, O as Transition, $ as process$1, I as watchEffect, d as computed, r as ref, j as onMounted, W as onUnmounted, c as createElementBlock, o as openBlock, a as createBaseVNode, f as createCommentVNode, v as createVNode, x as unref } from "./vue-CXxsqYcP.es.js";
|
|
2
|
-
import { d as derived, c, a as cB, f as fadeInTransition, b as cM, N as NBaseLoading, w as warnOnce, u as useConfig, e as useTheme, p as pxfy, g as createKey, h as useThemeClass, i as useCompitable, _ as _export_sfc, j as useSuperdocStore, s as storeToRefs, k as useSelection } from "./index-
|
|
2
|
+
import { d as derived, c, a as cB, f as fadeInTransition, b as cM, N as NBaseLoading, w as warnOnce, u as useConfig, e as useTheme, p as pxfy, g as createKey, h as useThemeClass, i as useCompitable, _ as _export_sfc, j as useSuperdocStore, s as storeToRefs, k as useSelection } from "./index-DgH1cx2c.es.js";
|
|
3
3
|
function self(vars) {
|
|
4
4
|
const {
|
|
5
5
|
opacityDisabled,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const superEditor_es = require("./super-editor.es-
|
|
2
|
+
const superEditor_es = require("./super-editor.es-CIDcWgLs.cjs");
|
|
3
3
|
const vue = require("./vue-DWle4Cai.cjs");
|
|
4
4
|
const jszip = require("./jszip-b7l8QkfH.cjs");
|
|
5
5
|
const blankDocx = require("./blank-docx-CPqX9RF5.cjs");
|
|
@@ -17409,7 +17409,7 @@ const _sfc_main = {
|
|
|
17409
17409
|
__name: "SuperDoc",
|
|
17410
17410
|
emits: ["selection-update"],
|
|
17411
17411
|
setup(__props, { emit: __emit }) {
|
|
17412
|
-
const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-
|
|
17412
|
+
const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-CvFw8S_D.cjs")));
|
|
17413
17413
|
const superdocStore = useSuperdocStore();
|
|
17414
17414
|
const commentsStore = useCommentsStore();
|
|
17415
17415
|
const {
|
|
@@ -18069,6 +18069,9 @@ class SuperDoc extends eventemitter3.EventEmitter {
|
|
|
18069
18069
|
this.isDev = this.config.isDev || false;
|
|
18070
18070
|
this.activeEditor = null;
|
|
18071
18071
|
this.comments = [];
|
|
18072
|
+
if (!this.config.selector) {
|
|
18073
|
+
throw new Error("SuperDoc: selector is required");
|
|
18074
|
+
}
|
|
18072
18075
|
this.app.mount(this.config.selector);
|
|
18073
18076
|
this.readyEditors = 0;
|
|
18074
18077
|
this.isLocked = this.config.isLocked || false;
|
|
@@ -18088,6 +18091,16 @@ class SuperDoc extends eventemitter3.EventEmitter {
|
|
|
18088
18091
|
users: this.users
|
|
18089
18092
|
};
|
|
18090
18093
|
}
|
|
18094
|
+
/**
|
|
18095
|
+
* Get the SuperDoc container element
|
|
18096
|
+
* @returns {HTMLElement | null}
|
|
18097
|
+
*/
|
|
18098
|
+
get element() {
|
|
18099
|
+
if (typeof this.config.selector === "string") {
|
|
18100
|
+
return document.querySelector(this.config.selector);
|
|
18101
|
+
}
|
|
18102
|
+
return this.config.selector;
|
|
18103
|
+
}
|
|
18091
18104
|
#patchNaiveUIStyles() {
|
|
18092
18105
|
const cspNonce = this.config.cspNonce;
|
|
18093
18106
|
const originalCreateElement = document.createElement;
|
|
@@ -18111,10 +18124,16 @@ class SuperDoc extends eventemitter3.EventEmitter {
|
|
|
18111
18124
|
}
|
|
18112
18125
|
if (hasDocumentConfig) {
|
|
18113
18126
|
const normalized = normalizeDocumentEntry(this.config.document);
|
|
18114
|
-
this.config.documents = [
|
|
18127
|
+
this.config.documents = [
|
|
18128
|
+
{
|
|
18129
|
+
id: uuid.v4(),
|
|
18130
|
+
...normalized
|
|
18131
|
+
}
|
|
18132
|
+
];
|
|
18115
18133
|
} else if (hasDocumentUrl) {
|
|
18116
18134
|
this.config.documents = [
|
|
18117
18135
|
{
|
|
18136
|
+
id: uuid.v4(),
|
|
18118
18137
|
type: DOCX,
|
|
18119
18138
|
url: this.config.document,
|
|
18120
18139
|
name: "document.docx",
|
|
@@ -18122,33 +18141,34 @@ class SuperDoc extends eventemitter3.EventEmitter {
|
|
|
18122
18141
|
}
|
|
18123
18142
|
];
|
|
18124
18143
|
} else if (hasDocumentFile) {
|
|
18144
|
+
const normalized = normalizeDocumentEntry(this.config.document);
|
|
18125
18145
|
this.config.documents = [
|
|
18126
18146
|
{
|
|
18127
|
-
|
|
18128
|
-
|
|
18129
|
-
name: this.config.document.name,
|
|
18130
|
-
isNewFile: true
|
|
18147
|
+
id: uuid.v4(),
|
|
18148
|
+
...normalized
|
|
18131
18149
|
}
|
|
18132
18150
|
];
|
|
18133
18151
|
} else if (hasDocumentBlob) {
|
|
18134
|
-
const
|
|
18135
|
-
let extension = ".docx";
|
|
18136
|
-
if (docType === PDF) {
|
|
18137
|
-
extension = ".pdf";
|
|
18138
|
-
} else if (docType === HTML) {
|
|
18139
|
-
extension = ".html";
|
|
18140
|
-
}
|
|
18152
|
+
const normalized = normalizeDocumentEntry(this.config.document);
|
|
18141
18153
|
this.config.documents = [
|
|
18142
18154
|
{
|
|
18143
|
-
|
|
18144
|
-
|
|
18145
|
-
name: `document${extension}`,
|
|
18146
|
-
isNewFile: true
|
|
18155
|
+
id: uuid.v4(),
|
|
18156
|
+
...normalized
|
|
18147
18157
|
}
|
|
18148
18158
|
];
|
|
18149
18159
|
}
|
|
18150
18160
|
if (Array.isArray(this.config.documents) && this.config.documents.length > 0) {
|
|
18151
|
-
this.config.documents = this.config.documents.map((d) =>
|
|
18161
|
+
this.config.documents = this.config.documents.map((d) => {
|
|
18162
|
+
const normalized = normalizeDocumentEntry(d);
|
|
18163
|
+
if (!normalized || typeof normalized !== "object") {
|
|
18164
|
+
return normalized;
|
|
18165
|
+
}
|
|
18166
|
+
const existingId = typeof normalized === "object" && "id" in normalized && normalized.id || d && typeof d === "object" && "id" in d && d.id;
|
|
18167
|
+
return {
|
|
18168
|
+
...normalized,
|
|
18169
|
+
id: existingId || uuid.v4()
|
|
18170
|
+
};
|
|
18171
|
+
});
|
|
18152
18172
|
}
|
|
18153
18173
|
}
|
|
18154
18174
|
#initVueApp() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { q as index$1, C as CommentsPluginKey, h as TrackChangesBasePluginKey, E as Editor, n as getRichTextExtensions, f as SuperInput, e as SuperEditor, A as AIWriter, g as SuperToolbar, i as createZip } from "./super-editor.es-
|
|
1
|
+
import { q as index$1, C as CommentsPluginKey, h as TrackChangesBasePluginKey, E as Editor, n as getRichTextExtensions, f as SuperInput, e as SuperEditor, A as AIWriter, g as SuperToolbar, i as createZip } from "./super-editor.es-WUoM0FI7.es.js";
|
|
2
2
|
import { a0 as effectScope, r as ref, _ as markRaw, $ as process$1, a1 as toRaw, d as computed, a2 as isRef, a3 as isReactive, C as toRef, i as inject, p as getCurrentInstance, l as watch, x as unref, a4 as hasInjectionContext, M as reactive, s as nextTick, a5 as getCurrentScope, a6 as onScopeDispose, a7 as toRefs, g as global$1, J as shallowRef, N as readonly, j as onMounted, k as onBeforeUnmount, h as onBeforeMount, S as onActivated, q as onDeactivated, z as createTextVNode, F as Fragment, Q as Comment, m as defineComponent, D as provide, H as withDirectives, B as h, U as Teleport, R as renderSlot, V as isVNode, I as watchEffect, O as Transition, a8 as TransitionGroup, E as mergeProps, P as vShow, G as cloneVNode, T as Text, c as createElementBlock, o as openBlock, t as toDisplayString, v as createVNode, y as withCtx, a as createBaseVNode, A as normalizeStyle, f as createCommentVNode, u as createBlock, w as withModifiers, n as normalizeClass, a9 as resolveDirective, e as renderList, b as createApp, X as resolveDynamicComponent, aa as defineAsyncComponent } from "./vue-CXxsqYcP.es.js";
|
|
3
3
|
import { B as Buffer$2 } from "./jszip-B8KIZSNe.es.js";
|
|
4
4
|
import { B as BlankDOCX } from "./blank-docx-iwdyG9RH.es.js";
|
|
@@ -17392,7 +17392,7 @@ const _sfc_main = {
|
|
|
17392
17392
|
__name: "SuperDoc",
|
|
17393
17393
|
emits: ["selection-update"],
|
|
17394
17394
|
setup(__props, { emit: __emit }) {
|
|
17395
|
-
const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-
|
|
17395
|
+
const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-D95oFKMa.es.js"));
|
|
17396
17396
|
const superdocStore = useSuperdocStore();
|
|
17397
17397
|
const commentsStore = useCommentsStore();
|
|
17398
17398
|
const {
|
|
@@ -18052,6 +18052,9 @@ class SuperDoc extends EventEmitter {
|
|
|
18052
18052
|
this.isDev = this.config.isDev || false;
|
|
18053
18053
|
this.activeEditor = null;
|
|
18054
18054
|
this.comments = [];
|
|
18055
|
+
if (!this.config.selector) {
|
|
18056
|
+
throw new Error("SuperDoc: selector is required");
|
|
18057
|
+
}
|
|
18055
18058
|
this.app.mount(this.config.selector);
|
|
18056
18059
|
this.readyEditors = 0;
|
|
18057
18060
|
this.isLocked = this.config.isLocked || false;
|
|
@@ -18071,6 +18074,16 @@ class SuperDoc extends EventEmitter {
|
|
|
18071
18074
|
users: this.users
|
|
18072
18075
|
};
|
|
18073
18076
|
}
|
|
18077
|
+
/**
|
|
18078
|
+
* Get the SuperDoc container element
|
|
18079
|
+
* @returns {HTMLElement | null}
|
|
18080
|
+
*/
|
|
18081
|
+
get element() {
|
|
18082
|
+
if (typeof this.config.selector === "string") {
|
|
18083
|
+
return document.querySelector(this.config.selector);
|
|
18084
|
+
}
|
|
18085
|
+
return this.config.selector;
|
|
18086
|
+
}
|
|
18074
18087
|
#patchNaiveUIStyles() {
|
|
18075
18088
|
const cspNonce = this.config.cspNonce;
|
|
18076
18089
|
const originalCreateElement = document.createElement;
|
|
@@ -18094,10 +18107,16 @@ class SuperDoc extends EventEmitter {
|
|
|
18094
18107
|
}
|
|
18095
18108
|
if (hasDocumentConfig) {
|
|
18096
18109
|
const normalized = normalizeDocumentEntry(this.config.document);
|
|
18097
|
-
this.config.documents = [
|
|
18110
|
+
this.config.documents = [
|
|
18111
|
+
{
|
|
18112
|
+
id: v4(),
|
|
18113
|
+
...normalized
|
|
18114
|
+
}
|
|
18115
|
+
];
|
|
18098
18116
|
} else if (hasDocumentUrl) {
|
|
18099
18117
|
this.config.documents = [
|
|
18100
18118
|
{
|
|
18119
|
+
id: v4(),
|
|
18101
18120
|
type: DOCX,
|
|
18102
18121
|
url: this.config.document,
|
|
18103
18122
|
name: "document.docx",
|
|
@@ -18105,33 +18124,34 @@ class SuperDoc extends EventEmitter {
|
|
|
18105
18124
|
}
|
|
18106
18125
|
];
|
|
18107
18126
|
} else if (hasDocumentFile) {
|
|
18127
|
+
const normalized = normalizeDocumentEntry(this.config.document);
|
|
18108
18128
|
this.config.documents = [
|
|
18109
18129
|
{
|
|
18110
|
-
|
|
18111
|
-
|
|
18112
|
-
name: this.config.document.name,
|
|
18113
|
-
isNewFile: true
|
|
18130
|
+
id: v4(),
|
|
18131
|
+
...normalized
|
|
18114
18132
|
}
|
|
18115
18133
|
];
|
|
18116
18134
|
} else if (hasDocumentBlob) {
|
|
18117
|
-
const
|
|
18118
|
-
let extension = ".docx";
|
|
18119
|
-
if (docType === PDF) {
|
|
18120
|
-
extension = ".pdf";
|
|
18121
|
-
} else if (docType === HTML) {
|
|
18122
|
-
extension = ".html";
|
|
18123
|
-
}
|
|
18135
|
+
const normalized = normalizeDocumentEntry(this.config.document);
|
|
18124
18136
|
this.config.documents = [
|
|
18125
18137
|
{
|
|
18126
|
-
|
|
18127
|
-
|
|
18128
|
-
name: `document${extension}`,
|
|
18129
|
-
isNewFile: true
|
|
18138
|
+
id: v4(),
|
|
18139
|
+
...normalized
|
|
18130
18140
|
}
|
|
18131
18141
|
];
|
|
18132
18142
|
}
|
|
18133
18143
|
if (Array.isArray(this.config.documents) && this.config.documents.length > 0) {
|
|
18134
|
-
this.config.documents = this.config.documents.map((d) =>
|
|
18144
|
+
this.config.documents = this.config.documents.map((d) => {
|
|
18145
|
+
const normalized = normalizeDocumentEntry(d);
|
|
18146
|
+
if (!normalized || typeof normalized !== "object") {
|
|
18147
|
+
return normalized;
|
|
18148
|
+
}
|
|
18149
|
+
const existingId = typeof normalized === "object" && "id" in normalized && normalized.id || d && typeof d === "object" && "id" in d && d.id;
|
|
18150
|
+
return {
|
|
18151
|
+
...normalized,
|
|
18152
|
+
id: existingId || v4()
|
|
18153
|
+
};
|
|
18154
|
+
});
|
|
18135
18155
|
}
|
|
18136
18156
|
}
|
|
18137
18157
|
#initVueApp() {
|
|
@@ -24856,17 +24856,16 @@ const getParagraphSpacing = (node, docx, styleId = "", marks = [], options = {})
|
|
|
24856
24856
|
};
|
|
24857
24857
|
const getDefaultParagraphStyle = (docx, styleId = "") => {
|
|
24858
24858
|
const styles = docx["word/styles.xml"];
|
|
24859
|
-
|
|
24859
|
+
const rootElements = styles?.elements?.[0]?.elements;
|
|
24860
|
+
if (!rootElements?.length) {
|
|
24860
24861
|
return {};
|
|
24861
24862
|
}
|
|
24862
|
-
const defaults =
|
|
24863
|
-
const pDefault = defaults
|
|
24863
|
+
const defaults = rootElements.find((el) => el.name === "w:docDefaults");
|
|
24864
|
+
const pDefault = defaults?.elements?.find((el) => el.name === "w:pPrDefault") || {};
|
|
24864
24865
|
const pPrDefault = pDefault?.elements?.find((el) => el.name === "w:pPr");
|
|
24865
24866
|
const pPrDefaultSpacingTag = pPrDefault?.elements?.find((el) => el.name === "w:spacing") || {};
|
|
24866
24867
|
const pPrDefaultIndentTag = pPrDefault?.elements?.find((el) => el.name === "w:ind") || {};
|
|
24867
|
-
const stylesNormal =
|
|
24868
|
-
(el) => el.name === "w:style" && el.attributes["w:styleId"] === "Normal"
|
|
24869
|
-
);
|
|
24868
|
+
const stylesNormal = rootElements.find((el) => el.name === "w:style" && el.attributes["w:styleId"] === "Normal");
|
|
24870
24869
|
const pPrNormal = stylesNormal?.elements?.find((el) => el.name === "w:pPr");
|
|
24871
24870
|
const pPrNormalSpacingTag = pPrNormal?.elements?.find((el) => el.name === "w:spacing") || {};
|
|
24872
24871
|
const pPrNormalIndentTag = pPrNormal?.elements?.find((el) => el.name === "w:ind") || {};
|
|
@@ -24875,9 +24874,7 @@ const getDefaultParagraphStyle = (docx, styleId = "") => {
|
|
|
24875
24874
|
let pPrStyleIdIndentTag = {};
|
|
24876
24875
|
let pPrStyleJc = {};
|
|
24877
24876
|
if (styleId) {
|
|
24878
|
-
const stylesById =
|
|
24879
|
-
(el) => el.name === "w:style" && el.attributes["w:styleId"] === styleId
|
|
24880
|
-
);
|
|
24877
|
+
const stylesById = rootElements.find((el) => el.name === "w:style" && el.attributes["w:styleId"] === styleId);
|
|
24881
24878
|
const pPrById = stylesById?.elements?.find((el) => el.name === "w:pPr");
|
|
24882
24879
|
pPrStyleIdSpacingTag = pPrById?.elements?.find((el) => el.name === "w:spacing") || {};
|
|
24883
24880
|
pPrStyleIdIndentTag = pPrById?.elements?.find((el) => el.name === "w:ind") || {};
|
|
@@ -30611,6 +30608,18 @@ const config = {
|
|
|
30611
30608
|
attributes: validXmlAttributes
|
|
30612
30609
|
};
|
|
30613
30610
|
const translator = NodeTranslator.from(config);
|
|
30611
|
+
const DEFAULT_SECTION_PROPS_TWIPS = Object.freeze({
|
|
30612
|
+
pageSize: Object.freeze({ width: "12240", height: "15840" }),
|
|
30613
|
+
pageMargins: Object.freeze({
|
|
30614
|
+
top: "1440",
|
|
30615
|
+
right: "1440",
|
|
30616
|
+
bottom: "1440",
|
|
30617
|
+
left: "1440",
|
|
30618
|
+
header: "720",
|
|
30619
|
+
footer: "720",
|
|
30620
|
+
gutter: "0"
|
|
30621
|
+
})
|
|
30622
|
+
});
|
|
30614
30623
|
const isLineBreakOnlyRun = (node) => {
|
|
30615
30624
|
if (!node) return false;
|
|
30616
30625
|
if (node.type === "lineBreak" || node.type === "hardBreak") return true;
|
|
@@ -30663,28 +30672,63 @@ function exportSchemaToJson(params2) {
|
|
|
30663
30672
|
return handler2(params2);
|
|
30664
30673
|
}
|
|
30665
30674
|
function translateBodyNode(params2) {
|
|
30666
|
-
let sectPr = params2.bodyNode?.elements
|
|
30675
|
+
let sectPr = params2.bodyNode?.elements?.find((n) => n.name === "w:sectPr");
|
|
30676
|
+
if (!sectPr) {
|
|
30677
|
+
sectPr = {
|
|
30678
|
+
type: "element",
|
|
30679
|
+
name: "w:sectPr",
|
|
30680
|
+
elements: []
|
|
30681
|
+
};
|
|
30682
|
+
} else if (!sectPr.elements) {
|
|
30683
|
+
sectPr = { ...sectPr, elements: [] };
|
|
30684
|
+
}
|
|
30667
30685
|
if (params2.converter) {
|
|
30668
|
-
const hasHeader = sectPr
|
|
30686
|
+
const hasHeader = sectPr.elements?.some((n) => n.name === "w:headerReference");
|
|
30669
30687
|
const hasDefaultHeader = params2.converter.headerIds?.default;
|
|
30670
30688
|
if (!hasHeader && hasDefaultHeader && !params2.editor.options.isHeaderOrFooter) {
|
|
30671
30689
|
const defaultHeader = generateDefaultHeaderFooter("header", params2.converter.headerIds?.default);
|
|
30672
30690
|
sectPr.elements.push(defaultHeader);
|
|
30673
30691
|
}
|
|
30674
|
-
const hasFooter = sectPr
|
|
30692
|
+
const hasFooter = sectPr.elements?.some((n) => n.name === "w:footerReference");
|
|
30675
30693
|
const hasDefaultFooter = params2.converter.footerIds?.default;
|
|
30676
30694
|
if (!hasFooter && hasDefaultFooter && !params2.editor.options.isHeaderOrFooter) {
|
|
30677
30695
|
const defaultFooter = generateDefaultHeaderFooter("footer", params2.converter.footerIds?.default);
|
|
30678
30696
|
sectPr.elements.push(defaultFooter);
|
|
30679
30697
|
}
|
|
30680
|
-
const newMargins = params2.converter.pageStyles
|
|
30681
|
-
|
|
30682
|
-
|
|
30683
|
-
|
|
30684
|
-
|
|
30685
|
-
|
|
30686
|
-
|
|
30687
|
-
|
|
30698
|
+
const newMargins = params2.converter.pageStyles?.pageMargins;
|
|
30699
|
+
if (newMargins) {
|
|
30700
|
+
let sectPrMargins = sectPr.elements.find((n) => n.name === "w:pgMar");
|
|
30701
|
+
if (!sectPrMargins) {
|
|
30702
|
+
sectPrMargins = {
|
|
30703
|
+
type: "element",
|
|
30704
|
+
name: "w:pgMar",
|
|
30705
|
+
attributes: {}
|
|
30706
|
+
};
|
|
30707
|
+
sectPr.elements.push(sectPrMargins);
|
|
30708
|
+
} else if (!sectPrMargins.attributes) {
|
|
30709
|
+
sectPrMargins.attributes = {};
|
|
30710
|
+
}
|
|
30711
|
+
Object.entries(newMargins).forEach(([key2, value]) => {
|
|
30712
|
+
const convertedValue = inchesToTwips(value);
|
|
30713
|
+
sectPrMargins.attributes[`w:${key2}`] = convertedValue;
|
|
30714
|
+
});
|
|
30715
|
+
}
|
|
30716
|
+
let sectPrPgSz = sectPr.elements.find((n) => n.name === "w:pgSz");
|
|
30717
|
+
if (!sectPrPgSz) {
|
|
30718
|
+
sectPrPgSz = {
|
|
30719
|
+
type: "element",
|
|
30720
|
+
name: "w:pgSz",
|
|
30721
|
+
attributes: {}
|
|
30722
|
+
};
|
|
30723
|
+
sectPr.elements.push(sectPrPgSz);
|
|
30724
|
+
} else if (!sectPrPgSz.attributes) {
|
|
30725
|
+
sectPrPgSz.attributes = {};
|
|
30726
|
+
}
|
|
30727
|
+
const pageSize = params2.converter.pageStyles?.pageSize;
|
|
30728
|
+
const widthInches = pageSize?.width;
|
|
30729
|
+
const heightInches = pageSize?.height;
|
|
30730
|
+
sectPrPgSz.attributes["w:w"] = widthInches ? String(inchesToTwips(widthInches)) : sectPrPgSz.attributes["w:w"] ?? DEFAULT_SECTION_PROPS_TWIPS.pageSize.width;
|
|
30731
|
+
sectPrPgSz.attributes["w:h"] = heightInches ? String(inchesToTwips(heightInches)) : sectPrPgSz.attributes["w:h"] ?? DEFAULT_SECTION_PROPS_TWIPS.pageSize.height;
|
|
30688
30732
|
}
|
|
30689
30733
|
const elements = translateChildNodes(params2);
|
|
30690
30734
|
if (params2.isHeaderFooter) {
|
|
@@ -32699,6 +32743,7 @@ const createDocumentJson = (docx, converter, editor) => {
|
|
|
32699
32743
|
const nodeListHandler = defaultNodeListHandler();
|
|
32700
32744
|
const bodyNode = json.elements[0].elements.find((el) => el.name === "w:body");
|
|
32701
32745
|
if (bodyNode) {
|
|
32746
|
+
ensureSectionProperties(bodyNode);
|
|
32702
32747
|
const node = bodyNode;
|
|
32703
32748
|
const contentElements = node.elements?.filter((n) => n.name !== "w:sectPr") ?? [];
|
|
32704
32749
|
const content = pruneIgnoredNodes(contentElements);
|
|
@@ -32932,6 +32977,59 @@ function getDocumentStyles(node, docx, converter, editor) {
|
|
|
32932
32977
|
styles.alternateHeaders = isAlternatingHeadersOddEven(docx);
|
|
32933
32978
|
return styles;
|
|
32934
32979
|
}
|
|
32980
|
+
const DEFAULT_SECTION_PROPS = Object.freeze({
|
|
32981
|
+
pageSize: Object.freeze({ width: "12240", height: "15840" }),
|
|
32982
|
+
pageMargins: Object.freeze({
|
|
32983
|
+
top: "1440",
|
|
32984
|
+
right: "1440",
|
|
32985
|
+
bottom: "1440",
|
|
32986
|
+
left: "1440",
|
|
32987
|
+
header: "720",
|
|
32988
|
+
footer: "720",
|
|
32989
|
+
gutter: "0"
|
|
32990
|
+
})
|
|
32991
|
+
});
|
|
32992
|
+
function ensureSectionProperties(bodyNode, converter) {
|
|
32993
|
+
if (!bodyNode.elements) bodyNode.elements = [];
|
|
32994
|
+
let sectPr = bodyNode.elements.find((el) => el.name === "w:sectPr");
|
|
32995
|
+
if (!sectPr) {
|
|
32996
|
+
sectPr = {
|
|
32997
|
+
type: "element",
|
|
32998
|
+
name: "w:sectPr",
|
|
32999
|
+
elements: []
|
|
33000
|
+
};
|
|
33001
|
+
bodyNode.elements.push(sectPr);
|
|
33002
|
+
} else if (!sectPr.elements) {
|
|
33003
|
+
sectPr.elements = [];
|
|
33004
|
+
}
|
|
33005
|
+
const ensureChild = (name, factory) => {
|
|
33006
|
+
let child = sectPr.elements.find((el) => el.name === name);
|
|
33007
|
+
if (!child) {
|
|
33008
|
+
child = factory();
|
|
33009
|
+
sectPr.elements.push(child);
|
|
33010
|
+
} else if (!child.attributes) {
|
|
33011
|
+
child.attributes = {};
|
|
33012
|
+
}
|
|
33013
|
+
return child;
|
|
33014
|
+
};
|
|
33015
|
+
const pgSz = ensureChild("w:pgSz", () => ({
|
|
33016
|
+
type: "element",
|
|
33017
|
+
name: "w:pgSz",
|
|
33018
|
+
attributes: {}
|
|
33019
|
+
}));
|
|
33020
|
+
pgSz.attributes["w:w"] = pgSz.attributes["w:w"] ?? DEFAULT_SECTION_PROPS.pageSize.width;
|
|
33021
|
+
pgSz.attributes["w:h"] = pgSz.attributes["w:h"] ?? DEFAULT_SECTION_PROPS.pageSize.height;
|
|
33022
|
+
const pgMar = ensureChild("w:pgMar", () => ({
|
|
33023
|
+
type: "element",
|
|
33024
|
+
name: "w:pgMar",
|
|
33025
|
+
attributes: {}
|
|
33026
|
+
}));
|
|
33027
|
+
Object.entries(DEFAULT_SECTION_PROPS.pageMargins).forEach(([key2, value]) => {
|
|
33028
|
+
const attrKey = `w:${key2}`;
|
|
33029
|
+
if (pgMar.attributes[attrKey] == null) pgMar.attributes[attrKey] = value;
|
|
33030
|
+
});
|
|
33031
|
+
return sectPr;
|
|
33032
|
+
}
|
|
32935
33033
|
function getStyleDefinitions(docx) {
|
|
32936
33034
|
const styles = docx["word/styles.xml"];
|
|
32937
33035
|
if (!styles) return [];
|
|
@@ -33124,6 +33222,36 @@ const FONT_FAMILY_FALLBACKS = Object.freeze({
|
|
|
33124
33222
|
auto: "sans-serif"
|
|
33125
33223
|
});
|
|
33126
33224
|
const DEFAULT_GENERIC_FALLBACK = "sans-serif";
|
|
33225
|
+
const DEFAULT_FONT_SIZE_PT = 10;
|
|
33226
|
+
const collectRunDefaultProperties = (runProps, { allowOverrideTypeface = true, allowOverrideSize = true, themeResolver, state: state2 }) => {
|
|
33227
|
+
if (!runProps?.elements?.length || !state2) return;
|
|
33228
|
+
const fontsNode = runProps.elements.find((el) => el.name === "w:rFonts");
|
|
33229
|
+
if (fontsNode?.attributes) {
|
|
33230
|
+
const themeName = fontsNode.attributes["w:asciiTheme"];
|
|
33231
|
+
if (themeName) {
|
|
33232
|
+
const themeInfo = themeResolver?.(themeName) || {};
|
|
33233
|
+
if ((allowOverrideTypeface || !state2.typeface) && themeInfo.typeface) state2.typeface = themeInfo.typeface;
|
|
33234
|
+
if ((allowOverrideTypeface || !state2.panose) && themeInfo.panose) state2.panose = themeInfo.panose;
|
|
33235
|
+
}
|
|
33236
|
+
const ascii = fontsNode.attributes["w:ascii"];
|
|
33237
|
+
if ((allowOverrideTypeface || !state2.typeface) && ascii) {
|
|
33238
|
+
state2.typeface = ascii;
|
|
33239
|
+
}
|
|
33240
|
+
}
|
|
33241
|
+
const sizeNode = runProps.elements.find((el) => el.name === "w:sz");
|
|
33242
|
+
if (sizeNode?.attributes?.["w:val"]) {
|
|
33243
|
+
const sizeTwips = Number(sizeNode.attributes["w:val"]);
|
|
33244
|
+
if (Number.isFinite(sizeTwips)) {
|
|
33245
|
+
if (state2.fallbackSzTwips === void 0) state2.fallbackSzTwips = sizeTwips;
|
|
33246
|
+
const sizePt = sizeTwips / 2;
|
|
33247
|
+
if (allowOverrideSize || state2.fontSizePt === void 0) state2.fontSizePt = sizePt;
|
|
33248
|
+
}
|
|
33249
|
+
}
|
|
33250
|
+
const kernNode = runProps.elements.find((el) => el.name === "w:kern");
|
|
33251
|
+
if (kernNode?.attributes?.["w:val"]) {
|
|
33252
|
+
if (allowOverrideSize || state2.kern === void 0) state2.kern = kernNode.attributes["w:val"];
|
|
33253
|
+
}
|
|
33254
|
+
};
|
|
33127
33255
|
const _SuperConverter = class _SuperConverter2 {
|
|
33128
33256
|
constructor(params2 = null) {
|
|
33129
33257
|
__privateAdd$2(this, _SuperConverter_instances);
|
|
@@ -33251,49 +33379,45 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
33251
33379
|
}
|
|
33252
33380
|
getDocumentDefaultStyles() {
|
|
33253
33381
|
const styles = this.convertedXml["word/styles.xml"];
|
|
33254
|
-
|
|
33255
|
-
const
|
|
33256
|
-
|
|
33257
|
-
|
|
33258
|
-
const
|
|
33259
|
-
const
|
|
33260
|
-
|
|
33261
|
-
|
|
33262
|
-
|
|
33263
|
-
|
|
33264
|
-
|
|
33265
|
-
|
|
33266
|
-
|
|
33267
|
-
|
|
33268
|
-
|
|
33269
|
-
|
|
33270
|
-
|
|
33271
|
-
|
|
33272
|
-
|
|
33273
|
-
|
|
33274
|
-
|
|
33275
|
-
|
|
33276
|
-
|
|
33277
|
-
|
|
33278
|
-
|
|
33279
|
-
|
|
33280
|
-
|
|
33281
|
-
|
|
33282
|
-
|
|
33283
|
-
|
|
33284
|
-
|
|
33285
|
-
|
|
33286
|
-
|
|
33287
|
-
|
|
33288
|
-
|
|
33289
|
-
|
|
33290
|
-
|
|
33291
|
-
|
|
33292
|
-
|
|
33293
|
-
const kern = rElements.find((el) => el.name === "w:kern")?.attributes["w:val"];
|
|
33294
|
-
const fontFamilyCss = _SuperConverter2.toCssFontFamily(typeface, this.convertedXml);
|
|
33295
|
-
return { fontSizePt, kern, typeface, panose, fontFamilyCss };
|
|
33296
|
-
}
|
|
33382
|
+
const styleRoot = styles?.elements?.[0];
|
|
33383
|
+
const styleElements = styleRoot?.elements || [];
|
|
33384
|
+
if (!styleElements.length) return {};
|
|
33385
|
+
const defaults = styleElements.find((el) => el.name === "w:docDefaults");
|
|
33386
|
+
const normalStyle = styleElements.find((el) => el.name === "w:style" && el.attributes?.["w:styleId"] === "Normal");
|
|
33387
|
+
const defaultsState = {
|
|
33388
|
+
typeface: void 0,
|
|
33389
|
+
panose: void 0,
|
|
33390
|
+
fontSizePt: void 0,
|
|
33391
|
+
kern: void 0,
|
|
33392
|
+
fallbackSzTwips: void 0
|
|
33393
|
+
};
|
|
33394
|
+
const docDefaultRun = defaults?.elements?.find((el) => el.name === "w:rPrDefault");
|
|
33395
|
+
const docDefaultProps = docDefaultRun?.elements?.find((el) => el.name === "w:rPr") ?? docDefaultRun;
|
|
33396
|
+
collectRunDefaultProperties(docDefaultProps, {
|
|
33397
|
+
allowOverrideTypeface: true,
|
|
33398
|
+
allowOverrideSize: true,
|
|
33399
|
+
themeResolver: (theme) => this.getThemeInfo(theme),
|
|
33400
|
+
state: defaultsState
|
|
33401
|
+
});
|
|
33402
|
+
const normalRunProps = normalStyle?.elements?.find((el) => el.name === "w:rPr") ?? null;
|
|
33403
|
+
collectRunDefaultProperties(normalRunProps, {
|
|
33404
|
+
allowOverrideTypeface: true,
|
|
33405
|
+
allowOverrideSize: true,
|
|
33406
|
+
themeResolver: (theme) => this.getThemeInfo(theme),
|
|
33407
|
+
state: defaultsState
|
|
33408
|
+
});
|
|
33409
|
+
if (defaultsState.fontSizePt === void 0) {
|
|
33410
|
+
if (Number.isFinite(defaultsState.fallbackSzTwips)) defaultsState.fontSizePt = defaultsState.fallbackSzTwips / 2;
|
|
33411
|
+
else defaultsState.fontSizePt = DEFAULT_FONT_SIZE_PT;
|
|
33412
|
+
}
|
|
33413
|
+
const fontFamilyCss = defaultsState.typeface ? _SuperConverter2.toCssFontFamily(defaultsState.typeface, this.convertedXml) : void 0;
|
|
33414
|
+
const result = {};
|
|
33415
|
+
if (defaultsState.fontSizePt !== void 0) result.fontSizePt = defaultsState.fontSizePt;
|
|
33416
|
+
if (defaultsState.kern !== void 0) result.kern = defaultsState.kern;
|
|
33417
|
+
if (defaultsState.typeface) result.typeface = defaultsState.typeface;
|
|
33418
|
+
if (defaultsState.panose) result.panose = defaultsState.panose;
|
|
33419
|
+
if (fontFamilyCss) result.fontFamilyCss = fontFamilyCss;
|
|
33420
|
+
return result;
|
|
33297
33421
|
}
|
|
33298
33422
|
getDocumentFonts() {
|
|
33299
33423
|
const fontTable = this.convertedXml["word/fontTable.xml"];
|
|
@@ -53591,15 +53715,21 @@ const intToJapaneseCounting = (num) => {
|
|
|
53591
53715
|
}
|
|
53592
53716
|
return result;
|
|
53593
53717
|
};
|
|
53594
|
-
const
|
|
53595
|
-
|
|
53718
|
+
const isKeyboardInvocation = (event) => {
|
|
53719
|
+
return event.type === "contextmenu" && typeof event.detail === "number" && event.detail === 0 && (event.button === 0 || event.button === void 0) && event.clientX === 0 && event.clientY === 0;
|
|
53720
|
+
};
|
|
53721
|
+
const prefersNativeMenu = (event) => {
|
|
53596
53722
|
if (!event) return false;
|
|
53597
53723
|
if (event.ctrlKey || event.metaKey) {
|
|
53598
53724
|
return true;
|
|
53599
53725
|
}
|
|
53600
|
-
|
|
53601
|
-
|
|
53726
|
+
return isKeyboardInvocation(event);
|
|
53727
|
+
};
|
|
53728
|
+
const shouldAllowNativeContextMenu = (event) => {
|
|
53729
|
+
return prefersNativeMenu(event);
|
|
53602
53730
|
};
|
|
53731
|
+
const shouldBypassContextMenu = shouldAllowNativeContextMenu;
|
|
53732
|
+
const CustomSelectionPluginKey = new PluginKey("CustomSelection");
|
|
53603
53733
|
const handleClickOutside = (event, editor) => {
|
|
53604
53734
|
const editorElem = editor?.options?.element;
|
|
53605
53735
|
if (!editorElem) return;
|
|
@@ -83101,7 +83231,7 @@ class SuperToolbar extends EventEmitter2 {
|
|
|
83101
83231
|
if (!argument) return;
|
|
83102
83232
|
item.onActivate({ zoom: argument });
|
|
83103
83233
|
this.emit("superdoc-command", { item, argument });
|
|
83104
|
-
const layers =
|
|
83234
|
+
const layers = this.superdoc.element?.querySelector(".layers");
|
|
83105
83235
|
if (!layers) return;
|
|
83106
83236
|
const isMobileDevice = typeof screen.orientation !== "undefined";
|
|
83107
83237
|
const isSmallScreen = window.matchMedia("(max-width: 834px)").matches;
|
|
@@ -84163,14 +84293,6 @@ function getStructureFromResolvedPos(state2, pos) {
|
|
|
84163
84293
|
return null;
|
|
84164
84294
|
}
|
|
84165
84295
|
}
|
|
84166
|
-
const shouldBypassContextMenu = (event) => {
|
|
84167
|
-
if (!event) return false;
|
|
84168
|
-
if (event.ctrlKey || event.metaKey) {
|
|
84169
|
-
return true;
|
|
84170
|
-
}
|
|
84171
|
-
const isKeyboardInvocation = event.type === "contextmenu" && typeof event.detail === "number" && event.detail === 0 && (event.button === 0 || event.button === void 0) && event.clientX === 0 && event.clientY === 0;
|
|
84172
|
-
return Boolean(isKeyboardInvocation);
|
|
84173
|
-
};
|
|
84174
84296
|
const isModuleEnabled = (editorOptions, moduleName) => {
|
|
84175
84297
|
switch (moduleName) {
|
|
84176
84298
|
case "ai":
|