@shenjipo/mention-vue2 2.3.0 → 2.5.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 CHANGED
@@ -1 +1 @@
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;
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 i=o=>{try{f(t.next(o))}catch(a){u(a)}},r=o=>{try{f(t.throw(o))}catch(a){u(a)}},f=o=>o.done?l(o.value):Promise.resolve(o.value).then(i,r);f((t=t.apply(n,e)).next())});Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const k=require("@shenjipo/mention-editor"),s=require("vue-demi"),v=require("@floating-ui/dom"),w=n=>n&&typeof n=="object"&&"default"in n?n:{default:n},E=w(k);function m(n,e,t,l,u,i,r,f){var o=typeof n=="function"?n.options:n;e&&(o.render=e,o.staticRenderFns=t,o._compiled=!0),l&&(o.functional=!0),i&&(o._scopeId="data-v-"+i);var a;if(r?(a=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=a):u&&(a=f?function(){u.call(this,(o.functional?this.parent:this).$root.$options.shadowRoot)}:u),a)if(o.functional){o._injectStyles=a;var d=o.render;o.render=function(g,p){return a.call(p),d(g,p)}}else{var _=o.beforeCreate;o.beforeCreate=_?[].concat(_,a):[a]}return{exports:n,options:o}}const R={name:"MEditorVue2",props:{modelValue:{type:String,default:""},options:{type:Object,default:()=>({placeholder:"请输入内容,可粘贴图片到此处,按下/唤起快捷指令,"})}},emits:["input","fileReject","imageInput","deleteMention"],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 E.default({element:u.value,placeholder:n.options.placeholder,onChange:r=>{e("input",r)},onFileInput:r=>{e("fileInput",r)},onMentionDelete(r){e("deleteMention",r)}}))});const i=()=>{l.value.clear(),e("update:modelValue","")};return t({editor:l,clear:i}),{editor:l,editorRef:u,clear:i}}};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=m(R,x,F,!1,null,"3a09ec83",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(i){return i.preventDefault(),e.handleItemClick(l)}}},[e._v(" "+e._s(l.label)+" ")])}):t("div",{staticClass:"suggestion-menu-item disabled"},[e._v("无数据")])],2)},A=[],V=m(U,D,A,!1,null,"af9205e7",null,null);const L=V.exports;function N(n,e,t,l){const u=s.ref(0),i=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",i,!0)}),s.onBeforeUnmount(()=>{n&&n.domElement&&n.domElement.removeEventListener("keydown",i,!0)}),s.watch(()=>e,()=>{u.value=0}),u}function T(n,e,t,l=8){const u=s.ref(0);return s.watch([n,e],([i,r])=>{r!=null&&(i&&i.length>0?u.value=r.length:r.length-u.value>l&&t())}),{lastUsefulQueryLength:u}}const W={name:"SuggestionMenuWrapper",components:{SuggestionMenu:L},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"),i=o=>{n.closeMenu(),n.clearQuery(),n.insertMention(o)},r=N(u.value,n.query,e,i);T(e,l,n.closeMenu);const f=()=>{const o=n.query;l.value=n.query,t.value="loading",n.getItems(n.query).then(a=>{l.value===o&&(e.value=a,t.value="loaded")})};return s.onMounted(f),s.watch(()=>n.query,()=>{f()}),{items:e,loadingState:t,selectedIndex:r,onItemClickInternal:i}}};var j=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=m(W,j,O,!1,null,"e4189e8f",null,null);const B=P.exports;function z(n,e,t,l={}){const u=s.ref(null),i=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||!i.value)&&(o(),a())}));const o=()=>{const c=u.value,g=i.value;!c||!g||v.computePosition(c,g,{placement:l.placement||"bottom-start",middleware:[v.offset(l.offset||8),v.flip(),v.shift({padding:8})]}).then(({x:p,y:I})=>{r.value={position:"absolute",left:`${p}px`,top:`${I}px`}})};function a(){!u.value||!i.value||(f=v.autoUpdate(u.value,i.value,o))}function d(){f&&(f(),f=null)}const _=s.computed(()=>M({display:"flex",zIndex:t},r.value));return{floatingRef:i,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:i}=z(()=>l.value,()=>{var d;return((d=t.value)==null?void 0:d.referencePos)||null},2e3,{placement:"bottom-start",middleware:[v.offset(10),v.flip({mainAxis:!0,crossAxis:!1}),v.shift(),v.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:i,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=m(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
@@ -13,51 +13,51 @@ var I = (n, e, t) => new Promise((o, u) => {
13
13
  var s = (l) => {
14
14
  try {
15
15
  d(t.next(l));
16
- } catch (a) {
17
- u(a);
16
+ } catch (i) {
17
+ u(i);
18
18
  }
19
19
  }, r = (l) => {
20
20
  try {
21
21
  d(t.throw(l));
22
- } catch (a) {
23
- u(a);
22
+ } catch (i) {
23
+ u(i);
24
24
  }
25
25
  }, d = (l) => l.done ? o(l.value) : Promise.resolve(l.value).then(s, r);
26
26
  d((t = t.apply(n, e)).next());
27
27
  });
28
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";
29
+ import { ref as f, provide as U, onMounted as m, onBeforeUnmount as S, watch as v, inject as $, nextTick as D, computed as q } from "vue-demi";
30
+ import { computePosition as A, offset as b, flip as k, shift as R, autoUpdate as L, size as N } from "@floating-ui/dom";
31
31
  function y(n, e, t, o, u, s, r, d) {
32
32
  var l = typeof n == "function" ? n.options : n;
33
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
34
+ var i;
35
+ if (r ? (i = function(a) {
36
+ a = a || // cached call
37
37
  this.$vnode && this.$vnode.ssrContext || // stateful
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() {
38
+ this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext, !a && typeof __VUE_SSR_CONTEXT__ != "undefined" && (a = __VUE_SSR_CONTEXT__), u && u.call(this, a), a && a._registeredComponents && a._registeredComponents.add(r);
39
+ }, l._ssrRegister = i) : u && (i = d ? function() {
40
40
  u.call(
41
41
  this,
42
42
  (l.functional ? this.parent : this).$root.$options.shadowRoot
43
43
  );
44
- } : u), a)
44
+ } : u), i)
45
45
  if (l.functional) {
46
- l._injectStyles = a;
46
+ l._injectStyles = i;
47
47
  var c = l.render;
48
- l.render = function(v, m) {
49
- return a.call(m), c(v, m);
48
+ l.render = function(g, p) {
49
+ return i.call(p), c(g, p);
50
50
  };
51
51
  } else {
52
52
  var _ = l.beforeCreate;
53
- l.beforeCreate = _ ? [].concat(_, a) : [a];
53
+ l.beforeCreate = _ ? [].concat(_, i) : [i];
54
54
  }
55
55
  return {
56
56
  exports: n,
57
57
  options: l
58
58
  };
59
59
  }
60
- const N = {
60
+ const V = {
61
61
  name: "MEditorVue2",
62
62
  props: {
63
63
  modelValue: { type: String, default: "" },
@@ -68,21 +68,21 @@ const N = {
68
68
  })
69
69
  }
70
70
  },
71
- emits: ["update:modelValue", "fileReject", "imageInput"],
71
+ emits: ["input", "fileReject", "imageInput", "deleteMention"],
72
72
  setup(n, { emit: e, expose: t }) {
73
73
  const o = f(null), u = f(null);
74
- U("editor", o), p(() => {
74
+ U("editor", o), m(() => {
75
75
  u.value && (o.value = new Q({
76
76
  element: u.value,
77
77
  placeholder: n.options.placeholder,
78
78
  onChange: (r) => {
79
- e("update:modelValue", r);
79
+ e("input", r);
80
80
  },
81
- onFileReject: (r) => {
82
- e("fileReject", r);
81
+ onFileInput: (r) => {
82
+ e("fileInput", r);
83
83
  },
84
- onImageInput: (r) => {
85
- e("imageInput", r);
84
+ onMentionDelete(r) {
85
+ e("deleteMention", r);
86
86
  }
87
87
  }));
88
88
  });
@@ -99,18 +99,18 @@ const N = {
99
99
  var W = function() {
100
100
  var e = this, t = e._self._c;
101
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);
102
- }, T = [], j = /* @__PURE__ */ y(
103
- N,
102
+ }, T = [], O = /* @__PURE__ */ y(
103
+ V,
104
104
  W,
105
105
  T,
106
106
  !1,
107
107
  null,
108
- "8f854357",
108
+ "3a09ec83",
109
109
  null,
110
110
  null
111
111
  );
112
- const ce = j.exports;
113
- const O = {
112
+ const ce = O.exports;
113
+ const P = {
114
114
  name: "SuggestionMenu",
115
115
  props: {
116
116
  items: { type: Array, required: !0 },
@@ -123,7 +123,7 @@ const O = {
123
123
  }
124
124
  }
125
125
  };
126
- var P = function() {
126
+ var j = function() {
127
127
  var e = this, t = e._self._c;
128
128
  return t("div", { staticClass: "bn-suggestion-menu" }, [e.items.length ? e._l(e.items, function(o, u) {
129
129
  return t("div", { key: o.id, staticClass: "suggestion-menu-item", class: { active: u === e.selectedIndex }, on: { mousedown: function(s) {
@@ -131,8 +131,8 @@ var P = function() {
131
131
  } } }, [e._v(" " + e._s(o.label) + " ")]);
132
132
  }) : t("div", { staticClass: "suggestion-menu-item disabled" }, [e._v("无数据")])], 2);
133
133
  }, z = [], B = /* @__PURE__ */ y(
134
- O,
135
134
  P,
135
+ j,
136
136
  z,
137
137
  !1,
138
138
  null,
@@ -143,11 +143,11 @@ var P = function() {
143
143
  const K = B.exports;
144
144
  function X(n, e, t, o) {
145
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;
146
- return p(() => {
146
+ return m(() => {
147
147
  n && n.domElement && n.domElement.addEventListener("keydown", s, !0);
148
148
  }), S(() => {
149
149
  n && n.domElement && n.domElement.removeEventListener("keydown", s, !0);
150
- }), g(
150
+ }), v(
151
151
  () => e,
152
152
  () => {
153
153
  u.value = 0;
@@ -156,7 +156,7 @@ function X(n, e, t, o) {
156
156
  }
157
157
  function H(n, e, t, o = 8) {
158
158
  const u = f(0);
159
- return g(
159
+ return v(
160
160
  [n, e],
161
161
  ([s, r]) => {
162
162
  r != null && (s && s.length > 0 ? u.value = r.length : r.length - u.value > o && t());
@@ -190,11 +190,11 @@ const G = {
190
190
  H(e, o, n.closeMenu);
191
191
  const d = () => {
192
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");
193
+ o.value = n.query, t.value = "loading", n.getItems(n.query).then((i) => {
194
+ o.value === l && (e.value = i, t.value = "loaded");
195
195
  });
196
196
  };
197
- return p(d), g(
197
+ return m(d), v(
198
198
  () => n.query,
199
199
  () => {
200
200
  d();
@@ -224,48 +224,48 @@ const ee = Z.exports;
224
224
  function te(n, e, t, o = {}) {
225
225
  const u = f(null), s = f(null), r = f({});
226
226
  let d = null;
227
- g(
227
+ v(
228
228
  e,
229
- (i) => {
230
- i && (u.value = {
231
- getBoundingClientRect: () => i
229
+ (a) => {
230
+ a && (u.value = {
231
+ getBoundingClientRect: () => a
232
232
  }, l());
233
233
  },
234
234
  { immediate: !0 }
235
- ), g(
235
+ ), v(
236
236
  n,
237
- (i) => I(this, null, function* () {
238
- if (!i) {
237
+ (a) => I(this, null, function* () {
238
+ if (!a) {
239
239
  c();
240
240
  return;
241
241
  }
242
- yield V(), !(!u.value || !s.value) && (l(), a());
242
+ yield D(), !(!u.value || !s.value) && (l(), i());
243
243
  })
244
244
  );
245
245
  const l = () => {
246
- const i = u.value, v = s.value;
247
- !i || !v || A(i, v, {
246
+ const a = u.value, g = s.value;
247
+ !a || !g || A(a, g, {
248
248
  placement: o.placement || "bottom-start",
249
249
  middleware: [
250
- q(o.offset || 8),
251
- b(),
252
- k({ padding: 8 })
250
+ b(o.offset || 8),
251
+ k(),
252
+ R({ padding: 8 })
253
253
  ]
254
- }).then(({ x: m, y: x }) => {
254
+ }).then(({ x: p, y: x }) => {
255
255
  r.value = {
256
256
  position: "absolute",
257
- left: `${m}px`,
257
+ left: `${p}px`,
258
258
  top: `${x}px`
259
259
  };
260
260
  });
261
261
  };
262
- function a() {
263
- !u.value || !s.value || (d = D(u.value, s.value, l));
262
+ function i() {
263
+ !u.value || !s.value || (d = L(u.value, s.value, l));
264
264
  }
265
265
  function c() {
266
266
  d && (d(), d = null);
267
267
  }
268
- const _ = R(() => C({
268
+ const _ = q(() => C({
269
269
  display: "flex",
270
270
  zIndex: t
271
271
  }, r.value));
@@ -286,7 +286,7 @@ const ne = {
286
286
  onItemClick: { type: Function }
287
287
  },
288
288
  setup(n) {
289
- const e = $("editor"), t = f(null), o = R(() => {
289
+ const e = $("editor"), t = f(null), o = q(() => {
290
290
  var _;
291
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
292
  return c != null ? c : !1;
@@ -300,10 +300,10 @@ const ne = {
300
300
  {
301
301
  placement: "bottom-start",
302
302
  middleware: [
303
- q(10),
304
- b({ mainAxis: !0, crossAxis: !1 }),
305
- k(),
306
- L({
303
+ b(10),
304
+ k({ mainAxis: !0, crossAxis: !1 }),
305
+ R(),
306
+ N({
307
307
  apply({ availableHeight: c, elements: _ }) {
308
308
  Object.assign(_.floating.style, {
309
309
  maxHeight: `${c - 10}px`
@@ -316,7 +316,7 @@ const ne = {
316
316
  }
317
317
  );
318
318
  let r = null;
319
- return p(() => {
319
+ return m(() => {
320
320
  r = e.value.suggestionMenus.onUpdate(
321
321
  n.triggerCharacter,
322
322
  (c) => {
@@ -0,0 +1,7 @@
1
+ import { default as MEditor } from '@shenjipo/mention-editor';
2
+ import { default as Vue } from 'vue';
3
+ export type MEditorVue2Type = Vue & {
4
+ editor: MEditor;
5
+ clear: () => void;
6
+ };
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,0BAA0B,CAAA;AAC9C,OAAO,GAAG,MAAM,KAAK,CAAA;AAErB,MAAM,MAAM,eAAe,GAAG,GAAG,GAAG;IAChC,MAAM,EAAE,OAAO,CAAA;IACf,KAAK,EAAE,MAAM,IAAI,CAAA;CACpB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@shenjipo/mention-vue2",
3
- "version": "2.3.0",
3
+ "version": "2.5.0",
4
+ "type": "module",
4
5
  "main": "dist/index.cjs.js",
5
6
  "module": "dist/index.esm.js",
6
7
  "types": "dist/index.d.ts",
@@ -11,7 +12,10 @@
11
12
  "require": "./dist/index.cjs.js",
12
13
  "types": "./dist/index.d.ts"
13
14
  },
14
- "./dist/index.css": "./dist/index.css"
15
+ "./dist/index.css": "./dist/index.css",
16
+ "./types": {
17
+ "types": "./dist/types/index.d.ts"
18
+ }
15
19
  },
16
20
  "files": [
17
21
  "dist"
@@ -23,7 +27,7 @@
23
27
  "@floating-ui/dom": "^1.1.9",
24
28
  "vue": "^2.7.7",
25
29
  "vue-demi": "^0.14.10",
26
- "@shenjipo/mention-editor": "2.3.0"
30
+ "@shenjipo/mention-editor": "2.5.0"
27
31
  },
28
32
  "devDependencies": {
29
33
  "@types/node": "^16.11.45",