@harbour-enterprises/superdoc 0.22.0-next.4 → 0.22.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.
Files changed (28) hide show
  1. package/dist/chunks/{PdfViewer-CxIz7yf-.cjs → PdfViewer-Badqoc1e.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-BBpGCmdE.es.js → PdfViewer-dsL5uHg1.es.js} +1 -1
  3. package/dist/chunks/{index-CYCctXm3.es.js → index-DBNzXf1D.es.js} +2 -2
  4. package/dist/chunks/{index-BE07bQaY.cjs → index-DVrbZM76.cjs} +2 -2
  5. package/dist/chunks/{super-editor.es-Ccu1wOj1.es.js → super-editor.es-DruRanWK.es.js} +157 -59
  6. package/dist/chunks/{super-editor.es-cZsHkhM6.cjs → super-editor.es-p3eqHXlj.cjs} +157 -59
  7. package/dist/core/types/index.d.ts.map +1 -1
  8. package/dist/super-editor/ai-writer.es.js +2 -2
  9. package/dist/super-editor/chunks/{converter-DBwwYo1I.js → converter-DujfV3Zn.js} +46 -34
  10. package/dist/super-editor/chunks/{docx-zipper-BCI-3XE9.js → docx-zipper-DccEqL60.js} +73 -12
  11. package/dist/super-editor/chunks/{editor-B2S-zXBF.js → editor-Dq3xPdti.js} +41 -16
  12. package/dist/super-editor/chunks/{toolbar-BX9nPPG0.js → toolbar-u5oyT_9K.js} +2 -2
  13. package/dist/super-editor/converter.es.js +1 -1
  14. package/dist/super-editor/docx-zipper.es.js +2 -2
  15. package/dist/super-editor/editor.es.js +3 -3
  16. package/dist/super-editor/file-zipper.es.js +1 -1
  17. package/dist/super-editor/src/core/DocxZipper.d.ts +1 -1
  18. package/dist/super-editor/src/core/super-converter/exporter.d.ts +1 -0
  19. package/dist/super-editor/src/extensions/custom-selection/custom-selection.d.ts +5 -0
  20. package/dist/super-editor/super-editor.es.js +6 -6
  21. package/dist/super-editor/toolbar.es.js +2 -2
  22. package/dist/super-editor.cjs +1 -1
  23. package/dist/super-editor.es.js +1 -1
  24. package/dist/superdoc.cjs +2 -2
  25. package/dist/superdoc.es.js +2 -2
  26. package/dist/superdoc.umd.js +157 -59
  27. package/dist/superdoc.umd.js.map +1 -1
  28. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const vue = require("./vue-DWle4Cai.cjs");
