@ajaxjs/ui 1.4.2 → 1.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("vue"),u={},a=(e,r)=>{const o=e.__vccOpts||e;for(const[n,t]of r)o[n]=t;return o};function i(e,r,o,n,t,c){return s.openBlock(),s.createElementBlock("button",null,"hihi")}const l=a(u,[["render",i]]);function p(e,r){const n=(r?parent.location:window.location).search.substring(1).split("&");for(let t=0;t<n.length;t++){const c=n[t].split("=");if(c[0]==e)return c[1]}return null}exports.MyButton=l;exports.getQueryParam=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("vue"),C={},c=(e,t)=>{const l=e.__vccOpts||e;for(const[r,n]of t)l[r]=n;return l};function y(e,t,l,r,n,s){return o.openBlock(),o.createElementBlock("button",null,"hihi")}const p=c(C,[["render",y]]),g=o.defineComponent({name:"HtmlEditor",props:{modelValue:String,uploadImageActionUrl:String,isIonicons:Boolean},emits:["update:modelValue","onchange"],data(){return{isShowCode:!1,iframeEl:null,sourceEditor:null}},mounted(){this.iframeEl=this.$el.querySelector("iframe"),this.sourceEditor=this.$el.querySelector("textarea"),this.iframeEl.contentWindow.onload=e=>{this.iframeDoc=this.iframeEl.contentWindow.document,this.iframeDoc.designMode="on",this.iframeDoc.addEventListener("paste",k.bind(this)),new MutationObserver((t,l)=>{this.isShowCode||(this.sourceEditor.value=this.iframeDoc.body.innerHTML,this.$emit("onchange",this.sourceEditor.value)),this.$emit("update:modelValue",this.iframeDoc.body.innerHTML)}).observe(this.iframeDoc.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0})},this.sourceEditor.oninput=e=>{this.isShowCode&&this.sourceEditor.value&&(this.setIframeBody(this.sourceEditor.value),this.$emit("onchange",this.sourceEditor.value))}},methods:{setIframeBody(e){this.iframeDoc&&this.iframeDoc.body&&(this.iframeDoc.body.innerHTML=e)},getValue(e,t){let l=this.iframeDoc.body.innerHTML;return e&&(l=E(l)),t&&(l=encodeURIComponent(l)),l},createLink(){const e=prompt("请输入 URL 地址");e&&this.format("createLink",e)},insertImage(){window.isCreate?alert("请保存记录后再上传图片。"):this.uploadImgMgr.show(e=>{e&&e.isOk&&this.format("insertImage",e.fullUrl)})},cleanHTML(){this.setIframeBody(HtmlSanitizer.SanitizeHtml(this.iframeDoc.body.innerHTML))},saveRemoteImage2Local(){const e=this.iframeDoc.querySelectorAll("img"),t=new Array,l=[];for(let r=0,n=e.length;r<n;r++){const s=e[r],i=s.getAttribute("src");i!=null&&/^http/.test(i)&&(t.push(s),l.push(i))}l.length||console.log("未发现有远程图片")},onCmdClk(e){const t=e.target,l=t.className.split(" ").shift();this.format(l)},format(e,t){t?this.iframeDoc.execCommand(e,!1,t):this.iframeDoc.execCommand(e,!1)},onFontsizeChoserClk(e){const t=e.target,l=e.currentTarget.children;let r,n;for(r=0,n=l.length;r<n&&t!=l[r];r++);this.format("fontsize",r+"")},onFontfamilyChoserClk(e){const t=e.target;this.format("fontname",t.innerHTML);const l=t.parentNode;l.style.display="none",setTimeout(()=>l.style.display="",300)},createColorPickerHTML(){const e=["00","33","66","99","CC","FF"];let t,l,r,n;const s=['<div class="colorhead"><span class="colortitle">颜色选择</span></div><div class="colorbody"><table cellspaci="0" cellpadding="0"><tr>'];for(let i=0;i<6;++i){s.push('<td><table class="colorpanel" cellspacing="0" cellpadding="0">');for(let a=0,f=e[i];a<6;++a){s.push("<tr>");for(let d=0,u=e[a];d<6;++d)t=e[d],r=d==5&&i!=2&&i!=5?";border-right:none;":"",n=a==5&&i<3?";border-bottom:none":"",l="#"+f+t+u,s.push('<td unselectable="on" style="background-color: '+l+r+n+'" title="'+l+'"></td>');s.push("</tr>")}s.push("</table></td>"),e[i]=="66"&&s.push("</tr><tr>")}return s.push("</tr></table></div>"),s.join("")}},watch:{modelValue(e,t){t||this.setIframeBody(e)},isShowCode(e){e?(this.iframeEl.classList.add("hide"),this.sourceEditor.classList.add("show"),m.call(this,!0)):(this.iframeEl.classList.remove("hide"),this.sourceEditor.classList.remove("show"),m.call(this,!1))}}});function k(e){if(!this.uploadImageActionUrl){alert("未提供图片上传地址");return}const t=e.clipboardData&&e.clipboardData.items;if(!t||!t.length)return;let l=null;for(let s=0;s<t.length;s++){const i=t[s];if(i.type.indexOf("image")!==-1){l=i.getAsFile();break}}if(!l)return;e.preventDefault();const r=new FormData;r.append("file",l,l.name);const n=new XMLHttpRequest;n.addEventListener("load",s=>{if(n.status>=200&&n.status<300){const i=JSON.parse(n.responseText);console.log("Success:",i),this.format("insertImage",i.data.url)}else console.error("Upload failed with status:",n.status),alert("Upload failed!")}),n.addEventListener("error",function(s){console.error("Network error during upload:",s),alert("Upload failed due to a network error!")}),n.open("POST",this.uploadImageActionUrl),n.send(r)}function m(e){this.$el.querySelectorAll(".toolbar i").forEach(t=>{t.className.indexOf("switchMode")==-1&&(t.style.color=e?"lightgray":"")})}function E(e){return e=e.replace(/<(\/)*(\\?xml:|meta|link|span|font|del|ins|st1:|[ovwxp]:)((.|\s)*?)>/gi,""),e=e.replace(/(class|style|type|start)=("(.*?)"|(\w*))/gi,""),e=e.replace(/<style(.*?)style>/gi,""),e=e.replace(/<script(.*?)script>/gi,""),e=e.replace(/<!--(.*?)-->/gi,""),e}const h={class:"aj-form-html-editor"},v={class:"toolbar"},N={class:"dorpdown"},V={class:"dorpdown"},w={class:"dorpdown"},b=["innerHTML"],I={class:"dorpdown"},L=["innerHTML"];function A(e,t,l,r,n,s){return o.openBlock(),o.createElementBlock("div",h,[o.createElementVNode("ul",v,[o.createElementVNode("li",N,[t[20]||(t[20]=o.createElementVNode("i",{title:"字体",class:"text-icon"},"A",-1)),o.createElementVNode("div",{class:"fontfamilyChoser",onClick:t[0]||(t[0]=(...i)=>e.onFontfamilyChoserClk&&e.onFontfamilyChoserClk(...i))},[...t[19]||(t[19]=[o.createStaticVNode('<a style="font-family:&#39;宋体&#39;;">宋体</a><a style="font-family:&#39;黑体&#39;;">黑体</a><a style="font-family:&#39;楷体&#39;;">楷体</a><a style="font-family:&#39;隶书&#39;;">隶书</a><a style="font-family:&#39;幼圆&#39;;">幼圆</a><a style="font-family:&#39;Microsoft YaHei&#39;;">Microsoft YaHei</a><a style="font-family:Arial;">Arial</a><a style="font-family:&#39;Arial Narrow&#39;;">Arial Narrow</a><a style="font-family:&#39;Arial Black&#39;;">Arial Black</a><a style="font-family:&#39;Comic Sans MS&#39;;">Comic Sans MS</a><a style="font-family:Courier;">Courier</a><a style="font-family:System;">System</a><a style="font-family:&#39;Times New Roman&#39;;">Times New Roman</a><a style="font-family:Verdana;">Verdana</a>',14)])])]),o.createElementVNode("li",V,[t[22]||(t[22]=o.createElementVNode("i",{title:"字号",class:"text-icon"},"H",-1)),o.createElementVNode("div",{class:"fontsizeChoser",onClick:t[1]||(t[1]=(...i)=>e.onFontsizeChoserClk&&e.onFontsizeChoserClk(...i))},[...t[21]||(t[21]=[o.createStaticVNode('<a style="font-size:xx-small;">极小</a><a style="font-size:x-small;">特小</a><a style="font-size:small;">小</a><a style="font-size:medium;">中</a><a style="font-size:large;">大</a><a style="font-size:x-large;">特大</a><a style="font-size:xx-large;line-height:140%;">极大</a>',7)])])]),o.createElementVNode("li",{onClick:t[2]||(t[2]=(...i)=>e.onCmdClk&&e.onCmdClk(...i))},[...t[23]||(t[23]=[o.createElementVNode("i",{title:"加粗",class:"bold text-icon"},"B",-1)])]),o.createElementVNode("li",{onClick:t[3]||(t[3]=(...i)=>e.onCmdClk&&e.onCmdClk(...i))},[...t[24]||(t[24]=[o.createElementVNode("i",{title:"斜体",class:"italic text-icon",style:{"font-style":"italic"}},"I",-1)])]),o.createElementVNode("li",{onClick:t[4]||(t[4]=(...i)=>e.onCmdClk&&e.onCmdClk(...i))},[...t[25]||(t[25]=[o.createElementVNode("i",{title:"下划线",class:"underline text-icon",style:{"text-decoration":"underline"}},"U",-1)])]),o.createElementVNode("li",{onClick:t[5]||(t[5]=(...i)=>e.onCmdClk&&e.onCmdClk(...i))},[o.createElementVNode("i",{title:"左对齐",class:o.normalizeClass("justifyleft "+(e.isIonicons?"ivu-icon ivu-icon-bingo-menu-fold":"fontAwesome fa-align-left"))},null,2)]),o.createElementVNode("li",{onClick:t[6]||(t[6]=(...i)=>e.onCmdClk&&e.onCmdClk(...i))},[o.createElementVNode("i",{title:"中间对齐",class:o.normalizeClass("justifycenter "+(e.isIonicons?"ivu-icon ivu-icon-md-menu":"fontAwesome fa-align-center"))},null,2)]),o.createElementVNode("li",{onClick:t[7]||(t[7]=(...i)=>e.onCmdClk&&e.onCmdClk(...i))},[o.createElementVNode("i",{title:"右对齐",class:o.normalizeClass("justifyright "+(e.isIonicons?"ivu-icon ivu-icon-bingo-menu-unfold":"fontAwesome fa-align-right"))},null,2)]),o.createElementVNode("li",{onClick:t[8]||(t[8]=(...i)=>e.onCmdClk&&e.onCmdClk(...i))},[o.createElementVNode("i",{title:"数字编号",class:o.normalizeClass("insertorderedlist "+(e.isIonicons?"ivu-icon ivu-icon-md-list":"fontAwesome fa-list-ol"))},null,2)]),o.createElementVNode("li",{onClick:t[9]||(t[9]=(...i)=>e.onCmdClk&&e.onCmdClk(...i))},[o.createElementVNode("i",{title:"项目编号",class:o.normalizeClass("insertunorderedlist "+(e.isIonicons?"ivu-icon ivu-icon-ios-list":"fontAwesome fa-list-ul"))},null,2)]),o.createElementVNode("li",{onClick:t[10]||(t[10]=(...i)=>e.onCmdClk&&e.onCmdClk(...i))},[o.createElementVNode("i",{title:"增加缩进",class:o.normalizeClass("outdent "+(e.isIonicons?"ivu-icon ivu-icon-ios-return-left":"fontAwesome fa-outdent"))},null,2)]),o.createElementVNode("li",{onClick:t[11]||(t[11]=(...i)=>e.onCmdClk&&e.onCmdClk(...i))},[o.createElementVNode("i",{title:"减少缩进",class:o.normalizeClass("indent "+(e.isIonicons?"ivu-icon ivu-icon-ios-return-right":"fontAwesome fa-indent"))},null,2)]),o.createElementVNode("li",w,[o.createElementVNode("i",{title:"字体颜色",class:o.normalizeClass(e.isIonicons?"ivu-icon ivu-icon-md-brush":"fontAwesome fa-paint-brush")},null,2),o.createElementVNode("div",{class:"colorPicker",innerHTML:e.createColorPickerHTML(),onClick:t[12]||(t[12]=i=>e.format("foreColor",i.target.title))},null,8,b)]),o.createElementVNode("li",I,[o.createElementVNode("i",{title:"背景颜色",class:o.normalizeClass(e.isIonicons?"ivu-icon ivu-icon-ios-brush-outline":"fontAwesome fa-pencil")},null,2),o.createElementVNode("div",{class:"colorPicker",innerHTML:e.createColorPickerHTML(),onClick:t[13]||(t[13]=i=>e.format("backColor",i.target.title))},null,8,L)]),o.createElementVNode("li",{onClick:t[14]||(t[14]=(...i)=>e.createLink&&e.createLink(...i))},[o.createElementVNode("i",{title:"增加链接",class:o.normalizeClass(e.isIonicons?"ivu-icon ivu-icon-ios-link":"fontAwesome fa-link")},null,2)]),o.createElementVNode("li",{onClick:t[15]||(t[15]=(...i)=>e.insertImage&&e.insertImage(...i))},[o.createElementVNode("i",{title:"增加图片",class:o.normalizeClass(e.isIonicons?"ivu-icon ivu-icon-md-images":"fontAwesome fa-regular fa-image")},null,2)]),o.createElementVNode("li",{onClick:t[16]||(t[16]=(...i)=>e.saveRemoteImage2Local&&e.saveRemoteImage2Local(...i))},[o.createElementVNode("i",{title:"一键存图",class:o.normalizeClass(e.isIonicons?"ivu-icon ivu-icon-md-photos":"fontAwesome fa-camera")},null,2)]),o.createElementVNode("li",{onClick:t[17]||(t[17]=(...i)=>e.cleanHTML&&e.cleanHTML(...i))},[o.createElementVNode("i",{title:"清理 HTML",class:o.normalizeClass(e.isIonicons?"ivu-icon ivu-icon-md-done-all":"fontAwesome fa-eraser")},null,2)]),o.createElementVNode("li",{onClick:t[18]||(t[18]=i=>e.isShowCode=!e.isShowCode)},[o.createElementVNode("i",{title:"切换到代码",class:o.normalizeClass((e.isIonicons?"ivu-icon ivu-icon-md-code":"fontAwesome fa-code")+" switchMode")},null,2)])]),t[26]||(t[26]=o.createElementVNode("div",{class:"editorBody"},[o.createElementVNode("iframe",{srcdoc:"<html><body></body></html>"}),o.createElementVNode("textarea")],-1))])}const M=c(g,[["render",A]]);function z(e,t){const r=(t?parent.location:window.location).search.substring(1).split("&");for(let n=0;n<r.length;n++){const s=r[n].split("=");if(s[0]==e)return s[1]}return null}exports.HtmlEditor=M;exports.MyButton=p;exports.getQueryParam=z;
@@ -1,24 +1,397 @@
1
- import { openBlock as s, createElementBlock as i } from "vue";
2
- const a = {}, u = (n, r) => {
3
- const e = n.__vccOpts || n;
4
- for (const [o, t] of r)
5
- e[o] = t;
6
- return e;
1
+ import { openBlock as c, createElementBlock as C, defineComponent as k, createElementVNode as t, createStaticVNode as m, normalizeClass as a } from "vue";
2
+ const h = {}, y = (i, e) => {
3
+ const s = i.__vccOpts || i;
4
+ for (const [r, l] of e)
5
+ s[r] = l;
6
+ return s;
7
7
  };
8
- function l(n, r, e, o, t, c) {
9
- return s(), i("button", null, "hihi");
8
+ function v(i, e, s, r, l, n) {
9
+ return c(), C("button", null, "hihi");
10
10
  }
11
- const _ = /* @__PURE__ */ u(a, [["render", l]]);
12
- function f(n, r) {
13
- const o = (r ? parent.location : window.location).search.substring(1).split("&");
14
- for (let t = 0; t < o.length; t++) {
15
- const c = o[t].split("=");
16
- if (c[0] == n)
17
- return c[1];
11
+ const B = /* @__PURE__ */ y(h, [["render", v]]), w = k({
12
+ name: "HtmlEditor",
13
+ props: {
14
+ modelValue: String,
15
+ // 双向绑定
16
+ uploadImageActionUrl: String,
17
+ // 图片上传路径
18
+ isIonicons: Boolean
19
+ // 是否使用 ionicons 图标
20
+ },
21
+ emits: ["update:modelValue", "onchange"],
22
+ data() {
23
+ return {
24
+ isShowCode: !1,
25
+ // 是否显示 HTML 源码
26
+ iframeEl: null,
27
+ sourceEditor: null
28
+ };
29
+ },
30
+ mounted() {
31
+ this.iframeEl = this.$el.querySelector("iframe"), this.sourceEditor = this.$el.querySelector("textarea"), this.iframeEl.contentWindow.onload = (i) => {
32
+ this.iframeDoc = this.iframeEl.contentWindow.document, this.iframeDoc.designMode = "on", this.iframeDoc.addEventListener("paste", b.bind(this)), new MutationObserver((e, s) => {
33
+ this.isShowCode || (this.sourceEditor.value = this.iframeDoc.body.innerHTML, this.$emit("onchange", this.sourceEditor.value)), this.$emit("update:modelValue", this.iframeDoc.body.innerHTML);
34
+ }).observe(this.iframeDoc.body, { attributes: !0, childList: !0, subtree: !0, characterData: !0 });
35
+ }, this.sourceEditor.oninput = (i) => {
36
+ this.isShowCode && this.sourceEditor.value && (this.setIframeBody(this.sourceEditor.value), this.$emit("onchange", this.sourceEditor.value));
37
+ };
38
+ },
39
+ methods: {
40
+ /**
41
+ * 输入 HTML 内容
42
+ *
43
+ * @param html
44
+ */
45
+ setIframeBody(i) {
46
+ this.iframeDoc && this.iframeDoc.body && (this.iframeDoc.body.innerHTML = i);
47
+ },
48
+ /**
49
+ * 获取内容的 HTML
50
+ *
51
+ * @param cleanWord 是否清理冗余标签
52
+ * @param encode 是否 URL 编码
53
+ */
54
+ getValue(i, e) {
55
+ let s = this.iframeDoc.body.innerHTML;
56
+ return i && (s = I(s)), e && (s = encodeURIComponent(s)), s;
57
+ },
58
+ createLink() {
59
+ const i = prompt("请输入 URL 地址");
60
+ i && this.format("createLink", i);
61
+ },
62
+ insertImage() {
63
+ window.isCreate ? alert("请保存记录后再上传图片。") : this.uploadImgMgr.show((i) => {
64
+ i && i.isOk && this.format("insertImage", i.fullUrl);
65
+ });
66
+ },
67
+ /**
68
+ * 清理冗余 HTML
69
+ */
70
+ cleanHTML() {
71
+ this.setIframeBody(HtmlSanitizer.SanitizeHtml(this.iframeDoc.body.innerHTML));
72
+ },
73
+ /**
74
+ * 一键存图
75
+ */
76
+ saveRemoteImage2Local() {
77
+ const i = this.iframeDoc.querySelectorAll("img"), e = new Array(), s = [];
78
+ for (let r = 0, l = i.length; r < l; r++) {
79
+ const n = i[r], o = n.getAttribute("src");
80
+ o != null && /^http/.test(o) && (e.push(n), s.push(o));
81
+ }
82
+ s.length || console.log("未发现有远程图片");
83
+ },
84
+ /**
85
+ * 当工具条点击的时候触发
86
+ *
87
+ * @param ev
88
+ */
89
+ onCmdClk(i) {
90
+ const e = i.target, s = e.className.split(" ").shift();
91
+ this.format(s);
92
+ },
93
+ /**
94
+ * 通过 document.execCommand() 来操纵可编辑内容区域的元素
95
+ *
96
+ * @param type 命令的名称
97
+ * @param para 一些命令(例如 insertImage)需要额外的参数(insertImage 需要提供插入 image 的 url),默认为 null
98
+ */
99
+ format(i, e) {
100
+ e ? this.iframeDoc.execCommand(i, !1, e) : this.iframeDoc.execCommand(i, !1);
101
+ },
102
+ /**
103
+ * 选择字号大小
104
+ *
105
+ * @param ev
106
+ */
107
+ onFontsizeChoserClk(i) {
108
+ const e = i.target, s = i.currentTarget.children;
109
+ let r, l;
110
+ for (r = 0, l = s.length; r < l && e != s[r]; r++)
111
+ ;
112
+ this.format("fontsize", r + "");
113
+ },
114
+ /**
115
+ * 选择字体
116
+ *
117
+ * @param ev
118
+ */
119
+ onFontfamilyChoserClk(i) {
120
+ const e = i.target;
121
+ this.format("fontname", e.innerHTML);
122
+ const s = e.parentNode;
123
+ s.style.display = "none", setTimeout(() => s.style.display = "", 300);
124
+ },
125
+ /**
126
+ * 创建颜色选择器
127
+ */
128
+ createColorPickerHTML() {
129
+ const i = ["00", "33", "66", "99", "CC", "FF"];
130
+ let e, s, r, l;
131
+ const n = ['<div class="colorhead"><span class="colortitle">颜色选择</span></div><div class="colorbody"><table cellspaci="0" cellpadding="0"><tr>'];
132
+ for (let o = 0; o < 6; ++o) {
133
+ n.push('<td><table class="colorpanel" cellspacing="0" cellpadding="0">');
134
+ for (let d = 0, p = i[o]; d < 6; ++d) {
135
+ n.push("<tr>");
136
+ for (let f = 0, g = i[d]; f < 6; ++f)
137
+ e = i[f], r = f == 5 && o != 2 && o != 5 ? ";border-right:none;" : "", l = d == 5 && o < 3 ? ";border-bottom:none" : "", s = "#" + p + e + g, n.push('<td unselectable="on" style="background-color: ' + s + r + l + '" title="' + s + '"></td>');
138
+ n.push("</tr>");
139
+ }
140
+ n.push("</table></td>"), i[o] == "66" && n.push("</tr><tr>");
141
+ }
142
+ return n.push("</tr></table></div>"), n.join("");
143
+ }
144
+ },
145
+ watch: {
146
+ // v(newHtml: string, oldHtml: string): void {
147
+ // console.log(newHtml)
148
+ // if (!oldHtml) // 当没有值的时候输入,就是在初始化的时候(第一次)
149
+ // this.setIframeBody(newHtml);
150
+ // },
151
+ modelValue(i, e) {
152
+ e || this.setIframeBody(i);
153
+ },
154
+ /**
155
+ * 切換 HTML 編輯 or 可視化編輯
156
+ *
157
+ * @param n
158
+ */
159
+ isShowCode(i) {
160
+ i ? (this.iframeEl.classList.add("hide"), this.sourceEditor.classList.add("show"), u.call(this, !0)) : (this.iframeEl.classList.remove("hide"), this.sourceEditor.classList.remove("show"), u.call(this, !1));
161
+ }
162
+ }
163
+ });
164
+ function b(i) {
165
+ if (!this.uploadImageActionUrl) {
166
+ alert("未提供图片上传地址");
167
+ return;
168
+ }
169
+ const e = i.clipboardData && i.clipboardData.items;
170
+ if (!e || !e.length)
171
+ return;
172
+ let s = null;
173
+ for (let n = 0; n < e.length; n++) {
174
+ const o = e[n];
175
+ if (o.type.indexOf("image") !== -1) {
176
+ s = o.getAsFile();
177
+ break;
178
+ }
179
+ }
180
+ if (!s)
181
+ return;
182
+ i.preventDefault();
183
+ const r = new FormData();
184
+ r.append("file", s, s.name);
185
+ const l = new XMLHttpRequest();
186
+ l.addEventListener("load", (n) => {
187
+ if (l.status >= 200 && l.status < 300) {
188
+ const o = JSON.parse(l.responseText);
189
+ console.log("Success:", o), this.format("insertImage", o.data.url);
190
+ } else
191
+ console.error("Upload failed with status:", l.status), alert("Upload failed!");
192
+ }), l.addEventListener("error", function(n) {
193
+ console.error("Network error during upload:", n), alert("Upload failed due to a network error!");
194
+ }), l.open("POST", this.uploadImageActionUrl), l.send(r);
195
+ }
196
+ function u(i) {
197
+ this.$el.querySelectorAll(".toolbar i").forEach((e) => {
198
+ e.className.indexOf("switchMode") == -1 && (e.style.color = i ? "lightgray" : "");
199
+ });
200
+ }
201
+ function I(i) {
202
+ return i = i.replace(/<(\/)*(\\?xml:|meta|link|span|font|del|ins|st1:|[ovwxp]:)((.|\s)*?)>/gi, ""), i = i.replace(/(class|style|type|start)=("(.*?)"|(\w*))/gi, ""), i = i.replace(/<style(.*?)style>/gi, ""), i = i.replace(/<script(.*?)script>/gi, ""), i = i.replace(/<!--(.*?)-->/gi, ""), i;
203
+ }
204
+ const L = { class: "aj-form-html-editor" }, A = { class: "toolbar" }, M = { class: "dorpdown" }, E = { class: "dorpdown" }, H = { class: "dorpdown" }, S = ["innerHTML"], T = { class: "dorpdown" }, D = ["innerHTML"];
205
+ function $(i, e, s, r, l, n) {
206
+ return c(), C("div", L, [
207
+ t("ul", A, [
208
+ t("li", M, [
209
+ e[20] || (e[20] = t("i", {
210
+ title: "字体",
211
+ class: "text-icon"
212
+ }, "A", -1)),
213
+ t("div", {
214
+ class: "fontfamilyChoser",
215
+ onClick: e[0] || (e[0] = (...o) => i.onFontfamilyChoserClk && i.onFontfamilyChoserClk(...o))
216
+ }, [...e[19] || (e[19] = [
217
+ m('<a style="font-family:&#39;宋体&#39;;">宋体</a><a style="font-family:&#39;黑体&#39;;">黑体</a><a style="font-family:&#39;楷体&#39;;">楷体</a><a style="font-family:&#39;隶书&#39;;">隶书</a><a style="font-family:&#39;幼圆&#39;;">幼圆</a><a style="font-family:&#39;Microsoft YaHei&#39;;">Microsoft YaHei</a><a style="font-family:Arial;">Arial</a><a style="font-family:&#39;Arial Narrow&#39;;">Arial Narrow</a><a style="font-family:&#39;Arial Black&#39;;">Arial Black</a><a style="font-family:&#39;Comic Sans MS&#39;;">Comic Sans MS</a><a style="font-family:Courier;">Courier</a><a style="font-family:System;">System</a><a style="font-family:&#39;Times New Roman&#39;;">Times New Roman</a><a style="font-family:Verdana;">Verdana</a>', 14)
218
+ ])])
219
+ ]),
220
+ t("li", E, [
221
+ e[22] || (e[22] = t("i", {
222
+ title: "字号",
223
+ class: "text-icon"
224
+ }, "H", -1)),
225
+ t("div", {
226
+ class: "fontsizeChoser",
227
+ onClick: e[1] || (e[1] = (...o) => i.onFontsizeChoserClk && i.onFontsizeChoserClk(...o))
228
+ }, [...e[21] || (e[21] = [
229
+ m('<a style="font-size:xx-small;">极小</a><a style="font-size:x-small;">特小</a><a style="font-size:small;">小</a><a style="font-size:medium;">中</a><a style="font-size:large;">大</a><a style="font-size:x-large;">特大</a><a style="font-size:xx-large;line-height:140%;">极大</a>', 7)
230
+ ])])
231
+ ]),
232
+ t("li", {
233
+ onClick: e[2] || (e[2] = (...o) => i.onCmdClk && i.onCmdClk(...o))
234
+ }, [...e[23] || (e[23] = [
235
+ t("i", {
236
+ title: "加粗",
237
+ class: "bold text-icon"
238
+ }, "B", -1)
239
+ ])]),
240
+ t("li", {
241
+ onClick: e[3] || (e[3] = (...o) => i.onCmdClk && i.onCmdClk(...o))
242
+ }, [...e[24] || (e[24] = [
243
+ t("i", {
244
+ title: "斜体",
245
+ class: "italic text-icon",
246
+ style: { "font-style": "italic" }
247
+ }, "I", -1)
248
+ ])]),
249
+ t("li", {
250
+ onClick: e[4] || (e[4] = (...o) => i.onCmdClk && i.onCmdClk(...o))
251
+ }, [...e[25] || (e[25] = [
252
+ t("i", {
253
+ title: "下划线",
254
+ class: "underline text-icon",
255
+ style: { "text-decoration": "underline" }
256
+ }, "U", -1)
257
+ ])]),
258
+ t("li", {
259
+ onClick: e[5] || (e[5] = (...o) => i.onCmdClk && i.onCmdClk(...o))
260
+ }, [
261
+ t("i", {
262
+ title: "左对齐",
263
+ class: a("justifyleft " + (i.isIonicons ? "ivu-icon ivu-icon-bingo-menu-fold" : "fontAwesome fa-align-left"))
264
+ }, null, 2)
265
+ ]),
266
+ t("li", {
267
+ onClick: e[6] || (e[6] = (...o) => i.onCmdClk && i.onCmdClk(...o))
268
+ }, [
269
+ t("i", {
270
+ title: "中间对齐",
271
+ class: a("justifycenter " + (i.isIonicons ? "ivu-icon ivu-icon-md-menu" : "fontAwesome fa-align-center"))
272
+ }, null, 2)
273
+ ]),
274
+ t("li", {
275
+ onClick: e[7] || (e[7] = (...o) => i.onCmdClk && i.onCmdClk(...o))
276
+ }, [
277
+ t("i", {
278
+ title: "右对齐",
279
+ class: a("justifyright " + (i.isIonicons ? "ivu-icon ivu-icon-bingo-menu-unfold" : "fontAwesome fa-align-right"))
280
+ }, null, 2)
281
+ ]),
282
+ t("li", {
283
+ onClick: e[8] || (e[8] = (...o) => i.onCmdClk && i.onCmdClk(...o))
284
+ }, [
285
+ t("i", {
286
+ title: "数字编号",
287
+ class: a("insertorderedlist " + (i.isIonicons ? "ivu-icon ivu-icon-md-list" : "fontAwesome fa-list-ol"))
288
+ }, null, 2)
289
+ ]),
290
+ t("li", {
291
+ onClick: e[9] || (e[9] = (...o) => i.onCmdClk && i.onCmdClk(...o))
292
+ }, [
293
+ t("i", {
294
+ title: "项目编号",
295
+ class: a("insertunorderedlist " + (i.isIonicons ? "ivu-icon ivu-icon-ios-list" : "fontAwesome fa-list-ul"))
296
+ }, null, 2)
297
+ ]),
298
+ t("li", {
299
+ onClick: e[10] || (e[10] = (...o) => i.onCmdClk && i.onCmdClk(...o))
300
+ }, [
301
+ t("i", {
302
+ title: "增加缩进",
303
+ class: a("outdent " + (i.isIonicons ? "ivu-icon ivu-icon-ios-return-left" : "fontAwesome fa-outdent"))
304
+ }, null, 2)
305
+ ]),
306
+ t("li", {
307
+ onClick: e[11] || (e[11] = (...o) => i.onCmdClk && i.onCmdClk(...o))
308
+ }, [
309
+ t("i", {
310
+ title: "减少缩进",
311
+ class: a("indent " + (i.isIonicons ? "ivu-icon ivu-icon-ios-return-right" : "fontAwesome fa-indent"))
312
+ }, null, 2)
313
+ ]),
314
+ t("li", H, [
315
+ t("i", {
316
+ title: "字体颜色",
317
+ class: a(i.isIonicons ? "ivu-icon ivu-icon-md-brush" : "fontAwesome fa-paint-brush")
318
+ }, null, 2),
319
+ t("div", {
320
+ class: "colorPicker",
321
+ innerHTML: i.createColorPickerHTML(),
322
+ onClick: e[12] || (e[12] = (o) => i.format("foreColor", o.target.title))
323
+ }, null, 8, S)
324
+ ]),
325
+ t("li", T, [
326
+ t("i", {
327
+ title: "背景颜色",
328
+ class: a(i.isIonicons ? "ivu-icon ivu-icon-ios-brush-outline" : "fontAwesome fa-pencil")
329
+ }, null, 2),
330
+ t("div", {
331
+ class: "colorPicker",
332
+ innerHTML: i.createColorPickerHTML(),
333
+ onClick: e[13] || (e[13] = (o) => i.format("backColor", o.target.title))
334
+ }, null, 8, D)
335
+ ]),
336
+ t("li", {
337
+ onClick: e[14] || (e[14] = (...o) => i.createLink && i.createLink(...o))
338
+ }, [
339
+ t("i", {
340
+ title: "增加链接",
341
+ class: a(i.isIonicons ? "ivu-icon ivu-icon-ios-link" : "fontAwesome fa-link")
342
+ }, null, 2)
343
+ ]),
344
+ t("li", {
345
+ onClick: e[15] || (e[15] = (...o) => i.insertImage && i.insertImage(...o))
346
+ }, [
347
+ t("i", {
348
+ title: "增加图片",
349
+ class: a(i.isIonicons ? "ivu-icon ivu-icon-md-images" : "fontAwesome fa-regular fa-image")
350
+ }, null, 2)
351
+ ]),
352
+ t("li", {
353
+ onClick: e[16] || (e[16] = (...o) => i.saveRemoteImage2Local && i.saveRemoteImage2Local(...o))
354
+ }, [
355
+ t("i", {
356
+ title: "一键存图",
357
+ class: a(i.isIonicons ? "ivu-icon ivu-icon-md-photos" : "fontAwesome fa-camera")
358
+ }, null, 2)
359
+ ]),
360
+ t("li", {
361
+ onClick: e[17] || (e[17] = (...o) => i.cleanHTML && i.cleanHTML(...o))
362
+ }, [
363
+ t("i", {
364
+ title: "清理 HTML",
365
+ class: a(i.isIonicons ? "ivu-icon ivu-icon-md-done-all" : "fontAwesome fa-eraser")
366
+ }, null, 2)
367
+ ]),
368
+ t("li", {
369
+ onClick: e[18] || (e[18] = (o) => i.isShowCode = !i.isShowCode)
370
+ }, [
371
+ t("i", {
372
+ title: "切换到代码",
373
+ class: a((i.isIonicons ? "ivu-icon ivu-icon-md-code" : "fontAwesome fa-code") + " switchMode")
374
+ }, null, 2)
375
+ ])
376
+ ]),
377
+ e[26] || (e[26] = t("div", { class: "editorBody" }, [
378
+ t("iframe", { srcdoc: "<html><body></body></html>" }),
379
+ t("textarea")
380
+ ], -1))
381
+ ]);
382
+ }
383
+ const N = /* @__PURE__ */ y(w, [["render", $]]);
384
+ function P(i, e) {
385
+ const r = (e ? parent.location : window.location).search.substring(1).split("&");
386
+ for (let l = 0; l < r.length; l++) {
387
+ const n = r[l].split("=");
388
+ if (n[0] == i)
389
+ return n[1];
18
390
  }
19
391
  return null;
20
392
  }
21
393
  export {
22
- _ as MyButton,
23
- f as getQueryParam
394
+ N as HtmlEditor,
395
+ B as MyButton,
396
+ P as getQueryParam
24
397
  };
@@ -1 +1 @@
1
- (function(e,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(e=typeof globalThis<"u"?globalThis:e||self,t(e.ajaxjs_ui={},e.Vue))})(this,(function(e,t){"use strict";const c={},f=(o,i)=>{const u=o.__vccOpts||o;for(const[r,n]of i)u[r]=n;return u};function a(o,i,u,r,n,s){return t.openBlock(),t.createElementBlock("button",null,"hihi")}const l=f(c,[["render",a]]);function p(o,i){const r=(i?parent.location:window.location).search.substring(1).split("&");for(let n=0;n<r.length;n++){const s=r[n].split("=");if(s[0]==o)return s[1]}return null}e.MyButton=l,e.getQueryParam=p,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(a,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],o):(a=typeof globalThis<"u"?globalThis:a||self,o(a.ajaxjs_ui={},a.Vue))})(this,(function(a,o){"use strict";const u={},f=(e,t)=>{const l=e.__vccOpts||e;for(const[r,n]of t)l[r]=n;return l};function C(e,t,l,r,n,s){return o.openBlock(),o.createElementBlock("button",null,"hihi")}const y=f(u,[["render",C]]),p=o.defineComponent({name:"HtmlEditor",props:{modelValue:String,uploadImageActionUrl:String,isIonicons:Boolean},emits:["update:modelValue","onchange"],data(){return{isShowCode:!1,iframeEl:null,sourceEditor:null}},mounted(){this.iframeEl=this.$el.querySelector("iframe"),this.sourceEditor=this.$el.querySelector("textarea"),this.iframeEl.contentWindow.onload=e=>{this.iframeDoc=this.iframeEl.contentWindow.document,this.iframeDoc.designMode="on",this.iframeDoc.addEventListener("paste",g.bind(this)),new MutationObserver((t,l)=>{this.isShowCode||(this.sourceEditor.value=this.iframeDoc.body.innerHTML,this.$emit("onchange",this.sourceEditor.value)),this.$emit("update:modelValue",this.iframeDoc.body.innerHTML)}).observe(this.iframeDoc.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0})},this.sourceEditor.oninput=e=>{this.isShowCode&&this.sourceEditor.value&&(this.setIframeBody(this.sourceEditor.value),this.$emit("onchange",this.sourceEditor.value))}},methods:{setIframeBody(e){this.iframeDoc&&this.iframeDoc.body&&(this.iframeDoc.body.innerHTML=e)},getValue(e,t){let l=this.iframeDoc.body.innerHTML;return e&&(l=k(l)),t&&(l=encodeURIComponent(l)),l},createLink(){const e=prompt("请输入 URL 地址");e&&this.format("createLink",e)},insertImage(){window.isCreate?alert("请保存记录后再上传图片。"):this.uploadImgMgr.show(e=>{e&&e.isOk&&this.format("insertImage",e.fullUrl)})},cleanHTML(){this.setIframeBody(HtmlSanitizer.SanitizeHtml(this.iframeDoc.body.innerHTML))},saveRemoteImage2Local(){const e=this.iframeDoc.querySelectorAll("img"),t=new Array,l=[];for(let r=0,n=e.length;r<n;r++){const s=e[r],i=s.getAttribute("src");i!=null&&/^http/.test(i)&&(t.push(s),l.push(i))}l.length||console.log("未发现有远程图片")},onCmdClk(e){const t=e.target,l=t.className.split(" ").shift();this.format(l)},format(e,t){t?this.iframeDoc.execCommand(e,!1,t):this.iframeDoc.execCommand(e,!1)},onFontsizeChoserClk(e){const t=e.target,l=e.currentTarget.children;let r,n;for(r=0,n=l.length;r<n&&t!=l[r];r++);this.format("fontsize",r+"")},onFontfamilyChoserClk(e){const t=e.target;this.format("fontname",t.innerHTML);const l=t.parentNode;l.style.display="none",setTimeout(()=>l.style.display="",300)},createColorPickerHTML(){const e=["00","33","66","99","CC","FF"];let t,l,r,n;const s=['<div class="colorhead"><span class="colortitle">颜色选择</span></div><div class="colorbody"><table cellspaci="0" cellpadding="0"><tr>'];for(let i=0;i<6;++i){s.push('<td><table class="colorpanel" cellspacing="0" cellpadding="0">');for(let d=0,S=e[i];d<6;++d){s.push("<tr>");for(let m=0,H=e[d];m<6;++m)t=e[m],r=m==5&&i!=2&&i!=5?";border-right:none;":"",n=d==5&&i<3?";border-bottom:none":"",l="#"+S+t+H,s.push('<td unselectable="on" style="background-color: '+l+r+n+'" title="'+l+'"></td>');s.push("</tr>")}s.push("</table></td>"),e[i]=="66"&&s.push("</tr><tr>")}return s.push("</tr></table></div>"),s.join("")}},watch:{modelValue(e,t){t||this.setIframeBody(e)},isShowCode(e){e?(this.iframeEl.classList.add("hide"),this.sourceEditor.classList.add("show"),c.call(this,!0)):(this.iframeEl.classList.remove("hide"),this.sourceEditor.classList.remove("show"),c.call(this,!1))}}});function g(e){if(!this.uploadImageActionUrl){alert("未提供图片上传地址");return}const t=e.clipboardData&&e.clipboardData.items;if(!t||!t.length)return;let l=null;for(let s=0;s<t.length;s++){const i=t[s];if(i.type.indexOf("image")!==-1){l=i.getAsFile();break}}if(!l)return;e.preventDefault();const r=new FormData;r.append("file",l,l.name);const n=new XMLHttpRequest;n.addEventListener("load",s=>{if(n.status>=200&&n.status<300){const i=JSON.parse(n.responseText);console.log("Success:",i),this.format("insertImage",i.data.url)}else console.error("Upload failed with status:",n.status),alert("Upload failed!")}),n.addEventListener("error",function(s){console.error("Network error during upload:",s),alert("Upload failed due to a network error!")}),n.open("POST",this.uploadImageActionUrl),n.send(r)}function c(e){this.$el.querySelectorAll(".toolbar i").forEach(t=>{t.className.indexOf("switchMode")==-1&&(t.style.color=e?"lightgray":"")})}function k(e){return e=e.replace(/<(\/)*(\\?xml:|meta|link|span|font|del|ins|st1:|[ovwxp]:)((.|\s)*?)>/gi,""),e=e.replace(/(class|style|type|start)=("(.*?)"|(\w*))/gi,""),e=e.replace(/<style(.*?)style>/gi,""),e=e.replace(/<script(.*?)script>/gi,""),e=e.replace(/<!--(.*?)-->/gi,""),e}const E={class:"aj-form-html-editor"},h={class:"toolbar"},N={class:"dorpdown"},V={class:"dorpdown"},w={class:"dorpdown"},b=["innerHTML"],I={class:"dorpdown"},L=["innerHTML"];function A(e,t,l,r,n,s){return o.openBlock(),o.createElementBlock("div",E,[o.createElementVNode("ul",h,[o.createElementVNode("li",N,[t[20]||(t[20]=o.createElementVNode("i",{title:"字体",class:"text-icon"},"A",-1)),o.createElementVNode("div",{class:"fontfamilyChoser",onClick:t[0]||(t[0]=(...i)=>e.onFontfamilyChoserClk&&e.onFontfamilyChoserClk(...i))},[...t[19]||(t[19]=[o.createStaticVNode('<a style="font-family:&#39;宋体&#39;;">宋体</a><a style="font-family:&#39;黑体&#39;;">黑体</a><a style="font-family:&#39;楷体&#39;;">楷体</a><a style="font-family:&#39;隶书&#39;;">隶书</a><a style="font-family:&#39;幼圆&#39;;">幼圆</a><a style="font-family:&#39;Microsoft YaHei&#39;;">Microsoft YaHei</a><a style="font-family:Arial;">Arial</a><a style="font-family:&#39;Arial Narrow&#39;;">Arial Narrow</a><a style="font-family:&#39;Arial Black&#39;;">Arial Black</a><a style="font-family:&#39;Comic Sans MS&#39;;">Comic Sans MS</a><a style="font-family:Courier;">Courier</a><a style="font-family:System;">System</a><a style="font-family:&#39;Times New Roman&#39;;">Times New Roman</a><a style="font-family:Verdana;">Verdana</a>',14)])])]),o.createElementVNode("li",V,[t[22]||(t[22]=o.createElementVNode("i",{title:"字号",class:"text-icon"},"H",-1)),o.createElementVNode("div",{class:"fontsizeChoser",onClick:t[1]||(t[1]=(...i)=>e.onFontsizeChoserClk&&e.onFontsizeChoserClk(...i))},[...t[21]||(t[21]=[o.createStaticVNode('<a style="font-size:xx-small;">极小</a><a style="font-size:x-small;">特小</a><a style="font-size:small;">小</a><a style="font-size:medium;">中</a><a style="font-size:large;">大</a><a style="font-size:x-large;">特大</a><a style="font-size:xx-large;line-height:140%;">极大</a>',7)])])]),o.createElementVNode("li",{onClick:t[2]||(t[2]=(...i)=>e.onCmdClk&&e.onCmdClk(...i))},[...t[23]||(t[23]=[o.createElementVNode("i",{title:"加粗",class:"bold text-icon"},"B",-1)])]),o.createElementVNode("li",{onClick:t[3]||(t[3]=(...i)=>e.onCmdClk&&e.onCmdClk(...i))},[...t[24]||(t[24]=[o.createElementVNode("i",{title:"斜体",class:"italic text-icon",style:{"font-style":"italic"}},"I",-1)])]),o.createElementVNode("li",{onClick:t[4]||(t[4]=(...i)=>e.onCmdClk&&e.onCmdClk(...i))},[...t[25]||(t[25]=[o.createElementVNode("i",{title:"下划线",class:"underline text-icon",style:{"text-decoration":"underline"}},"U",-1)])]),o.createElementVNode("li",{onClick:t[5]||(t[5]=(...i)=>e.onCmdClk&&e.onCmdClk(...i))},[o.createElementVNode("i",{title:"左对齐",class:o.normalizeClass("justifyleft "+(e.isIonicons?"ivu-icon ivu-icon-bingo-menu-fold":"fontAwesome fa-align-left"))},null,2)]),o.createElementVNode("li",{onClick:t[6]||(t[6]=(...i)=>e.onCmdClk&&e.onCmdClk(...i))},[o.createElementVNode("i",{title:"中间对齐",class:o.normalizeClass("justifycenter "+(e.isIonicons?"ivu-icon ivu-icon-md-menu":"fontAwesome fa-align-center"))},null,2)]),o.createElementVNode("li",{onClick:t[7]||(t[7]=(...i)=>e.onCmdClk&&e.onCmdClk(...i))},[o.createElementVNode("i",{title:"右对齐",class:o.normalizeClass("justifyright "+(e.isIonicons?"ivu-icon ivu-icon-bingo-menu-unfold":"fontAwesome fa-align-right"))},null,2)]),o.createElementVNode("li",{onClick:t[8]||(t[8]=(...i)=>e.onCmdClk&&e.onCmdClk(...i))},[o.createElementVNode("i",{title:"数字编号",class:o.normalizeClass("insertorderedlist "+(e.isIonicons?"ivu-icon ivu-icon-md-list":"fontAwesome fa-list-ol"))},null,2)]),o.createElementVNode("li",{onClick:t[9]||(t[9]=(...i)=>e.onCmdClk&&e.onCmdClk(...i))},[o.createElementVNode("i",{title:"项目编号",class:o.normalizeClass("insertunorderedlist "+(e.isIonicons?"ivu-icon ivu-icon-ios-list":"fontAwesome fa-list-ul"))},null,2)]),o.createElementVNode("li",{onClick:t[10]||(t[10]=(...i)=>e.onCmdClk&&e.onCmdClk(...i))},[o.createElementVNode("i",{title:"增加缩进",class:o.normalizeClass("outdent "+(e.isIonicons?"ivu-icon ivu-icon-ios-return-left":"fontAwesome fa-outdent"))},null,2)]),o.createElementVNode("li",{onClick:t[11]||(t[11]=(...i)=>e.onCmdClk&&e.onCmdClk(...i))},[o.createElementVNode("i",{title:"减少缩进",class:o.normalizeClass("indent "+(e.isIonicons?"ivu-icon ivu-icon-ios-return-right":"fontAwesome fa-indent"))},null,2)]),o.createElementVNode("li",w,[o.createElementVNode("i",{title:"字体颜色",class:o.normalizeClass(e.isIonicons?"ivu-icon ivu-icon-md-brush":"fontAwesome fa-paint-brush")},null,2),o.createElementVNode("div",{class:"colorPicker",innerHTML:e.createColorPickerHTML(),onClick:t[12]||(t[12]=i=>e.format("foreColor",i.target.title))},null,8,b)]),o.createElementVNode("li",I,[o.createElementVNode("i",{title:"背景颜色",class:o.normalizeClass(e.isIonicons?"ivu-icon ivu-icon-ios-brush-outline":"fontAwesome fa-pencil")},null,2),o.createElementVNode("div",{class:"colorPicker",innerHTML:e.createColorPickerHTML(),onClick:t[13]||(t[13]=i=>e.format("backColor",i.target.title))},null,8,L)]),o.createElementVNode("li",{onClick:t[14]||(t[14]=(...i)=>e.createLink&&e.createLink(...i))},[o.createElementVNode("i",{title:"增加链接",class:o.normalizeClass(e.isIonicons?"ivu-icon ivu-icon-ios-link":"fontAwesome fa-link")},null,2)]),o.createElementVNode("li",{onClick:t[15]||(t[15]=(...i)=>e.insertImage&&e.insertImage(...i))},[o.createElementVNode("i",{title:"增加图片",class:o.normalizeClass(e.isIonicons?"ivu-icon ivu-icon-md-images":"fontAwesome fa-regular fa-image")},null,2)]),o.createElementVNode("li",{onClick:t[16]||(t[16]=(...i)=>e.saveRemoteImage2Local&&e.saveRemoteImage2Local(...i))},[o.createElementVNode("i",{title:"一键存图",class:o.normalizeClass(e.isIonicons?"ivu-icon ivu-icon-md-photos":"fontAwesome fa-camera")},null,2)]),o.createElementVNode("li",{onClick:t[17]||(t[17]=(...i)=>e.cleanHTML&&e.cleanHTML(...i))},[o.createElementVNode("i",{title:"清理 HTML",class:o.normalizeClass(e.isIonicons?"ivu-icon ivu-icon-md-done-all":"fontAwesome fa-eraser")},null,2)]),o.createElementVNode("li",{onClick:t[18]||(t[18]=i=>e.isShowCode=!e.isShowCode)},[o.createElementVNode("i",{title:"切换到代码",class:o.normalizeClass((e.isIonicons?"ivu-icon ivu-icon-md-code":"fontAwesome fa-code")+" switchMode")},null,2)])]),t[26]||(t[26]=o.createElementVNode("div",{class:"editorBody"},[o.createElementVNode("iframe",{srcdoc:"<html><body></body></html>"}),o.createElementVNode("textarea")],-1))])}const M=f(p,[["render",A]]);function z(e,t){const r=(t?parent.location:window.location).search.substring(1).split("&");for(let n=0;n<r.length;n++){const s=r[n].split("=");if(s[0]==e)return s[1]}return null}a.HtmlEditor=M,a.MyButton=y,a.getQueryParam=z,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
@@ -0,0 +1,68 @@
1
+ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
2
+ modelValue: StringConstructor;
3
+ uploadImageActionUrl: StringConstructor;
4
+ isIonicons: BooleanConstructor;
5
+ }>, {}, any, {}, {
6
+ /**
7
+ * 输入 HTML 内容
8
+ *
9
+ * @param html
10
+ */
11
+ setIframeBody(html: string): void;
12
+ /**
13
+ * 获取内容的 HTML
14
+ *
15
+ * @param cleanWord 是否清理冗余标签
16
+ * @param encode 是否 URL 编码
17
+ */
18
+ getValue(cleanWord: boolean, encode: boolean): string;
19
+ createLink(): void;
20
+ insertImage(): void;
21
+ /**
22
+ * 清理冗余 HTML
23
+ */
24
+ cleanHTML(): void;
25
+ /**
26
+ * 一键存图
27
+ */
28
+ saveRemoteImage2Local(): void;
29
+ /**
30
+ * 当工具条点击的时候触发
31
+ *
32
+ * @param ev
33
+ */
34
+ onCmdClk(ev: Event): void;
35
+ /**
36
+ * 通过 document.execCommand() 来操纵可编辑内容区域的元素
37
+ *
38
+ * @param type 命令的名称
39
+ * @param para 一些命令(例如 insertImage)需要额外的参数(insertImage 需要提供插入 image 的 url),默认为 null
40
+ */
41
+ format(type: string, para?: string): void;
42
+ /**
43
+ * 选择字号大小
44
+ *
45
+ * @param ev
46
+ */
47
+ onFontsizeChoserClk(ev: Event): void;
48
+ /**
49
+ * 选择字体
50
+ *
51
+ * @param ev
52
+ */
53
+ onFontfamilyChoserClk(ev: Event): void;
54
+ /**
55
+ * 创建颜色选择器
56
+ */
57
+ createColorPickerHTML(): string;
58
+ }, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("update:modelValue" | "onchange")[], "update:modelValue" | "onchange", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
59
+ modelValue: StringConstructor;
60
+ uploadImageActionUrl: StringConstructor;
61
+ isIonicons: BooleanConstructor;
62
+ }>> & Readonly<{
63
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
64
+ onOnchange?: ((...args: any[]) => any) | undefined;
65
+ }>, {
66
+ isIonicons: boolean;
67
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
68
+ export default _default;
package/dist/ui.css ADDED
@@ -0,0 +1 @@
1
+ .aj-form-html-editor ul.toolbar{border:1px solid #C5C5C5;border-radius:4px 4px 0 0;border-bottom:0;background-color:#e8e7e4;width:100%;min-height:30px;margin:0;box-sizing:border-box;padding:3px 4px}.aj-form-html-editor ul.toolbar>li{list-style:none;float:left;cursor:pointer}.aj-form-html-editor ul.toolbar>li>i{border:1px solid transparent;min-width:25px;height:20px;line-height:20px;text-align:center;display:block}.aj-form-html-editor ul.toolbar>li>i.text-icon{font-family:Times New Roman;font-weight:700;font-style:normal}.aj-form-html-editor ul.toolbar>li>i.fontAwesome{padding-top:2px;font: 18px/1 FontAwesome}.aj-form-html-editor ul.toolbar>li>i:hover{border-right-color:#aaa;border-bottom-color:#aaa;border-top-color:#fff;border-left-color:#fff}.aj-form-html-editor ul.toolbar>li>i:active{border-right-color:#f3f8fc;border-bottom-color:#f3f8fc;border-top-color:#ccc;border-left-color:#ccc}.aj-form-html-editor ul.toolbar>li ul li{padding:3px;cursor:pointer}.aj-form-html-editor ul.toolbar>li ul li:hover{background-color:#d3d3d3}.aj-form-html-editor ul.toolbar>li .cleanHTML{background-size:16px 16px}.aj-form-html-editor ul.toolbar>li .noBg{background-image:none}.aj-form-html-editor .editorBody iframe,.aj-form-html-editor .editorBody textarea{border:1px solid #C5C5C5;border-radius:0 0 4px 4px;border-top-width:0;box-sizing:border-box;background-color:#fff;min-height:300px;width:100%}.aj-form-html-editor .editorBody iframe.hide{display:none}.aj-form-html-editor .editorBody textarea{resize:none;display:none}.aj-form-html-editor .editorBody textarea.show{display:block}.aj-form-html-editor .colorPicker{width:210px;border:1px solid #D3D3D3;position:absolute}.aj-form-html-editor .colorPicker table{border-collapse:collapse}.aj-form-html-editor .colorPicker .colorhead{height:23px;line-height:23px;font-weight:700;width:100%}.aj-form-html-editor .colorPicker .colortitle{margin-left:6px;font-size:12px}.aj-form-html-editor .colorPicker .colorpanel td{border:1px solid #000;height:10px;width:10px;overflow:hidden;font-size:1px;cursor:pointer}.aj-form-html-editor .fontfamilyChoser a,.aj-form-html-editor .fontsizeChoser a{display:block;padding:2px;color:#000;line-height:120%;text-decoration:none}.aj-form-html-editor .fontfamilyChoser a:hover,.aj-form-html-editor .fontsizeChoser a:hover{background:#e5e5e5}.aj-form-html-editor .dorpdown{position:relative}.aj-form-html-editor .dorpdown:hover .fontfamilyChoser,.aj-form-html-editor .dorpdown .fontfamilyChoser:hover,.aj-form-html-editor .dorpdown:hover .fontsizeChoser,.aj-form-html-editor .dorpdown .fontsizeChoser:hover,.aj-form-html-editor .dorpdown:hover .colorPicker,.aj-form-html-editor .dorpdown .colorPicker:hover{display:block}.aj-form-html-editor .dorpdown>div{display:none;position:absolute;top:22px;left:0;background-color:#f5f5f5;border:1px solid lightgray;border-top:0;padding:5px;width:230px}.aj-form-html-editor .dorpdown .fontsizeChoser{top:inherit;right:0}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ajaxjs/ui",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
File without changes