markdown-flow-ui 0.2.35 → 0.3.0-dev.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/README.md +12 -0
- package/dist/_virtual/index.es10.js +2 -2
- package/dist/_virtual/index.es3.js +5 -4
- package/dist/_virtual/index.es3.js.map +1 -1
- package/dist/_virtual/index.es4.js +4 -5
- package/dist/_virtual/index.es4.js.map +1 -1
- package/dist/_virtual/index.es5.js +5 -5
- package/dist/_virtual/index.es6.js +5 -3
- package/dist/_virtual/index.es6.js.map +1 -1
- package/dist/_virtual/index.es7.js +3 -5
- package/dist/_virtual/index.es7.js.map +1 -1
- package/dist/_virtual/index.es8.js +2 -2
- package/dist/_virtual/index10.cjs +1 -1
- package/dist/_virtual/index3.cjs +1 -1
- package/dist/_virtual/index4.cjs +1 -1
- package/dist/_virtual/index5.cjs +1 -1
- package/dist/_virtual/index6.cjs +1 -1
- package/dist/_virtual/index7.cjs +1 -1
- package/dist/_virtual/index8.cjs +1 -1
- package/dist/_virtual/variable-marker.cjs +2 -0
- package/dist/_virtual/variable-marker.cjs.map +1 -0
- package/dist/_virtual/variable-marker.es.js +5 -0
- package/dist/_virtual/variable-marker.es.js.map +1 -0
- package/dist/_virtual/variable-name.cjs +2 -0
- package/dist/_virtual/variable-name.cjs.map +1 -0
- package/dist/_virtual/variable-name.es.js +5 -0
- package/dist/_virtual/variable-name.es.js.map +1 -0
- package/dist/components/ContentRender/ContentRender.cjs +2 -2
- package/dist/components/ContentRender/ContentRender.cjs.map +1 -1
- package/dist/components/ContentRender/ContentRender.es.js +206 -205
- package/dist/components/ContentRender/ContentRender.es.js.map +1 -1
- package/dist/components/ContentRender/plugins/CustomVariable.cjs +1 -1
- package/dist/components/ContentRender/plugins/CustomVariable.cjs.map +1 -1
- package/dist/components/ContentRender/plugins/CustomVariable.es.js +52 -51
- package/dist/components/ContentRender/plugins/CustomVariable.es.js.map +1 -1
- package/dist/components/ContentRender/utils/inline-code-ranges.cjs +9 -9
- package/dist/components/ContentRender/utils/inline-code-ranges.cjs.map +1 -1
- package/dist/components/ContentRender/utils/inline-code-ranges.d.ts +3 -0
- package/dist/components/ContentRender/utils/inline-code-ranges.es.js +185 -161
- package/dist/components/ContentRender/utils/inline-code-ranges.es.js.map +1 -1
- package/dist/components/ContentRender/utils/mermaid-parse.cjs +4 -4
- package/dist/components/ContentRender/utils/mermaid-parse.cjs.map +1 -1
- package/dist/components/ContentRender/utils/mermaid-parse.es.js +53 -48
- package/dist/components/ContentRender/utils/mermaid-parse.es.js.map +1 -1
- package/dist/components/ContentRender/utils/split-content.cjs +6 -6
- package/dist/components/ContentRender/utils/split-content.cjs.map +1 -1
- package/dist/components/ContentRender/utils/split-content.d.ts +1 -0
- package/dist/components/ContentRender/utils/split-content.es.js +361 -313
- package/dist/components/ContentRender/utils/split-content.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.cjs.map +1 -1
- package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.es.js +286 -290
- package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/components/VariableSelect.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/components/VariableSelect.cjs.map +1 -1
- package/dist/components/MarkdownFlowEditor/components/VariableSelect.es.js +62 -63
- package/dist/components/MarkdownFlowEditor/components/VariableSelect.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/locales/ar-SA.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/ar-SA.json.d.ts +1 -1
- package/dist/components/MarkdownFlowEditor/locales/ar-SA.json.es.js +1 -1
- package/dist/components/MarkdownFlowEditor/locales/de-DE.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/de-DE.json.d.ts +1 -1
- package/dist/components/MarkdownFlowEditor/locales/de-DE.json.es.js +13 -13
- package/dist/components/MarkdownFlowEditor/locales/en-US.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/en-US.json.d.ts +1 -1
- package/dist/components/MarkdownFlowEditor/locales/en-US.json.es.js +19 -19
- package/dist/components/MarkdownFlowEditor/locales/es-ES.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/es-ES.json.d.ts +1 -1
- package/dist/components/MarkdownFlowEditor/locales/es-ES.json.es.js +13 -13
- package/dist/components/MarkdownFlowEditor/locales/fil-PH.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/fil-PH.json.d.ts +1 -1
- package/dist/components/MarkdownFlowEditor/locales/fil-PH.json.es.js +16 -16
- package/dist/components/MarkdownFlowEditor/locales/fr-FR.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/fr-FR.json.d.ts +1 -1
- package/dist/components/MarkdownFlowEditor/locales/fr-FR.json.es.js +13 -13
- package/dist/components/MarkdownFlowEditor/locales/ja-JP.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/ja-JP.json.d.ts +1 -1
- package/dist/components/MarkdownFlowEditor/locales/ja-JP.json.es.js +1 -1
- package/dist/components/MarkdownFlowEditor/locales/th-TH.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/th-TH.json.d.ts +1 -1
- package/dist/components/MarkdownFlowEditor/locales/th-TH.json.es.js +1 -1
- package/dist/components/MarkdownFlowEditor/locales/ur-PK.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/ur-PK.json.d.ts +1 -1
- package/dist/components/MarkdownFlowEditor/locales/ur-PK.json.es.js +1 -1
- package/dist/components/MarkdownFlowEditor/locales/vi-VN.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/vi-VN.json.d.ts +1 -1
- package/dist/components/MarkdownFlowEditor/locales/vi-VN.json.es.js +13 -13
- package/dist/components/MarkdownFlowEditor/locales/zh-CN.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/zh-CN.json.d.ts +1 -1
- package/dist/components/MarkdownFlowEditor/locales/zh-CN.json.es.js +1 -1
- package/dist/components/MarkdownFlowEditor/plugins/SyntaxHighlighter.cjs +3 -3
- package/dist/components/MarkdownFlowEditor/plugins/SyntaxHighlighter.cjs.map +1 -1
- package/dist/components/MarkdownFlowEditor/plugins/SyntaxHighlighter.es.js +176 -174
- package/dist/components/MarkdownFlowEditor/plugins/SyntaxHighlighter.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/plugins/VariablePlaceholder.cjs +2 -1
- package/dist/components/MarkdownFlowEditor/plugins/VariablePlaceholder.cjs.map +1 -1
- package/dist/components/MarkdownFlowEditor/plugins/VariablePlaceholder.d.ts +3 -1
- package/dist/components/MarkdownFlowEditor/plugins/VariablePlaceholder.es.js +38 -55
- package/dist/components/MarkdownFlowEditor/plugins/VariablePlaceholder.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/plugins/VariablePlaceholder.test.d.ts +1 -0
- package/dist/components/MarkdownFlowEditor/utils.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/utils.cjs.map +1 -1
- package/dist/components/MarkdownFlowEditor/utils.d.ts +2 -3
- package/dist/components/MarkdownFlowEditor/utils.es.js +47 -51
- package/dist/components/MarkdownFlowEditor/utils.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/utils.variables.test.d.ts +1 -0
- package/dist/components/ui/inputGroup/textarea.cjs +1 -1
- package/dist/components/ui/inputGroup/textarea.es.js +1 -1
- package/dist/lib/interaction-defaults.cjs +1 -1
- package/dist/lib/interaction-defaults.cjs.map +1 -1
- package/dist/lib/interaction-defaults.es.js +123 -132
- package/dist/lib/interaction-defaults.es.js.map +1 -1
- package/dist/lib/interaction-defaults.failure.test.d.ts +1 -0
- package/dist/node_modules/@braintree/sanitize-url/dist/index.cjs +1 -1
- package/dist/node_modules/@braintree/sanitize-url/dist/index.es.js +1 -1
- package/dist/node_modules/classnames/index.cjs +1 -1
- package/dist/node_modules/classnames/index.es.js +1 -1
- package/dist/node_modules/cose-base/cose-base.cjs +1 -1
- package/dist/node_modules/cose-base/cose-base.cjs.map +1 -1
- package/dist/node_modules/cose-base/cose-base.es.js +1 -1
- package/dist/node_modules/cytoscape-fcose/node_modules/cose-base/cose-base.cjs +1 -1
- package/dist/node_modules/cytoscape-fcose/node_modules/cose-base/cose-base.cjs.map +1 -1
- package/dist/node_modules/cytoscape-fcose/node_modules/cose-base/cose-base.es.js +1 -1
- package/dist/node_modules/cytoscape-fcose/node_modules/layout-base/layout-base.cjs +1 -1
- package/dist/node_modules/cytoscape-fcose/node_modules/layout-base/layout-base.cjs.map +1 -1
- package/dist/node_modules/cytoscape-fcose/node_modules/layout-base/layout-base.es.js +1 -1
- package/dist/node_modules/hast-util-to-jsx-runtime/lib/index.cjs +1 -1
- package/dist/node_modules/hast-util-to-jsx-runtime/lib/index.es.js +1 -1
- package/dist/node_modules/layout-base/layout-base.cjs +1 -1
- package/dist/node_modules/layout-base/layout-base.cjs.map +1 -1
- package/dist/node_modules/layout-base/layout-base.es.js +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-AAMF2YG6.cjs +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-AAMF2YG6.es.js +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-OMD6QJNC.cjs +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-OMD6QJNC.es.js +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-U37J5Y7L.cjs +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-U37J5Y7L.es.js +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-WV7ZQ7D5.cjs +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-WV7ZQ7D5.es.js +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-4MX5Z3NR.cjs +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-4MX5Z3NR.es.js +1 -1
- package/dist/node_modules/rc-input/es/BaseInput.cjs +1 -1
- package/dist/node_modules/rc-input/es/BaseInput.es.js +1 -1
- package/dist/node_modules/rc-textarea/es/ResizableTextArea.cjs +1 -1
- package/dist/node_modules/rc-textarea/es/ResizableTextArea.es.js +1 -1
- package/dist/node_modules/rc-textarea/es/TextArea.cjs +1 -1
- package/dist/node_modules/rc-textarea/es/TextArea.es.js +1 -1
- package/dist/node_modules/rc-textarea/es/index.cjs +1 -1
- package/dist/node_modules/rc-textarea/es/index.es.js +1 -1
- package/dist/node_modules/remark-flow/dist/escaping.cjs +2 -2
- package/dist/node_modules/remark-flow/dist/escaping.cjs.map +1 -1
- package/dist/node_modules/remark-flow/dist/escaping.es.js +128 -63
- package/dist/node_modules/remark-flow/dist/escaping.es.js.map +1 -1
- package/dist/node_modules/remark-flow/dist/index.cjs +1 -1
- package/dist/node_modules/remark-flow/dist/index.cjs.map +1 -1
- package/dist/node_modules/remark-flow/dist/index.es.js +62 -33
- package/dist/node_modules/remark-flow/dist/index.es.js.map +1 -1
- package/dist/node_modules/remark-flow/dist/interaction-parser.cjs +1 -1
- package/dist/node_modules/remark-flow/dist/interaction-parser.cjs.map +1 -1
- package/dist/node_modules/remark-flow/dist/interaction-parser.es.js +260 -256
- package/dist/node_modules/remark-flow/dist/interaction-parser.es.js.map +1 -1
- package/dist/node_modules/remark-flow/dist/interaction-plugin-core.cjs +1 -1
- package/dist/node_modules/remark-flow/dist/interaction-plugin-core.cjs.map +1 -1
- package/dist/node_modules/remark-flow/dist/interaction-plugin-core.es.js +71 -42
- package/dist/node_modules/remark-flow/dist/interaction-plugin-core.es.js.map +1 -1
- package/dist/node_modules/remark-flow/dist/interaction-syntax.cjs +1 -1
- package/dist/node_modules/remark-flow/dist/interaction-syntax.cjs.map +1 -1
- package/dist/node_modules/remark-flow/dist/interaction-syntax.es.js +500 -46
- package/dist/node_modules/remark-flow/dist/interaction-syntax.es.js.map +1 -1
- package/dist/node_modules/remark-flow/dist/variable-marker.cjs +2 -0
- package/dist/node_modules/remark-flow/dist/variable-marker.cjs.map +1 -0
- package/dist/node_modules/remark-flow/dist/variable-marker.es.js +77 -0
- package/dist/node_modules/remark-flow/dist/variable-marker.es.js.map +1 -0
- package/dist/node_modules/remark-flow/dist/variable-name.cjs +15 -0
- package/dist/node_modules/remark-flow/dist/variable-name.cjs.map +1 -0
- package/dist/node_modules/remark-flow/dist/variable-name.es.js +748 -0
- package/dist/node_modules/remark-flow/dist/variable-name.es.js.map +1 -0
- package/dist/node_modules/style-to-object/cjs/index.cjs +1 -1
- package/dist/node_modules/style-to-object/cjs/index.cjs.map +1 -1
- package/dist/node_modules/style-to-object/cjs/index.es.js +1 -1
- package/dist/node_modules/unified/lib/index.cjs +1 -1
- package/dist/node_modules/unified/lib/index.es.js +1 -1
- package/package.json +2 -2
|
@@ -1,70 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SelectedOption as
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
const
|
|
6
|
-
const t =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
for (; (r = n.exec(t)) !== null; ) {
|
|
11
|
-
const o = r.index ?? 0, i = o + r[0].length;
|
|
12
|
-
if (d(e, o, i))
|
|
13
|
-
return !0;
|
|
14
|
-
n.lastIndex === r.index && n.lastIndex++;
|
|
15
|
-
}
|
|
16
|
-
return !1;
|
|
17
|
-
}, d = (e, t, n) => {
|
|
18
|
-
const r = t + 2, o = n - 2;
|
|
19
|
-
return o < r ? !1 : e.state.selection.ranges.some((i) => {
|
|
20
|
-
const h = i.anchor >= r && i.anchor <= o, p = i.head >= r && i.head <= o;
|
|
21
|
-
return h || p;
|
|
1
|
+
import { ViewPlugin as g, EditorView as u, Decoration as o } from "../../../node_modules/@codemirror/view/dist/index.es.js";
|
|
2
|
+
import { SelectedOption as m } from "../types.es.js";
|
|
3
|
+
import p from "./PlaceholderWidget.es.js";
|
|
4
|
+
import { d as a } from "../../../_virtual/index.es.js";
|
|
5
|
+
const d = (e, s, r) => {
|
|
6
|
+
const t = s + 2, n = r - 2;
|
|
7
|
+
return n < t ? !1 : e.state.selection.ranges.some((i) => {
|
|
8
|
+
const h = i.anchor >= t && i.anchor <= n, f = i.head >= t && i.head <= n;
|
|
9
|
+
return h || f;
|
|
22
10
|
});
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return null
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
t
|
|
40
|
-
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
}
|
|
11
|
+
}, c = (e, s) => {
|
|
12
|
+
const r = e.state.doc.toString();
|
|
13
|
+
return o.set(
|
|
14
|
+
s.flatMap((t) => {
|
|
15
|
+
const n = r.slice(t.start, t.end);
|
|
16
|
+
return t.name === null || // CodeMirror inline widgets cannot replace line breaks in marker padding.
|
|
17
|
+
n.includes(`
|
|
18
|
+
`) || d(e, t.start, t.end) ? [] : [
|
|
19
|
+
o.replace({
|
|
20
|
+
widget: new p(
|
|
21
|
+
n,
|
|
22
|
+
{ tag: "variable", title: t.name },
|
|
23
|
+
"tag-variable",
|
|
24
|
+
m.Variable,
|
|
25
|
+
e
|
|
26
|
+
)
|
|
27
|
+
}).range(t.start, t.end)
|
|
28
|
+
];
|
|
29
|
+
})
|
|
30
|
+
);
|
|
31
|
+
}, l = (e, s) => s.filter(
|
|
32
|
+
(r) => d(e, r.start, r.end)
|
|
33
|
+
).map((r) => r.start).join(","), x = g.fromClass(
|
|
44
34
|
class {
|
|
45
35
|
constructor(e) {
|
|
46
|
-
this.
|
|
36
|
+
this.markers = a.findDocumentVariableMarkers(e.state.doc.toString()), this.selectionSignature = l(e, this.markers), this.placeholders = c(e, this.markers);
|
|
47
37
|
}
|
|
48
38
|
update(e) {
|
|
49
|
-
if (e.
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
this.selectionInsideVariable = t, this.placeholders = s.createDeco(e.view);
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
39
|
+
if (e.docChanged && (this.markers = a.findDocumentVariableMarkers(e.state.doc.toString())), e.docChanged || e.selectionSet) {
|
|
40
|
+
const s = l(e.view, this.markers);
|
|
41
|
+
(e.docChanged || s !== this.selectionSignature) && (this.selectionSignature = s, this.placeholders = c(e.view, this.markers));
|
|
55
42
|
}
|
|
56
|
-
this.placeholders = s.updateDeco(
|
|
57
|
-
e,
|
|
58
|
-
this.placeholders
|
|
59
|
-
);
|
|
60
43
|
}
|
|
61
44
|
},
|
|
62
45
|
{
|
|
63
46
|
decorations: (e) => e.placeholders,
|
|
64
|
-
provide: (e) =>
|
|
47
|
+
provide: (e) => u.atomicRanges.of((s) => s.plugin(e)?.placeholders || o.none)
|
|
65
48
|
}
|
|
66
49
|
);
|
|
67
50
|
export {
|
|
68
|
-
|
|
51
|
+
x as default
|
|
69
52
|
};
|
|
70
53
|
//# sourceMappingURL=VariablePlaceholder.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VariablePlaceholder.es.js","sources":["../../../../src/components/MarkdownFlowEditor/plugins/VariablePlaceholder.ts"],"sourcesContent":["import {\n EditorView,\n Decoration,\n DecorationSet,\n ViewPlugin,\n ViewUpdate,\n
|
|
1
|
+
{"version":3,"file":"VariablePlaceholder.es.js","sources":["../../../../src/components/MarkdownFlowEditor/plugins/VariablePlaceholder.ts"],"sourcesContent":["import {\n EditorView,\n Decoration,\n DecorationSet,\n ViewPlugin,\n ViewUpdate,\n} from \"@codemirror/view\";\nimport { SelectedOption } from \"../types\";\nimport PlaceholderWidget from \"./PlaceholderWidget\";\nimport { findDocumentVariableMarkers } from \"../utils\";\n\nconst selectionInsideVariableExpression = (\n view: EditorView,\n from: number,\n to: number\n) => {\n const innerStart = from + 2;\n const innerEnd = to - 2;\n if (innerEnd < innerStart) {\n return false;\n }\n return view.state.selection.ranges.some((range) => {\n const isAnchorInside =\n range.anchor >= innerStart && range.anchor <= innerEnd;\n const isHeadInside = range.head >= innerStart && range.head <= innerEnd;\n return isAnchorInside || isHeadInside;\n });\n};\n\nconst buildPlaceholders = (\n view: EditorView,\n markers: ReturnType<typeof findDocumentVariableMarkers>\n): DecorationSet => {\n const text = view.state.doc.toString();\n return Decoration.set(\n markers.flatMap((marker) => {\n const rawMarker = text.slice(marker.start, marker.end);\n if (\n marker.name === null ||\n // CodeMirror inline widgets cannot replace line breaks in marker padding.\n rawMarker.includes(\"\\n\") ||\n selectionInsideVariableExpression(view, marker.start, marker.end)\n ) {\n return [];\n }\n return [\n Decoration.replace({\n widget: new PlaceholderWidget(\n rawMarker,\n { tag: \"variable\", title: marker.name },\n \"tag-variable\",\n SelectedOption.Variable,\n view\n ),\n }).range(marker.start, marker.end),\n ];\n })\n );\n};\n\nconst selectedMarkers = (\n view: EditorView,\n markers: ReturnType<typeof findDocumentVariableMarkers>\n) =>\n markers\n .filter((marker) =>\n selectionInsideVariableExpression(view, marker.start, marker.end)\n )\n .map((marker) => marker.start)\n .join(\",\");\n\nconst VariablePlaceholder = ViewPlugin.fromClass(\n class {\n placeholders: DecorationSet;\n markers: ReturnType<typeof findDocumentVariableMarkers>;\n selectionSignature: string;\n constructor(view: EditorView) {\n this.markers = findDocumentVariableMarkers(view.state.doc.toString());\n this.selectionSignature = selectedMarkers(view, this.markers);\n this.placeholders = buildPlaceholders(view, this.markers);\n }\n update(update: ViewUpdate) {\n if (update.docChanged)\n this.markers = findDocumentVariableMarkers(update.state.doc.toString());\n if (update.docChanged || update.selectionSet) {\n const signature = selectedMarkers(update.view, this.markers);\n if (update.docChanged || signature !== this.selectionSignature) {\n this.selectionSignature = signature;\n this.placeholders = buildPlaceholders(update.view, this.markers);\n }\n }\n }\n },\n {\n decorations: (instance) => instance.placeholders,\n provide: (plugin) =>\n EditorView.atomicRanges.of((view) => {\n return view.plugin(plugin)?.placeholders || Decoration.none;\n }),\n }\n);\n\nexport default VariablePlaceholder;\n"],"names":["selectionInsideVariableExpression","view","from","to","innerStart","innerEnd","range","isAnchorInside","isHeadInside","buildPlaceholders","markers","text","Decoration","marker","rawMarker","PlaceholderWidget","SelectedOption","selectedMarkers","VariablePlaceholder","ViewPlugin","findDocumentVariableMarkers","update","signature","instance","plugin","EditorView"],"mappings":";;;;AAWA,MAAMA,IAAoC,CACxCC,GACAC,GACAC,MACG;AACH,QAAMC,IAAaF,IAAO,GACpBG,IAAWF,IAAK;AACtB,SAAIE,IAAWD,IACN,KAEFH,EAAK,MAAM,UAAU,OAAO,KAAK,CAACK,MAAU;AACjD,UAAMC,IACJD,EAAM,UAAUF,KAAcE,EAAM,UAAUD,GAC1CG,IAAeF,EAAM,QAAQF,KAAcE,EAAM,QAAQD;AAC/D,WAAOE,KAAkBC;AAAA,EAC3B,CAAC;AACH,GAEMC,IAAoB,CACxBR,GACAS,MACkB;AAClB,QAAMC,IAAOV,EAAK,MAAM,IAAI,SAAA;AAC5B,SAAOW,EAAW;AAAA,IAChBF,EAAQ,QAAQ,CAACG,MAAW;AAC1B,YAAMC,IAAYH,EAAK,MAAME,EAAO,OAAOA,EAAO,GAAG;AACrD,aACEA,EAAO,SAAS;AAAA,MAEhBC,EAAU,SAAS;AAAA,CAAI,KACvBd,EAAkCC,GAAMY,EAAO,OAAOA,EAAO,GAAG,IAEzD,CAAA,IAEF;AAAA,QACLD,EAAW,QAAQ;AAAA,UACjB,QAAQ,IAAIG;AAAA,YACVD;AAAA,YACA,EAAE,KAAK,YAAY,OAAOD,EAAO,KAAA;AAAA,YACjC;AAAA,YACAG,EAAe;AAAA,YACff;AAAA,UAAA;AAAA,QACF,CACD,EAAE,MAAMY,EAAO,OAAOA,EAAO,GAAG;AAAA,MAAA;AAAA,IAErC,CAAC;AAAA,EAAA;AAEL,GAEMI,IAAkB,CACtBhB,GACAS,MAEAA,EACG;AAAA,EAAO,CAACG,MACPb,EAAkCC,GAAMY,EAAO,OAAOA,EAAO,GAAG;AAClE,EACC,IAAI,CAACA,MAAWA,EAAO,KAAK,EAC5B,KAAK,GAAG,GAEPK,IAAsBC,EAAW;AAAA,EACrC,MAAM;AAAA,IAIJ,YAAYlB,GAAkB;AAC5B,WAAK,UAAUmB,8BAA4BnB,EAAK,MAAM,IAAI,UAAU,GACpE,KAAK,qBAAqBgB,EAAgBhB,GAAM,KAAK,OAAO,GAC5D,KAAK,eAAeQ,EAAkBR,GAAM,KAAK,OAAO;AAAA,IAC1D;AAAA,IACA,OAAOoB,GAAoB;AAGzB,UAFIA,EAAO,eACT,KAAK,UAAUD,8BAA4BC,EAAO,MAAM,IAAI,UAAU,IACpEA,EAAO,cAAcA,EAAO,cAAc;AAC5C,cAAMC,IAAYL,EAAgBI,EAAO,MAAM,KAAK,OAAO;AAC3D,SAAIA,EAAO,cAAcC,MAAc,KAAK,wBAC1C,KAAK,qBAAqBA,GAC1B,KAAK,eAAeb,EAAkBY,EAAO,MAAM,KAAK,OAAO;AAAA,MAEnE;AAAA,IACF;AAAA,EAAA;AAAA,EAEF;AAAA,IACE,aAAa,CAACE,MAAaA,EAAS;AAAA,IACpC,SAAS,CAACC,MACRC,EAAW,aAAa,GAAG,CAACxB,MACnBA,EAAK,OAAOuB,CAAM,GAAG,gBAAgBZ,EAAW,IACxD;AAAA,EAAA;AAEP;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./types.cjs"),g=require("./utils/video.cjs"),d=require("../../_virtual/index.cjs"),s="===",$=(t,e)=>{switch(t){case m.SelectedOption.Image:return{resourceUrl:e.url,resourceTitle:e.title,scalePercent:e.scalePercent};case m.SelectedOption.Video:return{resourceUrl:e.url,resourceTitle:e.title};case m.SelectedOption.Variable:return{variableName:d.distExports.normalizeVariableName(e.title??"")??void 0};default:return{resourceUrl:e.url??"",resourceTitle:e.title??""}}};function V(t,e){return i=>{const a=i.matchBefore(/\/(\w*)$/);if(!a)return null;const c=(r,n,o,l,u)=>{r.dispatch({changes:{from:o,to:l,insert:""}}),t(u)};return{from:a.from,to:a.to,options:[{label:e?.variable??"Variable",apply:(r,n,o,l)=>{c(r,n,o,l,m.SelectedOption.Variable)}},{label:e?.image??"Image",apply:(r,n,o,l)=>{c(r,n,o,l,m.SelectedOption.Image)}},{label:e?.video??"Video",apply:(r,n,o,l)=>{c(r,n,o,l,m.SelectedOption.Video)}}],filter:!1}}}const f=t=>g.getVideoEmbedUrl(t),p=t=>t.replace(/&/g,"&").replace(/"/g,"""),w=t=>t.replace(/([\[\]\\])/g,"\\$1"),h=t=>Math.max(1,Math.min(1e3,Math.round(t))),b=t=>{const e=t.trim();return e?new RegExp(`^${s}\\s*[\\s\\S]*?\\s*${s}$`).test(e)?e:`${s} ${e} ${s}`:`${s}${s}`},x=t=>{const e=t.trim(),i=new RegExp(`^${s}\\s*([\\s\\S]*?)\\s*${s}$`);return(e.match(i)?.[1]??e).trim()},E=({resourceUrl:t,resourceTitle:e,scalePercent:i})=>{const a=typeof i=="number"?h(i):void 0,c=p(t),r=e?p(e):void 0,n=e?w(e):"",o=typeof a=="number"&&a!==100?` width="${a}%"`:"",l=r?` alt="${r}" title="${r}"`:"",u=!a||a===100?``:`<img src="${c}"${l}${o} />`;return b(u)},S=(t,e)=>{const i=f(t),a=e?p(e):"",c=p(t),r=p(i),n=`<iframe data-tag="video" data-title="${a}" data-url="${c}" class="w-full aspect-video rounded-lg border-0" src="${r}" allowfullscreen="" allow="autoplay; encrypted-media"></iframe>`;return b(n)};exports.createSlashCommands=V;exports.extractVariableNames=d.distExports.extractVariableNames;exports.findDocumentVariableMarkers=d.distExports.findDocumentVariableMarkers;exports.findVariableMarkers=d.distExports.findVariableMarkers;exports.formatVariableReference=d.distExports.formatVariableReference;exports.getEmbedUrl=f;exports.getImageContentToInsert=E;exports.getVideoContentToInsert=S;exports.normalizeVariableName=d.distExports.normalizeVariableName;exports.parseContentInfo=$;exports.trimVariablePadding=d.distExports.trimVariablePadding;exports.unwrapFixedOutput=x;exports.wrapWithFixedOutput=b;
|
|
2
2
|
//# sourceMappingURL=utils.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","sources":["../../../src/components/MarkdownFlowEditor/utils.ts"],"sourcesContent":["import {\n type CompletionContext,\n type CompletionResult,\n} from \"@codemirror/autocomplete\";\nimport { EditorView } from \"@codemirror/view\";\nimport { SelectedOption } from \"./types\";\nimport { getVideoEmbedUrl } from \"./utils/video\";\n\nconst VARIABLE_NAME_SOURCE = \"[\\\\p{L}\\\\p{N}_]+\";\nconst VARIABLE_NAME_REGEXP = new RegExp(`^${VARIABLE_NAME_SOURCE}$`, \"u\");\nconst VARIABLE_EXPRESSION_PATTERN = `\\\\{\\\\{(${VARIABLE_NAME_SOURCE})\\\\}\\\\}`;\nconst FIXED_OUTPUT_MARKER = \"===\";\n\nconst createVariableExpressionRegexp = () =>\n new RegExp(VARIABLE_EXPRESSION_PATTERN, \"gu\");\n\nconst isValidVariableName = (name: string) =>\n typeof name === \"string\" && VARIABLE_NAME_REGEXP.test(name);\n\nconst extractVariableNames = (content: string) => {\n if (!content) {\n return [];\n }\n const matches: string[] = [];\n const regexp = createVariableExpressionRegexp();\n let match: RegExpExecArray | null;\n\n while ((match = regexp.exec(content)) !== null) {\n matches.push(match[1]);\n }\n\n return matches;\n};\n\nconst parseContentInfo = (\n type: SelectedOption,\n dataset: { title?: string; url?: string; scalePercent?: number }\n) => {\n switch (type) {\n case SelectedOption.Image:\n return {\n resourceUrl: dataset.url,\n resourceTitle: dataset.title,\n scalePercent: dataset.scalePercent,\n };\n\n case SelectedOption.Video:\n return {\n resourceUrl: dataset.url,\n resourceTitle: dataset.title,\n };\n case SelectedOption.Variable:\n return {\n variableName: dataset.title,\n };\n default:\n return {\n resourceUrl: dataset.url ?? \"\",\n resourceTitle: dataset.title ?? \"\",\n };\n }\n};\n\nfunction createSlashCommands(\n onSelectOption: (selectedOption: SelectedOption) => void,\n labels?: {\n divider?: string;\n fixedText?: string;\n image?: string;\n video?: string;\n variable?: string;\n }\n) {\n return (context: CompletionContext): CompletionResult | null => {\n const word = context.matchBefore(/\\/(\\w*)$/);\n if (!word) return null;\n\n const handleSelect = (\n view: EditorView,\n _: any,\n from: number,\n to: number,\n selectedOption: SelectedOption\n ) => {\n view.dispatch({\n changes: { from, to, insert: \"\" },\n });\n onSelectOption(selectedOption);\n };\n\n return {\n from: word.from,\n to: word.to,\n options: [\n // {\n // label: labels?.divider ?? \"Divider\",\n // apply: (view, _, from, to) => {\n // handleSelect(view, _, from, to, SelectedOption.Divider);\n // },\n // },\n // {\n // label: labels?.fixedText ?? \"Fixed Text\",\n // apply: (view, _, from, to) => {\n // handleSelect(view, _, from, to, SelectedOption.FixedText);\n // },\n // },\n {\n label: labels?.variable ?? \"Variable\",\n apply: (view, _, from, to) => {\n handleSelect(view, _, from, to, SelectedOption.Variable);\n },\n },\n {\n label: labels?.image ?? \"Image\",\n apply: (view, _, from, to) => {\n handleSelect(view, _, from, to, SelectedOption.Image);\n },\n },\n {\n label: labels?.video ?? \"Video\",\n apply: (view, _, from, to) => {\n handleSelect(view, _, from, to, SelectedOption.Video);\n },\n },\n ],\n filter: false,\n };\n };\n}\n\nconst getEmbedUrl = (url: string) => {\n return getVideoEmbedUrl(url);\n};\n\nconst escapeHtmlAttribute = (value: string) =>\n value.replace(/&/g, \"&\").replace(/\"/g, \""\");\n\nconst escapeMarkdownText = (text: string) =>\n text.replace(/([\\[\\]\\\\])/g, \"\\\\$1\");\n\nconst clampScalePercent = (value: number) =>\n Math.max(1, Math.min(1000, Math.round(value)));\n\nconst wrapWithFixedOutput = (content: string) => {\n const normalizedContent = content.trim();\n if (!normalizedContent) {\n return `${FIXED_OUTPUT_MARKER}${FIXED_OUTPUT_MARKER}`;\n }\n const wrappedPattern = new RegExp(\n `^${FIXED_OUTPUT_MARKER}\\\\s*[\\\\s\\\\S]*?\\\\s*${FIXED_OUTPUT_MARKER}$`\n );\n if (wrappedPattern.test(normalizedContent)) {\n return normalizedContent;\n }\n return `${FIXED_OUTPUT_MARKER} ${normalizedContent} ${FIXED_OUTPUT_MARKER}`;\n};\n\nconst unwrapFixedOutput = (content: string) => {\n const normalizedContent = content.trim();\n const wrappedPattern = new RegExp(\n `^${FIXED_OUTPUT_MARKER}\\\\s*([\\\\s\\\\S]*?)\\\\s*${FIXED_OUTPUT_MARKER}$`\n );\n const match = normalizedContent.match(wrappedPattern);\n return (match?.[1] ?? normalizedContent).trim();\n};\n\nconst getImageContentToInsert = ({\n resourceUrl,\n resourceTitle,\n scalePercent,\n}: {\n resourceUrl: string;\n resourceTitle?: string;\n scalePercent?: number;\n}) => {\n const clampedScale =\n typeof scalePercent === \"number\"\n ? clampScalePercent(scalePercent)\n : undefined;\n const sanitizedHtmlUrl = escapeHtmlAttribute(resourceUrl);\n const sanitizedTitle = resourceTitle\n ? escapeHtmlAttribute(resourceTitle)\n : undefined;\n const markdownTitle = resourceTitle ? escapeMarkdownText(resourceTitle) : \"\";\n const widthAttribute =\n typeof clampedScale === \"number\" && clampedScale !== 100\n ? ` width=\"${clampedScale}%\"`\n : \"\";\n const htmlTitleAttributes = sanitizedTitle\n ? ` alt=\"${sanitizedTitle}\" title=\"${sanitizedTitle}\"`\n : \"\";\n const imageMarkup =\n !clampedScale || clampedScale === 100\n ? ``\n : `<img src=\"${sanitizedHtmlUrl}\"${htmlTitleAttributes}${widthAttribute} />`;\n\n return wrapWithFixedOutput(imageMarkup);\n};\n\nconst getVideoContentToInsert = (\n resourceUrl: string,\n resourceTitle: string\n) => {\n const embedUrl = getEmbedUrl(resourceUrl);\n const sanitizedTitle = resourceTitle\n ? escapeHtmlAttribute(resourceTitle)\n : \"\";\n const sanitizedResourceUrl = escapeHtmlAttribute(resourceUrl);\n const sanitizedEmbedUrl = escapeHtmlAttribute(embedUrl);\n const videoMarkup = `<iframe data-tag=\"video\" data-title=\"${sanitizedTitle}\" data-url=\"${sanitizedResourceUrl}\" class=\"w-full aspect-video rounded-lg border-0\" src=\"${sanitizedEmbedUrl}\" allowfullscreen=\"\" allow=\"autoplay; encrypted-media\"></iframe>`;\n\n return wrapWithFixedOutput(videoMarkup);\n};\n\nexport {\n createSlashCommands,\n parseContentInfo,\n getEmbedUrl,\n getImageContentToInsert,\n getVideoContentToInsert,\n isValidVariableName,\n extractVariableNames,\n createVariableExpressionRegexp,\n wrapWithFixedOutput,\n unwrapFixedOutput,\n};\n"],"names":["VARIABLE_NAME_SOURCE","VARIABLE_NAME_REGEXP","VARIABLE_EXPRESSION_PATTERN","FIXED_OUTPUT_MARKER","createVariableExpressionRegexp","isValidVariableName","name","extractVariableNames","content","matches","regexp","match","parseContentInfo","type","dataset","SelectedOption","createSlashCommands","onSelectOption","labels","context","word","handleSelect","view","_","from","to","selectedOption","getEmbedUrl","url","getVideoEmbedUrl","escapeHtmlAttribute","value","escapeMarkdownText","text","clampScalePercent","wrapWithFixedOutput","normalizedContent","unwrapFixedOutput","wrappedPattern","getImageContentToInsert","resourceUrl","resourceTitle","scalePercent","clampedScale","sanitizedHtmlUrl","sanitizedTitle","markdownTitle","widthAttribute","htmlTitleAttributes","imageMarkup","getVideoContentToInsert","embedUrl","sanitizedResourceUrl","sanitizedEmbedUrl","videoMarkup"],"mappings":"8IAQMA,EAAuB,mBACvBC,EAAuB,IAAI,OAAO,IAAID,CAAoB,IAAK,GAAG,EAClEE,EAA8B,UAAUF,CAAoB,UAC5DG,EAAsB,MAEtBC,EAAiC,IACrC,IAAI,OAAOF,EAA6B,IAAI,EAExCG,EAAuBC,GAC3B,OAAOA,GAAS,UAAYL,EAAqB,KAAKK,CAAI,EAEtDC,EAAwB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YA,IAAiB,IACjD,WAAWA,CAAY,KACvB,GACAK,EAAsBH,EACxB,SAASA,CAAc,YAAYA,CAAc,IACjD,GACEI,EACJ,CAACN,GAAgBA,IAAiB,IAC9B,KAAKG,CAAa,KAAKN,CAAW,IAClC,aAAaI,CAAgB,IAAII,CAAmB,GAAGD,CAAc,MAE3E,OAAOZ,EAAoBc,CAAW,CACxC,EAEMC,EAA0B,CAC9BV,EACAC,IACG,CACH,MAAMU,EAAWxB,EAAYa,CAAW,EAClCK,EAAiBJ,EACnBX,EAAoBW,CAAa,EACjC,GACEW,EAAuBtB,EAAoBU,CAAW,EACtDa,EAAoBvB,EAAoBqB,CAAQ,EAChDG,EAAc,wCAAwCT,CAAc,eAAeO,CAAoB,0DAA0DC,CAAiB,mEAExL,OAAOlB,EAAoBmB,CAAW,CACxC"}
|
|
1
|
+
{"version":3,"file":"utils.cjs","sources":["../../../src/components/MarkdownFlowEditor/utils.ts"],"sourcesContent":["import {\n type CompletionContext,\n type CompletionResult,\n} from \"@codemirror/autocomplete\";\nimport { EditorView } from \"@codemirror/view\";\nimport { SelectedOption } from \"./types\";\nimport { getVideoEmbedUrl } from \"./utils/video\";\n\nimport {\n createVariableExpressionRegex,\n extractVariableNames,\n findVariableMarkers,\n findDocumentVariableMarkers,\n formatVariableReference,\n formatVariableAssignment,\n isValidVariableName,\n normalizeVariableName,\n trimVariablePadding,\n} from \"remark-flow\";\n\nconst FIXED_OUTPUT_MARKER = \"===\";\nconst createVariableExpressionRegexp = () =>\n createVariableExpressionRegex(\"gu\");\n\nconst parseContentInfo = (\n type: SelectedOption,\n dataset: { title?: string; url?: string; scalePercent?: number }\n) => {\n switch (type) {\n case SelectedOption.Image:\n return {\n resourceUrl: dataset.url,\n resourceTitle: dataset.title,\n scalePercent: dataset.scalePercent,\n };\n\n case SelectedOption.Video:\n return {\n resourceUrl: dataset.url,\n resourceTitle: dataset.title,\n };\n case SelectedOption.Variable:\n return {\n variableName: normalizeVariableName(dataset.title ?? \"\") ?? undefined,\n };\n default:\n return {\n resourceUrl: dataset.url ?? \"\",\n resourceTitle: dataset.title ?? \"\",\n };\n }\n};\n\nfunction createSlashCommands(\n onSelectOption: (selectedOption: SelectedOption) => void,\n labels?: {\n divider?: string;\n fixedText?: string;\n image?: string;\n video?: string;\n variable?: string;\n }\n) {\n return (context: CompletionContext): CompletionResult | null => {\n const word = context.matchBefore(/\\/(\\w*)$/);\n if (!word) return null;\n\n const handleSelect = (\n view: EditorView,\n _: any,\n from: number,\n to: number,\n selectedOption: SelectedOption\n ) => {\n view.dispatch({\n changes: { from, to, insert: \"\" },\n });\n onSelectOption(selectedOption);\n };\n\n return {\n from: word.from,\n to: word.to,\n options: [\n // {\n // label: labels?.divider ?? \"Divider\",\n // apply: (view, _, from, to) => {\n // handleSelect(view, _, from, to, SelectedOption.Divider);\n // },\n // },\n // {\n // label: labels?.fixedText ?? \"Fixed Text\",\n // apply: (view, _, from, to) => {\n // handleSelect(view, _, from, to, SelectedOption.FixedText);\n // },\n // },\n {\n label: labels?.variable ?? \"Variable\",\n apply: (view, _, from, to) => {\n handleSelect(view, _, from, to, SelectedOption.Variable);\n },\n },\n {\n label: labels?.image ?? \"Image\",\n apply: (view, _, from, to) => {\n handleSelect(view, _, from, to, SelectedOption.Image);\n },\n },\n {\n label: labels?.video ?? \"Video\",\n apply: (view, _, from, to) => {\n handleSelect(view, _, from, to, SelectedOption.Video);\n },\n },\n ],\n filter: false,\n };\n };\n}\n\nconst getEmbedUrl = (url: string) => {\n return getVideoEmbedUrl(url);\n};\n\nconst escapeHtmlAttribute = (value: string) =>\n value.replace(/&/g, \"&\").replace(/\"/g, \""\");\n\nconst escapeMarkdownText = (text: string) =>\n text.replace(/([\\[\\]\\\\])/g, \"\\\\$1\");\n\nconst clampScalePercent = (value: number) =>\n Math.max(1, Math.min(1000, Math.round(value)));\n\nconst wrapWithFixedOutput = (content: string) => {\n const normalizedContent = content.trim();\n if (!normalizedContent) {\n return `${FIXED_OUTPUT_MARKER}${FIXED_OUTPUT_MARKER}`;\n }\n const wrappedPattern = new RegExp(\n `^${FIXED_OUTPUT_MARKER}\\\\s*[\\\\s\\\\S]*?\\\\s*${FIXED_OUTPUT_MARKER}$`\n );\n if (wrappedPattern.test(normalizedContent)) {\n return normalizedContent;\n }\n return `${FIXED_OUTPUT_MARKER} ${normalizedContent} ${FIXED_OUTPUT_MARKER}`;\n};\n\nconst unwrapFixedOutput = (content: string) => {\n const normalizedContent = content.trim();\n const wrappedPattern = new RegExp(\n `^${FIXED_OUTPUT_MARKER}\\\\s*([\\\\s\\\\S]*?)\\\\s*${FIXED_OUTPUT_MARKER}$`\n );\n const match = normalizedContent.match(wrappedPattern);\n return (match?.[1] ?? normalizedContent).trim();\n};\n\nconst getImageContentToInsert = ({\n resourceUrl,\n resourceTitle,\n scalePercent,\n}: {\n resourceUrl: string;\n resourceTitle?: string;\n scalePercent?: number;\n}) => {\n const clampedScale =\n typeof scalePercent === \"number\"\n ? clampScalePercent(scalePercent)\n : undefined;\n const sanitizedHtmlUrl = escapeHtmlAttribute(resourceUrl);\n const sanitizedTitle = resourceTitle\n ? escapeHtmlAttribute(resourceTitle)\n : undefined;\n const markdownTitle = resourceTitle ? escapeMarkdownText(resourceTitle) : \"\";\n const widthAttribute =\n typeof clampedScale === \"number\" && clampedScale !== 100\n ? ` width=\"${clampedScale}%\"`\n : \"\";\n const htmlTitleAttributes = sanitizedTitle\n ? ` alt=\"${sanitizedTitle}\" title=\"${sanitizedTitle}\"`\n : \"\";\n const imageMarkup =\n !clampedScale || clampedScale === 100\n ? ``\n : `<img src=\"${sanitizedHtmlUrl}\"${htmlTitleAttributes}${widthAttribute} />`;\n\n return wrapWithFixedOutput(imageMarkup);\n};\n\nconst getVideoContentToInsert = (\n resourceUrl: string,\n resourceTitle: string\n) => {\n const embedUrl = getEmbedUrl(resourceUrl);\n const sanitizedTitle = resourceTitle\n ? escapeHtmlAttribute(resourceTitle)\n : \"\";\n const sanitizedResourceUrl = escapeHtmlAttribute(resourceUrl);\n const sanitizedEmbedUrl = escapeHtmlAttribute(embedUrl);\n const videoMarkup = `<iframe data-tag=\"video\" data-title=\"${sanitizedTitle}\" data-url=\"${sanitizedResourceUrl}\" class=\"w-full aspect-video rounded-lg border-0\" src=\"${sanitizedEmbedUrl}\" allowfullscreen=\"\" allow=\"autoplay; encrypted-media\"></iframe>`;\n\n return wrapWithFixedOutput(videoMarkup);\n};\n\nexport {\n createSlashCommands,\n parseContentInfo,\n getEmbedUrl,\n getImageContentToInsert,\n getVideoContentToInsert,\n isValidVariableName,\n normalizeVariableName,\n trimVariablePadding,\n extractVariableNames,\n findVariableMarkers,\n findDocumentVariableMarkers,\n formatVariableReference,\n formatVariableAssignment,\n createVariableExpressionRegexp,\n wrapWithFixedOutput,\n unwrapFixedOutput,\n};\n"],"names":["FIXED_OUTPUT_MARKER","parseContentInfo","type","dataset","SelectedOption","normalizeVariableName","createSlashCommands","onSelectOption","labels","context","word","handleSelect","view","_","from","to","selectedOption","getEmbedUrl","url","getVideoEmbedUrl","escapeHtmlAttribute","value","escapeMarkdownText","text","clampScalePercent","wrapWithFixedOutput","content","normalizedContent","unwrapFixedOutput","wrappedPattern","getImageContentToInsert","resourceUrl","resourceTitle","scalePercent","clampedScale","sanitizedHtmlUrl","sanitizedTitle","markdownTitle","widthAttribute","htmlTitleAttributes","imageMarkup","getVideoContentToInsert","embedUrl","sanitizedResourceUrl","sanitizedEmbedUrl","videoMarkup"],"mappings":"oLAoBMA,EAAsB,MAItBC,EAAmB,CACvBC,EACAC,IACG,CACH,OAAQD,EAAA,CACN,KAAKE,EAAAA,eAAe,MAClB,MAAO,CACL,YAAaD,EAAQ,IACrB,cAAeA,EAAQ,MACvB,aAAcA,EAAQ,YAAA,EAG1B,KAAKC,EAAAA,eAAe,MAClB,MAAO,CACL,YAAaD,EAAQ,IACrB,cAAeA,EAAQ,KAAA,EAE3B,KAAKC,EAAAA,eAAe,SAClB,MAAO,CACL,aAAcC,EAAAA,YAAAA,sBAAs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AOnB,EAAoBoB,CAAW,CACxC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { CompletionContext, CompletionResult } from '@codemirror/autocomplete';
|
|
2
2
|
import { SelectedOption } from './types.js';
|
|
3
|
+
import { extractVariableNames, findVariableMarkers, findDocumentVariableMarkers, formatVariableReference, formatVariableAssignment, isValidVariableName, normalizeVariableName, trimVariablePadding } from 'remark-flow';
|
|
3
4
|
declare const createVariableExpressionRegexp: () => RegExp;
|
|
4
|
-
declare const isValidVariableName: (name: string) => boolean;
|
|
5
|
-
declare const extractVariableNames: (content: string) => string[];
|
|
6
5
|
declare const parseContentInfo: (type: SelectedOption, dataset: {
|
|
7
6
|
title?: string;
|
|
8
7
|
url?: string;
|
|
@@ -39,4 +38,4 @@ declare const getImageContentToInsert: ({ resourceUrl, resourceTitle, scalePerce
|
|
|
39
38
|
scalePercent?: number;
|
|
40
39
|
}) => string;
|
|
41
40
|
declare const getVideoContentToInsert: (resourceUrl: string, resourceTitle: string) => string;
|
|
42
|
-
export { createSlashCommands, parseContentInfo, getEmbedUrl, getImageContentToInsert, getVideoContentToInsert, isValidVariableName, extractVariableNames, createVariableExpressionRegexp, wrapWithFixedOutput, unwrapFixedOutput, };
|
|
41
|
+
export { createSlashCommands, parseContentInfo, getEmbedUrl, getImageContentToInsert, getVideoContentToInsert, isValidVariableName, normalizeVariableName, trimVariablePadding, extractVariableNames, findVariableMarkers, findDocumentVariableMarkers, formatVariableReference, formatVariableAssignment, createVariableExpressionRegexp, wrapWithFixedOutput, unwrapFixedOutput, };
|
|
@@ -1,29 +1,22 @@
|
|
|
1
|
-
import { SelectedOption as
|
|
2
|
-
import { getVideoEmbedUrl as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return [];
|
|
6
|
-
const e = [], o = h();
|
|
7
|
-
let r;
|
|
8
|
-
for (; (r = o.exec(t)) !== null; )
|
|
9
|
-
e.push(r[1]);
|
|
10
|
-
return e;
|
|
11
|
-
}, S = (t, e) => {
|
|
1
|
+
import { SelectedOption as d } from "./types.es.js";
|
|
2
|
+
import { getVideoEmbedUrl as f } from "./utils/video.es.js";
|
|
3
|
+
import { d as m } from "../../_virtual/index.es.js";
|
|
4
|
+
const c = "===", x = (t, e) => {
|
|
12
5
|
switch (t) {
|
|
13
|
-
case
|
|
6
|
+
case d.Image:
|
|
14
7
|
return {
|
|
15
8
|
resourceUrl: e.url,
|
|
16
9
|
resourceTitle: e.title,
|
|
17
10
|
scalePercent: e.scalePercent
|
|
18
11
|
};
|
|
19
|
-
case
|
|
12
|
+
case d.Video:
|
|
20
13
|
return {
|
|
21
14
|
resourceUrl: e.url,
|
|
22
15
|
resourceTitle: e.title
|
|
23
16
|
};
|
|
24
|
-
case
|
|
17
|
+
case d.Variable:
|
|
25
18
|
return {
|
|
26
|
-
variableName: e.title
|
|
19
|
+
variableName: m.normalizeVariableName(e.title ?? "") ?? void 0
|
|
27
20
|
};
|
|
28
21
|
default:
|
|
29
22
|
return {
|
|
@@ -32,18 +25,18 @@ const d = "[\\p{L}\\p{N}_]+", f = new RegExp(`^${d}$`, "u"), E = `\\{\\{(${d})\\
|
|
|
32
25
|
};
|
|
33
26
|
}
|
|
34
27
|
};
|
|
35
|
-
function
|
|
28
|
+
function z(t, e) {
|
|
36
29
|
return (o) => {
|
|
37
|
-
const
|
|
38
|
-
if (!
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
changes: { from: i, to:
|
|
30
|
+
const a = o.matchBefore(/\/(\w*)$/);
|
|
31
|
+
if (!a) return null;
|
|
32
|
+
const s = (r, n, i, l, u) => {
|
|
33
|
+
r.dispatch({
|
|
34
|
+
changes: { from: i, to: l, insert: "" }
|
|
42
35
|
}), t(u);
|
|
43
36
|
};
|
|
44
37
|
return {
|
|
45
|
-
from:
|
|
46
|
-
to:
|
|
38
|
+
from: a.from,
|
|
39
|
+
to: a.to,
|
|
47
40
|
options: [
|
|
48
41
|
// {
|
|
49
42
|
// label: labels?.divider ?? "Divider",
|
|
@@ -59,20 +52,20 @@ function T(t, e) {
|
|
|
59
52
|
// },
|
|
60
53
|
{
|
|
61
54
|
label: e?.variable ?? "Variable",
|
|
62
|
-
apply: (
|
|
63
|
-
|
|
55
|
+
apply: (r, n, i, l) => {
|
|
56
|
+
s(r, n, i, l, d.Variable);
|
|
64
57
|
}
|
|
65
58
|
},
|
|
66
59
|
{
|
|
67
60
|
label: e?.image ?? "Image",
|
|
68
|
-
apply: (
|
|
69
|
-
|
|
61
|
+
apply: (r, n, i, l) => {
|
|
62
|
+
s(r, n, i, l, d.Image);
|
|
70
63
|
}
|
|
71
64
|
},
|
|
72
65
|
{
|
|
73
66
|
label: e?.video ?? "Video",
|
|
74
|
-
apply: (
|
|
75
|
-
|
|
67
|
+
apply: (r, n, i, l) => {
|
|
68
|
+
s(r, n, i, l, d.Video);
|
|
76
69
|
}
|
|
77
70
|
}
|
|
78
71
|
],
|
|
@@ -80,37 +73,40 @@ function T(t, e) {
|
|
|
80
73
|
};
|
|
81
74
|
};
|
|
82
75
|
}
|
|
83
|
-
const
|
|
76
|
+
const $ = (t) => f(t), p = (t) => t.replace(/&/g, "&").replace(/"/g, """), g = (t) => t.replace(/([\[\]\\])/g, "\\$1"), V = (t) => Math.max(1, Math.min(1e3, Math.round(t))), b = (t) => {
|
|
84
77
|
const e = t.trim();
|
|
85
78
|
return e ? new RegExp(
|
|
86
|
-
`^${
|
|
87
|
-
).test(e) ? e : `${
|
|
88
|
-
},
|
|
79
|
+
`^${c}\\s*[\\s\\S]*?\\s*${c}$`
|
|
80
|
+
).test(e) ? e : `${c} ${e} ${c}` : `${c}${c}`;
|
|
81
|
+
}, v = (t) => {
|
|
89
82
|
const e = t.trim(), o = new RegExp(
|
|
90
|
-
`^${
|
|
83
|
+
`^${c}\\s*([\\s\\S]*?)\\s*${c}$`
|
|
91
84
|
);
|
|
92
85
|
return (e.match(o)?.[1] ?? e).trim();
|
|
93
|
-
},
|
|
86
|
+
}, U = ({
|
|
94
87
|
resourceUrl: t,
|
|
95
88
|
resourceTitle: e,
|
|
96
89
|
scalePercent: o
|
|
97
90
|
}) => {
|
|
98
|
-
const
|
|
99
|
-
return
|
|
100
|
-
},
|
|
101
|
-
const o =
|
|
102
|
-
return
|
|
103
|
-
};
|
|
91
|
+
const a = typeof o == "number" ? V(o) : void 0, s = p(t), r = e ? p(e) : void 0, n = e ? g(e) : "", i = typeof a == "number" && a !== 100 ? ` width="${a}%"` : "", l = r ? ` alt="${r}" title="${r}"` : "", u = !a || a === 100 ? `` : `<img src="${s}"${l}${i} />`;
|
|
92
|
+
return b(u);
|
|
93
|
+
}, k = (t, e) => {
|
|
94
|
+
const o = $(t), a = e ? p(e) : "", s = p(t), r = p(o), n = `<iframe data-tag="video" data-title="${a}" data-url="${s}" class="w-full aspect-video rounded-lg border-0" src="${r}" allowfullscreen="" allow="autoplay; encrypted-media"></iframe>`;
|
|
95
|
+
return b(n);
|
|
96
|
+
}, E = m.extractVariableNames, I = m.findDocumentVariableMarkers, P = m.findVariableMarkers, T = m.formatVariableReference, y = m.normalizeVariableName, R = m.trimVariablePadding;
|
|
104
97
|
export {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
I as
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
98
|
+
z as createSlashCommands,
|
|
99
|
+
E as extractVariableNames,
|
|
100
|
+
I as findDocumentVariableMarkers,
|
|
101
|
+
P as findVariableMarkers,
|
|
102
|
+
T as formatVariableReference,
|
|
103
|
+
$ as getEmbedUrl,
|
|
104
|
+
U as getImageContentToInsert,
|
|
105
|
+
k as getVideoContentToInsert,
|
|
106
|
+
y as normalizeVariableName,
|
|
107
|
+
x as parseContentInfo,
|
|
108
|
+
R as trimVariablePadding,
|
|
109
|
+
v as unwrapFixedOutput,
|
|
110
|
+
b as wrapWithFixedOutput
|
|
115
111
|
};
|
|
116
112
|
//# sourceMappingURL=utils.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.es.js","sources":["../../../src/components/MarkdownFlowEditor/utils.ts"],"sourcesContent":["import {\n type CompletionContext,\n type CompletionResult,\n} from \"@codemirror/autocomplete\";\nimport { EditorView } from \"@codemirror/view\";\nimport { SelectedOption } from \"./types\";\nimport { getVideoEmbedUrl } from \"./utils/video\";\n\nconst VARIABLE_NAME_SOURCE = \"[\\\\p{L}\\\\p{N}_]+\";\nconst VARIABLE_NAME_REGEXP = new RegExp(`^${VARIABLE_NAME_SOURCE}$`, \"u\");\nconst VARIABLE_EXPRESSION_PATTERN = `\\\\{\\\\{(${VARIABLE_NAME_SOURCE})\\\\}\\\\}`;\nconst FIXED_OUTPUT_MARKER = \"===\";\n\nconst createVariableExpressionRegexp = () =>\n new RegExp(VARIABLE_EXPRESSION_PATTERN, \"gu\");\n\nconst isValidVariableName = (name: string) =>\n typeof name === \"string\" && VARIABLE_NAME_REGEXP.test(name);\n\nconst extractVariableNames = (content: string) => {\n if (!content) {\n return [];\n }\n const matches: string[] = [];\n const regexp = createVariableExpressionRegexp();\n let match: RegExpExecArray | null;\n\n while ((match = regexp.exec(content)) !== null) {\n matches.push(match[1]);\n }\n\n return matches;\n};\n\nconst parseContentInfo = (\n type: SelectedOption,\n dataset: { title?: string; url?: string; scalePercent?: number }\n) => {\n switch (type) {\n case SelectedOption.Image:\n return {\n resourceUrl: dataset.url,\n resourceTitle: dataset.title,\n scalePercent: dataset.scalePercent,\n };\n\n case SelectedOption.Video:\n return {\n resourceUrl: dataset.url,\n resourceTitle: dataset.title,\n };\n case SelectedOption.Variable:\n return {\n variableName: dataset.title,\n };\n default:\n return {\n resourceUrl: dataset.url ?? \"\",\n resourceTitle: dataset.title ?? \"\",\n };\n }\n};\n\nfunction createSlashCommands(\n onSelectOption: (selectedOption: SelectedOption) => void,\n labels?: {\n divider?: string;\n fixedText?: string;\n image?: string;\n video?: string;\n variable?: string;\n }\n) {\n return (context: CompletionContext): CompletionResult | null => {\n const word = context.matchBefore(/\\/(\\w*)$/);\n if (!word) return null;\n\n const handleSelect = (\n view: EditorView,\n _: any,\n from: number,\n to: number,\n selectedOption: SelectedOption\n ) => {\n view.dispatch({\n changes: { from, to, insert: \"\" },\n });\n onSelectOption(selectedOption);\n };\n\n return {\n from: word.from,\n to: word.to,\n options: [\n // {\n // label: labels?.divider ?? \"Divider\",\n // apply: (view, _, from, to) => {\n // handleSelect(view, _, from, to, SelectedOption.Divider);\n // },\n // },\n // {\n // label: labels?.fixedText ?? \"Fixed Text\",\n // apply: (view, _, from, to) => {\n // handleSelect(view, _, from, to, SelectedOption.FixedText);\n // },\n // },\n {\n label: labels?.variable ?? \"Variable\",\n apply: (view, _, from, to) => {\n handleSelect(view, _, from, to, SelectedOption.Variable);\n },\n },\n {\n label: labels?.image ?? \"Image\",\n apply: (view, _, from, to) => {\n handleSelect(view, _, from, to, SelectedOption.Image);\n },\n },\n {\n label: labels?.video ?? \"Video\",\n apply: (view, _, from, to) => {\n handleSelect(view, _, from, to, SelectedOption.Video);\n },\n },\n ],\n filter: false,\n };\n };\n}\n\nconst getEmbedUrl = (url: string) => {\n return getVideoEmbedUrl(url);\n};\n\nconst escapeHtmlAttribute = (value: string) =>\n value.replace(/&/g, \"&\").replace(/\"/g, \""\");\n\nconst escapeMarkdownText = (text: string) =>\n text.replace(/([\\[\\]\\\\])/g, \"\\\\$1\");\n\nconst clampScalePercent = (value: number) =>\n Math.max(1, Math.min(1000, Math.round(value)));\n\nconst wrapWithFixedOutput = (content: string) => {\n const normalizedContent = content.trim();\n if (!normalizedContent) {\n return `${FIXED_OUTPUT_MARKER}${FIXED_OUTPUT_MARKER}`;\n }\n const wrappedPattern = new RegExp(\n `^${FIXED_OUTPUT_MARKER}\\\\s*[\\\\s\\\\S]*?\\\\s*${FIXED_OUTPUT_MARKER}$`\n );\n if (wrappedPattern.test(normalizedContent)) {\n return normalizedContent;\n }\n return `${FIXED_OUTPUT_MARKER} ${normalizedContent} ${FIXED_OUTPUT_MARKER}`;\n};\n\nconst unwrapFixedOutput = (content: string) => {\n const normalizedContent = content.trim();\n const wrappedPattern = new RegExp(\n `^${FIXED_OUTPUT_MARKER}\\\\s*([\\\\s\\\\S]*?)\\\\s*${FIXED_OUTPUT_MARKER}$`\n );\n const match = normalizedContent.match(wrappedPattern);\n return (match?.[1] ?? normalizedContent).trim();\n};\n\nconst getImageContentToInsert = ({\n resourceUrl,\n resourceTitle,\n scalePercent,\n}: {\n resourceUrl: string;\n resourceTitle?: string;\n scalePercent?: number;\n}) => {\n const clampedScale =\n typeof scalePercent === \"number\"\n ? clampScalePercent(scalePercent)\n : undefined;\n const sanitizedHtmlUrl = escapeHtmlAttribute(resourceUrl);\n const sanitizedTitle = resourceTitle\n ? escapeHtmlAttribute(resourceTitle)\n : undefined;\n const markdownTitle = resourceTitle ? escapeMarkdownText(resourceTitle) : \"\";\n const widthAttribute =\n typeof clampedScale === \"number\" && clampedScale !== 100\n ? ` width=\"${clampedScale}%\"`\n : \"\";\n const htmlTitleAttributes = sanitizedTitle\n ? ` alt=\"${sanitizedTitle}\" title=\"${sanitizedTitle}\"`\n : \"\";\n const imageMarkup =\n !clampedScale || clampedScale === 100\n ? ``\n : `<img src=\"${sanitizedHtmlUrl}\"${htmlTitleAttributes}${widthAttribute} />`;\n\n return wrapWithFixedOutput(imageMarkup);\n};\n\nconst getVideoContentToInsert = (\n resourceUrl: string,\n resourceTitle: string\n) => {\n const embedUrl = getEmbedUrl(resourceUrl);\n const sanitizedTitle = resourceTitle\n ? escapeHtmlAttribute(resourceTitle)\n : \"\";\n const sanitizedResourceUrl = escapeHtmlAttribute(resourceUrl);\n const sanitizedEmbedUrl = escapeHtmlAttribute(embedUrl);\n const videoMarkup = `<iframe data-tag=\"video\" data-title=\"${sanitizedTitle}\" data-url=\"${sanitizedResourceUrl}\" class=\"w-full aspect-video rounded-lg border-0\" src=\"${sanitizedEmbedUrl}\" allowfullscreen=\"\" allow=\"autoplay; encrypted-media\"></iframe>`;\n\n return wrapWithFixedOutput(videoMarkup);\n};\n\nexport {\n createSlashCommands,\n parseContentInfo,\n getEmbedUrl,\n getImageContentToInsert,\n getVideoContentToInsert,\n isValidVariableName,\n extractVariableNames,\n createVariableExpressionRegexp,\n wrapWithFixedOutput,\n unwrapFixedOutput,\n};\n"],"names":["VARIABLE_NAME_SOURCE","VARIABLE_NAME_REGEXP","VARIABLE_EXPRESSION_PATTERN","FIXED_OUTPUT_MARKER","createVariableExpressionRegexp","isValidVariableName","name","extractVariableNames","content","matches","regexp","match","parseContentInfo","type","dataset","SelectedOption","createSlashCommands","onSelectOption","labels","context","word","handleSelect","view","_","from","to","selectedOption","getEmbedUrl","url","getVideoEmbedUrl","escapeHtmlAttribute","value","escapeMarkdownText","text","clampScalePercent","wrapWithFixedOutput","normalizedContent","unwrapFixedOutput","wrappedPattern","getImageContentToInsert","resourceUrl","resourceTitle","scalePercent","clampedScale","sanitizedHtmlUrl","sanitizedTitle","markdownTitle","widthAttribute","htmlTitleAttributes","imageMarkup","getVideoContentToInsert","embedUrl","sanitizedResourceUrl","sanitizedEmbedUrl","videoMarkup"],"mappings":";;AAQA,MAAMA,IAAuB,oBACvBC,IAAuB,IAAI,OAAO,IAAID,CAAoB,KAAK,GAAG,GAClEE,IAA8B,UAAUF,CAAoB,WAC5DG,IAAsB,OAEtBC,IAAiC,MACrC,IAAI,OAAOF,GAA6B,IAAI,GAExCG,IAAsB,CAACC,MAC3B,OAAOA,KAAS,YAAYL,EAAqB,KAAKK,CAAI,GAEtDC,IAAuB,CAACC,MAAoB;AAChD,MAAI,CAACA;AACH,WAAO,CAAA;AAET,QAAMC,IAAoB,CAAA,GACpBC,IAASN,EAAA;AACf,MAAIO;AAEJ,UAAQA,IAAQD,EAAO,KAAKF,CAAO,OAAO;AACxC,IAAAC,EAAQ,KAAKE,EAAM,CAAC,CAAC;AAGvB,SAAOF;AACT,GAEMG,IAAmB,CACvBC,GACAC,MACG;AACH,UAAQD,GAAA;AAAA,IACN,KAAKE,EAAe;AAClB,a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AAa,IACjC,QACEK,IAAgBL,IAAgBT,EAAmBS,CAAa,IAAI,IACpEM,IACJ,OAAOJ,KAAiB,YAAYA,MAAiB,MACjD,WAAWA,CAAY,OACvB,IACAK,IAAsBH,IACxB,SAASA,CAAc,YAAYA,CAAc,MACjD,IACEI,IACJ,CAACN,KAAgBA,MAAiB,MAC9B,KAAKG,CAAa,KAAKN,CAAW,MAClC,aAAaI,CAAgB,IAAII,CAAmB,GAAGD,CAAc;AAE3E,SAAOZ,EAAoBc,CAAW;AACxC,GAEMC,IAA0B,CAC9BV,GACAC,MACG;AACH,QAAMU,IAAWxB,EAAYa,CAAW,GAClCK,IAAiBJ,IACnBX,EAAoBW,CAAa,IACjC,IACEW,IAAuBtB,EAAoBU,CAAW,GACtDa,IAAoBvB,EAAoBqB,CAAQ,GAChDG,IAAc,wCAAwCT,CAAc,eAAeO,CAAoB,0DAA0DC,CAAiB;AAExL,SAAOlB,EAAoBmB,CAAW;AACxC;"}
|
|
1
|
+
{"version":3,"file":"utils.es.js","sources":["../../../src/components/MarkdownFlowEditor/utils.ts"],"sourcesContent":["import {\n type CompletionContext,\n type CompletionResult,\n} from \"@codemirror/autocomplete\";\nimport { EditorView } from \"@codemirror/view\";\nimport { SelectedOption } from \"./types\";\nimport { getVideoEmbedUrl } from \"./utils/video\";\n\nimport {\n createVariableExpressionRegex,\n extractVariableNames,\n findVariableMarkers,\n findDocumentVariableMarkers,\n formatVariableReference,\n formatVariableAssignment,\n isValidVariableName,\n normalizeVariableName,\n trimVariablePadding,\n} from \"remark-flow\";\n\nconst FIXED_OUTPUT_MARKER = \"===\";\nconst createVariableExpressionRegexp = () =>\n createVariableExpressionRegex(\"gu\");\n\nconst parseContentInfo = (\n type: SelectedOption,\n dataset: { title?: string; url?: string; scalePercent?: number }\n) => {\n switch (type) {\n case SelectedOption.Image:\n return {\n resourceUrl: dataset.url,\n resourceTitle: dataset.title,\n scalePercent: dataset.scalePercent,\n };\n\n case SelectedOption.Video:\n return {\n resourceUrl: dataset.url,\n resourceTitle: dataset.title,\n };\n case SelectedOption.Variable:\n return {\n variableName: normalizeVariableName(dataset.title ?? \"\") ?? undefined,\n };\n default:\n return {\n resourceUrl: dataset.url ?? \"\",\n resourceTitle: dataset.title ?? \"\",\n };\n }\n};\n\nfunction createSlashCommands(\n onSelectOption: (selectedOption: SelectedOption) => void,\n labels?: {\n divider?: string;\n fixedText?: string;\n image?: string;\n video?: string;\n variable?: string;\n }\n) {\n return (context: CompletionContext): CompletionResult | null => {\n const word = context.matchBefore(/\\/(\\w*)$/);\n if (!word) return null;\n\n const handleSelect = (\n view: EditorView,\n _: any,\n from: number,\n to: number,\n selectedOption: SelectedOption\n ) => {\n view.dispatch({\n changes: { from, to, insert: \"\" },\n });\n onSelectOption(selectedOption);\n };\n\n return {\n from: word.from,\n to: word.to,\n options: [\n // {\n // label: labels?.divider ?? \"Divider\",\n // apply: (view, _, from, to) => {\n // handleSelect(view, _, from, to, SelectedOption.Divider);\n // },\n // },\n // {\n // label: labels?.fixedText ?? \"Fixed Text\",\n // apply: (view, _, from, to) => {\n // handleSelect(view, _, from, to, SelectedOption.FixedText);\n // },\n // },\n {\n label: labels?.variable ?? \"Variable\",\n apply: (view, _, from, to) => {\n handleSelect(view, _, from, to, SelectedOption.Variable);\n },\n },\n {\n label: labels?.image ?? \"Image\",\n apply: (view, _, from, to) => {\n handleSelect(view, _, from, to, SelectedOption.Image);\n },\n },\n {\n label: labels?.video ?? \"Video\",\n apply: (view, _, from, to) => {\n handleSelect(view, _, from, to, SelectedOption.Video);\n },\n },\n ],\n filter: false,\n };\n };\n}\n\nconst getEmbedUrl = (url: string) => {\n return getVideoEmbedUrl(url);\n};\n\nconst escapeHtmlAttribute = (value: string) =>\n value.replace(/&/g, \"&\").replace(/\"/g, \""\");\n\nconst escapeMarkdownText = (text: string) =>\n text.replace(/([\\[\\]\\\\])/g, \"\\\\$1\");\n\nconst clampScalePercent = (value: number) =>\n Math.max(1, Math.min(1000, Math.round(value)));\n\nconst wrapWithFixedOutput = (content: string) => {\n const normalizedContent = content.trim();\n if (!normalizedContent) {\n return `${FIXED_OUTPUT_MARKER}${FIXED_OUTPUT_MARKER}`;\n }\n const wrappedPattern = new RegExp(\n `^${FIXED_OUTPUT_MARKER}\\\\s*[\\\\s\\\\S]*?\\\\s*${FIXED_OUTPUT_MARKER}$`\n );\n if (wrappedPattern.test(normalizedContent)) {\n return normalizedContent;\n }\n return `${FIXED_OUTPUT_MARKER} ${normalizedContent} ${FIXED_OUTPUT_MARKER}`;\n};\n\nconst unwrapFixedOutput = (content: string) => {\n const normalizedContent = content.trim();\n const wrappedPattern = new RegExp(\n `^${FIXED_OUTPUT_MARKER}\\\\s*([\\\\s\\\\S]*?)\\\\s*${FIXED_OUTPUT_MARKER}$`\n );\n const match = normalizedContent.match(wrappedPattern);\n return (match?.[1] ?? normalizedContent).trim();\n};\n\nconst getImageContentToInsert = ({\n resourceUrl,\n resourceTitle,\n scalePercent,\n}: {\n resourceUrl: string;\n resourceTitle?: string;\n scalePercent?: number;\n}) => {\n const clampedScale =\n typeof scalePercent === \"number\"\n ? clampScalePercent(scalePercent)\n : undefined;\n const sanitizedHtmlUrl = escapeHtmlAttribute(resourceUrl);\n const sanitizedTitle = resourceTitle\n ? escapeHtmlAttribute(resourceTitle)\n : undefined;\n const markdownTitle = resourceTitle ? escapeMarkdownText(resourceTitle) : \"\";\n const widthAttribute =\n typeof clampedScale === \"number\" && clampedScale !== 100\n ? ` width=\"${clampedScale}%\"`\n : \"\";\n const htmlTitleAttributes = sanitizedTitle\n ? ` alt=\"${sanitizedTitle}\" title=\"${sanitizedTitle}\"`\n : \"\";\n const imageMarkup =\n !clampedScale || clampedScale === 100\n ? ``\n : `<img src=\"${sanitizedHtmlUrl}\"${htmlTitleAttributes}${widthAttribute} />`;\n\n return wrapWithFixedOutput(imageMarkup);\n};\n\nconst getVideoContentToInsert = (\n resourceUrl: string,\n resourceTitle: string\n) => {\n const embedUrl = getEmbedUrl(resourceUrl);\n const sanitizedTitle = resourceTitle\n ? escapeHtmlAttribute(resourceTitle)\n : \"\";\n const sanitizedResourceUrl = escapeHtmlAttribute(resourceUrl);\n const sanitizedEmbedUrl = escapeHtmlAttribute(embedUrl);\n const videoMarkup = `<iframe data-tag=\"video\" data-title=\"${sanitizedTitle}\" data-url=\"${sanitizedResourceUrl}\" class=\"w-full aspect-video rounded-lg border-0\" src=\"${sanitizedEmbedUrl}\" allowfullscreen=\"\" allow=\"autoplay; encrypted-media\"></iframe>`;\n\n return wrapWithFixedOutput(videoMarkup);\n};\n\nexport {\n createSlashCommands,\n parseContentInfo,\n getEmbedUrl,\n getImageContentToInsert,\n getVideoContentToInsert,\n isValidVariableName,\n normalizeVariableName,\n trimVariablePadding,\n extractVariableNames,\n findVariableMarkers,\n findDocumentVariableMarkers,\n formatVariableReference,\n formatVariableAssignment,\n createVariableExpressionRegexp,\n wrapWithFixedOutput,\n unwrapFixedOutput,\n};\n"],"names":["FIXED_OUTPUT_MARKER","parseContentInfo","type","dataset","SelectedOption","normalizeVariableName","createSlashCommands","onSelectOption","labels","context","word","handleSelect","view","_","from","to","selectedOption","getEmbedUrl","url","getVideoEmbedUrl","escapeHtmlAttribute","value","escapeMarkdownText","text","clampScalePercent","wrapWithFixedOutput","content","normalizedContent","unwrapFixedOutput","wrappedPattern","getImageContentToInsert","resourceUrl","resourceTitle","scalePercent","clampedScale","sanitizedHtmlUrl","sanitizedTitle","markdownTitle","widthAttribute","htmlTitleAttributes","imageMarkup","getVideoContentToInsert","embedUrl","sanitizedResourceUrl","sanitizedEmbedUrl","videoMarkup"],"mappings":";;;AAoBA,MAAMA,IAAsB,OAItBC,IAAmB,CACvBC,GACAC,MACG;AACH,UAAQD,GAAA;AAAA,IACN,KAAKE,EAAe;AAClB,aAAO;AAAA,QACL,aAAaD,EAAQ;AAAA,QACrB,eAAeA,EAAQ;AAAA,QACvB,cAAcA,EAAQ;AAAA,MAAA;AAAA,IAG1B,KAAKC,EAAe;AAClB,aAAO;AA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CAAY,OACvB,IACAK,IAAsBH,IACxB,SAASA,CAAc,YAAYA,CAAc,MACjD,IACEI,IACJ,CAACN,KAAgBA,MAAiB,MAC9B,KAAKG,CAAa,KAAKN,CAAW,MAClC,aAAaI,CAAgB,IAAII,CAAmB,GAAGD,CAAc;AAE3E,SAAOb,EAAoBe,CAAW;AACxC,GAEMC,IAA0B,CAC9BV,GACAC,MACG;AACH,QAAMU,IAAWzB,EAAYc,CAAW,GAClCK,IAAiBJ,IACnBZ,EAAoBY,CAAa,IACjC,IACEW,IAAuBvB,EAAoBW,CAAW,GACtDa,IAAoBxB,EAAoBsB,CAAQ,GAChDG,IAAc,wCAAwCT,CAAc,eAAeO,CAAoB,0DAA0DC,CAAiB;AAExL,SAAOnB,EAAoBoB,CAAW;AACxC;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),d=require("react"),u=require("../../../node_modules/rc-textarea/es/TextArea.cjs");require("../../../_virtual/
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),d=require("react"),u=require("../../../node_modules/rc-textarea/es/TextArea.cjs");require("../../../_virtual/index5.cjs");require("../../../node_modules/rc-resize-observer/es/index.cjs");require("../../../node_modules/rc-util/es/hooks/useLayoutEffect.cjs");require("../../../node_modules/rc-util/es/raf.cjs");const s=require("../../../lib/utils.cjs");function c(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const l=c(d),i=l.forwardRef(({className:e,autoSize:t={minRows:1},style:r,...a},n)=>o.jsx(u.default,{ref:n,autoSize:t,className:s.cn("border-input placeholder:text-muted-foreground aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 w-full rounded-md border bg-transparent pl-3 py-1.5 text-base shadow-xs transition-[color,box-shadow] outline-none disabled:cursor-not-allowed disabled:opacity-50","resize-none",e),style:{whiteSpace:"pre-wrap",wordBreak:"break-word",...r},...a}));i.displayName="Textarea";exports.Textarea=i;
|
|
2
2
|
//# sourceMappingURL=textarea.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as i } from "react/jsx-runtime";
|
|
2
2
|
import * as d from "react";
|
|
3
3
|
import n from "../../../node_modules/rc-textarea/es/TextArea.es.js";
|
|
4
|
-
import "../../../_virtual/index.
|
|
4
|
+
import "../../../_virtual/index.es5.js";
|
|
5
5
|
import "../../../node_modules/rc-resize-observer/es/index.es.js";
|
|
6
6
|
import "../../../node_modules/rc-util/es/hooks/useLayoutEffect.es.js";
|
|
7
7
|
import "../../../node_modules/rc-util/es/raf.es.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../_virtual/index.cjs"),b=require("../components/ContentRender/utils/inline-code-ranges.cjs"),p=u.distExports.createInteractionParser(),g=/<custom-variable\b/i,E=new RegExp(`\\?\\[(${u.distExports.INTERACTION_CONTENT_SOURCE})\\](?!\\()`),V=/^[\[{]/,m=t=>{if(t.type==="flowInteraction"&&"value"in t)return typeof t.value=="string"?t.value:null;if(t.children)for(const e of t.children){const r=m(e);if(r!==null)return r}return null},I=t=>{if(!t)return null;try{const e=m(b.getMarkdownSourceAnalysis(t).tree)??(g.test(t)?t:null);return e===null||p.parse(e).error?null:p.parseToRemarkFormat(e)}catch(e){console.warn("Failed to parse interaction block",e)}return null},T=(t,e)=>{if(!t)return null;const r=u.distExports.trimVariablePadding(t),n=e.buttonValues||[],i=e.buttonTexts||[],s=n.indexOf(r);if(s>-1)return{value:n[s],display:i[s]};const l=i.indexOf(r);return l>-1?{value:n[l]||i[l],display:i[l]}:null},v=t=>t.split(/[,,\n]/).map(e=>u.distExports.trimVariablePadding(e)).filter(Boolean),d=t=>{let e=0;for(;e<t.length&&(t[e]===","||t[e]===","||u.distExports.trimVariablePadding(t[e])==="");)e+=1;return t.slice(e)},P=t=>{const e=t.buttonValues||[],r=t.buttonTexts||[],n=[],i=new Set;return e.forEach((s,l)=>{const a=u.distExports.trimVariablePadding(`${s??""}`),o=u.distExports.trimVariablePadding(`${r[l]??""}`);[a,o].forEach(c=>{if(!c)return;const f=`${c}::${a||c}`;i.has(f)||(i.add(f),n.push({token:c,value:a||c}))})}),n.sort((s,l)=>l.token.length-s.token.length)},S=(t,e)=>{const r=d(t),n=P(e);for(const i of n){if(!r.startsWith(i.token))continue;const s=r[i.token.length];if(!(s&&s!==","&&s!==","&&u.distExports.trimVariablePadding(s)!==""))return i}return null},D=(t,e)=>{const r=v(t);if(!r.length)return{};const n=[],i=[];return r.forEach(s=>{const l=T(s,e);if(l){n.push(l.value);return}if(e.placeholder){i.push(s);return}n.push(s)}),{selectedValues:n.length?n:void 0,inputText:i.length?i.join(", "):void 0}},R=(t,e)=>{const r=[];let n=u.distExports.trimVariablePadding(t);for(;n;){const s=S(n,e);if(!s)break;r.push(s.value);const l=d(n);n=d(l.slice(s.token.length))}if(r.length>0)return{selectedValues:r,inputText:e.placeholder&&n.trim()?n.trim():void 0};const i=D(t,e);return i.selectedValues?.length?i:e.placeholder?{inputText:t.trim()}:i},O=t=>{if(!t||Array.isArray(t))return null;const e=Array.isArray(t.selectedValues)?t.selectedValues.map(i=>u.distExports.trimVariablePadding(`${i??""}`)).filter(Boolean):void 0,r=u.distExports.trimVariablePadding(`${t.buttonText??""}`),n=typeof t.inputText=="string"?t.inputText:void 0;return!e?.length&&!r&&!n?null:{buttonText:r||void 0,inputText:n,selectedValues:e?.length?e:void 0}},A=t=>{if(!t||!V.test(u.distExports.trimVariablePadding(t)))return null;try{const e=JSON.parse(t);return O(e)}catch{return null}},N=t=>!!(t&&(g.test(t)||E.test(t))),x=(t,e,r,n)=>n?.resolveDefaultValues?.({content:t,rawValue:e,interactionInfo:r})??null,h=(t,e,r)=>{const n=e==null?void 0:u.distExports.trimVariablePadding(e.toString());if(!n)return{};const i=A(n);if(i)return i;const s=x(t,n,null,r);if(s)return s;if(!N(t))return{buttonText:n,inputText:n};const l=I(t),a=x(t,n,l,r);if(a)return a;if(!l)return{buttonText:n,inputText:n};if(l.isMultiSelect)return R(n,l);const o=T(n,l);return o?{buttonText:o.value||o.display||n}:l.placeholder?{inputText:n}:{buttonText:n,inputText:n}},C=(t,e,r)=>{const n=h(t,e,r);return n.selectedValues?n.selectedValues:e?e.split(",").map(i=>u.distExports.trimVariablePadding(i)).filter(Boolean):void 0};exports.getInteractionDefaultSelectedValues=C;exports.getInteractionDefaultValues=h;
|
|
2
2
|
//# sourceMappingURL=interaction-defaults.cjs.map
|