@sendbird/actionbook-core 0.10.7 → 0.10.8

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
@@ -2418,6 +2418,14 @@ var gfmNoAutolinkToMarkdown = () => ({
2418
2418
  function isEmptyParagraph(node) {
2419
2419
  return node.type === "paragraph" && (!("children" in node) || !node.children || node.children.length === 0);
2420
2420
  }
2421
+ var JINJA_TAG_RE = /^\{%\s*(if|elif|else|endif)\b/;
2422
+ function isJinjaTagParagraph(node) {
2423
+ if (node.type !== "paragraph") return false;
2424
+ const children = node.children;
2425
+ if (!children || children.length !== 1) return false;
2426
+ const child = children[0];
2427
+ return child.type === "text" && typeof child.value === "string" && JINJA_TAG_RE.test(child.value);
2428
+ }
2421
2429
  function textHandler(node, parent, state, info) {
2422
2430
  const originalUnsafe = state.unsafe;
2423
2431
  state.unsafe = originalUnsafe.filter((p) => !(p.character === "_" && !p.atBreak));
@@ -2460,7 +2468,10 @@ function serializeToMarkdown(doc2) {
2460
2468
  // Empty paragraphs represent blank-line spacers.
2461
2469
  // Reduce the separator after an empty paragraph from \n\n to \n
2462
2470
  // so that 1 empty paragraph = 1 extra blank line in the output.
2463
- (left) => isEmptyParagraph(left) ? 0 : null
2471
+ (left) => isEmptyParagraph(left) ? 0 : null,
2472
+ // Consecutive paragraphs: single newline instead of blank line
2473
+ // (skip jinja tag paragraphs — they need blank lines for proper roundtrip)
2474
+ (left, right) => left.type === "paragraph" && right.type === "paragraph" && !isJinjaTagParagraph(left) && !isJinjaTagParagraph(right) ? 0 : null
2464
2475
  ],
2465
2476
  handlers: {
2466
2477
  text: textHandler,
@@ -5597,6 +5608,11 @@ function tokenize(input) {
5597
5608
  i++;
5598
5609
  continue;
5599
5610
  }
5611
+ if (input[i] === ",") {
5612
+ tokens.push({ type: "COMMA", value: "," });
5613
+ i++;
5614
+ continue;
5615
+ }
5600
5616
  return { tokens: [], error: `Unexpected character: ${input[i]}` };
5601
5617
  }
5602
5618
  tokens.push({ type: "EOF", value: "" });
@@ -5727,6 +5743,17 @@ var Parser = class {
5727
5743
  return null;
5728
5744
  case "IDENT": {
5729
5745
  this.advance();
5746
+ if (this.peek().type === "LPAREN") {
5747
+ this.advance();
5748
+ while (this.peek().type !== "RPAREN" && this.peek().type !== "EOF") {
5749
+ this.orExpr();
5750
+ if (this.peek().type === "COMMA") {
5751
+ this.advance();
5752
+ }
5753
+ }
5754
+ this.expect("RPAREN");
5755
+ return null;
5756
+ }
5730
5757
  return this.resolveVariable(t.value);
5731
5758
  }
5732
5759
  case "LPAREN": {
@@ -6656,7 +6683,7 @@ function createInlineToolTagNodeViewPlugin() {
6656
6683
  import { Plugin as Plugin6, PluginKey as PluginKey5 } from "prosemirror-state";
6657
6684
  import { Decoration as Decoration4, DecorationSet as DecorationSet4 } from "prosemirror-view";
6658
6685
  var jinjaPluginKey = new PluginKey5("jinjaDecoration");
6659
- var JINJA_TAG_RE = /\{%\s*(if|elif|else|endif)\s*([^%]*?)\s*%\}/g;
6686
+ var JINJA_TAG_RE2 = /\{%\s*(if|elif|else|endif)\s*([^%]*?)\s*%\}/g;
6660
6687
  function getBlockPositions(doc2) {
6661
6688
  const blocks = [];
6662
6689
  let index = 0;
@@ -6670,9 +6697,9 @@ function addInlineChipDecorations(doc2, decorations) {
6670
6697
  doc2.descendants((node, pos) => {
6671
6698
  if (!node.isText) return;
6672
6699
  const text2 = node.text;
6673
- JINJA_TAG_RE.lastIndex = 0;
6700
+ JINJA_TAG_RE2.lastIndex = 0;
6674
6701
  let match;
6675
- while ((match = JINJA_TAG_RE.exec(text2)) !== null) {
6702
+ while ((match = JINJA_TAG_RE2.exec(text2)) !== null) {
6676
6703
  const from = pos + match.index;
6677
6704
  const to = from + match[0].length;
6678
6705
  const keyword = match[1];
@@ -6837,6 +6864,7 @@ var JINJA_STYLES = `
6837
6864
  .jinja-branch-condition {
6838
6865
  flex: 1;
6839
6866
  min-width: 0;
6867
+ min-height: 20px;
6840
6868
  display: flex;
6841
6869
  flex-wrap: wrap;
6842
6870
  gap: 8px;
@@ -7014,6 +7042,15 @@ var JINJA_STYLES = `
7014
7042
  background: rgba(13, 13, 13, 0.04);
7015
7043
  }
7016
7044
 
7045
+ .jinja-ghost-btn.jinja-add-btn {
7046
+ color: #5E5E5E;
7047
+ }
7048
+
7049
+ .jinja-ghost-btn.jinja-add-btn.active {
7050
+ background: #DCDBFF;
7051
+ color: #6210CC;
7052
+ }
7053
+
7017
7054
  .jinja-ghost-btn:disabled {
7018
7055
  opacity: 0.45;
7019
7056
  cursor: default;
@@ -7316,7 +7353,7 @@ function ConditionDisplay({
7316
7353
  setIsEditing(true);
7317
7354
  }
7318
7355
  },
7319
- children: condition.length > 0 ? renderCondition(condition) : /* @__PURE__ */ jsx6("span", { className: "jinja-condition-placeholder", children: CONDITION_PLACEHOLDER })
7356
+ children: condition.length > 0 ? condition.trim().length > 0 ? renderCondition(condition) : /* @__PURE__ */ jsx6("span", { className: "jinja-token-identifier", children: condition }) : /* @__PURE__ */ jsx6("span", { className: "jinja-condition-placeholder", children: CONDITION_PLACEHOLDER })
7320
7357
  }
7321
7358
  );
7322
7359
  }
@@ -7390,6 +7427,16 @@ function JinjaBranchHeader({
7390
7427
  }, [menuSource]);
7391
7428
  const menuItems = [];
7392
7429
  if (editable) {
7430
+ if (!hasElseBranch) {
7431
+ menuItems.push({
7432
+ label: "Else if",
7433
+ onSelect: () => onAddBranch("elif")
7434
+ });
7435
+ menuItems.push({
7436
+ label: "Else",
7437
+ onSelect: () => onAddBranch("else")
7438
+ });
7439
+ }
7393
7440
  menuItems.push({
7394
7441
  label: "Delete",
7395
7442
  onSelect: onDelete
@@ -7444,8 +7491,9 @@ function JinjaBranchHeader({
7444
7491
  BranchPopupMenu,
7445
7492
  {
7446
7493
  position: { top: 28, right: 0 },
7447
- items: menuItems.map((item) => ({
7494
+ items: menuItems.filter((item) => item.label === "Delete").map((item) => ({
7448
7495
  ...item,
7496
+ label: branchType === "if" ? "Delete all" : "Delete",
7449
7497
  onSelect: () => {
7450
7498
  setMenuSource(null);
7451
7499
  item.onSelect();
@@ -7462,7 +7510,7 @@ function JinjaBranchHeader({
7462
7510
  "button",
7463
7511
  {
7464
7512
  type: "button",
7465
- className: "jinja-ghost-btn",
7513
+ className: `jinja-ghost-btn jinja-add-btn${menuSource === "footer" ? " active" : ""}`,
7466
7514
  "aria-label": "Add branch",
7467
7515
  disabled: !canOpenFooterMenu,
7468
7516
  onMouseDown: (event) => event.preventDefault(),
@@ -7471,9 +7519,9 @@ function JinjaBranchHeader({
7471
7519
  setMenuSource((current) => current === "footer" ? null : "footer");
7472
7520
  }
7473
7521
  },
7474
- children: /* @__PURE__ */ jsxs5("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", children: [
7475
- /* @__PURE__ */ jsx6("line", { x1: "8", y1: "3", x2: "8", y2: "13" }),
7476
- /* @__PURE__ */ jsx6("line", { x1: "3", y1: "8", x2: "13", y2: "8" })
7522
+ children: /* @__PURE__ */ jsxs5("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
7523
+ /* @__PURE__ */ jsx6("path", { d: "M7.33337 11L7.33337 8.66666L5.00004 8.66666V7.33333L7.33337 7.33333V4.99999H8.66671V7.33333H11V8.66666H8.66671L8.66671 11H7.33337Z", fill: "currentColor" }),
7524
+ /* @__PURE__ */ jsx6("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M8.00004 14.6667C11.6819 14.6667 14.6667 11.6819 14.6667 7.99999C14.6667 4.3181 11.6819 1.33333 8.00004 1.33333C4.31814 1.33333 1.33337 4.3181 1.33337 7.99999C1.33337 11.6819 4.31814 14.6667 8.00004 14.6667ZM13.3334 7.99999C13.3334 10.9455 10.9456 13.3333 8.00004 13.3333C5.05452 13.3333 2.66671 10.9455 2.66671 7.99999C2.66671 5.05448 5.05452 2.66666 8.00004 2.66666C10.9456 2.66666 13.3334 5.05448 13.3334 7.99999Z", fill: "currentColor" })
7477
7525
  ] })
7478
7526
  }
7479
7527
  ),
@@ -7871,7 +7919,7 @@ function createLinkPlugin() {
7871
7919
  // src/ui/plugin/dragHandlePlugin.ts
7872
7920
  import { Plugin as Plugin9, PluginKey as PluginKey7 } from "prosemirror-state";
7873
7921
  var PLUGIN_KEY = new PluginKey7("dragHandle");
7874
- var GRIP_SVG = `<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
7922
+ var GRIP_SVG = `<svg width="16" height="16" viewBox="0 0 12 12" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
7875
7923
  <circle cx="4" cy="2.5" r="1.2"/><circle cx="8" cy="2.5" r="1.2"/>
7876
7924
  <circle cx="4" cy="6" r="1.2"/><circle cx="8" cy="6" r="1.2"/>
7877
7925
  <circle cx="4" cy="9.5" r="1.2"/><circle cx="8" cy="9.5" r="1.2"/>
@@ -8481,6 +8529,7 @@ var DragHandleController = class {
8481
8529
  this.dropIndicator.className = "ab-drop-indicator";
8482
8530
  this.dropIndicator.style.display = "none";
8483
8531
  parent.appendChild(this.dropIndicator);
8532
+ this.scrollContainer = this.findScrollContainer(this.view.dom);
8484
8533
  this.tickAutoScroll();
8485
8534
  }
8486
8535
  addGlobalDragListeners(pointerId) {
@@ -8629,6 +8678,7 @@ var DragHandleController = class {
8629
8678
  while (current) {
8630
8679
  const overflow = getComputedStyle(current).overflowY;
8631
8680
  if (overflow === "auto" || overflow === "scroll") return current;
8681
+ if (overflow === "hidden" && (current.classList.contains("ps") || current.scrollHeight > current.clientHeight + 1)) return current;
8632
8682
  current = current.parentElement;
8633
8683
  }
8634
8684
  return el.parentElement ?? el;
@@ -9715,7 +9765,7 @@ function DropdownItem({ item, onRun }) {
9715
9765
  transition: "background 0.1s"
9716
9766
  },
9717
9767
  children: [
9718
- /* @__PURE__ */ jsx10("span", { style: { width: 24, flexShrink: 0, textAlign: "center", fontWeight: 700, fontSize: 12, fontFamily: "monospace", color: "#6210CC" }, children: item.shortLabel }),
9768
+ /* @__PURE__ */ jsx10("span", { style: { width: 24, flexShrink: 0, textAlign: "center", fontWeight: 700, fontSize: 12, fontFamily: "monospace", color: item.active ? "#6210CC" : "#666" }, children: item.shortLabel }),
9719
9769
  item.label
9720
9770
  ]
9721
9771
  }