@shenjipo/mention-vue2 2.2.0 → 2.3.0
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.
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +153 -126
- package/package.json +10 -2
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";var $=Object.defineProperty;var y=Object.getOwnPropertySymbols;var q=Object.prototype.hasOwnProperty,b=Object.prototype.propertyIsEnumerable;var h=(n,e,t)=>e in n?$(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,M=(n,e)=>{for(var t in e||(e={}))q.call(e,t)&&h(n,t,e[t]);if(y)for(var t of y(e))b.call(e,t)&&h(n,t,e[t]);return n};var C=(n,e,t)=>new Promise((l,u)=>{var a=o=>{try{f(t.next(o))}catch(i){u(i)}},r=o=>{try{f(t.throw(o))}catch(i){u(i)}},f=o=>o.done?l(o.value):Promise.resolve(o.value).then(a,r);f((t=t.apply(n,e)).next())});Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const R=require("@shenjipo/mention-editor"),s=require("vue-demi"),g=require("@floating-ui/dom"),k=n=>n&&typeof n=="object"&&"default"in n?n:{default:n},w=k(R);function p(n,e,t,l,u,a,r,f){var o=typeof n=="function"?n.options:n;e&&(o.render=e,o.staticRenderFns=t,o._compiled=!0),l&&(o.functional=!0),a&&(o._scopeId="data-v-"+a);var i;if(r?(i=function(c){c=c||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!c&&typeof __VUE_SSR_CONTEXT__!="undefined"&&(c=__VUE_SSR_CONTEXT__),u&&u.call(this,c),c&&c._registeredComponents&&c._registeredComponents.add(r)},o._ssrRegister=i):u&&(i=f?function(){u.call(this,(o.functional?this.parent:this).$root.$options.shadowRoot)}:u),i)if(o.functional){o._injectStyles=i;var d=o.render;o.render=function(v,m){return i.call(m),d(v,m)}}else{var _=o.beforeCreate;o.beforeCreate=_?[].concat(_,i):[i]}return{exports:n,options:o}}const E={name:"MEditorVue2",props:{modelValue:{type:String,default:""},options:{type:Object,default:()=>({placeholder:"请输入内容,可粘贴图片到此处,按下/唤起快捷指令,"})}},emits:["update:modelValue","fileReject","imageInput"],setup(n,{emit:e,expose:t}){const l=s.ref(null),u=s.ref(null);s.provide("editor",l),s.onMounted(()=>{u.value&&(l.value=new w.default({element:u.value,placeholder:n.options.placeholder,onChange:r=>{e("update:modelValue",r)},onFileReject:r=>{e("fileReject",r)},onImageInput:r=>{e("imageInput",r)}}))});const a=()=>{l.value.clear(),e("update:modelValue","")};return t({editor:l,clear:a}),{editor:l,editorRef:u,clear:a}}};var x=function(){var e=this,t=e._self._c;return t("div",{staticClass:"mention-editor-wrapper"},[e._t("header"),t("div",{ref:"editorRef",staticClass:"mention-editor"},[e.editor?e._t("default"):e._e()],2),e._t("footer")],2)},F=[],Q=p(E,x,F,!1,null,"8f854357",null,null);const S=Q.exports;const U={name:"SuggestionMenu",props:{items:{type:Array,required:!0},loadingState:{type:String,default:"idle"},selectedIndex:{type:Number,default:0}},methods:{handleItemClick(n){this.$emit("itemClick",n)}}};var D=function(){var e=this,t=e._self._c;return t("div",{staticClass:"bn-suggestion-menu"},[e.items.length?e._l(e.items,function(l,u){return t("div",{key:l.id,staticClass:"suggestion-menu-item",class:{active:u===e.selectedIndex},on:{mousedown:function(a){return a.preventDefault(),e.handleItemClick(l)}}},[e._v(" "+e._s(l.label)+" ")])}):t("div",{staticClass:"suggestion-menu-item disabled"},[e._v("无数据")])],2)},V=[],A=p(U,D,V,!1,null,"af9205e7",null,null);const j=A.exports;function L(n,e,t,l){const u=s.ref(0),a=r=>r.key==="ArrowUp"?(r.preventDefault(),t.value&&t.value.length&&(u.value=(u.value-1+t.value.length)%t.value.length),!0):r.key==="ArrowDown"?(r.preventDefault(),t.value&&t.value.length&&(u.value=(u.value+1)%t.value.length),!0):r.key==="Enter"&&!r.isComposing?(r.preventDefault(),t.value&&t.value.length&&l&&l(t.value[u.value]),!0):!1;return s.onMounted(()=>{n&&n.domElement&&n.domElement.addEventListener("keydown",a,!0)}),s.onBeforeUnmount(()=>{n&&n.domElement&&n.domElement.removeEventListener("keydown",a,!0)}),s.watch(()=>e,()=>{u.value=0}),u}function N(n,e,t,l=8){const u=s.ref(0);return s.watch([n,e],([a,r])=>{r!=null&&(a&&a.length>0?u.value=r.length:r.length-u.value>l&&t())}),{lastUsefulQueryLength:u}}const T={name:"SuggestionMenuWrapper",components:{SuggestionMenu:j},props:{query:{type:String,required:!0},getItems:{type:Function,required:!0},onItemClick:{type:Function},closeMenu:{type:Function,required:!0},clearQuery:{type:Function,required:!0},insertMention:{type:Function,required:!0}},setup(n){const e=s.ref([]),t=s.ref("idle"),l=s.ref(""),u=s.inject("editor"),a=o=>{n.closeMenu(),n.clearQuery(),n.insertMention(o)},r=L(u.value,n.query,e,a);N(e,l,n.closeMenu);const f=()=>{const o=n.query;l.value=n.query,t.value="loading",n.getItems(n.query).then(i=>{l.value===o&&(e.value=i,t.value="loaded")})};return s.onMounted(f),s.watch(()=>n.query,()=>{f()}),{items:e,loadingState:t,selectedIndex:r,onItemClickInternal:a}}};var W=function(){var e=this,t=e._self._c;return t("SuggestionMenu",{attrs:{items:e.items,"loading-state":e.loadingState,"selected-index":e.selectedIndex},on:{itemClick:e.onItemClickInternal}})},O=[],P=p(T,W,O,!1,null,"e4189e8f",null,null);const B=P.exports;function z(n,e,t,l={}){const u=s.ref(null),a=s.ref(null),r=s.ref({});let f=null;s.watch(e,c=>{c&&(u.value={getBoundingClientRect:()=>c},o())},{immediate:!0}),s.watch(n,c=>C(this,null,function*(){if(!c){d();return}yield s.nextTick(),!(!u.value||!a.value)&&(o(),i())}));const o=()=>{const c=u.value,v=a.value;!c||!v||g.computePosition(c,v,{placement:l.placement||"bottom-start",middleware:[g.offset(l.offset||8),g.flip(),g.shift({padding:8})]}).then(({x:m,y:I})=>{r.value={position:"absolute",left:`${m}px`,top:`${I}px`}})};function i(){!u.value||!a.value||(f=g.autoUpdate(u.value,a.value,o))}function d(){f&&(f(),f=null)}const _=s.computed(()=>M({display:"flex",zIndex:t},r.value));return{floatingRef:a,style:_}}const K={name:"SuggestionMenuController",components:{SuggestionMenuWrapper:B},props:{triggerCharacter:{type:String,required:!0},minQueryLength:{type:Number},getItems:{type:Function,required:!0},onItemClick:{type:Function}},setup(n){const e=s.inject("editor"),t=s.ref(null),l=s.computed(()=>{var _;const d=((_=t.value)==null?void 0:_.show)&&(!n.minQueryLength||t.value.ignoreQueryLength||!t.value.query.startsWith(" ")&&t.value.query.length>=n.minQueryLength);return d!=null?d:!1}),{floatingRef:u,style:a}=z(()=>l.value,()=>{var d;return((d=t.value)==null?void 0:d.referencePos)||null},2e3,{placement:"bottom-start",middleware:[g.offset(10),g.flip({mainAxis:!0,crossAxis:!1}),g.shift(),g.size({apply({availableHeight:d,elements:_}){Object.assign(_.floating.style,{maxHeight:`${d-10}px`})}})],onDismiss(){}});let r=null;return s.onMounted(()=>{r=e.value.suggestionMenus.onUpdate(n.triggerCharacter,d=>{t.value=d})}),s.onBeforeUnmount(()=>{r&&r()}),{state:t,floatingRef:u,style:a,showDom:l,closeMenu:()=>{e.value.suggestionMenus.closeMenu()},clearQuery:()=>{e.value.suggestionMenus.clearQuery()},insertMention:d=>{e.value.suggestionMenus.insertMention(d)}}}};var X=function(){var e=this,t=e._self._c;return e.showDom?t("div",{ref:"floatingRef",style:e.style},[t("SuggestionMenuWrapper",{attrs:{query:e.state.query,getItems:e.getItems,onItemClick:e.onItemClick,closeMenu:e.closeMenu,clearQuery:e.clearQuery,insertMention:e.insertMention}})],1):e._e()},H=[],G=p(K,X,H,!1,null,"f5b73a66",null,null);const J=G.exports;exports.MEditorVue2=S;exports.SuggestionMenuController=J;exports.default=S;
|
package/dist/index.esm.js
CHANGED
|
@@ -1,36 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
var E = Object.defineProperty;
|
|
2
|
+
var h = Object.getOwnPropertySymbols;
|
|
3
|
+
var w = Object.prototype.hasOwnProperty, F = Object.prototype.propertyIsEnumerable;
|
|
4
|
+
var M = (n, e, t) => e in n ? E(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, C = (n, e) => {
|
|
5
|
+
for (var t in e || (e = {}))
|
|
6
|
+
w.call(e, t) && M(n, t, e[t]);
|
|
7
|
+
if (h)
|
|
8
|
+
for (var t of h(e))
|
|
9
|
+
F.call(e, t) && M(n, t, e[t]);
|
|
10
|
+
return n;
|
|
11
|
+
};
|
|
12
|
+
var I = (n, e, t) => new Promise((o, u) => {
|
|
13
|
+
var s = (l) => {
|
|
14
|
+
try {
|
|
15
|
+
d(t.next(l));
|
|
16
|
+
} catch (a) {
|
|
17
|
+
u(a);
|
|
18
|
+
}
|
|
19
|
+
}, r = (l) => {
|
|
20
|
+
try {
|
|
21
|
+
d(t.throw(l));
|
|
22
|
+
} catch (a) {
|
|
23
|
+
u(a);
|
|
24
|
+
}
|
|
25
|
+
}, d = (l) => l.done ? o(l.value) : Promise.resolve(l.value).then(s, r);
|
|
26
|
+
d((t = t.apply(n, e)).next());
|
|
27
|
+
});
|
|
28
|
+
import Q from "@shenjipo/mention-editor";
|
|
29
|
+
import { ref as f, provide as U, onMounted as p, onBeforeUnmount as S, watch as g, inject as $, nextTick as V, computed as R } from "vue-demi";
|
|
30
|
+
import { computePosition as A, offset as q, flip as b, shift as k, autoUpdate as D, size as L } from "@floating-ui/dom";
|
|
31
|
+
function y(n, e, t, o, u, s, r, d) {
|
|
32
|
+
var l = typeof n == "function" ? n.options : n;
|
|
33
|
+
e && (l.render = e, l.staticRenderFns = t, l._compiled = !0), o && (l.functional = !0), s && (l._scopeId = "data-v-" + s);
|
|
34
|
+
var a;
|
|
35
|
+
if (r ? (a = function(i) {
|
|
36
|
+
i = i || // cached call
|
|
10
37
|
this.$vnode && this.$vnode.ssrContext || // stateful
|
|
11
|
-
this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext, !
|
|
12
|
-
},
|
|
38
|
+
this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext, !i && typeof __VUE_SSR_CONTEXT__ != "undefined" && (i = __VUE_SSR_CONTEXT__), u && u.call(this, i), i && i._registeredComponents && i._registeredComponents.add(r);
|
|
39
|
+
}, l._ssrRegister = a) : u && (a = d ? function() {
|
|
13
40
|
u.call(
|
|
14
41
|
this,
|
|
15
|
-
(
|
|
42
|
+
(l.functional ? this.parent : this).$root.$options.shadowRoot
|
|
16
43
|
);
|
|
17
|
-
} : u),
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
var c =
|
|
21
|
-
|
|
22
|
-
return
|
|
44
|
+
} : u), a)
|
|
45
|
+
if (l.functional) {
|
|
46
|
+
l._injectStyles = a;
|
|
47
|
+
var c = l.render;
|
|
48
|
+
l.render = function(v, m) {
|
|
49
|
+
return a.call(m), c(v, m);
|
|
23
50
|
};
|
|
24
51
|
} else {
|
|
25
|
-
var _ =
|
|
26
|
-
|
|
52
|
+
var _ = l.beforeCreate;
|
|
53
|
+
l.beforeCreate = _ ? [].concat(_, a) : [a];
|
|
27
54
|
}
|
|
28
55
|
return {
|
|
29
56
|
exports: n,
|
|
30
|
-
options:
|
|
57
|
+
options: l
|
|
31
58
|
};
|
|
32
59
|
}
|
|
33
|
-
const
|
|
60
|
+
const N = {
|
|
34
61
|
name: "MEditorVue2",
|
|
35
62
|
props: {
|
|
36
63
|
modelValue: { type: String, default: "" },
|
|
@@ -43,9 +70,9 @@ const F = {
|
|
|
43
70
|
},
|
|
44
71
|
emits: ["update:modelValue", "fileReject", "imageInput"],
|
|
45
72
|
setup(n, { emit: e, expose: t }) {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
u.value && (
|
|
73
|
+
const o = f(null), u = f(null);
|
|
74
|
+
U("editor", o), p(() => {
|
|
75
|
+
u.value && (o.value = new Q({
|
|
49
76
|
element: u.value,
|
|
50
77
|
placeholder: n.options.placeholder,
|
|
51
78
|
onChange: (r) => {
|
|
@@ -59,31 +86,31 @@ const F = {
|
|
|
59
86
|
}
|
|
60
87
|
}));
|
|
61
88
|
});
|
|
62
|
-
const
|
|
63
|
-
|
|
89
|
+
const s = () => {
|
|
90
|
+
o.value.clear(), e("update:modelValue", "");
|
|
64
91
|
};
|
|
65
|
-
return t({ editor:
|
|
66
|
-
editor:
|
|
92
|
+
return t({ editor: o, clear: s }), {
|
|
93
|
+
editor: o,
|
|
67
94
|
editorRef: u,
|
|
68
|
-
clear:
|
|
95
|
+
clear: s
|
|
69
96
|
};
|
|
70
97
|
}
|
|
71
98
|
};
|
|
72
|
-
var
|
|
99
|
+
var W = function() {
|
|
73
100
|
var e = this, t = e._self._c;
|
|
74
101
|
return t("div", { staticClass: "mention-editor-wrapper" }, [e._t("header"), t("div", { ref: "editorRef", staticClass: "mention-editor" }, [e.editor ? e._t("default") : e._e()], 2), e._t("footer")], 2);
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
102
|
+
}, T = [], j = /* @__PURE__ */ y(
|
|
103
|
+
N,
|
|
104
|
+
W,
|
|
105
|
+
T,
|
|
79
106
|
!1,
|
|
80
107
|
null,
|
|
81
108
|
"8f854357",
|
|
82
109
|
null,
|
|
83
110
|
null
|
|
84
111
|
);
|
|
85
|
-
const
|
|
86
|
-
const
|
|
112
|
+
const ce = j.exports;
|
|
113
|
+
const O = {
|
|
87
114
|
name: "SuggestionMenu",
|
|
88
115
|
props: {
|
|
89
116
|
items: { type: Array, required: !0 },
|
|
@@ -96,30 +123,30 @@ const A = {
|
|
|
96
123
|
}
|
|
97
124
|
}
|
|
98
125
|
};
|
|
99
|
-
var
|
|
126
|
+
var P = function() {
|
|
100
127
|
var e = this, t = e._self._c;
|
|
101
|
-
return t("div", { staticClass: "bn-suggestion-menu" }, [e.items.length ? e._l(e.items, function(
|
|
102
|
-
return t("div", { key:
|
|
103
|
-
return
|
|
104
|
-
} } }, [e._v(" " + e._s(
|
|
128
|
+
return t("div", { staticClass: "bn-suggestion-menu" }, [e.items.length ? e._l(e.items, function(o, u) {
|
|
129
|
+
return t("div", { key: o.id, staticClass: "suggestion-menu-item", class: { active: u === e.selectedIndex }, on: { mousedown: function(s) {
|
|
130
|
+
return s.preventDefault(), e.handleItemClick(o);
|
|
131
|
+
} } }, [e._v(" " + e._s(o.label) + " ")]);
|
|
105
132
|
}) : t("div", { staticClass: "suggestion-menu-item disabled" }, [e._v("无数据")])], 2);
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
133
|
+
}, z = [], B = /* @__PURE__ */ y(
|
|
134
|
+
O,
|
|
135
|
+
P,
|
|
136
|
+
z,
|
|
110
137
|
!1,
|
|
111
138
|
null,
|
|
112
139
|
"af9205e7",
|
|
113
140
|
null,
|
|
114
141
|
null
|
|
115
142
|
);
|
|
116
|
-
const
|
|
117
|
-
function
|
|
118
|
-
const u =
|
|
143
|
+
const K = B.exports;
|
|
144
|
+
function X(n, e, t, o) {
|
|
145
|
+
const u = f(0), s = (r) => r.key === "ArrowUp" ? (r.preventDefault(), t.value && t.value.length && (u.value = (u.value - 1 + t.value.length) % t.value.length), !0) : r.key === "ArrowDown" ? (r.preventDefault(), t.value && t.value.length && (u.value = (u.value + 1) % t.value.length), !0) : r.key === "Enter" && !r.isComposing ? (r.preventDefault(), t.value && t.value.length && o && o(t.value[u.value]), !0) : !1;
|
|
119
146
|
return p(() => {
|
|
120
|
-
n && n.domElement && n.domElement.addEventListener("keydown",
|
|
121
|
-
}),
|
|
122
|
-
n && n.domElement && n.domElement.removeEventListener("keydown",
|
|
147
|
+
n && n.domElement && n.domElement.addEventListener("keydown", s, !0);
|
|
148
|
+
}), S(() => {
|
|
149
|
+
n && n.domElement && n.domElement.removeEventListener("keydown", s, !0);
|
|
123
150
|
}), g(
|
|
124
151
|
() => e,
|
|
125
152
|
() => {
|
|
@@ -127,21 +154,21 @@ function T(n, e, t, l) {
|
|
|
127
154
|
}
|
|
128
155
|
), u;
|
|
129
156
|
}
|
|
130
|
-
function
|
|
131
|
-
const u =
|
|
157
|
+
function H(n, e, t, o = 8) {
|
|
158
|
+
const u = f(0);
|
|
132
159
|
return g(
|
|
133
160
|
[n, e],
|
|
134
|
-
([
|
|
135
|
-
r != null && (
|
|
161
|
+
([s, r]) => {
|
|
162
|
+
r != null && (s && s.length > 0 ? u.value = r.length : r.length - u.value > o && t());
|
|
136
163
|
}
|
|
137
164
|
), {
|
|
138
165
|
lastUsefulQueryLength: u
|
|
139
166
|
};
|
|
140
167
|
}
|
|
141
|
-
const
|
|
168
|
+
const G = {
|
|
142
169
|
name: "SuggestionMenuWrapper",
|
|
143
170
|
components: {
|
|
144
|
-
SuggestionMenu:
|
|
171
|
+
SuggestionMenu: K
|
|
145
172
|
},
|
|
146
173
|
props: {
|
|
147
174
|
query: { type: String, required: !0 },
|
|
@@ -152,106 +179,105 @@ const O = {
|
|
|
152
179
|
insertMention: { type: Function, required: !0 }
|
|
153
180
|
},
|
|
154
181
|
setup(n) {
|
|
155
|
-
const e =
|
|
156
|
-
n.closeMenu(), n.clearQuery(), n.insertMention(
|
|
157
|
-
}, r =
|
|
182
|
+
const e = f([]), t = f("idle"), o = f(""), u = $("editor"), s = (l) => {
|
|
183
|
+
n.closeMenu(), n.clearQuery(), n.insertMention(l);
|
|
184
|
+
}, r = X(
|
|
158
185
|
u.value,
|
|
159
186
|
n.query,
|
|
160
187
|
e,
|
|
161
|
-
|
|
188
|
+
s
|
|
162
189
|
);
|
|
163
|
-
|
|
164
|
-
const
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
190
|
+
H(e, o, n.closeMenu);
|
|
191
|
+
const d = () => {
|
|
192
|
+
const l = n.query;
|
|
193
|
+
o.value = n.query, t.value = "loading", n.getItems(n.query).then((a) => {
|
|
194
|
+
o.value === l && (e.value = a, t.value = "loaded");
|
|
168
195
|
});
|
|
169
196
|
};
|
|
170
|
-
return p(
|
|
197
|
+
return p(d), g(
|
|
171
198
|
() => n.query,
|
|
172
199
|
() => {
|
|
173
|
-
|
|
200
|
+
d();
|
|
174
201
|
}
|
|
175
202
|
), {
|
|
176
203
|
items: e,
|
|
177
204
|
loadingState: t,
|
|
178
205
|
selectedIndex: r,
|
|
179
|
-
onItemClickInternal:
|
|
206
|
+
onItemClickInternal: s
|
|
180
207
|
};
|
|
181
208
|
}
|
|
182
209
|
};
|
|
183
|
-
var
|
|
210
|
+
var J = function() {
|
|
184
211
|
var e = this, t = e._self._c;
|
|
185
212
|
return t("SuggestionMenu", { attrs: { items: e.items, "loading-state": e.loadingState, "selected-index": e.selectedIndex }, on: { itemClick: e.onItemClickInternal } });
|
|
186
|
-
},
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
213
|
+
}, Y = [], Z = /* @__PURE__ */ y(
|
|
214
|
+
G,
|
|
215
|
+
J,
|
|
216
|
+
Y,
|
|
190
217
|
!1,
|
|
191
218
|
null,
|
|
192
219
|
"e4189e8f",
|
|
193
220
|
null,
|
|
194
221
|
null
|
|
195
222
|
);
|
|
196
|
-
const
|
|
197
|
-
function
|
|
198
|
-
const u =
|
|
199
|
-
let
|
|
223
|
+
const ee = Z.exports;
|
|
224
|
+
function te(n, e, t, o = {}) {
|
|
225
|
+
const u = f(null), s = f(null), r = f({});
|
|
226
|
+
let d = null;
|
|
200
227
|
g(
|
|
201
228
|
e,
|
|
202
|
-
(
|
|
203
|
-
|
|
204
|
-
getBoundingClientRect: () =>
|
|
205
|
-
},
|
|
229
|
+
(i) => {
|
|
230
|
+
i && (u.value = {
|
|
231
|
+
getBoundingClientRect: () => i
|
|
232
|
+
}, l());
|
|
206
233
|
},
|
|
207
234
|
{ immediate: !0 }
|
|
208
235
|
), g(
|
|
209
236
|
n,
|
|
210
|
-
|
|
211
|
-
if (!
|
|
237
|
+
(i) => I(this, null, function* () {
|
|
238
|
+
if (!i) {
|
|
212
239
|
c();
|
|
213
240
|
return;
|
|
214
241
|
}
|
|
215
|
-
|
|
216
|
-
}
|
|
242
|
+
yield V(), !(!u.value || !s.value) && (l(), a());
|
|
243
|
+
})
|
|
217
244
|
);
|
|
218
|
-
const
|
|
219
|
-
const
|
|
220
|
-
!
|
|
221
|
-
placement:
|
|
245
|
+
const l = () => {
|
|
246
|
+
const i = u.value, v = s.value;
|
|
247
|
+
!i || !v || A(i, v, {
|
|
248
|
+
placement: o.placement || "bottom-start",
|
|
222
249
|
middleware: [
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
250
|
+
q(o.offset || 8),
|
|
251
|
+
b(),
|
|
252
|
+
k({ padding: 8 })
|
|
226
253
|
]
|
|
227
|
-
}).then(({ x: m, y:
|
|
254
|
+
}).then(({ x: m, y: x }) => {
|
|
228
255
|
r.value = {
|
|
229
256
|
position: "absolute",
|
|
230
257
|
left: `${m}px`,
|
|
231
|
-
top: `${
|
|
258
|
+
top: `${x}px`
|
|
232
259
|
};
|
|
233
260
|
});
|
|
234
261
|
};
|
|
235
|
-
function
|
|
236
|
-
!u.value || !
|
|
262
|
+
function a() {
|
|
263
|
+
!u.value || !s.value || (d = D(u.value, s.value, l));
|
|
237
264
|
}
|
|
238
265
|
function c() {
|
|
239
|
-
|
|
266
|
+
d && (d(), d = null);
|
|
240
267
|
}
|
|
241
|
-
const _ =
|
|
268
|
+
const _ = R(() => C({
|
|
242
269
|
display: "flex",
|
|
243
|
-
zIndex: t
|
|
244
|
-
|
|
245
|
-
}));
|
|
270
|
+
zIndex: t
|
|
271
|
+
}, r.value));
|
|
246
272
|
return {
|
|
247
|
-
floatingRef:
|
|
273
|
+
floatingRef: s,
|
|
248
274
|
style: _
|
|
249
275
|
};
|
|
250
276
|
}
|
|
251
|
-
const
|
|
277
|
+
const ne = {
|
|
252
278
|
name: "SuggestionMenuController",
|
|
253
279
|
components: {
|
|
254
|
-
SuggestionMenuWrapper:
|
|
280
|
+
SuggestionMenuWrapper: ee
|
|
255
281
|
},
|
|
256
282
|
props: {
|
|
257
283
|
triggerCharacter: { type: String, required: !0 },
|
|
@@ -260,11 +286,12 @@ const H = {
|
|
|
260
286
|
onItemClick: { type: Function }
|
|
261
287
|
},
|
|
262
288
|
setup(n) {
|
|
263
|
-
const e =
|
|
289
|
+
const e = $("editor"), t = f(null), o = R(() => {
|
|
264
290
|
var _;
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
291
|
+
const c = ((_ = t.value) == null ? void 0 : _.show) && (!n.minQueryLength || t.value.ignoreQueryLength || !t.value.query.startsWith(" ") && t.value.query.length >= n.minQueryLength);
|
|
292
|
+
return c != null ? c : !1;
|
|
293
|
+
}), { floatingRef: u, style: s } = te(
|
|
294
|
+
() => o.value,
|
|
268
295
|
() => {
|
|
269
296
|
var c;
|
|
270
297
|
return ((c = t.value) == null ? void 0 : c.referencePos) || null;
|
|
@@ -273,10 +300,10 @@ const H = {
|
|
|
273
300
|
{
|
|
274
301
|
placement: "bottom-start",
|
|
275
302
|
middleware: [
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
303
|
+
q(10),
|
|
304
|
+
b({ mainAxis: !0, crossAxis: !1 }),
|
|
305
|
+
k(),
|
|
306
|
+
L({
|
|
280
307
|
apply({ availableHeight: c, elements: _ }) {
|
|
281
308
|
Object.assign(_.floating.style, {
|
|
282
309
|
maxHeight: `${c - 10}px`
|
|
@@ -296,13 +323,13 @@ const H = {
|
|
|
296
323
|
t.value = c;
|
|
297
324
|
}
|
|
298
325
|
);
|
|
299
|
-
}),
|
|
326
|
+
}), S(() => {
|
|
300
327
|
r && r();
|
|
301
328
|
}), {
|
|
302
329
|
state: t,
|
|
303
330
|
floatingRef: u,
|
|
304
|
-
style:
|
|
305
|
-
showDom:
|
|
331
|
+
style: s,
|
|
332
|
+
showDom: o,
|
|
306
333
|
closeMenu: () => {
|
|
307
334
|
e.value.suggestionMenus.closeMenu();
|
|
308
335
|
},
|
|
@@ -315,22 +342,22 @@ const H = {
|
|
|
315
342
|
};
|
|
316
343
|
}
|
|
317
344
|
};
|
|
318
|
-
var
|
|
345
|
+
var ue = function() {
|
|
319
346
|
var e = this, t = e._self._c;
|
|
320
347
|
return e.showDom ? t("div", { ref: "floatingRef", style: e.style }, [t("SuggestionMenuWrapper", { attrs: { query: e.state.query, getItems: e.getItems, onItemClick: e.onItemClick, closeMenu: e.closeMenu, clearQuery: e.clearQuery, insertMention: e.insertMention } })], 1) : e._e();
|
|
321
|
-
},
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
348
|
+
}, re = [], le = /* @__PURE__ */ y(
|
|
349
|
+
ne,
|
|
350
|
+
ue,
|
|
351
|
+
re,
|
|
325
352
|
!1,
|
|
326
353
|
null,
|
|
327
354
|
"f5b73a66",
|
|
328
355
|
null,
|
|
329
356
|
null
|
|
330
357
|
);
|
|
331
|
-
const
|
|
358
|
+
const de = le.exports;
|
|
332
359
|
export {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
360
|
+
ce as MEditorVue2,
|
|
361
|
+
de as SuggestionMenuController,
|
|
362
|
+
ce as default
|
|
336
363
|
};
|
package/package.json
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shenjipo/mention-vue2",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"main": "dist/index.cjs.js",
|
|
5
5
|
"module": "dist/index.esm.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"style": "dist/index.css",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.esm.js",
|
|
11
|
+
"require": "./dist/index.cjs.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
},
|
|
14
|
+
"./dist/index.css": "./dist/index.css"
|
|
15
|
+
},
|
|
8
16
|
"files": [
|
|
9
17
|
"dist"
|
|
10
18
|
],
|
|
@@ -15,7 +23,7 @@
|
|
|
15
23
|
"@floating-ui/dom": "^1.1.9",
|
|
16
24
|
"vue": "^2.7.7",
|
|
17
25
|
"vue-demi": "^0.14.10",
|
|
18
|
-
"@shenjipo/mention-editor": "2.
|
|
26
|
+
"@shenjipo/mention-editor": "2.3.0"
|
|
19
27
|
},
|
|
20
28
|
"devDependencies": {
|
|
21
29
|
"@types/node": "^16.11.45",
|