iking-template-inset 0.0.1 → 0.0.3

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.
@@ -0,0 +1,86 @@
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({
3
+ __name: "App",
4
+ props: {
5
+ modelVlaue: {
6
+ type: String,
7
+ default: ""
8
+ },
9
+ height: { type: Number, default: 300 },
10
+ width: { type: Number, default: 600 },
11
+ tagList: {
12
+ type: Array,
13
+ default: () => []
14
+ },
15
+ class: {
16
+ type: String,
17
+ default: ""
18
+ }
19
+ },
20
+ 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);
28
+ });
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}`;
40
+ else {
41
+ const a = t.value;
42
+ t.value = a.substring(0, l.value) + n + a.substring(l.value);
43
+ }
44
+ i.value.innerHTML = t.value;
45
+ };
46
+ return (e, n) => (c(), u("div", {
47
+ class: h(`msg-template ${o.class}`)
48
+ }, [
49
+ v("div", C, [
50
+ (c(!0), u(_, null, $(s.tagList, (a, m) => (c(), u("div", {
51
+ onClick: (D) => g(a),
52
+ key: m
53
+ }, [
54
+ e.$slots.item ? I(e.$slots, "item", {
55
+ key: 0,
56
+ item: { ...a, index: m }
57
+ }, void 0, !0) : (c(), u(_, { key: 1 }, [
58
+ N(S(a.label), 1)
59
+ ], 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(() => {
68
+ }, ["prevent"]), ["enter"])),
69
+ onKeyup: y,
70
+ onClick: p
71
+ }, null, 544)
72
+ ], 2));
73
+ }
74
+ });
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);
82
+ };
83
+ export {
84
+ K as default,
85
+ O as install
86
+ };
@@ -0,0 +1 @@
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"}})});
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-18f96dd0]{display:flex}.msg-template>div[data-v-18f96dd0]{flex:1;border:1px solid #9d9393;border-radius:4px;padding:8px;margin-right:16px}.msg-template .left-template-tag[data-v-18f96dd0]{display:flex;flex-wrap:wrap}.msg-template .left-template-tag div[data-v-18f96dd0]{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-18f96dd0]{counter-increment:true}.msg-template .right-template[data-v-18f96dd0]: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-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}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "iking-template-inset",
3
3
  "private": false,
4
- "version": "0.0.1",
4
+ "version": "0.0.3",
5
5
  "main": "./dist/ikingtemplateinset.umd.js",
6
6
  "module": "./dist/ikingtemplateinset.es.js",
7
7
  "author": "金合研究院",
@@ -1,80 +0,0 @@
1
- import { defineComponent as g, ref as r, watch as k, openBlock as u, createElementBlock as c, createElementVNode as _, Fragment as m, renderList as h, renderSlot as b, createTextVNode as $, toDisplayString as I, withKeys as N, withModifiers as T, nextTick as w } from "vue";
2
- const x = { class: "msg-template" }, L = { class: "left-template-tag" }, S = ["onClick"], V = /* @__PURE__ */ g({
3
- __name: "App",
4
- props: {
5
- modelVlaue: {
6
- type: String,
7
- default: ""
8
- },
9
- height: { type: Number, default: 300 },
10
- width: { type: Number, default: 600 },
11
- tagList: {
12
- type: Array,
13
- default: () => []
14
- }
15
- },
16
- emits: ["update:modelVlaue"],
17
- setup(o, { emit: d }) {
18
- const n = r(-1), a = r(), i = () => {
19
- const e = document.getSelection();
20
- n.value = e != null && e.baseNode ? e != null && e.baseOffset ? e == null ? void 0 : e.baseOffset : 0 : -1;
21
- }, t = r(""), v = r("");
22
- k(t, (e) => {
23
- d("update:modelVlaue", e);
24
- });
25
- const f = (e) => {
26
- const s = document.getSelection();
27
- i(), w(() => {
28
- t.value = e.target.innerHTML, v.value = s.baseNode.data;
29
- });
30
- }, y = (e) => {
31
- const s = `\u3010${e.label}\${${e.value}}\u3011`;
32
- if (n.value === -1)
33
- t.value = `${t.value}${s}`;
34
- else if (n.value === 0)
35
- t.value = `${s}${t.value}`;
36
- else {
37
- const l = t.value;
38
- t.value = l.substring(0, n.value) + s + l.substring(n.value);
39
- }
40
- a.value.innerHTML = t.value;
41
- };
42
- return (e, s) => (u(), c("div", x, [
43
- _("div", L, [
44
- (u(!0), c(m, null, h(o.tagList, (l, p) => (u(), c("div", {
45
- onClick: (K) => y(l),
46
- key: p
47
- }, [
48
- e.$slots.item ? b(e.$slots, "item", {
49
- key: 0,
50
- item: { ...l, index: p }
51
- }, void 0, !0) : (u(), c(m, { key: 1 }, [
52
- $(I(l.label), 1)
53
- ], 64))
54
- ], 8, S))), 128))
55
- ]),
56
- _("div", {
57
- ref_key: "insetDom",
58
- ref: a,
59
- class: "right-template",
60
- contenteditable: "",
61
- onKeydown: s[0] || (s[0] = N(T(() => {
62
- }, ["prevent"]), ["enter"])),
63
- onKeyup: f,
64
- onClick: i
65
- }, null, 544)
66
- ]));
67
- }
68
- });
69
- const A = (o, d) => {
70
- const n = o.__vccOpts || o;
71
- for (const [a, i] of d)
72
- n[a] = i;
73
- return n;
74
- }, C = /* @__PURE__ */ A(V, [["__scopeId", "data-v-18f96dd0"]]), M = (o) => {
75
- o.component("IkingTemplateInset", C);
76
- };
77
- export {
78
- C as default,
79
- M as install
80
- };
@@ -1 +0,0 @@
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 f={class:"msg-template"},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:()=>[]}},emits:["update:modelVlaue"],setup(a,{emit:d}){const l=e.ref(-1),c=e.ref(),r=()=>{const t=document.getSelection();l.value=t!=null&&t.baseNode?t!=null&&t.baseOffset?t==null?void 0:t.baseOffset:0:-1},n=e.ref(""),g=e.ref("");e.watch(n,t=>{d("update:modelVlaue",t)});const h=t=>{const s=document.getSelection();r(),e.nextTick(()=>{n.value=t.target.innerHTML,g.value=s.baseNode.data})},b=t=>{const s=`\u3010${t.label}\${${t.value}}\u3011`;if(l.value===-1)n.value=`${n.value}${s}`;else if(l.value===0)n.value=`${s}${n.value}`;else{const i=n.value;n.value=i.substring(0,l.value)+s+i.substring(l.value)}c.value.innerHTML=n.value};return(t,s)=>(e.openBlock(),e.createElementBlock("div",f,[e.createElementVNode("div",m,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.tagList,(i,u)=>(e.openBlock(),e.createElementBlock("div",{onClick:I=>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:h,onClick:r},null,544)]))}}),v="",T="",p=((a,d)=>{const l=a.__vccOpts||a;for(const[c,r]of d)l[c]=r;return l})(y,[["__scopeId","data-v-18f96dd0"]]),k=a=>{a.component("IkingTemplateInset",p)};o.default=p,o.install=k,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});