@linker-design-plus/tiny-peony 1.3.7 → 1.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -69,5 +69,5 @@ return ret;
69
69
  generatorPosition: ${f>N+k?ag.底部:ag.顶部}
70
70
  shortcutPosition: ${f>N+k+AI?VA.底部:VA.顶部}
71
71
  subShortcutPosition: ${f>N+k+AI+xC?PA.顶部对齐:PA.底部对齐}
72
- `),i(f>N+k?ag.底部:ag.顶部),a(f>N+k+AI+8?VA.底部:VA.顶部),h(f>N+k+AI+xC?PA.顶部对齐:PA.底部对齐)},D=zI(d);return E.onMounted(()=>{var y;(y=B.value)==null||y.addEventListener("scroll",D)}),E.onUnmounted(()=>{var y;(y=B.value)==null||y.removeEventListener("scroll",D)}),{generatorPosition:o,shortcutPosition:c,subShortcutPosition:r,setGeneratorPosition:i,setShortcutPosition:a,setSubShortcutPosition:h,calcModalPosition:d}},[Fo]=HA("refine-generator"),No=E.defineComponent({name:"RefineGenerator",props:{width:{type:[Number,String],default:"100%"}},emits:{},setup:C=>{const{highlightRange:t,unhighlightRange:B,revertRange:o}=Dt(),i=E.inject(Eg),{agentId:c,createSession:a,sendSessionMessage:r,abortSession:h}=i.refineContext,[d,D]=fA(void 0),y=()=>(r.abort(),h({sessionId:d.value})),R=E.ref(),[F,f]=fA({zIndex:-10}),[N,k]=fA(!1,nA=>{nA||(d.value&&[LA.等待生成,LA.正在生成].includes(x.value)&&y(),D(void 0),RA(!1),UA(void 0),v(!1),P(LA.未生成),b(0),BA([]),gA(void 0),SA(!0),f({zIndex:-10}))}),U=()=>{var KA,TA,jA,gg;if(Y(i)||Y(i.editorCore.value))return;const nA=gB((KA=X.value)==null?void 0:KA.getBoundingClientRect(),(TA=Array.from(i.editorCore.value._editorElement.querySelectorAll(".tag-range-highlight")).pop())==null?void 0:TA.getBoundingClientRect(),1);f({top:`${nA.top+(((jA=X.value)==null?void 0:jA.scrollTop)??0)}px`,left:0,width:`${(gg=i.editorCore.value)==null?void 0:gg._editorElement.offsetWidth}px`})},M=()=>{Y(i)||Y(i.editorCore.value)||(U(),k(!0))},O=nA=>{var KA;N.value&&((KA=R.value)!=null&&KA.contains(nA.target)||(B(),k(!1)))},V=zI(()=>{N.value&&U()}),[X,$]=fA(void 0);E.onMounted(()=>{var nA;$(document.body.querySelector(".c-editor-container--refinable")),document.addEventListener("mousedown",O),(nA=X.value)==null||nA.addEventListener("scroll",V)}),E.onUnmounted(()=>{var nA;document.removeEventListener("mousedown",O),(nA=X.value)==null||nA.removeEventListener("scroll",V)});const T=sE(C.width)?`${C.width}px`:C.width,[QA,RA]=II(),[pA,UA]=fA(void 0),[bA,SA]=II(!0),[p,v]=II(),[x,P]=fA(LA.未生成),[_,b]=fA(0),[j,BA]=fA([]),[eA,gA]=fA(void 0),hA={name:"RefineGenerator",refineGeneratorRef:R,visible:N,width:T,generating:QA,prompt:pA,shortcutVisible:bA,content:j,activedContent:eA,contentVisible:p,contentPage:_,contentState:x,setVisible:k,setRefineGenerating:RA,setRefinePrompt:UA,setShortVisible:SA,setRefineContent:BA,setActivedRefineContent:gA,genRefineContent:async nA=>{var Kg,Dg;if(QA.value)return;RA(!0),UA(void 0),BA((nA==null?void 0:nA.generateType)===wg.刷新?[...j.value,{...j.value[_.value-1],content:""}]:[gg(nA)]),gA(j.value[j.value.length-1]),b(j.value.length),P(LA.等待生成),D($C());const KA=await a({agentId:c,sessionId:d.value});v(!0),P(LA.正在生成),r({messageRequest:{agent_id:c,message:{content:Array.from(document.body.querySelectorAll(`.${QI}`)).map(JA=>JA.textContent??"").join(""),conversation_id:KA.data.conversionId},meta_data:{ai_rewrite:((Kg=eA.value)==null?void 0:Kg.shortcutType)??((Dg=eA.value)==null?void 0:Dg.prompt),sessionId:d.value}}},{onmessage:jA,onclose:()=>{console.log("---onclose "),TA()},onerror:JA=>{console.log("---onerror ",JA),TA()}});function TA(){Hg(),RA(!1),P(LA.未生成),SA(!0)}function jA(JA){const vA=JSON.parse(JA.data);vA.type==="answer"&&(eA.value.content+=vA.content)}function gg(JA){const vA=(JA==null?void 0:JA.generateType)===wg.重置;return{isManualPrompt:vA,prompt:vA?JA.prompt:void 0,shortcutType:vA?JA.shortcutType:void 0,content:""}}},setContentPage:b,setContentVisible:v,setContentState:P,showRefineGenerator:M,abortSession:y,scrollElm:X,highlightRange:t,unhighlightRange:B,revertRange:o},{generatorPosition:DA,shortcutPosition:Ag,subShortcutPosition:Yg,setGeneratorPosition:hg,setShortcutPosition:tI,setSubShortcutPosition:oI,calcModalPosition:Hg}=Ro(hA);return E.provide(mg,{...hA,generatorPosition:DA,shortcutPosition:Ag,subShortcutPosition:Yg,setGeneratorPosition:hg,setShortcutPosition:tI,setSubShortcutPosition:oI,calcModalPosition:Hg}),{innerRender:()=>E.createVNode(E.Fragment,null,[E.createVNode(fo,null,null),E.createVNode("div",{ref:R,class:"c-refine-generator-wrapper",style:{...F.value,display:N.value?"block":"none"}},[E.createVNode("div",{class:"c-refine-generator-wrapper__inner"},[E.createVNode("div",{class:Fo(),style:{width:T}},[E.createVNode(to,{modelValue:j.value,"onUpdate:modelValue":nA=>j.value=nA},null),E.createVNode(uo,{modelValue:pA.value,"onUpdate:modelValue":nA=>pA.value=nA},null)]),E.createVNode(yo,null,null)])])]),innerSetVisible:k}},methods:{setVisible(C){this.innerSetVisible(C)}},render(){return this.innerRender()}}),ko={};function Go(C,t){return E.openBlock(),E.createElementBlock("svg",E.mergeProps({xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 1024 1024","aria-hidden":"true",role:"img",class:"iconify iconify--mdi",width:"18",height:"18",preserveAspectRatio:"xMidYMid meet"},C.$attrs),t[0]||(t[0]=[E.createElementVNode("path",{d:"M843.0592 474.9312l-448-307.2-0.1024 0.1024A51.712 51.712 0 0 0 359.168 153.6c-28.5184 0-51.712 22.9376-51.712 51.2 0 15.5136-0.6144 45.9264 0 45.312V819.2c0 28.2624 23.1936 51.2 51.712 51.2 13.9776 0 26.624-5.4784 35.84-14.336h0.0512l448-307.2a50.7904 50.7904 0 0 0 15.872-36.864v-0.1024-0.1024a50.8416 50.8416 0 0 0-15.872-36.864z",fill:"currentColor"},null,-1)]),16)}const So=dA(ko,[["render",Go]]),Lo={};function Uo(C,t){return E.openBlock(),E.createElementBlock("svg",E.mergeProps({xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 1024 1024","aria-hidden":"true",role:"img",class:"iconify iconify--mdi",width:"18",height:"18",preserveAspectRatio:"xMidYMid meet"},C.$attrs),t[0]||(t[0]=[E.createElementVNode("path",{d:"M299.90284958 17.10664903a70.69905013 70.69905013 0 0 0-70.69905015 70.69905014v848.38860166a70.69905013 70.69905013 0 1 0 141.39810028 0V87.80569917a70.69905013 70.69905013 0 0 0-70.69905013-70.69905014z m424.19430084 0a70.69905013 70.69905013 0 0 0-70.69905013 70.69905014v848.38860166a70.69905013 70.69905013 0 1 0 141.39810028 0V87.80569917a70.69905013 70.69905013 0 0 0-70.69905015-70.69905014z",fill:"currentColor"},null,-1)]),16)}const Mo=dA(Lo,[["render",Uo]]),po={};function Jo(C,t){return E.openBlock(),E.createElementBlock("svg",E.mergeProps({xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 1024 1024","aria-hidden":"true",role:"img",class:"iconify iconify--mdi",width:"18",height:"18",preserveAspectRatio:"xMidYMid meet"},C.$attrs),t[0]||(t[0]=[E.createElementVNode("path",{d:"M512 56.888889a455.111111 455.111111 0 1 1 0 910.222222A455.111111 455.111111 0 0 1 512 56.888889z m0 401.521778L404.764444 351.118222a37.944889 37.944889 0 1 0-53.646222 53.646222L458.410667 512l-107.292445 107.235556a37.944889 37.944889 0 1 0 53.646222 53.646222L512 565.589333l107.235556 107.292445a37.944889 37.944889 0 1 0 53.646222-53.646222L565.589333 512l107.292445-107.235556a37.944889 37.944889 0 1 0-53.646222-53.646222L512 458.410667z",fill:"currentColor"},null,-1)]),16)}const bC=dA(po,[["render",Jo]]),[NA]=HA("editor-container"),[YA]=HA("anchor-item"),TC=E.defineComponent({name:"EditorContainer",props:{preTime:{type:String,default:"00:00:00"},realTime:{type:String,default:"00:00:00"},textCount:{type:Number,default:0},highlight:{type:Boolean,default:void 0},listenAnchorId:{type:Number,default:-1},listenMode:{type:String,default:"single"},placeholder:{type:String,default:"请输入或者上传文稿"},simple:{type:Boolean,default:!1},maxLength:{type:Number,default:1e4},showWordLimit:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},class:{type:[String,Array],default:()=>[]},contentStyle:{type:Object,default:()=>({})},refinable:{type:Boolean,default:!1},refineContext:{type:Object},editorHeight:{type:[Number,String],default:"calc(100% - 62px)"}},emits:{change:C=>!0,"update:textCount":C=>!0,anchorListen:(C,t)=>!0,anchorListenStop:C=>!0,anchorRemove:C=>!0},setup:(C,{slots:t,emit:B})=>{const o=E.ref(),i=E.ref(),{editorCore:c,editorAction:a,count:r,hasPausationTag:h,getContent:d,setContent:D,appendContent:y,getTextContent:R,insertContent:F,deleteContent:f,updateContent:N,isCaret:k,isRange:U,isSelectionInDifferentParas:M,isSelectionContainsTag:O,getAnchorTtsMark:V,getAnchorTtsEmotionAndRole:X,isAllMarkedByAnchor:$,addExtraAnchors:T,clearContent:QA,renderHighlight:RA,unrenderHighlight:pA}=ut(o,C,B);E.provide(Eg,{name:"Editor",editorCore:c,editorAction:a,getContent:d,setContent:D,appendContent:y,getTextContent:R,insertContent:F,deleteContent:f,updateContent:N,isCaret:k,isRange:U,isSelectionContainsTag:O,getAnchorTtsMark:V,getAnchorTtsEmotionAndRole:X,isAllMarkedByAnchor:$,addExtraAnchors:T,clearContent:QA,renderHighlight:RA,unrenderHighlight:pA,refineContext:C.refineContext});const UA=E.computed(()=>{var BA,eA;return((eA=(BA=a.value)==null?void 0:BA.plugin.anchor)==null?void 0:eA.data)??{}}),bA=E.computed(()=>Object.values(UA.value).flat().length),SA=E.computed(()=>r.value<=0&&!h.value),p=(BA,eA,gA)=>{Array.from(document.body.querySelectorAll(`span[data-frag-id="anchor_${BA}"]`)).forEach(hA=>{var DA,Ag;return(Ag=(DA=a.value)==null?void 0:DA.plugin.anchor)==null?void 0:Ag.remove(hA)}),B("anchorRemove",gA)},v=BA=>Object.entries(BA).filter(([eA,gA])=>!!gA.length).map(([eA,gA])=>E.createVNode("div",{style:{position:"absolute",top:`${eA}px`,width:"100%",paddingLeft:"24px",transform:"translateY(-4px)"},class:[gA.length>1&&"multi-anchor"]},[gA.length>1?gA.map(({background:IA,data:hA,id:DA})=>x(DA,eA,IA,hA,!0)):x(gA[0].id,eA,gA[0].background,gA[0].data)])),x=(BA,eA,gA,IA,hA=!1)=>{const DA=()=>C.listenMode===CI.multiple||C.listenAnchorId!==BA?E.createVNode("span",{onClick:()=>B("anchorListen",IA,V(BA))},[E.createVNode(So,{class:YA("info-play")},null)]):E.createVNode("span",{onClick:()=>B("anchorListenStop",IA)},[E.createVNode(Mo,{class:YA("info-play")},null)]);return(hg=>E.createVNode(lA.Tooltip,null,{default:hg,content:()=>E.createVNode("section",{class:YA("tooltip")},[E.createVNode("p",null,[E.createTextVNode("主播: "),IA.name]),E.createVNode("p",null,[E.createTextVNode("情绪: "),IA.activeEmotion]),IA.activeRole&&IA.activeRole!=="无"?E.createVNode("p",null,[E.createTextVNode("角色: "),IA.activeRole||"--"]):null,E.createVNode("p",null,[E.createTextVNode("语速: "),IA.speed]),E.createVNode("p",null,[E.createTextVNode("音量: "),IA.volume])])}))(()=>E.createVNode("section",{class:YA(),style:{backgroundColor:gA}},[E.createVNode("img",{src:IA.avatar,class:YA("avatar")},null),E.createVNode("section",{class:YA("info"),style:{display:hA?"none":"flex"}},[E.createVNode("span",{class:YA("info-name"),title:IA.name},[IA.name]),E.createVNode("label",{class:YA("info-speed-volume")},[E.createTextVNode("语速: "),IA.speed,E.createTextVNode(", 音量: "),IA.volume]),E.createVNode("div",{onClick:()=>p(BA,eA,IA)},[E.createVNode(bC,{class:YA("info-rem")},null)]),DA()]),hA?E.createVNode(E.Fragment,null,[E.createVNode("div",{class:YA("btn-layer"),style:C.listenMode===CI.single&&C.listenAnchorId===BA?{display:"block"}:{}},[DA()]),E.createVNode("div",{class:YA("rem"),onClick:()=>p(BA,eA,IA)},[E.createVNode(bC,{class:YA("info-rem")},null)])]):null]))},P=()=>{},_=()=>{var BA;return E.createVNode("div",{class:NA("status",{simple:C.simple,disabled:C.disabled})},[((BA=t["footer-left"])==null?void 0:BA.call(t))??(C.simple?null:E.createVNode(lA.Button,{class:NA("status-clear"),onClick:QA},{default:()=>[E.createTextVNode("清空")]})),E.createVNode("div",{class:NA("status-info")},[C.simple?null:E.createVNode(E.Fragment,null,[E.createVNode("label",{class:NA("status-info-label")},[E.createVNode("span",null,[E.createTextVNode("预计时长:")]),E.createVNode("span",null,[C.preTime||"00:00:00"])]),E.createVNode("label",{class:NA("status-info-label")},[E.createVNode("span",null,[E.createTextVNode("实际时长:")]),E.createVNode("span",null,[C.realTime||"00:00:00"])])]),C.showWordLimit?E.createVNode("label",{class:NA("status-info-length")},[E.createVNode("span",null,[r.value<=C.maxLength?r.value:C.maxLength]),E.createVNode("span",null,[E.createTextVNode(" / ")]),E.createVNode("span",null,[C.maxLength,C.simple?"":"字"])]):null])])},b=E.ref();return{action:a,innerRender:()=>{var BA,eA;return E.createVNode("section",{class:NA("wrapper")},[E.createVNode("div",{class:NA("",{simple:C.simple,disabled:C.disabled,refinable:C.refinable}),style:{height:cE(C.editorHeight)?C.editorHeight:`${C.editorHeight}px`}},[!C.simple&&P(),E.createVNode("div",{class:NA("core")},[E.createVNode("div",{class:NA("core-content")},[E.createVNode("div",{class:NA("core-content-editor")},[E.createVNode("div",{class:NA("core-content-editor-placeholder"),style:{display:SA.value?"block":"none"}},[C.placeholder]),E.createVNode("div",{ref:o,class:NA("core-content-editor-content"),contenteditable:!C.disabled,onDragover:gA=>gA.preventDefault(),onDrop:gA=>gA.preventDefault()},[E.createVNode("p",{class:kA},[E.createVNode("br",null,null)])])])]),C.simple?null:E.createVNode("div",{ref:i,class:NA("core-anchor")},[bA.value?v(UA.value):null])]),!C.simple&&!Object.values(UA.value).flat().length?E.createVNode("div",{class:NA("anchor-placeholder")},[E.createVNode("img",{src:yt},null)]):null,!C.simple&&E.createVNode("div",{class:NA("splitor")},null),!C.simple&&E.createVNode(kt,null,null),C.refinable&&E.createVNode(No,{ref:b},null)]),_(),E.createVNode("span",{style:"display: none"},[JSON.stringify(Object.keys(((eA=(BA=a.value)==null?void 0:BA.plugin.anchor)==null?void 0:eA.data)??{}))])])},innerGetContent:d,innerSetContent:D,innerAppendContent:y,innerGetTextContent:R,innerInsertContent:F,innerDeleteContent:f,innerUpdateContent:N,innerIsCaret:k,innerIsRange:U,innerIsSelectionInDifferentParas:M,innerIsSelectionContainsTag:O,innerGetAnchorTtsMark:V,innerGetAnchorTtsEmotionAndRole:X,innerIsAllMarkedByAnchor:$,innerAddExtraAnchors:T,innerClearContent:QA,innerRenderHightlight:RA,innerUnrenderHightlight:pA}},methods:{getContent(C){return this.innerGetContent(C)},getHtml(C){return this.getContent(C)},setContent(C){return this.innerSetContent(C)},setHtml(C){return this.setContent(C)},appendContent(C){return this.innerAppendContent(C)},getTextContent(){return this.innerGetTextContent()},insertContent(C){return this.innerInsertContent(C)},deleteContent(){return this.innerDeleteContent()},updateContent(C){return this.innerUpdateContent(C)},isCaret(){return this.innerIsCaret()},isRange(){return this.innerIsRange()},isSelectionInDifferentParas(){return this.innerIsSelectionInDifferentParas()},isSelectionContainsTag(C){return this.innerIsSelectionContainsTag(C)},getAnchorTtsMark(C,t=!1){return this.innerGetAnchorTtsMark(C,t)},getAnchorTtsEmotionAndRole(C){return this.innerGetAnchorTtsEmotionAndRole(C)},isAllMarkedByAnchor(){return this.innerIsAllMarkedByAnchor()},addExtraAnchors(C){return this.innerAddExtraAnchors(C)},clearContent(){return this.innerClearContent()},clear(){return this.setContent(`<p class="${kA}"><br /></p>`)},renderHighlight(C){return this.innerRenderHightlight(C)},unrenderHighlight(){return this.innerUnrenderHightlight()}},render(){return this.innerRender()}}),TI=Object.assign(TC,{install:(C,t)=>{C.component("EditorContainer",TC)}}),mo=Object.assign(TI,{install:C=>{C.component(TI.name,TI)}});exports.ICommandExecutor=_C;exports.IContentManager=XC;exports.ICursorManager=zC;exports.IEditorCore=OC;exports.IPlugin=Ug;exports.IUndoManager=ZC;exports.ListenModeEnum=CI;exports.PluginFlag=K;exports.SelectionType=WC;exports.default=mo;
72
+ `),i(f>N+k?ag.底部:ag.顶部),a(f>N+k+AI+8?VA.底部:VA.顶部),h(f>N+k+AI+xC?PA.顶部对齐:PA.底部对齐)},D=zI(d);return E.onMounted(()=>{var y;(y=B.value)==null||y.addEventListener("scroll",D)}),E.onUnmounted(()=>{var y;(y=B.value)==null||y.removeEventListener("scroll",D)}),{generatorPosition:o,shortcutPosition:c,subShortcutPosition:r,setGeneratorPosition:i,setShortcutPosition:a,setSubShortcutPosition:h,calcModalPosition:d}},[Fo]=HA("refine-generator"),No=E.defineComponent({name:"RefineGenerator",props:{width:{type:[Number,String],default:"100%"}},emits:{},setup:C=>{const{highlightRange:t,unhighlightRange:B,revertRange:o}=Dt(),i=E.inject(Eg),{agentId:c,createSession:a,sendSessionMessage:r,abortSession:h}=i.refineContext,[d,D]=fA(void 0),y=()=>(r.abort(),h({sessionId:d.value})),R=E.ref(),[F,f]=fA({zIndex:-10}),[N,k]=fA(!1,nA=>{nA||(d.value&&[LA.等待生成,LA.正在生成].includes(x.value)&&y(),D(void 0),RA(!1),UA(void 0),v(!1),P(LA.未生成),b(0),BA([]),gA(void 0),SA(!0),f({zIndex:-10}))}),U=()=>{var KA,TA,jA,gg;if(Y(i)||Y(i.editorCore.value))return;const nA=gB((KA=X.value)==null?void 0:KA.getBoundingClientRect(),(TA=Array.from(i.editorCore.value._editorElement.querySelectorAll(".tag-range-highlight")).pop())==null?void 0:TA.getBoundingClientRect(),1);f({top:`${nA.top+(((jA=X.value)==null?void 0:jA.scrollTop)??0)}px`,left:0,width:`${(gg=i.editorCore.value)==null?void 0:gg._editorElement.offsetWidth}px`})},M=()=>{Y(i)||Y(i.editorCore.value)||(U(),k(!0))},O=nA=>{var KA;N.value&&((KA=R.value)!=null&&KA.contains(nA.target)||(B(),k(!1)))},V=zI(()=>{N.value&&U()}),[X,$]=fA(void 0);E.onMounted(()=>{var nA;$(document.body.querySelector(".c-editor-container--refinable")),document.addEventListener("mousedown",O),(nA=X.value)==null||nA.addEventListener("scroll",V)}),E.onUnmounted(()=>{var nA;document.removeEventListener("mousedown",O),(nA=X.value)==null||nA.removeEventListener("scroll",V)});const T=sE(C.width)?`${C.width}px`:C.width,[QA,RA]=II(),[pA,UA]=fA(void 0),[bA,SA]=II(!0),[p,v]=II(),[x,P]=fA(LA.未生成),[_,b]=fA(0),[j,BA]=fA([]),[eA,gA]=fA(void 0),hA={name:"RefineGenerator",refineGeneratorRef:R,visible:N,width:T,generating:QA,prompt:pA,shortcutVisible:bA,content:j,activedContent:eA,contentVisible:p,contentPage:_,contentState:x,setVisible:k,setRefineGenerating:RA,setRefinePrompt:UA,setShortVisible:SA,setRefineContent:BA,setActivedRefineContent:gA,genRefineContent:async nA=>{var Kg,Dg;if(QA.value)return;RA(!0),UA(void 0),BA((nA==null?void 0:nA.generateType)===wg.刷新?[...j.value,{...j.value[_.value-1],content:""}]:[gg(nA)]),gA(j.value[j.value.length-1]),b(j.value.length),P(LA.等待生成),D($C());const KA=await a({agentId:c,sessionId:d.value});v(!0),P(LA.正在生成),r({messageRequest:{agent_id:c,message:{content:Array.from(document.body.querySelectorAll(`.${QI}`)).map(JA=>JA.textContent??"").join(""),conversation_id:KA.data.conversionId},meta_data:{ai_rewrite:((Kg=eA.value)==null?void 0:Kg.shortcutType)??((Dg=eA.value)==null?void 0:Dg.prompt),sessionId:d.value}}},{onmessage:jA,onclose:()=>{console.log("---onclose "),TA()},onerror:JA=>{console.log("---onerror ",JA),TA()}});async function TA(){RA(!1),P(LA.未生成),await E.nextTick(),Hg(),SA(!0)}function jA(JA){const vA=JSON.parse(JA.data);vA.type==="answer"&&(eA.value.content+=vA.content)}function gg(JA){const vA=(JA==null?void 0:JA.generateType)===wg.重置;return{isManualPrompt:vA,prompt:vA?JA.prompt:void 0,shortcutType:vA?JA.shortcutType:void 0,content:""}}},setContentPage:b,setContentVisible:v,setContentState:P,showRefineGenerator:M,abortSession:y,scrollElm:X,highlightRange:t,unhighlightRange:B,revertRange:o},{generatorPosition:DA,shortcutPosition:Ag,subShortcutPosition:Yg,setGeneratorPosition:hg,setShortcutPosition:tI,setSubShortcutPosition:oI,calcModalPosition:Hg}=Ro(hA);return E.provide(mg,{...hA,generatorPosition:DA,shortcutPosition:Ag,subShortcutPosition:Yg,setGeneratorPosition:hg,setShortcutPosition:tI,setSubShortcutPosition:oI,calcModalPosition:Hg}),{innerRender:()=>E.createVNode(E.Fragment,null,[E.createVNode(fo,null,null),E.createVNode("div",{ref:R,class:"c-refine-generator-wrapper",style:{...F.value,display:N.value?"block":"none"}},[E.createVNode("div",{class:"c-refine-generator-wrapper__inner"},[E.createVNode("div",{class:Fo(),style:{width:T}},[E.createVNode(to,{modelValue:j.value,"onUpdate:modelValue":nA=>j.value=nA},null),E.createVNode(uo,{modelValue:pA.value,"onUpdate:modelValue":nA=>pA.value=nA},null)]),E.createVNode(yo,null,null)])])]),innerSetVisible:k}},methods:{setVisible(C){this.innerSetVisible(C)}},render(){return this.innerRender()}}),ko={};function Go(C,t){return E.openBlock(),E.createElementBlock("svg",E.mergeProps({xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 1024 1024","aria-hidden":"true",role:"img",class:"iconify iconify--mdi",width:"18",height:"18",preserveAspectRatio:"xMidYMid meet"},C.$attrs),t[0]||(t[0]=[E.createElementVNode("path",{d:"M843.0592 474.9312l-448-307.2-0.1024 0.1024A51.712 51.712 0 0 0 359.168 153.6c-28.5184 0-51.712 22.9376-51.712 51.2 0 15.5136-0.6144 45.9264 0 45.312V819.2c0 28.2624 23.1936 51.2 51.712 51.2 13.9776 0 26.624-5.4784 35.84-14.336h0.0512l448-307.2a50.7904 50.7904 0 0 0 15.872-36.864v-0.1024-0.1024a50.8416 50.8416 0 0 0-15.872-36.864z",fill:"currentColor"},null,-1)]),16)}const So=dA(ko,[["render",Go]]),Lo={};function Uo(C,t){return E.openBlock(),E.createElementBlock("svg",E.mergeProps({xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 1024 1024","aria-hidden":"true",role:"img",class:"iconify iconify--mdi",width:"18",height:"18",preserveAspectRatio:"xMidYMid meet"},C.$attrs),t[0]||(t[0]=[E.createElementVNode("path",{d:"M299.90284958 17.10664903a70.69905013 70.69905013 0 0 0-70.69905015 70.69905014v848.38860166a70.69905013 70.69905013 0 1 0 141.39810028 0V87.80569917a70.69905013 70.69905013 0 0 0-70.69905013-70.69905014z m424.19430084 0a70.69905013 70.69905013 0 0 0-70.69905013 70.69905014v848.38860166a70.69905013 70.69905013 0 1 0 141.39810028 0V87.80569917a70.69905013 70.69905013 0 0 0-70.69905015-70.69905014z",fill:"currentColor"},null,-1)]),16)}const Mo=dA(Lo,[["render",Uo]]),po={};function Jo(C,t){return E.openBlock(),E.createElementBlock("svg",E.mergeProps({xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 1024 1024","aria-hidden":"true",role:"img",class:"iconify iconify--mdi",width:"18",height:"18",preserveAspectRatio:"xMidYMid meet"},C.$attrs),t[0]||(t[0]=[E.createElementVNode("path",{d:"M512 56.888889a455.111111 455.111111 0 1 1 0 910.222222A455.111111 455.111111 0 0 1 512 56.888889z m0 401.521778L404.764444 351.118222a37.944889 37.944889 0 1 0-53.646222 53.646222L458.410667 512l-107.292445 107.235556a37.944889 37.944889 0 1 0 53.646222 53.646222L512 565.589333l107.235556 107.292445a37.944889 37.944889 0 1 0 53.646222-53.646222L565.589333 512l107.292445-107.235556a37.944889 37.944889 0 1 0-53.646222-53.646222L512 458.410667z",fill:"currentColor"},null,-1)]),16)}const bC=dA(po,[["render",Jo]]),[NA]=HA("editor-container"),[YA]=HA("anchor-item"),TC=E.defineComponent({name:"EditorContainer",props:{preTime:{type:String,default:"00:00:00"},realTime:{type:String,default:"00:00:00"},textCount:{type:Number,default:0},highlight:{type:Boolean,default:void 0},listenAnchorId:{type:Number,default:-1},listenMode:{type:String,default:"single"},placeholder:{type:String,default:"请输入或者上传文稿"},simple:{type:Boolean,default:!1},maxLength:{type:Number,default:1e4},showWordLimit:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},class:{type:[String,Array],default:()=>[]},contentStyle:{type:Object,default:()=>({})},refinable:{type:Boolean,default:!1},refineContext:{type:Object},editorHeight:{type:[Number,String],default:"calc(100% - 62px)"}},emits:{change:C=>!0,"update:textCount":C=>!0,anchorListen:(C,t)=>!0,anchorListenStop:C=>!0,anchorRemove:C=>!0},setup:(C,{slots:t,emit:B})=>{const o=E.ref(),i=E.ref(),{editorCore:c,editorAction:a,count:r,hasPausationTag:h,getContent:d,setContent:D,appendContent:y,getTextContent:R,insertContent:F,deleteContent:f,updateContent:N,isCaret:k,isRange:U,isSelectionInDifferentParas:M,isSelectionContainsTag:O,getAnchorTtsMark:V,getAnchorTtsEmotionAndRole:X,isAllMarkedByAnchor:$,addExtraAnchors:T,clearContent:QA,renderHighlight:RA,unrenderHighlight:pA}=ut(o,C,B);E.provide(Eg,{name:"Editor",editorCore:c,editorAction:a,getContent:d,setContent:D,appendContent:y,getTextContent:R,insertContent:F,deleteContent:f,updateContent:N,isCaret:k,isRange:U,isSelectionContainsTag:O,getAnchorTtsMark:V,getAnchorTtsEmotionAndRole:X,isAllMarkedByAnchor:$,addExtraAnchors:T,clearContent:QA,renderHighlight:RA,unrenderHighlight:pA,refineContext:C.refineContext});const UA=E.computed(()=>{var BA,eA;return((eA=(BA=a.value)==null?void 0:BA.plugin.anchor)==null?void 0:eA.data)??{}}),bA=E.computed(()=>Object.values(UA.value).flat().length),SA=E.computed(()=>r.value<=0&&!h.value),p=(BA,eA,gA)=>{Array.from(document.body.querySelectorAll(`span[data-frag-id="anchor_${BA}"]`)).forEach(hA=>{var DA,Ag;return(Ag=(DA=a.value)==null?void 0:DA.plugin.anchor)==null?void 0:Ag.remove(hA)}),B("anchorRemove",gA)},v=BA=>Object.entries(BA).filter(([eA,gA])=>!!gA.length).map(([eA,gA])=>E.createVNode("div",{style:{position:"absolute",top:`${eA}px`,width:"100%",paddingLeft:"24px",transform:"translateY(-4px)"},class:[gA.length>1&&"multi-anchor"]},[gA.length>1?gA.map(({background:IA,data:hA,id:DA})=>x(DA,eA,IA,hA,!0)):x(gA[0].id,eA,gA[0].background,gA[0].data)])),x=(BA,eA,gA,IA,hA=!1)=>{const DA=()=>C.listenMode===CI.multiple||C.listenAnchorId!==BA?E.createVNode("span",{onClick:()=>B("anchorListen",IA,V(BA))},[E.createVNode(So,{class:YA("info-play")},null)]):E.createVNode("span",{onClick:()=>B("anchorListenStop",IA)},[E.createVNode(Mo,{class:YA("info-play")},null)]);return(hg=>E.createVNode(lA.Tooltip,null,{default:hg,content:()=>E.createVNode("section",{class:YA("tooltip")},[E.createVNode("p",null,[E.createTextVNode("主播: "),IA.name]),E.createVNode("p",null,[E.createTextVNode("情绪: "),IA.activeEmotion]),IA.activeRole&&IA.activeRole!=="无"?E.createVNode("p",null,[E.createTextVNode("角色: "),IA.activeRole||"--"]):null,E.createVNode("p",null,[E.createTextVNode("语速: "),IA.speed]),E.createVNode("p",null,[E.createTextVNode("音量: "),IA.volume])])}))(()=>E.createVNode("section",{class:YA(),style:{backgroundColor:gA}},[E.createVNode("img",{src:IA.avatar,class:YA("avatar")},null),E.createVNode("section",{class:YA("info"),style:{display:hA?"none":"flex"}},[E.createVNode("span",{class:YA("info-name"),title:IA.name},[IA.name]),E.createVNode("label",{class:YA("info-speed-volume")},[E.createTextVNode("语速: "),IA.speed,E.createTextVNode(", 音量: "),IA.volume]),E.createVNode("div",{onClick:()=>p(BA,eA,IA)},[E.createVNode(bC,{class:YA("info-rem")},null)]),DA()]),hA?E.createVNode(E.Fragment,null,[E.createVNode("div",{class:YA("btn-layer"),style:C.listenMode===CI.single&&C.listenAnchorId===BA?{display:"block"}:{}},[DA()]),E.createVNode("div",{class:YA("rem"),onClick:()=>p(BA,eA,IA)},[E.createVNode(bC,{class:YA("info-rem")},null)])]):null]))},P=()=>{},_=()=>{var BA;return E.createVNode("div",{class:NA("status",{simple:C.simple,disabled:C.disabled})},[((BA=t["footer-left"])==null?void 0:BA.call(t))??(C.simple?null:E.createVNode(lA.Button,{class:NA("status-clear"),onClick:QA},{default:()=>[E.createTextVNode("清空")]})),E.createVNode("div",{class:NA("status-info")},[C.simple?null:E.createVNode(E.Fragment,null,[E.createVNode("label",{class:NA("status-info-label")},[E.createVNode("span",null,[E.createTextVNode("预计时长:")]),E.createVNode("span",null,[C.preTime||"00:00:00"])]),E.createVNode("label",{class:NA("status-info-label")},[E.createVNode("span",null,[E.createTextVNode("实际时长:")]),E.createVNode("span",null,[C.realTime||"00:00:00"])])]),C.showWordLimit?E.createVNode("label",{class:NA("status-info-length")},[E.createVNode("span",null,[r.value<=C.maxLength?r.value:C.maxLength]),E.createVNode("span",null,[E.createTextVNode(" / ")]),E.createVNode("span",null,[C.maxLength,C.simple?"":"字"])]):null])])},b=E.ref();return{action:a,innerRender:()=>{var BA,eA;return E.createVNode("section",{class:NA("wrapper")},[E.createVNode("div",{class:NA("",{simple:C.simple,disabled:C.disabled,refinable:C.refinable}),style:{height:cE(C.editorHeight)?C.editorHeight:`${C.editorHeight}px`}},[!C.simple&&P(),E.createVNode("div",{class:NA("core")},[E.createVNode("div",{class:NA("core-content")},[E.createVNode("div",{class:NA("core-content-editor")},[E.createVNode("div",{class:NA("core-content-editor-placeholder"),style:{display:SA.value?"block":"none"}},[C.placeholder]),E.createVNode("div",{ref:o,class:NA("core-content-editor-content"),contenteditable:!C.disabled,onDragover:gA=>gA.preventDefault(),onDrop:gA=>gA.preventDefault()},[E.createVNode("p",{class:kA},[E.createVNode("br",null,null)])])])]),C.simple?null:E.createVNode("div",{ref:i,class:NA("core-anchor")},[bA.value?v(UA.value):null])]),!C.simple&&!Object.values(UA.value).flat().length?E.createVNode("div",{class:NA("anchor-placeholder")},[E.createVNode("img",{src:yt},null)]):null,!C.simple&&E.createVNode("div",{class:NA("splitor")},null),!C.simple&&E.createVNode(kt,null,null),C.refinable&&E.createVNode(No,{ref:b},null)]),_(),E.createVNode("span",{style:"display: none"},[JSON.stringify(Object.keys(((eA=(BA=a.value)==null?void 0:BA.plugin.anchor)==null?void 0:eA.data)??{}))])])},innerGetContent:d,innerSetContent:D,innerAppendContent:y,innerGetTextContent:R,innerInsertContent:F,innerDeleteContent:f,innerUpdateContent:N,innerIsCaret:k,innerIsRange:U,innerIsSelectionInDifferentParas:M,innerIsSelectionContainsTag:O,innerGetAnchorTtsMark:V,innerGetAnchorTtsEmotionAndRole:X,innerIsAllMarkedByAnchor:$,innerAddExtraAnchors:T,innerClearContent:QA,innerRenderHightlight:RA,innerUnrenderHightlight:pA}},methods:{getContent(C){return this.innerGetContent(C)},getHtml(C){return this.getContent(C)},setContent(C){return this.innerSetContent(C)},setHtml(C){return this.setContent(C)},appendContent(C){return this.innerAppendContent(C)},getTextContent(){return this.innerGetTextContent()},insertContent(C){return this.innerInsertContent(C)},deleteContent(){return this.innerDeleteContent()},updateContent(C){return this.innerUpdateContent(C)},isCaret(){return this.innerIsCaret()},isRange(){return this.innerIsRange()},isSelectionInDifferentParas(){return this.innerIsSelectionInDifferentParas()},isSelectionContainsTag(C){return this.innerIsSelectionContainsTag(C)},getAnchorTtsMark(C,t=!1){return this.innerGetAnchorTtsMark(C,t)},getAnchorTtsEmotionAndRole(C){return this.innerGetAnchorTtsEmotionAndRole(C)},isAllMarkedByAnchor(){return this.innerIsAllMarkedByAnchor()},addExtraAnchors(C){return this.innerAddExtraAnchors(C)},clearContent(){return this.innerClearContent()},clear(){return this.setContent(`<p class="${kA}"><br /></p>`)},renderHighlight(C){return this.innerRenderHightlight(C)},unrenderHighlight(){return this.innerUnrenderHightlight()}},render(){return this.innerRender()}}),TI=Object.assign(TC,{install:(C,t)=>{C.component("EditorContainer",TC)}}),mo=Object.assign(TI,{install:C=>{C.component(TI.name,TI)}});exports.ICommandExecutor=_C;exports.IContentManager=XC;exports.ICursorManager=zC;exports.IEditorCore=OC;exports.IPlugin=Ug;exports.IUndoManager=ZC;exports.ListenModeEnum=CI;exports.PluginFlag=K;exports.SelectionType=WC;exports.default=mo;
73
73
  //# sourceMappingURL=index.js.map