markdown-flow-ui 0.1.111 → 0.1.112
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/index.cjs10.js +1 -1
- package/dist/_virtual/index.cjs9.js +1 -1
- package/dist/_virtual/index.es10.js +2 -2
- package/dist/_virtual/index.es9.js +2 -2
- package/dist/assets/markdown-flow-ui.css +1 -1
- package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.cjs.js +1 -1
- package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.cjs.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.es.js +321 -317
- package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/plugins/ImgPlaceholder.cjs.js +1 -1
- package/dist/components/MarkdownFlowEditor/plugins/ImgPlaceholder.cjs.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/plugins/ImgPlaceholder.es.js +48 -44
- package/dist/components/MarkdownFlowEditor/plugins/ImgPlaceholder.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/plugins/PlaceholderWidget.cjs.js +1 -1
- package/dist/components/MarkdownFlowEditor/plugins/PlaceholderWidget.cjs.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/plugins/PlaceholderWidget.d.ts +1 -0
- package/dist/components/MarkdownFlowEditor/plugins/PlaceholderWidget.es.js +38 -28
- package/dist/components/MarkdownFlowEditor/plugins/PlaceholderWidget.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/plugins/VideoPlaceholder.cjs.js +1 -1
- package/dist/components/MarkdownFlowEditor/plugins/VideoPlaceholder.cjs.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/plugins/VideoPlaceholder.es.js +28 -26
- package/dist/components/MarkdownFlowEditor/plugins/VideoPlaceholder.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/utils.cjs.js +1 -1
- package/dist/components/MarkdownFlowEditor/utils.cjs.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/utils.d.ts +8 -1
- package/dist/components/MarkdownFlowEditor/utils.es.js +59 -39
- package/dist/components/MarkdownFlowEditor/utils.es.js.map +1 -1
- package/dist/components/Slide/Slide.cjs.js.map +1 -1
- package/dist/components/Slide/Slide.es.js.map +1 -1
- package/dist/components/Slide/useSlide.cjs.js.map +1 -1
- package/dist/components/Slide/useSlide.es.js.map +1 -1
- package/dist/components/Slide/utils/streamingNavigation.cjs.js.map +1 -1
- package/dist/components/Slide/utils/streamingNavigation.es.js.map +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.cjs.js.map +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.es.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.es.js +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e={
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e={};exports.__exports=e;
|
|
2
2
|
//# sourceMappingURL=index.cjs10.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e={};exports.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e={exports:{}};exports.__module=e;
|
|
2
2
|
//# sourceMappingURL=index.cjs9.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.tag-image,.tag-video{display:inline-flex;align-items:center;gap:
|
|
1
|
+
.tag-image,.tag-video{display:inline-flex;align-items:center;gap:4px;cursor:pointer;font-family:inherit;font-size:14px;font-style:normal;font-weight:400;line-height:20px}.tag-placeholder-content{display:inline-flex;align-items:center;gap:2px;color:#0e46fb}.tag-fixed-output-marker{color:purple}:is(.tag-image,.tag-video,.tag-variable):hover{background:#d9d9d9;border-radius:2px}.tag-placeholder-icon{display:inline-flex;align-items:center;justify-content:center;color:inherit}.tag-placeholder-icon svg{width:14px;height:14px}.tag-fixed-text,.tag-fixed-text-placeholder{display:inline-block;background-color:#d7d7d7;border-radius:6px;padding:0 6px;margin:0 0 0 4px;line-height:1.6;cursor:text;position:relative}.tag-fixed-text{color:inherit}.tag-fixed-text-placeholder{color:var(--base-muted-foreground, #737373);font-size:12px}.tag-fixed-text-placeholder .tag-fixed-text-inner{color:inherit}.tag-fixed-text-tag{display:inline-block;width:0;overflow:hidden;opacity:0;pointer-events:none}.tag-fixed-text:hover:after,.tag-fixed-text-placeholder:hover:after{content:attr(data-tooltip);position:absolute;left:50%;bottom:calc(100% + 6px);transform:translate(-50%);background-color:#000000bf;color:#fff;font-size:12px;padding:4px 8px;border-radius:4px;white-space:nowrap;pointer-events:none;z-index:10}.tag-fixed-text:hover:before,.tag-fixed-text-placeholder:hover:before{content:"";position:absolute;left:50%;bottom:100%;transform:translate(-50%);border-width:4px;border-style:solid;border-color:rgba(0,0,0,.75) transparent transparent transparent;pointer-events:none;z-index:10}.tag-divider{display:flex;align-items:center;gap:9px;width:100%;padding:6px 0;cursor:pointer;-webkit-user-select:none;user-select:none}.tag-divider img{width:24px;height:24px;flex-shrink:0}.tag-divider-line{flex:1;border-bottom:1px dashed rgba(0,0,0,.25)}.tag-icon{margin-left:10px}.tag-variable{color:#0e46fb;cursor:pointer}.tag-variable:hover{color:#0331c9}.syntax-string{color:#d4631c!important}.syntax-keyword,.syntax-bracket,.syntax-bracket *{color:purple!important}.syntax-variable{color:#0e46fb!important}.syntax-variable-invalid{color:#d4631c!important}.syntax-percent-valid{color:#0e46fb!important}.syntax-percent-invalid{color:#d4631c!important}.syntax-comment,.syntax-comment *{color:green!important}.syntax-fixed,.syntax-fixed *{color:purple!important}.syntax-button-text{color:#d4631c!important}.cm-tooltip.cm-tooltip-autocomplete{border:1px solid #e5e5e5;background-color:#fff;border-radius:4px;box-shadow:0 2px 6px #0000001a;box-sizing:border-box;width:150px;padding:5px}.cm-tooltip-autocomplete ul li{width:138px}.cm-tooltip-autocomplete ul li:hover{background-color:#f9fafb;cursor:pointer;width:140px}.cm-activeLine .cm-line{background-color:transparent}.cm-editor{padding:0}.cm-editor:focus{outline:none}.cm-editor .cm-content:focus-visible{outline:none;box-shadow:none}.cm-editor .cm-scroller{padding:24px;box-sizing:border-box}.cm-editor .cm-content{caret-color:var(--base-foreground, #0a0a0a)}.markdown-flow-editor-toolbar{position:sticky;top:0;z-index:1;left:0;right:0;display:flex;align-items:center;gap:12px;border-bottom:1px solid var(--base-border, #e5e5e5);border-radius:var(--border-radius-rounded-lg, 10px) var(--border-radius-rounded-lg, 10px) 0 0;padding:6px 12px;background:var(--base-muted, #f5f5f5)}.markdown-flow-editor-toolbar-left{display:flex;align-items:center;gap:0;flex-wrap:wrap}.markdown-flow-editor-toolbar-right-wrapper{margin-left:auto;display:flex;align-items:center}.markdown-flow-editor-toolbar-right{display:inline-flex;align-items:center;gap:8px}.markdown-flow-editor-toolbar-right-item{display:inline-flex}.markdown-flow-editor-toolbar button{display:inline-flex;align-items:center;justify-content:center;border-radius:4px;border:none;background:transparent;color:#0a0a0a;cursor:pointer;padding:6px;transition:background .2s ease,color .2s ease}.markdown-flow-editor-toolbar button:last-child{margin-right:0}.markdown-flow-editor-toolbar button:not(:disabled):hover{background:#0000000d}.markdown-flow-editor-toolbar button[data-active=true]{background:#00000014}.markdown-flow-editor-toolbar button:disabled{color:#0a0a0a66;cursor:not-allowed}.markdown-flow-editor-toolbar-right-button{border:1px solid var(--base-border, #e5e5e5);background:#fff;padding:6px 10px;border-radius:6px;font-size:13px;gap:6px;display:inline-flex;align-items:center;justify-content:center}.markdown-flow-editor-toolbar-right-button:not(:disabled):hover{background:#0000000a}.toolbar-right-icon{display:inline-flex;align-items:center}.markdown-flow-editor-variable-search{width:260px;border-radius:8px;border:1px solid var(--base-border, #e5e5e5);background:#fff;box-shadow:0 20px 25px -5px #0000001a,0 10px 10px -5px #0000000a;padding:10px;z-index:50}.variable-search-icon{position:absolute;left:12px;top:50%;transform:translateY(-50%);width:16px;height:16px;color:var(--base-muted-foreground, #737373)}.variable-search-input{padding-left:32px;height:36px;border-radius:8px}.variable-search-list{max-height:320px;overflow-y:auto;margin-top:8px}.variable-search-section+.variable-search-section{margin-top:12px}.variable-search-section-title{font-size:12px;font-weight:600;color:var(--base-muted-foreground, #737373);margin:4px 0}.variable-search-item{width:100%;text-align:left;border:none;background:transparent;border-radius:6px;padding:8px 10px;display:flex;flex-direction:column;gap:2px;cursor:pointer}.variable-search-item:not(:disabled):hover,.variable-search-item-active{background:#0e46fb14}.variable-search-item-name{font-size:14px;font-weight:600;color:#111}.variable-search-item-label{font-size:12px;color:var(--base-muted-foreground, #737373)}.variable-search-empty{font-size:13px;color:var(--base-muted-foreground, #737373);text-align:center;padding:24px 8px 8px}.markdown-flow-editor[data-disabled=true]{opacity:.8;background:var(--base-muted, #f5f5f5);cursor:not-allowed}.markdown-flow-editor[data-disabled=true] .cm-editor{background-color:transparent}.markdown-flow-editor[data-disabled=true] .cm-content{cursor:not-allowed}.markdown-flow-editor{color:#0a0a0a;font-family:PingFang SC,Microsoft YaHei,Source Han Sans SC,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;position:relative;font-size:var(--text-md-font-size, 16px);font-style:normal;font-weight:400;border-radius:var(--border-radius-rounded-lg, 10px);border:var(--border-width-border, 1px) solid var(--base-border, #e5e5e5);background:var(--base-card, #fff);box-shadow:var(--shadow-xs-offset-x, 0) var(--shadow-xs-offset-y, 1px) var(--shadow-xs-blur-radius, 2px) var(--shadow-xs-spread-radius, 0) var(--shadow-xs-color, rgba(0, 0, 0, .05));height:100%;width:100%;overflow:auto}.ͼ1 .cm-line,.ͼ1 .cm-content{padding:0}.cm-line{font-family:PingFang SC,Microsoft YaHei,Source Han Sans SC,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;line-height:30px}.cm-editor.cm-focused{outline:none}.cm-activeLine{background-color:transparent!important}.c6,.ͼ1b,.c1c,.ͼ6,.ͼ7,.ͼ1c,.c7{text-decoration:auto}.markdown-flow-editor[data-disabled=true]{background-color:#fff}pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}/*!
|
|
2
2
|
Theme: GitHub
|
|
3
3
|
Description: Light theme as seen on github.com
|
|
4
4
|
Author: github.com
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("../../_virtual/jsx-runtime.cjs.js"),r=require("react"),Be=require("../../markdown-flow-ui/node_modules/.pnpm/@uiw_react-codemirror@4.25.2_@babel_runtime@7.28.4_@codemirror_autocomplete@6.19.1_@cod_3434c6a3f0eb7fac49dbaa3a471d1162/node_modules/@uiw/react-codemirror/esm/index.cjs.js"),He=require("../../markdown-flow-ui/node_modules/.pnpm/@codemirror_autocomplete@6.19.1/node_modules/@codemirror/autocomplete/dist/index.cjs.js"),pe=require("../../markdown-flow-ui/node_modules/.pnpm/@codemirror_view@6.38.6/node_modules/@codemirror/view/dist/index.cjs.js"),Ue=require("../../markdown-flow-ui/node_modules/.pnpm/@codemirror_lang-markdown@6.5.0/node_modules/@codemirror/lang-markdown/dist/index.cjs.js"),de=require("../../markdown-flow-ui/node_modules/.pnpm/@codemirror_language@6.11.3/node_modules/@codemirror/language/dist/index.cjs.js"),K=require("../ui/tooltip.cjs.js"),Fe=require("./components/CustomDialog.cjs.js"),De=require("./components/CustomPopover.cjs.js"),_e=require("./components/EditorToolbar.cjs.js"),Ge=require("./components/VariableSearchDropdown.cjs.js"),We=require("./editor-context.cjs.js"),Qe=require("./components/ImageInject.cjs.js"),Ye=require("./components/VideoInject.cjs.js"),Je=require("./components/VariableSelect.cjs.js"),m=require("./types.cjs.js");;/* empty css */const N=require("./utils.cjs.js"),Ke=require("./plugins/ImgPlaceholder.cjs.js"),Xe=require("./plugins/VideoPlaceholder.cjs.js"),Ze=require("./plugins/VariablePlaceholder.cjs.js"),et=require("./plugins/SyntaxHighlighter.cjs.js"),Ce=require("./locales/en-US.json.cjs.js"),tt=require("./locales/zh-CN.json.cjs.js"),X=require("../../markdown-flow-ui/node_modules/.pnpm/i18next@23.16.8/node_modules/i18next/dist/esm/i18next.cjs.js"),nt=require("../../markdown-flow-ui/node_modules/.pnpm/react-i18next@15.7.4_i18next@23.16.8_react-dom@19.0.1_react@19.0.1__react@19.0.1_typescript@5.9.3/node_modules/react-i18next/dist/es/initReactI18next.cjs.js"),ot=require("../../markdown-flow-ui/node_modules/.pnpm/react-i18next@15.7.4_i18next@23.16.8_react-dom@19.0.1_react@19.0.1__react@19.0.1_typescript@5.9.3/node_modules/react-i18next/dist/es/useTranslation.cjs.js"),Z={"en-US":{translation:Ce.default},"zh-CN":{translation:tt.default}};X.default.isInitialized?Object.entries(Z).forEach(([C,p])=>{X.default.addResourceBundle(C,"translation",p.translation,!0,!0)}):X.default.use(nt.initReactI18next).init({resources:Z,lng:"en-US",fallbackLng:"en-US",interpolation:{escapeValue:!1}});const ge=[],xe=(C,p)=>{if(!C||p<0)return!1;const v=N.createVariableExpressionRegexp();let V;for(;(V=v.exec(C))!==null;){const E=V.index??0,H=E+V[0].length,k=E+2,U=H-2;if(p>=k&&p<=U)return!0;v.lastIndex===V.index&&v.lastIndex++}return!1},rt=(C="")=>`{{${C}}}`,st=({content:C="",editMode:p="codeEdit",variables:v,systemVariables:V,onChange:E,onBlur:H,locale:k="en-US",uploadProps:U,disabled:o=!1,toolbarActionsRight:F,onReady:be})=>{const{t:i,i18n:$}=ot.useTranslation();r.useEffect(()=>{k&&$.language!==k&&$.changeLanguage(k)},[$,k]);const Se=k||$.language,O=Z[Se]?.translation??Ce.default,x=r.useMemo(()=>({image:i("toolbarInsertImage",{defaultValue:"Insert image"}),video:i("toolbarInsertVideo",{defaultValue:"Insert video"}),addVariable:i("toolbarInsertNewVariable",{defaultValue:"Insert new variable"}),search:i("toolbarInsertExistingVariable",{defaultValue:"Insert existing variable"}),confirmOutput:i("toolbarConfirmOutput",{defaultValue:"Confirm output"}),insertLink:i("toolbarInsertLink",{defaultValue:"Insert link"}),insertButton:i("toolbarInsertButton",{defaultValue:"Insert button"}),insertSingleChoice:i("toolbarInsertSingleChoice",{defaultValue:"Insert single choice"}),insertMultiChoice:i("toolbarInsertMultiChoice",{defaultValue:"Insert multi choice"}),insertInput:i("toolbarInsertInput",{defaultValue:"Insert input"}),singleChoiceOption1:i("toolbarChoiceOption1",{defaultValue:"Option 1"}),singleChoiceOption2:i("toolbarChoiceOption2",{defaultValue:"Option 2"}),inputPlaceholder:i("toolbarInputPlaceholder",{defaultValue:"Please enter"})}),[i]),Ve=r.useMemo(()=>({searchPlaceholder:i("variableSearchPlaceholder",{defaultValue:"Search variable"}),systemLabel:i("variableSectionSystem","System Variables"),customLabel:i("variableSectionCustom","Custom Variables"),emptyLabel:i("variableNotFound","No variables found")}),[i]),Ee=p==="quickEdit"?i("placeholderQuickEdit",{defaultValue:i("placeholderCodeEdit",{defaultValue:i("placeholder")})}):i("placeholderCodeEdit",{defaultValue:i("placeholder")}),R=r.useMemo(()=>{const e=new Set;return(V??ge).filter(t=>{const s=typeof t?.name=="string"?t.name.toLowerCase():"";return!s||e.has(s)?!1:(e.add(s),!0)})},[V]),D=r.useMemo(()=>{const e=new Set(R.map(s=>s.name.toLowerCase())),t=new Set;return(v??ge).filter(s=>{const n=typeof s?.name=="string"?s.name.toLowerCase():"";return!n||e.has(n)||t.has(n)?!1:(t.add(n),!0)})},[v,R]),[_,I]=r.useState(!1),[G,j]=r.useState(!1),[ke,L]=r.useState(null),[ee,W]=r.useState(D),[M,Ie]=r.useState(R);r.useEffect(()=>{W(D)},[D]),r.useEffect(()=>{Ie(R)},[R]);const[b,w]=r.useState(m.SelectedOption.Empty),[f,P]=r.useState(),a=r.useRef(null),A=r.useRef(null),z=r.useRef(null),[Q,te]=r.useState(!1),g=r.useCallback(()=>{te(!1),z.current=null},[]),we=r.useCallback(e=>{if(!o){if(Q&&z.current===e){g();return}z.current=e,te(!0)}},[g,o,Q]),ve={selectedOption:b,setSelectedOption:w,dialogOpen:_,setDialogOpen:I,popoverOpen:G,setPopoverOpen:j,popoverPosition:ke,setPopoverPosition:L};r.useEffect(()=>{o&&(I(!1),j(!1),w(m.SelectedOption.Empty),P(null),L(null),g())},[g,o,I,j,L,w,P]);const T=r.useCallback(e=>{if(p!=="quickEdit"||!e)return;const t=N.extractVariableNames(e);if(!t.length)return;const s=new Set(M.map(n=>n.name.toLowerCase()));W(n=>{const l=new Set(n.map(d=>d.name.toLowerCase())),u=new Set,h=[];return t.forEach(d=>{const S=d.toLowerCase();!d||s.has(S)||l.has(S)||u.has(S)||(h.push({name:d}),u.add(S))}),h.length?[...h,...n]:n})},[p,M]);r.useEffect(()=>{T(C)},[C,T]);const Y=r.useCallback(e=>{if(!o)if(g(),w(e),e===m.SelectedOption.Variable){if(a.current){const{state:t}=a.current,s=t.selection.main.from,n=a.current.coordsAtPos(s);n&&L({x:n.left,y:n.bottom})}j(!0)}else I(!0)},[g,o]),q=r.useCallback(e=>{if(o||!a.current)return;const{state:t,dispatch:s}=a.current,n=t.selection.main.from;s({changes:{from:n,insert:e},selection:{anchor:n+e.length}})},[a,o]),ne=r.useCallback(e=>{if(o||!a.current)return;const{state:t,dispatch:s}=a.current,n=t.selection.main;s({changes:{from:n.from,to:n.to,insert:e},selection:{anchor:n.from+e.length}})},[o]),oe=r.useCallback(()=>{a.current?.focus()},[]),re=r.useCallback(()=>a.current?.state.doc.toString()??"",[]),se=r.useCallback(e=>{if(o)return;if(!a.current){E?.(e);return}const t=a.current,{state:s,dispatch:n}=t;n({changes:{from:0,to:s.doc.length,insert:e},selection:{anchor:e.length}})},[o,E]),ae=r.useCallback(()=>{if(o||!f||!a.current||f.from===-1)return;const{from:e,to:t}=f,{dispatch:s}=a.current;s({changes:{from:e,to:t,insert:""}})},[f,a,o]),B=r.useCallback((e,t,s=!1)=>{if(o||!a.current)return;const n=a.current,{state:l,dispatch:u}=n,h=t??l.selection.main,d=rt(e),S=s?d.length:2+e.length;u({changes:{from:h.from,to:h.to,insert:d},selection:{anchor:h.from+S}}),n.focus()},[o]),Oe=r.useCallback(()=>{o||(g(),B(""))},[g,o,B]),je=r.useCallback(()=>{if(o||!a.current)return;const e=a.current,{state:t,dispatch:s}=e,n=t.selection.main;s({changes:{from:n.from,to:n.to,insert:"======"},selection:{anchor:n.from+3}}),e.focus()},[o]),Te=r.useCallback(()=>{if(o||!a.current)return;const e=a.current,{state:t,dispatch:s}=e,n=t.selection.main;s({changes:{from:n.from,to:n.to,insert:"[]()"},selection:{anchor:n.from+1}}),e.focus()},[o]),qe=r.useCallback(()=>{if(o||!a.current)return;const e=a.current,{state:t,dispatch:s}=e,n=t.selection.main;s({changes:{from:n.from,to:n.to,insert:"?[]"},selection:{anchor:n.from+2}}),e.focus()},[o]),ye=r.useCallback(()=>{if(o||!a.current)return;const e=a.current,{state:t,dispatch:s}=e,n=t.selection.main,l=x.singleChoiceOption1,u=x.singleChoiceOption2,h=`?[%{{}} ${l} | ${u}]`;s({changes:{from:n.from,to:n.to,insert:h},selection:{anchor:n.from+5}}),e.focus()},[o,x.singleChoiceOption1,x.singleChoiceOption2]),Re=r.useCallback(()=>{if(o||!a.current)return;const e=a.current,{state:t,dispatch:s}=e,n=t.selection.main,l=x.singleChoiceOption1,u=x.singleChoiceOption2,h=`?[%{{}} ${l} || ${u}]`;s({changes:{from:n.from,to:n.to,insert:h},selection:{anchor:n.from+5}}),e.focus()},[o,x.singleChoiceOption1,x.singleChoiceOption2]),Le=r.useCallback(()=>{if(o||!a.current)return;const e=a.current,{state:t,dispatch:s}=e,n=t.selection.main,u=`?[%{{}}...${x.inputPlaceholder??"请输入"}]`;s({changes:{from:n.from,to:n.to,insert:u},selection:{anchor:n.from+5}}),e.focus()},[o,x.inputPlaceholder]),Pe=r.useCallback(({resourceUrl:e,resourceTitle:t,scalePercent:s})=>{if(!e||o)return;const n=e.replace(/"/g,"""),l=typeof s=="number"?Math.max(1,Math.min(1e3,Math.round(s))):void 0,u=t?.replace(/"/g,"""),d=t?(J=>J.replace(/([\[\]\\])/g,"\\$1"))(t):"",S=typeof l=="number"&&l!==100?` width="${l}%"`:"",ze=u?` alt="${u}" title="${u}"`:"",he=!l||l===100?``:`<img src="${n}"${ze}${S} />`;if(f?.type===m.SelectedOption.Image){if(ae(),!a.current)return;const{dispatch:J}=a.current;J({changes:{from:f.from,insert:he}})}else q(he);I(!1)},[q,b,o]),Ne=r.useCallback(({resourceUrl:e,resourceTitle:t})=>{if(o)return;const s=N.getVideoContentToInsert(e,t);if(f?.type===m.SelectedOption.Video){if(ae(),!a.current)return;const{dispatch:n}=a.current;n({changes:{from:f.from,insert:s}})}else q(s);I(!1)},[q,b,o]),ie=r.useCallback(e=>{if(o)return;const t=f?.type===m.SelectedOption.Variable?{from:f.from,to:f.to}:void 0;B(e.name,t,!0),j(!1),g()},[o,B,f,g]),le=r.useCallback(()=>He.autocompletion({override:[N.createSlashCommands(Y,{image:O.slashImage,video:O.slashVideo,variable:O.slashVariable})]}),[O.slashImage,O.slashVideo,O.slashVariable,Y]),ce=r.useCallback(e=>{if(a.current=e.view,p==="quickEdit"&&A.current&&e.selectionSet){const t=e.state.selection.main.head,s=e.state.doc.toString();xe(s,t)||(T(s),A.current=null)}},[T,p]),ue=r.useCallback(e=>{if(e.stopPropagation(),o)return;const{type:t,from:s,to:n,dataset:l,target:u}=e.detail,h=N.parseContentInfo(t,l);if(P({type:t,value:h,from:s,to:n}),w(t),t===m.SelectedOption.Variable){if(u){const d=u.getBoundingClientRect();L({x:d.left,y:d.bottom})}j(!0)}else I(!0)},[o]);r.useEffect(()=>{_||(w(m.SelectedOption.Empty),P(null))},[_]),r.useEffect(()=>{!G&&b===m.SelectedOption.Variable&&(w(m.SelectedOption.Empty),P(null))},[G,b]),r.useEffect(()=>{const e=t=>{t.detail.view===a.current&&ue(t)};return window.addEventListener("globalTagClick",e),()=>{window.removeEventListener("globalTagClick",e)}},[ue]);const $e=r.useMemo(()=>{const e=[pe.EditorView.lineWrapping,Ue.markdown(),de.syntaxHighlighting(de.defaultHighlightStyle),et.default];return o||e.push(le()),p==="quickEdit"&&e.push(Ke.default,Xe.default,Ze.default),e.push(pe.EditorView.updateListener.of(t=>{ce(t)})),e},[o,p,le,ce]),Me=r.useCallback(e=>{if(o)return;const t=a.current?.state.selection.main.head??-1;xe(e,t)?A.current=e:(A.current=null,T(e)),E?.(e)},[T,E,o]),fe=!o&&Q,y=r.useMemo(()=>({insertTextAtCursor:q,replaceSelection:ne,focus:oe,getContent:re,setContent:se}),[oe,re,q,ne,se]),me=r.useCallback(e=>{o||"render"in e||e.onClick?.(y)},[o,y]),Ae=r.useMemo(()=>F?.length?c.jsxRuntimeExports.jsx("div",{className:"markdown-flow-editor-toolbar-right",children:F.map(e=>{if("render"in e)return c.jsxRuntimeExports.jsx("div",{className:"markdown-flow-editor-toolbar-right-item",children:e.render(y)},e.key);const t=e.label||e.tooltip||void 0,s=c.jsxRuntimeExports.jsxs("button",{type:"button",disabled:o||e.disabled,onClick:()=>me(e),className:"markdown-flow-editor-toolbar-right-button","aria-label":t,title:e.label||e.tooltip,children:[e.icon?c.jsxRuntimeExports.jsx("span",{className:"toolbar-right-icon",children:e.icon}):null,e.label?c.jsxRuntimeExports.jsx("span",{className:"toolbar-right-label",children:e.label}):null]},e.key),n=e.tooltip?c.jsxRuntimeExports.jsxs(K.Tooltip,{children:[c.jsxRuntimeExports.jsx(K.TooltipTrigger,{asChild:!0,children:s}),c.jsxRuntimeExports.jsx(K.TooltipContent,{side:"top",children:e.tooltip})]}):s;return c.jsxRuntimeExports.jsx("div",{className:"markdown-flow-editor-toolbar-right-item",children:n},e.key)})}):null,[o,y,me,F]);return r.useEffect(()=>{be?.(y)},[y]),c.jsxRuntimeExports.jsxs("div",{className:"markdown-flow-editor","data-disabled":o?"true":void 0,"aria-disabled":o,children:[c.jsxRuntimeExports.jsx(_e.default,{disabled:o,labels:x,onSelect:Y,onInsertVariablePlaceholder:Oe,onVariableSearchToggle:we,onVariableSearchClose:g,onInsertConfirmOutput:je,onInsertLink:Te,onInsertButton:qe,onInsertSingleChoice:ye,onInsertMultiChoice:Re,onInsertInputField:Le,variableSearchActive:fe,rightSlot:Ae}),c.jsxRuntimeExports.jsx(Ge.default,{open:fe,anchorElement:z.current,onClose:g,onSelect:ie,variables:ee,systemVariables:M,labels:Ve}),c.jsxRuntimeExports.jsx("div",{className:"markdown-flow-editor-body relative overflow-auto",children:c.jsxRuntimeExports.jsxs(We.default.Provider,{value:ve,children:[c.jsxRuntimeExports.jsx(Be.default,{extensions:$e,basicSetup:{lineNumbers:!1,syntaxHighlighting:!0,highlightActiveLine:!0,highlightActiveLineGutter:!0,foldGutter:!1},className:"rounded-md",placeholder:Ee,value:C,theme:"light",minHeight:"2rem",editable:!o,onChange:Me,onBlur:H}),!o&&c.jsxRuntimeExports.jsxs(Fe.default,{labels:{title:b===m.SelectedOption.Image?i("dialogTitleImage"):b===m.SelectedOption.Video?i("dialogTitleVideo"):b===m.SelectedOption.Variable?i("dialogTitleVariable"):i("dialogTitle")},children:[b===m.SelectedOption.Image&&c.jsxRuntimeExports.jsx(Qe.default,{value:f?.value,onSelect:Pe,uploadProps:U}),b===m.SelectedOption.Video&&c.jsxRuntimeExports.jsx(Ye.default,{value:f?.value,onSelect:Ne})]}),!o&&c.jsxRuntimeExports.jsx(De.default,{children:c.jsxRuntimeExports.jsx(Je.default,{variables:ee,systemVariables:M,selectedName:f?.value?.variableName,onSelect:ie,onAddVariable:e=>{W(t=>{const s=e.name.toLowerCase();return t.some(l=>l.name.toLowerCase()===s)?t:[e,...t]})}})})]})})]})};exports.default=st;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("../../_virtual/jsx-runtime.cjs.js"),r=require("react"),$e=require("../../markdown-flow-ui/node_modules/.pnpm/@uiw_react-codemirror@4.25.2_@babel_runtime@7.28.4_@codemirror_autocomplete@6.19.1_@cod_3434c6a3f0eb7fac49dbaa3a471d1162/node_modules/@uiw/react-codemirror/esm/index.cjs.js"),ze=require("../../markdown-flow-ui/node_modules/.pnpm/@codemirror_autocomplete@6.19.1/node_modules/@codemirror/autocomplete/dist/index.cjs.js"),me=require("../../markdown-flow-ui/node_modules/.pnpm/@codemirror_view@6.38.6/node_modules/@codemirror/view/dist/index.cjs.js"),Me=require("../../markdown-flow-ui/node_modules/.pnpm/@codemirror_lang-markdown@6.5.0/node_modules/@codemirror/lang-markdown/dist/index.cjs.js"),he=require("../../markdown-flow-ui/node_modules/.pnpm/@codemirror_language@6.11.3/node_modules/@codemirror/language/dist/index.cjs.js"),K=require("../ui/tooltip.cjs.js"),Be=require("./components/CustomDialog.cjs.js"),He=require("./components/CustomPopover.cjs.js"),Ue=require("./components/EditorToolbar.cjs.js"),Fe=require("./components/VariableSearchDropdown.cjs.js"),De=require("./editor-context.cjs.js"),_e=require("./components/ImageInject.cjs.js"),Ge=require("./components/VideoInject.cjs.js"),We=require("./components/VariableSelect.cjs.js"),f=require("./types.cjs.js");;/* empty css */const y=require("./utils.cjs.js"),Qe=require("./plugins/ImgPlaceholder.cjs.js"),Ye=require("./plugins/VideoPlaceholder.cjs.js"),Je=require("./plugins/VariablePlaceholder.cjs.js"),Ke=require("./plugins/SyntaxHighlighter.cjs.js"),ge=require("./locales/en-US.json.cjs.js"),Xe=require("./locales/zh-CN.json.cjs.js"),X=require("../../markdown-flow-ui/node_modules/.pnpm/i18next@23.16.8/node_modules/i18next/dist/esm/i18next.cjs.js"),Ze=require("../../markdown-flow-ui/node_modules/.pnpm/react-i18next@15.7.4_i18next@23.16.8_react-dom@19.0.1_react@19.0.1__react@19.0.1_typescript@5.9.3/node_modules/react-i18next/dist/es/initReactI18next.cjs.js"),et=require("../../markdown-flow-ui/node_modules/.pnpm/react-i18next@15.7.4_i18next@23.16.8_react-dom@19.0.1_react@19.0.1__react@19.0.1_typescript@5.9.3/node_modules/react-i18next/dist/es/useTranslation.cjs.js"),Z={"en-US":{translation:ge.default},"zh-CN":{translation:Xe.default}};X.default.isInitialized?Object.entries(Z).forEach(([C,m])=>{X.default.addResourceBundle(C,"translation",m.translation,!0,!0)}):X.default.use(Ze.initReactI18next).init({resources:Z,lng:"en-US",fallbackLng:"en-US",interpolation:{escapeValue:!1}});const pe=[],de=(C,m)=>{if(!C||m<0)return!1;const v=y.createVariableExpressionRegexp();let b;for(;(b=v.exec(C))!==null;){const V=b.index??0,U=V+b[0].length,E=V+2,F=U-2;if(m>=E&&m<=F)return!0;v.lastIndex===b.index&&v.lastIndex++}return!1},tt=(C="")=>`{{${C}}}`,nt=({content:C="",editMode:m="codeEdit",variables:v,systemVariables:b,onChange:V,onBlur:U,locale:E="en-US",uploadProps:F,disabled:o=!1,toolbarActionsRight:D,onReady:xe})=>{const{t:i,i18n:A}=et.useTranslation();r.useEffect(()=>{E&&A.language!==E&&A.changeLanguage(E)},[A,E]);const Ce=E||A.language,w=Z[Ce]?.translation??ge.default,g=r.useMemo(()=>({image:i("toolbarInsertImage",{defaultValue:"Insert image"}),video:i("toolbarInsertVideo",{defaultValue:"Insert video"}),addVariable:i("toolbarInsertNewVariable",{defaultValue:"Insert new variable"}),search:i("toolbarInsertExistingVariable",{defaultValue:"Insert existing variable"}),confirmOutput:i("toolbarConfirmOutput",{defaultValue:"Confirm output"}),insertLink:i("toolbarInsertLink",{defaultValue:"Insert link"}),insertButton:i("toolbarInsertButton",{defaultValue:"Insert button"}),insertSingleChoice:i("toolbarInsertSingleChoice",{defaultValue:"Insert single choice"}),insertMultiChoice:i("toolbarInsertMultiChoice",{defaultValue:"Insert multi choice"}),insertInput:i("toolbarInsertInput",{defaultValue:"Insert input"}),singleChoiceOption1:i("toolbarChoiceOption1",{defaultValue:"Option 1"}),singleChoiceOption2:i("toolbarChoiceOption2",{defaultValue:"Option 2"}),inputPlaceholder:i("toolbarInputPlaceholder",{defaultValue:"Please enter"})}),[i]),Se=r.useMemo(()=>({searchPlaceholder:i("variableSearchPlaceholder",{defaultValue:"Search variable"}),systemLabel:i("variableSectionSystem","System Variables"),customLabel:i("variableSectionCustom","Custom Variables"),emptyLabel:i("variableNotFound","No variables found")}),[i]),be=m==="quickEdit"?i("placeholderQuickEdit",{defaultValue:i("placeholderCodeEdit",{defaultValue:i("placeholder")})}):i("placeholderCodeEdit",{defaultValue:i("placeholder")}),L=r.useMemo(()=>{const e=new Set;return(b??pe).filter(n=>{const s=typeof n?.name=="string"?n.name.toLowerCase():"";return!s||e.has(s)?!1:(e.add(s),!0)})},[b]),_=r.useMemo(()=>{const e=new Set(L.map(s=>s.name.toLowerCase())),n=new Set;return(v??pe).filter(s=>{const t=typeof s?.name=="string"?s.name.toLowerCase():"";return!t||e.has(t)||n.has(t)?!1:(n.add(t),!0)})},[v,L]),[G,I]=r.useState(!1),[W,O]=r.useState(!1),[Ve,P]=r.useState(null),[ee,Q]=r.useState(_),[$,Ee]=r.useState(L);r.useEffect(()=>{Q(_)},[_]),r.useEffect(()=>{Ee(L)},[L]);const[S,k]=r.useState(f.SelectedOption.Empty),[c,N]=r.useState(),a=r.useRef(null),z=r.useRef(null),M=r.useRef(null),[Y,te]=r.useState(!1),d=r.useCallback(()=>{te(!1),M.current=null},[]),Ie=r.useCallback(e=>{if(!o){if(Y&&M.current===e){d();return}M.current=e,te(!0)}},[d,o,Y]),ke={selectedOption:S,setSelectedOption:k,dialogOpen:G,setDialogOpen:I,popoverOpen:W,setPopoverOpen:O,popoverPosition:Ve,setPopoverPosition:P};r.useEffect(()=>{o&&(I(!1),O(!1),k(f.SelectedOption.Empty),N(null),P(null),d())},[d,o,I,O,P,k,N]);const j=r.useCallback(e=>{if(m!=="quickEdit"||!e)return;const n=y.extractVariableNames(e);if(!n.length)return;const s=new Set($.map(t=>t.name.toLowerCase()));Q(t=>{const u=new Set(t.map(x=>x.name.toLowerCase())),h=new Set,p=[];return n.forEach(x=>{const q=x.toLowerCase();!x||s.has(q)||u.has(q)||h.has(q)||(p.push({name:x}),h.add(q))}),p.length?[...p,...t]:t})},[m,$]);r.useEffect(()=>{j(C)},[C,j]);const J=r.useCallback(e=>{if(!o)if(d(),k(e),e===f.SelectedOption.Variable){if(a.current){const{state:n}=a.current,s=n.selection.main.from,t=a.current.coordsAtPos(s);t&&P({x:t.left,y:t.bottom})}O(!0)}else I(!0)},[d,o]),R=r.useCallback(e=>{if(o||!a.current)return;const{state:n,dispatch:s}=a.current,t=n.selection.main.from;s({changes:{from:t,insert:e},selection:{anchor:t+e.length}})},[a,o]),ne=r.useCallback(e=>{if(o||!a.current)return;const{state:n,dispatch:s}=a.current,t=n.selection.main;s({changes:{from:t.from,to:t.to,insert:e},selection:{anchor:t.from+e.length}})},[o]),oe=r.useCallback(()=>{a.current?.focus()},[]),re=r.useCallback(()=>a.current?.state.doc.toString()??"",[]),se=r.useCallback(e=>{if(o)return;if(!a.current){V?.(e);return}const n=a.current,{state:s,dispatch:t}=n;t({changes:{from:0,to:s.doc.length,insert:e},selection:{anchor:e.length}})},[o,V]),B=r.useCallback(()=>{if(o||!c||!a.current||c.from===-1)return;const{from:e,to:n}=c,{dispatch:s}=a.current;s({changes:{from:e,to:n,insert:""}})},[c,a,o]),H=r.useCallback((e,n,s=!1)=>{if(o||!a.current)return;const t=a.current,{state:u,dispatch:h}=t,p=n??u.selection.main,x=tt(e),q=s?x.length:2+e.length;h({changes:{from:p.from,to:p.to,insert:x},selection:{anchor:p.from+q}}),t.focus()},[o]),ve=r.useCallback(()=>{o||(d(),H(""))},[d,o,H]),we=r.useCallback(()=>{if(o||!a.current)return;const e=a.current,{state:n,dispatch:s}=e,t=n.selection.main;s({changes:{from:t.from,to:t.to,insert:"======"},selection:{anchor:t.from+3}}),e.focus()},[o]),Oe=r.useCallback(()=>{if(o||!a.current)return;const e=a.current,{state:n,dispatch:s}=e,t=n.selection.main;s({changes:{from:t.from,to:t.to,insert:"[]()"},selection:{anchor:t.from+1}}),e.focus()},[o]),je=r.useCallback(()=>{if(o||!a.current)return;const e=a.current,{state:n,dispatch:s}=e,t=n.selection.main;s({changes:{from:t.from,to:t.to,insert:"?[]"},selection:{anchor:t.from+2}}),e.focus()},[o]),Re=r.useCallback(()=>{if(o||!a.current)return;const e=a.current,{state:n,dispatch:s}=e,t=n.selection.main,u=g.singleChoiceOption1,h=g.singleChoiceOption2,p=`?[%{{}} ${u} | ${h}]`;s({changes:{from:t.from,to:t.to,insert:p},selection:{anchor:t.from+5}}),e.focus()},[o,g.singleChoiceOption1,g.singleChoiceOption2]),Te=r.useCallback(()=>{if(o||!a.current)return;const e=a.current,{state:n,dispatch:s}=e,t=n.selection.main,u=g.singleChoiceOption1,h=g.singleChoiceOption2,p=`?[%{{}} ${u} || ${h}]`;s({changes:{from:t.from,to:t.to,insert:p},selection:{anchor:t.from+5}}),e.focus()},[o,g.singleChoiceOption1,g.singleChoiceOption2]),qe=r.useCallback(()=>{if(o||!a.current)return;const e=a.current,{state:n,dispatch:s}=e,t=n.selection.main,h=`?[%{{}}...${g.inputPlaceholder??"请输入"}]`;s({changes:{from:t.from,to:t.to,insert:h},selection:{anchor:t.from+5}}),e.focus()},[o,g.inputPlaceholder]),ye=r.useCallback(({resourceUrl:e,resourceTitle:n,scalePercent:s})=>{if(!e||o)return;const t=y.getImageContentToInsert({resourceUrl:e,resourceTitle:n,scalePercent:s});if(c?.type===f.SelectedOption.Image){if(B(),!a.current)return;const{dispatch:u}=a.current;u({changes:{from:c.from,insert:t}})}else R(t);I(!1)},[B,o,R,c]),Le=r.useCallback(({resourceUrl:e,resourceTitle:n})=>{if(o)return;const s=y.getVideoContentToInsert(e,n);if(c?.type===f.SelectedOption.Video){if(B(),!a.current)return;const{dispatch:t}=a.current;t({changes:{from:c.from,insert:s}})}else R(s);I(!1)},[B,o,R,c]),ae=r.useCallback(e=>{if(o)return;const n=c?.type===f.SelectedOption.Variable?{from:c.from,to:c.to}:void 0;H(e.name,n,!0),O(!1),d()},[o,H,c,d]),ie=r.useCallback(()=>ze.autocompletion({override:[y.createSlashCommands(J,{image:w.slashImage,video:w.slashVideo,variable:w.slashVariable})]}),[w.slashImage,w.slashVideo,w.slashVariable,J]),le=r.useCallback(e=>{if(a.current=e.view,m==="quickEdit"&&z.current&&e.selectionSet){const n=e.state.selection.main.head,s=e.state.doc.toString();de(s,n)||(j(s),z.current=null)}},[j,m]),ce=r.useCallback(e=>{if(e.stopPropagation(),o)return;const{type:n,from:s,to:t,dataset:u,target:h}=e.detail,p=y.parseContentInfo(n,u);if(N({type:n,value:p,from:s,to:t}),k(n),n===f.SelectedOption.Variable){if(h){const x=h.getBoundingClientRect();P({x:x.left,y:x.bottom})}O(!0)}else I(!0)},[o]);r.useEffect(()=>{G||(k(f.SelectedOption.Empty),N(null))},[G]),r.useEffect(()=>{!W&&S===f.SelectedOption.Variable&&(k(f.SelectedOption.Empty),N(null))},[W,S]),r.useEffect(()=>{const e=n=>{n.detail.view===a.current&&ce(n)};return window.addEventListener("globalTagClick",e),()=>{window.removeEventListener("globalTagClick",e)}},[ce]);const Pe=r.useMemo(()=>{const e=[me.EditorView.lineWrapping,Me.markdown(),he.syntaxHighlighting(he.defaultHighlightStyle),Ke.default];return o||e.push(ie()),m==="quickEdit"&&e.push(Qe.default,Ye.default,Je.default),e.push(me.EditorView.updateListener.of(n=>{le(n)})),e},[o,m,ie,le]),Ne=r.useCallback(e=>{if(o)return;const n=a.current?.state.selection.main.head??-1;de(e,n)?z.current=e:(z.current=null,j(e)),V?.(e)},[j,V,o]),ue=!o&&Y,T=r.useMemo(()=>({insertTextAtCursor:R,replaceSelection:ne,focus:oe,getContent:re,setContent:se}),[oe,re,R,ne,se]),fe=r.useCallback(e=>{o||"render"in e||e.onClick?.(T)},[o,T]),Ae=r.useMemo(()=>D?.length?l.jsxRuntimeExports.jsx("div",{className:"markdown-flow-editor-toolbar-right",children:D.map(e=>{if("render"in e)return l.jsxRuntimeExports.jsx("div",{className:"markdown-flow-editor-toolbar-right-item",children:e.render(T)},e.key);const n=e.label||e.tooltip||void 0,s=l.jsxRuntimeExports.jsxs("button",{type:"button",disabled:o||e.disabled,onClick:()=>fe(e),className:"markdown-flow-editor-toolbar-right-button","aria-label":n,title:e.label||e.tooltip,children:[e.icon?l.jsxRuntimeExports.jsx("span",{className:"toolbar-right-icon",children:e.icon}):null,e.label?l.jsxRuntimeExports.jsx("span",{className:"toolbar-right-label",children:e.label}):null]},e.key),t=e.tooltip?l.jsxRuntimeExports.jsxs(K.Tooltip,{children:[l.jsxRuntimeExports.jsx(K.TooltipTrigger,{asChild:!0,children:s}),l.jsxRuntimeExports.jsx(K.TooltipContent,{side:"top",children:e.tooltip})]}):s;return l.jsxRuntimeExports.jsx("div",{className:"markdown-flow-editor-toolbar-right-item",children:t},e.key)})}):null,[o,T,fe,D]);return r.useEffect(()=>{xe?.(T)},[T]),l.jsxRuntimeExports.jsxs("div",{className:"markdown-flow-editor","data-disabled":o?"true":void 0,"aria-disabled":o,children:[l.jsxRuntimeExports.jsx(Ue.default,{disabled:o,labels:g,onSelect:J,onInsertVariablePlaceholder:ve,onVariableSearchToggle:Ie,onVariableSearchClose:d,onInsertConfirmOutput:we,onInsertLink:Oe,onInsertButton:je,onInsertSingleChoice:Re,onInsertMultiChoice:Te,onInsertInputField:qe,variableSearchActive:ue,rightSlot:Ae}),l.jsxRuntimeExports.jsx(Fe.default,{open:ue,anchorElement:M.current,onClose:d,onSelect:ae,variables:ee,systemVariables:$,labels:Se}),l.jsxRuntimeExports.jsx("div",{className:"markdown-flow-editor-body relative overflow-auto",children:l.jsxRuntimeExports.jsxs(De.default.Provider,{value:ke,children:[l.jsxRuntimeExports.jsx($e.default,{extensions:Pe,basicSetup:{lineNumbers:!1,syntaxHighlighting:!0,highlightActiveLine:!0,highlightActiveLineGutter:!0,foldGutter:!1},className:"rounded-md",placeholder:be,value:C,theme:"light",minHeight:"2rem",editable:!o,onChange:Ne,onBlur:U}),!o&&l.jsxRuntimeExports.jsxs(Be.default,{labels:{title:S===f.SelectedOption.Image?i("dialogTitleImage"):S===f.SelectedOption.Video?i("dialogTitleVideo"):S===f.SelectedOption.Variable?i("dialogTitleVariable"):i("dialogTitle")},children:[S===f.SelectedOption.Image&&l.jsxRuntimeExports.jsx(_e.default,{value:c?.value,onSelect:ye,uploadProps:F}),S===f.SelectedOption.Video&&l.jsxRuntimeExports.jsx(Ge.default,{value:c?.value,onSelect:Le})]}),!o&&l.jsxRuntimeExports.jsx(He.default,{children:l.jsxRuntimeExports.jsx(We.default,{variables:ee,systemVariables:$,selectedName:c?.value?.variableName,onSelect:ae,onAddVariable:e=>{Q(n=>{const s=e.name.toLowerCase();return n.some(u=>u.name.toLowerCase()===s)?n:[e,...n]})}})})]})})]})};exports.default=nt;
|
|
2
2
|
//# sourceMappingURL=MarkdownFlowEditor.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownFlowEditor.cjs.js","sources":["../../../src/components/MarkdownFlowEditor/MarkdownFlowEditor.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState, useCallback, useRef, useEffect, useMemo } from \"react\";\nimport CodeMirror from \"@uiw/react-codemirror\";\nimport { autocompletion } from \"@codemirror/autocomplete\";\nimport { EditorView, ViewUpdate } from \"@codemirror/view\";\nimport { markdown } from \"@codemirror/lang-markdown\";\nimport {\n syntaxHighlighting,\n defaultHighlightStyle,\n} from \"@codemirror/language\";\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"../ui/tooltip\";\nimport CustomDialog from \"./components/CustomDialog\";\nimport CustomPopover from \"./components/CustomPopover\";\nimport EditorToolbar from \"./components/EditorToolbar\";\nimport VariableSearchDropdown from \"./components/VariableSearchDropdown\";\nimport EditorContext from \"./editor-context\";\nimport ImageInject from \"./components/ImageInject\";\nimport VideoInject from \"./components/VideoInject\";\nimport VariableSelect from \"./components/VariableSelect\";\nimport {\n SelectedOption,\n IEditorContext,\n Variable,\n SelectContentInfo,\n PopoverPosition,\n EditorAction,\n EditorApi,\n} from \"./types\";\nimport \"./markdownFlowEditor.css\";\n\nimport {\n createSlashCommands,\n parseContentInfo,\n getVideoContentToInsert,\n extractVariableNames,\n createVariableExpressionRegexp,\n} from \"./utils\";\nimport ImgPlaceholder from \"./plugins/ImgPlaceholder\";\nimport VideoPlaceholder from \"./plugins/VideoPlaceholder\";\nimport VariablePlaceholder from \"./plugins/VariablePlaceholder\";\nimport SyntaxHighlighter from \"./plugins/SyntaxHighlighter\";\n// import createFixedTextPlaceholder from \"./plugins/FixedTextPlaceholder\";\n// import DividerPlaceholder from \"./plugins/DividerPlaceholder\";\nimport enUS from \"./locales/en-US.json\";\nimport zhCN from \"./locales/zh-CN.json\";\nimport { initReactI18next, useTranslation } from \"react-i18next\";\nimport i18next from \"i18next\";\nimport { UploadProps } from \"./uploadTypes\";\n\nconst resources = {\n \"en-US\": { translation: enUS },\n \"zh-CN\": { translation: zhCN },\n};\n\nif (!i18next.isInitialized) {\n i18next.use(initReactI18next).init({\n resources,\n lng: \"en-US\",\n fallbackLng: \"en-US\",\n interpolation: { escapeValue: false },\n });\n} else {\n Object.entries(resources).forEach(([lng, resource]) => {\n i18next.addResourceBundle(\n lng,\n \"translation\",\n resource.translation,\n true,\n true\n );\n });\n}\n\nexport enum EditMode {\n CodeEdit = \"codeEdit\",\n QuickEdit = \"quickEdit\",\n}\n\ntype EditorProps = {\n content?: string;\n editMode?: EditMode;\n variables?: Variable[];\n systemVariables?: Variable[];\n onChange?: (value: string) => void;\n onBlur?: () => void;\n locale?: \"en-US\" | \"zh-CN\";\n uploadProps?: UploadProps;\n disabled?: boolean;\n toolbarActionsRight?: EditorAction[];\n onReady?: (api: EditorApi) => void;\n};\n\nconst EMPTY_VARIABLES: Variable[] = [];\n\n// Detect whether cursor is still inside a {{variable}} expression\nconst isCursorInsideVariableExpression = (\n content: string,\n cursorPosition: number\n) => {\n if (!content || cursorPosition < 0) {\n return false;\n }\n const regexp = createVariableExpressionRegexp();\n let match: RegExpExecArray | null;\n\n while ((match = regexp.exec(content)) !== null) {\n const matchStart = match.index ?? 0;\n const matchEnd = matchStart + match[0].length;\n const innerStart = matchStart + 2;\n const innerEnd = matchEnd - 2;\n if (cursorPosition >= innerStart && cursorPosition <= innerEnd) {\n return true;\n }\n if (regexp.lastIndex === match.index) {\n regexp.lastIndex++;\n }\n }\n\n return false;\n};\n\nconst buildVariableTemplate = (variableName = \"\") => `{{${variableName}}}`;\n\nconst Editor: React.FC<EditorProps> = ({\n content = \"\",\n editMode = EditMode.CodeEdit,\n variables: initialVariables,\n systemVariables: initialSystemVariables,\n onChange,\n onBlur,\n locale = \"en-US\",\n uploadProps,\n disabled = false,\n toolbarActionsRight,\n onReady,\n}) => {\n const { t, i18n } = useTranslation();\n useEffect(() => {\n if (locale && i18n.language !== locale) {\n i18n.changeLanguage(locale);\n }\n }, [i18n, locale]);\n const activeLocale = (locale || i18n.language) as \"en-US\" | \"zh-CN\";\n const currentStrings = resources[activeLocale]?.translation ?? enUS;\n const toolbarLabels = useMemo(\n () => ({\n image: t(\"toolbarInsertImage\", {\n defaultValue: \"Insert image\",\n }),\n video: t(\"toolbarInsertVideo\", {\n defaultValue: \"Insert video\",\n }),\n addVariable: t(\"toolbarInsertNewVariable\", {\n defaultValue: \"Insert new variable\",\n }),\n search: t(\"toolbarInsertExistingVariable\", {\n defaultValue: \"Insert existing variable\",\n }),\n confirmOutput: t(\"toolbarConfirmOutput\", {\n defaultValue: \"Confirm output\",\n }),\n insertLink: t(\"toolbarInsertLink\", {\n defaultValue: \"Insert link\",\n }),\n insertButton: t(\"toolbarInsertButton\", {\n defaultValue: \"Insert button\",\n }),\n insertSingleChoice: t(\"toolbarInsertSingleChoice\", {\n defaultValue: \"Insert single choice\",\n }),\n insertMultiChoice: t(\"toolbarInsertMultiChoice\", {\n defaultValue: \"Insert multi choice\",\n }),\n insertInput: t(\"toolbarInsertInput\", {\n defaultValue: \"Insert input\",\n }),\n singleChoiceOption1: t(\"toolbarChoiceOption1\", {\n defaultValue: \"Option 1\",\n }),\n singleChoiceOption2: t(\"toolbarChoiceOption2\", {\n defaultValue: \"Option 2\",\n }),\n inputPlaceholder: t(\"toolbarInputPlaceholder\", {\n defaultValue: \"Please enter\",\n }),\n }),\n [t]\n );\n const variableSearchLabels = useMemo(\n () => ({\n searchPlaceholder: t(\"variableSearchPlaceholder\", {\n defaultValue: \"Search variable\",\n }),\n systemLabel: t(\"variableSectionSystem\", \"System Variables\"),\n customLabel: t(\"variableSectionCustom\", \"Custom Variables\"),\n emptyLabel: t(\"variableNotFound\", \"No variables found\"),\n }),\n [t]\n );\n const placeholderText =\n editMode === EditMode.QuickEdit\n ? t(\"placeholderQuickEdit\", {\n defaultValue: t(\"placeholderCodeEdit\", {\n defaultValue: t(\"placeholder\"),\n }),\n })\n : t(\"placeholderCodeEdit\", { defaultValue: t(\"placeholder\") });\n // Normalize variables to avoid duplicating system variables in the custom list\n const normalizedSystemVariables = useMemo(() => {\n const seen = new Set<string>();\n return (initialSystemVariables ?? EMPTY_VARIABLES).filter((variable) => {\n const normalized =\n typeof variable?.name === \"string\" ? variable.name.toLowerCase() : \"\";\n if (!normalized || seen.has(normalized)) {\n return false;\n }\n seen.add(normalized);\n return true;\n });\n }, [initialSystemVariables]);\n\n const normalizedCustomVariables = useMemo(() => {\n const systemNameSet = new Set(\n normalizedSystemVariables.map((variable) => variable.name.toLowerCase())\n );\n const seen = new Set<string>();\n return (initialVariables ?? EMPTY_VARIABLES).filter((variable) => {\n const normalized =\n typeof variable?.name === \"string\" ? variable.name.toLowerCase() : \"\";\n if (\n !normalized ||\n systemNameSet.has(normalized) ||\n seen.has(normalized)\n ) {\n return false;\n }\n seen.add(normalized);\n return true;\n });\n }, [initialVariables, normalizedSystemVariables]);\n\n const [dialogOpen, setDialogOpen] = useState(false);\n const [popoverOpen, setPopoverOpen] = useState(false);\n const [popoverPosition, setPopoverPosition] =\n useState<PopoverPosition | null>(null);\n const [variables, setVariables] = useState<Variable[]>(\n normalizedCustomVariables\n );\n const [systemVariables, setSystemVariables] = useState<Variable[]>(\n normalizedSystemVariables\n );\n\n useEffect(() => {\n setVariables(normalizedCustomVariables);\n }, [normalizedCustomVariables]);\n\n useEffect(() => {\n setSystemVariables(normalizedSystemVariables);\n }, [normalizedSystemVariables]);\n\n const [selectedOption, setSelectedOption] = useState<SelectedOption>(\n SelectedOption.Empty\n );\n const [selectContentInfo, setSelectContentInfo] =\n useState<SelectContentInfo | null>();\n const editorViewRef = useRef<EditorView | null>(null);\n const pendingVariableContentRef = useRef<string | null>(null);\n const variableSearchAnchorRef = useRef<HTMLButtonElement | null>(null);\n const [variableSearchOpen, setVariableSearchOpen] = useState(false);\n const closeVariableSearch = useCallback(() => {\n setVariableSearchOpen(false);\n variableSearchAnchorRef.current = null;\n }, []);\n const handleVariableSearchToggle = useCallback(\n (button: HTMLButtonElement) => {\n if (disabled) {\n return;\n }\n if (variableSearchOpen && variableSearchAnchorRef.current === button) {\n closeVariableSearch();\n return;\n }\n variableSearchAnchorRef.current = button;\n setVariableSearchOpen(true);\n },\n [closeVariableSearch, disabled, variableSearchOpen]\n );\n\n const editorContextValue: IEditorContext = {\n selectedOption,\n setSelectedOption,\n dialogOpen,\n setDialogOpen,\n popoverOpen,\n setPopoverOpen,\n popoverPosition,\n setPopoverPosition,\n };\n\n useEffect(() => {\n if (!disabled) {\n return;\n }\n setDialogOpen(false);\n setPopoverOpen(false);\n setSelectedOption(SelectedOption.Empty);\n setSelectContentInfo(null);\n setPopoverPosition(null);\n closeVariableSearch();\n }, [\n closeVariableSearch,\n disabled,\n setDialogOpen,\n setPopoverOpen,\n setPopoverPosition,\n setSelectedOption,\n setSelectContentInfo,\n ]);\n\n const addVariablesFromContent = useCallback(\n (text: string) => {\n if (editMode !== EditMode.QuickEdit || !text) {\n return;\n }\n\n const names = extractVariableNames(text);\n if (!names.length) {\n return;\n }\n\n const systemNameSet = new Set(\n systemVariables.map((variable) => variable.name.toLowerCase())\n );\n\n setVariables((prev) => {\n const existingNames = new Set(\n prev.map((variable) => variable.name.toLowerCase())\n );\n const addedNames = new Set<string>();\n const newVariables: Variable[] = [];\n\n names.forEach((rawName) => {\n const normalized = rawName.toLowerCase();\n if (\n !rawName ||\n systemNameSet.has(normalized) ||\n existingNames.has(normalized) ||\n addedNames.has(normalized)\n ) {\n return;\n }\n newVariables.push({ name: rawName });\n addedNames.add(normalized);\n });\n\n if (!newVariables.length) {\n return prev;\n }\n\n return [...newVariables, ...prev];\n });\n },\n [editMode, systemVariables]\n );\n\n useEffect(() => {\n addVariablesFromContent(content);\n }, [content, addVariablesFromContent]);\n\n // const insertFixedText = useCallback(() => {\n // if (!editorViewRef.current) return;\n // const view = editorViewRef.current;\n // const { state, dispatch } = view;\n // const selection = state.selection.main;\n // const selectedText = state.sliceDoc(selection.from, selection.to);\n // const startTag = \"===\";\n // const endTag = \"===\";\n // const insertContent = `${startTag}${selectedText ?? \"\"}${endTag}`;\n\n // dispatch({\n // changes: {\n // from: selection.from,\n // to: selection.to,\n // insert: insertContent,\n // },\n // selection: {\n // anchor: selection.from + startTag.length + (selectedText?.length ?? 0),\n // },\n // });\n // view.focus();\n // }, []);\n\n // const insertDivider = useCallback(() => {\n // if (!editorViewRef.current) return;\n // const view = editorViewRef.current;\n // const { state, dispatch } = view;\n // const selection = state.selection.main;\n // const insertContent = `\\n\\n---\\n\\n`;\n\n // dispatch({\n // changes: {\n // from: selection.from,\n // to: selection.to,\n // insert: insertContent,\n // },\n // selection: {\n // anchor: selection.from + insertContent.length,\n // },\n // });\n // view.focus();\n // }, []);\n\n const onSelectedOption = useCallback(\n (option: SelectedOption) => {\n if (disabled) {\n return;\n }\n closeVariableSearch();\n // if (option === SelectedOption.FixedText) {\n // insertFixedText();\n // setSelectedOption(SelectedOption.Empty);\n // setDialogOpen(false);\n // setPopoverOpen(false);\n // setSelectContentInfo(null);\n // setPopoverPosition(null);\n // return;\n // }\n\n // if (option === SelectedOption.Divider) {\n // insertDivider();\n // setSelectedOption(SelectedOption.Empty);\n // setDialogOpen(false);\n // setPopoverOpen(false);\n // setSelectContentInfo(null);\n // setPopoverPosition(null);\n // return;\n // }\n\n setSelectedOption(option);\n\n if (option === SelectedOption.Variable) {\n if (editorViewRef.current) {\n const { state } = editorViewRef.current;\n const pos = state.selection.main.from;\n const coords = editorViewRef.current.coordsAtPos(pos);\n if (coords) {\n setPopoverPosition({\n x: coords.left,\n y: coords.bottom,\n });\n }\n }\n setPopoverOpen(true);\n } else {\n setDialogOpen(true);\n }\n },\n [closeVariableSearch, disabled]\n );\n\n const insertText = useCallback(\n (text: string) => {\n if (disabled || !editorViewRef.current) return;\n\n const { state, dispatch } = editorViewRef.current;\n const from = state.selection.main.from;\n\n dispatch({\n changes: { from, insert: text },\n selection: { anchor: from + text.length },\n });\n },\n [editorViewRef, disabled]\n );\n\n const replaceSelection = useCallback(\n (text: string) => {\n if (disabled || !editorViewRef.current) {\n return;\n }\n const { state, dispatch } = editorViewRef.current;\n const selection = state.selection.main;\n dispatch({\n changes: { from: selection.from, to: selection.to, insert: text },\n selection: { anchor: selection.from + text.length },\n });\n },\n [disabled]\n );\n\n const focusEditor = useCallback(() => {\n editorViewRef.current?.focus();\n }, []);\n\n const getContent = useCallback(() => {\n return editorViewRef.current?.state.doc.toString() ?? \"\";\n }, []);\n\n const setContent = useCallback(\n (text: string) => {\n if (disabled) {\n return;\n }\n if (!editorViewRef.current) {\n onChange?.(text);\n return;\n }\n const view = editorViewRef.current;\n const { state, dispatch } = view;\n dispatch({\n changes: { from: 0, to: state.doc.length, insert: text },\n selection: { anchor: text.length },\n });\n },\n [disabled, onChange]\n );\n\n const deleteSelectedContent = useCallback(() => {\n if (disabled) {\n return;\n }\n if (\n !selectContentInfo ||\n !editorViewRef.current ||\n selectContentInfo.from === -1\n )\n return;\n\n const { from, to } = selectContentInfo;\n const { dispatch } = editorViewRef.current;\n\n dispatch({\n changes: { from, to, insert: \"\" },\n });\n }, [selectContentInfo, editorViewRef, disabled]);\n\n const insertVariableContent = useCallback(\n (\n variableName: string,\n range?: { from: number; to: number },\n placeCursorAtEnd = false\n ) => {\n if (disabled || !editorViewRef.current) {\n return;\n }\n const view = editorViewRef.current;\n const { state, dispatch } = view;\n const selection = range ?? state.selection.main;\n const template = buildVariableTemplate(variableName);\n const cursorOffset = placeCursorAtEnd\n ? template.length\n : 2 + variableName.length; // 2 braces before variable content\n\n dispatch({\n changes: {\n from: selection.from,\n to: selection.to,\n insert: template,\n },\n selection: {\n anchor: selection.from + cursorOffset,\n },\n });\n view.focus();\n },\n [disabled]\n );\n\n const insertVariableTemplate = useCallback(() => {\n if (disabled) {\n return;\n }\n closeVariableSearch();\n insertVariableContent(\"\");\n }, [closeVariableSearch, disabled, insertVariableContent]);\n\n const insertConfirmOutputMarker = useCallback(() => {\n if (disabled || !editorViewRef.current) {\n return;\n }\n const view = editorViewRef.current;\n const { state, dispatch } = view;\n const selection = state.selection.main;\n const template = \"======\";\n dispatch({\n changes: {\n from: selection.from,\n to: selection.to,\n insert: template,\n },\n selection: {\n anchor: selection.from + 3,\n },\n });\n view.focus();\n }, [disabled]);\n\n const insertLinkTemplate = useCallback(() => {\n if (disabled || !editorViewRef.current) {\n return;\n }\n const view = editorViewRef.current;\n const { state, dispatch } = view;\n const selection = state.selection.main;\n const template = \"[]()\";\n dispatch({\n changes: {\n from: selection.from,\n to: selection.to,\n insert: template,\n },\n selection: {\n anchor: selection.from + 1,\n },\n });\n view.focus();\n }, [disabled]);\n\n const insertButtonTemplate = useCallback(() => {\n if (disabled || !editorViewRef.current) {\n return;\n }\n const view = editorViewRef.current;\n const { state, dispatch } = view;\n const selection = state.selection.main;\n const template = \"?[]\";\n dispatch({\n changes: {\n from: selection.from,\n to: selection.to,\n insert: template,\n },\n selection: {\n anchor: selection.from + 2,\n },\n });\n view.focus();\n }, [disabled]);\n\n const insertSingleChoiceTemplate = useCallback(() => {\n if (disabled || !editorViewRef.current) {\n return;\n }\n const view = editorViewRef.current;\n const { state, dispatch } = view;\n const selection = state.selection.main;\n const optionLabel1 = toolbarLabels.singleChoiceOption1;\n const optionLabel2 = toolbarLabels.singleChoiceOption2;\n const template = `?[%{{}} ${optionLabel1} | ${optionLabel2}]`;\n dispatch({\n changes: {\n from: selection.from,\n to: selection.to,\n insert: template,\n },\n selection: {\n anchor: selection.from + 5,\n },\n });\n view.focus();\n }, [\n disabled,\n toolbarLabels.singleChoiceOption1,\n toolbarLabels.singleChoiceOption2,\n ]);\n\n const insertMultiChoiceTemplate = useCallback(() => {\n if (disabled || !editorViewRef.current) {\n return;\n }\n const view = editorViewRef.current;\n const { state, dispatch } = view;\n const selection = state.selection.main;\n const optionLabel1 = toolbarLabels.singleChoiceOption1;\n const optionLabel2 = toolbarLabels.singleChoiceOption2;\n const template = `?[%{{}} ${optionLabel1} || ${optionLabel2}]`;\n dispatch({\n changes: {\n from: selection.from,\n to: selection.to,\n insert: template,\n },\n selection: {\n anchor: selection.from + 5,\n },\n });\n view.focus();\n }, [\n disabled,\n toolbarLabels.singleChoiceOption1,\n toolbarLabels.singleChoiceOption2,\n ]);\n\n const insertInputFieldTemplate = useCallback(() => {\n if (disabled || !editorViewRef.current) {\n return;\n }\n const view = editorViewRef.current;\n const { state, dispatch } = view;\n const selection = state.selection.main;\n const placeholder = toolbarLabels.inputPlaceholder ?? \"请输入\";\n const template = `?[%{{}}...${placeholder}]`;\n dispatch({\n changes: {\n from: selection.from,\n to: selection.to,\n insert: template,\n },\n selection: {\n anchor: selection.from + 5,\n },\n });\n view.focus();\n }, [disabled, toolbarLabels.inputPlaceholder]);\n\n const handleSelectImage = useCallback(\n ({\n resourceUrl,\n resourceTitle,\n scalePercent,\n }: {\n resourceUrl?: string;\n resourceTitle?: string;\n scalePercent?: number;\n }) => {\n if (!resourceUrl || disabled) return;\n const sanitizedHtmlUrl = resourceUrl.replace(/\"/g, \""\");\n const clampedScale =\n typeof scalePercent === \"number\"\n ? Math.max(1, Math.min(1000, Math.round(scalePercent)))\n : undefined;\n const sanitizedTitle = resourceTitle?.replace(/\"/g, \""\");\n const escapeMarkdownText = (text: string) =>\n text.replace(/([\\[\\]\\\\])/g, \"\\\\$1\");\n const markdownTitle = resourceTitle\n ? escapeMarkdownText(resourceTitle)\n : \"\";\n const widthAttribute =\n typeof clampedScale === \"number\" && clampedScale !== 100\n ? ` width=\"${clampedScale}%\"`\n : \"\";\n const htmlTitleAttributes = sanitizedTitle\n ? ` alt=\"${sanitizedTitle}\" title=\"${sanitizedTitle}\"`\n : \"\";\n\n const textToInsert =\n !clampedScale || clampedScale === 100\n ? ``\n : `<img src=\"${sanitizedHtmlUrl}\"${htmlTitleAttributes}${widthAttribute} />`;\n if (selectContentInfo?.type === SelectedOption.Image) {\n deleteSelectedContent();\n if (!editorViewRef.current) return;\n const { dispatch } = editorViewRef.current;\n dispatch({\n changes: { from: selectContentInfo.from, insert: textToInsert },\n });\n } else {\n insertText(textToInsert);\n }\n setDialogOpen(false);\n },\n [insertText, selectedOption, disabled]\n );\n\n const handleSelectVideo = useCallback(\n ({\n resourceUrl,\n resourceTitle,\n }: {\n resourceUrl: string;\n resourceTitle: string;\n }) => {\n if (disabled) {\n return;\n }\n const textToInsert = getVideoContentToInsert(resourceUrl, resourceTitle);\n if (selectContentInfo?.type === SelectedOption.Video) {\n deleteSelectedContent();\n if (!editorViewRef.current) return;\n const { dispatch } = editorViewRef.current;\n dispatch({\n changes: { from: selectContentInfo.from, insert: textToInsert },\n });\n } else {\n insertText(textToInsert);\n }\n setDialogOpen(false);\n },\n [insertText, selectedOption, disabled]\n );\n\n const handleSelectVariable = useCallback(\n (variable: Variable) => {\n if (disabled) {\n return;\n }\n const selectionRange =\n selectContentInfo?.type === SelectedOption.Variable\n ? { from: selectContentInfo.from, to: selectContentInfo.to }\n : undefined;\n insertVariableContent(variable.name, selectionRange, true);\n setPopoverOpen(false);\n closeVariableSearch();\n },\n [disabled, insertVariableContent, selectContentInfo, closeVariableSearch]\n );\n\n const slashCommandsExtension = useCallback(() => {\n return autocompletion({\n override: [\n createSlashCommands(onSelectedOption, {\n // divider: currentStrings.slashDivider,\n // fixedText: currentStrings.slashFixedText,\n image: currentStrings.slashImage,\n video: currentStrings.slashVideo,\n variable: currentStrings.slashVariable,\n }),\n ],\n });\n }, [\n // currentStrings.slashDivider,\n // currentStrings.slashFixedText,\n currentStrings.slashImage,\n currentStrings.slashVideo,\n currentStrings.slashVariable,\n onSelectedOption,\n ]);\n\n // const fixedTextPlaceholderExtension = useMemo(\n // () =>\n // createFixedTextPlaceholder(\n // currentStrings.fixedTextPlaceholder ?? \"添加固定文本\",\n // currentStrings.fixedTextTooltip ??\n // currentStrings.slashFixedText ??\n // \"固定文本\"\n // ),\n // [\n // currentStrings.fixedTextPlaceholder,\n // currentStrings.fixedTextTooltip,\n // currentStrings.slashFixedText,\n // ]\n // );\n\n const handleEditorUpdate = useCallback(\n (update: ViewUpdate) => {\n editorViewRef.current = update.view;\n if (\n editMode === EditMode.QuickEdit &&\n pendingVariableContentRef.current &&\n update.selectionSet\n ) {\n const cursorPosition = update.state.selection.main.head;\n const docText = update.state.doc.toString();\n const stillInside = isCursorInsideVariableExpression(\n docText,\n cursorPosition\n );\n if (!stillInside) {\n addVariablesFromContent(docText);\n pendingVariableContentRef.current = null;\n }\n }\n },\n [addVariablesFromContent, editMode]\n );\n\n const handleTagClick = useCallback(\n (event: any) => {\n event.stopPropagation();\n if (disabled) {\n return;\n }\n const { type, from, to, dataset, target } = event.detail;\n const value = parseContentInfo(type, dataset);\n setSelectContentInfo({\n type,\n value,\n from,\n to,\n });\n setSelectedOption(type);\n\n if (type === SelectedOption.Variable) {\n if (target) {\n const rect = target.getBoundingClientRect();\n setPopoverPosition({\n x: rect.left,\n y: rect.bottom,\n });\n }\n setPopoverOpen(true);\n } else {\n setDialogOpen(true);\n }\n },\n [disabled]\n );\n\n useEffect(() => {\n if (!dialogOpen) {\n setSelectedOption(SelectedOption.Empty);\n setSelectContentInfo(null);\n }\n }, [dialogOpen]);\n\n useEffect(() => {\n if (!popoverOpen && selectedOption === SelectedOption.Variable) {\n setSelectedOption(SelectedOption.Empty);\n setSelectContentInfo(null);\n }\n }, [popoverOpen, selectedOption]);\n\n useEffect(() => {\n const handleWrap = (e: any) => {\n if (e.detail.view === editorViewRef.current) {\n handleTagClick(e);\n }\n };\n window.addEventListener(\"globalTagClick\", handleWrap);\n return () => {\n window.removeEventListener(\"globalTagClick\", handleWrap);\n };\n }, [handleTagClick]);\n\n const editorExtensions = useMemo(() => {\n const extensions = [\n EditorView.lineWrapping,\n markdown(),\n syntaxHighlighting(defaultHighlightStyle),\n SyntaxHighlighter,\n ];\n\n if (!disabled) {\n extensions.push(slashCommandsExtension());\n }\n\n if (editMode === EditMode.QuickEdit) {\n extensions.push(\n ImgPlaceholder,\n VideoPlaceholder,\n VariablePlaceholder\n // fixedTextPlaceholderExtension,\n // DividerPlaceholder,\n );\n }\n\n extensions.push(\n EditorView.updateListener.of((update) => {\n handleEditorUpdate(update);\n })\n );\n\n return extensions;\n }, [disabled, editMode, slashCommandsExtension, handleEditorUpdate]);\n\n const handleContentChange = useCallback(\n (value: string) => {\n if (disabled) {\n return;\n }\n const cursorPosition =\n editorViewRef.current?.state.selection.main.head ?? -1;\n const skipAddition = isCursorInsideVariableExpression(\n value,\n cursorPosition\n );\n if (skipAddition) {\n pendingVariableContentRef.current = value;\n } else {\n pendingVariableContentRef.current = null;\n addVariablesFromContent(value);\n }\n onChange?.(value);\n },\n [addVariablesFromContent, onChange, disabled]\n );\n\n const isVariableSearchOpen = !disabled && variableSearchOpen;\n const editorApi = useMemo(\n () => ({\n insertTextAtCursor: insertText,\n replaceSelection,\n focus: focusEditor,\n getContent,\n setContent,\n }),\n [focusEditor, getContent, insertText, replaceSelection, setContent]\n );\n\n const handleToolbarActionClick = useCallback(\n (action: EditorAction) => {\n if (disabled || \"render\" in action) {\n return;\n }\n action.onClick?.(editorApi);\n },\n [disabled, editorApi]\n );\n\n const toolbarRightSlot = useMemo(() => {\n if (!toolbarActionsRight?.length) {\n return null;\n }\n return (\n <div className=\"markdown-flow-editor-toolbar-right\">\n {toolbarActionsRight.map((action) => {\n if (\"render\" in action) {\n return (\n <div\n className=\"markdown-flow-editor-toolbar-right-item\"\n key={action.key}\n >\n {action.render(editorApi)}\n </div>\n );\n }\n const ariaLabel = action.label || action.tooltip || undefined;\n const button = (\n <button\n type=\"button\"\n key={action.key}\n disabled={disabled || action.disabled}\n onClick={() => handleToolbarActionClick(action)}\n className=\"markdown-flow-editor-toolbar-right-button\"\n aria-label={ariaLabel}\n title={action.label || action.tooltip}\n >\n {action.icon ? (\n <span className=\"toolbar-right-icon\">{action.icon}</span>\n ) : null}\n {action.label ? (\n <span className=\"toolbar-right-label\">{action.label}</span>\n ) : null}\n </button>\n );\n const wrapped = action.tooltip ? (\n <Tooltip>\n <TooltipTrigger asChild>{button}</TooltipTrigger>\n <TooltipContent side=\"top\">{action.tooltip}</TooltipContent>\n </Tooltip>\n ) : (\n button\n );\n return (\n <div\n className=\"markdown-flow-editor-toolbar-right-item\"\n key={action.key}\n >\n {wrapped}\n </div>\n );\n })}\n </div>\n );\n }, [disabled, editorApi, handleToolbarActionClick, toolbarActionsRight]);\n\n useEffect(() => {\n onReady?.(editorApi);\n }, [editorApi]);\n\n return (\n <div\n className=\"markdown-flow-editor\"\n data-disabled={disabled ? \"true\" : undefined}\n aria-disabled={disabled}\n >\n <EditorToolbar\n disabled={disabled}\n labels={toolbarLabels}\n onSelect={onSelectedOption}\n onInsertVariablePlaceholder={insertVariableTemplate}\n onVariableSearchToggle={handleVariableSearchToggle}\n onVariableSearchClose={closeVariableSearch}\n onInsertConfirmOutput={insertConfirmOutputMarker}\n onInsertLink={insertLinkTemplate}\n onInsertButton={insertButtonTemplate}\n onInsertSingleChoice={insertSingleChoiceTemplate}\n onInsertMultiChoice={insertMultiChoiceTemplate}\n onInsertInputField={insertInputFieldTemplate}\n variableSearchActive={isVariableSearchOpen}\n rightSlot={toolbarRightSlot}\n />\n <VariableSearchDropdown\n open={isVariableSearchOpen}\n anchorElement={variableSearchAnchorRef.current}\n onClose={closeVariableSearch}\n onSelect={handleSelectVariable}\n variables={variables}\n systemVariables={systemVariables}\n labels={variableSearchLabels}\n />\n <div className=\"markdown-flow-editor-body relative overflow-auto\">\n <EditorContext.Provider value={editorContextValue}>\n <CodeMirror\n extensions={editorExtensions}\n basicSetup={{\n lineNumbers: false,\n syntaxHighlighting: true,\n highlightActiveLine: true,\n highlightActiveLineGutter: true,\n foldGutter: false,\n }}\n className=\"rounded-md\"\n placeholder={placeholderText}\n value={content}\n theme=\"light\"\n minHeight=\"2rem\"\n editable={!disabled}\n onChange={handleContentChange}\n onBlur={onBlur}\n />\n {!disabled && (\n <CustomDialog\n labels={{\n title:\n selectedOption === SelectedOption.Image\n ? t(\"dialogTitleImage\")\n : selectedOption === SelectedOption.Video\n ? t(\"dialogTitleVideo\")\n : selectedOption === SelectedOption.Variable\n ? t(\"dialogTitleVariable\")\n : t(\"dialogTitle\"),\n }}\n >\n {selectedOption === SelectedOption.Image && (\n <ImageInject\n value={selectContentInfo?.value}\n onSelect={handleSelectImage}\n uploadProps={uploadProps}\n />\n )}\n {selectedOption === SelectedOption.Video && (\n <VideoInject\n value={selectContentInfo?.value}\n onSelect={handleSelectVideo}\n />\n )}\n </CustomDialog>\n )}\n\n {!disabled && (\n <CustomPopover>\n <VariableSelect\n variables={variables}\n systemVariables={systemVariables}\n selectedName={selectContentInfo?.value?.variableName}\n onSelect={handleSelectVariable}\n onAddVariable={(variable) => {\n setVariables((prev) => {\n const normalized = variable.name.toLowerCase();\n const exists = prev.some(\n (item) => item.name.toLowerCase() === normalized\n );\n if (exists) {\n return prev;\n }\n return [variable, ...prev];\n });\n }}\n />\n </CustomPopover>\n )}\n </EditorContext.Provider>\n </div>\n </div>\n );\n};\n\nexport default Editor;\n"],"names":["resources","enUS","zhCN","i18next","lng","resource","initReactI18next","EMPTY_VARIABLES","isCursorInsideVariableExpression","content","cursorPosition","regexp","createVariableExpressionRegexp","match","matchStart","matchEnd","innerStart","innerEnd","buildVariableTemplate","variableName","Editor","editMode","initialVariables","initialSystemVariables","onChange","onBlur","locale","uploadProps","disabled","toolbarActionsRight","onReady","t","i18n","useTranslation","useEffect","activeLocale","currentStrings","toolbarLabels","useMemo","variableSearchLabels","placeholderText","normalizedSystemVariables","seen","variable","normalized","normalizedCustomVariables","systemNameSet","dialogOpen","setDialogOpen","useState","popoverOpen","setPopoverOpen","popoverPosition","setPopoverPosition","variables","setVariables","systemVariables","setSystemVariables","selectedOption","setSelectedOption","SelectedOption","selectContentInfo","setSelectContentInfo","editorViewRef","useRef","pendingVariableContentRef","variableSearchAnchorRef","variableSearchOpen","setVariableSearchOpen","closeVariableSearch","useCallback","handleVariableSearchToggle","button","editorContextValue","addVariablesFromContent","text","names","extractVariableNames","prev","existingNames","addedNames","newVariables","rawName","onSelectedOption","option","state","pos","coords","insertText","dispatch","from","replaceSelection","selection","focusEditor","getContent","setContent","view","deleteSelectedContent","to","insertVariableContent","range","placeCursorAtEnd","template","cursorOffset","insertVariableTemplate","insertConfirmOutputMarker","insertLinkTemplate","insertButtonTemplate","insertSingleChoiceTemplate","optionLabel1","optionLabel2","insertMultiChoiceTemplate","insertInputFieldTemplate","handleSelectImage","resourceUrl","resourceTitle","scalePercent","sanitizedHtmlUrl","clampedScale","sanitizedTitle","markdownTitle","widthAttribute","htmlTitleAttributes","textToInsert","handleSelectVideo","getVideoContentToInsert","handleSelectVariable","selectionRange","slashCommandsExtension","autocompletion","createSlashCommands","handleEditorUpdate","update","docText","handleTagClick","event","type","dataset","target","value","parseContentInfo","rect","handleWrap","e","editorExtensions","extensions","EditorView","markdown","syntaxHighlighting","defaultHighlightStyle","SyntaxHighlighter","ImgPlaceholder","VideoPlaceholder","VariablePlaceholder","handleContentChange","isVariableSearchOpen","editorApi","handleToolbarActionClick","action","toolbarRightSlot","jsx","ariaLabel","jsxs","wrapped","Tooltip","TooltipTrigger","TooltipContent","EditorToolbar","VariableSearchDropdown","EditorContext","CodeMirror","CustomDialog","ImageInject","VideoInject","CustomPopover","VariableSelect","item"],"mappings":"0vEAkDMA,EAAY,CAChB,QAAS,CAAE,YAAaC,UAAA,EACxB,QAAS,CAAE,YAAaC,GAAAA,OAAA,CAC1B,EAEKC,EAAAA,QAAQ,cAQX,OAAO,QAAQH,CAAS,EAAE,QAAQ,CAAC,CAACI,EAAKC,CAAQ,IAAM,CACrDF,EAAAA,QAAQ,kBACNC,EACA,cACAC,EAAS,YACT,GACA,EAAA,CAEJ,CAAC,EAfDF,EAAAA,QAAQ,IAAIG,mBAAgB,EAAE,KAAK,CACjC,UAAAN,EACA,IAAK,QACL,YAAa,QACb,cAAe,CAAE,YAAa,EAAA,CAAM,CACrC,EAgCH,MAAMO,GAA8B,CAAA,EAG9BC,GAAmC,CACvCC,EACAC,IACG,CACH,GAAI,CAACD,GAAWC,EAAiB,EAC/B,MAAO,GAET,MAAMC,EAASC,EAAAA,+BAAA,EACf,IAAIC,EAEJ,MAAQA,EAAQF,EAAO,KAAKF,CAAO,KAAO,MAAM,CAC9C,MAAMK,EAAaD,EAAM,OAAS,EAC5BE,EAAWD,EAAaD,EAAM,CAAC,EAAE,OACjCG,EAAaF,EAAa,EAC1BG,EAAWF,EAAW,EAC5B,GAAIL,GAAkBM,GAAcN,GAAkBO,EACpD,MAAO,GAELN,EAAO,YAAcE,EAAM,OAC7BF,EAAO,WAEX,CAEA,MAAO,EACT,EAEMO,GAAwB,CAACC,EAAe,KAAO,KAAKA,CAAY,KAEhEC,GAAgC,CAAC,CACrC,QAAAX,EAAU,GACV,SAAAY,EAAW,WACX,UA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,CAACG,GACAsI,EAAAA,kBAAAA,KAACS,GAAAA,QAAA,CACC,OAAQ,CACN,MACEjH,IAAmBE,EAAAA,eAAe,MAC9B7B,EAAE,kBAAkB,EACpB2B,IAAmBE,iBAAe,MAChC7B,EAAE,kBAAkB,EACpB2B,IAAmBE,EAAAA,eAAe,SAChC7B,EAAE,qBAAqB,EACvBA,EAAE,aAAa,CAAA,EAG1B,SAAA,CAAA2B,IAAmBE,EAAAA,eAAe,OACjCoG,EAAAA,kBAAAA,IAACY,GAAAA,QAAA,CACC,MAAO/G,GAAmB,MAC1B,SAAUoD,GACV,YAAAtF,CAAA,CAAA,EAGH+B,IAAmBE,EAAAA,eAAe,OACjCoG,EAAAA,kBAAAA,IAACa,GAAAA,QAAA,CACC,MAAOhH,GAAmB,MAC1B,SAAU+D,EAAA,CAAA,CACZ,CAAA,CAAA,EAKL,CAAChG,GACAoI,EAAAA,kBAAAA,IAACc,WAAA,CACC,SAAAd,EAAAA,kBAAAA,IAACe,GAAAA,QAAA,CACC,UAAAzH,GACA,gBAAAE,EACA,aAAcK,GAAmB,OAAO,aACxC,SAAUiE,GACV,cAAgBnF,GAAa,CAC3BY,EAAcuB,GAAS,CACrB,MAAMlC,EAAaD,EAAS,KAAK,YAAA,EAIjC,OAHemC,EAAK,KACjBkG,GAASA,EAAK,KAAK,gBAAkBpI,CAAA,EAG/BkC,EAEF,CAACnC,EAAU,GAAGmC,CAAI,CAC3B,CAAC,CACH,CAAA,CAAA,CACF,CACF,CAAA,CAAA,CAEJ,CAAA,CACF,CAAA,CAAA,CAAA,CAGN"}
|
|
1
|
+
{"version":3,"file":"MarkdownFlowEditor.cjs.js","sources":["../../../src/components/MarkdownFlowEditor/MarkdownFlowEditor.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState, useCallback, useRef, useEffect, useMemo } from \"react\";\nimport CodeMirror from \"@uiw/react-codemirror\";\nimport { autocompletion } from \"@codemirror/autocomplete\";\nimport { EditorView, ViewUpdate } from \"@codemirror/view\";\nimport { markdown } from \"@codemirror/lang-markdown\";\nimport {\n syntaxHighlighting,\n defaultHighlightStyle,\n} from \"@codemirror/language\";\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"../ui/tooltip\";\nimport CustomDialog from \"./components/CustomDialog\";\nimport CustomPopover from \"./components/CustomPopover\";\nimport EditorToolbar from \"./components/EditorToolbar\";\nimport VariableSearchDropdown from \"./components/VariableSearchDropdown\";\nimport EditorContext from \"./editor-context\";\nimport ImageInject from \"./components/ImageInject\";\nimport VideoInject from \"./components/VideoInject\";\nimport VariableSelect from \"./components/VariableSelect\";\nimport {\n SelectedOption,\n IEditorContext,\n Variable,\n SelectContentInfo,\n PopoverPosition,\n EditorAction,\n EditorApi,\n} from \"./types\";\nimport \"./markdownFlowEditor.css\";\n\nimport {\n createSlashCommands,\n parseContentInfo,\n getImageContentToInsert,\n getVideoContentToInsert,\n extractVariableNames,\n createVariableExpressionRegexp,\n} from \"./utils\";\nimport ImgPlaceholder from \"./plugins/ImgPlaceholder\";\nimport VideoPlaceholder from \"./plugins/VideoPlaceholder\";\nimport VariablePlaceholder from \"./plugins/VariablePlaceholder\";\nimport SyntaxHighlighter from \"./plugins/SyntaxHighlighter\";\n// import createFixedTextPlaceholder from \"./plugins/FixedTextPlaceholder\";\n// import DividerPlaceholder from \"./plugins/DividerPlaceholder\";\nimport enUS from \"./locales/en-US.json\";\nimport zhCN from \"./locales/zh-CN.json\";\nimport { initReactI18next, useTranslation } from \"react-i18next\";\nimport i18next from \"i18next\";\nimport { UploadProps } from \"./uploadTypes\";\n\nconst resources = {\n \"en-US\": { translation: enUS },\n \"zh-CN\": { translation: zhCN },\n};\n\nif (!i18next.isInitialized) {\n i18next.use(initReactI18next).init({\n resources,\n lng: \"en-US\",\n fallbackLng: \"en-US\",\n interpolation: { escapeValue: false },\n });\n} else {\n Object.entries(resources).forEach(([lng, resource]) => {\n i18next.addResourceBundle(\n lng,\n \"translation\",\n resource.translation,\n true,\n true\n );\n });\n}\n\nexport enum EditMode {\n CodeEdit = \"codeEdit\",\n QuickEdit = \"quickEdit\",\n}\n\ntype EditorProps = {\n content?: string;\n editMode?: EditMode;\n variables?: Variable[];\n systemVariables?: Variable[];\n onChange?: (value: string) => void;\n onBlur?: () => void;\n locale?: \"en-US\" | \"zh-CN\";\n uploadProps?: UploadProps;\n disabled?: boolean;\n toolbarActionsRight?: EditorAction[];\n onReady?: (api: EditorApi) => void;\n};\n\nconst EMPTY_VARIABLES: Variable[] = [];\n\n// Detect whether cursor is still inside a {{variable}} expression\nconst isCursorInsideVariableExpression = (\n content: string,\n cursorPosition: number\n) => {\n if (!content || cursorPosition < 0) {\n return false;\n }\n const regexp = createVariableExpressionRegexp();\n let match: RegExpExecArray | null;\n\n while ((match = regexp.exec(content)) !== null) {\n const matchStart = match.index ?? 0;\n const matchEnd = matchStart + match[0].length;\n const innerStart = matchStart + 2;\n const innerEnd = matchEnd - 2;\n if (cursorPosition >= innerStart && cursorPosition <= innerEnd) {\n return true;\n }\n if (regexp.lastIndex === match.index) {\n regexp.lastIndex++;\n }\n }\n\n return false;\n};\n\nconst buildVariableTemplate = (variableName = \"\") => `{{${variableName}}}`;\n\nconst Editor: React.FC<EditorProps> = ({\n content = \"\",\n editMode = EditMode.CodeEdit,\n variables: initialVariables,\n systemVariables: initialSystemVariables,\n onChange,\n onBlur,\n locale = \"en-US\",\n uploadProps,\n disabled = false,\n toolbarActionsRight,\n onReady,\n}) => {\n const { t, i18n } = useTranslation();\n useEffect(() => {\n if (locale && i18n.language !== locale) {\n i18n.changeLanguage(locale);\n }\n }, [i18n, locale]);\n const activeLocale = (locale || i18n.language) as \"en-US\" | \"zh-CN\";\n const currentStrings = resources[activeLocale]?.translation ?? enUS;\n const toolbarLabels = useMemo(\n () => ({\n image: t(\"toolbarInsertImage\", {\n defaultValue: \"Insert image\",\n }),\n video: t(\"toolbarInsertVideo\", {\n defaultValue: \"Insert video\",\n }),\n addVariable: t(\"toolbarInsertNewVariable\", {\n defaultValue: \"Insert new variable\",\n }),\n search: t(\"toolbarInsertExistingVariable\", {\n defaultValue: \"Insert existing variable\",\n }),\n confirmOutput: t(\"toolbarConfirmOutput\", {\n defaultValue: \"Confirm output\",\n }),\n insertLink: t(\"toolbarInsertLink\", {\n defaultValue: \"Insert link\",\n }),\n insertButton: t(\"toolbarInsertButton\", {\n defaultValue: \"Insert button\",\n }),\n insertSingleChoice: t(\"toolbarInsertSingleChoice\", {\n defaultValue: \"Insert single choice\",\n }),\n insertMultiChoice: t(\"toolbarInsertMultiChoice\", {\n defaultValue: \"Insert multi choice\",\n }),\n insertInput: t(\"toolbarInsertInput\", {\n defaultValue: \"Insert input\",\n }),\n singleChoiceOption1: t(\"toolbarChoiceOption1\", {\n defaultValue: \"Option 1\",\n }),\n singleChoiceOption2: t(\"toolbarChoiceOption2\", {\n defaultValue: \"Option 2\",\n }),\n inputPlaceholder: t(\"toolbarInputPlaceholder\", {\n defaultValue: \"Please enter\",\n }),\n }),\n [t]\n );\n const variableSearchLabels = useMemo(\n () => ({\n searchPlaceholder: t(\"variableSearchPlaceholder\", {\n defaultValue: \"Search variable\",\n }),\n systemLabel: t(\"variableSectionSystem\", \"System Variables\"),\n customLabel: t(\"variableSectionCustom\", \"Custom Variables\"),\n emptyLabel: t(\"variableNotFound\", \"No variables found\"),\n }),\n [t]\n );\n const placeholderText =\n editMode === EditMode.QuickEdit\n ? t(\"placeholderQuickEdit\", {\n defaultValue: t(\"placeholderCodeEdit\", {\n defaultValue: t(\"placeholder\"),\n }),\n })\n : t(\"placeholderCodeEdit\", { defaultValue: t(\"placeholder\") });\n // Normalize variables to avoid duplicating system variables in the custom list\n const normalizedSystemVariables = useMemo(() => {\n const seen = new Set<string>();\n return (initialSystemVariables ?? EMPTY_VARIABLES).filter((variable) => {\n const normalized =\n typeof variable?.name === \"string\" ? variable.name.toLowerCase() : \"\";\n if (!normalized || seen.has(normalized)) {\n return false;\n }\n seen.add(normalized);\n return true;\n });\n }, [initialSystemVariables]);\n\n const normalizedCustomVariables = useMemo(() => {\n const systemNameSet = new Set(\n normalizedSystemVariables.map((variable) => variable.name.toLowerCase())\n );\n const seen = new Set<string>();\n return (initialVariables ?? EMPTY_VARIABLES).filter((variable) => {\n const normalized =\n typeof variable?.name === \"string\" ? variable.name.toLowerCase() : \"\";\n if (\n !normalized ||\n systemNameSet.has(normalized) ||\n seen.has(normalized)\n ) {\n return false;\n }\n seen.add(normalized);\n return true;\n });\n }, [initialVariables, normalizedSystemVariables]);\n\n const [dialogOpen, setDialogOpen] = useState(false);\n const [popoverOpen, setPopoverOpen] = useState(false);\n const [popoverPosition, setPopoverPosition] =\n useState<PopoverPosition | null>(null);\n const [variables, setVariables] = useState<Variable[]>(\n normalizedCustomVariables\n );\n const [systemVariables, setSystemVariables] = useState<Variable[]>(\n normalizedSystemVariables\n );\n\n useEffect(() => {\n setVariables(normalizedCustomVariables);\n }, [normalizedCustomVariables]);\n\n useEffect(() => {\n setSystemVariables(normalizedSystemVariables);\n }, [normalizedSystemVariables]);\n\n const [selectedOption, setSelectedOption] = useState<SelectedOption>(\n SelectedOption.Empty\n );\n const [selectContentInfo, setSelectContentInfo] =\n useState<SelectContentInfo | null>();\n const editorViewRef = useRef<EditorView | null>(null);\n const pendingVariableContentRef = useRef<string | null>(null);\n const variableSearchAnchorRef = useRef<HTMLButtonElement | null>(null);\n const [variableSearchOpen, setVariableSearchOpen] = useState(false);\n const closeVariableSearch = useCallback(() => {\n setVariableSearchOpen(false);\n variableSearchAnchorRef.current = null;\n }, []);\n const handleVariableSearchToggle = useCallback(\n (button: HTMLButtonElement) => {\n if (disabled) {\n return;\n }\n if (variableSearchOpen && variableSearchAnchorRef.current === button) {\n closeVariableSearch();\n return;\n }\n variableSearchAnchorRef.current = button;\n setVariableSearchOpen(true);\n },\n [closeVariableSearch, disabled, variableSearchOpen]\n );\n\n const editorContextValue: IEditorContext = {\n selectedOption,\n setSelectedOption,\n dialogOpen,\n setDialogOpen,\n popoverOpen,\n setPopoverOpen,\n popoverPosition,\n setPopoverPosition,\n };\n\n useEffect(() => {\n if (!disabled) {\n return;\n }\n setDialogOpen(false);\n setPopoverOpen(false);\n setSelectedOption(SelectedOption.Empty);\n setSelectContentInfo(null);\n setPopoverPosition(null);\n closeVariableSearch();\n }, [\n closeVariableSearch,\n disabled,\n setDialogOpen,\n setPopoverOpen,\n setPopoverPosition,\n setSelectedOption,\n setSelectContentInfo,\n ]);\n\n const addVariablesFromContent = useCallback(\n (text: string) => {\n if (editMode !== EditMode.QuickEdit || !text) {\n return;\n }\n\n const names = extractVariableNames(text);\n if (!names.length) {\n return;\n }\n\n const systemNameSet = new Set(\n systemVariables.map((variable) => variable.name.toLowerCase())\n );\n\n setVariables((prev) => {\n const existingNames = new Set(\n prev.map((variable) => variable.name.toLowerCase())\n );\n const addedNames = new Set<string>();\n const newVariables: Variable[] = [];\n\n names.forEach((rawName) => {\n const normalized = rawName.toLowerCase();\n if (\n !rawName ||\n systemNameSet.has(normalized) ||\n existingNames.has(normalized) ||\n addedNames.has(normalized)\n ) {\n return;\n }\n newVariables.push({ name: rawName });\n addedNames.add(normalized);\n });\n\n if (!newVariables.length) {\n return prev;\n }\n\n return [...newVariables, ...prev];\n });\n },\n [editMode, systemVariables]\n );\n\n useEffect(() => {\n addVariablesFromContent(content);\n }, [content, addVariablesFromContent]);\n\n // const insertFixedText = useCallback(() => {\n // if (!editorViewRef.current) return;\n // const view = editorViewRef.current;\n // const { state, dispatch } = view;\n // const selection = state.selection.main;\n // const selectedText = state.sliceDoc(selection.from, selection.to);\n // const startTag = \"===\";\n // const endTag = \"===\";\n // const insertContent = `${startTag}${selectedText ?? \"\"}${endTag}`;\n\n // dispatch({\n // changes: {\n // from: selection.from,\n // to: selection.to,\n // insert: insertContent,\n // },\n // selection: {\n // anchor: selection.from + startTag.length + (selectedText?.length ?? 0),\n // },\n // });\n // view.focus();\n // }, []);\n\n // const insertDivider = useCallback(() => {\n // if (!editorViewRef.current) return;\n // const view = editorViewRef.current;\n // const { state, dispatch } = view;\n // const selection = state.selection.main;\n // const insertContent = `\\n\\n---\\n\\n`;\n\n // dispatch({\n // changes: {\n // from: selection.from,\n // to: selection.to,\n // insert: insertContent,\n // },\n // selection: {\n // anchor: selection.from + insertContent.length,\n // },\n // });\n // view.focus();\n // }, []);\n\n const onSelectedOption = useCallback(\n (option: SelectedOption) => {\n if (disabled) {\n return;\n }\n closeVariableSearch();\n // if (option === SelectedOption.FixedText) {\n // insertFixedText();\n // setSelectedOption(SelectedOption.Empty);\n // setDialogOpen(false);\n // setPopoverOpen(false);\n // setSelectContentInfo(null);\n // setPopoverPosition(null);\n // return;\n // }\n\n // if (option === SelectedOption.Divider) {\n // insertDivider();\n // setSelectedOption(SelectedOption.Empty);\n // setDialogOpen(false);\n // setPopoverOpen(false);\n // setSelectContentInfo(null);\n // setPopoverPosition(null);\n // return;\n // }\n\n setSelectedOption(option);\n\n if (option === SelectedOption.Variable) {\n if (editorViewRef.current) {\n const { state } = editorViewRef.current;\n const pos = state.selection.main.from;\n const coords = editorViewRef.current.coordsAtPos(pos);\n if (coords) {\n setPopoverPosition({\n x: coords.left,\n y: coords.bottom,\n });\n }\n }\n setPopoverOpen(true);\n } else {\n setDialogOpen(true);\n }\n },\n [closeVariableSearch, disabled]\n );\n\n const insertText = useCallback(\n (text: string) => {\n if (disabled || !editorViewRef.current) return;\n\n const { state, dispatch } = editorViewRef.current;\n const from = state.selection.main.from;\n\n dispatch({\n changes: { from, insert: text },\n selection: { anchor: from + text.length },\n });\n },\n [editorViewRef, disabled]\n );\n\n const replaceSelection = useCallback(\n (text: string) => {\n if (disabled || !editorViewRef.current) {\n return;\n }\n const { state, dispatch } = editorViewRef.current;\n const selection = state.selection.main;\n dispatch({\n changes: { from: selection.from, to: selection.to, insert: text },\n selection: { anchor: selection.from + text.length },\n });\n },\n [disabled]\n );\n\n const focusEditor = useCallback(() => {\n editorViewRef.current?.focus();\n }, []);\n\n const getContent = useCallback(() => {\n return editorViewRef.current?.state.doc.toString() ?? \"\";\n }, []);\n\n const setContent = useCallback(\n (text: string) => {\n if (disabled) {\n return;\n }\n if (!editorViewRef.current) {\n onChange?.(text);\n return;\n }\n const view = editorViewRef.current;\n const { state, dispatch } = view;\n dispatch({\n changes: { from: 0, to: state.doc.length, insert: text },\n selection: { anchor: text.length },\n });\n },\n [disabled, onChange]\n );\n\n const deleteSelectedContent = useCallback(() => {\n if (disabled) {\n return;\n }\n if (\n !selectContentInfo ||\n !editorViewRef.current ||\n selectContentInfo.from === -1\n )\n return;\n\n const { from, to } = selectContentInfo;\n const { dispatch } = editorViewRef.current;\n\n dispatch({\n changes: { from, to, insert: \"\" },\n });\n }, [selectContentInfo, editorViewRef, disabled]);\n\n const insertVariableContent = useCallback(\n (\n variableName: string,\n range?: { from: number; to: number },\n placeCursorAtEnd = false\n ) => {\n if (disabled || !editorViewRef.current) {\n return;\n }\n const view = editorViewRef.current;\n const { state, dispatch } = view;\n const selection = range ?? state.selection.main;\n const template = buildVariableTemplate(variableName);\n const cursorOffset = placeCursorAtEnd\n ? template.length\n : 2 + variableName.length; // 2 braces before variable content\n\n dispatch({\n changes: {\n from: selection.from,\n to: selection.to,\n insert: template,\n },\n selection: {\n anchor: selection.from + cursorOffset,\n },\n });\n view.focus();\n },\n [disabled]\n );\n\n const insertVariableTemplate = useCallback(() => {\n if (disabled) {\n return;\n }\n closeVariableSearch();\n insertVariableContent(\"\");\n }, [closeVariableSearch, disabled, insertVariableContent]);\n\n const insertConfirmOutputMarker = useCallback(() => {\n if (disabled || !editorViewRef.current) {\n return;\n }\n const view = editorViewRef.current;\n const { state, dispatch } = view;\n const selection = state.selection.main;\n const template = \"======\";\n dispatch({\n changes: {\n from: selection.from,\n to: selection.to,\n insert: template,\n },\n selection: {\n anchor: selection.from + 3,\n },\n });\n view.focus();\n }, [disabled]);\n\n const insertLinkTemplate = useCallback(() => {\n if (disabled || !editorViewRef.current) {\n return;\n }\n const view = editorViewRef.current;\n const { state, dispatch } = view;\n const selection = state.selection.main;\n const template = \"[]()\";\n dispatch({\n changes: {\n from: selection.from,\n to: selection.to,\n insert: template,\n },\n selection: {\n anchor: selection.from + 1,\n },\n });\n view.focus();\n }, [disabled]);\n\n const insertButtonTemplate = useCallback(() => {\n if (disabled || !editorViewRef.current) {\n return;\n }\n const view = editorViewRef.current;\n const { state, dispatch } = view;\n const selection = state.selection.main;\n const template = \"?[]\";\n dispatch({\n changes: {\n from: selection.from,\n to: selection.to,\n insert: template,\n },\n selection: {\n anchor: selection.from + 2,\n },\n });\n view.focus();\n }, [disabled]);\n\n const insertSingleChoiceTemplate = useCallback(() => {\n if (disabled || !editorViewRef.current) {\n return;\n }\n const view = editorViewRef.current;\n const { state, dispatch } = view;\n const selection = state.selection.main;\n const optionLabel1 = toolbarLabels.singleChoiceOption1;\n const optionLabel2 = toolbarLabels.singleChoiceOption2;\n const template = `?[%{{}} ${optionLabel1} | ${optionLabel2}]`;\n dispatch({\n changes: {\n from: selection.from,\n to: selection.to,\n insert: template,\n },\n selection: {\n anchor: selection.from + 5,\n },\n });\n view.focus();\n }, [\n disabled,\n toolbarLabels.singleChoiceOption1,\n toolbarLabels.singleChoiceOption2,\n ]);\n\n const insertMultiChoiceTemplate = useCallback(() => {\n if (disabled || !editorViewRef.current) {\n return;\n }\n const view = editorViewRef.current;\n const { state, dispatch } = view;\n const selection = state.selection.main;\n const optionLabel1 = toolbarLabels.singleChoiceOption1;\n const optionLabel2 = toolbarLabels.singleChoiceOption2;\n const template = `?[%{{}} ${optionLabel1} || ${optionLabel2}]`;\n dispatch({\n changes: {\n from: selection.from,\n to: selection.to,\n insert: template,\n },\n selection: {\n anchor: selection.from + 5,\n },\n });\n view.focus();\n }, [\n disabled,\n toolbarLabels.singleChoiceOption1,\n toolbarLabels.singleChoiceOption2,\n ]);\n\n const insertInputFieldTemplate = useCallback(() => {\n if (disabled || !editorViewRef.current) {\n return;\n }\n const view = editorViewRef.current;\n const { state, dispatch } = view;\n const selection = state.selection.main;\n const placeholder = toolbarLabels.inputPlaceholder ?? \"请输入\";\n const template = `?[%{{}}...${placeholder}]`;\n dispatch({\n changes: {\n from: selection.from,\n to: selection.to,\n insert: template,\n },\n selection: {\n anchor: selection.from + 5,\n },\n });\n view.focus();\n }, [disabled, toolbarLabels.inputPlaceholder]);\n\n const handleSelectImage = useCallback(\n ({\n resourceUrl,\n resourceTitle,\n scalePercent,\n }: {\n resourceUrl?: string;\n resourceTitle?: string;\n scalePercent?: number;\n }) => {\n if (!resourceUrl || disabled) return;\n const textToInsert = getImageContentToInsert({\n resourceUrl,\n resourceTitle,\n scalePercent,\n });\n if (selectContentInfo?.type === SelectedOption.Image) {\n deleteSelectedContent();\n if (!editorViewRef.current) return;\n const { dispatch } = editorViewRef.current;\n dispatch({\n changes: { from: selectContentInfo.from, insert: textToInsert },\n });\n } else {\n insertText(textToInsert);\n }\n setDialogOpen(false);\n },\n [deleteSelectedContent, disabled, insertText, selectContentInfo]\n );\n\n const handleSelectVideo = useCallback(\n ({\n resourceUrl,\n resourceTitle,\n }: {\n resourceUrl: string;\n resourceTitle: string;\n }) => {\n if (disabled) {\n return;\n }\n const textToInsert = getVideoContentToInsert(resourceUrl, resourceTitle);\n if (selectContentInfo?.type === SelectedOption.Video) {\n deleteSelectedContent();\n if (!editorViewRef.current) return;\n const { dispatch } = editorViewRef.current;\n dispatch({\n changes: { from: selectContentInfo.from, insert: textToInsert },\n });\n } else {\n insertText(textToInsert);\n }\n setDialogOpen(false);\n },\n [deleteSelectedContent, disabled, insertText, selectContentInfo]\n );\n\n const handleSelectVariable = useCallback(\n (variable: Variable) => {\n if (disabled) {\n return;\n }\n const selectionRange =\n selectContentInfo?.type === SelectedOption.Variable\n ? { from: selectContentInfo.from, to: selectContentInfo.to }\n : undefined;\n insertVariableContent(variable.name, selectionRange, true);\n setPopoverOpen(false);\n closeVariableSearch();\n },\n [disabled, insertVariableContent, selectContentInfo, closeVariableSearch]\n );\n\n const slashCommandsExtension = useCallback(() => {\n return autocompletion({\n override: [\n createSlashCommands(onSelectedOption, {\n // divider: currentStrings.slashDivider,\n // fixedText: currentStrings.slashFixedText,\n image: currentStrings.slashImage,\n video: currentStrings.slashVideo,\n variable: currentStrings.slashVariable,\n }),\n ],\n });\n }, [\n // currentStrings.slashDivider,\n // currentStrings.slashFixedText,\n currentStrings.slashImage,\n currentStrings.slashVideo,\n currentStrings.slashVariable,\n onSelectedOption,\n ]);\n\n // const fixedTextPlaceholderExtension = useMemo(\n // () =>\n // createFixedTextPlaceholder(\n // currentStrings.fixedTextPlaceholder ?? \"添加固定文本\",\n // currentStrings.fixedTextTooltip ??\n // currentStrings.slashFixedText ??\n // \"固定文本\"\n // ),\n // [\n // currentStrings.fixedTextPlaceholder,\n // currentStrings.fixedTextTooltip,\n // currentStrings.slashFixedText,\n // ]\n // );\n\n const handleEditorUpdate = useCallback(\n (update: ViewUpdate) => {\n editorViewRef.current = update.view;\n if (\n editMode === EditMode.QuickEdit &&\n pendingVariableContentRef.current &&\n update.selectionSet\n ) {\n const cursorPosition = update.state.selection.main.head;\n const docText = update.state.doc.toString();\n const stillInside = isCursorInsideVariableExpression(\n docText,\n cursorPosition\n );\n if (!stillInside) {\n addVariablesFromContent(docText);\n pendingVariableContentRef.current = null;\n }\n }\n },\n [addVariablesFromContent, editMode]\n );\n\n const handleTagClick = useCallback(\n (event: any) => {\n event.stopPropagation();\n if (disabled) {\n return;\n }\n const { type, from, to, dataset, target } = event.detail;\n const value = parseContentInfo(type, dataset);\n setSelectContentInfo({\n type,\n value,\n from,\n to,\n });\n setSelectedOption(type);\n\n if (type === SelectedOption.Variable) {\n if (target) {\n const rect = target.getBoundingClientRect();\n setPopoverPosition({\n x: rect.left,\n y: rect.bottom,\n });\n }\n setPopoverOpen(true);\n } else {\n setDialogOpen(true);\n }\n },\n [disabled]\n );\n\n useEffect(() => {\n if (!dialogOpen) {\n setSelectedOption(SelectedOption.Empty);\n setSelectContentInfo(null);\n }\n }, [dialogOpen]);\n\n useEffect(() => {\n if (!popoverOpen && selectedOption === SelectedOption.Variable) {\n setSelectedOption(SelectedOption.Empty);\n setSelectContentInfo(null);\n }\n }, [popoverOpen, selectedOption]);\n\n useEffect(() => {\n const handleWrap = (e: any) => {\n if (e.detail.view === editorViewRef.current) {\n handleTagClick(e);\n }\n };\n window.addEventListener(\"globalTagClick\", handleWrap);\n return () => {\n window.removeEventListener(\"globalTagClick\", handleWrap);\n };\n }, [handleTagClick]);\n\n const editorExtensions = useMemo(() => {\n const extensions = [\n EditorView.lineWrapping,\n markdown(),\n syntaxHighlighting(defaultHighlightStyle),\n SyntaxHighlighter,\n ];\n\n if (!disabled) {\n extensions.push(slashCommandsExtension());\n }\n\n if (editMode === EditMode.QuickEdit) {\n extensions.push(\n ImgPlaceholder,\n VideoPlaceholder,\n VariablePlaceholder\n // fixedTextPlaceholderExtension,\n // DividerPlaceholder,\n );\n }\n\n extensions.push(\n EditorView.updateListener.of((update) => {\n handleEditorUpdate(update);\n })\n );\n\n return extensions;\n }, [disabled, editMode, slashCommandsExtension, handleEditorUpdate]);\n\n const handleContentChange = useCallback(\n (value: string) => {\n if (disabled) {\n return;\n }\n const cursorPosition =\n editorViewRef.current?.state.selection.main.head ?? -1;\n const skipAddition = isCursorInsideVariableExpression(\n value,\n cursorPosition\n );\n if (skipAddition) {\n pendingVariableContentRef.current = value;\n } else {\n pendingVariableContentRef.current = null;\n addVariablesFromContent(value);\n }\n onChange?.(value);\n },\n [addVariablesFromContent, onChange, disabled]\n );\n\n const isVariableSearchOpen = !disabled && variableSearchOpen;\n const editorApi = useMemo(\n () => ({\n insertTextAtCursor: insertText,\n replaceSelection,\n focus: focusEditor,\n getContent,\n setContent,\n }),\n [focusEditor, getContent, insertText, replaceSelection, setContent]\n );\n\n const handleToolbarActionClick = useCallback(\n (action: EditorAction) => {\n if (disabled || \"render\" in action) {\n return;\n }\n action.onClick?.(editorApi);\n },\n [disabled, editorApi]\n );\n\n const toolbarRightSlot = useMemo(() => {\n if (!toolbarActionsRight?.length) {\n return null;\n }\n return (\n <div className=\"markdown-flow-editor-toolbar-right\">\n {toolbarActionsRight.map((action) => {\n if (\"render\" in action) {\n return (\n <div\n className=\"markdown-flow-editor-toolbar-right-item\"\n key={action.key}\n >\n {action.render(editorApi)}\n </div>\n );\n }\n const ariaLabel = action.label || action.tooltip || undefined;\n const button = (\n <button\n type=\"button\"\n key={action.key}\n disabled={disabled || action.disabled}\n onClick={() => handleToolbarActionClick(action)}\n className=\"markdown-flow-editor-toolbar-right-button\"\n aria-label={ariaLabel}\n title={action.label || action.tooltip}\n >\n {action.icon ? (\n <span className=\"toolbar-right-icon\">{action.icon}</span>\n ) : null}\n {action.label ? (\n <span className=\"toolbar-right-label\">{action.label}</span>\n ) : null}\n </button>\n );\n const wrapped = action.tooltip ? (\n <Tooltip>\n <TooltipTrigger asChild>{button}</TooltipTrigger>\n <TooltipContent side=\"top\">{action.tooltip}</TooltipContent>\n </Tooltip>\n ) : (\n button\n );\n return (\n <div\n className=\"markdown-flow-editor-toolbar-right-item\"\n key={action.key}\n >\n {wrapped}\n </div>\n );\n })}\n </div>\n );\n }, [disabled, editorApi, handleToolbarActionClick, toolbarActionsRight]);\n\n useEffect(() => {\n onReady?.(editorApi);\n }, [editorApi]);\n\n return (\n <div\n className=\"markdown-flow-editor\"\n data-disabled={disabled ? \"true\" : undefined}\n aria-disabled={disabled}\n >\n <EditorToolbar\n disabled={disabled}\n labels={toolbarLabels}\n onSelect={onSelectedOption}\n onInsertVariablePlaceholder={insertVariableTemplate}\n onVariableSearchToggle={handleVariableSearchToggle}\n onVariableSearchClose={closeVariableSearch}\n onInsertConfirmOutput={insertConfirmOutputMarker}\n onInsertLink={insertLinkTemplate}\n onInsertButton={insertButtonTemplate}\n onInsertSingleChoice={insertSingleChoiceTemplate}\n onInsertMultiChoice={insertMultiChoiceTemplate}\n onInsertInputField={insertInputFieldTemplate}\n variableSearchActive={isVariableSearchOpen}\n rightSlot={toolbarRightSlot}\n />\n <VariableSearchDropdown\n open={isVariableSearchOpen}\n anchorElement={variableSearchAnchorRef.current}\n onClose={closeVariableSearch}\n onSelect={handleSelectVariable}\n variables={variables}\n systemVariables={systemVariables}\n labels={variableSearchLabels}\n />\n <div className=\"markdown-flow-editor-body relative overflow-auto\">\n <EditorContext.Provider value={editorContextValue}>\n <CodeMirror\n extensions={editorExtensions}\n basicSetup={{\n lineNumbers: false,\n syntaxHighlighting: true,\n highlightActiveLine: true,\n highlightActiveLineGutter: true,\n foldGutter: false,\n }}\n className=\"rounded-md\"\n placeholder={placeholderText}\n value={content}\n theme=\"light\"\n minHeight=\"2rem\"\n editable={!disabled}\n onChange={handleContentChange}\n onBlur={onBlur}\n />\n {!disabled && (\n <CustomDialog\n labels={{\n title:\n selectedOption === SelectedOption.Image\n ? t(\"dialogTitleImage\")\n : selectedOption === SelectedOption.Video\n ? t(\"dialogTitleVideo\")\n : selectedOption === SelectedOption.Variable\n ? t(\"dialogTitleVariable\")\n : t(\"dialogTitle\"),\n }}\n >\n {selectedOption === SelectedOption.Image && (\n <ImageInject\n value={selectContentInfo?.value}\n onSelect={handleSelectImage}\n uploadProps={uploadProps}\n />\n )}\n {selectedOption === SelectedOption.Video && (\n <VideoInject\n value={selectContentInfo?.value}\n onSelect={handleSelectVideo}\n />\n )}\n </CustomDialog>\n )}\n\n {!disabled && (\n <CustomPopover>\n <VariableSelect\n variables={variables}\n systemVariables={systemVariables}\n selectedName={selectContentInfo?.value?.variableName}\n onSelect={handleSelectVariable}\n onAddVariable={(variable) => {\n setVariables((prev) => {\n const normalized = variable.name.toLowerCase();\n const exists = prev.some(\n (item) => item.name.toLowerCase() === normalized\n );\n if (exists) {\n return prev;\n }\n return [variable, ...prev];\n });\n }}\n />\n </CustomPopover>\n )}\n </EditorContext.Provider>\n </div>\n </div>\n );\n};\n\nexport default Editor;\n"],"names":["resources","enUS","zhCN","i18next","lng","resource","initReactI18next","EMPTY_VARIABLES","isCursorInsideVariableExpression","content","cursorPosition","regexp","createVariableExpressionRegexp","match","matchStart","matchEnd","innerStart","innerEnd","buildVariableTemplate","variableName","Editor","editMode","initialVariables","initialSystemVariables","onChange","onBlur","locale","uploadProps","disabled","toolbarActionsRight","onReady","t","i18n","useTranslation","useEffect","activeLocale","currentStrings","toolbarLabels","useMemo","variableSearchLabels","placeholderText","normalizedSystemVariables","seen","variable","normalized","normalizedCustomVariables","systemNameSet","dialogOpen","setDialogOpen","useState","popoverOpen","setPopoverOpen","popoverPosition","setPopoverPosition","variables","setVariables","systemVariables","setSystemVariables","selectedOption","setSelectedOption","SelectedOption","selectContentInfo","setSelectContentInfo","editorViewRef","useRef","pendingVariableContentRef","variableSearchAnchorRef","variableSearchOpen","setVariableSearchOpen","closeVariableSearch","useCallback","handleVariableSearchToggle","button","editorContextValue","addVariablesFromContent","text","names","extractVariableNames","prev","existingNames","addedNames","newVariables","rawName","onSelectedOption","option","state","pos","coords","insertText","dispatch","from","replaceSelection","selection","focusEditor","getContent","setContent","view","deleteSelectedContent","to","insertVariableContent","range","placeCursorAtEnd","template","cursorOffset","insertVariableTemplate","insertConfirmOutputMarker","insertLinkTemplate","insertButtonTemplate","insertSingleChoiceTemplate","optionLabel1","optionLabel2","insertMultiChoiceTemplate","insertInputFieldTemplate","handleSelectImage","resourceUrl","resourceTitle","scalePercent","textToInsert","getImageContentToInsert","handleSelectVideo","getVideoContentToInsert","handleSelectVariable","selectionRange","slashCommandsExtension","autocompletion","createSlashCommands","handleEditorUpdate","update","docText","handleTagClick","event","type","dataset","target","value","parseContentInfo","rect","handleWrap","e","editorExtensions","extensions","EditorView","markdown","syntaxHighlighting","defaultHighlightStyle","SyntaxHighlighter","ImgPlaceholder","VideoPlaceholder","VariablePlaceholder","handleContentChange","isVariableSearchOpen","editorApi","handleToolbarActionClick","action","toolbarRightSlot","jsx","ariaLabel","jsxs","wrapped","Tooltip","TooltipTrigger","TooltipContent","EditorToolbar","VariableSearchDropdown","EditorContext","CodeMirror","CustomDialog","ImageInject","VideoInject","CustomPopover","VariableSelect","item"],"mappings":"0vEAmDMA,EAAY,CACh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