asma-ui-richeditor 0.1.0 → 0.1.1

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.
@@ -53,4 +53,4 @@ import t,{forwardRef as e,useRef as n,useState as r,useDebugValue as o,useEffect
53
53
  *
54
54
  * This source code is licensed under the MIT license found in the
55
55
  * LICENSE file in the root directory of this source tree.
56
- */"production"===process.env.NODE_ENV?ra.exports=function(){if(na)return oa;na=1;var e=t,n=Ys,r="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},o=n.useSyncExternalStore,i=e.useRef,s=e.useEffect,a=e.useMemo,l=e.useDebugValue;return oa.useSyncExternalStoreWithSelector=function(t,e,n,c,d){var h=i(null);if(null===h.current){var p={hasValue:!1,value:null};h.current=p}else p=h.current;h=a((function(){function t(t){if(!s){if(s=!0,o=t,t=c(t),void 0!==d&&p.hasValue){var e=p.value;if(d(e,t))return i=e}return i=t}if(e=i,r(o,t))return e;var n=c(t);return void 0!==d&&d(e,n)?e:(o=t,i=n)}var o,i,s=!1,a=void 0===n?null:n;return[function(){return t(e())},null===a?void 0:function(){return t(a())}]}),[e,n,c,d]);var u=o(t,h[0],h[1]);return s((function(){p.hasValue=!0,p.value=u}),[u]),l(u),u},oa}():ra.exports=(ia||(ia=1,"production"!==process.env.NODE_ENV&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=t,n=Ys,r="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},o=n.useSyncExternalStore,i=e.useRef,s=e.useEffect,a=e.useMemo,l=e.useDebugValue;sa.useSyncExternalStoreWithSelector=function(t,e,n,c,d){var h,p=i(null);null===p.current?(h={hasValue:!1,value:null},p.current=h):h=p.current;var u=a((function(){var t,o,i=!1,s=function(e){if(!i){i=!0,t=e;var n=c(e);if(void 0!==d&&h.hasValue){var s=h.value;if(d(s,n))return o=s,s}return o=n,n}var a=o;if(r(t,e))return a;var l=c(e);return void 0!==d&&d(a,l)?a:(t=e,o=l,l)},a=void 0===n?null:n;return[function(){return s(e())},null===a?void 0:function(){return s(a())}]}),[e,n,c,d]),f=u[0],m=u[1],g=o(t,f,m);return s((function(){h.hasValue=!0,h.value=g}),[g]),l(g),g},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),sa);var aa=ra.exports;class la{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber||(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber}),this.lastSnapshot}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const t=()=>{this.transactionNumber+=1,this.subscribers.forEach((t=>t()))},e=this.editor;return e.on("transaction",t),()=>{e.off("transaction",t)}}}}const ca="production"!==process.env.NODE_ENV,da=typeof window>"u",ha=da||!!(typeof window<"u"&&window.next);class pa{constructor(t){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=t,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(t){this.editor=t,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach((t=>t()))}getInitialEditor(){if(void 0===this.options.current.immediatelyRender)return da||ha?(ca&&console.warn("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches."),null):this.createEditor();if(this.options.current.immediatelyRender&&da&&ca)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const t={...this.options.current,onBeforeCreate:(...t)=>{var e,n;return null===(n=(e=this.options.current).onBeforeCreate)||void 0===n?void 0:n.call(e,...t)},onBlur:(...t)=>{var e,n;return null===(n=(e=this.options.current).onBlur)||void 0===n?void 0:n.call(e,...t)},onCreate:(...t)=>{var e,n;return null===(n=(e=this.options.current).onCreate)||void 0===n?void 0:n.call(e,...t)},onDestroy:(...t)=>{var e,n;return null===(n=(e=this.options.current).onDestroy)||void 0===n?void 0:n.call(e,...t)},onFocus:(...t)=>{var e,n;return null===(n=(e=this.options.current).onFocus)||void 0===n?void 0:n.call(e,...t)},onSelectionUpdate:(...t)=>{var e,n;return null===(n=(e=this.options.current).onSelectionUpdate)||void 0===n?void 0:n.call(e,...t)},onTransaction:(...t)=>{var e,n;return null===(n=(e=this.options.current).onTransaction)||void 0===n?void 0:n.call(e,...t)},onUpdate:(...t)=>{var e,n;return null===(n=(e=this.options.current).onUpdate)||void 0===n?void 0:n.call(e,...t)},onContentError:(...t)=>{var e,n;return null===(n=(e=this.options.current).onContentError)||void 0===n?void 0:n.call(e,...t)}};return new _s(t)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(t){return this.subscriptions.add(t),()=>{this.subscriptions.delete(t)}}onRender(t){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&0===t.length?this.editor.setOptions(this.options.current):this.refreshEditorInstance(t),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(t){if(this.editor&&!this.editor.isDestroyed){if(null===this.previousDeps)return void(this.previousDeps=t);if(this.previousDeps.length===t.length&&this.previousDeps.every(((e,n)=>e===t[n])))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=t}scheduleDestroy(){const t=this.instanceId,e=this.editor;this.scheduledDestructionTimeout=setTimeout((()=>{this.isComponentMounted&&this.instanceId===t?e&&e.setOptions(this.options.current):e&&!e.isDestroyed&&(e.destroy(),this.instanceId===t&&this.setEditor(null))}),1)}}function ua(t={},e=[]){const s=n(t);s.current=t;const[a]=r((()=>new pa(s))),l=Ys.useSyncExternalStore(a.subscribe,a.getEditor,a.getServerSnapshot);return o(l),i(a.onRender(e)),function(t){const[e]=r((()=>new la(t.editor))),n=aa.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getServerSnapshot,t.selector,t.equalityFn);i((()=>e.watch(t.editor)),[t.editor,e]),o(n)}({editor:l,selector:({transactionNumber:e})=>!1===t.shouldRerenderOnTransaction?null:t.immediatelyRender&&0===e?0:e+1}),l}s({editor:null}).Consumer;const fa=s({onDragStart:void 0});t.forwardRef(((e,n)=>{const{onDragStart:r}=a(fa),o=e.as||"div";return t.createElement(o,{...e,ref:n,"data-node-view-wrapper":"",onDragStart:r,style:{whiteSpace:"normal",...e.style}})}));const ma=Hs.create({name:"doc",topNode:!0,content:"block+"}),ga=Hs.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:t}){return["p",Ii(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),ya=Hs.create({name:"text",group:"inline"}),ba=Zi.create({name:"placeholder",addOptions:()=>({emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}),addProseMirrorPlugins(){return[new Pe({key:new _e("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,o=[];if(!n)return null;const i=this.editor.isEmpty;return t.descendants(((t,e)=>{const n=r>=e&&r<=e+t.nodeSize,s=!t.isLeaf&&Es(t);if((n||!this.options.showOnlyCurrent)&&s){const r=[this.options.emptyNodeClass];i&&r.push(this.options.emptyEditorClass);const s=xo.node(e,e+t.nodeSize,{class:r.join(" "),"data-placeholder":"function"==typeof this.options.placeholder?this.options.placeholder({editor:this.editor,node:t,pos:e,hasAnchor:n}):this.options.placeholder});o.push(s)}return this.options.includeChildren})),Mo.create(t,o)}}})]}}),va=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,wa=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,ka=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,xa=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Sa=Fs.create({name:"bold",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"strong"},{tag:"b",getAttrs:t=>"normal"!==t.style.fontWeight&&null},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}],renderHTML({HTMLAttributes:t}){return["strong",Ii(this.options.HTMLAttributes,t),0]},addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Vs({find:va,type:this.type}),Vs({find:ka,type:this.type})]},addPasteRules(){return[Ws({find:wa,type:this.type}),Ws({find:xa,type:this.type})]}}),Oa=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Ma=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Ca=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Ta=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Ea=Fs.create({name:"italic",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"em"},{tag:"i",getAttrs:t=>"normal"!==t.style.fontStyle&&null},{style:"font-style=italic"}],renderHTML({HTMLAttributes:t}){return["em",Ii(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Vs({find:Oa,type:this.type}),Vs({find:Ca,type:this.type})]},addPasteRules(){return[Ws({find:Ma,type:this.type}),Ws({find:Ta,type:this.type})]}}),Na=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Aa=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Da=Fs.create({name:"strike",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>!!t.includes("line-through")&&{}}],renderHTML({HTMLAttributes:t}){return["s",Ii(this.options.HTMLAttributes,t),0]},addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Vs({find:Na,type:this.type})]},addPasteRules(){return[Ws({find:Aa,type:this.type})]}}),Ra=Fs.create({name:"textStyle",priority:101,addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"span",getAttrs:t=>!!t.hasAttribute("style")&&{}}],renderHTML({HTMLAttributes:t}){return["span",Ii(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{const n=ks(t,this.type);return!!Object.entries(n).some((([,t])=>!!t))||e.unsetMark(this.name)}}}}),Ia=Zi.create({name:"color",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;return null===(e=t.style.color)||void 0===e?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands:()=>({setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()})}),$a=Hs.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:t}){return["li",Ii(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),La=Fs.create({name:"textStyle",priority:101,addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"span",getAttrs:t=>!!t.hasAttribute("style")&&{}}],renderHTML({HTMLAttributes:t}){return["span",Ii(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{const n=ks(t,this.type);return!!Object.entries(n).some((([,t])=>!!t))||e.unsetMark(this.name)}}}}),Pa=/^(\d+)\.\s$/,za=Hs.create({name:"orderedList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes:()=>({start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:void 0,parseHTML:t=>t.getAttribute("type")}}),parseHTML:()=>[{tag:"ol"}],renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return 1===e?["ol",Ii(this.options.HTMLAttributes,n),0]:["ol",Ii(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes($a.name,this.editor.getAttributes(La.name)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=js({find:Pa,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:(t,e)=>e.childCount+e.attrs.start===+t[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=js({find:Pa,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(La.name)}),joinPredicate:(t,e)=>e.childCount+e.attrs.start===+t[1],editor:this.editor})),[t]}}),Ba=Hs.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:t}){return["li",Ii(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),_a=Hs.create({name:"heading",addOptions:()=>({levels:[1,2,3,4,5,6],HTMLAttributes:{}}),content:"inline*",group:"block",defining:!0,addAttributes:()=>({level:{default:1,rendered:!1}}),parseHTML(){return this.options.levels.map((t=>({tag:`h${t}`,attrs:{level:t}})))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,Ii(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:t=>({commands:e})=>!!this.options.levels.includes(t.level)&&e.setNode(this.name,t),toggleHeading:t=>({commands:e})=>!!this.options.levels.includes(t.level)&&e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return this.options.levels.reduce(((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})})),{})},addInputRules(){return this.options.levels.map((t=>function(t){return new Hi({find:t.find,handler:({state:e,range:n,match:r})=>{const o=e.doc.resolve(n.from),i=Pi(t.getAttributes,void 0,r)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)}})}({find:new RegExp(`^(#{1,${t}})\\s$`),type:this.type,getAttributes:{level:t}})))}}),Va=Hs.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:t}){return["li",Ii(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),ja=Fs.create({name:"textStyle",priority:101,addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"span",getAttrs:t=>!!t.hasAttribute("style")&&{}}],renderHTML({HTMLAttributes:t}){return["span",Ii(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{const n=ks(t,this.type);return!!Object.entries(n).some((([,t])=>!!t))||e.unsetMark(this.name)}}}}),Fa=/^\s*([-+*])\s$/,Ha=Hs.create({name:"bulletList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML:()=>[{tag:"ul"}],renderHTML({HTMLAttributes:t}){return["ul",Ii(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Va.name,this.editor.getAttributes(ja.name)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=js({find:Fa,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=js({find:Fa,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(ja.name),editor:this.editor})),[t]}}),Wa=/^\s*>\s$/,qa=Hs.create({name:"blockquote",addOptions:()=>({HTMLAttributes:{}}),content:"block+",group:"block",defining:!0,parseHTML:()=>[{tag:"blockquote"}],renderHTML({HTMLAttributes:t}){return["blockquote",Ii(this.options.HTMLAttributes,t),0]},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[js({find:Wa,type:this.type})]}}),Ja=Hs.create({name:"hardBreak",addOptions:()=>({keepMarks:!0,HTMLAttributes:{}}),inline:!0,group:"inline",selectable:!1,parseHTML:()=>[{tag:"br"}],renderHTML({HTMLAttributes:t}){return["br",Ii(this.options.HTMLAttributes,t)]},renderText:()=>"\n",addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command((()=>{const{selection:t,storedMarks:o}=n;if(t.$from.parent.type.spec.isolating)return!1;const{keepMarks:i}=this.options,{splittableMarks:s}=r.extensionManager,a=o||t.$to.parentOffset&&t.$from.marks();return e().insertContent({type:this.name}).command((({tr:t,dispatch:e})=>{if(e&&a&&i){const e=a.filter((t=>s.includes(t.type.name)));t.ensureMarks(e)}return!0})).run()}))])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Ka=Hs.create({name:"horizontalRule",addOptions:()=>({HTMLAttributes:{}}),group:"block",parseHTML:()=>[{tag:"hr"}],renderHTML({HTMLAttributes:t}){return["hr",Ii(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{const{selection:n}=e,{$from:r,$to:o}=n,i=t();return 0===r.parentOffset?i.insertContentAt({from:Math.max(r.pos-1,0),to:o.pos},{type:this.name}):function(t){return t instanceof Se}(n)?i.insertContentAt(o.pos,{type:this.name}):i.insertContent({type:this.name}),i.command((({tr:t,dispatch:e})=>{var n;if(e){const{$to:e}=t.selection,r=e.end();if(e.nodeAfter)e.nodeAfter.isTextblock?t.setSelection(ke.create(t.doc,e.pos+1)):e.nodeAfter.isBlock?t.setSelection(Se.create(t.doc,e.pos)):t.setSelection(ke.create(t.doc,e.pos));else{const o=null===(n=e.parent.type.contentMatch.defaultType)||void 0===n?void 0:n.create();o&&(t.insert(r,o),t.setSelection(ke.create(t.doc,r+1)))}t.scrollIntoView()}return!0})).run()}}},addInputRules(){return[(t={find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type},new Hi({find:t.find,handler:({state:e,range:n,match:r})=>{const o=Pi(t.getAttributes,void 0,r)||{},{tr:i}=e,s=n.from;let a=n.to;const l=t.type.create(o);if(r[1]){let t=s+r[0].lastIndexOf(r[1]);t>a?t=a:a=t+r[1].length;const e=r[0][r[0].length-1];i.insertText(e,s+r[0].length-1),i.replaceWith(t,a,l)}else if(r[0]){const e=t.type.isInline?s:s-1;i.insert(e,t.type.create(o)).delete(i.mapping.map(s),i.mapping.map(a))}i.scrollIntoView()}}))];var t}}),Ua=({editor:t})=>t?g.jsxs("div",{className:"flex gap-2 items-center flex-wrap border border-delta-200 rounded",children:[g.jsx(d,{dataTest:"richeditor-bold-button",size:"small",variant:t.isActive("bold")?"outlined":"textGray",onClick:()=>t.chain().focus().toggleBold().run(),disabled:!t.can().chain().focus().toggleBold().run(),children:"Bold"}),g.jsx(d,{dataTest:"richeditor-italic-button",size:"small",variant:t.isActive("italic")?"outlined":"textGray",onClick:()=>t.chain().focus().toggleItalic().run(),disabled:!t.can().chain().focus().toggleItalic().run(),children:"Italic"}),g.jsx(d,{dataTest:"richeditor-strike-button",size:"small",variant:t.isActive("strike")?"outlined":"textGray",onClick:()=>t.chain().focus().toggleStrike().run(),disabled:!t.can().chain().focus().toggleStrike().run(),children:"Strike"}),g.jsx(d,{dataTest:"richeditor-clear-marks-button",size:"small",variant:"textGray",onClick:()=>t.chain().focus().unsetAllMarks().run(),children:"Clear marks"}),g.jsx(d,{dataTest:"richeditor-clear-nodes-button",size:"small",variant:"textGray",onClick:()=>t.chain().focus().clearNodes().run(),children:"Clear nodes"}),g.jsx(d,{dataTest:"richeditor-paragraph-button",size:"small",variant:t.isActive("paragraph")?"outlined":"textGray",onClick:()=>t.chain().focus().setParagraph().run(),children:"Paragraph"}),g.jsx(d,{dataTest:"richeditor-h1-button",size:"small",variant:t.isActive("heading",{level:1})?"outlined":"textGray",onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),children:"H1"}),g.jsx(d,{dataTest:"richeditor-h2-button",size:"small",variant:t.isActive("heading",{level:2})?"outlined":"textGray",onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),children:"H2"}),g.jsx(d,{dataTest:"richeditor-h3-button",size:"small",variant:t.isActive("heading",{level:3})?"outlined":"textGray",onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),children:"H3"}),g.jsx(d,{dataTest:"richeditor-h4-button",size:"small",variant:t.isActive("heading",{level:4})?"outlined":"textGray",onClick:()=>t.chain().focus().toggleHeading({level:4}).run(),children:"H4"}),g.jsx(d,{dataTest:"richeditor-h5-button",size:"small",variant:t.isActive("heading",{level:5})?"outlined":"textGray",onClick:()=>t.chain().focus().toggleHeading({level:5}).run(),children:"H5"}),g.jsx(d,{dataTest:"richeditor-h6-button",size:"small",variant:t.isActive("heading",{level:6})?"outlined":"textGray",onClick:()=>t.chain().focus().toggleHeading({level:6}).run(),children:"H6"}),g.jsx(d,{dataTest:"richeditor-bullet-list-button",size:"small",variant:t.isActive("bulletList")?"outlined":"textGray",onClick:()=>t.chain().focus().toggleBulletList().run(),children:"Bullet list"}),g.jsx(d,{dataTest:"richeditor-ordered-list-button",size:"small",variant:t.isActive("orderedList")?"outlined":"textGray",onClick:()=>t.chain().focus().toggleOrderedList().run(),children:"Ordered list"}),g.jsx(d,{dataTest:"richeditor-blockquote-button",size:"small",variant:t.isActive("blockquote")?"outlined":"textGray",onClick:()=>t.chain().focus().toggleBlockquote().run(),children:"Blockquote"}),g.jsx(d,{dataTest:"richeditor-horizontal-rule-button",size:"small",variant:"textGray",onClick:()=>t.chain().focus().setHorizontalRule().run(),children:"Horizontal rule"}),g.jsx(d,{dataTest:"richeditor-hard-break-button",size:"small",variant:"textGray",onClick:()=>t.chain().focus().setHardBreak().run(),children:"Hard break"}),g.jsx("input",{type:"color",onInput:e=>t.chain().focus().setColor(e.currentTarget.value).run(),value:t.getAttributes("textStyle").color,"data-testid":"setColor"})]}):null,Ga=[ma,ga,ya],Ya=[Sa,Ea,Da,Ia,Ra,Ha,za,Ba,_a,qa,Ka,Ja],Xa=({dataTest:t,id:e,inputRef:n,className:r,disabled:o,ghost:i,is_error:s,label:a,placeholder:c,helperText:d,isRequired:h,hideMenuBar:p,noDefaultStyles:u,...f})=>{const m=ua({...f,extensions:o||i||p?[...Ga,ba.configure({placeholder:c}),...f.extensions||[]]:[...Ga,...Ya,ba.configure({placeholder:c}),...f.extensions||[]],shouldRerenderOnTransaction:f.shouldRerenderOnTransaction||!1,immediatelyRender:f.immediatelyRender||!0,editable:f.editable||!o&&!i},[]);return l(n,(()=>m)),m?g.jsxs("div",{className:"relative",children:[a&&g.jsx("span",{className:"text-custom-grey-06 mb-2 font-sans text-xs font-semibold leading-4","data-test":`label-${t}`,children:a}),!p&&!o&&!i&&g.jsx(Ua,{editor:m}),g.jsx(ea,{id:e,className:b(!u&&"core-ui-rte",!o&&!i&&"core-ui-rte-edit-mode",i&&"core-ui-rte-ghost-mode",s&&"core-ui-rte-error",r),editor:m}),(s||h)&&g.jsx("span",{className:b("core-ui-rte-helper-text",s&&"core-ui-rte-error"),"data-test":`error-${t}`,children:d})]}):null};export{Xa as RichInput};
56
+ */"production"===process.env.NODE_ENV?ra.exports=function(){if(na)return oa;na=1;var e=t,n=Ys,r="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},o=n.useSyncExternalStore,i=e.useRef,s=e.useEffect,a=e.useMemo,l=e.useDebugValue;return oa.useSyncExternalStoreWithSelector=function(t,e,n,c,d){var h=i(null);if(null===h.current){var p={hasValue:!1,value:null};h.current=p}else p=h.current;h=a((function(){function t(t){if(!s){if(s=!0,o=t,t=c(t),void 0!==d&&p.hasValue){var e=p.value;if(d(e,t))return i=e}return i=t}if(e=i,r(o,t))return e;var n=c(t);return void 0!==d&&d(e,n)?e:(o=t,i=n)}var o,i,s=!1,a=void 0===n?null:n;return[function(){return t(e())},null===a?void 0:function(){return t(a())}]}),[e,n,c,d]);var u=o(t,h[0],h[1]);return s((function(){p.hasValue=!0,p.value=u}),[u]),l(u),u},oa}():ra.exports=(ia||(ia=1,"production"!==process.env.NODE_ENV&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=t,n=Ys,r="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},o=n.useSyncExternalStore,i=e.useRef,s=e.useEffect,a=e.useMemo,l=e.useDebugValue;sa.useSyncExternalStoreWithSelector=function(t,e,n,c,d){var h,p=i(null);null===p.current?(h={hasValue:!1,value:null},p.current=h):h=p.current;var u=a((function(){var t,o,i=!1,s=function(e){if(!i){i=!0,t=e;var n=c(e);if(void 0!==d&&h.hasValue){var s=h.value;if(d(s,n))return o=s,s}return o=n,n}var a=o;if(r(t,e))return a;var l=c(e);return void 0!==d&&d(a,l)?a:(t=e,o=l,l)},a=void 0===n?null:n;return[function(){return s(e())},null===a?void 0:function(){return s(a())}]}),[e,n,c,d]),f=u[0],m=u[1],g=o(t,f,m);return s((function(){h.hasValue=!0,h.value=g}),[g]),l(g),g},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),sa);var aa=ra.exports;class la{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber||(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber}),this.lastSnapshot}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const t=()=>{this.transactionNumber+=1,this.subscribers.forEach((t=>t()))},e=this.editor;return e.on("transaction",t),()=>{e.off("transaction",t)}}}}const ca="production"!==process.env.NODE_ENV,da=typeof window>"u",ha=da||!!(typeof window<"u"&&window.next);class pa{constructor(t){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=t,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(t){this.editor=t,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach((t=>t()))}getInitialEditor(){if(void 0===this.options.current.immediatelyRender)return da||ha?(ca&&console.warn("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches."),null):this.createEditor();if(this.options.current.immediatelyRender&&da&&ca)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const t={...this.options.current,onBeforeCreate:(...t)=>{var e,n;return null===(n=(e=this.options.current).onBeforeCreate)||void 0===n?void 0:n.call(e,...t)},onBlur:(...t)=>{var e,n;return null===(n=(e=this.options.current).onBlur)||void 0===n?void 0:n.call(e,...t)},onCreate:(...t)=>{var e,n;return null===(n=(e=this.options.current).onCreate)||void 0===n?void 0:n.call(e,...t)},onDestroy:(...t)=>{var e,n;return null===(n=(e=this.options.current).onDestroy)||void 0===n?void 0:n.call(e,...t)},onFocus:(...t)=>{var e,n;return null===(n=(e=this.options.current).onFocus)||void 0===n?void 0:n.call(e,...t)},onSelectionUpdate:(...t)=>{var e,n;return null===(n=(e=this.options.current).onSelectionUpdate)||void 0===n?void 0:n.call(e,...t)},onTransaction:(...t)=>{var e,n;return null===(n=(e=this.options.current).onTransaction)||void 0===n?void 0:n.call(e,...t)},onUpdate:(...t)=>{var e,n;return null===(n=(e=this.options.current).onUpdate)||void 0===n?void 0:n.call(e,...t)},onContentError:(...t)=>{var e,n;return null===(n=(e=this.options.current).onContentError)||void 0===n?void 0:n.call(e,...t)}};return new _s(t)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(t){return this.subscriptions.add(t),()=>{this.subscriptions.delete(t)}}onRender(t){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&0===t.length?this.editor.setOptions(this.options.current):this.refreshEditorInstance(t),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(t){if(this.editor&&!this.editor.isDestroyed){if(null===this.previousDeps)return void(this.previousDeps=t);if(this.previousDeps.length===t.length&&this.previousDeps.every(((e,n)=>e===t[n])))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=t}scheduleDestroy(){const t=this.instanceId,e=this.editor;this.scheduledDestructionTimeout=setTimeout((()=>{this.isComponentMounted&&this.instanceId===t?e&&e.setOptions(this.options.current):e&&!e.isDestroyed&&(e.destroy(),this.instanceId===t&&this.setEditor(null))}),1)}}function ua(t={},e=[]){const s=n(t);s.current=t;const[a]=r((()=>new pa(s))),l=Ys.useSyncExternalStore(a.subscribe,a.getEditor,a.getServerSnapshot);return o(l),i(a.onRender(e)),function(t){const[e]=r((()=>new la(t.editor))),n=aa.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getServerSnapshot,t.selector,t.equalityFn);i((()=>e.watch(t.editor)),[t.editor,e]),o(n)}({editor:l,selector:({transactionNumber:e})=>!1===t.shouldRerenderOnTransaction?null:t.immediatelyRender&&0===e?0:e+1}),l}s({editor:null}).Consumer;const fa=s({onDragStart:void 0});t.forwardRef(((e,n)=>{const{onDragStart:r}=a(fa),o=e.as||"div";return t.createElement(o,{...e,ref:n,"data-node-view-wrapper":"",onDragStart:r,style:{whiteSpace:"normal",...e.style}})}));const ma=Hs.create({name:"doc",topNode:!0,content:"block+"}),ga=Hs.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:t}){return["p",Ii(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),ya=Hs.create({name:"text",group:"inline"}),ba=Zi.create({name:"placeholder",addOptions:()=>({emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}),addProseMirrorPlugins(){return[new Pe({key:new _e("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,o=[];if(!n)return null;const i=this.editor.isEmpty;return t.descendants(((t,e)=>{const n=r>=e&&r<=e+t.nodeSize,s=!t.isLeaf&&Es(t);if((n||!this.options.showOnlyCurrent)&&s){const r=[this.options.emptyNodeClass];i&&r.push(this.options.emptyEditorClass);const s=xo.node(e,e+t.nodeSize,{class:r.join(" "),"data-placeholder":"function"==typeof this.options.placeholder?this.options.placeholder({editor:this.editor,node:t,pos:e,hasAnchor:n}):this.options.placeholder});o.push(s)}return this.options.includeChildren})),Mo.create(t,o)}}})]}}),va=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,wa=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,ka=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,xa=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Sa=Fs.create({name:"bold",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"strong"},{tag:"b",getAttrs:t=>"normal"!==t.style.fontWeight&&null},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}],renderHTML({HTMLAttributes:t}){return["strong",Ii(this.options.HTMLAttributes,t),0]},addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Vs({find:va,type:this.type}),Vs({find:ka,type:this.type})]},addPasteRules(){return[Ws({find:wa,type:this.type}),Ws({find:xa,type:this.type})]}}),Oa=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Ma=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Ca=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Ta=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Ea=Fs.create({name:"italic",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"em"},{tag:"i",getAttrs:t=>"normal"!==t.style.fontStyle&&null},{style:"font-style=italic"}],renderHTML({HTMLAttributes:t}){return["em",Ii(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Vs({find:Oa,type:this.type}),Vs({find:Ca,type:this.type})]},addPasteRules(){return[Ws({find:Ma,type:this.type}),Ws({find:Ta,type:this.type})]}}),Na=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Aa=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Da=Fs.create({name:"strike",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>!!t.includes("line-through")&&{}}],renderHTML({HTMLAttributes:t}){return["s",Ii(this.options.HTMLAttributes,t),0]},addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Vs({find:Na,type:this.type})]},addPasteRules(){return[Ws({find:Aa,type:this.type})]}}),Ra=Fs.create({name:"textStyle",priority:101,addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"span",getAttrs:t=>!!t.hasAttribute("style")&&{}}],renderHTML({HTMLAttributes:t}){return["span",Ii(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{const n=ks(t,this.type);return!!Object.entries(n).some((([,t])=>!!t))||e.unsetMark(this.name)}}}}),Ia=Zi.create({name:"color",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;return null===(e=t.style.color)||void 0===e?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands:()=>({setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()})}),$a=Hs.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:t}){return["li",Ii(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),La=Fs.create({name:"textStyle",priority:101,addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"span",getAttrs:t=>!!t.hasAttribute("style")&&{}}],renderHTML({HTMLAttributes:t}){return["span",Ii(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{const n=ks(t,this.type);return!!Object.entries(n).some((([,t])=>!!t))||e.unsetMark(this.name)}}}}),Pa=/^(\d+)\.\s$/,za=Hs.create({name:"orderedList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes:()=>({start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:void 0,parseHTML:t=>t.getAttribute("type")}}),parseHTML:()=>[{tag:"ol"}],renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return 1===e?["ol",Ii(this.options.HTMLAttributes,n),0]:["ol",Ii(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes($a.name,this.editor.getAttributes(La.name)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=js({find:Pa,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:(t,e)=>e.childCount+e.attrs.start===+t[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=js({find:Pa,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(La.name)}),joinPredicate:(t,e)=>e.childCount+e.attrs.start===+t[1],editor:this.editor})),[t]}}),Ba=Hs.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:t}){return["li",Ii(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),_a=Hs.create({name:"heading",addOptions:()=>({levels:[1,2,3,4,5,6],HTMLAttributes:{}}),content:"inline*",group:"block",defining:!0,addAttributes:()=>({level:{default:1,rendered:!1}}),parseHTML(){return this.options.levels.map((t=>({tag:`h${t}`,attrs:{level:t}})))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,Ii(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:t=>({commands:e})=>!!this.options.levels.includes(t.level)&&e.setNode(this.name,t),toggleHeading:t=>({commands:e})=>!!this.options.levels.includes(t.level)&&e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return this.options.levels.reduce(((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})})),{})},addInputRules(){return this.options.levels.map((t=>function(t){return new Hi({find:t.find,handler:({state:e,range:n,match:r})=>{const o=e.doc.resolve(n.from),i=Pi(t.getAttributes,void 0,r)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)}})}({find:new RegExp(`^(#{1,${t}})\\s$`),type:this.type,getAttributes:{level:t}})))}}),Va=Hs.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:t}){return["li",Ii(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),ja=Fs.create({name:"textStyle",priority:101,addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"span",getAttrs:t=>!!t.hasAttribute("style")&&{}}],renderHTML({HTMLAttributes:t}){return["span",Ii(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{const n=ks(t,this.type);return!!Object.entries(n).some((([,t])=>!!t))||e.unsetMark(this.name)}}}}),Fa=/^\s*([-+*])\s$/,Ha=Hs.create({name:"bulletList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML:()=>[{tag:"ul"}],renderHTML({HTMLAttributes:t}){return["ul",Ii(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Va.name,this.editor.getAttributes(ja.name)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=js({find:Fa,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=js({find:Fa,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(ja.name),editor:this.editor})),[t]}}),Wa=/^\s*>\s$/,qa=Hs.create({name:"blockquote",addOptions:()=>({HTMLAttributes:{}}),content:"block+",group:"block",defining:!0,parseHTML:()=>[{tag:"blockquote"}],renderHTML({HTMLAttributes:t}){return["blockquote",Ii(this.options.HTMLAttributes,t),0]},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[js({find:Wa,type:this.type})]}}),Ja=Hs.create({name:"hardBreak",addOptions:()=>({keepMarks:!0,HTMLAttributes:{}}),inline:!0,group:"inline",selectable:!1,parseHTML:()=>[{tag:"br"}],renderHTML({HTMLAttributes:t}){return["br",Ii(this.options.HTMLAttributes,t)]},renderText:()=>"\n",addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command((()=>{const{selection:t,storedMarks:o}=n;if(t.$from.parent.type.spec.isolating)return!1;const{keepMarks:i}=this.options,{splittableMarks:s}=r.extensionManager,a=o||t.$to.parentOffset&&t.$from.marks();return e().insertContent({type:this.name}).command((({tr:t,dispatch:e})=>{if(e&&a&&i){const e=a.filter((t=>s.includes(t.type.name)));t.ensureMarks(e)}return!0})).run()}))])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Ka=Hs.create({name:"horizontalRule",addOptions:()=>({HTMLAttributes:{}}),group:"block",parseHTML:()=>[{tag:"hr"}],renderHTML({HTMLAttributes:t}){return["hr",Ii(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{const{selection:n}=e,{$from:r,$to:o}=n,i=t();return 0===r.parentOffset?i.insertContentAt({from:Math.max(r.pos-1,0),to:o.pos},{type:this.name}):function(t){return t instanceof Se}(n)?i.insertContentAt(o.pos,{type:this.name}):i.insertContent({type:this.name}),i.command((({tr:t,dispatch:e})=>{var n;if(e){const{$to:e}=t.selection,r=e.end();if(e.nodeAfter)e.nodeAfter.isTextblock?t.setSelection(ke.create(t.doc,e.pos+1)):e.nodeAfter.isBlock?t.setSelection(Se.create(t.doc,e.pos)):t.setSelection(ke.create(t.doc,e.pos));else{const o=null===(n=e.parent.type.contentMatch.defaultType)||void 0===n?void 0:n.create();o&&(t.insert(r,o),t.setSelection(ke.create(t.doc,r+1)))}t.scrollIntoView()}return!0})).run()}}},addInputRules(){return[(t={find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type},new Hi({find:t.find,handler:({state:e,range:n,match:r})=>{const o=Pi(t.getAttributes,void 0,r)||{},{tr:i}=e,s=n.from;let a=n.to;const l=t.type.create(o);if(r[1]){let t=s+r[0].lastIndexOf(r[1]);t>a?t=a:a=t+r[1].length;const e=r[0][r[0].length-1];i.insertText(e,s+r[0].length-1),i.replaceWith(t,a,l)}else if(r[0]){const e=t.type.isInline?s:s-1;i.insert(e,t.type.create(o)).delete(i.mapping.map(s),i.mapping.map(a))}i.scrollIntoView()}}))];var t}}),Ua=({editor:t})=>t?g.jsxs("div",{className:"flex gap-2 items-center flex-wrap border border-delta-200 rounded",children:[g.jsx(d,{dataTest:"richeditor-bold-button",size:"small",variant:t.isActive("bold")?"outlined":"textGray",onClick:()=>t.chain().focus().toggleBold().run(),disabled:!t.can().chain().focus().toggleBold().run(),children:"Bold"}),g.jsx(d,{dataTest:"richeditor-italic-button",size:"small",variant:t.isActive("italic")?"outlined":"textGray",onClick:()=>t.chain().focus().toggleItalic().run(),disabled:!t.can().chain().focus().toggleItalic().run(),children:"Italic"}),g.jsx(d,{dataTest:"richeditor-strike-button",size:"small",variant:t.isActive("strike")?"outlined":"textGray",onClick:()=>t.chain().focus().toggleStrike().run(),disabled:!t.can().chain().focus().toggleStrike().run(),children:"Strike"}),g.jsx(d,{dataTest:"richeditor-clear-marks-button",size:"small",variant:"textGray",onClick:()=>t.chain().focus().unsetAllMarks().run(),children:"Clear marks"}),g.jsx(d,{dataTest:"richeditor-clear-nodes-button",size:"small",variant:"textGray",onClick:()=>t.chain().focus().clearNodes().run(),children:"Clear nodes"}),g.jsx(d,{dataTest:"richeditor-paragraph-button",size:"small",variant:t.isActive("paragraph")?"outlined":"textGray",onClick:()=>t.chain().focus().setParagraph().run(),children:"Paragraph"}),g.jsx(d,{dataTest:"richeditor-h1-button",size:"small",variant:t.isActive("heading",{level:1})?"outlined":"textGray",onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),children:"H1"}),g.jsx(d,{dataTest:"richeditor-h2-button",size:"small",variant:t.isActive("heading",{level:2})?"outlined":"textGray",onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),children:"H2"}),g.jsx(d,{dataTest:"richeditor-h3-button",size:"small",variant:t.isActive("heading",{level:3})?"outlined":"textGray",onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),children:"H3"}),g.jsx(d,{dataTest:"richeditor-h4-button",size:"small",variant:t.isActive("heading",{level:4})?"outlined":"textGray",onClick:()=>t.chain().focus().toggleHeading({level:4}).run(),children:"H4"}),g.jsx(d,{dataTest:"richeditor-h5-button",size:"small",variant:t.isActive("heading",{level:5})?"outlined":"textGray",onClick:()=>t.chain().focus().toggleHeading({level:5}).run(),children:"H5"}),g.jsx(d,{dataTest:"richeditor-h6-button",size:"small",variant:t.isActive("heading",{level:6})?"outlined":"textGray",onClick:()=>t.chain().focus().toggleHeading({level:6}).run(),children:"H6"}),g.jsx(d,{dataTest:"richeditor-bullet-list-button",size:"small",variant:t.isActive("bulletList")?"outlined":"textGray",onClick:()=>t.chain().focus().toggleBulletList().run(),children:"Bullet list"}),g.jsx(d,{dataTest:"richeditor-ordered-list-button",size:"small",variant:t.isActive("orderedList")?"outlined":"textGray",onClick:()=>t.chain().focus().toggleOrderedList().run(),children:"Ordered list"}),g.jsx(d,{dataTest:"richeditor-blockquote-button",size:"small",variant:t.isActive("blockquote")?"outlined":"textGray",onClick:()=>t.chain().focus().toggleBlockquote().run(),children:"Blockquote"}),g.jsx(d,{dataTest:"richeditor-horizontal-rule-button",size:"small",variant:"textGray",onClick:()=>t.chain().focus().setHorizontalRule().run(),children:"Horizontal rule"}),g.jsx(d,{dataTest:"richeditor-hard-break-button",size:"small",variant:"textGray",onClick:()=>t.chain().focus().setHardBreak().run(),children:"Hard break"}),g.jsx("input",{type:"color",onInput:e=>t.chain().focus().setColor(e.currentTarget.value).run(),value:t.getAttributes("textStyle").color,"data-testid":"setColor"})]}):null,Ga=[ma,ga,ya],Ya=[Sa,Ea,Da,Ia,Ra,Ha,za,Ba,_a,qa,Ka,Ja],Xa=({dataTest:t,id:e,inputRef:n,className:r,disabled:o,ghost:i,is_error:s,label:a,placeholder:c,helperText:d,isRequired:h,hideMenuBar:p,noDefaultStyles:u,...f})=>{const m=ua({...f,extensions:o||i||p?[...Ga,ba.configure({placeholder:c}),...f.extensions||[]]:[...Ga,...Ya,ba.configure({placeholder:c}),...f.extensions||[]],shouldRerenderOnTransaction:f.shouldRerenderOnTransaction||!1,immediatelyRender:f.immediatelyRender||!0,editable:f.editable||!o&&!i},[]);return l(n,(()=>m)),m?g.jsxs("div",{className:"relative",children:[a&&g.jsx("span",{className:"text-custom-grey-06 mb-2 font-sans text-xs font-semibold leading-4","data-test":`label-${t}`,children:a}),!p&&!o&&!i&&g.jsx(Ua,{editor:m}),g.jsx(ea,{id:e,className:b(!u&&"core-ui-rte",!u&&!o&&!i&&"core-ui-rte-edit-mode",i&&"core-ui-rte-ghost-mode",s&&"core-ui-rte-error",r),editor:m}),(s||h)&&g.jsx("span",{className:b("core-ui-rte-helper-text",s&&"core-ui-rte-error"),"data-test":`error-${t}`,children:d})]}):null};export{Xa as RichInput};
package/package.json CHANGED
@@ -1,133 +1,133 @@
1
1
  {
2
- "name": "asma-ui-richeditor",
3
- "publishConfig": {
4
- "access": "public"
2
+ "name": "asma-ui-richeditor",
3
+ "publishConfig": {
4
+ "access": "public"
5
+ },
6
+ "version": "0.1.1",
7
+ "type": "module",
8
+ "files": [
9
+ "dist/**/*",
10
+ "dist/style.css",
11
+ "tw-configs/**/*"
12
+ ],
13
+ "keywords": [],
14
+ "author": "asma-team",
15
+ "types": "./dist/index.d.ts",
16
+ "main": "./dist/asma-ui-richeditor.es.js",
17
+ "module": "./dist/asma-ui-richeditor.es.js",
18
+ "license": "UNLICENSED",
19
+ "dependencies": {
20
+ "@emotion/react": "^11.11.1",
21
+ "@emotion/styled": "^11.11.0",
22
+ "@fontsource/roboto": "^5.0.4",
23
+ "@mui/material": "^5.13.7",
24
+ "@tiptap/extension-blockquote": "^2.6.5",
25
+ "@tiptap/extension-bold": "^2.6.5",
26
+ "@tiptap/extension-bullet-list": "^2.6.5",
27
+ "@tiptap/extension-color": "^2.6.5",
28
+ "@tiptap/extension-document": "^2.6.5",
29
+ "@tiptap/extension-hard-break": "^2.6.5",
30
+ "@tiptap/extension-heading": "^2.6.5",
31
+ "@tiptap/extension-horizontal-rule": "^2.6.5",
32
+ "@tiptap/extension-italic": "^2.6.5",
33
+ "@tiptap/extension-list-item": "^2.6.5",
34
+ "@tiptap/extension-ordered-list": "^2.6.5",
35
+ "@tiptap/extension-paragraph": "^2.6.5",
36
+ "@tiptap/extension-placeholder": "^2.6.5",
37
+ "@tiptap/extension-strike": "^2.6.5",
38
+ "@tiptap/extension-text": "^2.6.5",
39
+ "@tiptap/extension-text-style": "^2.6.5",
40
+ "@tiptap/react": "^2.6.5",
41
+ "clsx": "^2.1.1",
42
+ "node": "18.17.0",
43
+ "react": "^18.2.0",
44
+ "react-dom": "^18.2.0"
45
+ },
46
+ "devDependencies": {
47
+ "@changesets/cli": "^2.26.2",
48
+ "@faker-js/faker": "^8.0.2",
49
+ "@rollup/plugin-terser": "^0.4.3",
50
+ "@storybook/addon-a11y": "^7.6.9",
51
+ "@storybook/addon-essentials": "^7.6.9",
52
+ "@storybook/addon-interactions": "^7.6.9",
53
+ "@storybook/addon-links": "^7.6.9",
54
+ "@storybook/addon-mdx-gfm": "^7.6.9",
55
+ "@storybook/addon-styling": "^1.3.7",
56
+ "@storybook/addons": "^7.6.9",
57
+ "@storybook/blocks": "^7.6.9",
58
+ "@storybook/manager-api": "^7.6.9",
59
+ "@storybook/preset-create-react-app": "^7.6.9",
60
+ "@storybook/react": "^7.6.9",
61
+ "@storybook/react-vite": "^7.6.9",
62
+ "@storybook/test-runner": "^0.16.0",
63
+ "@storybook/testing-library": "^0.2.2",
64
+ "@storybook/theming": "^7.6.9",
65
+ "@types/lodash-es": "^4.17.7",
66
+ "@types/node": "^18.0.3",
67
+ "@types/react": "^18.0.37",
68
+ "@types/react-dom": "^18.0.11",
69
+ "@typescript-eslint/eslint-plugin": "^5.59.0",
70
+ "@typescript-eslint/parser": "^5.59.0",
71
+ "@vitejs/plugin-react": "^4.0.0",
72
+ "asma-core-ui": "^3.0.71",
73
+ "autoprefixer": "^10.4.14",
74
+ "axe-playwright": "^1.2.3",
75
+ "axios": "^1.6.8",
76
+ "eslint": "^8.38.0",
77
+ "eslint-plugin-react-hooks": "^4.6.0",
78
+ "eslint-plugin-react-refresh": "^0.3.4",
79
+ "eslint-plugin-storybook": "^0.6.15",
80
+ "postcss": "^8.4.24",
81
+ "prop-types": "^15.8.1",
82
+ "rollup-plugin-typescript2": "^0.35.0",
83
+ "storybook": "^7.6.9",
84
+ "storybook-addon-themes": "^6.1.0",
85
+ "tailwind-scrollbar": "^3.1.0",
86
+ "tailwindcss": "^3.3.2",
87
+ "typescript": "^5.0.2",
88
+ "typescript-plugin-css-modules": "^5.0.1",
89
+ "vite": "^4.3.9",
90
+ "vite-plugin-css-injected-by-js": "^3.5.1",
91
+ "vite-plugin-dts": "^3.1.1",
92
+ "vite-tsconfig-paths": "^4.2.0"
93
+ },
94
+ "peerDependencies": {
95
+ "@emotion/react": "^11.*",
96
+ "@emotion/styled": "^11.*",
97
+ "@mui/material": "^5.*",
98
+ "immer": "^9.*",
99
+ "react": "^18.*",
100
+ "react-dom": "^18.*"
101
+ },
102
+ "resolutions": {
103
+ "@types/node": "18.0.3",
104
+ "node": "18.17.0"
105
+ },
106
+ "exports": {
107
+ ".": {
108
+ "import": "./dist/asma-ui-richeditor.es.js"
5
109
  },
6
- "version": "0.1.0",
7
- "type": "module",
8
- "files": [
9
- "dist/**/*",
10
- "dist/style.css",
11
- "tw-configs/**/*"
12
- ],
13
- "keywords": [],
14
- "author": "asma-team",
15
- "types": "./dist/index.d.ts",
16
- "main": "./dist/asma-ui-richeditor.es.js",
17
- "module": "./dist/asma-ui-richeditor.es.js",
18
- "scripts": {
19
- "dev": "vite",
20
- "build": "npx tsc && rm -rf ./dist && vite build",
21
- "preview": "vite preview",
22
- "lint": "eslint src/**/*.{js,jsx,ts,tsx}",
23
- "version": "echo $npm_package_version",
24
- "lint:fix": "eslint --fix src/**/*.{jsx,ts,tsx}",
25
- "prettier": "prettier --write src//**/*.{ts,tsx,scss} --config ./.prettierrc",
26
- "storybook": "storybook dev -p 6006",
27
- "storybook:no-browser": "storybook dev -p 6006 --no-open",
28
- "storybook:node18": "export NODE_OPTIONS=--openssl-legacy-provider && storybook dev -p 6006",
29
- "storybook:node18:win": "set NODE_OPTIONS=--openssl-legacy-provider && storybook dev -p 6006",
30
- "build-storybook": "export NODE_OPTIONS=--max_old_space_size=6240 && storybook build",
31
- "test-storybook": "test-storybook",
32
- "changeset:pre-beta": "changeset pre enter beta",
33
- "changeset:pre-exit": "changeset pre exit",
34
- "changeset:version": "changeset version",
35
- "changeset:publish": "changeset publish",
36
- "changeset:status": "changeset status"
37
- },
38
- "license": "UNLICENSED",
39
- "dependencies": {
40
- "@emotion/react": "^11.11.1",
41
- "@emotion/styled": "^11.11.0",
42
- "@fontsource/roboto": "^5.0.4",
43
- "@mui/material": "^5.13.7",
44
- "@tiptap/extension-blockquote": "^2.6.5",
45
- "@tiptap/extension-bold": "^2.6.5",
46
- "@tiptap/extension-bullet-list": "^2.6.5",
47
- "@tiptap/extension-color": "^2.6.5",
48
- "@tiptap/extension-document": "^2.6.5",
49
- "@tiptap/extension-hard-break": "^2.6.5",
50
- "@tiptap/extension-heading": "^2.6.5",
51
- "@tiptap/extension-horizontal-rule": "^2.6.5",
52
- "@tiptap/extension-italic": "^2.6.5",
53
- "@tiptap/extension-list-item": "^2.6.5",
54
- "@tiptap/extension-ordered-list": "^2.6.5",
55
- "@tiptap/extension-paragraph": "^2.6.5",
56
- "@tiptap/extension-placeholder": "^2.6.5",
57
- "@tiptap/extension-strike": "^2.6.5",
58
- "@tiptap/extension-text": "^2.6.5",
59
- "@tiptap/extension-text-style": "^2.6.5",
60
- "@tiptap/react": "^2.6.5",
61
- "clsx": "^2.1.1",
62
- "node": "18.17.0",
63
- "react": "^18.2.0",
64
- "react-dom": "^18.2.0"
65
- },
66
- "devDependencies": {
67
- "@changesets/cli": "^2.26.2",
68
- "@faker-js/faker": "^8.0.2",
69
- "@rollup/plugin-terser": "^0.4.3",
70
- "@storybook/addon-a11y": "^7.6.9",
71
- "@storybook/addon-essentials": "^7.6.9",
72
- "@storybook/addon-interactions": "^7.6.9",
73
- "@storybook/addon-links": "^7.6.9",
74
- "@storybook/addon-mdx-gfm": "^7.6.9",
75
- "@storybook/addon-styling": "^1.3.7",
76
- "@storybook/addons": "^7.6.9",
77
- "@storybook/blocks": "^7.6.9",
78
- "@storybook/manager-api": "^7.6.9",
79
- "@storybook/preset-create-react-app": "^7.6.9",
80
- "@storybook/react": "^7.6.9",
81
- "@storybook/react-vite": "^7.6.9",
82
- "@storybook/test-runner": "^0.16.0",
83
- "@storybook/testing-library": "^0.2.2",
84
- "@storybook/theming": "^7.6.9",
85
- "@types/lodash-es": "^4.17.7",
86
- "@types/node": "^18.0.3",
87
- "@types/react": "^18.0.37",
88
- "@types/react-dom": "^18.0.11",
89
- "@typescript-eslint/eslint-plugin": "^5.59.0",
90
- "@typescript-eslint/parser": "^5.59.0",
91
- "@vitejs/plugin-react": "^4.0.0",
92
- "asma-core-ui": "^3.0.71",
93
- "autoprefixer": "^10.4.14",
94
- "axe-playwright": "^1.2.3",
95
- "axios": "^1.6.8",
96
- "eslint": "^8.38.0",
97
- "eslint-plugin-react-hooks": "^4.6.0",
98
- "eslint-plugin-react-refresh": "^0.3.4",
99
- "eslint-plugin-storybook": "^0.6.15",
100
- "postcss": "^8.4.24",
101
- "prop-types": "^15.8.1",
102
- "rollup-plugin-typescript2": "^0.35.0",
103
- "storybook": "^7.6.9",
104
- "storybook-addon-themes": "^6.1.0",
105
- "tailwind-scrollbar": "^3.1.0",
106
- "tailwindcss": "^3.3.2",
107
- "typescript": "^5.0.2",
108
- "typescript-plugin-css-modules": "^5.0.1",
109
- "vite": "^4.3.9",
110
- "vite-plugin-css-injected-by-js": "^3.5.1",
111
- "vite-plugin-dts": "^3.1.1",
112
- "vite-tsconfig-paths": "^4.2.0"
113
- },
114
- "peerDependencies": {
115
- "@emotion/react": "^11.*",
116
- "@emotion/styled": "^11.*",
117
- "@mui/material": "^5.*",
118
- "immer": "^9.*",
119
- "react": "^18.*",
120
- "react-dom": "^18.*"
121
- },
122
- "resolutions": {
123
- "@types/node": "18.0.3",
124
- "node": "18.17.0"
125
- },
126
- "exports": {
127
- ".": {
128
- "import": "./dist/asma-ui-richeditor.es.js"
129
- },
130
- "./dist/style.css": "./dist/style.css",
131
- "./tw-configs/twConfigs.json": "./tw-configs/twConfigs.json"
132
- }
133
- }
110
+ "./dist/style.css": "./dist/style.css",
111
+ "./tw-configs/twConfigs.json": "./tw-configs/twConfigs.json"
112
+ },
113
+ "scripts": {
114
+ "dev": "vite",
115
+ "build": "npx tsc && rm -rf ./dist && vite build",
116
+ "preview": "vite preview",
117
+ "lint": "eslint src/**/*.{js,jsx,ts,tsx}",
118
+ "version": "echo $npm_package_version",
119
+ "lint:fix": "eslint --fix src/**/*.{jsx,ts,tsx}",
120
+ "prettier": "prettier --write src//**/*.{ts,tsx,scss} --config ./.prettierrc",
121
+ "storybook": "storybook dev -p 6006",
122
+ "storybook:no-browser": "storybook dev -p 6006 --no-open",
123
+ "storybook:node18": "export NODE_OPTIONS=--openssl-legacy-provider && storybook dev -p 6006",
124
+ "storybook:node18:win": "set NODE_OPTIONS=--openssl-legacy-provider && storybook dev -p 6006",
125
+ "build-storybook": "export NODE_OPTIONS=--max_old_space_size=6240 && storybook build",
126
+ "test-storybook": "test-storybook",
127
+ "changeset:pre-beta": "changeset pre enter beta",
128
+ "changeset:pre-exit": "changeset pre exit",
129
+ "changeset:version": "changeset version",
130
+ "changeset:publish": "changeset publish",
131
+ "changeset:status": "changeset status"
132
+ }
133
+ }