reactjs-tiptap-editor
Version:
A modern WYSIWYG rich text editor based on tiptap and shadcn ui for React
2 lines (1 loc) • 4.22 kB
JavaScript
;const S=require("react");function P({update:e,notify:t,unwatched:s}){return{link:r,unlink:g,propagate:O,checkDirty:m,shallowPropagate:x};function r(n,i,f){const d=i.depsTail;if(d!==void 0&&d.dep===n)return;const u=d!==void 0?d.nextDep:i.deps;if(u!==void 0&&u.dep===n){u.version=f,i.depsTail=u;return}const l=n.subsTail;if(l!==void 0&&l.version===f&&l.sub===i)return;const a=i.depsTail=n.subsTail={version:f,dep:n,sub:i,prevDep:d,nextDep:u,prevSub:l,nextSub:void 0};u!==void 0&&(u.prevDep=a),d!==void 0?d.nextDep=a:i.deps=a,l!==void 0?l.nextSub=a:n.subs=a}function g(n,i=n.sub){const f=n.dep,d=n.prevDep,u=n.nextDep,l=n.nextSub,a=n.prevSub;return u!==void 0?u.prevDep=d:i.depsTail=d,d!==void 0?d.nextDep=u:i.deps=u,l!==void 0?l.prevSub=a:f.subsTail=a,a!==void 0?a.nextSub=l:(f.subs=l)===void 0&&s(f),u}function O(n){let i=n.nextSub,f;e:do{const d=n.sub;let u=d.flags;if(u&60?u&12?u&4?!(u&48)&&E(n,d)?(d.flags=u|40,u&=1):u=0:d.flags=u&-9|32:u=0:d.flags=u|32,u&2&&t(d),u&1){const l=d.subs;if(l!==void 0){const a=(n=l).nextSub;a!==void 0&&(f={value:i,prev:f},i=a);continue}}if((n=i)!==void 0){i=n.nextSub;continue}for(;f!==void 0;)if(n=f.value,f=f.prev,n!==void 0){i=n.nextSub;continue e}break}while(!0)}function m(n,i){let f,d=0,u=!1;e:do{const l=n.dep,a=l.flags;if(i.flags&16)u=!0;else if((a&17)===17){if(e(l)){const c=l.subs;c.nextSub!==void 0&&x(c),u=!0}}else if((a&33)===33){(n.nextSub!==void 0||n.prevSub!==void 0)&&(f={value:n,prev:f}),n=l.deps,i=l,++d;continue}if(!u){const c=n.nextDep;if(c!==void 0){n=c;continue}}for(;d--;){const c=i.subs,T=c.nextSub!==void 0;if(T?(n=f.value,f=f.prev):n=c,u){if(e(i)){T&&x(c),i=n.sub;continue}u=!1}else i.flags&=-33;i=n.sub;const w=n.nextDep;if(w!==void 0){n=w;continue e}}return u}while(!0)}function x(n){do{const i=n.sub,f=i.flags;(f&48)===32&&(i.flags=f|16,(f&6)===2&&t(i))}while((n=n.nextSub)!==void 0)}function E(n,i){let f=i.depsTail;for(;f!==void 0;){if(f===n)return!0;f=f.prevDep}return!1}}let y=0,o=0,h=0,b;const p=[],{link:V,unlink:I,propagate:R,checkDirty:A,shallowPropagate:M}=P({update(e){return e.depsTail!==void 0?z(e):C(e)},notify(e){var r;let t=h,s=t;do if(p[t++]=e,e.flags&=-3,e=(r=e.subs)==null?void 0:r.sub,e===void 0||!(e.flags&2))break;while(!0);for(h=t;s<--t;){const g=p[s];p[s++]=p[t],p[t]=g}},unwatched(e){e.flags&1?e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=17,v(e)):L.call(e)}});function D(e){const t=b;return b=e,t}function j(e){return G.bind({currentValue:e,pendingValue:e,subs:void 0,subsTail:void 0,flags:1})}function q(e){const t={fn:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:6},s=D(t);s!==void 0&&V(t,s,0);try{t.fn()}finally{b=s,t.flags&=-5}return H.bind(t)}function z(e){++y,e.depsTail=void 0,e.flags=5;const t=D(e);try{const s=e.value;return s!==(e.value=e.getter(s))}finally{b=t,e.flags&=-5,v(e)}}function C(e){return e.flags=1,e.currentValue!==(e.currentValue=e.pendingValue)}function B(e){const t=e.flags;if(t&16||t&32&&A(e.deps,e)){++y,e.depsTail=void 0,e.flags=6;const s=D(e);try{e.fn()}finally{b=s,e.flags&=-5,v(e)}}else e.flags=2}function F(){try{for(;o<h;){const e=p[o];p[o++]=void 0,B(e)}}finally{for(;o<h;){const e=p[o];p[o++]=void 0,e.flags|=10}o=0,h=0}}function G(...e){var t;if(e.length){if(this.pendingValue!==(this.pendingValue=e[0])){this.flags=17;const s=this.subs;s!==void 0&&(R(s),F())}}else{if(this.flags&16&&C(this)){const r=this.subs;r!==void 0&&M(r)}let s=b;for(;s!==void 0;){if(s.flags&3){V(this,s,y);break}s=(t=s.subs)==null?void 0:t.sub}return this.currentValue}}function H(){L.call(this)}function L(){this.depsTail=void 0,this.flags=0,v(this);const e=this.subs;e!==void 0&&I(e)}function v(e){const t=e.depsTail;let s=t!==void 0?t.nextDep:e.deps;for(;s!==void 0;)s=I(s,e)}var J=j;function K(e){let t=S.useSyncExternalStore(r=>{let g=q(()=>{e(),r()});return()=>g()},()=>e(),()=>e()),s=S.useCallback(r=>{e(typeof r=="function"?r(e()):r)},[]);return[t,s]}function N(e){return S.useSyncExternalStore(t=>{let s=q(()=>{e(),t()});return()=>s()},()=>e(),()=>e())}function Q(e){return S.useCallback(t=>{e(typeof t=="function"?t(e()):t)},[])}function U(e){return{value:()=>e(),setValue:t=>{e(typeof t=="function"?t(e()):t)}}}exports.S=Q;exports.V=K;exports.b=N;exports.v=U;exports.y=J;