@duxweb/dvha-pro 1.1.13 → 1.1.15

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.
@@ -1 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("vue"),g=require("@duxweb/dvha-core"),U=require("@vueuse/core"),x=require("aieditor"),$=require("naive-ui");require("vue-router");require("@overlastic/vue");require("clsx");require("vue-echarts");require("vue3-ace-editor");require("ace-builds/src-noconflict/mode-vue");require("ace-builds/src-noconflict/mode-javascript");require("ace-builds/src-noconflict/mode-html");require("ace-builds/src-noconflict/mode-json");require("ace-builds/src-noconflict/mode-json5");require("ace-builds/src-noconflict/theme-tomorrow_night");require("ace-builds/src-noconflict/theme-tomorrow");require("ace-builds/src-noconflict/ext-searchbox");require("ace-builds/src-noconflict/ext-language_tools");require("ace-builds/src-noconflict/mode-snippets");require("vue-cropper");require("jinrishici");require("lodash-es");require("vue-draggable-plus");require("@vee-validate/i18n");require("colorizr");require("echarts");require("highlight.js/lib/core");require("highlight.js/lib/languages/bash");require("highlight.js/lib/languages/css");require("highlight.js/lib/languages/go");require("highlight.js/lib/languages/java");require("highlight.js/lib/languages/javascript");require("highlight.js/lib/languages/json");require("highlight.js/lib/languages/markdown");require("highlight.js/lib/languages/php");require("highlight.js/lib/languages/python");require("highlight.js/lib/languages/shell");require("highlight.js/lib/languages/sql");require("highlight.js/lib/languages/typescript");require("highlight.js/lib/languages/xml");require("@ant-design/colors");require("@unocss/preset-icons/browser");require("@unocss/preset-typography");require("unocss/preset-wind4");require("@vee-validate/i18n/dist/locale/en.json");require("@vee-validate/i18n/dist/locale/zh_CN.json");require("vee-validate");require("vue-command-palette");require("@duxweb/dvha-naiveui");require("../../pages/page404.cjs");require("short-unique-id");const E=require("../upload/config.cjs");require("@vue-flow/core");require("@vue-flow/background");;/* empty css */const L=require("../../hooks/modal.cjs");require("mime");require("@iconify-json/tabler/icons.json");require("../posterEditor/elements/index.cjs");require("fabric");require("dayjs");require("@tanstack/vue-query");require("pinia");const V=u.defineComponent({name:"DuxAiEditor",props:{value:String,defaultValue:String,uploadPath:String,uploadHeaders:Object,editorType:{type:String,default:"richtext"},aiPath:String,fileManager:{type:Boolean,default:!0},fileManagerType:{type:String,default:"all"},height:{type:String,default:"500px"},onUpdateValue:Function},setup(r,{emit:y,expose:k}){const o=u.ref();let a=null;k({get aiEditor(){return a}});let l=!1;const f=g.useTheme(),{config:v}=g.useManage(),M=g.useGetAuth(),{t:h}=g.useI18n(),C=$.useMessage(),b=L.useModal(),H=r.value??r.defaultValue??"",d=U.useVModel(r,"value",y),s=u.computed(()=>r.uploadPath||v.apiPath?.upload||"upload"),m=g.useUpload({path:s.value,autoUpload:!1}),{managePath:P,method:S}=E.useUploadConfig();u.watch(()=>r.value,e=>{!a||l||(r.editorType==="markdown"?a.setMarkdownContent(e||""):a.setContent(e||""))},{immediate:!0,flush:"post"});const q=e=>new Promise((t,n)=>{m.addFiles([e],"file").then(()=>{m.trigger().then(i=>{i.forEach(c=>{const p=c?.data?.data;t({errorCode:0,data:{src:p?.url,alt:c?.filename}})})}).catch(i=>{C.error(i.message),n(i)}).finally(()=>{m.clearFiles()})})}),T=e=>{const t=String(e?.filetype||""),n=String(e?.url||"");return/^image\//i.test(t)||/\.(?:png|jpe?g|gif|bmp|webp|svg)$/i.test(n)?"image":/^video\//i.test(t)||/\.(?:mp4|webm|ogg|mov|m4v)$/i.test(n)?"video":"attachment"};return u.onMounted(()=>{a=new x.AiEditor({theme:f.isDark.value?"dark":"light",element:o.value,placeholder:h("components.editor.placeholder"),content:H,contentIsMarkdown:r.editorType==="markdown",onChange:e=>{l=!0,d.value=r.editorType==="markdown"?e.getMarkdown():e.getHtml(),l=!1},onBlur:e=>{l=!0,d.value=r.editorType==="markdown"?e.getMarkdown():e.getHtml(),l=!1},image:{uploadUrl:s.value,uploadHeaders:r.uploadHeaders||{},uploader:q,defaultSize:"auto"},video:{uploadUrl:s.value,uploadHeaders:r.uploadHeaders||{},uploader:q},attachment:{uploadUrl:s.value,uploadHeaders:r.uploadHeaders||{},uploader:q},ai:{models:{custom:{url:r.aiPath||v.apiPath?.ai||"ai",headers:()=>({"Content-Type":"application/json",Authorization:M.token}),wrapPayload:e=>JSON.stringify({prompt:e}),parseMessage:e=>{const t=JSON.parse(e);return{role:"assistant",content:t.message,index:t.number,status:t.status}},protocol:"sse"}}},toolbarKeys:["undo","redo","brush","eraser","divider","heading","font-family","font-size","divider","bold","italic","underline","strike","link","code","subscript","superscript","hr","todo","emoji","divider","highlight","font-color","divider","align","line-height","divider","bullet-list","ordered-list","indent-decrease","indent-increase","break","divider",...r.fileManager?[{id:"dux-file-manager-image",tip:h("components.upload.fileManager"),icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M3.08697 9H20.9134C21.4657 9 21.9134 9.44772 21.9134 10C21.9134 10.0277 21.9122 10.0554 21.9099 10.083L21.0766 20.083C21.0334 20.6013 20.6001 21 20.08 21H3.9203C3.40021 21 2.96695 20.6013 2.92376 20.083L2.09042 10.083C2.04456 9.53267 2.45355 9.04932 3.00392 9.00345C3.03155 9.00115 3.05925 9 3.08697 9ZM4.84044 19H19.1599L19.8266 11H4.17377L4.84044 19ZM13.4144 5H20.0002C20.5525 5 21.0002 5.44772 21.0002 6V7H3.00017V4C3.00017 3.44772 3.44789 3 4.00017 3H11.4144L13.4144 5Z"></path></svg>',onClick:(e,t)=>{b.show({title:h("components.uploadManage.title")||h("components.upload.fileManager"),width:"800px",component:()=>Promise.resolve().then(()=>require("../upload/manager.cjs")),componentProps:{path:P.value,type:r.fileManagerType||"all",multiple:!0,uploadParams:{path:s.value,accept:"*/*",method:S.value}}}).then(n=>{n?.forEach?.(i=>{const c=T(i),p=i?.filename||"";if(c==="image")t.insert({type:"image",attrs:{src:i.url,alt:p,width:"auto"}});else if(c==="video")t.insert({type:"video",attrs:{src:i.url,controls:"true",width:350}});else{const w=i?.filename||i?.name||"file";r.editorType==="markdown"?t.insertMarkdown(`[${w}](${i.url})`):t.insert(`<a href="${i.url}" target="_blank">${w}</a>`)}})})}}]:[],"image","video","attachment","quote","container","code-block","table","divider","printer","fullscreen","ai"]}),d.value!=null&&(r.editorType==="markdown"?a.setMarkdownContent(d.value||""):a.setContent(d.value||""))}),u.onUnmounted(()=>{a?.destroy()}),u.watch(f.isDark,e=>{o.value&&(o.value.classList.remove("aie-theme-dark","aie-theme-light"),o.value.classList.add(e?"aie-theme-dark":"aie-theme-light"))},{immediate:!0}),()=>u.createVNode("div",{ref:o,style:`height: ${r.height}; width:100%`},null)}});exports.DuxAiEditor=V;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("vue"),p=require("@duxweb/dvha-core"),j=require("@vueuse/core"),V=require("aieditor"),D=require("naive-ui");require("vue-router");require("@overlastic/vue");require("clsx");require("vue-echarts");require("vue3-ace-editor");require("ace-builds/src-noconflict/mode-vue");require("ace-builds/src-noconflict/mode-javascript");require("ace-builds/src-noconflict/mode-html");require("ace-builds/src-noconflict/mode-json");require("ace-builds/src-noconflict/mode-json5");require("ace-builds/src-noconflict/theme-tomorrow_night");require("ace-builds/src-noconflict/theme-tomorrow");require("ace-builds/src-noconflict/ext-searchbox");require("ace-builds/src-noconflict/ext-language_tools");require("ace-builds/src-noconflict/mode-snippets");require("vue-cropper");require("jinrishici");require("lodash-es");require("vue-draggable-plus");require("@vee-validate/i18n");require("colorizr");require("echarts");require("highlight.js/lib/core");require("highlight.js/lib/languages/bash");require("highlight.js/lib/languages/css");require("highlight.js/lib/languages/go");require("highlight.js/lib/languages/java");require("highlight.js/lib/languages/javascript");require("highlight.js/lib/languages/json");require("highlight.js/lib/languages/markdown");require("highlight.js/lib/languages/php");require("highlight.js/lib/languages/python");require("highlight.js/lib/languages/shell");require("highlight.js/lib/languages/sql");require("highlight.js/lib/languages/typescript");require("highlight.js/lib/languages/xml");require("@ant-design/colors");require("@unocss/preset-icons/browser");require("@unocss/preset-typography");require("unocss/preset-wind4");require("@vee-validate/i18n/dist/locale/en.json");require("@vee-validate/i18n/dist/locale/zh_CN.json");require("vee-validate");require("vue-command-palette");require("@duxweb/dvha-naiveui");require("../../pages/page404.cjs");require("short-unique-id");const F=require("../upload/config.cjs");require("@vue-flow/core");require("@vue-flow/background");;/* empty css */const O=require("../../hooks/modal.cjs");require("mime");require("@iconify-json/tabler/icons.json");require("../posterEditor/elements/index.cjs");require("fabric");require("dayjs");require("@tanstack/vue-query");require("pinia");const z=o.defineComponent({name:"DuxAiEditor",props:{value:String,defaultValue:String,uploadPath:String,uploadHeaders:Object,editorType:{type:String,default:"richtext"},aiPath:String,fileManager:{type:Boolean,default:!0},fileManagerType:{type:String,default:"all"},height:{type:String,default:"500px"}},setup(e,{emit:b,expose:H}){const d=o.ref();let i=null,q=!1;const y=p.useTheme(),{config:k}=p.useManage(),S=p.useGetAuth(),{t:h}=p.useI18n(),x=D.useMessage(),P=O.useModal(),w=j.useVModel(e,"value",b,{passive:!0}),g=o.computed(()=>e.uploadPath||k.apiPath?.upload||"upload"),f=p.useUpload({path:g.value,autoUpload:!1}),{managePath:T,method:E}=F.useUploadConfig(),U=()=>{if(!i||q)return;const r=w.value||"";e.editorType==="markdown"?i.setMarkdownContent(r):i.setContent(r)},C=()=>{if(!i)return;q=!0;const r=e.editorType==="markdown"?i.getMarkdown():i.getHtml();w.value=r,o.nextTick(()=>{q=!1})},v=r=>new Promise((u,a)=>{f.addFiles([r],"file").then(()=>{f.trigger().then(l=>{l.forEach(s=>{const c=s?.data?.data;u({errorCode:0,data:{src:c?.url,alt:s?.filename}})})}).catch(l=>{x.error(l.message),a(l)}).finally(()=>{f.clearFiles()})})}),M=r=>{const u=String(r?.filetype||""),a=String(r?.url||"");return/^image\//i.test(u)||/\.(?:png|jpe?g|gif|bmp|webp|svg)$/i.test(a)?"image":/^video\//i.test(u)||/\.(?:mp4|webm|ogg|mov|m4v)$/i.test(a)?"video":"attachment"},A=()=>{if(!d.value)return;const r=e.value||e.defaultValue||"";i=new V.AiEditor({element:d.value,theme:y.isDark.value?"dark":"light",placeholder:h("components.editor.placeholder"),content:r,contentIsMarkdown:e.editorType==="markdown",onChange:C,onBlur:C,image:{uploadUrl:g.value,uploadHeaders:e.uploadHeaders||{},uploader:v,defaultSize:"auto"},video:{uploadUrl:g.value,uploadHeaders:e.uploadHeaders||{},uploader:v},attachment:{uploadUrl:g.value,uploadHeaders:e.uploadHeaders||{},uploader:v},ai:{models:{custom:{url:e.aiPath||k.apiPath?.ai||"ai",headers:()=>({"Content-Type":"application/json",Authorization:S.token}),wrapPayload:u=>JSON.stringify({prompt:u}),parseMessage:u=>{const a=JSON.parse(u);return{role:"assistant",content:a.message,index:a.number,status:a.status}},protocol:"sse"}}},toolbarKeys:["undo","redo","brush","eraser","divider","heading","font-family","font-size","divider","bold","italic","underline","strike","link","code","subscript","superscript","hr","todo","emoji","divider","highlight","font-color","divider","align","line-height","divider","bullet-list","ordered-list","indent-decrease","indent-increase","break","divider",...e.fileManager?[{id:"dux-file-manager-image",tip:h("components.upload.fileManager"),icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M3.08697 9H20.9134C21.4657 9 21.9134 9.44772 21.9134 10C21.9134 10.0277 21.9122 10.0554 21.9099 10.083L21.0766 20.083C21.0334 20.6013 20.6001 21 20.08 21H3.9203C3.40021 21 2.96695 20.6013 2.92376 20.083L2.09042 10.083C2.04456 9.53267 2.45355 9.04932 3.00392 9.00345C3.03155 9.00115 3.05925 9 3.08697 9ZM4.84044 19H19.1599L19.8266 11H4.17377L4.84044 19ZM13.4144 5H20.0002C20.5525 5 21.0002 5.44772 21.0002 6V7H3.00017V4C3.00017 3.44772 3.44789 3 4.00017 3H11.4144L13.4144 5Z"></path></svg>',onClick:(u,a)=>{P.show({title:h("components.uploadManage.title")||h("components.upload.fileManager"),width:"800px",component:()=>Promise.resolve().then(()=>require("../upload/manager.cjs")),componentProps:{path:T.value,type:e.fileManagerType||"all",multiple:!0,uploadParams:{path:g.value,accept:"*/*",method:E.value}}}).then(l=>{const s=Array.isArray(l)?[...l]:l?[l]:[];if(!s.length)return;if(e.editorType==="markdown"){const t=s.filter(n=>n?.url).map(n=>{const m=n?.filename||n?.name||"file";return M(n)==="image"?`![${m}](${n.url})`:`[${m}](${n.url})`});t.length&&a.insertMarkdown(t.join(`
2
+
3
+ `));return}const c=s.filter(t=>t?.url).map(t=>{const n=M(t),m=t?.filename||"";return n==="image"?{type:"image",attrs:{src:t.url,alt:m,width:"auto"}}:n==="video"?{type:"video",attrs:{src:t.url,controls:"true",width:350}}:{type:"paragraph",content:[{type:"text",text:t?.filename||t?.name||"file",marks:[{type:"link",attrs:{href:t.url,target:"_blank"}}]}]}});c.length&&a.insert(c.length===1?c[0]:c)})}}]:[],"image","video","attachment","quote","container","code-block","table","divider","printer","fullscreen","ai"]})},$=()=>{i&&(i.destroy(),i=null)};return o.watch(()=>e.value,U),o.watch(()=>y.isDark.value,r=>{d.value&&(d.value.classList.toggle("aie-theme-dark",r),d.value.classList.toggle("aie-theme-light",!r))},{immediate:!0}),H({get aiEditor(){return i}}),o.onMounted(()=>{o.nextTick(()=>{A()})}),o.onUnmounted(()=>{$()}),()=>o.createVNode("div",{ref:d,style:{height:e.height,width:"100%"}},null)}});exports.DuxAiEditor=z;
@@ -1,5 +1,5 @@
1
1
  "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=`/* layer: properties */
2
- @supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))){*, ::before, ::after, ::backdrop{--un-text-opacity:100%;--un-bg-opacity:100%;--un-from-opacity:100%;--un-shadow-opacity:100%;--un-divide-y-reverse:initial;--un-border-style:solid;--un-divide-x-reverse:initial;--un-divide-opacity:100%;--un-ease:initial;--un-border-opacity:100%;--un-translate-x:initial;--un-translate-y:initial;--un-translate-z:initial;--un-to-opacity:100%;--un-outline-style:solid;--un-fill-opacity:100%;--un-space-y-reverse:initial;}}
2
+ @supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))){*, ::before, ::after, ::backdrop{--un-text-opacity:100%;--un-bg-opacity:100%;--un-from-opacity:100%;--un-divide-y-reverse:initial;--un-border-style:solid;--un-divide-x-reverse:initial;--un-divide-opacity:100%;--un-shadow-opacity:100%;--un-ease:initial;--un-border-opacity:100%;--un-translate-x:initial;--un-translate-y:initial;--un-translate-z:initial;--un-to-opacity:100%;--un-outline-style:solid;--un-fill-opacity:100%;--un-space-y-reverse:initial;}}
3
3
  @property --un-text-opacity{syntax:"<percentage>";inherits:false;initial-value:100%;}
4
4
  @property --un-outline-style{syntax:"*";inherits:false;initial-value:solid;}
5
5
  @property --un-border-opacity{syntax:"<percentage>";inherits:false;initial-value:100%;}
@@ -1,8 +1,8 @@
1
- import { defineComponent as x, ref as U, computed as E, watch as w, onMounted as L, onUnmounted as V, createVNode as $ } from "vue";
2
- import { useTheme as A, useManage as j, useGetAuth as D, useI18n as F, useUpload as z } from "@duxweb/dvha-core";
3
- import { useVModel as B } from "@vueuse/core";
4
- import { AiEditor as N } from "aieditor";
5
- import { useMessage as O } from "naive-ui";
1
+ import { defineComponent as j, ref as F, computed as z, watch as M, onMounted as B, nextTick as H, onUnmounted as D, createVNode as I } from "vue";
2
+ import { useTheme as N, useManage as O, useGetAuth as Z, useI18n as J, useUpload as _ } from "@duxweb/dvha-core";
3
+ import { useVModel as q } from "@vueuse/core";
4
+ import { AiEditor as G } from "aieditor";
5
+ import { useMessage as K } from "naive-ui";
6
6
  import "vue-router";
7
7
  import "@overlastic/vue";
8
8
  import "clsx";
@@ -50,11 +50,11 @@ import "vue-command-palette";
50
50
  import "@duxweb/dvha-naiveui";
51
51
  import "../../pages/page404.js";
52
52
  import "short-unique-id";
53
- import { useUploadConfig as Z } from "../upload/config.js";
53
+ import { useUploadConfig as R } from "../upload/config.js";
54
54
  import "@vue-flow/core";
55
55
  import "@vue-flow/background";
56
56
  /* empty css */
57
- import { useModal as I } from "../../hooks/modal.js";
57
+ import { useModal as Q } from "../../hooks/modal.js";
58
58
  import "mime";
59
59
  import "@iconify-json/tabler/icons.json";
60
60
  import "../posterEditor/elements/index.js";
@@ -62,14 +62,13 @@ import "fabric";
62
62
  import "dayjs";
63
63
  import "@tanstack/vue-query";
64
64
  import "pinia";
65
- const et = /* @__PURE__ */ x({
65
+ const le = /* @__PURE__ */ j({
66
66
  name: "DuxAiEditor",
67
67
  props: {
68
68
  value: String,
69
69
  defaultValue: String,
70
70
  uploadPath: String,
71
71
  uploadHeaders: Object,
72
- // 编辑器类型:富文本 或 Markdown
73
72
  editorType: {
74
73
  type: String,
75
74
  default: "richtext"
@@ -86,108 +85,104 @@ const et = /* @__PURE__ */ x({
86
85
  height: {
87
86
  type: String,
88
87
  default: "500px"
89
- },
90
- onUpdateValue: Function
88
+ }
91
89
  },
92
90
  setup(t, {
93
- emit: y,
94
- expose: k
91
+ emit: b,
92
+ expose: x
95
93
  }) {
96
- const n = U();
97
- let r = null;
98
- k({
99
- get aiEditor() {
100
- return r;
101
- }
102
- });
103
- let l = !1;
104
- const g = A(), {
105
- config: f
106
- } = j(), M = D(), {
94
+ const d = F();
95
+ let o = null, g = !1;
96
+ const v = N(), {
97
+ config: y
98
+ } = O(), S = Z(), {
107
99
  t: u
108
- } = F(), C = O(), H = I(), b = t.value ?? t.defaultValue ?? "", d = B(t, "value", y), m = E(() => t.uploadPath || f.apiPath?.upload || "upload"), s = z({
109
- path: m.value,
100
+ } = J(), P = K(), T = Q(), k = q(t, "value", b, {
101
+ passive: !0
102
+ }), s = z(() => t.uploadPath || y.apiPath?.upload || "upload"), f = _({
103
+ path: s.value,
110
104
  autoUpload: !1
111
105
  }), {
112
- managePath: P,
113
- method: S
114
- } = Z();
115
- w(() => t.value, (e) => {
116
- !r || l || (t.editorType === "markdown" ? r.setMarkdownContent(e || "") : r.setContent(e || ""));
117
- }, {
118
- immediate: !0,
119
- flush: "post"
120
- });
121
- const c = (e) => new Promise((o, a) => {
122
- s.addFiles([e], "file").then(() => {
123
- s.trigger().then((i) => {
124
- i.forEach((p) => {
125
- const h = p?.data?.data;
126
- o({
106
+ managePath: E,
107
+ method: U
108
+ } = R(), A = () => {
109
+ if (!o || g) return;
110
+ const e = k.value || "";
111
+ t.editorType === "markdown" ? o.setMarkdownContent(e) : o.setContent(e);
112
+ }, w = () => {
113
+ if (!o) return;
114
+ g = !0;
115
+ const e = t.editorType === "markdown" ? o.getMarkdown() : o.getHtml();
116
+ k.value = e, H(() => {
117
+ g = !1;
118
+ });
119
+ }, h = (e) => new Promise((n, i) => {
120
+ f.addFiles([e], "file").then(() => {
121
+ f.trigger().then((l) => {
122
+ l.forEach((p) => {
123
+ const m = p?.data?.data;
124
+ n({
127
125
  errorCode: 0,
128
126
  data: {
129
- src: h?.url,
127
+ src: m?.url,
130
128
  alt: p?.filename
131
129
  }
132
130
  });
133
131
  });
134
- }).catch((i) => {
135
- C.error(i.message), a(i);
132
+ }).catch((l) => {
133
+ P.error(l.message), i(l);
136
134
  }).finally(() => {
137
- s.clearFiles();
135
+ f.clearFiles();
138
136
  });
139
137
  });
140
- }), T = (e) => {
141
- const o = String(e?.filetype || ""), a = String(e?.url || "");
142
- return /^image\//i.test(o) || /\.(?:png|jpe?g|gif|bmp|webp|svg)$/i.test(a) ? "image" : /^video\//i.test(o) || /\.(?:mp4|webm|ogg|mov|m4v)$/i.test(a) ? "video" : "attachment";
143
- };
144
- return L(() => {
145
- r = new N({
146
- theme: g.isDark.value ? "dark" : "light",
147
- element: n.value,
138
+ }), C = (e) => {
139
+ const n = String(e?.filetype || ""), i = String(e?.url || "");
140
+ return /^image\//i.test(n) || /\.(?:png|jpe?g|gif|bmp|webp|svg)$/i.test(i) ? "image" : /^video\//i.test(n) || /\.(?:mp4|webm|ogg|mov|m4v)$/i.test(i) ? "video" : "attachment";
141
+ }, L = () => {
142
+ if (!d.value) return;
143
+ const e = t.value || t.defaultValue || "";
144
+ o = new G({
145
+ element: d.value,
146
+ theme: v.isDark.value ? "dark" : "light",
148
147
  placeholder: u("components.editor.placeholder"),
149
- content: b,
148
+ content: e,
150
149
  contentIsMarkdown: t.editorType === "markdown",
151
- onChange: (e) => {
152
- l = !0, d.value = t.editorType === "markdown" ? e.getMarkdown() : e.getHtml(), l = !1;
153
- },
154
- onBlur: (e) => {
155
- l = !0, d.value = t.editorType === "markdown" ? e.getMarkdown() : e.getHtml(), l = !1;
156
- },
150
+ onChange: w,
151
+ onBlur: w,
157
152
  image: {
158
- uploadUrl: m.value,
153
+ uploadUrl: s.value,
159
154
  uploadHeaders: t.uploadHeaders || {},
160
- uploader: c,
155
+ uploader: h,
161
156
  defaultSize: "auto"
162
157
  },
163
158
  video: {
164
- uploadUrl: m.value,
159
+ uploadUrl: s.value,
165
160
  uploadHeaders: t.uploadHeaders || {},
166
- uploader: c
161
+ uploader: h
167
162
  },
168
163
  attachment: {
169
- uploadUrl: m.value,
164
+ uploadUrl: s.value,
170
165
  uploadHeaders: t.uploadHeaders || {},
171
- uploader: c
166
+ uploader: h
172
167
  },
173
168
  ai: {
174
169
  models: {
175
170
  custom: {
176
- url: t.aiPath || f.apiPath?.ai || "ai",
171
+ url: t.aiPath || y.apiPath?.ai || "ai",
177
172
  headers: () => ({
178
173
  "Content-Type": "application/json",
179
- Authorization: M.token
174
+ Authorization: S.token
180
175
  }),
181
- wrapPayload: (e) => JSON.stringify({
182
- prompt: e
176
+ wrapPayload: (n) => JSON.stringify({
177
+ prompt: n
183
178
  }),
184
- parseMessage: (e) => {
185
- const o = JSON.parse(e);
179
+ parseMessage: (n) => {
180
+ const i = JSON.parse(n);
186
181
  return {
187
182
  role: "assistant",
188
- content: o.message,
189
- index: o.number,
190
- status: o.status
183
+ content: i.message,
184
+ index: i.number,
185
+ status: i.status
191
186
  };
192
187
  },
193
188
  protocol: "sse"
@@ -198,63 +193,96 @@ const et = /* @__PURE__ */ x({
198
193
  id: "dux-file-manager-image",
199
194
  tip: u("components.upload.fileManager"),
200
195
  icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M3.08697 9H20.9134C21.4657 9 21.9134 9.44772 21.9134 10C21.9134 10.0277 21.9122 10.0554 21.9099 10.083L21.0766 20.083C21.0334 20.6013 20.6001 21 20.08 21H3.9203C3.40021 21 2.96695 20.6013 2.92376 20.083L2.09042 10.083C2.04456 9.53267 2.45355 9.04932 3.00392 9.00345C3.03155 9.00115 3.05925 9 3.08697 9ZM4.84044 19H19.1599L19.8266 11H4.17377L4.84044 19ZM13.4144 5H20.0002C20.5525 5 21.0002 5.44772 21.0002 6V7H3.00017V4C3.00017 3.44772 3.44789 3 4.00017 3H11.4144L13.4144 5Z"></path></svg>',
201
- onClick: (e, o) => {
202
- H.show({
196
+ onClick: (n, i) => {
197
+ T.show({
203
198
  title: u("components.uploadManage.title") || u("components.upload.fileManager"),
204
199
  width: "800px",
205
200
  component: () => import("../upload/manager.js"),
206
201
  componentProps: {
207
- path: P.value,
202
+ path: E.value,
208
203
  type: t.fileManagerType || "all",
209
204
  multiple: !0,
210
205
  uploadParams: {
211
- path: m.value,
206
+ path: s.value,
212
207
  accept: "*/*",
213
- method: S.value
208
+ method: U.value
214
209
  }
215
210
  }
216
- }).then((a) => {
217
- a?.forEach?.((i) => {
218
- const p = T(i), h = i?.filename || "";
219
- if (p === "image")
220
- o.insert({
221
- type: "image",
222
- attrs: {
223
- src: i.url,
224
- alt: h,
225
- width: "auto"
226
- }
227
- });
228
- else if (p === "video")
229
- o.insert({
230
- type: "video",
231
- attrs: {
232
- src: i.url,
233
- controls: "true",
234
- width: 350
235
- }
236
- });
237
- else {
238
- const v = i?.filename || i?.name || "file";
239
- t.editorType === "markdown" ? o.insertMarkdown(`[${v}](${i.url})`) : o.insert(`<a href="${i.url}" target="_blank">${v}</a>`);
240
- }
211
+ }).then((l) => {
212
+ const p = Array.isArray(l) ? [...l] : l ? [l] : [];
213
+ if (!p.length) return;
214
+ if (t.editorType === "markdown") {
215
+ const r = p.filter((a) => a?.url).map((a) => {
216
+ const c = a?.filename || a?.name || "file";
217
+ return C(a) === "image" ? `![${c}](${a.url})` : `[${c}](${a.url})`;
218
+ });
219
+ r.length && i.insertMarkdown(r.join(`
220
+
221
+ `));
222
+ return;
223
+ }
224
+ const m = p.filter((r) => r?.url).map((r) => {
225
+ const a = C(r), c = r?.filename || "";
226
+ return a === "image" ? {
227
+ type: "image",
228
+ attrs: {
229
+ src: r.url,
230
+ alt: c,
231
+ width: "auto"
232
+ }
233
+ } : a === "video" ? {
234
+ type: "video",
235
+ attrs: {
236
+ src: r.url,
237
+ controls: "true",
238
+ width: 350
239
+ }
240
+ } : {
241
+ type: "paragraph",
242
+ content: [{
243
+ type: "text",
244
+ text: r?.filename || r?.name || "file",
245
+ marks: [{
246
+ type: "link",
247
+ attrs: {
248
+ href: r.url,
249
+ target: "_blank"
250
+ }
251
+ }]
252
+ }]
253
+ };
241
254
  });
255
+ m.length && i.insert(m.length === 1 ? m[0] : m);
242
256
  });
243
257
  }
244
258
  }] : [], "image", "video", "attachment", "quote", "container", "code-block", "table", "divider", "printer", "fullscreen", "ai"]
245
- }), d.value != null && (t.editorType === "markdown" ? r.setMarkdownContent(d.value || "") : r.setContent(d.value || ""));
246
- }), V(() => {
247
- r?.destroy();
248
- }), w(g.isDark, (e) => {
249
- n.value && (n.value.classList.remove("aie-theme-dark", "aie-theme-light"), n.value.classList.add(e ? "aie-theme-dark" : "aie-theme-light"));
259
+ });
260
+ }, V = () => {
261
+ o && (o.destroy(), o = null);
262
+ };
263
+ return M(() => t.value, A), M(() => v.isDark.value, (e) => {
264
+ d.value && (d.value.classList.toggle("aie-theme-dark", e), d.value.classList.toggle("aie-theme-light", !e));
250
265
  }, {
251
266
  immediate: !0
252
- }), () => $("div", {
253
- ref: n,
254
- style: `height: ${t.height}; width:100%`
267
+ }), x({
268
+ get aiEditor() {
269
+ return o;
270
+ }
271
+ }), B(() => {
272
+ H(() => {
273
+ L();
274
+ });
275
+ }), D(() => {
276
+ V();
277
+ }), () => I("div", {
278
+ ref: d,
279
+ style: {
280
+ height: t.height,
281
+ width: "100%"
282
+ }
255
283
  }, null);
256
284
  }
257
285
  });
258
286
  export {
259
- et as DuxAiEditor
287
+ le as DuxAiEditor
260
288
  };
@@ -1,5 +1,5 @@
1
1
  const r = `/* layer: properties */
2
- @supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))){*, ::before, ::after, ::backdrop{--un-text-opacity:100%;--un-bg-opacity:100%;--un-from-opacity:100%;--un-shadow-opacity:100%;--un-divide-y-reverse:initial;--un-border-style:solid;--un-divide-x-reverse:initial;--un-divide-opacity:100%;--un-ease:initial;--un-border-opacity:100%;--un-translate-x:initial;--un-translate-y:initial;--un-translate-z:initial;--un-to-opacity:100%;--un-outline-style:solid;--un-fill-opacity:100%;--un-space-y-reverse:initial;}}
2
+ @supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))){*, ::before, ::after, ::backdrop{--un-text-opacity:100%;--un-bg-opacity:100%;--un-from-opacity:100%;--un-divide-y-reverse:initial;--un-border-style:solid;--un-divide-x-reverse:initial;--un-divide-opacity:100%;--un-shadow-opacity:100%;--un-ease:initial;--un-border-opacity:100%;--un-translate-x:initial;--un-translate-y:initial;--un-translate-z:initial;--un-to-opacity:100%;--un-outline-style:solid;--un-fill-opacity:100%;--un-space-y-reverse:initial;}}
3
3
  @property --un-text-opacity{syntax:"<percentage>";inherits:false;initial-value:100%;}
4
4
  @property --un-outline-style{syntax:"*";inherits:false;initial-value:solid;}
5
5
  @property --un-border-opacity{syntax:"<percentage>";inherits:false;initial-value:100%;}
@@ -21,7 +21,6 @@ export declare const DuxAiEditor: import("vue").DefineComponent<import("vue").Ex
21
21
  type: StringConstructor;
22
22
  default: string;
23
23
  };
24
- onUpdateValue: PropType<(value: string) => void>;
25
24
  }>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
26
25
  value: StringConstructor;
27
26
  defaultValue: StringConstructor;
@@ -44,7 +43,6 @@ export declare const DuxAiEditor: import("vue").DefineComponent<import("vue").Ex
44
43
  type: StringConstructor;
45
44
  default: string;
46
45
  };
47
- onUpdateValue: PropType<(value: string) => void>;
48
46
  }>> & Readonly<{}>, {
49
47
  height: string;
50
48
  editorType: "markdown" | "richtext";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@duxweb/dvha-pro",
3
3
  "type": "module",
4
- "version": "1.1.13",
4
+ "version": "1.1.15",
5
5
  "author": "DuxWeb",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -33,8 +33,8 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "@ant-design/colors": "^7.2.1",
36
- "@duxweb/dvha-core": "^1.1.13",
37
- "@duxweb/dvha-naiveui": "^1.1.13",
36
+ "@duxweb/dvha-core": "^1.1.15",
37
+ "@duxweb/dvha-naiveui": "^1.1.15",
38
38
  "@iconify-json/tabler": "^1.2.23",
39
39
  "@overlastic/vue": "^0.8.3",
40
40
  "@tanstack/vue-query": "^5.90.7",