@frontify/fondue 12.0.0-beta.67 → 12.0.0-beta.68

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
@@ -70,7 +70,7 @@
70
70
  font-weight: bold;
71
71
  line-height: 10px;
72
72
  border-radius: 2px;
73
- `]},zE0=e=>t.default.createElement(h.MentionInputElement,{...e,styles:bE0});class TE0 extends A0{constructor(l=h.ELEMENT_MENTION_INPUT,o=zE0){super(l,o)}}class HE0 extends y0{constructor(l){super(vE0,{markupElement:new ZE0().setNodeWithMentionable(l.mentionableItems),markupInputElement:new TE0,...l})}inline(){var l;return kE0(((l=this.props)==null?void 0:l.mentionableItems)||[])}plugins(){return[h.createComboboxPlugin(),h.createMentionPlugin(pE0)]}}const yI=new Dx;yI.setPlugin(new ry,new cy).setPlugin(new Px).setPlugin([new Gx,new _x,new ey,new ly,new ny,new my,new Jx],[new Kx,new Wx,new $x,new qx,new Qx,new Yx,new Ox,new fy,new Ly]);const RH=new Dx;RH.setPlugin([new ry,new cy],[new Px],[new Gx,new _x,new ey,new ly,new ny,new my,new Jx],[new Kx,new Wx,new $x,new qx,new Qx,new Yx,new Ox,new jH,new fy,new Ly]);class qe{static getInstance(){return this.editor===void 0&&this.init(),this.editor}static init(l=Ce(),o=yI){const i=gk(l,o);return this.editor=h.createPlateEditor({id:l,plugins:i.create()}),this}}b0(qe,"editor"),b0(qe,"editorId",Ce());const jE0=e=>new DOMParser().parseFromString(e,"text/html").body.children.length>0,VE0=e=>jE0(e)?e:`<p>${e}</p>`,FH=[{type:h.ELEMENT_PARAGRAPH,children:[{text:""}]}],kI=({editorId:e="parseRawValue",raw:l,plugins:o})=>{const i=qe.init(`${e}_parseRawValue`,o).getInstance();let u=FH;if(!l)return u;try{u=JSON.parse(l)}catch{const d=l.trim().replace(/>\s+</g,"><"),s=VE0(d),m=h.deserializeHtml(i,{element:s,stripWhitespace:!0});m&&(u=m)}return i.children=u,h.normalizeEditor(i,{force:!0}),i.children},pI=e=>e&&typeof e=="object"&&!Array.isArray(e),Ek=(e,l)=>{if(!pI(e)||!pI(l))return{};const o=Object.assign({},e);for(const i of Object.keys(l)){if(i in e&&pI(l[i])){o[i]=Ek(e[i],l[i]);continue}Object.assign(o,{[i]:l[i]})}return o},DE0=e=>e.hasOwnProperty("type")&&typeof e.type=="string"&&e.type.length>0,BE0=e=>e.hasOwnProperty("children")&&Array.isArray(e.children)&&e.children.length===1,RE0=e=>typeof e=="object"&&e.hasOwnProperty("text")&&typeof e.text=="string"&&e.text.length===0,FE0=e=>BE0(e)&&RE0(e.children[0]),PE0=e=>{if(!e)return!0;if(Array.isArray(e)&&e.length<2){if(e.length===0)return!0;const l=e[0];if(DE0(l)&&FE0(l))return!0}return!1},OE0=({children:e,editorWidth:l,toolbarButtonGroups:o=[]})=>{const[i,u]=n.useState();return n.useEffect(()=>{const d=Vb(o);d>0&&u(d+o.length+jb)},[l,o]),t.default.createElement(h.BalloonToolbar,{floatingOptions:{middleware:[h.flip(),h.shift()]},styles:{root:{border:"none",background:"#ffffff",width:i}}},t.default.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))},PH={[d0.BOTTOM]:{PlateWrapperClassNames:"tw-relative tw-w-full tw-flex tw-flex-col",ToolbarWrapper:fo0},[d0.FLOATING]:{PlateWrapperClassNames:"tw-relative tw-w-full",ToolbarWrapper:OE0},[d0.TOP]:{PlateWrapperClassNames:"tw-relative tw-w-full tw-flex tw-flex-col-reverse",ToolbarWrapper:Lo0}},UE0=(e,l)=>{const o=PH[e].PlateWrapperClassNames;return M([o,l&&"tw-border tw-border-line tw-rounded"])},OH=()=>{var e;(e=document.activeElement)==null||e.blur()},QE0=({children:e,apply:l})=>{for(const o of e)l({type:"remove_node",path:[0],node:o})},YE0=({value:e})=>{const l=h.usePlateEditorRef();return n.useEffect(()=>{e&&(QE0(l),h.insertNodes(l,e))},[l,e]),null},GE0={position:"relative",height:"0"},WE0=({id:e,value:l,placeholder:o="",readonly:i=!1,designTokens:u=I1,onTextChange:d,onBlur:s,padding:m=Vx.None,position:f=d0.FLOATING,plugins:L=yI,updateValueOnChange:w=!1,onKeyDown:v,onValueChanged:g,border:E=!0})=>{const A=z0(e),{localValue:C,onChange:I,memoizedValue:Z,config:S}=Ao0({editorId:A,initialValue:l,onTextChange:d,plugins:L,onValueChanged:g}),y=n.useRef({placeholder:o,renderPlaceholder:({children:H,attributes:F})=>{const D={...F,style:{...F.style,...GE0}};return t.default.createElement("span",{...D},H)},readOnly:i,onBlur:()=>s&&s(JSON.stringify(C.current)),className:m,onKeyDown:H=>{H.code==="Tab"&&OH(),v&&v(H)}});return t.default.createElement(Mo0,{value:{designTokens:u,position:f,border:E}},t.default.createElement(h.Plate,{id:A,onChange:I,editableProps:y.current,plugins:S.create(),initialValue:Z},S.toolbar(),S.inline(),w&&t.default.createElement(YE0,{value:kI({editorId:A,raw:l})})))},KE0=(e,l)=>(l.strikethrough&&l.bold&&l.italic?e=le(e,"~~***"):l.bold&&l.italic?e=le(e,"***"):(l.bold&&(e=le(e,"**")),l.italic&&(e=le(e,"_")),l.strikethrough&&(e=le(e,"~~")),l.code&&(e=le(e,"`"))),e),UH=e=>e.split("").reverse().join("");function le(e,l){const o=e.trim(),i=o,u=`${l}${i}${UH(l)}`;if(i.length===e.length)return u;const d=l+i+UH(l);return e.replace(o,d)}const ae=e=>!("type"in e),qE0=e=>`@[${e.category}:${e.key}]`,$E0=(e,l,o,i)=>{const u=o&&o.parentType===e.olList,d=o.children.length===1&&ae(o.children[0]);let s="";for(let m=0;i>m;m++)u?s+=" ":s+=" ";return`${s}${u?"1.":"-"} ${l}${d?`
73
+ `]},zE0=e=>t.default.createElement(h.MentionInputElement,{...e,styles:bE0});class TE0 extends A0{constructor(l=h.ELEMENT_MENTION_INPUT,o=zE0){super(l,o)}}class HE0 extends y0{constructor(l){super(vE0,{markupElement:new ZE0().setNodeWithMentionable(l.mentionableItems),markupInputElement:new TE0,...l})}inline(){var l;return kE0(((l=this.props)==null?void 0:l.mentionableItems)||[])}plugins(){return[h.createComboboxPlugin(),h.createMentionPlugin(pE0)]}}const yI=new Dx;yI.setPlugin(new ry,new cy).setPlugin(new Px).setPlugin([new Gx,new _x,new ey,new ly,new ny,new my,new Jx],[new Kx,new Wx,new $x,new qx,new Qx,new Yx,new Ox,new fy,new Ly]);const RH=new Dx;RH.setPlugin([new ry,new cy],[new Px],[new Gx,new _x,new ey,new ly,new ny,new my,new Jx],[new Kx,new Wx,new $x,new qx,new Qx,new Yx,new Ox,new jH,new fy,new Ly]);class qe{static getInstance(){return this.editor===void 0&&this.init(),this.editor}static init(l=Ce(),o=yI){const i=gk(l,o);return this.editor=h.createPlateEditor({id:l,plugins:i.create()}),this}}b0(qe,"editor"),b0(qe,"editorId",Ce());const jE0=e=>new DOMParser().parseFromString(e,"text/html").body.children.length>0,VE0=e=>jE0(e)?e:`<p>${e}</p>`,FH=[{type:h.ELEMENT_PARAGRAPH,children:[{text:""}]}],kI=({editorId:e="parseRawValue",raw:l,plugins:o})=>{const i=qe.init(`${e}_parseRawValue`,o).getInstance();let u=FH;if(!l)return u;try{u=JSON.parse(l)}catch{const d=l.trim().replace(/>\s+</g,"><"),s=VE0(d),m=h.deserializeHtml(i,{element:s,stripWhitespace:!0});m&&(u=m)}return i.children=u,h.normalizeEditor(i,{force:!0}),i.children},pI=e=>e&&typeof e=="object"&&!Array.isArray(e),Ek=(e,l)=>{if(!pI(e)||!pI(l))return{};const o=Object.assign({},e);for(const i of Object.keys(l)){if(i in e&&pI(l[i])){o[i]=Ek(e[i],l[i]);continue}Object.assign(o,{[i]:l[i]})}return o},DE0=e=>e.hasOwnProperty("type")&&typeof e.type=="string"&&e.type.length>0,BE0=e=>e.hasOwnProperty("children")&&Array.isArray(e.children)&&e.children.length===1,RE0=e=>typeof e=="object"&&e.hasOwnProperty("text")&&typeof e.text=="string"&&e.text.length===0,FE0=e=>BE0(e)&&RE0(e.children[0]),PE0=e=>{if(!e)return!0;if(Array.isArray(e)&&e.length<2){if(e.length===0)return!0;const l=e[0];if(DE0(l)&&FE0(l))return!0}return!1},OE0=({children:e,editorWidth:l,toolbarButtonGroups:o=[]})=>{const[i,u]=n.useState();return n.useEffect(()=>{const d=Vb(o);d>0&&u(d+o.length+jb)},[l,o]),t.default.createElement(h.BalloonToolbar,{floatingOptions:{middleware:[h.flip(),h.shift()]},styles:{root:{border:"none",background:"#ffffff",width:i}}},t.default.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))},PH={[d0.BOTTOM]:{PlateWrapperClassNames:"tw-relative tw-w-full tw-flex tw-flex-col",ToolbarWrapper:fo0},[d0.FLOATING]:{PlateWrapperClassNames:"tw-relative tw-w-full",ToolbarWrapper:OE0},[d0.TOP]:{PlateWrapperClassNames:"tw-relative tw-w-full tw-flex tw-flex-col-reverse",ToolbarWrapper:Lo0}},UE0=(e,l)=>{const o=PH[e].PlateWrapperClassNames;return M([o,l&&"tw-border tw-border-line tw-rounded"])},OH=()=>{var e;(e=document.activeElement)==null||e.blur()},QE0=({children:e,apply:l})=>{for(const o of e)l({type:"remove_node",path:[0],node:o})},YE0=({value:e})=>{const l=h.usePlateEditorRef();return n.useEffect(()=>{e&&(QE0(l),h.insertNodes(l,e))},[l,e]),null},GE0={position:"relative",height:"0"},WE0=({id:e,value:l,placeholder:o="",readonly:i=!1,designTokens:u=I1,onTextChange:d,onBlur:s,padding:m=Vx.None,position:f=d0.FLOATING,plugins:L=yI,updateValueOnChange:w=!1,onKeyDown:v,onValueChanged:g,border:E=!0})=>{const A=z0(e),{localValue:C,onChange:I,memoizedValue:Z,config:S}=Ao0({editorId:A,initialValue:l,onTextChange:d,plugins:L,onValueChanged:g}),y=n.useRef({placeholder:o,renderPlaceholder:({children:H,attributes:F})=>{const D={...F,style:{...F.style,...GE0}};return t.default.createElement("span",{...D},H)},readOnly:i,onBlur:()=>s&&s(JSON.stringify(C.current)),className:m,onKeyDown:H=>{H.code==="Tab"&&OH(),v&&v(H,C.current)}});return t.default.createElement(Mo0,{value:{designTokens:u,position:f,border:E}},t.default.createElement(h.Plate,{id:A,onChange:I,editableProps:y.current,plugins:S.create(),initialValue:Z},S.toolbar(),S.inline(),w&&t.default.createElement(YE0,{value:kI({editorId:A,raw:l})})))},KE0=(e,l)=>(l.strikethrough&&l.bold&&l.italic?e=le(e,"~~***"):l.bold&&l.italic?e=le(e,"***"):(l.bold&&(e=le(e,"**")),l.italic&&(e=le(e,"_")),l.strikethrough&&(e=le(e,"~~")),l.code&&(e=le(e,"`"))),e),UH=e=>e.split("").reverse().join("");function le(e,l){const o=e.trim(),i=o,u=`${l}${i}${UH(l)}`;if(i.length===e.length)return u;const d=l+i+UH(l);return e.replace(o,d)}const ae=e=>!("type"in e),qE0=e=>`@[${e.category}:${e.key}]`,$E0=(e,l,o,i)=>{const u=o&&o.parentType===e.olList,d=o.children.length===1&&ae(o.children[0]);let s="";for(let m=0;i>m;m++)u?s+=" ":s+=" ";return`${s}${u?"1.":"-"} ${l}${d?`
74
74
  `:""}`},XE0=(e,l,o,i)=>(i===l.codeBlock||o===l.codeBlock||(e=ce.default(e)),e),JE0=(e,l,o,i,u,d)=>{var m,f;const s=e.nodeTypes;switch(u){case s.heading[1]:return`# ${l}
75
75
  `;case s.heading[2]:return`## ${l}
76
76
  `;case s.heading[3]:return`### ${l}