@harbour-enterprises/superdoc 0.20.0-next.4 → 0.20.0-next.6
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-Ne_-LxpG.cjs → PdfViewer--YKlzafo.cjs} +1 -1
- package/dist/chunks/{PdfViewer-BjZBgs8x.es.js → PdfViewer-CuiUv0d5.es.js} +1 -1
- package/dist/chunks/{index-BVjAJUtV.es.js → index-Cl1u_lKk.es.js} +2 -2
- package/dist/chunks/{index-OFvCtpf7.cjs → index-CuHtS7O9.cjs} +2 -2
- package/dist/chunks/{super-editor.es-CCU9etUT.cjs → super-editor.es-BIW7iKAk.cjs} +1792 -1307
- package/dist/chunks/{super-editor.es-DgTNVbvS.es.js → super-editor.es-DN4v75aq.es.js} +1792 -1307
- 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-BPTfSIJf.js → converter-kutpjDQU.js} +687 -470
- package/dist/super-editor/chunks/{docx-zipper-ikgI-2vM.js → docx-zipper-BjcI24VU.js} +1 -1
- package/dist/super-editor/chunks/{editor-C1C_smD4.js → editor-ps-v4FlA.js} +687 -434
- package/dist/super-editor/chunks/{toolbar-pP4CmNcz.js → toolbar-Ch271j8X.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/v2/importer/tableImporter.d.ts +0 -22
- package/dist/super-editor/src/core/super-converter/v3/handlers/utils.d.ts +10 -3
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bidiVisual/bidiVisual-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bidiVisual/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bottom/bottom-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bottom/index.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/bottom/marginBottom-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/end/end-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/end/index.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/end/marginEnd-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/gridCol/gridCol-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/gridCol/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/insideH/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/insideH/insideH-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/insideV/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/insideV/insideV-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/left/index.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/left/left-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/left/marginLeft-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/right/index.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/right/marginRight-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/right/right-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/shd/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/shd/shd-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/start/index.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/start/marginStart-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/start/start-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tbl/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tbl/tbl-translator.d.ts +28 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblBorders/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblBorders/tblBorders-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblCaption/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblCaption/tblCaption-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblCellMar/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblCellMar/tblCellMar-translator.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblDescription/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblDescription/tblDescription-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblGrid/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblGrid/tblGrid-translator.d.ts +5 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblInd/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblInd/tblInd-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblLayout/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblLayout/tblLayout-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblLook/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblLook/tblLook-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblOverlap/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblOverlap/tblOverlap-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblPr/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblPr/tblPr-translator.d.ts +5 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyle/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyle/tblStyle-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyleColBandSize/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyleColBandSize/tblStyleColBandSize-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyleRowBandSize/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblStyleRowBandSize/tblStyleRowBandSize-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblW/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblW/tblW-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblpPr/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblpPr/tblpPr-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tc/helpers/legacy-handle-table-cell-node.d.ts +1 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/top/index.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/top/marginTop-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/top/top-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/node-translator/node-translator.d.ts +3 -1
- package/dist/super-editor/src/extensions/image/imageHelpers/handleBase64.d.ts +1 -0
- package/dist/super-editor/src/extensions/image/imageHelpers/handleUrl.d.ts +2 -0
- package/dist/super-editor/src/extensions/image/imageHelpers/imageRegistrationPlugin.d.ts +11 -0
- package/dist/super-editor/src/extensions/image/imageHelpers/index.d.ts +1 -1
- package/dist/super-editor/src/extensions/image/imageHelpers/processUploadedImage.d.ts +2 -2
- package/dist/super-editor/src/extensions/image/imageHelpers/startImageUpload.d.ts +18 -23
- package/dist/super-editor/src/extensions/table/table.d.ts +330 -0
- package/dist/super-editor/super-editor.es.js +65 -50
- 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 +2420 -1935
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/super-editor/src/extensions/image/imageHelpers/imagePlaceholderPlugin.d.ts +0 -5
|
@@ -2,8 +2,8 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __typeError = (msg) => {
|
|
3
3
|
throw TypeError(msg);
|
|
4
4
|
};
|
|
5
|
-
var __defNormalProp = (obj,
|
|
6
|
-
var __publicField = (obj,
|
|
5
|
+
var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
|
|
6
|
+
var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
|
|
7
7
|
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
8
8
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
9
9
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
@@ -12,9 +12,9 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
12
12
|
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, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, registerPluginByNameIfNotExists_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _ListItemNodeView_instances, init_fn2, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn, _DocumentSectionView_instances, init_fn3, addToolTip_fn;
|
|
13
13
|
import * as Y from "yjs";
|
|
14
14
|
import { UndoManager, Item as Item$1, ContentType, Text as Text$1, XmlElement, encodeStateAsUpdate } from "yjs";
|
|
15
|
-
import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as ReplaceStep, E as NodeRange, G as findWrapping, L as ListHelpers, H as findParentNode, I as isMacOS, J as isIOS, K as getSchemaTypeByName, O as inputRulesPlugin, Q as TrackDeleteMarkName, U as TrackInsertMarkName, V as v4, W as TrackFormatMarkName, X as comments_module_events, Y as findMark, Z as objectIncludes, _ as AddMarkStep, $ as RemoveMarkStep, a0 as twipsToLines, a1 as pixelsToTwips, a2 as helpers, a3 as posToDOMRect, a4 as CommandService, a5 as SuperConverter, a6 as createDocument, a7 as createDocFromMarkdown, a8 as createDocFromHTML, a9 as EditorState, aa as hasSomeParentWithClass, ab as isActive, ac as unflattenListsInHtml, ad as parseSizeUnit, ae as minMax, af as getLineHeightValueString, ag as InputRule, ah as kebabCase, ai as findParentNodeClosestToPos, aj as getListItemStyleDefinitions, ak as docxNumberigHelpers, al as parseIndentElement, am as combineIndents, an as StepMap, ao as
|
|
15
|
+
import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as ReplaceStep, E as NodeRange, G as findWrapping, L as ListHelpers, H as findParentNode, I as isMacOS, J as isIOS, K as getSchemaTypeByName, O as inputRulesPlugin, Q as TrackDeleteMarkName, U as TrackInsertMarkName, V as v4, W as TrackFormatMarkName, X as comments_module_events, Y as findMark, Z as objectIncludes, _ as AddMarkStep, $ as RemoveMarkStep, a0 as twipsToLines, a1 as pixelsToTwips, a2 as helpers, a3 as posToDOMRect, a4 as CommandService, a5 as SuperConverter, a6 as createDocument, a7 as createDocFromMarkdown, a8 as createDocFromHTML, a9 as EditorState, aa as hasSomeParentWithClass, ab as isActive, ac as unflattenListsInHtml, ad as parseSizeUnit, ae as minMax, af as getLineHeightValueString, ag as InputRule, ah as kebabCase, ai as findParentNodeClosestToPos, aj as getListItemStyleDefinitions, ak as docxNumberigHelpers, al as parseIndentElement, am as combineIndents, an as StepMap, ao as SelectionRange, ap as Transform, aq as isInTable$1, ar as generateDocxRandomId, as as insertNewRelationship, at as updateDOMAttributes, au as htmlHandler } from "./converter-kutpjDQU.js";
|
|
16
16
|
import { ref, computed, createElementBlock, openBlock, withModifiers, Fragment as Fragment$1, renderList, normalizeClass, createCommentVNode, toDisplayString, createElementVNode, createApp } from "vue";
|
|
17
|
-
import { D as DocxZipper } from "./docx-zipper-
|
|
17
|
+
import { D as DocxZipper } from "./docx-zipper-BjcI24VU.js";
|
|
18
18
|
var GOOD_LEAF_SIZE = 200;
|
|
19
19
|
var RopeSequence = function RopeSequence2() {
|
|
20
20
|
};
|
|
@@ -662,11 +662,11 @@ function hasBlockDesc(dom) {
|
|
|
662
662
|
const selectionCollapsed = function(domSel) {
|
|
663
663
|
return domSel.focusNode && isEquivalentPosition(domSel.focusNode, domSel.focusOffset, domSel.anchorNode, domSel.anchorOffset);
|
|
664
664
|
};
|
|
665
|
-
function keyEvent(keyCode,
|
|
665
|
+
function keyEvent(keyCode, key2) {
|
|
666
666
|
let event = document.createEvent("Event");
|
|
667
667
|
event.initEvent("keydown", true, true);
|
|
668
668
|
event.keyCode = keyCode;
|
|
669
|
-
event.key = event.code =
|
|
669
|
+
event.key = event.code = key2;
|
|
670
670
|
return event;
|
|
671
671
|
}
|
|
672
672
|
function deepActiveElement(doc2) {
|
|
@@ -5914,9 +5914,9 @@ const writeAny = (encoder, data) => {
|
|
|
5914
5914
|
const keys2 = Object.keys(data);
|
|
5915
5915
|
writeVarUint(encoder, keys2.length);
|
|
5916
5916
|
for (let i = 0; i < keys2.length; i++) {
|
|
5917
|
-
const
|
|
5918
|
-
writeVarString(encoder,
|
|
5919
|
-
writeAny(encoder, data[
|
|
5917
|
+
const key2 = keys2[i];
|
|
5918
|
+
writeVarString(encoder, key2);
|
|
5919
|
+
writeAny(encoder, data[key2]);
|
|
5920
5920
|
}
|
|
5921
5921
|
}
|
|
5922
5922
|
break;
|
|
@@ -5935,17 +5935,17 @@ const unexpectedCase = () => {
|
|
|
5935
5935
|
throw create$1("Unexpected case");
|
|
5936
5936
|
};
|
|
5937
5937
|
const create = () => /* @__PURE__ */ new Map();
|
|
5938
|
-
const setIfUndefined = (map2,
|
|
5939
|
-
let set = map2.get(
|
|
5938
|
+
const setIfUndefined = (map2, key2, createT) => {
|
|
5939
|
+
let set = map2.get(key2);
|
|
5940
5940
|
if (set === void 0) {
|
|
5941
|
-
map2.set(
|
|
5941
|
+
map2.set(key2, set = createT());
|
|
5942
5942
|
}
|
|
5943
5943
|
return set;
|
|
5944
5944
|
};
|
|
5945
5945
|
const keys = Object.keys;
|
|
5946
5946
|
const every = (obj, f) => {
|
|
5947
|
-
for (const
|
|
5948
|
-
if (!f(obj[
|
|
5947
|
+
for (const key2 in obj) {
|
|
5948
|
+
if (!f(obj[key2], key2)) {
|
|
5949
5949
|
return false;
|
|
5950
5950
|
}
|
|
5951
5951
|
}
|
|
@@ -6001,14 +6001,14 @@ class VarStoragePolyfill {
|
|
|
6001
6001
|
* @param {string} key
|
|
6002
6002
|
* @param {any} newValue
|
|
6003
6003
|
*/
|
|
6004
|
-
setItem(
|
|
6005
|
-
this.map.set(
|
|
6004
|
+
setItem(key2, newValue) {
|
|
6005
|
+
this.map.set(key2, newValue);
|
|
6006
6006
|
}
|
|
6007
6007
|
/**
|
|
6008
6008
|
* @param {string} key
|
|
6009
6009
|
*/
|
|
6010
|
-
getItem(
|
|
6011
|
-
return this.map.get(
|
|
6010
|
+
getItem(key2) {
|
|
6011
|
+
return this.map.get(key2);
|
|
6012
6012
|
}
|
|
6013
6013
|
}
|
|
6014
6014
|
let _localStorage = new VarStoragePolyfill();
|
|
@@ -6051,9 +6051,9 @@ const computeParams = () => {
|
|
|
6051
6051
|
params = create();
|
|
6052
6052
|
(location.search || "?").slice(1).split("&").forEach((kv) => {
|
|
6053
6053
|
if (kv.length !== 0) {
|
|
6054
|
-
const [
|
|
6055
|
-
params.set(`--${fromCamelCase(
|
|
6056
|
-
params.set(`-${fromCamelCase(
|
|
6054
|
+
const [key2, value] = kv.split("=");
|
|
6055
|
+
params.set(`--${fromCamelCase(key2, "-")}`, value);
|
|
6056
|
+
params.set(`-${fromCamelCase(key2, "-")}`, value);
|
|
6057
6057
|
}
|
|
6058
6058
|
});
|
|
6059
6059
|
} else {
|
|
@@ -6336,8 +6336,8 @@ const ySyncPlugin = (yXmlFragment, {
|
|
|
6336
6336
|
const change = tr.getMeta(ySyncPluginKey);
|
|
6337
6337
|
if (change !== void 0) {
|
|
6338
6338
|
pluginState = Object.assign({}, pluginState);
|
|
6339
|
-
for (const
|
|
6340
|
-
pluginState[
|
|
6339
|
+
for (const key2 in change) {
|
|
6340
|
+
pluginState[key2] = change[key2];
|
|
6341
6341
|
}
|
|
6342
6342
|
}
|
|
6343
6343
|
pluginState.addToHistory = tr.getMeta("addToHistory") !== false;
|
|
@@ -6609,7 +6609,7 @@ class ProsemirrorBinding {
|
|
|
6609
6609
|
snapshot = Y.snapshot(historyDoc);
|
|
6610
6610
|
if (historyType._item === null) {
|
|
6611
6611
|
const rootKey = Array.from(this.doc.share.keys()).find(
|
|
6612
|
-
(
|
|
6612
|
+
(key2) => this.doc.share.get(key2) === this.type
|
|
6613
6613
|
);
|
|
6614
6614
|
historyType = historyDoc.getXmlFragment(rootKey);
|
|
6615
6615
|
} else {
|
|
@@ -6898,10 +6898,10 @@ const createTypeFromTextNodes = (nodes, meta) => {
|
|
|
6898
6898
|
};
|
|
6899
6899
|
const createTypeFromElementNode = (node, meta) => {
|
|
6900
6900
|
const type = new Y.XmlElement(node.type.name);
|
|
6901
|
-
for (const
|
|
6902
|
-
const val = node.attrs[
|
|
6903
|
-
if (val !== null &&
|
|
6904
|
-
type.setAttribute(
|
|
6901
|
+
for (const key2 in node.attrs) {
|
|
6902
|
+
const val = node.attrs[key2];
|
|
6903
|
+
if (val !== null && key2 !== "ychange") {
|
|
6904
|
+
type.setAttribute(key2, val);
|
|
6905
6905
|
}
|
|
6906
6906
|
}
|
|
6907
6907
|
type.insert(
|
|
@@ -6916,13 +6916,13 @@ const createTypeFromElementNode = (node, meta) => {
|
|
|
6916
6916
|
const createTypeFromTextOrElementNode = (node, meta) => node instanceof Array ? createTypeFromTextNodes(node, meta) : createTypeFromElementNode(node, meta);
|
|
6917
6917
|
const isObject = (val) => typeof val === "object" && val !== null;
|
|
6918
6918
|
const equalAttrs = (pattrs, yattrs) => {
|
|
6919
|
-
const keys2 = Object.keys(pattrs).filter((
|
|
6920
|
-
let eq = keys2.length === (yattrs == null ? 0 : Object.keys(yattrs).filter((
|
|
6919
|
+
const keys2 = Object.keys(pattrs).filter((key2) => pattrs[key2] !== null);
|
|
6920
|
+
let eq = keys2.length === (yattrs == null ? 0 : Object.keys(yattrs).filter((key2) => yattrs[key2] !== null).length);
|
|
6921
6921
|
for (let i = 0; i < keys2.length && eq; i++) {
|
|
6922
|
-
const
|
|
6923
|
-
const l = pattrs[
|
|
6924
|
-
const r2 = yattrs[
|
|
6925
|
-
eq =
|
|
6922
|
+
const key2 = keys2[i];
|
|
6923
|
+
const l = pattrs[key2];
|
|
6924
|
+
const r2 = yattrs[key2];
|
|
6925
|
+
eq = key2 === "ychange" || l === r2 || isObject(l) && isObject(r2) && equalAttrs(l, r2);
|
|
6926
6926
|
}
|
|
6927
6927
|
return eq;
|
|
6928
6928
|
};
|
|
@@ -7069,18 +7069,18 @@ const updateYFragment = (y, yDomFragment, pNode, meta) => {
|
|
|
7069
7069
|
if (yDomFragment instanceof Y.XmlElement) {
|
|
7070
7070
|
const yDomAttrs = yDomFragment.getAttributes();
|
|
7071
7071
|
const pAttrs = pNode.attrs;
|
|
7072
|
-
for (const
|
|
7073
|
-
if (pAttrs[
|
|
7074
|
-
if (yDomAttrs[
|
|
7075
|
-
yDomFragment.setAttribute(
|
|
7072
|
+
for (const key2 in pAttrs) {
|
|
7073
|
+
if (pAttrs[key2] !== null) {
|
|
7074
|
+
if (yDomAttrs[key2] !== pAttrs[key2] && key2 !== "ychange") {
|
|
7075
|
+
yDomFragment.setAttribute(key2, pAttrs[key2]);
|
|
7076
7076
|
}
|
|
7077
7077
|
} else {
|
|
7078
|
-
yDomFragment.removeAttribute(
|
|
7078
|
+
yDomFragment.removeAttribute(key2);
|
|
7079
7079
|
}
|
|
7080
7080
|
}
|
|
7081
|
-
for (const
|
|
7082
|
-
if (pAttrs[
|
|
7083
|
-
yDomFragment.removeAttribute(
|
|
7081
|
+
for (const key2 in yDomAttrs) {
|
|
7082
|
+
if (pAttrs[key2] === void 0) {
|
|
7083
|
+
yDomFragment.removeAttribute(key2);
|
|
7084
7084
|
}
|
|
7085
7085
|
}
|
|
7086
7086
|
}
|
|
@@ -7211,19 +7211,19 @@ const updateMetas = () => {
|
|
|
7211
7211
|
const tr = view.state.tr;
|
|
7212
7212
|
const syncState = ySyncPluginKey.getState(view.state);
|
|
7213
7213
|
if (syncState && syncState.binding && !syncState.binding.isDestroyed) {
|
|
7214
|
-
metas.forEach((val,
|
|
7215
|
-
tr.setMeta(
|
|
7214
|
+
metas.forEach((val, key2) => {
|
|
7215
|
+
tr.setMeta(key2, val);
|
|
7216
7216
|
});
|
|
7217
7217
|
view.dispatch(tr);
|
|
7218
7218
|
}
|
|
7219
7219
|
});
|
|
7220
7220
|
};
|
|
7221
|
-
const setMeta$1 = (view,
|
|
7221
|
+
const setMeta$1 = (view, key2, value) => {
|
|
7222
7222
|
if (!viewsToUpdate) {
|
|
7223
7223
|
viewsToUpdate = /* @__PURE__ */ new Map();
|
|
7224
7224
|
timeout(0, updateMetas);
|
|
7225
7225
|
}
|
|
7226
|
-
setIfUndefined(viewsToUpdate, view, create).set(
|
|
7226
|
+
setIfUndefined(viewsToUpdate, view, create).set(key2, value);
|
|
7227
7227
|
};
|
|
7228
7228
|
const absolutePositionToRelativePosition = (pos, type, mapping) => {
|
|
7229
7229
|
if (pos === 0) {
|
|
@@ -7923,21 +7923,21 @@ class Attribute {
|
|
|
7923
7923
|
let attrs = {};
|
|
7924
7924
|
for (const item of items) {
|
|
7925
7925
|
const mergedAttributes = { ...attrs };
|
|
7926
|
-
for (const [
|
|
7927
|
-
const exists = mergedAttributes[
|
|
7926
|
+
for (const [key2, value] of Object.entries(item)) {
|
|
7927
|
+
const exists = mergedAttributes[key2];
|
|
7928
7928
|
if (!exists) {
|
|
7929
|
-
mergedAttributes[
|
|
7929
|
+
mergedAttributes[key2] = value;
|
|
7930
7930
|
continue;
|
|
7931
7931
|
}
|
|
7932
|
-
if (
|
|
7932
|
+
if (key2 === "class") {
|
|
7933
7933
|
const valueClasses = value ? value.split(" ") : [];
|
|
7934
|
-
const existingClasses = mergedAttributes[
|
|
7934
|
+
const existingClasses = mergedAttributes[key2] ? mergedAttributes[key2].split(" ") : [];
|
|
7935
7935
|
const insertClasses = valueClasses.filter((value2) => !existingClasses.includes(value2));
|
|
7936
|
-
mergedAttributes[
|
|
7937
|
-
} else if (
|
|
7938
|
-
mergedAttributes[
|
|
7936
|
+
mergedAttributes[key2] = [...existingClasses, ...insertClasses].join(" ");
|
|
7937
|
+
} else if (key2 === "style") {
|
|
7938
|
+
mergedAttributes[key2] = [mergedAttributes[key2], value].join("; ");
|
|
7939
7939
|
} else {
|
|
7940
|
-
mergedAttributes[
|
|
7940
|
+
mergedAttributes[key2] = value;
|
|
7941
7941
|
}
|
|
7942
7942
|
}
|
|
7943
7943
|
attrs = mergedAttributes;
|
|
@@ -8247,8 +8247,8 @@ const insertTabNode = () => ({ tr, state, dispatch }) => {
|
|
|
8247
8247
|
if (dispatch) dispatch(tr);
|
|
8248
8248
|
return true;
|
|
8249
8249
|
};
|
|
8250
|
-
const setMeta = (
|
|
8251
|
-
tr.setMeta(
|
|
8250
|
+
const setMeta = (key2, value) => ({ tr }) => {
|
|
8251
|
+
tr.setMeta(key2, value);
|
|
8252
8252
|
return true;
|
|
8253
8253
|
};
|
|
8254
8254
|
const ensureMarks = (state, splittableMarks) => {
|
|
@@ -11376,14 +11376,14 @@ const updateYdocDocxData = async (editor, ydoc) => {
|
|
|
11376
11376
|
const metaMap = ydoc.getMap("meta");
|
|
11377
11377
|
const docx = [...metaMap.get("docx")];
|
|
11378
11378
|
const newXml = await editor.exportDocx({ getUpdatedDocs: true });
|
|
11379
|
-
Object.keys(newXml).forEach((
|
|
11380
|
-
const fileIndex = docx.findIndex((item) => item.name ===
|
|
11379
|
+
Object.keys(newXml).forEach((key2) => {
|
|
11380
|
+
const fileIndex = docx.findIndex((item) => item.name === key2);
|
|
11381
11381
|
if (fileIndex > -1) {
|
|
11382
11382
|
docx.splice(fileIndex, 1);
|
|
11383
11383
|
}
|
|
11384
11384
|
docx.push({
|
|
11385
|
-
name:
|
|
11386
|
-
content: newXml[
|
|
11385
|
+
name: key2,
|
|
11386
|
+
content: newXml[key2]
|
|
11387
11387
|
});
|
|
11388
11388
|
});
|
|
11389
11389
|
ydoc.transact(
|
|
@@ -11399,8 +11399,8 @@ const initPaginationData = async (editor) => {
|
|
|
11399
11399
|
const sectionData = { headers: {}, footers: {} };
|
|
11400
11400
|
const headerIds = editor.converter.headerIds.ids;
|
|
11401
11401
|
const footerIds = editor.converter.footerIds.ids;
|
|
11402
|
-
for (let
|
|
11403
|
-
const sectionId = headerIds[
|
|
11402
|
+
for (let key2 in headerIds) {
|
|
11403
|
+
const sectionId = headerIds[key2];
|
|
11404
11404
|
if (!sectionId) continue;
|
|
11405
11405
|
const dataForThisSection = editor.converter.headers[sectionId];
|
|
11406
11406
|
if (!sectionData.headers[sectionId]) sectionData.headers[sectionId] = {};
|
|
@@ -11410,8 +11410,8 @@ const initPaginationData = async (editor) => {
|
|
|
11410
11410
|
sectionData.headers[sectionId].sectionEditor = sectionEditor;
|
|
11411
11411
|
sectionData.headers[sectionId].sectionContainer = sectionContainer;
|
|
11412
11412
|
}
|
|
11413
|
-
for (let
|
|
11414
|
-
const sectionId = footerIds[
|
|
11413
|
+
for (let key2 in footerIds) {
|
|
11414
|
+
const sectionId = footerIds[key2];
|
|
11415
11415
|
if (!sectionId) continue;
|
|
11416
11416
|
const dataForThisSection = editor.converter.footers[sectionId];
|
|
11417
11417
|
if (!sectionData.headers[sectionId]) sectionData.footers[sectionId] = {};
|
|
@@ -12480,16 +12480,16 @@ const generateTableIfNecessary = ({ tableNode, annotationValues, tr, state }) =>
|
|
|
12480
12480
|
if (rowsToGenerate <= 1) return;
|
|
12481
12481
|
const validateAttributes = (attrs) => {
|
|
12482
12482
|
const cleaned = {};
|
|
12483
|
-
for (const [
|
|
12483
|
+
for (const [key2, value] of Object.entries(attrs)) {
|
|
12484
12484
|
if (value !== void 0 && value !== null) {
|
|
12485
|
-
if (
|
|
12486
|
-
cleaned[
|
|
12487
|
-
} else if (
|
|
12488
|
-
cleaned[
|
|
12485
|
+
if (key2 === "displayLabel") {
|
|
12486
|
+
cleaned[key2] = String(value);
|
|
12487
|
+
} else if (key2 === "rawHtml" || key2 === "linkUrl" || key2 === "imageSrc") {
|
|
12488
|
+
cleaned[key2] = String(value);
|
|
12489
12489
|
} else if (typeof value === "string" && value.length > 0) {
|
|
12490
|
-
cleaned[
|
|
12490
|
+
cleaned[key2] = value;
|
|
12491
12491
|
} else if (typeof value !== "string") {
|
|
12492
|
-
cleaned[
|
|
12492
|
+
cleaned[key2] = value;
|
|
12493
12493
|
}
|
|
12494
12494
|
}
|
|
12495
12495
|
}
|
|
@@ -12767,10 +12767,10 @@ const Collaboration = Extension.create({
|
|
|
12767
12767
|
this.options.fragment = fragment;
|
|
12768
12768
|
const metaMap = this.options.ydoc.getMap("media");
|
|
12769
12769
|
metaMap.observe((event) => {
|
|
12770
|
-
event.changes.keys.forEach((_,
|
|
12771
|
-
if (!(
|
|
12772
|
-
const fileData = metaMap.get(
|
|
12773
|
-
this.editor.storage.image.media[
|
|
12770
|
+
event.changes.keys.forEach((_, key2) => {
|
|
12771
|
+
if (!(key2 in this.editor.storage.image.media)) {
|
|
12772
|
+
const fileData = metaMap.get(key2);
|
|
12773
|
+
this.editor.storage.image.media[key2] = fileData;
|
|
12774
12774
|
}
|
|
12775
12775
|
});
|
|
12776
12776
|
});
|
|
@@ -12790,8 +12790,8 @@ const initializeMetaMap = (ydoc, editor) => {
|
|
|
12790
12790
|
metaMap.set("docx", editor.options.content);
|
|
12791
12791
|
metaMap.set("fonts", editor.options.fonts);
|
|
12792
12792
|
const mediaMap = ydoc.getMap("media");
|
|
12793
|
-
Object.entries(editor.options.mediaFiles).forEach(([
|
|
12794
|
-
mediaMap.set(
|
|
12793
|
+
Object.entries(editor.options.mediaFiles).forEach(([key2, value]) => {
|
|
12794
|
+
mediaMap.set(key2, value);
|
|
12795
12795
|
});
|
|
12796
12796
|
};
|
|
12797
12797
|
const checkDocxChanged = (transaction) => {
|
|
@@ -13553,8 +13553,8 @@ function processRelationships(root, convertedXml, results) {
|
|
|
13553
13553
|
};
|
|
13554
13554
|
const seenIds = /* @__PURE__ */ new Set();
|
|
13555
13555
|
const filtered = [];
|
|
13556
|
-
function extractStringAttr(attrs,
|
|
13557
|
-
return typeof attrs[
|
|
13556
|
+
function extractStringAttr(attrs, key2) {
|
|
13557
|
+
return typeof attrs[key2] === "string" ? attrs[key2].trim() : "";
|
|
13558
13558
|
}
|
|
13559
13559
|
for (const rel of root.elements) {
|
|
13560
13560
|
rel.attributes = rel.attributes || {};
|
|
@@ -13776,10 +13776,10 @@ class SuperValidator {
|
|
|
13776
13776
|
this.logger.debug("Document analysis:", documentAnalysis);
|
|
13777
13777
|
let hasModifiedDocument = false;
|
|
13778
13778
|
const validationResults = [];
|
|
13779
|
-
Object.entries(__privateGet(this, _stateValidators)).forEach(([
|
|
13780
|
-
this.logger.debug(`🕵 Validating with ${
|
|
13779
|
+
Object.entries(__privateGet(this, _stateValidators)).forEach(([key2, validator]) => {
|
|
13780
|
+
this.logger.debug(`🕵 Validating with ${key2}...`);
|
|
13781
13781
|
const { results, modified } = validator(tr, documentAnalysis);
|
|
13782
|
-
validationResults.push({ key, results });
|
|
13782
|
+
validationResults.push({ key: key2, results });
|
|
13783
13783
|
hasModifiedDocument = hasModifiedDocument || modified;
|
|
13784
13784
|
});
|
|
13785
13785
|
if (!this.dryRun) dispatch(tr);
|
|
@@ -13796,10 +13796,10 @@ class SuperValidator {
|
|
|
13796
13796
|
const { dispatch } = __privateGet(this, _editor).view;
|
|
13797
13797
|
let hasModifiedDocument = false;
|
|
13798
13798
|
const validationResults = [];
|
|
13799
|
-
Object.entries(__privateGet(this, _xmlValidators)).forEach(([
|
|
13800
|
-
this.logger.debug(`🕵 Validating export with ${
|
|
13799
|
+
Object.entries(__privateGet(this, _xmlValidators)).forEach(([key2, validator]) => {
|
|
13800
|
+
this.logger.debug(`🕵 Validating export with ${key2}...`);
|
|
13801
13801
|
const { results, modified } = validator();
|
|
13802
|
-
validationResults.push({ key, results });
|
|
13802
|
+
validationResults.push({ key: key2, results });
|
|
13803
13803
|
hasModifiedDocument = hasModifiedDocument || modified;
|
|
13804
13804
|
});
|
|
13805
13805
|
if (!this.dryRun && hasModifiedDocument) dispatch(tr);
|
|
@@ -13823,11 +13823,11 @@ initializeValidators_fn = function() {
|
|
|
13823
13823
|
const requiredMarks = /* @__PURE__ */ new Set();
|
|
13824
13824
|
const initializeValidatorSet = (validatorFactories) => {
|
|
13825
13825
|
return Object.fromEntries(
|
|
13826
|
-
Object.entries(validatorFactories).map(([
|
|
13827
|
-
const validatorLogger = this.logger.withPrefix(
|
|
13826
|
+
Object.entries(validatorFactories).map(([key2, factory]) => {
|
|
13827
|
+
const validatorLogger = this.logger.withPrefix(key2);
|
|
13828
13828
|
const validator = factory({ editor: __privateGet(this, _editor), logger: validatorLogger });
|
|
13829
13829
|
__privateMethod(this, _SuperValidator_instances, collectValidatorRequirements_fn).call(this, validator, requiredNodes, requiredMarks);
|
|
13830
|
-
return [
|
|
13830
|
+
return [key2, validator];
|
|
13831
13831
|
})
|
|
13832
13832
|
);
|
|
13833
13833
|
};
|
|
@@ -15149,8 +15149,8 @@ initMedia_fn = function() {
|
|
|
15149
15149
|
if (!this.options.ydoc) return this.storage.image.media = this.options.mediaFiles;
|
|
15150
15150
|
const mediaMap = this.options.ydoc.getMap("media");
|
|
15151
15151
|
if (this.options.isNewFile) {
|
|
15152
|
-
Object.entries(this.options.mediaFiles).forEach(([
|
|
15153
|
-
mediaMap.set(
|
|
15152
|
+
Object.entries(this.options.mediaFiles).forEach(([key2, value]) => {
|
|
15153
|
+
mediaMap.set(key2, value);
|
|
15154
15154
|
});
|
|
15155
15155
|
this.storage.image.media = this.options.mediaFiles;
|
|
15156
15156
|
} else {
|
|
@@ -16034,11 +16034,11 @@ const FormatCommands = Extension.create({
|
|
|
16034
16034
|
const { type, attrs } = mark;
|
|
16035
16035
|
const { name } = type;
|
|
16036
16036
|
if (name === "textStyle") {
|
|
16037
|
-
Object.keys(attrs).forEach((
|
|
16038
|
-
if (!attrs[
|
|
16037
|
+
Object.keys(attrs).forEach((key2) => {
|
|
16038
|
+
if (!attrs[key2]) return;
|
|
16039
16039
|
const attributes = {};
|
|
16040
|
-
attributes[
|
|
16041
|
-
processedMarks.push({ name:
|
|
16040
|
+
attributes[key2] = attrs[key2];
|
|
16041
|
+
processedMarks.push({ name: key2, attrs: attributes });
|
|
16042
16042
|
});
|
|
16043
16043
|
} else {
|
|
16044
16044
|
processedMarks.push({ name, attrs });
|
|
@@ -16053,13 +16053,13 @@ const FormatCommands = Extension.create({
|
|
|
16053
16053
|
fontFamily: ["setFontFamily", "unsetFontFamily"]
|
|
16054
16054
|
};
|
|
16055
16055
|
let result = chain();
|
|
16056
|
-
Object.keys(marksToCommands).forEach((
|
|
16057
|
-
const [setCommand, unsetCommand, defaultParam] = marksToCommands[
|
|
16058
|
-
const markToApply = processedMarks.find((mark) => mark.name ===
|
|
16059
|
-
const hasEmptyAttrs = markToApply?.attrs && markToApply?.attrs[
|
|
16056
|
+
Object.keys(marksToCommands).forEach((key2) => {
|
|
16057
|
+
const [setCommand, unsetCommand, defaultParam] = marksToCommands[key2];
|
|
16058
|
+
const markToApply = processedMarks.find((mark) => mark.name === key2);
|
|
16059
|
+
const hasEmptyAttrs = markToApply?.attrs && markToApply?.attrs[key2];
|
|
16060
16060
|
let cmd = {};
|
|
16061
16061
|
if (!markToApply && !hasEmptyAttrs) cmd = { command: unsetCommand, argument: defaultParam };
|
|
16062
|
-
else cmd = { command: setCommand, argument: markToApply.attrs[
|
|
16062
|
+
else cmd = { command: setCommand, argument: markToApply.attrs[key2] || defaultParam };
|
|
16063
16063
|
result = result[cmd.command](cmd.argument);
|
|
16064
16064
|
});
|
|
16065
16065
|
this.storage.storedStyle = null;
|
|
@@ -17563,7 +17563,7 @@ const generateLinkedStyleString = (linkedStyle, basedOnStyle, node, parent, incl
|
|
|
17563
17563
|
resultStyles["text-transform"] = basedOnDefinitionStyles["text-transform"];
|
|
17564
17564
|
}
|
|
17565
17565
|
Object.entries(resultStyles).forEach(([k, value]) => {
|
|
17566
|
-
const
|
|
17566
|
+
const key2 = kebabCase(k);
|
|
17567
17567
|
const flattenedMarks = [];
|
|
17568
17568
|
node?.marks?.forEach((n) => {
|
|
17569
17569
|
if (n.type.name === "textStyle") {
|
|
@@ -17574,46 +17574,46 @@ const generateLinkedStyleString = (linkedStyle, basedOnStyle, node, parent, incl
|
|
|
17574
17574
|
});
|
|
17575
17575
|
return;
|
|
17576
17576
|
}
|
|
17577
|
-
flattenedMarks.push({ key: n.type.name, value: n.attrs[
|
|
17577
|
+
flattenedMarks.push({ key: n.type.name, value: n.attrs[key2] });
|
|
17578
17578
|
});
|
|
17579
|
-
const mark = flattenedMarks.find((n) => n.key ===
|
|
17579
|
+
const mark = flattenedMarks.find((n) => n.key === key2);
|
|
17580
17580
|
const hasParentIndent = Object.keys(parent?.attrs?.indent || {});
|
|
17581
17581
|
const hasParentSpacing = Object.keys(parent?.attrs?.spacing || {});
|
|
17582
17582
|
const listTypes = ["orderedList", "listItem"];
|
|
17583
17583
|
if (!mark) {
|
|
17584
|
-
if (
|
|
17584
|
+
if (key2 === "spacing" && includeSpacing && !hasParentSpacing) {
|
|
17585
17585
|
const space = getSpacingStyle(value);
|
|
17586
17586
|
Object.entries(space).forEach(([k2, v]) => {
|
|
17587
17587
|
markValue[k2] = v;
|
|
17588
17588
|
});
|
|
17589
|
-
} else if (
|
|
17589
|
+
} else if (key2 === "indent" && includeSpacing && !hasParentIndent) {
|
|
17590
17590
|
const { leftIndent, rightIndent, firstLine } = value;
|
|
17591
17591
|
if (leftIndent) markValue["margin-left"] = leftIndent + "px";
|
|
17592
17592
|
if (rightIndent) markValue["margin-right"] = rightIndent + "px";
|
|
17593
17593
|
if (firstLine) markValue["text-indent"] = firstLine + "px";
|
|
17594
|
-
} else if (
|
|
17594
|
+
} else if (key2 === "bold" && node) {
|
|
17595
17595
|
const val = value?.value;
|
|
17596
17596
|
if (!listTypes.includes(node.type.name) && val !== "0") {
|
|
17597
17597
|
markValue["font-weight"] = "bold";
|
|
17598
17598
|
}
|
|
17599
|
-
} else if (
|
|
17599
|
+
} else if (key2 === "text-transform" && node) {
|
|
17600
17600
|
if (!listTypes.includes(node.type.name)) {
|
|
17601
|
-
markValue[
|
|
17601
|
+
markValue[key2] = value;
|
|
17602
17602
|
}
|
|
17603
|
-
} else if (
|
|
17603
|
+
} else if (key2 === "font-size" && node) {
|
|
17604
17604
|
if (!listTypes.includes(node.type.name)) {
|
|
17605
|
-
markValue[
|
|
17605
|
+
markValue[key2] = value;
|
|
17606
17606
|
}
|
|
17607
|
-
} else if (
|
|
17607
|
+
} else if (key2 === "color" && node) {
|
|
17608
17608
|
if (!listTypes.includes(node.type.name)) {
|
|
17609
|
-
markValue[
|
|
17609
|
+
markValue[key2] = value;
|
|
17610
17610
|
}
|
|
17611
17611
|
} else if (typeof value === "string") {
|
|
17612
|
-
markValue[
|
|
17612
|
+
markValue[key2] = value;
|
|
17613
17613
|
}
|
|
17614
17614
|
}
|
|
17615
17615
|
});
|
|
17616
|
-
const final = Object.entries(markValue).map(([
|
|
17616
|
+
const final = Object.entries(markValue).map(([key2, value]) => `${key2}: ${value}`).join(";");
|
|
17617
17617
|
return final;
|
|
17618
17618
|
};
|
|
17619
17619
|
const applyLinkedStyleToTransaction = (tr, editor, style) => {
|
|
@@ -18308,7 +18308,7 @@ function orderedListSync(editor) {
|
|
|
18308
18308
|
listNumberingType,
|
|
18309
18309
|
customFormat
|
|
18310
18310
|
};
|
|
18311
|
-
const keysChanged = Object.keys(updatedAttrs).some((
|
|
18311
|
+
const keysChanged = Object.keys(updatedAttrs).some((key2) => node.attrs[key2] !== updatedAttrs[key2]);
|
|
18312
18312
|
if (keysChanged) {
|
|
18313
18313
|
tr.setNodeMarkup(pos, void 0, updatedAttrs);
|
|
18314
18314
|
}
|
|
@@ -19347,6 +19347,12 @@ const HardBreak = Node$1.create({
|
|
|
19347
19347
|
};
|
|
19348
19348
|
}
|
|
19349
19349
|
});
|
|
19350
|
+
const getColStyleDeclaration = (minWidth, width) => {
|
|
19351
|
+
if (width) {
|
|
19352
|
+
return ["width", `${Math.max(width, minWidth)}px`];
|
|
19353
|
+
}
|
|
19354
|
+
return ["min-width", `${minWidth}px`];
|
|
19355
|
+
};
|
|
19350
19356
|
const createTableView = ({ editor }) => {
|
|
19351
19357
|
return class TableView {
|
|
19352
19358
|
constructor(node, cellMinWidth) {
|
|
@@ -19435,11 +19441,11 @@ function updateTable(editor, node, table) {
|
|
|
19435
19441
|
const allExtensionsAttrs = editor.extensionService.attributes;
|
|
19436
19442
|
const tableExtensionAttrs = allExtensionsAttrs.filter((e) => e.type === "table");
|
|
19437
19443
|
const htmlAttributes = Attribute.getAttributesToRender(node, tableExtensionAttrs);
|
|
19438
|
-
Object.entries(htmlAttributes).forEach(([
|
|
19439
|
-
if (
|
|
19444
|
+
Object.entries(htmlAttributes).forEach(([key2, value]) => {
|
|
19445
|
+
if (key2 === "style") {
|
|
19440
19446
|
table.style.cssText = value;
|
|
19441
19447
|
} else {
|
|
19442
|
-
table.setAttribute(
|
|
19448
|
+
table.setAttribute(key2, value);
|
|
19443
19449
|
}
|
|
19444
19450
|
});
|
|
19445
19451
|
}
|
|
@@ -19507,26 +19513,55 @@ const createTable = (schema, rowsCount, colsCount, withHeaderRow, cellContent =
|
|
|
19507
19513
|
const tableBorders = createTableBorders();
|
|
19508
19514
|
return types.table.createChecked({ borders: tableBorders }, rows);
|
|
19509
19515
|
};
|
|
19516
|
+
const createColGroup = (node, cellMinWidth, overrideCol, overrideValue) => {
|
|
19517
|
+
let totalWidth = 0;
|
|
19518
|
+
let fixedWidth = true;
|
|
19519
|
+
const cols = [];
|
|
19520
|
+
const colsValues = [];
|
|
19521
|
+
const row = node.firstChild;
|
|
19522
|
+
if (!row) return {};
|
|
19523
|
+
for (let i = 0, col = 0; i < row.childCount; i++) {
|
|
19524
|
+
const { colspan, colwidth } = row.child(i).attrs;
|
|
19525
|
+
for (let j = 0; j < colspan; j++, col++) {
|
|
19526
|
+
const hasWidth = overrideCol === col ? overrideValue : colwidth && colwidth[j];
|
|
19527
|
+
totalWidth += hasWidth || cellMinWidth;
|
|
19528
|
+
if (!hasWidth) fixedWidth = false;
|
|
19529
|
+
const [prop, value] = getColStyleDeclaration(cellMinWidth, hasWidth);
|
|
19530
|
+
cols.push(["col", { style: `${prop}: ${value}` }]);
|
|
19531
|
+
colsValues.push(parseInt(value, 10));
|
|
19532
|
+
}
|
|
19533
|
+
}
|
|
19534
|
+
const tableWidth = fixedWidth ? `${totalWidth}px` : "";
|
|
19535
|
+
const tableMinWidth = fixedWidth ? "" : `${totalWidth}px`;
|
|
19536
|
+
const colgroup = ["colgroup", {}, ...cols];
|
|
19537
|
+
const colgroupValues = [...colsValues];
|
|
19538
|
+
return {
|
|
19539
|
+
colgroup,
|
|
19540
|
+
tableWidth,
|
|
19541
|
+
tableMinWidth,
|
|
19542
|
+
colgroupValues
|
|
19543
|
+
};
|
|
19544
|
+
};
|
|
19510
19545
|
var readFromCache;
|
|
19511
19546
|
var addToCache;
|
|
19512
19547
|
if (typeof WeakMap != "undefined") {
|
|
19513
19548
|
let cache = /* @__PURE__ */ new WeakMap();
|
|
19514
|
-
readFromCache = (
|
|
19515
|
-
addToCache = (
|
|
19516
|
-
cache.set(
|
|
19549
|
+
readFromCache = (key2) => cache.get(key2);
|
|
19550
|
+
addToCache = (key2, value) => {
|
|
19551
|
+
cache.set(key2, value);
|
|
19517
19552
|
return value;
|
|
19518
19553
|
};
|
|
19519
19554
|
} else {
|
|
19520
19555
|
const cache = [];
|
|
19521
19556
|
const cacheSize = 10;
|
|
19522
19557
|
let cachePos = 0;
|
|
19523
|
-
readFromCache = (
|
|
19558
|
+
readFromCache = (key2) => {
|
|
19524
19559
|
for (let i = 0; i < cache.length; i += 2)
|
|
19525
|
-
if (cache[i] ==
|
|
19560
|
+
if (cache[i] == key2) return cache[i + 1];
|
|
19526
19561
|
};
|
|
19527
|
-
addToCache = (
|
|
19562
|
+
addToCache = (key2, value) => {
|
|
19528
19563
|
if (cachePos == cacheSize) cachePos = 0;
|
|
19529
|
-
cache[cachePos++] =
|
|
19564
|
+
cache[cachePos++] = key2;
|
|
19530
19565
|
return cache[cachePos++] = value;
|
|
19531
19566
|
};
|
|
19532
19567
|
}
|
|
@@ -21760,8 +21795,8 @@ const Table = Node$1.create({
|
|
|
21760
21795
|
default: {},
|
|
21761
21796
|
renderDOM({ borders }) {
|
|
21762
21797
|
if (!borders) return {};
|
|
21763
|
-
const style = Object.entries(borders).reduce((acc, [
|
|
21764
|
-
return `${acc}border-${
|
|
21798
|
+
const style = Object.entries(borders).reduce((acc, [key2, { size, color }]) => {
|
|
21799
|
+
return `${acc}border-${key2}: ${Math.ceil(size)}px solid ${color || "black"};`;
|
|
21765
21800
|
}, "");
|
|
21766
21801
|
return {
|
|
21767
21802
|
style
|
|
@@ -21820,6 +21855,24 @@ const Table = Node$1.create({
|
|
|
21820
21855
|
tableCellSpacing: {
|
|
21821
21856
|
default: null,
|
|
21822
21857
|
rendered: false
|
|
21858
|
+
},
|
|
21859
|
+
/**
|
|
21860
|
+
* @category Attribute
|
|
21861
|
+
* @param {TableProperties} [tableProperties] - Properties for the table.
|
|
21862
|
+
* @see {@link https://ecma-international.org/publications-and-standards/standards/ecma-376/} "Fundamentals And Markup Language Reference", page 371-483
|
|
21863
|
+
*/
|
|
21864
|
+
tableProperties: {
|
|
21865
|
+
default: null,
|
|
21866
|
+
rendered: false
|
|
21867
|
+
},
|
|
21868
|
+
/**
|
|
21869
|
+
* @category Attribute
|
|
21870
|
+
* @param {TableGrid} [grid] - Grid definition for the table
|
|
21871
|
+
* @see {@link https://ecma-international.org/publications-and-standards/standards/ecma-376/} "Fundamentals And Markup Language Reference", page 432
|
|
21872
|
+
*/
|
|
21873
|
+
grid: {
|
|
21874
|
+
default: null,
|
|
21875
|
+
rendered: false
|
|
21823
21876
|
}
|
|
21824
21877
|
};
|
|
21825
21878
|
},
|
|
@@ -22876,11 +22929,11 @@ createAnnotation_fn = function({ displayLabel } = {}) {
|
|
|
22876
22929
|
let mergedAttrs = Attribute.mergeAttributes(this.htmlAttributes, {
|
|
22877
22930
|
style: omitHighlight ? "" : annotationStyle
|
|
22878
22931
|
});
|
|
22879
|
-
for (let [
|
|
22880
|
-
if (
|
|
22932
|
+
for (let [key2, value] of Object.entries(mergedAttrs)) {
|
|
22933
|
+
if (key2 === "style") {
|
|
22881
22934
|
annotation.style.cssText = value;
|
|
22882
22935
|
} else {
|
|
22883
|
-
annotation.setAttribute(
|
|
22936
|
+
annotation.setAttribute(key2, value);
|
|
22884
22937
|
}
|
|
22885
22938
|
}
|
|
22886
22939
|
return {
|
|
@@ -23054,13 +23107,13 @@ function hash$2(str) {
|
|
|
23054
23107
|
}
|
|
23055
23108
|
const colorToInt = (x) => parseInt(x.replace(/_/g, ""), 36);
|
|
23056
23109
|
const compressedColorMap = "1q29ehhb 1n09sgk7 1kl1ekf_ _yl4zsno 16z9eiv3 1p29lhp8 _bd9zg04 17u0____ _iw9zhe5 _to73___ _r45e31e _7l6g016 _jh8ouiv _zn3qba8 1jy4zshs 11u87k0u 1ro9yvyo 1aj3xael 1gz9zjz0 _3w8l4xo 1bf1ekf_ _ke3v___ _4rrkb__ 13j776yz _646mbhl _nrjr4__ _le6mbhl 1n37ehkb _m75f91n _qj3bzfz 1939yygw 11i5z6x8 _1k5f8xs 1509441m 15t5lwgf _ae2th1n _tg1ugcv 1lp1ugcv 16e14up_ _h55rw7n _ny9yavn _7a11xb_ 1ih442g9 _pv442g9 1mv16xof 14e6y7tu 1oo9zkds 17d1cisi _4v9y70f _y98m8kc 1019pq0v 12o9zda8 _348j4f4 1et50i2o _8epa8__ _ts6senj 1o350i2o 1mi9eiuo 1259yrp0 1ln80gnw _632xcoy 1cn9zldc _f29edu4 1n490c8q _9f9ziet 1b94vk74 _m49zkct 1kz6s73a 1eu9dtog _q58s1rz 1dy9sjiq __u89jo3 _aj5nkwg _ld89jo3 13h9z6wx _qa9z2ii _l119xgq _bs5arju 1hj4nwk9 1qt4nwk9 1ge6wau6 14j9zlcw 11p1edc_ _ms1zcxe _439shk6 _jt9y70f _754zsow 1la40eju _oq5p___ _x279qkz 1fa5r3rv _yd2d9ip _424tcku _8y1di2_ _zi2uabw _yy7rn9h 12yz980_ __39ljp6 1b59zg0x _n39zfzp 1fy9zest _b33k___ _hp9wq92 1il50hz4 _io472ub _lj9z3eo 19z9ykg0 _8t8iu3a 12b9bl4a 1ak5yw0o _896v4ku _tb8k8lv _s59zi6t _c09ze0p 1lg80oqn 1id9z8wb _238nba5 1kq6wgdi _154zssg _tn3zk49 _da9y6tc 1sg7cv4f _r12jvtt 1gq5fmkz 1cs9rvci _lp9jn1c _xw1tdnb 13f9zje6 16f6973h _vo7ir40 _bt5arjf _rc45e4t _hr4e100 10v4e100 _hc9zke2 _w91egv_ _sj2r1kk 13c87yx8 _vqpds__ _ni8ggk8 _tj9yqfb 1ia2j4r4 _7x9b10u 1fc9ld4j 1eq9zldr _5j9lhpx _ez9zl6o _md61fzm".split(" ").reduce((acc, next) => {
|
|
23057
|
-
const
|
|
23110
|
+
const key2 = colorToInt(next.substring(0, 3));
|
|
23058
23111
|
const hex = colorToInt(next.substring(3)).toString(16);
|
|
23059
23112
|
let prefix = "";
|
|
23060
23113
|
for (let i = 0; i < 6 - hex.length; i++) {
|
|
23061
23114
|
prefix += "0";
|
|
23062
23115
|
}
|
|
23063
|
-
acc[
|
|
23116
|
+
acc[key2] = `${prefix}${hex}`;
|
|
23064
23117
|
return acc;
|
|
23065
23118
|
}, {});
|
|
23066
23119
|
function nameToHex(color) {
|
|
@@ -24176,41 +24229,480 @@ function getFormatAttrsFromMarks(marks) {
|
|
|
24176
24229
|
}
|
|
24177
24230
|
return formatAttrs;
|
|
24178
24231
|
}
|
|
24179
|
-
const
|
|
24180
|
-
|
|
24232
|
+
const simpleHash = (str) => {
|
|
24233
|
+
let hash2 = 0;
|
|
24234
|
+
for (let i = 0; i < str.length; i++) {
|
|
24235
|
+
const char = str.charCodeAt(i);
|
|
24236
|
+
hash2 = (hash2 << 5) - hash2 + char;
|
|
24237
|
+
hash2 = hash2 & hash2;
|
|
24238
|
+
}
|
|
24239
|
+
return Math.abs(hash2).toString();
|
|
24240
|
+
};
|
|
24241
|
+
const base64ToFile = (base64String) => {
|
|
24242
|
+
const arr = base64String.split(",");
|
|
24243
|
+
const mimeMatch = arr[0].match(/:(.*?);/);
|
|
24244
|
+
const mimeType = mimeMatch ? mimeMatch[1] : "";
|
|
24245
|
+
const data = arr[1];
|
|
24246
|
+
const binaryString = atob(data);
|
|
24247
|
+
const hash2 = simpleHash(binaryString);
|
|
24248
|
+
const extension = mimeType.split("/")[1] || "bin";
|
|
24249
|
+
const filename = `image-${hash2}.${extension}`;
|
|
24250
|
+
const bytes = new Uint8Array(binaryString.length);
|
|
24251
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
24252
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
24253
|
+
}
|
|
24254
|
+
const blob = new Blob([bytes], { type: mimeType });
|
|
24255
|
+
return new File([blob], filename, { type: mimeType });
|
|
24256
|
+
};
|
|
24257
|
+
const urlToFile = async (url, filename, mimeType) => {
|
|
24258
|
+
try {
|
|
24259
|
+
const response = await fetch(url, {
|
|
24260
|
+
mode: "cors",
|
|
24261
|
+
credentials: "omit",
|
|
24262
|
+
headers: {
|
|
24263
|
+
// Add common headers that might help with CORS
|
|
24264
|
+
Accept: "image/*,*/*;q=0.8"
|
|
24265
|
+
}
|
|
24266
|
+
});
|
|
24267
|
+
if (!response.ok) {
|
|
24268
|
+
console.warn(`Failed to fetch image from ${url}: ${response.status} ${response.statusText}`);
|
|
24269
|
+
return null;
|
|
24270
|
+
}
|
|
24271
|
+
const blob = await response.blob();
|
|
24272
|
+
const finalFilename = filename || extractFilenameFromUrl(url);
|
|
24273
|
+
const finalMimeType = mimeType || response.headers.get("content-type") || blob.type || "image/jpeg";
|
|
24274
|
+
return new File([blob], finalFilename, { type: finalMimeType });
|
|
24275
|
+
} catch (error) {
|
|
24276
|
+
if (isCorsError(error)) {
|
|
24277
|
+
console.warn(`CORS policy prevents accessing image from ${url}:`, error.message);
|
|
24278
|
+
return null;
|
|
24279
|
+
}
|
|
24280
|
+
console.error(`Error fetching image from ${url}:`, error);
|
|
24281
|
+
return null;
|
|
24282
|
+
}
|
|
24283
|
+
};
|
|
24284
|
+
const isCorsError = (error) => {
|
|
24285
|
+
const errorMessage = error.message.toLowerCase();
|
|
24286
|
+
const errorName = error.name.toLowerCase();
|
|
24287
|
+
return errorName.includes("cors") || errorMessage.includes("cors") || errorMessage.includes("cross-origin") || errorMessage.includes("access-control") || errorMessage.includes("network error") || // Often indicates CORS in browsers
|
|
24288
|
+
errorMessage.includes("failed to fetch");
|
|
24289
|
+
};
|
|
24290
|
+
const extractFilenameFromUrl = (url) => {
|
|
24291
|
+
try {
|
|
24292
|
+
const urlObj = new URL(url);
|
|
24293
|
+
const pathname = urlObj.pathname;
|
|
24294
|
+
const filename = pathname.split("/").pop();
|
|
24295
|
+
if (filename && !filename.includes(".")) {
|
|
24296
|
+
return `${filename}.jpg`;
|
|
24297
|
+
}
|
|
24298
|
+
return filename || "image.jpg";
|
|
24299
|
+
} catch {
|
|
24300
|
+
return "image.jpg";
|
|
24301
|
+
}
|
|
24302
|
+
};
|
|
24303
|
+
const validateUrlAccessibility = async (url) => {
|
|
24304
|
+
try {
|
|
24305
|
+
const response = await fetch(url, {
|
|
24306
|
+
method: "HEAD",
|
|
24307
|
+
mode: "cors",
|
|
24308
|
+
credentials: "omit"
|
|
24309
|
+
});
|
|
24310
|
+
return response.ok;
|
|
24311
|
+
} catch (_error) {
|
|
24312
|
+
return false;
|
|
24313
|
+
}
|
|
24314
|
+
};
|
|
24315
|
+
const handleImageUpload = (file) => {
|
|
24316
|
+
return new Promise((resolve, reject) => {
|
|
24317
|
+
let reader = new FileReader();
|
|
24318
|
+
reader.onload = (event) => {
|
|
24319
|
+
resolve(event.target.result);
|
|
24320
|
+
};
|
|
24321
|
+
reader.onerror = reject;
|
|
24322
|
+
setTimeout(() => reader.readAsDataURL(file), 250);
|
|
24323
|
+
});
|
|
24324
|
+
};
|
|
24325
|
+
const processUploadedImage = (fileData, getMaxContentSize) => {
|
|
24326
|
+
return new Promise((resolve, reject) => {
|
|
24327
|
+
const img = new window.Image();
|
|
24328
|
+
img.onload = () => {
|
|
24329
|
+
const canvas = document.createElement("canvas");
|
|
24330
|
+
const { width: logicalWidth, height: logicalHeight } = getAllowedImageDimensions(
|
|
24331
|
+
img.width,
|
|
24332
|
+
img.height,
|
|
24333
|
+
getMaxContentSize
|
|
24334
|
+
);
|
|
24335
|
+
canvas.width = img.width;
|
|
24336
|
+
canvas.height = img.height;
|
|
24337
|
+
const ctx = canvas.getContext("2d");
|
|
24338
|
+
if (ctx) {
|
|
24339
|
+
ctx.imageSmoothingEnabled = true;
|
|
24340
|
+
try {
|
|
24341
|
+
ctx.imageSmoothingQuality = "high";
|
|
24342
|
+
} catch {
|
|
24343
|
+
}
|
|
24344
|
+
}
|
|
24345
|
+
ctx.drawImage(img, 0, 0, img.width, img.height);
|
|
24346
|
+
const dpr = typeof window !== "undefined" && window.devicePixelRatio ? window.devicePixelRatio : 1;
|
|
24347
|
+
const targetPixelWidth = Math.round(logicalWidth * dpr);
|
|
24348
|
+
const targetPixelHeight = Math.round(logicalHeight * dpr);
|
|
24349
|
+
const finalTargetWidth = Math.min(targetPixelWidth, img.width);
|
|
24350
|
+
const finalTargetHeight = Math.min(targetPixelHeight, img.height);
|
|
24351
|
+
const resizeNeeded = finalTargetWidth !== img.width || finalTargetHeight !== img.height;
|
|
24352
|
+
if (resizeNeeded) {
|
|
24353
|
+
multiStepResize(canvas, finalTargetWidth, finalTargetHeight);
|
|
24354
|
+
}
|
|
24355
|
+
if (typeof fileData === "string") {
|
|
24356
|
+
const resizedBase64 = canvas.toDataURL();
|
|
24357
|
+
resolve(resizedBase64);
|
|
24358
|
+
} else {
|
|
24359
|
+
canvas.toBlob((blob) => {
|
|
24360
|
+
const updatedFile = new File([blob], fileData.name, {
|
|
24361
|
+
type: fileData.type,
|
|
24362
|
+
lastModified: Date.now()
|
|
24363
|
+
});
|
|
24364
|
+
resolve({ file: updatedFile, width: logicalWidth, height: logicalHeight });
|
|
24365
|
+
});
|
|
24366
|
+
}
|
|
24367
|
+
};
|
|
24368
|
+
img.onerror = (error) => reject(error);
|
|
24369
|
+
img.src = typeof fileData === "string" ? fileData : URL.createObjectURL(fileData);
|
|
24370
|
+
});
|
|
24371
|
+
};
|
|
24372
|
+
const getAllowedImageDimensions = (width, height, getMaxContentSize) => {
|
|
24373
|
+
const { width: maxWidth, height: maxHeight } = getMaxContentSize();
|
|
24374
|
+
if (!maxWidth || !maxHeight) return { width, height };
|
|
24375
|
+
let adjustedWidth = width;
|
|
24376
|
+
let adjustedHeight = height;
|
|
24377
|
+
const aspectRatio = width / height;
|
|
24378
|
+
if (height > maxHeight) {
|
|
24379
|
+
adjustedHeight = maxHeight;
|
|
24380
|
+
adjustedWidth = Math.round(maxHeight * aspectRatio);
|
|
24381
|
+
}
|
|
24382
|
+
if (adjustedWidth > maxWidth) {
|
|
24383
|
+
adjustedWidth = maxWidth;
|
|
24384
|
+
adjustedHeight = Math.round(maxWidth / aspectRatio);
|
|
24385
|
+
}
|
|
24386
|
+
return { width: adjustedWidth, height: adjustedHeight };
|
|
24387
|
+
};
|
|
24388
|
+
function resample_high_quality(canvas, width, height, resize_canvas) {
|
|
24389
|
+
var width_source = canvas.width;
|
|
24390
|
+
var height_source = canvas.height;
|
|
24391
|
+
width = Math.round(width);
|
|
24392
|
+
height = Math.round(height);
|
|
24393
|
+
var ratio_w = width_source / width;
|
|
24394
|
+
var ratio_h = height_source / height;
|
|
24395
|
+
var ratio_w_half = Math.ceil(ratio_w / 2);
|
|
24396
|
+
var ratio_h_half = Math.ceil(ratio_h / 2);
|
|
24397
|
+
var ctx = canvas.getContext("2d");
|
|
24398
|
+
var img = ctx.getImageData(0, 0, width_source, height_source);
|
|
24399
|
+
var img2 = ctx.createImageData(width, height);
|
|
24400
|
+
var data = img.data;
|
|
24401
|
+
var data2 = img2.data;
|
|
24402
|
+
for (var j = 0; j < height; j++) {
|
|
24403
|
+
for (var i = 0; i < width; i++) {
|
|
24404
|
+
var x2 = (i + j * width) * 4;
|
|
24405
|
+
var weight = 0;
|
|
24406
|
+
var weights = 0;
|
|
24407
|
+
var weights_alpha = 0;
|
|
24408
|
+
var gx_r = 0;
|
|
24409
|
+
var gx_g = 0;
|
|
24410
|
+
var gx_b = 0;
|
|
24411
|
+
var gx_a = 0;
|
|
24412
|
+
var center_y = (j + 0.5) * ratio_h;
|
|
24413
|
+
var yy_start = Math.floor(j * ratio_h);
|
|
24414
|
+
var yy_stop = Math.ceil((j + 1) * ratio_h);
|
|
24415
|
+
for (var yy = yy_start; yy < yy_stop; yy++) {
|
|
24416
|
+
var dy = Math.abs(center_y - (yy + 0.5)) / ratio_h_half;
|
|
24417
|
+
var center_x = (i + 0.5) * ratio_w;
|
|
24418
|
+
var w0 = dy * dy;
|
|
24419
|
+
var xx_start = Math.floor(i * ratio_w);
|
|
24420
|
+
var xx_stop = Math.ceil((i + 1) * ratio_w);
|
|
24421
|
+
for (var xx = xx_start; xx < xx_stop; xx++) {
|
|
24422
|
+
var dx = Math.abs(center_x - (xx + 0.5)) / ratio_w_half;
|
|
24423
|
+
var w = Math.sqrt(w0 + dx * dx);
|
|
24424
|
+
if (w >= 1) {
|
|
24425
|
+
continue;
|
|
24426
|
+
}
|
|
24427
|
+
weight = 2 * w * w * w - 3 * w * w + 1;
|
|
24428
|
+
var pos_x = 4 * (xx + yy * width_source);
|
|
24429
|
+
gx_a += weight * data[pos_x + 3];
|
|
24430
|
+
weights_alpha += weight;
|
|
24431
|
+
if (data[pos_x + 3] < 255) weight = weight * data[pos_x + 3] / 250;
|
|
24432
|
+
gx_r += weight * data[pos_x];
|
|
24433
|
+
gx_g += weight * data[pos_x + 1];
|
|
24434
|
+
gx_b += weight * data[pos_x + 2];
|
|
24435
|
+
weights += weight;
|
|
24436
|
+
}
|
|
24437
|
+
}
|
|
24438
|
+
data2[x2] = gx_r / weights;
|
|
24439
|
+
data2[x2 + 1] = gx_g / weights;
|
|
24440
|
+
data2[x2 + 2] = gx_b / weights;
|
|
24441
|
+
data2[x2 + 3] = gx_a / weights_alpha;
|
|
24442
|
+
}
|
|
24443
|
+
}
|
|
24444
|
+
{
|
|
24445
|
+
canvas.width = width;
|
|
24446
|
+
canvas.height = height;
|
|
24447
|
+
}
|
|
24448
|
+
ctx.putImageData(img2, 0, 0);
|
|
24449
|
+
}
|
|
24450
|
+
function multiStepResize(canvas, width, height) {
|
|
24451
|
+
let oc = document.createElement("canvas");
|
|
24452
|
+
let octx = oc.getContext("2d");
|
|
24453
|
+
let ctx = canvas.getContext("2d");
|
|
24454
|
+
let steps = Math.ceil(Math.log(canvas.width / width) / Math.log(2));
|
|
24455
|
+
steps = Math.max(steps, 1);
|
|
24456
|
+
let stepWidth = width * Math.pow(2, steps - 1);
|
|
24457
|
+
let stepHeight = height * Math.pow(2, steps - 1);
|
|
24458
|
+
let currentWidth = canvas.width;
|
|
24459
|
+
let currentHeight = canvas.height;
|
|
24460
|
+
oc.width = currentWidth;
|
|
24461
|
+
oc.height = currentHeight;
|
|
24462
|
+
octx.drawImage(canvas, 0, 0);
|
|
24463
|
+
while (steps > 0) {
|
|
24464
|
+
stepWidth = Math.max(stepWidth, width);
|
|
24465
|
+
stepHeight = Math.max(stepHeight, height);
|
|
24466
|
+
canvas.width = stepWidth;
|
|
24467
|
+
canvas.height = stepHeight;
|
|
24468
|
+
ctx.drawImage(oc, 0, 0, currentWidth, currentHeight, 0, 0, stepWidth, stepHeight);
|
|
24469
|
+
currentWidth = stepWidth;
|
|
24470
|
+
currentHeight = stepHeight;
|
|
24471
|
+
oc.width = currentWidth;
|
|
24472
|
+
oc.height = currentHeight;
|
|
24473
|
+
octx.drawImage(canvas, 0, 0);
|
|
24474
|
+
stepWidth = Math.round(stepWidth / 2);
|
|
24475
|
+
stepHeight = Math.round(stepHeight / 2);
|
|
24476
|
+
steps--;
|
|
24477
|
+
}
|
|
24478
|
+
resample_high_quality(canvas, width, height);
|
|
24479
|
+
}
|
|
24480
|
+
const fileTooLarge = (file) => {
|
|
24481
|
+
let fileSizeMb = Number((file.size / (1024 * 1024)).toFixed(4));
|
|
24482
|
+
if (fileSizeMb > 5) {
|
|
24483
|
+
window.alert("Image size must be less than 5MB");
|
|
24484
|
+
return true;
|
|
24485
|
+
}
|
|
24486
|
+
return false;
|
|
24487
|
+
};
|
|
24488
|
+
const checkAndProcessImage = async ({ getMaxContentSize, file }) => {
|
|
24489
|
+
if (fileTooLarge(file)) {
|
|
24490
|
+
return { file: null, size: { width: 0, height: 0 } };
|
|
24491
|
+
}
|
|
24492
|
+
try {
|
|
24493
|
+
const processedImageResult = await processUploadedImage(file, getMaxContentSize);
|
|
24494
|
+
const process = processedImageResult;
|
|
24495
|
+
return { file: process.file, size: { width: process.width, height: process.height } };
|
|
24496
|
+
} catch (err) {
|
|
24497
|
+
console.warn("Error processing image:", err);
|
|
24498
|
+
return { file: null, size: { width: 0, height: 0 } };
|
|
24499
|
+
}
|
|
24500
|
+
};
|
|
24501
|
+
function replaceSelectionWithImagePlaceholder({ editorOptions, view, id }) {
|
|
24502
|
+
let { tr } = view.state;
|
|
24503
|
+
let { selection } = tr;
|
|
24504
|
+
if (editorOptions.isHeaderOrFooter) {
|
|
24505
|
+
selection = editorOptions.lastSelection;
|
|
24506
|
+
}
|
|
24507
|
+
if (!selection.empty && !editorOptions.isHeaderOrFooter) {
|
|
24508
|
+
tr.deleteSelection();
|
|
24509
|
+
}
|
|
24510
|
+
tr = addImagePlaceholder(view.state, tr, id, selection.from);
|
|
24511
|
+
view.dispatch(tr);
|
|
24512
|
+
}
|
|
24513
|
+
async function uploadAndInsertImage({ editor, view, file, size, id }) {
|
|
24514
|
+
const imageUploadHandler = typeof editor.options.handleImageUpload === "function" ? editor.options.handleImageUpload : handleImageUpload;
|
|
24515
|
+
try {
|
|
24516
|
+
let url = await imageUploadHandler(file);
|
|
24517
|
+
let fileName = file.name.replace(" ", "_");
|
|
24518
|
+
let placeholderPos = findPlaceholder(view.state, id);
|
|
24519
|
+
if (placeholderPos == null) {
|
|
24520
|
+
return;
|
|
24521
|
+
}
|
|
24522
|
+
let mediaPath = `word/media/${fileName}`;
|
|
24523
|
+
let rId = null;
|
|
24524
|
+
if (editor.options.mode === "docx") {
|
|
24525
|
+
const [, path] = mediaPath.split("word/");
|
|
24526
|
+
const id2 = addImageRelationship({ editor, path });
|
|
24527
|
+
if (id2) rId = id2;
|
|
24528
|
+
}
|
|
24529
|
+
let imageNode = view.state.schema.nodes.image.create({
|
|
24530
|
+
src: mediaPath,
|
|
24531
|
+
size,
|
|
24532
|
+
id,
|
|
24533
|
+
rId
|
|
24534
|
+
});
|
|
24535
|
+
editor.storage.image.media = Object.assign(editor.storage.image.media, { [mediaPath]: url });
|
|
24536
|
+
if (editor.options.ydoc && typeof editor.commands.addImageToCollaboration === "function") {
|
|
24537
|
+
editor.commands.addImageToCollaboration({ mediaPath, fileData: url });
|
|
24538
|
+
}
|
|
24539
|
+
let tr = view.state.tr;
|
|
24540
|
+
tr.replaceWith(placeholderPos, placeholderPos, imageNode);
|
|
24541
|
+
tr = removeImagePlaceholder(view.state, tr, id);
|
|
24542
|
+
view.dispatch(tr);
|
|
24543
|
+
} catch {
|
|
24544
|
+
const tr = removeImagePlaceholder(view.state, view.state.tr, id);
|
|
24545
|
+
view.dispatch(tr);
|
|
24546
|
+
}
|
|
24547
|
+
}
|
|
24548
|
+
function addImageRelationship({ editor, path }) {
|
|
24549
|
+
const target = path;
|
|
24550
|
+
const type = "image";
|
|
24551
|
+
try {
|
|
24552
|
+
const id = insertNewRelationship(target, type, editor);
|
|
24553
|
+
return id;
|
|
24554
|
+
} catch {
|
|
24555
|
+
return null;
|
|
24556
|
+
}
|
|
24557
|
+
}
|
|
24558
|
+
const key = new PluginKey("ImageRegistration");
|
|
24559
|
+
const ImageRegistrationPlugin = ({ editor }) => {
|
|
24560
|
+
const { view } = editor;
|
|
24181
24561
|
return new Plugin({
|
|
24182
|
-
key
|
|
24562
|
+
key,
|
|
24183
24563
|
state: {
|
|
24184
24564
|
init() {
|
|
24185
|
-
return DecorationSet.empty;
|
|
24565
|
+
return { set: DecorationSet.empty };
|
|
24186
24566
|
},
|
|
24187
|
-
apply(tr, set) {
|
|
24567
|
+
apply(tr, { set }) {
|
|
24568
|
+
const meta = tr.getMeta(key);
|
|
24569
|
+
if (meta) {
|
|
24570
|
+
set = meta.set;
|
|
24571
|
+
return { set };
|
|
24572
|
+
}
|
|
24188
24573
|
set = set.map(tr.mapping, tr.doc);
|
|
24189
|
-
|
|
24190
|
-
|
|
24191
|
-
|
|
24192
|
-
|
|
24193
|
-
|
|
24574
|
+
return { set };
|
|
24575
|
+
}
|
|
24576
|
+
},
|
|
24577
|
+
appendTransaction: (trs, _oldState, state) => {
|
|
24578
|
+
let foundImages = [];
|
|
24579
|
+
trs.forEach((tr2) => {
|
|
24580
|
+
if (tr2.docChanged) {
|
|
24581
|
+
tr2.steps.forEach((step, index2) => {
|
|
24582
|
+
const stepMap = step.getMap();
|
|
24583
|
+
foundImages = foundImages.map(({ node, pos, id }) => {
|
|
24584
|
+
const mappedPos = stepMap.map(pos, -1);
|
|
24585
|
+
return { node, pos: mappedPos, id };
|
|
24586
|
+
});
|
|
24587
|
+
if (step instanceof ReplaceStep || step instanceof ReplaceAroundStep$1) {
|
|
24588
|
+
(tr2.docs[index2 + 1] || tr2.doc).nodesBetween(
|
|
24589
|
+
stepMap.map(step.from, -1),
|
|
24590
|
+
stepMap.map(step.to, 1),
|
|
24591
|
+
(node, pos) => {
|
|
24592
|
+
if (node.type.name === "image" && !node.attrs.src.startsWith("word/media")) {
|
|
24593
|
+
const id = {};
|
|
24594
|
+
foundImages.push({ node, pos, id });
|
|
24595
|
+
} else {
|
|
24596
|
+
return true;
|
|
24597
|
+
}
|
|
24598
|
+
}
|
|
24599
|
+
);
|
|
24600
|
+
}
|
|
24194
24601
|
});
|
|
24195
|
-
set = set.add(tr.doc, [deco]);
|
|
24196
|
-
} else if (action?.type === "remove") {
|
|
24197
|
-
set = set.remove(set.find(null, null, (spec) => spec.id == action.id));
|
|
24198
24602
|
}
|
|
24199
|
-
|
|
24603
|
+
});
|
|
24604
|
+
if (!foundImages || foundImages.length === 0) {
|
|
24605
|
+
return null;
|
|
24200
24606
|
}
|
|
24607
|
+
registerImages(foundImages, editor, view);
|
|
24608
|
+
const tr = state.tr;
|
|
24609
|
+
let { set } = key.getState(state);
|
|
24610
|
+
foundImages.slice().sort((a, b) => a.pos - b.pos).forEach(({ pos, id }) => {
|
|
24611
|
+
let deco = Decoration.widget(pos, () => document.createElement("placeholder"), {
|
|
24612
|
+
side: -1,
|
|
24613
|
+
id
|
|
24614
|
+
});
|
|
24615
|
+
set = set.add(tr.doc, [deco]);
|
|
24616
|
+
});
|
|
24617
|
+
foundImages.slice().sort((a, b) => b.pos - a.pos).forEach(({ node, pos }) => {
|
|
24618
|
+
tr.delete(pos, pos + node.nodeSize);
|
|
24619
|
+
});
|
|
24620
|
+
set = set.map(tr.mapping, tr.doc);
|
|
24621
|
+
tr.setMeta(key, { set });
|
|
24622
|
+
return tr;
|
|
24201
24623
|
},
|
|
24202
24624
|
props: {
|
|
24203
24625
|
decorations(state) {
|
|
24204
|
-
|
|
24626
|
+
let { set } = key.getState(state);
|
|
24627
|
+
return set;
|
|
24205
24628
|
}
|
|
24206
24629
|
}
|
|
24207
24630
|
});
|
|
24208
24631
|
};
|
|
24209
24632
|
const findPlaceholder = (state, id) => {
|
|
24210
|
-
let
|
|
24211
|
-
let found =
|
|
24633
|
+
let { set } = key.getState(state);
|
|
24634
|
+
let found = set?.find(null, null, (spec) => spec.id === id);
|
|
24212
24635
|
return found?.length ? found[0].from : null;
|
|
24213
24636
|
};
|
|
24637
|
+
const removeImagePlaceholder = (state, tr, id) => {
|
|
24638
|
+
let { set } = key.getState(state);
|
|
24639
|
+
set = set.map(tr.mapping, tr.doc);
|
|
24640
|
+
set = set.remove(set.find(null, null, (spec) => spec.id == id));
|
|
24641
|
+
return tr.setMeta(key, { set, type: "remove" });
|
|
24642
|
+
};
|
|
24643
|
+
const addImagePlaceholder = (state, tr, id, pos) => {
|
|
24644
|
+
let { set } = key.getState(state);
|
|
24645
|
+
set = set.map(tr.mapping, tr.doc);
|
|
24646
|
+
let deco = Decoration.widget(pos, () => document.createElement("placeholder"), {
|
|
24647
|
+
id
|
|
24648
|
+
});
|
|
24649
|
+
set = set.add(tr.doc, [deco]);
|
|
24650
|
+
return tr.setMeta(key, { set, type: "add" });
|
|
24651
|
+
};
|
|
24652
|
+
const getImageRegistrationMetaType = (tr) => {
|
|
24653
|
+
const meta = tr.getMeta(key);
|
|
24654
|
+
if (meta && meta.type) {
|
|
24655
|
+
return meta.type;
|
|
24656
|
+
}
|
|
24657
|
+
return null;
|
|
24658
|
+
};
|
|
24659
|
+
const registerImages = async (foundImages, editor, view) => {
|
|
24660
|
+
foundImages.forEach(async (image) => {
|
|
24661
|
+
const src = image.node.attrs.src;
|
|
24662
|
+
const id = image.id;
|
|
24663
|
+
let file = null;
|
|
24664
|
+
if (src.startsWith("http")) {
|
|
24665
|
+
const isAccessible = await validateUrlAccessibility(src);
|
|
24666
|
+
if (isAccessible) {
|
|
24667
|
+
file = await urlToFile(src);
|
|
24668
|
+
} else {
|
|
24669
|
+
console.warn(`Image URL ${src} is not accessible due to CORS or other restrictions. Using original URL.`);
|
|
24670
|
+
const tr = view.state.tr;
|
|
24671
|
+
removeImagePlaceholder(view.state, tr, id);
|
|
24672
|
+
view.dispatch(tr);
|
|
24673
|
+
return;
|
|
24674
|
+
}
|
|
24675
|
+
} else if (src.startsWith("data:")) {
|
|
24676
|
+
file = base64ToFile(src);
|
|
24677
|
+
} else {
|
|
24678
|
+
console.error(`Unsupported image source: ${src}`);
|
|
24679
|
+
}
|
|
24680
|
+
if (!file) {
|
|
24681
|
+
const tr = view.state.tr;
|
|
24682
|
+
removeImagePlaceholder(view.state, tr, id);
|
|
24683
|
+
view.dispatch(tr);
|
|
24684
|
+
return;
|
|
24685
|
+
}
|
|
24686
|
+
try {
|
|
24687
|
+
const process = await checkAndProcessImage({
|
|
24688
|
+
getMaxContentSize: () => editor.getMaxContentSize(),
|
|
24689
|
+
file
|
|
24690
|
+
});
|
|
24691
|
+
if (!process.file) {
|
|
24692
|
+
const tr = view.state.tr;
|
|
24693
|
+
removeImagePlaceholder(view.state, tr, id);
|
|
24694
|
+
view.dispatch(tr);
|
|
24695
|
+
return;
|
|
24696
|
+
}
|
|
24697
|
+
await uploadAndInsertImage({ editor, view, file: process.file, size: process.size, id });
|
|
24698
|
+
} catch (error) {
|
|
24699
|
+
console.error(`Error processing image from ${src}:`, error);
|
|
24700
|
+
const tr = view.state.tr;
|
|
24701
|
+
removeImagePlaceholder(view.state, tr, id);
|
|
24702
|
+
view.dispatch(tr);
|
|
24703
|
+
}
|
|
24704
|
+
});
|
|
24705
|
+
};
|
|
24214
24706
|
const ImagePositionPluginKey = new PluginKey("ImagePosition");
|
|
24215
24707
|
const ImagePositionPlugin = ({ editor }) => {
|
|
24216
24708
|
const { view } = editor;
|
|
@@ -24543,7 +25035,7 @@ const Image = Node$1.create({
|
|
|
24543
25035
|
};
|
|
24544
25036
|
},
|
|
24545
25037
|
addPmPlugins() {
|
|
24546
|
-
return [
|
|
25038
|
+
return [ImageRegistrationPlugin({ editor: this.editor }), ImagePositionPlugin({ editor: this.editor })];
|
|
24547
25039
|
}
|
|
24548
25040
|
});
|
|
24549
25041
|
const ACCEPT_IMAGE_TYPES = [".jpg", ".jpeg", ".png", "image/jpeg", "image/png"];
|
|
@@ -24568,247 +25060,6 @@ const getFileOpener = () => {
|
|
|
24568
25060
|
};
|
|
24569
25061
|
return openFile;
|
|
24570
25062
|
};
|
|
24571
|
-
const handleImageUpload = (file) => {
|
|
24572
|
-
return new Promise((resolve, reject) => {
|
|
24573
|
-
let reader = new FileReader();
|
|
24574
|
-
reader.onload = (event) => {
|
|
24575
|
-
resolve(event.target.result);
|
|
24576
|
-
};
|
|
24577
|
-
reader.onerror = reject;
|
|
24578
|
-
setTimeout(() => reader.readAsDataURL(file), 250);
|
|
24579
|
-
});
|
|
24580
|
-
};
|
|
24581
|
-
const processUploadedImage = (fileData, editor) => {
|
|
24582
|
-
return new Promise((resolve, reject) => {
|
|
24583
|
-
const img = new window.Image();
|
|
24584
|
-
img.onload = () => {
|
|
24585
|
-
const canvas = document.createElement("canvas");
|
|
24586
|
-
const { width: logicalWidth, height: logicalHeight } = getAllowedImageDimensions(img.width, img.height, editor);
|
|
24587
|
-
canvas.width = img.width;
|
|
24588
|
-
canvas.height = img.height;
|
|
24589
|
-
const ctx = canvas.getContext("2d");
|
|
24590
|
-
if (ctx) {
|
|
24591
|
-
ctx.imageSmoothingEnabled = true;
|
|
24592
|
-
try {
|
|
24593
|
-
ctx.imageSmoothingQuality = "high";
|
|
24594
|
-
} catch {
|
|
24595
|
-
}
|
|
24596
|
-
}
|
|
24597
|
-
ctx.drawImage(img, 0, 0, img.width, img.height);
|
|
24598
|
-
const dpr = typeof window !== "undefined" && window.devicePixelRatio ? window.devicePixelRatio : 1;
|
|
24599
|
-
const targetPixelWidth = Math.round(logicalWidth * dpr);
|
|
24600
|
-
const targetPixelHeight = Math.round(logicalHeight * dpr);
|
|
24601
|
-
const finalTargetWidth = Math.min(targetPixelWidth, img.width);
|
|
24602
|
-
const finalTargetHeight = Math.min(targetPixelHeight, img.height);
|
|
24603
|
-
const resizeNeeded = finalTargetWidth !== img.width || finalTargetHeight !== img.height;
|
|
24604
|
-
if (resizeNeeded) {
|
|
24605
|
-
multiStepResize(canvas, finalTargetWidth, finalTargetHeight);
|
|
24606
|
-
}
|
|
24607
|
-
if (typeof fileData === "string") {
|
|
24608
|
-
const resizedBase64 = canvas.toDataURL();
|
|
24609
|
-
resolve(resizedBase64);
|
|
24610
|
-
} else {
|
|
24611
|
-
canvas.toBlob((blob) => {
|
|
24612
|
-
const updatedFile = new File([blob], fileData.name, {
|
|
24613
|
-
type: fileData.type,
|
|
24614
|
-
lastModified: Date.now()
|
|
24615
|
-
});
|
|
24616
|
-
resolve({ file: updatedFile, width: logicalWidth, height: logicalHeight });
|
|
24617
|
-
});
|
|
24618
|
-
}
|
|
24619
|
-
};
|
|
24620
|
-
img.onerror = (error) => reject(error);
|
|
24621
|
-
img.src = typeof fileData === "string" ? fileData : URL.createObjectURL(fileData);
|
|
24622
|
-
});
|
|
24623
|
-
};
|
|
24624
|
-
const getAllowedImageDimensions = (width, height, editor) => {
|
|
24625
|
-
const { width: maxWidth, height: maxHeight } = editor.getMaxContentSize();
|
|
24626
|
-
if (!maxWidth || !maxHeight) return { width, height };
|
|
24627
|
-
let adjustedWidth = width;
|
|
24628
|
-
let adjustedHeight = height;
|
|
24629
|
-
const aspectRatio = width / height;
|
|
24630
|
-
if (height > maxHeight) {
|
|
24631
|
-
adjustedHeight = maxHeight;
|
|
24632
|
-
adjustedWidth = Math.round(maxHeight * aspectRatio);
|
|
24633
|
-
}
|
|
24634
|
-
if (adjustedWidth > maxWidth) {
|
|
24635
|
-
adjustedWidth = maxWidth;
|
|
24636
|
-
adjustedHeight = Math.round(maxWidth / aspectRatio);
|
|
24637
|
-
}
|
|
24638
|
-
return { width: adjustedWidth, height: adjustedHeight };
|
|
24639
|
-
};
|
|
24640
|
-
function resample_high_quality(canvas, width, height, resize_canvas) {
|
|
24641
|
-
var width_source = canvas.width;
|
|
24642
|
-
var height_source = canvas.height;
|
|
24643
|
-
width = Math.round(width);
|
|
24644
|
-
height = Math.round(height);
|
|
24645
|
-
var ratio_w = width_source / width;
|
|
24646
|
-
var ratio_h = height_source / height;
|
|
24647
|
-
var ratio_w_half = Math.ceil(ratio_w / 2);
|
|
24648
|
-
var ratio_h_half = Math.ceil(ratio_h / 2);
|
|
24649
|
-
var ctx = canvas.getContext("2d");
|
|
24650
|
-
var img = ctx.getImageData(0, 0, width_source, height_source);
|
|
24651
|
-
var img2 = ctx.createImageData(width, height);
|
|
24652
|
-
var data = img.data;
|
|
24653
|
-
var data2 = img2.data;
|
|
24654
|
-
for (var j = 0; j < height; j++) {
|
|
24655
|
-
for (var i = 0; i < width; i++) {
|
|
24656
|
-
var x2 = (i + j * width) * 4;
|
|
24657
|
-
var weight = 0;
|
|
24658
|
-
var weights = 0;
|
|
24659
|
-
var weights_alpha = 0;
|
|
24660
|
-
var gx_r = 0;
|
|
24661
|
-
var gx_g = 0;
|
|
24662
|
-
var gx_b = 0;
|
|
24663
|
-
var gx_a = 0;
|
|
24664
|
-
var center_y = (j + 0.5) * ratio_h;
|
|
24665
|
-
var yy_start = Math.floor(j * ratio_h);
|
|
24666
|
-
var yy_stop = Math.ceil((j + 1) * ratio_h);
|
|
24667
|
-
for (var yy = yy_start; yy < yy_stop; yy++) {
|
|
24668
|
-
var dy = Math.abs(center_y - (yy + 0.5)) / ratio_h_half;
|
|
24669
|
-
var center_x = (i + 0.5) * ratio_w;
|
|
24670
|
-
var w0 = dy * dy;
|
|
24671
|
-
var xx_start = Math.floor(i * ratio_w);
|
|
24672
|
-
var xx_stop = Math.ceil((i + 1) * ratio_w);
|
|
24673
|
-
for (var xx = xx_start; xx < xx_stop; xx++) {
|
|
24674
|
-
var dx = Math.abs(center_x - (xx + 0.5)) / ratio_w_half;
|
|
24675
|
-
var w = Math.sqrt(w0 + dx * dx);
|
|
24676
|
-
if (w >= 1) {
|
|
24677
|
-
continue;
|
|
24678
|
-
}
|
|
24679
|
-
weight = 2 * w * w * w - 3 * w * w + 1;
|
|
24680
|
-
var pos_x = 4 * (xx + yy * width_source);
|
|
24681
|
-
gx_a += weight * data[pos_x + 3];
|
|
24682
|
-
weights_alpha += weight;
|
|
24683
|
-
if (data[pos_x + 3] < 255) weight = weight * data[pos_x + 3] / 250;
|
|
24684
|
-
gx_r += weight * data[pos_x];
|
|
24685
|
-
gx_g += weight * data[pos_x + 1];
|
|
24686
|
-
gx_b += weight * data[pos_x + 2];
|
|
24687
|
-
weights += weight;
|
|
24688
|
-
}
|
|
24689
|
-
}
|
|
24690
|
-
data2[x2] = gx_r / weights;
|
|
24691
|
-
data2[x2 + 1] = gx_g / weights;
|
|
24692
|
-
data2[x2 + 2] = gx_b / weights;
|
|
24693
|
-
data2[x2 + 3] = gx_a / weights_alpha;
|
|
24694
|
-
}
|
|
24695
|
-
}
|
|
24696
|
-
{
|
|
24697
|
-
canvas.width = width;
|
|
24698
|
-
canvas.height = height;
|
|
24699
|
-
}
|
|
24700
|
-
ctx.putImageData(img2, 0, 0);
|
|
24701
|
-
}
|
|
24702
|
-
function multiStepResize(canvas, targetWidth, targetHeight) {
|
|
24703
|
-
const originalWidth = canvas.width;
|
|
24704
|
-
const originalHeight = canvas.height;
|
|
24705
|
-
const scaleX = targetWidth / originalWidth;
|
|
24706
|
-
const scaleY = targetHeight / originalHeight;
|
|
24707
|
-
const scaleFactor = Math.min(scaleX, scaleY);
|
|
24708
|
-
if (scaleFactor < 0.5) {
|
|
24709
|
-
let currentWidth = originalWidth;
|
|
24710
|
-
let currentHeight = originalHeight;
|
|
24711
|
-
while (currentWidth > targetWidth * 2 || currentHeight > targetHeight * 2) {
|
|
24712
|
-
const nextWidth = Math.round(currentWidth / 2);
|
|
24713
|
-
const nextHeight = Math.round(currentHeight / 2);
|
|
24714
|
-
resample_high_quality(canvas, nextWidth, nextHeight);
|
|
24715
|
-
currentWidth = nextWidth;
|
|
24716
|
-
currentHeight = nextHeight;
|
|
24717
|
-
}
|
|
24718
|
-
if (currentWidth !== targetWidth || currentHeight !== targetHeight) {
|
|
24719
|
-
resample_high_quality(canvas, targetWidth, targetHeight);
|
|
24720
|
-
}
|
|
24721
|
-
} else {
|
|
24722
|
-
resample_high_quality(canvas, targetWidth, targetHeight);
|
|
24723
|
-
}
|
|
24724
|
-
}
|
|
24725
|
-
const startImageUpload = async ({ editor, view, file }) => {
|
|
24726
|
-
const imageUploadHandler = typeof editor.options.handleImageUpload === "function" ? editor.options.handleImageUpload : handleImageUpload;
|
|
24727
|
-
let fileSizeMb = Number((file.size / (1024 * 1024)).toFixed(4));
|
|
24728
|
-
if (fileSizeMb > 5) {
|
|
24729
|
-
window.alert("Image size must be less than 5MB");
|
|
24730
|
-
return;
|
|
24731
|
-
}
|
|
24732
|
-
let width;
|
|
24733
|
-
let height;
|
|
24734
|
-
try {
|
|
24735
|
-
const processedImageResult = await processUploadedImage(file, editor);
|
|
24736
|
-
width = processedImageResult.width;
|
|
24737
|
-
height = processedImageResult.height;
|
|
24738
|
-
file = processedImageResult.file;
|
|
24739
|
-
} catch (err) {
|
|
24740
|
-
console.warn("Error processing image:", err);
|
|
24741
|
-
editor.emit("exception", { error: err, editor });
|
|
24742
|
-
return;
|
|
24743
|
-
}
|
|
24744
|
-
await uploadImage({
|
|
24745
|
-
editor,
|
|
24746
|
-
view,
|
|
24747
|
-
file,
|
|
24748
|
-
size: { width, height },
|
|
24749
|
-
uploadHandler: imageUploadHandler
|
|
24750
|
-
});
|
|
24751
|
-
};
|
|
24752
|
-
async function uploadImage({ editor, view, file, size, uploadHandler }) {
|
|
24753
|
-
let id = {};
|
|
24754
|
-
let { tr, schema } = view.state;
|
|
24755
|
-
let { selection } = tr;
|
|
24756
|
-
if (editor.options.isHeaderOrFooter) {
|
|
24757
|
-
selection = editor.options.lastSelection;
|
|
24758
|
-
}
|
|
24759
|
-
if (!selection.empty && !editor.options.isHeaderOrFooter) {
|
|
24760
|
-
tr.deleteSelection();
|
|
24761
|
-
}
|
|
24762
|
-
let imageMeta = {
|
|
24763
|
-
type: "add",
|
|
24764
|
-
pos: selection.from,
|
|
24765
|
-
id
|
|
24766
|
-
};
|
|
24767
|
-
tr.setMeta(ImagePlaceholderPluginKey, imageMeta);
|
|
24768
|
-
view.dispatch(tr);
|
|
24769
|
-
try {
|
|
24770
|
-
let url = await uploadHandler(file);
|
|
24771
|
-
let fileName = file.name.replace(" ", "_");
|
|
24772
|
-
let placeholderPos = findPlaceholder(view.state, id);
|
|
24773
|
-
if (placeholderPos == null) {
|
|
24774
|
-
return;
|
|
24775
|
-
}
|
|
24776
|
-
let removeMeta = { type: "remove", id };
|
|
24777
|
-
let mediaPath = `word/media/${fileName}`;
|
|
24778
|
-
let rId = null;
|
|
24779
|
-
if (editor.options.mode === "docx") {
|
|
24780
|
-
const [, path] = mediaPath.split("word/");
|
|
24781
|
-
const imageid = addImageRelationship({ editor, path });
|
|
24782
|
-
if (imageid) rId = imageid;
|
|
24783
|
-
}
|
|
24784
|
-
let imageNode = schema.nodes.image.create({
|
|
24785
|
-
src: mediaPath,
|
|
24786
|
-
size,
|
|
24787
|
-
rId
|
|
24788
|
-
});
|
|
24789
|
-
editor.storage.image.media = Object.assign(editor.storage.image.media, { [mediaPath]: url });
|
|
24790
|
-
if (editor.options.ydoc) {
|
|
24791
|
-
editor.commands.addImageToCollaboration({ mediaPath, fileData: url });
|
|
24792
|
-
}
|
|
24793
|
-
view.dispatch(
|
|
24794
|
-
view.state.tr.replaceWith(placeholderPos, placeholderPos, imageNode).setMeta(ImagePlaceholderPluginKey, removeMeta)
|
|
24795
|
-
);
|
|
24796
|
-
} catch (error) {
|
|
24797
|
-
let removeMeta = { type: "remove", id };
|
|
24798
|
-
view.dispatch(tr.setMeta(ImagePlaceholderPluginKey, removeMeta));
|
|
24799
|
-
editor.emit("exception", { error, editor });
|
|
24800
|
-
}
|
|
24801
|
-
}
|
|
24802
|
-
function addImageRelationship({ editor, path }) {
|
|
24803
|
-
const target = path;
|
|
24804
|
-
const type = "image";
|
|
24805
|
-
try {
|
|
24806
|
-
const relationshipId = insertNewRelationship(target, type, editor);
|
|
24807
|
-
return relationshipId;
|
|
24808
|
-
} catch {
|
|
24809
|
-
return null;
|
|
24810
|
-
}
|
|
24811
|
-
}
|
|
24812
25063
|
const BookmarkStart = Node$1.create({
|
|
24813
25064
|
name: "bookmarkStart",
|
|
24814
25065
|
group: "inline",
|
|
@@ -25123,8 +25374,8 @@ renderDom_fn = function(node, htmlAttributes) {
|
|
|
25123
25374
|
__privateMethod(this, _AutoPageNumberNodeView_instances, scheduleUpdateNodeStyle_fn).call(this, currentPos, marks);
|
|
25124
25375
|
Object.assign(nodeContent.style, styles);
|
|
25125
25376
|
nodeContent.appendChild(content);
|
|
25126
|
-
Object.entries(htmlAttributes).forEach(([
|
|
25127
|
-
if (value) nodeContent.setAttribute(
|
|
25377
|
+
Object.entries(htmlAttributes).forEach(([key2, value]) => {
|
|
25378
|
+
if (value) nodeContent.setAttribute(key2, value);
|
|
25128
25379
|
});
|
|
25129
25380
|
return nodeContent;
|
|
25130
25381
|
};
|
|
@@ -25190,8 +25441,8 @@ const processMarks = (marks) => {
|
|
|
25190
25441
|
break;
|
|
25191
25442
|
default:
|
|
25192
25443
|
if (attrs?.style) {
|
|
25193
|
-
Object.entries(attrs.style).forEach(([
|
|
25194
|
-
styles[
|
|
25444
|
+
Object.entries(attrs.style).forEach(([key2, value]) => {
|
|
25445
|
+
styles[key2] = value;
|
|
25195
25446
|
});
|
|
25196
25447
|
}
|
|
25197
25448
|
break;
|
|
@@ -27853,8 +28104,8 @@ function mergePaddingObject(paddingObject) {
|
|
|
27853
28104
|
return Object.assign({}, getFreshSideObject(), paddingObject);
|
|
27854
28105
|
}
|
|
27855
28106
|
function expandToHashMap(value, keys2) {
|
|
27856
|
-
return keys2.reduce(function(hashMap,
|
|
27857
|
-
hashMap[
|
|
28107
|
+
return keys2.reduce(function(hashMap, key2) {
|
|
28108
|
+
hashMap[key2] = value;
|
|
27858
28109
|
return hashMap;
|
|
27859
28110
|
}, {});
|
|
27860
28111
|
}
|
|
@@ -28310,10 +28561,10 @@ function detectOverflow$1(state, options) {
|
|
|
28310
28561
|
var offsetData = state.modifiersData.offset;
|
|
28311
28562
|
if (elementContext === popper && offsetData) {
|
|
28312
28563
|
var offset2 = offsetData[placement];
|
|
28313
|
-
Object.keys(overflowOffsets).forEach(function(
|
|
28314
|
-
var multiply = [right, bottom].indexOf(
|
|
28315
|
-
var axis = [top, bottom].indexOf(
|
|
28316
|
-
overflowOffsets[
|
|
28564
|
+
Object.keys(overflowOffsets).forEach(function(key2) {
|
|
28565
|
+
var multiply = [right, bottom].indexOf(key2) >= 0 ? 1 : -1;
|
|
28566
|
+
var axis = [top, bottom].indexOf(key2) >= 0 ? "y" : "x";
|
|
28567
|
+
overflowOffsets[key2] += offset2[axis] * multiply;
|
|
28317
28568
|
});
|
|
28318
28569
|
}
|
|
28319
28570
|
return overflowOffsets;
|
|
@@ -28760,8 +29011,8 @@ function mergeByName(modifiers2) {
|
|
|
28760
29011
|
}) : current;
|
|
28761
29012
|
return merged2;
|
|
28762
29013
|
}, {});
|
|
28763
|
-
return Object.keys(merged).map(function(
|
|
28764
|
-
return merged[
|
|
29014
|
+
return Object.keys(merged).map(function(key2) {
|
|
29015
|
+
return merged[key2];
|
|
28765
29016
|
});
|
|
28766
29017
|
}
|
|
28767
29018
|
var DEFAULT_OPTIONS = {
|
|
@@ -28918,8 +29169,8 @@ var TOUCH_OPTIONS = {
|
|
|
28918
29169
|
var TIPPY_DEFAULT_APPEND_TO = function TIPPY_DEFAULT_APPEND_TO2() {
|
|
28919
29170
|
return document.body;
|
|
28920
29171
|
};
|
|
28921
|
-
function hasOwnProperty(obj,
|
|
28922
|
-
return {}.hasOwnProperty.call(obj,
|
|
29172
|
+
function hasOwnProperty(obj, key2) {
|
|
29173
|
+
return {}.hasOwnProperty.call(obj, key2);
|
|
28923
29174
|
}
|
|
28924
29175
|
function getValueAtIndexOrReturn(value, index2, defaultValue) {
|
|
28925
29176
|
if (Array.isArray(value)) {
|
|
@@ -28949,8 +29200,8 @@ function debounce(fn2, ms) {
|
|
|
28949
29200
|
}
|
|
28950
29201
|
function removeProperties(obj, keys2) {
|
|
28951
29202
|
var clone = Object.assign({}, obj);
|
|
28952
|
-
keys2.forEach(function(
|
|
28953
|
-
delete clone[
|
|
29203
|
+
keys2.forEach(function(key2) {
|
|
29204
|
+
delete clone[key2];
|
|
28954
29205
|
});
|
|
28955
29206
|
return clone;
|
|
28956
29207
|
}
|
|
@@ -28977,9 +29228,9 @@ function arrayFrom(value) {
|
|
|
28977
29228
|
return [].slice.call(value);
|
|
28978
29229
|
}
|
|
28979
29230
|
function removeUndefinedProps(obj) {
|
|
28980
|
-
return Object.keys(obj).reduce(function(acc,
|
|
28981
|
-
if (obj[
|
|
28982
|
-
acc[
|
|
29231
|
+
return Object.keys(obj).reduce(function(acc, key2) {
|
|
29232
|
+
if (obj[key2] !== void 0) {
|
|
29233
|
+
acc[key2] = obj[key2];
|
|
28983
29234
|
}
|
|
28984
29235
|
return acc;
|
|
28985
29236
|
}, {});
|
|
@@ -29231,8 +29482,8 @@ var setDefaultProps = function setDefaultProps2(partialProps) {
|
|
|
29231
29482
|
validateProps(partialProps, []);
|
|
29232
29483
|
}
|
|
29233
29484
|
var keys2 = Object.keys(partialProps);
|
|
29234
|
-
keys2.forEach(function(
|
|
29235
|
-
defaultProps[
|
|
29485
|
+
keys2.forEach(function(key2) {
|
|
29486
|
+
defaultProps[key2] = partialProps[key2];
|
|
29236
29487
|
});
|
|
29237
29488
|
};
|
|
29238
29489
|
function getExtendedPassedProps(passedProps) {
|
|
@@ -29251,18 +29502,18 @@ function getDataAttributeProps(reference2, plugins) {
|
|
|
29251
29502
|
var propKeys = plugins ? Object.keys(getExtendedPassedProps(Object.assign({}, defaultProps, {
|
|
29252
29503
|
plugins
|
|
29253
29504
|
}))) : defaultKeys;
|
|
29254
|
-
var props = propKeys.reduce(function(acc,
|
|
29255
|
-
var valueAsString = (reference2.getAttribute("data-tippy-" +
|
|
29505
|
+
var props = propKeys.reduce(function(acc, key2) {
|
|
29506
|
+
var valueAsString = (reference2.getAttribute("data-tippy-" + key2) || "").trim();
|
|
29256
29507
|
if (!valueAsString) {
|
|
29257
29508
|
return acc;
|
|
29258
29509
|
}
|
|
29259
|
-
if (
|
|
29260
|
-
acc[
|
|
29510
|
+
if (key2 === "content") {
|
|
29511
|
+
acc[key2] = valueAsString;
|
|
29261
29512
|
} else {
|
|
29262
29513
|
try {
|
|
29263
|
-
acc[
|
|
29514
|
+
acc[key2] = JSON.parse(valueAsString);
|
|
29264
29515
|
} catch (e) {
|
|
29265
|
-
acc[
|
|
29516
|
+
acc[key2] = valueAsString;
|
|
29266
29517
|
}
|
|
29267
29518
|
}
|
|
29268
29519
|
return acc;
|
|
@@ -30186,8 +30437,8 @@ tippy.setDefaultProps({
|
|
|
30186
30437
|
});
|
|
30187
30438
|
const _export_sfc = (sfc, props) => {
|
|
30188
30439
|
const target = sfc.__vccOpts || sfc;
|
|
30189
|
-
for (const [
|
|
30190
|
-
target[
|
|
30440
|
+
for (const [key2, val] of props) {
|
|
30441
|
+
target[key2] = val;
|
|
30191
30442
|
}
|
|
30192
30443
|
return target;
|
|
30193
30444
|
};
|
|
@@ -31579,9 +31830,9 @@ const Pagination = Extension.create({
|
|
|
31579
31830
|
if (syncMeta && syncMeta.isChangeOrigin || listSyncMeta) {
|
|
31580
31831
|
return { ...oldState };
|
|
31581
31832
|
}
|
|
31582
|
-
const
|
|
31583
|
-
if (
|
|
31584
|
-
if (
|
|
31833
|
+
const imageRegistrationMetaType = getImageRegistrationMetaType(tr);
|
|
31834
|
+
if (imageRegistrationMetaType) {
|
|
31835
|
+
if (imageRegistrationMetaType === "remove") {
|
|
31585
31836
|
onImageLoad(editor);
|
|
31586
31837
|
}
|
|
31587
31838
|
return { ...oldState };
|
|
@@ -32982,18 +33233,20 @@ export {
|
|
|
32982
33233
|
getQuickFormatList as a,
|
|
32983
33234
|
generateLinkedStyleString as b,
|
|
32984
33235
|
getFileOpener as c,
|
|
32985
|
-
|
|
32986
|
-
|
|
32987
|
-
|
|
33236
|
+
checkAndProcessImage as d,
|
|
33237
|
+
uploadAndInsertImage as e,
|
|
33238
|
+
undoDepth as f,
|
|
32988
33239
|
global as g,
|
|
32989
|
-
|
|
32990
|
-
|
|
32991
|
-
|
|
32992
|
-
|
|
32993
|
-
|
|
32994
|
-
|
|
32995
|
-
|
|
32996
|
-
|
|
33240
|
+
redoDepth as h,
|
|
33241
|
+
getStarterExtensions as i,
|
|
33242
|
+
getRichTextExtensions as j,
|
|
33243
|
+
Extension as k,
|
|
33244
|
+
index$1 as l,
|
|
33245
|
+
index as m,
|
|
33246
|
+
AnnotatorHelpers as n,
|
|
33247
|
+
SectionHelpers as o,
|
|
33248
|
+
getAllowedImageDimensions as p,
|
|
33249
|
+
replaceSelectionWithImagePlaceholder as r,
|
|
32997
33250
|
useHighContrastMode as u,
|
|
32998
33251
|
yUndoPluginKey as y
|
|
32999
33252
|
};
|