@harbour-enterprises/superdoc 0.18.0-next.8 → 0.18.0
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-B6aQ9Btm.cjs → PdfViewer-DaCVS3a7.cjs} +1 -1
- package/dist/chunks/{PdfViewer-bV0Nu1AE.es.js → PdfViewer-nEK0Vfg8.es.js} +1 -1
- package/dist/chunks/{index-B4iJqRzO.es.js → index-C5Pduo01.es.js} +3 -3
- package/dist/chunks/{index-DHYO80_n.cjs → index-liKutwiS.cjs} +3 -3
- package/dist/chunks/{super-editor.es-CW3H3ZkZ.es.js → super-editor.es-BJ3WXpls.es.js} +123 -21
- package/dist/chunks/{super-editor.es-CLOaeb5i.cjs → super-editor.es-C6AwTfxt.cjs} +123 -21
- package/dist/core/SuperDoc.d.ts.map +1 -1
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-w8KtZzlN.js → converter-CYyQ8x__.js} +144 -75
- package/dist/super-editor/chunks/{docx-zipper-HBvnt_-z.js → docx-zipper-Bp08RJ7s.js} +1 -1
- package/dist/super-editor/chunks/{editor-C2iCXpca.js → editor-l8pXp1qF.js} +40 -6
- package/dist/super-editor/chunks/{toolbar-BYNEDGz5.js → toolbar-VazJjXhB.js} +2 -2
- package/dist/super-editor/converter.es.js +2 -2
- 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/commands/insertContent.d.ts +4 -4
- package/dist/super-editor/src/core/helpers/contentProcessor.d.ts +13 -0
- package/dist/super-editor/src/core/helpers/htmlSanitizer.d.ts +8 -0
- package/dist/super-editor/src/core/helpers/importHtml.d.ts +3 -2
- package/dist/super-editor/src/core/helpers/importMarkdown.d.ts +2 -1
- package/dist/super-editor/src/core/helpers/index.d.ts +1 -0
- package/dist/super-editor/super-editor.es.js +18 -18
- 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 +124 -22
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/superdoc.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a, E, b, S, d, i, j, n, r, p, q } from "./chunks/super-editor.es-
|
|
2
|
-
import { D, H, P, S as S2, m, l } from "./chunks/index-
|
|
1
|
+
import { a, E, b, S, d, i, j, n, r, p, q } from "./chunks/super-editor.es-BJ3WXpls.es.js";
|
|
2
|
+
import { D, H, P, S as S2, m, l } from "./chunks/index-C5Pduo01.es.js";
|
|
3
3
|
import "./chunks/vue-CXxsqYcP.es.js";
|
|
4
4
|
import "./chunks/jszip-B8KIZSNe.es.js";
|
|
5
5
|
import { B } from "./chunks/blank-docx-iwdyG9RH.es.js";
|
package/dist/superdoc.umd.js
CHANGED
|
@@ -29535,11 +29535,48 @@
|
|
|
29535
29535
|
}
|
|
29536
29536
|
return false;
|
|
29537
29537
|
};
|
|
29538
|
-
function
|
|
29538
|
+
function stripHtmlStyles(html) {
|
|
29539
|
+
if (!html) return "";
|
|
29540
|
+
const parser = new DOMParser();
|
|
29541
|
+
const doc2 = parser.parseFromString(html, "text/html");
|
|
29542
|
+
const SEMANTIC_ATTRS = [
|
|
29543
|
+
"href",
|
|
29544
|
+
"src",
|
|
29545
|
+
"alt",
|
|
29546
|
+
"title",
|
|
29547
|
+
"colspan",
|
|
29548
|
+
"rowspan",
|
|
29549
|
+
"headers",
|
|
29550
|
+
"scope",
|
|
29551
|
+
"lang",
|
|
29552
|
+
"dir",
|
|
29553
|
+
"cite",
|
|
29554
|
+
"start",
|
|
29555
|
+
"type"
|
|
29556
|
+
// for lists
|
|
29557
|
+
];
|
|
29558
|
+
const cleanNode = (node2) => {
|
|
29559
|
+
if (node2.nodeType !== Node.ELEMENT_NODE) return;
|
|
29560
|
+
[...node2.attributes].forEach((attr) => {
|
|
29561
|
+
if (!SEMANTIC_ATTRS.includes(attr.name.toLowerCase())) {
|
|
29562
|
+
node2.removeAttribute(attr.name);
|
|
29563
|
+
}
|
|
29564
|
+
});
|
|
29565
|
+
[...node2.children].forEach(cleanNode);
|
|
29566
|
+
};
|
|
29567
|
+
cleanNode(doc2.body);
|
|
29568
|
+
return doc2.body.innerHTML;
|
|
29569
|
+
}
|
|
29570
|
+
function createDocFromHTML(content, schema, options = {}) {
|
|
29571
|
+
const { isImport = false } = options;
|
|
29539
29572
|
let parsedContent;
|
|
29540
29573
|
if (typeof content === "string") {
|
|
29574
|
+
const cleanHtml = stripHtmlStyles(content);
|
|
29541
29575
|
const tempDiv = document.createElement("div");
|
|
29542
|
-
|
|
29576
|
+
if (isImport) {
|
|
29577
|
+
tempDiv.dataset.superdocImport = "true";
|
|
29578
|
+
}
|
|
29579
|
+
tempDiv.innerHTML = cleanHtml;
|
|
29543
29580
|
parsedContent = tempDiv;
|
|
29544
29581
|
} else {
|
|
29545
29582
|
parsedContent = content;
|
|
@@ -30623,14 +30660,39 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
30623
30660
|
gfm: true
|
|
30624
30661
|
// GitHub Flavored Markdown support
|
|
30625
30662
|
});
|
|
30626
|
-
function createDocFromMarkdown(markdown, schema) {
|
|
30663
|
+
function createDocFromMarkdown(markdown, schema, options = {}) {
|
|
30627
30664
|
const html = convertMarkdownToHTML(markdown);
|
|
30628
|
-
return createDocFromHTML(html, schema);
|
|
30665
|
+
return createDocFromHTML(html, schema, options);
|
|
30629
30666
|
}
|
|
30630
30667
|
function convertMarkdownToHTML(markdown) {
|
|
30631
30668
|
let html = d.parse(markdown, { async: false });
|
|
30632
30669
|
return html.replace(/<\/p>\n<ul>/g, "</p>\n<p> </p>\n<ul>").replace(/<\/p>\n<ol>/g, "</p>\n<p> </p>\n<ol>").replace(/<\/ul>\n<h/g, "</ul>\n<p> </p>\n<h").replace(/<\/ol>\n<h/g, "</ol>\n<p> </p>\n<h");
|
|
30633
30670
|
}
|
|
30671
|
+
function processContent({ content, type: type2, schema }) {
|
|
30672
|
+
let doc2;
|
|
30673
|
+
switch (type2) {
|
|
30674
|
+
case "html":
|
|
30675
|
+
doc2 = createDocFromHTML(content, schema, { isImport: true });
|
|
30676
|
+
break;
|
|
30677
|
+
case "markdown":
|
|
30678
|
+
doc2 = createDocFromMarkdown(content, schema, { isImport: true });
|
|
30679
|
+
break;
|
|
30680
|
+
case "text":
|
|
30681
|
+
const wrapper = document.createElement("div");
|
|
30682
|
+
wrapper.dataset.superdocImport = "true";
|
|
30683
|
+
const para = document.createElement("p");
|
|
30684
|
+
para.textContent = content;
|
|
30685
|
+
wrapper.appendChild(para);
|
|
30686
|
+
doc2 = DOMParser$1.fromSchema(schema).parse(wrapper);
|
|
30687
|
+
break;
|
|
30688
|
+
case "schema":
|
|
30689
|
+
doc2 = schema.nodeFromJSON(content);
|
|
30690
|
+
break;
|
|
30691
|
+
default:
|
|
30692
|
+
throw new Error(`Unknown content type: ${type2}`);
|
|
30693
|
+
}
|
|
30694
|
+
return doc2;
|
|
30695
|
+
}
|
|
30634
30696
|
const helpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
30635
30697
|
__proto__: null,
|
|
30636
30698
|
chainableEditorState,
|
|
@@ -30662,7 +30724,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
30662
30724
|
isMarkActive,
|
|
30663
30725
|
isNodeActive,
|
|
30664
30726
|
isTextSelection,
|
|
30665
|
-
posToDOMRect
|
|
30727
|
+
posToDOMRect,
|
|
30728
|
+
processContent
|
|
30666
30729
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
30667
30730
|
const generateNewListDefinition = ({ numId, listType, level, start: start2, text, fmt, editor }) => {
|
|
30668
30731
|
if (typeof listType === "string") listType = editor.schema.nodes[listType];
|
|
@@ -30732,17 +30795,22 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
30732
30795
|
const { abstract } = ListHelpers.getListDefinitionDetails({ numId, level, listType, editor });
|
|
30733
30796
|
const numbering = editor.converter.numbering;
|
|
30734
30797
|
const newNumbering = { ...numbering };
|
|
30798
|
+
if (!abstract) {
|
|
30799
|
+
ListHelpers.generateNewListDefinition({ numId: newId, listType, editor });
|
|
30800
|
+
return newId;
|
|
30801
|
+
}
|
|
30735
30802
|
const newAbstractId = getNewListId(editor, "abstracts");
|
|
30736
30803
|
const newAbstractDef = {
|
|
30737
30804
|
...abstract,
|
|
30738
30805
|
attributes: {
|
|
30739
|
-
...abstract.attributes,
|
|
30806
|
+
...abstract.attributes || {},
|
|
30740
30807
|
"w:abstractNumId": String(newAbstractId)
|
|
30741
30808
|
}
|
|
30742
30809
|
};
|
|
30743
30810
|
newNumbering.abstracts[newAbstractId] = newAbstractDef;
|
|
30744
30811
|
const newNumDef = getBasicNumIdTag(newId, newAbstractId);
|
|
30745
30812
|
newNumbering.definitions[newId] = newNumDef;
|
|
30813
|
+
editor.converter.numbering = newNumbering;
|
|
30746
30814
|
return newId;
|
|
30747
30815
|
};
|
|
30748
30816
|
const getBasicNumIdTag = (numId, abstractId) => {
|
|
@@ -38367,7 +38435,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
38367
38435
|
return;
|
|
38368
38436
|
}
|
|
38369
38437
|
}
|
|
38370
|
-
static updateDocumentVersion(docx = this.convertedXml, version2 = "0.17.
|
|
38438
|
+
static updateDocumentVersion(docx = this.convertedXml, version2 = "0.17.3") {
|
|
38371
38439
|
const customLocation = "docProps/custom.xml";
|
|
38372
38440
|
if (!docx[customLocation]) {
|
|
38373
38441
|
docx[customLocation] = generateCustomXml();
|
|
@@ -38849,7 +38917,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
38849
38917
|
function generateCustomXml() {
|
|
38850
38918
|
return DEFAULT_CUSTOM_XML;
|
|
38851
38919
|
}
|
|
38852
|
-
function generateSuperdocVersion(pid = 2, version2 = "0.17.
|
|
38920
|
+
function generateSuperdocVersion(pid = 2, version2 = "0.17.3") {
|
|
38853
38921
|
return {
|
|
38854
38922
|
type: "element",
|
|
38855
38923
|
name: "property",
|
|
@@ -43327,7 +43395,30 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
43327
43395
|
const selectNodeForward = () => ({ state: state2, dispatch }) => selectNodeForward$1(state2, dispatch);
|
|
43328
43396
|
const selectTextblockStart = () => ({ state: state2, dispatch }) => selectTextblockStart$1(state2, dispatch);
|
|
43329
43397
|
const selectTextblockEnd = () => ({ state: state2, dispatch }) => selectTextblockEnd$1(state2, dispatch);
|
|
43330
|
-
const insertContent = (value, options) => ({ tr, commands: commands2 }) => {
|
|
43398
|
+
const insertContent = (value, options = {}) => ({ tr, state: state2, commands: commands2, editor }) => {
|
|
43399
|
+
if (options.contentType) {
|
|
43400
|
+
const validTypes = ["html", "markdown", "text", "schema"];
|
|
43401
|
+
if (!validTypes.includes(options.contentType)) {
|
|
43402
|
+
console.error(`[insertContent] Invalid contentType: "${options.contentType}". Use: ${validTypes.join(", ")}`);
|
|
43403
|
+
return false;
|
|
43404
|
+
}
|
|
43405
|
+
try {
|
|
43406
|
+
const processedDoc = processContent({
|
|
43407
|
+
content: value,
|
|
43408
|
+
type: options.contentType,
|
|
43409
|
+
schema: state2.schema
|
|
43410
|
+
});
|
|
43411
|
+
const jsonContent = processedDoc.toJSON();
|
|
43412
|
+
const ok = commands2.insertContentAt({ from: tr.selection.from, to: tr.selection.to }, jsonContent, options);
|
|
43413
|
+
if (ok && (options.contentType === "html" || options.contentType === "markdown")) {
|
|
43414
|
+
Promise.resolve().then(() => editor.migrateListsToV2?.());
|
|
43415
|
+
}
|
|
43416
|
+
return ok;
|
|
43417
|
+
} catch (error) {
|
|
43418
|
+
console.error(`[insertContent] Failed to process ${options.contentType}:`, error);
|
|
43419
|
+
return false;
|
|
43420
|
+
}
|
|
43421
|
+
}
|
|
43331
43422
|
return commands2.insertContentAt({ from: tr.selection.from, to: tr.selection.to }, value, options);
|
|
43332
43423
|
};
|
|
43333
43424
|
const removeWhitespaces = (node2) => {
|
|
@@ -55728,7 +55819,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
55728
55819
|
* @returns {Object | void} Migration results
|
|
55729
55820
|
*/
|
|
55730
55821
|
processCollaborationMigrations() {
|
|
55731
|
-
console.debug("[checkVersionMigrations] Current editor version", "0.17.
|
|
55822
|
+
console.debug("[checkVersionMigrations] Current editor version", "0.17.3");
|
|
55732
55823
|
if (!this.options.ydoc) return;
|
|
55733
55824
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
55734
55825
|
let docVersion = metaMap.get("version");
|
|
@@ -56085,8 +56176,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
56085
56176
|
doc2 = createDocument(this.converter, this.schema, this);
|
|
56086
56177
|
doc2 = __privateMethod$1(this, _Editor_instances, prepareDocumentForImport_fn).call(this, doc2);
|
|
56087
56178
|
if (this.options.markdown) {
|
|
56088
|
-
doc2 = createDocFromMarkdown(this.options.markdown, this.schema);
|
|
56089
|
-
} else if (this.options.html) doc2 = createDocFromHTML(this.options.html, this.schema);
|
|
56179
|
+
doc2 = createDocFromMarkdown(this.options.markdown, this.schema, { isImport: true });
|
|
56180
|
+
} else if (this.options.html) doc2 = createDocFromHTML(this.options.html, this.schema, { isImport: true });
|
|
56090
56181
|
else if (this.options.jsonOverride) doc2 = this.schema.nodeFromJSON(this.options.jsonOverride);
|
|
56091
56182
|
if (fragment) doc2 = yXmlFragmentToProseMirrorRootNode(fragment, this.schema);
|
|
56092
56183
|
}
|
|
@@ -59406,6 +59497,17 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
59406
59497
|
rsidDel: { rendered: false },
|
|
59407
59498
|
spacing: {
|
|
59408
59499
|
default: getDefaultSpacing(),
|
|
59500
|
+
parseDOM: (element) => {
|
|
59501
|
+
if (element && element.closest("[data-superdoc-import]")) {
|
|
59502
|
+
return {
|
|
59503
|
+
lineSpaceAfter: 11,
|
|
59504
|
+
lineSpaceBefore: 0,
|
|
59505
|
+
line: 1.15,
|
|
59506
|
+
lineRule: "auto"
|
|
59507
|
+
};
|
|
59508
|
+
}
|
|
59509
|
+
return void 0;
|
|
59510
|
+
},
|
|
59409
59511
|
renderDOM: (attrs) => {
|
|
59410
59512
|
const { spacing } = attrs;
|
|
59411
59513
|
if (!spacing) return {};
|
|
@@ -84157,7 +84259,7 @@ ${style2}
|
|
|
84157
84259
|
if (listeners.fn) return 1;
|
|
84158
84260
|
return listeners.length;
|
|
84159
84261
|
};
|
|
84160
|
-
EventEmitter2.prototype.emit = function emit2(event,
|
|
84262
|
+
EventEmitter2.prototype.emit = function emit2(event, a1, a22, a3, a4, a52) {
|
|
84161
84263
|
var evt = prefix2 ? prefix2 + event : event;
|
|
84162
84264
|
if (!this._events[evt]) return false;
|
|
84163
84265
|
var listeners = this._events[evt], len2 = arguments.length, args, i2;
|
|
@@ -84167,15 +84269,15 @@ ${style2}
|
|
|
84167
84269
|
case 1:
|
|
84168
84270
|
return listeners.fn.call(listeners.context), true;
|
|
84169
84271
|
case 2:
|
|
84170
|
-
return listeners.fn.call(listeners.context,
|
|
84272
|
+
return listeners.fn.call(listeners.context, a1), true;
|
|
84171
84273
|
case 3:
|
|
84172
|
-
return listeners.fn.call(listeners.context,
|
|
84274
|
+
return listeners.fn.call(listeners.context, a1, a22), true;
|
|
84173
84275
|
case 4:
|
|
84174
|
-
return listeners.fn.call(listeners.context,
|
|
84276
|
+
return listeners.fn.call(listeners.context, a1, a22, a3), true;
|
|
84175
84277
|
case 5:
|
|
84176
|
-
return listeners.fn.call(listeners.context,
|
|
84278
|
+
return listeners.fn.call(listeners.context, a1, a22, a3, a4), true;
|
|
84177
84279
|
case 6:
|
|
84178
|
-
return listeners.fn.call(listeners.context,
|
|
84280
|
+
return listeners.fn.call(listeners.context, a1, a22, a3, a4, a52), true;
|
|
84179
84281
|
}
|
|
84180
84282
|
for (i2 = 1, args = new Array(len2 - 1); i2 < len2; i2++) {
|
|
84181
84283
|
args[i2 - 1] = arguments[i2];
|
|
@@ -84190,13 +84292,13 @@ ${style2}
|
|
|
84190
84292
|
listeners[i2].fn.call(listeners[i2].context);
|
|
84191
84293
|
break;
|
|
84192
84294
|
case 2:
|
|
84193
|
-
listeners[i2].fn.call(listeners[i2].context,
|
|
84295
|
+
listeners[i2].fn.call(listeners[i2].context, a1);
|
|
84194
84296
|
break;
|
|
84195
84297
|
case 3:
|
|
84196
|
-
listeners[i2].fn.call(listeners[i2].context,
|
|
84298
|
+
listeners[i2].fn.call(listeners[i2].context, a1, a22);
|
|
84197
84299
|
break;
|
|
84198
84300
|
case 4:
|
|
84199
|
-
listeners[i2].fn.call(listeners[i2].context,
|
|
84301
|
+
listeners[i2].fn.call(listeners[i2].context, a1, a22, a3);
|
|
84200
84302
|
break;
|
|
84201
84303
|
default:
|
|
84202
84304
|
if (!args) for (j2 = 1, args = new Array(len2 - 1); j2 < len2; j2++) {
|
|
@@ -105777,7 +105879,7 @@ ${style2}
|
|
|
105777
105879
|
this.config.colors = shuffleArray(this.config.colors);
|
|
105778
105880
|
this.userColorMap = /* @__PURE__ */ new Map();
|
|
105779
105881
|
this.colorIndex = 0;
|
|
105780
|
-
this.version = "0.17.
|
|
105882
|
+
this.version = "0.17.3";
|
|
105781
105883
|
this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
|
|
105782
105884
|
this.superdocId = config2.superdocId || v4();
|
|
105783
105885
|
this.colors = this.config.colors;
|