iking-template-inset 0.0.4 → 0.0.6

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-28 11:40:01
7
+ * @LastEditTime : 2022-11-28 12:09:42
8
8
  */
9
9
  /// <reference types="vite/client" />
10
10
 
@@ -23,6 +23,8 @@ declare module 'iking-template-inset' {
23
23
  border: string;
24
24
  // 排列方式
25
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 h, useCssVars as b, ref as i, watch as k, openBlock as u, createElementBlock as c, normalizeStyle as $, createElementVNode as v, Fragment as f, renderList as x, renderSlot as I, createTextVNode as S, toDisplayString as w, withKeys as N, withModifiers as T, nextTick as V } from "vue";
2
- const C = { class: "left-template-tag" }, L = ["onClick"], A = /* @__PURE__ */ h({
1
+ import { defineComponent as k, useCssVars as x, ref as i, watch as S, openBlock as c, createElementBlock as d, normalizeStyle as m, createElementVNode as f, Fragment as y, renderList as b, renderSlot as A, createTextVNode as w, toDisplayString as I, withDirectives as V, withKeys as B, withModifiers as C, vModelText as z } from "vue";
2
+ const F = ["onClick"], K = ["placeholder"], N = /* @__PURE__ */ k({
3
3
  __name: "App",
4
4
  props: {
5
5
  modelVlaue: {
@@ -19,77 +19,89 @@ const C = { class: "left-template-tag" }, L = ["onClick"], A = /* @__PURE__ */ h
19
19
  horizontal: {
20
20
  type: Boolean,
21
21
  default: !0
22
+ },
23
+ placeholder: {
24
+ type: String,
25
+ default: "\u8BF7\u8F93\u5165\u6216\u70B9\u51FB\u63D2\u5165\u53C2\u6570"
22
26
  }
23
27
  },
24
- emits: ["update:modelVlaue"],
25
- setup(n, { emit: d }) {
26
- const a = n;
27
- b((e) => ({
28
- "47b9f5d6": n.border
28
+ emits: ["update:modelVlaue", "origional"],
29
+ setup(l, { emit: s }) {
30
+ const r = l;
31
+ x((e) => ({
32
+ "7ec6a286": l.border
29
33
  }));
30
- const l = i(-1), r = i(), p = () => {
31
- const e = document.getSelection();
32
- l.value = e != null && e.baseNode ? e != null && e.baseOffset ? e == null ? void 0 : e.baseOffset : 0 : -1;
33
- }, t = i(""), _ = i("");
34
- k(t, (e) => {
35
- d("update:modelVlaue", e);
34
+ const o = i(-1), u = () => {
35
+ var t;
36
+ const e = (t = p.value) == null ? void 0 : t.selectionStart;
37
+ o.value = e ? e || 0 : -1;
38
+ }, a = i(""), g = i(""), p = i(null), h = /【\S.*?\$/g;
39
+ S(a, (e) => {
40
+ s("update:modelVlaue", e.replaceAll(h, "$").replaceAll("\u3011", "")), s("origional", e);
36
41
  });
37
- const y = (e) => {
38
- const o = document.getSelection();
39
- p(), V(() => {
40
- t.value = e.target.innerHTML, _.value = o.baseNode.data;
41
- });
42
- }, g = (e) => {
43
- const o = `\u3010${e.label}\${${e.value}}\u3011`;
44
- if (l.value === -1)
45
- t.value = `${t.value}${o}`;
46
- else if (l.value === 0)
47
- t.value = `${o}${t.value}`;
42
+ const _ = (e) => {
43
+ var t;
44
+ u(), g.value = (t = p.value) == null ? void 0 : t.selectionStart;
45
+ }, $ = (e) => {
46
+ const t = `\u3010${e.label}\${${e.value}}\u3011`;
47
+ if (o.value === -1)
48
+ a.value = `${a.value}${t}`;
49
+ else if (o.value === 0)
50
+ a.value = `${t}${a.value}`;
48
51
  else {
49
- const s = t.value;
50
- t.value = s.substring(0, l.value) + o + s.substring(l.value);
52
+ const n = a.value;
53
+ a.value = n.substring(0, o.value) + t + n.substring(o.value);
51
54
  }
52
- r.value.innerHTML = t.value;
53
55
  };
54
- return (e, o) => (u(), c("div", {
56
+ return (e, t) => (c(), d("div", {
55
57
  class: "msg-template",
56
- style: $({ "flex-direction": a.horizontal ? "row" : "column", height: `${a.height}px` })
58
+ style: m({
59
+ "flex-direction": r.horizontal ? "row" : "column",
60
+ height: `${r.height}px`
61
+ })
57
62
  }, [
58
- v("div", C, [
59
- (u(!0), c(f, null, x(n.tagList, (s, m) => (u(), c("div", {
60
- onClick: (B) => g(s),
61
- key: m
63
+ f("div", {
64
+ class: "left-template-tag",
65
+ style: m({ "margin-right": r.horizontal ? "16px" : "0" })
66
+ }, [
67
+ (c(!0), d(y, null, b(l.tagList, (n, v) => (c(), d("div", {
68
+ onClick: (L) => $(n),
69
+ key: v
62
70
  }, [
63
- e.$slots.item ? I(e.$slots, "item", {
71
+ e.$slots.item ? A(e.$slots, "item", {
64
72
  key: 0,
65
- item: { ...s, index: m }
66
- }, void 0, !0) : (u(), c(f, { key: 1 }, [
67
- S(w(s.label), 1)
73
+ item: { ...n, index: v }
74
+ }, void 0, !0) : (c(), d(y, { key: 1 }, [
75
+ w(I(n.label), 1)
68
76
  ], 64))
69
- ], 8, L))), 128))
70
- ]),
71
- v("div", {
72
- ref_key: "insetDom",
73
- ref: r,
74
- class: "right-template",
75
- contenteditable: "",
76
- onKeydown: o[0] || (o[0] = N(T(() => {
77
+ ], 8, F))), 128))
78
+ ], 4),
79
+ V(f("textarea", {
80
+ ref_key: "refArea",
81
+ ref: p,
82
+ "onUpdate:modelValue": t[0] || (t[0] = (n) => a.value = n),
83
+ onKeyup: _,
84
+ onClick: u,
85
+ onKeydown: t[1] || (t[1] = B(C(() => {
77
86
  }, ["prevent"]), ["enter"])),
78
- onKeyup: y,
79
- onClick: p
80
- }, null, 544)
87
+ class: "right-template",
88
+ placeholder: l.placeholder
89
+ }, `
90
+ `, 40, K), [
91
+ [z, a.value]
92
+ ])
81
93
  ], 4));
82
94
  }
83
95
  });
84
- const K = (n, d) => {
85
- const a = n.__vccOpts || n;
86
- for (const [l, r] of d)
87
- a[l] = r;
88
- return a;
89
- }, z = /* @__PURE__ */ K(A, [["__scopeId", "data-v-dc887f16"]]), M = (n) => {
90
- n.component("IkingTemplateInset", z);
96
+ const T = (l, s) => {
97
+ const r = l.__vccOpts || l;
98
+ for (const [o, u] of s)
99
+ r[o] = u;
100
+ return r;
101
+ }, D = /* @__PURE__ */ T(N, [["__scopeId", "data-v-c0c17efa"]]), M = (l) => {
102
+ l.component("IkingTemplateInset", D);
91
103
  };
92
104
  export {
93
- z as default,
105
+ D as default,
94
106
  M as install
95
107
  };
@@ -1 +1,2 @@
1
- (function(o,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(o=typeof globalThis<"u"?globalThis:o||self,e(o.IkingTemplateInset={},o.Vue))})(this,function(o,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:()=>[]},border:{type:String,default:"1px solid #dcdfe6"},horizontal:{type:Boolean,default:!0}},emits:["update:modelVlaue"],setup(l,{emit:d}){const r=l;e.useCssVars(t=>({"47b9f5d6":l.border}));const a=e.ref(-1),c=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(""),h=e.ref("");e.watch(n,t=>{d("update:modelVlaue",t)});const k=t=>{const s=document.getSelection();f(),e.nextTick(()=>{n.value=t.target.innerHTML,h.value=s.baseNode.data})},b=t=>{const s=`\u3010${t.label}\${${t.value}}\u3011`;if(a.value===-1)n.value=`${n.value}${s}`;else if(a.value===0)n.value=`${s}${n.value}`;else{const i=n.value;n.value=i.substring(0,a.value)+s+i.substring(a.value)}c.value.innerHTML=n.value};return(t,s)=>(e.openBlock(),e.createElementBlock("div",{class:"msg-template",style:e.normalizeStyle({"flex-direction":r.horizontal?"row":"column",height:`${r.height}px`})},[e.createElementVNode("div",m,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.tagList,(i,u)=>(e.openBlock(),e.createElementBlock("div",{onClick:B=>b(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:c,class:"right-template",contenteditable:"",onKeydown:s[0]||(s[0]=e.withKeys(e.withModifiers(()=>{},["prevent"]),["enter"])),onKeyup:k,onClick:f},null,544)],4))}}),$="",x="",p=((l,d)=>{const r=l.__vccOpts||l;for(const[a,c]of d)r[a]=c;return r})(y,[["__scopeId","data-v-dc887f16"]]),g=l=>{l.component("IkingTemplateInset",p)};o.default=p,o.install=g,Object.defineProperties(o,{__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"],g=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","origional"],setup(n,{emit:c}){const i=n;e.useCssVars(t=>({"7ec6a286":n.border}));const s=e.ref(-1),d=()=>{var l;const t=(l=p.value)==null?void 0:l.selectionStart;s.value=t?t||0:-1},o=e.ref(""),h=e.ref(""),p=e.ref(null),k=/【\S.*?\$/g;e.watch(o,t=>{c("update:modelVlaue",t.replaceAll(k,"$").replaceAll("\u3011","")),c("origional",t)});const $=t=>{var l;d(),h.value=(l=p.value)==null?void 0:l.selectionStart},x=t=>{const l=`\u3010${t.label}\${${t.value}}\u3011`;if(s.value===-1)o.value=`${o.value}${l}`;else if(s.value===0)o.value=`${l}${o.value}`;else{const r=o.value;o.value=r.substring(0,s.value)+l+r.substring(s.value)}};return(t,l)=>(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:I=>x(r),key:f},[t.$slots.item?e.renderSlot(t.$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":l[0]||(l[0]=r=>o.value=r),onKeyup:$,onClick:d,onKeydown:l[1]||(l[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})(g,[["__scopeId","data-v-c0c17efa"]]),_=n=>{n.component("IkingTemplateInset",u)};a.default=u,a.install=_,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-dc887f16]{display:flex;width:100%;margin-bottom:8px;justify-content:space-between}.msg-template>div[data-v-dc887f16]{flex:1;border:var(--47b9f5d6);border-radius:4px;padding:8px;height:100%;min-height:50px;width:calc(100% - 16px)}.msg-template .left-template-tag[data-v-dc887f16]{display:flex;flex-wrap:wrap}.msg-template .left-template-tag div[data-v-dc887f16]{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-dc887f16]{counter-increment:true}.msg-template .right-template[data-v-dc887f16]: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-c0c17efa]{display:flex;width:100%;margin-bottom:8px;justify-content:space-between}.msg-template>div[data-v-c0c17efa],.msg-template textarea[data-v-c0c17efa]{flex:1;border:var(--7ec6a286);border-radius:4px;padding:8px;height:100%;min-height:50px;width:calc(100% - 16px)}.msg-template .left-template-tag div[data-v-c0c17efa]{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-c0c17efa]{background:rgba(255,255,255,0)}.msg-template .right-template[data-v-c0c17efa]: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.4",
4
+ "version": "0.0.6",
5
5
  "main": "./dist/ikingtemplateinset.umd.js",
6
6
  "module": "./dist/ikingtemplateinset.es.js",
7
7
  "author": "金合研究院",