@harbour-enterprises/superdoc 0.20.0-next.3 → 0.20.0-next.5
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-B9b7_8E2.cjs → PdfViewer-Blwty0A0.cjs} +1 -1
- package/dist/chunks/{PdfViewer-DbuZR81Q.es.js → PdfViewer-DcPZsBsK.es.js} +1 -1
- package/dist/chunks/{index-CLepjsej.cjs → index-BB5vhzVT.cjs} +2 -2
- package/dist/chunks/{index-CEAEymUl.es.js → index-BZzn2Rcn.es.js} +2 -2
- package/dist/chunks/{super-editor.es-C7rC3O3K.es.js → super-editor.es-BTcVSa_f.es.js} +2149 -1550
- package/dist/chunks/{super-editor.es-TdXXCNpJ.cjs → super-editor.es-BgBNGRxg.cjs} +2149 -1550
- package/dist/core/SuperDoc.d.ts.map +1 -1
- package/dist/style.css +38 -0
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-BZ638uQi.js → converter-BPTfSIJf.js} +919 -813
- package/dist/super-editor/chunks/{docx-zipper-B-DSvrA8.js → docx-zipper-ikgI-2vM.js} +1 -1
- package/dist/super-editor/chunks/{editor-JXnNPHDg.js → editor-hh7sL4Wv.js} +1013 -529
- package/dist/super-editor/chunks/{toolbar-CGu2Zc7R.js → toolbar-B-apzt27.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/helpers/index.d.ts +1 -0
- package/dist/super-editor/src/core/helpers/updateDOMAttributes.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/exporter.d.ts +7 -1
- package/dist/super-editor/src/core/super-converter/v2/importer/imageImporter.d.ts +0 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/index.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/drawing/drawing-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/drawing/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/anchor/anchor-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/anchor/helpers/handle-anchor-node.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/anchor/helpers/translate-anchor-node.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/anchor/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/helpers/decode-image-node-helpers.d.ts +18 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/helpers/encode-image-node-helpers.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/inline/helpers/handle-inline-node.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/inline/helpers/translate-inline-node.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/inline/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/wp/inline/inline-translator.d.ts +6 -0
- 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/structured-content/StructuredContentBlockView.d.ts +10 -0
- package/dist/super-editor/src/extensions/structured-content/StructuredContentInlineView.d.ts +10 -0
- package/dist/super-editor/src/extensions/structured-content/StructuredContentViewBase.d.ts +24 -0
- package/dist/super-editor/src/extensions/structured-content/structured-content-block.d.ts +3 -1
- package/dist/super-editor/src/extensions/structured-content/structured-content.d.ts +3 -1
- package/dist/super-editor/style.css +38 -0
- package/dist/super-editor/super-editor.es.js +65 -55
- 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 +2777 -2178
- 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 getColStyleDeclaration, ap as SelectionRange, aq as Transform, ar as isInTable$1, as as createColGroup, at as generateDocxRandomId, au as insertNewRelationship, av as htmlHandler } from "./converter-
|
|
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 getColStyleDeclaration, ap as SelectionRange, aq as Transform, ar as isInTable$1, as as createColGroup, at as generateDocxRandomId, au as insertNewRelationship, av as updateDOMAttributes, aw as htmlHandler } from "./converter-BPTfSIJf.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-ikgI-2vM.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
|
}
|
|
@@ -19435,11 +19435,11 @@ function updateTable(editor, node, table) {
|
|
|
19435
19435
|
const allExtensionsAttrs = editor.extensionService.attributes;
|
|
19436
19436
|
const tableExtensionAttrs = allExtensionsAttrs.filter((e) => e.type === "table");
|
|
19437
19437
|
const htmlAttributes = Attribute.getAttributesToRender(node, tableExtensionAttrs);
|
|
19438
|
-
Object.entries(htmlAttributes).forEach(([
|
|
19439
|
-
if (
|
|
19438
|
+
Object.entries(htmlAttributes).forEach(([key2, value]) => {
|
|
19439
|
+
if (key2 === "style") {
|
|
19440
19440
|
table.style.cssText = value;
|
|
19441
19441
|
} else {
|
|
19442
|
-
table.setAttribute(
|
|
19442
|
+
table.setAttribute(key2, value);
|
|
19443
19443
|
}
|
|
19444
19444
|
});
|
|
19445
19445
|
}
|
|
@@ -19511,22 +19511,22 @@ var readFromCache;
|
|
|
19511
19511
|
var addToCache;
|
|
19512
19512
|
if (typeof WeakMap != "undefined") {
|
|
19513
19513
|
let cache = /* @__PURE__ */ new WeakMap();
|
|
19514
|
-
readFromCache = (
|
|
19515
|
-
addToCache = (
|
|
19516
|
-
cache.set(
|
|
19514
|
+
readFromCache = (key2) => cache.get(key2);
|
|
19515
|
+
addToCache = (key2, value) => {
|
|
19516
|
+
cache.set(key2, value);
|
|
19517
19517
|
return value;
|
|
19518
19518
|
};
|
|
19519
19519
|
} else {
|
|
19520
19520
|
const cache = [];
|
|
19521
19521
|
const cacheSize = 10;
|
|
19522
19522
|
let cachePos = 0;
|
|
19523
|
-
readFromCache = (
|
|
19523
|
+
readFromCache = (key2) => {
|
|
19524
19524
|
for (let i = 0; i < cache.length; i += 2)
|
|
19525
|
-
if (cache[i] ==
|
|
19525
|
+
if (cache[i] == key2) return cache[i + 1];
|
|
19526
19526
|
};
|
|
19527
|
-
addToCache = (
|
|
19527
|
+
addToCache = (key2, value) => {
|
|
19528
19528
|
if (cachePos == cacheSize) cachePos = 0;
|
|
19529
|
-
cache[cachePos++] =
|
|
19529
|
+
cache[cachePos++] = key2;
|
|
19530
19530
|
return cache[cachePos++] = value;
|
|
19531
19531
|
};
|
|
19532
19532
|
}
|
|
@@ -21760,8 +21760,8 @@ const Table = Node$1.create({
|
|
|
21760
21760
|
default: {},
|
|
21761
21761
|
renderDOM({ borders }) {
|
|
21762
21762
|
if (!borders) return {};
|
|
21763
|
-
const style = Object.entries(borders).reduce((acc, [
|
|
21764
|
-
return `${acc}border-${
|
|
21763
|
+
const style = Object.entries(borders).reduce((acc, [key2, { size, color }]) => {
|
|
21764
|
+
return `${acc}border-${key2}: ${Math.ceil(size)}px solid ${color || "black"};`;
|
|
21765
21765
|
}, "");
|
|
21766
21766
|
return {
|
|
21767
21767
|
style
|
|
@@ -22876,11 +22876,11 @@ createAnnotation_fn = function({ displayLabel } = {}) {
|
|
|
22876
22876
|
let mergedAttrs = Attribute.mergeAttributes(this.htmlAttributes, {
|
|
22877
22877
|
style: omitHighlight ? "" : annotationStyle
|
|
22878
22878
|
});
|
|
22879
|
-
for (let [
|
|
22880
|
-
if (
|
|
22879
|
+
for (let [key2, value] of Object.entries(mergedAttrs)) {
|
|
22880
|
+
if (key2 === "style") {
|
|
22881
22881
|
annotation.style.cssText = value;
|
|
22882
22882
|
} else {
|
|
22883
|
-
annotation.setAttribute(
|
|
22883
|
+
annotation.setAttribute(key2, value);
|
|
22884
22884
|
}
|
|
22885
22885
|
}
|
|
22886
22886
|
return {
|
|
@@ -23054,13 +23054,13 @@ function hash$2(str) {
|
|
|
23054
23054
|
}
|
|
23055
23055
|
const colorToInt = (x) => parseInt(x.replace(/_/g, ""), 36);
|
|
23056
23056
|
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
|
|
23057
|
+
const key2 = colorToInt(next.substring(0, 3));
|
|
23058
23058
|
const hex = colorToInt(next.substring(3)).toString(16);
|
|
23059
23059
|
let prefix = "";
|
|
23060
23060
|
for (let i = 0; i < 6 - hex.length; i++) {
|
|
23061
23061
|
prefix += "0";
|
|
23062
23062
|
}
|
|
23063
|
-
acc[
|
|
23063
|
+
acc[key2] = `${prefix}${hex}`;
|
|
23064
23064
|
return acc;
|
|
23065
23065
|
}, {});
|
|
23066
23066
|
function nameToHex(color) {
|
|
@@ -24176,41 +24176,480 @@ function getFormatAttrsFromMarks(marks) {
|
|
|
24176
24176
|
}
|
|
24177
24177
|
return formatAttrs;
|
|
24178
24178
|
}
|
|
24179
|
-
const
|
|
24180
|
-
|
|
24179
|
+
const simpleHash = (str) => {
|
|
24180
|
+
let hash2 = 0;
|
|
24181
|
+
for (let i = 0; i < str.length; i++) {
|
|
24182
|
+
const char = str.charCodeAt(i);
|
|
24183
|
+
hash2 = (hash2 << 5) - hash2 + char;
|
|
24184
|
+
hash2 = hash2 & hash2;
|
|
24185
|
+
}
|
|
24186
|
+
return Math.abs(hash2).toString();
|
|
24187
|
+
};
|
|
24188
|
+
const base64ToFile = (base64String) => {
|
|
24189
|
+
const arr = base64String.split(",");
|
|
24190
|
+
const mimeMatch = arr[0].match(/:(.*?);/);
|
|
24191
|
+
const mimeType = mimeMatch ? mimeMatch[1] : "";
|
|
24192
|
+
const data = arr[1];
|
|
24193
|
+
const binaryString = atob(data);
|
|
24194
|
+
const hash2 = simpleHash(binaryString);
|
|
24195
|
+
const extension = mimeType.split("/")[1] || "bin";
|
|
24196
|
+
const filename = `image-${hash2}.${extension}`;
|
|
24197
|
+
const bytes = new Uint8Array(binaryString.length);
|
|
24198
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
24199
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
24200
|
+
}
|
|
24201
|
+
const blob = new Blob([bytes], { type: mimeType });
|
|
24202
|
+
return new File([blob], filename, { type: mimeType });
|
|
24203
|
+
};
|
|
24204
|
+
const urlToFile = async (url, filename, mimeType) => {
|
|
24205
|
+
try {
|
|
24206
|
+
const response = await fetch(url, {
|
|
24207
|
+
mode: "cors",
|
|
24208
|
+
credentials: "omit",
|
|
24209
|
+
headers: {
|
|
24210
|
+
// Add common headers that might help with CORS
|
|
24211
|
+
Accept: "image/*,*/*;q=0.8"
|
|
24212
|
+
}
|
|
24213
|
+
});
|
|
24214
|
+
if (!response.ok) {
|
|
24215
|
+
console.warn(`Failed to fetch image from ${url}: ${response.status} ${response.statusText}`);
|
|
24216
|
+
return null;
|
|
24217
|
+
}
|
|
24218
|
+
const blob = await response.blob();
|
|
24219
|
+
const finalFilename = filename || extractFilenameFromUrl(url);
|
|
24220
|
+
const finalMimeType = mimeType || response.headers.get("content-type") || blob.type || "image/jpeg";
|
|
24221
|
+
return new File([blob], finalFilename, { type: finalMimeType });
|
|
24222
|
+
} catch (error) {
|
|
24223
|
+
if (isCorsError(error)) {
|
|
24224
|
+
console.warn(`CORS policy prevents accessing image from ${url}:`, error.message);
|
|
24225
|
+
return null;
|
|
24226
|
+
}
|
|
24227
|
+
console.error(`Error fetching image from ${url}:`, error);
|
|
24228
|
+
return null;
|
|
24229
|
+
}
|
|
24230
|
+
};
|
|
24231
|
+
const isCorsError = (error) => {
|
|
24232
|
+
const errorMessage = error.message.toLowerCase();
|
|
24233
|
+
const errorName = error.name.toLowerCase();
|
|
24234
|
+
return errorName.includes("cors") || errorMessage.includes("cors") || errorMessage.includes("cross-origin") || errorMessage.includes("access-control") || errorMessage.includes("network error") || // Often indicates CORS in browsers
|
|
24235
|
+
errorMessage.includes("failed to fetch");
|
|
24236
|
+
};
|
|
24237
|
+
const extractFilenameFromUrl = (url) => {
|
|
24238
|
+
try {
|
|
24239
|
+
const urlObj = new URL(url);
|
|
24240
|
+
const pathname = urlObj.pathname;
|
|
24241
|
+
const filename = pathname.split("/").pop();
|
|
24242
|
+
if (filename && !filename.includes(".")) {
|
|
24243
|
+
return `${filename}.jpg`;
|
|
24244
|
+
}
|
|
24245
|
+
return filename || "image.jpg";
|
|
24246
|
+
} catch {
|
|
24247
|
+
return "image.jpg";
|
|
24248
|
+
}
|
|
24249
|
+
};
|
|
24250
|
+
const validateUrlAccessibility = async (url) => {
|
|
24251
|
+
try {
|
|
24252
|
+
const response = await fetch(url, {
|
|
24253
|
+
method: "HEAD",
|
|
24254
|
+
mode: "cors",
|
|
24255
|
+
credentials: "omit"
|
|
24256
|
+
});
|
|
24257
|
+
return response.ok;
|
|
24258
|
+
} catch (_error) {
|
|
24259
|
+
return false;
|
|
24260
|
+
}
|
|
24261
|
+
};
|
|
24262
|
+
const handleImageUpload = (file) => {
|
|
24263
|
+
return new Promise((resolve, reject) => {
|
|
24264
|
+
let reader = new FileReader();
|
|
24265
|
+
reader.onload = (event) => {
|
|
24266
|
+
resolve(event.target.result);
|
|
24267
|
+
};
|
|
24268
|
+
reader.onerror = reject;
|
|
24269
|
+
setTimeout(() => reader.readAsDataURL(file), 250);
|
|
24270
|
+
});
|
|
24271
|
+
};
|
|
24272
|
+
const processUploadedImage = (fileData, getMaxContentSize) => {
|
|
24273
|
+
return new Promise((resolve, reject) => {
|
|
24274
|
+
const img = new window.Image();
|
|
24275
|
+
img.onload = () => {
|
|
24276
|
+
const canvas = document.createElement("canvas");
|
|
24277
|
+
const { width: logicalWidth, height: logicalHeight } = getAllowedImageDimensions(
|
|
24278
|
+
img.width,
|
|
24279
|
+
img.height,
|
|
24280
|
+
getMaxContentSize
|
|
24281
|
+
);
|
|
24282
|
+
canvas.width = img.width;
|
|
24283
|
+
canvas.height = img.height;
|
|
24284
|
+
const ctx = canvas.getContext("2d");
|
|
24285
|
+
if (ctx) {
|
|
24286
|
+
ctx.imageSmoothingEnabled = true;
|
|
24287
|
+
try {
|
|
24288
|
+
ctx.imageSmoothingQuality = "high";
|
|
24289
|
+
} catch {
|
|
24290
|
+
}
|
|
24291
|
+
}
|
|
24292
|
+
ctx.drawImage(img, 0, 0, img.width, img.height);
|
|
24293
|
+
const dpr = typeof window !== "undefined" && window.devicePixelRatio ? window.devicePixelRatio : 1;
|
|
24294
|
+
const targetPixelWidth = Math.round(logicalWidth * dpr);
|
|
24295
|
+
const targetPixelHeight = Math.round(logicalHeight * dpr);
|
|
24296
|
+
const finalTargetWidth = Math.min(targetPixelWidth, img.width);
|
|
24297
|
+
const finalTargetHeight = Math.min(targetPixelHeight, img.height);
|
|
24298
|
+
const resizeNeeded = finalTargetWidth !== img.width || finalTargetHeight !== img.height;
|
|
24299
|
+
if (resizeNeeded) {
|
|
24300
|
+
multiStepResize(canvas, finalTargetWidth, finalTargetHeight);
|
|
24301
|
+
}
|
|
24302
|
+
if (typeof fileData === "string") {
|
|
24303
|
+
const resizedBase64 = canvas.toDataURL();
|
|
24304
|
+
resolve(resizedBase64);
|
|
24305
|
+
} else {
|
|
24306
|
+
canvas.toBlob((blob) => {
|
|
24307
|
+
const updatedFile = new File([blob], fileData.name, {
|
|
24308
|
+
type: fileData.type,
|
|
24309
|
+
lastModified: Date.now()
|
|
24310
|
+
});
|
|
24311
|
+
resolve({ file: updatedFile, width: logicalWidth, height: logicalHeight });
|
|
24312
|
+
});
|
|
24313
|
+
}
|
|
24314
|
+
};
|
|
24315
|
+
img.onerror = (error) => reject(error);
|
|
24316
|
+
img.src = typeof fileData === "string" ? fileData : URL.createObjectURL(fileData);
|
|
24317
|
+
});
|
|
24318
|
+
};
|
|
24319
|
+
const getAllowedImageDimensions = (width, height, getMaxContentSize) => {
|
|
24320
|
+
const { width: maxWidth, height: maxHeight } = getMaxContentSize();
|
|
24321
|
+
if (!maxWidth || !maxHeight) return { width, height };
|
|
24322
|
+
let adjustedWidth = width;
|
|
24323
|
+
let adjustedHeight = height;
|
|
24324
|
+
const aspectRatio = width / height;
|
|
24325
|
+
if (height > maxHeight) {
|
|
24326
|
+
adjustedHeight = maxHeight;
|
|
24327
|
+
adjustedWidth = Math.round(maxHeight * aspectRatio);
|
|
24328
|
+
}
|
|
24329
|
+
if (adjustedWidth > maxWidth) {
|
|
24330
|
+
adjustedWidth = maxWidth;
|
|
24331
|
+
adjustedHeight = Math.round(maxWidth / aspectRatio);
|
|
24332
|
+
}
|
|
24333
|
+
return { width: adjustedWidth, height: adjustedHeight };
|
|
24334
|
+
};
|
|
24335
|
+
function resample_high_quality(canvas, width, height, resize_canvas) {
|
|
24336
|
+
var width_source = canvas.width;
|
|
24337
|
+
var height_source = canvas.height;
|
|
24338
|
+
width = Math.round(width);
|
|
24339
|
+
height = Math.round(height);
|
|
24340
|
+
var ratio_w = width_source / width;
|
|
24341
|
+
var ratio_h = height_source / height;
|
|
24342
|
+
var ratio_w_half = Math.ceil(ratio_w / 2);
|
|
24343
|
+
var ratio_h_half = Math.ceil(ratio_h / 2);
|
|
24344
|
+
var ctx = canvas.getContext("2d");
|
|
24345
|
+
var img = ctx.getImageData(0, 0, width_source, height_source);
|
|
24346
|
+
var img2 = ctx.createImageData(width, height);
|
|
24347
|
+
var data = img.data;
|
|
24348
|
+
var data2 = img2.data;
|
|
24349
|
+
for (var j = 0; j < height; j++) {
|
|
24350
|
+
for (var i = 0; i < width; i++) {
|
|
24351
|
+
var x2 = (i + j * width) * 4;
|
|
24352
|
+
var weight = 0;
|
|
24353
|
+
var weights = 0;
|
|
24354
|
+
var weights_alpha = 0;
|
|
24355
|
+
var gx_r = 0;
|
|
24356
|
+
var gx_g = 0;
|
|
24357
|
+
var gx_b = 0;
|
|
24358
|
+
var gx_a = 0;
|
|
24359
|
+
var center_y = (j + 0.5) * ratio_h;
|
|
24360
|
+
var yy_start = Math.floor(j * ratio_h);
|
|
24361
|
+
var yy_stop = Math.ceil((j + 1) * ratio_h);
|
|
24362
|
+
for (var yy = yy_start; yy < yy_stop; yy++) {
|
|
24363
|
+
var dy = Math.abs(center_y - (yy + 0.5)) / ratio_h_half;
|
|
24364
|
+
var center_x = (i + 0.5) * ratio_w;
|
|
24365
|
+
var w0 = dy * dy;
|
|
24366
|
+
var xx_start = Math.floor(i * ratio_w);
|
|
24367
|
+
var xx_stop = Math.ceil((i + 1) * ratio_w);
|
|
24368
|
+
for (var xx = xx_start; xx < xx_stop; xx++) {
|
|
24369
|
+
var dx = Math.abs(center_x - (xx + 0.5)) / ratio_w_half;
|
|
24370
|
+
var w = Math.sqrt(w0 + dx * dx);
|
|
24371
|
+
if (w >= 1) {
|
|
24372
|
+
continue;
|
|
24373
|
+
}
|
|
24374
|
+
weight = 2 * w * w * w - 3 * w * w + 1;
|
|
24375
|
+
var pos_x = 4 * (xx + yy * width_source);
|
|
24376
|
+
gx_a += weight * data[pos_x + 3];
|
|
24377
|
+
weights_alpha += weight;
|
|
24378
|
+
if (data[pos_x + 3] < 255) weight = weight * data[pos_x + 3] / 250;
|
|
24379
|
+
gx_r += weight * data[pos_x];
|
|
24380
|
+
gx_g += weight * data[pos_x + 1];
|
|
24381
|
+
gx_b += weight * data[pos_x + 2];
|
|
24382
|
+
weights += weight;
|
|
24383
|
+
}
|
|
24384
|
+
}
|
|
24385
|
+
data2[x2] = gx_r / weights;
|
|
24386
|
+
data2[x2 + 1] = gx_g / weights;
|
|
24387
|
+
data2[x2 + 2] = gx_b / weights;
|
|
24388
|
+
data2[x2 + 3] = gx_a / weights_alpha;
|
|
24389
|
+
}
|
|
24390
|
+
}
|
|
24391
|
+
{
|
|
24392
|
+
canvas.width = width;
|
|
24393
|
+
canvas.height = height;
|
|
24394
|
+
}
|
|
24395
|
+
ctx.putImageData(img2, 0, 0);
|
|
24396
|
+
}
|
|
24397
|
+
function multiStepResize(canvas, width, height) {
|
|
24398
|
+
let oc = document.createElement("canvas");
|
|
24399
|
+
let octx = oc.getContext("2d");
|
|
24400
|
+
let ctx = canvas.getContext("2d");
|
|
24401
|
+
let steps = Math.ceil(Math.log(canvas.width / width) / Math.log(2));
|
|
24402
|
+
steps = Math.max(steps, 1);
|
|
24403
|
+
let stepWidth = width * Math.pow(2, steps - 1);
|
|
24404
|
+
let stepHeight = height * Math.pow(2, steps - 1);
|
|
24405
|
+
let currentWidth = canvas.width;
|
|
24406
|
+
let currentHeight = canvas.height;
|
|
24407
|
+
oc.width = currentWidth;
|
|
24408
|
+
oc.height = currentHeight;
|
|
24409
|
+
octx.drawImage(canvas, 0, 0);
|
|
24410
|
+
while (steps > 0) {
|
|
24411
|
+
stepWidth = Math.max(stepWidth, width);
|
|
24412
|
+
stepHeight = Math.max(stepHeight, height);
|
|
24413
|
+
canvas.width = stepWidth;
|
|
24414
|
+
canvas.height = stepHeight;
|
|
24415
|
+
ctx.drawImage(oc, 0, 0, currentWidth, currentHeight, 0, 0, stepWidth, stepHeight);
|
|
24416
|
+
currentWidth = stepWidth;
|
|
24417
|
+
currentHeight = stepHeight;
|
|
24418
|
+
oc.width = currentWidth;
|
|
24419
|
+
oc.height = currentHeight;
|
|
24420
|
+
octx.drawImage(canvas, 0, 0);
|
|
24421
|
+
stepWidth = Math.round(stepWidth / 2);
|
|
24422
|
+
stepHeight = Math.round(stepHeight / 2);
|
|
24423
|
+
steps--;
|
|
24424
|
+
}
|
|
24425
|
+
resample_high_quality(canvas, width, height);
|
|
24426
|
+
}
|
|
24427
|
+
const fileTooLarge = (file) => {
|
|
24428
|
+
let fileSizeMb = Number((file.size / (1024 * 1024)).toFixed(4));
|
|
24429
|
+
if (fileSizeMb > 5) {
|
|
24430
|
+
window.alert("Image size must be less than 5MB");
|
|
24431
|
+
return true;
|
|
24432
|
+
}
|
|
24433
|
+
return false;
|
|
24434
|
+
};
|
|
24435
|
+
const checkAndProcessImage = async ({ getMaxContentSize, file }) => {
|
|
24436
|
+
if (fileTooLarge(file)) {
|
|
24437
|
+
return { file: null, size: { width: 0, height: 0 } };
|
|
24438
|
+
}
|
|
24439
|
+
try {
|
|
24440
|
+
const processedImageResult = await processUploadedImage(file, getMaxContentSize);
|
|
24441
|
+
const process = processedImageResult;
|
|
24442
|
+
return { file: process.file, size: { width: process.width, height: process.height } };
|
|
24443
|
+
} catch (err) {
|
|
24444
|
+
console.warn("Error processing image:", err);
|
|
24445
|
+
return { file: null, size: { width: 0, height: 0 } };
|
|
24446
|
+
}
|
|
24447
|
+
};
|
|
24448
|
+
function replaceSelectionWithImagePlaceholder({ editorOptions, view, id }) {
|
|
24449
|
+
let { tr } = view.state;
|
|
24450
|
+
let { selection } = tr;
|
|
24451
|
+
if (editorOptions.isHeaderOrFooter) {
|
|
24452
|
+
selection = editorOptions.lastSelection;
|
|
24453
|
+
}
|
|
24454
|
+
if (!selection.empty && !editorOptions.isHeaderOrFooter) {
|
|
24455
|
+
tr.deleteSelection();
|
|
24456
|
+
}
|
|
24457
|
+
tr = addImagePlaceholder(view.state, tr, id, selection.from);
|
|
24458
|
+
view.dispatch(tr);
|
|
24459
|
+
}
|
|
24460
|
+
async function uploadAndInsertImage({ editor, view, file, size, id }) {
|
|
24461
|
+
const imageUploadHandler = typeof editor.options.handleImageUpload === "function" ? editor.options.handleImageUpload : handleImageUpload;
|
|
24462
|
+
try {
|
|
24463
|
+
let url = await imageUploadHandler(file);
|
|
24464
|
+
let fileName = file.name.replace(" ", "_");
|
|
24465
|
+
let placeholderPos = findPlaceholder(view.state, id);
|
|
24466
|
+
if (placeholderPos == null) {
|
|
24467
|
+
return;
|
|
24468
|
+
}
|
|
24469
|
+
let mediaPath = `word/media/${fileName}`;
|
|
24470
|
+
let rId = null;
|
|
24471
|
+
if (editor.options.mode === "docx") {
|
|
24472
|
+
const [, path] = mediaPath.split("word/");
|
|
24473
|
+
const id2 = addImageRelationship({ editor, path });
|
|
24474
|
+
if (id2) rId = id2;
|
|
24475
|
+
}
|
|
24476
|
+
let imageNode = view.state.schema.nodes.image.create({
|
|
24477
|
+
src: mediaPath,
|
|
24478
|
+
size,
|
|
24479
|
+
id,
|
|
24480
|
+
rId
|
|
24481
|
+
});
|
|
24482
|
+
editor.storage.image.media = Object.assign(editor.storage.image.media, { [mediaPath]: url });
|
|
24483
|
+
if (editor.options.ydoc && typeof editor.commands.addImageToCollaboration === "function") {
|
|
24484
|
+
editor.commands.addImageToCollaboration({ mediaPath, fileData: url });
|
|
24485
|
+
}
|
|
24486
|
+
let tr = view.state.tr;
|
|
24487
|
+
tr.replaceWith(placeholderPos, placeholderPos, imageNode);
|
|
24488
|
+
tr = removeImagePlaceholder(view.state, tr, id);
|
|
24489
|
+
view.dispatch(tr);
|
|
24490
|
+
} catch {
|
|
24491
|
+
const tr = removeImagePlaceholder(view.state, view.state.tr, id);
|
|
24492
|
+
view.dispatch(tr);
|
|
24493
|
+
}
|
|
24494
|
+
}
|
|
24495
|
+
function addImageRelationship({ editor, path }) {
|
|
24496
|
+
const target = path;
|
|
24497
|
+
const type = "image";
|
|
24498
|
+
try {
|
|
24499
|
+
const id = insertNewRelationship(target, type, editor);
|
|
24500
|
+
return id;
|
|
24501
|
+
} catch {
|
|
24502
|
+
return null;
|
|
24503
|
+
}
|
|
24504
|
+
}
|
|
24505
|
+
const key = new PluginKey("ImageRegistration");
|
|
24506
|
+
const ImageRegistrationPlugin = ({ editor }) => {
|
|
24507
|
+
const { view } = editor;
|
|
24181
24508
|
return new Plugin({
|
|
24182
|
-
key
|
|
24509
|
+
key,
|
|
24183
24510
|
state: {
|
|
24184
24511
|
init() {
|
|
24185
|
-
return DecorationSet.empty;
|
|
24512
|
+
return { set: DecorationSet.empty };
|
|
24186
24513
|
},
|
|
24187
|
-
apply(tr, set) {
|
|
24514
|
+
apply(tr, { set }) {
|
|
24515
|
+
const meta = tr.getMeta(key);
|
|
24516
|
+
if (meta) {
|
|
24517
|
+
set = meta.set;
|
|
24518
|
+
return { set };
|
|
24519
|
+
}
|
|
24188
24520
|
set = set.map(tr.mapping, tr.doc);
|
|
24189
|
-
|
|
24190
|
-
|
|
24191
|
-
|
|
24192
|
-
|
|
24193
|
-
|
|
24521
|
+
return { set };
|
|
24522
|
+
}
|
|
24523
|
+
},
|
|
24524
|
+
appendTransaction: (trs, _oldState, state) => {
|
|
24525
|
+
let foundImages = [];
|
|
24526
|
+
trs.forEach((tr2) => {
|
|
24527
|
+
if (tr2.docChanged) {
|
|
24528
|
+
tr2.steps.forEach((step, index2) => {
|
|
24529
|
+
const stepMap = step.getMap();
|
|
24530
|
+
foundImages = foundImages.map(({ node, pos, id }) => {
|
|
24531
|
+
const mappedPos = stepMap.map(pos, -1);
|
|
24532
|
+
return { node, pos: mappedPos, id };
|
|
24533
|
+
});
|
|
24534
|
+
if (step instanceof ReplaceStep || step instanceof ReplaceAroundStep$1) {
|
|
24535
|
+
(tr2.docs[index2 + 1] || tr2.doc).nodesBetween(
|
|
24536
|
+
stepMap.map(step.from, -1),
|
|
24537
|
+
stepMap.map(step.to, 1),
|
|
24538
|
+
(node, pos) => {
|
|
24539
|
+
if (node.type.name === "image" && !node.attrs.src.startsWith("word/media")) {
|
|
24540
|
+
const id = {};
|
|
24541
|
+
foundImages.push({ node, pos, id });
|
|
24542
|
+
} else {
|
|
24543
|
+
return true;
|
|
24544
|
+
}
|
|
24545
|
+
}
|
|
24546
|
+
);
|
|
24547
|
+
}
|
|
24194
24548
|
});
|
|
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
24549
|
}
|
|
24199
|
-
|
|
24550
|
+
});
|
|
24551
|
+
if (!foundImages || foundImages.length === 0) {
|
|
24552
|
+
return null;
|
|
24200
24553
|
}
|
|
24554
|
+
registerImages(foundImages, editor, view);
|
|
24555
|
+
const tr = state.tr;
|
|
24556
|
+
let { set } = key.getState(state);
|
|
24557
|
+
foundImages.slice().sort((a, b) => a.pos - b.pos).forEach(({ pos, id }) => {
|
|
24558
|
+
let deco = Decoration.widget(pos, () => document.createElement("placeholder"), {
|
|
24559
|
+
side: -1,
|
|
24560
|
+
id
|
|
24561
|
+
});
|
|
24562
|
+
set = set.add(tr.doc, [deco]);
|
|
24563
|
+
});
|
|
24564
|
+
foundImages.slice().sort((a, b) => b.pos - a.pos).forEach(({ node, pos }) => {
|
|
24565
|
+
tr.delete(pos, pos + node.nodeSize);
|
|
24566
|
+
});
|
|
24567
|
+
set = set.map(tr.mapping, tr.doc);
|
|
24568
|
+
tr.setMeta(key, { set });
|
|
24569
|
+
return tr;
|
|
24201
24570
|
},
|
|
24202
24571
|
props: {
|
|
24203
24572
|
decorations(state) {
|
|
24204
|
-
|
|
24573
|
+
let { set } = key.getState(state);
|
|
24574
|
+
return set;
|
|
24205
24575
|
}
|
|
24206
24576
|
}
|
|
24207
24577
|
});
|
|
24208
24578
|
};
|
|
24209
24579
|
const findPlaceholder = (state, id) => {
|
|
24210
|
-
let
|
|
24211
|
-
let found =
|
|
24580
|
+
let { set } = key.getState(state);
|
|
24581
|
+
let found = set?.find(null, null, (spec) => spec.id === id);
|
|
24212
24582
|
return found?.length ? found[0].from : null;
|
|
24213
24583
|
};
|
|
24584
|
+
const removeImagePlaceholder = (state, tr, id) => {
|
|
24585
|
+
let { set } = key.getState(state);
|
|
24586
|
+
set = set.map(tr.mapping, tr.doc);
|
|
24587
|
+
set = set.remove(set.find(null, null, (spec) => spec.id == id));
|
|
24588
|
+
return tr.setMeta(key, { set, type: "remove" });
|
|
24589
|
+
};
|
|
24590
|
+
const addImagePlaceholder = (state, tr, id, pos) => {
|
|
24591
|
+
let { set } = key.getState(state);
|
|
24592
|
+
set = set.map(tr.mapping, tr.doc);
|
|
24593
|
+
let deco = Decoration.widget(pos, () => document.createElement("placeholder"), {
|
|
24594
|
+
id
|
|
24595
|
+
});
|
|
24596
|
+
set = set.add(tr.doc, [deco]);
|
|
24597
|
+
return tr.setMeta(key, { set, type: "add" });
|
|
24598
|
+
};
|
|
24599
|
+
const getImageRegistrationMetaType = (tr) => {
|
|
24600
|
+
const meta = tr.getMeta(key);
|
|
24601
|
+
if (meta && meta.type) {
|
|
24602
|
+
return meta.type;
|
|
24603
|
+
}
|
|
24604
|
+
return null;
|
|
24605
|
+
};
|
|
24606
|
+
const registerImages = async (foundImages, editor, view) => {
|
|
24607
|
+
foundImages.forEach(async (image) => {
|
|
24608
|
+
const src = image.node.attrs.src;
|
|
24609
|
+
const id = image.id;
|
|
24610
|
+
let file = null;
|
|
24611
|
+
if (src.startsWith("http")) {
|
|
24612
|
+
const isAccessible = await validateUrlAccessibility(src);
|
|
24613
|
+
if (isAccessible) {
|
|
24614
|
+
file = await urlToFile(src);
|
|
24615
|
+
} else {
|
|
24616
|
+
console.warn(`Image URL ${src} is not accessible due to CORS or other restrictions. Using original URL.`);
|
|
24617
|
+
const tr = view.state.tr;
|
|
24618
|
+
removeImagePlaceholder(view.state, tr, id);
|
|
24619
|
+
view.dispatch(tr);
|
|
24620
|
+
return;
|
|
24621
|
+
}
|
|
24622
|
+
} else if (src.startsWith("data:")) {
|
|
24623
|
+
file = base64ToFile(src);
|
|
24624
|
+
} else {
|
|
24625
|
+
console.error(`Unsupported image source: ${src}`);
|
|
24626
|
+
}
|
|
24627
|
+
if (!file) {
|
|
24628
|
+
const tr = view.state.tr;
|
|
24629
|
+
removeImagePlaceholder(view.state, tr, id);
|
|
24630
|
+
view.dispatch(tr);
|
|
24631
|
+
return;
|
|
24632
|
+
}
|
|
24633
|
+
try {
|
|
24634
|
+
const process = await checkAndProcessImage({
|
|
24635
|
+
getMaxContentSize: () => editor.getMaxContentSize(),
|
|
24636
|
+
file
|
|
24637
|
+
});
|
|
24638
|
+
if (!process.file) {
|
|
24639
|
+
const tr = view.state.tr;
|
|
24640
|
+
removeImagePlaceholder(view.state, tr, id);
|
|
24641
|
+
view.dispatch(tr);
|
|
24642
|
+
return;
|
|
24643
|
+
}
|
|
24644
|
+
await uploadAndInsertImage({ editor, view, file: process.file, size: process.size, id });
|
|
24645
|
+
} catch (error) {
|
|
24646
|
+
console.error(`Error processing image from ${src}:`, error);
|
|
24647
|
+
const tr = view.state.tr;
|
|
24648
|
+
removeImagePlaceholder(view.state, tr, id);
|
|
24649
|
+
view.dispatch(tr);
|
|
24650
|
+
}
|
|
24651
|
+
});
|
|
24652
|
+
};
|
|
24214
24653
|
const ImagePositionPluginKey = new PluginKey("ImagePosition");
|
|
24215
24654
|
const ImagePositionPlugin = ({ editor }) => {
|
|
24216
24655
|
const { view } = editor;
|
|
@@ -24476,339 +24915,98 @@ const Image = Node$1.create({
|
|
|
24476
24915
|
default: {},
|
|
24477
24916
|
renderDOM: ({ marginOffset, anchorData }) => {
|
|
24478
24917
|
const relativeFromPageV = anchorData?.vRelativeFrom === "page";
|
|
24479
|
-
const maxMarginV = 500;
|
|
24480
|
-
const { left: left2 = 0, top: top2 = 0 } = marginOffset ?? {};
|
|
24481
|
-
let style = "";
|
|
24482
|
-
if (left2) style += `margin-left: ${left2}px;`;
|
|
24483
|
-
if (top2) {
|
|
24484
|
-
if (relativeFromPageV && top2 >= maxMarginV) style += `margin-top: ${maxMarginV}px;`;
|
|
24485
|
-
else style += `margin-top: ${top2}px;`;
|
|
24486
|
-
}
|
|
24487
|
-
return { style };
|
|
24488
|
-
}
|
|
24489
|
-
},
|
|
24490
|
-
/**
|
|
24491
|
-
* @category Attribute
|
|
24492
|
-
* @param {string} [style] - Custom inline CSS styles
|
|
24493
|
-
*/
|
|
24494
|
-
style: {
|
|
24495
|
-
default: null,
|
|
24496
|
-
rendered: true,
|
|
24497
|
-
renderDOM: ({ style }) => {
|
|
24498
|
-
if (!style) return {};
|
|
24499
|
-
return { style };
|
|
24500
|
-
}
|
|
24501
|
-
}
|
|
24502
|
-
};
|
|
24503
|
-
},
|
|
24504
|
-
parseDOM() {
|
|
24505
|
-
return [
|
|
24506
|
-
{
|
|
24507
|
-
tag: this.options.allowBase64 ? "img[src]" : 'img[src]:not([src^="data:"])'
|
|
24508
|
-
}
|
|
24509
|
-
];
|
|
24510
|
-
},
|
|
24511
|
-
renderDOM({ htmlAttributes }) {
|
|
24512
|
-
return ["img", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
|
|
24513
|
-
},
|
|
24514
|
-
addCommands() {
|
|
24515
|
-
return {
|
|
24516
|
-
/**
|
|
24517
|
-
* Insert an image at the current position
|
|
24518
|
-
* @category Command
|
|
24519
|
-
* @param {Object} options - Image attributes
|
|
24520
|
-
* @param {string} options.src - Image source URL or data URI
|
|
24521
|
-
* @param {string} [options.alt] - Alternative text
|
|
24522
|
-
* @param {string} [options.title] - Image title
|
|
24523
|
-
* @param {Object} [options.size] - Image dimensions
|
|
24524
|
-
* @returns {Function} Command function
|
|
24525
|
-
* @example
|
|
24526
|
-
* // Insert an image from a URL
|
|
24527
|
-
* setImage({ src: 'https://example.com/image.jpg' })
|
|
24528
|
-
*
|
|
24529
|
-
* // Insert a base64 encoded image
|
|
24530
|
-
* setImage({
|
|
24531
|
-
* src: 'data:image/png;base64,...',
|
|
24532
|
-
* alt: 'Company logo',
|
|
24533
|
-
* size: { width: 200 }
|
|
24534
|
-
* })
|
|
24535
|
-
* @note Supports URLs, relative paths, and base64 data URIs
|
|
24536
|
-
*/
|
|
24537
|
-
setImage: (options) => ({ commands: commands2 }) => {
|
|
24538
|
-
return commands2.insertContent({
|
|
24539
|
-
type: this.name,
|
|
24540
|
-
attrs: options
|
|
24541
|
-
});
|
|
24542
|
-
}
|
|
24543
|
-
};
|
|
24544
|
-
},
|
|
24545
|
-
addPmPlugins() {
|
|
24546
|
-
return [ImagePlaceholderPlugin(), ImagePositionPlugin({ editor: this.editor })];
|
|
24547
|
-
}
|
|
24548
|
-
});
|
|
24549
|
-
const ACCEPT_IMAGE_TYPES = [".jpg", ".jpeg", ".png", "image/jpeg", "image/png"];
|
|
24550
|
-
const getFileOpener = () => {
|
|
24551
|
-
let fileInput = document.createElement("input");
|
|
24552
|
-
fileInput.type = "file";
|
|
24553
|
-
let acceptTypes = ACCEPT_IMAGE_TYPES;
|
|
24554
|
-
fileInput.accept = acceptTypes.join(",");
|
|
24555
|
-
const openFile = () => {
|
|
24556
|
-
return new Promise((resolve, reject) => {
|
|
24557
|
-
fileInput.onchange = async () => {
|
|
24558
|
-
const files = fileInput.files;
|
|
24559
|
-
if (!files) return resolve(null);
|
|
24560
|
-
const file = files.item(0);
|
|
24561
|
-
if (!file) return resolve(null);
|
|
24562
|
-
return resolve({ file });
|
|
24563
|
-
};
|
|
24564
|
-
fileInput.oncancel = () => resolve(null);
|
|
24565
|
-
fileInput.onerror = reject;
|
|
24566
|
-
fileInput.click();
|
|
24567
|
-
});
|
|
24568
|
-
};
|
|
24569
|
-
return openFile;
|
|
24570
|
-
};
|
|
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;
|
|
24918
|
+
const maxMarginV = 500;
|
|
24919
|
+
const { left: left2 = 0, top: top2 = 0 } = marginOffset ?? {};
|
|
24920
|
+
let style = "";
|
|
24921
|
+
if (left2) style += `margin-left: ${left2}px;`;
|
|
24922
|
+
if (top2) {
|
|
24923
|
+
if (relativeFromPageV && top2 >= maxMarginV) style += `margin-top: ${maxMarginV}px;`;
|
|
24924
|
+
else style += `margin-top: ${top2}px;`;
|
|
24925
|
+
}
|
|
24926
|
+
return { style };
|
|
24927
|
+
}
|
|
24928
|
+
},
|
|
24929
|
+
/**
|
|
24930
|
+
* @category Attribute
|
|
24931
|
+
* @param {string} [style] - Custom inline CSS styles
|
|
24932
|
+
*/
|
|
24933
|
+
style: {
|
|
24934
|
+
default: null,
|
|
24935
|
+
rendered: true,
|
|
24936
|
+
renderDOM: ({ style }) => {
|
|
24937
|
+
if (!style) return {};
|
|
24938
|
+
return { style };
|
|
24688
24939
|
}
|
|
24689
24940
|
}
|
|
24690
|
-
|
|
24691
|
-
|
|
24692
|
-
|
|
24693
|
-
|
|
24694
|
-
|
|
24695
|
-
|
|
24696
|
-
|
|
24697
|
-
|
|
24698
|
-
|
|
24699
|
-
}
|
|
24700
|
-
|
|
24701
|
-
}
|
|
24702
|
-
|
|
24703
|
-
|
|
24704
|
-
|
|
24705
|
-
|
|
24706
|
-
|
|
24707
|
-
|
|
24708
|
-
|
|
24709
|
-
|
|
24710
|
-
|
|
24711
|
-
|
|
24712
|
-
|
|
24713
|
-
|
|
24714
|
-
|
|
24715
|
-
|
|
24716
|
-
|
|
24717
|
-
|
|
24718
|
-
|
|
24719
|
-
|
|
24720
|
-
|
|
24721
|
-
|
|
24722
|
-
|
|
24723
|
-
|
|
24724
|
-
|
|
24725
|
-
|
|
24726
|
-
|
|
24727
|
-
|
|
24728
|
-
|
|
24729
|
-
|
|
24730
|
-
|
|
24731
|
-
|
|
24732
|
-
|
|
24733
|
-
|
|
24734
|
-
|
|
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();
|
|
24941
|
+
};
|
|
24942
|
+
},
|
|
24943
|
+
parseDOM() {
|
|
24944
|
+
return [
|
|
24945
|
+
{
|
|
24946
|
+
tag: this.options.allowBase64 ? "img[src]" : 'img[src]:not([src^="data:"])'
|
|
24947
|
+
}
|
|
24948
|
+
];
|
|
24949
|
+
},
|
|
24950
|
+
renderDOM({ htmlAttributes }) {
|
|
24951
|
+
return ["img", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
|
|
24952
|
+
},
|
|
24953
|
+
addCommands() {
|
|
24954
|
+
return {
|
|
24955
|
+
/**
|
|
24956
|
+
* Insert an image at the current position
|
|
24957
|
+
* @category Command
|
|
24958
|
+
* @param {Object} options - Image attributes
|
|
24959
|
+
* @param {string} options.src - Image source URL or data URI
|
|
24960
|
+
* @param {string} [options.alt] - Alternative text
|
|
24961
|
+
* @param {string} [options.title] - Image title
|
|
24962
|
+
* @param {Object} [options.size] - Image dimensions
|
|
24963
|
+
* @returns {Function} Command function
|
|
24964
|
+
* @example
|
|
24965
|
+
* // Insert an image from a URL
|
|
24966
|
+
* setImage({ src: 'https://example.com/image.jpg' })
|
|
24967
|
+
*
|
|
24968
|
+
* // Insert a base64 encoded image
|
|
24969
|
+
* setImage({
|
|
24970
|
+
* src: 'data:image/png;base64,...',
|
|
24971
|
+
* alt: 'Company logo',
|
|
24972
|
+
* size: { width: 200 }
|
|
24973
|
+
* })
|
|
24974
|
+
* @note Supports URLs, relative paths, and base64 data URIs
|
|
24975
|
+
*/
|
|
24976
|
+
setImage: (options) => ({ commands: commands2 }) => {
|
|
24977
|
+
return commands2.insertContent({
|
|
24978
|
+
type: this.name,
|
|
24979
|
+
attrs: options
|
|
24980
|
+
});
|
|
24981
|
+
}
|
|
24982
|
+
};
|
|
24983
|
+
},
|
|
24984
|
+
addPmPlugins() {
|
|
24985
|
+
return [ImageRegistrationPlugin({ editor: this.editor }), ImagePositionPlugin({ editor: this.editor })];
|
|
24761
24986
|
}
|
|
24762
|
-
|
|
24763
|
-
|
|
24764
|
-
|
|
24765
|
-
|
|
24766
|
-
|
|
24767
|
-
|
|
24768
|
-
|
|
24769
|
-
|
|
24770
|
-
|
|
24771
|
-
|
|
24772
|
-
|
|
24773
|
-
|
|
24774
|
-
|
|
24775
|
-
|
|
24776
|
-
|
|
24777
|
-
|
|
24778
|
-
|
|
24779
|
-
|
|
24780
|
-
|
|
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
|
|
24987
|
+
});
|
|
24988
|
+
const ACCEPT_IMAGE_TYPES = [".jpg", ".jpeg", ".png", "image/jpeg", "image/png"];
|
|
24989
|
+
const getFileOpener = () => {
|
|
24990
|
+
let fileInput = document.createElement("input");
|
|
24991
|
+
fileInput.type = "file";
|
|
24992
|
+
let acceptTypes = ACCEPT_IMAGE_TYPES;
|
|
24993
|
+
fileInput.accept = acceptTypes.join(",");
|
|
24994
|
+
const openFile = () => {
|
|
24995
|
+
return new Promise((resolve, reject) => {
|
|
24996
|
+
fileInput.onchange = async () => {
|
|
24997
|
+
const files = fileInput.files;
|
|
24998
|
+
if (!files) return resolve(null);
|
|
24999
|
+
const file = files.item(0);
|
|
25000
|
+
if (!file) return resolve(null);
|
|
25001
|
+
return resolve({ file });
|
|
25002
|
+
};
|
|
25003
|
+
fileInput.oncancel = () => resolve(null);
|
|
25004
|
+
fileInput.onerror = reject;
|
|
25005
|
+
fileInput.click();
|
|
24788
25006
|
});
|
|
24789
|
-
|
|
24790
|
-
|
|
24791
|
-
|
|
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
|
-
}
|
|
25007
|
+
};
|
|
25008
|
+
return openFile;
|
|
25009
|
+
};
|
|
24812
25010
|
const BookmarkStart = Node$1.create({
|
|
24813
25011
|
name: "bookmarkStart",
|
|
24814
25012
|
group: "inline",
|
|
@@ -25123,8 +25321,8 @@ renderDom_fn = function(node, htmlAttributes) {
|
|
|
25123
25321
|
__privateMethod(this, _AutoPageNumberNodeView_instances, scheduleUpdateNodeStyle_fn).call(this, currentPos, marks);
|
|
25124
25322
|
Object.assign(nodeContent.style, styles);
|
|
25125
25323
|
nodeContent.appendChild(content);
|
|
25126
|
-
Object.entries(htmlAttributes).forEach(([
|
|
25127
|
-
if (value) nodeContent.setAttribute(
|
|
25324
|
+
Object.entries(htmlAttributes).forEach(([key2, value]) => {
|
|
25325
|
+
if (value) nodeContent.setAttribute(key2, value);
|
|
25128
25326
|
});
|
|
25129
25327
|
return nodeContent;
|
|
25130
25328
|
};
|
|
@@ -25190,8 +25388,8 @@ const processMarks = (marks) => {
|
|
|
25190
25388
|
break;
|
|
25191
25389
|
default:
|
|
25192
25390
|
if (attrs?.style) {
|
|
25193
|
-
Object.entries(attrs.style).forEach(([
|
|
25194
|
-
styles[
|
|
25391
|
+
Object.entries(attrs.style).forEach(([key2, value]) => {
|
|
25392
|
+
styles[key2] = value;
|
|
25195
25393
|
});
|
|
25196
25394
|
}
|
|
25197
25395
|
break;
|
|
@@ -25439,69 +25637,353 @@ const ContentBlock = Node$1.create({
|
|
|
25439
25637
|
};
|
|
25440
25638
|
}
|
|
25441
25639
|
});
|
|
25640
|
+
class StructuredContentViewBase {
|
|
25641
|
+
constructor(props) {
|
|
25642
|
+
__publicField(this, "node");
|
|
25643
|
+
__publicField(this, "view");
|
|
25644
|
+
__publicField(this, "getPos");
|
|
25645
|
+
__publicField(this, "decorations");
|
|
25646
|
+
__publicField(this, "innerDecorations");
|
|
25647
|
+
__publicField(this, "editor");
|
|
25648
|
+
__publicField(this, "extension");
|
|
25649
|
+
__publicField(this, "htmlAttributes");
|
|
25650
|
+
__publicField(this, "root");
|
|
25651
|
+
__publicField(this, "isDragging", false);
|
|
25652
|
+
this.node = props.node;
|
|
25653
|
+
this.view = props.editor.view;
|
|
25654
|
+
this.getPos = props.getPos;
|
|
25655
|
+
this.decorations = props.decorations;
|
|
25656
|
+
this.innerDecorations = props.innerDecorations;
|
|
25657
|
+
this.editor = props.editor;
|
|
25658
|
+
this.extension = props.extension;
|
|
25659
|
+
this.htmlAttributes = props.htmlAttributes;
|
|
25660
|
+
this.mount(props);
|
|
25661
|
+
}
|
|
25662
|
+
mount(props) {
|
|
25663
|
+
return;
|
|
25664
|
+
}
|
|
25665
|
+
get dom() {
|
|
25666
|
+
return this.root;
|
|
25667
|
+
}
|
|
25668
|
+
get contentDOM() {
|
|
25669
|
+
return null;
|
|
25670
|
+
}
|
|
25671
|
+
update(node, decorations, innerDecorations) {
|
|
25672
|
+
if (node.type !== this.node.type) {
|
|
25673
|
+
return false;
|
|
25674
|
+
}
|
|
25675
|
+
this.node = node;
|
|
25676
|
+
this.decorations = decorations;
|
|
25677
|
+
this.innerDecorations = innerDecorations;
|
|
25678
|
+
this.updateHTMLAttributes();
|
|
25679
|
+
return true;
|
|
25680
|
+
}
|
|
25681
|
+
stopEvent(event) {
|
|
25682
|
+
if (!this.dom) return false;
|
|
25683
|
+
const target = event.target;
|
|
25684
|
+
const isInElement = this.dom.contains(target) && !this.contentDOM?.contains(target);
|
|
25685
|
+
if (!isInElement) return false;
|
|
25686
|
+
const isDragEvent = event.type.startsWith("drag");
|
|
25687
|
+
const isDropEvent = event.type === "drop";
|
|
25688
|
+
const isInput = ["INPUT", "BUTTON", "SELECT", "TEXTAREA"].includes(target.tagName) || target.isContentEditable;
|
|
25689
|
+
if (isInput && !isDropEvent && !isDragEvent) return true;
|
|
25690
|
+
const { isEditable } = this.editor;
|
|
25691
|
+
const { isDragging } = this;
|
|
25692
|
+
const isDraggable = !!this.node.type.spec.draggable;
|
|
25693
|
+
const isSelectable = NodeSelection.isSelectable(this.node);
|
|
25694
|
+
const isCopyEvent = event.type === "copy";
|
|
25695
|
+
const isPasteEvent = event.type === "paste";
|
|
25696
|
+
const isCutEvent = event.type === "cut";
|
|
25697
|
+
const isClickEvent = event.type === "mousedown";
|
|
25698
|
+
if (!isDraggable && isSelectable && isDragEvent && event.target === this.dom) {
|
|
25699
|
+
event.preventDefault();
|
|
25700
|
+
}
|
|
25701
|
+
if (isDraggable && isDragEvent && !isDragging && event.target === this.dom) {
|
|
25702
|
+
event.preventDefault();
|
|
25703
|
+
return false;
|
|
25704
|
+
}
|
|
25705
|
+
if (isDraggable && isEditable && !isDragging && isClickEvent) {
|
|
25706
|
+
const dragHandle = target.closest("[data-drag-handle]");
|
|
25707
|
+
const isValidDragHandle = dragHandle && (this.dom === dragHandle || this.dom.contains(dragHandle));
|
|
25708
|
+
if (isValidDragHandle) {
|
|
25709
|
+
this.isDragging = true;
|
|
25710
|
+
document.addEventListener(
|
|
25711
|
+
"dragend",
|
|
25712
|
+
() => {
|
|
25713
|
+
this.isDragging = false;
|
|
25714
|
+
},
|
|
25715
|
+
{ once: true }
|
|
25716
|
+
);
|
|
25717
|
+
document.addEventListener(
|
|
25718
|
+
"drop",
|
|
25719
|
+
() => {
|
|
25720
|
+
this.isDragging = false;
|
|
25721
|
+
},
|
|
25722
|
+
{ once: true }
|
|
25723
|
+
);
|
|
25724
|
+
document.addEventListener(
|
|
25725
|
+
"mouseup",
|
|
25726
|
+
() => {
|
|
25727
|
+
this.isDragging = false;
|
|
25728
|
+
},
|
|
25729
|
+
{ once: true }
|
|
25730
|
+
);
|
|
25731
|
+
}
|
|
25732
|
+
}
|
|
25733
|
+
if (isDragging || isDropEvent || isCopyEvent || isPasteEvent || isCutEvent || isClickEvent && isSelectable) {
|
|
25734
|
+
return false;
|
|
25735
|
+
}
|
|
25736
|
+
return true;
|
|
25737
|
+
}
|
|
25738
|
+
ignoreMutation(mutation) {
|
|
25739
|
+
if (!this.dom || !this.contentDOM) return true;
|
|
25740
|
+
if (this.node.isLeaf || this.node.isAtom) return true;
|
|
25741
|
+
if (mutation.type === "selection") return false;
|
|
25742
|
+
if (this.contentDOM === mutation.target && mutation.type === "attributes") return true;
|
|
25743
|
+
if (this.contentDOM.contains(mutation.target)) return false;
|
|
25744
|
+
return true;
|
|
25745
|
+
}
|
|
25746
|
+
destroy() {
|
|
25747
|
+
this.dom.remove();
|
|
25748
|
+
this.contentDOM?.remove();
|
|
25749
|
+
}
|
|
25750
|
+
updateAttributes(attrs) {
|
|
25751
|
+
const pos = this.getPos();
|
|
25752
|
+
if (typeof pos !== "number") {
|
|
25753
|
+
return;
|
|
25754
|
+
}
|
|
25755
|
+
return this.view.dispatch(
|
|
25756
|
+
this.view.state.tr.setNodeMarkup(pos, void 0, {
|
|
25757
|
+
...this.node.attrs,
|
|
25758
|
+
...attrs
|
|
25759
|
+
})
|
|
25760
|
+
);
|
|
25761
|
+
}
|
|
25762
|
+
updateHTMLAttributes() {
|
|
25763
|
+
const { extensionService } = this.editor;
|
|
25764
|
+
const { attributes } = extensionService;
|
|
25765
|
+
const extensionAttrs = attributes.filter((i) => i.type === this.node.type.name);
|
|
25766
|
+
this.htmlAttributes = Attribute.getAttributesToRender(this.node, extensionAttrs);
|
|
25767
|
+
}
|
|
25768
|
+
createDragHandle() {
|
|
25769
|
+
const dragHandle = document.createElement("span");
|
|
25770
|
+
dragHandle.classList.add("sd-structured-content-draggable");
|
|
25771
|
+
dragHandle.draggable = true;
|
|
25772
|
+
dragHandle.contentEditable = "false";
|
|
25773
|
+
dragHandle.dataset.dragHandle = "";
|
|
25774
|
+
const textElement = document.createElement("span");
|
|
25775
|
+
textElement.textContent = "Structured content";
|
|
25776
|
+
dragHandle.append(textElement);
|
|
25777
|
+
return dragHandle;
|
|
25778
|
+
}
|
|
25779
|
+
onDragStart(event) {
|
|
25780
|
+
const { view } = this.editor;
|
|
25781
|
+
const target = event.target;
|
|
25782
|
+
const dragHandle = target.nodeType === 3 ? target.parentElement?.closest("[data-drag-handle]") : target.closest("[data-drag-handle]");
|
|
25783
|
+
if (!this.dom || this.contentDOM?.contains(target) || !dragHandle) {
|
|
25784
|
+
return;
|
|
25785
|
+
}
|
|
25786
|
+
let x = 0;
|
|
25787
|
+
let y = 0;
|
|
25788
|
+
if (this.dom !== dragHandle) {
|
|
25789
|
+
const domBox = this.dom.getBoundingClientRect();
|
|
25790
|
+
const handleBox = dragHandle.getBoundingClientRect();
|
|
25791
|
+
const offsetX = event.offsetX ?? event.nativeEvent?.offsetX;
|
|
25792
|
+
const offsetY = event.offsetY ?? event.nativeEvent?.offsetY;
|
|
25793
|
+
x = handleBox.x - domBox.x + offsetX;
|
|
25794
|
+
y = handleBox.y - domBox.y + offsetY;
|
|
25795
|
+
}
|
|
25796
|
+
event.dataTransfer?.setDragImage(this.dom, x, y);
|
|
25797
|
+
const pos = this.getPos();
|
|
25798
|
+
if (typeof pos !== "number") {
|
|
25799
|
+
return;
|
|
25800
|
+
}
|
|
25801
|
+
const selection = NodeSelection.create(view.state.doc, pos);
|
|
25802
|
+
const transaction = view.state.tr.setSelection(selection);
|
|
25803
|
+
view.dispatch(transaction);
|
|
25804
|
+
}
|
|
25805
|
+
}
|
|
25806
|
+
class StructuredContentInlineView extends StructuredContentViewBase {
|
|
25807
|
+
constructor(props) {
|
|
25808
|
+
super(props);
|
|
25809
|
+
}
|
|
25810
|
+
mount() {
|
|
25811
|
+
this.buildView();
|
|
25812
|
+
}
|
|
25813
|
+
get contentDOM() {
|
|
25814
|
+
const contentElement = this.dom?.querySelector(`.${structuredContentInnerClass$1}`);
|
|
25815
|
+
return contentElement || null;
|
|
25816
|
+
}
|
|
25817
|
+
createElement() {
|
|
25818
|
+
const element = document.createElement("span");
|
|
25819
|
+
element.classList.add(structuredContentClass$1);
|
|
25820
|
+
element.setAttribute("data-structured-content", "");
|
|
25821
|
+
const contentElement = document.createElement("span");
|
|
25822
|
+
contentElement.classList.add(structuredContentInnerClass$1);
|
|
25823
|
+
element.append(contentElement);
|
|
25824
|
+
const domAttrs = Attribute.mergeAttributes(this.htmlAttributes);
|
|
25825
|
+
updateDOMAttributes(element, { ...domAttrs });
|
|
25826
|
+
return { element, contentElement };
|
|
25827
|
+
}
|
|
25828
|
+
buildView() {
|
|
25829
|
+
const { element } = this.createElement();
|
|
25830
|
+
const dragHandle = this.createDragHandle();
|
|
25831
|
+
element.prepend(dragHandle);
|
|
25832
|
+
element.addEventListener("dragstart", (e) => this.onDragStart(e));
|
|
25833
|
+
this.root = element;
|
|
25834
|
+
}
|
|
25835
|
+
updateView() {
|
|
25836
|
+
const domAttrs = Attribute.mergeAttributes(this.htmlAttributes);
|
|
25837
|
+
updateDOMAttributes(this.dom, { ...domAttrs });
|
|
25838
|
+
}
|
|
25839
|
+
update(node, decorations, innerDecorations) {
|
|
25840
|
+
const result = super.update(node, decorations, innerDecorations);
|
|
25841
|
+
if (!result) return false;
|
|
25842
|
+
this.updateView();
|
|
25843
|
+
return true;
|
|
25844
|
+
}
|
|
25845
|
+
}
|
|
25846
|
+
const structuredContentClass$1 = "sd-structured-content";
|
|
25847
|
+
const structuredContentInnerClass$1 = "sd-structured-content__content";
|
|
25442
25848
|
const StructuredContent = Node$1.create({
|
|
25443
25849
|
name: "structuredContent",
|
|
25444
|
-
group: "inline",
|
|
25850
|
+
group: "inline structuredContent",
|
|
25445
25851
|
inline: true,
|
|
25446
25852
|
content: "inline*",
|
|
25853
|
+
isolating: true,
|
|
25854
|
+
atom: false,
|
|
25855
|
+
// false - has editable content.
|
|
25856
|
+
draggable: true,
|
|
25447
25857
|
addOptions() {
|
|
25448
25858
|
return {
|
|
25449
|
-
structuredContentClass: "sd-structured-content-tag",
|
|
25450
25859
|
htmlAttributes: {
|
|
25860
|
+
class: structuredContentClass$1,
|
|
25451
25861
|
"aria-label": "Structured content node"
|
|
25452
25862
|
}
|
|
25453
25863
|
};
|
|
25454
25864
|
},
|
|
25455
25865
|
addAttributes() {
|
|
25456
25866
|
return {
|
|
25867
|
+
id: {
|
|
25868
|
+
default: null,
|
|
25869
|
+
parseDOM: (elem) => elem.getAttribute("data-id"),
|
|
25870
|
+
renderDOM: (attrs) => {
|
|
25871
|
+
if (!attrs.id) return {};
|
|
25872
|
+
return { "data-id": attrs.id };
|
|
25873
|
+
}
|
|
25874
|
+
},
|
|
25457
25875
|
sdtPr: {
|
|
25458
25876
|
rendered: false
|
|
25459
25877
|
}
|
|
25460
25878
|
};
|
|
25461
25879
|
},
|
|
25462
25880
|
parseDOM() {
|
|
25463
|
-
return [{ tag:
|
|
25881
|
+
return [{ tag: "span[data-structured-content]" }];
|
|
25464
25882
|
},
|
|
25465
25883
|
renderDOM({ htmlAttributes }) {
|
|
25466
25884
|
return [
|
|
25467
25885
|
"span",
|
|
25468
25886
|
Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes, {
|
|
25469
|
-
|
|
25887
|
+
"data-structured-content": ""
|
|
25470
25888
|
}),
|
|
25471
25889
|
0
|
|
25472
25890
|
];
|
|
25891
|
+
},
|
|
25892
|
+
addNodeView() {
|
|
25893
|
+
return (props) => {
|
|
25894
|
+
return new StructuredContentInlineView({ ...props });
|
|
25895
|
+
};
|
|
25473
25896
|
}
|
|
25474
25897
|
});
|
|
25898
|
+
class StructuredContentBlockView extends StructuredContentViewBase {
|
|
25899
|
+
constructor(props) {
|
|
25900
|
+
super(props);
|
|
25901
|
+
}
|
|
25902
|
+
mount() {
|
|
25903
|
+
this.buildView();
|
|
25904
|
+
}
|
|
25905
|
+
get contentDOM() {
|
|
25906
|
+
const contentElement = this.dom?.querySelector(`.${structuredContentInnerClass}`);
|
|
25907
|
+
return contentElement || null;
|
|
25908
|
+
}
|
|
25909
|
+
createElement() {
|
|
25910
|
+
const element = document.createElement("div");
|
|
25911
|
+
element.classList.add(structuredContentClass);
|
|
25912
|
+
element.setAttribute("data-structured-content-block", "");
|
|
25913
|
+
const contentElement = document.createElement("div");
|
|
25914
|
+
contentElement.classList.add(structuredContentInnerClass);
|
|
25915
|
+
element.append(contentElement);
|
|
25916
|
+
const domAttrs = Attribute.mergeAttributes(this.htmlAttributes);
|
|
25917
|
+
updateDOMAttributes(element, { ...domAttrs });
|
|
25918
|
+
return { element, contentElement };
|
|
25919
|
+
}
|
|
25920
|
+
buildView() {
|
|
25921
|
+
const { element } = this.createElement();
|
|
25922
|
+
const dragHandle = this.createDragHandle();
|
|
25923
|
+
element.prepend(dragHandle);
|
|
25924
|
+
element.addEventListener("dragstart", (e) => this.onDragStart(e));
|
|
25925
|
+
this.root = element;
|
|
25926
|
+
}
|
|
25927
|
+
updateView() {
|
|
25928
|
+
const domAttrs = Attribute.mergeAttributes(this.htmlAttributes);
|
|
25929
|
+
updateDOMAttributes(this.dom, { ...domAttrs });
|
|
25930
|
+
}
|
|
25931
|
+
update(node, decorations, innerDecorations) {
|
|
25932
|
+
const result = super.update(node, decorations, innerDecorations);
|
|
25933
|
+
if (!result) return false;
|
|
25934
|
+
this.updateView();
|
|
25935
|
+
return true;
|
|
25936
|
+
}
|
|
25937
|
+
}
|
|
25938
|
+
const structuredContentClass = "sd-structured-content-block";
|
|
25939
|
+
const structuredContentInnerClass = "sd-structured-content-block__content";
|
|
25475
25940
|
const StructuredContentBlock = Node$1.create({
|
|
25476
25941
|
name: "structuredContentBlock",
|
|
25477
|
-
group: "block",
|
|
25942
|
+
group: "block structuredContent",
|
|
25478
25943
|
content: "block*",
|
|
25944
|
+
isolating: true,
|
|
25945
|
+
atom: false,
|
|
25946
|
+
// false - has editable content.
|
|
25947
|
+
draggable: true,
|
|
25479
25948
|
addOptions() {
|
|
25480
25949
|
return {
|
|
25481
|
-
structuredContentClass: "sd-structured-content-block-tag",
|
|
25482
25950
|
htmlAttributes: {
|
|
25951
|
+
class: structuredContentClass,
|
|
25483
25952
|
"aria-label": "Structured content block node"
|
|
25484
25953
|
}
|
|
25485
25954
|
};
|
|
25486
25955
|
},
|
|
25487
25956
|
addAttributes() {
|
|
25488
25957
|
return {
|
|
25958
|
+
id: {
|
|
25959
|
+
default: null,
|
|
25960
|
+
parseDOM: (elem) => elem.getAttribute("data-id"),
|
|
25961
|
+
renderDOM: (attrs) => {
|
|
25962
|
+
if (!attrs.id) return {};
|
|
25963
|
+
return { "data-id": attrs.id };
|
|
25964
|
+
}
|
|
25965
|
+
},
|
|
25489
25966
|
sdtPr: {
|
|
25490
25967
|
rendered: false
|
|
25491
25968
|
}
|
|
25492
25969
|
};
|
|
25493
25970
|
},
|
|
25494
25971
|
parseDOM() {
|
|
25495
|
-
return [{ tag:
|
|
25972
|
+
return [{ tag: "div[data-structured-content-block]" }];
|
|
25496
25973
|
},
|
|
25497
25974
|
renderDOM({ htmlAttributes }) {
|
|
25498
25975
|
return [
|
|
25499
25976
|
"div",
|
|
25500
25977
|
Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes, {
|
|
25501
|
-
|
|
25978
|
+
"data-structured-content-block": ""
|
|
25502
25979
|
}),
|
|
25503
25980
|
0
|
|
25504
25981
|
];
|
|
25982
|
+
},
|
|
25983
|
+
addNodeView() {
|
|
25984
|
+
return (props) => {
|
|
25985
|
+
return new StructuredContentBlockView({ ...props });
|
|
25986
|
+
};
|
|
25505
25987
|
}
|
|
25506
25988
|
});
|
|
25507
25989
|
class DocumentSectionView {
|
|
@@ -27569,8 +28051,8 @@ function mergePaddingObject(paddingObject) {
|
|
|
27569
28051
|
return Object.assign({}, getFreshSideObject(), paddingObject);
|
|
27570
28052
|
}
|
|
27571
28053
|
function expandToHashMap(value, keys2) {
|
|
27572
|
-
return keys2.reduce(function(hashMap,
|
|
27573
|
-
hashMap[
|
|
28054
|
+
return keys2.reduce(function(hashMap, key2) {
|
|
28055
|
+
hashMap[key2] = value;
|
|
27574
28056
|
return hashMap;
|
|
27575
28057
|
}, {});
|
|
27576
28058
|
}
|
|
@@ -28026,10 +28508,10 @@ function detectOverflow$1(state, options) {
|
|
|
28026
28508
|
var offsetData = state.modifiersData.offset;
|
|
28027
28509
|
if (elementContext === popper && offsetData) {
|
|
28028
28510
|
var offset2 = offsetData[placement];
|
|
28029
|
-
Object.keys(overflowOffsets).forEach(function(
|
|
28030
|
-
var multiply = [right, bottom].indexOf(
|
|
28031
|
-
var axis = [top, bottom].indexOf(
|
|
28032
|
-
overflowOffsets[
|
|
28511
|
+
Object.keys(overflowOffsets).forEach(function(key2) {
|
|
28512
|
+
var multiply = [right, bottom].indexOf(key2) >= 0 ? 1 : -1;
|
|
28513
|
+
var axis = [top, bottom].indexOf(key2) >= 0 ? "y" : "x";
|
|
28514
|
+
overflowOffsets[key2] += offset2[axis] * multiply;
|
|
28033
28515
|
});
|
|
28034
28516
|
}
|
|
28035
28517
|
return overflowOffsets;
|
|
@@ -28476,8 +28958,8 @@ function mergeByName(modifiers2) {
|
|
|
28476
28958
|
}) : current;
|
|
28477
28959
|
return merged2;
|
|
28478
28960
|
}, {});
|
|
28479
|
-
return Object.keys(merged).map(function(
|
|
28480
|
-
return merged[
|
|
28961
|
+
return Object.keys(merged).map(function(key2) {
|
|
28962
|
+
return merged[key2];
|
|
28481
28963
|
});
|
|
28482
28964
|
}
|
|
28483
28965
|
var DEFAULT_OPTIONS = {
|
|
@@ -28634,8 +29116,8 @@ var TOUCH_OPTIONS = {
|
|
|
28634
29116
|
var TIPPY_DEFAULT_APPEND_TO = function TIPPY_DEFAULT_APPEND_TO2() {
|
|
28635
29117
|
return document.body;
|
|
28636
29118
|
};
|
|
28637
|
-
function hasOwnProperty(obj,
|
|
28638
|
-
return {}.hasOwnProperty.call(obj,
|
|
29119
|
+
function hasOwnProperty(obj, key2) {
|
|
29120
|
+
return {}.hasOwnProperty.call(obj, key2);
|
|
28639
29121
|
}
|
|
28640
29122
|
function getValueAtIndexOrReturn(value, index2, defaultValue) {
|
|
28641
29123
|
if (Array.isArray(value)) {
|
|
@@ -28665,8 +29147,8 @@ function debounce(fn2, ms) {
|
|
|
28665
29147
|
}
|
|
28666
29148
|
function removeProperties(obj, keys2) {
|
|
28667
29149
|
var clone = Object.assign({}, obj);
|
|
28668
|
-
keys2.forEach(function(
|
|
28669
|
-
delete clone[
|
|
29150
|
+
keys2.forEach(function(key2) {
|
|
29151
|
+
delete clone[key2];
|
|
28670
29152
|
});
|
|
28671
29153
|
return clone;
|
|
28672
29154
|
}
|
|
@@ -28693,9 +29175,9 @@ function arrayFrom(value) {
|
|
|
28693
29175
|
return [].slice.call(value);
|
|
28694
29176
|
}
|
|
28695
29177
|
function removeUndefinedProps(obj) {
|
|
28696
|
-
return Object.keys(obj).reduce(function(acc,
|
|
28697
|
-
if (obj[
|
|
28698
|
-
acc[
|
|
29178
|
+
return Object.keys(obj).reduce(function(acc, key2) {
|
|
29179
|
+
if (obj[key2] !== void 0) {
|
|
29180
|
+
acc[key2] = obj[key2];
|
|
28699
29181
|
}
|
|
28700
29182
|
return acc;
|
|
28701
29183
|
}, {});
|
|
@@ -28947,8 +29429,8 @@ var setDefaultProps = function setDefaultProps2(partialProps) {
|
|
|
28947
29429
|
validateProps(partialProps, []);
|
|
28948
29430
|
}
|
|
28949
29431
|
var keys2 = Object.keys(partialProps);
|
|
28950
|
-
keys2.forEach(function(
|
|
28951
|
-
defaultProps[
|
|
29432
|
+
keys2.forEach(function(key2) {
|
|
29433
|
+
defaultProps[key2] = partialProps[key2];
|
|
28952
29434
|
});
|
|
28953
29435
|
};
|
|
28954
29436
|
function getExtendedPassedProps(passedProps) {
|
|
@@ -28967,18 +29449,18 @@ function getDataAttributeProps(reference2, plugins) {
|
|
|
28967
29449
|
var propKeys = plugins ? Object.keys(getExtendedPassedProps(Object.assign({}, defaultProps, {
|
|
28968
29450
|
plugins
|
|
28969
29451
|
}))) : defaultKeys;
|
|
28970
|
-
var props = propKeys.reduce(function(acc,
|
|
28971
|
-
var valueAsString = (reference2.getAttribute("data-tippy-" +
|
|
29452
|
+
var props = propKeys.reduce(function(acc, key2) {
|
|
29453
|
+
var valueAsString = (reference2.getAttribute("data-tippy-" + key2) || "").trim();
|
|
28972
29454
|
if (!valueAsString) {
|
|
28973
29455
|
return acc;
|
|
28974
29456
|
}
|
|
28975
|
-
if (
|
|
28976
|
-
acc[
|
|
29457
|
+
if (key2 === "content") {
|
|
29458
|
+
acc[key2] = valueAsString;
|
|
28977
29459
|
} else {
|
|
28978
29460
|
try {
|
|
28979
|
-
acc[
|
|
29461
|
+
acc[key2] = JSON.parse(valueAsString);
|
|
28980
29462
|
} catch (e) {
|
|
28981
|
-
acc[
|
|
29463
|
+
acc[key2] = valueAsString;
|
|
28982
29464
|
}
|
|
28983
29465
|
}
|
|
28984
29466
|
return acc;
|
|
@@ -29902,8 +30384,8 @@ tippy.setDefaultProps({
|
|
|
29902
30384
|
});
|
|
29903
30385
|
const _export_sfc = (sfc, props) => {
|
|
29904
30386
|
const target = sfc.__vccOpts || sfc;
|
|
29905
|
-
for (const [
|
|
29906
|
-
target[
|
|
30387
|
+
for (const [key2, val] of props) {
|
|
30388
|
+
target[key2] = val;
|
|
29907
30389
|
}
|
|
29908
30390
|
return target;
|
|
29909
30391
|
};
|
|
@@ -31295,9 +31777,9 @@ const Pagination = Extension.create({
|
|
|
31295
31777
|
if (syncMeta && syncMeta.isChangeOrigin || listSyncMeta) {
|
|
31296
31778
|
return { ...oldState };
|
|
31297
31779
|
}
|
|
31298
|
-
const
|
|
31299
|
-
if (
|
|
31300
|
-
if (
|
|
31780
|
+
const imageRegistrationMetaType = getImageRegistrationMetaType(tr);
|
|
31781
|
+
if (imageRegistrationMetaType) {
|
|
31782
|
+
if (imageRegistrationMetaType === "remove") {
|
|
31301
31783
|
onImageLoad(editor);
|
|
31302
31784
|
}
|
|
31303
31785
|
return { ...oldState };
|
|
@@ -32698,18 +33180,20 @@ export {
|
|
|
32698
33180
|
getQuickFormatList as a,
|
|
32699
33181
|
generateLinkedStyleString as b,
|
|
32700
33182
|
getFileOpener as c,
|
|
32701
|
-
|
|
32702
|
-
|
|
32703
|
-
|
|
33183
|
+
checkAndProcessImage as d,
|
|
33184
|
+
uploadAndInsertImage as e,
|
|
33185
|
+
undoDepth as f,
|
|
32704
33186
|
global as g,
|
|
32705
|
-
|
|
32706
|
-
|
|
32707
|
-
|
|
32708
|
-
|
|
32709
|
-
|
|
32710
|
-
|
|
32711
|
-
|
|
32712
|
-
|
|
33187
|
+
redoDepth as h,
|
|
33188
|
+
getStarterExtensions as i,
|
|
33189
|
+
getRichTextExtensions as j,
|
|
33190
|
+
Extension as k,
|
|
33191
|
+
index$1 as l,
|
|
33192
|
+
index as m,
|
|
33193
|
+
AnnotatorHelpers as n,
|
|
33194
|
+
SectionHelpers as o,
|
|
33195
|
+
getAllowedImageDimensions as p,
|
|
33196
|
+
replaceSelectionWithImagePlaceholder as r,
|
|
32713
33197
|
useHighContrastMode as u,
|
|
32714
33198
|
yUndoPluginKey as y
|
|
32715
33199
|
};
|