@frontify/fondue 12.0.0-beta.249 → 12.0.0-beta.250

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -68,7 +68,7 @@ Shift+Ctrl+Return`:"Already at maximum numbers of columns"),onMouseDown:u=>DV(a,
68
68
  font-weight: bold;
69
69
  line-height: 10px;
70
70
  border-radius: 2px;
71
- `]},pL0=e=>t.createElement(h.MentionInputElement,{...e,styles:zL0});class VL0 extends n0{constructor(l=h.ELEMENT_MENTION_INPUT,a=pL0){super(l,a)}}class TL0 extends a0{constructor(l){super(EL0,{markupElement:new UV().setNodeWithMentionable(l.mentionableItems),markupInputElement:new VL0,...l})}inline(){var l;return kL0(((l=this.props)==null?void 0:l.mentionableItems)||[])}plugins(){return[h.createComboboxPlugin(),h.createMentionPlugin(bL0)]}}const jL0="blur-on-break-plugin",l7=()=>{var e;(e=document.activeElement)==null||e.blur()},DL0=(e,{options:{onBreak:l=()=>{}}})=>a=>{h.Hotkeys.isSplitBlock(a)&&(a.stopPropagation(),a.preventDefault(),l7(),typeof l=="function"&&l(e.children))},FL0="blurOnBreak",BL0=h.createPluginFactory({key:FL0,handlers:{onKeyDown:DL0}});class OL0 extends a0{constructor(a){super(jL0,{...a});Y(this,"onBreak");this.onBreak=a==null?void 0:a.onBreak}plugins(){return[BL0({options:{onBreak:this.onBreak}})]}}const B1=new NV;B1.setPlugin(new qp).setPlugin(new uV({textStyles:[new cV]})).setPlugin([new Pp,new Xp,new TV,new zV,new Rp,new Yp],[new Tp,new Vp,new Dp,new jp,new ZV,new pp,new CV,new HV,new Wp]);class s2{static getInstance(){return this.editor===void 0&&this.init(),this.editor}static init(l=x1(),a=B1){const o=J3(l,a);return this.editor=h.createPlateEditor({id:l,plugins:o.create()}),this}}Y(s2,"editor"),Y(s2,"editorId",x1());const PL0=e=>new DOMParser().parseFromString(e,"text/html").body.children.length>0,UL0=e=>PL0(e)?e:`<p>${e}</p>`,YV=[{type:h.ELEMENT_PARAGRAPH,children:[{text:""}]}],m2=({editorId:e="parseRawValue",raw:l,plugins:a})=>{const o=s2.init(`${e}_parseRawValue`,a).getInstance();let i=YV;if(!l)return i;try{i=JSON.parse(l)}catch{const c=l.trim().replaceAll(/>\s+</g,"><"),s=UL0(c),m=h.deserializeHtml(o,{element:s,stripWhitespace:!0});m&&(i=m)}return o.children=i,h.normalizeEditor(o,{force:!0}),o.children},h5=e=>e&&typeof e=="object"&&!Array.isArray(e),GV=(e,l)=>{if(!h5(e)||!h5(l))return{};const a=Object.assign({},e);for(const o of Object.keys(l)){if(o in e&&h5(l[o])){a[o]=GV(e[o],l[o]);continue}Object.assign(a,{[o]:l[o]})}return a},QL0=e=>e.hasOwnProperty("type")&&typeof e.type=="string"&&e.type.length>0,YL0=e=>e.hasOwnProperty("children")&&Array.isArray(e.children)&&e.children.length===1,GL0=e=>typeof e=="object"&&e.hasOwnProperty("text")&&typeof e.text=="string"&&e.text.length===0,WL0=e=>YL0(e)&&GL0(e.children[0]),qL0=e=>{if(!e)return!0;if(Array.isArray(e)&&e.length<2){if(e.length===0)return!0;const l=e[0];if(QL0(l)&&WL0(l))return!0}return!1},KL0=({children:e,editorWidth:l,toolbarButtonGroups:a=[],toolbarWidth:o})=>{const[i,c]=t.useState();return t.useEffect(()=>{if(o)c(o);else{const s=Zp(a);s>0&&c(s+a.length+Mp)}},[l,o,a]),t.createElement(h.BalloonToolbar,{floatingOptions:{middleware:[h.flip(),h.shift()]},styles:{root:{border:"none",background:"#ffffff",width:i}}},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))},WV={[f0.BOTTOM]:{PlateWrapperClassNames:"tw-relative tw-w-full tw-flex tw-flex-col",ToolbarWrapper:qc0},[f0.FLOATING]:{PlateWrapperClassNames:"tw-relative tw-w-full",ToolbarWrapper:KL0},[f0.TOP]:{PlateWrapperClassNames:"tw-relative tw-w-full tw-flex tw-flex-col-reverse",ToolbarWrapper:Kc0}},$L0=(e,l)=>{const a=WV[e].PlateWrapperClassNames;return A([a,l&&"tw-border tw-border-line-strong tw-rounded"])},XL0=({children:e,apply:l})=>{for(const a of e)l({type:"remove_node",path:[0],node:a})},JL0=({value:e})=>{const l=h.usePlateEditorRef();return t.useEffect(()=>{e&&(XL0(l),h.insertNodes(l,e))},[l,e]),null},_L0={position:"relative",height:"0"},qV=({id:e,value:l,placeholder:a="",readonly:o=!1,onTextChange:i,onBlur:c,padding:s=y3.None,position:m=f0.FLOATING,plugins:L=B1,updateValueOnChange:d=!1,onValueChanged:u,border:f=!0,toolbarWidth:w})=>{var b,x;const g=C0(e),{localValue:v,onChange:I,memoizedValue:C,config:E}=_c0({editorId:g,initialValue:l,onTextChange:i,plugins:L,onValueChanged:u}),N=L.plugins.find(M=>M.key===F1),Z=((b=N==null?void 0:N.options)==null?void 0:b.columns)??1,S=((x=N==null?void 0:N.options)==null?void 0:x.gap)??X3,k={placeholder:a,renderPlaceholder:({children:M,attributes:H})=>{const p={...H,style:{...H.style,..._L0}};return t.createElement("span",{...p},M)},readOnly:o,onBlur:()=>c&&c(JSON.stringify(v.current)),className:`${s}`,style:{columns:Z,columnGap:S},onKeyDown:M=>{M.code==="Tab"&&l7()},scrollSelectionIntoView:()=>{}};return t.createElement(yp,{value:{styles:E.styles(),position:m,border:f}},t.createElement(h.Plate,{id:g,onChange:I,editableProps:k,plugins:E.create(),initialValue:C},E.toolbar(w),E.inline(),d&&t.createElement(JL0,{value:m2({editorId:g,raw:l,plugins:L})})))};qV.displayName="FondueRichTextEditor";const KV=e=>e.split("").reverse().join(""),O1=(e,l)=>{const a=e.trim(),o=a,i=`${l}${o}${KV(l)}`;if(o.length===e.length)return i;const c=l+o+KV(l);return e.replace(a,c)},RL0=(e,l)=>{const a=`
71
+ `]},pL0=e=>t.createElement(h.MentionInputElement,{...e,styles:zL0});class VL0 extends n0{constructor(l=h.ELEMENT_MENTION_INPUT,a=pL0){super(l,a)}}class TL0 extends a0{constructor(l){super(EL0,{markupElement:new UV().setNodeWithMentionable(l.mentionableItems),markupInputElement:new VL0,...l})}inline(){var l;return kL0(((l=this.props)==null?void 0:l.mentionableItems)||[])}plugins(){return[h.createComboboxPlugin(),h.createMentionPlugin(bL0)]}}const jL0="blur-on-break-plugin",l7=()=>{var e;(e=document.activeElement)==null||e.blur()},DL0=(e,{options:{onBreak:l=()=>{}}})=>a=>{h.Hotkeys.isSplitBlock(a)&&(a.stopPropagation(),a.preventDefault(),l7(),typeof l=="function"&&l(e.children))},FL0="blurOnBreak",BL0=h.createPluginFactory({key:FL0,handlers:{onKeyDown:DL0}});class OL0 extends a0{constructor(a){super(jL0,{...a});Y(this,"onBreak");this.onBreak=a==null?void 0:a.onBreak}plugins(){return[BL0({options:{onBreak:this.onBreak}})]}}const B1=new NV;B1.setPlugin(new qp).setPlugin(new uV({textStyles:[new cV]})).setPlugin([new Pp,new Xp,new TV,new zV,new Rp,new Yp],[new Tp,new Vp,new Dp,new jp,new ZV,new pp,new CV,new HV,new Wp]);class s2{static getInstance(){return this.editor===void 0&&this.init(),this.editor}static init(l=x1(),a=B1){const o=J3(l,a);return this.editor=h.createPlateEditor({id:l,plugins:o.create()}),this}}Y(s2,"editor"),Y(s2,"editorId",x1());const PL0=e=>new DOMParser().parseFromString(e,"text/html").body.children.length>0,UL0=e=>PL0(e)?e:`<p>${e}</p>`,YV=[{type:h.ELEMENT_PARAGRAPH,children:[{text:""}]}],m2=({editorId:e="parseRawValue",raw:l,plugins:a})=>{const o=s2.init(`${e}_parseRawValue`,a).getInstance();let i=YV;if(!l)return i;try{i=JSON.parse(l)}catch{const c=l.trim().replaceAll(/>\s+</g,"><"),s=UL0(c),m=h.deserializeHtml(o,{element:s,stripWhitespace:!0});m&&(i=m)}return o.children=i,h.normalizeEditor(o,{force:!0}),o.children},h5=e=>e&&typeof e=="object"&&!Array.isArray(e),GV=(e,l)=>{if(!h5(e)||!h5(l))return{};const a=Object.assign({},e);for(const o of Object.keys(l)){if(o in e&&h5(l[o])){a[o]=GV(e[o],l[o]);continue}Object.assign(a,{[o]:l[o]})}return a},QL0=e=>e.hasOwnProperty("type")&&typeof e.type=="string"&&e.type.length>0,YL0=e=>e.hasOwnProperty("children")&&Array.isArray(e.children)&&e.children.length===1,GL0=e=>typeof e=="object"&&e.hasOwnProperty("text")&&typeof e.text=="string"&&e.text.length===0,WL0=e=>YL0(e)&&GL0(e.children[0]),qL0=e=>{if(!e)return!0;if(Array.isArray(e)&&e.length<2){if(e.length===0)return!0;const l=e[0];if(QL0(l)&&WL0(l))return!0}return!1},KL0=({children:e,editorWidth:l,toolbarButtonGroups:a=[],toolbarWidth:o})=>{const[i,c]=t.useState();return t.useEffect(()=>{if(o)c(o);else{const s=Zp(a);s>0&&c(s+a.length+Mp)}},[l,o,a]),t.createElement(h.BalloonToolbar,{floatingOptions:{middleware:[h.flip(),h.shift()]},styles:{root:{border:"none",background:"#ffffff",width:i}}},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))},WV={[f0.BOTTOM]:{PlateWrapperClassNames:"tw-relative tw-w-full tw-flex tw-flex-col",ToolbarWrapper:qc0},[f0.FLOATING]:{PlateWrapperClassNames:"tw-relative tw-w-full",ToolbarWrapper:KL0},[f0.TOP]:{PlateWrapperClassNames:"tw-relative tw-w-full tw-flex tw-flex-col-reverse",ToolbarWrapper:Kc0}},$L0=(e,l)=>{const a=WV[e].PlateWrapperClassNames;return A([a,l&&"tw-border tw-border-line-strong tw-rounded"])},XL0=({children:e,apply:l})=>{for(const a of e)l({type:"remove_node",path:[0],node:a})},JL0=({value:e})=>{const l=h.usePlateEditorRef();return t.useEffect(()=>{e&&(XL0(l),h.insertNodes(l,e))},[l,e]),null},_L0={position:"relative",height:"0"},qV=({id:e,value:l,placeholder:a="",readonly:o=!1,onTextChange:i,onBlur:c,padding:s=y3.None,position:m=f0.FLOATING,plugins:L=B1,updateValueOnChange:d=!1,onValueChanged:u,border:f=!0,toolbarWidth:w})=>{var b,x;const g=C0(e),{localValue:v,onChange:I,memoizedValue:C,config:E}=_c0({editorId:g,initialValue:l,onTextChange:i,plugins:L,onValueChanged:u}),N=L.plugins.find(M=>M.key===F1),Z=((b=N==null?void 0:N.options)==null?void 0:b.columns)??1,S=((x=N==null?void 0:N.options)==null?void 0:x.gap)??X3,k={placeholder:a,renderPlaceholder:({children:M,attributes:H})=>{const p={...H,style:{...H.style,..._L0}};return t.createElement("span",{...p},M)},readOnly:o,onBlur:()=>c&&c(JSON.stringify(v.current)),className:`${s}`,style:{columns:Z,columnGap:S},onKeyDown:M=>{M.code==="Tab"&&l7()},scrollSelectionIntoView:()=>{}};return t.createElement(yp,{value:{styles:E.styles(),position:m,border:f}},t.createElement(h.Plate,{id:g,onChange:I,editableProps:k,plugins:E.create(),initialValue:C},!k.readOnly&&E.toolbar(w),E.inline(),d&&t.createElement(JL0,{value:m2({editorId:g,raw:l,plugins:L})})))};qV.displayName="FondueRichTextEditor";const KV=e=>e.split("").reverse().join(""),O1=(e,l)=>{const a=e.trim(),o=a,i=`${l}${o}${KV(l)}`;if(o.length===e.length)return i;const c=l+o+KV(l);return e.replace(a,c)},RL0=(e,l)=>{const a=`
72
72
  `;return(l.strikethrough||l.bold||l.italic)&&new RegExp(a,"g").test(e)&&(e=e.replaceAll(a,`\\
73
73
  `)),e},ed0=(e,l)=>(l.strikethrough&&l.bold&&l.italic?e=O1(e,"~~***"):l.bold&&l.italic?e=O1(e,"***"):(l.bold&&(e=O1(e,"**")),l.italic&&(e=O1(e,"_")),l.strikethrough&&(e=O1(e,"~~")),l.code&&(e=O1(e,"`"))),e=RL0(e,l),e),P1=e=>!("type"in e),td0={paragraph:"paragraph",blockQuote:"block_quote",codeBlock:"code_block",link:"link",ulList:"ul_list",olList:"ol_list",listItem:"list_item",listItemChild:"lic",heading:{1:"heading_one",2:"heading_two",3:"heading_three",4:"heading_four",5:"heading_five",6:"heading_six"},emphasisMark:"italic",strongMark:"bold",deleteMark:"strikethrough",inlineCodeMark:"code",thematicBreak:"thematic_break",image:"image",mention:"mention"},f5={Blank:"_blank",Self:"_self"},ld0=e=>`@[${e.category}:${e.id}]`,nd0=e=>`${e}
74
74
  `,rd0=(e,l,a,o)=>{const i=a&&a.parentType===e.olList,c=a.children.length===1&&P1(a.children[0]);let s="";for(let m=0;o>m;m++)i?s+=" ":s+=" ";return`${s}${i?"1.":"-"} ${l}${c?`