@sendbird/actionbook-core 0.9.1 → 0.9.3
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/index.js +21 -1
- package/dist/index.js.map +1 -1
- package/dist/ui/index.js +461 -224
- package/dist/ui/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5640,6 +5640,20 @@ function findMatchingJinjaBranch(tree, containerNode, context) {
|
|
|
5640
5640
|
|
|
5641
5641
|
// src/actionbookToAST.ts
|
|
5642
5642
|
var EMPTY_DOC = { type: "doc", content: [{ type: "paragraph", content: [] }] };
|
|
5643
|
+
var JINJA_BLOCK_TAG_RE = /^\s*\{%\s*(if|elif|else|endif)\s/m;
|
|
5644
|
+
function needsJinjaReparse(doc2, instruction) {
|
|
5645
|
+
if (!instruction || !JINJA_BLOCK_TAG_RE.test(instruction)) return false;
|
|
5646
|
+
function hasJinjaBlock(nodes) {
|
|
5647
|
+
for (const node of nodes) {
|
|
5648
|
+
if (node.type === "jinjaIfBlock") return true;
|
|
5649
|
+
if ("content" in node && Array.isArray(node.content)) {
|
|
5650
|
+
if (hasJinjaBlock(node.content)) return true;
|
|
5651
|
+
}
|
|
5652
|
+
}
|
|
5653
|
+
return false;
|
|
5654
|
+
}
|
|
5655
|
+
return !hasJinjaBlock(doc2.content);
|
|
5656
|
+
}
|
|
5643
5657
|
var ActionbookConversionError = class extends Error {
|
|
5644
5658
|
constructor(message) {
|
|
5645
5659
|
super(message);
|
|
@@ -5669,6 +5683,9 @@ function actionbookToAST(manual) {
|
|
|
5669
5683
|
if (errors2.length > 0) {
|
|
5670
5684
|
throw new ActionbookConversionError(`Schema validation failed: ${errors2[0].message}`);
|
|
5671
5685
|
}
|
|
5686
|
+
if (v2.instruction && needsJinjaReparse(doc3, v2.instruction)) {
|
|
5687
|
+
return parseMarkdown(v2.instruction, { jinjaNodes: true });
|
|
5688
|
+
}
|
|
5672
5689
|
return doc3;
|
|
5673
5690
|
}
|
|
5674
5691
|
const doc2 = fromProseMirrorJSON(obj);
|
|
@@ -5676,10 +5693,13 @@ function actionbookToAST(manual) {
|
|
|
5676
5693
|
if (errors.length > 0) {
|
|
5677
5694
|
throw new ActionbookConversionError(`Schema validation after PM conversion failed: ${errors[0].message}`);
|
|
5678
5695
|
}
|
|
5696
|
+
if (v2.instruction && needsJinjaReparse(doc2, v2.instruction)) {
|
|
5697
|
+
return parseMarkdown(v2.instruction, { jinjaNodes: true });
|
|
5698
|
+
}
|
|
5679
5699
|
return doc2;
|
|
5680
5700
|
}
|
|
5681
5701
|
if (v2.instruction) {
|
|
5682
|
-
return parseMarkdown(v2.instruction);
|
|
5702
|
+
return parseMarkdown(v2.instruction, { jinjaNodes: true });
|
|
5683
5703
|
}
|
|
5684
5704
|
return EMPTY_DOC;
|
|
5685
5705
|
}
|