@harbour-enterprises/superdoc 0.24.0-next.2 → 0.24.0-next.4
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--Z8scsXq.es.js → PdfViewer-D7C8g2G4.es.js} +1 -1
- package/dist/chunks/{PdfViewer-CYiJzT44.cjs → PdfViewer-kOVuv-4I.cjs} +1 -1
- package/dist/chunks/blank-docx-ABm6XYAA.es.js +4 -0
- package/dist/chunks/blank-docx-DfW3Eeh2.cjs +3 -0
- package/dist/chunks/{index-CBSXpA57.cjs → index-BFKwBQjS.cjs} +12 -4
- package/dist/chunks/{index-CCf_X9Jy.es.js → index-CnEAVnHQ.es.js} +12 -4
- package/dist/chunks/{super-editor.es-CZFQdEKI.cjs → super-editor.es-BmGTQ05x.cjs} +1954 -1216
- package/dist/chunks/{super-editor.es-BFco6Gra.es.js → super-editor.es-CBPoWvjs.es.js} +1954 -1216
- package/dist/core/SuperDoc.d.ts.map +1 -1
- package/dist/core/types/index.d.ts.map +1 -1
- package/dist/style.css +32 -31
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-nWAUAQ83.js → converter-DpPj67OW.js} +1537 -1175
- package/dist/super-editor/chunks/{docx-zipper-B2uMUaj9.js → docx-zipper-6Kc95yG-.js} +1 -1
- package/dist/super-editor/chunks/{editor-DAyiX5AL.js → editor-Dx6AhT5N.js} +454 -57
- package/dist/super-editor/chunks/{toolbar-LmzuO_YJ.js → toolbar-CXSg2lJ9.js} +2 -2
- package/dist/super-editor/converter.es.js +1 -1
- package/dist/super-editor/docx-zipper.es.js +2 -2
- package/dist/super-editor/editor.es.js +3 -3
- package/dist/super-editor/file-zipper.es.js +1 -1
- package/dist/super-editor/style.css +5 -4
- package/dist/super-editor/super-editor/src/core/Editor.d.ts +11 -0
- package/dist/super-editor/super-editor/src/core/helpers/canRenderFont.d.ts +12 -0
- package/dist/super-editor/super-editor/src/core/super-converter/SuperConverter.d.ts +6 -1
- package/dist/super-editor/super-editor/src/core/super-converter/helpers.d.ts +23 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v2/importer/docxImporter.d.ts +3 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v2/importer/tableImporter.d.ts +5 -3
- package/dist/super-editor/super-editor/src/core/super-converter/v2/importer/trackChangesImporter.d.ts +5 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v2/importer/types/index.d.ts +5 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/helpers.d.ts +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/utils.d.ts +9 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/del/del-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/del/index.d.ts +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/gridSpan/gridSpan-translator.d.ts +6 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/gridSpan/index.d.ts +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/header/header-translator.d.ts +6 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/header/index.d.ts +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/headers/headers-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/headers/index.d.ts +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/hideMark/hideMark-translator.d.ts +6 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/hideMark/index.d.ts +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/ins/index.d.ts +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/ins/ins-translator.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/noWrap/index.d.ts +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/noWrap/noWrap-translator.d.ts +6 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/shd/shd-translator.d.ts +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tc/helpers/translate-table-cell.d.ts +0 -5
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tcBorders/index.d.ts +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tcBorders/tcBorders-translator.d.ts +6 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tcFitText/index.d.ts +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tcFitText/tcFitText-translator.d.ts +6 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tcMar/index.d.ts +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tcMar/tcMar-translator.d.ts +6 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tcPr/index.d.ts +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tcPr/tcPr-translator.d.ts +5 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tcW/index.d.ts +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tcW/tcW-translator.d.ts +6 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/textDirection/index.d.ts +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/textDirection/textDirection-translator.d.ts +6 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tl2br/index.d.ts +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tl2br/tl2br-translator.d.ts +6 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tr2bl/index.d.ts +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/tr2bl/tr2bl-translator.d.ts +6 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/vAlign/index.d.ts +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/vAlign/vAlign-translator.d.ts +6 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/vMerge/index.d.ts +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/vMerge/vMerge-translator.d.ts +6 -0
- package/dist/super-editor/super-editor/src/extensions/image/image.d.ts +1 -1
- package/dist/super-editor/super-editor/src/extensions/image/imageHelpers/index.d.ts +1 -0
- package/dist/super-editor/super-editor/src/extensions/image/imageHelpers/legacyAttributes.d.ts +17 -0
- package/dist/super-editor/super-editor/src/extensions/table-cell/table-cell.d.ts +112 -0
- package/dist/super-editor/super-editor.es.js +91 -76
- 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 +3 -3
- package/dist/superdoc.es.js +3 -3
- package/dist/superdoc.umd.js +1964 -1218
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/blank-docx-CPqX9RF5.cjs +0 -3
- package/dist/chunks/blank-docx-iwdyG9RH.es.js +0 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { p as process$1,
|
|
1
|
+
import { p as process$1, ax as commonjsGlobal, B as Buffer, ay as getDefaultExportFromCjs, az as getContentTypesFromXml, aA as xmljs } from "./converter-DpPj67OW.js";
|
|
2
2
|
function commonjsRequire(path) {
|
|
3
3
|
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
4
4
|
}
|
|
@@ -9,12 +9,12 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
|
|
|
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);
|
|
10
10
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
11
11
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
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, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ListItemNodeView_instances, init_fn3, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn;
|
|
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, checkFonts_fn, determineUnsupportedFontsWithLocalFonts_fn, determineUnsupportedFontsWithCanvas_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, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ListItemNodeView_instances, init_fn3, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_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 updateDOMAttributes, ah as findChildren$5, ai as htmlHandler, aj as generateRandomSigned32BitIntStrId, ak as InputRule, al as kebabCase, am as findParentNodeClosestToPos, an as getListItemStyleDefinitions, ao as docxNumberigHelpers, ap as parseIndentElement, aq as combineIndents, ar as SelectionRange, as as Transform, at as isInTable$1, au as generateDocxRandomId, av as insertNewRelationship } 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 updateDOMAttributes, ah as findChildren$5, ai as htmlHandler, aj as generateRandomSigned32BitIntStrId, ak as InputRule, al as kebabCase, am as findParentNodeClosestToPos, an as getListItemStyleDefinitions, ao as docxNumberigHelpers, ap as parseIndentElement, aq as combineIndents, ar as SelectionRange, as as Transform, at as isInTable$1, au as generateDocxRandomId, av as insertNewRelationship, aw as inchesToPixels } from "./converter-DpPj67OW.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-6Kc95yG-.js";
|
|
18
18
|
var GOOD_LEAF_SIZE = 200;
|
|
19
19
|
var RopeSequence = function RopeSequence2() {
|
|
20
20
|
};
|
|
@@ -13101,6 +13101,29 @@ const setImageNodeSelection = (view, pos) => {
|
|
|
13101
13101
|
}
|
|
13102
13102
|
return false;
|
|
13103
13103
|
};
|
|
13104
|
+
function canRenderFont(fontName, fallbackFont = "sans-serif") {
|
|
13105
|
+
const _canRenderFont = (fontName2, fallbackFont2) => {
|
|
13106
|
+
const canvas = document.createElement("canvas");
|
|
13107
|
+
const ctx = canvas.getContext("2d");
|
|
13108
|
+
ctx.textBaseline = "top";
|
|
13109
|
+
const text = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
13110
|
+
ctx.font = `72px ${fallbackFont2}`;
|
|
13111
|
+
const initialTextMeasurement = ctx.measureText(text);
|
|
13112
|
+
const fallbackWidth = initialTextMeasurement.width;
|
|
13113
|
+
const fallbackHeight = initialTextMeasurement.actualBoundingBoxDescent;
|
|
13114
|
+
ctx.font = `72px "${fontName2}", ${fallbackFont2}`;
|
|
13115
|
+
const customTextMeasurement = ctx.measureText(text);
|
|
13116
|
+
const customFontWidth = customTextMeasurement.width;
|
|
13117
|
+
const customFontHeight = customTextMeasurement.actualBoundingBoxDescent;
|
|
13118
|
+
const isAvailable = customFontWidth !== fallbackWidth || customFontHeight !== fallbackHeight;
|
|
13119
|
+
return isAvailable;
|
|
13120
|
+
};
|
|
13121
|
+
if (_canRenderFont(fontName, fallbackFont)) {
|
|
13122
|
+
return true;
|
|
13123
|
+
}
|
|
13124
|
+
const oppositeFallbackFont = fallbackFont === "sans-serif" ? "serif" : "sans-serif";
|
|
13125
|
+
return _canRenderFont(fontName, oppositeFallbackFont);
|
|
13126
|
+
}
|
|
13104
13127
|
const { findChildren: findChildren$3 } = helpers;
|
|
13105
13128
|
function getAllFieldAnnotations(state) {
|
|
13106
13129
|
let fieldAnnotations = findChildren$3(state.doc, (node) => node.type.name === "fieldAnnotation");
|
|
@@ -14193,6 +14216,11 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14193
14216
|
* @type {boolean}
|
|
14194
14217
|
*/
|
|
14195
14218
|
__publicField(this, "isFocused", false);
|
|
14219
|
+
/**
|
|
14220
|
+
* All the embedded fonts that were imported by the Editor
|
|
14221
|
+
* @type {string[]}
|
|
14222
|
+
*/
|
|
14223
|
+
__publicField(this, "fontsImported", []);
|
|
14196
14224
|
__publicField(this, "options", {
|
|
14197
14225
|
element: null,
|
|
14198
14226
|
selector: null,
|
|
@@ -14253,6 +14281,7 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14253
14281
|
onPaginationUpdate: () => null,
|
|
14254
14282
|
onException: () => null,
|
|
14255
14283
|
onListDefinitionsChange: () => null,
|
|
14284
|
+
onFontsResolved: null,
|
|
14256
14285
|
// async (file) => url;
|
|
14257
14286
|
handleImageUpload: null,
|
|
14258
14287
|
// telemetry
|
|
@@ -15238,6 +15267,9 @@ init_fn = function() {
|
|
|
15238
15267
|
this.emit("beforeCreate", { editor: this });
|
|
15239
15268
|
this.on("contentError", this.options.onContentError);
|
|
15240
15269
|
this.mount(this.options.element);
|
|
15270
|
+
if (!this.options.isHeadless) {
|
|
15271
|
+
__privateMethod(this, _Editor_instances, checkFonts_fn).call(this);
|
|
15272
|
+
}
|
|
15241
15273
|
this.on("create", this.options.onCreate);
|
|
15242
15274
|
this.on("update", this.options.onUpdate);
|
|
15243
15275
|
this.on("selectionUpdate", this.options.onSelectionUpdate);
|
|
@@ -15438,13 +15470,90 @@ initMedia_fn = function() {
|
|
|
15438
15470
|
* @returns {void}
|
|
15439
15471
|
*/
|
|
15440
15472
|
initFonts_fn = function() {
|
|
15441
|
-
const
|
|
15442
|
-
if (styleString?.length) {
|
|
15473
|
+
const results = this.converter.getFontFaceImportString();
|
|
15474
|
+
if (results?.styleString?.length) {
|
|
15443
15475
|
const style = document.createElement("style");
|
|
15444
|
-
style.textContent = styleString;
|
|
15476
|
+
style.textContent = results.styleString;
|
|
15445
15477
|
document.head.appendChild(style);
|
|
15478
|
+
this.fontsImported = results.fontsImported;
|
|
15446
15479
|
}
|
|
15447
15480
|
};
|
|
15481
|
+
checkFonts_fn = async function() {
|
|
15482
|
+
if (!this.options.onFontsResolved || typeof this.options.onFontsResolved !== "function") {
|
|
15483
|
+
return;
|
|
15484
|
+
}
|
|
15485
|
+
if (this.options.isHeadless) {
|
|
15486
|
+
return;
|
|
15487
|
+
}
|
|
15488
|
+
const fontsUsedInDocument = this.converter.getDocumentFonts();
|
|
15489
|
+
if (!("queryLocalFonts" in window)) {
|
|
15490
|
+
console.warn("[SuperDoc] Could not get access to local fonts. Using fallback solution.");
|
|
15491
|
+
const unsupportedFonts = __privateMethod(this, _Editor_instances, determineUnsupportedFontsWithCanvas_fn).call(this, fontsUsedInDocument);
|
|
15492
|
+
this.options.onFontsResolved({
|
|
15493
|
+
documentFonts: fontsUsedInDocument,
|
|
15494
|
+
unsupportedFonts
|
|
15495
|
+
});
|
|
15496
|
+
return;
|
|
15497
|
+
}
|
|
15498
|
+
const localFontAccess = await navigator.permissions.query({ name: "local-fonts" });
|
|
15499
|
+
if (localFontAccess.state === "denied") {
|
|
15500
|
+
console.warn("[SuperDoc] Could not get access to local fonts. Using fallback solution.");
|
|
15501
|
+
const unsupportedFonts = __privateMethod(this, _Editor_instances, determineUnsupportedFontsWithCanvas_fn).call(this, fontsUsedInDocument);
|
|
15502
|
+
this.options.onFontsResolved({
|
|
15503
|
+
documentFonts: fontsUsedInDocument,
|
|
15504
|
+
unsupportedFonts
|
|
15505
|
+
});
|
|
15506
|
+
return;
|
|
15507
|
+
}
|
|
15508
|
+
try {
|
|
15509
|
+
const localFonts = await window.queryLocalFonts();
|
|
15510
|
+
const uniqueLocalFonts = [...new Set(localFonts.map((font) => font.family))];
|
|
15511
|
+
const unsupportedFonts = __privateMethod(this, _Editor_instances, determineUnsupportedFontsWithLocalFonts_fn).call(this, fontsUsedInDocument, uniqueLocalFonts);
|
|
15512
|
+
this.options.onFontsResolved({
|
|
15513
|
+
documentFonts: fontsUsedInDocument,
|
|
15514
|
+
unsupportedFonts
|
|
15515
|
+
});
|
|
15516
|
+
} catch {
|
|
15517
|
+
console.warn("[SuperDoc] Could not get access to local fonts. Using fallback solution.");
|
|
15518
|
+
const unsupportedFonts = __privateMethod(this, _Editor_instances, determineUnsupportedFontsWithCanvas_fn).call(this, fontsUsedInDocument);
|
|
15519
|
+
this.options.onFontsResolved({
|
|
15520
|
+
documentFonts: fontsUsedInDocument,
|
|
15521
|
+
unsupportedFonts
|
|
15522
|
+
});
|
|
15523
|
+
}
|
|
15524
|
+
};
|
|
15525
|
+
/**
|
|
15526
|
+
* Determines which fonts used in the document are not available locally nor imported.
|
|
15527
|
+
*
|
|
15528
|
+
* @param {string[]} fonts - Array of font family names used in the document.
|
|
15529
|
+
* @param {string[]} localFonts - Array of local font family names available on the system.
|
|
15530
|
+
* @returns {string[]} Array of font names that are unsupported.
|
|
15531
|
+
*/
|
|
15532
|
+
determineUnsupportedFontsWithLocalFonts_fn = function(fonts, localFonts) {
|
|
15533
|
+
const unsupportedFonts = fonts.filter((font) => {
|
|
15534
|
+
const isLocalFont = localFonts.includes(font);
|
|
15535
|
+
const isFontImported = this.fontsImported.includes(font);
|
|
15536
|
+
return !isLocalFont && !isFontImported;
|
|
15537
|
+
});
|
|
15538
|
+
return unsupportedFonts;
|
|
15539
|
+
};
|
|
15540
|
+
/**
|
|
15541
|
+
* Determines which fonts used in the document are not supported
|
|
15542
|
+
* by attempting to render them on a canvas.
|
|
15543
|
+
* Fonts are considered unsupported if they cannot be rendered
|
|
15544
|
+
* and are not already imported in the document via @font-face.
|
|
15545
|
+
*
|
|
15546
|
+
* @param {string[]} fonts - Array of font family names used in the document.
|
|
15547
|
+
* @returns {string[]} Array of unsupported font family names.
|
|
15548
|
+
*/
|
|
15549
|
+
determineUnsupportedFontsWithCanvas_fn = function(fonts) {
|
|
15550
|
+
const unsupportedFonts = fonts.filter((font) => {
|
|
15551
|
+
const canRender = canRenderFont(font);
|
|
15552
|
+
const isFontImported = this.fontsImported.includes(font);
|
|
15553
|
+
return !canRender && !isFontImported;
|
|
15554
|
+
});
|
|
15555
|
+
return unsupportedFonts;
|
|
15556
|
+
};
|
|
15448
15557
|
/**
|
|
15449
15558
|
* Creates document PM schema.
|
|
15450
15559
|
* @returns {void}
|
|
@@ -24256,6 +24365,15 @@ const TableCell = Node$1.create({
|
|
|
24256
24365
|
widthUnit: {
|
|
24257
24366
|
default: "px",
|
|
24258
24367
|
rendered: false
|
|
24368
|
+
},
|
|
24369
|
+
/**
|
|
24370
|
+
* @category Attribute
|
|
24371
|
+
* @param {TableCellProperties} tableCellProperties - Properties for the table cell.
|
|
24372
|
+
* @see {@link https://ecma-international.org/publications-and-standards/standards/ecma-376/} "Fundamentals And Markup Language Reference", page 463
|
|
24373
|
+
*/
|
|
24374
|
+
tableCellProperties: {
|
|
24375
|
+
default: null,
|
|
24376
|
+
rendered: false
|
|
24259
24377
|
}
|
|
24260
24378
|
};
|
|
24261
24379
|
},
|
|
@@ -26415,6 +26533,58 @@ const registerImages = async (foundImages, editor, view) => {
|
|
|
26415
26533
|
}
|
|
26416
26534
|
});
|
|
26417
26535
|
};
|
|
26536
|
+
const normalizeWrap = (attrs = {}) => {
|
|
26537
|
+
const wrap = attrs.wrap;
|
|
26538
|
+
if (wrap?.type && wrap.type !== "Inline") {
|
|
26539
|
+
return {
|
|
26540
|
+
type: wrap.type,
|
|
26541
|
+
attrs: wrap.attrs ?? {}
|
|
26542
|
+
};
|
|
26543
|
+
}
|
|
26544
|
+
if (wrap?.type === "Inline" && Object.keys(wrap.attrs ?? {}).length) {
|
|
26545
|
+
return {
|
|
26546
|
+
type: "Inline",
|
|
26547
|
+
attrs: wrap.attrs
|
|
26548
|
+
};
|
|
26549
|
+
}
|
|
26550
|
+
if (!wrap && attrs.wrapText) {
|
|
26551
|
+
return {
|
|
26552
|
+
type: "Square",
|
|
26553
|
+
attrs: {
|
|
26554
|
+
wrapText: attrs.wrapText
|
|
26555
|
+
}
|
|
26556
|
+
};
|
|
26557
|
+
}
|
|
26558
|
+
if (!wrap && attrs.wrapTopAndBottom) {
|
|
26559
|
+
return {
|
|
26560
|
+
type: "TopAndBottom",
|
|
26561
|
+
attrs: {}
|
|
26562
|
+
};
|
|
26563
|
+
}
|
|
26564
|
+
if (wrap?.type === "Inline") {
|
|
26565
|
+
return {
|
|
26566
|
+
type: "Inline",
|
|
26567
|
+
attrs: wrap.attrs ?? {}
|
|
26568
|
+
};
|
|
26569
|
+
}
|
|
26570
|
+
return {
|
|
26571
|
+
type: "Inline",
|
|
26572
|
+
attrs: {}
|
|
26573
|
+
};
|
|
26574
|
+
};
|
|
26575
|
+
const normalizeMarginOffset = (marginOffset = {}) => {
|
|
26576
|
+
const { left: left2, horizontal, ...rest } = marginOffset;
|
|
26577
|
+
return {
|
|
26578
|
+
...rest,
|
|
26579
|
+
horizontal: horizontal ?? left2
|
|
26580
|
+
};
|
|
26581
|
+
};
|
|
26582
|
+
const getNormalizedImageAttrs = (attrs = {}) => {
|
|
26583
|
+
return {
|
|
26584
|
+
wrap: normalizeWrap(attrs),
|
|
26585
|
+
marginOffset: normalizeMarginOffset(attrs.marginOffset ?? {})
|
|
26586
|
+
};
|
|
26587
|
+
};
|
|
26418
26588
|
const ImagePositionPluginKey = new PluginKey("ImagePosition");
|
|
26419
26589
|
const ImagePositionPlugin = ({ editor }) => {
|
|
26420
26590
|
const { view } = editor;
|
|
@@ -26462,7 +26632,8 @@ const getImagePositionDecorations = (state, view) => {
|
|
|
26462
26632
|
let style = "";
|
|
26463
26633
|
let className = "";
|
|
26464
26634
|
const { vRelativeFrom, alignH } = node.attrs.anchorData;
|
|
26465
|
-
const { size, padding
|
|
26635
|
+
const { size, padding } = node.attrs;
|
|
26636
|
+
const { marginOffset } = getNormalizedImageAttrs(node.attrs);
|
|
26466
26637
|
const pageBreak = findPreviousDomNodeWithClass(view, pos, "pagination-break-wrapper");
|
|
26467
26638
|
if (pageBreak) {
|
|
26468
26639
|
switch (alignH) {
|
|
@@ -26579,7 +26750,24 @@ const Image = Node$1.create({
|
|
|
26579
26750
|
rendered: false
|
|
26580
26751
|
},
|
|
26581
26752
|
originalAttributes: { rendered: false },
|
|
26582
|
-
|
|
26753
|
+
/**
|
|
26754
|
+
* @category Attribute
|
|
26755
|
+
* @param {Object} wrap - Wrapping options
|
|
26756
|
+
* @param {string} wrap.type - Wrap type: "None", "Square", "Through", "Tight", "TopAndBottom", "Inline"
|
|
26757
|
+
* @param {Object} [wrap.attrs] - Wrap attributes (only allowed attributes for the given type will be accepted)
|
|
26758
|
+
* @param {string} [wrap.attrs.wrapText] - Text wrapping mode for Square type: "bothSides", "largest", "left", "right"
|
|
26759
|
+
* @param {number} [wrap.attrs.distTop] - Top distance in pixels
|
|
26760
|
+
* @param {number} [wrap.attrs.distBottom] - Bottom distance in pixels
|
|
26761
|
+
* @param {number} [wrap.attrs.distLeft] - Left distance in pixels
|
|
26762
|
+
* @param {number} [wrap.attrs.distRight] - Right distance in pixels
|
|
26763
|
+
* @param {Array} [wrap.attrs.polygon] - Polygon points for Through/Tight types: [[x1,y1], [x2,y2], ...]
|
|
26764
|
+
* @param {boolean} [wrap.attrs.behindDoc] - Whether image should be behind document text (for wrapNone)
|
|
26765
|
+
*/
|
|
26766
|
+
wrap: {
|
|
26767
|
+
default: { type: "Inline" },
|
|
26768
|
+
rendered: false
|
|
26769
|
+
// Handled in main renderDOM
|
|
26770
|
+
},
|
|
26583
26771
|
anchorData: {
|
|
26584
26772
|
default: null,
|
|
26585
26773
|
rendered: false
|
|
@@ -26625,7 +26813,6 @@ const Image = Node$1.create({
|
|
|
26625
26813
|
* @private
|
|
26626
26814
|
*/
|
|
26627
26815
|
simplePos: { rendered: false },
|
|
26628
|
-
wrapText: { rendered: false },
|
|
26629
26816
|
extension: { rendered: false },
|
|
26630
26817
|
size: {
|
|
26631
26818
|
default: {},
|
|
@@ -26641,55 +26828,13 @@ const Image = Node$1.create({
|
|
|
26641
26828
|
},
|
|
26642
26829
|
padding: {
|
|
26643
26830
|
default: {},
|
|
26644
|
-
|
|
26645
|
-
|
|
26646
|
-
const { rotation } = transformData;
|
|
26647
|
-
const { height, width } = size;
|
|
26648
|
-
if (rotation && height && width) {
|
|
26649
|
-
const { horizontal, vertical } = getRotationMargins(width, height, rotation);
|
|
26650
|
-
left2 += horizontal;
|
|
26651
|
-
right2 += horizontal;
|
|
26652
|
-
top2 += vertical;
|
|
26653
|
-
bottom2 += vertical;
|
|
26654
|
-
}
|
|
26655
|
-
let style = "";
|
|
26656
|
-
if (left2 && marginOffset?.left == null) style += `margin-left: ${left2}px;`;
|
|
26657
|
-
if (top2 && marginOffset?.top == null) style += `margin-top: ${top2}px;`;
|
|
26658
|
-
if (bottom2) style += `margin-bottom: ${bottom2}px;`;
|
|
26659
|
-
if (right2) style += `margin-right: ${right2}px;`;
|
|
26660
|
-
return { style };
|
|
26661
|
-
}
|
|
26831
|
+
rendered: false
|
|
26832
|
+
// Handled in main renderDOM
|
|
26662
26833
|
},
|
|
26663
26834
|
marginOffset: {
|
|
26664
26835
|
default: {},
|
|
26665
|
-
|
|
26666
|
-
|
|
26667
|
-
const hasMarginOffsets = marginOffset?.left != null || marginOffset?.top != null;
|
|
26668
|
-
if (!hasAnchorData && !hasMarginOffsets) return {};
|
|
26669
|
-
const relativeFromPageV = anchorData?.vRelativeFrom === "page";
|
|
26670
|
-
const maxMarginV = 500;
|
|
26671
|
-
const baseLeft = marginOffset?.left ?? 0;
|
|
26672
|
-
const baseTop = marginOffset?.top ?? 0;
|
|
26673
|
-
let rotationLeft = 0;
|
|
26674
|
-
let rotationTop = 0;
|
|
26675
|
-
const { rotation } = transformData ?? {};
|
|
26676
|
-
const { height, width } = size ?? {};
|
|
26677
|
-
if (rotation && height && width) {
|
|
26678
|
-
const { horizontal, vertical } = getRotationMargins(width, height, rotation);
|
|
26679
|
-
rotationLeft = horizontal;
|
|
26680
|
-
rotationTop = vertical;
|
|
26681
|
-
}
|
|
26682
|
-
const left2 = baseLeft + rotationLeft;
|
|
26683
|
-
const top2 = baseTop + rotationTop;
|
|
26684
|
-
let style = "";
|
|
26685
|
-
if (left2) style += `margin-left: ${left2}px;`;
|
|
26686
|
-
if (top2) {
|
|
26687
|
-
if (relativeFromPageV && top2 >= maxMarginV) style += `margin-top: ${maxMarginV}px;`;
|
|
26688
|
-
else style += `margin-top: ${top2}px;`;
|
|
26689
|
-
}
|
|
26690
|
-
if (!style) return {};
|
|
26691
|
-
return { style };
|
|
26692
|
-
}
|
|
26836
|
+
rendered: false
|
|
26837
|
+
// Handled in main renderDOM
|
|
26693
26838
|
},
|
|
26694
26839
|
style: {
|
|
26695
26840
|
default: null,
|
|
@@ -26708,8 +26853,181 @@ const Image = Node$1.create({
|
|
|
26708
26853
|
}
|
|
26709
26854
|
];
|
|
26710
26855
|
},
|
|
26711
|
-
renderDOM({ htmlAttributes }) {
|
|
26712
|
-
|
|
26856
|
+
renderDOM({ node, htmlAttributes }) {
|
|
26857
|
+
const { wrap, marginOffset } = getNormalizedImageAttrs(node.attrs);
|
|
26858
|
+
const { anchorData, padding, transformData = {}, size = { width: 0, height: 0 } } = node.attrs;
|
|
26859
|
+
const margin = {
|
|
26860
|
+
left: 0,
|
|
26861
|
+
right: 0,
|
|
26862
|
+
top: 0,
|
|
26863
|
+
bottom: 0
|
|
26864
|
+
};
|
|
26865
|
+
let centered = false;
|
|
26866
|
+
let floatRight = false;
|
|
26867
|
+
let baseHorizontal = marginOffset?.horizontal || 0;
|
|
26868
|
+
let style = "";
|
|
26869
|
+
if (padding) {
|
|
26870
|
+
if (padding.left) margin.left += padding.left;
|
|
26871
|
+
if (padding.right) margin.right += padding.right;
|
|
26872
|
+
if (padding.top) margin.top += padding.top;
|
|
26873
|
+
if (padding.bottom) margin.bottom += padding.bottom;
|
|
26874
|
+
}
|
|
26875
|
+
const { rotation } = transformData;
|
|
26876
|
+
const { height, width } = size;
|
|
26877
|
+
if (rotation && height && width) {
|
|
26878
|
+
const { horizontal, vertical } = getRotationMargins(width, height, rotation);
|
|
26879
|
+
margin.left += horizontal;
|
|
26880
|
+
margin.right += horizontal;
|
|
26881
|
+
margin.top += vertical;
|
|
26882
|
+
margin.bottom += vertical;
|
|
26883
|
+
}
|
|
26884
|
+
if (wrap && wrap.type) {
|
|
26885
|
+
const { type, attrs = {} } = wrap;
|
|
26886
|
+
switch (type) {
|
|
26887
|
+
case "None":
|
|
26888
|
+
style += "position: absolute;";
|
|
26889
|
+
if (attrs.behindDoc) {
|
|
26890
|
+
style += "z-index: -1;";
|
|
26891
|
+
} else {
|
|
26892
|
+
style += "z-index: 1;";
|
|
26893
|
+
}
|
|
26894
|
+
break;
|
|
26895
|
+
case "Square":
|
|
26896
|
+
style += "shape-outside: border-box; clear: both;";
|
|
26897
|
+
if (attrs.wrapText === "right") {
|
|
26898
|
+
style += "float: left;";
|
|
26899
|
+
} else if (attrs.wrapText === "left") {
|
|
26900
|
+
style += "float: right;";
|
|
26901
|
+
floatRight = true;
|
|
26902
|
+
} else if (["largest", "bothSides"].includes(attrs.wrapText)) {
|
|
26903
|
+
const pageStyles2 = this.editor?.converter?.pageStyles;
|
|
26904
|
+
if (pageStyles2?.pageSize && pageStyles2?.pageMargins && size.width) {
|
|
26905
|
+
const pageWidth = inchesToPixels(pageStyles2.pageSize.width);
|
|
26906
|
+
const leftMargin = inchesToPixels(pageStyles2.pageMargins.left);
|
|
26907
|
+
const rightMargin = inchesToPixels(pageStyles2.pageMargins.right);
|
|
26908
|
+
const contentWidth = pageWidth - leftMargin - rightMargin;
|
|
26909
|
+
const imageWidth = size.width + (attrs.distLeft || 0) + (attrs.distRight || 0);
|
|
26910
|
+
const leftSpace = marginOffset.horizontal;
|
|
26911
|
+
const rightSpace = contentWidth - leftSpace - imageWidth;
|
|
26912
|
+
if (rightSpace < 0) {
|
|
26913
|
+
style += "float: left;";
|
|
26914
|
+
} else if (rightSpace > leftSpace) {
|
|
26915
|
+
style += "float: left;";
|
|
26916
|
+
} else {
|
|
26917
|
+
style += "float: right;";
|
|
26918
|
+
floatRight = true;
|
|
26919
|
+
baseHorizontal = rightSpace;
|
|
26920
|
+
}
|
|
26921
|
+
} else {
|
|
26922
|
+
style += "float: left;";
|
|
26923
|
+
}
|
|
26924
|
+
}
|
|
26925
|
+
if (attrs.distTop) margin.top += attrs.distTop;
|
|
26926
|
+
if (attrs.distBottom) margin.bottom += attrs.distBottom;
|
|
26927
|
+
if (attrs.distLeft) margin.left += attrs.distLeft;
|
|
26928
|
+
if (attrs.distRight) margin.right += attrs.distRight;
|
|
26929
|
+
break;
|
|
26930
|
+
case "Through":
|
|
26931
|
+
case "Tight":
|
|
26932
|
+
style += "clear: both;";
|
|
26933
|
+
const pageStyles = this.editor?.converter?.pageStyles;
|
|
26934
|
+
if (pageStyles?.pageSize && pageStyles?.pageMargins && size.width) {
|
|
26935
|
+
const pageWidth = inchesToPixels(pageStyles.pageSize.width);
|
|
26936
|
+
const leftMargin = inchesToPixels(pageStyles.pageMargins.left);
|
|
26937
|
+
const rightMargin = inchesToPixels(pageStyles.pageMargins.right);
|
|
26938
|
+
const contentWidth = pageWidth - leftMargin - rightMargin;
|
|
26939
|
+
const imageWidth = size.width + (attrs.distLeft || 0) + (attrs.distRight || 0);
|
|
26940
|
+
const leftSpace = marginOffset.horizontal;
|
|
26941
|
+
const rightSpace = contentWidth - leftSpace - imageWidth;
|
|
26942
|
+
if (rightSpace < 0) {
|
|
26943
|
+
style += "float: left;";
|
|
26944
|
+
} else if (rightSpace > leftSpace) {
|
|
26945
|
+
style += "float: left;";
|
|
26946
|
+
} else {
|
|
26947
|
+
style += "float: right;";
|
|
26948
|
+
floatRight = true;
|
|
26949
|
+
baseHorizontal = rightSpace;
|
|
26950
|
+
}
|
|
26951
|
+
} else {
|
|
26952
|
+
style += "float: left;";
|
|
26953
|
+
}
|
|
26954
|
+
if (attrs.distTop) margin.top += attrs.distTop;
|
|
26955
|
+
if (attrs.distBottom) margin.bottom += attrs.distBottom;
|
|
26956
|
+
if (attrs.distLeft) margin.left += attrs.distLeft;
|
|
26957
|
+
if (attrs.distRight) margin.right += attrs.distRight;
|
|
26958
|
+
if (attrs.polygon) {
|
|
26959
|
+
let horizontalOffset = floatRight ? attrs.polygon[0][0] || 0 : marginOffset.horizontal + 15;
|
|
26960
|
+
let maxX = 0;
|
|
26961
|
+
let minX = 0;
|
|
26962
|
+
let minY = 0;
|
|
26963
|
+
let maxY = 0;
|
|
26964
|
+
attrs.polygon.forEach(([x, y]) => {
|
|
26965
|
+
if (floatRight && x < horizontalOffset) horizontalOffset = x;
|
|
26966
|
+
if (x > maxX) maxX = x;
|
|
26967
|
+
if (x < minX) minX = x;
|
|
26968
|
+
if (y > maxY) maxY = y;
|
|
26969
|
+
if (y < minY) minY = y;
|
|
26970
|
+
});
|
|
26971
|
+
const originalWidth = maxX - minX;
|
|
26972
|
+
const originalHeight = maxY - minY;
|
|
26973
|
+
const scaleWidth = Math.min(1, size.width / originalWidth);
|
|
26974
|
+
const scaleHeight = Math.min(1, size.height / originalHeight);
|
|
26975
|
+
const verticalOffset = Math.max(0, marginOffset.top);
|
|
26976
|
+
const points = attrs.polygon.map(([x, y]) => `${horizontalOffset + x * scaleWidth}px ${verticalOffset + y * scaleHeight}px`).join(", ");
|
|
26977
|
+
style += `shape-outside: polygon(${points});`;
|
|
26978
|
+
}
|
|
26979
|
+
break;
|
|
26980
|
+
case "TopAndBottom":
|
|
26981
|
+
style += "display: block; clear: both;";
|
|
26982
|
+
if (attrs.distTop) margin.top += attrs.distTop;
|
|
26983
|
+
if (attrs.distBottom) margin.bottom += attrs.distBottom;
|
|
26984
|
+
centered = true;
|
|
26985
|
+
break;
|
|
26986
|
+
}
|
|
26987
|
+
}
|
|
26988
|
+
const hasAnchorData = Boolean(anchorData);
|
|
26989
|
+
const hasMarginOffsets = marginOffset?.horizontal != null || marginOffset?.top != null;
|
|
26990
|
+
if (hasAnchorData || hasMarginOffsets) {
|
|
26991
|
+
const relativeFromPageV = anchorData?.vRelativeFrom === "page";
|
|
26992
|
+
const maxMarginV = 500;
|
|
26993
|
+
const baseTop = Math.max(0, marginOffset?.top ?? 0);
|
|
26994
|
+
let rotationHorizontal = 0;
|
|
26995
|
+
let rotationTop = 0;
|
|
26996
|
+
const { rotation: rotation2 } = transformData ?? {};
|
|
26997
|
+
const { height: height2, width: width2 } = size ?? {};
|
|
26998
|
+
if (rotation2 && height2 && width2) {
|
|
26999
|
+
const { horizontal: horizontal2, vertical } = getRotationMargins(width2, height2, rotation2);
|
|
27000
|
+
rotationHorizontal = horizontal2;
|
|
27001
|
+
rotationTop = vertical;
|
|
27002
|
+
}
|
|
27003
|
+
const horizontal = baseHorizontal + rotationHorizontal;
|
|
27004
|
+
const top2 = baseTop + rotationTop;
|
|
27005
|
+
if (horizontal) {
|
|
27006
|
+
if (floatRight) {
|
|
27007
|
+
margin.right += horizontal;
|
|
27008
|
+
} else {
|
|
27009
|
+
margin.left += horizontal;
|
|
27010
|
+
}
|
|
27011
|
+
}
|
|
27012
|
+
if (top2) {
|
|
27013
|
+
if (relativeFromPageV && top2 >= maxMarginV) margin.top += maxMarginV;
|
|
27014
|
+
else margin.top += top2;
|
|
27015
|
+
}
|
|
27016
|
+
}
|
|
27017
|
+
if (centered) {
|
|
27018
|
+
style += "margin-left: auto; margin-right: auto;";
|
|
27019
|
+
} else {
|
|
27020
|
+
if (margin.left) style += `margin-left: ${margin.left}px;`;
|
|
27021
|
+
if (margin.right) style += `margin-right: ${margin.right}px;`;
|
|
27022
|
+
}
|
|
27023
|
+
if (margin.top) style += `margin-top: ${margin.top}px;`;
|
|
27024
|
+
if (margin.bottom) style += `margin-bottom: ${margin.bottom}px;`;
|
|
27025
|
+
const finalAttributes = { ...htmlAttributes };
|
|
27026
|
+
if (style) {
|
|
27027
|
+
const existingStyle = finalAttributes.style || "";
|
|
27028
|
+
finalAttributes.style = existingStyle + (existingStyle ? " " : "") + style;
|
|
27029
|
+
}
|
|
27030
|
+
return ["img", Attribute.mergeAttributes(this.options.htmlAttributes, finalAttributes)];
|
|
26713
27031
|
},
|
|
26714
27032
|
addCommands() {
|
|
26715
27033
|
return {
|
|
@@ -26731,6 +27049,85 @@ const Image = Node$1.create({
|
|
|
26731
27049
|
type: this.name,
|
|
26732
27050
|
attrs: options
|
|
26733
27051
|
});
|
|
27052
|
+
},
|
|
27053
|
+
/**
|
|
27054
|
+
* Set the wrapping mode and attributes for the selected image
|
|
27055
|
+
* @category Command
|
|
27056
|
+
* @param {Object} options - Wrapping options
|
|
27057
|
+
* @param {string} options.type - Wrap type: "None", "Square", "Through", "Tight", "TopAndBottom", "Inline"
|
|
27058
|
+
* @param {Object} [options.attrs] - Wrap attributes (only allowed attributes for the given type will be accepted)
|
|
27059
|
+
* @param {string} [options.attrs.wrapText] - Text wrapping mode for Square type: "bothSides", "largest", "left", "right"
|
|
27060
|
+
* @param {number} [options.attrs.distTop] - Top distance in pixels
|
|
27061
|
+
* @param {number} [options.attrs.distBottom] - Bottom distance in pixels
|
|
27062
|
+
* @param {number} [options.attrs.distLeft] - Left distance in pixels
|
|
27063
|
+
* @param {number} [options.attrs.distRight] - Right distance in pixels
|
|
27064
|
+
* @param {Array} [options.attrs.polygon] - Polygon points for Through/Tight types: [[x1,y1], [x2,y2], ...]
|
|
27065
|
+
* @param {boolean} [options.attrs.behindDoc] - Whether image should be behind document text (for wrapNone)
|
|
27066
|
+
* @example
|
|
27067
|
+
* // No wrapping, behind document
|
|
27068
|
+
* editor.commands.setWrapping({ type: 'None', attrs: {behindDoc: true} })
|
|
27069
|
+
*
|
|
27070
|
+
* // Square wrapping on both sides with distances
|
|
27071
|
+
* editor.commands.setWrapping({
|
|
27072
|
+
* type: 'Square',
|
|
27073
|
+
* attrs: {
|
|
27074
|
+
* wrapText: 'bothSides',
|
|
27075
|
+
* distTop: 10,
|
|
27076
|
+
* distBottom: 10,
|
|
27077
|
+
* distLeft: 10,
|
|
27078
|
+
* distRight: 10
|
|
27079
|
+
* }
|
|
27080
|
+
* })
|
|
27081
|
+
*
|
|
27082
|
+
* // Tight wrapping with polygon
|
|
27083
|
+
* editor.commands.setWrapping({
|
|
27084
|
+
* type: 'Tight',
|
|
27085
|
+
* attrs: {
|
|
27086
|
+
* polygon: [[0, 0], [100, 0], [100, 100], [0, 100]]
|
|
27087
|
+
* }
|
|
27088
|
+
* })
|
|
27089
|
+
*
|
|
27090
|
+
* // Top and bottom wrapping
|
|
27091
|
+
* editor.commands.setWrapping({
|
|
27092
|
+
* type: 'TopAndBottom',
|
|
27093
|
+
* attrs: {
|
|
27094
|
+
* distTop: 15,
|
|
27095
|
+
* distBottom: 15
|
|
27096
|
+
* }
|
|
27097
|
+
* })
|
|
27098
|
+
*/
|
|
27099
|
+
setWrapping: (options) => ({ chain, state }) => {
|
|
27100
|
+
const { selection } = state;
|
|
27101
|
+
const { $from } = selection;
|
|
27102
|
+
const node = $from.nodeAfter;
|
|
27103
|
+
if (!node || node.type.name !== this.name) {
|
|
27104
|
+
return false;
|
|
27105
|
+
}
|
|
27106
|
+
const { type, attrs = {} } = options;
|
|
27107
|
+
const allowedAttrs = {};
|
|
27108
|
+
const allowedAttributes = {
|
|
27109
|
+
None: ["behindDoc"],
|
|
27110
|
+
Square: ["wrapText", "distTop", "distBottom", "distLeft", "distRight"],
|
|
27111
|
+
Through: ["distTop", "distBottom", "distLeft", "distRight", "polygon"],
|
|
27112
|
+
Tight: ["distTop", "distBottom", "distLeft", "distRight", "polygon"],
|
|
27113
|
+
TopAndBottom: ["distTop", "distBottom"],
|
|
27114
|
+
Inline: []
|
|
27115
|
+
};
|
|
27116
|
+
const allowedForType = allowedAttributes[type] || [];
|
|
27117
|
+
Object.keys(attrs).forEach((key2) => {
|
|
27118
|
+
if (allowedForType.includes(key2)) {
|
|
27119
|
+
allowedAttrs[key2] = attrs[key2];
|
|
27120
|
+
}
|
|
27121
|
+
});
|
|
27122
|
+
const updatedAttrs = {
|
|
27123
|
+
...node.attrs,
|
|
27124
|
+
wrap: {
|
|
27125
|
+
type,
|
|
27126
|
+
attrs: allowedAttrs
|
|
27127
|
+
},
|
|
27128
|
+
isAnchor: type !== "Inline"
|
|
27129
|
+
};
|
|
27130
|
+
return chain().updateAttributes(this.name, updatedAttrs).run();
|
|
26734
27131
|
}
|
|
26735
27132
|
};
|
|
26736
27133
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { computed, createElementBlock, openBlock, createElementVNode, createCommentVNode, normalizeClass, normalizeStyle, ref, withKeys, unref, withModifiers, createBlock, toDisplayString, withDirectives, vModelText, nextTick, getCurrentInstance, createVNode, readonly, watch, onMounted, onBeforeUnmount, reactive, onBeforeMount, inject, onActivated, onDeactivated, createTextVNode, Fragment, Comment, defineComponent, provide, h, Teleport, toRef, renderSlot, isVNode, shallowRef, watchEffect, mergeProps, Transition, vShow, cloneVNode, Text, renderList, withCtx } from "vue";
|
|
2
|
-
import { p as process$1 } from "./converter-
|
|
3
|
-
import { _ as _export_sfc, u as useHighContrastMode, g as global$1 } from "./editor-
|
|
2
|
+
import { p as process$1 } from "./converter-DpPj67OW.js";
|
|
3
|
+
import { _ as _export_sfc, u as useHighContrastMode, g as global$1 } from "./editor-Dx6AhT5N.js";
|
|
4
4
|
const sanitizeNumber = (value, defaultNumber) => {
|
|
5
5
|
let sanitized = value.replace(/[^0-9.]/g, "");
|
|
6
6
|
sanitized = parseFloat(sanitized);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { E } from "./chunks/editor-
|
|
2
|
-
import "./chunks/converter-
|
|
3
|
-
import "./chunks/docx-zipper-
|
|
1
|
+
import { E } from "./chunks/editor-Dx6AhT5N.js";
|
|
2
|
+
import "./chunks/converter-DpPj67OW.js";
|
|
3
|
+
import "./chunks/docx-zipper-6Kc95yG-.js";
|
|
4
4
|
export {
|
|
5
5
|
E as Editor
|
|
6
6
|
};
|