@contentful/field-editor-rich-text 3.4.17 → 3.4.19
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/CHANGELOG.md +10 -0
- package/dist/field-editor-rich-text.cjs.development.js +2819 -4299
- package/dist/field-editor-rich-text.cjs.development.js.map +1 -1
- package/dist/field-editor-rich-text.cjs.production.min.js +162 -1
- package/dist/field-editor-rich-text.cjs.production.min.js.map +1 -1
- package/dist/field-editor-rich-text.esm.js +2820 -4300
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,2 +1,163 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),n=e(t),r=require("@contentful/field-editor-reference"),i=require("@contentful/field-editor-shared"),o=require("@contentful/rich-text-types"),a=require("@udecode/plate-core"),l=require("emotion"),c=e(require("fast-deep-equal")),s=e(require("lodash/noop")),u=require("slate-react"),d=require("@udecode/plate-serializer-docx"),f=require("@udecode/plate-break"),p=require("@udecode/plate-reset-node"),m=require("react-popper"),E=require("@contentful/f36-components"),y=require("@contentful/f36-utils"),h=e(require("constate")),v=e(require("is-hotkey")),g=require("slate"),S=e(require("lodash/find")),L=e(require("lodash/flow")),b=e(require("lodash/get")),C=e(require("@contentful/f36-tokens")),T=require("@contentful/f36-icons"),k=require("@udecode/plate-list"),I=e(require("lodash/castArray")),A=require("@udecode/plate-basic-marks"),N=e(require("is-plain-obj")),D=require("@udecode/plate-paragraph"),B=require("@udecode/plate-select"),O=require("@udecode/plate-table"),R=require("@contentful/contentful-slatejs-adapter"),x=require("@contentful/rich-text-plain-text-renderer"),w=require("@udecode/plate-trailing-block"),K=e(require("lodash/debounce")),_=e(require("prop-types"));function P(e,t,n,r,i,o,a){try{var l=e[o](a),c=l.value}catch(e){return void n(e)}l.done?t(c):Promise.resolve(c).then(r,i)}function M(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){P(o,r,i,a,l,"next",e)}function l(e){P(o,r,i,a,l,"throw",e)}a(void 0)}))}}function H(){return(H=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function z(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,q(e,t)}function F(e){return(F=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function q(e,t){return(q=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function U(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function G(e,t,n){return(G=U()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&q(i,n.prototype),i}).apply(null,arguments)}function Y(e){var t="function"==typeof Map?new Map:void 0;return(Y=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return G(e,arguments,F(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),q(n,e)})(e)}function j(e,t){return t||(t=e.slice(0)),e.raw=t,e}function W(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function V(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return W(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?W(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var X=u.useReadOnly,Q=a.usePlateEditorRef,$=a.usePlateEditorState;function Z(e){var t=e.field;return"rich-text-editor-"+e.entry.getSys().id+"-"+t.id+"-"+t.locale}var J=t.createContext(""),ee=J.Provider;function te(e){var n=t.useContext(J);if(e)return e;if(!n)throw new Error("could not find editor id. Please ensure the component is wrapped in <ContentfulEditorIdProvider> ");return n}function ne(e){var t=te(e);return $(t)}var re=function(e,t){return a.withoutNormalizing(e,t)},ie=function(e,t){a.focusEditor(e,t)},oe=function(e,t,n){return void 0===n&&(n={exactMatch:!1,suppressThrow:!1}),a.toSlatePoint(e,t,n)};function ae(e){var n=e.sdk;return t.useMemo((function(){return n}),[])}var le=h(ae),ce=le[0],se=le[1],ue=function(e,t){return a.getEditorString(e,t)},de=function(e){return a.isText(e)},fe=function(e,t){return a.getStartPoint(e,t)},pe=function(e,t){return a.isSelectionAtBlockStart(e,t)},me=function(e,t){return a.getBlockAbove(e,t)},Ee=function(e,t,n){return a.getNodeEntry(e,t,n)},ye=function(e,t){return a.getNodeEntries(e,t)},he=function(e,t,n){return a.getParentNode(e,t,n)},ve=function(e,t){return a.someNode(e,t)},ge=function(e){return g.Text.isText(e[0])?[]:a.getChildren(e)},Se=function(e,t){return g.Node.get(e,t)},Le=function(e){return a.isCollapsed(e)},be=function(e,t,n){return a.getRange(e,t,n)},Ce=function(e){return g.Range.edges(e)},Te=function(e){return g.Range.end(e)},ke=function(e,t){return a.getAboveNode(e,t)},Ie=function(e,t,n){return a.getCommonNode(e,t,n)},Ae=function(e,t){return a.findNode(e,t)},Ne=function(e,t){return a.isMarkActive(e,t)},De=function(e){return a.isEditor(e)},Be=function(e){return a.isEditorReadOnly(e)},Oe=function(e){return a.isElement(e)},Re=function(e,t){return a.findNodePath(e,t)},xe=function(e,t){return g.Path.isAncestor(e,t)},we=function(e,t){return a.isAncestorEmpty(e,t)},Ke=function(e){return g.Path.parent(e)},_e=function(e){return g.Path.next(e)},Pe=function(e){return g.Path.previous(e)},Me=function(e){return a.getLastChildPath(e)},He=function(e){return a.isFirstChild(e)},ze=function(e,t){return a.isLastChild(e,t)},Fe=function(e,t,n){return a.match(e,t,n)},qe=function(e,t){return a.someHtmlElement(e,t)},Ue=function(e,t){return a.getPluginType(e,t)},Ge=function(e,t){return a.setSelection(e,t)},Ye=function(e,t){return a.select(e,t)},je=function(e,t){return a.moveSelection(e,t)},We=function(e,t){return a.collapseSelection(e,t)},Ve=function(e,t,n){a.setNodes(e,t,n)},Xe=function(e,t,n){return a.insertNodes(e,t,n)},Qe=function(e,t){return a.splitNodes(e,t)},$e=function(e,t){return a.liftNodes(e,t)},Ze=function(e,t){return a.unwrapNodes(e,t)},Je=function(e,t,n){return a.wrapNodes(e,t,n)},et=function(e,t,n){a.removeMark(e,{key:t,at:n})},tt=function(e,t,n){return a.insertText(e,t,n)},nt=function(e,t){a.deleteText(e,t)},rt=function(e,t){a.removeNodes(e,t)},it=function(e,t){a.moveNodes(e,t)},ot="undefined"!=typeof navigator&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),at=/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9.]+)(:?\s|$)/.test(navigator.userAgent),lt=[o.INLINES.HYPERLINK,o.INLINES.ENTRY_HYPERLINK,o.INLINES.ASSET_HYPERLINK];function ct(e,t){return!!Array.from(ye(e,{match:function(e){return Oe(e)&&e.type===t}}))[0]}function st(e){return 1===e.length}function ut(e,t,n){var r,i;if(!(n=null!=(r=n)?r:null==(i=e.selection)?void 0:i.focus.path))return[];for(var o=Array.isArray(t)?t:[t],a=0;a<n.length;a++){var l=Ee(e,n.slice(0,a+1));if(o.includes(l[0].type))return l}return[]}function dt(e,t){return!!e&&!!ut(e,t)[0]}function ft(e){je(e,{distance:1,unit:"offset"})}function pt(e,t){Xe(e,{type:o.BLOCKS.PARAGRAPH,children:[{text:""}],data:{},isVoid:!1},t)}function mt(e,t){e.selection&&function(e,t){var n=t.text,r=t.url,i=t.target,o=t.type,a=t.path;Et(e)&&!a&&yt(e);var l=e.selection,c=l&&Le(l),s={type:o,data:{},children:c?[{text:n}]:[]};r&&(s.data={uri:r}),i&&(s.data={target:i}),a?(Ve(e,s,{at:a}),tt(e,n,{at:a}),Ye(e,a)):c?Xe(e,s):(Je(e,s,{split:!0}),nt(e),tt(e,n),We(e,{edge:"end"}))}(e,t)}function Et(e){return!!e&&!!Array.from(ye(e,{match:function(e){return!De(e)&&Oe(e)&<.includes(e.type)}}))[0]}function yt(e){Ze(e,{match:function(e){return!De(e)&&Oe(e)&<.includes(e.type)}})}var ht=Object.values(o.INLINES),vt=function(e){return de(e)||Oe(e)&&ht.includes(e.type)},gt=function(e){var t=window.scrollX,n=window.scrollY;ie(e),ot&&setTimeout((function(){window.scrollTo(t,n)}),0)};function St(e,t,n){!function(e,t,n){a.toggleNodeType(e,t,n)}(e,t,n),Ve(e,{data:{}})}var Lt=[o.BLOCKS.DOCUMENT,o.BLOCKS.PARAGRAPH,"text"],bt=function(e,t,n){var r=function(e,t){return L((function(e){return S(e,t)}),(function(e){return b(e,t)}))(e.validations)}(e,t);return void 0===r||Lt.concat(r).includes(n)},Ct=function(e,t){return bt(e,"enabledNodeTypes",t)},Tt=function(e,t){return bt(e,"enabledMarks",t)};function kt(e,t){return e(t={exports:{}},t.exports),t.exports}var It=kt((function(e){var t=function(e){var t=Object.prototype,n=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",o=r.asyncIterator||"@@asyncIterator",a=r.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function c(e,t,n,r){var i=Object.create((t&&t.prototype instanceof d?t:d).prototype),o=new C(r||[]);return i._invoke=function(e,t,n){var r="suspendedStart";return function(i,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw o;return{value:void 0,done:!0}}for(n.method=i,n.arg=o;;){var a=n.delegate;if(a){var l=S(a,n);if(l){if(l===u)continue;return l}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var c=s(e,t,n);if("normal"===c.type){if(r=n.done?"completed":"suspendedYield",c.arg===u)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r="completed",n.method="throw",n.arg=c.arg)}}}(e,n,o),i}function s(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var u={};function d(){}function f(){}function p(){}var m={};l(m,i,(function(){return this}));var E=Object.getPrototypeOf,y=E&&E(E(T([])));y&&y!==t&&n.call(y,i)&&(m=y);var h=p.prototype=d.prototype=Object.create(m);function v(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function g(e,t){var r;this._invoke=function(i,o){function a(){return new t((function(r,a){!function r(i,o,a,l){var c=s(e[i],e,o);if("throw"!==c.type){var u=c.arg,d=u.value;return d&&"object"==typeof d&&n.call(d,"__await")?t.resolve(d.__await).then((function(e){r("next",e,a,l)}),(function(e){r("throw",e,a,l)})):t.resolve(d).then((function(e){u.value=e,a(u)}),(function(e){return r("throw",e,a,l)}))}l(c.arg)}(i,o,r,a)}))}return r=r?r.then(a,a):a()}}function S(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,S(e,t),"throw"===t.method))return u;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return u}var r=s(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,u;var i=r.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,u):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,u)}function L(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function b(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function C(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(L,this),this.reset(!0)}function T(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,o=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:k}}function k(){return{value:void 0,done:!0}}return f.prototype=p,l(h,"constructor",p),l(p,"constructor",f),f.displayName=l(p,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,l(e,a,"GeneratorFunction")),e.prototype=Object.create(h),e},e.awrap=function(e){return{__await:e}},v(g.prototype),l(g.prototype,o,(function(){return this})),e.AsyncIterator=g,e.async=function(t,n,r,i,o){void 0===o&&(o=Promise);var a=new g(c(t,n,r,i),o);return e.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},v(h),l(h,a,"Generator"),l(h,i,(function(){return this})),l(h,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=T,C.prototype={constructor:C,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(b),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return a.type="throw",a.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var l=n.call(o,"catchLoc"),c=n.call(o,"finallyLoc");if(l&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,u):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),u},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),b(n),u}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;b(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:T(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),u}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}));function At(){return(At=M(It.mark((function e(t,n){return It.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.space.getAssets({query:n});case 2:return e.abrupt("return",e.sent.items.map((function(e){return{contentTypeName:"Asset",displayTitle:i.entityHelpers.getAssetTitle({asset:e,localeCode:t.field.locale,defaultLocaleCode:t.locales.default,defaultTitle:"Untitled"}),id:e.sys.id,entity:e,thumbnail:e.fields.file&&e.fields.file[t.field.locale]&&e.fields.file[t.field.locale].url+"?h=30"}})));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Nt(e,t,n){return Dt.apply(this,arguments)}function Dt(){return(Dt=M(It.mark((function e(t,n,r){return It.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.space.getEntries({content_type:n.sys.id,query:r});case 2:return e.abrupt("return",e.sent.items.map((function(e){var r=i.entityHelpers.getEntityDescription({contentType:n,entity:e,localeCode:t.field.locale,defaultLocaleCode:t.locales.default}),o=i.entityHelpers.getEntryTitle({entry:e,contentType:n,localeCode:t.field.locale,defaultLocaleCode:t.locales.default,defaultTitle:"Untitled"});return{contentTypeName:n.name,displayTitle:o,id:e.sys.contentType.sys.id,description:r,entry:e}})));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Bt(e,t,n){if(null!=e&&e.selection){var r=function(e,t){return{type:e,data:{target:{sys:{id:t.sys.id,type:"Link",linkType:t.sys.type}}},children:[{text:""}],isVoid:!0}}(t,n);e.selection&&ue(e,e.selection.focus.path)?Xe(e,r):Ve(e,r),gt(e)}}var Ot=function(e){var t=ke(e),n=be(e,t[1]);Ye(e,n.focus.path),et(e,"command-prompt",n),nt(e)},Rt=function(e){var t=ke(e),n=be(e,t[1]);n.focus.offset-n.anchor.offset>1&&nt(e,{at:n.focus,distance:n.focus.offset-1,reverse:!0})};function xt(e){return{inlineAllowed:Ct(e.field,o.INLINES.EMBEDDED_ENTRY),entriesAllowed:Ct(e.field,o.BLOCKS.EMBEDDED_ENTRY),assetsAllowed:Ct(e.field,o.BLOCKS.EMBEDDED_ASSET)}}var wt={container:l.css({position:"absolute",zIndex:C.zIndexNotification,fontWeight:C.fontWeightNormal,fontStyle:"normal",fontFamily:C.fontStackPrimary,"ul, ol, dl":{listStyle:"none",marginLeft:0}}),menuPoper:l.css({zIndex:C.zIndexModal}),menuContent:l.css({width:"400px",maxHeight:"300px"}),menuList:l.css({overflow:"auto",maxHeight:"200px"}),menuItem:l.css({display:"block",width:"100%",background:"none",border:0,margin:0,outline:"none",fontSize:C.fontSizeM,lineHeight:C.lineHeightM,fontWeight:C.fontWeightNormal,position:"relative",textAlign:"left",padding:C.spacingXs+" "+C.spacingM,wordBreak:"break-word",whiteSpace:"break-spaces",cursor:"pointer",hyphens:"auto",minWidth:"150px",textDecoration:"none",color:C.gray800,"&:hover":{backgroundColor:C.gray100},"&:disabled":{opacity:.5,cursor:"auto"}}),menuItemSelected:l.css({boxShadow:"inset "+C.glowPrimary,borderRadius:C.borderRadiusMedium}),menuDivider:l.css({border:"none",width:"100%",height:"1px",background:C.gray300,margin:C.spacingXs+" 0"}),menuHeader:l.css({zIndex:C.zIndexDefault,top:0,backgroundColor:C.gray100,padding:C.spacingM}),menuFooter:l.css({position:"sticky",bottom:0,backgroundColor:C.gray100,padding:C.spacingM}),footerList:l.css({listStyle:"none",color:C.gray600,fontSize:C.fontSizeM}),thumbnail:l.css({width:"30px",height:"30px",objectFit:"cover"})},Kt=function(e){var n=e.commandGroup,r=e.selectedItem;return t.createElement("section",{key:n.group},t.createElement(E.SectionHeading,{as:"h3",marginBottom:"spacingS",marginTop:"spacingS",marginLeft:"spacingM",marginRight:"spacingM"},n.group),n.commands.map((function(e){var n;return t.createElement("button",{key:e.id,id:e.id,className:l.cx(wt.menuItem,(n={},n[wt.menuItemSelected]=e.id===r,n)),onClick:e.callback},e.label)})),t.createElement("hr",{className:wt.menuDivider,"aria-orientation":"horizontal"}))},_t=function(e){var n,r=e.command;return t.createElement("button",{key:r.id,id:r.id,className:l.cx(wt.menuItem,(n={},n[wt.menuItemSelected]=r.id===e.selectedItem,n)),onClick:r.callback},t.createElement(E.Flex,{alignItems:"center",gap:"spacingS"},r.thumbnail&&t.createElement("img",{width:"30",height:"30",src:r.thumbnail,alt:"",className:wt.thumbnail}),t.createElement("span",null,r.label)))},Pt=function(e){var n=e.command;return t.createElement("button",{key:n.id,id:n.id,className:wt.menuItem},n.label)},Mt=function(e){var n=e.selectedItem;return t.createElement(t.Fragment,null,e.commandItems.map((function(e){return"group"in e?t.createElement(Kt,{commandGroup:e,selectedItem:n}):e.callback?t.createElement(_t,{command:e,selectedItem:n}):t.createElement(Pt,{command:e})})))},Ht=function(e){var n=e.query,r=e.editor,i=e.textContainer,a=se(),l=t.useRef(null),c=m.usePopper(i,null==l?void 0:l.current,{placement:"bottom-start"}),s=function(e,n,r){var i=e.space.getCachedContentTypes(),a=function(e,t){var n=!dt(t,o.BLOCKS.TABLE),r=xt(e);return{inlineAllowed:r.inlineAllowed,entriesAllowed:r.entriesAllowed&&n,assetsAllowed:r.assetsAllowed&&n}}(e,r),l=a.inlineAllowed,c=a.entriesAllowed,s=a.assetsAllowed,u=t.useState((function(){var t=function(t){return{id:t.sys.id,label:"Embed "+t.name,callback:function(){Nt(e,t,n).then((function(e){Rt(r),f(e.length?e.map((function(e){return{id:e.id+"-"+e.displayTitle.replace(/\W+/g,"-").toLowerCase(),label:e.displayTitle,callback:function(){if(Ot(r),r.selection){var t=r.selection;r.insertSoftBreak(),Bt(r,o.BLOCKS.EMBEDDED_ENTRY,e.entry),Ye(r,t),r.tracking.onCommandPaletteAction("insert",{nodeType:o.BLOCKS.EMBEDDED_ENTRY})}}}})):[{id:"no-results",label:"No results"}])}))}}},a=function(t){return{id:t.sys.id+"-inline",label:"Embed "+t.name+" - Inline",callback:function(){Nt(e,t,n).then((function(e){Rt(r),f(e.length?e.map((function(e){return{id:e.id+"-"+e.displayTitle.replace(/\W+/g,"-").toLowerCase(),label:e.displayTitle,callback:function(){var t={type:o.INLINES.EMBEDDED_ENTRY,children:[{text:""}],data:{target:{sys:{id:e.id,type:"Link",linkType:"Entry"}}}};Ot(r),Xe(r,t),r.insertText(""),r.tracking.onCommandPaletteAction("insert",{nodeType:o.INLINES.EMBEDDED_ENTRY})}}})):[{id:"no-results",label:"No results"}])}))}}},u=c||l?i.map((function(e){return{group:e.name,commands:c&&l?[t(e),a(e)]:c?[t(e)]:[a(e)]}})):[];return s?[].concat(u,[{group:"Assets",commands:[{id:"embed-asset",label:"Embed Asset",callback:function(){(function(e,t){return At.apply(this,arguments)})(e,n).then((function(e){Rt(r),f(e.length?e.map((function(e){return{id:e.id+"-"+e.displayTitle.replace(/\W+/g,"-").toLowerCase(),label:e.displayTitle,thumbnail:e.thumbnail,callback:function(){if(Ot(r),r.selection){var t=r.selection;r.insertSoftBreak(),Bt(r,o.BLOCKS.EMBEDDED_ASSET,e.entity),Ye(r,t),r.tracking.onCommandPaletteAction("insert",{nodeType:o.BLOCKS.EMBEDDED_ASSET})}}}})):[{id:"no-results",label:"No results"}])}))}}]}]):u})),d=u[0],f=u[1];return n?d.reduce((function(e,t){return"group"in t?t.commands.filter((function(e){return e.label.toLowerCase().includes(n.toLowerCase())})).length>0&&e.push(t):t.label.toLowerCase().includes(n.toLowerCase())&&e.push(t),e}),[]):d}(a,n,r),u=function(e,n){var r=t.useState((function(){return e.length?"group"in e[0]?e[0].commands[0].id:e[0].id:""})),i=r[0],o=r[1],a=t.useState(e.length>0),l=a[0],c=a[1];return t.useEffect((function(){if(n.current){var t=Array.from(n.current.querySelectorAll("button")),r=t.find((function(e){return e.id===i})),a=r?t.indexOf(r):0;return!r&&t.length&&(o(t[0].id),t[0].scrollIntoView({block:"nearest",inline:"start"})),e.length&&window.addEventListener("keydown",l),function(){return window.removeEventListener("keydown",l)}}function l(e){if(v("up",e)){if(e.preventDefault(),0===a)return;o(t[a-1].id),t[a-1].scrollIntoView({block:"nearest",inline:"start"})}else if(v("down",e)){if(e.preventDefault(),a===t.length-1)return;o(t[a+1].id),t[a+1].scrollIntoView({block:"nearest",inline:"start"})}else v("enter",e)&&(e.preventDefault(),r&&(o(""),r.click()))}}),[e,n,i]),t.useEffect((function(){var e=function(e){n.current&&!n.current.contains(e.target)&&c(!1)};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}}),[n]),{selectedItem:i,isOpen:l}}(s,l),d=u.selectedItem,f=u.isOpen;return s.length?t.createElement("div",{className:wt.container,tabIndex:-1,contentEditable:!1},t.createElement("div",{role:"alert"},t.createElement(E.ScreenReaderOnly,null,"Richtext commands. Currently focused item: ",d,". Press ",t.createElement("kbd",null,"enter")," to select, ",t.createElement("kbd",null,"arrows")," to navigate, ",t.createElement("kbd",null,"escape")," to close.")),t.createElement(y.Portal,null,t.createElement("div",H({"aria-hidden":!0,ref:l,className:wt.menuPoper,style:c.styles.popper},c.attributes.popper),t.createElement(E.Popover,{isOpen:f,usePortal:!1,autoFocus:!1},t.createElement(E.Popover.Trigger,null,t.createElement("span",null)),t.createElement(E.Popover.Content,{className:wt.menuContent,testId:"rich-text-commands"},t.createElement("header",{className:wt.menuHeader},t.createElement(E.SectionHeading,{marginBottom:"none"},"Richtext commands")),t.createElement("div",{className:wt.menuList,"data-test-id":"rich-text-commands-list"},t.createElement(Mt,{commandItems:s,selectedItem:d})),t.createElement("footer",{className:wt.menuFooter},t.createElement(E.Stack,{as:"ul",margin:"none",padding:"none",spacing:"spacingS",className:wt.footerList},t.createElement("li",null,t.createElement("kbd",null,"↑"),t.createElement("kbd",null,"↓")," to navigate"),t.createElement("li",null,t.createElement("kbd",null,"↵")," to confirm"),t.createElement("li",null,t.createElement("kbd",null,"esc")," to close")))))))):null},zt=function(e){var n=t.useMemo((function(){return(t=e.text.text).startsWith("/")?t.slice(1):t;var t}),[e.text.text]),r=e.editor,i=t.useState(),o=i[0],a=i[1];return t.createElement("span",H({ref:function(e){a(e)}},e.attributes),e.children,t.createElement(Ht,{query:n,editor:r,textContainer:o}))};function Ft(e){return function(t){var r,i=(r=te(void 0),Q(r)),o=n.useCallback((function(){return null==i?void 0:i.tracking.onViewportAction("linkRendered")}),[i]);return n.createElement(e,H({},t,{onEntityFetchComplete:o}))}}var qt=t.memo((function(e){return void 0===e.asset?t.createElement(E.AssetCard,{size:"default",isLoading:!0}):"failed"===e.asset?t.createElement(r.MissingEntityCard,{entityType:"Asset",isDisabled:e.isDisabled,onRemove:e.onRemove}):t.createElement(r.WrappedAssetCard,{getEntityScheduledActions:e.loadEntityScheduledActions,size:"small",isSelected:e.isSelected,isDisabled:e.isDisabled,localeCode:e.locale,defaultLocaleCode:e.sdk.locales.default,asset:e.asset,onEdit:e.onEdit,onRemove:e.isDisabled?void 0:e.onRemove,isClickable:!1})}),c);function Ut(e){var n=e.onEntityFetchComplete,i=r.useEntity("Asset",e.assetId),o=i.data,a=i.status,l=r.useEntityLoader().getEntityScheduledActions,c=t.useCallback((function(){return l("Asset",e.assetId)}),[l,e.assetId]);return t.useEffect((function(){"success"===a&&(null==n||n())}),[n,a]),t.createElement(qt,{asset:o,sdk:e.sdk,isDisabled:e.isDisabled,isSelected:e.isSelected,loadEntityScheduledActions:c,locale:e.locale,onEdit:e.onEdit,onRemove:e.onRemove})}qt.displayName="InternalAssetCard";var Gt=t.memo((function(e){var n=e.entry,i=e.sdk,o=e.loadEntityScheduledActions;if(void 0===n)return t.createElement(E.EntryCard,{isLoading:!0});if("failed"===n)return t.createElement(r.MissingEntityCard,{entityType:"Entry",isDisabled:e.isDisabled,onRemove:e.onRemove});var a=i.space.getCachedContentTypes().find((function(e){return e.sys.id===n.sys.contentType.sys.id}));return t.createElement(r.WrappedEntryCard,{size:"default",getAsset:e.sdk.space.getAsset,getEntityScheduledActions:o,isSelected:e.isSelected,isDisabled:e.isDisabled,localeCode:e.locale,defaultLocaleCode:e.sdk.locales.default,contentType:a,entry:n,onEdit:e.onEdit,onRemove:e.isDisabled?void 0:e.onRemove,isClickable:!1})}),c);Gt.displayName="ReferenceCard";var Yt=function(e){var n=e.entryId,i=e.onEntityFetchComplete,o=r.useEntity("Entry",n),a=o.data,l=o.status,c=r.useEntityLoader().getEntityScheduledActions,s=t.useCallback((function(){return c("Entry",n)}),[c,n]);return t.useEffect((function(){"success"===l&&(null==i||i())}),[i,l]),t.createElement(Gt,{entry:a,sdk:e.sdk,locale:e.locale,isDisabled:e.isDisabled,isSelected:e.isSelected,onEdit:e.onEdit,onRemove:e.onRemove,loadEntityScheduledActions:s})},jt={root:l.css({marginBottom:"1.25rem !important",display:"block"}),container:l.css({display:"inline-block",verticalAlign:"text-top",width:"100%"})};function Wt(e){var t=e.attributes,r=e.children,i=e.element,o=e.onEntityFetchComplete,a=u.useSelected(),l=ne(),c=se(),s=u.useReadOnly(),d=i.data.target.sys,f=d.id,p=d.linkType,m=n.useCallback((function(){return("Asset"===p?c.navigator.openAsset:c.navigator.openEntry)(f,{slideIn:!0})}),[c,f,p]),E=n.useCallback((function(){if(l){var e=Re(l,i);rt(l,{at:e})}}),[l,i]);return n.createElement("div",H({},t,{className:jt.root,"data-entity-type":p,"data-entity-id":f,contentEditable:!!at&&void 0,draggable:!!at||void 0}),n.createElement("div",{contentEditable:!at&&void 0,draggable:!!at||void 0,className:jt.container},"Entry"===p&&n.createElement(Yt,{sdk:c,entryId:f,locale:c.field.locale,isDisabled:s,isSelected:a,onRemove:E,onEdit:m,onEntityFetchComplete:o}),"Asset"===p&&n.createElement(Ut,{sdk:c,assetId:f,locale:c.field.locale,isDisabled:s,isSelected:a,onRemove:E,onEdit:m,onEntityFetchComplete:o})),r)}function Vt(e,t){return L((function(e){return S(e,"nodes")}),(function(e){return b(e,["nodes",t])}),(function(e){return S(e,"linkContentType")}),(function(e){return b(e,"linkContentType",[])}))(e.validations)}function Xt(e,t){return{entityType:Qt(t),locale:e.locale||null,contentTypes:Vt(e,t)}}function Qt(e){var t=e.split("-");if(-1!==t.indexOf("entry"))return"Entry";if(-1!==t.indexOf("asset"))return"Asset";throw new Error("RichText node type `"+e+"` has no associated `entityType`")}function $t(e){var t,n,r=new Set,i=!1,o=function(){return{wasClosed:i,isActive:!i&&n===t}},a=e.onSlideInNavigation((function(e){var l=e.oldSlideLevel,c=e.newSlideLevel;void 0===t&&(t=l),n=c,c<t&&(i=!0,a(),r.clear()),o().isActive&&c!==l&&r.forEach((function(e){return e()}))}));return{status:o,onActive:function(e){return i?s:(o().isActive&&e(),r.add(e),function(){return r.delete(e)})},unwatch:function(){a(),r.clear()}}}function Zt(e,t,n,r){return Jt.apply(this,arguments)}function Jt(){return(Jt=M(It.mark((function e(t,n,r,i){var o,a,l,c,s,u;return It.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i("openCreateEmbedDialog",{nodeType:t}),o=n.dialogs,a=Xt(n.field,t),l="Asset"===a.entityType?o.selectSingleAsset:o.selectSingleEntry,c=H({},a,{withCreate:!0}),s=$t(n.navigator),e.next=8,l(c);case 8:(u=e.sent)?(tn(r,t,u),en(r),i("insert",{nodeType:t})):i("cancelCreateEmbedDialog",{nodeType:t}),s.onActive((function(){s.unwatch(),gt(r)}));case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function en(e){var t,n=ke(e,{match:{type:[o.BLOCKS.EMBEDDED_ASSET,o.BLOCKS.EMBEDDED_ENTRY]}});if(n){var r=n[1].length-1,i=function(e,t){return a.getLastNodeByLevel(e,t)}(e,r),l=o.TEXT_CONTAINERS.includes(null!=(t=null==i?void 0:i[0].type)?t:"");0===r||l||pt(e),ft(e)}}function tn(e,t,n){if(null!=e&&e.selection){var r=function(e,t){return{type:e,data:{target:{sys:{id:t.sys.id,type:"Link",linkType:t.sys.type}}},children:[{text:""}],isVoid:!0}}(t,n);e.selection&&ue(e,e.selection.focus.path)?Xe(e,r):Ve(e,r)}}var nn,rn=l.css({marginRight:"10px"});function on(e){var t=e.isDisabled,r=e.nodeType,i=e.onClose,o=ne(),a=se(),l=function(){var e=M(It.mark((function e(t){return It.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.preventDefault(),o){e.next=3;break}return e.abrupt("return");case 3:return i(),e.next=6,Zt(r,a,o,o.tracking.onToolbarAction);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),c=function(e){var t=e.toLowerCase().split("-");if(t.includes("entry"))return"Entry";if(t.includes("asset"))return"Asset";throw new Error("Node type `"+e+"` has no associated `entityType`")}(r);return n.createElement(E.Menu.Item,{disabled:t,className:"rich-text__"+r+"-list-item",onClick:l,testId:"toolbar-toggle-"+r},n.createElement(E.Flex,{alignItems:"center",flexDirection:"row"},n.createElement(E.Icon,{as:"Asset"===c?T.AssetIcon:T.EmbeddedEntryBlockIcon,className:"rich-text__embedded-entry-list-icon "+rn,variant:"secondary"}),n.createElement("span",null,c)))}var an=((nn={})[o.BLOCKS.EMBEDDED_ENTRY]="Entry",nn[o.BLOCKS.EMBEDDED_ASSET]="Asset",nn);function ln(e,t){return function(n,r){var i=r.options.hotkey;return function(r){var o=ut(n,e)[1];o?("Delete"===r.key||"Backspace"===r.key)&&(r.preventDefault(),rt(n,{at:o})):i&&v(i,r)&&Zt(e,t,n,n.tracking.onShortcutAction)}}}var cn=function(e,t){return function(n){return{key:e,type:e,isElement:!0,isVoid:!0,component:Ft(Wt),options:{hotkey:t},handlers:{onKeyDown:ln(e,n)},deserializeHtml:{rules:[{validAttribute:{"data-entity-type":an[e]}}],withoutChildren:!0,getNode:function(t){return{type:e,children:[{text:""}],isVoid:!0,data:{target:{sys:{id:t.getAttribute("data-entity-id"),linkType:t.getAttribute("data-entity-type"),type:"Link"}}}}}}}}},sn=cn(o.BLOCKS.EMBEDDED_ENTRY,"mod+shift+e"),un=cn(o.BLOCKS.EMBEDDED_ASSET,"mod+shift+a"),dn=i.entityHelpers.getEntryTitle,fn=i.entityHelpers.getEntryStatus,pn={scheduledIcon:l.css({verticalAlign:"text-bottom",marginRight:C.spacing2Xs})};function mn(e){var t=r.useEntity("Entry",e.entryId),i=t.data,a=t.status,l=r.useEntityLoader().getEntityScheduledActions,c=e.sdk.space.getCachedContentTypes(),s=e.onEntityFetchComplete,u=n.useMemo((function(){if(i&&c)return c.find((function(e){return e.sys.id===i.sys.contentType.sys.id}))}),[c,i]);n.useEffect((function(){"success"===a&&(null==s||s())}),[a,s]);var d=u?u.name:"",f=n.useMemo((function(){return dn({entry:i,contentType:u,localeCode:e.sdk.field.locale,defaultLocaleCode:e.sdk.locales.default,defaultTitle:"Untitled"})}),[i,u,e.sdk.field.locale,e.sdk.locales.default]);if("error"===a)return n.createElement(E.InlineEntryCard,{title:"Entry missing or inaccessible",testId:o.INLINES.EMBEDDED_ENTRY,isSelected:e.isSelected});if("loading"===a)return n.createElement(E.InlineEntryCard,{isLoading:!0});var p=fn(i.sys);return"deleted"===p?n.createElement(E.InlineEntryCard,{title:"Entry missing or inaccessible",testId:o.INLINES.EMBEDDED_ENTRY,isSelected:e.isSelected,actions:[n.createElement(E.MenuItem,{key:"remove",onClick:e.onRemove,testId:"delete"},"Remove")]}):n.createElement(E.InlineEntryCard,{testId:o.INLINES.EMBEDDED_ENTRY,isSelected:e.isSelected,title:d+": "+f,status:p,actions:[n.createElement(E.MenuItem,{key:"edit",onClick:e.onEdit},"Edit"),n.createElement(E.MenuItem,{key:"remove",onClick:e.onRemove,disabled:e.isDisabled,testId:"delete"},"Remove")]},n.createElement(r.ScheduledIconWithTooltip,{getEntityScheduledActions:function(){return l("Entry",e.entryId)},entityType:"Entry",entityId:i.sys.id},n.createElement(T.ClockIcon,{className:pn.scheduledIcon,variant:"muted",testId:"scheduled-icon"})),n.createElement(E.Text,null,f))}function En(e){return{type:o.INLINES.EMBEDDED_ENTRY,children:[{text:""}],data:{target:{sys:{id:e,type:"Link",linkType:"Entry"}}}}}var yn,hn,vn,gn,Sn,Ln,bn,Cn,Tn,kn,In={icon:l.css({marginRight:"10px"}),root:l.css({display:"inline-block",margin:"0 "+C.spacing2Xs,fontSize:"inherit",span:{userSelect:"none"}})};function An(e){var n=ne(),r=se(),i=u.useSelected(),o=e.element.data.target.sys.id,a=u.useReadOnly();return t.createElement("span",H({},e.attributes,{className:In.root,"data-embedded-entity-inline-id":o,contentEditable:!!at&&void 0,draggable:!!at||void 0}),t.createElement("span",{contentEditable:!at&&void 0,draggable:!!at||void 0},t.createElement(mn,{sdk:r,entryId:o,isSelected:i,isDisabled:a,onRemove:function(){if(n){var t=Re(n,e.element);rt(n,{at:t})}},onEdit:function(){return r.navigator.openEntry(o,{slideIn:{waitForClose:!0}}).then((function(){n&>(n)}))},onEntityFetchComplete:e.onEntityFetchComplete})),e.children)}function Nn(e,t,n){return Dn.apply(this,arguments)}function Dn(){return(Dn=M(It.mark((function e(t,n,r){var i,a,l;return It.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r("openCreateEmbedDialog",{nodeType:o.INLINES.EMBEDDED_ENTRY}),i=H({},Xt(n.field,o.INLINES.EMBEDDED_ENTRY),{withCreate:!0}),a=$t(n.navigator),e.next=5,n.dialogs.selectSingleEntry(i);case 5:(l=e.sent)?(Xe(t,En(l.sys.id)),r("insert",{nodeType:o.INLINES.EMBEDDED_ENTRY})):r("cancelCreateEmbedDialog",{nodeType:o.INLINES.EMBEDDED_ENTRY}),a.onActive((function(){a.unwatch(),gt(t)}));case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Bn(e){var n=ne(),r=se();function i(){return(i=M(It.mark((function t(i){return It.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i.preventDefault(),n){t.next=3;break}return t.abrupt("return");case 3:return e.onClose(),t.next=6,Nn(n,r,n.tracking.onToolbarAction);case 6:ft(n);case 7:case"end":return t.stop()}}),t)})))).apply(this,arguments)}return t.createElement(E.Menu.Item,{disabled:e.isDisabled,className:"rich-text__entry-link-block-button",testId:"toolbar-toggle-"+o.INLINES.EMBEDDED_ENTRY,onClick:function(e){return i.apply(this,arguments)}},t.createElement(E.Flex,{alignItems:"center",flexDirection:"row"},t.createElement(T.EmbeddedEntryInlineIcon,{variant:"secondary",className:"rich-text__embedded-entry-list-icon "+In.icon}),t.createElement("span",null,"Inline entry")))}function On(e){return{key:o.INLINES.EMBEDDED_ENTRY,type:o.INLINES.EMBEDDED_ENTRY,isElement:!0,isInline:!0,isVoid:!0,component:Ft(An),options:{hotkey:"mod+shift+2"},handlers:{onKeyDown:Rn(e)},deserializeHtml:{rules:[{validAttribute:"data-embedded-entity-inline-id"}],withoutChildren:!0,getNode:function(e){return En(e.getAttribute("data-embedded-entity-inline-id"))}}}}function Rn(e){return function(t,n){var r=n.options.hotkey;return function(n){t&&r&&v(r,n)&&Nn(t,e,t.tracking.onShortcutAction)}}}var xn={dropdown:(Tn={root:l.css(yn||(yn=j(["\n font-weight: ",";\n "])),C.fontWeightDemiBold)},Tn[o.BLOCKS.PARAGRAPH]=l.css(hn||(hn=j(["\n font-size: ",";\n "])),C.fontSizeL),Tn[o.BLOCKS.HEADING_1]=l.css(vn||(vn=j(["\n font-size: 1.625rem;\n "]))),Tn[o.BLOCKS.HEADING_2]=l.css(gn||(gn=j(["\n font-size: 1.4375rem;\n "]))),Tn[o.BLOCKS.HEADING_3]=l.css(Sn||(Sn=j(["\n font-size: 1.25rem;\n "]))),Tn[o.BLOCKS.HEADING_4]=l.css(Ln||(Ln=j(["\n font-size: 1.125rem;\n "]))),Tn[o.BLOCKS.HEADING_5]=l.css(bn||(bn=j(["\n font-size: 1rem;\n "]))),Tn[o.BLOCKS.HEADING_6]=l.css(Cn||(Cn=j(["\n font-size: 0.875rem;\n "]))),Tn)},wn=((kn={})[o.BLOCKS.PARAGRAPH]="Normal text",kn[o.BLOCKS.HEADING_1]="Heading 1",kn[o.BLOCKS.HEADING_2]="Heading 2",kn[o.BLOCKS.HEADING_3]="Heading 3",kn[o.BLOCKS.HEADING_4]="Heading 4",kn[o.BLOCKS.HEADING_5]="Heading 5",kn[o.BLOCKS.HEADING_6]="Heading 6",kn);function Kn(e){var n=se(),r=ne(),i=t.useState(!1),a=i[0],c=i[1],s=t.useState(o.BLOCKS.PARAGRAPH),u=s[0],d=s[1];t.useEffect((function(){if(null!=r&&r.selection){var e=function(e){return e.selection?Array.from(ye(e,{at:e.selection,match:function(e){return Oe(e)}})).flat():[]}(r)[0].type;d(wn[e]?e:o.BLOCKS.PARAGRAPH)}}),[null==r?void 0:r.operations,null==r?void 0:r.selection]);var f=t.useMemo((function(){var e=Object.fromEntries(Object.keys(wn).map((function(e){return[e,Ct(n.field,e)]})));return[e,Object.values(e).filter(Boolean).length>0]}),[n.field]),p=f[0],m=f[1];return r?t.createElement(E.Menu,{isOpen:a,onClose:function(){return c(!1)}},t.createElement(E.Menu.Trigger,null,t.createElement(E.Button,{size:"small",testId:"toolbar-heading-toggle",variant:"transparent",endIcon:t.createElement(T.ChevronDownIcon,null),isDisabled:e.isDisabled,onClick:function(){return m&&c(!a)}},wn[u])),t.createElement(E.Menu.List,{testId:"dropdown-heading-list"}," ",Object.keys(wn).map((function(n){return p[n]&&t.createElement(E.Menu.Item,{key:n,isInitiallyFocused:u===n,onClick:(i=n,function(e){if(e.preventDefault(),null!=r&&r.selection){d(i),c(!1);var t=r.onChange;r.onChange=function(){gt(r),r.onChange=t,t.apply(void 0,arguments)};var n=ct(r,i);r.tracking.onToolbarAction(n?"remove":"insert",{nodeType:i}),St(r,{activeType:i,inactiveType:i})}}),testId:"dropdown-option-"+n,disabled:e.isDisabled},t.createElement("span",{className:l.cx(xn.dropdown.root,xn.dropdown[n])},wn[n]));var i})).filter(Boolean))):null}var _n,Pn,Mn,Hn,zn,Fn,qn,Un,Gn,Yn,jn,Wn,Vn,Xn,Qn,$n,Zn,Jn,er=function(e,t){rt(e,{at:t[1]})},tr=function(e,t){var n=t[1],r=function(e,t){return function(e,t,n){return Array.from(ye(e,{match:{type:o.TEXT_CONTAINERS},at:t,mode:"lowest"})).map((function(e){return e[0]}))}(e,t).map((function(e){return H({},e,{type:o.BLOCKS.PARAGRAPH})}))}(e,n);er(e,t),Xe(e,r,{at:n})},nr=function(e,t){Ze(e,{at:t[1]})},rr=function(e){return function(t,n){Je(t,{type:e,data:{},children:[]},{at:n[1]})}},ir=function(e,t){$e(e,{at:t[1]})},or={dropdown:(Gn={root:l.css(_n||(_n=j(["\n font-weight: ",";\n "])),C.fontWeightDemiBold)},Gn[o.BLOCKS.PARAGRAPH]=l.css(Pn||(Pn=j(["\n font-size: ",";\n "])),C.fontSizeL),Gn[o.BLOCKS.HEADING_1]=l.css(Mn||(Mn=j(["\n font-size: 1.625rem;\n "]))),Gn[o.BLOCKS.HEADING_2]=l.css(Hn||(Hn=j(["\n font-size: 1.4375rem;\n "]))),Gn[o.BLOCKS.HEADING_3]=l.css(zn||(zn=j(["\n font-size: 1.25rem;\n "]))),Gn[o.BLOCKS.HEADING_4]=l.css(Fn||(Fn=j(["\n font-size: 1.125rem;\n "]))),Gn[o.BLOCKS.HEADING_5]=l.css(qn||(qn=j(["\n font-size: 1rem;\n "]))),Gn[o.BLOCKS.HEADING_6]=l.css(Un||(Un=j(["\n font-size: 0.875rem;\n "]))),Gn),headings:(Zn={root:l.css(Yn||(Yn=j(["\n font-weight: ",";\n line-height: 1.3;\n margin: 0 0 ",";\n "])),C.fontWeightMedium,C.spacingS)},Zn[o.BLOCKS.HEADING_1]=l.css(jn||(jn=j(["\n font-size: 1.875rem;\n "]))),Zn[o.BLOCKS.HEADING_2]=l.css(Wn||(Wn=j(["\n font-size: 1.5625rem;\n "]))),Zn[o.BLOCKS.HEADING_3]=l.css(Vn||(Vn=j(["\n font-size: 1.375rem;\n "]))),Zn[o.BLOCKS.HEADING_4]=l.css(Xn||(Xn=j(["\n font-size: 1.25rem;\n "]))),Zn[o.BLOCKS.HEADING_5]=l.css(Qn||(Qn=j(["\n font-size: 1.125rem;\n "]))),Zn[o.BLOCKS.HEADING_6]=l.css($n||($n=j(["\n font-size: 1rem;\n "]))),Zn)};function ar(e,n){return function(r){return t.createElement(e,H({},r.attributes,{className:l.cx(or.headings.root,or.headings[n])}),r.children)}}var lr,cr,sr,ur=((Jn={})[o.BLOCKS.HEADING_1]=t.memo(ar("h1",o.BLOCKS.HEADING_1)),Jn[o.BLOCKS.HEADING_2]=t.memo(ar("h2",o.BLOCKS.HEADING_2)),Jn[o.BLOCKS.HEADING_3]=t.memo(ar("h3",o.BLOCKS.HEADING_3)),Jn[o.BLOCKS.HEADING_4]=t.memo(ar("h4",o.BLOCKS.HEADING_4)),Jn[o.BLOCKS.HEADING_5]=t.memo(ar("h5",o.BLOCKS.HEADING_5)),Jn[o.BLOCKS.HEADING_6]=t.memo(ar("h6",o.BLOCKS.HEADING_6)),Jn),dr=function(){var e;return{key:"HeadingPlugin",softBreak:[{hotkey:"shift+enter",query:{allow:o.HEADINGS}}],normalizer:[{match:{type:o.HEADINGS},validChildren:function(e,t){return vt(t[0])},transform:(e={},e[o.BLOCKS.PARAGRAPH]=nr,e.default=ir,e)}],then:function(e){return{exitBreak:[{hotkey:"enter",query:{allow:o.HEADINGS,end:!0,start:!0,filter:function(t){return!ke(e,{at:t[1],match:{type:o.BLOCKS.LIST_ITEM}})&&!Ne(e,"command-prompt")}}}]}},plugins:o.HEADINGS.map((function(e,t){var n,r=t+1;return{key:e,type:e,isElement:!0,component:ur[e],options:{hotkey:["mod+alt+"+r]},handlers:{onKeyDown:(n=e,function(e,t){var r=t.options.hotkey;return function(t){if(e.selection&&r&&v(r,t)){var i=ct(e,n);e.tracking.onShortcutAction(i?"remove":"insert",{nodeType:n}),St(e,{activeType:n,inactiveType:o.BLOCKS.PARAGRAPH})}}})},deserializeHtml:{rules:[{validNodeName:("h"+r).toUpperCase()}]}}}))}},fr={button:l.css({height:"30px",width:"30px",marginLeft:C.spacing2Xs,marginRight:C.spacing2Xs}),tooltip:l.css({zIndex:Number(C.zIndexTooltip)})};function pr(e){var t=e.title,r=e.testId,i=e.isActive,o=e.children,a=e.isDisabled,c=void 0!==a&&a,s=n.createElement(E.Button,{className:l.cx(fr.button,e.className),isDisabled:c,startIcon:o,onClick:function(t){t.preventDefault(),e.onClick()},testId:r,variant:i?"secondary":"transparent",size:"small"});return t?n.createElement(E.Tooltip,{className:fr.tooltip,placement:"bottom",content:t},s):s}var mr={container:l.css(lr||(lr=j(["\n margin: 0 0 ",";\n "])),C.spacingL),hr:l.css(cr||(cr=j(["\n margin: 0;\n height: ",";\n background: transparent;\n position: relative;\n border: 0;\n user-select: none;\n &:hover {\n cursor: pointer;\n }\n &::after {\n content: '';\n position: absolute;\n width: 100%;\n height: 1px;\n background: ",";\n top: 50%;\n }\n "])),C.spacingM,C.gray300),hrSelected:l.css(sr||(sr=j(["\n &::after {\n background: ",";\n -webkit-box-shadow: 0px 0px 5px ",";\n box-shadow: 0px 0px 5px ",";\n }\n "])),C.colorPrimary,C.colorPrimary,C.colorPrimary)};function Er(e){return function(t){if(e){var n=ut(e,o.BLOCKS.HR)[1];n&&("Backspace"===t.key||"Delete"===t.key)&&(t.preventDefault(),rt(e,{at:n}))}}}function yr(e){var n=ne();return n?t.createElement(pr,{title:"HR",isDisabled:e.isDisabled,onClick:function(){if(null!=n&&n.selection){var e={type:o.BLOCKS.HR,data:{},children:[{text:""}],isVoid:!0};ue(n,n.selection.focus.path)?Xe(n,e):Ve(n,e),function(e){je(e,{distance:1,unit:"line"})}(n),gt(n)}},testId:"hr-toolbar-button",isActive:ct(n,o.BLOCKS.HR)},t.createElement(T.HorizontalRuleIcon,null)):null}function hr(e){var n=u.useSelected(),r=u.useFocused();return t.createElement("div",H({},e.attributes,{className:mr.container,"data-void-element":o.BLOCKS.HR}),t.createElement("div",{draggable:!0,contentEditable:!1},t.createElement("hr",{className:l.cx(mr.hr,n&&r?mr.hrSelected:void 0)})),e.children)}var vr,gr,Sr,Lr={removeSelectionLabel:l.css(vr||(vr=j(["\n margin-left: ",";\n "])),C.spacingS)},br=((gr={})[o.INLINES.ENTRY_HYPERLINK]="Entry",gr[o.INLINES.ASSET_HYPERLINK]="Asset",gr),Cr=((Sr={})[o.INLINES.HYPERLINK]="URL",Sr[o.INLINES.ENTRY_HYPERLINK]="Entry",Sr[o.INLINES.ASSET_HYPERLINK]="Asset",Sr);function Tr(e){var n,i,a,l,c=lt.filter((function(t){return Ct(e.sdk.field,t)})),s=c[0],u=t.useState(null!=(n=e.linkText)?n:""),d=u[0],f=u[1],p=t.useState(null!=(i=e.linkType)?i:s),m=p[0],y=p[1],h=t.useState(null!=(a=e.linkTarget)?a:""),v=h[0],g=h[1],S=t.useState(null!=(l=e.linkEntity)?l:null),L=S[0],b=S[1];function C(e){var t=e.sys;return{sys:{id:t.id,type:"Link",linkType:t.type}}}function T(){return(T=M(It.mark((function t(){var n,r;return It.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n={locale:e.sdk.field.locale,contentTypes:Vt(e.sdk.field,o.INLINES.ENTRY_HYPERLINK)},t.next=3,e.sdk.dialogs.selectSingleEntry(n);case 3:r=t.sent,g(""),b(C(r));case 6:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function k(){return(k=M(It.mark((function t(){var n,r;return It.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n={locale:e.sdk.field.locale},t.next=3,e.sdk.dialogs.selectSingleAsset(n);case 3:r=t.sent,g(""),b(C(r));case 6:case"end":return t.stop()}}),t)})))).apply(this,arguments)}return t.createElement(r.EntityProvider,{sdk:e.sdk},t.createElement(t.Fragment,null,t.createElement(E.ModalContent,null,t.createElement(E.Form,null,!e.linkType&&t.createElement(E.FormControl,{id:"link-text",isRequired:!0},t.createElement(E.FormControl.Label,null,"Link text"),t.createElement(E.TextInput,{testId:"link-text-input",name:"link-text",value:d,onChange:function(e){return f(e.target.value)}})),c.length>1&&t.createElement(E.FormControl,{id:"link-type"},t.createElement(E.FormControl.Label,null,"Link type"),t.createElement(E.Select,{value:m,onChange:function(e){return y(e.target.value)},testId:"link-type-input",isDisabled:e.readonly},c.map((function(e){return t.createElement(E.Select.Option,{key:e,value:e},Cr[e])})))),m===o.INLINES.HYPERLINK&&t.createElement(E.FormControl,{id:"linkTarget",isRequired:!0},t.createElement(E.FormControl.Label,null,"Link target"),t.createElement(E.TextInput,{name:"linkTarget",value:v,onChange:function(e){b(null),g(e.target.value)},testId:"link-target-input",isDisabled:e.readonly}),t.createElement(E.FormControl.HelpText,null,"A protocol may be required, e.g. https://")),m!==o.INLINES.HYPERLINK&&t.createElement("div",null,t.createElement(E.FormLabel,{isRequired:!0,htmlFor:""},"Link target"," "),L&&L.sys.linkType===br[m]?t.createElement(t.Fragment,null,!e.readonly&&t.createElement(E.TextLink,{testId:"entity-selection-link",onClick:function(e){e.preventDefault(),b(null)},className:Lr.removeSelectionLabel},"Remove selection"),t.createElement("div",null,m===o.INLINES.ENTRY_HYPERLINK&&t.createElement(Yt,{sdk:e.sdk,locale:e.sdk.field.locale,entryId:L.sys.id,isDisabled:!0,isSelected:!1}),m===o.INLINES.ASSET_HYPERLINK&&t.createElement(Ut,{sdk:e.sdk,locale:e.sdk.field.locale,assetId:L.sys.id,isDisabled:!0,isSelected:!1}))):t.createElement("div",null,m===o.INLINES.ENTRY_HYPERLINK&&t.createElement(E.TextLink,{testId:"entity-selection-link",onClick:function(){return T.apply(this,arguments)}},"Select entry"),m===o.INLINES.ASSET_HYPERLINK&&t.createElement(E.TextLink,{testId:"entity-selection-link",onClick:function(){return k.apply(this,arguments)}},"Select asset"))))),t.createElement(E.ModalControls,null,t.createElement(E.Button,{type:"button",onClick:function(){return e.onClose(null)},variant:"secondary",testId:"cancel-cta",size:"small"},"Cancel"),t.createElement(E.Button,{type:"submit",variant:"positive",size:"small",isDisabled:e.readonly||!(m===o.INLINES.HYPERLINK?d&&v:Object.keys(br).includes(m)&&d&&L),onClick:function(t){t.preventDefault(),e.onClose({linkText:d,linkType:m,linkTarget:v,linkEntity:L})},testId:"confirm-cta"},e.linkType?"Update":"Insert"))))}function kr(e,t,n,r){return Ir.apply(this,arguments)}function Ir(){return(Ir=M(It.mark((function e(n,r,o,a){var l,c,s,u,d,f,p,m,E,y,h,v,g,S,L,b,C,T;return It.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c=Be(n),s=n.selection?H({},n.selection):void 0,a||s){e.next=4;break}return e.abrupt("return");case 4:return m=ut(n,lt,a),y=m[1],(E=m[0])&&y&&(u=E.type,d=ue(n,y),f=E.data.uri||"",p=E.data.target),h=null!=a?a:s,v=d||(n.selection?ue(n,n.selection):""),g=Boolean(E&&y),o(g?"openEditHyperlinkDialog":"openCreateHyperlinkDialog"),e.next=12,i.ModalDialogLauncher.openDialog({title:g?"Edit hyperlink":"Insert hyperlink",width:"large",shouldCloseOnEscapePress:!0,shouldCloseOnOverlayClick:!0,allowHeightOverflow:!0},(function(e){return t.createElement(Tr,{linkTarget:f,linkText:v,linkType:u,linkEntity:p,onClose:e.onClose,sdk:r,readonly:c})}));case 12:if(S=e.sent,Ye(n,h),S){e.next=18;break}return gt(n),o(g?"cancelEditHyperlinkDialog":"cancelCreateHyperlinkDialog"),e.abrupt("return");case 18:L=S.linkText,b=S.linkTarget,C=S.linkType,T=S.linkEntity,re(n,(function(){mt(n,{text:L,url:b,type:C,target:T,path:y})})),o(g?"edit":"insert",{nodeType:C,linkType:null!=(l=null==T?void 0:T.sys.linkType)?l:"uri"}),gt(n);case 22:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ar(e){var n=ne(),r=!(!n||!Et(n)),i=se();function o(){return(o=M(It.mark((function e(){return It.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n){e.next=2;break}return e.abrupt("return");case 2:r?(yt(n),n.tracking.onToolbarAction("unlinkHyperlinks")):kr(n,i,n.tracking.onToolbarAction);case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}return n?t.createElement(pr,{title:"Hyperlink",testId:"hyperlink-toolbar-button",onClick:function(){return o.apply(this,arguments)},isActive:r,isDisabled:e.isDisabled},t.createElement(T.LinkIcon,null)):null}var Nr=function(e,t){var n=t[1];return!a.isAncestorEmpty(e,t[0])&&""!==ue(e,n).trim()};function Dr(){return(Dr=M(It.mark((function e(t){var n,r,o,a,l,c,s,u,d,f,p,m,E;return It.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.sdk,r=t.entityId,a=t.localeCode,l=t.defaultLocaleCode,s="Entry"===(o=t.entityType)?n.space.getEntry:n.space.getAsset,e.next=4,s(r);case 4:return(u=e.sent).sys.contentType&&(d=u.sys.contentType.sys.id,c=n.space.getCachedContentTypes().find((function(e){return e.sys.id===d}))),f="Entry"===o?i.entityHelpers.getEntryTitle({entry:u,contentType:c,localeCode:a,defaultLocaleCode:l,defaultTitle:"Untitled"}):i.entityHelpers.getAssetTitle({asset:u,localeCode:a,defaultLocaleCode:l,defaultTitle:"Untitled"}),p=i.entityHelpers.getEntityDescription({entity:u,contentType:c,localeCode:a,defaultLocaleCode:l}),e.next=10,n.space.getEntityScheduledActions(o,r);case 10:return m=e.sent,E=i.entityHelpers.getEntryStatus(u.sys),e.abrupt("return",{jobs:m,entity:u,entityTitle:f,entityDescription:p,entityStatus:E,contentTypeName:c?c.name:""});case 13:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Br={hyperlinkWrapper:l.css({display:"inline",position:"static",a:{fontSize:"inherit !important"}}),hyperlink:l.css({fontSize:"inherit !important",display:"inline !important","&:hover":{fill:C.gray900},"&:focus":{fill:C.gray900}})};function Or(e){var n=ne(),i=se(),o=e.element.data.target,a=function(e){var n,i,o,a,l,c,s,u=(i=(n=e).sdk,o=n.target,a=n.onEntityFetchComplete,c=(l=t.useState({type:"loading"}))[0],s=l[1],t.useEffect((function(){var e,t;o&&function(e){return Dr.apply(this,arguments)}({sdk:i,entityId:null==o||null==(e=o.sys)?void 0:e.id,entityType:null==o||null==(t=o.sys)?void 0:t.linkType,localeCode:i.field.locale,defaultLocaleCode:i.locales.default}).then((function(e){s({type:"success",data:e})})).catch((function(e){console.log(e),s({type:"error",error:e})})).finally((function(){null==a||a()}))}),[i,o,a]),c),d=e.target.sys.linkType;return"loading"===u.type?"Loading "+d.toLowerCase()+"...":"error"===u.type?d+" missing or inaccessible":function(e){if(!e)return"";var t,n=e.entityStatus,i=e.jobs;return(e.contentTypeName||"Asset")+' "'+(("string"==typeof(t=e.entityTitle)&&t.length>60?t&&t.substr(0,61).replace(/(\s+\S(?=\S)|\s*)\.?.$/,"…"):t)||"Untitled")+'", '+n+" "+(i.length>0?r.getScheduleTooltipContent({job:i[0],jobsCount:i.length}):"")}(u.data)}({target:o,sdk:i,onEntityFetchComplete:e.onEntityFetchComplete});return o?t.createElement(E.Tooltip,{content:a,targetWrapperClassName:Br.hyperlinkWrapper,placement:"bottom",maxWidth:"auto"},t.createElement(E.TextLink,{as:"a",onClick:function(e){if(e.preventDefault(),e.stopPropagation(),n){var t=oe(n,[e.target,0]);t&&kr(n,i,n.tracking.onViewportAction,t.path)}},className:Br.hyperlink,"data-link-type":o.sys.linkType,"data-link-id":o.sys.id},e.children)):null}function Rr(e){var n=ne(),r=se(),i=e.element.data.uri;return t.createElement(E.Tooltip,{content:i,targetWrapperClassName:Br.hyperlinkWrapper,placement:"bottom",maxWidth:"auto"},t.createElement(E.TextLink,{as:"a",href:i,rel:"noopener noreferrer",onClick:function(e){if(e.preventDefault(),e.stopPropagation(),n){var t=oe(n,[e.target,0],{exactMatch:!1,suppressThrow:!1});kr(n,r,n.tracking.onViewportAction,null==t?void 0:t.path)}},className:Br.hyperlink},e.children))}var xr,wr,Kr,_r,Pr=function(e){return"A"===e.nodeName&&"Entry"===e.getAttribute("data-link-type")},Mr=function(e){return"A"===e.nodeName&&"Asset"===e.getAttribute("data-link-type")},Hr=function(e){return function(t,n){var r=n.options.hotkey;return function(n){t.selection&&(r&&!v(r,n)||(Et(t)?(yt(t),t.tracking.onShortcutAction("unlinkHyperlinks")):kr(t,e,t.tracking.onShortcutAction)))}}},zr=function(e){return function(t,n){return{type:e,children:n.children,data:e===o.INLINES.HYPERLINK?{uri:t.getAttribute("href")}:{target:{sys:{id:t.getAttribute("data-link-id"),linkType:t.getAttribute("data-link-type"),type:"Link"}}}}}},Fr=function(e){var t={isElement:!0,isInline:!0};return{key:"HyperlinkPlugin",options:{hotkey:"mod+k"},handlers:{onKeyDown:Hr(e)},plugins:[H({},t,{key:o.INLINES.HYPERLINK,type:o.INLINES.HYPERLINK,component:Rr,deserializeHtml:{rules:[{validNodeName:["A"]}],query:function(e){return!("A"!==(t=e).nodeName||!t.getAttribute("href")||"#"===t.getAttribute("href")||Pr(e)||Mr(e));var t},getNode:zr(o.INLINES.HYPERLINK)}}),H({},t,{key:o.INLINES.ENTRY_HYPERLINK,type:o.INLINES.ENTRY_HYPERLINK,component:Ft(Or),deserializeHtml:{rules:[{validNodeName:["A"]}],query:function(e){return Pr(e)},getNode:zr(o.INLINES.ENTRY_HYPERLINK)}}),H({},t,{key:o.INLINES.ASSET_HYPERLINK,type:o.INLINES.ASSET_HYPERLINK,component:Ft(Or),deserializeHtml:{rules:[{validNodeName:["A"]}],query:function(e){return Mr(e)},getNode:zr(o.INLINES.ASSET_HYPERLINK)}})],normalizer:[{match:{type:[o.INLINES.HYPERLINK,o.INLINES.ASSET_HYPERLINK,o.INLINES.ENTRY_HYPERLINK]},validNode:Nr,transform:er}]}},qr=l.css(xr||(xr=j(["\n padding: 0;\n margin: 0 0 1.25rem 1.25rem;\n\n div:first-child {\n margin: 0;\n line-height: ",";\n }\n"])),C.lineHeightDefault),Ur=((_r={})[o.BLOCKS.UL_LIST]=l.css(wr||(wr=j(["\n list-style-type: disc;\n ul {\n list-style-type: circle;\n ul {\n list-style-type: square;\n }\n }\n "]))),_r[o.BLOCKS.OL_LIST]=l.css(Kr||(Kr=j(["\n list-style-type: decimal;\n ol {\n list-style-type: upper-alpha;\n ol {\n list-style-type: lower-roman;\n ol {\n list-style-type: lower-alpha;\n }\n }\n }\n "]))),_r);function Gr(e,n){return function(r){return t.createElement(e,H({},r.attributes,{className:l.cx(qr,Ur[n])}),r.children)}}var Yr,jr=Gr("ul",o.BLOCKS.UL_LIST),Wr=Gr("ol",o.BLOCKS.OL_LIST),Vr=l.css(Yr||(Yr=j(["\n margin: 0;\n list-style: inherit;\n margin-top: ",";\n\n ol,\n ul {\n margin: 0 0 0 ",";\n }\n"])),C.spacingXs,C.spacingL);function Xr(e){return t.createElement("li",H({},e.attributes,{className:Vr}),e.children)}var Qr=a.ELEMENT_DEFAULT;function $r(e,t){return ye(e,{at:t,match:function(e,t){return Oe(e)&&e.type===o.BLOCKS.LIST_ITEM&&t.length>=2}}).next().done}var Zr=function(e,t){var n=(void 0===t?{}:t).at;re(e,(function(){do{$e(e,{at:n,match:function(e){return Oe(e)&&e.type===o.BLOCKS.LIST_ITEM},mode:"lowest"})}while(!$r(e,n));Ze(e,{at:n,match:{type:o.BLOCKS.LIST_ITEM},split:!1})}))},Jr=[o.BLOCKS.UL_LIST,o.BLOCKS.OL_LIST],ei=function(e,t){var n=t.type;return re(e,(function(){var t;if(e.selection)if(Le(e.selection)||!function(e,t){return a.isRangeAcrossBlocks(e,void 0)}(e)){var r=k.getListItemEntry(e);if(r)r.list[0].type!==n?Ve(e,{type:n},{at:e.selection,match:function(e){return Jr.includes(e.type)},mode:"lowest"}):Zr(e);else{Je(e,{type:n,children:[],data:{}});for(var i,l=[].concat(ye(e,{match:{type:Ue(e,Qr)}})),c={type:o.BLOCKS.LIST_ITEM,children:[],data:{}},s=V(l);!(i=s()).done;)Je(e,c,{at:i.value[1]})}}else{var u=Ce(e.selection),d=Ie(e,u[0].path,u[1].path);if(Jr.includes(d[0].type)||d[0].type===o.BLOCKS.LIST_ITEM){var f,p,m=d[0].type;if(d[0].type===o.BLOCKS.LIST_ITEM&&(m=null==(f=he(e,d[1]))||null==(p=f[0])?void 0:p.type),m!==n){var E=Ae(e,{at:(t=e.selection,g.Range.start(t)),match:{type:Jr},mode:"lowest"}),y=Ae(e,{at:Te(e.selection),match:{type:Jr},mode:"lowest"});if(!E||!y)return;var h=Math.min(E[1].length,y[1].length);Ve(e,{type:n},{at:e.selection,match:function(e,t){return Jr.includes(e.type)&&t.length>=h},mode:"all"})}else Zr(e)}else{var v=d[1].length;Array.from(ye(e,{mode:"all"})).filter((function(e){return e[1].length===v+1})).reverse().forEach((function(t){Jr.includes(t[0].type)?Ve(e,{type:n},{at:t[1]}):(Ve(e,{type:Ue(e,k.ELEMENT_LIC)},{at:t[1]}),Je(e,{type:o.BLOCKS.LIST_ITEM,children:[],data:{}},{at:t[1]}),Je(e,{type:n,children:[],data:{}},{at:t[1]}))}))}}}))},ti=function(e,t){var n=t.type,r=t.options.hotkey;return function(t){if("Tab"===t.key&&e.selection&&ke(e,{at:e.selection,match:{type:n}}))return t.preventDefault(),void function(e,t){var n,r=void 0===t?{}:t,i=r.increase,o=void 0===i||i,l=r.at,c=void 0===l?null!=(n=e.selection)?n:void 0:l,s=ye(e,{at:c,match:{type:Ue(e,k.ELEMENT_LIC)}}),u=Array.from(s);if(u.length){var d=[],f=[];u.forEach((function(t){var n=t[1],r=Ke(n);d.some((function(e){var t=Ke(e);return xe(t,r)}))||(d.push(n),f.push(function(e,t){return a.createPathRef(e,t)}(e,n)))}));var p=o?f:f.reverse();re(e,(function(){p.forEach((function(t){var n=t.unref();if(n){var r=k.getListItemEntry(e,{at:n});r&&(o?function(e,t){var n,r=t.list[0],i=t.listItem[1];try{n=Pe(i)}catch(e){return}var o,l,c=Ee(e,n);if(c){var s=Array.from((o=e,l=c[1],a.getNodeChildren(o,l,void 0))).find((function(t){return function(e,t,n){return a.match(e,t,n)}(t[0],t[1],{type:k.getListTypes(e)})})),u=_e(Me(null!=s?s:c));re(e,(function(){s||Je(e,{type:r.type,children:[],data:{}},{at:i}),it(e,{at:i,to:u})}))}}(e,r):k.isListNested(e,r.list[1])&&k.moveListItemUp(e,r))}}))}))}}(e,{increase:!t.shiftKey});if(r)for(var i,o=V(I(r));!(i=o()).done;)v(i.value)(t)&&ei(e,{type:n})}},ni=function(e){return[o.BLOCKS.OL_LIST,o.BLOCKS.UL_LIST].includes(e.type)},ri=function(e,t){var n=he(e,t[1])||[];return ni(n[0])},ii=function(e,t){var n=t[1],r=function(e,t){return ke(e,{at:t,mode:"lowest",match:ni})||[]}(e,n)[0];Je(e,{type:(null==r?void 0:r.type)||o.BLOCKS.UL_LIST,children:[],data:{}},{at:n})},oi=function(e,t){return 0!==ge(t).length},ai=function(e,t){var n=t[0];if(1===n.children.length){var r=n.children[0];return!de(r)&&!ni(r)}return!0},li=function(e,t){Xe(e,[{type:o.BLOCKS.PARAGRAPH,data:{},children:[{text:""}]}],{at:t[1].concat([0])})},ci=function(e,t){var n=t[0],r=t[1];rt(e,{at:r}),Xe(e,n.children[0].children,{at:r})},si=function(e,t){var n=e.selection;if(!n)return!1;if(a.isExpanded(n)){var r=Ce(n);if(Ie(e,r[0].path,r[1].path)[0].type===t)return!0}var i=me(e,{match:{type:[o.BLOCKS.OL_LIST,o.BLOCKS.UL_LIST]},mode:"lowest"});return(null==i?void 0:i[0].type)===t},ui=function(e){return[o.BLOCKS.UL_LIST,o.BLOCKS.OL_LIST].includes(e.type)},di=o.LIST_ITEM_BLOCKS,fi=function(e){var t=e.deleteBackward,n=e.deleteForward,r=e.deleteFragment;return e.deleteBackward=function(n){(function(e,t){var n=k.getListItemEntry(e,{}),r=!1;if(n){var i=n.list,l=n.listItem;pe(e,{match:function(e){return e.type===o.BLOCKS.LIST_ITEM}})&&re(e,(function(){if(!(r=k.removeFirstListItem(e,{list:i,listItem:l}))&&!(r=k.removeListItem(e,{list:i,listItem:l}))){if(a.isFirstChild(l[1])&&!k.isListNested(e,i[1]))return p.onKeyDownResetNode(e,a.mockPlugin({options:{rules:[{types:[o.BLOCKS.LIST_ITEM],defaultType:o.BLOCKS.PARAGRAPH,hotkey:"backspace",predicate:function(){return pe(e)},onReset:function(e){return Zr(e)}}]}}))(p.SIMULATE_BACKSPACE),void(r=!0);!function(e,t){a.deleteFragment(e,t)}(e,{unit:t,reverse:!0}),r=!0}}))}return r})(e,n)||t(n)},e.deleteForward=function(t){k.deleteForwardList(e)||n(t)},e.deleteFragment=function(){k.deleteFragmentList(e)||r()},e.insertBreak=function(e){var t=e.insertBreak;return function(){(function(e){if(!e.selection)return!1;var t,n=k.getListItemEntry(e,{});if(n){var r=n.list,i=n.listItem,l=i[0].children[0];if(a.isBlockAboveEmpty(e)&&1===i[0].children.length&&o.TEXT_CONTAINERS.includes(l.type)&&(t=k.moveListItemUp(e,{list:r,listItem:i})))return!0}return!!p.onKeyDownResetNode(e,a.mockPlugin({options:{rules:[{types:[a.getPluginType(e,k.ELEMENT_LI)],defaultType:a.getPluginType(e,a.ELEMENT_DEFAULT),predicate:function(){return!t&&a.isBlockAboveEmpty(e)},onReset:function(e){return k.unwrapList(e)}}]}}))(p.SIMULATE_BACKSPACE)||!(t||!function(e){if(!e.selection)return!1;var t=ke(e,{match:{type:o.TEXT_CONTAINERS}});if(!t)return!1;var n=t[1],r=he(e,n);if(!r)return!1;var i=r[1];return r[0].type===o.BLOCKS.LIST_ITEM&&(re(e,(function(){if(e.selection){var t=pe(e),r=function(e,t){return a.isSelectionAtBlockEnd(e,void 0)}(e),l=t&&He(n),c=!t&&!r;c&&Qe(e);var s=l?i:_e(i);Xe(e,function(e,t){void 0===t&&(t=!1);var n=[];if(t){var r=function(e){return a.getMarks(e)}(e)||{};n=[{type:o.BLOCKS.PARAGRAPH,data:{},children:[H({text:""},r)]}]}return{type:o.BLOCKS.LIST_ITEM,data:{},children:n}}(e,!c),{at:s});var u=t?n:_e(n),d=u[u.length-1]||0,f=s.concat([c?0:1]);l||function(e,t){a.moveChildren(e,t)}(e,{at:i,to:f,fromStartIndex:d}),Ye(e,s),We(e,{edge:"start"})}})),!0)}(e))})(e)||t()}}(e),e.insertFragment=function(e){var t=e.insertFragment;return function(n){if(e.selection){if(a.findNode(e,{match:{type:o.BLOCKS.LIST_ITEM},mode:"lowest"})){var r=function(e){var t=e[0];return o.TEXT_CONTAINERS.includes(t.type)?[].concat(t.children,e.slice(1)):e}(function(e){if(1!==e.length)return e;var t=e[0];return t.type!==o.BLOCKS.LIST_ITEM||1!==t.children.length?e:t.children}(n.flatMap((function(e){return function(e){if(!ui(e))return[e];var t=Array.from(a.getNodeTexts(e,void 0)),n=t.reduce((function(t,n){return xe(t[1],n[1])?t:Ie(e,n[1],t[1])}),function(e,t){for(var n=Ke(t[1]);Se(e,n).type!==o.BLOCKS.LIST_ITEM;)n=Ke(n);return[Se(e,n),n]}(e,t[0]));return ui(n[0])?n[0].children:[n[0]]}(e)})))),i=r.findIndex((function(t){return function(e,t){return a.isBlock(e,t)}(e,t)}));i<0&&(i=r.length);var l=r.slice(0,i),c=r.slice(i);return Xe(e,l,{at:e.selection,select:!0}),Xe(e,c,{at:e.selection,select:!0})}var s=ui(n[0])?[{text:""}].concat(n):n;return t(s)}}}(e),e.normalizeNode=k.normalizeList(e,{validLiChildrenTypes:di}),e};function pi(e){var n=se(),r=ne();function i(e){return function(){null!=r&&r.selection&&(ei(r,{type:e}),gt(r))}}return r?t.createElement(t.Fragment,null,Ct(n.field,o.BLOCKS.UL_LIST)&&t.createElement(pr,{title:"UL",testId:"ul-toolbar-button",onClick:i(o.BLOCKS.UL_LIST),isActive:si(r,o.BLOCKS.UL_LIST),isDisabled:e.isDisabled},t.createElement(T.ListBulletedIcon,null)),Ct(n.field,o.BLOCKS.OL_LIST)&&t.createElement(pr,{title:"OL",testId:"ol-toolbar-button",onClick:i(o.BLOCKS.OL_LIST),isActive:si(r,o.BLOCKS.OL_LIST),isDisabled:e.isDisabled},t.createElement(T.ListNumberedIcon,null))):null}var mi=function(e,t){var n=[o.MARKS.SUPERSCRIPT,o.MARKS.SUBSCRIPT];!function(e,t){a.toggleMark(e,t)}(e,{key:t,clear:n.includes(t)?n:[]})},Ei=function(e){return function(t,n){var r=n.options.hotkey;return function(n){if(t.selection&&r&&v(r,n)){n.preventDefault();var i=Ne(t,e);t.tracking.onShortcutAction(i?"unmark":"mark",{markType:e}),mi(t,e)}}}},yi=l.css({backgroundColor:C.blue100,color:C.blue600}),hi=function(e){var n=e.mark,r=e.title,i=e.icon,o=function(e){var o,a=e.isDisabled,c=ne(),s=t.useCallback((function(){if(null!=c&&c.selection){var e=Ne(c,n);c.tracking.onToolbarAction(e?"unmark":"mark",{markType:n}),mi(c,n),gt(c)}}),[c]);return c?i?t.createElement(pr,{title:r,testId:n+"-toolbar-button",onClick:s,isActive:Ne(c,n),isDisabled:a},i):t.createElement(E.Menu.Item,{onClick:s,disabled:a,className:l.cx((o={},o[yi]=Ne(c,n),o)),testId:n+"-toolbar-button"},r):null};return o.displayName=n,o},vi=hi({title:"Bold",mark:o.MARKS.BOLD,icon:t.createElement(T.FormatBoldIcon,null)}),gi={bold:l.css({fontWeight:600})};function Si(e){return t.createElement("strong",H({},e.attributes,{className:gi.bold}),e.children)}var Li=hi({title:"Code",mark:o.MARKS.CODE,icon:t.createElement(T.CodeIcon,null)}),bi=hi({title:"Code",mark:o.MARKS.CODE}),Ci={code:l.css({fontFamily:"monospace",fontSize:".9em"})};function Ti(e){return t.createElement("code",H({},e.attributes,{className:Ci.code}),e.children)}var ki=hi({title:"Italic",mark:o.MARKS.ITALIC,icon:t.createElement(T.FormatItalicIcon,null)}),Ii={italic:l.css({fontStyle:"italic"})};function Ai(e){return t.createElement("em",H({},e.attributes,{className:Ii.italic}),e.children)}var Ni={subscript:l.css({verticalAlign:"sub",fontSize:"smaller"})},Di=hi({title:"Subscript",mark:o.MARKS.SUBSCRIPT,icon:t.createElement(T.SubscriptIcon,{viewBox:"0 0 23 18"})}),Bi=hi({title:"Subscript",mark:o.MARKS.SUBSCRIPT});function Oi(e){return t.createElement("sub",H({},e.attributes,{className:Ni.subscript}),e.children)}var Ri={superscript:l.css({verticalAlign:"super",fontSize:"smaller"})},xi=hi({title:"Superscript",mark:o.MARKS.SUPERSCRIPT,icon:t.createElement(T.SuperscriptIcon,null)}),wi=hi({title:"Superscript",mark:o.MARKS.SUPERSCRIPT});function Ki(e){return t.createElement("sup",H({},e.attributes,{className:Ri.superscript}),e.children)}var _i=hi({title:"Underline",mark:o.MARKS.UNDERLINE,icon:t.createElement(T.FormatUnderlinedIcon,null)});function Pi(e){return t.createElement("u",H({},e.attributes),e.children)}var Mi,Hi,zi=function(e){return o.TEXT_CONTAINERS.includes(e.type)},Fi=[{match:de,validNode:function(e,t){var n,r=null==(n=he(e,t[1]))?void 0:n[0];return!!r&&(zi(r)||ht.includes(r.type)||e.isVoid(r))},transform:function(e,t){return rr(o.BLOCKS.PARAGRAPH)(e,t)}},{match:{type:ht},validNode:function(e,t){var n,r=null==(n=he(e,t[1]))?void 0:n[0];return!!r&&zi(r)},transform:rr(o.BLOCKS.PARAGRAPH)}],qi=function(e){function t(){return e.apply(this,arguments)||this}return z(t,e),t}(Y(Error)),Ui=function(e){return function(t,n){var r=n[0];return Oe(r)&&e.includes(r.type)}},Gi=function(e){var t=e.default;if(!t)throw new qi("A default transformer MUST be provided");return function(n,r){var i=r[0],o=Oe(i)?i.type:"default";return(e[o]||t)(n,r)}},Yi=function(e){for(var t,n=Fi,r=V(e.plugins);!(t=r()).done;){var i=t.value,o=i.normalizer;if(o)for(var a,l=V(o);!(a=l()).done;){var c=H({},a.value);if(!c.match&&!i.isElement)throw new qi("rule.match MUST be defined in a non-element plugin");if(c.match||(c.match={type:Ue(e,i.key)}),N(c.transform)){if("validNode"in c)throw new qi("conditional transformations are not supported in validNode rules");c.transform=Gi(H({default:er},c.transform))}c.transform||(c.transform=er),"validChildren"in c&&Array.isArray(c.validChildren)&&(c.validChildren=Ui(c.validChildren)),n.push(c)}}var s=function(t,n){re(e,(function(){t(e,n)}))},u=e.normalizeNode;return e.normalizeNode=function(t){for(var r,i=t[0],o=t[1],a=ge(t),l=V(n);!(r=l()).done;){var c=r.value;if(Fe(i,o,c.match)){if("validNode"in c&&!c.validNode(e,t))return void s(c.transform,t);if("validChildren"in c){var d=function(){var t=c.validChildren,n=a.find((function(n){return!t(e,n)}));if(n)return s(c.transform,n),{v:void 0}}();if("object"==typeof d)return d.v}}}return u(t)},e},ji=((Hi={})[o.BLOCKS.PARAGRAPH]=l.css(Mi||(Mi=j(["\n line-height: ",";\n margin-bottom: 1.5em;\n "])),C.lineHeightDefault),Hi);function Wi(e){return t.createElement("div",H({},e.attributes,{className:ji[o.BLOCKS.PARAGRAPH]}),e.children)}var Vi=function(e,t){var n=t.options.hotkey;return function(t){e.selection&&n&&v(n,t)&&St(e,{activeType:o.BLOCKS.PARAGRAPH,inactiveType:o.BLOCKS.PARAGRAPH})}},Xi=function(e){!function(e){var t=new Text(" "),n=e.parentNode;n&&(e.previousSibling&&n.insertBefore(t,e),e.nextSibling&&n.insertBefore(t,e.nextSibling))}(e),e.replaceWith.apply(e,Array.from(e.childNodes))},Qi=[function(e){return e.querySelectorAll("style").forEach((function(e){e.remove()})),e},function(e){if(!["google-sheets-html-origin",'meta[content="Excel.Sheet"]','meta[content*="Microsoft Excel"]'].some((function(t){return!!e.querySelector(t)})))return e;for(var t=function(e){var t;return""===(null!=(t=e.textContent)?t:"").trim()},n=Array.from(e.querySelectorAll("table")),r=function(){var e=o[i];e.querySelectorAll("tr").forEach((function(e){t(e)&&e.remove()}));for(var n=Array.from(e.querySelectorAll("tr")),r=1;;){var a=n.map((function(e){return e.querySelector("th:nth-of-type("+r+"), td:nth-of-type("+r+")")})).filter((function(e){return!!e}));if(0===a.length)break;a.every((function(e){return t(e)}))?a.forEach((function(e){return e.remove()})):r+=1}},i=0,o=n;i<o.length;i++)r();return e},function(e){return e.querySelectorAll("meta").forEach((function(e){return e.remove()})),e},function(e){var t="a :not("+["b","strong","code","pre","em","i","sub","sup","u","span"].join(",")+")";return e.querySelectorAll(t).forEach(Xi),e}],$i=function(e){var t,n=Qi.reduce((function(e,t){return t(e)}),(new DOMParser).parseFromString(e,"text/html")),r=[function(e){return e.replace(/<(\/)?(table|thead|tbody|tr|td|th|caption|col|colgroup|ol|ul|li)(.*)>\s+<(\/)?(table|thead|tbody|tr|td|th|caption|col|colgroup|ol|ul|li)/g,"<$1$2$3><$4$5")},function(e){return e.replace(/(?:<[^>^/]*>)\s*(?:<\/[^>]*>)<\/(div|p|table|thead|tbody|tr|td|th|caption|col|colgroup|ol|ul|li)/g,"</$1")},function(e){return e.replace(/\s*<\/(div|p|table|thead|tbody|tr|td|th|caption|col|colgroup|ol|ul|li)/g,"</$1")}];n.querySelector("table")&&r.unshift((function(e){return e.replace(/<div[^>]*>\s*(<table(?:.|\s)*<\/table>)\s*<\/div>/g,"$1")}));do{t=n.body.innerHTML,n.body.innerHTML=r.reduce((function(e,t){return t(e)}),n.body.innerHTML)}while(n.body.innerHTML!==t);return n.body.innerHTML},Zi=/data-slate-fragment="(.+?)"/m,Ji=l.css({margin:"0 0 1.3125rem",borderLeft:"6px solid "+C.gray200,paddingLeft:"0.875rem",fontStyle:"normal"});function eo(e){return t.createElement("blockquote",H({},e.attributes,{className:Ji}),e.children)}var to=function(e){var t=ke(e,{match:{type:o.TEXT_CONTAINERS},mode:"lowest"});if(!t)return!1;if(!we(e,t[0]))return!1;var n=me(e,{match:{type:o.BLOCKS.QUOTE},mode:"lowest"});return!!n&&!(!a.hasSingleChild(n[0])||!a.isLastChild(n,t[1]))};function no(e,t){if(e.selection){var n=ct(e,o.BLOCKS.QUOTE);null==t||t(n?"remove":"insert",{nodeType:o.BLOCKS.QUOTE}),re(e,(function(){e.selection&&(Ze(e,{match:function(e){return Oe(e)&&e.type===o.BLOCKS.QUOTE},split:!0}),n||Je(e,{type:o.BLOCKS.QUOTE,data:{},children:[]}))}))}}var ro=function(e,t){return function(n){var r=t.options.hotkey;r&&v(r,n)&&(n.preventDefault(),no(e,e.tracking.onShortcutAction))}},io=function(e){var t=e.insertFragment;return e.insertFragment=function(n){var r=n.length&&n[0],i=g.Element.isElement(r)&&r.type===o.BLOCKS.QUOTE,a=ke(e,{match:{type:o.TEXT_CONTAINERS}}),l=a&&""!==ue(e,a[1]);if(i&&l){var c=e.selection;(function(e){return!!e&&0!==g.Point.compare(e.anchor,e.focus)})(c)&&nt(e,{at:c});var s=ke(e,{match:{type:o.TEXT_CONTAINERS}});if(s&&""!==ue(e,s[1]))return void Xe(e,n)}t(n)},e};function oo(){var e;return{key:o.BLOCKS.QUOTE,type:o.BLOCKS.QUOTE,isElement:!0,component:eo,options:{hotkey:"mod+shift+1"},handlers:{onKeyDown:ro},deserializeHtml:{rules:[{validNodeName:"BLOCKQUOTE"}]},resetNode:[{hotkey:"backspace",types:[o.BLOCKS.QUOTE],predicate:to,onReset:no}],normalizer:[{validChildren:o.CONTAINERS[o.BLOCKS.QUOTE],transform:(e={},e[o.BLOCKS.QUOTE]=nr,e.default=ir,e)}],withOverrides:io}}function ao(e){var n=ne();return n?t.createElement(pr,{title:"Blockquote",onClick:function(){n&&(no(n,n.tracking.onToolbarAction),gt(n))},testId:"quote-toolbar-button",isDisabled:e.isDisabled,isActive:ct(n,o.BLOCKS.QUOTE)},t.createElement(T.QuoteIcon,null)):null}var lo=function(e,t){if(ve(e,{match:{type:o.BLOCKS.TABLE}})){var n=ke(e,{match:{type:o.BLOCKS.TABLE_ROW}});if(n){var r=n[0],i=t(n[1]);Xe(e,O.getEmptyRowNode(e,{header:!1,colCount:r.children.length}),{at:i,select:!0}),Ye(e,fe(e,i))}}},co=function(e){lo(e,(function(e){return _e(e)}))},so=function(e){lo(e,(function(e){return e}))},uo=function(e,t,n){var r=t.header;if(ve(e,{match:{type:o.BLOCKS.TABLE}})){var i=ke(e,{match:{type:[o.BLOCKS.TABLE_HEADER_CELL,o.BLOCKS.TABLE_CELL]}}),a=ke(e,{match:{type:o.BLOCKS.TABLE}});if(i&&a){var l=n(i[1]).slice(),c=l.length-2;a[0].children.forEach((function(t,n){l[c]=n,Xe(e,O.getEmptyCellNode(e,{header:r&&0===n}),{at:l,select:0===n})}))}}},fo=function(e,t){uo(e,t,(function(e){return _e(e)}))},po=function(e,t){uo(e,t,(function(e){return e}))};function mo(e){var t={type:o.BLOCKS.TABLE,data:{},children:[O.getEmptyRowNode(e,{colCount:2,header:!0}),O.getEmptyRowNode(e,{colCount:2})]};if(Xe(e,t),e.selection){var n=me(e,{match:{type:o.BLOCKS.TABLE}});if(!n)return;!function(e,t){a.selectEditor(e,t)}(e,{at:fe(e,n[1])})}!function(e){var t=function(e){var t;if(e.selection)return(t=e.selection.focus.path,g.Path.levels(t,void 0)).find((function(e){return 1===e.length}))}(e);if(t&&!He(t)){var n=Pe(t);if(n){var r=ye(e,{at:n,match:function(e){return e.type===o.BLOCKS.PARAGRAPH}})[0];r&&we(e,r[0])&&(it(e,{at:t,to:n}),rt(e,{at:t}))}}}(e)}var Eo,yo,ho,vo,go,So,Lo,bo=function(e,t){var n=he(e,t[1]);if(!n)throw new Error("table rows must be wrapped in a table node");return Math.max.apply(Math,ge(n).map((function(e){return ge(e).length})))-ge(t).length},Co=function(e,t){return 0!==ge(t).length},To=function(e){return Oe(e)&&e.type===o.BLOCKS.TABLE},ko={topRight:l.css({position:"absolute",top:"6px",right:"5px"})},Io=function(){var e=ne(),t=X(),r=n.useState(!1),i=r[0],a=r[1],l=n.useState(!1),c=l[0],s=l[1],u=n.useCallback((function(){a(!1)}),[]);n.useEffect((function(){s(Boolean(e&&function(e){var t=ke(e,{match:{type:o.BLOCKS.TABLE}});if(!t)return!1;var n=ge(t)[0];return!!n&&ge(n).every((function(e){return e[0].type===o.BLOCKS.TABLE_HEADER_CELL}))}(e)))}),[e]);var d=n.useMemo((function(){return!!e&&!ke(e,{match:{type:o.BLOCKS.TABLE_HEADER_CELL}})}),[e]),f=n.useCallback((function(){if(u(),e){var t=!c;s(t),function(e,t){var n=ke(e,{match:{type:o.BLOCKS.TABLE}});if(n){var r=ge(n)[0];r&&ge(r).forEach((function(n){Ve(e,{type:t?o.BLOCKS.TABLE_HEADER_CELL:o.BLOCKS.TABLE_CELL},{at:n[1]})}))}}(e,t)}}),[e,u,c]),p=n.useCallback((function(t,n,r){return function(){if(null!=e&&e.selection){u();var i=function(e){var t=ut(e,o.BLOCKS.TABLE)[0];return t?function(e){var t,n=e.children.length;return n?{numRows:n,numColumns:null==(t=e.children[0].children)?void 0:t.length}:null}(t):null}(e);re(e,(function(){t(e,{header:c})})),e.tracking.onViewportAction(n+"Table"+("Table"===r?"":r),{tableSize:i})}}}),[e,c,u]);return t?null:n.createElement(E.Menu,{placement:"left",isOpen:i,onOpen:function(){a(!0)},onClose:u},n.createElement(E.Menu.Trigger,null,n.createElement(E.IconButton,{size:"small",variant:"transparent",tabIndex:-1,className:ko.topRight,icon:n.createElement(T.ChevronDownIcon,null),"aria-label":"Open table menu",testId:"cf-table-actions-button"})),n.createElement(E.Menu.List,null,n.createElement(E.Menu.Item,{onClick:p(so,"insert","Row"),disabled:!d},"Add row above"),n.createElement(E.Menu.Item,{onClick:p(co,"insert","Row")},"Add row below"),n.createElement(E.Menu.Item,{onClick:p(po,"insert","Column")},"Add column left"),n.createElement(E.Menu.Item,{onClick:p(fo,"insert","Column")},"Add column right"),n.createElement(E.Menu.Divider,null),n.createElement(E.Menu.Item,{onClick:f},c?"Disable table header":"Enable table header"),n.createElement(E.Menu.Divider,null),n.createElement(E.Menu.Item,{onClick:p(O.deleteRow,"remove","Row")},"Delete row"),n.createElement(E.Menu.Item,{onClick:p(O.deleteColumn,"remove","Column")},"Delete column"),n.createElement(E.Menu.Item,{onClick:p(O.deleteTable,"remove","Table")},"Delete table")))},Ao=l.css(Eo||(Eo=j(["\n border: 1px solid ",";\n border-collapse: collapse;\n padding: 10px 12px;\n min-width: 48px;\n position: relative;\n vertical-align: top;\n\n div:last-child {\n margin-bottom: 0;\n }\n"])),C.gray400),No=function(e){var n=u.useSelected();return t.createElement("td",H({},e.attributes,e.element.data,{className:Ao}),n&&t.createElement(Io,null),e.children)},Do=l.css(yo||(yo=j(["\n background-clip: padding-box;\n background-color: ",";\n border: 1px solid ",";\n border-collapse: collapse;\n padding: 10px 12px;\n font-weight: ",";\n text-align: left;\n min-width: 48px;\n position: relative;\n\n div:last-child {\n margin-bottom: 0;\n }\n"])),C.gray200,C.gray400,C.fontWeightNormal),Bo=function(e){var n=u.useSelected();return t.createElement("th",H({},e.attributes,e.element.data,{className:Do}),n&&t.createElement(Io,null),e.children)},Oo=l.css(ho||(ho=j(["\n border: 1px solid ",";\n border-collapse: collapse;\n\n &:hover td {\n background-color: transparent !important;\n }\n"])),C.gray400),Ro=function(e){return t.createElement("tr",H({},e.attributes,{className:Oo}),e.children)},xo=l.css(vo||(vo=j(["\n margin-bottom: 1.5em;\n border-collapse: collapse;\n border-radius: 5px;\n border-style: hidden;\n box-shadow: 0 0 0 1px ",";\n width: 100%;\n table-layout: fixed;\n overflow: hidden;\n"])),C.gray400),wo=function(e){return t.createElement("div",{"data-block-type":o.BLOCKS.TABLE},t.createElement("table",H({className:xo},e.attributes),t.createElement("tbody",null,e.children)))},Ko=function(e){var t,n;if(!Oe(e))return[e];if(e.type!==o.BLOCKS.TABLE||1!==(null==(t=e.children)?void 0:t.length))return[e];var r=e.children[0];return 1!==(null==r||null==(n=r.children)?void 0:n.length)?[e]:r.children[0].children},_o=function(e,t){var n=O.onKeyDownTable(e,t);return function(t){var r,i,l=window.getSelection();if(l&&(null==(r=l.anchorNode.attributes)||null==(i=r["data-block-type"])?void 0:i.value)===o.BLOCKS.TABLE){if("Enter"===t.key){var c=ke(e,{match:{type:o.BLOCKS.TABLE}});if(!c)return;pt(e,{at:c[1],select:!0})}return t.preventDefault(),void t.stopPropagation()}if("Tab"===t.key&&!t.shiftKey){t.preventDefault();var s=O.getTableEntries(e,{});if(s){var u=s.table,d=s.row,f=ze(d,s.cell[1]);if(ze(u,d[1])&&f)return void co(e);n(t)}}"Escape"===t.key&&function(e){a.blurEditor(e)}(e)}},Po=Object.values(o.INLINES).map((function(e){return{type:e}})),Mo={document:{nodes:[{types:o.TOP_LEVEL_BLOCKS.map((function(e){return{type:e}}))}]},blocks:H((go={},go[o.BLOCKS.PARAGRAPH]={nodes:[{match:[].concat(Po,[{object:"text"}])}]},go[o.BLOCKS.HEADING_1]={nodes:[{match:[].concat(Po,[{object:"text"}])}]},go[o.BLOCKS.HEADING_2]={nodes:[{match:[].concat(Po,[{object:"text"}])}]},go[o.BLOCKS.HEADING_3]={nodes:[{match:[].concat(Po,[{object:"text"}])}]},go[o.BLOCKS.HEADING_4]={nodes:[{match:[].concat(Po,[{object:"text"}])}]},go[o.BLOCKS.HEADING_5]={nodes:[{match:[].concat(Po,[{object:"text"}])}]},go[o.BLOCKS.HEADING_6]={nodes:[{match:[].concat(Po,[{object:"text"}])}]},go),o.VOID_BLOCKS.reduce((function(e,t){var n;return H({},e,((n={})[t]={isVoid:!0},n))}),{}),(So={},So[o.BLOCKS.QUOTE]={nodes:[{match:[o.CONTAINERS[o.BLOCKS.QUOTE].map((function(e){return{type:e}}))],min:1}],normalize:function(e,t){if("child_type_invalid"===t.code)return e.unwrapBlockByKey(t.node.key,o.BLOCKS.QUOTE)}},So)),inlines:(Lo={},Lo[o.INLINES.HYPERLINK]={nodes:[{match:[{object:"text"}]}]},Lo[o.INLINES.ENTRY_HYPERLINK]={nodes:[{match:[{object:"text"}]}]},Lo[o.INLINES.ASSET_HYPERLINK]={nodes:[{match:[{object:"text"}]}]},Lo[o.INLINES.EMBEDDED_ENTRY]={isVoid:!0},Lo)};function Ho(e){var t=R.toContentfulDocument({document:e.children,schema:Mo});return x.documentToPlainTextString(t).length}function zo(e){var t=e.getData("text/html"),n=(new DOMParser).parseFromString(t,"text/html");return n.querySelector('[id*="docs-internal-guid"]')?"Google Docs":n.querySelector("google-sheets-html-origin")||n.querySelector("[data-sheets-value]")?"Google Spreadsheets":n.querySelector('meta[content*="Microsoft Excel"]')?"Microsoft Excel":n.querySelector('meta[content*="Microsoft Word"]')?"Microsoft Word":n.querySelector('[style*="Arial_MSFontService"]')&&(n.querySelector(".TextRun")||n.querySelector(".OutlineElement"))?"Microsoft Word Online":n.querySelector('meta[content="Cocoa HTML Writer"]')?"Apple Notes":n.querySelector('[style*="Slack-Lato, Slack-Fractions"]')?"Slack":"Unknown"}var Fo=function(e){var t={onViewportAction:function(t,n){return void 0===n&&(n={}),e(t,H({origin:"viewport-interaction"},n))},onShortcutAction:function(t,n){return void 0===n&&(n={}),e(t,H({origin:"shortcut"},n))},onShortcutOrViewportAction:function(t,n){return void 0===n&&(n={}),e(t,H({origin:"shortcut-or-viewport"},n))},onToolbarAction:function(t,n){return void 0===n&&(n={}),e(t,H({origin:"toolbar-icon"},n))},onCommandPaletteAction:function(t,n){return void 0===n&&(n={}),e(t,H({origin:"command-palette"},n))}};return{key:"TrackingPlugin",withOverrides:function(e){var n=e.insertData;return e.tracking=t,e.insertData=function(r){if(0!==r.types.length){var i,o=null==(i=window.getSelection())?void 0:i.toString().length,a=Ho(e);setTimeout((function(){var n=Ho(e);t.onShortcutOrViewportAction("paste",{characterCountAfter:n,characterCountBefore:a,characterCountSelection:o,source:zo(r)})}))}n(r)},e}}};function qo(e){return e.some((function(e){return e.type===o.BLOCKS.TABLE}))}var Uo=function(e){return e.type===o.BLOCKS.TABLE_HEADER_CELL},Go=function(e){return function(t,n){var r,i=n[0];return Oe(i)&&(null==(r=t.tracking)||r.onViewportAction("invalidTablePaste",{nodeType:i.type})),e(t,n)}},Yo=function(){var e;return O.createTablePlugin({type:o.BLOCKS.TABLE,handlers:{onKeyDown:_o},withOverrides:function(e,t){var n=e.normalizeNode;return O.withTable(e,t),e.normalizeNode=n,function(e){var t=e.insertData;e.insertData=function(n){if(n.getData("text/html")){var r=e.children;t(n);var i=e.children;setTimeout((function(){var t;qo(r)||qo(i)&&e.tracking.onViewportAction("paste",{tablePasted:!0,source:zo(n),hasHeadersOutsideFirstRow:(t=i,t.filter((function(e){return e.type===o.BLOCKS.TABLE})).flatMap((function(e){return e.children.slice(1)})).some((function(e){return e.children.some(Uo)})))})}),1)}else t(n)}}(e),e.insertFragment=function(e){var t=e.insertFragment;return function(n){var r;if(e.selection){var i=(n=n.flatMap(Ko)).some((function(e){return To(e)})),o=0===n.findIndex((function(e){return To(e)})),a=""!==ue(e,null==(r=e.selection)?void 0:r.focus.path);return i&&o&&a&&pt(e),t(n)}}}(e),e},overrideByKey:(e={},e[O.ELEMENT_TABLE]={type:o.BLOCKS.TABLE,component:wo,normalizer:[{validNode:Co},{validNode:function(e,t){var n=t[1],r=!!me(e,{at:n,match:{type:[o.BLOCKS.TABLE_CELL,o.BLOCKS.TABLE_HEADER_CELL]}});return st(n)||r},transform:ir},{validChildren:o.CONTAINERS[o.BLOCKS.TABLE]}]},e[O.ELEMENT_TR]={type:o.BLOCKS.TABLE_ROW,component:Ro,normalizer:[{validChildren:o.CONTAINERS[o.BLOCKS.TABLE_ROW],transform:rr(o.BLOCKS.TABLE_CELL)},{validNode:Co},{validNode:function(e,t){var n,r=null==(n=he(e,t[1]))?void 0:n[0];return r&&r.type===o.BLOCKS.TABLE},transform:rr(o.BLOCKS.TABLE)},{validNode:function(e,t){return 0===bo(e,t)},transform:function(e,t){var n,r=bo(e,t),i=_e(Me(t));Xe(e,(n={type:o.BLOCKS.TABLE_CELL,data:{},children:[{type:o.BLOCKS.PARAGRAPH,data:{},children:[{text:""}]}]},new Array(r).fill(n)),{at:i})}}]},e[O.ELEMENT_TH]={type:o.BLOCKS.TABLE_HEADER_CELL,component:Bo,normalizer:[{validChildren:o.CONTAINERS[o.BLOCKS.TABLE_HEADER_CELL],transform:Go(tr)}]},e[O.ELEMENT_TD]={type:o.BLOCKS.TABLE_CELL,component:No,normalizer:[{validChildren:o.CONTAINERS[o.BLOCKS.TABLE_CELL],transform:Go(tr)}]},e)})};function jo(e){var n=ne(),r=n&&function(e){return[O.ELEMENT_TABLE,O.ELEMENT_TH,O.ELEMENT_TR,O.ELEMENT_TD].some((function(t){return ct(e,t)}))}(n);function i(){return(i=M(It.mark((function e(){return It.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n){e.next=2;break}return e.abrupt("return");case 2:n.tracking.onToolbarAction("insertTable"),mo(n),gt(n);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}return n?t.createElement(pr,{title:"Table",testId:"table-toolbar-button",onClick:function(){return i.apply(this,arguments)},isActive:!!r,isDisabled:e.isDisabled},t.createElement(T.TableIcon,null)):null}function Wo(e){return void 0===e&&(e=[]),{key:"TextPlugin",handlers:{onMouseUp:function(e){return function(){e.selection&&Ge(e,function(e,t,n){return a.unhangRange(e,t,void 0)}(e,e.selection))}}},withOverrides:function(e){var t=e.insertText;e.insertText=function(n){var r=e.selection;if(r&&Le(r)){var i,o=null==(i=ke(e,{match:function(t){return function(e,t){return a.isInline(e,t)}(e,t)},mode:"highest"}))?void 0:i[1];if(o&&function(e,t,n){return a.isEndPoint(e,t,n)}(e,r.anchor,o)){var l=function(e,t,n){return a.getPointAfter(e,t,void 0)}(e,o);Ge(e,{anchor:l,focus:l})}}return t(n)};var n=e.deleteForward,r=e.deleteBackward;return e.deleteBackward=function(t){Vo(t,e,r)},e.deleteForward=function(t){Vo(t,e,n)},function(e){e.insertTextData=function(t){var n=t.getData("text/plain");if(!n)return!1;for(var r,i=!1,o=V(n.split(/\n{2}/));!(r=o()).done;){var a=r.value;/^(\r\n?|\n)$/.test(a)||(i&&Qe(e,{always:!0}),e.insertText(a),i=!0)}return!0}}(e),e},normalizer:[{match:de,transform:function(t,n){!function(e,t,n){a.unsetNodes(e,t,n)}(t,e,{at:n[1]})},validNode:function(t,n){var r=n[0];return!e.some((function(e){return e in r}))}}]}}function Vo(e,t,n){var r=ke(t,{match:{type:o.TEXT_CONTAINERS}});if(r){var i=r[1];if(we(t,r[0])&&1===i.length&&t.children.length>1){rt(t,{at:i});var l=function(e,t,n){return a.getPointBefore(e,t,n)}(t,t.selection,{unit:e});l&&ye(t,{match:function(e){return function(e,t){return a.queryNode(e,{allow:[o.BLOCKS.EMBEDDED_ASSET,o.BLOCKS.EMBEDDED_ENTRY,o.BLOCKS.HR]})}([e,l.path])},at:l})[0]&&Ye(t,l)}else n(e)}else n(e)}var Xo={deserializeAst:!0,deserializeHtml:!0,eventEditor:!0},Qo=function(e){return((null==e?void 0:e.content)||[]).length>0},$o=function(e){return function e(t){return void 0===t&&(t=[]),t.map((function(t){var n;return function(e){return"text"in e}(t)?t:0===(null==(n=t.children)?void 0:n.length)?H({},t,{children:[{text:"",data:{}}]}):H({},t,{children:e(null==t?void 0:t.children)})}))}(R.toSlatejsDocument({document:Qo(e)?e:o.EMPTY_DOCUMENT,schema:Mo}))},Zo="1px solid "+C.gray400,Jo={root:l.css({position:"relative"}),editor:l.css({borderRadius:"0 0 "+C.borderRadiusMedium+" "+C.borderRadiusMedium,border:Zo,borderTop:0,padding:"20px",fontSize:C.spacingM,fontFamily:C.fontStackPrimary,minHeight:"400px",background:C.colorWhite,outline:"none",whiteSpace:"pre-wrap",overflowWrap:"break-word",webkitUserModify:"read-write-plaintext-only",a:{span:{cursor:"not-allowed","&:hover":{cursor:"not-allowed"}}},"ul > li > div":{margin:0}}),hiddenToolbar:l.css({borderTop:Zo}),enabled:l.css({background:C.colorWhite,a:{span:{cursor:"pointer","&:hover":{cursor:"pointer"}}}}),disabled:l.css({background:C.gray100,cursor:"not-allowed"})};function ea(e){var n=e.children,r=e.isDisabled;return t.createElement(E.Menu,{placement:"bottom-end",isOpen:e.isOpen,onClose:e.onClose,onOpen:e.onToggle},t.createElement(E.Menu.Trigger,null,t.createElement(E.Button,{endIcon:t.createElement(T.ChevronDownIcon,null),testId:"toolbar-entity-dropdown-toggle",variant:"secondary",size:"small",startIcon:t.createElement(T.PlusIcon,null),isDisabled:r},"Embed")),t.createElement(E.Menu.List,{className:"toolbar-entity-dropdown-list"},n))}var ta,na=function(e){var r=e.isDisabled,i=e.canInsertBlocks,a=se(),l=ne(),c=t.useState(!1),s=c[0],u=c[1],d=function(){return u(!1)},f=Ct(a.field,o.INLINES.EMBEDDED_ENTRY),p=Ct(a.field,o.BLOCKS.EMBEDDED_ENTRY)&&i,m=Ct(a.field,o.BLOCKS.EMBEDDED_ASSET)&&i,E=n.createElement(n.Fragment,null,p&&n.createElement(on,{isDisabled:!!r,nodeType:o.BLOCKS.EMBEDDED_ENTRY,onClose:d}),f&&n.createElement(Bn,{isDisabled:!!r||Et(l),onClose:d}),m&&n.createElement(on,{isDisabled:!!r,nodeType:o.BLOCKS.EMBEDDED_ASSET,onClose:d}));return p||f||m?n.createElement(ea,{isDisabled:r,onClose:d,onToggle:function(){return u(!s)},isOpen:s},E):null},ra={toolbar:l.css({border:"1px solid "+C.gray400,backgroundColor:C.gray100,padding:C.spacingXs,borderRadius:C.borderRadiusMedium+" "+C.borderRadiusMedium+" 0 0"}),toolbarBtn:l.css({height:"30px",width:"30px",marginLeft:C.spacing2Xs,marginRight:C.spacing2Xs}),divider:l.css({display:"inline-block",height:"21px",width:"1px",background:C.gray300,margin:"0 "+C.spacing2Xs}),embedActionsWrapper:l.css({display:["-webkit-box","-ms-flexbox","flex"],webkitAlignSelf:"flex-start",alignSelf:"flex-start",msFlexItemAlign:"start",marginLeft:"auto"}),formattingOptionsWrapper:l.css({display:["-webkit-box","-ms-flexbox","flex"],msFlexAlign:"center",webkitBoxAlign:"center",alignItems:"center",msFlexWrap:"wrap",flexWrap:"wrap",marginRight:"20px"})},ia=function(e){var t=e.sdk,r=e.isDisabled,i=ne(),a=i&&(Ne(i,o.MARKS.SUPERSCRIPT)||Ne(i,o.MARKS.SUBSCRIPT)||Ne(i,o.MARKS.CODE));return n.createElement(E.Menu,null,n.createElement(E.Menu.Trigger,null,n.createElement("span",null,n.createElement(E.IconButton,{size:"small",className:ra.toolbarBtn,variant:a?"secondary":"transparent",icon:n.createElement(T.MoreHorizontalIcon,null),"aria-label":"toggle menu",isDisabled:r,testId:"dropdown-toolbar-button"}))),n.createElement(E.Menu.List,null,Tt(t.field,o.MARKS.SUPERSCRIPT)&&n.createElement(wi,{isDisabled:r}),Tt(t.field,o.MARKS.SUBSCRIPT)&&n.createElement(Bi,{isDisabled:r}),Tt(t.field,o.MARKS.CODE)&&n.createElement(bi,{isDisabled:r})))},oa=function(e){var t=e.isDisabled,r=se(),i=ne(),a=!dt(i,o.BLOCKS.TABLE),l=n.useMemo((function(){return e=r.field,{isAnyMarkEnabled:(t=function(t,n){return t.some((function(t){return n(e,t)}))})(Object.values(o.MARKS),Tt),isAnyHyperlinkEnabled:t([o.INLINES.HYPERLINK,o.INLINES.ASSET_HYPERLINK,o.INLINES.ENTRY_HYPERLINK],Ct),isAnyBlockFormattingEnabled:t([o.BLOCKS.UL_LIST,o.BLOCKS.OL_LIST,o.BLOCKS.QUOTE,o.BLOCKS.HR],Ct)};var e,t}),[r.field]),c=dt(i,o.BLOCKS.UL_LIST)||dt(i,o.BLOCKS.OL_LIST),s=dt(i,o.BLOCKS.QUOTE),u=t||!a||c||s,d=Tt(r.field,o.MARKS.BOLD)||Tt(r.field,o.MARKS.ITALIC)||Tt(r.field,o.MARKS.UNDERLINE),f=Tt(r.field,o.MARKS.SUPERSCRIPT)||Tt(r.field,o.MARKS.SUBSCRIPT)||Tt(r.field,o.MARKS.CODE),p=d&&f;return n.createElement(E.Flex,{testId:"toolbar",className:ra.toolbar,alignItems:"center"},n.createElement("div",{className:ra.formattingOptionsWrapper},n.createElement(Kn,{isDisabled:t||!a}),l.isAnyMarkEnabled&&n.createElement("span",{className:ra.divider}),Tt(r.field,o.MARKS.BOLD)&&n.createElement(vi,{isDisabled:t}),Tt(r.field,o.MARKS.ITALIC)&&n.createElement(ki,{isDisabled:t}),Tt(r.field,o.MARKS.UNDERLINE)&&n.createElement(_i,{isDisabled:t}),!d&&Tt(r.field,o.MARKS.SUPERSCRIPT)&&n.createElement(xi,{isDisabled:t}),!d&&Tt(r.field,o.MARKS.SUBSCRIPT)&&n.createElement(Di,{isDisabled:t}),!d&&Tt(r.field,o.MARKS.CODE)&&n.createElement(Li,{isDisabled:t}),p&&n.createElement(ia,{sdk:r,isDisabled:t}),l.isAnyHyperlinkEnabled&&n.createElement(n.Fragment,null,n.createElement("span",{className:ra.divider}),n.createElement(Ar,{isDisabled:t})),l.isAnyBlockFormattingEnabled&&n.createElement("span",{className:ra.divider}),n.createElement(pi,{isDisabled:t||!a}),Ct(r.field,o.BLOCKS.QUOTE)&&n.createElement(ao,{isDisabled:t||!a}),Ct(r.field,o.BLOCKS.HR)&&n.createElement(yr,{isDisabled:t||!a}),Ct(r.field,o.BLOCKS.TABLE)&&n.createElement(jo,{isDisabled:u})),n.createElement("div",{className:ra.embedActionsWrapper},n.createElement(na,{isDisabled:t,canInsertBlocks:a})))},aa={nativeSticky:l.css(ta||(ta=j(["\n position: -webkit-sticky;\n position: sticky;\n top: -1px;\n z-index: 2;\n "])))},la=function(e){return n.createElement("div",{className:e.isDisabled?"":aa.nativeSticky},e.children)},ca=["command-prompt"],sa=function(e){return"set_selection"!==e.type},ua=["sdk","isInitiallyDisabled","onAction","restrictedMarks"],da=function(e){var r,i,c,u,m,E,y=Z(e.sdk),h=n.useMemo((function(){var t,n,r,i,l,c,u,m,E,y;return n=e.sdk,r=null!=(t=e.onAction)?t:s,i=e.restrictedMarks,[a.createDeserializeHtmlPlugin(),a.createDeserializeAstPlugin(),d.createDeserializeDocxPlugin(),Fo(r),(E=[o.BLOCKS.EMBEDDED_ENTRY,o.BLOCKS.EMBEDDED_ASSET,o.BLOCKS.HR,o.INLINES.EMBEDDED_ENTRY],y={TABLE:[o.INLINES.EMBEDDED_ENTRY]},{key:"DragAndDropPlugin",handlers:{onDrop:function(e){return function(t){var n=Array.from(ye(e,{match:function(e){return E.includes(e.type)}}))[0];if(!n)return!1;var r=n[0];if(!t.nativeEvent.target)return!1;var i=function(e){var t=[];for(t.push(e);e.parentNode;)t.unshift(e.parentNode),e=e.parentNode;return t}(t.nativeEvent.target).some((function(e){var t;return!(!y[e.nodeName]||null!=(t=y[e.nodeName])&&t.includes(r.type))}));return i||e.history.undos.push([]),i}}}})].concat(Object.values(xt(n)).some(Boolean)?[{key:"command-prompt",type:"command-prompt",isLeaf:!0,component:zt,handlers:{onKeyDown:function(e){return function(t){if(v("shift?+/",{byKey:!0},t)&&(function(e,t,n){void 0===n&&(n=!0),a.addMark(e,"command-prompt",n)}(e),e.tracking.onCommandPaletteAction("openRichTextCommandPalette")),Ne(e,"command-prompt")){if(v("enter",t))return t.preventDefault();var n=ke(e),r=be(e,n[1]);v("backspace",t)&&r.focus.offset-r.anchor.offset==1&&et(e,"command-prompt",r),v("escape",t)&&(t.stopPropagation(),et(e,"command-prompt",r),e.tracking.onCommandPaletteAction("cancelRichTextCommandPalette"),ie(e))}}}}}]:[],[(m={type:o.BLOCKS.PARAGRAPH,component:Wi,options:{hotkey:["mod+opt+0"]},handlers:{onKeyDown:Vi},softBreak:[{hotkey:"shift+enter",query:{allow:o.BLOCKS.PARAGRAPH}}],deserializeHtml:{rules:[{validNodeName:["P","DIV"]}],query:function(e){return!(""===e.textContent||(t=e,t.hasAttribute("data-embedded-entity-inline-id")||t.hasAttribute("data-entity-type")));var t}},normalizer:[{validChildren:function(e,t){return vt(t[0])},transform:(u={},u[o.BLOCKS.PARAGRAPH]=nr,u.default=ir,u)}]},D.createParagraphPlugin(m)),k.createListPlugin({normalizer:[{match:{type:[o.BLOCKS.UL_LIST,o.BLOCKS.OL_LIST]},validChildren:[o.BLOCKS.LIST_ITEM],transform:rr(o.BLOCKS.LIST_ITEM)}],overrideByKey:(c={},c[k.ELEMENT_UL]={type:o.BLOCKS.UL_LIST,component:jr,handlers:{onKeyDown:ti},withOverrides:fi},c[k.ELEMENT_OL]={type:o.BLOCKS.OL_LIST,component:Wr,handlers:{onKeyDown:ti}},c[k.ELEMENT_LIC]={type:o.BLOCKS.PARAGRAPH},c[k.ELEMENT_LI]={type:o.BLOCKS.LIST_ITEM,component:Xr,normalizer:[{validNode:ri,transform:ii},{validNode:oi,transform:li},{validChildren:o.LIST_ITEM_BLOCKS,transform:tr},{validNode:ai,transform:ci}]},c)}),{key:o.BLOCKS.HR,type:o.BLOCKS.HR,isVoid:!0,isElement:!0,component:hr,handlers:{onKeyDown:Er},deserializeHtml:{rules:[{validNodeName:["HR"]},{validAttribute:{"data-void-element":o.BLOCKS.HR}}],withoutChildren:!0}},dr(),oo(),Yo(),sn(n),un(n),Fr(n),On(n),{key:"Marks",plugins:[A.createBoldPlugin({type:o.MARKS.BOLD,component:Si,options:{hotkey:["mod+b"]},handlers:{onKeyDown:Ei(o.MARKS.BOLD)},deserializeHtml:{rules:[{validNodeName:["STRONG","B"]},{validStyle:{fontWeight:["600","700","bold"]}}],query:function(e){return!function(e){return e.id.startsWith("docs-internal-guid")&&"B"===e.nodeName}(e)&&!qe(e,(function(e){return"normal"===e.style.fontWeight}))}}}),A.createCodePlugin({type:o.MARKS.CODE,component:Ti,options:{hotkey:["mod+/","mod+shift+7"]},handlers:{onKeyDown:Ei(o.MARKS.CODE)},deserializeHtml:{rules:[{validNodeName:["CODE","PRE"]},{validStyle:{fontFamily:["Consolas","monospace"]}}]}}),A.createItalicPlugin({type:o.MARKS.ITALIC,component:Ai,options:{hotkey:["mod+i"]},handlers:{onKeyDown:Ei(o.MARKS.ITALIC)},deserializeHtml:{rules:[{validNodeName:["I","EM"]},{validStyle:{fontStyle:"italic"}}],query:function(e){return!qe(e,(function(e){return"normal"===e.style.fontStyle}))}}}),A.createUnderlinePlugin({type:o.MARKS.UNDERLINE,component:Pi,options:{hotkey:["mod+u"]},handlers:{onKeyDown:Ei(o.MARKS.UNDERLINE)},deserializeHtml:{rules:[{validNodeName:["U"]},{validStyle:{textDecoration:["underline"]}}],query:function(e){return!qe(e,(function(e){return"none"===e.style.textDecoration}))}}}),A.createSuperscriptPlugin({type:o.MARKS.SUPERSCRIPT,component:Ki,handlers:{onKeyDown:Ei(o.MARKS.SUPERSCRIPT)},deserializeHtml:{rules:[{validNodeName:["SUP"]}]}}),A.createSubscriptPlugin({type:o.MARKS.SUBSCRIPT,component:Oi,handlers:{onKeyDown:Ei(o.MARKS.SUBSCRIPT)},deserializeHtml:{rules:[{validNodeName:["SUB"]}]}})]},w.createTrailingBlockPlugin({options:{type:o.BLOCKS.PARAGRAPH,level:0}}),Wo(i),{key:"VoidsPlugin",exitBreak:[{hotkey:"enter",before:!0,query:{filter:function(e){var t=e[0],n=e[1];return st(n)&&He(n)&&!!t.isVoid}}},{hotkey:"enter",level:-2,query:{filter:function(e){var t=e[0],n=e[1];return!(st(n)&&He(n)||!t.isVoid)}}}]},B.createSelectOnBackspacePlugin({options:{query:{allow:[o.INLINES.EMBEDDED_ENTRY]}}}),{key:"PasteHTMLPlugin",withOverrides:function(e){var t=e.insertData;return e.insertData=function(e){return t(function(e){if(!e.getData("application/x-slate-fragment")){var t=function(e){return(e.getData("text/html").match(Zi)||[])[1]}(e);if(t){var n=new DataTransfer;return e.types.forEach((function(t){n.setData(t,e.getData(t))})),n.setData("application/x-slate-fragment",t),n}}return e}(e))},e},inject:{pluginsByKey:(l={},l[a.KEY_DESERIALIZE_HTML]={editor:{insertData:{format:"text/html",transformData:$i}}},l)}},f.createSoftBreakPlugin({then:function(e){return{options:{rules:e.plugins.flatMap((function(e){return e.softBreak||[]}))}}}}),f.createExitBreakPlugin({options:{rules:[]},then:function(e){return{options:{rules:e.plugins.flatMap((function(e){return e.exitBreak||[]}))}}}}),p.createResetNodePlugin({options:{rules:[]},then:function(e){for(var t,n=e.plugins.flatMap((function(e){return e.resetNode||[]})),r=V(n);!(t=r()).done;){var i=t.value;i.defaultType||(i.defaultType=o.BLOCKS.PARAGRAPH)}return{options:{rules:n}}}}),{key:"NormalizerPlugin",withOverrides:Yi}])}),[e.sdk,e.onAction,e.restrictedMarks]),g=t.useState(!0),S=g[0],L=g[1],b=t.useState(!1),C=b[1],T=(i=(r={editorId:y,handler:e.onChange,skip:b[0]||S,onSkip:function(){return C(!1)}}).editorId,u=r.skip,m=r.onSkip,E=t.useMemo((function(){return K((function(e){var t=function e(t){return H({},t,{content:t.content.map((function(t){return"text"===t.nodeType?(t.marks=t.marks.filter((function(e){return!ca.includes(e.type)})),t):e(t)}))})}(R.toContentfulDocument({document:e,schema:Mo}));null==c||c(t)}),500)}),[c=r.handler]),t.useCallback((function(e){var t=a.getPlateSelectors(i).editor();if(!t)throw new Error("Editor change callback called but editor not defined. Editor id: "+i);if((null==t?void 0:t.operations.filter(sa)).length>0){if(u)return void(null==m||m());E(e)}}),[i,E,u,m]));t.useEffect((function(){L(!1);var t=function(e){return a.getPlateSelectors(e)}(y).editor();t&&(C(!0),function(e,t){re(e,(function(){[].concat(e.children).forEach((function(t){return e.apply({type:"remove_node",path:[0],node:t})})),t&&(a.isNode(t)?[t]:t).forEach((function(t,n){e.apply({type:"insert_node",path:[n],node:t})}));var n=function(e,t){return a.getEndPoint(e,[])}(e);n&&Ye(e,n)}))}(t,$o(e.value)))}),[e.value,y]);var I=l.cx(Jo.editor,void 0!==e.minHeight?l.css({minHeight:e.minHeight}):void 0,e.isDisabled?Jo.disabled:Jo.enabled,e.isToolbarHidden&&Jo.hiddenToolbar);return t.useEffect((function(){var t,n;S&&a.getPlateActions(y).value((t=$o(e.value),(n=function(e){return void 0===e&&(e={}),a.createPlateEditor(e)}({plugins:h,disableCorePlugins:Xo})).children=t,function(e,t){void 0===t&&(t={force:!0}),a.normalizeEditor(e,t)}(n,{force:!0}),n.children))}),[S,h,y,e.value]),n.createElement(ce,{sdk:e.sdk},n.createElement(ee,{value:y},n.createElement("div",{className:Jo.root,"data-test-id":"rich-text-editor"},n.createElement(a.Plate,{id:y,plugins:h,disableCorePlugins:Xo,editableProps:{className:I,readOnly:e.isDisabled},onChange:T,firstChildren:!e.isToolbarHidden&&n.createElement(la,{isDisabled:e.isDisabled},n.createElement(oa,{isDisabled:e.isDisabled}))}))))};function fa(e){var t=e.sys;return{sys:{id:t.id,type:"Link",linkType:t.type}}}var pa=function(e){function t(t){var n,r;(r=e.call(this,t)||this).handleSubmit=function(e){e.preventDefault(),r.props.onClose(r.getValue())},r.selectEntry=M(It.mark((function e(){var t,n,i;return It.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=(t=r.props.entitySelectorConfigs.Entry).locale,i=t.contentTypes,e.next=3,r.props.sdk.dialogs.selectSingleEntry({locale:n,contentTypes:i});case 3:r.setTargetEntity("Entry",e.sent);case 5:case"end":return e.stop()}}),e)}))),r.selectAsset=M(It.mark((function e(){var t;return It.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.props.entitySelectorConfigs.Asset.locale,e.next=3,r.props.sdk.dialogs.selectSingleAsset({locale:t});case 3:r.setTargetEntity("Asset",e.sent);case 5:case"end":return e.stop()}}),e)})));var i=t.value,o=i.text,a=i.type,l=i.uri,c=i.target,s=Boolean(c),u=((n={}).Entry=null,n.Asset=null,n),d=a;return s?u[d=c.sys.linkType]=c:d=t.allowedHyperlinkTypes.includes("uri")?"uri":t.allowedHyperlinkTypes[0],r.state={text:o,uri:l,entityLinks:u,type:d},r}z(t,e);var i=t.prototype;return i.setTargetEntity=function(e,t){this.setState((function(n){var r;return{entityLinks:H({},n.entityLinks,(r={},r[e]=t?fa(t):void 0,r))}}))},i.getValue=function(){var e=this.state,t=e.text,n=e.type,r=e.uri,i={type:n};return t&&(i.text=t),"uri"===n?i.uri=r:i.target=this.state.entityLinks[n],i},i.isLinkComplete=function(){var e=this.getValue();return!(!this.props.hideText&&!e.text)&&("uri"===e.type&&e.uri||e.target)},i.render=function(){var e=this,t=this.props.labels;return n.createElement(r.EntityProvider,{sdk:this.props.sdk},n.createElement(n.Fragment,null,n.createElement(E.ModalContent,null,this.renderFields()),n.createElement(E.ModalControls,null,n.createElement(E.Button,{type:"button",onClick:function(){return e.props.onClose(null)},variant:"secondary",testId:"cancel-cta",size:"small"},"Cancel"),n.createElement(E.Button,{type:"submit",variant:"positive",onClick:this.handleSubmit,isDisabled:!this.isLinkComplete(),testId:"confirm-cta",size:"small"},t.confirm))))},i.renderFields=function(){var e=this,t=this.props,r=t.hideText,i=t.allowedHyperlinkTypes,o=t.entitySelectorConfigs,a=this.state,l=a.uri,c=a.text,s=a.type,u="uri"===s&&(r||!!c);return n.createElement(E.Form,null,r?null:n.createElement(E.FormControl,{id:"link-text",isRequired:!0},n.createElement(E.FormControl.Label,null,"Link text"),n.createElement(E.TextInput,{testId:"link-text-input",name:"link-text",value:c||"",onChange:function(t){return e.setState({text:t.target.value})},autoFocus:!u})),function(e){return void 0===e&&(e={}),!!e.Entry||!!e.Asset}(o)&&n.createElement(E.FormControl,{id:"link-type",name:"link-type"},n.createElement(E.FormControl.Label,null,"Link type"),n.createElement(E.Select,{value:s,onChange:function(t){return e.setState({type:t.target.value})},testId:"link-type-select"},i.includes("uri")||"uri"===s?n.createElement(E.Select.Option,{value:"uri"},"URL"):null,i.includes("Entry")||"Entry"===s?n.createElement(E.Select.Option,{value:"Entry"},"Entry"):null,i.includes("Asset")||"Asset"===s?n.createElement(E.Select.Option,{value:"Asset"},"Asset"):null)),"uri"===s?n.createElement(E.FormControl,{id:"link-uri",isRequired:!0},n.createElement(E.FormControl.Label,null,"Link target"),n.createElement(E.TextInput,{testId:"link-target-input",name:"link-uri",value:l||"",placeholder:"https://",onChange:function(t){return e.setState({uri:t.target.value})},autoFocus:u}),n.createElement(E.FormControl.HelpText,null,"A protocol may be required, e.g. https://")):this.renderEntityField())},i.renderEntityField=function(){var e=this,t=this.state,r=t.type,i=t.entityLinks[r],o=!i;return n.createElement("div",null,n.createElement(E.FormLabel,{required:!0,htmlFor:""},"Link target"),!o&&n.createElement(E.TextLink,{as:"button",className:l.css({marginLeft:C.spacingS}),onClick:function(){return e.setTargetEntity(r,null)}},"Remove selection"),i&&n.createElement("div",null,"Entry"===r&&n.createElement(Yt,{sdk:this.props.sdk,locale:this.props.entitySelectorConfigs.Entry.locale,entryId:i.sys.id,isDisabled:!0,isSelected:!1}),"Asset"==r&&n.createElement(Ut,{sdk:this.props.sdk,locale:this.props.entitySelectorConfigs.Asset.locale,assetId:i.sys.id,isDisabled:!0,isSelected:!1})),o&&this.renderEntitySelector(r,o))},i.renderEntitySelector=function(e){return n.createElement("div",{className:l.css({marginTop:C.spacingS})},"Entry"===e&&n.createElement(E.TextLink,{as:"button",onClick:this.selectEntry},"Select entry"),"Asset"===e&&n.createElement(E.TextLink,{as:"button",onClick:this.selectAsset},"Select asset"))},t}(n.Component);pa.propTypes={sdk:_.object.isRequired,labels:_.shape({title:_.string,confirm:_.string}),value:_.shape({text:_.string,uri:_.string,target:_.object,type:_.oneOf(["uri","Entry","Asset"])}),entitySelectorConfigs:_.object,allowedHyperlinkTypes:_.arrayOf(_.oneOf(["Entry","Asset","uri"])),hideText:_.bool,onClose:_.func.isRequired},pa.defaultProps={labels:{title:"Insert link",confirm:"Insert link"},value:{},hideText:!1,entitySelectorConfigs:{},allowedHyperlinkTypes:["Entry","Asset","uri"]},exports.ConnectedRichTextEditor=da,exports.RichTextEditor=function(e){var a=e.sdk,l=e.isInitiallyDisabled,s=e.onAction,u=e.restrictedMarks,d=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)t.indexOf(n=o[r])>=0||(i[n]=e[n]);return i}(e,ua),f=t.useCallback((function(e){return!e||c(e,o.EMPTY_DOCUMENT)}),[]),p=Z(e.sdk);return n.createElement(r.EntityProvider,{sdk:a},n.createElement(i.FieldConnector,{throttle:0,field:a.field,isInitiallyDisabled:l,isEmptyValue:f,isEqualValues:c},(function(e){return n.createElement(da,H({},d,{key:"rich-text-editor-"+p,value:e.lastRemoteValue,sdk:a,onAction:s,isDisabled:e.disabled,onChange:e.setValue,restrictedMarks:u}))})))},exports.openRichTextDialog=function(e){return function(t){var r;return"rich-text-hyperlink-dialog"===(null==(r=t.parameters)?void 0:r.type)?i.ModalDialogLauncher.openDialog(t,(function(r){return n.createElement(pa,H({},t.parameters,{onClose:r.onClose,sdk:e}))})):Promise.reject()}},exports.renderRichTextDialog=function(e){var t=e.parameters.invocation;return"rich-text-hyperlink-dialog"===(null==t?void 0:t.type)?(e.window.startAutoResizer(),n.createElement(pa,H({},e.parameters.invocation,{onClose:e.close,sdk:e}))):n.createElement("div",null)};
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),n=e(t),i=require("@contentful/field-editor-reference"),o=require("@contentful/field-editor-shared"),l=require("@contentful/rich-text-types"),r=require("@udecode/plate-core"),s=require("emotion"),a=e(require("fast-deep-equal")),c=e(require("lodash/noop")),d=require("slate-react"),u=require("@udecode/plate-serializer-docx"),m=require("@udecode/plate-break"),p=require("@udecode/plate-reset-node"),E=require("react-popper"),y=require("@contentful/f36-components"),h=require("@contentful/f36-utils"),f=e(require("constate")),S=e(require("is-hotkey")),g=require("slate"),L=e(require("lodash/find")),C=e(require("lodash/flow")),T=e(require("lodash/get")),b=e(require("@contentful/f36-tokens")),I=require("@contentful/f36-icons"),A=require("@udecode/plate-list"),k=e(require("lodash/castArray")),N=require("@udecode/plate-basic-marks"),v=e(require("is-plain-obj")),D=require("@udecode/plate-paragraph"),B=require("@udecode/plate-select"),O=require("@udecode/plate-table"),R=require("@contentful/contentful-slatejs-adapter"),K=require("@contentful/rich-text-plain-text-renderer"),x=require("@udecode/plate-trailing-block"),w=e(require("lodash/debounce")),M=e(require("prop-types"));const _=d.useReadOnly,P=r.usePlateEditorRef,H=r.usePlateEditorState;function z(e){const{entry:t,field:n}=e;return`rich-text-editor-${t.getSys().id}-${n.id}-${n.locale}`}const F=t.createContext(""),q=F.Provider;function U(e){const n=t.useContext(F);if(e)return e;if(!n)throw new Error("could not find editor id. Please ensure the component is wrapped in <ContentfulEditorIdProvider> ");return n}function Y(e){const t=U(e);return H(t)}const G=(e,t)=>r.withoutNormalizing(e,t),$=(e,t)=>{r.focusEditor(e,t)},W=(e,t,n={exactMatch:!1,suppressThrow:!1})=>r.toSlatePoint(e,t,n);function V({sdk:e}){return t.useMemo(()=>e,[])}const[j,X]=f(V),Q=(e,t)=>r.getEditorString(e,t),Z=e=>r.isText(e),J=(e,t)=>r.getStartPoint(e,t),ee=(e,t)=>r.isSelectionAtBlockStart(e,t),te=(e,t)=>r.getBlockAbove(e,t),ne=(e,t,n)=>r.getNodeEntry(e,t,n),ie=(e,t)=>r.getNodeEntries(e,t),oe=(e,t,n)=>r.getParentNode(e,t,n),le=(e,t)=>r.someNode(e,t),re=e=>g.Text.isText(e[0])?[]:r.getChildren(e),se=(e,t)=>g.Node.get(e,t),ae=e=>r.isCollapsed(e),ce=(e,t,n)=>r.getRange(e,t,n),de=e=>g.Range.edges(e),ue=e=>g.Range.end(e),me=(e,t)=>r.getAboveNode(e,t),pe=(e,t,n)=>r.getCommonNode(e,t,n),Ee=(e,t)=>r.findNode(e,t),ye=(e,t)=>r.isMarkActive(e,t),he=e=>r.isEditor(e),fe=e=>r.isElement(e),Se=(e,t)=>r.findNodePath(e,t),ge=(e,t)=>g.Path.isAncestor(e,t),Le=(e,t)=>r.isAncestorEmpty(e,t),Ce=e=>g.Path.parent(e),Te=e=>g.Path.next(e),be=e=>g.Path.previous(e),Ie=e=>r.getLastChildPath(e),Ae=e=>r.isFirstChild(e),ke=(e,t)=>r.isLastChild(e,t),Ne=(e,t,n)=>r.match(e,t,n),ve=(e,t)=>r.someHtmlElement(e,t),De=(e,t)=>r.getPluginType(e,t),Be=(e,t)=>r.setSelection(e,t),Oe=(e,t)=>r.select(e,t),Re=(e,t)=>r.moveSelection(e,t),Ke=(e,t)=>r.collapseSelection(e,t),xe=(e,t,n)=>{r.setNodes(e,t,n)},we=(e,t,n)=>r.insertNodes(e,t,n),Me=(e,t)=>r.splitNodes(e,t),_e=(e,t)=>r.liftNodes(e,t),Pe=(e,t)=>r.unwrapNodes(e,t),He=(e,t,n)=>r.wrapNodes(e,t,n),ze=(e,t,n)=>{r.removeMark(e,{key:t,at:n})},Fe=(e,t,n)=>r.insertText(e,t,n),qe=(e,t)=>{r.deleteText(e,t)},Ue=(e,t)=>{r.removeNodes(e,t)},Ye=(e,t)=>{r.moveNodes(e,t)},Ge="undefined"!=typeof navigator&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),$e=/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9.]+)(:?\s|$)/.test(navigator.userAgent),We=[l.INLINES.HYPERLINK,l.INLINES.ENTRY_HYPERLINK,l.INLINES.ASSET_HYPERLINK];function Ve(e,t){const[n]=Array.from(ie(e,{match:e=>fe(e)&&e.type===t}));return!!n}function je(e){return 1===e.length}function Xe(e,t,n){var i;if(!(n=n??(null==(i=e.selection)?void 0:i.focus.path)))return[];const o=Array.isArray(t)?t:[t];for(let t=0;t<n.length;t++){const i=ne(e,n.slice(0,t+1));if(o.includes(i[0].type))return i}return[]}function Qe(e,t){if(!e)return!1;const[n]=Xe(e,t);return!!n}function Ze(e){Re(e,{distance:1,unit:"offset"})}function Je(e,t){we(e,{type:l.BLOCKS.PARAGRAPH,children:[{text:""}],data:{},isVoid:!1},t)}function et(e){if(!e)return!1;const[t]=Array.from(ie(e,{match:e=>!he(e)&&fe(e)&&We.includes(e.type)}));return!!t}function tt(e){Pe(e,{match:e=>!he(e)&&fe(e)&&We.includes(e.type)})}const nt=Object.values(l.INLINES),it=e=>Z(e)||fe(e)&&nt.includes(e.type),ot=e=>{const t=window.scrollX,n=window.scrollY;$(e),Ge&&setTimeout((function(){window.scrollTo(t,n)}),0)};function lt(e,t,n){((e,t,n)=>{r.toggleNodeType(e,t,n)})(e,t,n),xe(e,{data:{}})}const rt=[l.BLOCKS.DOCUMENT,l.BLOCKS.PARAGRAPH,"text"],st=(e,t,n)=>{const i=((e,t)=>C(e=>L(e,t),e=>T(e,t))(e.validations))(e,t);return void 0===i||rt.concat(i).includes(n)},at=(e,t)=>st(e,"enabledNodeTypes",t),ct=(e,t)=>st(e,"enabledMarks",t);async function dt(e,t,n){return(await e.space.getEntries({content_type:t.sys.id,query:n})).items.map(n=>{const i=o.entityHelpers.getEntityDescription({contentType:t,entity:n,localeCode:e.field.locale,defaultLocaleCode:e.locales.default}),l=o.entityHelpers.getEntryTitle({entry:n,contentType:t,localeCode:e.field.locale,defaultLocaleCode:e.locales.default,defaultTitle:"Untitled"});return{contentTypeName:t.name,displayTitle:l,id:n.sys.contentType.sys.id,description:i,entry:n}})}function ut(e,t,n){if(null==e||!e.selection)return;const i=((e,t)=>({type:e,data:{target:{sys:{id:t.sys.id,type:"Link",linkType:t.sys.type}}},children:[{text:""}],isVoid:!0}))(t,n);e.selection&&Q(e,e.selection.focus.path)?we(e,i):xe(e,i),ot(e)}const mt=e=>{const[,t]=me(e),n=ce(e,t);Oe(e,n.focus.path),ze(e,"command-prompt",n),qe(e)},pt=e=>{const[,t]=me(e),n=ce(e,t);n.focus.offset-n.anchor.offset>1&&qe(e,{at:n.focus,distance:n.focus.offset-1,reverse:!0})};function Et(e){return{inlineAllowed:at(e.field,l.INLINES.EMBEDDED_ENTRY),entriesAllowed:at(e.field,l.BLOCKS.EMBEDDED_ENTRY),assetsAllowed:at(e.field,l.BLOCKS.EMBEDDED_ASSET)}}const yt={container:s.css({position:"absolute",zIndex:b.zIndexNotification,fontWeight:b.fontWeightNormal,fontStyle:"normal",fontFamily:b.fontStackPrimary,"ul, ol, dl":{listStyle:"none",marginLeft:0}}),menuPoper:s.css({zIndex:b.zIndexModal}),menuContent:s.css({width:"400px",maxHeight:"300px"}),menuList:s.css({overflow:"auto",maxHeight:"200px"}),menuItem:s.css({display:"block",width:"100%",background:"none",border:0,margin:0,outline:"none",fontSize:b.fontSizeM,lineHeight:b.lineHeightM,fontWeight:b.fontWeightNormal,position:"relative",textAlign:"left",padding:`${b.spacingXs} ${b.spacingM}`,wordBreak:"break-word",whiteSpace:"break-spaces",cursor:"pointer",hyphens:"auto",minWidth:"150px",textDecoration:"none",color:b.gray800,"&:hover":{backgroundColor:b.gray100},"&:disabled":{opacity:.5,cursor:"auto"}}),menuItemSelected:s.css({boxShadow:"inset "+b.glowPrimary,borderRadius:b.borderRadiusMedium}),menuDivider:s.css({border:"none",width:"100%",height:"1px",background:b.gray300,margin:b.spacingXs+" 0"}),menuHeader:s.css({zIndex:b.zIndexDefault,top:0,backgroundColor:b.gray100,padding:b.spacingM}),menuFooter:s.css({position:"sticky",bottom:0,backgroundColor:b.gray100,padding:b.spacingM}),footerList:s.css({listStyle:"none",color:b.gray600,fontSize:b.fontSizeM}),thumbnail:s.css({width:"30px",height:"30px",objectFit:"cover"})},ht=({commandGroup:e,selectedItem:n})=>t.createElement("section",{key:e.group},t.createElement(y.SectionHeading,{as:"h3",marginBottom:"spacingS",marginTop:"spacingS",marginLeft:"spacingM",marginRight:"spacingM"},e.group),e.commands.map(e=>t.createElement("button",{key:e.id,id:e.id,className:s.cx(yt.menuItem,{[yt.menuItemSelected]:e.id===n}),onClick:e.callback},e.label)),t.createElement("hr",{className:yt.menuDivider,"aria-orientation":"horizontal"})),ft=({command:e,selectedItem:n})=>t.createElement("button",{key:e.id,id:e.id,className:s.cx(yt.menuItem,{[yt.menuItemSelected]:e.id===n}),onClick:e.callback},t.createElement(y.Flex,{alignItems:"center",gap:"spacingS"},e.thumbnail&&t.createElement("img",{width:"30",height:"30",src:e.thumbnail,alt:"",className:yt.thumbnail}),t.createElement("span",null,e.label))),St=({command:e})=>t.createElement("button",{key:e.id,id:e.id,className:yt.menuItem},e.label),gt=({commandItems:e,selectedItem:n})=>t.createElement(t.Fragment,null,e.map(e=>"group"in e?t.createElement(ht,{commandGroup:e,selectedItem:n}):e.callback?t.createElement(ft,{command:e,selectedItem:n}):t.createElement(St,{command:e}))),Lt=({query:e,editor:n,textContainer:i})=>{const r=X(),s=t.useRef(null),a=E.usePopper(i,null==s?void 0:s.current,{placement:"bottom-start"}),c=((e,n,i)=>{const r=e.space.getCachedContentTypes(),{inlineAllowed:s,entriesAllowed:a,assetsAllowed:c}=function(e,t){const n=!Qe(t,l.BLOCKS.TABLE),{inlineAllowed:i,entriesAllowed:o,assetsAllowed:r}=Et(e);return{inlineAllowed:i,entriesAllowed:o&&n,assetsAllowed:r&&n}}(e,i),[d,u]=t.useState(()=>{const t=t=>({id:t.sys.id,label:"Embed "+t.name,callback:()=>{dt(e,t,n).then(e=>{pt(i),u(e.length?e.map(e=>({id:`${e.id}-${e.displayTitle.replace(/\W+/g,"-").toLowerCase()}`,label:e.displayTitle,callback:()=>{if(mt(i),i.selection){const t=i.selection;i.insertSoftBreak(),ut(i,l.BLOCKS.EMBEDDED_ENTRY,e.entry),Oe(i,t),i.tracking.onCommandPaletteAction("insert",{nodeType:l.BLOCKS.EMBEDDED_ENTRY})}}})):[{id:"no-results",label:"No results"}])})}}),d=t=>({id:t.sys.id+"-inline",label:`Embed ${t.name} - Inline`,callback:()=>{dt(e,t,n).then(e=>{pt(i),u(e.length?e.map(e=>({id:`${e.id}-${e.displayTitle.replace(/\W+/g,"-").toLowerCase()}`,label:e.displayTitle,callback:()=>{const t={type:l.INLINES.EMBEDDED_ENTRY,children:[{text:""}],data:{target:{sys:{id:e.id,type:"Link",linkType:"Entry"}}}};mt(i),we(i,t),i.insertText(""),i.tracking.onCommandPaletteAction("insert",{nodeType:l.INLINES.EMBEDDED_ENTRY})}})):[{id:"no-results",label:"No results"}])})}}),m=a||s?r.map(e=>({group:e.name,commands:a&&s?[t(e),d(e)]:a?[t(e)]:[d(e)]})):[];if(c){const t={group:"Assets",commands:[{id:"embed-asset",label:"Embed Asset",callback:()=>{(async function(e,t){return(await e.space.getAssets({query:t})).items.map(t=>({contentTypeName:"Asset",displayTitle:o.entityHelpers.getAssetTitle({asset:t,localeCode:e.field.locale,defaultLocaleCode:e.locales.default,defaultTitle:"Untitled"}),id:t.sys.id,entity:t,thumbnail:t.fields.file&&t.fields.file[e.field.locale]&&t.fields.file[e.field.locale].url+"?h=30"}))})(e,n).then(e=>{pt(i),u(e.length?e.map(e=>({id:`${e.id}-${e.displayTitle.replace(/\W+/g,"-").toLowerCase()}`,label:e.displayTitle,thumbnail:e.thumbnail,callback:()=>{if(mt(i),i.selection){const t=i.selection;i.insertSoftBreak(),ut(i,l.BLOCKS.EMBEDDED_ASSET,e.entity),Oe(i,t),i.tracking.onCommandPaletteAction("insert",{nodeType:l.BLOCKS.EMBEDDED_ASSET})}}})):[{id:"no-results",label:"No results"}])})}}]};return[...m,t]}return m});return n?d.reduce((e,t)=>("group"in t?t.commands.filter(e=>e.label.toLowerCase().includes(n.toLowerCase())).length>0&&e.push(t):t.label.toLowerCase().includes(n.toLowerCase())&&e.push(t),e),[]):d})(r,e,n),{selectedItem:d,isOpen:u}=((e,n)=>{const[i,o]=t.useState(()=>e.length?"group"in e[0]?e[0].commands[0].id:e[0].id:""),[l,r]=t.useState(e.length>0);return t.useEffect(()=>{if(!n.current)return;const t=Array.from(n.current.querySelectorAll("button")),l=t.find(e=>e.id===i),r=l?t.indexOf(l):0;function s(e){if(S("up",e)){if(e.preventDefault(),0===r)return;o(t[r-1].id),t[r-1].scrollIntoView({block:"nearest",inline:"start"})}else if(S("down",e)){if(e.preventDefault(),r===t.length-1)return;o(t[r+1].id),t[r+1].scrollIntoView({block:"nearest",inline:"start"})}else S("enter",e)&&(e.preventDefault(),l&&(o(""),l.click()))}return!l&&t.length&&(o(t[0].id),t[0].scrollIntoView({block:"nearest",inline:"start"})),e.length&&window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[e,n,i]),t.useEffect(()=>{const e=e=>{n.current&&!n.current.contains(e.target)&&r(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[n]),{selectedItem:i,isOpen:l}})(c,s);return c.length?t.createElement("div",{className:yt.container,tabIndex:-1,contentEditable:!1},t.createElement("div",{role:"alert"},t.createElement(y.ScreenReaderOnly,null,"Richtext commands. Currently focused item: ",d,". Press ",t.createElement("kbd",null,"enter")," to select, ",t.createElement("kbd",null,"arrows")," to navigate, ",t.createElement("kbd",null,"escape")," to close.")),t.createElement(h.Portal,null,t.createElement("div",{"aria-hidden":!0,ref:s,className:yt.menuPoper,style:a.styles.popper,...a.attributes.popper},t.createElement(y.Popover,{isOpen:u,usePortal:!1,autoFocus:!1},t.createElement(y.Popover.Trigger,null,t.createElement("span",null)),t.createElement(y.Popover.Content,{className:yt.menuContent,testId:"rich-text-commands"},t.createElement("header",{className:yt.menuHeader},t.createElement(y.SectionHeading,{marginBottom:"none"},"Richtext commands")),t.createElement("div",{className:yt.menuList,"data-test-id":"rich-text-commands-list"},t.createElement(gt,{commandItems:c,selectedItem:d})),t.createElement("footer",{className:yt.menuFooter},t.createElement(y.Stack,{as:"ul",margin:"none",padding:"none",spacing:"spacingS",className:yt.footerList},t.createElement("li",null,t.createElement("kbd",null,"↑"),t.createElement("kbd",null,"↓")," to navigate"),t.createElement("li",null,t.createElement("kbd",null,"↵")," to confirm"),t.createElement("li",null,t.createElement("kbd",null,"esc")," to close")))))))):null},Ct=e=>{const n=t.useMemo(()=>{return(t=e.text.text).startsWith("/")?t.slice(1):t;var t},[e.text.text]),i=e.editor,[o,l]=t.useState();return t.createElement("span",{ref:e=>{l(e)},...e.attributes},e.children,t.createElement(Lt,{query:n,editor:i,textContainer:o}))};function Tt(){const e=[l.BLOCKS.EMBEDDED_ENTRY,l.BLOCKS.EMBEDDED_ASSET,l.BLOCKS.HR,l.INLINES.EMBEDDED_ENTRY],t={TABLE:[l.INLINES.EMBEDDED_ENTRY]};return{key:"DragAndDropPlugin",handlers:{onDrop:n=>i=>{const[o]=Array.from(ie(n,{match:t=>e.includes(t.type)}));if(!o)return!1;const[l]=o;if(!i.nativeEvent.target)return!1;const r=function(e){const t=[];for(t.push(e);e.parentNode;)t.unshift(e.parentNode),e=e.parentNode;return t}(i.nativeEvent.target).some(e=>{var n;return!(!t[e.nodeName]||null!=(n=t[e.nodeName])&&n.includes(l.type))});return r||n.history.undos.push([]),r}}}}function bt(e){return function(t){const i=function(e){const t=U(void 0);return P(t)}(),o=n.useCallback(()=>null==i?void 0:i.tracking.onViewportAction("linkRendered"),[i]);return n.createElement(e,{...t,onEntityFetchComplete:o})}}const It=t.memo(e=>void 0===e.asset?t.createElement(y.AssetCard,{size:"default",isLoading:!0}):"failed"===e.asset?t.createElement(i.MissingEntityCard,{entityType:"Asset",isDisabled:e.isDisabled,onRemove:e.onRemove}):t.createElement(i.WrappedAssetCard,{getEntityScheduledActions:e.loadEntityScheduledActions,size:"small",isSelected:e.isSelected,isDisabled:e.isDisabled,localeCode:e.locale,defaultLocaleCode:e.sdk.locales.default,asset:e.asset,onEdit:e.onEdit,onRemove:e.isDisabled?void 0:e.onRemove,isClickable:!1}),a);function At(e){const{onEntityFetchComplete:n}=e,{data:o,status:l}=i.useEntity("Asset",e.assetId),{getEntityScheduledActions:r}=i.useEntityLoader(),s=t.useCallback(()=>r("Asset",e.assetId),[r,e.assetId]);return t.useEffect(()=>{"success"===l&&(null==n||n())},[n,l]),t.createElement(It,{asset:o,sdk:e.sdk,isDisabled:e.isDisabled,isSelected:e.isSelected,loadEntityScheduledActions:s,locale:e.locale,onEdit:e.onEdit,onRemove:e.onRemove})}It.displayName="InternalAssetCard";const kt=t.memo(e=>{const{entry:n,sdk:o,loadEntityScheduledActions:l}=e;if(void 0===n)return t.createElement(y.EntryCard,{isLoading:!0});if("failed"===n)return t.createElement(i.MissingEntityCard,{entityType:"Entry",isDisabled:e.isDisabled,onRemove:e.onRemove});const r=o.space.getCachedContentTypes().find(e=>e.sys.id===n.sys.contentType.sys.id);return t.createElement(i.WrappedEntryCard,{size:"default",getAsset:e.sdk.space.getAsset,getEntityScheduledActions:l,isSelected:e.isSelected,isDisabled:e.isDisabled,localeCode:e.locale,defaultLocaleCode:e.sdk.locales.default,contentType:r,entry:n,onEdit:e.onEdit,onRemove:e.isDisabled?void 0:e.onRemove,isClickable:!1})},a);kt.displayName="ReferenceCard";const Nt=e=>{const{entryId:n,onEntityFetchComplete:o}=e,{data:l,status:r}=i.useEntity("Entry",n),{getEntityScheduledActions:s}=i.useEntityLoader(),a=t.useCallback(()=>s("Entry",n),[s,n]);return t.useEffect(()=>{"success"===r&&(null==o||o())},[o,r]),t.createElement(kt,{entry:l,sdk:e.sdk,locale:e.locale,isDisabled:e.isDisabled,isSelected:e.isSelected,onEdit:e.onEdit,onRemove:e.onRemove,loadEntityScheduledActions:a})},vt={root:s.css({marginBottom:"1.25rem !important",display:"block"}),container:s.css({display:"inline-block",verticalAlign:"text-top",width:"100%"})};function Dt(e){const{attributes:t,children:i,element:o,onEntityFetchComplete:l}=e,r=d.useSelected(),s=Y(),a=X(),c=d.useReadOnly(),{id:u,linkType:m}=o.data.target.sys,p=n.useCallback(()=>("Asset"===m?a.navigator.openAsset:a.navigator.openEntry)(u,{slideIn:!0}),[a,u,m]),E=n.useCallback(()=>{if(!s)return;const e=Se(s,o);Ue(s,{at:e})},[s,o]);return n.createElement("div",{...t,className:vt.root,"data-entity-type":m,"data-entity-id":u,contentEditable:!!$e&&void 0,draggable:!!$e||void 0},n.createElement("div",{contentEditable:!$e&&void 0,draggable:!!$e||void 0,className:vt.container},"Entry"===m&&n.createElement(Nt,{sdk:a,entryId:u,locale:a.field.locale,isDisabled:c,isSelected:r,onRemove:E,onEdit:p,onEntityFetchComplete:l}),"Asset"===m&&n.createElement(At,{sdk:a,assetId:u,locale:a.field.locale,isDisabled:c,isSelected:r,onRemove:E,onEdit:p,onEntityFetchComplete:l})),i)}function Bt(e,t){return C(e=>L(e,"nodes"),e=>T(e,["nodes",t]),e=>L(e,"linkContentType"),e=>T(e,"linkContentType",[]))(e.validations)}function Ot(e,t){return{entityType:Rt(t),locale:e.locale||null,contentTypes:Bt(e,t)}}function Rt(e){const t=e.split("-");if(-1!==t.indexOf("entry"))return"Entry";if(-1!==t.indexOf("asset"))return"Asset";throw new Error(`RichText node type \`${e}\` has no associated \`entityType\``)}function Kt(e){const t=new Set;let n,i,o=!1;const l=()=>({wasClosed:o,isActive:!o&&i===n}),r=e.onSlideInNavigation(({oldSlideLevel:e,newSlideLevel:s})=>{void 0===n&&(n=e),i=s,s<n&&(o=!0,r(),t.clear()),l().isActive&&s!==e&&t.forEach(e=>e())});return{status:l,onActive:function(e){return o?c:(l().isActive&&e(),t.add(e),()=>t.delete(e))},unwatch:function(){r(),t.clear()}}}async function xt(e,t,n,i){i("openCreateEmbedDialog",{nodeType:e});const{field:o,dialogs:s}=t,a=Ot(o,e),c="Asset"===a.entityType?s.selectSingleAsset:s.selectSingleEntry,d={...a,withCreate:!0},u=Kt(t.navigator),m=await c(d);m?(function(e,t,n){if(null==e||!e.selection)return;const i=((e,t)=>({type:e,data:{target:{sys:{id:t.sys.id,type:"Link",linkType:t.sys.type}}},children:[{text:""}],isVoid:!0}))(t,n);e.selection&&Q(e,e.selection.focus.path)?we(e,i):xe(e,i)}(n,e,m),function(e){const t=me(e,{match:{type:[l.BLOCKS.EMBEDDED_ASSET,l.BLOCKS.EMBEDDED_ENTRY]}});if(!t)return;const n=t[1].length-1,i=((e,t)=>r.getLastNodeByLevel(e,t))(e,n),o=l.TEXT_CONTAINERS.includes((null==i?void 0:i[0].type)??"");0===n||o||Je(e),Ze(e)}(n),i("insert",{nodeType:e})):i("cancelCreateEmbedDialog",{nodeType:e}),u.onActive(()=>{u.unwatch(),ot(n)})}const wt=s.css({marginRight:"10px"});function Mt({isDisabled:e,nodeType:t,onClose:i}){const o=Y(),l=X(),r=function(e){const t=e.toLowerCase().split("-");if(t.includes("entry"))return"Entry";if(t.includes("asset"))return"Asset";throw new Error(`Node type \`${e}\` has no associated \`entityType\``)}(t);return n.createElement(y.Menu.Item,{disabled:e,className:"rich-text__"+t+"-list-item",onClick:async e=>{e.preventDefault(),o&&(i(),await xt(t,l,o,o.tracking.onToolbarAction))},testId:"toolbar-toggle-"+t},n.createElement(y.Flex,{alignItems:"center",flexDirection:"row"},n.createElement(y.Icon,{as:"Asset"===r?I.AssetIcon:I.EmbeddedEntryBlockIcon,className:"rich-text__embedded-entry-list-icon "+wt,variant:"secondary"}),n.createElement("span",null,r)))}const _t={[l.BLOCKS.EMBEDDED_ENTRY]:"Entry",[l.BLOCKS.EMBEDDED_ASSET]:"Asset"};function Pt(e,t){return(n,{options:{hotkey:i}})=>o=>{const[,l]=Xe(n,e);if(l){const e="Backspace"===o.key;("Delete"===o.key||e)&&(o.preventDefault(),Ue(n,{at:l}))}else i&&S(i,o)&&xt(e,t,n,n.tracking.onShortcutAction)}}const Ht=(e,t)=>n=>({key:e,type:e,isElement:!0,isVoid:!0,component:bt(Dt),options:{hotkey:t},handlers:{onKeyDown:Pt(e,n)},deserializeHtml:{rules:[{validAttribute:{"data-entity-type":_t[e]}}],withoutChildren:!0,getNode:t=>({type:e,children:[{text:""}],isVoid:!0,data:{target:{sys:{id:t.getAttribute("data-entity-id"),linkType:t.getAttribute("data-entity-type"),type:"Link"}}}})}}),zt=Ht(l.BLOCKS.EMBEDDED_ENTRY,"mod+shift+e"),Ft=Ht(l.BLOCKS.EMBEDDED_ASSET,"mod+shift+a"),{getEntryTitle:qt,getEntryStatus:Ut}=o.entityHelpers,Yt={scheduledIcon:s.css({verticalAlign:"text-bottom",marginRight:b.spacing2Xs})};function Gt(e){const{data:t,status:o}=i.useEntity("Entry",e.entryId),{getEntityScheduledActions:r}=i.useEntityLoader(),s=e.sdk.space.getCachedContentTypes(),{onEntityFetchComplete:a}=e,c=n.useMemo(()=>{if(t&&s)return s.find(e=>e.sys.id===t.sys.contentType.sys.id)},[s,t]);n.useEffect(()=>{"success"===o&&(null==a||a())},[o,a]);const d=c?c.name:"",u=n.useMemo(()=>qt({entry:t,contentType:c,localeCode:e.sdk.field.locale,defaultLocaleCode:e.sdk.locales.default,defaultTitle:"Untitled"}),[t,c,e.sdk.field.locale,e.sdk.locales.default]);if("error"===o)return n.createElement(y.InlineEntryCard,{title:"Entry missing or inaccessible",testId:l.INLINES.EMBEDDED_ENTRY,isSelected:e.isSelected});if("loading"===o)return n.createElement(y.InlineEntryCard,{isLoading:!0});const m=Ut(t.sys);return"deleted"===m?n.createElement(y.InlineEntryCard,{title:"Entry missing or inaccessible",testId:l.INLINES.EMBEDDED_ENTRY,isSelected:e.isSelected,actions:[n.createElement(y.MenuItem,{key:"remove",onClick:e.onRemove,testId:"delete"},"Remove")]}):n.createElement(y.InlineEntryCard,{testId:l.INLINES.EMBEDDED_ENTRY,isSelected:e.isSelected,title:`${d}: ${u}`,status:m,actions:[n.createElement(y.MenuItem,{key:"edit",onClick:e.onEdit},"Edit"),n.createElement(y.MenuItem,{key:"remove",onClick:e.onRemove,disabled:e.isDisabled,testId:"delete"},"Remove")]},n.createElement(i.ScheduledIconWithTooltip,{getEntityScheduledActions:()=>r("Entry",e.entryId),entityType:"Entry",entityId:t.sys.id},n.createElement(I.ClockIcon,{className:Yt.scheduledIcon,variant:"muted",testId:"scheduled-icon"})),n.createElement(y.Text,null,u))}function $t(e){return{type:l.INLINES.EMBEDDED_ENTRY,children:[{text:""}],data:{target:{sys:{id:e,type:"Link",linkType:"Entry"}}}}}const Wt={icon:s.css({marginRight:"10px"}),root:s.css({display:"inline-block",margin:"0 "+b.spacing2Xs,fontSize:"inherit",span:{userSelect:"none"}})};function Vt(e){const n=Y(),i=X(),o=d.useSelected(),{id:l}=e.element.data.target.sys,r=d.useReadOnly();return t.createElement("span",{...e.attributes,className:Wt.root,"data-embedded-entity-inline-id":l,contentEditable:!!$e&&void 0,draggable:!!$e||void 0},t.createElement("span",{contentEditable:!$e&&void 0,draggable:!!$e||void 0},t.createElement(Gt,{sdk:i,entryId:l,isSelected:o,isDisabled:r,onRemove:function(){if(!n)return;const t=Se(n,e.element);Ue(n,{at:t})},onEdit:function(){return i.navigator.openEntry(l,{slideIn:{waitForClose:!0}}).then(()=>{n&&ot(n)})},onEntityFetchComplete:e.onEntityFetchComplete})),e.children)}async function jt(e,t,n){n("openCreateEmbedDialog",{nodeType:l.INLINES.EMBEDDED_ENTRY});const i={...Ot(t.field,l.INLINES.EMBEDDED_ENTRY),withCreate:!0},o=Kt(t.navigator),r=await t.dialogs.selectSingleEntry(i);r?(we(e,$t(r.sys.id)),n("insert",{nodeType:l.INLINES.EMBEDDED_ENTRY})):n("cancelCreateEmbedDialog",{nodeType:l.INLINES.EMBEDDED_ENTRY}),o.onActive(()=>{o.unwatch(),ot(e)})}function Xt(e){const n=Y(),i=X();return t.createElement(y.Menu.Item,{disabled:e.isDisabled,className:"rich-text__entry-link-block-button",testId:"toolbar-toggle-"+l.INLINES.EMBEDDED_ENTRY,onClick:async function(t){t.preventDefault(),n&&(e.onClose(),await jt(n,i,n.tracking.onToolbarAction),Ze(n))}},t.createElement(y.Flex,{alignItems:"center",flexDirection:"row"},t.createElement(I.EmbeddedEntryInlineIcon,{variant:"secondary",className:"rich-text__embedded-entry-list-icon "+Wt.icon}),t.createElement("span",null,"Inline entry")))}function Qt(e){return{key:l.INLINES.EMBEDDED_ENTRY,type:l.INLINES.EMBEDDED_ENTRY,isElement:!0,isInline:!0,isVoid:!0,component:bt(Vt),options:{hotkey:"mod+shift+2"},handlers:{onKeyDown:Zt(e)},deserializeHtml:{rules:[{validAttribute:"data-embedded-entity-inline-id"}],withoutChildren:!0,getNode:e=>$t(e.getAttribute("data-embedded-entity-inline-id"))}}}function Zt(e){return function(t,{options:{hotkey:n}}){return function(i){t&&n&&S(n,i)&&jt(t,e,t.tracking.onShortcutAction)}}}const Jt={dropdown:{root:s.css`
|
|
2
|
+
font-weight: ${b.fontWeightDemiBold};
|
|
3
|
+
`,[l.BLOCKS.PARAGRAPH]:s.css`
|
|
4
|
+
font-size: ${b.fontSizeL};
|
|
5
|
+
`,[l.BLOCKS.HEADING_1]:s.css`
|
|
6
|
+
font-size: 1.625rem;
|
|
7
|
+
`,[l.BLOCKS.HEADING_2]:s.css`
|
|
8
|
+
font-size: 1.4375rem;
|
|
9
|
+
`,[l.BLOCKS.HEADING_3]:s.css`
|
|
10
|
+
font-size: 1.25rem;
|
|
11
|
+
`,[l.BLOCKS.HEADING_4]:s.css`
|
|
12
|
+
font-size: 1.125rem;
|
|
13
|
+
`,[l.BLOCKS.HEADING_5]:s.css`
|
|
14
|
+
font-size: 1rem;
|
|
15
|
+
`,[l.BLOCKS.HEADING_6]:s.css`
|
|
16
|
+
font-size: 0.875rem;
|
|
17
|
+
`}},en={[l.BLOCKS.PARAGRAPH]:"Normal text",[l.BLOCKS.HEADING_1]:"Heading 1",[l.BLOCKS.HEADING_2]:"Heading 2",[l.BLOCKS.HEADING_3]:"Heading 3",[l.BLOCKS.HEADING_4]:"Heading 4",[l.BLOCKS.HEADING_5]:"Heading 5",[l.BLOCKS.HEADING_6]:"Heading 6"};function tn(e){const n=X(),i=Y(),[o,r]=t.useState(!1),[a,c]=t.useState(l.BLOCKS.PARAGRAPH);t.useEffect(()=>{if(null==i||!i.selection)return;const[e]=function(e){return e.selection?Array.from(ie(e,{at:e.selection,match:e=>fe(e)})).flat():[]}(i),t=e.type;c(en[t]?t:l.BLOCKS.PARAGRAPH)},[null==i?void 0:i.operations,null==i?void 0:i.selection]);const[d,u]=t.useMemo(()=>{const e=Object.fromEntries(Object.keys(en).map(e=>[e,at(n.field,e)]));return[e,Object.values(e).filter(Boolean).length>0]},[n.field]);return i?t.createElement(y.Menu,{isOpen:o,onClose:()=>r(!1)},t.createElement(y.Menu.Trigger,null,t.createElement(y.Button,{size:"small",testId:"toolbar-heading-toggle",variant:"transparent",endIcon:t.createElement(I.ChevronDownIcon,null),isDisabled:e.isDisabled,onClick:()=>u&&r(!o)},en[a])),t.createElement(y.Menu.List,{testId:"dropdown-heading-list"}," ",Object.keys(en).map(n=>{return d[n]&&t.createElement(y.Menu.Item,{key:n,isInitiallyFocused:a===n,onClick:(o=n,e=>{if(e.preventDefault(),null==i||!i.selection)return;c(o),r(!1);const t=i.onChange;i.onChange=(...e)=>{ot(i),i.onChange=t,t(...e)};const n=Ve(i,o);i.tracking.onToolbarAction(n?"remove":"insert",{nodeType:o}),lt(i,{activeType:o,inactiveType:o})}),testId:"dropdown-option-"+n,disabled:e.isDisabled},t.createElement("span",{className:s.cx(Jt.dropdown.root,Jt.dropdown[n])},en[n]));var o}).filter(Boolean))):null}const nn=(e,[,t])=>{Ue(e,{at:t})},on=(e,t)=>{const n=t[1],i=function(e,t){return function(e,t,n){return Array.from(ie(e,{match:{type:l.TEXT_CONTAINERS},at:t,mode:"lowest"})).map(([e])=>e)}(e,t).map(e=>({...e,type:l.BLOCKS.PARAGRAPH}))}(e,n);nn(e,t),we(e,i,{at:n})},ln=(e,[,t])=>{Pe(e,{at:t})},rn=e=>(t,[,n])=>{He(t,{type:e,data:{},children:[]},{at:n})},sn=(e,[,t])=>{_e(e,{at:t})},an={dropdown:{root:s.css`
|
|
18
|
+
font-weight: ${b.fontWeightDemiBold};
|
|
19
|
+
`,[l.BLOCKS.PARAGRAPH]:s.css`
|
|
20
|
+
font-size: ${b.fontSizeL};
|
|
21
|
+
`,[l.BLOCKS.HEADING_1]:s.css`
|
|
22
|
+
font-size: 1.625rem;
|
|
23
|
+
`,[l.BLOCKS.HEADING_2]:s.css`
|
|
24
|
+
font-size: 1.4375rem;
|
|
25
|
+
`,[l.BLOCKS.HEADING_3]:s.css`
|
|
26
|
+
font-size: 1.25rem;
|
|
27
|
+
`,[l.BLOCKS.HEADING_4]:s.css`
|
|
28
|
+
font-size: 1.125rem;
|
|
29
|
+
`,[l.BLOCKS.HEADING_5]:s.css`
|
|
30
|
+
font-size: 1rem;
|
|
31
|
+
`,[l.BLOCKS.HEADING_6]:s.css`
|
|
32
|
+
font-size: 0.875rem;
|
|
33
|
+
`},headings:{root:s.css`
|
|
34
|
+
font-weight: ${b.fontWeightMedium};
|
|
35
|
+
line-height: 1.3;
|
|
36
|
+
margin: 0 0 ${b.spacingS};
|
|
37
|
+
`,[l.BLOCKS.HEADING_1]:s.css`
|
|
38
|
+
font-size: 1.875rem;
|
|
39
|
+
`,[l.BLOCKS.HEADING_2]:s.css`
|
|
40
|
+
font-size: 1.5625rem;
|
|
41
|
+
`,[l.BLOCKS.HEADING_3]:s.css`
|
|
42
|
+
font-size: 1.375rem;
|
|
43
|
+
`,[l.BLOCKS.HEADING_4]:s.css`
|
|
44
|
+
font-size: 1.25rem;
|
|
45
|
+
`,[l.BLOCKS.HEADING_5]:s.css`
|
|
46
|
+
font-size: 1.125rem;
|
|
47
|
+
`,[l.BLOCKS.HEADING_6]:s.css`
|
|
48
|
+
font-size: 1rem;
|
|
49
|
+
`}};function cn(e,n){return function(i){return t.createElement(e,{...i.attributes,className:s.cx(an.headings.root,an.headings[n])},i.children)}}const dn={[l.BLOCKS.HEADING_1]:t.memo(cn("h1",l.BLOCKS.HEADING_1)),[l.BLOCKS.HEADING_2]:t.memo(cn("h2",l.BLOCKS.HEADING_2)),[l.BLOCKS.HEADING_3]:t.memo(cn("h3",l.BLOCKS.HEADING_3)),[l.BLOCKS.HEADING_4]:t.memo(cn("h4",l.BLOCKS.HEADING_4)),[l.BLOCKS.HEADING_5]:t.memo(cn("h5",l.BLOCKS.HEADING_5)),[l.BLOCKS.HEADING_6]:t.memo(cn("h6",l.BLOCKS.HEADING_6))},un={button:s.css({height:"30px",width:"30px",marginLeft:b.spacing2Xs,marginRight:b.spacing2Xs}),tooltip:s.css({zIndex:Number(b.zIndexTooltip)})};function mn(e){const{title:t,testId:i,isActive:o,children:l,className:r,isDisabled:a=!1}=e,c=n.createElement(y.Button,{className:s.cx(un.button,r),isDisabled:a,startIcon:l,onClick:t=>{t.preventDefault(),e.onClick()},testId:i,variant:o?"secondary":"transparent",size:"small"});return t?n.createElement(y.Tooltip,{className:un.tooltip,placement:"bottom",content:t},c):c}const pn={container:s.css`
|
|
50
|
+
margin: 0 0 ${b.spacingL};
|
|
51
|
+
`,hr:s.css`
|
|
52
|
+
margin: 0;
|
|
53
|
+
height: ${b.spacingM};
|
|
54
|
+
background: transparent;
|
|
55
|
+
position: relative;
|
|
56
|
+
border: 0;
|
|
57
|
+
user-select: none;
|
|
58
|
+
&:hover {
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
}
|
|
61
|
+
&::after {
|
|
62
|
+
content: '';
|
|
63
|
+
position: absolute;
|
|
64
|
+
width: 100%;
|
|
65
|
+
height: 1px;
|
|
66
|
+
background: ${b.gray300};
|
|
67
|
+
top: 50%;
|
|
68
|
+
}
|
|
69
|
+
`,hrSelected:s.css`
|
|
70
|
+
&::after {
|
|
71
|
+
background: ${b.colorPrimary};
|
|
72
|
+
-webkit-box-shadow: 0px 0px 5px ${b.colorPrimary};
|
|
73
|
+
box-shadow: 0px 0px 5px ${b.colorPrimary};
|
|
74
|
+
}
|
|
75
|
+
`};function En(e){return t=>{if(!e)return;const[,n]=Xe(e,l.BLOCKS.HR);if(n){const i="Delete"===t.key;("Backspace"===t.key||i)&&(t.preventDefault(),Ue(e,{at:n}))}}}function yn(e){const n=Y();return n?t.createElement(mn,{title:"HR",isDisabled:e.isDisabled,onClick:function(){if(null==n||!n.selection)return;const e={type:l.BLOCKS.HR,data:{},children:[{text:""}],isVoid:!0};Q(n,n.selection.focus.path)?we(n,e):xe(n,e),function(e){Re(e,{distance:1,unit:"line"})}(n),ot(n)},testId:"hr-toolbar-button",isActive:Ve(n,l.BLOCKS.HR)},t.createElement(I.HorizontalRuleIcon,null)):null}function hn(e){const n=d.useSelected(),i=d.useFocused();return t.createElement("div",{...e.attributes,className:pn.container,"data-void-element":l.BLOCKS.HR},t.createElement("div",{draggable:!0,contentEditable:!1},t.createElement("hr",{className:s.cx(pn.hr,n&&i?pn.hrSelected:void 0)})),e.children)}const fn={removeSelectionLabel:s.css`
|
|
76
|
+
margin-left: ${b.spacingS};
|
|
77
|
+
`},Sn={[l.INLINES.ENTRY_HYPERLINK]:"Entry",[l.INLINES.ASSET_HYPERLINK]:"Asset"},gn={[l.INLINES.HYPERLINK]:"URL",[l.INLINES.ENTRY_HYPERLINK]:"Entry",[l.INLINES.ASSET_HYPERLINK]:"Asset"};function Ln(e){const n=We.filter(t=>at(e.sdk.field,t)),[o]=n,[r,s]=t.useState(e.linkText??""),[a,c]=t.useState(e.linkType??o),[d,u]=t.useState(e.linkTarget??""),[m,p]=t.useState(e.linkEntity??null);function E(e){const{id:t,type:n}=e.sys;return{sys:{id:t,type:"Link",linkType:n}}}return t.createElement(i.EntityProvider,{sdk:e.sdk},t.createElement(t.Fragment,null,t.createElement(y.ModalContent,null,t.createElement(y.Form,null,!e.linkType&&t.createElement(y.FormControl,{id:"link-text",isRequired:!0},t.createElement(y.FormControl.Label,null,"Link text"),t.createElement(y.TextInput,{testId:"link-text-input",name:"link-text",value:r,onChange:e=>s(e.target.value)})),n.length>1&&t.createElement(y.FormControl,{id:"link-type"},t.createElement(y.FormControl.Label,null,"Link type"),t.createElement(y.Select,{value:a,onChange:e=>c(e.target.value),testId:"link-type-input",isDisabled:e.readonly},n.map(e=>t.createElement(y.Select.Option,{key:e,value:e},gn[e])))),a===l.INLINES.HYPERLINK&&t.createElement(y.FormControl,{id:"linkTarget",isRequired:!0},t.createElement(y.FormControl.Label,null,"Link target"),t.createElement(y.TextInput,{name:"linkTarget",value:d,onChange:e=>{p(null),u(e.target.value)},testId:"link-target-input",isDisabled:e.readonly}),t.createElement(y.FormControl.HelpText,null,"A protocol may be required, e.g. https://")),a!==l.INLINES.HYPERLINK&&t.createElement("div",null,t.createElement(y.FormLabel,{isRequired:!0,htmlFor:""},"Link target"," "),m&&m.sys.linkType===Sn[a]?t.createElement(t.Fragment,null,!e.readonly&&t.createElement(y.TextLink,{testId:"entity-selection-link",onClick:function(e){e.preventDefault(),p(null)},className:fn.removeSelectionLabel},"Remove selection"),t.createElement("div",null,a===l.INLINES.ENTRY_HYPERLINK&&t.createElement(Nt,{sdk:e.sdk,locale:e.sdk.field.locale,entryId:m.sys.id,isDisabled:!0,isSelected:!1}),a===l.INLINES.ASSET_HYPERLINK&&t.createElement(At,{sdk:e.sdk,locale:e.sdk.field.locale,assetId:m.sys.id,isDisabled:!0,isSelected:!1}))):t.createElement("div",null,a===l.INLINES.ENTRY_HYPERLINK&&t.createElement(y.TextLink,{testId:"entity-selection-link",onClick:async function(){const t={locale:e.sdk.field.locale,contentTypes:Bt(e.sdk.field,l.INLINES.ENTRY_HYPERLINK)},n=await e.sdk.dialogs.selectSingleEntry(t);u(""),p(E(n))}},"Select entry"),a===l.INLINES.ASSET_HYPERLINK&&t.createElement(y.TextLink,{testId:"entity-selection-link",onClick:async function(){const t={locale:e.sdk.field.locale},n=await e.sdk.dialogs.selectSingleAsset(t);u(""),p(E(n))}},"Select asset"))))),t.createElement(y.ModalControls,null,t.createElement(y.Button,{type:"button",onClick:()=>e.onClose(null),variant:"secondary",testId:"cancel-cta",size:"small"},"Cancel"),t.createElement(y.Button,{type:"submit",variant:"positive",size:"small",isDisabled:e.readonly||!(a===l.INLINES.HYPERLINK?r&&d:Object.keys(Sn).includes(a)&&r&&m),onClick:function(t){t.preventDefault(),e.onClose({linkText:r,linkType:a,linkTarget:d,linkEntity:m})},testId:"confirm-cta"},e.linkType?"Update":"Insert"))))}async function Cn(e,n,i,l){const s=(e=>r.isEditorReadOnly(e))(e),a=e.selection?{...e.selection}:void 0;if(!l&&!a)return;let c,d,u,m;const[p,E]=Xe(e,We,l);p&&E&&(c=p.type,d=Q(e,E),u=p.data.uri||"",m=p.data.target);const y=l??a,h=d||(e.selection?Q(e,e.selection):""),f=Boolean(p&&E);i(f?"openEditHyperlinkDialog":"openCreateHyperlinkDialog");const S=await o.ModalDialogLauncher.openDialog({title:f?"Edit hyperlink":"Insert hyperlink",width:"large",shouldCloseOnEscapePress:!0,shouldCloseOnOverlayClick:!0,allowHeightOverflow:!0},({onClose:e})=>t.createElement(Ln,{linkTarget:u,linkText:h,linkType:c,linkEntity:m,onClose:e,sdk:n,readonly:s}));if(Oe(e,y),!S)return ot(e),void i(f?"cancelEditHyperlinkDialog":"cancelCreateHyperlinkDialog");const{linkText:g,linkTarget:L,linkType:C,linkEntity:T}=S;G(e,()=>{!function(e,t){e.selection&&function(e,{text:t,url:n,target:i,type:o,path:l}){et(e)&&!l&&tt(e);const{selection:r}=e,s=r&&ae(r),a={type:o,data:{},children:s?[{text:t}]:[]};n&&(a.data={uri:n}),i&&(a.data={target:i}),l?(xe(e,a,{at:l}),Fe(e,t,{at:l}),Oe(e,l)):s?we(e,a):(He(e,a,{split:!0}),qe(e),Fe(e,t),Ke(e,{edge:"end"}))}(e,t)}(e,{text:g,url:L,type:C,target:T,path:E})}),i(f?"edit":"insert",{nodeType:C,linkType:(null==T?void 0:T.sys.linkType)??"uri"}),ot(e)}function Tn(e){const n=Y(),i=!(!n||!et(n)),o=X();return n?t.createElement(mn,{title:"Hyperlink",testId:"hyperlink-toolbar-button",onClick:async function(){n&&(i?(tt(n),n.tracking.onToolbarAction("unlinkHyperlinks")):Cn(n,o,n.tracking.onToolbarAction))},isActive:i,isDisabled:e.isDisabled},t.createElement(I.LinkIcon,null)):null}const bn=(e,t)=>{const[n,i]=t;return!r.isAncestorEmpty(e,n)&&""!==Q(e,i).trim()},In={hyperlinkWrapper:s.css({display:"inline",position:"static",a:{fontSize:"inherit !important"}}),hyperlink:s.css({fontSize:"inherit !important",display:"inline !important","&:hover":{fill:b.gray900},"&:focus":{fill:b.gray900}})};function An(e){const n=Y(),l=X(),{target:r}=e.element.data,{onEntityFetchComplete:s}=e,a=function(e){const n=function({sdk:e,target:n,onEntityFetchComplete:i}){const[l,r]=t.useState({type:"loading"});return t.useEffect(()=>{var t,l;n&&async function({sdk:e,entityId:t,entityType:n,localeCode:i,defaultLocaleCode:l}){let r;const s="Entry"===n?e.space.getEntry:e.space.getAsset,a=await s(t);if(a.sys.contentType){const t=a.sys.contentType.sys.id;r=e.space.getCachedContentTypes().find(e=>e.sys.id===t)}const c="Entry"===n?o.entityHelpers.getEntryTitle({entry:a,contentType:r,localeCode:i,defaultLocaleCode:l,defaultTitle:"Untitled"}):o.entityHelpers.getAssetTitle({asset:a,localeCode:i,defaultLocaleCode:l,defaultTitle:"Untitled"}),d=o.entityHelpers.getEntityDescription({entity:a,contentType:r,localeCode:i,defaultLocaleCode:l});return{jobs:await e.space.getEntityScheduledActions(n,t),entity:a,entityTitle:c,entityDescription:d,entityStatus:o.entityHelpers.getEntryStatus(a.sys),contentTypeName:r?r.name:""}}({sdk:e,entityId:null==n||null==(t=n.sys)?void 0:t.id,entityType:null==n||null==(l=n.sys)?void 0:l.linkType,localeCode:e.field.locale,defaultLocaleCode:e.locales.default}).then(e=>{r({type:"success",data:e})}).catch(e=>{console.log(e),r({type:"error",error:e})}).finally(()=>{null==i||i()})},[e,n,i]),l}(e),{linkType:l}=e.target.sys;return"loading"===n.type?`Loading ${l.toLowerCase()}...`:"error"===n.type?l+" missing or inaccessible":function(e){if(!e)return"";const{entityTitle:t,contentTypeName:n,entityStatus:o,jobs:l}=e;var r;return`${n||"Asset"} "${("string"==typeof(r=t)&&r.length>60?r&&r.substr(0,61).replace(/(\s+\S(?=\S)|\s*)\.?.$/,"…"):r)||"Untitled"}", ${o} ${l.length>0?i.getScheduleTooltipContent({job:l[0],jobsCount:l.length}):""}`}(n.data)}({target:r,sdk:l,onEntityFetchComplete:s});return r?t.createElement(y.Tooltip,{content:a,targetWrapperClassName:In.hyperlinkWrapper,placement:"bottom",maxWidth:"auto"},t.createElement(y.TextLink,{as:"a",onClick:function(e){if(e.preventDefault(),e.stopPropagation(),!n)return;const t=W(n,[e.target,0]);t&&Cn(n,l,n.tracking.onViewportAction,t.path)},className:In.hyperlink,"data-link-type":r.sys.linkType,"data-link-id":r.sys.id},e.children)):null}function kn(e){const n=Y(),i=X(),{uri:o}=e.element.data;return t.createElement(y.Tooltip,{content:o,targetWrapperClassName:In.hyperlinkWrapper,placement:"bottom",maxWidth:"auto"},t.createElement(y.TextLink,{as:"a",href:o,rel:"noopener noreferrer",onClick:function(e){if(e.preventDefault(),e.stopPropagation(),!n)return;const t=W(n,[e.target,0],{exactMatch:!1,suppressThrow:!1});Cn(n,i,n.tracking.onViewportAction,null==t?void 0:t.path)},className:In.hyperlink},e.children))}const Nn=e=>"A"===e.nodeName&&"Entry"===e.getAttribute("data-link-type"),vn=e=>"A"===e.nodeName&&"Asset"===e.getAttribute("data-link-type"),Dn=e=>(t,{options:{hotkey:n}})=>i=>{t.selection&&(n&&!S(n,i)||(et(t)?(tt(t),t.tracking.onShortcutAction("unlinkHyperlinks")):Cn(t,e,t.tracking.onShortcutAction)))},Bn=e=>(t,n)=>({type:e,children:n.children,data:e===l.INLINES.HYPERLINK?{uri:t.getAttribute("href")}:{target:{sys:{id:t.getAttribute("data-link-id"),linkType:t.getAttribute("data-link-type"),type:"Link"}}}}),On=e=>{const t={isElement:!0,isInline:!0};return{key:"HyperlinkPlugin",options:{hotkey:"mod+k"},handlers:{onKeyDown:Dn(e)},plugins:[{...t,key:l.INLINES.HYPERLINK,type:l.INLINES.HYPERLINK,component:kn,deserializeHtml:{rules:[{validNodeName:["A"]}],query:e=>{return!("A"!==(t=e).nodeName||!t.getAttribute("href")||"#"===t.getAttribute("href")||Nn(e)||vn(e));var t},getNode:Bn(l.INLINES.HYPERLINK)}},{...t,key:l.INLINES.ENTRY_HYPERLINK,type:l.INLINES.ENTRY_HYPERLINK,component:bt(An),deserializeHtml:{rules:[{validNodeName:["A"]}],query:e=>Nn(e),getNode:Bn(l.INLINES.ENTRY_HYPERLINK)}},{...t,key:l.INLINES.ASSET_HYPERLINK,type:l.INLINES.ASSET_HYPERLINK,component:bt(An),deserializeHtml:{rules:[{validNodeName:["A"]}],query:e=>vn(e),getNode:Bn(l.INLINES.ASSET_HYPERLINK)}}],normalizer:[{match:{type:[l.INLINES.HYPERLINK,l.INLINES.ASSET_HYPERLINK,l.INLINES.ENTRY_HYPERLINK]},validNode:bn,transform:nn}]}},Rn=s.css`
|
|
78
|
+
padding: 0;
|
|
79
|
+
margin: 0 0 1.25rem 1.25rem;
|
|
80
|
+
|
|
81
|
+
div:first-child {
|
|
82
|
+
margin: 0;
|
|
83
|
+
line-height: ${b.lineHeightDefault};
|
|
84
|
+
}
|
|
85
|
+
`,Kn={[l.BLOCKS.UL_LIST]:s.css`
|
|
86
|
+
list-style-type: disc;
|
|
87
|
+
ul {
|
|
88
|
+
list-style-type: circle;
|
|
89
|
+
ul {
|
|
90
|
+
list-style-type: square;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
`,[l.BLOCKS.OL_LIST]:s.css`
|
|
94
|
+
list-style-type: decimal;
|
|
95
|
+
ol {
|
|
96
|
+
list-style-type: upper-alpha;
|
|
97
|
+
ol {
|
|
98
|
+
list-style-type: lower-roman;
|
|
99
|
+
ol {
|
|
100
|
+
list-style-type: lower-alpha;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
`};function xn(e,n){return function(i){return t.createElement(e,{...i.attributes,className:s.cx(Rn,Kn[n])},i.children)}}const wn=xn("ul",l.BLOCKS.UL_LIST),Mn=xn("ol",l.BLOCKS.OL_LIST),_n=s.css`
|
|
105
|
+
margin: 0;
|
|
106
|
+
list-style: inherit;
|
|
107
|
+
margin-top: ${b.spacingXs};
|
|
108
|
+
|
|
109
|
+
ol,
|
|
110
|
+
ul {
|
|
111
|
+
margin: 0 0 0 ${b.spacingL};
|
|
112
|
+
}
|
|
113
|
+
`;function Pn(e){return t.createElement("li",{...e.attributes,className:_n},e.children)}const Hn=r.ELEMENT_DEFAULT;function zn(e,t){return ie(e,{at:t,match:(e,t)=>fe(e)&&e.type===l.BLOCKS.LIST_ITEM&&t.length>=2}).next().done}const Fn=(e,{at:t}={})=>{G(e,()=>{do{_e(e,{at:t,match:e=>fe(e)&&e.type===l.BLOCKS.LIST_ITEM,mode:"lowest"})}while(!zn(e,t));Pe(e,{at:t,match:{type:l.BLOCKS.LIST_ITEM},split:!1})})},qn=[l.BLOCKS.UL_LIST,l.BLOCKS.OL_LIST],Un=(e,{type:t})=>G(e,()=>{var n;if(e.selection)if(ae(e.selection)||!((e,t)=>r.isRangeAcrossBlocks(e,void 0))(e)){const n=A.getListItemEntry(e);if(n){const{list:i}=n;i[0].type!==t?xe(e,{type:t},{at:e.selection,match:e=>qn.includes(e.type),mode:"lowest"}):Fn(e)}else{He(e,{type:t,children:[],data:{}});const n=[...ie(e,{match:{type:De(e,Hn)}})],i={type:l.BLOCKS.LIST_ITEM,children:[],data:{}};for(const[,t]of n)He(e,i,{at:t})}}else{const[r,s]=de(e.selection),a=pe(e,r.path,s.path);if(qn.includes(a[0].type)||a[0].type===l.BLOCKS.LIST_ITEM){let r=a[0].type;var i,o;if(a[0].type===l.BLOCKS.LIST_ITEM&&(r=null==(i=oe(e,a[1]))||null==(o=i[0])?void 0:o.type),r!==t){const i=Ee(e,{at:(n=e.selection,g.Range.start(n)),match:{type:qn},mode:"lowest"}),o=Ee(e,{at:ue(e.selection),match:{type:qn},mode:"lowest"});if(!i||!o)return;const l=Math.min(i[1].length,o[1].length);xe(e,{type:t},{at:e.selection,match:(e,t)=>qn.includes(e.type)&&t.length>=l,mode:"all"})}else Fn(e)}else{const n=a[1].length;Array.from(ie(e,{mode:"all"})).filter(([,e])=>e.length===n+1).reverse().forEach(n=>{qn.includes(n[0].type)?xe(e,{type:t},{at:n[1]}):(xe(e,{type:De(e,A.ELEMENT_LIC)},{at:n[1]}),He(e,{type:l.BLOCKS.LIST_ITEM,children:[],data:{}},{at:n[1]}),He(e,{type:t,children:[],data:{}},{at:n[1]}))})}}}),Yn=(e,{type:t,options:{hotkey:n}})=>i=>{if("Tab"===i.key&&e.selection&&me(e,{at:e.selection,match:{type:t}}))return i.preventDefault(),void((e,{increase:t=!0,at:n=e.selection??void 0}={})=>{const i=ie(e,{at:n,match:{type:De(e,A.ELEMENT_LIC)}}),o=Array.from(i);if(!o.length)return;const l=[],s=[];o.forEach(t=>{const n=t[1],i=Ce(n);l.some(e=>{const t=Ce(e);return ge(t,i)})||(l.push(n),s.push(((e,t)=>r.createPathRef(e,t))(e,n)))});const a=t?s:s.reverse();G(e,()=>{a.forEach(n=>{const i=n.unref();if(!i)return;const o=A.getListItemEntry(e,{at:i});o&&(t?((e,{list:t,listItem:n})=>{const[i]=t,[,o]=n;let l;try{l=be(o)}catch(e){return}const s=ne(e,l);if(s){const[,t]=s,n=Array.from((a=e,c=t,r.getNodeChildren(a,c,void 0))).find(([t,n])=>((e,t,n)=>r.match(e,t,n))(t,n,{type:A.getListTypes(e)})),l=Te(Ie(n??s));G(e,()=>{n||He(e,{type:i.type,children:[],data:{}},{at:o}),Ye(e,{at:o,to:l})})}var a,c})(e,o):A.isListNested(e,o.list[1])&&A.moveListItemUp(e,o))})})})(e,{increase:!i.shiftKey});if(!n)return;const o=k(n);for(const n of o)S(n)(i)&&Un(e,{type:t})},Gn=e=>[l.BLOCKS.OL_LIST,l.BLOCKS.UL_LIST].includes(e.type),$n=(e,[,t])=>{const[n]=oe(e,t)||[];return Gn(n)},Wn=(e,[,t])=>{const[n]=((e,t)=>me(e,{at:t,mode:"lowest",match:Gn})||[])(e,t);He(e,{type:(null==n?void 0:n.type)||l.BLOCKS.UL_LIST,children:[],data:{}},{at:t})},Vn=(e,t)=>0!==re(t).length,jn=(e,[t])=>{if(1===t.children.length){const e=t.children[0];return!Z(e)&&!Gn(e)}return!0},Xn=(e,[,t])=>{we(e,[{type:l.BLOCKS.PARAGRAPH,data:{},children:[{text:""}]}],{at:t.concat([0])})},Qn=(e,t)=>{const[n,i]=t;Ue(e,{at:i}),we(e,n.children[0].children,{at:i})},Zn=(e,t)=>{const{selection:n}=e;if(!n)return!1;if(r.isExpanded(n)){const[i,o]=de(n);if(pe(e,i.path,o.path)[0].type===t)return!0}const i=te(e,{match:{type:[l.BLOCKS.OL_LIST,l.BLOCKS.UL_LIST]},mode:"lowest"});return(null==i?void 0:i[0].type)===t},Jn=e=>[l.BLOCKS.UL_LIST,l.BLOCKS.OL_LIST].includes(e.type),ei=l.LIST_ITEM_BLOCKS,ti=e=>{const{deleteBackward:t,deleteForward:n,deleteFragment:i}=e;return e.deleteBackward=n=>{((e,t)=>{const n=A.getListItemEntry(e,{});let i=!1;if(n){const{list:o,listItem:s}=n;ee(e,{match:e=>e.type===l.BLOCKS.LIST_ITEM})&&G(e,()=>{if(i=A.removeFirstListItem(e,{list:o,listItem:s}),!i&&(i=A.removeListItem(e,{list:o,listItem:s}),!i)){if(r.isFirstChild(s[1])&&!A.isListNested(e,o[1]))return p.onKeyDownResetNode(e,r.mockPlugin({options:{rules:[{types:[l.BLOCKS.LIST_ITEM],defaultType:l.BLOCKS.PARAGRAPH,hotkey:"backspace",predicate:()=>ee(e),onReset:e=>Fn(e)}]}}))(p.SIMULATE_BACKSPACE),void(i=!0);((e,t)=>{r.deleteFragment(e,t)})(e,{unit:t,reverse:!0}),i=!0}})}return i})(e,n)||t(n)},e.deleteForward=t=>{A.deleteForwardList(e)||n(t)},e.deleteFragment=()=>{A.deleteFragmentList(e)||i()},e.insertBreak=(e=>{const{insertBreak:t}=e;return()=>{(e=>{if(!e.selection)return!1;const t=A.getListItemEntry(e,{});let n;if(t){const{list:i,listItem:o}=t,s=o[0].children[0];if(r.isBlockAboveEmpty(e)&&1===o[0].children.length&&l.TEXT_CONTAINERS.includes(s.type)&&(n=A.moveListItemUp(e,{list:i,listItem:o}),n))return!0}return!!p.onKeyDownResetNode(e,r.mockPlugin({options:{rules:[{types:[r.getPluginType(e,A.ELEMENT_LI)],defaultType:r.getPluginType(e,r.ELEMENT_DEFAULT),predicate:()=>!n&&r.isBlockAboveEmpty(e),onReset:e=>A.unwrapList(e)}]}}))(p.SIMULATE_BACKSPACE)||!(n||!(e=>{if(!e.selection)return!1;const t=me(e,{match:{type:l.TEXT_CONTAINERS}});if(!t)return!1;const[,n]=t,i=oe(e,n);if(!i)return!1;const[o,s]=i;return o.type===l.BLOCKS.LIST_ITEM&&(G(e,()=>{if(!e.selection)return;const t=ee(e),i=((e,t)=>r.isSelectionAtBlockEnd(e,void 0))(e),o=t&&Ae(n),a=!t&&!i;a&&Me(e);const c=o?s:Te(s);we(e,((e,t=!1)=>{let n=[];if(t){const t=(e=>r.getMarks(e))(e)||{};n=[{type:l.BLOCKS.PARAGRAPH,data:{},children:[{text:"",...t}]}]}return{type:l.BLOCKS.LIST_ITEM,data:{},children:n}})(e,!a),{at:c});const d=t?n:Te(n),u=d[d.length-1]||0,m=c.concat([a?0:1]);o||((e,t)=>{r.moveChildren(e,t)})(e,{at:s,to:m,fromStartIndex:u}),Oe(e,c),Ke(e,{edge:"start"})}),!0)})(e))})(e)||t()}})(e),e.insertFragment=(e=>{const{insertFragment:t}=e;return n=>{if(!e.selection)return;if(r.findNode(e,{match:{type:l.BLOCKS.LIST_ITEM},mode:"lowest"})){const t=(e=>{const t=e[0];return l.TEXT_CONTAINERS.includes(t.type)?[...t.children,...e.slice(1)]:e})((e=>{if(1!==e.length)return e;const t=e[0];return t.type!==l.BLOCKS.LIST_ITEM||1!==t.children.length?e:t.children})(n.flatMap(e=>(e=>{if(!Jn(e))return[e];const t=Array.from(r.getNodeTexts(e,void 0)),n=t.reduce((t,n)=>ge(t[1],n[1])?t:pe(e,n[1],t[1]),((e,t)=>{let n=Ce(t[1]);for(;se(e,n).type!==l.BLOCKS.LIST_ITEM;)n=Ce(n);return[se(e,n),n]})(e,t[0]));return Jn(n[0])?n[0].children:[n[0]]})(e))));let i=t.findIndex(t=>((e,t)=>r.isBlock(e,t))(e,t));i<0&&(i=t.length);const o=t.slice(0,i),s=t.slice(i);return we(e,o,{at:e.selection,select:!0}),we(e,s,{at:e.selection,select:!0})}const i=Jn(n[0])?[{text:""},...n]:n;return t(i)}})(e),e.normalizeNode=A.normalizeList(e,{validLiChildrenTypes:ei}),e};function ni(e){const n=X(),i=Y();function o(e){return()=>{null!=i&&i.selection&&(Un(i,{type:e}),ot(i))}}return i?t.createElement(t.Fragment,null,at(n.field,l.BLOCKS.UL_LIST)&&t.createElement(mn,{title:"UL",testId:"ul-toolbar-button",onClick:o(l.BLOCKS.UL_LIST),isActive:Zn(i,l.BLOCKS.UL_LIST),isDisabled:e.isDisabled},t.createElement(I.ListBulletedIcon,null)),at(n.field,l.BLOCKS.OL_LIST)&&t.createElement(mn,{title:"OL",testId:"ol-toolbar-button",onClick:o(l.BLOCKS.OL_LIST),isActive:Zn(i,l.BLOCKS.OL_LIST),isDisabled:e.isDisabled},t.createElement(I.ListNumberedIcon,null))):null}const ii=(e,t)=>{const n=[l.MARKS.SUPERSCRIPT,l.MARKS.SUBSCRIPT];((e,t)=>{r.toggleMark(e,t)})(e,{key:t,clear:n.includes(t)?n:[]})},oi=e=>(t,{options:{hotkey:n}})=>i=>{if(t.selection&&n&&S(n,i)){i.preventDefault();const n=ye(t,e);t.tracking.onShortcutAction(n?"unmark":"mark",{markType:e}),ii(t,e)}},li=s.css({backgroundColor:b.blue100,color:b.blue600}),ri=({mark:e,title:n,icon:i})=>{const o=({isDisabled:o})=>{const l=Y(),r=t.useCallback(()=>{if(null==l||!l.selection)return;const t=ye(l,e);l.tracking.onToolbarAction(t?"unmark":"mark",{markType:e}),ii(l,e),ot(l)},[l]);return l?i?t.createElement(mn,{title:n,testId:e+"-toolbar-button",onClick:r,isActive:ye(l,e),isDisabled:o},i):t.createElement(y.Menu.Item,{onClick:r,disabled:o,className:s.cx({[li]:ye(l,e)}),testId:e+"-toolbar-button"},n):null};return o.displayName=e,o},si=ri({title:"Bold",mark:l.MARKS.BOLD,icon:t.createElement(I.FormatBoldIcon,null)}),ai={bold:s.css({fontWeight:600})};function ci(e){return t.createElement("strong",{...e.attributes,className:ai.bold},e.children)}const di=ri({title:"Code",mark:l.MARKS.CODE,icon:t.createElement(I.CodeIcon,null)}),ui=ri({title:"Code",mark:l.MARKS.CODE}),mi={code:s.css({fontFamily:"monospace",fontSize:".9em"})};function pi(e){return t.createElement("code",{...e.attributes,className:mi.code},e.children)}const Ei=ri({title:"Italic",mark:l.MARKS.ITALIC,icon:t.createElement(I.FormatItalicIcon,null)}),yi={italic:s.css({fontStyle:"italic"})};function hi(e){return t.createElement("em",{...e.attributes,className:yi.italic},e.children)}const fi={subscript:s.css({verticalAlign:"sub",fontSize:"smaller"})},Si=ri({title:"Subscript",mark:l.MARKS.SUBSCRIPT,icon:t.createElement(I.SubscriptIcon,{viewBox:"0 0 23 18"})}),gi=ri({title:"Subscript",mark:l.MARKS.SUBSCRIPT});function Li(e){return t.createElement("sub",{...e.attributes,className:fi.subscript},e.children)}const Ci={superscript:s.css({verticalAlign:"super",fontSize:"smaller"})},Ti=ri({title:"Superscript",mark:l.MARKS.SUPERSCRIPT,icon:t.createElement(I.SuperscriptIcon,null)}),bi=ri({title:"Superscript",mark:l.MARKS.SUPERSCRIPT});function Ii(e){return t.createElement("sup",{...e.attributes,className:Ci.superscript},e.children)}const Ai=ri({title:"Underline",mark:l.MARKS.UNDERLINE,icon:t.createElement(I.FormatUnderlinedIcon,null)});function ki(e){return t.createElement("u",{...e.attributes},e.children)}const Ni=e=>l.TEXT_CONTAINERS.includes(e.type),vi=[{match:Z,validNode:(e,[,t])=>{var n;const i=null==(n=oe(e,t))?void 0:n[0];return!!i&&(Ni(i)||nt.includes(i.type)||e.isVoid(i))},transform:(e,t)=>rn(l.BLOCKS.PARAGRAPH)(e,t)},{match:{type:nt},validNode:(e,[,t])=>{var n;const i=null==(n=oe(e,t))?void 0:n[0];return!!i&&Ni(i)},transform:rn(l.BLOCKS.PARAGRAPH)}];class Di extends Error{}const Bi=e=>(t,[n])=>fe(n)&&e.includes(n.type),Oi=e=>{const t=e.default;if(!t)throw new Di("A default transformer MUST be provided");return(n,i)=>{const[o]=i,l=fe(o)?o.type:"default";return(e[l]||t)(n,i)}},Ri=e=>{const t=vi;for(const n of e.plugins){const{normalizer:i}=n;if(i)for(const o of i){const i={...o};if(!i.match&&!n.isElement)throw new Di("rule.match MUST be defined in a non-element plugin");if(i.match||(i.match={type:De(e,n.key)}),v(i.transform)){if("validNode"in i)throw new Di("conditional transformations are not supported in validNode rules");i.transform=Oi({default:nn,...i.transform})}i.transform||(i.transform=nn),"validChildren"in i&&Array.isArray(i.validChildren)&&(i.validChildren=Bi(i.validChildren)),t.push(i)}}const n=(t,n)=>{G(e,()=>{t(e,n)})},{normalizeNode:i}=e;return e.normalizeNode=o=>{const[l,r]=o,s=re(o);for(const i of t)if(Ne(l,r,i.match)){if("validNode"in i&&!i.validNode(e,o))return void n(i.transform,o);if("validChildren"in i){const t=i.validChildren,o=s.find(n=>!t(e,n));if(o)return void n(i.transform,o)}}return i(o)},e},Ki={[l.BLOCKS.PARAGRAPH]:s.css`
|
|
114
|
+
line-height: ${b.lineHeightDefault};
|
|
115
|
+
margin-bottom: 1.5em;
|
|
116
|
+
`};function xi(e){return t.createElement("div",{...e.attributes,className:Ki[l.BLOCKS.PARAGRAPH]},e.children)}const wi=(e,{options:{hotkey:t}})=>n=>{e.selection&&t&&S(t,n)&<(e,{activeType:l.BLOCKS.PARAGRAPH,inactiveType:l.BLOCKS.PARAGRAPH})},Mi=e=>{(e=>{const t=new Text(" "),n=e.parentNode;n&&(e.previousSibling&&n.insertBefore(t,e),e.nextSibling&&n.insertBefore(t,e.nextSibling))})(e),e.replaceWith(...Array.from(e.childNodes))},_i=[e=>(e.querySelectorAll("style").forEach(e=>{e.remove()}),e),e=>{if(!["google-sheets-html-origin",'meta[content="Excel.Sheet"]','meta[content*="Microsoft Excel"]'].some(t=>!!e.querySelector(t)))return e;const t=e=>""===(e.textContent??"").trim(),n=Array.from(e.querySelectorAll("table"));for(const e of n){e.querySelectorAll("tr").forEach(e=>{t(e)&&e.remove()});const n=Array.from(e.querySelectorAll("tr"));let i=1;for(;;){const e=n.map(e=>e.querySelector(`th:nth-of-type(${i}), td:nth-of-type(${i})`)).filter(e=>!!e);if(0===e.length)break;e.every(e=>t(e))?e.forEach(e=>e.remove()):i+=1}}return e},e=>(e.querySelectorAll("meta").forEach(e=>e.remove()),e),e=>{const t=`a :not(${["b","strong","code","pre","em","i","sub","sup","u","span"].join(",")})`;return e.querySelectorAll(t).forEach(Mi),e}];function Pi(e){const t=e.parentElement;t&&"DIV"===t.tagName&&1===t.children.length&&(t.replaceWith(e),Pi(e))}const Hi=e=>{const t=_i.reduce((e,t)=>t(e),(new DOMParser).parseFromString(e,"text/html")),n=[e=>e.replace(/<(\/)?(table|thead|tbody|tr|td|th|caption|col|colgroup|ol|ul|li)(.*)>\s+<(\/)?(table|thead|tbody|tr|td|th|caption|col|colgroup|ol|ul|li)/g,"<$1$2$3><$4$5"),e=>e.replace(/(?:<[^>^/]*>)\s*(?:<\/[^>]*>)<\/(div|p|table|thead|tbody|tr|td|th|caption|col|colgroup|ol|ul|li)/g,"</$1"),e=>e.replace(/\s*<\/(div|p|table|thead|tbody|tr|td|th|caption|col|colgroup|ol|ul|li)/g,"</$1")];let i;do{i=t.body.innerHTML,t.body.innerHTML=n.reduce((e,t)=>t(e),t.body.innerHTML)}while(t.body.innerHTML!==i);return t.querySelectorAll("table").forEach(Pi),t.body.innerHTML},zi=/data-slate-fragment="(.+?)"/m,Fi=s.css({margin:"0 0 1.3125rem",borderLeft:"6px solid "+b.gray200,paddingLeft:"0.875rem",fontStyle:"normal"});function qi(e){return t.createElement("blockquote",{...e.attributes,className:Fi},e.children)}const Ui=e=>{const t=me(e,{match:{type:l.TEXT_CONTAINERS},mode:"lowest"});if(!t)return!1;if(!Le(e,t[0]))return!1;const n=te(e,{match:{type:l.BLOCKS.QUOTE},mode:"lowest"});return!!n&&!(!r.hasSingleChild(n[0])||!r.isLastChild(n,t[1]))};function Yi(e,t){if(!e.selection)return;const n=Ve(e,l.BLOCKS.QUOTE);null==t||t(n?"remove":"insert",{nodeType:l.BLOCKS.QUOTE}),G(e,()=>{e.selection&&(Pe(e,{match:e=>fe(e)&&e.type===l.BLOCKS.QUOTE,split:!0}),!n)&&He(e,{type:l.BLOCKS.QUOTE,data:{},children:[]})})}const Gi=(e,t)=>n=>{const{hotkey:i}=t.options;i&&S(i,n)&&(n.preventDefault(),Yi(e,e.tracking.onShortcutAction))},$i=e=>{const{insertFragment:t}=e;return e.insertFragment=n=>{const i=n.length&&n[0],o=g.Element.isElement(i)&&i.type===l.BLOCKS.QUOTE,r=me(e,{match:{type:l.TEXT_CONTAINERS}}),s=r&&""!==Q(e,r[1]);if(o&&s){const{selection:t}=e;(e=>!!e&&0!==g.Point.compare(e.anchor,e.focus))(t)&&qe(e,{at:t});const i=me(e,{match:{type:l.TEXT_CONTAINERS}});if(i&&""!==Q(e,i[1]))return void we(e,n)}t(n)},e};function Wi(e){const n=Y();return n?t.createElement(mn,{title:"Blockquote",onClick:function(){n&&(Yi(n,n.tracking.onToolbarAction),ot(n))},testId:"quote-toolbar-button",isDisabled:e.isDisabled,isActive:Ve(n,l.BLOCKS.QUOTE)},t.createElement(I.QuoteIcon,null)):null}const Vi=(e,t)=>{if(le(e,{match:{type:l.BLOCKS.TABLE}})){const n=me(e,{match:{type:l.BLOCKS.TABLE_ROW}});if(n){const[i,o]=n,l=t(o);we(e,O.getEmptyRowNode(e,{header:!1,colCount:i.children.length}),{at:l,select:!0}),Oe(e,J(e,l))}}},ji=e=>{Vi(e,e=>Te(e))},Xi=e=>{Vi(e,e=>e)},Qi=(e,{header:t},n)=>{if(le(e,{match:{type:l.BLOCKS.TABLE}})){const i=me(e,{match:{type:[l.BLOCKS.TABLE_HEADER_CELL,l.BLOCKS.TABLE_CELL]}}),o=me(e,{match:{type:l.BLOCKS.TABLE}});if(i&&o){const l=n(i[1]).slice(),r=l.length-2;o[0].children.forEach((n,i)=>{l[r]=i,we(e,O.getEmptyCellNode(e,{header:t&&0===i}),{at:l,select:0===i})})}}},Zi=(e,t)=>{Qi(e,t,e=>Te(e))},Ji=(e,t)=>{Qi(e,t,e=>e)},eo=(e,t)=>{const[,n]=t,i=oe(e,n);if(!i)throw new Error("table rows must be wrapped in a table node");return Math.max(...re(i).map(e=>re(e).length))-re(t).length},to=(e,t)=>0!==re(t).length,no=e=>fe(e)&&e.type===l.BLOCKS.TABLE,io={topRight:s.css({position:"absolute",top:"6px",right:"5px"})},oo=()=>{const e=Y(),t=_(),[i,o]=n.useState(!1),[r,s]=n.useState(!1),a=n.useCallback(()=>{o(!1)},[]);n.useEffect(()=>{s(Boolean(e&&function(e){const t=me(e,{match:{type:l.BLOCKS.TABLE}});if(!t)return!1;const n=re(t)[0];return!!n&&re(n).every(([e])=>e.type===l.BLOCKS.TABLE_HEADER_CELL)}(e)))},[e]);const c=n.useMemo(()=>!!e&&!me(e,{match:{type:l.BLOCKS.TABLE_HEADER_CELL}}),[e]),d=n.useCallback(()=>{if(a(),!e)return;const t=!r;s(t),((e,t)=>{const n=me(e,{match:{type:l.BLOCKS.TABLE}});if(!n)return;const i=re(n)[0];i&&re(i).forEach(([,n])=>{xe(e,{type:t?l.BLOCKS.TABLE_HEADER_CELL:l.BLOCKS.TABLE_CELL},{at:n})})})(e,t)},[e,a,r]),u=n.useCallback((t,n,i)=>()=>{if(null==e||!e.selection)return;a();const o=(e=>{const[t]=Xe(e,l.BLOCKS.TABLE);return t?function(e){var t;const n=e.children.length;if(!n)return null;const[i]=e.children;return{numRows:n,numColumns:null==(t=i.children)?void 0:t.length}}(t):null})(e);G(e,()=>{t(e,{header:r})}),e.tracking.onViewportAction(`${n}Table${"Table"===i?"":i}`,{tableSize:o})},[e,r,a]);return t?null:n.createElement(y.Menu,{placement:"left",isOpen:i,onOpen:()=>{o(!0)},onClose:a},n.createElement(y.Menu.Trigger,null,n.createElement(y.IconButton,{size:"small",variant:"transparent",tabIndex:-1,className:io.topRight,icon:n.createElement(I.ChevronDownIcon,null),"aria-label":"Open table menu",testId:"cf-table-actions-button"})),n.createElement(y.Menu.List,null,n.createElement(y.Menu.Item,{onClick:u(Xi,"insert","Row"),disabled:!c},"Add row above"),n.createElement(y.Menu.Item,{onClick:u(ji,"insert","Row")},"Add row below"),n.createElement(y.Menu.Item,{onClick:u(Ji,"insert","Column")},"Add column left"),n.createElement(y.Menu.Item,{onClick:u(Zi,"insert","Column")},"Add column right"),n.createElement(y.Menu.Divider,null),n.createElement(y.Menu.Item,{onClick:d},r?"Disable table header":"Enable table header"),n.createElement(y.Menu.Divider,null),n.createElement(y.Menu.Item,{onClick:u(O.deleteRow,"remove","Row")},"Delete row"),n.createElement(y.Menu.Item,{onClick:u(O.deleteColumn,"remove","Column")},"Delete column"),n.createElement(y.Menu.Item,{onClick:u(O.deleteTable,"remove","Table")},"Delete table")))},lo=s.css`
|
|
117
|
+
border: 1px solid ${b.gray400};
|
|
118
|
+
border-collapse: collapse;
|
|
119
|
+
padding: 10px 12px;
|
|
120
|
+
min-width: 48px;
|
|
121
|
+
position: relative;
|
|
122
|
+
vertical-align: top;
|
|
123
|
+
|
|
124
|
+
div:last-child {
|
|
125
|
+
margin-bottom: 0;
|
|
126
|
+
}
|
|
127
|
+
`,ro=e=>{const n=d.useSelected();return t.createElement("td",{...e.attributes,...e.element.data,className:lo},n&&t.createElement(oo,null),e.children)},so=s.css`
|
|
128
|
+
background-clip: padding-box;
|
|
129
|
+
background-color: ${b.gray200};
|
|
130
|
+
border: 1px solid ${b.gray400};
|
|
131
|
+
border-collapse: collapse;
|
|
132
|
+
padding: 10px 12px;
|
|
133
|
+
font-weight: ${b.fontWeightNormal};
|
|
134
|
+
text-align: left;
|
|
135
|
+
min-width: 48px;
|
|
136
|
+
position: relative;
|
|
137
|
+
|
|
138
|
+
div:last-child {
|
|
139
|
+
margin-bottom: 0;
|
|
140
|
+
}
|
|
141
|
+
`,ao=e=>{const n=d.useSelected();return t.createElement("th",{...e.attributes,...e.element.data,className:so},n&&t.createElement(oo,null),e.children)},co=s.css`
|
|
142
|
+
border: 1px solid ${b.gray400};
|
|
143
|
+
border-collapse: collapse;
|
|
144
|
+
|
|
145
|
+
&:hover td {
|
|
146
|
+
background-color: transparent !important;
|
|
147
|
+
}
|
|
148
|
+
`,uo=e=>t.createElement("tr",{...e.attributes,className:co},e.children),mo=s.css`
|
|
149
|
+
margin-bottom: 1.5em;
|
|
150
|
+
border-collapse: collapse;
|
|
151
|
+
border-radius: 5px;
|
|
152
|
+
border-style: hidden;
|
|
153
|
+
box-shadow: 0 0 0 1px ${b.gray400};
|
|
154
|
+
width: 100%;
|
|
155
|
+
table-layout: fixed;
|
|
156
|
+
overflow: hidden;
|
|
157
|
+
`,po=e=>t.createElement("div",{"data-block-type":l.BLOCKS.TABLE},t.createElement("table",{className:mo,...e.attributes},t.createElement("tbody",null,e.children))),Eo=e=>{var t,n;if(!fe(e))return[e];if(e.type!==l.BLOCKS.TABLE||1!==(null==(t=e.children)?void 0:t.length))return[e];const i=e.children[0];return 1!==(null==i||null==(n=i.children)?void 0:n.length)?[e]:i.children[0].children},yo=(e,t)=>{const n=O.onKeyDownTable(e,t);return t=>{const i=window.getSelection();var o,s;if(i&&(null==(o=i.anchorNode.attributes)||null==(s=o["data-block-type"])?void 0:s.value)===l.BLOCKS.TABLE){if("Enter"===t.key){const t=me(e,{match:{type:l.BLOCKS.TABLE}});if(!t)return;const[,n]=t;Je(e,{at:n,select:!0})}return t.preventDefault(),void t.stopPropagation()}if("Tab"===t.key&&!t.shiftKey){t.preventDefault();const i=O.getTableEntries(e,{});if(i){const{table:o,row:l,cell:r}=i,s=ke(l,r[1]);if(ke(o,l[1])&&s)return void ji(e);n(t)}}"Escape"===t.key&&(e=>{r.blurEditor(e)})(e)}},ho=Object.values(l.INLINES).map(e=>({type:e}));var fo={document:{nodes:[{types:l.TOP_LEVEL_BLOCKS.map(e=>({type:e}))}]},blocks:{[l.BLOCKS.PARAGRAPH]:{nodes:[{match:[...ho,{object:"text"}]}]},[l.BLOCKS.HEADING_1]:{nodes:[{match:[...ho,{object:"text"}]}]},[l.BLOCKS.HEADING_2]:{nodes:[{match:[...ho,{object:"text"}]}]},[l.BLOCKS.HEADING_3]:{nodes:[{match:[...ho,{object:"text"}]}]},[l.BLOCKS.HEADING_4]:{nodes:[{match:[...ho,{object:"text"}]}]},[l.BLOCKS.HEADING_5]:{nodes:[{match:[...ho,{object:"text"}]}]},[l.BLOCKS.HEADING_6]:{nodes:[{match:[...ho,{object:"text"}]}]},...l.VOID_BLOCKS.reduce((e,t)=>({...e,[t]:{isVoid:!0}}),{}),[l.BLOCKS.QUOTE]:{nodes:[{match:[l.CONTAINERS[l.BLOCKS.QUOTE].map(e=>({type:e}))],min:1}],normalize:(e,t)=>{if("child_type_invalid"===t.code)return e.unwrapBlockByKey(t.node.key,l.BLOCKS.QUOTE)}}},inlines:{[l.INLINES.HYPERLINK]:{nodes:[{match:[{object:"text"}]}]},[l.INLINES.ENTRY_HYPERLINK]:{nodes:[{match:[{object:"text"}]}]},[l.INLINES.ASSET_HYPERLINK]:{nodes:[{match:[{object:"text"}]}]},[l.INLINES.EMBEDDED_ENTRY]:{isVoid:!0}}};function So(e){const t=R.toContentfulDocument({document:e.children,schema:fo});return K.documentToPlainTextString(t).length}function go(e){const t=e.getData("text/html"),n=(new DOMParser).parseFromString(t,"text/html");return n.querySelector('[id*="docs-internal-guid"]')?"Google Docs":n.querySelector("google-sheets-html-origin")||n.querySelector("[data-sheets-value]")?"Google Spreadsheets":n.querySelector('meta[content*="Microsoft Excel"]')?"Microsoft Excel":n.querySelector('meta[content*="Microsoft Word"]')?"Microsoft Word":n.querySelector('[style*="Arial_MSFontService"]')&&(n.querySelector(".TextRun")||n.querySelector(".OutlineElement"))?"Microsoft Word Online":n.querySelector('meta[content="Cocoa HTML Writer"]')?"Apple Notes":n.querySelector('[style*="Slack-Lato, Slack-Fractions"]')?"Slack":"Unknown"}const Lo=e=>{const t={onViewportAction:(t,n={})=>e(t,{origin:"viewport-interaction",...n}),onShortcutAction:(t,n={})=>e(t,{origin:"shortcut",...n}),onShortcutOrViewportAction:(t,n={})=>e(t,{origin:"shortcut-or-viewport",...n}),onToolbarAction:(t,n={})=>e(t,{origin:"toolbar-icon",...n}),onCommandPaletteAction:(t,n={})=>e(t,{origin:"command-palette",...n})};return{key:"TrackingPlugin",withOverrides:e=>{const{insertData:n}=e;return e.tracking=t,e.insertData=i=>{if(0!==i.types.length){var o;const n=null==(o=window.getSelection())?void 0:o.toString().length,l=So(e);setTimeout(()=>{const o=So(e);t.onShortcutOrViewportAction("paste",{characterCountAfter:o,characterCountBefore:l,characterCountSelection:n,source:go(i)})})}n(i)},e}}};function Co(e){return e.some(({type:e})=>e===l.BLOCKS.TABLE)}const To=({type:e})=>e===l.BLOCKS.TABLE_HEADER_CELL,bo=e=>(t,n)=>{const[i]=n;var o;return fe(i)&&(null==(o=t.tracking)||o.onViewportAction("invalidTablePaste",{nodeType:i.type})),e(t,n)};function Io(e){const n=Y(),i=n&&function(e){return[O.ELEMENT_TABLE,O.ELEMENT_TH,O.ELEMENT_TR,O.ELEMENT_TD].some(t=>Ve(e,t))}(n);return n?t.createElement(mn,{title:"Table",testId:"table-toolbar-button",onClick:async function(){n&&(n.tracking.onToolbarAction("insertTable"),function(e){const t={type:l.BLOCKS.TABLE,data:{},children:[O.getEmptyRowNode(e,{colCount:2,header:!0}),O.getEmptyRowNode(e,{colCount:2})]};if(we(e,t),e.selection){const t=te(e,{match:{type:l.BLOCKS.TABLE}});if(!t)return;((e,t)=>{r.selectEditor(e,t)})(e,{at:J(e,t[1])})}!function(e){const t=function(e){var t;if(e.selection)return(t=e.selection.focus.path,g.Path.levels(t,void 0)).find(e=>1===e.length)}(e);if(!t||Ae(t))return;const n=be(t);if(!n)return;const[i]=ie(e,{at:n,match:e=>e.type===l.BLOCKS.PARAGRAPH});if(!i)return;const[o]=i;Le(e,o)&&(Ye(e,{at:t,to:n}),Ue(e,{at:t}))}(e)}(n),ot(n))},isActive:!!i,isDisabled:e.isDisabled},t.createElement(I.TableIcon,null)):null}function Ao(e=[]){return{key:"TextPlugin",handlers:{onMouseUp:e=>()=>{e.selection&&Be(e,((e,t,n)=>r.unhangRange(e,t,void 0))(e,e.selection))}},withOverrides:e=>{const{insertText:t}=e;e.insertText=n=>{const{selection:i}=e;if(i&&ae(i)){var o;const t=null==(o=me(e,{match:t=>((e,t)=>r.isInline(e,t))(e,t),mode:"highest"}))?void 0:o[1];if(t&&((e,t,n)=>r.isEndPoint(e,t,n))(e,i.anchor,t)){const n=((e,t,n)=>r.getPointAfter(e,t,void 0))(e,t);Be(e,{anchor:n,focus:n})}}return t(n)};const{deleteForward:n,deleteBackward:i}=e;return e.deleteBackward=t=>{ko(t,e,i)},e.deleteForward=t=>{ko(t,e,n)},function(e){e.insertTextData=t=>{const n=t.getData("text/plain");if(!n)return!1;const i=n.split(/\n{2}/);let o=!1;for(const t of i)/^(\r\n?|\n)$/.test(t)||(o&&Me(e,{always:!0}),e.insertText(t),o=!0);return!0}}(e),e},normalizer:[{match:Z,transform:(t,[,n])=>{((e,t,n)=>{r.unsetNodes(e,t,n)})(t,e,{at:n})},validNode:(t,[n])=>!e.some(e=>e in n)}]}}function ko(e,t,n){const i=me(t,{match:{type:l.TEXT_CONTAINERS}});if(i){const[o,s]=i,a=Le(t,o),c=1===s.length,d=t.children.length>1;if(a&&c&&d){Ue(t,{at:s});const n=((e,t,n)=>r.getPointBefore(e,t,n))(t,t.selection,{unit:e});if(n){const[e]=ie(t,{match:e=>((e,t)=>r.queryNode(e,{allow:[l.BLOCKS.EMBEDDED_ASSET,l.BLOCKS.EMBEDDED_ENTRY,l.BLOCKS.HR]}))([e,n.path]),at:n});e&&Oe(t,n)}}else n(e)}else n(e)}const No={deserializeAst:!0,deserializeHtml:!0,eventEditor:!0},vo=e=>((null==e?void 0:e.content)||[]).length>0,Do=e=>function e(t=[]){return t.map(t=>{var n;return(e=>"text"in e)(t)?t:0===(null==(n=t.children)?void 0:n.length)?{...t,children:[{text:"",data:{}}]}:{...t,children:e(null==t?void 0:t.children)}})}(R.toSlatejsDocument({document:vo(e)?e:l.EMPTY_DOCUMENT,schema:fo})),Bo="1px solid "+b.gray400,Oo={root:s.css({position:"relative"}),editor:s.css({borderRadius:`0 0 ${b.borderRadiusMedium} ${b.borderRadiusMedium}`,border:Bo,borderTop:0,padding:"20px",fontSize:b.spacingM,fontFamily:b.fontStackPrimary,minHeight:"400px",background:b.colorWhite,outline:"none",whiteSpace:"pre-wrap",overflowWrap:"break-word",webkitUserModify:"read-write-plaintext-only",a:{span:{cursor:"not-allowed","&:hover":{cursor:"not-allowed"}}},"ul > li > div":{margin:0}}),hiddenToolbar:s.css({borderTop:Bo}),enabled:s.css({background:b.colorWhite,a:{span:{cursor:"pointer","&:hover":{cursor:"pointer"}}}}),disabled:s.css({background:b.gray100,cursor:"not-allowed"})};function Ro({children:e,isDisabled:n,isOpen:i,onClose:o,onToggle:l}){return t.createElement(y.Menu,{placement:"bottom-end",isOpen:i,onClose:o,onOpen:l},t.createElement(y.Menu.Trigger,null,t.createElement(y.Button,{endIcon:t.createElement(I.ChevronDownIcon,null),testId:"toolbar-entity-dropdown-toggle",variant:"secondary",size:"small",startIcon:t.createElement(I.PlusIcon,null),isDisabled:n},"Embed")),t.createElement(y.Menu.List,{className:"toolbar-entity-dropdown-list"},e))}const Ko=({isDisabled:e,canInsertBlocks:i})=>{const o=X(),r=Y(),[s,a]=t.useState(!1),c=()=>a(!1),d=at(o.field,l.INLINES.EMBEDDED_ENTRY),u=at(o.field,l.BLOCKS.EMBEDDED_ENTRY)&&i,m=at(o.field,l.BLOCKS.EMBEDDED_ASSET)&&i,p=n.createElement(n.Fragment,null,u&&n.createElement(Mt,{isDisabled:!!e,nodeType:l.BLOCKS.EMBEDDED_ENTRY,onClose:c}),d&&n.createElement(Xt,{isDisabled:!!e||et(r),onClose:c}),m&&n.createElement(Mt,{isDisabled:!!e,nodeType:l.BLOCKS.EMBEDDED_ASSET,onClose:c}));return u||d||m?n.createElement(Ro,{isDisabled:e,onClose:c,onToggle:()=>a(!s),isOpen:s},p):null},xo={toolbar:s.css({border:"1px solid "+b.gray400,backgroundColor:b.gray100,padding:b.spacingXs,borderRadius:`${b.borderRadiusMedium} ${b.borderRadiusMedium} 0 0`}),toolbarBtn:s.css({height:"30px",width:"30px",marginLeft:b.spacing2Xs,marginRight:b.spacing2Xs}),divider:s.css({display:"inline-block",height:"21px",width:"1px",background:b.gray300,margin:"0 "+b.spacing2Xs}),embedActionsWrapper:s.css({display:["-webkit-box","-ms-flexbox","flex"],webkitAlignSelf:"flex-start",alignSelf:"flex-start",msFlexItemAlign:"start",marginLeft:"auto"}),formattingOptionsWrapper:s.css({display:["-webkit-box","-ms-flexbox","flex"],msFlexAlign:"center",webkitBoxAlign:"center",alignItems:"center",msFlexWrap:"wrap",flexWrap:"wrap",marginRight:"20px"})},wo=({sdk:e,isDisabled:t})=>{const i=Y(),o=i&&(ye(i,l.MARKS.SUPERSCRIPT)||ye(i,l.MARKS.SUBSCRIPT)||ye(i,l.MARKS.CODE));return n.createElement(y.Menu,null,n.createElement(y.Menu.Trigger,null,n.createElement("span",null,n.createElement(y.IconButton,{size:"small",className:xo.toolbarBtn,variant:o?"secondary":"transparent",icon:n.createElement(I.MoreHorizontalIcon,null),"aria-label":"toggle menu",isDisabled:t,testId:"dropdown-toolbar-button"}))),n.createElement(y.Menu.List,null,ct(e.field,l.MARKS.SUPERSCRIPT)&&n.createElement(bi,{isDisabled:t}),ct(e.field,l.MARKS.SUBSCRIPT)&&n.createElement(gi,{isDisabled:t}),ct(e.field,l.MARKS.CODE)&&n.createElement(ui,{isDisabled:t})))},Mo=({isDisabled:e})=>{const t=X(),i=Y(),o=!Qe(i,l.BLOCKS.TABLE),r=n.useMemo(()=>function(e){const t=(t,n)=>t.some(t=>n(e,t));return{isAnyMarkEnabled:t(Object.values(l.MARKS),ct),isAnyHyperlinkEnabled:t([l.INLINES.HYPERLINK,l.INLINES.ASSET_HYPERLINK,l.INLINES.ENTRY_HYPERLINK],at),isAnyBlockFormattingEnabled:t([l.BLOCKS.UL_LIST,l.BLOCKS.OL_LIST,l.BLOCKS.QUOTE,l.BLOCKS.HR],at)}}(t.field),[t.field]),s=Qe(i,l.BLOCKS.UL_LIST)||Qe(i,l.BLOCKS.OL_LIST),a=Qe(i,l.BLOCKS.QUOTE),c=e||!o||s||a,d=ct(t.field,l.MARKS.BOLD)||ct(t.field,l.MARKS.ITALIC)||ct(t.field,l.MARKS.UNDERLINE),u=ct(t.field,l.MARKS.SUPERSCRIPT)||ct(t.field,l.MARKS.SUBSCRIPT)||ct(t.field,l.MARKS.CODE),m=d&&u;return n.createElement(y.Flex,{testId:"toolbar",className:xo.toolbar,alignItems:"center"},n.createElement("div",{className:xo.formattingOptionsWrapper},n.createElement(tn,{isDisabled:e||!o}),r.isAnyMarkEnabled&&n.createElement("span",{className:xo.divider}),ct(t.field,l.MARKS.BOLD)&&n.createElement(si,{isDisabled:e}),ct(t.field,l.MARKS.ITALIC)&&n.createElement(Ei,{isDisabled:e}),ct(t.field,l.MARKS.UNDERLINE)&&n.createElement(Ai,{isDisabled:e}),!d&&ct(t.field,l.MARKS.SUPERSCRIPT)&&n.createElement(Ti,{isDisabled:e}),!d&&ct(t.field,l.MARKS.SUBSCRIPT)&&n.createElement(Si,{isDisabled:e}),!d&&ct(t.field,l.MARKS.CODE)&&n.createElement(di,{isDisabled:e}),m&&n.createElement(wo,{sdk:t,isDisabled:e}),r.isAnyHyperlinkEnabled&&n.createElement(n.Fragment,null,n.createElement("span",{className:xo.divider}),n.createElement(Tn,{isDisabled:e})),r.isAnyBlockFormattingEnabled&&n.createElement("span",{className:xo.divider}),n.createElement(ni,{isDisabled:e||!o}),at(t.field,l.BLOCKS.QUOTE)&&n.createElement(Wi,{isDisabled:e||!o}),at(t.field,l.BLOCKS.HR)&&n.createElement(yn,{isDisabled:e||!o}),at(t.field,l.BLOCKS.TABLE)&&n.createElement(Io,{isDisabled:c})),n.createElement("div",{className:xo.embedActionsWrapper},n.createElement(Ko,{isDisabled:e,canInsertBlocks:o})))},_o={nativeSticky:s.css`
|
|
158
|
+
position: -webkit-sticky;
|
|
159
|
+
position: sticky;
|
|
160
|
+
top: -1px;
|
|
161
|
+
z-index: 2;
|
|
162
|
+
`},Po=({isDisabled:e,children:t})=>n.createElement("div",{className:e?"":_o.nativeSticky},t),Ho=["command-prompt"],zo=e=>({...e,content:e.content.map(e=>"text"===e.nodeType?(e.marks=e.marks.filter(e=>!Ho.includes(e.type)),e):zo(e))}),Fo=e=>"set_selection"!==e.type,qo=e=>{const i=z(e.sdk),o=n.useMemo(()=>{return t=e.sdk,n=e.onAction??c,i=e.restrictedMarks,[r.createDeserializeHtmlPlugin(),r.createDeserializeAstPlugin(),u.createDeserializeDocxPlugin(),Lo(n),Tt(),...Object.values(Et(t)).some(Boolean)?[{key:"command-prompt",type:"command-prompt",isLeaf:!0,component:Ct,handlers:{onKeyDown:e=>t=>{if(S("shift?+/",{byKey:!0},t)&&(((e,t,n=!0)=>{r.addMark(e,"command-prompt",n)})(e),e.tracking.onCommandPaletteAction("openRichTextCommandPalette")),!ye(e,"command-prompt"))return;if(S("enter",t))return t.preventDefault();const[,n]=me(e),i=ce(e,n);S("backspace",t)&&i.focus.offset-i.anchor.offset==1&&ze(e,"command-prompt",i),S("escape",t)&&(t.stopPropagation(),ze(e,"command-prompt",i),e.tracking.onCommandPaletteAction("cancelRichTextCommandPalette"),$(e))}}}]:[],D.createParagraphPlugin({type:l.BLOCKS.PARAGRAPH,component:xi,options:{hotkey:["mod+opt+0"]},handlers:{onKeyDown:wi},softBreak:[{hotkey:"shift+enter",query:{allow:l.BLOCKS.PARAGRAPH}}],deserializeHtml:{rules:[{validNodeName:["P","DIV"]}],query:e=>{return!(""===e.textContent||(t=e,t.hasAttribute("data-embedded-entity-inline-id")||t.hasAttribute("data-entity-type")));var t}},normalizer:[{validChildren:(e,[t])=>it(t),transform:{[l.BLOCKS.PARAGRAPH]:ln,default:sn}}]}),A.createListPlugin({normalizer:[{match:{type:[l.BLOCKS.UL_LIST,l.BLOCKS.OL_LIST]},validChildren:[l.BLOCKS.LIST_ITEM],transform:rn(l.BLOCKS.LIST_ITEM)}],overrideByKey:{[A.ELEMENT_UL]:{type:l.BLOCKS.UL_LIST,component:wn,handlers:{onKeyDown:Yn},withOverrides:ti},[A.ELEMENT_OL]:{type:l.BLOCKS.OL_LIST,component:Mn,handlers:{onKeyDown:Yn}},[A.ELEMENT_LIC]:{type:l.BLOCKS.PARAGRAPH},[A.ELEMENT_LI]:{type:l.BLOCKS.LIST_ITEM,component:Pn,normalizer:[{validNode:$n,transform:Wn},{validNode:Vn,transform:Xn},{validChildren:l.LIST_ITEM_BLOCKS,transform:on},{validNode:jn,transform:Qn}]}}}),{key:l.BLOCKS.HR,type:l.BLOCKS.HR,isVoid:!0,isElement:!0,component:hn,handlers:{onKeyDown:En},deserializeHtml:{rules:[{validNodeName:["HR"]},{validAttribute:{"data-void-element":l.BLOCKS.HR}}],withoutChildren:!0}},{key:"HeadingPlugin",softBreak:[{hotkey:"shift+enter",query:{allow:l.HEADINGS}}],normalizer:[{match:{type:l.HEADINGS},validChildren:(e,[t])=>it(t),transform:{[l.BLOCKS.PARAGRAPH]:ln,default:sn}}],then:e=>({exitBreak:[{hotkey:"enter",query:{allow:l.HEADINGS,end:!0,start:!0,filter:([,t])=>!me(e,{at:t,match:{type:l.BLOCKS.LIST_ITEM}})&&!ye(e,"command-prompt")}}]}),plugins:l.HEADINGS.map((e,t)=>{const n=t+1;return{key:e,type:e,isElement:!0,component:dn[e],options:{hotkey:["mod+alt+"+n]},handlers:{onKeyDown:(i=e,(e,{options:{hotkey:t}})=>n=>{if(e.selection&&t&&S(t,n)){const t=Ve(e,i);e.tracking.onShortcutAction(t?"remove":"insert",{nodeType:i}),lt(e,{activeType:i,inactiveType:l.BLOCKS.PARAGRAPH})}})},deserializeHtml:{rules:[{validNodeName:("h"+n).toUpperCase()}]}};var i})},{key:l.BLOCKS.QUOTE,type:l.BLOCKS.QUOTE,isElement:!0,component:qi,options:{hotkey:"mod+shift+1"},handlers:{onKeyDown:Gi},deserializeHtml:{rules:[{validNodeName:"BLOCKQUOTE"}]},resetNode:[{hotkey:"backspace",types:[l.BLOCKS.QUOTE],predicate:Ui,onReset:Yi}],normalizer:[{validChildren:l.CONTAINERS[l.BLOCKS.QUOTE],transform:{[l.BLOCKS.QUOTE]:ln,default:sn}}],withOverrides:$i},O.createTablePlugin({type:l.BLOCKS.TABLE,handlers:{onKeyDown:yo},withOverrides:(e,t)=>{const{normalizeNode:n}=e;return O.withTable(e,t),e.normalizeNode=n,function(e){const{insertData:t}=e;e.insertData=n=>{if(n.getData("text/html")){const{children:i}=e;t(n);const{children:o}=e;setTimeout(()=>{var t;Co(i)||Co(o)&&e.tracking.onViewportAction("paste",{tablePasted:!0,source:go(n),hasHeadersOutsideFirstRow:(t=o,t.filter(({type:e})=>e===l.BLOCKS.TABLE).flatMap(({children:e})=>e.slice(1)).some(({children:e})=>e.some(To)))})},1)}else t(n)}}(e),e.insertFragment=(e=>{const{insertFragment:t}=e;return n=>{var i;if(!e.selection)return;const o=(n=n.flatMap(Eo)).some(e=>no(e)),l=0===n.findIndex(e=>no(e)),r=""!==Q(e,null==(i=e.selection)?void 0:i.focus.path);return o&&l&&r&&Je(e),t(n)}})(e),e},overrideByKey:{[O.ELEMENT_TABLE]:{type:l.BLOCKS.TABLE,component:po,normalizer:[{validNode:to},{validNode:(e,[,t])=>{const n=!!te(e,{at:t,match:{type:[l.BLOCKS.TABLE_CELL,l.BLOCKS.TABLE_HEADER_CELL]}});return je(t)||n},transform:sn},{validChildren:l.CONTAINERS[l.BLOCKS.TABLE]}]},[O.ELEMENT_TR]:{type:l.BLOCKS.TABLE_ROW,component:uo,normalizer:[{validChildren:l.CONTAINERS[l.BLOCKS.TABLE_ROW],transform:rn(l.BLOCKS.TABLE_CELL)},{validNode:to},{validNode:(e,[,t])=>{var n;const i=null==(n=oe(e,t))?void 0:n[0];return i&&i.type===l.BLOCKS.TABLE},transform:rn(l.BLOCKS.TABLE)},{validNode:(e,t)=>0===eo(e,t),transform:(e,t)=>{const n=eo(e,t),i=Te(Ie(t));we(e,(e=>{const t={type:l.BLOCKS.TABLE_CELL,data:{},children:[{type:l.BLOCKS.PARAGRAPH,data:{},children:[{text:""}]}]};return new Array(e).fill(t)})(n),{at:i})}}]},[O.ELEMENT_TH]:{type:l.BLOCKS.TABLE_HEADER_CELL,component:ao,normalizer:[{validChildren:l.CONTAINERS[l.BLOCKS.TABLE_HEADER_CELL],transform:bo(on)}]},[O.ELEMENT_TD]:{type:l.BLOCKS.TABLE_CELL,component:ro,normalizer:[{validChildren:l.CONTAINERS[l.BLOCKS.TABLE_CELL],transform:bo(on)}]}}}),zt(t),Ft(t),On(t),Qt(t),{key:"Marks",plugins:[N.createBoldPlugin({type:l.MARKS.BOLD,component:ci,options:{hotkey:["mod+b"]},handlers:{onKeyDown:oi(l.MARKS.BOLD)},deserializeHtml:{rules:[{validNodeName:["STRONG","B"]},{validStyle:{fontWeight:["600","700","bold"]}}],query:e=>!(e=>e.id.startsWith("docs-internal-guid")&&"B"===e.nodeName)(e)&&!ve(e,e=>"normal"===e.style.fontWeight)}}),N.createCodePlugin({type:l.MARKS.CODE,component:pi,options:{hotkey:["mod+/","mod+shift+7"]},handlers:{onKeyDown:oi(l.MARKS.CODE)},deserializeHtml:{rules:[{validNodeName:["CODE","PRE"]},{validStyle:{fontFamily:["Consolas","monospace"]}}]}}),N.createItalicPlugin({type:l.MARKS.ITALIC,component:hi,options:{hotkey:["mod+i"]},handlers:{onKeyDown:oi(l.MARKS.ITALIC)},deserializeHtml:{rules:[{validNodeName:["I","EM"]},{validStyle:{fontStyle:"italic"}}],query:e=>!ve(e,e=>"normal"===e.style.fontStyle)}}),N.createUnderlinePlugin({type:l.MARKS.UNDERLINE,component:ki,options:{hotkey:["mod+u"]},handlers:{onKeyDown:oi(l.MARKS.UNDERLINE)},deserializeHtml:{rules:[{validNodeName:["U"]},{validStyle:{textDecoration:["underline"]}}],query:e=>!ve(e,e=>"none"===e.style.textDecoration)}}),N.createSuperscriptPlugin({type:l.MARKS.SUPERSCRIPT,component:Ii,handlers:{onKeyDown:oi(l.MARKS.SUPERSCRIPT)},deserializeHtml:{rules:[{validNodeName:["SUP"]}]}}),N.createSubscriptPlugin({type:l.MARKS.SUBSCRIPT,component:Li,handlers:{onKeyDown:oi(l.MARKS.SUBSCRIPT)},deserializeHtml:{rules:[{validNodeName:["SUB"]}]}})]},x.createTrailingBlockPlugin({options:{type:l.BLOCKS.PARAGRAPH,level:0}}),Ao(i),{key:"VoidsPlugin",exitBreak:[{hotkey:"enter",before:!0,query:{filter:([e,t])=>je(t)&&Ae(t)&&!!e.isVoid}},{hotkey:"enter",level:-2,query:{filter:([e,t])=>!(je(t)&&Ae(t)||!e.isVoid)}}]},B.createSelectOnBackspacePlugin({options:{query:{allow:[l.INLINES.EMBEDDED_ENTRY]}}}),{key:"PasteHTMLPlugin",withOverrides:e=>{const{insertData:t}=e;return e.insertData=e=>t((e=>{if(!e.getData("application/x-slate-fragment")){const t=(e=>{const t=e.getData("text/html"),[,n]=t.match(zi)||[];return n})(e);if(t){const n=new DataTransfer;return e.types.forEach(t=>{n.setData(t,e.getData(t))}),n.setData("application/x-slate-fragment",t),n}}return e})(e)),e},inject:{pluginsByKey:{[r.KEY_DESERIALIZE_HTML]:{editor:{insertData:{format:"text/html",transformData:Hi}}}}}},m.createSoftBreakPlugin({then:e=>({options:{rules:e.plugins.flatMap(e=>e.softBreak||[])}})}),m.createExitBreakPlugin({options:{rules:[]},then:e=>({options:{rules:e.plugins.flatMap(e=>e.exitBreak||[])}})}),p.createResetNodePlugin({options:{rules:[]},then:e=>{const t=e.plugins.flatMap(e=>e.resetNode||[]);for(const e of t)e.defaultType||(e.defaultType=l.BLOCKS.PARAGRAPH);return{options:{rules:t}}}}),{key:"NormalizerPlugin",withOverrides:Ri}];var t,n,i},[e.sdk,e.onAction,e.restrictedMarks]),[a,d]=t.useState(!0),[E,y]=t.useState(!1),h=(({editorId:e,handler:n,skip:i,onSkip:o})=>{const l=t.useMemo(()=>w(e=>{const t=R.toContentfulDocument({document:e,schema:fo}),i=zo(t);null==n||n(i)},500),[n]);return t.useCallback(t=>{const n=r.getPlateSelectors(e).editor();if(!n)throw new Error("Editor change callback called but editor not defined. Editor id: "+e);if((null==n?void 0:n.operations.filter(Fo)).length>0){if(i)return void(null==o||o());l(t)}},[e,l,i,o])})({editorId:i,handler:e.onChange,skip:E||a,onSkip:()=>y(!1)});t.useEffect(()=>{d(!1);const t=(e=>r.getPlateSelectors(e))(i).editor();t&&(y(!0),((e,t)=>{G(e,()=>{[...e.children].forEach(t=>e.apply({type:"remove_node",path:[0],node:t})),t&&(r.isNode(t)?[t]:t).forEach((t,n)=>{e.apply({type:"insert_node",path:[n],node:t})});const n=((e,t)=>r.getEndPoint(e,[]))(e);n&&Oe(e,n)})})(t,Do(e.value)))},[e.value,i]);const f=s.cx(Oo.editor,void 0!==e.minHeight?s.css({minHeight:e.minHeight}):void 0,e.isDisabled?Oo.disabled:Oo.enabled,e.isToolbarHidden&&Oo.hiddenToolbar);return t.useEffect(()=>{a&&r.getPlateActions(i).value(((e,t)=>{const n=((e={})=>r.createPlateEditor(e))(t);return n.children=e,((e,t={force:!0})=>{r.normalizeEditor(e,t)})(n,{force:!0}),n.children})(Do(e.value),{plugins:o,disableCorePlugins:No}))},[a,o,i,e.value]),n.createElement(j,{sdk:e.sdk},n.createElement(q,{value:i},n.createElement("div",{className:Oo.root,"data-test-id":"rich-text-editor"},n.createElement(r.Plate,{id:i,plugins:o,disableCorePlugins:No,editableProps:{className:f,readOnly:e.isDisabled},onChange:h,firstChildren:!e.isToolbarHidden&&n.createElement(Po,{isDisabled:e.isDisabled},n.createElement(Mo,{isDisabled:e.isDisabled}))}))))};function Uo(e){const{id:t,type:n}=e.sys;return{sys:{id:t,type:"Link",linkType:n}}}class Yo extends n.Component{constructor(e){super(e),this.handleSubmit=e=>{e.preventDefault(),this.props.onClose(this.getValue())},this.selectEntry=async()=>{const{locale:e,contentTypes:t}=this.props.entitySelectorConfigs.Entry,n=await this.props.sdk.dialogs.selectSingleEntry({locale:e,contentTypes:t});this.setTargetEntity("Entry",n)},this.selectAsset=async()=>{const{locale:e}=this.props.entitySelectorConfigs.Asset,t=await this.props.sdk.dialogs.selectSingleAsset({locale:e});this.setTargetEntity("Asset",t)};const{text:t,type:n,uri:i,target:o}=e.value,l={Entry:null,Asset:null};let r=n;Boolean(o)?(r=o.sys.linkType,l[r]=o):r=e.allowedHyperlinkTypes.includes("uri")?"uri":e.allowedHyperlinkTypes[0],this.state={text:t,uri:i,entityLinks:l,type:r}}setTargetEntity(e,t){this.setState(n=>({entityLinks:{...n.entityLinks,[e]:t?Uo(t):void 0}}))}getValue(){const{text:e,type:t,uri:n}=this.state,i={type:t};return e&&(i.text=e),"uri"===t?i.uri=n:i.target=this.state.entityLinks[t],i}isLinkComplete(){const{text:e,type:t,uri:n,target:i}=this.getValue();return!(!this.props.hideText&&!e)&&("uri"===t&&n||i)}render(){const{labels:e}=this.props;return n.createElement(i.EntityProvider,{sdk:this.props.sdk},n.createElement(n.Fragment,null,n.createElement(y.ModalContent,null,this.renderFields()),n.createElement(y.ModalControls,null,n.createElement(y.Button,{type:"button",onClick:()=>this.props.onClose(null),variant:"secondary",testId:"cancel-cta",size:"small"},"Cancel"),n.createElement(y.Button,{type:"submit",variant:"positive",onClick:this.handleSubmit,isDisabled:!this.isLinkComplete(),testId:"confirm-cta",size:"small"},e.confirm))))}renderFields(){const{hideText:e,allowedHyperlinkTypes:t,entitySelectorConfigs:i}=this.props,{uri:o,text:l,type:r}=this.state,s="uri"===r&&(e||!!l);return n.createElement(y.Form,null,e?null:n.createElement(y.FormControl,{id:"link-text",isRequired:!0},n.createElement(y.FormControl.Label,null,"Link text"),n.createElement(y.TextInput,{testId:"link-text-input",name:"link-text",value:l||"",onChange:e=>this.setState({text:e.target.value}),autoFocus:!s})),function(e={}){return!!e.Entry||!!e.Asset}(i)&&n.createElement(y.FormControl,{id:"link-type",name:"link-type"},n.createElement(y.FormControl.Label,null,"Link type"),n.createElement(y.Select,{value:r,onChange:e=>this.setState({type:e.target.value}),testId:"link-type-select"},t.includes("uri")||"uri"===r?n.createElement(y.Select.Option,{value:"uri"},"URL"):null,t.includes("Entry")||"Entry"===r?n.createElement(y.Select.Option,{value:"Entry"},"Entry"):null,t.includes("Asset")||"Asset"===r?n.createElement(y.Select.Option,{value:"Asset"},"Asset"):null)),"uri"===r?n.createElement(y.FormControl,{id:"link-uri",isRequired:!0},n.createElement(y.FormControl.Label,null,"Link target"),n.createElement(y.TextInput,{testId:"link-target-input",name:"link-uri",value:o||"",placeholder:"https://",onChange:e=>this.setState({uri:e.target.value}),autoFocus:s}),n.createElement(y.FormControl.HelpText,null,"A protocol may be required, e.g. https://")):this.renderEntityField())}renderEntityField(){const{type:e,entityLinks:t}=this.state,i=t[e],o=!i;return n.createElement("div",null,n.createElement(y.FormLabel,{required:!0,htmlFor:""},"Link target"),!o&&n.createElement(y.TextLink,{as:"button",className:s.css({marginLeft:b.spacingS}),onClick:()=>this.setTargetEntity(e,null)},"Remove selection"),i&&n.createElement("div",null,"Entry"===e&&n.createElement(Nt,{sdk:this.props.sdk,locale:this.props.entitySelectorConfigs.Entry.locale,entryId:i.sys.id,isDisabled:!0,isSelected:!1}),"Asset"==e&&n.createElement(At,{sdk:this.props.sdk,locale:this.props.entitySelectorConfigs.Asset.locale,assetId:i.sys.id,isDisabled:!0,isSelected:!1})),o&&this.renderEntitySelector(e,o))}renderEntitySelector(e){return n.createElement("div",{className:s.css({marginTop:b.spacingS})},"Entry"===e&&n.createElement(y.TextLink,{as:"button",onClick:this.selectEntry},"Select entry"),"Asset"===e&&n.createElement(y.TextLink,{as:"button",onClick:this.selectAsset},"Select asset"))}}Yo.propTypes={sdk:M.object.isRequired,labels:M.shape({title:M.string,confirm:M.string}),value:M.shape({text:M.string,uri:M.string,target:M.object,type:M.oneOf(["uri","Entry","Asset"])}),entitySelectorConfigs:M.object,allowedHyperlinkTypes:M.arrayOf(M.oneOf(["Entry","Asset","uri"])),hideText:M.bool,onClose:M.func.isRequired},Yo.defaultProps={labels:{title:"Insert link",confirm:"Insert link"},value:{},hideText:!1,entitySelectorConfigs:{},allowedHyperlinkTypes:["Entry","Asset","uri"]},exports.ConnectedRichTextEditor=qo,exports.RichTextEditor=e=>{const{sdk:r,isInitiallyDisabled:s,onAction:c,restrictedMarks:d,...u}=e,m=t.useCallback(e=>!e||a(e,l.EMPTY_DOCUMENT),[]),p=z(e.sdk);return n.createElement(i.EntityProvider,{sdk:r},n.createElement(o.FieldConnector,{throttle:0,field:r.field,isInitiallyDisabled:s,isEmptyValue:m,isEqualValues:a},({lastRemoteValue:e,disabled:t,setValue:i})=>n.createElement(qo,{...u,key:"rich-text-editor-"+p,value:e,sdk:r,onAction:c,isDisabled:t,onChange:i,restrictedMarks:d})))},exports.openRichTextDialog=e=>t=>{var i;return"rich-text-hyperlink-dialog"===(null==(i=t.parameters)?void 0:i.type)?o.ModalDialogLauncher.openDialog(t,({onClose:i})=>n.createElement(Yo,{...t.parameters,onClose:i,sdk:e})):Promise.reject()},exports.renderRichTextDialog=e=>{const t=e.parameters.invocation;return"rich-text-hyperlink-dialog"===(null==t?void 0:t.type)?(e.window.startAutoResizer(),n.createElement(Yo,{...e.parameters.invocation,onClose:e.close,sdk:e})):n.createElement("div",null)};
|
|
2
163
|
//# sourceMappingURL=field-editor-rich-text.cjs.production.min.js.map
|