@sendbird/actionbook-core 0.9.9 → 0.10.1

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/ui/index.js CHANGED
@@ -2020,7 +2020,7 @@ function resourceTagToMarkdown() {
2020
2020
  }
2021
2021
 
2022
2022
  // src/markdown/plugins/jumpPoint.ts
2023
- var JUMP_POINT_RE = /\^([A-Za-z_]+)\^/g;
2023
+ var JUMP_POINT_RE = /\^([\p{L}\p{N}_-]+)\^/gu;
2024
2024
  function splitTextWithJumpPoints(text2) {
2025
2025
  const results = [];
2026
2026
  let lastIndex = 0;
@@ -2649,6 +2649,18 @@ function useEditorView(config) {
2649
2649
  viewInstanceRef.current = null;
2650
2650
  };
2651
2651
  }, []);
2652
+ const prevEditableRef = useRef(config.editable);
2653
+ useEffect(() => {
2654
+ if (prevEditableRef.current !== config.editable) {
2655
+ prevEditableRef.current = config.editable;
2656
+ const view = viewInstanceRef.current;
2657
+ if (view) {
2658
+ const tr = view.state.tr;
2659
+ tr.setMeta("editableChanged", true);
2660
+ view.dispatch(tr);
2661
+ }
2662
+ }
2663
+ }, [config.editable]);
2652
2664
  const viewRef = useCallback((container) => {
2653
2665
  if (container === containerRef.current) return;
2654
2666
  if (viewInstanceRef.current) {
@@ -2665,7 +2677,7 @@ function useEditorView(config) {
2665
2677
  const view = new EditorView(container, {
2666
2678
  state,
2667
2679
  nodeViews,
2668
- editable: () => configRef.current.editable !== false,
2680
+ editable: () => configRef.current.editable === true,
2669
2681
  dispatchTransaction(tr) {
2670
2682
  const newState = view.state.apply(tr);
2671
2683
  view.updateState(newState);
@@ -2721,13 +2733,87 @@ function useEditorView(config) {
2721
2733
  // src/ui/plugin/inputRulesPlugin.ts
2722
2734
  import { InputRule, textblockTypeInputRule, wrappingInputRule } from "prosemirror-inputrules";
2723
2735
  import { TextSelection } from "prosemirror-state";
2736
+
2737
+ // src/ui/plugin/slashCommandPlugin.ts
2738
+ import { Plugin, PluginKey } from "prosemirror-state";
2739
+ var slashCommandKey = new PluginKey("slashCommand");
2740
+ var TRIGGER_RE = /(?:^|\s)(\/[^\s]*)$/;
2741
+ function deriveState(state, dismissedFrom) {
2742
+ const inactive = { active: false, range: null, query: "", parentType: "" };
2743
+ const { selection } = state;
2744
+ if (!selection.empty) return inactive;
2745
+ const { $from } = selection;
2746
+ const parentType = $from.parent.type.name;
2747
+ for (let d = $from.depth; d > 0; d--) {
2748
+ if ($from.node(d).type.name === "noteBlock") return inactive;
2749
+ }
2750
+ const textBefore = $from.parent.textBetween(0, $from.parentOffset, "\n", "\0");
2751
+ const match = TRIGGER_RE.exec(textBefore);
2752
+ if (!match) return inactive;
2753
+ const slashText = match[1];
2754
+ const slashStartInParent = textBefore.lastIndexOf(slashText);
2755
+ const from = $from.start() + slashStartInParent;
2756
+ const to = $from.pos;
2757
+ if (dismissedFrom === from) return inactive;
2758
+ return {
2759
+ active: true,
2760
+ range: { from, to },
2761
+ query: slashText.slice(1),
2762
+ parentType
2763
+ };
2764
+ }
2765
+ function createSlashCommandPlugin() {
2766
+ const plugin = new Plugin({
2767
+ key: slashCommandKey,
2768
+ state: {
2769
+ init(_, state) {
2770
+ const derived = deriveState(state, null);
2771
+ return { ...derived, _dismissedFrom: null };
2772
+ },
2773
+ apply(tr, prev, _old, newState) {
2774
+ const meta = tr.getMeta(slashCommandKey);
2775
+ let dismissedFrom = prev._dismissedFrom;
2776
+ if (meta?.dismiss !== void 0) {
2777
+ dismissedFrom = meta.dismiss;
2778
+ } else if (dismissedFrom !== null) {
2779
+ const derived2 = deriveState(newState, null);
2780
+ if (derived2.active && derived2.range && derived2.range.from !== dismissedFrom) {
2781
+ dismissedFrom = null;
2782
+ }
2783
+ }
2784
+ const derived = deriveState(newState, dismissedFrom);
2785
+ return { ...derived, _dismissedFrom: dismissedFrom };
2786
+ }
2787
+ }
2788
+ // Expose only the public fields via the key
2789
+ // (InternalState is a superset of SlashCommandState so reads work fine)
2790
+ });
2791
+ return {
2792
+ name: "slashCommand",
2793
+ plugins: () => [plugin],
2794
+ keymap: () => ({
2795
+ Escape: (state, dispatch) => {
2796
+ const s = slashCommandKey.getState(state);
2797
+ if (!s?.active || !s.range) return false;
2798
+ if (dispatch) {
2799
+ const tr = state.tr;
2800
+ tr.setMeta(slashCommandKey, { dismiss: s.range.from });
2801
+ dispatch(tr);
2802
+ }
2803
+ return true;
2804
+ }
2805
+ })
2806
+ };
2807
+ }
2808
+
2809
+ // src/ui/plugin/inputRulesPlugin.ts
2724
2810
  var HEADING_RE = /^(#{1,6})\s$/;
2725
2811
  var BLOCKQUOTE_RE = /^\s*>\s$/;
2726
2812
  var CODE_BLOCK_RE = /^```([a-zA-Z0-9]*)$/;
2727
2813
  var HR_RE = /^([-*_])\1{2,}$/;
2728
2814
  var BULLET_LIST_RE = /^\s*([-*])\s$/;
2729
2815
  var ORDERED_LIST_RE = /^(\d+)\.\s$/;
2730
- var JUMP_POINT_RE2 = /\^([A-Za-z_]+)\^$/;
2816
+ var JUMP_POINT_RE2 = /\^([\p{L}\p{N}_-]+)\^$/u;
2731
2817
  var BOLD_STAR_RE = /(?:^|[^*])\*\*([^*]+)\*\*$/;
2732
2818
  var BOLD_UNDER_RE = /(?:^|[^_])__([^_]+)__$/;
2733
2819
  var ITALIC_STAR_RE = /(?:^|[^*])\*([^*]+)\*$/;
@@ -2794,6 +2880,8 @@ function handleListInputRule(state, start, end, listType, attrs) {
2794
2880
  }
2795
2881
  function markInputRule(pattern, markType, markerLen) {
2796
2882
  return new InputRule(pattern, (state, match, start, end) => {
2883
+ const slashState = slashCommandKey.getState(state);
2884
+ if (slashState?.active) return null;
2797
2885
  const textContent2 = match[1];
2798
2886
  const fullMatch = match[0];
2799
2887
  const markedLength = markerLen * 2 + textContent2.length;
@@ -3286,9 +3374,20 @@ var enterCommand = chainCommands(
3286
3374
  );
3287
3375
  var shiftEnterCommand = (state, dispatch) => {
3288
3376
  if (dispatch) {
3289
- dispatch(
3290
- state.tr.replaceSelectionWith(hardBreak.create()).scrollIntoView()
3291
- );
3377
+ const { from, to, $from } = state.selection;
3378
+ const tr = state.tr;
3379
+ if (from !== to) tr.delete(from, to);
3380
+ const insertPos = tr.mapping.map(from);
3381
+ const marks = $from.marks();
3382
+ tr.insert(insertPos, hardBreak.create());
3383
+ const afterBr = insertPos + 1;
3384
+ tr.insertText("\u200B", afterBr);
3385
+ const cursorPos = afterBr + 1;
3386
+ if (cursorPos <= tr.doc.content.size) {
3387
+ tr.setSelection(TextSelection2.create(tr.doc, cursorPos));
3388
+ }
3389
+ if (marks.length > 0) tr.setStoredMarks(marks);
3390
+ dispatch(tr.scrollIntoView());
3292
3391
  }
3293
3392
  return true;
3294
3393
  };
@@ -3315,7 +3414,7 @@ function createKeymapPlugin() {
3315
3414
 
3316
3415
  // src/ui/plugin/markdownClipboard.ts
3317
3416
  import { DOMParser as ProseMirrorDOMParser, Fragment, Slice } from "prosemirror-model";
3318
- import { Plugin, PluginKey } from "prosemirror-state";
3417
+ import { Plugin as Plugin2, PluginKey as PluginKey2 } from "prosemirror-state";
3319
3418
 
3320
3419
  // src/ast/traverse.ts
3321
3420
  var MAX_DEPTH3 = 128;
@@ -5198,7 +5297,7 @@ function buildDocumentTree(doc2) {
5198
5297
  }
5199
5298
 
5200
5299
  // src/ui/plugin/markdownClipboard.ts
5201
- var key = new PluginKey("markdownClipboard");
5300
+ var key = new PluginKey2("markdownClipboard");
5202
5301
  var MAX_PASTE_LIST_DEPTH = 3;
5203
5302
  var MAX_FLATTEN_DEPTH = 128;
5204
5303
  function flattenDeepLists(node, listDepth = 0, _recurseDepth = 0) {
@@ -5261,7 +5360,7 @@ function textToSlice(text2, view) {
5261
5360
  view.state.doc.descendants((node) => {
5262
5361
  if (node.type.name === "jumpPoint") existingIds.add(node.attrs.id);
5263
5362
  });
5264
- const deduped = text2.replace(/\^([A-Za-z_][A-Za-z0-9_]*)\^/gm, (match, id) => {
5363
+ const deduped = text2.replace(/\^([\p{L}\p{N}_-]+)\^/gmu, (match, id) => {
5265
5364
  if (existingIds.has(id)) return id;
5266
5365
  existingIds.add(id);
5267
5366
  return match;
@@ -5278,7 +5377,7 @@ function textToSlice(text2, view) {
5278
5377
  }
5279
5378
  var URL_RE = /^https?:\/\/[^\s]+$/i;
5280
5379
  function createPlugin() {
5281
- return new Plugin({
5380
+ return new Plugin2({
5282
5381
  key,
5283
5382
  props: {
5284
5383
  handlePaste(view, event) {
@@ -5344,9 +5443,9 @@ function createMarkdownClipboardPlugin() {
5344
5443
  }
5345
5444
 
5346
5445
  // src/ui/plugin/jumpPointPlugin.ts
5347
- import { Plugin as Plugin2, PluginKey as PluginKey2, TextSelection as TextSelection3 } from "prosemirror-state";
5446
+ import { Plugin as Plugin3, PluginKey as PluginKey3, TextSelection as TextSelection3 } from "prosemirror-state";
5348
5447
  import { Decoration, DecorationSet } from "prosemirror-view";
5349
- var adjacentKey = new PluginKey2("jumpPointAdjacent");
5448
+ var adjacentKey = new PluginKey3("jumpPointAdjacent");
5350
5449
  var JUMP_POINT_ADJACENT_SPEC = { jumpPointAdjacent: true };
5351
5450
  function buildDecorations(state) {
5352
5451
  const { selection } = state;
@@ -5362,10 +5461,10 @@ function buildDecorations(state) {
5362
5461
  });
5363
5462
  return DecorationSet.create(state.doc, decorations);
5364
5463
  }
5365
- var jumpPointEditKey = new PluginKey2("jumpPointEdit");
5366
- var JUMP_POINT_FULL_RE = /^\^([A-Za-z_][A-Za-z0-9_]*)\^$/;
5464
+ var jumpPointEditKey = new PluginKey3("jumpPointEdit");
5465
+ var JUMP_POINT_FULL_RE = /^\^([\p{L}\p{N}_-]+)\^$/u;
5367
5466
  function createJumpPointEditPlugin() {
5368
- return new Plugin2({
5467
+ return new Plugin3({
5369
5468
  key: jumpPointEditKey,
5370
5469
  state: {
5371
5470
  init: () => ({ rawRange: null }),
@@ -5467,7 +5566,7 @@ function createJumpPointAdjacentPlugin() {
5467
5566
  }),
5468
5567
  plugins: () => [
5469
5568
  createJumpPointEditPlugin(),
5470
- new Plugin2({
5569
+ new Plugin3({
5471
5570
  key: adjacentKey,
5472
5571
  state: {
5473
5572
  init(_, state) {
@@ -5633,9 +5732,9 @@ function createJumpPointNodeViewPlugin() {
5633
5732
  }
5634
5733
 
5635
5734
  // src/ui/plugin/jumpPointValidationPlugin.ts
5636
- import { Plugin as Plugin3, PluginKey as PluginKey3 } from "prosemirror-state";
5735
+ import { Plugin as Plugin4, PluginKey as PluginKey4 } from "prosemirror-state";
5637
5736
  import { Decoration as Decoration2, DecorationSet as DecorationSet2 } from "prosemirror-view";
5638
- var pluginKey = new PluginKey3("jumpPointValidation");
5737
+ var pluginKey = new PluginKey4("jumpPointValidation");
5639
5738
  function collectJumpPointIds(state) {
5640
5739
  const ids = /* @__PURE__ */ new Set();
5641
5740
  state.doc.descendants((node) => {
@@ -5685,7 +5784,7 @@ function createJumpPointValidationPlugin() {
5685
5784
  return {
5686
5785
  name: "jumpPointValidation",
5687
5786
  plugins: () => [
5688
- new Plugin3({
5787
+ new Plugin4({
5689
5788
  key: pluginKey,
5690
5789
  state: {
5691
5790
  init(_, state) {
@@ -5801,9 +5900,9 @@ function createInlineToolTagNodeViewPlugin() {
5801
5900
  }
5802
5901
 
5803
5902
  // src/ui/plugin/jinjaDecoration.ts
5804
- import { Plugin as Plugin4, PluginKey as PluginKey4 } from "prosemirror-state";
5903
+ import { Plugin as Plugin5, PluginKey as PluginKey5 } from "prosemirror-state";
5805
5904
  import { Decoration as Decoration3, DecorationSet as DecorationSet3 } from "prosemirror-view";
5806
- var jinjaPluginKey = new PluginKey4("jinjaDecoration");
5905
+ var jinjaPluginKey = new PluginKey5("jinjaDecoration");
5807
5906
  var JINJA_TAG_RE = /\{%\s*(if|elif|else|endif)\s*([^%]*?)\s*%\}/g;
5808
5907
  function getBlockPositions(doc2) {
5809
5908
  const blocks = [];
@@ -5894,7 +5993,7 @@ function createJinjaDecorationPlugin() {
5894
5993
  return {
5895
5994
  name: "jinjaDecoration",
5896
5995
  plugins: () => [
5897
- new Plugin4({
5996
+ new Plugin5({
5898
5997
  key: jinjaPluginKey,
5899
5998
  state: {
5900
5999
  init(_, state) {
@@ -5918,7 +6017,7 @@ function createJinjaDecorationPlugin() {
5918
6017
  // src/ui/plugin/jinjaIfBlockPlugin.tsx
5919
6018
  import { useEffect as useEffect2, useRef as useRef2, useState as useState3 } from "react";
5920
6019
  import { createRoot as createRoot2 } from "react-dom/client";
5921
- import { TextSelection as TextSelection4 } from "prosemirror-state";
6020
+ import { Plugin as Plugin6, TextSelection as TextSelection4 } from "prosemirror-state";
5922
6021
  import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
5923
6022
  var PLACEHOLDER_TEXT = "Describe what AI agent should do when this condition is met";
5924
6023
  var CONDITION_PLACEHOLDER = "Write a condition in natural language";
@@ -6711,10 +6810,13 @@ var JinjaIfBranchView = class {
6711
6810
  this.root = createRoot2(this.headerContainer);
6712
6811
  this._onSiblingsChanged = () => this.render();
6713
6812
  this.dom.addEventListener("jinja-siblings-changed", this._onSiblingsChanged);
6813
+ this._onEditableChanged = () => this.render();
6814
+ this.dom.addEventListener("jinja-editable-changed", this._onEditableChanged);
6714
6815
  this.syncDOM();
6715
6816
  this.render();
6716
6817
  }
6717
6818
  _onSiblingsChanged = null;
6819
+ _onEditableChanged = null;
6718
6820
  syncDOM() {
6719
6821
  const branchType = this.node.attrs.branchType;
6720
6822
  this.dom.className = `jinja-branch jinja-branch-${branchType}`;
@@ -6751,7 +6853,7 @@ var JinjaIfBranchView = class {
6751
6853
  {
6752
6854
  branchType,
6753
6855
  condition,
6754
- editable: this.view.editable,
6856
+ editable: this.view.editable && this.view.dom.getAttribute("contenteditable") !== "false",
6755
6857
  isLastBranch: showAddButton,
6756
6858
  hasElseBranch: context && nodePos != null ? getElseBranch(this.view, nodePos) : false,
6757
6859
  onConditionChange: (value) => {
@@ -6800,13 +6902,37 @@ var JinjaIfBranchView = class {
6800
6902
  if (this._onSiblingsChanged) {
6801
6903
  this.dom.removeEventListener("jinja-siblings-changed", this._onSiblingsChanged);
6802
6904
  }
6905
+ if (this._onEditableChanged) {
6906
+ this.dom.removeEventListener("jinja-editable-changed", this._onEditableChanged);
6907
+ }
6803
6908
  StyleManager.release();
6804
6909
  setTimeout(() => this.root.unmount(), 0);
6805
6910
  }
6806
6911
  };
6912
+ function createEditableWatcherPlugin() {
6913
+ let lastEditable = null;
6914
+ return new Plugin6({
6915
+ view(editorView) {
6916
+ lastEditable = editorView.editable;
6917
+ return {
6918
+ update(view) {
6919
+ const currentEditable = view.editable;
6920
+ if (lastEditable !== null && lastEditable !== currentEditable) {
6921
+ const event = new Event("jinja-editable-changed", { bubbles: true });
6922
+ view.dom.querySelectorAll("[data-jinja-branch]").forEach((el) => {
6923
+ el.dispatchEvent(event);
6924
+ });
6925
+ }
6926
+ lastEditable = currentEditable;
6927
+ }
6928
+ };
6929
+ }
6930
+ });
6931
+ }
6807
6932
  function createJinjaIfBlockPlugin() {
6808
6933
  return {
6809
6934
  name: "jinjaIfBlock",
6935
+ plugins: () => [createEditableWatcherPlugin()],
6810
6936
  nodeViews: () => ({
6811
6937
  jinjaIfBlock: (() => new JinjaIfBlockView()),
6812
6938
  jinjaIfBranch: ((node, view, getPos) => new JinjaIfBranchView(node, view, getPos))
@@ -6816,10 +6942,10 @@ function createJinjaIfBlockPlugin() {
6816
6942
 
6817
6943
  // src/ui/plugin/linkPlugin.ts
6818
6944
  import { InputRule as InputRule2, inputRules as inputRules2 } from "prosemirror-inputrules";
6819
- import { Plugin as Plugin5, PluginKey as PluginKey5, TextSelection as TextSelection5 } from "prosemirror-state";
6945
+ import { Plugin as Plugin7, PluginKey as PluginKey6, TextSelection as TextSelection5 } from "prosemirror-state";
6820
6946
  var LINK_INPUT_RE = /\\?\[([^\]]*?)\\?\]\(([^)\s]*?)(?:\s+"([^"]*)")?\)$/;
6821
6947
  var LINK_FULL_RE = /^\\?\[([^\]]*?)\\?\]\(([^)\s]*?)(?:\s+"([^"]*)")?\)$/;
6822
- var linkEditKey = new PluginKey5("linkEdit");
6948
+ var linkEditKey = new PluginKey6("linkEdit");
6823
6949
  function getMarkRange($pos, type) {
6824
6950
  const { parentOffset } = $pos;
6825
6951
  let child = $pos.parent.childAfter(parentOffset);
@@ -6867,7 +6993,7 @@ function explodeLinkToRaw(state) {
6867
6993
  return tr;
6868
6994
  }
6869
6995
  function createLinkEditPlugin() {
6870
- return new Plugin5({
6996
+ return new Plugin7({
6871
6997
  key: linkEditKey,
6872
6998
  state: {
6873
6999
  init: () => ({ rawRange: null }),
@@ -6937,8 +7063,8 @@ function createLinkInputRule() {
6937
7063
  );
6938
7064
  }
6939
7065
  function createLinkClickPlugin() {
6940
- return new Plugin5({
6941
- key: new PluginKey5("linkClick"),
7066
+ return new Plugin7({
7067
+ key: new PluginKey6("linkClick"),
6942
7068
  props: {
6943
7069
  handleDOMEvents: {
6944
7070
  click: (_view, event) => {
@@ -6990,8 +7116,8 @@ function createLinkPlugin() {
6990
7116
  }
6991
7117
 
6992
7118
  // src/ui/plugin/dragHandlePlugin.ts
6993
- import { Plugin as Plugin6, PluginKey as PluginKey6 } from "prosemirror-state";
6994
- var PLUGIN_KEY = new PluginKey6("dragHandle");
7119
+ import { Plugin as Plugin8, PluginKey as PluginKey7 } from "prosemirror-state";
7120
+ var PLUGIN_KEY = new PluginKey7("dragHandle");
6995
7121
  var GRIP_SVG = `<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
6996
7122
  <circle cx="4" cy="2.5" r="1.2"/><circle cx="8" cy="2.5" r="1.2"/>
6997
7123
  <circle cx="4" cy="6" r="1.2"/><circle cx="8" cy="6" r="1.2"/>
@@ -7798,7 +7924,7 @@ function createDragHandlePlugin() {
7798
7924
  plugins: () => {
7799
7925
  let controller = null;
7800
7926
  return [
7801
- new Plugin6({
7927
+ new Plugin8({
7802
7928
  key: PLUGIN_KEY,
7803
7929
  view(editorView) {
7804
7930
  controller = new DragHandleController(editorView);
@@ -7921,10 +8047,10 @@ function createTodoNodeViewPlugin() {
7921
8047
  }
7922
8048
 
7923
8049
  // src/ui/plugin/placeholderPlugin.ts
7924
- import { Plugin as Plugin7, PluginKey as PluginKey7 } from "prosemirror-state";
8050
+ import { Plugin as Plugin9, PluginKey as PluginKey8 } from "prosemirror-state";
7925
8051
  import { Decoration as Decoration4, DecorationSet as DecorationSet4 } from "prosemirror-view";
7926
8052
  var PLACEHOLDER_TEXT2 = "Type to start writing, or press / to insert an action.";
7927
- var pluginKey2 = new PluginKey7("placeholder");
8053
+ var pluginKey2 = new PluginKey8("placeholder");
7928
8054
  function buildDecorations4(state) {
7929
8055
  const { doc: doc2, selection } = state;
7930
8056
  if (!selection.empty) return DecorationSet4.empty;
@@ -7950,7 +8076,7 @@ function createPlaceholderPlugin() {
7950
8076
  return {
7951
8077
  name: "placeholder",
7952
8078
  plugins: () => [
7953
- new Plugin7({
8079
+ new Plugin9({
7954
8080
  key: pluginKey2,
7955
8081
  state: {
7956
8082
  init(_, state) {
@@ -7973,78 +8099,6 @@ function createPlaceholderPlugin() {
7973
8099
  };
7974
8100
  }
7975
8101
 
7976
- // src/ui/plugin/slashCommandPlugin.ts
7977
- import { Plugin as Plugin8, PluginKey as PluginKey8 } from "prosemirror-state";
7978
- var slashCommandKey = new PluginKey8("slashCommand");
7979
- var TRIGGER_RE = /(?:^|\s)(\/[^\s]*)$/;
7980
- function deriveState(state, dismissedFrom) {
7981
- const inactive = { active: false, range: null, query: "", parentType: "" };
7982
- const { selection } = state;
7983
- if (!selection.empty) return inactive;
7984
- const { $from } = selection;
7985
- const parentType = $from.parent.type.name;
7986
- for (let d = $from.depth; d > 0; d--) {
7987
- if ($from.node(d).type.name === "noteBlock") return inactive;
7988
- }
7989
- const textBefore = $from.parent.textBetween(0, $from.parentOffset, "\n", "\0");
7990
- const match = TRIGGER_RE.exec(textBefore);
7991
- if (!match) return inactive;
7992
- const slashText = match[1];
7993
- const slashStartInParent = textBefore.lastIndexOf(slashText);
7994
- const from = $from.start() + slashStartInParent;
7995
- const to = $from.pos;
7996
- if (dismissedFrom === from) return inactive;
7997
- return {
7998
- active: true,
7999
- range: { from, to },
8000
- query: slashText.slice(1),
8001
- parentType
8002
- };
8003
- }
8004
- function createSlashCommandPlugin() {
8005
- const plugin = new Plugin8({
8006
- key: slashCommandKey,
8007
- state: {
8008
- init(_, state) {
8009
- const derived = deriveState(state, null);
8010
- return { ...derived, _dismissedFrom: null };
8011
- },
8012
- apply(tr, prev, _old, newState) {
8013
- const meta = tr.getMeta(slashCommandKey);
8014
- let dismissedFrom = prev._dismissedFrom;
8015
- if (meta?.dismiss !== void 0) {
8016
- dismissedFrom = meta.dismiss;
8017
- } else if (dismissedFrom !== null) {
8018
- const derived2 = deriveState(newState, null);
8019
- if (derived2.active && derived2.range && derived2.range.from !== dismissedFrom) {
8020
- dismissedFrom = null;
8021
- }
8022
- }
8023
- const derived = deriveState(newState, dismissedFrom);
8024
- return { ...derived, _dismissedFrom: dismissedFrom };
8025
- }
8026
- }
8027
- // Expose only the public fields via the key
8028
- // (InternalState is a superset of SlashCommandState so reads work fine)
8029
- });
8030
- return {
8031
- name: "slashCommand",
8032
- plugins: () => [plugin],
8033
- keymap: () => ({
8034
- Escape: (state, dispatch) => {
8035
- const s = slashCommandKey.getState(state);
8036
- if (!s?.active || !s.range) return false;
8037
- if (dispatch) {
8038
- const tr = state.tr;
8039
- tr.setMeta(slashCommandKey, { dismiss: s.range.from });
8040
- dispatch(tr);
8041
- }
8042
- return true;
8043
- }
8044
- })
8045
- };
8046
- }
8047
-
8048
8102
  // src/ui/components/SlashCommandMenu.tsx
8049
8103
  import React4, { useEffect as useEffect3, useLayoutEffect, useRef as useRef3, useState as useState4 } from "react";
8050
8104
  import { createPortal } from "react-dom";
@@ -9757,7 +9811,7 @@ function FloatingMenu({ view, editorState }) {
9757
9811
  }
9758
9812
 
9759
9813
  // src/ui/plugin/inlineSuggestPlugin.ts
9760
- import { Plugin as Plugin9, PluginKey as PluginKey9 } from "prosemirror-state";
9814
+ import { Plugin as Plugin10, PluginKey as PluginKey9 } from "prosemirror-state";
9761
9815
  import { Decoration as Decoration5, DecorationSet as DecorationSet5 } from "prosemirror-view";
9762
9816
  var inlineSuggestKey = new PluginKey9("inlineSuggest");
9763
9817
  var DEBOUNCE_MS = 600;
@@ -9766,7 +9820,7 @@ function createInlineSuggestPlugin(provider, endpoint, options) {
9766
9820
  return {
9767
9821
  name: "inlineSuggest",
9768
9822
  plugins: () => [
9769
- new Plugin9({
9823
+ new Plugin10({
9770
9824
  key: inlineSuggestKey,
9771
9825
  state: {
9772
9826
  init: () => ({ suggestion: null, anchorPos: null }),