markdown-flow-ui 0.3.4-dev.1 → 0.3.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/README.md +8 -17
- 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.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/index3.cjs +1 -1
- package/dist/_virtual/index4.cjs +1 -1
- package/dist/_virtual/index6.cjs +1 -1
- package/dist/_virtual/index7.cjs +1 -1
- package/dist/components/ContentRender/ContentRender.cjs.map +1 -1
- package/dist/components/ContentRender/ContentRender.es.js +0 -1
- package/dist/components/ContentRender/ContentRender.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.d.ts +0 -2
- package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.es.js +260 -284
- package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/components/EditorToolbar.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/components/EditorToolbar.cjs.map +1 -1
- package/dist/components/MarkdownFlowEditor/components/EditorToolbar.es.js +40 -48
- package/dist/components/MarkdownFlowEditor/components/EditorToolbar.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/editorI18n.d.ts +0 -22
- package/dist/components/MarkdownFlowEditor/locales/ar-SA.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/ar-SA.json.d.ts +5 -6
- package/dist/components/MarkdownFlowEditor/locales/ar-SA.json.es.js +16 -18
- package/dist/components/MarkdownFlowEditor/locales/ar-SA.json.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/locales/de-DE.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/de-DE.json.d.ts +5 -6
- package/dist/components/MarkdownFlowEditor/locales/de-DE.json.es.js +49 -51
- package/dist/components/MarkdownFlowEditor/locales/de-DE.json.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/locales/en-US.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/en-US.json.d.ts +5 -6
- package/dist/components/MarkdownFlowEditor/locales/en-US.json.es.js +41 -43
- package/dist/components/MarkdownFlowEditor/locales/en-US.json.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/locales/es-ES.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/es-ES.json.d.ts +5 -6
- package/dist/components/MarkdownFlowEditor/locales/es-ES.json.es.js +49 -51
- package/dist/components/MarkdownFlowEditor/locales/es-ES.json.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/locales/fil-PH.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/fil-PH.json.d.ts +5 -6
- package/dist/components/MarkdownFlowEditor/locales/fil-PH.json.es.js +47 -49
- package/dist/components/MarkdownFlowEditor/locales/fil-PH.json.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/locales/fr-FR.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/fr-FR.json.d.ts +5 -6
- package/dist/components/MarkdownFlowEditor/locales/fr-FR.json.es.js +45 -47
- package/dist/components/MarkdownFlowEditor/locales/fr-FR.json.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/locales/ja-JP.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/ja-JP.json.d.ts +5 -6
- package/dist/components/MarkdownFlowEditor/locales/ja-JP.json.es.js +19 -21
- package/dist/components/MarkdownFlowEditor/locales/ja-JP.json.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/locales/th-TH.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/th-TH.json.d.ts +5 -6
- package/dist/components/MarkdownFlowEditor/locales/th-TH.json.es.js +18 -20
- package/dist/components/MarkdownFlowEditor/locales/th-TH.json.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/locales/ur-PK.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/ur-PK.json.d.ts +5 -6
- package/dist/components/MarkdownFlowEditor/locales/ur-PK.json.es.js +13 -15
- package/dist/components/MarkdownFlowEditor/locales/ur-PK.json.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/locales/vi-VN.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/vi-VN.json.d.ts +5 -6
- package/dist/components/MarkdownFlowEditor/locales/vi-VN.json.es.js +41 -43
- package/dist/components/MarkdownFlowEditor/locales/vi-VN.json.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/locales/zh-CN.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/zh-CN.json.d.ts +5 -6
- package/dist/components/MarkdownFlowEditor/locales/zh-CN.json.es.js +23 -25
- package/dist/components/MarkdownFlowEditor/locales/zh-CN.json.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/plugins/FixedTextPlaceholder.test.d.ts +1 -0
- package/dist/components/MarkdownFlowEditor/plugins/PlaceholderWidget.cjs.map +1 -1
- package/dist/components/MarkdownFlowEditor/plugins/PlaceholderWidget.es.js.map +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.d.ts +2 -6
- package/dist/components/MarkdownFlowEditor/plugins/SyntaxHighlighter.es.js +152 -157
- package/dist/components/MarkdownFlowEditor/plugins/SyntaxHighlighter.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/utils.cjs.map +1 -1
- package/dist/components/MarkdownFlowEditor/utils.es.js +0 -12
- package/dist/components/MarkdownFlowEditor/utils.es.js.map +1 -1
- package/dist/components/ui/inputGroup/textarea.cjs +1 -1
- package/dist/components/ui/inputGroup/textarea.es.js +1 -1
- package/dist/markdown-flow-ui-lib.css +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/mermaid/dist/chunks/mermaid.core/c4Diagram-5PPSVZJV.cjs +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-5PPSVZJV.es.js +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-2GRJ4B5K.cjs +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-2GRJ4B5K.es.js +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-NSK5VX7P.cjs +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-NSK5VX7P.es.js +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/classDiagram-JCYQIIEL.cjs +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/classDiagram-JCYQIIEL.es.js +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/classDiagram-v2-OCEON4UE.cjs +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/classDiagram-v2-OCEON4UE.es.js +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/flowDiagram-UKHOOZJN.cjs +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/flowDiagram-UKHOOZJN.es.js +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-PKOTCBZU.cjs +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-PKOTCBZU.es.js +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-SI44F4Z6.cjs +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-SI44F4Z6.es.js +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/stateDiagram-OKZ733FA.cjs +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/stateDiagram-OKZ733FA.es.js +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/stateDiagram-v2-UEYNNEHI.cjs +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/stateDiagram-v2-UEYNNEHI.es.js +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/swimlanesDiagram-ULZ7WXOC.cjs +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/swimlanesDiagram-ULZ7WXOC.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/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 +70 -67
- 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.es.js +1 -1
- package/package.json +2 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const A=require("../../../node_modules/@codemirror/view/dist/index.cjs"),
|
|
2
|
-
`,
|
|
3
|
-
`,
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const A=require("../../../node_modules/@codemirror/view/dist/index.cjs"),_=require("../../../node_modules/@codemirror/state/dist/index.cjs"),$=require("../../ContentRender/utils/inline-code-ranges.cjs"),B=require("../../../_virtual/index.cjs"),E=require("../utils.cjs"),q=/<!--[\s\S]*?-->/g,F=n=>{const i=E.findVariableMarkers(n),f=n.indexOf("{{",i.at(-1)?.end??0);return f===-1?i:[...i,{start:f,end:n.length,name:null}]},M=new RegExp(`\\?\\[(${B.distExports.INTERACTION_CONTENT_SOURCE})\\](?!\\()`,"g"),L=n=>$.getMarkdownSourceAnalysis(n).interactions;function j(n,i){const f=[];let l=null,s=0;for(;s<=n.length;){const u=n.indexOf(`
|
|
2
|
+
`,s),e=u===-1?n.length:u;if(n.slice(s,e).trim()==="!==="&&!i(s)&&(l===null?l=s:(f.push({from:l,to:e,className:"syntax-fixed"}),l=null)),u===-1)break;s=u+1}return f}function T(n,i,f){const l=[];let s=0;const u=t=>{for(;s<i.length&&i[s].to<=t;)s++;const r=i[s];return!!r&&t>=r.from&&t<r.to};let e=0;for(;e<=n.length;){const t=n.indexOf(`
|
|
3
|
+
`,e),r=t===-1?n.length:t,d=n.slice(e,r),x=[];let g=0;for(;g<d.length;){const c=d.indexOf("===",g);if(c===-1)break;const p=e+c;!(p>0&&n[p-1]==="!")&&!u(p)&&!f(p)&&x.push(p),g=c+3}for(let c=0;c+1<x.length;c+=2)l.push({from:x[c],to:x[c+1]+3,className:"syntax-fixed"});if(t===-1)break;e=t+1}return l}function U(n,i){const f=[];let l;for(q.lastIndex=0;(l=q.exec(n))!==null;)i(l.index)||f.push({from:l.index,to:l.index+l[0].length,className:"syntax-comment"});return f}function D(n){const i=E.findDocumentVariableMarkers(n),f=e=>i.some(t=>e>=t.start&&e<t.end),l=U(n,f),s=[...j(n,f),...T(n,l,f),...l].sort((e,t)=>e.from!==t.from?e.from-t.from:t.to-e.to),u=[];for(const e of s){const t=u[u.length-1];(!t||e.from>=t.to)&&u.push(e)}return u}function H(n,i=()=>!1){const f=[],l=E.findDocumentVariableMarkers(n),s=[];M.lastIndex=0;const u=(t,r)=>s.some(d=>!(r<=d.from||t>=d.to)),e=(t,r,d)=>t>=r||u(t,r)?!1:(s.push({from:t,to:r}),f.push({from:t,to:r,className:d}),!0);for(const t of D(n))e(t.from,t.to,t.className);for(const t of L(n)){M.lastIndex=t.start;const r=M.exec(n);if(!r||r.index!==t.start||r.index+r[0].length!==t.end)continue;const d=r.index,x=r.index+r[0].length,g=r[1],c=d+2;if(u(d,x)||l.some(b=>b.start<=d&&d<b.end))continue;e(d,d+1,"syntax-keyword"),e(d+1,d+2,"syntax-bracket"),e(x-1,x,"syntax-bracket");const p=F(g),y=p[0],w=y?y.start-1:-1,V=w>=0&&g[w]==="%"&&E.trimVariablePadding(g.slice(0,w))==="";if(g.startsWith("%")||V){let b="syntax-percent-invalid";if(y&&V){const o=c+y.start,h=c+y.end,I=i(o,h);b=y.name!==null&&!I?"syntax-percent-valid":"syntax-percent-invalid"}const v=c+(V?w:0);e(v,v+1,b);const O=[],R=[],S=[];for(const o of p)R.push({from:c+o.start,to:c+o.end,className:o.name===null?"syntax-variable-invalid":"syntax-variable"});let m=0;for(;m<g.length;){const o=R.find(I=>c+m===I.from);if(o){m=o.to-c;continue}if(B.distExports.isEscape(g,m)){m+=2;continue}const h=g.startsWith("||",m)?"||":g[m]==="|"?"|":g.startsWith("...",m)?"...":null;if(!h){m+=1;continue}O.push({from:c+m,to:c+m+h.length}),m+=h.length}const a=[...O.map(o=>({...o,className:"syntax-keyword"})),...R.map(o=>({...o,className:o.className}))].sort((o,h)=>o.from!==h.from?o.from-h.from:o.to-h.to);for(const o of a)o.className.startsWith("syntax-variable")&&i(o.from,o.to)||e(o.from,o.to,o.className)&&S.push({from:o.from,to:o.to});const N=v+1,C=x-1;let k=N;const P=S.sort((o,h)=>o.from!==h.from?o.from-h.from:o.to-h.to);for(const o of P)k<o.from&&e(k,o.from,"syntax-string"),k=Math.max(k,o.to);k<C&&e(k,C,"syntax-string")}else{const b=[],v=[];for(const a of F(g))b.push({from:c+a.start,to:c+a.end,className:a.name===null?"syntax-variable-invalid":"syntax-variable"});const O=b.sort((a,N)=>a.from!==N.from?a.from-N.from:a.to-N.to);for(const a of O)a.className.startsWith("syntax-variable")&&i(a.from,a.to)||e(a.from,a.to,a.className)&&v.push({from:a.from,to:a.to});const R=c,S=x-1;let m=R;for(const a of v)m<a.from&&e(m,a.from,"syntax-button-text"),m=Math.max(m,a.to);m<S&&e(m,S,"syntax-button-text")}}for(const t of l)t.name!==null&&!i(t.start,t.end)&&e(t.start,t.end,"syntax-variable");return f.sort((t,r)=>t.from!==r.from?t.from-r.from:r.to-t.to),f}function W(n){const i=new _.RangeSetBuilder,f=n.state.doc.toString(),l=H(f,(s,u)=>n.state.selection.ranges.some(e=>e.from>=s&&e.to<=u));for(const s of l)if(s.from<s.to)try{i.add(s.from,s.to,A.Decoration.mark({class:s.className}))}catch(u){console.warn("SyntaxHighlighter: Failed to add decoration",s,u)}return i.finish()}const z=A.ViewPlugin.fromClass(class{constructor(n){this.decorations=W(n)}update(n){(n.docChanged||n.viewportChanged||n.selectionSet)&&(this.decorations=W(n.view))}},{decorations:n=>n.decorations});exports.collectOuterBlockRanges=D;exports.collectSyntaxHighlightRanges=H;exports.default=z;
|
|
4
4
|
//# sourceMappingURL=SyntaxHighlighter.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SyntaxHighlighter.cjs","sources":["../../../../src/components/MarkdownFlowEditor/plugins/SyntaxHighlighter.ts"],"sourcesContent":["import {\n Decoration,\n DecorationSet,\n EditorView,\n ViewPlugin,\n ViewUpdate,\n} from \"@codemirror/view\";\nimport { RangeSetBuilder } from \"@codemirror/state\";\nimport { getMarkdownSourceAnalysis } from \"../../ContentRender/utils/inline-code-ranges\";\nimport { INTERACTION_CONTENT_SOURCE, isEscape } from \"remark-flow\";\n\nimport {\n findVariableMarkers,\n findDocumentVariableMarkers,\n trimVariablePadding,\n} from \"../utils\";\n\nconst commentRegex = /<!--[\\s\\S]*?-->/g;\n\n// An unfinished marker still owns its tail, so nested syntax stays literal while typing.\nconst interactionVariableRanges = (text: string) => {\n const markers = findVariableMarkers(text);\n const pending = text.indexOf(\"{{\", markers.at(-1)?.end ?? 0);\n return pending === -1\n ? markers\n : [...markers, { start: pending, end: text.length, name: null }];\n};\n// The grammar's own definition of where an interaction ends, so a `\\]` an option escaped does\n// not cut the highlight short, and the same `(?!\\()` the parser uses, so `?[text](url)` stays a\n// markdown link. Taken from remark-flow rather than written again here: the editor and the\n// parser have to agree about what they are looking at.\nconst controlBlockRegex = new RegExp(\n `\\\\?\\\\[(${INTERACTION_CONTENT_SOURCE})\\\\](?!\\\\()`,\n \"g\"\n);\n\nconst documentControlRanges = (text: string) =>\n getMarkdownSourceAnalysis(text).interactions;\n\nexport interface SyntaxHighlightRange {\n from: number;\n to: number;\n className: string;\n}\n\nfunction collectMultilineFixedOutputRanges(\n docText: string,\n isInsideVariable: (position: number) => boolean\n): SyntaxHighlightRange[] {\n const ranges: SyntaxHighlightRange[] = [];\n let pendingStart: number | null = null;\n let lineStart = 0;\n\n while (lineStart <= docText.length) {\n const newlineIndex = docText.indexOf(\"\\n\", lineStart);\n const lineEnd = newlineIndex === -1 ? docText.length : newlineIndex;\n const lineText = docText.slice(lineStart, lineEnd);\n\n if (lineText.trim() === \"!===\" && !isInsideVariable(lineStart)) {\n if (pendingStart === null) {\n pendingStart = lineStart;\n } else {\n ranges.push({\n from: pendingStart,\n to: lineEnd,\n className: \"syntax-fixed\",\n });\n pendingStart = null;\n }\n }\n\n if (newlineIndex === -1) {\n break;\n }\n\n lineStart = newlineIndex + 1;\n }\n\n return ranges;\n}\n\nfunction collectSingleLineFixedOutputRanges(\n docText: string,\n commentRanges: SyntaxHighlightRange[],\n isInsideVariable: (position: number) => boolean\n): SyntaxHighlightRange[] {\n const ranges: SyntaxHighlightRange[] = [];\n let commentIndex = 0;\n\n const isInsideComment = (index: number) => {\n while (\n commentIndex < commentRanges.length &&\n commentRanges[commentIndex].to <= index\n ) {\n commentIndex++;\n }\n\n const range = commentRanges[commentIndex];\n return !!range && index >= range.from && index < range.to;\n };\n\n let lineStart = 0;\n while (lineStart <= docText.length) {\n const newlineIndex = docText.indexOf(\"\\n\", lineStart);\n const lineEnd = newlineIndex === -1 ? docText.length : newlineIndex;\n const lineText = docText.slice(lineStart, lineEnd);\n const markerPositions: number[] = [];\n let searchFrom = 0;\n\n while (searchFrom < lineText.length) {\n const markerOffset = lineText.indexOf(\"===\", searchFrom);\n if (markerOffset === -1) {\n break;\n }\n\n const markerIndex = lineStart + markerOffset;\n const isNegated = markerIndex > 0 && docText[markerIndex - 1] === \"!\";\n if (\n !isNegated &&\n !isInsideComment(markerIndex) &&\n !isInsideVariable(markerIndex)\n ) {\n markerPositions.push(markerIndex);\n }\n\n searchFrom = markerOffset + 3;\n }\n\n for (let i = 0; i + 1 < markerPositions.length; i += 2) {\n ranges.push({\n from: markerPositions[i],\n to: markerPositions[i + 1] + 3,\n className: \"syntax-fixed\",\n });\n }\n\n if (newlineIndex === -1) {\n break;\n }\n\n lineStart = newlineIndex + 1;\n }\n\n return ranges;\n}\n\nfunction collectCommentRanges(\n docText: string,\n isInsideVariable: (position: number) => boolean\n): SyntaxHighlightRange[] {\n const ranges: SyntaxHighlightRange[] = [];\n let match;\n\n commentRegex.lastIndex = 0;\n while ((match = commentRegex.exec(docText)) !== null) {\n if (isInsideVariable(match.index)) continue;\n ranges.push({\n from: match.index,\n to: match.index + match[0].length,\n className: \"syntax-comment\",\n });\n }\n\n return ranges;\n}\n\n/**\n * Collects non-overlapping fixed-output and comment wrapper ranges.\n *\n * @param docText - Document text to scan.\n * @returns Outer syntax highlight ranges sorted by document position.\n */\nexport function collectOuterBlockRanges(\n docText: string\n): SyntaxHighlightRange[] {\n const variables = findDocumentVariableMarkers(docText);\n const isInsideVariable = (position: number) =>\n variables.some(\n (marker) => position >= marker.start && position < marker.end\n );\n const commentRanges = collectCommentRanges(docText, isInsideVariable);\n const blockRanges = [\n ...collectMultilineFixedOutputRanges(docText, isInsideVariable),\n ...collectSingleLineFixedOutputRanges(\n docText,\n commentRanges,\n isInsideVariable\n ),\n ...commentRanges,\n ].sort((a, b) => {\n if (a.from !== b.from) return a.from - b.from;\n return b.to - a.to;\n });\n\n const outerRanges: SyntaxHighlightRange[] = [];\n\n for (const range of blockRanges) {\n const lastOuter = outerRanges[outerRanges.length - 1];\n if (!lastOuter || range.from >= lastOuter.to) {\n outerRanges.push(range);\n }\n }\n\n return outerRanges;\n}\n\n/**\n * Collects all custom syntax highlight ranges for editor decorations.\n *\n * @param docText - Document text to scan.\n * @param isCursorInside - Returns true when the current cursor is inside a range.\n * @returns Non-overlapping syntax highlight ranges sorted by document position.\n */\nexport function collectSyntaxHighlightRanges(\n docText: string,\n isCursorInside: (from: number, to: number) => boolean = () => false,\n questionMode = false\n): SyntaxHighlightRange[] {\n const matches: SyntaxHighlightRange[] = [];\n const documentVariables = findDocumentVariableMarkers(docText);\n const occupied: { from: number; to: number }[] = [];\n\n controlBlockRegex.lastIndex = 0;\n\n // Prevent overlapping decorations so styling stays deterministic\n const isOverlapping = (from: number, to: number) =>\n occupied.some((range) => !(to <= range.from || from >= range.to));\n\n const addMatch = (from: number, to: number, className: string) => {\n if (from >= to) return false;\n if (isOverlapping(from, to)) return false;\n occupied.push({ from, to });\n matches.push({ from, to, className });\n return true;\n };\n\n // 1. Outer block ranges win over any syntax inside them.\n for (const range of collectOuterBlockRanges(docText)) {\n addMatch(range.from, range.to, range.className);\n }\n\n // 2. Control Blocks\n for (const control of documentControlRanges(docText)) {\n // Native Markdown owns document boundaries. The shared token grammar still\n // supplies the exact source offsets used for individual editor decorations.\n controlBlockRegex.lastIndex = control.start;\n const match = controlBlockRegex.exec(docText);\n if (\n !match ||\n match.index !== control.start ||\n match.index + match[0].length !== control.end\n )\n continue;\n const fullStart = match.index;\n const fullEnd = match.index + match[0].length;\n const content = match[1];\n const contentStart = fullStart + 2; // after ?[\n if (\n isOverlapping(fullStart, fullEnd) ||\n documentVariables.some(\n (marker) => marker.start <= fullStart && fullStart < marker.end\n )\n ) {\n continue;\n }\n\n // Outer brackets and question mark\n addMatch(fullStart, fullStart + 1, \"syntax-keyword\"); // ?\n addMatch(fullStart + 1, fullStart + 2, \"syntax-bracket\"); // [\n addMatch(fullEnd - 1, fullEnd, \"syntax-bracket\"); // ]\n\n const variables = interactionVariableRanges(content);\n const firstVariable = variables[0];\n const percentIndex = firstVariable ? firstVariable.start - 1 : -1;\n const hasLeadingAssignment =\n percentIndex >= 0 &&\n content[percentIndex] === \"%\" &&\n trimVariablePadding(content.slice(0, percentIndex)) === \"\";\n if (content.startsWith(\"%\") || hasLeadingAssignment) {\n // Input / Select\n let percentClass = \"syntax-percent-invalid\";\n if (firstVariable && hasLeadingAssignment) {\n const varFrom = contentStart + firstVariable.start;\n const varTo = contentStart + firstVariable.end;\n const cursorInsideVar = isCursorInside(varFrom, varTo);\n percentClass =\n firstVariable.name !== null && !cursorInsideVar\n ? \"syntax-percent-valid\"\n : \"syntax-percent-invalid\";\n }\n const percentStart =\n contentStart + (hasLeadingAssignment ? percentIndex : 0);\n addMatch(percentStart, percentStart + 1, percentClass); // %\n\n const operatorRanges: { from: number; to: number }[] = [];\n const variableRanges: { from: number; to: number; className: string }[] =\n [];\n const appliedTokenRanges: { from: number; to: number }[] = [];\n\n // Keep a variable name atomic even when it contains option punctuation.\n for (const variable of variables) {\n variableRanges.push({\n from: contentStart + variable.start,\n to: contentStart + variable.end,\n className:\n variable.name === null\n ? \"syntax-variable-invalid\"\n : \"syntax-variable\",\n });\n }\n\n // Inner operators | || ... -- skipping any an option escaped, the way the parser does.\n // Painted as separators, they told the author the grammar had split an option that it\n // had in fact left whole.\n let scanIndex = 0;\n while (scanIndex < content.length) {\n const variable = variableRanges.find(\n (range) => contentStart + scanIndex === range.from\n );\n if (variable) {\n scanIndex = variable.to - contentStart;\n continue;\n }\n if (isEscape(content, scanIndex)) {\n scanIndex += 2;\n continue;\n }\n const operator = content.startsWith(\"||\", scanIndex)\n ? \"||\"\n : content[scanIndex] === \"|\"\n ? \"|\"\n : content.startsWith(\"...\", scanIndex)\n ? \"...\"\n : null;\n if (!operator) {\n scanIndex += 1;\n continue;\n }\n operatorRanges.push({\n from: contentStart + scanIndex,\n to: contentStart + scanIndex + operator.length,\n });\n scanIndex += operator.length;\n }\n\n const allTokens = [\n ...operatorRanges.map((range) => ({\n ...range,\n className: \"syntax-keyword\",\n })),\n ...variableRanges.map((range) => ({\n ...range,\n className: range.className,\n })),\n ].sort((a, b) => {\n if (a.from !== b.from) return a.from - b.from;\n return a.to - b.to;\n });\n\n for (const token of allTokens) {\n if (\n token.className.startsWith(\"syntax-variable\") &&\n isCursorInside(token.from, token.to)\n ) {\n continue;\n }\n if (addMatch(token.from, token.to, token.className)) {\n appliedTokenRanges.push({ from: token.from, to: token.to });\n }\n }\n\n // Content (Dark Blue) for remaining text segments\n const stringStart = percentStart + 1;\n const stringEnd = fullEnd - 1;\n let cursor = stringStart;\n const sortedApplied = appliedTokenRanges.sort((a, b) => {\n if (a.from !== b.from) return a.from - b.from;\n return a.to - b.to;\n });\n\n for (const token of sortedApplied) {\n if (cursor < token.from) {\n addMatch(cursor, token.from, \"syntax-string\");\n }\n cursor = Math.max(cursor, token.to);\n }\n if (cursor < stringEnd) {\n addMatch(cursor, stringEnd, \"syntax-string\");\n }\n } else {\n // Button ?[text]\n const variableRanges: { from: number; to: number; className: string }[] =\n [];\n const appliedVariableRanges: { from: number; to: number }[] = [];\n\n for (const variable of interactionVariableRanges(content)) {\n variableRanges.push({\n from: contentStart + variable.start,\n to: contentStart + variable.end,\n className:\n variable.name === null\n ? \"syntax-variable-invalid\"\n : \"syntax-variable\",\n });\n }\n\n const sortedVariables = variableRanges.sort((a, b) => {\n if (a.from !== b.from) return a.from - b.from;\n return a.to - b.to;\n });\n\n for (const variable of sortedVariables) {\n if (\n variable.className.startsWith(\"syntax-variable\") &&\n isCursorInside(variable.from, variable.to)\n ) {\n continue;\n }\n if (addMatch(variable.from, variable.to, variable.className)) {\n appliedVariableRanges.push({ from: variable.from, to: variable.to });\n }\n }\n\n const buttonTextStart = contentStart;\n const buttonTextEnd = fullEnd - 1;\n let cursor = buttonTextStart;\n\n for (const variable of appliedVariableRanges) {\n if (cursor < variable.from) {\n addMatch(cursor, variable.from, \"syntax-button-text\");\n }\n cursor = Math.max(cursor, variable.to);\n }\n if (cursor < buttonTextEnd) {\n addMatch(cursor, buttonTextEnd, \"syntax-button-text\");\n }\n }\n }\n\n // 3. Variables (only if not already decorated; invalid ones stay default outside control blocks)\n for (const variable of questionMode ? [] : documentVariables) {\n if (\n variable.name !== null &&\n !isCursorInside(variable.start, variable.end)\n ) {\n addMatch(variable.start, variable.end, \"syntax-variable\");\n }\n }\n\n // Sort matches by 'from' asc, then 'to' desc (longest first)\n matches.sort((a, b) => {\n if (a.from !== b.from) return a.from - b.from;\n return b.to - a.to;\n });\n\n return matches;\n}\n\nfunction buildDecorations(\n view: EditorView,\n questionMode = false\n): DecorationSet {\n const builder = new RangeSetBuilder<Decoration>();\n const docText = view.state.doc.toString();\n const matches = collectSyntaxHighlightRanges(\n docText,\n (from, to) => {\n return view.state.selection.ranges.some((range) => {\n return range.from >= from && range.to <= to;\n });\n },\n questionMode\n );\n\n for (const m of matches) {\n if (m.from < m.to) {\n try {\n builder.add(m.from, m.to, Decoration.mark({ class: m.className }));\n } catch (e) {\n console.warn(\"SyntaxHighlighter: Failed to add decoration\", m, e);\n }\n }\n }\n\n return builder.finish();\n}\n\nconst createSyntaxHighlighter = (questionMode = false) =>\n ViewPlugin.fromClass(\n class {\n decorations: DecorationSet;\n\n constructor(view: EditorView) {\n this.decorations = buildDecorations(view, questionMode);\n }\n\n update(update: ViewUpdate) {\n if (\n update.docChanged ||\n update.viewportChanged ||\n update.selectionSet\n ) {\n this.decorations = buildDecorations(update.view, questionMode);\n }\n }\n },\n {\n decorations: (instance) => instance.decorations,\n }\n );\n\nconst SyntaxHighlighter = createSyntaxHighlighter();\nexport const QuestionSyntaxHighlighter = createSyntaxHighlighter(true);\n\nexport default SyntaxHighlighter;\n"],"names":["commentRegex","interactionVariableRanges","text","markers","findVariableMarkers","pending","controlBlockRegex","INTERACTION_CONTENT_SOURCE","documentControlRanges","getMarkdownSourceAnalysis","collectMultilineFixedOutputRanges","docText","isInsideVariable","ranges","pendingStart","lineStart","newlineIndex","lineEnd","collectSingleLineFixedOutputRanges","commentRanges","commentIndex","isInsideComment","index","range","lineText","markerPositions","searchFrom","markerOffset","markerIndex","i","collectCommentRanges","match","collectOuterBlockRanges","variables","findDocumentVariableMarkers","position","marker","blockRanges","a","b","outerRanges","lastOuter","collectSyntaxHighlightRanges","isCursorInside","questionMode","matches","documentVariables","occupied","isOverlapping","from","to","addMatch","className","control","fullStart","fullEnd","content","contentStart","firstVariable","percentIndex","hasLeadingAssignment","trimVariablePadding","percentClass","varFrom","varTo","cursorInsideVar","percentStart","operatorRanges","variableRanges","appliedTokenRanges","variable","scanIndex","isEscape","operator","allTokens","token","stringStart","stringEnd","cursor","sortedApplied","appliedVariableRanges","sortedVariables","buttonTextStart","buttonTextEnd","buildDecorations","view","builder","RangeSetBuilder","m","Decoration","e","createSyntaxHighlighter","ViewPlugin","update","instance","SyntaxHighlighter","QuestionSyntaxHighlighter"],"mappings":"0XAiBMA,EAAe,mBAGfC,EAA6BC,GAAiB,CAClD,MAAMC,EAAUC,EAAAA,oBAAoBF,CAAI,EAClCG,EAAUH,EAAK,QAAQ,KAAMC,EAAQ,GAAG,EAAE,GAAG,KAAO,CAAC,EAC3D,OAAOE,IAAY,GACfF,EACA,CAAC,GAAGA,EAAS,CAAE,MAAOE,EAAS,IAAKH,EAAK,OAAQ,KAAM,KAAM,CACnE,EAKMI,EAAoB,IAAI,OA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ACFF,EAAQ,IAAIE,EAAE,KAAMA,EAAE,GAAIC,aAAW,KAAK,CAAE,MAAOD,EAAE,SAAA,CAAW,CAAC,CACnE,OAASE,EAAG,CACV,QAAQ,KAAK,8CAA+CF,EAAGE,CAAC,CAClE,CAIJ,OAAOJ,EAAQ,OAAA,CACjB,CAEA,MAAMK,EAA0B,CAAC/C,EAAe,KAC9CgD,EAAAA,WAAW,UACT,KAAM,CAGJ,YAAYP,EAAkB,CAC5B,KAAK,YAAcD,EAAiBC,EAAMzC,CAAY,CACxD,CAEA,OAAOiD,EAAoB,EAEvBA,EAAO,YACPA,EAAO,iBACPA,EAAO,gBAEP,KAAK,YAAcT,EAAiBS,EAAO,KAAMjD,CAAY,EAEjE,CAAA,EAEF,CACE,YAAckD,GAAaA,EAAS,WAAA,CAExC,EAEIC,EAAoBJ,EAAA,EACbK,EAA4BL,EAAwB,EAAI"}
|
|
1
|
+
{"version":3,"file":"SyntaxHighlighter.cjs","sources":["../../../../src/components/MarkdownFlowEditor/plugins/SyntaxHighlighter.ts"],"sourcesContent":["import {\n Decoration,\n DecorationSet,\n EditorView,\n ViewPlugin,\n ViewUpdate,\n} from \"@codemirror/view\";\nimport { RangeSetBuilder } from \"@codemirror/state\";\nimport { getMarkdownSourceAnalysis } from \"../../ContentRender/utils/inline-code-ranges\";\nimport { INTERACTION_CONTENT_SOURCE, isEscape } from \"remark-flow\";\n\nimport {\n findVariableMarkers,\n findDocumentVariableMarkers,\n trimVariablePadding,\n} from \"../utils\";\n\nconst commentRegex = /<!--[\\s\\S]*?-->/g;\n\n// An unfinished marker still owns its tail, so nested syntax stays literal while typing.\nconst interactionVariableRanges = (text: string) => {\n const markers = findVariableMarkers(text);\n const pending = text.indexOf(\"{{\", markers.at(-1)?.end ?? 0);\n return pending === -1\n ? markers\n : [...markers, { start: pending, end: text.length, name: null }];\n};\n// The grammar's own definition of where an interaction ends, so a `\\]` an option escaped does\n// not cut the highlight short, and the same `(?!\\()` the parser uses, so `?[text](url)` stays a\n// markdown link. Taken from remark-flow rather than written again here: the editor and the\n// parser have to agree about what they are looking at.\nconst controlBlockRegex = new RegExp(\n `\\\\?\\\\[(${INTERACTION_CONTENT_SOURCE})\\\\](?!\\\\()`,\n \"g\"\n);\n\nconst documentControlRanges = (text: string) =>\n getMarkdownSourceAnalysis(text).interactions;\n\nexport interface SyntaxHighlightRange {\n from: number;\n to: number;\n className: string;\n}\n\nfunction collectMultilineFixedOutputRanges(\n docText: string,\n isInsideVariable: (position: number) => boolean\n): SyntaxHighlightRange[] {\n const ranges: SyntaxHighlightRange[] = [];\n let pendingStart: number | null = null;\n let lineStart = 0;\n\n while (lineStart <= docText.length) {\n const newlineIndex = docText.indexOf(\"\\n\", lineStart);\n const lineEnd = newlineIndex === -1 ? docText.length : newlineIndex;\n const lineText = docText.slice(lineStart, lineEnd);\n\n if (lineText.trim() === \"!===\" && !isInsideVariable(lineStart)) {\n if (pendingStart === null) {\n pendingStart = lineStart;\n } else {\n ranges.push({\n from: pendingStart,\n to: lineEnd,\n className: \"syntax-fixed\",\n });\n pendingStart = null;\n }\n }\n\n if (newlineIndex === -1) {\n break;\n }\n\n lineStart = newlineIndex + 1;\n }\n\n return ranges;\n}\n\nfunction collectSingleLineFixedOutputRanges(\n docText: string,\n commentRanges: SyntaxHighlightRange[],\n isInsideVariable: (position: number) => boolean\n): SyntaxHighlightRange[] {\n const ranges: SyntaxHighlightRange[] = [];\n let commentIndex = 0;\n\n const isInsideComment = (index: number) => {\n while (\n commentIndex < commentRanges.length &&\n commentRanges[commentIndex].to <= index\n ) {\n commentIndex++;\n }\n\n const range = commentRanges[commentIndex];\n return !!range && index >= range.from && index < range.to;\n };\n\n let lineStart = 0;\n while (lineStart <= docText.length) {\n const newlineIndex = docText.indexOf(\"\\n\", lineStart);\n const lineEnd = newlineIndex === -1 ? docText.length : newlineIndex;\n const lineText = docText.slice(lineStart, lineEnd);\n const markerPositions: number[] = [];\n let searchFrom = 0;\n\n while (searchFrom < lineText.length) {\n const markerOffset = lineText.indexOf(\"===\", searchFrom);\n if (markerOffset === -1) {\n break;\n }\n\n const markerIndex = lineStart + markerOffset;\n const isNegated = markerIndex > 0 && docText[markerIndex - 1] === \"!\";\n if (\n !isNegated &&\n !isInsideComment(markerIndex) &&\n !isInsideVariable(markerIndex)\n ) {\n markerPositions.push(markerIndex);\n }\n\n searchFrom = markerOffset + 3;\n }\n\n for (let i = 0; i + 1 < markerPositions.length; i += 2) {\n ranges.push({\n from: markerPositions[i],\n to: markerPositions[i + 1] + 3,\n className: \"syntax-fixed\",\n });\n }\n\n if (newlineIndex === -1) {\n break;\n }\n\n lineStart = newlineIndex + 1;\n }\n\n return ranges;\n}\n\nfunction collectCommentRanges(\n docText: string,\n isInsideVariable: (position: number) => boolean\n): SyntaxHighlightRange[] {\n const ranges: SyntaxHighlightRange[] = [];\n let match;\n\n commentRegex.lastIndex = 0;\n while ((match = commentRegex.exec(docText)) !== null) {\n if (isInsideVariable(match.index)) continue;\n ranges.push({\n from: match.index,\n to: match.index + match[0].length,\n className: \"syntax-comment\",\n });\n }\n\n return ranges;\n}\n\n/**\n * Collects non-overlapping preserved output and comment wrapper ranges.\n *\n * @param docText - Document text to scan.\n * @returns Outer syntax highlight ranges sorted by document position.\n */\nexport function collectOuterBlockRanges(\n docText: string\n): SyntaxHighlightRange[] {\n const variables = findDocumentVariableMarkers(docText);\n const isInsideVariable = (position: number) =>\n variables.some(\n (marker) => position >= marker.start && position < marker.end\n );\n const commentRanges = collectCommentRanges(docText, isInsideVariable);\n const blockRanges = [\n ...collectMultilineFixedOutputRanges(docText, isInsideVariable),\n ...collectSingleLineFixedOutputRanges(\n docText,\n commentRanges,\n isInsideVariable\n ),\n ...commentRanges,\n ].sort((a, b) => {\n if (a.from !== b.from) return a.from - b.from;\n return b.to - a.to;\n });\n\n const outerRanges: SyntaxHighlightRange[] = [];\n\n for (const range of blockRanges) {\n const lastOuter = outerRanges[outerRanges.length - 1];\n if (!lastOuter || range.from >= lastOuter.to) {\n outerRanges.push(range);\n }\n }\n\n return outerRanges;\n}\n\n/**\n * Collects all custom syntax highlight ranges for editor decorations.\n *\n * @param docText - Document text to scan.\n * @param isCursorInside - Returns true when the current cursor is inside a range.\n * @returns Non-overlapping syntax highlight ranges sorted by document position.\n */\nexport function collectSyntaxHighlightRanges(\n docText: string,\n isCursorInside: (from: number, to: number) => boolean = () => false\n): SyntaxHighlightRange[] {\n const matches: SyntaxHighlightRange[] = [];\n const documentVariables = findDocumentVariableMarkers(docText);\n const occupied: { from: number; to: number }[] = [];\n\n controlBlockRegex.lastIndex = 0;\n\n // Prevent overlapping decorations so styling stays deterministic\n const isOverlapping = (from: number, to: number) =>\n occupied.some((range) => !(to <= range.from || from >= range.to));\n\n const addMatch = (from: number, to: number, className: string) => {\n if (from >= to) return false;\n if (isOverlapping(from, to)) return false;\n occupied.push({ from, to });\n matches.push({ from, to, className });\n return true;\n };\n\n // 1. Outer block ranges win over any syntax inside them.\n for (const range of collectOuterBlockRanges(docText)) {\n addMatch(range.from, range.to, range.className);\n }\n\n // 2. Control Blocks\n for (const control of documentControlRanges(docText)) {\n // Native Markdown owns document boundaries. The shared token grammar still\n // supplies the exact source offsets used for individual editor decorations.\n controlBlockRegex.lastIndex = control.start;\n const match = controlBlockRegex.exec(docText);\n if (\n !match ||\n match.index !== control.start ||\n match.index + match[0].length !== control.end\n )\n continue;\n const fullStart = match.index;\n const fullEnd = match.index + match[0].length;\n const content = match[1];\n const contentStart = fullStart + 2; // after ?[\n if (\n isOverlapping(fullStart, fullEnd) ||\n documentVariables.some(\n (marker) => marker.start <= fullStart && fullStart < marker.end\n )\n ) {\n continue;\n }\n\n // Outer brackets and question mark\n addMatch(fullStart, fullStart + 1, \"syntax-keyword\"); // ?\n addMatch(fullStart + 1, fullStart + 2, \"syntax-bracket\"); // [\n addMatch(fullEnd - 1, fullEnd, \"syntax-bracket\"); // ]\n\n const variables = interactionVariableRanges(content);\n const firstVariable = variables[0];\n const percentIndex = firstVariable ? firstVariable.start - 1 : -1;\n const hasLeadingAssignment =\n percentIndex >= 0 &&\n content[percentIndex] === \"%\" &&\n trimVariablePadding(content.slice(0, percentIndex)) === \"\";\n if (content.startsWith(\"%\") || hasLeadingAssignment) {\n // Input / Select\n let percentClass = \"syntax-percent-invalid\";\n if (firstVariable && hasLeadingAssignment) {\n const varFrom = contentStart + firstVariable.start;\n const varTo = contentStart + firstVariable.end;\n const cursorInsideVar = isCursorInside(varFrom, varTo);\n percentClass =\n firstVariable.name !== null && !cursorInsideVar\n ? \"syntax-percent-valid\"\n : \"syntax-percent-invalid\";\n }\n const percentStart =\n contentStart + (hasLeadingAssignment ? percentIndex : 0);\n addMatch(percentStart, percentStart + 1, percentClass); // %\n\n const operatorRanges: { from: number; to: number }[] = [];\n const variableRanges: { from: number; to: number; className: string }[] =\n [];\n const appliedTokenRanges: { from: number; to: number }[] = [];\n\n // Keep a variable name atomic even when it contains option punctuation.\n for (const variable of variables) {\n variableRanges.push({\n from: contentStart + variable.start,\n to: contentStart + variable.end,\n className:\n variable.name === null\n ? \"syntax-variable-invalid\"\n : \"syntax-variable\",\n });\n }\n\n // Inner operators | || ... -- skipping any an option escaped, the way the parser does.\n // Painted as separators, they told the author the grammar had split an option that it\n // had in fact left whole.\n let scanIndex = 0;\n while (scanIndex < content.length) {\n const variable = variableRanges.find(\n (range) => contentStart + scanIndex === range.from\n );\n if (variable) {\n scanIndex = variable.to - contentStart;\n continue;\n }\n if (isEscape(content, scanIndex)) {\n scanIndex += 2;\n continue;\n }\n const operator = content.startsWith(\"||\", scanIndex)\n ? \"||\"\n : content[scanIndex] === \"|\"\n ? \"|\"\n : content.startsWith(\"...\", scanIndex)\n ? \"...\"\n : null;\n if (!operator) {\n scanIndex += 1;\n continue;\n }\n operatorRanges.push({\n from: contentStart + scanIndex,\n to: contentStart + scanIndex + operator.length,\n });\n scanIndex += operator.length;\n }\n\n const allTokens = [\n ...operatorRanges.map((range) => ({\n ...range,\n className: \"syntax-keyword\",\n })),\n ...variableRanges.map((range) => ({\n ...range,\n className: range.className,\n })),\n ].sort((a, b) => {\n if (a.from !== b.from) return a.from - b.from;\n return a.to - b.to;\n });\n\n for (const token of allTokens) {\n if (\n token.className.startsWith(\"syntax-variable\") &&\n isCursorInside(token.from, token.to)\n ) {\n continue;\n }\n if (addMatch(token.from, token.to, token.className)) {\n appliedTokenRanges.push({ from: token.from, to: token.to });\n }\n }\n\n // Content (Dark Blue) for remaining text segments\n const stringStart = percentStart + 1;\n const stringEnd = fullEnd - 1;\n let cursor = stringStart;\n const sortedApplied = appliedTokenRanges.sort((a, b) => {\n if (a.from !== b.from) return a.from - b.from;\n return a.to - b.to;\n });\n\n for (const token of sortedApplied) {\n if (cursor < token.from) {\n addMatch(cursor, token.from, \"syntax-string\");\n }\n cursor = Math.max(cursor, token.to);\n }\n if (cursor < stringEnd) {\n addMatch(cursor, stringEnd, \"syntax-string\");\n }\n } else {\n // Button ?[text]\n const variableRanges: { from: number; to: number; className: string }[] =\n [];\n const appliedVariableRanges: { from: number; to: number }[] = [];\n\n for (const variable of interactionVariableRanges(content)) {\n variableRanges.push({\n from: contentStart + variable.start,\n to: contentStart + variable.end,\n className:\n variable.name === null\n ? \"syntax-variable-invalid\"\n : \"syntax-variable\",\n });\n }\n\n const sortedVariables = variableRanges.sort((a, b) => {\n if (a.from !== b.from) return a.from - b.from;\n return a.to - b.to;\n });\n\n for (const variable of sortedVariables) {\n if (\n variable.className.startsWith(\"syntax-variable\") &&\n isCursorInside(variable.from, variable.to)\n ) {\n continue;\n }\n if (addMatch(variable.from, variable.to, variable.className)) {\n appliedVariableRanges.push({ from: variable.from, to: variable.to });\n }\n }\n\n const buttonTextStart = contentStart;\n const buttonTextEnd = fullEnd - 1;\n let cursor = buttonTextStart;\n\n for (const variable of appliedVariableRanges) {\n if (cursor < variable.from) {\n addMatch(cursor, variable.from, \"syntax-button-text\");\n }\n cursor = Math.max(cursor, variable.to);\n }\n if (cursor < buttonTextEnd) {\n addMatch(cursor, buttonTextEnd, \"syntax-button-text\");\n }\n }\n }\n\n // 3. Variables (only if not already decorated; invalid ones stay default outside control blocks)\n for (const variable of documentVariables) {\n if (\n variable.name !== null &&\n !isCursorInside(variable.start, variable.end)\n ) {\n addMatch(variable.start, variable.end, \"syntax-variable\");\n }\n }\n\n // Sort matches by 'from' asc, then 'to' desc (longest first)\n matches.sort((a, b) => {\n if (a.from !== b.from) return a.from - b.from;\n return b.to - a.to;\n });\n\n return matches;\n}\n\nfunction buildDecorations(view: EditorView): DecorationSet {\n const builder = new RangeSetBuilder<Decoration>();\n const docText = view.state.doc.toString();\n const matches = collectSyntaxHighlightRanges(docText, (from, to) => {\n return view.state.selection.ranges.some((range) => {\n return range.from >= from && range.to <= to;\n });\n });\n\n for (const m of matches) {\n if (m.from < m.to) {\n try {\n builder.add(m.from, m.to, Decoration.mark({ class: m.className }));\n } catch (e) {\n console.warn(\"SyntaxHighlighter: Failed to add decoration\", m, e);\n }\n }\n }\n\n return builder.finish();\n}\n\nconst SyntaxHighlighter = ViewPlugin.fromClass(\n class {\n decorations: DecorationSet;\n\n constructor(view: EditorView) {\n this.decorations = buildDecorations(view);\n }\n\n update(update: ViewUpdate) {\n if (update.docChanged || update.viewportChanged || update.selectionSet) {\n this.decorations = buildDecorations(update.view);\n }\n }\n },\n {\n decorations: (instance) => instance.decorations,\n }\n);\n\nexport default SyntaxHighlighter;\n"],"names":["commentRegex","interactionVariableRanges","text","markers","findVariableMarkers","pending","controlBlockRegex","INTERACTION_CONTENT_SOURCE","documentControlRanges","getMarkdownSourceAnalysis","collectMultilineFixedOutputRanges","docText","isInsideVariable","ranges","pendingStart","lineStart","newlineIndex","lineEnd","collectSingleLineFixedOutputRanges","commentRanges","commentIndex","isInsideComment","index","range","lineText","markerPositions","searchFrom","markerOffset","markerIndex","i","collectCommentRanges","match","collectOuterBlockRanges","variables","findDocumentVariableMarkers","position","marker","blockRanges","a","b","outerRanges","lastOuter","collectSyntaxHighlightRanges","isCursorInside","matches","documentVariables","occupied","isOverlapping","from","to","addMatch","className","control","fullStart","fullEnd","content","contentStart","firstVariable","percentIndex","hasLeadingAssignment","trimVariablePadding","percentClass","varFrom","varTo","cursorInsideVar","percentStart","operatorRanges","variableRanges","appliedTokenRanges","variable","scanIndex","isEscape","operator","allTokens","token","stringStart","stringEnd","cursor","sortedApplied","appliedVariableRanges","sortedVariables","buttonTextStart","buttonTextEnd","buildDecorations","view","builder","RangeSetBuilder","m","Decoration","e","SyntaxHighlighter","ViewPlugin","update","instance"],"mappings":"0XAiBMA,EAAe,mBAGfC,EAA6BC,GAAiB,CAClD,MAAMC,EAAUC,EAAAA,oBAAoBF,CAAI,EAClCG,EAAUH,EAAK,QAAQ,KAAMC,EAAQ,GAAG,EAAE,GAAG,KAAO,CAAC,EAC3D,OAAOE,IAAY,GACfF,EACA,CAAC,GAAGA,EAAS,CAAE,MAAOE,EAAS,IAAKH,EAAK,OAAQ,KAAM,KAAM,CACnE,EAKMI,EAAoB,IAAI,OAC5B,UAAUC,EAAAA,YAAAA,0BAA0B,cACpC,GACF,EAEMC,EAAyBN,GAC7BO,4BAA0BP,CAAI,EAAE,aAQlC,SAASQ,EACPC,EACAC,EACwB,CACxB,MAAMC,EAAiC,CAAA,EACvC,IAAIC,EAA8B,KAC9BC,EAAY,EAEhB,KAAOA,GAAaJ,EAAQ,QAAQ,CAClC,MAAMK,EAAeL,EAAQ,QAAQ;AAAA,EAAMI,CAAS,EAC9CE,EAAUD,IAAiB,GAAKL,EAAQ,OAASK,EAgBvD,GAfiBL,EAAQ,MAAMI,EAAWE,CAAO,EAEpC,KAAA,IAAW,QAAU,CAACL,EAAiBG,CAAS,IACvDD,IAAiB,KACnBA,EAAeC,GAEfF,EAAO,KAAK,CACV,KAAMC,EACN,GAAIG,EACJ,UAAW,cAAA,CACZ,EACDH,EAAe,OAIfE,IAAiB,GACnB,MAGFD,EAAYC,EAAe,CAC7B,CAEA,OAAOH,CACT,CAEA,SAASK,EACPP,EACAQ,EACAP,EACwB,CACxB,MAA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S,MAClB,CAAC1B,EAAe0B,EAAS,MAAOA,EAAS,GAAG,GAE5CnB,EAASmB,EAAS,MAAOA,EAAS,IAAK,iBAAiB,EAK5D,OAAAzB,EAAQ,KAAK,CAACN,EAAGC,IACXD,EAAE,OAASC,EAAE,KAAaD,EAAE,KAAOC,EAAE,KAClCA,EAAE,GAAKD,EAAE,EACjB,EAEMM,CACT,CAEA,SAASuC,EAAiBC,EAAiC,CACzD,MAAMC,EAAU,IAAIC,kBACd3E,EAAUyE,EAAK,MAAM,IAAI,SAAA,EACzBxC,EAAUF,EAA6B/B,EAAS,CAACqC,EAAMC,IACpDmC,EAAK,MAAM,UAAU,OAAO,KAAM7D,GAChCA,EAAM,MAAQyB,GAAQzB,EAAM,IAAM0B,CAC1C,CACF,EAED,UAAWsC,KAAK3C,EACd,GAAI2C,EAAE,KAAOA,EAAE,GACb,GAAI,CACFF,EAAQ,IAAIE,EAAE,KAAMA,EAAE,GAAIC,aAAW,KAAK,CAAE,MAAOD,EAAE,SAAA,CAAW,CAAC,CACnE,OAASE,EAAG,CACV,QAAQ,KAAK,8CAA+CF,EAAGE,CAAC,CAClE,CAIJ,OAAOJ,EAAQ,OAAA,CACjB,CAEA,MAAMK,EAAoBC,EAAAA,WAAW,UACnC,KAAM,CAGJ,YAAYP,EAAkB,CAC5B,KAAK,YAAcD,EAAiBC,CAAI,CAC1C,CAEA,OAAOQ,EAAoB,EACrBA,EAAO,YAAcA,EAAO,iBAAmBA,EAAO,gBACxD,KAAK,YAAcT,EAAiBS,EAAO,IAAI,EAEnD,CAAA,EAEF,CACE,YAAcC,GAAaA,EAAS,WAAA,CAExC"}
|
|
@@ -5,7 +5,7 @@ export interface SyntaxHighlightRange {
|
|
|
5
5
|
className: string;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
|
-
* Collects non-overlapping
|
|
8
|
+
* Collects non-overlapping preserved output and comment wrapper ranges.
|
|
9
9
|
*
|
|
10
10
|
* @param docText - Document text to scan.
|
|
11
11
|
* @returns Outer syntax highlight ranges sorted by document position.
|
|
@@ -18,13 +18,9 @@ export declare function collectOuterBlockRanges(docText: string): SyntaxHighligh
|
|
|
18
18
|
* @param isCursorInside - Returns true when the current cursor is inside a range.
|
|
19
19
|
* @returns Non-overlapping syntax highlight ranges sorted by document position.
|
|
20
20
|
*/
|
|
21
|
-
export declare function collectSyntaxHighlightRanges(docText: string, isCursorInside?: (from: number, to: number) => boolean
|
|
21
|
+
export declare function collectSyntaxHighlightRanges(docText: string, isCursorInside?: (from: number, to: number) => boolean): SyntaxHighlightRange[];
|
|
22
22
|
declare const SyntaxHighlighter: ViewPlugin<{
|
|
23
23
|
decorations: DecorationSet;
|
|
24
24
|
update(update: ViewUpdate): void;
|
|
25
25
|
}, undefined>;
|
|
26
|
-
export declare const QuestionSyntaxHighlighter: ViewPlugin<{
|
|
27
|
-
decorations: DecorationSet;
|
|
28
|
-
update(update: ViewUpdate): void;
|
|
29
|
-
}, undefined>;
|
|
30
26
|
export default SyntaxHighlighter;
|
|
@@ -1,221 +1,216 @@
|
|
|
1
|
-
import { ViewPlugin as
|
|
2
|
-
import { RangeSetBuilder as
|
|
3
|
-
import { getMarkdownSourceAnalysis as
|
|
1
|
+
import { ViewPlugin as H, Decoration as P } from "../../../node_modules/@codemirror/view/dist/index.es.js";
|
|
2
|
+
import { RangeSetBuilder as L } from "../../../node_modules/@codemirror/state/dist/index.es.js";
|
|
3
|
+
import { getMarkdownSourceAnalysis as _ } from "../../ContentRender/utils/inline-code-ranges.es.js";
|
|
4
4
|
import { d as A } from "../../../_virtual/index.es.js";
|
|
5
|
-
import { findDocumentVariableMarkers as B, trimVariablePadding as
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
return f === -1 ?
|
|
9
|
-
},
|
|
5
|
+
import { findDocumentVariableMarkers as B, trimVariablePadding as U, findVariableMarkers as $ } from "../utils.es.js";
|
|
6
|
+
const M = /<!--[\s\S]*?-->/g, F = (n) => {
|
|
7
|
+
const i = $(n), f = n.indexOf("{{", i.at(-1)?.end ?? 0);
|
|
8
|
+
return f === -1 ? i : [...i, { start: f, end: n.length, name: null }];
|
|
9
|
+
}, V = new RegExp(
|
|
10
10
|
`\\?\\[(${A.INTERACTION_CONTENT_SOURCE})\\](?!\\()`,
|
|
11
11
|
"g"
|
|
12
|
-
),
|
|
13
|
-
function
|
|
12
|
+
), j = (n) => _(n).interactions;
|
|
13
|
+
function q(n, i) {
|
|
14
14
|
const f = [];
|
|
15
|
-
let
|
|
16
|
-
for (;
|
|
17
|
-
const
|
|
18
|
-
`,
|
|
19
|
-
if (n.slice(
|
|
20
|
-
from:
|
|
21
|
-
to:
|
|
15
|
+
let l = null, s = 0;
|
|
16
|
+
for (; s <= n.length; ) {
|
|
17
|
+
const u = n.indexOf(`
|
|
18
|
+
`, s), e = u === -1 ? n.length : u;
|
|
19
|
+
if (n.slice(s, e).trim() === "!===" && !i(s) && (l === null ? l = s : (f.push({
|
|
20
|
+
from: l,
|
|
21
|
+
to: e,
|
|
22
22
|
className: "syntax-fixed"
|
|
23
|
-
}),
|
|
23
|
+
}), l = null)), u === -1)
|
|
24
24
|
break;
|
|
25
|
-
|
|
25
|
+
s = u + 1;
|
|
26
26
|
}
|
|
27
27
|
return f;
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
const
|
|
31
|
-
let
|
|
32
|
-
const
|
|
33
|
-
for (;
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
return !!
|
|
29
|
+
function z(n, i, f) {
|
|
30
|
+
const l = [];
|
|
31
|
+
let s = 0;
|
|
32
|
+
const u = (t) => {
|
|
33
|
+
for (; s < i.length && i[s].to <= t; )
|
|
34
|
+
s++;
|
|
35
|
+
const r = i[s];
|
|
36
|
+
return !!r && t >= r.from && t < r.to;
|
|
37
37
|
};
|
|
38
|
-
let
|
|
39
|
-
for (;
|
|
38
|
+
let e = 0;
|
|
39
|
+
for (; e <= n.length; ) {
|
|
40
40
|
const t = n.indexOf(`
|
|
41
|
-
`,
|
|
42
|
-
let
|
|
43
|
-
for (;
|
|
44
|
-
const
|
|
45
|
-
if (
|
|
41
|
+
`, e), r = t === -1 ? n.length : t, d = n.slice(e, r), x = [];
|
|
42
|
+
let g = 0;
|
|
43
|
+
for (; g < d.length; ) {
|
|
44
|
+
const c = d.indexOf("===", g);
|
|
45
|
+
if (c === -1)
|
|
46
46
|
break;
|
|
47
|
-
const
|
|
48
|
-
!(
|
|
47
|
+
const p = e + c;
|
|
48
|
+
!(p > 0 && n[p - 1] === "!") && !u(p) && !f(p) && x.push(p), g = c + 3;
|
|
49
49
|
}
|
|
50
|
-
for (let
|
|
51
|
-
|
|
52
|
-
from:
|
|
53
|
-
to:
|
|
50
|
+
for (let c = 0; c + 1 < x.length; c += 2)
|
|
51
|
+
l.push({
|
|
52
|
+
from: x[c],
|
|
53
|
+
to: x[c + 1] + 3,
|
|
54
54
|
className: "syntax-fixed"
|
|
55
55
|
});
|
|
56
56
|
if (t === -1)
|
|
57
57
|
break;
|
|
58
|
-
|
|
58
|
+
e = t + 1;
|
|
59
59
|
}
|
|
60
|
-
return
|
|
60
|
+
return l;
|
|
61
61
|
}
|
|
62
|
-
function
|
|
62
|
+
function G(n, i) {
|
|
63
63
|
const f = [];
|
|
64
|
-
let
|
|
65
|
-
for (
|
|
66
|
-
|
|
67
|
-
from:
|
|
68
|
-
to:
|
|
64
|
+
let l;
|
|
65
|
+
for (M.lastIndex = 0; (l = M.exec(n)) !== null; )
|
|
66
|
+
i(l.index) || f.push({
|
|
67
|
+
from: l.index,
|
|
68
|
+
to: l.index + l[0].length,
|
|
69
69
|
className: "syntax-comment"
|
|
70
70
|
});
|
|
71
71
|
return f;
|
|
72
72
|
}
|
|
73
|
-
function
|
|
74
|
-
const
|
|
75
|
-
(t) =>
|
|
76
|
-
),
|
|
77
|
-
...
|
|
78
|
-
...
|
|
73
|
+
function J(n) {
|
|
74
|
+
const i = B(n), f = (e) => i.some(
|
|
75
|
+
(t) => e >= t.start && e < t.end
|
|
76
|
+
), l = G(n, f), s = [
|
|
77
|
+
...q(n, f),
|
|
78
|
+
...z(
|
|
79
79
|
n,
|
|
80
|
-
|
|
80
|
+
l,
|
|
81
81
|
f
|
|
82
82
|
),
|
|
83
|
-
...
|
|
84
|
-
].sort((
|
|
85
|
-
for (const
|
|
86
|
-
const t =
|
|
87
|
-
(!t ||
|
|
83
|
+
...l
|
|
84
|
+
].sort((e, t) => e.from !== t.from ? e.from - t.from : t.to - e.to), u = [];
|
|
85
|
+
for (const e of s) {
|
|
86
|
+
const t = u[u.length - 1];
|
|
87
|
+
(!t || e.from >= t.to) && u.push(e);
|
|
88
88
|
}
|
|
89
|
-
return
|
|
89
|
+
return u;
|
|
90
90
|
}
|
|
91
|
-
function
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
for (const
|
|
96
|
-
t
|
|
97
|
-
for (const
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
if (!
|
|
91
|
+
function K(n, i = () => !1) {
|
|
92
|
+
const f = [], l = B(n), s = [];
|
|
93
|
+
V.lastIndex = 0;
|
|
94
|
+
const u = (t, r) => s.some((d) => !(r <= d.from || t >= d.to)), e = (t, r, d) => t >= r || u(t, r) ? !1 : (s.push({ from: t, to: r }), f.push({ from: t, to: r, className: d }), !0);
|
|
95
|
+
for (const t of J(n))
|
|
96
|
+
e(t.from, t.to, t.className);
|
|
97
|
+
for (const t of j(n)) {
|
|
98
|
+
V.lastIndex = t.start;
|
|
99
|
+
const r = V.exec(n);
|
|
100
|
+
if (!r || r.index !== t.start || r.index + r[0].length !== t.end)
|
|
101
101
|
continue;
|
|
102
|
-
const
|
|
103
|
-
if (
|
|
104
|
-
(
|
|
102
|
+
const d = r.index, x = r.index + r[0].length, g = r[1], c = d + 2;
|
|
103
|
+
if (u(d, x) || l.some(
|
|
104
|
+
(b) => b.start <= d && d < b.end
|
|
105
105
|
))
|
|
106
106
|
continue;
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
if (
|
|
110
|
-
let
|
|
111
|
-
if (
|
|
112
|
-
const
|
|
113
|
-
|
|
107
|
+
e(d, d + 1, "syntax-keyword"), e(d + 1, d + 2, "syntax-bracket"), e(x - 1, x, "syntax-bracket");
|
|
108
|
+
const p = F(g), y = p[0], w = y ? y.start - 1 : -1, E = w >= 0 && g[w] === "%" && U(g.slice(0, w)) === "";
|
|
109
|
+
if (g.startsWith("%") || E) {
|
|
110
|
+
let b = "syntax-percent-invalid";
|
|
111
|
+
if (y && E) {
|
|
112
|
+
const o = c + y.start, h = c + y.end, I = i(o, h);
|
|
113
|
+
b = y.name !== null && !I ? "syntax-percent-valid" : "syntax-percent-invalid";
|
|
114
114
|
}
|
|
115
|
-
const v =
|
|
116
|
-
|
|
117
|
-
const O = [], N = [],
|
|
118
|
-
for (const
|
|
115
|
+
const v = c + (E ? w : 0);
|
|
116
|
+
e(v, v + 1, b);
|
|
117
|
+
const O = [], N = [], R = [];
|
|
118
|
+
for (const o of p)
|
|
119
119
|
N.push({
|
|
120
|
-
from:
|
|
121
|
-
to:
|
|
122
|
-
className:
|
|
120
|
+
from: c + o.start,
|
|
121
|
+
to: c + o.end,
|
|
122
|
+
className: o.name === null ? "syntax-variable-invalid" : "syntax-variable"
|
|
123
123
|
});
|
|
124
|
-
let
|
|
125
|
-
for (;
|
|
126
|
-
const
|
|
127
|
-
(
|
|
124
|
+
let m = 0;
|
|
125
|
+
for (; m < g.length; ) {
|
|
126
|
+
const o = N.find(
|
|
127
|
+
(I) => c + m === I.from
|
|
128
128
|
);
|
|
129
|
-
if (
|
|
130
|
-
|
|
129
|
+
if (o) {
|
|
130
|
+
m = o.to - c;
|
|
131
131
|
continue;
|
|
132
132
|
}
|
|
133
|
-
if (A.isEscape(
|
|
134
|
-
|
|
133
|
+
if (A.isEscape(g, m)) {
|
|
134
|
+
m += 2;
|
|
135
135
|
continue;
|
|
136
136
|
}
|
|
137
|
-
const
|
|
138
|
-
if (!
|
|
139
|
-
|
|
137
|
+
const h = g.startsWith("||", m) ? "||" : g[m] === "|" ? "|" : g.startsWith("...", m) ? "..." : null;
|
|
138
|
+
if (!h) {
|
|
139
|
+
m += 1;
|
|
140
140
|
continue;
|
|
141
141
|
}
|
|
142
142
|
O.push({
|
|
143
|
-
from:
|
|
144
|
-
to:
|
|
145
|
-
}),
|
|
143
|
+
from: c + m,
|
|
144
|
+
to: c + m + h.length
|
|
145
|
+
}), m += h.length;
|
|
146
146
|
}
|
|
147
|
-
const
|
|
148
|
-
...O.map((
|
|
149
|
-
...
|
|
147
|
+
const a = [
|
|
148
|
+
...O.map((o) => ({
|
|
149
|
+
...o,
|
|
150
150
|
className: "syntax-keyword"
|
|
151
151
|
})),
|
|
152
|
-
...N.map((
|
|
153
|
-
...
|
|
154
|
-
className:
|
|
152
|
+
...N.map((o) => ({
|
|
153
|
+
...o,
|
|
154
|
+
className: o.className
|
|
155
155
|
}))
|
|
156
|
-
].sort((
|
|
157
|
-
for (const
|
|
158
|
-
|
|
159
|
-
const
|
|
160
|
-
let k =
|
|
161
|
-
const
|
|
162
|
-
for (const
|
|
163
|
-
k <
|
|
164
|
-
k <
|
|
156
|
+
].sort((o, h) => o.from !== h.from ? o.from - h.from : o.to - h.to);
|
|
157
|
+
for (const o of a)
|
|
158
|
+
o.className.startsWith("syntax-variable") && i(o.from, o.to) || e(o.from, o.to, o.className) && R.push({ from: o.from, to: o.to });
|
|
159
|
+
const S = v + 1, C = x - 1;
|
|
160
|
+
let k = S;
|
|
161
|
+
const D = R.sort((o, h) => o.from !== h.from ? o.from - h.from : o.to - h.to);
|
|
162
|
+
for (const o of D)
|
|
163
|
+
k < o.from && e(k, o.from, "syntax-string"), k = Math.max(k, o.to);
|
|
164
|
+
k < C && e(k, C, "syntax-string");
|
|
165
165
|
} else {
|
|
166
|
-
const
|
|
167
|
-
for (const
|
|
168
|
-
|
|
169
|
-
from:
|
|
170
|
-
to:
|
|
171
|
-
className:
|
|
166
|
+
const b = [], v = [];
|
|
167
|
+
for (const a of F(g))
|
|
168
|
+
b.push({
|
|
169
|
+
from: c + a.start,
|
|
170
|
+
to: c + a.end,
|
|
171
|
+
className: a.name === null ? "syntax-variable-invalid" : "syntax-variable"
|
|
172
172
|
});
|
|
173
|
-
const O =
|
|
174
|
-
for (const
|
|
175
|
-
|
|
176
|
-
const N =
|
|
177
|
-
let
|
|
178
|
-
for (const
|
|
179
|
-
|
|
180
|
-
|
|
173
|
+
const O = b.sort((a, S) => a.from !== S.from ? a.from - S.from : a.to - S.to);
|
|
174
|
+
for (const a of O)
|
|
175
|
+
a.className.startsWith("syntax-variable") && i(a.from, a.to) || e(a.from, a.to, a.className) && v.push({ from: a.from, to: a.to });
|
|
176
|
+
const N = c, R = x - 1;
|
|
177
|
+
let m = N;
|
|
178
|
+
for (const a of v)
|
|
179
|
+
m < a.from && e(m, a.from, "syntax-button-text"), m = Math.max(m, a.to);
|
|
180
|
+
m < R && e(m, R, "syntax-button-text");
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
|
-
for (const
|
|
184
|
-
|
|
185
|
-
return
|
|
183
|
+
for (const t of l)
|
|
184
|
+
t.name !== null && !i(t.start, t.end) && e(t.start, t.end, "syntax-variable");
|
|
185
|
+
return f.sort((t, r) => t.from !== r.from ? t.from - r.from : r.to - t.to), f;
|
|
186
186
|
}
|
|
187
|
-
function W(n
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
s
|
|
192
|
-
);
|
|
193
|
-
for (const a of d)
|
|
194
|
-
if (a.from < a.to)
|
|
187
|
+
function W(n) {
|
|
188
|
+
const i = new L(), f = n.state.doc.toString(), l = K(f, (s, u) => n.state.selection.ranges.some((e) => e.from >= s && e.to <= u));
|
|
189
|
+
for (const s of l)
|
|
190
|
+
if (s.from < s.to)
|
|
195
191
|
try {
|
|
196
|
-
|
|
197
|
-
} catch (
|
|
198
|
-
console.warn("SyntaxHighlighter: Failed to add decoration",
|
|
192
|
+
i.add(s.from, s.to, P.mark({ class: s.className }));
|
|
193
|
+
} catch (u) {
|
|
194
|
+
console.warn("SyntaxHighlighter: Failed to add decoration", s, u);
|
|
199
195
|
}
|
|
200
|
-
return
|
|
196
|
+
return i.finish();
|
|
201
197
|
}
|
|
202
|
-
const
|
|
198
|
+
const tt = H.fromClass(
|
|
203
199
|
class {
|
|
204
|
-
constructor(
|
|
205
|
-
this.decorations = W(
|
|
200
|
+
constructor(n) {
|
|
201
|
+
this.decorations = W(n);
|
|
206
202
|
}
|
|
207
|
-
update(
|
|
208
|
-
(
|
|
203
|
+
update(n) {
|
|
204
|
+
(n.docChanged || n.viewportChanged || n.selectionSet) && (this.decorations = W(n.view));
|
|
209
205
|
}
|
|
210
206
|
},
|
|
211
207
|
{
|
|
212
|
-
decorations: (
|
|
208
|
+
decorations: (n) => n.decorations
|
|
213
209
|
}
|
|
214
|
-
)
|
|
210
|
+
);
|
|
215
211
|
export {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
et as default
|
|
212
|
+
J as collectOuterBlockRanges,
|
|
213
|
+
K as collectSyntaxHighlightRanges,
|
|
214
|
+
tt as default
|
|
220
215
|
};
|
|
221
216
|
//# sourceMappingURL=SyntaxHighlighter.es.js.map
|