4
- const superdoc = require("./index-BE07bQaY.cjs");
4
+ const superdoc = require("./index-DVrbZM76.cjs");
5
5
  function self(vars) {
6
6
  const {
7
7
  opacityDisabled,
@@ -1,5 +1,5 @@
1
1
  import { m as defineComponent, B as h, O as Transition, $ as process$1, I as watchEffect, d as computed, r as ref, j as onMounted, W as onUnmounted, c as createElementBlock, o as openBlock, a as createBaseVNode, f as createCommentVNode, v as createVNode, x as unref } from "./vue-CXxsqYcP.es.js";
2
- import { d as derived, c, a as cB, f as fadeInTransition, b as cM, N as NBaseLoading, w as warnOnce, u as useConfig, e as useTheme, p as pxfy, g as createKey, h as useThemeClass, i as useCompitable, _ as _export_sfc, j as useSuperdocStore, s as storeToRefs, k as useSelection } from "./index-CYCctXm3.es.js";
2
+ import { d as derived, c, a as cB, f as fadeInTransition, b as cM, N as NBaseLoading, w as warnOnce, u as useConfig, e as useTheme, p as pxfy, g as createKey, h as useThemeClass, i as useCompitable, _ as _export_sfc, j as useSuperdocStore, s as storeToRefs, k as useSelection } from "./index-DBNzXf1D.es.js";
3
3
  function self(vars) {
4
4
  const {
5
5
  opacityDisabled,
@@ -1,4 +1,4 @@
1
- import { q as index$1, C as CommentsPluginKey, h as TrackChangesBasePluginKey, E as Editor, n as getRichTextExtensions, f as SuperInput, e as SuperEditor, A as AIWriter, g as SuperToolbar, i as createZip } from "./super-editor.es-Ccu1wOj1.es.js";
1
+ import { q as index$1, C as CommentsPluginKey, h as TrackChangesBasePluginKey, E as Editor, n as getRichTextExtensions, f as SuperInput, e as SuperEditor, A as AIWriter, g as SuperToolbar, i as createZip } from "./super-editor.es-DruRanWK.es.js";
2
2
  import { a0 as effectScope, r as ref, _ as markRaw, $ as process$1, a1 as toRaw, d as computed, a2 as isRef, a3 as isReactive, C as toRef, i as inject, p as getCurrentInstance, l as watch, x as unref, a4 as hasInjectionContext, M as reactive, s as nextTick, a5 as getCurrentScope, a6 as onScopeDispose, a7 as toRefs, g as global$1, J as shallowRef, N as readonly, j as onMounted, k as onBeforeUnmount, h as onBeforeMount, S as onActivated, q as onDeactivated, z as createTextVNode, F as Fragment, Q as Comment, m as defineComponent, D as provide, H as withDirectives, B as h, U as Teleport, R as renderSlot, V as isVNode, I as watchEffect, O as Transition, a8 as TransitionGroup, E as mergeProps, P as vShow, G as cloneVNode, T as Text, c as createElementBlock, o as openBlock, t as toDisplayString, v as createVNode, y as withCtx, a as createBaseVNode, A as normalizeStyle, f as createCommentVNode, u as createBlock, w as withModifiers, n as normalizeClass, a9 as resolveDirective, e as renderList, b as createApp, X as resolveDynamicComponent, aa as defineAsyncComponent } from "./vue-CXxsqYcP.es.js";
3
3
  import { B as Buffer$2 } from "./jszip-B8KIZSNe.es.js";
4
4
  import { B as BlankDOCX } from "./blank-docx-iwdyG9RH.es.js";
@@ -17392,7 +17392,7 @@ const _sfc_main = {
17392
17392
  __name: "SuperDoc",
17393
17393
  emits: ["selection-update"],
17394
17394
  setup(__props, { emit: __emit }) {
17395
- const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-BBpGCmdE.es.js"));
17395
+ const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-dsL5uHg1.es.js"));
17396
17396
  const superdocStore = useSuperdocStore();
17397
17397
  const commentsStore = useCommentsStore();
17398
17398
  const {
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const superEditor_es = require("./super-editor.es-cZsHkhM6.cjs");
2
+ const superEditor_es = require("./super-editor.es-p3eqHXlj.cjs");
3
3
  const vue = require("./vue-DWle4Cai.cjs");
4
4
  const jszip = require("./jszip-b7l8QkfH.cjs");
5
5
  const blankDocx = require("./blank-docx-CPqX9RF5.cjs");
@@ -17409,7 +17409,7 @@ const _sfc_main = {
17409
17409
  __name: "SuperDoc",
17410
17410
  emits: ["selection-update"],
17411
17411
  setup(__props, { emit: __emit }) {
17412
- const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-CxIz7yf-.cjs")));
17412
+ const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-Badqoc1e.cjs")));
17413
17413
  const superdocStore = useSuperdocStore();
17414
17414
  const commentsStore = useCommentsStore();
17415
17415
  const {
@@ -30603,6 +30603,51 @@ const DEFAULT_SECTION_PROPS_TWIPS = Object.freeze({
30603
30603
  gutter: "0"
30604
30604
  })
30605
30605
  });
30606
+ const ensureSectionLayoutDefaults = (sectPr, converter) => {
30607
+ if (!sectPr) {
30608
+ return {
30609
+ type: "element",
30610
+ name: "w:sectPr",
30611
+ elements: []
30612
+ };
30613
+ }
30614
+ if (!sectPr.elements) sectPr.elements = [];
30615
+ const ensureChild = (name) => {
30616
+ let child = sectPr.elements.find((n) => n.name === name);
30617
+ if (!child) {
30618
+ child = {
30619
+ type: "element",
30620
+ name,
30621
+ elements: [],
30622
+ attributes: {}
30623
+ };
30624
+ sectPr.elements.push(child);
30625
+ } else {
30626
+ if (!child.elements) child.elements = [];
30627
+ if (!child.attributes) child.attributes = {};
30628
+ }
30629
+ return child;
30630
+ };
30631
+ const pageSize = converter?.pageStyles?.pageSize;
30632
+ const pgSz = ensureChild("w:pgSz");
30633
+ if (pageSize?.width != null) pgSz.attributes["w:w"] = String(inchesToTwips(pageSize.width));
30634
+ if (pageSize?.height != null) pgSz.attributes["w:h"] = String(inchesToTwips(pageSize.height));
30635
+ if (pgSz.attributes["w:w"] == null) pgSz.attributes["w:w"] = DEFAULT_SECTION_PROPS_TWIPS.pageSize.width;
30636
+ if (pgSz.attributes["w:h"] == null) pgSz.attributes["w:h"] = DEFAULT_SECTION_PROPS_TWIPS.pageSize.height;
30637
+ const pageMargins = converter?.pageStyles?.pageMargins;
30638
+ const pgMar = ensureChild("w:pgMar");
30639
+ if (pageMargins) {
30640
+ Object.entries(pageMargins).forEach(([key2, value]) => {
30641
+ const converted = inchesToTwips(value);
30642
+ if (converted != null) pgMar.attributes[`w:${key2}`] = String(converted);
30643
+ });
30644
+ }
30645
+ Object.entries(DEFAULT_SECTION_PROPS_TWIPS.pageMargins).forEach(([key2, value]) => {
30646
+ const attrKey = `w:${key2}`;
30647
+ if (pgMar.attributes[attrKey] == null) pgMar.attributes[attrKey] = value;
30648
+ });
30649
+ return sectPr;
30650
+ };
30606
30651
  const isLineBreakOnlyRun = (node) => {
30607
30652
  if (!node) return false;
30608
30653
  if (node.type === "lineBreak" || node.type === "hardBreak") return true;
@@ -30665,6 +30710,7 @@ function translateBodyNode(params2) {
30665
30710
  } else if (!sectPr.elements) {
30666
30711
  sectPr = { ...sectPr, elements: [] };
30667
30712
  }
30713
+ sectPr = ensureSectionLayoutDefaults(sectPr, params2.converter);
30668
30714
  if (params2.converter) {
30669
30715
  const hasHeader = sectPr.elements?.some((n) => n.name === "w:headerReference");
30670
30716
  const hasDefaultHeader = params2.converter.headerIds?.default;
@@ -30678,40 +30724,6 @@ function translateBodyNode(params2) {
30678
30724
  const defaultFooter = generateDefaultHeaderFooter("footer", params2.converter.footerIds?.default);
30679
30725
  sectPr.elements.push(defaultFooter);
30680
30726
  }
30681
- const newMargins = params2.converter.pageStyles?.pageMargins;
30682
- if (newMargins) {
30683
- let sectPrMargins = sectPr.elements.find((n) => n.name === "w:pgMar");
30684
- if (!sectPrMargins) {
30685
- sectPrMargins = {
30686
- type: "element",
30687
- name: "w:pgMar",
30688
- attributes: {}
30689
- };
30690
- sectPr.elements.push(sectPrMargins);
30691
- } else if (!sectPrMargins.attributes) {
30692
- sectPrMargins.attributes = {};
30693
- }
30694
- Object.entries(newMargins).forEach(([key2, value]) => {
30695
- const convertedValue = inchesToTwips(value);
30696
- sectPrMargins.attributes[`w:${key2}`] = convertedValue;
30697
- });
30698
- }
30699
- let sectPrPgSz = sectPr.elements.find((n) => n.name === "w:pgSz");
30700
- if (!sectPrPgSz) {
30701
- sectPrPgSz = {
30702
- type: "element",
30703
- name: "w:pgSz",
30704
- attributes: {}
30705
- };
30706
- sectPr.elements.push(sectPrPgSz);
30707
- } else if (!sectPrPgSz.attributes) {
30708
- sectPrPgSz.attributes = {};
30709
- }
30710
- const pageSize = params2.converter.pageStyles?.pageSize;
30711
- const widthInches = pageSize?.width;
30712
- const heightInches = pageSize?.height;
30713
- sectPrPgSz.attributes["w:w"] = widthInches ? String(inchesToTwips(widthInches)) : sectPrPgSz.attributes["w:w"] ?? DEFAULT_SECTION_PROPS_TWIPS.pageSize.width;
30714
- sectPrPgSz.attributes["w:h"] = heightInches ? String(inchesToTwips(heightInches)) : sectPrPgSz.attributes["w:h"] ?? DEFAULT_SECTION_PROPS_TWIPS.pageSize.height;
30715
30727
  }
30716
30728
  const elements = translateChildNodes(params2);
30717
30729
  if (params2.isHeaderFooter) {
@@ -36267,14 +36279,19 @@ class DocxZipper {
36267
36279
  /**
36268
36280
  * Update [Content_Types].xml with extensions of new Image annotations
36269
36281
  */
36270
- async updateContentTypes(docx, media, fromJson) {
36282
+ async updateContentTypes(docx, media, fromJson, updatedDocs = {}) {
36283
+ const additionalPartNames = Object.keys(updatedDocs || {});
36271
36284
  const newMediaTypes = Object.keys(media).map((name) => {
36272
36285
  return this.getFileExtension(name);
36273
36286
  }).filter(Boolean);
36274
36287
  const contentTypesPath = "[Content_Types].xml";
36275
36288
  let contentTypesXml;
36276
36289
  if (fromJson) {
36277
- contentTypesXml = docx.files.find((file) => file.name === contentTypesPath)?.content || "";
36290
+ if (Array.isArray(docx.files)) {
36291
+ contentTypesXml = docx.files.find((file) => file.name === contentTypesPath)?.content || "";
36292
+ } else {
36293
+ contentTypesXml = docx.files?.[contentTypesPath] || "";
36294
+ }
36278
36295
  } else contentTypesXml = await docx.file(contentTypesPath).async("string");
36279
36296
  let typesString = "";
36280
36297
  const defaultMediaTypes = getContentTypesFromXml(contentTypesXml);
@@ -36300,24 +36317,39 @@ class DocxZipper {
36300
36317
  const hasCommentsExtensible = types2.elements?.some(
36301
36318
  (el) => el.name === "Override" && el.attributes.PartName === "/word/commentsExtensible.xml"
36302
36319
  );
36303
- if (docx.files["word/comments.xml"]) {
36320
+ const hasFile = (filename) => {
36321
+ if (!docx?.files) return false;
36322
+ if (!fromJson) return Boolean(docx.files[filename]);
36323
+ if (Array.isArray(docx.files)) return docx.files.some((file) => file.name === filename);
36324
+ return Boolean(docx.files[filename]);
36325
+ };
36326
+ if (hasFile("word/comments.xml")) {
36304
36327
  const commentsDef = `<Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml" />`;
36305
36328
  if (!hasComments) typesString += commentsDef;
36306
36329
  }
36307
- if (docx.files["word/commentsExtended.xml"]) {
36330
+ if (hasFile("word/commentsExtended.xml")) {
36308
36331
  const commentsExtendedDef = `<Override PartName="/word/commentsExtended.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml" />`;
36309
36332
  if (!hasCommentsExtended) typesString += commentsExtendedDef;
36310
36333
  }
36311
- if (docx.files["word/commentsIds.xml"]) {
36334
+ if (hasFile("word/commentsIds.xml")) {
36312
36335
  const commentsIdsDef = `<Override PartName="/word/commentsIds.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsIds+xml" />`;
36313
36336
  if (!hasCommentsIds) typesString += commentsIdsDef;
36314
36337
  }
36315
- if (docx.files["word/commentsExtensible.xml"]) {
36338
+ if (hasFile("word/commentsExtensible.xml")) {
36316
36339
  const commentsExtendedDef = `<Override PartName="/word/commentsExtensible.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtensible+xml" />`;
36317
36340
  if (!hasCommentsExtensible) typesString += commentsExtendedDef;
36318
36341
  }
36319
- Object.keys(docx.files).forEach((name) => {
36320
- if (name.includes(".rels") || !name.includes("header") && !name.includes("footer")) return;
36342
+ const partNames = new Set(additionalPartNames);
36343
+ if (docx?.files) {
36344
+ if (fromJson && Array.isArray(docx.files)) {
36345
+ docx.files.forEach((file) => partNames.add(file.name));
36346
+ } else {
36347
+ Object.keys(docx.files).forEach((key2) => partNames.add(key2));
36348
+ }
36349
+ }
36350
+ partNames.forEach((name) => {
36351
+ if (name.includes(".rels")) return;
36352
+ if (!name.includes("header") && !name.includes("footer")) return;
36321
36353
  const hasExtensible = types2.elements?.some(
36322
36354
  (el) => el.name === "Override" && el.attributes.PartName === `/${name}`
36323
36355
  );
@@ -36328,7 +36360,48 @@ class DocxZipper {
36328
36360
  }
36329
36361
  });
36330
36362
  const beginningString = '<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">';
36331
- const updatedContentTypesXml = contentTypesXml.replace(beginningString, `${beginningString}${typesString}`);
36363
+ let updatedContentTypesXml = contentTypesXml.replace(beginningString, `${beginningString}${typesString}`);
36364
+ let relationshipsXml = updatedDocs["word/_rels/document.xml.rels"];
36365
+ if (!relationshipsXml) {
36366
+ if (fromJson) {
36367
+ if (Array.isArray(docx.files)) {
36368
+ relationshipsXml = docx.files.find((file) => file.name === "word/_rels/document.xml.rels")?.content;
36369
+ } else {
36370
+ relationshipsXml = docx.files?.["word/_rels/document.xml.rels"];
36371
+ }
36372
+ } else {
36373
+ relationshipsXml = await docx.file("word/_rels/document.xml.rels")?.async("string");
36374
+ }
36375
+ }
36376
+ if (relationshipsXml) {
36377
+ try {
36378
+ const relJson = xmljs.xml2js(relationshipsXml, { compact: false });
36379
+ const relationships = relJson.elements?.find((el) => el.name === "Relationships");
36380
+ relationships?.elements?.forEach((rel) => {
36381
+ const type2 = rel.attributes?.Type;
36382
+ const target = rel.attributes?.Target;
36383
+ if (!type2 || !target) return;
36384
+ const isHeader = type2.includes("/header");
36385
+ const isFooter = type2.includes("/footer");
36386
+ if (!isHeader && !isFooter) return;
36387
+ let sanitizedTarget = target.replace(/^\.\//, "");
36388
+ if (sanitizedTarget.startsWith("../")) sanitizedTarget = sanitizedTarget.slice(3);
36389
+ if (sanitizedTarget.startsWith("/")) sanitizedTarget = sanitizedTarget.slice(1);
36390
+ const partName = sanitizedTarget.startsWith("word/") ? sanitizedTarget : `word/${sanitizedTarget}`;
36391
+ partNames.add(partName);
36392
+ });
36393
+ } catch (error) {
36394
+ console.warn("Failed to parse document relationships while updating content types", error);
36395
+ }
36396
+ }
36397
+ partNames.forEach((name) => {
36398
+ if (name.includes(".rels")) return;
36399
+ if (!name.includes("header") && !name.includes("footer")) return;
36400
+ if (updatedContentTypesXml.includes(`PartName="/${name}"`)) return;
36401
+ const type2 = name.includes("header") ? "header" : "footer";
36402
+ const extendedDef = `<Override PartName="/${name}" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.${type2}+xml"/>`;
36403
+ updatedContentTypesXml = updatedContentTypesXml.replace("</Types>", `${extendedDef}</Types>`);
36404
+ });
36332
36405
  if (fromJson) return updatedContentTypesXml;
36333
36406
  docx.file(contentTypesPath, updatedContentTypesXml);
36334
36407
  }
@@ -36369,7 +36442,7 @@ class DocxZipper {
36369
36442
  for (const [fontName, fontUintArray] of Object.entries(fonts)) {
36370
36443
  zip.file(fontName, fontUintArray);
36371
36444
  }
36372
- await this.updateContentTypes(zip, media);
36445
+ await this.updateContentTypes(zip, media, false, updatedDocs);
36373
36446
  return zip;
36374
36447
  }
36375
36448
  /**
@@ -36395,7 +36468,7 @@ class DocxZipper {
36395
36468
  Object.keys(media).forEach((path) => {
36396
36469
  unzippedOriginalDocx.file(path, media[path]);
36397
36470
  });
36398
- await this.updateContentTypes(unzippedOriginalDocx, media);
36471
+ await this.updateContentTypes(unzippedOriginalDocx, media, false, updatedDocs);
36399
36472
  return unzippedOriginalDocx;
36400
36473
  }
36401
36474
  }
@@ -51157,7 +51230,8 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
51157
51230
  files: this.options.content
51158
51231
  },
51159
51232
  media,
51160
- true
51233
+ true,
51234
+ updatedDocs
51161
51235
  );
51162
51236
  return updatedDocs;
51163
51237
  }
@@ -53716,6 +53790,16 @@ const shouldAllowNativeContextMenu = (event) => {
53716
53790
  return prefersNativeMenu(event);
53717
53791
  };
53718
53792
  const shouldBypassContextMenu = shouldAllowNativeContextMenu;
53793
+ const DEFAULT_SELECTION_STATE = Object.freeze({
53794
+ focused: false,
53795
+ preservedSelection: null,
53796
+ showVisualSelection: false,
53797
+ skipFocusReset: false
53798
+ });
53799
+ const normalizeSelectionState = (state2 = {}) => ({
53800
+ ...DEFAULT_SELECTION_STATE,
53801
+ ...state2
53802
+ });
53719
53803
  const CustomSelectionPluginKey = new PluginKey("CustomSelection");
53720
53804
  const handleClickOutside = (event, editor) => {
53721
53805
  const editorElem = editor?.options?.element;
@@ -53753,11 +53837,7 @@ const CustomSelection = Extension.create({
53753
53837
  const customSelectionPlugin = new Plugin({
53754
53838
  key: CustomSelectionPluginKey,
53755
53839
  state: {
53756
- init: () => ({
53757
- focused: false,
53758
- preservedSelection: null,
53759
- showVisualSelection: false
53760
- }),
53840
+ init: () => ({ ...DEFAULT_SELECTION_STATE }),
53761
53841
  apply: (tr, value) => {
53762
53842
  const meta = getFocusMeta(tr);
53763
53843
  if (meta !== void 0) {
@@ -53788,7 +53868,8 @@ const CustomSelection = Extension.create({
53788
53868
  setFocusMeta(view.state.tr, {
53789
53869
  focused: true,
53790
53870
  preservedSelection: selection,
53791
- showVisualSelection: true
53871
+ showVisualSelection: true,
53872
+ skipFocusReset: true
53792
53873
  })
53793
53874
  );
53794
53875
  }
@@ -53809,7 +53890,8 @@ const CustomSelection = Extension.create({
53809
53890
  setFocusMeta(view.state.tr, {
53810
53891
  focused: true,
53811
53892
  preservedSelection: selection2,
53812
- showVisualSelection: true
53893
+ showVisualSelection: true,
53894
+ skipFocusReset: true
53813
53895
  })
53814
53896
  );
53815
53897
  this.editor.setOptions({
@@ -53832,7 +53914,8 @@ const CustomSelection = Extension.create({
53832
53914
  setFocusMeta(view.state.tr, {
53833
53915
  focused: true,
53834
53916
  preservedSelection: selection,
53835
- showVisualSelection: true
53917
+ showVisualSelection: true,
53918
+ skipFocusReset: false
53836
53919
  })
53837
53920
  );
53838
53921
  this.editor.setOptions({
@@ -53850,7 +53933,8 @@ const CustomSelection = Extension.create({
53850
53933
  setFocusMeta(view.state.tr, {
53851
53934
  focused: true,
53852
53935
  preservedSelection: selection,
53853
- showVisualSelection: true
53936
+ showVisualSelection: true,
53937
+ skipFocusReset: false
53854
53938
  })
53855
53939
  );
53856
53940
  }
@@ -53861,7 +53945,8 @@ const CustomSelection = Extension.create({
53861
53945
  setFocusMeta(view.state.tr, {
53862
53946
  focused: false,
53863
53947
  preservedSelection: null,
53864
- showVisualSelection: false
53948
+ showVisualSelection: false,
53949
+ skipFocusReset: false
53865
53950
  })
53866
53951
  );
53867
53952
  if (!selection.empty && !this.editor.options.element?.contains(target)) {
@@ -53878,12 +53963,20 @@ const CustomSelection = Extension.create({
53878
53963
  const isElement2 = target instanceof Element;
53879
53964
  const isToolbarBtn = isElement2 && isToolbarButton(target);
53880
53965
  const isToolbarInp = isElement2 && isToolbarInput(target);
53966
+ const focusState = getFocusState(view.state);
53967
+ if (focusState?.skipFocusReset) {
53968
+ view.dispatch(
53969
+ setFocusMeta(view.state.tr, normalizeSelectionState({ ...focusState, skipFocusReset: false }))
53970
+ );
53971
+ return false;
53972
+ }
53881
53973
  if (!isToolbarBtn && !isToolbarInp) {
53882
53974
  view.dispatch(
53883
53975
  setFocusMeta(view.state.tr, {
53884
53976
  focused: false,
53885
53977
  preservedSelection: null,
53886
- showVisualSelection: false
53978
+ showVisualSelection: false,
53979
+ skipFocusReset: false
53887
53980
  })
53888
53981
  );
53889
53982
  }
@@ -53894,12 +53987,16 @@ const CustomSelection = Extension.create({
53894
53987
  const isToolbarBtn = isElement2 && isToolbarButton(target);
53895
53988
  const isToolbarInp = isElement2 && isToolbarInput(target);
53896
53989
  const state2 = getFocusState(view.state);
53990
+ if (state2?.skipFocusReset) {
53991
+ return false;
53992
+ }
53897
53993
  if (isToolbarBtn || isToolbarInp) {
53898
53994
  view.dispatch(
53899
53995
  setFocusMeta(view.state.tr, {
53900
53996
  focused: true,
53901
53997
  preservedSelection: state2.preservedSelection || view.state.selection,
53902
- showVisualSelection: true
53998
+ showVisualSelection: true,
53999
+ skipFocusReset: false
53903
54000
  })
53904
54001
  );
53905
54002
  } else {
@@ -53907,7 +54004,8 @@ const CustomSelection = Extension.create({
53907
54004
  setFocusMeta(view.state.tr, {
53908
54005
  focused: false,
53909
54006
  preservedSelection: null,
53910
- showVisualSelection: false
54007
+ showVisualSelection: false,
54008
+ skipFocusReset: false
53911
54009
  })
53912
54010
  );
53913
54011
  }