iking-template-inset 0.0.3 → 0.0.5

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.
@@ -4,7 +4,7 @@
4
4
  * @description :
5
5
  * @updateInfo :
6
6
  * @Date : 2022-11-21 10:28:10
7
- * @LastEditTime : 2022-11-21 10:28:43
7
+ * @LastEditTime : 2022-11-28 12:09:42
8
8
  */
9
9
  /// <reference types="vite/client" />
10
10
 
@@ -13,16 +13,18 @@ declare module 'iking-template-inset' {
13
13
  const component: Component<{
14
14
  width: number; // 宽度
15
15
  height: number; // 高度
16
- show: boolean;// 是否显示
17
- sliderSize: number; // 滑块大小
18
- scale: number; // 滑块缩放比例
19
- range: number; // 误差范围
20
- images: string[] | null; // 自定义图片数组
21
- successText: string; // 校验通过文字
22
- failText: string; // 校验失败文字
23
- sliderText: string; // 滑块文字
24
- padding: number; // 内边距
25
- el: HTMLBaseElement | string //CSS 选择器字符串或者一个真实的 DOM 节点
16
+ // 参数列表
17
+ tagList: Array<{
18
+ label: string;
19
+ value: string;
20
+ [key: string]: any;
21
+ }[]>,
22
+ // "1px solid #dcdfe6"
23
+ border: string;
24
+ // 排列方式
25
+ horizontal: Boolean
26
+ // placeholder
27
+ placeholder: string
26
28
  }>
27
29
  export default component
28
30
  }
@@ -1,5 +1,5 @@
1
- import { defineComponent as b, ref as r, watch as k, openBlock as c, createElementBlock as u, normalizeClass as h, createElementVNode as v, Fragment as _, renderList as $, renderSlot as I, createTextVNode as N, toDisplayString as S, withKeys as T, withModifiers as w, nextTick as x } from "vue";
2
- const C = { class: "left-template-tag" }, L = ["onClick"], V = /* @__PURE__ */ b({
1
+ import { defineComponent as k, useCssVars as x, ref as u, watch as $, openBlock as i, createElementBlock as d, normalizeStyle as m, createElementVNode as f, Fragment as y, renderList as b, renderSlot as S, createTextVNode as w, toDisplayString as I, withDirectives as V, withKeys as A, withModifiers as B, vModelText as C } from "vue";
2
+ const z = ["onClick"], F = ["placeholder"], K = /* @__PURE__ */ k({
3
3
  __name: "App",
4
4
  props: {
5
5
  modelVlaue: {
@@ -12,75 +12,96 @@ const C = { class: "left-template-tag" }, L = ["onClick"], V = /* @__PURE__ */ b
12
12
  type: Array,
13
13
  default: () => []
14
14
  },
15
- class: {
15
+ border: {
16
16
  type: String,
17
- default: ""
17
+ default: "1px solid #dcdfe6"
18
+ },
19
+ horizontal: {
20
+ type: Boolean,
21
+ default: !0
22
+ },
23
+ placeholder: {
24
+ type: String,
25
+ default: "\u8BF7\u8F93\u5165\u6216\u70B9\u51FB\u63D2\u5165\u53C2\u6570"
18
26
  }
19
27
  },
20
28
  emits: ["update:modelVlaue"],
21
- setup(s, { emit: d }) {
22
- const o = s, l = r(-1), i = r(), p = () => {
23
- const e = document.getSelection();
24
- l.value = e != null && e.baseNode ? e != null && e.baseOffset ? e == null ? void 0 : e.baseOffset : 0 : -1;
25
- }, t = r(""), f = r("");
26
- k(t, (e) => {
27
- d("update:modelVlaue", e);
29
+ setup(l, { emit: c }) {
30
+ const s = l;
31
+ x((t) => ({
32
+ "8d8ff372": l.border
33
+ }));
34
+ const a = u(-1), r = () => {
35
+ var e;
36
+ const t = (e = p.value) == null ? void 0 : e.selectionStart;
37
+ a.value = t ? t || 0 : -1;
38
+ }, n = u(""), h = u(""), p = u(null);
39
+ $(n, (t) => {
40
+ c("update:modelVlaue", t);
28
41
  });
29
- const y = (e) => {
30
- const n = document.getSelection();
31
- p(), x(() => {
32
- t.value = e.target.innerHTML, f.value = n.baseNode.data;
33
- });
34
- }, g = (e) => {
35
- const n = `\u3010${e.label}\${${e.value}}\u3011`;
36
- if (l.value === -1)
37
- t.value = `${t.value}${n}`;
38
- else if (l.value === 0)
39
- t.value = `${n}${t.value}`;
42
+ const _ = (t) => {
43
+ var e;
44
+ r(), h.value = (e = p.value) == null ? void 0 : e.selectionStart;
45
+ }, g = (t) => {
46
+ const e = `\u3010${t.label}\${${t.value}}\u3011`;
47
+ if (a.value === -1)
48
+ n.value = `${n.value}${e}`;
49
+ else if (a.value === 0)
50
+ n.value = `${e}${n.value}`;
40
51
  else {
41
- const a = t.value;
42
- t.value = a.substring(0, l.value) + n + a.substring(l.value);
52
+ const o = n.value;
53
+ n.value = o.substring(0, a.value) + e + o.substring(a.value);
43
54
  }
44
- i.value.innerHTML = t.value;
45
55
  };
46
- return (e, n) => (c(), u("div", {
47
- class: h(`msg-template ${o.class}`)
56
+ return (t, e) => (i(), d("div", {
57
+ class: "msg-template",
58
+ style: m({
59
+ "flex-direction": s.horizontal ? "row" : "column",
60
+ height: `${s.height}px`
61
+ })
48
62
  }, [
49
- v("div", C, [
50
- (c(!0), u(_, null, $(s.tagList, (a, m) => (c(), u("div", {
51
- onClick: (D) => g(a),
52
- key: m
63
+ f("div", {
64
+ class: "left-template-tag",
65
+ style: m({ "margin-right": s.horizontal ? "16px" : "0" })
66
+ }, [
67
+ (i(!0), d(y, null, b(l.tagList, (o, v) => (i(), d("div", {
68
+ onClick: (D) => g(o),
69
+ key: v
53
70
  }, [
54
- e.$slots.item ? I(e.$slots, "item", {
71
+ t.$slots.item ? S(t.$slots, "item", {
55
72
  key: 0,
56
- item: { ...a, index: m }
57
- }, void 0, !0) : (c(), u(_, { key: 1 }, [
58
- N(S(a.label), 1)
73
+ item: { ...o, index: v }
74
+ }, void 0, !0) : (i(), d(y, { key: 1 }, [
75
+ w(I(o.label), 1)
59
76
  ], 64))
60
- ], 8, L))), 128))
61
- ]),
62
- v("div", {
63
- ref_key: "insetDom",
64
- ref: i,
65
- class: "right-template",
66
- contenteditable: "",
67
- onKeydown: n[0] || (n[0] = T(w(() => {
77
+ ], 8, z))), 128))
78
+ ], 4),
79
+ V(f("textarea", {
80
+ ref_key: "refArea",
81
+ ref: p,
82
+ "onUpdate:modelValue": e[0] || (e[0] = (o) => n.value = o),
83
+ onKeyup: _,
84
+ onClick: r,
85
+ onKeydown: e[1] || (e[1] = A(B(() => {
68
86
  }, ["prevent"]), ["enter"])),
69
- onKeyup: y,
70
- onClick: p
71
- }, null, 544)
72
- ], 2));
87
+ class: "right-template",
88
+ placeholder: l.placeholder
89
+ }, `
90
+ `, 40, F), [
91
+ [C, n.value]
92
+ ])
93
+ ], 4));
73
94
  }
74
95
  });
75
- const A = (s, d) => {
76
- const o = s.__vccOpts || s;
77
- for (const [l, i] of d)
78
- o[l] = i;
79
- return o;
80
- }, K = /* @__PURE__ */ A(V, [["__scopeId", "data-v-fd1bc07f"]]), O = (s) => {
81
- s.component("IkingTemplateInset", K);
96
+ const N = (l, c) => {
97
+ const s = l.__vccOpts || l;
98
+ for (const [a, r] of c)
99
+ s[a] = r;
100
+ return s;
101
+ }, T = /* @__PURE__ */ N(K, [["__scopeId", "data-v-8e5e4859"]]), E = (l) => {
102
+ l.component("IkingTemplateInset", T);
82
103
  };
83
104
  export {
84
- K as default,
85
- O as install
105
+ T as default,
106
+ E as install
86
107
  };
@@ -1 +1,2 @@
1
- (function(l,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(l=typeof globalThis<"u"?globalThis:l||self,e(l.IkingTemplateInset={},l.Vue))})(this,function(l,e){"use strict";const m={class:"left-template-tag"},_=["onClick"],y=e.defineComponent({__name:"App",props:{modelVlaue:{type:String,default:""},height:{type:Number,default:300},width:{type:Number,default:600},tagList:{type:Array,default:()=>[]},class:{type:String,default:""}},emits:["update:modelVlaue"],setup(s,{emit:d}){const c=s,a=e.ref(-1),r=e.ref(),f=()=>{const t=document.getSelection();a.value=t!=null&&t.baseNode?t!=null&&t.baseOffset?t==null?void 0:t.baseOffset:0:-1},n=e.ref(""),k=e.ref("");e.watch(n,t=>{d("update:modelVlaue",t)});const b=t=>{const o=document.getSelection();f(),e.nextTick(()=>{n.value=t.target.innerHTML,k.value=o.baseNode.data})},h=t=>{const o=`\u3010${t.label}\${${t.value}}\u3011`;if(a.value===-1)n.value=`${n.value}${o}`;else if(a.value===0)n.value=`${o}${n.value}`;else{const i=n.value;n.value=i.substring(0,a.value)+o+i.substring(a.value)}r.value.innerHTML=n.value};return(t,o)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(`msg-template ${c.class}`)},[e.createElementVNode("div",m,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.tagList,(i,u)=>(e.openBlock(),e.createElementBlock("div",{onClick:I=>h(i),key:u},[t.$slots.item?e.renderSlot(t.$slots,"item",{key:0,item:{...i,index:u}},void 0,!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(i.label),1)],64))],8,_))),128))]),e.createElementVNode("div",{ref_key:"insetDom",ref:r,class:"right-template",contenteditable:"",onKeydown:o[0]||(o[0]=e.withKeys(e.withModifiers(()=>{},["prevent"]),["enter"])),onKeyup:b,onClick:f},null,544)],2))}}),$="",T="",p=((s,d)=>{const c=s.__vccOpts||s;for(const[a,r]of d)c[a]=r;return c})(y,[["__scopeId","data-v-fd1bc07f"]]),g=s=>{s.component("IkingTemplateInset",p)};l.default=p,l.install=g,Object.defineProperties(l,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(a,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(a=typeof globalThis<"u"?globalThis:a||self,e(a.IkingTemplateInset={},a.Vue))})(this,function(a,e){"use strict";const m=["onClick"],y=["placeholder"],_=e.defineComponent({__name:"App",props:{modelVlaue:{type:String,default:""},height:{type:Number,default:300},width:{type:Number,default:600},tagList:{type:Array,default:()=>[]},border:{type:String,default:"1px solid #dcdfe6"},horizontal:{type:Boolean,default:!0},placeholder:{type:String,default:"\u8BF7\u8F93\u5165\u6216\u70B9\u51FB\u63D2\u5165\u53C2\u6570"}},emits:["update:modelVlaue"],setup(n,{emit:c}){const i=n;e.useCssVars(l=>({"8d8ff372":n.border}));const s=e.ref(-1),d=()=>{var t;const l=(t=p.value)==null?void 0:t.selectionStart;s.value=l?l||0:-1},o=e.ref(""),g=e.ref(""),p=e.ref(null);e.watch(o,l=>{c("update:modelVlaue",l)});const k=l=>{var t;d(),g.value=(t=p.value)==null?void 0:t.selectionStart},x=l=>{const t=`\u3010${l.label}\${${l.value}}\u3011`;if(s.value===-1)o.value=`${o.value}${t}`;else if(s.value===0)o.value=`${t}${o.value}`;else{const r=o.value;o.value=r.substring(0,s.value)+t+r.substring(s.value)}};return(l,t)=>(e.openBlock(),e.createElementBlock("div",{class:"msg-template",style:e.normalizeStyle({"flex-direction":i.horizontal?"row":"column",height:`${i.height}px`})},[e.createElementVNode("div",{class:"left-template-tag",style:e.normalizeStyle({"margin-right":i.horizontal?"16px":"0"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.tagList,(r,f)=>(e.openBlock(),e.createElementBlock("div",{onClick:b=>x(r),key:f},[l.$slots.item?e.renderSlot(l.$slots,"item",{key:0,item:{...r,index:f}},void 0,!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(r.label),1)],64))],8,m))),128))],4),e.withDirectives(e.createElementVNode("textarea",{ref_key:"refArea",ref:p,"onUpdate:modelValue":t[0]||(t[0]=r=>o.value=r),onKeyup:k,onClick:d,onKeydown:t[1]||(t[1]=e.withKeys(e.withModifiers(()=>{},["prevent"]),["enter"])),class:"right-template",placeholder:n.placeholder},`
2
+ `,40,y),[[e.vModelText,o.value]])],4))}}),B="",S="",u=((n,c)=>{const i=n.__vccOpts||n;for(const[s,d]of c)i[s]=d;return i})(_,[["__scopeId","data-v-8e5e4859"]]),h=n=>{n.component("IkingTemplateInset",u)};a.default=u,a.install=h,Object.defineProperties(a,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- .__templeate_param_tag{display:inline-block;padding:2px;background:#dfdfdf;font-size:13px;border-radius:4px;margin-right:2px}.msg-template[data-v-fd1bc07f]{display:flex;width:100%;margin-bottom:8px}.msg-template>div[data-v-fd1bc07f]{flex:1;border:1px solid #9d9393;border-radius:4px;padding:8px}.msg-template .left-template-tag[data-v-fd1bc07f]{display:flex;flex-wrap:wrap;margin-right:16px}.msg-template .left-template-tag div[data-v-fd1bc07f]{cursor:pointer;user-select:none;padding:3px 8px;margin:3px 1px 3px 3px;width:100px;border-radius:4px;background:#edebeb}.msg-template .right-template[data-v-fd1bc07f]{counter-increment:true}.msg-template .right-template[data-v-fd1bc07f]:focus-visible{outline:none}
1
+ .__templeate_param_tag{display:inline-block;padding:2px;background:#dfdfdf;font-size:13px;border-radius:4px;margin-right:2px}.msg-template[data-v-8e5e4859]{display:flex;width:100%;margin-bottom:8px;justify-content:space-between}.msg-template>div[data-v-8e5e4859],.msg-template textarea[data-v-8e5e4859]{flex:1;border:var(--8d8ff372);border-radius:4px;padding:8px;height:100%;min-height:50px;width:calc(100% - 16px)}.msg-template .left-template-tag div[data-v-8e5e4859]{display:inline-flex;align-items:center;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;flex-wrap:wrap;cursor:pointer;user-select:none;padding:3px 8px;width:100px;border-radius:4px;background:#edebeb;margin-right:8px;margin-bottom:8px;height:24px;color:#464646}.msg-template .right-template[data-v-8e5e4859]{background:rgba(255,255,255,0)}.msg-template .right-template[data-v-8e5e4859]:focus-visible{outline:none}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "iking-template-inset",
3
3
  "private": false,
4
- "version": "0.0.3",
4
+ "version": "0.0.5",
5
5
  "main": "./dist/ikingtemplateinset.umd.js",
6
6
  "module": "./dist/ikingtemplateinset.es.js",
7
7
  "author": "金合研究院",