Socket
Socket
Sign inDemoInstall

@hydrabot/slate-vue

Package Overview
Dependencies
Maintainers
3
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hydrabot/slate-vue - npm Package Compare versions

Comparing version 0.2.4 to 0.2.6

2

dist/components/editable.d.ts

@@ -16,3 +16,3 @@ import * as tsx from "vue-tsx-support";

}
export declare const Editable: tsx._TsxComponentV3<import("vue").default & EditableData & UseRef & {
export declare const Editable: tsx._TsxComponentV3<import("vue").default<Record<string, any>, Record<string, any>, never, never, never, never, (event: string, ...args: any[]) => import("vue").default<Record<string, any>, Record<string, any>, never, never, never, never, any>> & EditableData & UseRef & {
_onClick(event: IEvent): void;

@@ -19,0 +19,0 @@ onSelectionchange(): void;

@@ -12,3 +12,3 @@ /**

*/
export declare const Element: tsx._TsxComponentV3<import("vue").default & Pick<providedByEditable, "readOnly" | "renderElement"> & UseRef & {
export declare const Element: tsx._TsxComponentV3<import("vue").default<Record<string, any>, Record<string, any>, never, never, never, never, (event: string, ...args: any[]) => import("vue").default<Record<string, any>, Record<string, any>, never, never, never, never, any>> & Pick<providedByEditable, "readOnly" | "renderElement"> & UseRef & {
element: import("slate").BaseElement;

@@ -21,2 +21,2 @@ }, {}, {} & {

*/
export declare const DefaultElement: (props: RenderElementProps) => tsx._TsxComponentV3<import("vue").default, {}, {} & {}, {}, {}, {}>;
export declare const DefaultElement: (props: RenderElementProps) => tsx._TsxComponentV3<import("vue").default<Record<string, any>, Record<string, any>, never, never, never, never, (event: string, ...args: any[]) => import("vue").default<Record<string, any>, Record<string, any>, never, never, never, never, any>>, {}, {} & {}, {}, {}, {}>;
import * as tsx from 'vue-tsx-support';
export declare const fragment: tsx._TsxComponentV3<import("vue").default & {
export declare const fragment: tsx._TsxComponentV3<import("vue").default<Record<string, any>, Record<string, any>, never, never, never, never, (event: string, ...args: any[]) => import("vue").default<Record<string, any>, Record<string, any>, never, never, never, never, any>> & {
name: string;

@@ -4,0 +4,0 @@ }, {}, {} & {

@@ -6,3 +6,3 @@ import * as tsx from 'vue-tsx-support';

*/
declare const Leaf: tsx._TsxComponentV3<import("vue").default & Pick<providedByEditable, "renderLeaf"> & {
declare const Leaf: tsx._TsxComponentV3<import("vue").default<Record<string, any>, Record<string, any>, never, never, never, never, (event: string, ...args: any[]) => import("vue").default<Record<string, any>, Record<string, any>, never, never, never, never, any>> & Pick<providedByEditable, "renderLeaf"> & {
text: import("slate").BaseText;

@@ -9,0 +9,0 @@ leaf: import("slate").BaseText;

@@ -10,3 +10,3 @@ /**

}
export declare const Slate: tsx._TsxComponentV3<Vue & SlateData & {
export declare const Slate: tsx._TsxComponentV3<Vue<Record<string, any>, Record<string, any>, never, never, never, never, (event: string, ...args: any[]) => Vue<Record<string, any>, Record<string, any>, never, never, never, never, any>> & SlateData & {
genUid(): string;

@@ -13,0 +13,0 @@ /**

@@ -6,3 +6,3 @@ import * as tsx from "vue-tsx-support";

*/
declare const string: tsx._TsxComponentV3<import("vue").default & providedByText & {
declare const string: tsx._TsxComponentV3<import("vue").default<Record<string, any>, Record<string, any>, never, never, never, never, (event: string, ...args: any[]) => import("vue").default<Record<string, any>, Record<string, any>, never, never, never, never, any>> & providedByText & {
leaf: import("slate").BaseText;

@@ -9,0 +9,0 @@ editor: any;

@@ -6,3 +6,3 @@ import * as tsx from 'vue-tsx-support';

*/
declare const Text: tsx._TsxComponentV3<import("vue").default & Pick<providedByEditable, "placeholder" | "decorate"> & UseRef & {
declare const Text: tsx._TsxComponentV3<import("vue").default<Record<string, any>, Record<string, any>, never, never, never, never, (event: string, ...args: any[]) => import("vue").default<Record<string, any>, Record<string, any>, never, never, never, never, any>> & Pick<providedByEditable, "placeholder" | "decorate"> & UseRef & {
text: import("slate").BaseText;

@@ -9,0 +9,0 @@ isLast: boolean;

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("vue-tsx-support"),e=require("@hydrabot/slate-vue-shared"),n=require("vue"),r=require("slate"),o=require("direction");function i(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}function a(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}})),e.default=t,Object.freeze(e)}var s=a(t),c=i(n),d=i(o),u=null,l=!1,f=0;function h(){if(!u)throw new Error("invalid hooks call: hooks can only be called in a function passed to withHooks.")}function p(t){return t._isVue?t.$el:t}function E(t,e){h();var n=++f;if(l){var r=function t(){var e=t.current;e&&(e(),t.current=null)},o=function t(){var e=t.current;e&&(r.current=e.call(this),t.current=null)};o.current=t,u._effectStore[n]={effect:o,cleanup:r,deps:e},u.$on("hook:mounted",o),u.$on("hook:destroyed",r),(!e||e.length>0)&&u.$on("hook:updated",o)}else{var i=u._effectStore[n],a=i.effect,s=i.cleanup,c=i.deps,d=void 0===c?[]:c;i.deps=e,e&&!e.some((function(t,e){return t!==d[e]}))||(s(),a.current=t)}}function m(t){h();var e=(++f).toString(),n=u._refsStore;return u.$on("hook:mounted",(function(){this.$refs[e]&&(n[e].current=p(this.$refs[e]))})),u.$on("hook:updated",(function(){this.$refs[e]&&(n[e].current=p(this.$refs[e]))})),l?n[e]={current:t,id:e}:n[e]}function v(t){t.mixin({beforeCreate:function(){var t=this.$options,e=t.hooks,n=t.data;e&&(this._effectStore={},this._refsStore={},this._computedStore={},this.$options.data=function(){var t=n?n.call(this):{};return t._state={},t})},beforeMount:function(){var t=this.$options,e=t.hooks,n=t.render;e&&n&&(this.$options.render=function(t){f=0,u=this,l=!this._vnode;var r=e.call(this,this.$props);Object.assign(this._self,r);var o=n.call(this,t);return u=null,o})}})}function _(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function g(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?_(Object(n),!0).forEach((function(e){O(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):_(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function O(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==n)return;var r,o,i=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(i.push(r.value),!e||i.length!==e);a=!0);}catch(t){s=!0,o=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw o}}return i}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return b(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return b(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var N,x=function(t){return r.Editor.isEditor(t)?t._state:t.children},S=function(t,e){if(r.Text.isText(t))throw new Error("Cannot get the child of a text node: ".concat(JSON.stringify(t)));var n=x(t)[e];if(null==n)throw new Error("Cannot get child at index `".concat(e,"` in node: ").concat(JSON.stringify(t)));return n},T=function(t,e){for(var n=t,o=0;o<e.length;o++){var i=e[o],a=x(n);if(r.Text.isText(n)||!a[i])return!1;n=a[i]}return!0},C=function(t,e){for(var n=t,o=0;o<e.length;o++){var i=e[o],a=x(n);if(r.Text.isText(n)||!a[i])throw new Error("Cannot find a descendant at path [".concat(e,"] in node: ").concat(JSON.stringify(t)));n=a[i]}return n},$=function(t,e){for(var n=e.slice(),o=r.Node.get(t,n),i=x(o);o&&!r.Text.isText(o)&&0!==i.length;)o=i[0],n.push(0);return[o,n]},D=function(t,e){for(var n=e.slice(),o=r.Node.get(t,n),i=x(o);o&&!r.Text.isText(o)&&0!==i.length;){var a=i.length-1;o=i[a],n.push(a)}return[o,n]},w=function*(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.pass,o=e.reverse,i=void 0!==o&&o,a=e.from,s=void 0===a?[]:a,c=e.to,d=new Set,u=[],l=t;!c||!(i?r.Path.isBefore(u,c):r.Path.isAfter(u,c));)if(d.has(l)||(yield[l,u]),d.has(l)||r.Text.isText(l)||0===x(l).length||null!=n&&!1!==n([l,u])){if(0===u.length)break;if(!i){var f=r.Path.next(u);if(r.Node.has(t,f)){u=f,l=r.Node.get(t,u);continue}}if(i&&0!==u[u.length-1]){var h=r.Path.previous(u);u=h,l=r.Node.get(t,u)}else u=r.Path.parent(u),l=r.Node.get(t,u),d.add(l)}else{d.add(l);var p=i?x(l).length-1:0;r.Path.isAncestor(u,s)&&(p=s[u.length]),u=u.concat(p),l=r.Node.get(t,u)}},P=(N=r.Transforms.select,r.Transforms.select=function(t,e){var n;return e.__ob__&&(n=e,e=JSON.parse(JSON.stringify(n))),N(t,e)},r.Transforms),L=function(){var t=r.Node.get,e=r.Node.nodes,n=r.Node.has,o=r.Node.first,i=r.Node.child,a=r.Node.last;return r.Node.child=S,r.Node.has=T,r.Node.get=C,r.Node.first=$,r.Node.last=D,r.Node.nodes=w,function(){r.Node.get=t,r.Node.nodes=e,r.Node.has=n,r.Node.first=o,r.Node.child=i,r.Node.last=a}},j=function(t){return function(){var e=L(),n=t.apply(void 0,arguments);return e(),n}};e.VueEditor.toDOMRange=j(e.VueEditor.toDOMRange);var M=function(t){return e.EDITOR_TO_GVM.get(t)},F=function(t,e){var n=t._watcher.update;t._watcher.update=function(){var r=t.$editor._operation;if(r){if("remove_text"===r.type||"insert_text"===r.type||"set_selection"===r.type)return;if("remove_node"===r.type&&"element"===e)return}n.call(t._watcher)}},k=s.component({mounted:function(){this.$editor._state.__ob__.dep.addSub(this._watcher)}}),I=s.component({created:function(){var t=M(this.$editor),e=this.element||this.node;t.selected.elements.push(e)},computed:{selected:function(){if(this.element){var t=M(this.$editor),n=e.NODE_TO_KEY.get(this.element);return!!n&&t.selected[n.id]}return!1}}}),B=s.component({computed:{readOnly:function(){return e.VueEditor.isReadOnly(this.$editor)}}}),V=s.component({computed:{focused:function(){return M(this.$editor).focused}}}),R=function(){var t=e.withVue(r.createEditor()),n=new c.default({data:{focused:!1,selected:{elements:[]}},methods:{updateSelected:function(){var t=this,n=e.GVM_TO_EDITOR.get(this),o=n.selection;o&&this.selected.elements.forEach((function(i){var a=e.NODE_TO_KEY.get(i);if(a){var s=a.id,c=e.VueEditor.findPath(n,i),d=r.Editor.range(n,c),u=r.Range.intersection(d,o);t.$set(t.selected,s,!!u)}}))}}});return e.EDITOR_TO_GVM.set(t,n),e.GVM_TO_EDITOR.set(n,t),t},A={install:function(t,e){t.mixin({beforeCreate:function(){this.$editor||(this.$options.components.Slate?(this.$editor=R(),null!=e&&e.editorCreated&&e.editorCreated.call(this,this.$editor)):this.$editor=this.$parent&&this.$parent.$editor)}}),t.use(v)}},K=function(t,e,n){Object.defineProperty(t,e,{configurable:!0,get:function(){return n},set:function(t){console.warn("tried to set frozen property ".concat(e," with ").concat(t))}})},Y=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;Object.defineProperty(t,e,{configurable:!0,writable:!0,value:n})},q=s.component({abstract:!0,name:"Fragment",props:{name:{type:String,default:function(){return Math.floor(Date.now()*Math.random()).toString(16)}}},mounted:function(){var t=this.$el,e=t.parentNode,n=document.createComment("fragment#".concat(this.name,"#head")),r=document.createComment("fragment#".concat(this.name,"#tail"));e.insertBefore(n,t),e.insertBefore(r,t),t.appendChild=function(n){e.insertBefore(n,r),K(n,"parentNode",t)},t.insertBefore=function(n,r){e.insertBefore(n,r),K(n,"parentNode",t)},t.removeChild=function(t){e.removeChild(t),Y(t,"parentNode")},Array.from(t.childNodes).forEach((function(e){return t.appendChild(e)})),e.removeChild(t),K(t,"parentNode",e),K(t,"nextSibling",r.nextSibling),K(r,"parentNode",t);var o=e.insertBefore;e.insertBefore=function(r,i){o.call(e,r,i!==t?i:n)};var i=e.removeChild;e.removeChild=function(a){if(a===t){for(;n.nextSibling!==r;)t.removeChild(n.nextSibling);e.removeChild(n),e.removeChild(r),Y(t,"parentNode"),e.insertBefore=o,e.removeChild=i}else i.call(e,a)}},render:function(t){var e=this.$slots.default;return t("div",{key:this.name},e)}}),G=s.component({name:"slate",props:{value:String},components:{fragment:q},data:function(){return{name:null}},created:function(){var t=this;this.renderSlate(),this.$editor.clear=function(){t.renderSlate(JSON.stringify([{children:[{text:""}]}]))}},watch:{value:function(t,e){t!==e&&this.renderSlate(t)}},methods:{genUid:function(){return Math.floor(Date.now()*Math.random()).toString(16)},renderSlate:function(t){var e=t||this.value,n=this.$editor;n.children=JSON.parse(e);var r=JSON.parse(e);n._state=c.default.observable(r),this.clearEditor(),this.name=this.genUid()},clearEditor:function(){this.$editor.selection=null}},render:function(){var t=this,n=arguments[0];return e.EDITOR_TO_ON_CHANGE.set(this.$editor,(function(){t.$editor._state.__ob__.dep.notify();var n=M(t.$editor);n.focused=e.VueEditor.isFocused(t.$editor);var r=t.$editor._operation;r&&"set_selection"===r.type&&n.updateSelected(),t.$emit("onChange")})),n(q,{attrs:{name:this.name}},[this.$scopedSlots.default&&this.$scopedSlots.default({})])}}),J=s.component({props:{text:String,isTrailing:Boolean},render:function(){var t=arguments[0],e=this.text,n=this.isTrailing,r=void 0!==n&&n;return t("span",{attrs:{"data-slate-string":!0}},[e,r?"\n":null])}}),z={functional:!0,render:function(t,e){var n=e.props,r=n.length,o=void 0===r?0:r,i=n.isLineBreak,a=void 0!==i&&i;return t("span",{attrs:{"data-slate-zero-width":a?"n":"z","data-slate-length":o}},["\ufeff",a?t("br"):null])}},U=s.component({props:{leaf:{type:Object},editor:Object},inject:["isLast","parent","text"],components:{TextString:J},data:function(){return{}},render:function(){var t=arguments[0],n=this.leaf,o=this.editor,i=this.isLast,a=this.parent,s=this.text,c=e.VueEditor.findPath(o,s),d=r.Path.parent(c);return o.isVoid(a)?t(z,{attrs:{length:r.Node.string(a).length}}):""!==n.text||a.children[a.children.length-1]!==s||o.isInline(a)||""!==r.Editor.string(o,d)?""===n.text?t(z):i&&"\n"===n.text.slice(-1)?t(J,{attrs:{isTrailing:!0,text:n.text}}):t(J,{attrs:{text:n.text}}):t(z,{attrs:{isLineBreak:!0}})}}),X=s.component({props:{text:{type:Object},leaf:{type:Object}},inject:["renderLeaf"],components:{string:U,fragment:q},data:function(){return{}},render:function(t){var n=this.renderLeaf,r=void 0===n?H:n,o=this.text,i=this.leaf,a=t(U,{attrs:{text:o,editor:this.$editor,leaf:i}});i[e.PLACEHOLDER_SYMBOL]&&(a=t(q,[t("span",{attrs:{contenteditable:!1},style:{pointerEvents:"none",display:"inline-block",verticalAlign:"text-top",width:"0",maxWidth:"100%",whiteSpace:"nowrap",opacity:"0.333"}},[i.placeholder]),a]));return t(r({children:a,attributes:{"data-slate-leaf":!0},leaf:i,text:o}))}}),H=function(t){return s.component({render:function(){var e=arguments[0],n=t.attributes,r=t.children;return e("span",{attrs:g({},n)},[r])}})},W=s.component({props:{text:{type:Object},isLast:Boolean,parent:{type:Object},decorations:{type:Array}},components:{leaf:X},inject:["decorate","placeholder"],provide:function(){return{text:this.text,isLast:this.isLast,parent:this.parent}},data:function(){return{ref:null}},hooks:function(){var t=this.ref=m(null),n=this.text,r=this.$editor,o=e.VueEditor.findKey(r,n);E((function(){t.current?(e.KEY_TO_ELEMENT.set(o,t.current),e.NODE_TO_ELEMENT.set(n,t.current),e.ELEMENT_TO_NODE.set(t.current,n)):(e.KEY_TO_ELEMENT.delete(o),e.NODE_TO_ELEMENT.delete(n))}))},render:function(t,n){var o=this.text,i=this.placeholder,a=this.decorations;if(!a){var s=this.$editor,c=e.VueEditor.findPath(s,o);if(this.decorate&&(a=this.decorate([o,c])),i&&1===s.children.length&&1===Array.from(r.Node.texts(s)).length&&""===r.Node.string(s)){var d,u=r.Editor.start(s,[]);a.push((O(d={},e.PLACEHOLDER_SYMBOL,!0),O(d,"placeholder",i),O(d,"anchor",u),O(d,"focus",u),d))}}for(var l=r.Text.decorations(o,a),f=[],h=0;h<l.length;h++){var p=l[h];f.push(t(X,{attrs:{leaf:p}}))}return t("span",{attrs:{"data-slate-node":"text"},ref:this.ref.id},[f])}}),Q=s.component({props:{element:{type:Object}},inject:["readOnly","renderElement"],components:{Children:tt},data:function(){return{ref:null}},mounted:function(){F(this,"element")},hooks:function(){var t=this.ref=m(null),n=this.element,r=e.VueEditor.findKey(this.$editor,n);E((function(){t.current?(e.KEY_TO_ELEMENT.set(r,t.current),e.NODE_TO_ELEMENT.set(n,t.current),e.ELEMENT_TO_NODE.set(t.current,n)):(e.KEY_TO_ELEMENT.delete(r),e.NODE_TO_ELEMENT.delete(n))}))},render:function(t){var n=this.element,o=this.renderElement,i=void 0===o?Z:o,a=this.ref,s=this.$editor,c=s.isInline(n),u=t(tt,{attrs:{node:n}}),l={"data-slate-node":"element"};if(c&&(l["data-slate-inline"]=!0),!c&&r.Editor.hasInlines(s,n)){var f=r.Node.string(n),h=d.default(f);"rtl"===h&&(l.dir=h)}if(r.Editor.isVoid(s,n)){l["data-slate-void"]=!0,!this.readOnly&&c&&(l.contentEditable=!1);var p=c?"span":"div",E=y(r.Node.texts(n),1),m=y(E[0],1)[0];u=this.readOnly?null:t(p,{attrs:{"data-slate-spacer":!0},style:{height:"0",color:"transparent",outline:"none",position:"absolute"}},[t(W,{attrs:{decorations:[],isLast:!1,parent:n,text:m}})]),e.NODE_TO_INDEX.set(m,0),e.NODE_TO_PARENT.set(m,n)}return t(i({element:n,attributes:l,children:u}),{ref:a.id})}}),Z=function(t){return s.component({render:function(){var e=arguments[0],n=t.attributes,r=t.children,o=t.element,i=this.$editor,a=i.isInline(o)?"span":"div";return e(a,{attrs:g({},n),style:{position:"relative"}},[r])}})},tt=s.component({props:{node:{type:Object}},components:{TextComponent:W,ElementComponent:Q,fragment:q},mixins:[k],mounted:function(){F(this,"children")},render:function(){for(var t=arguments[0],n=this.$editor,o=this.node,i=e.VueEditor.findPath(n,o),a=r.Element.isElement(o)&&!n.isInline(o)&&r.Editor.hasInlines(n,o),s=[],c=r.Editor.isEditor(o)?o._state:o.children,d=null,u=0;u<c.length;u++){var l=c[u],f=e.VueEditor.findKey(n,l),h=i.concat(u);if(r.Editor.range(n,h),e.NODE_TO_INDEX.set(l,u),e.NODE_TO_PARENT.set(l,o),n._operation&&e.KEY_TO_VNODE.get(f)){var p=n._operation.path;if("split_node"===n._operation.type&&r.Path.isSibling(h,p)&&!r.Path.equals(h,p)&&!r.Path.equals(h,r.Path.next(p))){d=e.KEY_TO_VNODE.get(f),s.push(d);continue}if("merge_node"===n._operation.type){var E=r.Path.parent(p);if(r.Path.isSibling(h,E)&&!r.Path.isParent(h,p)){d=e.KEY_TO_VNODE.get(f),s.push(d);continue}}if("remove_node"===n._operation.type&&r.Path.isSibling(h,p)&&!r.Path.equals(h,p)){d=e.KEY_TO_VNODE.get(f),s.push(d);continue}}r.Element.isElement(l)?(d=t(Q,{attrs:{element:l},key:f.id}),s.push(d)):(d=t(W,{attrs:{isLast:a&&u===c.length-1,parent:o,text:l},key:f.id}),s.push(d)),e.KEY_TO_VNODE.set(f,d)}return t(q,[s])}}),et=!(e.IS_FIREFOX||e.IS_EDGE_LEGACY),nt=s.component({props:{autoFocus:Boolean,renderLeaf:Function,renderElement:Function,readOnly:Boolean,decorate:{type:Function,default:function(){return[]}},placeholder:String,spellCheck:Boolean,autoCorrect:String,autoCapitalize:String,onBeforeInput:{type:Function},onKeyDown:{type:Function},onClick:{type:Function},onCompositionEnd:{type:Function},onCompositionStart:{type:Function},onCut:{type:Function},onCopy:{type:Function},onDragOver:{type:Function},onDragStart:{type:Function},onDragStop:{type:Function},onPaste:{type:Function},onFocus:{type:Function},onBlur:{type:Function},onDrop:{type:Function}},components:{Children:tt},mixins:[k],provide:function(){return{renderLeaf:this.renderLeaf,renderElement:this.renderElement,decorate:this.decorate,readOnly:this.readOnly,placeholder:this.placeholder}},data:function(){return{latestElement:null,isComposing:!1,isUpdatingSelection:!1,ref:null}},methods:{_onClick:function(t){e.EditableComponent.onClick(t,this.$editor,this)},onSelectionchange:function(){e.EditableComponent.onSelectionchange(this.$editor,this)},_onBeforeInput:function(t){e.EditableComponent.onBeforeInput(t,this.$editor,this)},_onCompositionEnd:function(t){e.EditableComponent.onCompositionEnd(t,this.$editor,this)},_onCompositionStart:function(t){e.EditableComponent.onCompositionStart(t,this.$editor,this)},_onKeyDown:function(t){e.EditableComponent.onKeyDown(t,this.$editor,this)},_onFocus:function(t){e.EditableComponent.onFocus(t,this.$editor,this)},_onBlur:function(t){e.EditableComponent.onBlur(t,this.$editor,this)},_onCopy:function(t){e.EditableComponent.onCopy(t,this.$editor,this)},_onPaste:function(t){e.EditableComponent.onPaste(t,this.$editor,this)},_onCut:function(t){e.EditableComponent.onCut(t,this.$editor,this)},_onDragOver:function(t){e.EditableComponent.onDragOver(t,this.$editor,this)},_onDragStart:function(t){e.EditableComponent.onDragStart(t,this.$editor,this)},_onDrop:function(t){e.EditableComponent.onDrop(t,this.$editor,this)}},hooks:function(){var t=this,n=this.ref=m(null),o=this.$editor;e.IS_READ_ONLY.set(o,this.readOnly);E((function(){return document.addEventListener("selectionchange",t.onSelectionchange),function(){document.removeEventListener("selectionchange",t.onSelectionchange)}})),E((function(){n.current?(e.EDITOR_TO_ELEMENT.set(o,n.current),e.NODE_TO_ELEMENT.set(o,n.current),e.ELEMENT_TO_NODE.set(n.current,o)):e.NODE_TO_ELEMENT.delete(o)})),E((function(){var n=o.selection,i=window.getSelection();if(!t.isComposing&&i&&e.VueEditor.isFocused(o)){var a="None"!==i.type;if(n||a){var s=e.EDITOR_TO_ELEMENT.get(o),c=!1;if(s.contains(i.anchorNode)&&s.contains(i.focusNode)&&(c=!0),!(a&&c&&n&&r.Range.equals(e.VueEditor.toSlateRange(o,i),n))){var d=e.VueEditor.toDOMNode(o,o);t.isUpdatingSelection=!0;var u=n&&e.VueEditor.toDOMRange(o,n);u?(r.Range.isBackward(n)?i.setBaseAndExtent(u.endContainer,u.endOffset,u.startContainer,u.startOffset):i.setBaseAndExtent(u.startContainer,u.startOffset,u.endContainer,u.endOffset),u.startContainer.parentElement):i.removeAllRanges(),setTimeout((function(){u&&e.IS_FIREFOX&&d.focus(),t.isUpdatingSelection=!1}))}}}})),E((function(){n.current&&t.autoFocus&&setTimeout((function(){n.current.focus()}),0)}),[t.autoFocus]),e.IS_FIREFOX&&E((function(){e.addOnBeforeInput(n.current,!0)}),[])},render:function(){var t=arguments[0],e=this.$editor,n=this.ref,r={click:this._onClick,keydown:this._onKeyDown,focus:this._onFocus,blur:this._onBlur,beforeinput:this._onBeforeInput,copy:this._onCopy,cut:this._onCut,compositionend:this._onCompositionEnd,compositionstart:this._onCompositionStart,dragover:this._onDragOver,dragstart:this._onDragStart,drop:this._onDrop,paste:this._onPaste},o={spellcheck:et?this.spellCheck:void 0,autocorrect:et?this.autoCorrect:void 0,autocapitalize:et?this.autoCapitalize:void 0};return t("div",{attrs:g({"data-gramm":!1,role:this.readOnly?void 0:"textbox",contenteditable:!this.readOnly,"data-slate-editor":!0,"data-slate-node":"value"},o),ref:n.id,style:{outline:"none",whiteSpace:"pre-wrap",wordWrap:"break-word"},on:g({},r)},[t(tt,{attrs:{node:e,selection:e.selection}})])}});Object.defineProperty(exports,"VueEditor",{enumerable:!0,get:function(){return e.VueEditor}}),exports.Editable=nt,exports.FocusedMixin=V,exports.ReadOnlyMixin=B,exports.SelectedMixin=I,exports.Slate=G,exports.SlateMixin=k,exports.SlatePlugin=A,exports.Transforms=P,exports.elementWatcherPlugin=F,exports.fragment=q,exports.getGvm=M,exports.useEffect=E,exports.useRef=m,exports.vueRuntime=function(t){for(var e=L(),n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];var i=t.apply(void 0,r);return e(),i},exports.vueRuntimeFunc=j;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue-tsx-support"),t=require("@hydrabot/slate-vue-shared"),n=require("vue"),o=require("slate"),r=require("direction");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function s(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var a=s(e),d=i(n),l=i(r);let c=null,h=!1,u=0;function p(){if(!c)throw new Error("invalid hooks call: hooks can only be called in a function passed to withHooks.")}function f(e){return e._isVue?e.$el:e}function E(e,t){p();const n=++u;if(h){const o=()=>{const{current:e}=o;e&&(e(),o.current=null)},r=function(){const{current:e}=r;e&&(o.current=e.call(this),r.current=null)};r.current=e,c._effectStore[n]={effect:r,cleanup:o,deps:t},c.$on("hook:mounted",r),c.$on("hook:destroyed",o),(!t||t.length>0)&&c.$on("hook:updated",r)}else{const o=c._effectStore[n],{effect:r,cleanup:i,deps:s=[]}=o;o.deps=t,t&&!t.some(((e,t)=>e!==s[t]))||(i(),r.current=e)}}function m(e){p();const t=(++u).toString(),{_refsStore:n}=c;return c.$on("hook:mounted",(function(){this.$refs[t]&&(n[t].current=f(this.$refs[t]))})),c.$on("hook:updated",(function(){this.$refs[t]&&(n[t].current=f(this.$refs[t]))})),h?n[t]={current:e,id:t}:n[t]}function _(e){e.mixin({beforeCreate(){const{hooks:e,data:t}=this.$options;e&&(this._effectStore={},this._refsStore={},this._computedStore={},this.$options.data=function(){const e=t?t.call(this):{};return e._state={},e})},beforeMount(){const{hooks:e,render:t}=this.$options;e&&t&&(this.$options.render=function(n){u=0,c=this,h=!this._vnode;const o=e.call(this,this.$props);Object.assign(this._self,o);const r=t.call(this,n);return c=null,r})}})}const g=e=>o.Editor.isEditor(e)?e._state:e.children,O={child(e,t){if(o.Text.isText(e))throw new Error(`Cannot get the child of a text node: ${JSON.stringify(e)}`);const n=g(e)[t];if(null==n)throw new Error(`Cannot get child at index \`${t}\` in node: ${JSON.stringify(e)}`);return n},has(e,t){let n=e;for(let e=0;e<t.length;e++){const r=t[e],i=g(n);if(o.Text.isText(n)||!i[r])return!1;n=i[r]}return!0},get(e,t){let n=e;for(let r=0;r<t.length;r++){const i=t[r],s=g(n);if(o.Text.isText(n)||!s[i])throw new Error(`Cannot find a descendant at path [${t}] in node: ${JSON.stringify(e)}`);n=s[i]}return n},first(e,t){const n=t.slice();let r=o.Node.get(e,n);const i=g(r);for(;r&&!o.Text.isText(r)&&0!==i.length;)r=i[0],n.push(0);return[r,n]},last(e,t){const n=t.slice();let r=o.Node.get(e,n);const i=g(r);for(;r&&!o.Text.isText(r)&&0!==i.length;){const e=i.length-1;r=i[e],n.push(e)}return[r,n]},*nodes(e,t={}){const{pass:n,reverse:r=!1}=t,{from:i=[],to:s}=t,a=new Set;let d=[],l=e;for(;!s||!(r?o.Path.isBefore(d,s):o.Path.isAfter(d,s));)if(a.has(l)||(yield[l,d]),a.has(l)||o.Text.isText(l)||0===g(l).length||null!=n&&!1!==n([l,d])){if(0===d.length)break;if(!r){const t=o.Path.next(d);if(o.Node.has(e,t)){d=t,l=o.Node.get(e,d);continue}}if(r&&0!==d[d.length-1]){d=o.Path.previous(d),l=o.Node.get(e,d)}else d=o.Path.parent(d),l=o.Node.get(e,d),a.add(l)}else{a.add(l);let t=r?g(l).length-1:0;o.Path.isAncestor(d,i)&&(t=i[d.length]),d=d.concat(t),l=o.Node.get(e,d)}}},y=(()=>{const{select:e}=o.Transforms;return o.Transforms.select=(t,n)=>{var o;return n.__ob__&&(o=n,n=JSON.parse(JSON.stringify(o))),e(t,n)},o.Transforms})(),N=()=>{const{get:e,nodes:t,has:n,first:r,child:i,last:s}=o.Node;return o.Node.child=O.child,o.Node.has=O.has,o.Node.get=O.get,o.Node.first=O.first,o.Node.last=O.last,o.Node.nodes=O.nodes,()=>{o.Node.get=e,o.Node.nodes=t,o.Node.has=n,o.Node.first=r,o.Node.child=i,o.Node.last=s}},x=e=>(...t)=>{const n=N(),o=e(...t);return n(),o};t.VueEditor.toDOMRange=x(t.VueEditor.toDOMRange);const T=()=>new d.default({data:{focused:!1,selected:{elements:[]}},methods:{updateSelected(){const e=t.GVM_TO_EDITOR.get(this),{selection:n}=e;n&&this.selected.elements.forEach((r=>{const i=t.NODE_TO_KEY.get(r);if(i){const{id:s}=i,a=t.VueEditor.findPath(e,r),d=o.Editor.range(e,a),l=o.Range.intersection(d,n);this.$set(this.selected,s,!!l)}}))}}}),C=e=>t.EDITOR_TO_GVM.get(e),$=(e,t)=>{const n=e._watcher.update;e._watcher.update=()=>{const o=e.$editor._operation;if(o){if("remove_text"===o.type||"insert_text"===o.type||"set_selection"===o.type)return;if("remove_node"===o.type&&"element"===t)return}n.call(e._watcher)}},b=a.component({mounted(){this.$editor._state.__ob__.dep.addSub(this._watcher)}}),S=a.component({created(){const e=C(this.$editor),t=this.element||this.node;e.selected.elements.push(t)},computed:{selected(){if(this.element){const e=C(this.$editor),n=t.NODE_TO_KEY.get(this.element);return!!n&&e.selected[n.id]}return!1}}}),v=a.component({computed:{readOnly(){return t.VueEditor.isReadOnly(this.$editor)}}}),D=a.component({computed:{focused(){return C(this.$editor).focused}}}),w={install(e,n){e.mixin({beforeCreate(){this.$editor||(this.$options.components.Slate?(this.$editor=(()=>{const e=t.withVue(o.createEditor()),n=T();return t.EDITOR_TO_GVM.set(e,n),t.GVM_TO_EDITOR.set(n,e),e})(),null!=n&&n.editorCreated&&n.editorCreated.call(this,this.$editor)):this.$editor=this.$parent&&this.$parent.$editor)}}),e.use(_)}},L=(e,t,n)=>{Object.defineProperty(e,t,{configurable:!0,get:()=>n,set(e){console.warn(`tried to set frozen property ${t} with ${e}`)}})},P=(e,t,n=null)=>{Object.defineProperty(e,t,{configurable:!0,writable:!0,value:n})},M=a.component({abstract:!0,name:"Fragment",props:{name:{type:String,default:()=>Math.floor(Date.now()*Math.random()).toString(16)}},mounted(){const e=this.$el,t=e.parentNode,n=document.createComment(`fragment#${this.name}#head`),o=document.createComment(`fragment#${this.name}#tail`);t.insertBefore(n,e),t.insertBefore(o,e),e.appendChild=n=>{t.insertBefore(n,o),L(n,"parentNode",e)},e.insertBefore=(n,o)=>{t.insertBefore(n,o),L(n,"parentNode",e)},e.removeChild=e=>{t.removeChild(e),P(e,"parentNode")},Array.from(e.childNodes).forEach((t=>e.appendChild(t))),t.removeChild(e),L(e,"parentNode",t),L(e,"nextSibling",o.nextSibling),L(o,"parentNode",e);const r=t.insertBefore;t.insertBefore=(o,i)=>{r.call(t,o,i!==e?i:n)};const i=t.removeChild;t.removeChild=s=>{if(s===e){for(;n.nextSibling!==o;)e.removeChild(n.nextSibling);t.removeChild(n),t.removeChild(o),P(e,"parentNode"),t.insertBefore=r,t.removeChild=i}else i.call(t,s)}},render(e){const t=this.$slots.default;return e("div",{key:this.name},t)}}),F=a.component({name:"slate",props:{value:String},components:{fragment:M},data:()=>({name:null}),created(){this.renderSlate(),this.$editor.clear=()=>{this.renderSlate(JSON.stringify([{children:[{text:""}]}]))}},watch:{value(e,t){e!==t&&this.renderSlate(e)}},methods:{genUid:()=>Math.floor(Date.now()*Math.random()).toString(16),renderSlate(e){const t=e||this.value,n=this.$editor;n.children=JSON.parse(t);const o=JSON.parse(t);n._state=d.default.observable(o),this.clearEditor(),this.name=this.genUid()},clearEditor(){this.$editor.selection=null}},render(){const e=arguments[0];return t.EDITOR_TO_ON_CHANGE.set(this.$editor,(()=>{this.$editor._state.__ob__.dep.notify();const e=C(this.$editor);e.focused=t.VueEditor.isFocused(this.$editor);let n=this.$editor._operation;n&&"set_selection"===n.type&&e.updateSelected(),this.$emit("onChange")})),e(M,{attrs:{name:this.name}},[this.$scopedSlots.default&&this.$scopedSlots.default({})])}}),k=a.component({props:{text:String,isTrailing:Boolean},render(){const e=arguments[0],{text:t,isTrailing:n=!1}=this;return e("span",{attrs:{"data-slate-string":!0}},[t,n?"\n":null])}}),B={functional:!0,render:(e,{props:t})=>{const{length:n=0,isLineBreak:o=!1}=t;return e("span",{attrs:{"data-slate-zero-width":o?"n":"z","data-slate-length":n}},["\ufeff",o?e("br"):null])}},V=a.component({props:{leaf:{type:Object},editor:Object},inject:["isLast","parent","text"],components:{TextString:k},data:()=>({}),render(){const e=arguments[0],{leaf:n,editor:r,isLast:i,parent:s,text:a}=this,d=t.VueEditor.findPath(r,a),l=o.Path.parent(d);return r.isVoid(s)?e(B,{attrs:{length:o.Node.string(s).length}}):""!==n.text||s.children[s.children.length-1]!==a||r.isInline(s)||""!==o.Editor.string(r,l)?""===n.text?e(B):i&&"\n"===n.text.slice(-1)?e(k,{attrs:{isTrailing:!0,text:n.text}}):e(k,{attrs:{text:n.text}}):e(B,{attrs:{isLineBreak:!0}})}}),I=a.component({props:{text:{type:Object},leaf:{type:Object}},inject:["renderLeaf"],components:{string:V,fragment:M},data:()=>({}),render(e){const{renderLeaf:n=R,text:o,leaf:r}=this;let i=e(V,{attrs:{text:o,editor:this.$editor,leaf:r}});r[t.PLACEHOLDER_SYMBOL]&&(i=e(M,[e("span",{attrs:{contenteditable:!1},style:{pointerEvents:"none",display:"inline-block",verticalAlign:"text-top",width:"0",maxWidth:"100%",whiteSpace:"nowrap",opacity:"0.333"}},[r.placeholder]),i]));return e(n({children:i,attributes:{"data-slate-leaf":!0},leaf:r,text:o}))}}),R=e=>a.component({render(){const t=arguments[0],{attributes:n,children:o}=e;return t("span",{attrs:{...n}},[o])}}),j=a.component({props:{text:{type:Object},isLast:Boolean,parent:{type:Object},decorations:{type:Array}},components:{leaf:I},inject:["decorate","placeholder"],provide(){return{text:this.text,isLast:this.isLast,parent:this.parent}},data:()=>({ref:null}),hooks(){const e=this.ref=m(null),{text:n}=this,o=this.$editor,r=t.VueEditor.findKey(o,n);E((()=>{e.current?(t.KEY_TO_ELEMENT.set(r,e.current),t.NODE_TO_ELEMENT.set(n,e.current),t.ELEMENT_TO_NODE.set(e.current,n)):(t.KEY_TO_ELEMENT.delete(r),t.NODE_TO_ELEMENT.delete(n))}))},render(e,n){const{text:r,placeholder:i}=this;let s=this.decorations;if(!s){const e=this.$editor,n=t.VueEditor.findPath(e,r);if(this.decorate&&(s=this.decorate([r,n])),i&&1===e.children.length&&1===Array.from(o.Node.texts(e)).length&&""===o.Node.string(e)){const n=o.Editor.start(e,[]);s.push({[t.PLACEHOLDER_SYMBOL]:!0,placeholder:i,anchor:n,focus:n})}}const a=o.Text.decorations(r,s),d=[];for(let t=0;t<a.length;t++){const n=a[t];d.push(e(n,{attrs:{leaf:n}}))}return e("span",{attrs:{"data-slate-node":"text"},ref:this.ref.id},[d])}}),K=a.component({props:{element:{type:Object}},inject:["readOnly","renderElement"],components:{Children:Y},data:()=>({ref:null}),mounted(){$(this,"element")},hooks(){const e=this.ref=m(null),n=this.element,o=t.VueEditor.findKey(this.$editor,n);E((()=>{e.current?(t.KEY_TO_ELEMENT.set(o,e.current),t.NODE_TO_ELEMENT.set(n,e.current),t.ELEMENT_TO_NODE.set(e.current,n)):(t.KEY_TO_ELEMENT.delete(o),t.NODE_TO_ELEMENT.delete(n))}))},render(e){const{element:n,renderElement:r=A,ref:i}=this,s=this.$editor,a=s.isInline(n);let d=e(Y,{attrs:{node:n}});const c={"data-slate-node":"element"};if(a&&(c["data-slate-inline"]=!0),!a&&o.Editor.hasInlines(s,n)){const e=o.Node.string(n),t=l.default(e);"rtl"===t&&(c.dir=t)}if(o.Editor.isVoid(s,n)){c["data-slate-void"]=!0,!this.readOnly&&a&&(c.contentEditable=!1);const r=a?"span":"div",[[i]]=o.Node.texts(n);d=this.readOnly?null:e(r,{attrs:{"data-slate-spacer":!0},style:{height:"0",color:"transparent",outline:"none",position:"absolute"}},[e(j,{attrs:{decorations:[],isLast:!1,parent:n,text:i}})]),t.NODE_TO_INDEX.set(i,0),t.NODE_TO_PARENT.set(i,n)}return e(r({element:n,attributes:c,children:d}),{ref:i.id})}}),A=e=>a.component({render(){const t=arguments[0],{attributes:n,children:o,element:r}=e;return t(this.$editor.isInline(r)?"span":"div",{attrs:{...n},style:{position:"relative"}},[o])}}),Y=a.component({props:{node:{type:Object}},components:{TextComponent:j,ElementComponent:K,fragment:M},mixins:[b],mounted(){$(this,"children")},render(){const e=arguments[0],n=this.$editor,{node:r}=this,i=t.VueEditor.findPath(n,r),s=o.Element.isElement(r)&&!n.isInline(r)&&o.Editor.hasInlines(n,r),a=[],d=o.Editor.isEditor(r)?r._state:r.children;let l=null;for(let c=0;c<d.length;c++){const h=d[c],u=t.VueEditor.findKey(n,h),p=i.concat(c);if(o.Editor.range(n,p),t.NODE_TO_INDEX.set(h,c),t.NODE_TO_PARENT.set(h,r),n._operation&&t.KEY_TO_VNODE.get(u)){const e=n._operation.path;if("split_node"===n._operation.type&&o.Path.isSibling(p,e)&&!o.Path.equals(p,e)&&!o.Path.equals(p,o.Path.next(e))){l=t.KEY_TO_VNODE.get(u),a.push(l);continue}if("merge_node"===n._operation.type){const n=o.Path.parent(e);if(o.Path.isSibling(p,n)&&!o.Path.isParent(p,e)){l=t.KEY_TO_VNODE.get(u),a.push(l);continue}}if("remove_node"===n._operation.type&&o.Path.isSibling(p,e)&&!o.Path.equals(p,e)){l=t.KEY_TO_VNODE.get(u),a.push(l);continue}}o.Element.isElement(h)?(l=e(K,{attrs:{element:h},key:u.id}),a.push(l)):(l=e(j,{attrs:{isLast:s&&c===d.length-1,parent:r,text:h},key:u.id}),a.push(l)),t.KEY_TO_VNODE.set(u,l)}return e(M,[a])}}),q=!(t.IS_FIREFOX||t.IS_EDGE_LEGACY),G=a.component({props:{autoFocus:Boolean,renderLeaf:Function,renderElement:Function,readOnly:Boolean,decorate:{type:Function,default:()=>[]},placeholder:String,spellCheck:Boolean,autoCorrect:String,autoCapitalize:String,onBeforeInput:{type:Function},onKeyDown:{type:Function},onClick:{type:Function},onCompositionEnd:{type:Function},onCompositionStart:{type:Function},onCut:{type:Function},onCopy:{type:Function},onDragOver:{type:Function},onDragStart:{type:Function},onDragStop:{type:Function},onPaste:{type:Function},onFocus:{type:Function},onBlur:{type:Function},onDrop:{type:Function}},components:{Children:Y},mixins:[b],provide(){return{renderLeaf:this.renderLeaf,renderElement:this.renderElement,decorate:this.decorate,readOnly:this.readOnly,placeholder:this.placeholder}},data:()=>({latestElement:null,isComposing:!1,isUpdatingSelection:!1,ref:null}),methods:{_onClick(e){t.EditableComponent.onClick(e,this.$editor,this)},onSelectionchange(){t.EditableComponent.onSelectionchange(this.$editor,this)},_onBeforeInput(e){t.EditableComponent.onBeforeInput(e,this.$editor,this)},_onCompositionEnd(e){t.EditableComponent.onCompositionEnd(e,this.$editor,this)},_onCompositionStart(e){t.EditableComponent.onCompositionStart(e,this.$editor,this)},_onKeyDown(e){t.EditableComponent.onKeyDown(e,this.$editor,this)},_onFocus(e){t.EditableComponent.onFocus(e,this.$editor,this)},_onBlur(e){t.EditableComponent.onBlur(e,this.$editor,this)},_onCopy(e){t.EditableComponent.onCopy(e,this.$editor,this)},_onPaste(e){t.EditableComponent.onPaste(e,this.$editor,this)},_onCut(e){t.EditableComponent.onCut(e,this.$editor,this)},_onDragOver(e){t.EditableComponent.onDragOver(e,this.$editor,this)},_onDragStart(e){t.EditableComponent.onDragStart(e,this.$editor,this)},_onDrop(e){t.EditableComponent.onDrop(e,this.$editor,this)}},hooks(){const e=this.ref=m(null),n=this.$editor;t.IS_READ_ONLY.set(n,this.readOnly);(()=>{E((()=>(document.addEventListener("selectionchange",this.onSelectionchange),()=>{document.removeEventListener("selectionchange",this.onSelectionchange)})))})(),E((()=>{e.current?(t.EDITOR_TO_ELEMENT.set(n,e.current),t.NODE_TO_ELEMENT.set(n,e.current),t.ELEMENT_TO_NODE.set(e.current,n)):t.NODE_TO_ELEMENT.delete(n)})),(()=>{E((()=>{const{selection:e}=n,r=window.getSelection();if(this.isComposing||!r||!t.VueEditor.isFocused(n))return;const i="None"!==r.type;if(!e&&!i)return;const s=t.EDITOR_TO_ELEMENT.get(n);let a=!1;if(s.contains(r.anchorNode)&&s.contains(r.focusNode)&&(a=!0),i&&a&&e&&o.Range.equals(t.VueEditor.toSlateRange(n,r),e))return;const d=t.VueEditor.toDOMNode(n,n);this.isUpdatingSelection=!0;const l=e&&t.VueEditor.toDOMRange(n,e);l?(o.Range.isBackward(e)?r.setBaseAndExtent(l.endContainer,l.endOffset,l.startContainer,l.startOffset):r.setBaseAndExtent(l.startContainer,l.startOffset,l.endContainer,l.endOffset),l.startContainer.parentElement):r.removeAllRanges(),setTimeout((()=>{l&&t.IS_FIREFOX&&d.focus(),this.isUpdatingSelection=!1}))}))})(),(()=>{E((()=>{e.current&&this.autoFocus&&setTimeout((()=>{e.current.focus()}),0)}),[this.autoFocus])})(),t.IS_FIREFOX&&E((()=>{t.addOnBeforeInput(e.current,!0)}),[])},render(){const e=arguments[0],t=this.$editor,{ref:n}=this,o={click:this._onClick,keydown:this._onKeyDown,focus:this._onFocus,blur:this._onBlur,beforeinput:this._onBeforeInput,copy:this._onCopy,cut:this._onCut,compositionend:this._onCompositionEnd,compositionstart:this._onCompositionStart,dragover:this._onDragOver,dragstart:this._onDragStart,drop:this._onDrop,paste:this._onPaste},r={spellcheck:q?this.spellCheck:void 0,autocorrect:q?this.autoCorrect:void 0,autocapitalize:q?this.autoCapitalize:void 0};return e("div",{attrs:{"data-gramm":!1,role:this.readOnly?void 0:"textbox",contenteditable:!this.readOnly,"data-slate-editor":!0,"data-slate-node":"value",...r},ref:n.id,style:{outline:"none",whiteSpace:"pre-wrap",wordWrap:"break-word"},on:{...o}},[e(Y,{attrs:{node:t,selection:t.selection}})])}});Object.defineProperty(exports,"VueEditor",{enumerable:!0,get:function(){return t.VueEditor}}),exports.Editable=G,exports.FocusedMixin=D,exports.ReadOnlyMixin=v,exports.SelectedMixin=S,exports.Slate=F,exports.SlateMixin=b,exports.SlatePlugin=w,exports.Transforms=y,exports.elementWatcherPlugin=$,exports.fragment=M,exports.getGvm=C,exports.useEffect=E,exports.useRef=m,exports.vueRuntime=(e,...t)=>{const n=N(),o=e(...t);return n(),o},exports.vueRuntimeFunc=x;
//# sourceMappingURL=index.cjs.js.map

@@ -1,2 +0,2 @@

import*as t from"vue-tsx-support";import{VueEditor as e,EDITOR_TO_GVM as n,NODE_TO_KEY as r,withVue as o,GVM_TO_EDITOR as i,EDITOR_TO_ON_CHANGE as a,PLACEHOLDER_SYMBOL as s,KEY_TO_ELEMENT as c,NODE_TO_ELEMENT as u,ELEMENT_TO_NODE as l,NODE_TO_INDEX as d,NODE_TO_PARENT as f,KEY_TO_VNODE as h,EditableComponent as p,IS_READ_ONLY as m,IS_FIREFOX as v,IS_EDGE_LEGACY as g,EDITOR_TO_ELEMENT as y,addOnBeforeInput as b}from"@hydrabot/slate-vue-shared";export{VueEditor}from"@hydrabot/slate-vue-shared";import _ from"vue";import{Transforms as S,Text as $,Editor as O,Node as x,Path as C,createEditor as w,Range as E,Element as k}from"slate";import j from"direction";var B=null,D=!1,F=0;function N(){if(!B)throw new Error("invalid hooks call: hooks can only be called in a function passed to withHooks.")}function P(t){return t._isVue?t.$el:t}function A(t,e){N();var n=++F;if(D){var r=function t(){var e=t.current;e&&(e(),t.current=null)},o=function t(){var e=t.current;e&&(r.current=e.call(this),t.current=null)};o.current=t,B._effectStore[n]={effect:o,cleanup:r,deps:e},B.$on("hook:mounted",o),B.$on("hook:destroyed",r),(!e||e.length>0)&&B.$on("hook:updated",o)}else{var i=B._effectStore[n],a=i.effect,s=i.cleanup,c=i.deps,u=void 0===c?[]:c;i.deps=e,e&&!e.some((function(t,e){return t!==u[e]}))||(s(),a.current=t)}}function L(t){N();var e=(++F).toString(),n=B._refsStore;return B.$on("hook:mounted",(function(){this.$refs[e]&&(n[e].current=P(this.$refs[e]))})),B.$on("hook:updated",(function(){this.$refs[e]&&(n[e].current=P(this.$refs[e]))})),D?n[e]={current:t,id:e}:n[e]}function T(t){t.mixin({beforeCreate:function(){var t=this.$options,e=t.hooks,n=t.data;e&&(this._effectStore={},this._refsStore={},this._computedStore={},this.$options.data=function(){var t=n?n.call(this):{};return t._state={},t})},beforeMount:function(){var t=this.$options,e=t.hooks,n=t.render;e&&n&&(this.$options.render=function(t){F=0,B=this,D=!this._vnode;var r=e.call(this,this.$props);Object.assign(this._self,r);var o=n.call(this,t);return B=null,o})}})}function I(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function M(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?I(Object(n),!0).forEach((function(e){J(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):I(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function J(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function K(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==n)return;var r,o,i=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(i.push(r.value),!e||i.length!==e);a=!0);}catch(t){s=!0,o=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw o}}return i}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return z(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return z(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function z(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var R,U=function(t){return O.isEditor(t)?t._state:t.children},q=function(t,e){if($.isText(t))throw new Error("Cannot get the child of a text node: ".concat(JSON.stringify(t)));var n=U(t)[e];if(null==n)throw new Error("Cannot get child at index `".concat(e,"` in node: ").concat(JSON.stringify(t)));return n},V=function(t,e){for(var n=t,r=0;r<e.length;r++){var o=e[r],i=U(n);if($.isText(n)||!i[o])return!1;n=i[o]}return!0},W=function(t,e){for(var n=t,r=0;r<e.length;r++){var o=e[r],i=U(n);if($.isText(n)||!i[o])throw new Error("Cannot find a descendant at path [".concat(e,"] in node: ").concat(JSON.stringify(t)));n=i[o]}return n},H=function(t,e){for(var n=e.slice(),r=x.get(t,n),o=U(r);r&&!$.isText(r)&&0!==o.length;)r=o[0],n.push(0);return[r,n]},G=function(t,e){for(var n=e.slice(),r=x.get(t,n),o=U(r);r&&!$.isText(r)&&0!==o.length;){var i=o.length-1;r=o[i],n.push(i)}return[r,n]},Q=function*(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.pass,r=e.reverse,o=void 0!==r&&r,i=e.from,a=void 0===i?[]:i,s=e.to,c=new Set,u=[],l=t;!s||!(o?C.isBefore(u,s):C.isAfter(u,s));)if(c.has(l)||(yield[l,u]),c.has(l)||$.isText(l)||0===U(l).length||null!=n&&!1!==n([l,u])){if(0===u.length)break;if(!o){var d=C.next(u);if(x.has(t,d)){u=d,l=x.get(t,u);continue}}if(o&&0!==u[u.length-1]){var f=C.previous(u);u=f,l=x.get(t,u)}else u=C.parent(u),l=x.get(t,u),c.add(l)}else{c.add(l);var h=o?U(l).length-1:0;C.isAncestor(u,a)&&(h=a[u.length]),u=u.concat(h),l=x.get(t,u)}},X=(R=S.select,S.select=function(t,e){var n;return e.__ob__&&(n=e,e=JSON.parse(JSON.stringify(n))),R(t,e)},S),Y=function(){var t=x.get,e=x.nodes,n=x.has,r=x.first,o=x.child,i=x.last;return x.child=q,x.has=V,x.get=W,x.first=H,x.last=G,x.nodes=Q,function(){x.get=t,x.nodes=e,x.has=n,x.first=r,x.child=o,x.last=i}},Z=function(t){return function(){var e=Y(),n=t.apply(void 0,arguments);return e(),n}},tt=function(t){for(var e=Y(),n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];var i=t.apply(void 0,r);return e(),i};e.toDOMRange=Z(e.toDOMRange);var et=function(t){return n.get(t)},nt=function(t,e){var n=t._watcher.update;t._watcher.update=function(){var r=t.$editor._operation;if(r){if("remove_text"===r.type||"insert_text"===r.type||"set_selection"===r.type)return;if("remove_node"===r.type&&"element"===e)return}n.call(t._watcher)}},rt=t.component({mounted:function(){this.$editor._state.__ob__.dep.addSub(this._watcher)}}),ot=t.component({created:function(){var t=et(this.$editor),e=this.element||this.node;t.selected.elements.push(e)},computed:{selected:function(){if(this.element){var t=et(this.$editor),e=r.get(this.element);return!!e&&t.selected[e.id]}return!1}}}),it=t.component({computed:{readOnly:function(){return e.isReadOnly(this.$editor)}}}),at=t.component({computed:{focused:function(){return et(this.$editor).focused}}}),st=function(){var t=o(w()),a=new _({data:{focused:!1,selected:{elements:[]}},methods:{updateSelected:function(){var t=this,n=i.get(this),o=n.selection;o&&this.selected.elements.forEach((function(i){var a=r.get(i);if(a){var s=a.id,c=e.findPath(n,i),u=O.range(n,c),l=E.intersection(u,o);t.$set(t.selected,s,!!l)}}))}}});return n.set(t,a),i.set(a,t),t},ct={install:function(t,e){t.mixin({beforeCreate:function(){this.$editor||(this.$options.components.Slate?(this.$editor=st(),null!=e&&e.editorCreated&&e.editorCreated.call(this,this.$editor)):this.$editor=this.$parent&&this.$parent.$editor)}}),t.use(T)}},ut=function(t,e,n){Object.defineProperty(t,e,{configurable:!0,get:function(){return n},set:function(t){console.warn("tried to set frozen property ".concat(e," with ").concat(t))}})},lt=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;Object.defineProperty(t,e,{configurable:!0,writable:!0,value:n})},dt=t.component({abstract:!0,name:"Fragment",props:{name:{type:String,default:function(){return Math.floor(Date.now()*Math.random()).toString(16)}}},mounted:function(){var t=this.$el,e=t.parentNode,n=document.createComment("fragment#".concat(this.name,"#head")),r=document.createComment("fragment#".concat(this.name,"#tail"));e.insertBefore(n,t),e.insertBefore(r,t),t.appendChild=function(n){e.insertBefore(n,r),ut(n,"parentNode",t)},t.insertBefore=function(n,r){e.insertBefore(n,r),ut(n,"parentNode",t)},t.removeChild=function(t){e.removeChild(t),lt(t,"parentNode")},Array.from(t.childNodes).forEach((function(e){return t.appendChild(e)})),e.removeChild(t),ut(t,"parentNode",e),ut(t,"nextSibling",r.nextSibling),ut(r,"parentNode",t);var o=e.insertBefore;e.insertBefore=function(r,i){o.call(e,r,i!==t?i:n)};var i=e.removeChild;e.removeChild=function(a){if(a===t){for(;n.nextSibling!==r;)t.removeChild(n.nextSibling);e.removeChild(n),e.removeChild(r),lt(t,"parentNode"),e.insertBefore=o,e.removeChild=i}else i.call(e,a)}},render:function(t){var e=this.$slots.default;return t("div",{key:this.name},e)}}),ft=t.component({name:"slate",props:{value:String},components:{fragment:dt},data:function(){return{name:null}},created:function(){var t=this;this.renderSlate(),this.$editor.clear=function(){t.renderSlate(JSON.stringify([{children:[{text:""}]}]))}},watch:{value:function(t,e){t!==e&&this.renderSlate(t)}},methods:{genUid:function(){return Math.floor(Date.now()*Math.random()).toString(16)},renderSlate:function(t){var e=t||this.value,n=this.$editor;n.children=JSON.parse(e);var r=JSON.parse(e);n._state=_.observable(r),this.clearEditor(),this.name=this.genUid()},clearEditor:function(){this.$editor.selection=null}},render:function(){var t=this,n=arguments[0];return a.set(this.$editor,(function(){t.$editor._state.__ob__.dep.notify();var n=et(t.$editor);n.focused=e.isFocused(t.$editor);var r=t.$editor._operation;r&&"set_selection"===r.type&&n.updateSelected(),t.$emit("onChange")})),n(dt,{attrs:{name:this.name}},[this.$scopedSlots.default&&this.$scopedSlots.default({})])}}),ht=t.component({props:{text:String,isTrailing:Boolean},render:function(){var t=arguments[0],e=this.text,n=this.isTrailing,r=void 0!==n&&n;return t("span",{attrs:{"data-slate-string":!0}},[e,r?"\n":null])}}),pt={functional:!0,render:function(t,e){var n=e.props,r=n.length,o=void 0===r?0:r,i=n.isLineBreak,a=void 0!==i&&i;return t("span",{attrs:{"data-slate-zero-width":a?"n":"z","data-slate-length":o}},["\ufeff",a?t("br"):null])}},mt=t.component({props:{leaf:{type:Object},editor:Object},inject:["isLast","parent","text"],components:{TextString:ht},data:function(){return{}},render:function(){var t=arguments[0],n=this.leaf,r=this.editor,o=this.isLast,i=this.parent,a=this.text,s=e.findPath(r,a),c=C.parent(s);return r.isVoid(i)?t(pt,{attrs:{length:x.string(i).length}}):""!==n.text||i.children[i.children.length-1]!==a||r.isInline(i)||""!==O.string(r,c)?""===n.text?t(pt):o&&"\n"===n.text.slice(-1)?t(ht,{attrs:{isTrailing:!0,text:n.text}}):t(ht,{attrs:{text:n.text}}):t(pt,{attrs:{isLineBreak:!0}})}}),vt=t.component({props:{text:{type:Object},leaf:{type:Object}},inject:["renderLeaf"],components:{string:mt,fragment:dt},data:function(){return{}},render:function(t){var e=this.renderLeaf,n=void 0===e?gt:e,r=this.text,o=this.leaf,i=t(mt,{attrs:{text:r,editor:this.$editor,leaf:o}});o[s]&&(i=t(dt,[t("span",{attrs:{contenteditable:!1},style:{pointerEvents:"none",display:"inline-block",verticalAlign:"text-top",width:"0",maxWidth:"100%",whiteSpace:"nowrap",opacity:"0.333"}},[o.placeholder]),i]));return t(n({children:i,attributes:{"data-slate-leaf":!0},leaf:o,text:r}))}}),gt=function(e){return t.component({render:function(){var t=arguments[0],n=e.attributes,r=e.children;return t("span",{attrs:M({},n)},[r])}})},yt=t.component({props:{text:{type:Object},isLast:Boolean,parent:{type:Object},decorations:{type:Array}},components:{leaf:vt},inject:["decorate","placeholder"],provide:function(){return{text:this.text,isLast:this.isLast,parent:this.parent}},data:function(){return{ref:null}},hooks:function(){var t=this.ref=L(null),n=this.text,r=this.$editor,o=e.findKey(r,n);A((function(){t.current?(c.set(o,t.current),u.set(n,t.current),l.set(t.current,n)):(c.delete(o),u.delete(n))}))},render:function(t,n){var r=this.text,o=this.placeholder,i=this.decorations;if(!i){var a=this.$editor,c=e.findPath(a,r);if(this.decorate&&(i=this.decorate([r,c])),o&&1===a.children.length&&1===Array.from(x.texts(a)).length&&""===x.string(a)){var u,l=O.start(a,[]);i.push((J(u={},s,!0),J(u,"placeholder",o),J(u,"anchor",l),J(u,"focus",l),u))}}for(var d=$.decorations(r,i),f=[],h=0;h<d.length;h++){var p=d[h];f.push(t(vt,{attrs:{leaf:p}}))}return t("span",{attrs:{"data-slate-node":"text"},ref:this.ref.id},[f])}}),bt=t.component({props:{element:{type:Object}},inject:["readOnly","renderElement"],components:{Children:St},data:function(){return{ref:null}},mounted:function(){nt(this,"element")},hooks:function(){var t=this.ref=L(null),n=this.element,r=e.findKey(this.$editor,n);A((function(){t.current?(c.set(r,t.current),u.set(n,t.current),l.set(t.current,n)):(c.delete(r),u.delete(n))}))},render:function(t){var e=this.element,n=this.renderElement,r=void 0===n?_t:n,o=this.ref,i=this.$editor,a=i.isInline(e),s=t(St,{attrs:{node:e}}),c={"data-slate-node":"element"};if(a&&(c["data-slate-inline"]=!0),!a&&O.hasInlines(i,e)){var u=x.string(e),l=j(u);"rtl"===l&&(c.dir=l)}if(O.isVoid(i,e)){c["data-slate-void"]=!0,!this.readOnly&&a&&(c.contentEditable=!1);var h=a?"span":"div",p=K(x.texts(e),1),m=K(p[0],1)[0];s=this.readOnly?null:t(h,{attrs:{"data-slate-spacer":!0},style:{height:"0",color:"transparent",outline:"none",position:"absolute"}},[t(yt,{attrs:{decorations:[],isLast:!1,parent:e,text:m}})]),d.set(m,0),f.set(m,e)}return t(r({element:e,attributes:c,children:s}),{ref:o.id})}}),_t=function(e){return t.component({render:function(){var t=arguments[0],n=e.attributes,r=e.children,o=e.element,i=this.$editor,a=i.isInline(o)?"span":"div";return t(a,{attrs:M({},n),style:{position:"relative"}},[r])}})},St=t.component({props:{node:{type:Object}},components:{TextComponent:yt,ElementComponent:bt,fragment:dt},mixins:[rt],mounted:function(){nt(this,"children")},render:function(){for(var t=arguments[0],n=this.$editor,r=this.node,o=e.findPath(n,r),i=k.isElement(r)&&!n.isInline(r)&&O.hasInlines(n,r),a=[],s=O.isEditor(r)?r._state:r.children,c=null,u=0;u<s.length;u++){var l=s[u],p=e.findKey(n,l),m=o.concat(u);if(O.range(n,m),d.set(l,u),f.set(l,r),n._operation&&h.get(p)){var v=n._operation.path;if("split_node"===n._operation.type&&C.isSibling(m,v)&&!C.equals(m,v)&&!C.equals(m,C.next(v))){c=h.get(p),a.push(c);continue}if("merge_node"===n._operation.type){var g=C.parent(v);if(C.isSibling(m,g)&&!C.isParent(m,v)){c=h.get(p),a.push(c);continue}}if("remove_node"===n._operation.type&&C.isSibling(m,v)&&!C.equals(m,v)){c=h.get(p),a.push(c);continue}}k.isElement(l)?(c=t(bt,{attrs:{element:l},key:p.id}),a.push(c)):(c=t(yt,{attrs:{isLast:i&&u===s.length-1,parent:r,text:l},key:p.id}),a.push(c)),h.set(p,c)}return t(dt,[a])}}),$t=!(v||g),Ot=t.component({props:{autoFocus:Boolean,renderLeaf:Function,renderElement:Function,readOnly:Boolean,decorate:{type:Function,default:function(){return[]}},placeholder:String,spellCheck:Boolean,autoCorrect:String,autoCapitalize:String,onBeforeInput:{type:Function},onKeyDown:{type:Function},onClick:{type:Function},onCompositionEnd:{type:Function},onCompositionStart:{type:Function},onCut:{type:Function},onCopy:{type:Function},onDragOver:{type:Function},onDragStart:{type:Function},onDragStop:{type:Function},onPaste:{type:Function},onFocus:{type:Function},onBlur:{type:Function},onDrop:{type:Function}},components:{Children:St},mixins:[rt],provide:function(){return{renderLeaf:this.renderLeaf,renderElement:this.renderElement,decorate:this.decorate,readOnly:this.readOnly,placeholder:this.placeholder}},data:function(){return{latestElement:null,isComposing:!1,isUpdatingSelection:!1,ref:null}},methods:{_onClick:function(t){p.onClick(t,this.$editor,this)},onSelectionchange:function(){p.onSelectionchange(this.$editor,this)},_onBeforeInput:function(t){p.onBeforeInput(t,this.$editor,this)},_onCompositionEnd:function(t){p.onCompositionEnd(t,this.$editor,this)},_onCompositionStart:function(t){p.onCompositionStart(t,this.$editor,this)},_onKeyDown:function(t){p.onKeyDown(t,this.$editor,this)},_onFocus:function(t){p.onFocus(t,this.$editor,this)},_onBlur:function(t){p.onBlur(t,this.$editor,this)},_onCopy:function(t){p.onCopy(t,this.$editor,this)},_onPaste:function(t){p.onPaste(t,this.$editor,this)},_onCut:function(t){p.onCut(t,this.$editor,this)},_onDragOver:function(t){p.onDragOver(t,this.$editor,this)},_onDragStart:function(t){p.onDragStart(t,this.$editor,this)},_onDrop:function(t){p.onDrop(t,this.$editor,this)}},hooks:function(){var t=this,n=this.ref=L(null),r=this.$editor;m.set(r,this.readOnly);A((function(){return document.addEventListener("selectionchange",t.onSelectionchange),function(){document.removeEventListener("selectionchange",t.onSelectionchange)}})),A((function(){n.current?(y.set(r,n.current),u.set(r,n.current),l.set(n.current,r)):u.delete(r)})),A((function(){var n=r.selection,o=window.getSelection();if(!t.isComposing&&o&&e.isFocused(r)){var i="None"!==o.type;if(n||i){var a=y.get(r),s=!1;if(a.contains(o.anchorNode)&&a.contains(o.focusNode)&&(s=!0),!(i&&s&&n&&E.equals(e.toSlateRange(r,o),n))){var c=e.toDOMNode(r,r);t.isUpdatingSelection=!0;var u=n&&e.toDOMRange(r,n);u?(E.isBackward(n)?o.setBaseAndExtent(u.endContainer,u.endOffset,u.startContainer,u.startOffset):o.setBaseAndExtent(u.startContainer,u.startOffset,u.endContainer,u.endOffset),u.startContainer.parentElement):o.removeAllRanges(),setTimeout((function(){u&&v&&c.focus(),t.isUpdatingSelection=!1}))}}}})),A((function(){n.current&&t.autoFocus&&setTimeout((function(){n.current.focus()}),0)}),[t.autoFocus]),v&&A((function(){b(n.current,!0)}),[])},render:function(){var t=arguments[0],e=this.$editor,n=this.ref,r={click:this._onClick,keydown:this._onKeyDown,focus:this._onFocus,blur:this._onBlur,beforeinput:this._onBeforeInput,copy:this._onCopy,cut:this._onCut,compositionend:this._onCompositionEnd,compositionstart:this._onCompositionStart,dragover:this._onDragOver,dragstart:this._onDragStart,drop:this._onDrop,paste:this._onPaste},o={spellcheck:$t?this.spellCheck:void 0,autocorrect:$t?this.autoCorrect:void 0,autocapitalize:$t?this.autoCapitalize:void 0};return t("div",{attrs:M({"data-gramm":!1,role:this.readOnly?void 0:"textbox",contenteditable:!this.readOnly,"data-slate-editor":!0,"data-slate-node":"value"},o),ref:n.id,style:{outline:"none",whiteSpace:"pre-wrap",wordWrap:"break-word"},on:M({},r)},[t(St,{attrs:{node:e,selection:e.selection}})])}});export{Ot as Editable,at as FocusedMixin,it as ReadOnlyMixin,ot as SelectedMixin,ft as Slate,rt as SlateMixin,ct as SlatePlugin,X as Transforms,nt as elementWatcherPlugin,dt as fragment,et as getGvm,A as useEffect,L as useRef,tt as vueRuntime,Z as vueRuntimeFunc};
import*as t from"vue-tsx-support";import{VueEditor as e,NODE_TO_KEY as n,EDITOR_TO_GVM as o,withVue as r,GVM_TO_EDITOR as s,EDITOR_TO_ON_CHANGE as i,PLACEHOLDER_SYMBOL as a,KEY_TO_ELEMENT as l,NODE_TO_ELEMENT as c,ELEMENT_TO_NODE as d,NODE_TO_INDEX as h,NODE_TO_PARENT as p,KEY_TO_VNODE as u,EditableComponent as f,IS_READ_ONLY as m,IS_FIREFOX as g,IS_EDGE_LEGACY as y,EDITOR_TO_ELEMENT as $,addOnBeforeInput as _}from"@hydrabot/slate-vue-shared";export{VueEditor}from"@hydrabot/slate-vue-shared";import S from"vue";import{Transforms as x,Text as C,Node as v,Path as b,Editor as O,createEditor as w,Range as E,Element as k}from"slate";import B from"direction";let F=null,D=!1,N=0;function L(){if(!F)throw new Error("invalid hooks call: hooks can only be called in a function passed to withHooks.")}function j(t){return t._isVue?t.$el:t}function T(t,e){L();const n=++N;if(D){const o=()=>{const{current:t}=o;t&&(t(),o.current=null)},r=function(){const{current:t}=r;t&&(o.current=t.call(this),r.current=null)};r.current=t,F._effectStore[n]={effect:r,cleanup:o,deps:e},F.$on("hook:mounted",r),F.$on("hook:destroyed",o),(!e||e.length>0)&&F.$on("hook:updated",r)}else{const o=F._effectStore[n],{effect:r,cleanup:s,deps:i=[]}=o;o.deps=e,e&&!e.some(((t,e)=>t!==i[e]))||(s(),r.current=t)}}function P(t){L();const e=(++N).toString(),{_refsStore:n}=F;return F.$on("hook:mounted",(function(){this.$refs[e]&&(n[e].current=j(this.$refs[e]))})),F.$on("hook:updated",(function(){this.$refs[e]&&(n[e].current=j(this.$refs[e]))})),D?n[e]={current:t,id:e}:n[e]}function I(t){t.mixin({beforeCreate(){const{hooks:t,data:e}=this.$options;t&&(this._effectStore={},this._refsStore={},this._computedStore={},this.$options.data=function(){const t=e?e.call(this):{};return t._state={},t})},beforeMount(){const{hooks:t,render:e}=this.$options;t&&e&&(this.$options.render=function(n){N=0,F=this,D=!this._vnode;const o=t.call(this,this.$props);Object.assign(this._self,o);const r=e.call(this,n);return F=null,r})}})}const A=t=>O.isEditor(t)?t._state:t.children,M={child(t,e){if(C.isText(t))throw new Error(`Cannot get the child of a text node: ${JSON.stringify(t)}`);const n=A(t)[e];if(null==n)throw new Error(`Cannot get child at index \`${e}\` in node: ${JSON.stringify(t)}`);return n},has(t,e){let n=t;for(let t=0;t<e.length;t++){const o=e[t],r=A(n);if(C.isText(n)||!r[o])return!1;n=r[o]}return!0},get(t,e){let n=t;for(let o=0;o<e.length;o++){const r=e[o],s=A(n);if(C.isText(n)||!s[r])throw new Error(`Cannot find a descendant at path [${e}] in node: ${JSON.stringify(t)}`);n=s[r]}return n},first(t,e){const n=e.slice();let o=v.get(t,n);const r=A(o);for(;o&&!C.isText(o)&&0!==r.length;)o=r[0],n.push(0);return[o,n]},last(t,e){const n=e.slice();let o=v.get(t,n);const r=A(o);for(;o&&!C.isText(o)&&0!==r.length;){const t=r.length-1;o=r[t],n.push(t)}return[o,n]},*nodes(t,e={}){const{pass:n,reverse:o=!1}=e,{from:r=[],to:s}=e,i=new Set;let a=[],l=t;for(;!s||!(o?b.isBefore(a,s):b.isAfter(a,s));)if(i.has(l)||(yield[l,a]),i.has(l)||C.isText(l)||0===A(l).length||null!=n&&!1!==n([l,a])){if(0===a.length)break;if(!o){const e=b.next(a);if(v.has(t,e)){a=e,l=v.get(t,a);continue}}if(o&&0!==a[a.length-1]){a=b.previous(a),l=v.get(t,a)}else a=b.parent(a),l=v.get(t,a),i.add(l)}else{i.add(l);let e=o?A(l).length-1:0;b.isAncestor(a,r)&&(e=r[a.length]),a=a.concat(e),l=v.get(t,a)}}},J=(()=>{const{select:t}=x;return x.select=(e,n)=>{var o;return n.__ob__&&(o=n,n=JSON.parse(JSON.stringify(o))),t(e,n)},x})(),K=()=>{const{get:t,nodes:e,has:n,first:o,child:r,last:s}=v;return v.child=M.child,v.has=M.has,v.get=M.get,v.first=M.first,v.last=M.last,v.nodes=M.nodes,()=>{v.get=t,v.nodes=e,v.has=n,v.first=o,v.child=r,v.last=s}},z=t=>(...e)=>{const n=K(),o=t(...e);return n(),o},R=(t,...e)=>{const n=K(),o=t(...e);return n(),o};e.toDOMRange=z(e.toDOMRange);const U=()=>new S({data:{focused:!1,selected:{elements:[]}},methods:{updateSelected(){const t=s.get(this),{selection:o}=t;o&&this.selected.elements.forEach((r=>{const s=n.get(r);if(s){const{id:n}=s,i=e.findPath(t,r),a=O.range(t,i),l=E.intersection(a,o);this.$set(this.selected,n,!!l)}}))}}}),q=t=>o.get(t),V=(t,e)=>{const n=t._watcher.update;t._watcher.update=()=>{const o=t.$editor._operation;if(o){if("remove_text"===o.type||"insert_text"===o.type||"set_selection"===o.type)return;if("remove_node"===o.type&&"element"===e)return}n.call(t._watcher)}},W=t.component({mounted(){this.$editor._state.__ob__.dep.addSub(this._watcher)}}),H=t.component({created(){const t=q(this.$editor),e=this.element||this.node;t.selected.elements.push(e)},computed:{selected(){if(this.element){const t=q(this.$editor),e=n.get(this.element);return!!e&&t.selected[e.id]}return!1}}}),G=t.component({computed:{readOnly(){return e.isReadOnly(this.$editor)}}}),Q=t.component({computed:{focused(){return q(this.$editor).focused}}}),X={install(t,e){t.mixin({beforeCreate(){this.$editor||(this.$options.components.Slate?(this.$editor=(()=>{const t=r(w()),e=U();return o.set(t,e),s.set(e,t),t})(),null!=e&&e.editorCreated&&e.editorCreated.call(this,this.$editor)):this.$editor=this.$parent&&this.$parent.$editor)}}),t.use(I)}},Y=(t,e,n)=>{Object.defineProperty(t,e,{configurable:!0,get:()=>n,set(t){console.warn(`tried to set frozen property ${e} with ${t}`)}})},Z=(t,e,n=null)=>{Object.defineProperty(t,e,{configurable:!0,writable:!0,value:n})},tt=t.component({abstract:!0,name:"Fragment",props:{name:{type:String,default:()=>Math.floor(Date.now()*Math.random()).toString(16)}},mounted(){const t=this.$el,e=t.parentNode,n=document.createComment(`fragment#${this.name}#head`),o=document.createComment(`fragment#${this.name}#tail`);e.insertBefore(n,t),e.insertBefore(o,t),t.appendChild=n=>{e.insertBefore(n,o),Y(n,"parentNode",t)},t.insertBefore=(n,o)=>{e.insertBefore(n,o),Y(n,"parentNode",t)},t.removeChild=t=>{e.removeChild(t),Z(t,"parentNode")},Array.from(t.childNodes).forEach((e=>t.appendChild(e))),e.removeChild(t),Y(t,"parentNode",e),Y(t,"nextSibling",o.nextSibling),Y(o,"parentNode",t);const r=e.insertBefore;e.insertBefore=(o,s)=>{r.call(e,o,s!==t?s:n)};const s=e.removeChild;e.removeChild=i=>{if(i===t){for(;n.nextSibling!==o;)t.removeChild(n.nextSibling);e.removeChild(n),e.removeChild(o),Z(t,"parentNode"),e.insertBefore=r,e.removeChild=s}else s.call(e,i)}},render(t){const e=this.$slots.default;return t("div",{key:this.name},e)}}),et=t.component({name:"slate",props:{value:String},components:{fragment:tt},data:()=>({name:null}),created(){this.renderSlate(),this.$editor.clear=()=>{this.renderSlate(JSON.stringify([{children:[{text:""}]}]))}},watch:{value(t,e){t!==e&&this.renderSlate(t)}},methods:{genUid:()=>Math.floor(Date.now()*Math.random()).toString(16),renderSlate(t){const e=t||this.value,n=this.$editor;n.children=JSON.parse(e);const o=JSON.parse(e);n._state=S.observable(o),this.clearEditor(),this.name=this.genUid()},clearEditor(){this.$editor.selection=null}},render(){const t=arguments[0];return i.set(this.$editor,(()=>{this.$editor._state.__ob__.dep.notify();const t=q(this.$editor);t.focused=e.isFocused(this.$editor);let n=this.$editor._operation;n&&"set_selection"===n.type&&t.updateSelected(),this.$emit("onChange")})),t(tt,{attrs:{name:this.name}},[this.$scopedSlots.default&&this.$scopedSlots.default({})])}}),nt=t.component({props:{text:String,isTrailing:Boolean},render(){const t=arguments[0],{text:e,isTrailing:n=!1}=this;return t("span",{attrs:{"data-slate-string":!0}},[e,n?"\n":null])}}),ot={functional:!0,render:(t,{props:e})=>{const{length:n=0,isLineBreak:o=!1}=e;return t("span",{attrs:{"data-slate-zero-width":o?"n":"z","data-slate-length":n}},["\ufeff",o?t("br"):null])}},rt=t.component({props:{leaf:{type:Object},editor:Object},inject:["isLast","parent","text"],components:{TextString:nt},data:()=>({}),render(){const t=arguments[0],{leaf:n,editor:o,isLast:r,parent:s,text:i}=this,a=e.findPath(o,i),l=b.parent(a);return o.isVoid(s)?t(ot,{attrs:{length:v.string(s).length}}):""!==n.text||s.children[s.children.length-1]!==i||o.isInline(s)||""!==O.string(o,l)?""===n.text?t(ot):r&&"\n"===n.text.slice(-1)?t(nt,{attrs:{isTrailing:!0,text:n.text}}):t(nt,{attrs:{text:n.text}}):t(ot,{attrs:{isLineBreak:!0}})}}),st=t.component({props:{text:{type:Object},leaf:{type:Object}},inject:["renderLeaf"],components:{string:rt,fragment:tt},data:()=>({}),render(t){const{renderLeaf:e=it,text:n,leaf:o}=this;let r=t(rt,{attrs:{text:n,editor:this.$editor,leaf:o}});o[a]&&(r=t(tt,[t("span",{attrs:{contenteditable:!1},style:{pointerEvents:"none",display:"inline-block",verticalAlign:"text-top",width:"0",maxWidth:"100%",whiteSpace:"nowrap",opacity:"0.333"}},[o.placeholder]),r]));return t(e({children:r,attributes:{"data-slate-leaf":!0},leaf:o,text:n}))}}),it=e=>t.component({render(){const t=arguments[0],{attributes:n,children:o}=e;return t("span",{attrs:{...n}},[o])}}),at=t.component({props:{text:{type:Object},isLast:Boolean,parent:{type:Object},decorations:{type:Array}},components:{leaf:st},inject:["decorate","placeholder"],provide(){return{text:this.text,isLast:this.isLast,parent:this.parent}},data:()=>({ref:null}),hooks(){const t=this.ref=P(null),{text:n}=this,o=this.$editor,r=e.findKey(o,n);T((()=>{t.current?(l.set(r,t.current),c.set(n,t.current),d.set(t.current,n)):(l.delete(r),c.delete(n))}))},render(t,n){const{text:o,placeholder:r}=this;let s=this.decorations;if(!s){const t=this.$editor,n=e.findPath(t,o);if(this.decorate&&(s=this.decorate([o,n])),r&&1===t.children.length&&1===Array.from(v.texts(t)).length&&""===v.string(t)){const e=O.start(t,[]);s.push({[a]:!0,placeholder:r,anchor:e,focus:e})}}const i=C.decorations(o,s),l=[];for(let e=0;e<i.length;e++){const n=i[e];l.push(t(n,{attrs:{leaf:n}}))}return t("span",{attrs:{"data-slate-node":"text"},ref:this.ref.id},[l])}}),lt=t.component({props:{element:{type:Object}},inject:["readOnly","renderElement"],components:{Children:dt},data:()=>({ref:null}),mounted(){V(this,"element")},hooks(){const t=this.ref=P(null),n=this.element,o=e.findKey(this.$editor,n);T((()=>{t.current?(l.set(o,t.current),c.set(n,t.current),d.set(t.current,n)):(l.delete(o),c.delete(n))}))},render(t){const{element:e,renderElement:n=ct,ref:o}=this,r=this.$editor,s=r.isInline(e);let i=t(dt,{attrs:{node:e}});const a={"data-slate-node":"element"};if(s&&(a["data-slate-inline"]=!0),!s&&O.hasInlines(r,e)){const t=v.string(e),n=B(t);"rtl"===n&&(a.dir=n)}if(O.isVoid(r,e)){a["data-slate-void"]=!0,!this.readOnly&&s&&(a.contentEditable=!1);const n=s?"span":"div",[[o]]=v.texts(e);i=this.readOnly?null:t(n,{attrs:{"data-slate-spacer":!0},style:{height:"0",color:"transparent",outline:"none",position:"absolute"}},[t(at,{attrs:{decorations:[],isLast:!1,parent:e,text:o}})]),h.set(o,0),p.set(o,e)}return t(n({element:e,attributes:a,children:i}),{ref:o.id})}}),ct=e=>t.component({render(){const t=arguments[0],{attributes:n,children:o,element:r}=e;return t(this.$editor.isInline(r)?"span":"div",{attrs:{...n},style:{position:"relative"}},[o])}}),dt=t.component({props:{node:{type:Object}},components:{TextComponent:at,ElementComponent:lt,fragment:tt},mixins:[W],mounted(){V(this,"children")},render(){const t=arguments[0],n=this.$editor,{node:o}=this,r=e.findPath(n,o),s=k.isElement(o)&&!n.isInline(o)&&O.hasInlines(n,o),i=[],a=O.isEditor(o)?o._state:o.children;let l=null;for(let c=0;c<a.length;c++){const d=a[c],f=e.findKey(n,d),m=r.concat(c);if(O.range(n,m),h.set(d,c),p.set(d,o),n._operation&&u.get(f)){const t=n._operation.path;if("split_node"===n._operation.type&&b.isSibling(m,t)&&!b.equals(m,t)&&!b.equals(m,b.next(t))){l=u.get(f),i.push(l);continue}if("merge_node"===n._operation.type){const e=b.parent(t);if(b.isSibling(m,e)&&!b.isParent(m,t)){l=u.get(f),i.push(l);continue}}if("remove_node"===n._operation.type&&b.isSibling(m,t)&&!b.equals(m,t)){l=u.get(f),i.push(l);continue}}k.isElement(d)?(l=t(lt,{attrs:{element:d},key:f.id}),i.push(l)):(l=t(at,{attrs:{isLast:s&&c===a.length-1,parent:o,text:d},key:f.id}),i.push(l)),u.set(f,l)}return t(tt,[i])}}),ht=!(g||y),pt=t.component({props:{autoFocus:Boolean,renderLeaf:Function,renderElement:Function,readOnly:Boolean,decorate:{type:Function,default:()=>[]},placeholder:String,spellCheck:Boolean,autoCorrect:String,autoCapitalize:String,onBeforeInput:{type:Function},onKeyDown:{type:Function},onClick:{type:Function},onCompositionEnd:{type:Function},onCompositionStart:{type:Function},onCut:{type:Function},onCopy:{type:Function},onDragOver:{type:Function},onDragStart:{type:Function},onDragStop:{type:Function},onPaste:{type:Function},onFocus:{type:Function},onBlur:{type:Function},onDrop:{type:Function}},components:{Children:dt},mixins:[W],provide(){return{renderLeaf:this.renderLeaf,renderElement:this.renderElement,decorate:this.decorate,readOnly:this.readOnly,placeholder:this.placeholder}},data:()=>({latestElement:null,isComposing:!1,isUpdatingSelection:!1,ref:null}),methods:{_onClick(t){f.onClick(t,this.$editor,this)},onSelectionchange(){f.onSelectionchange(this.$editor,this)},_onBeforeInput(t){f.onBeforeInput(t,this.$editor,this)},_onCompositionEnd(t){f.onCompositionEnd(t,this.$editor,this)},_onCompositionStart(t){f.onCompositionStart(t,this.$editor,this)},_onKeyDown(t){f.onKeyDown(t,this.$editor,this)},_onFocus(t){f.onFocus(t,this.$editor,this)},_onBlur(t){f.onBlur(t,this.$editor,this)},_onCopy(t){f.onCopy(t,this.$editor,this)},_onPaste(t){f.onPaste(t,this.$editor,this)},_onCut(t){f.onCut(t,this.$editor,this)},_onDragOver(t){f.onDragOver(t,this.$editor,this)},_onDragStart(t){f.onDragStart(t,this.$editor,this)},_onDrop(t){f.onDrop(t,this.$editor,this)}},hooks(){const t=this.ref=P(null),n=this.$editor;m.set(n,this.readOnly);(()=>{T((()=>(document.addEventListener("selectionchange",this.onSelectionchange),()=>{document.removeEventListener("selectionchange",this.onSelectionchange)})))})(),T((()=>{t.current?($.set(n,t.current),c.set(n,t.current),d.set(t.current,n)):c.delete(n)})),(()=>{T((()=>{const{selection:t}=n,o=window.getSelection();if(this.isComposing||!o||!e.isFocused(n))return;const r="None"!==o.type;if(!t&&!r)return;const s=$.get(n);let i=!1;if(s.contains(o.anchorNode)&&s.contains(o.focusNode)&&(i=!0),r&&i&&t&&E.equals(e.toSlateRange(n,o),t))return;const a=e.toDOMNode(n,n);this.isUpdatingSelection=!0;const l=t&&e.toDOMRange(n,t);l?(E.isBackward(t)?o.setBaseAndExtent(l.endContainer,l.endOffset,l.startContainer,l.startOffset):o.setBaseAndExtent(l.startContainer,l.startOffset,l.endContainer,l.endOffset),l.startContainer.parentElement):o.removeAllRanges(),setTimeout((()=>{l&&g&&a.focus(),this.isUpdatingSelection=!1}))}))})(),(()=>{T((()=>{t.current&&this.autoFocus&&setTimeout((()=>{t.current.focus()}),0)}),[this.autoFocus])})(),g&&T((()=>{_(t.current,!0)}),[])},render(){const t=arguments[0],e=this.$editor,{ref:n}=this,o={click:this._onClick,keydown:this._onKeyDown,focus:this._onFocus,blur:this._onBlur,beforeinput:this._onBeforeInput,copy:this._onCopy,cut:this._onCut,compositionend:this._onCompositionEnd,compositionstart:this._onCompositionStart,dragover:this._onDragOver,dragstart:this._onDragStart,drop:this._onDrop,paste:this._onPaste},r={spellcheck:ht?this.spellCheck:void 0,autocorrect:ht?this.autoCorrect:void 0,autocapitalize:ht?this.autoCapitalize:void 0};return t("div",{attrs:{"data-gramm":!1,role:this.readOnly?void 0:"textbox",contenteditable:!this.readOnly,"data-slate-editor":!0,"data-slate-node":"value",...r},ref:n.id,style:{outline:"none",whiteSpace:"pre-wrap",wordWrap:"break-word"},on:{...o}},[t(dt,{attrs:{node:e,selection:e.selection}})])}});export{pt as Editable,Q as FocusedMixin,G as ReadOnlyMixin,H as SelectedMixin,et as Slate,W as SlateMixin,X as SlatePlugin,J as Transforms,V as elementWatcherPlugin,tt as fragment,q as getGvm,T as useEffect,P as useRef,R as vueRuntime,z as vueRuntimeFunc};
//# sourceMappingURL=index.es.js.map

@@ -6,10 +6,10 @@ import * as tsx from 'vue-tsx-support';

export declare const elementWatcherPlugin: (vm: any, type: string) => void;
export declare const SlateMixin: tsx._TsxComponentV3<Vue, {}, {} & {}, {}, {}, {}>;
export declare const SelectedMixin: tsx._TsxComponentV3<Vue & {
export declare const SlateMixin: tsx._TsxComponentV3<Vue<Record<string, any>, Record<string, any>, never, never, never, never, (event: string, ...args: any[]) => Vue<Record<string, any>, Record<string, any>, never, never, never, never, any>>, {}, {} & {}, {}, {}, {}>;
export declare const SelectedMixin: tsx._TsxComponentV3<Vue<Record<string, any>, Record<string, any>, never, never, never, never, (event: string, ...args: any[]) => Vue<Record<string, any>, Record<string, any>, never, never, never, never, any>> & {
selected: any;
}, {}, {} & {}, {}, {}, {}>;
export declare const ReadOnlyMixin: tsx._TsxComponentV3<Vue & {
export declare const ReadOnlyMixin: tsx._TsxComponentV3<Vue<Record<string, any>, Record<string, any>, never, never, never, never, (event: string, ...args: any[]) => Vue<Record<string, any>, Record<string, any>, never, never, never, never, any>> & {
readOnly: boolean;
}, {}, {} & {}, {}, {}, {}>;
export declare const FocusedMixin: tsx._TsxComponentV3<Vue & {
export declare const FocusedMixin: tsx._TsxComponentV3<Vue<Record<string, any>, Record<string, any>, never, never, never, never, (event: string, ...args: any[]) => Vue<Record<string, any>, Record<string, any>, never, never, never, never, any>> & {
focused: any;

@@ -22,4 +22,4 @@ }, {}, {} & {}, {}, {}, {}>;

export declare const SlatePlugin: {
install(Vue: any, options?: SlatePluginOptions | undefined): void;
install(Vue: any, options?: SlatePluginOptions): void;
};
export {};
{
"name": "@hydrabot/slate-vue",
"version": "0.2.4",
"version": "0.2.6",
"dependencies": {
"@hydrabot/slate-vue-shared": "^0.2.4",
"@hydrabot/slate-vue-shared": "^0.2.6",
"direction": "1.0.4",
"is-hotkey": "^0.2.0",
"slate": "0.72.3",
"vue": "2.6.14",
"vue": "2.7.7",
"vue-tsx-support": "^3.0.0"

@@ -11,0 +11,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc