@sendbird/actionbook-core 0.10.3 → 0.10.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/ui/index.js CHANGED
@@ -3008,7 +3008,7 @@ function createHistoryPlugin() {
3008
3008
 
3009
3009
  // src/ui/plugin/keymapPlugin.ts
3010
3010
  import { baseKeymap, chainCommands, newlineInCode, createParagraphNear, liftEmptyBlock, splitBlock, toggleMark, setBlockType, joinBackward } from "prosemirror-commands";
3011
- import { TextSelection as TextSelection2 } from "prosemirror-state";
3011
+ import { Plugin as Plugin2, TextSelection as TextSelection2 } from "prosemirror-state";
3012
3012
  import { keymap as keymap3 } from "prosemirror-keymap";
3013
3013
  import { liftListItem, sinkListItem, splitListItem, wrapInList } from "prosemirror-schema-list";
3014
3014
 
@@ -3104,6 +3104,10 @@ function createNoteBlockPlugin() {
3104
3104
  // src/ui/plugin/keymapPlugin.ts
3105
3105
  var TAB_CHAR = " ";
3106
3106
  var { listItem, bulletList, orderedList, hardBreak, heading, paragraph, horizontalRule, blockquote } = actionbookSchema.nodes;
3107
+ function isEffectivelyEmpty(node) {
3108
+ if (node.content.size === 0) return true;
3109
+ return node.textContent.trim().length === 0 && !node.firstChild?.isAtom;
3110
+ }
3107
3111
  var { bold: boldMark, italic: italicMark, underline: underlineMark, strikethrough: strikethroughMark, code: codeMark } = actionbookSchema.marks;
3108
3112
  function cursorDirectlyInListItem(state) {
3109
3113
  const { $from } = state.selection;
@@ -3112,9 +3116,8 @@ function cursorDirectlyInListItem(state) {
3112
3116
  var backspaceAfterList = (state, dispatch) => {
3113
3117
  const { $from } = state.selection;
3114
3118
  if (!state.selection.empty) return false;
3115
- if ($from.parentOffset !== 0) return false;
3116
3119
  if ($from.parent.type !== paragraph) return false;
3117
- if ($from.parent.content.size !== 0) return false;
3120
+ if (!isEffectivelyEmpty($from.parent)) return false;
3118
3121
  const parentDepth = $from.depth - 1;
3119
3122
  if (parentDepth < 0) return false;
3120
3123
  const indexInParent = $from.index(parentDepth);
@@ -3133,9 +3136,8 @@ var backspaceAfterList = (state, dispatch) => {
3133
3136
  var backspaceAfterLeafBlock = (state, dispatch) => {
3134
3137
  const { $from } = state.selection;
3135
3138
  if (!state.selection.empty) return false;
3136
- if ($from.parentOffset !== 0) return false;
3137
3139
  if ($from.parent.type !== paragraph) return false;
3138
- if ($from.parent.content.size !== 0) return false;
3140
+ if (!isEffectivelyEmpty($from.parent)) return false;
3139
3141
  const parentDepth = $from.depth - 1;
3140
3142
  if (parentDepth < 0) return false;
3141
3143
  const indexInParent = $from.index(parentDepth);
@@ -3150,8 +3152,8 @@ var backspaceAfterLeafBlock = (state, dispatch) => {
3150
3152
  };
3151
3153
  var backspaceDeleteEmptyBlock = (state, dispatch) => {
3152
3154
  const { $from } = state.selection;
3153
- if (!state.selection.empty || $from.parentOffset !== 0) return false;
3154
- if ($from.parent.type !== paragraph || $from.parent.content.size !== 0) return false;
3155
+ if (!state.selection.empty) return false;
3156
+ if ($from.parent.type !== paragraph || !isEffectivelyEmpty($from.parent)) return false;
3155
3157
  const deletableTypes = /* @__PURE__ */ new Set(["jinjaIfBlock", "jinjaIfBranch", "noteBlock", "blockquote"]);
3156
3158
  for (let d = $from.depth - 1; d > 0; d--) {
3157
3159
  const ancestor = $from.node(d);
@@ -3391,6 +3393,18 @@ var shiftEnterCommand = (state, dispatch) => {
3391
3393
  }
3392
3394
  return true;
3393
3395
  };
3396
+ function createEmptyDocGuardPlugin() {
3397
+ return new Plugin2({
3398
+ appendTransaction(_, __, newState) {
3399
+ const { doc: doc2 } = newState;
3400
+ if (doc2.childCount !== 1) return null;
3401
+ const only = doc2.child(0);
3402
+ if (only.type === paragraph) return null;
3403
+ if (only.content.size !== 0) return null;
3404
+ return newState.tr.setNodeMarkup(0, paragraph);
3405
+ }
3406
+ });
3407
+ }
3394
3408
  function createKeymapPlugin() {
3395
3409
  return {
3396
3410
  name: "keymapPlugin",
@@ -3408,13 +3422,13 @@ function createKeymapPlugin() {
3408
3422
  "Mod-Shift-7": wrapInList(bulletList),
3409
3423
  "Mod-Shift-8": wrapInList(orderedList)
3410
3424
  }),
3411
- plugins: () => [keymap3(baseKeymap)]
3425
+ plugins: () => [keymap3(baseKeymap), createEmptyDocGuardPlugin()]
3412
3426
  };
3413
3427
  }
3414
3428
 
3415
3429
  // src/ui/plugin/markdownClipboard.ts
3416
3430
  import { DOMParser as ProseMirrorDOMParser, Fragment, Slice } from "prosemirror-model";
3417
- import { Plugin as Plugin2, PluginKey as PluginKey2 } from "prosemirror-state";
3431
+ import { Plugin as Plugin3, PluginKey as PluginKey2 } from "prosemirror-state";
3418
3432
 
3419
3433
  // src/ast/traverse.ts
3420
3434
  var MAX_DEPTH3 = 128;
@@ -5691,7 +5705,7 @@ function textToSlice(text2, view) {
5691
5705
  }
5692
5706
  var URL_RE = /^https?:\/\/[^\s]+$/i;
5693
5707
  function createPlugin() {
5694
- return new Plugin2({
5708
+ return new Plugin3({
5695
5709
  key,
5696
5710
  props: {
5697
5711
  handlePaste(view, event) {
@@ -5757,7 +5771,7 @@ function createMarkdownClipboardPlugin() {
5757
5771
  }
5758
5772
 
5759
5773
  // src/ui/plugin/jumpPointPlugin.ts
5760
- import { Plugin as Plugin3, PluginKey as PluginKey3, TextSelection as TextSelection3 } from "prosemirror-state";
5774
+ import { Plugin as Plugin4, PluginKey as PluginKey3, TextSelection as TextSelection3 } from "prosemirror-state";
5761
5775
  import { Decoration, DecorationSet } from "prosemirror-view";
5762
5776
  var adjacentKey = new PluginKey3("jumpPointAdjacent");
5763
5777
  var JUMP_POINT_ADJACENT_SPEC = { jumpPointAdjacent: true };
@@ -5778,7 +5792,7 @@ function buildDecorations(state) {
5778
5792
  var jumpPointEditKey = new PluginKey3("jumpPointEdit");
5779
5793
  var JUMP_POINT_FULL_RE = /^\^([\p{L}\p{N}_-]+)\^$/u;
5780
5794
  function createJumpPointEditPlugin() {
5781
- return new Plugin3({
5795
+ return new Plugin4({
5782
5796
  key: jumpPointEditKey,
5783
5797
  state: {
5784
5798
  init: () => ({ rawRange: null }),
@@ -5880,7 +5894,7 @@ function createJumpPointAdjacentPlugin() {
5880
5894
  }),
5881
5895
  plugins: () => [
5882
5896
  createJumpPointEditPlugin(),
5883
- new Plugin3({
5897
+ new Plugin4({
5884
5898
  key: adjacentKey,
5885
5899
  state: {
5886
5900
  init(_, state) {
@@ -6046,7 +6060,7 @@ function createJumpPointNodeViewPlugin() {
6046
6060
  }
6047
6061
 
6048
6062
  // src/ui/plugin/jumpPointValidationPlugin.ts
6049
- import { Plugin as Plugin4, PluginKey as PluginKey4 } from "prosemirror-state";
6063
+ import { Plugin as Plugin5, PluginKey as PluginKey4 } from "prosemirror-state";
6050
6064
  import { Decoration as Decoration2, DecorationSet as DecorationSet2 } from "prosemirror-view";
6051
6065
  var pluginKey = new PluginKey4("jumpPointValidation");
6052
6066
  function collectJumpPointIds(state) {
@@ -6098,7 +6112,7 @@ function createJumpPointValidationPlugin() {
6098
6112
  return {
6099
6113
  name: "jumpPointValidation",
6100
6114
  plugins: () => [
6101
- new Plugin4({
6115
+ new Plugin5({
6102
6116
  key: pluginKey,
6103
6117
  state: {
6104
6118
  init(_, state) {
@@ -6136,9 +6150,14 @@ function buildDecorations2(state) {
6136
6150
  class: "broken-anchor-ref",
6137
6151
  "data-broken-ref": refId,
6138
6152
  title: `Anchor "${refId}" no longer exists`,
6139
- style: "color: #D9352C; text-decoration-color: #D9352C;"
6153
+ style: "color: #D9352C; font-weight: 500; text-decoration: none;"
6140
6154
  })
6141
6155
  );
6156
+ const icon = document.createElement("span");
6157
+ icon.textContent = " \u26A0";
6158
+ icon.style.cssText = "color: #D9352C; font-size: 14px; vertical-align: middle;";
6159
+ icon.setAttribute("aria-hidden", "true");
6160
+ decos.push(Decoration2.widget(to, icon, { side: 1 }));
6142
6161
  }
6143
6162
  if (decos.length === 0) return DecorationSet2.empty;
6144
6163
  return DecorationSet2.create(state.doc, decos);
@@ -6214,7 +6233,7 @@ function createInlineToolTagNodeViewPlugin() {
6214
6233
  }
6215
6234
 
6216
6235
  // src/ui/plugin/jinjaDecoration.ts
6217
- import { Plugin as Plugin5, PluginKey as PluginKey5 } from "prosemirror-state";
6236
+ import { Plugin as Plugin6, PluginKey as PluginKey5 } from "prosemirror-state";
6218
6237
  import { Decoration as Decoration3, DecorationSet as DecorationSet3 } from "prosemirror-view";
6219
6238
  var jinjaPluginKey = new PluginKey5("jinjaDecoration");
6220
6239
  var JINJA_TAG_RE = /\{%\s*(if|elif|else|endif)\s*([^%]*?)\s*%\}/g;
@@ -6307,7 +6326,7 @@ function createJinjaDecorationPlugin() {
6307
6326
  return {
6308
6327
  name: "jinjaDecoration",
6309
6328
  plugins: () => [
6310
- new Plugin5({
6329
+ new Plugin6({
6311
6330
  key: jinjaPluginKey,
6312
6331
  state: {
6313
6332
  init(_, state) {
@@ -6331,7 +6350,7 @@ function createJinjaDecorationPlugin() {
6331
6350
  // src/ui/plugin/jinjaIfBlockPlugin.tsx
6332
6351
  import { useEffect as useEffect2, useRef as useRef2, useState as useState3 } from "react";
6333
6352
  import { createRoot as createRoot2 } from "react-dom/client";
6334
- import { Plugin as Plugin6, TextSelection as TextSelection4 } from "prosemirror-state";
6353
+ import { Plugin as Plugin7, TextSelection as TextSelection4 } from "prosemirror-state";
6335
6354
  import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
6336
6355
  var PLACEHOLDER_TEXT = "Describe what AI agent should do when this condition is met";
6337
6356
  var CONDITION_PLACEHOLDER = "Write a condition in natural language";
@@ -7252,7 +7271,7 @@ var JinjaIfBranchView = class {
7252
7271
  };
7253
7272
  function createEditableWatcherPlugin() {
7254
7273
  let lastEditable = null;
7255
- return new Plugin6({
7274
+ return new Plugin7({
7256
7275
  view(editorView) {
7257
7276
  lastEditable = editorView.editable;
7258
7277
  return {
@@ -7283,7 +7302,7 @@ function createJinjaIfBlockPlugin() {
7283
7302
 
7284
7303
  // src/ui/plugin/linkPlugin.ts
7285
7304
  import { InputRule as InputRule2, inputRules as inputRules2 } from "prosemirror-inputrules";
7286
- import { Plugin as Plugin7, PluginKey as PluginKey6, TextSelection as TextSelection5 } from "prosemirror-state";
7305
+ import { Plugin as Plugin8, PluginKey as PluginKey6, TextSelection as TextSelection5 } from "prosemirror-state";
7287
7306
  var LINK_INPUT_RE = /\\?\[([^\]]*?)\\?\]\(([^)\s]*?)(?:\s+"([^"]*)")?\)$/;
7288
7307
  var LINK_FULL_RE = /^\\?\[([^\]]*?)\\?\]\(([^)\s]*?)(?:\s+"([^"]*)")?\)$/;
7289
7308
  var linkEditKey = new PluginKey6("linkEdit");
@@ -7334,7 +7353,7 @@ function explodeLinkToRaw(state) {
7334
7353
  return tr;
7335
7354
  }
7336
7355
  function createLinkEditPlugin() {
7337
- return new Plugin7({
7356
+ return new Plugin8({
7338
7357
  key: linkEditKey,
7339
7358
  state: {
7340
7359
  init: () => ({ rawRange: null }),
@@ -7409,7 +7428,7 @@ function createLinkInputRule() {
7409
7428
  );
7410
7429
  }
7411
7430
  function createLinkClickPlugin() {
7412
- return new Plugin7({
7431
+ return new Plugin8({
7413
7432
  key: new PluginKey6("linkClick"),
7414
7433
  props: {
7415
7434
  handleDOMEvents: {
@@ -7462,7 +7481,7 @@ function createLinkPlugin() {
7462
7481
  }
7463
7482
 
7464
7483
  // src/ui/plugin/dragHandlePlugin.ts
7465
- import { Plugin as Plugin8, PluginKey as PluginKey7 } from "prosemirror-state";
7484
+ import { Plugin as Plugin9, PluginKey as PluginKey7 } from "prosemirror-state";
7466
7485
  var PLUGIN_KEY = new PluginKey7("dragHandle");
7467
7486
  var GRIP_SVG = `<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
7468
7487
  <circle cx="4" cy="2.5" r="1.2"/><circle cx="8" cy="2.5" r="1.2"/>
@@ -8270,7 +8289,7 @@ function createDragHandlePlugin() {
8270
8289
  plugins: () => {
8271
8290
  let controller = null;
8272
8291
  return [
8273
- new Plugin8({
8292
+ new Plugin9({
8274
8293
  key: PLUGIN_KEY,
8275
8294
  view(editorView) {
8276
8295
  controller = new DragHandleController(editorView);
@@ -8393,9 +8412,8 @@ function createTodoNodeViewPlugin() {
8393
8412
  }
8394
8413
 
8395
8414
  // src/ui/plugin/placeholderPlugin.ts
8396
- import { Plugin as Plugin9, PluginKey as PluginKey8 } from "prosemirror-state";
8415
+ import { Plugin as Plugin10, PluginKey as PluginKey8 } from "prosemirror-state";
8397
8416
  import { Decoration as Decoration4, DecorationSet as DecorationSet4 } from "prosemirror-view";
8398
- var PLACEHOLDER_TEXT2 = "Type to start writing, or press / to insert an action.";
8399
8417
  var pluginKey2 = new PluginKey8("placeholder");
8400
8418
  function buildDecorations4(state) {
8401
8419
  const { doc: doc2, selection } = state;
@@ -8413,17 +8431,25 @@ function buildDecorations4(state) {
8413
8431
  }
8414
8432
  const pos = $from.before($from.depth);
8415
8433
  const deco = Decoration4.node(pos, pos + parent.nodeSize, {
8416
- class: "ab-empty-paragraph",
8417
- "data-placeholder": PLACEHOLDER_TEXT2
8434
+ class: "ab-empty-paragraph"
8418
8435
  });
8419
8436
  return DecorationSet4.create(doc2, [deco]);
8420
8437
  }
8421
8438
  function createPlaceholderPlugin() {
8439
+ let isEditable = true;
8422
8440
  return {
8423
8441
  name: "placeholder",
8424
8442
  plugins: () => [
8425
- new Plugin9({
8443
+ new Plugin10({
8426
8444
  key: pluginKey2,
8445
+ view(editorView) {
8446
+ isEditable = editorView.editable;
8447
+ return {
8448
+ update(view) {
8449
+ isEditable = view.editable;
8450
+ }
8451
+ };
8452
+ },
8427
8453
  state: {
8428
8454
  init(_, state) {
8429
8455
  return buildDecorations4(state);
@@ -8437,6 +8463,7 @@ function createPlaceholderPlugin() {
8437
8463
  },
8438
8464
  props: {
8439
8465
  decorations(state) {
8466
+ if (!isEditable) return DecorationSet4.empty;
8440
8467
  return pluginKey2.getState(state) ?? DecorationSet4.empty;
8441
8468
  }
8442
8469
  }
@@ -10362,7 +10389,7 @@ function FloatingMenu({ view, editorState }) {
10362
10389
  }
10363
10390
 
10364
10391
  // src/ui/plugin/inlineSuggestPlugin.ts
10365
- import { Plugin as Plugin10, PluginKey as PluginKey9 } from "prosemirror-state";
10392
+ import { Plugin as Plugin11, PluginKey as PluginKey9 } from "prosemirror-state";
10366
10393
  import { Decoration as Decoration5, DecorationSet as DecorationSet5 } from "prosemirror-view";
10367
10394
  var inlineSuggestKey = new PluginKey9("inlineSuggest");
10368
10395
  var DEBOUNCE_MS = 600;
@@ -10371,7 +10398,7 @@ function createInlineSuggestPlugin(provider, endpoint, options) {
10371
10398
  return {
10372
10399
  name: "inlineSuggest",
10373
10400
  plugins: () => [
10374
- new Plugin10({
10401
+ new Plugin11({
10375
10402
  key: inlineSuggestKey,
10376
10403
  state: {
10377
10404
  init: () => ({ suggestion: null, anchorPos: null }),