@frontify/fondue 12.0.0-beta.135 → 12.0.0-beta.136
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/RichTextEditor/RichTextEditor.es.js +25 -23
- package/dist/components/RichTextEditor/RichTextEditor.es.js.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -69,7 +69,7 @@ Shift+Ctrl+Return`:"Already at maximum numbers of columns"),onMouseDown:u=>Qb(a,
|
|
|
69
69
|
font-weight: bold;
|
|
70
70
|
line-height: 10px;
|
|
71
71
|
border-radius: 2px;
|
|
72
|
-
`]},rc0=e=>t.createElement(m.MentionInputElement,{...e,styles:nc0});class ac0 extends s0{constructor(l=m.ELEMENT_MENTION_INPUT,a=rc0){super(l,a)}}class oc0 extends w0{constructor(l){super(Wi0,{markupElement:new Kb().setNodeWithMentionable(l.mentionableItems),markupInputElement:new ac0,...l})}inline(){var l;return tc0(((l=this.props)==null?void 0:l.mentionableItems)||[])}plugins(){return[m.createComboboxPlugin(),m.createMentionPlugin(lc0)]}}const ic0="blur-on-break-plugin",r3=()=>{var e;(e=document.activeElement)==null||e.blur()},cc0=(e,{options:{onBreak:l=()=>{}}})=>a=>{m.Hotkeys.isSplitBlock(a)&&(a.stopPropagation(),a.preventDefault(),r3(),typeof l=="function"&&l(e.children))},sc0="blurOnBreak",mc0=m.createPluginFactory({key:sc0,handlers:{onKeyDown:cc0}});class Lc0 extends w0{constructor(a){super(ic0,{...a});i0(this,"onBreak");this.onBreak=a==null?void 0:a.onBreak}plugins(){return[mc0({options:{onBreak:this.onBreak}})]}}const Q2=new zb;Q2.setPlugin(new hb,new Hb).setPlugin(new Pz).setPlugin([new Xz,new gb,new Ob,new Bb,new Eb,new sb,new db],[new Yz,new Qz,new Wz,new Gz,new kb,new Uz,new Nb,new pb,new wb]);class K1{static getInstance(){return this.editor===void 0&&this.init(),this.editor}static init(l=H1(),a=Q2){const o=Re(l,a);return this.editor=m.createPlateEditor({id:l,plugins:o.create()}),this}}i0(K1,"editor"),i0(K1,"editorId",H1());const dc0=e=>new DOMParser().parseFromString(e,"text/html").body.children.length>0,uc0=e=>dc0(e)?e:`<p>${e}</p>`,Jb=[{type:m.ELEMENT_PARAGRAPH,children:[{text:""}]}],Y2=({editorId:e="parseRawValue",raw:l,plugins:a})=>{const o=K1.init(`${e}_parseRawValue`,a).getInstance();let i=Jb;if(!l)return i;try{i=JSON.parse(l)}catch{const c=l.trim().replace(/>\s+</g,"><"),s=uc0(c),L=m.deserializeHtml(o,{element:s,stripWhitespace:!0});L&&(i=L)}return o.children=i,m.normalizeEditor(o,{force:!0}),o.children},G2=e=>e&&typeof e=="object"&&!Array.isArray(e),a3=(e,l)=>{if(!G2(e)||!G2(l))return{};const a=Object.assign({},e);for(const o of Object.keys(l)){if(o in e&&G2(l[o])){a[o]=a3(e[o],l[o]);continue}Object.assign(a,{[o]:l[o]})}return a},wc0=e=>e.hasOwnProperty("type")&&typeof e.type=="string"&&e.type.length>0,hc0=e=>e.hasOwnProperty("children")&&Array.isArray(e.children)&&e.children.length===1,fc0=e=>typeof e=="object"&&e.hasOwnProperty("text")&&typeof e.text=="string"&&e.text.length===0,vc0=e=>hc0(e)&&fc0(e.children[0]),gc0=e=>{if(!e)return!0;if(Array.isArray(e)&&e.length<2){if(e.length===0)return!0;const l=e[0];if(wc0(l)&&vc0(l))return!0}return!1},Ac0=({children:e,editorWidth:l,toolbarButtonGroups:a=[]})=>{const[o,i]=t.useState();return t.useEffect(()=>{const c=xz(a);c>0&&i(c+a.length+Sz)},[l,a]),t.createElement(m.BalloonToolbar,{floatingOptions:{middleware:[m.flip(),m.shift()]},styles:{root:{border:"none",background:"#ffffff",width:o}}},t.createElement("div",{"data-test-id":"toolbar-floating",className:"tw-rounded tw-min-h-12 tw-border tw-border-line tw-shadow-lg tw-bg-base tw-divide-y tw-divide-line tw-flex tw-flex-wrap"},e))},$b={[t0.BOTTOM]:{PlateWrapperClassNames:"tw-relative tw-w-full tw-flex tw-flex-col",ToolbarWrapper:ta0},[t0.FLOATING]:{PlateWrapperClassNames:"tw-relative tw-w-full",ToolbarWrapper:Ac0},[t0.TOP]:{PlateWrapperClassNames:"tw-relative tw-w-full tw-flex tw-flex-col-reverse",ToolbarWrapper:la0}},Cc0=(e,l)=>{const a=$b[e].PlateWrapperClassNames;return v([a,l&&"tw-border tw-border-line tw-rounded"])},Ec0=({children:e,apply:l})=>{for(const a of e)l({type:"remove_node",path:[0],node:a})},Mc0=({value:e})=>{const l=m.usePlateEditorRef();return t.useEffect(()=>{e&&(Ec0(l),m.insertNodes(l,e))},[l,e]),null},Ic0={position:"relative",height:"0"},_b=({id:e,value:l,placeholder:a="",readonly:o=!1,designTokens:i=i1,onTextChange:c,onBlur:s,padding:L=Be.None,position:d=t0.FLOATING,plugins:u=Q2,updateValueOnChange:w=!1,onValueChanged:h,border:f=!0})=>{var C,y;const A=A0(e),{localValue:g,onChange:I,memoizedValue:E,config:Z}=oa0({editorId:A,initialValue:l,onTextChange:c,plugins:u,onValueChanged:h}),M=u.plugins.find(H=>H.key===M1),N=((C=M==null?void 0:M.options)==null?void 0:C.columns)??1,S=((y=M==null?void 0:M.options)==null?void 0:y.gap)??_e,T={placeholder:a,renderPlaceholder:({children:H,attributes:b})=>{const k={...b,style:{...b.style,...Ic0}};return t.createElement("span",{...k},H)},readOnly:o,onBlur:()=>s&&s(JSON.stringify(g.current)),className:`${L}`,style:{columns:N,columnGap:S},onKeyDown:H=>{H.code==="Tab"&&r3()}};return t.createElement(ma0,{value:{designTokens:i,position:d,border:f}},t.createElement(m.Plate,{id:A,onChange:I,editableProps:T,plugins:Z.create(),initialValue:E},Z.toolbar(),Z.inline(),w&&t.createElement(Mc0,{value:Y2({editorId:A,raw:l,plugins:u})})))};_b.displayName="FondueRichTextEditor";const Zc0=(e,l)=>(l.strikethrough&&l.bold&&l.italic?e=I1(e,"~~***"):l.bold&&l.italic?e=I1(e,"***"):(l.bold&&(e=I1(e,"**")),l.italic&&(e=I1(e,"_")),l.strikethrough&&(e=I1(e,"~~")),l.code&&(e=I1(e,"`"))),e),Rb=e=>e.split("").reverse().join("");function I1(e,l){const a=e.trim(),o=a,i=`${l}${o}${Rb(l)}`;if(o.length===e.length)return i;const c=l+o+Rb(l);return e.replace(a,c)}const Z1=e=>!("type"in e),Nc0=e=>`@[${e.category}:${e.id}]`,Sc0=e=>`${e}
|
|
72
|
+
`]},rc0=e=>t.createElement(m.MentionInputElement,{...e,styles:nc0});class ac0 extends s0{constructor(l=m.ELEMENT_MENTION_INPUT,a=rc0){super(l,a)}}class oc0 extends w0{constructor(l){super(Wi0,{markupElement:new Kb().setNodeWithMentionable(l.mentionableItems),markupInputElement:new ac0,...l})}inline(){var l;return tc0(((l=this.props)==null?void 0:l.mentionableItems)||[])}plugins(){return[m.createComboboxPlugin(),m.createMentionPlugin(lc0)]}}const ic0="blur-on-break-plugin",r3=()=>{var e;(e=document.activeElement)==null||e.blur()},cc0=(e,{options:{onBreak:l=()=>{}}})=>a=>{m.Hotkeys.isSplitBlock(a)&&(a.stopPropagation(),a.preventDefault(),r3(),typeof l=="function"&&l(e.children))},sc0="blurOnBreak",mc0=m.createPluginFactory({key:sc0,handlers:{onKeyDown:cc0}});class Lc0 extends w0{constructor(a){super(ic0,{...a});i0(this,"onBreak");this.onBreak=a==null?void 0:a.onBreak}plugins(){return[mc0({options:{onBreak:this.onBreak}})]}}const Q2=new zb;Q2.setPlugin(new hb,new Hb).setPlugin(new Pz).setPlugin([new Xz,new gb,new Ob,new Bb,new Eb,new sb,new db],[new Yz,new Qz,new Wz,new Gz,new kb,new Uz,new Nb,new pb,new wb]);class K1{static getInstance(){return this.editor===void 0&&this.init(),this.editor}static init(l=H1(),a=Q2){const o=Re(l,a);return this.editor=m.createPlateEditor({id:l,plugins:o.create()}),this}}i0(K1,"editor"),i0(K1,"editorId",H1());const dc0=e=>new DOMParser().parseFromString(e,"text/html").body.children.length>0,uc0=e=>dc0(e)?e:`<p>${e}</p>`,Jb=[{type:m.ELEMENT_PARAGRAPH,children:[{text:""}]}],Y2=({editorId:e="parseRawValue",raw:l,plugins:a})=>{const o=K1.init(`${e}_parseRawValue`,a).getInstance();let i=Jb;if(!l)return i;try{i=JSON.parse(l)}catch{const c=l.trim().replace(/>\s+</g,"><"),s=uc0(c),L=m.deserializeHtml(o,{element:s,stripWhitespace:!0});L&&(i=L)}return o.children=i,m.normalizeEditor(o,{force:!0}),o.children},G2=e=>e&&typeof e=="object"&&!Array.isArray(e),a3=(e,l)=>{if(!G2(e)||!G2(l))return{};const a=Object.assign({},e);for(const o of Object.keys(l)){if(o in e&&G2(l[o])){a[o]=a3(e[o],l[o]);continue}Object.assign(a,{[o]:l[o]})}return a},wc0=e=>e.hasOwnProperty("type")&&typeof e.type=="string"&&e.type.length>0,hc0=e=>e.hasOwnProperty("children")&&Array.isArray(e.children)&&e.children.length===1,fc0=e=>typeof e=="object"&&e.hasOwnProperty("text")&&typeof e.text=="string"&&e.text.length===0,vc0=e=>hc0(e)&&fc0(e.children[0]),gc0=e=>{if(!e)return!0;if(Array.isArray(e)&&e.length<2){if(e.length===0)return!0;const l=e[0];if(wc0(l)&&vc0(l))return!0}return!1},Ac0=({children:e,editorWidth:l,toolbarButtonGroups:a=[]})=>{const[o,i]=t.useState();return t.useEffect(()=>{const c=xz(a);c>0&&i(c+a.length+Sz)},[l,a]),t.createElement(m.BalloonToolbar,{floatingOptions:{middleware:[m.flip(),m.shift()]},styles:{root:{border:"none",background:"#ffffff",width:o}}},t.createElement("div",{"data-test-id":"toolbar-floating",className:"tw-rounded tw-min-h-12 tw-border tw-border-line tw-shadow-lg tw-bg-base tw-divide-y tw-divide-line tw-flex tw-flex-wrap"},e))},$b={[t0.BOTTOM]:{PlateWrapperClassNames:"tw-relative tw-w-full tw-flex tw-flex-col",ToolbarWrapper:ta0},[t0.FLOATING]:{PlateWrapperClassNames:"tw-relative tw-w-full",ToolbarWrapper:Ac0},[t0.TOP]:{PlateWrapperClassNames:"tw-relative tw-w-full tw-flex tw-flex-col-reverse",ToolbarWrapper:la0}},Cc0=(e,l)=>{const a=$b[e].PlateWrapperClassNames;return v([a,l&&"tw-border tw-border-line tw-rounded"])},Ec0=({children:e,apply:l})=>{for(const a of e)l({type:"remove_node",path:[0],node:a})},Mc0=({value:e})=>{const l=m.usePlateEditorRef();return t.useEffect(()=>{e&&(Ec0(l),m.insertNodes(l,e))},[l,e]),null},Ic0={position:"relative",height:"0"},_b=({id:e,value:l,placeholder:a="",readonly:o=!1,designTokens:i=i1,onTextChange:c,onBlur:s,padding:L=Be.None,position:d=t0.FLOATING,plugins:u=Q2,updateValueOnChange:w=!1,onValueChanged:h,border:f=!0})=>{var C,y;const A=A0(e),{localValue:g,onChange:I,memoizedValue:E,config:Z}=oa0({editorId:A,initialValue:l,onTextChange:c,plugins:u,onValueChanged:h}),M=u.plugins.find(H=>H.key===M1),N=((C=M==null?void 0:M.options)==null?void 0:C.columns)??1,S=((y=M==null?void 0:M.options)==null?void 0:y.gap)??_e,T={placeholder:a,renderPlaceholder:({children:H,attributes:b})=>{const k={...b,style:{...b.style,...Ic0}};return t.createElement("span",{...k},H)},readOnly:o,onBlur:()=>s&&s(JSON.stringify(g.current)),className:`${L}`,style:{columns:N,columnGap:S},onKeyDown:H=>{H.code==="Tab"&&r3()},scrollSelectionIntoView:()=>{}};return t.createElement(ma0,{value:{designTokens:i,position:d,border:f}},t.createElement(m.Plate,{id:A,onChange:I,editableProps:T,plugins:Z.create(),initialValue:E},Z.toolbar(),Z.inline(),w&&t.createElement(Mc0,{value:Y2({editorId:A,raw:l,plugins:u})})))};_b.displayName="FondueRichTextEditor";const Zc0=(e,l)=>(l.strikethrough&&l.bold&&l.italic?e=I1(e,"~~***"):l.bold&&l.italic?e=I1(e,"***"):(l.bold&&(e=I1(e,"**")),l.italic&&(e=I1(e,"_")),l.strikethrough&&(e=I1(e,"~~")),l.code&&(e=I1(e,"`"))),e),Rb=e=>e.split("").reverse().join("");function I1(e,l){const a=e.trim(),o=a,i=`${l}${o}${Rb(l)}`;if(o.length===e.length)return i;const c=l+o+Rb(l);return e.replace(a,c)}const Z1=e=>!("type"in e),Nc0=e=>`@[${e.category}:${e.id}]`,Sc0=e=>`${e}
|
|
73
73
|
`,xc0=(e,l,a,o)=>{const i=a&&a.parentType===e.olList,c=a.children.length===1&&Z1(a.children[0]);let s="";for(let L=0;o>L;L++)i?s+=" ":s+=" ";return`${s}${i?"1.":"-"} ${l}${c?`
|
|
74
74
|
`:""}`},yc0=(e,l,a,o)=>(o===l.codeBlock||a===l.codeBlock||(e=$1(e)),e),kc0=(e,l,a,o,i,c)=>{const s=e.nodeTypes;switch(i){case s.heading[1]:return`# ${l}
|
|
75
75
|
`;case s.heading[2]:return`## ${l}
|