@sendbird/actionbook-core 0.9.8 → 0.9.9
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 +56 -37
- package/dist/ui/index.js.map +1 -1
- package/package.json +1 -1
package/dist/ui/index.js
CHANGED
|
@@ -2886,14 +2886,6 @@ function createInputRulesPlugin() {
|
|
|
2886
2886
|
rules.push(
|
|
2887
2887
|
new InputRule(JUMP_POINT_RE2, (state, match, start, end) => {
|
|
2888
2888
|
const id = match[1];
|
|
2889
|
-
let exists = false;
|
|
2890
|
-
state.doc.descendants((node) => {
|
|
2891
|
-
if (node.type === jumpPointType && node.attrs.id === id) {
|
|
2892
|
-
exists = true;
|
|
2893
|
-
return false;
|
|
2894
|
-
}
|
|
2895
|
-
});
|
|
2896
|
-
if (exists) return null;
|
|
2897
2889
|
const tr = state.tr.delete(start, end).insert(start, jumpPointType.create({ id }));
|
|
2898
2890
|
const afterAtom = start + 1;
|
|
2899
2891
|
tr.insertText(" ", afterAtom);
|
|
@@ -5407,18 +5399,10 @@ function createJumpPointEditPlugin() {
|
|
|
5407
5399
|
const [, id] = match;
|
|
5408
5400
|
const jumpPointType = newState.schema.nodes.jumpPoint;
|
|
5409
5401
|
if (jumpPointType) {
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
}
|
|
5415
|
-
});
|
|
5416
|
-
if (!duplicate) {
|
|
5417
|
-
reconvertTr.replaceWith(safeFrom, safeTo, jumpPointType.create({ id }));
|
|
5418
|
-
const mappedCursor = reconvertTr.mapping.map(cursor);
|
|
5419
|
-
const clampedCursor = Math.min(mappedCursor, reconvertTr.doc.content.size);
|
|
5420
|
-
reconvertTr.setSelection(TextSelection3.near(reconvertTr.doc.resolve(clampedCursor)));
|
|
5421
|
-
}
|
|
5402
|
+
reconvertTr.replaceWith(safeFrom, safeTo, jumpPointType.create({ id }));
|
|
5403
|
+
const mappedCursor = reconvertTr.mapping.map(cursor);
|
|
5404
|
+
const clampedCursor = Math.min(mappedCursor, reconvertTr.doc.content.size);
|
|
5405
|
+
reconvertTr.setSelection(TextSelection3.near(reconvertTr.doc.resolve(clampedCursor)));
|
|
5422
5406
|
}
|
|
5423
5407
|
}
|
|
5424
5408
|
}
|
|
@@ -6319,15 +6303,6 @@ function getElseBranch(view, nodePos) {
|
|
|
6319
6303
|
}
|
|
6320
6304
|
return false;
|
|
6321
6305
|
}
|
|
6322
|
-
function deleteBlock(view, blockPos) {
|
|
6323
|
-
const blockNode = view.state.doc.nodeAt(blockPos);
|
|
6324
|
-
if (blockNode?.type.name !== "jinjaIfBlock") {
|
|
6325
|
-
return false;
|
|
6326
|
-
}
|
|
6327
|
-
view.dispatch(view.state.tr.delete(blockPos, blockPos + blockNode.nodeSize).scrollIntoView());
|
|
6328
|
-
view.focus();
|
|
6329
|
-
return true;
|
|
6330
|
-
}
|
|
6331
6306
|
function insertNewBranch(view, nodePos, branchType, condition = "") {
|
|
6332
6307
|
const context = getBranchContext(view, nodePos);
|
|
6333
6308
|
if (!context) return false;
|
|
@@ -6353,14 +6328,36 @@ function insertNewBranch(view, nodePos, branchType, condition = "") {
|
|
|
6353
6328
|
function deleteBranch(view, nodePos, branchType) {
|
|
6354
6329
|
const context = getBranchContext(view, nodePos);
|
|
6355
6330
|
if (!context) return false;
|
|
6331
|
+
const { branchNode, branchPos, branchIndex, blockNode, blockPos } = context;
|
|
6332
|
+
const branchContent = branchNode.content;
|
|
6356
6333
|
if (branchType === "if") {
|
|
6357
|
-
if (
|
|
6358
|
-
|
|
6334
|
+
if (blockNode.childCount === 1) {
|
|
6335
|
+
const tr2 = view.state.tr;
|
|
6336
|
+
if (isBranchBodyEmpty(branchNode)) {
|
|
6337
|
+
tr2.replaceWith(blockPos, blockPos + blockNode.nodeSize, view.state.schema.nodes.paragraph.create());
|
|
6338
|
+
tr2.setSelection(TextSelection4.near(tr2.doc.resolve(blockPos)));
|
|
6339
|
+
} else {
|
|
6340
|
+
tr2.replaceWith(blockPos, blockPos + blockNode.nodeSize, branchContent);
|
|
6341
|
+
tr2.setSelection(TextSelection4.near(tr2.doc.resolve(blockPos)));
|
|
6342
|
+
}
|
|
6343
|
+
view.dispatch(tr2.scrollIntoView());
|
|
6344
|
+
view.focus();
|
|
6345
|
+
return true;
|
|
6359
6346
|
}
|
|
6360
|
-
const nextBranch =
|
|
6347
|
+
const nextBranch = blockNode.child(branchIndex + 1);
|
|
6361
6348
|
const promotedCondition = typeof nextBranch.attrs.condition === "string" ? nextBranch.attrs.condition : "";
|
|
6362
|
-
const tr = view.state.tr
|
|
6363
|
-
|
|
6349
|
+
const tr = view.state.tr;
|
|
6350
|
+
if (!isBranchBodyEmpty(branchNode)) {
|
|
6351
|
+
const nextBranchPos = branchPos + branchNode.nodeSize;
|
|
6352
|
+
const nextBranchContentStart = nextBranchPos + 1;
|
|
6353
|
+
for (let i = branchContent.childCount - 1; i >= 0; i--) {
|
|
6354
|
+
tr.insert(nextBranchContentStart, branchContent.child(i));
|
|
6355
|
+
}
|
|
6356
|
+
}
|
|
6357
|
+
const mappedBranchPos = tr.mapping.map(branchPos);
|
|
6358
|
+
const mappedBranchEnd = tr.mapping.map(branchPos + branchNode.nodeSize);
|
|
6359
|
+
tr.delete(mappedBranchPos, mappedBranchEnd);
|
|
6360
|
+
tr.setNodeMarkup(mappedBranchPos, void 0, {
|
|
6364
6361
|
...nextBranch.attrs,
|
|
6365
6362
|
branchType: "if",
|
|
6366
6363
|
condition: promotedCondition
|
|
@@ -6369,7 +6366,23 @@ function deleteBranch(view, nodePos, branchType) {
|
|
|
6369
6366
|
view.focus();
|
|
6370
6367
|
return true;
|
|
6371
6368
|
}
|
|
6372
|
-
|
|
6369
|
+
if (!isBranchBodyEmpty(branchNode) && branchIndex > 0) {
|
|
6370
|
+
const prevBranch = blockNode.child(branchIndex - 1);
|
|
6371
|
+
const prevBranchPos = branchPos - prevBranch.nodeSize;
|
|
6372
|
+
const prevBranchContentEnd = prevBranchPos + prevBranch.nodeSize - 1;
|
|
6373
|
+
const tr = view.state.tr;
|
|
6374
|
+
for (let i = 0; i < branchContent.childCount; i++) {
|
|
6375
|
+
tr.insert(prevBranchContentEnd + i, branchContent.child(i));
|
|
6376
|
+
}
|
|
6377
|
+
const mappedBranchPos = tr.mapping.map(branchPos);
|
|
6378
|
+
const mappedBranchEnd = tr.mapping.map(branchPos + branchNode.nodeSize);
|
|
6379
|
+
tr.delete(mappedBranchPos, mappedBranchEnd);
|
|
6380
|
+
tr.setSelection(TextSelection4.near(tr.doc.resolve(tr.mapping.map(prevBranchContentEnd)), -1));
|
|
6381
|
+
view.dispatch(tr.scrollIntoView());
|
|
6382
|
+
view.focus();
|
|
6383
|
+
return true;
|
|
6384
|
+
}
|
|
6385
|
+
view.dispatch(view.state.tr.delete(branchPos, branchPos + branchNode.nodeSize).scrollIntoView());
|
|
6373
6386
|
view.focus();
|
|
6374
6387
|
return true;
|
|
6375
6388
|
}
|
|
@@ -6388,7 +6401,8 @@ function ConditionDisplay({
|
|
|
6388
6401
|
branchType,
|
|
6389
6402
|
condition,
|
|
6390
6403
|
editable = true,
|
|
6391
|
-
onConditionChange
|
|
6404
|
+
onConditionChange,
|
|
6405
|
+
onBackspaceEmpty
|
|
6392
6406
|
}) {
|
|
6393
6407
|
const [isEditing, setIsEditing] = useState3(false);
|
|
6394
6408
|
const [draftValue, setDraftValue] = useState3(condition);
|
|
@@ -6443,6 +6457,10 @@ function ConditionDisplay({
|
|
|
6443
6457
|
event.preventDefault();
|
|
6444
6458
|
cancel();
|
|
6445
6459
|
}
|
|
6460
|
+
if (event.key === "Backspace" && draftValue === "" && onBackspaceEmpty) {
|
|
6461
|
+
event.preventDefault();
|
|
6462
|
+
onBackspaceEmpty();
|
|
6463
|
+
}
|
|
6446
6464
|
}
|
|
6447
6465
|
}
|
|
6448
6466
|
);
|
|
@@ -6562,7 +6580,8 @@ function JinjaBranchHeader({
|
|
|
6562
6580
|
branchType,
|
|
6563
6581
|
condition,
|
|
6564
6582
|
editable,
|
|
6565
|
-
onConditionChange
|
|
6583
|
+
onConditionChange,
|
|
6584
|
+
onBackspaceEmpty: onDelete
|
|
6566
6585
|
}
|
|
6567
6586
|
),
|
|
6568
6587
|
editable ? /* @__PURE__ */ jsxs5("div", { className: "jinja-branch-actions", ref: kebabRef, children: [
|