@harbour-enterprises/superdoc 0.23.0-next.26 → 0.23.0-next.27

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.
@@ -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-ZWZLQtoU.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-CZ9iIRr8.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-DScOqhcx.es.js";
3
3
  function self(vars) {
4
4
  const {
5
5
  opacityDisabled,
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const vue = require("./vue-DKMj1I9B.cjs");
4
- const superdoc = require("./index-A1XH4hzI.cjs");
4
+ const superdoc = require("./index-BjwQD_um.cjs");
5
5
  function self(vars) {
6
6
  const {
7
7
  opacityDisabled,
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const superEditor_es = require("./super-editor.es-DhxK40cW.cjs");
2
+ const superEditor_es = require("./super-editor.es-DpCRbxmi.cjs");
3
3
  const vue = require("./vue-DKMj1I9B.cjs");
4
4
  const blankDocx = require("./blank-docx-CPqX9RF5.cjs");
5
5
  const eventemitter3 = require("./eventemitter3-DkXkH2rT.cjs");
@@ -17116,7 +17116,7 @@ const _sfc_main = {
17116
17116
  __name: "SuperDoc",
17117
17117
  emits: ["selection-update"],
17118
17118
  setup(__props, { emit: __emit }) {
17119
- const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-Ba9s5reX.cjs")));
17119
+ const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-DJ7UGyBT.cjs")));
17120
17120
  const superdocStore = useSuperdocStore();
17121
17121
  const commentsStore = useCommentsStore();
17122
17122
  const {
@@ -1,4 +1,4 @@
1
- import { q as index, 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-CcuilWh0.es.js";
1
+ import { q as index, 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-D0-dqxm2.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-ZWZLQtoU.es.js";
3
3
  import { B as BlankDOCX } from "./blank-docx-iwdyG9RH.es.js";
4
4
  import { E as EventEmitter } from "./eventemitter3-BWEnUdTY.es.js";
@@ -17099,7 +17099,7 @@ const _sfc_main = {
17099
17099
  __name: "SuperDoc",
17100
17100
  emits: ["selection-update"],
17101
17101
  setup(__props, { emit: __emit }) {
17102
- const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-D_3AuXzb.es.js"));
17102
+ const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-C8baB1bn.es.js"));
17103
17103
  const superdocStore = useSuperdocStore();
17104
17104
  const commentsStore = useCommentsStore();
17105
17105
  const {
@@ -71972,7 +71972,7 @@ const fileHalfDashedIconSvg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="
71972
71972
  const commentIconSvg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M512 240c0 114.9-114.6 208-256 208c-37.1 0-72.3-6.4-104.1-17.9c-11.9 8.7-31.3 20.6-54.3 30.6C73.6 471.1 44.7 480 16 480c-6.5 0-12.3-3.9-14.8-9.9c-2.5-6-1.1-12.8 3.4-17.4c0 0 0 0 0 0s0 0 0 0s0 0 0 0c0 0 0 0 0 0l.3-.3c.3-.3 .7-.7 1.3-1.4c1.1-1.2 2.8-3.1 4.9-5.7c4.1-5 9.6-12.4 15.2-21.6c10-16.6 19.5-38.4 21.4-62.9C17.7 326.8 0 285.1 0 240C0 125.1 114.6 32 256 32s256 93.1 256 208z"/></svg>';
71973
71973
  const circleIconSvg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512z"/></svg>';
71974
71974
  const checkIconSvg$1 = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"/></svg>';
71975
- const xmarkIconSvg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"/></svg>';
71975
+ const xMarkIconSvg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"/></svg>';
71976
71976
  const upRightFromSquareIconSvg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M352 0c-12.9 0-24.6 7.8-29.6 19.8s-2.2 25.7 6.9 34.9L370.7 96 201.4 265.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L416 141.3l41.4 41.4c9.2 9.2 22.9 11.9 34.9 6.9s19.8-16.6 19.8-29.6l0-128c0-17.7-14.3-32-32-32L352 0zM80 32C35.8 32 0 67.8 0 112L0 432c0 44.2 35.8 80 80 80l320 0c44.2 0 80-35.8 80-80l0-112c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 112c0 8.8-7.2 16-16 16L80 448c-8.8 0-16-7.2-16-16l0-320c0-8.8 7.2-16 16-16l112 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L80 32z"/></svg>';
71977
71977
  const ellipsisVerticalIconSvg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M64 360a56 56 0 1 0 0 112 56 56 0 1 0 0-112zm0-160a56 56 0 1 0 0 112 56 56 0 1 0 0-112zM120 96A56 56 0 1 0 8 96a56 56 0 1 0 112 0z"/></svg>';
71978
71978
  const caretUpIconSvg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M182.6 137.4c-12.5-12.5-32.8-12.5-45.3 0l-128 128c-9.2 9.2-11.9 22.9-6.9 34.9s16.6 19.8 29.6 19.8l256 0c12.9 0 24.6-7.8 29.6-19.8s2.2-25.7-6.9-34.9l-128-128z"/></svg>';
@@ -72027,7 +72027,7 @@ const toolbarIcons = {
72027
72027
  colorOption: circleIconSvg,
72028
72028
  colorOptionCheck: checkIconSvg$1,
72029
72029
  linkInput: linkIconSvg,
72030
- removeLink: xmarkIconSvg,
72030
+ removeLink: xMarkIconSvg,
72031
72031
  openLink: upRightFromSquareIconSvg,
72032
72032
  overflow: ellipsisVerticalIconSvg,
72033
72033
  dropdownCaretUp: caretUpIconSvg,
@@ -85866,7 +85866,9 @@ const ICONS = {
85866
85866
  copy: copyIconSvg,
85867
85867
  paste: pasteIconSvg,
85868
85868
  addDocumentSection: plusIconSvg,
85869
- removeDocumentSection: trashIconSvg
85869
+ removeDocumentSection: trashIconSvg,
85870
+ trackChangesAccept: checkIconSvg$1,
85871
+ trackChangesReject: xMarkIconSvg
85870
85872
  };
85871
85873
  const TEXTS = {
85872
85874
  addRowBefore: "Insert row above",
@@ -85889,7 +85891,9 @@ const TEXTS = {
85889
85891
  copy: "Copy",
85890
85892
  paste: "Paste",
85891
85893
  removeDocumentSection: "Remove section",
85892
- createDocumentSection: "Create section"
85894
+ createDocumentSection: "Create section",
85895
+ trackChangesAccept: "Accept change",
85896
+ trackChangesReject: "Reject change"
85893
85897
  };
85894
85898
  const tableActionsOptions = [
85895
85899
  {
@@ -86093,34 +86097,37 @@ async function getEditorContext(editor, event) {
86093
86097
  const isInSectionNode = structureFromResolvedPos?.isInSectionNode ?? selectionHasNodeOrMark(state2, "documentSection", { requireEnds: true });
86094
86098
  const currentNodeType = node?.type?.name || null;
86095
86099
  const activeMarks = [];
86100
+ let trackedChangeId = null;
86096
86101
  if (event && pos !== null) {
86097
86102
  const $pos = state2.doc.resolve(pos);
86098
- if ($pos.marks && typeof $pos.marks === "function") {
86099
- $pos.marks().forEach((mark) => activeMarks.push(mark.type.name));
86103
+ const processMark = (mark) => {
86104
+ if (!activeMarks.includes(mark.type.name)) {
86105
+ activeMarks.push(mark.type.name);
86106
+ }
86107
+ if (!trackedChangeId && (mark.type.name === "trackInsert" || mark.type.name === "trackDelete" || mark.type.name === "trackFormat")) {
86108
+ trackedChangeId = mark.attrs.id;
86109
+ }
86110
+ };
86111
+ for (let depth = 0; depth <= $pos.depth; depth++) {
86112
+ const nodeAtDepth = $pos.node(depth);
86113
+ if (nodeAtDepth && nodeAtDepth.marks) {
86114
+ nodeAtDepth.marks.forEach(processMark);
86115
+ }
86100
86116
  }
86101
- if (node && node.marks) {
86102
- node.marks.forEach((mark) => activeMarks.push(mark.type.name));
86117
+ if (state2.storedMarks) {
86118
+ state2.storedMarks.forEach(processMark);
86103
86119
  }
86104
86120
  } else {
86105
86121
  state2.storedMarks?.forEach((mark) => activeMarks.push(mark.type.name));
86106
86122
  state2.selection.$head.marks().forEach((mark) => activeMarks.push(mark.type.name));
86107
86123
  }
86108
- const isTrackedChange = activeMarks.includes("trackInsert") || activeMarks.includes("trackDelete");
86109
- let trackedChangeId = null;
86110
- if (isTrackedChange && event && pos !== null) {
86111
- const $pos = state2.doc.resolve(pos);
86112
- const marksAtPos = $pos.marks();
86113
- const trackedMark = marksAtPos.find((mark) => mark.type.name === "trackInsert" || mark.type.name === "trackDelete");
86114
- if (trackedMark) {
86115
- trackedChangeId = trackedMark.attrs.id;
86116
- }
86117
- }
86124
+ const isTrackedChange = activeMarks.includes("trackInsert") || activeMarks.includes("trackDelete") || activeMarks.includes("trackFormat");
86118
86125
  const cursorCoords = pos ? view.coordsAtPos(pos) : null;
86119
86126
  const cursorPosition = cursorCoords ? {
86120
86127
  x: cursorCoords.left,
86121
86128
  y: cursorCoords.top
86122
86129
  } : null;
86123
- return {
86130
+ const context = {
86124
86131
  // Selection info
86125
86132
  selectedText,
86126
86133
  hasSelection: !empty2,
@@ -86146,9 +86153,11 @@ async function getEditorContext(editor, event) {
86146
86153
  pos,
86147
86154
  node,
86148
86155
  event,
86156
+ trigger: event ? "click" : "slash",
86149
86157
  // Editor reference for advanced use cases
86150
86158
  editor
86151
86159
  };
86160
+ return context;
86152
86161
  }
86153
86162
  function computeCanUndo(editor, state2) {
86154
86163
  if (typeof editor?.can === "function") {
@@ -86229,160 +86238,209 @@ const isModuleEnabled = (editorOptions, moduleName) => {
86229
86238
  switch (moduleName) {
86230
86239
  case "ai":
86231
86240
  return !!editorOptions?.isAiEnabled;
86232
- // Example for future use cases
86233
- // case 'comments':
86234
- // return !!editorOptions?.isCommentsEnabled;
86235
86241
  default:
86236
86242
  return true;
86237
86243
  }
86238
86244
  };
86239
- function applyCustomMenuConfiguration(defaultSections, context) {
86240
- const { editor } = context;
86241
- const slashMenuConfig = editor.options?.slashMenuConfig;
86242
- if (!slashMenuConfig) {
86243
- return defaultSections;
86244
- }
86245
- let sections = [];
86246
- if (slashMenuConfig.includeDefaultItems !== false) {
86247
- sections = [...defaultSections];
86248
- }
86249
- if (slashMenuConfig.customItems && Array.isArray(slashMenuConfig.customItems)) {
86250
- sections = [...sections, ...slashMenuConfig.customItems];
86251
- }
86252
- if (typeof slashMenuConfig.menuProvider === "function") {
86245
+ const shouldShowItem = (item, context) => {
86246
+ if (typeof item.showWhen === "function") {
86253
86247
  try {
86254
- sections = slashMenuConfig.menuProvider(context, sections) || sections;
86248
+ return item.showWhen(context);
86255
86249
  } catch (error) {
86256
- console.warn("[SlashMenu] Error in custom menuProvider:", error);
86250
+ console.warn("[SlashMenu] showWhen error for item", item.id, ":", error);
86251
+ return false;
86257
86252
  }
86258
86253
  }
86259
- return sections;
86260
- }
86261
- function filterCustomItems(sections, context) {
86262
- return sections.map((section) => {
86263
- const filteredItems = section.items.filter((item) => {
86264
- if (typeof item.showWhen === "function") {
86265
- try {
86266
- return item.showWhen(context);
86267
- } catch (error) {
86268
- console.warn(`[SlashMenu] Error in showWhen for item ${item.id}:`, error);
86269
- return false;
86270
- }
86271
- }
86272
- return true;
86273
- });
86274
- return {
86275
- ...section,
86276
- items: filteredItems
86277
- };
86278
- }).filter((section) => section.items.length > 0);
86279
- }
86280
- function getItems(context) {
86281
- const { editor, selectedText, trigger: trigger2, clipboardContent } = context;
86282
- const clipboardHasContent = Boolean(
86283
- clipboardContent?.hasContent || clipboardContent?.html || clipboardContent?.text || typeof clipboardContent?.size === "number" && clipboardContent.size > 0 || clipboardContent && typeof clipboardContent?.content?.size === "number" && clipboardContent.content.size > 0 || clipboardContent?.raw && typeof clipboardContent.raw.size === "number" && clipboardContent.raw.size > 0 || clipboardContent?.raw && typeof clipboardContent.raw?.content?.size === "number" && clipboardContent.raw.content.size > 0
86284
- );
86285
- const isInTable2 = selectionHasNodeOrMark(editor.view.state, "table", { requireEnds: true });
86286
- const isInSectionNode = selectionHasNodeOrMark(editor.view.state, "documentSection", { requireEnds: true });
86287
- const sections = [
86254
+ };
86255
+ function getItems(context, customItems = [], includeDefaultItems = true) {
86256
+ const { selectedText, editor } = context;
86257
+ if (arguments.length === 1 && editor?.options?.slashMenuConfig) {
86258
+ customItems = editor.options.slashMenuConfig.items || editor.options.slashMenuConfig.customItems || [];
86259
+ includeDefaultItems = editor.options.slashMenuConfig.includeDefaultItems !== false;
86260
+ }
86261
+ const enhancedContext = {
86262
+ ...context,
86263
+ isInTable: context.isInTable ?? false,
86264
+ isInSectionNode: context.isInSectionNode ?? false,
86265
+ isTrackedChange: context.isTrackedChange ?? false,
86266
+ clipboardContent: context.clipboardContent ?? { hasContent: false },
86267
+ selectedText: context.selectedText ?? "",
86268
+ hasSelection: context.hasSelection ?? Boolean(context.selectedText)
86269
+ };
86270
+ const defaultSections = [
86288
86271
  {
86289
86272
  id: "ai-content",
86273
+ isDefault: true,
86290
86274
  items: [
86291
86275
  {
86292
86276
  id: "insert-text",
86293
86277
  label: selectedText ? TEXTS.replaceText : TEXTS.insertText,
86294
86278
  icon: ICONS.ai,
86295
86279
  component: AIWriter,
86280
+ isDefault: true,
86296
86281
  action: (editor2) => {
86297
86282
  if (editor2?.commands && typeof editor2.commands?.insertAiMark === "function") {
86298
86283
  editor2.commands.insertAiMark();
86299
86284
  }
86300
86285
  },
86301
- allowedTriggers: [TRIGGERS.slash, TRIGGERS.click],
86302
- requiresModule: "ai"
86286
+ showWhen: (context2) => {
86287
+ const { trigger: trigger2 } = context2;
86288
+ const allowedTriggers = [TRIGGERS.slash, TRIGGERS.click];
86289
+ return allowedTriggers.includes(trigger2) && isModuleEnabled(context2.editor?.options, "ai");
86290
+ }
86291
+ }
86292
+ ]
86293
+ },
86294
+ {
86295
+ id: "track-changes",
86296
+ isDefault: true,
86297
+ items: [
86298
+ {
86299
+ id: "track-changes-accept",
86300
+ icon: ICONS.trackChangesAccept,
86301
+ label: TEXTS.trackChangesAccept,
86302
+ isDefault: true,
86303
+ action: (editor2, context2) => {
86304
+ if (context2?.trackedChangeId) {
86305
+ editor2.commands.acceptTrackedChangeById(context2.trackedChangeId);
86306
+ } else {
86307
+ editor2.commands.acceptTrackedChangeBySelection();
86308
+ }
86309
+ },
86310
+ showWhen: (context2) => {
86311
+ const { trigger: trigger2, isTrackedChange } = context2;
86312
+ return trigger2 === TRIGGERS.click && isTrackedChange;
86313
+ }
86314
+ },
86315
+ {
86316
+ id: "track-changes-reject",
86317
+ label: TEXTS.trackChangesReject,
86318
+ icon: ICONS.trackChangesReject,
86319
+ isDefault: true,
86320
+ action: (editor2, context2) => {
86321
+ if (context2?.trackedChangeId) {
86322
+ editor2.commands.rejectTrackedChangeById(context2.trackedChangeId);
86323
+ } else {
86324
+ editor2.commands.rejectTrackedChangeOnSelection();
86325
+ }
86326
+ },
86327
+ showWhen: (context2) => {
86328
+ const { trigger: trigger2, isTrackedChange } = context2;
86329
+ return trigger2 === TRIGGERS.click && isTrackedChange;
86330
+ }
86303
86331
  }
86304
86332
  ]
86305
86333
  },
86306
86334
  {
86307
86335
  id: "document-sections",
86336
+ isDefault: true,
86308
86337
  items: [
86309
86338
  {
86310
86339
  id: "insert-document-section",
86311
86340
  label: TEXTS.createDocumentSection,
86312
86341
  icon: ICONS.addDocumentSection,
86342
+ isDefault: true,
86313
86343
  action: (editor2) => {
86314
86344
  editor2.commands.createDocumentSection();
86315
86345
  },
86316
- allowedTriggers: [TRIGGERS.click]
86346
+ showWhen: (context2) => {
86347
+ const { trigger: trigger2 } = context2;
86348
+ return trigger2 === TRIGGERS.click;
86349
+ }
86317
86350
  },
86318
86351
  {
86319
86352
  id: "remove-section",
86320
86353
  label: TEXTS.removeDocumentSection,
86321
86354
  icon: ICONS.removeDocumentSection,
86355
+ isDefault: true,
86322
86356
  action: (editor2) => {
86323
86357
  editor2.commands.removeSectionAtSelection();
86324
86358
  },
86325
- allowedTriggers: [TRIGGERS.click],
86326
- requiresSectionParent: true
86359
+ showWhen: (context2) => {
86360
+ const { trigger: trigger2, isInSectionNode } = context2;
86361
+ return trigger2 === TRIGGERS.click && isInSectionNode;
86362
+ }
86327
86363
  }
86328
86364
  ]
86329
86365
  },
86330
86366
  {
86331
86367
  id: "general",
86368
+ isDefault: true,
86332
86369
  items: [
86333
86370
  {
86334
86371
  id: "insert-link",
86335
86372
  label: TEXTS.insertLink,
86336
86373
  icon: ICONS.link,
86337
86374
  component: LinkInput,
86338
- allowedTriggers: [TRIGGERS.click]
86375
+ isDefault: true,
86376
+ showWhen: (context2) => {
86377
+ const { trigger: trigger2 } = context2;
86378
+ return trigger2 === TRIGGERS.click;
86379
+ }
86339
86380
  },
86340
86381
  {
86341
86382
  id: "insert-table",
86342
86383
  label: TEXTS.insertTable,
86343
86384
  icon: ICONS.table,
86344
86385
  component: TableGrid,
86345
- allowedTriggers: [TRIGGERS.slash, TRIGGERS.click]
86386
+ isDefault: true,
86387
+ showWhen: (context2) => {
86388
+ const { trigger: trigger2, isInTable: isInTable2 } = context2;
86389
+ const allowedTriggers = [TRIGGERS.slash, TRIGGERS.click];
86390
+ return allowedTriggers.includes(trigger2) && !isInTable2;
86391
+ }
86346
86392
  },
86347
86393
  {
86348
86394
  id: "edit-table",
86349
86395
  label: TEXTS.editTable,
86350
86396
  icon: ICONS.table,
86351
86397
  component: TableActions,
86352
- allowedTriggers: [TRIGGERS.slash, TRIGGERS.click],
86353
- requiresTableParent: true
86398
+ isDefault: true,
86399
+ showWhen: (context2) => {
86400
+ const { trigger: trigger2, isInTable: isInTable2 } = context2;
86401
+ const allowedTriggers = [TRIGGERS.slash, TRIGGERS.click];
86402
+ return allowedTriggers.includes(trigger2) && isInTable2;
86403
+ }
86354
86404
  }
86355
86405
  ]
86356
86406
  },
86357
86407
  {
86358
86408
  id: "clipboard",
86409
+ isDefault: true,
86359
86410
  items: [
86360
86411
  {
86361
86412
  id: "cut",
86362
86413
  label: TEXTS.cut,
86363
86414
  icon: ICONS.cut,
86415
+ isDefault: true,
86364
86416
  action: (editor2) => {
86365
86417
  editor2.view.focus();
86366
86418
  document.execCommand("cut");
86367
86419
  },
86368
- allowedTriggers: [TRIGGERS.click],
86369
- requiresSelection: true
86420
+ showWhen: (context2) => {
86421
+ const { trigger: trigger2, selectedText: selectedText2 } = context2;
86422
+ return trigger2 === TRIGGERS.click && selectedText2;
86423
+ }
86370
86424
  },
86371
86425
  {
86372
86426
  id: "copy",
86373
86427
  label: TEXTS.copy,
86374
86428
  icon: ICONS.copy,
86429
+ isDefault: true,
86375
86430
  action: (editor2) => {
86376
86431
  editor2.view.focus();
86377
86432
  document.execCommand("copy");
86378
86433
  },
86379
- allowedTriggers: [TRIGGERS.click],
86380
- requiresSelection: true
86434
+ showWhen: (context2) => {
86435
+ const { trigger: trigger2, selectedText: selectedText2 } = context2;
86436
+ return trigger2 === TRIGGERS.click && selectedText2;
86437
+ }
86381
86438
  },
86382
86439
  {
86383
86440
  id: "paste",
86384
86441
  label: TEXTS.paste,
86385
86442
  icon: ICONS.paste,
86443
+ isDefault: true,
86386
86444
  action: async (editor2) => {
86387
86445
  try {
86388
86446
  const clipboardItems = await navigator.clipboard.read();
@@ -86396,7 +86454,7 @@ function getItems(context) {
86396
86454
  text = await (await item.getType("text/plain")).text();
86397
86455
  }
86398
86456
  }
86399
- const handled = handleClipboardPaste({ editor: editor2, view: editor2.view }, html, text);
86457
+ const handled = handleClipboardPaste({ editor: editor2, view: editor2.view }, html);
86400
86458
  if (!handled) {
86401
86459
  const dataTransfer = new DataTransfer();
86402
86460
  if (html) dataTransfer.setData("text/html", html);
@@ -86412,30 +86470,52 @@ function getItems(context) {
86412
86470
  console.warn("Failed to paste:", error);
86413
86471
  }
86414
86472
  },
86415
- allowedTriggers: [TRIGGERS.click, TRIGGERS.slash],
86416
- requiresClipboard: true
86473
+ showWhen: (context2) => {
86474
+ const { trigger: trigger2, clipboardContent } = context2;
86475
+ const allowedTriggers = [TRIGGERS.click, TRIGGERS.slash];
86476
+ const hasContent = clipboardContent?.hasContent || clipboardContent?.size > 0 || clipboardContent?.content?.size > 0;
86477
+ return allowedTriggers.includes(trigger2) && hasContent;
86478
+ }
86417
86479
  }
86418
86480
  ]
86419
86481
  }
86420
86482
  ];
86421
- let allSections = applyCustomMenuConfiguration(sections, context);
86422
- const filteredSections = allSections.map((section) => {
86423
- const filteredItems = section.items.filter((item) => {
86424
- if (item.requiresModule && !isModuleEnabled(editor?.options, item.requiresModule)) return false;
86425
- if (item.requiresSelection && !selectedText) return false;
86426
- if (!item.allowedTriggers.includes(trigger2)) return false;
86427
- if (item.requiresClipboard && !clipboardHasContent) return false;
86428
- if (item.requiresTableParent && !isInTable2 || item.id === "insert-table" && isInTable2) return false;
86429
- if (item.requiresSectionParent && !isInSectionNode) return false;
86430
- return true;
86483
+ let allSections = [];
86484
+ if (includeDefaultItems) {
86485
+ allSections = [...defaultSections];
86486
+ }
86487
+ if (customItems.length > 0) {
86488
+ customItems.forEach((customSection) => {
86489
+ const existingSectionIndex = allSections.findIndex((section) => section.id === customSection.id);
86490
+ if (existingSectionIndex !== -1) {
86491
+ allSections[existingSectionIndex].items = [
86492
+ ...allSections[existingSectionIndex].items,
86493
+ ...customSection.items.map((item) => ({ ...item, isDefault: false }))
86494
+ ];
86495
+ } else {
86496
+ allSections.push({
86497
+ ...customSection,
86498
+ isDefault: false,
86499
+ items: customSection.items.map((item) => ({ ...item, isDefault: false }))
86500
+ });
86501
+ }
86431
86502
  });
86503
+ }
86504
+ if (editor?.options?.slashMenuConfig?.menuProvider) {
86505
+ try {
86506
+ allSections = editor.options.slashMenuConfig.menuProvider(enhancedContext, allSections) || allSections;
86507
+ } catch (error) {
86508
+ console.warn("[SlashMenu] menuProvider error:", error);
86509
+ }
86510
+ }
86511
+ const filteredSections = allSections.map((section) => {
86512
+ const filteredItems = section.items.filter((item) => shouldShowItem(item, enhancedContext));
86432
86513
  return {
86433
86514
  ...section,
86434
86515
  items: filteredItems
86435
86516
  };
86436
86517
  }).filter((section) => section.items.length > 0);
86437
- const finalSections = filterCustomItems(filteredSections, context);
86438
- return finalSections;
86518
+ return filteredSections;
86439
86519
  }
86440
86520
  const _hoisted_1$3 = { class: "slash-menu-items" };
86441
86521
  const _hoisted_2$1 = {
@@ -86518,13 +86598,28 @@ const _sfc_main$4 = {
86518
86598
  });
86519
86599
  const customItemRefs = /* @__PURE__ */ new Map();
86520
86600
  const setCustomItemRef = (el, item) => {
86521
- if (el && item.render) {
86601
+ if (el) {
86522
86602
  customItemRefs.set(item.id, { element: el, item });
86523
86603
  nextTick(() => {
86524
86604
  renderCustomItem(item.id);
86525
86605
  });
86526
86606
  }
86527
86607
  };
86608
+ const defaultRender = (context) => {
86609
+ const item = context.item || context.currentItem;
86610
+ const container = document.createElement("div");
86611
+ container.className = "slash-menu-default-content";
86612
+ if (item.icon) {
86613
+ const iconSpan = document.createElement("span");
86614
+ iconSpan.className = "slash-menu-item-icon";
86615
+ iconSpan.innerHTML = item.icon;
86616
+ container.appendChild(iconSpan);
86617
+ }
86618
+ const labelSpan = document.createElement("span");
86619
+ labelSpan.textContent = item.label;
86620
+ container.appendChild(labelSpan);
86621
+ return container;
86622
+ };
86528
86623
  const renderCustomItem = async (itemId) => {
86529
86624
  const refData = customItemRefs.get(itemId);
86530
86625
  if (!refData || refData.element.hasCustomContent) return;
@@ -86533,8 +86628,9 @@ const _sfc_main$4 = {
86533
86628
  if (!currentContext.value) {
86534
86629
  currentContext.value = await getEditorContext(props.editor);
86535
86630
  }
86536
- const context = currentContext.value;
86537
- const customElement = item.render(context);
86631
+ const contextWithItem = { ...currentContext.value, currentItem: item };
86632
+ const renderFunction = item.render || defaultRender;
86633
+ const customElement = renderFunction(contextWithItem);
86538
86634
  if (customElement instanceof HTMLElement) {
86539
86635
  element.innerHTML = "";
86540
86636
  element.appendChild(customElement);
@@ -86542,7 +86638,9 @@ const _sfc_main$4 = {
86542
86638
  }
86543
86639
  } catch (error) {
86544
86640
  console.warn(`[SlashMenu] Error rendering custom item ${itemId}:`, error);
86545
- element.innerHTML = `<span>${item.label || "Custom Item"}</span>`;
86641
+ const fallbackElement = defaultRender({ ...currentContext.value || {}, currentItem: item });
86642
+ element.innerHTML = "";
86643
+ element.appendChild(fallbackElement);
86546
86644
  element.hasCustomContent = true;
86547
86645
  }
86548
86646
  };
@@ -86737,19 +86835,20 @@ const _sfc_main$4 = {
86737
86835
  class: normalizeClass(["slash-menu-item", { "is-selected": item.id === selectedId.value }]),
86738
86836
  onClick: ($event) => executeCommand(item)
86739
86837
  }, [
86740
- item.render ? (openBlock(), createElementBlock("div", {
86741
- key: 0,
86838
+ createBaseVNode("div", {
86742
86839
  ref_for: true,
86743
86840
  ref: (el) => setCustomItemRef(el, item),
86744
86841
  class: "slash-menu-custom-item"
86745
- }, null, 512)) : (openBlock(), createElementBlock(Fragment$1, { key: 1 }, [
86746
- item.icon ? (openBlock(), createElementBlock("span", {
86747
- key: 0,
86748
- class: "slash-menu-item-icon",
86749
- innerHTML: item.icon
86750
- }, null, 8, _hoisted_4)) : createCommentVNode("", true),
86751
- createBaseVNode("span", null, toDisplayString(item.label), 1)
86752
- ], 64))
86842
+ }, [
86843
+ !item.render ? (openBlock(), createElementBlock(Fragment$1, { key: 0 }, [
86844
+ item.icon ? (openBlock(), createElementBlock("span", {
86845
+ key: 0,
86846
+ class: "slash-menu-item-icon",
86847
+ innerHTML: item.icon
86848
+ }, null, 8, _hoisted_4)) : createCommentVNode("", true),
86849
+ createBaseVNode("span", null, toDisplayString(item.label), 1)
86850
+ ], 64)) : createCommentVNode("", true)
86851
+ ], 512)
86753
86852
  ], 10, _hoisted_3$1);
86754
86853
  }), 128))
86755
86854
  ], 64);