silverstripe-cms/client/dist/js/TinyMCE_sslink-internal.js
2024-08-30 12:02:03 +12:00

1 line
2.6 KiB
JavaScript

!function(){"use strict";var t={207:function(t){t.exports=Injector},127:function(t){t.exports=InsertLinkModal},594:function(t){t.exports=React},145:function(t){t.exports=ReactDomClient},40:function(t){t.exports=ReactRedux},502:function(t){t.exports=ShortcodeSerialiser},153:function(t){t.exports=TinyMCEActionRegistrar},815:function(t){t.exports=i18n},669:function(t){t.exports=jQuery}},e={};function n(i){var r=e[i];if(void 0!==r)return r.exports;var o=e[i]={exports:{}};return t[i](o,o.exports,n),o.exports}!function(){var t=c(n(815)),e=c(n(153)),i=c(n(594)),r=n(145),o=n(40),a=c(n(669)),s=c(n(502)),l=n(127),d=n(207);function c(t){return t&&t.__esModule?t:{default:t}}const u="sslinkinternal",p={init(n){e.default.addAction("sslink",{text:t.default._t("CMS.LINKLABEL_PAGE","Page on this site"),onAction:t=>t.execCommand(u),priority:90},n.getParam("editorIdentifier")).addCommandWithUrlTest(u,/^\[sitetree_link.+]$/),n.addCommand(u,(()=>{(0,a.default)(`#${n.id}`).entwine("ss").openLinkInternalDialog()}))}},f="insert-link__dialog-wrapper--internal",g=(0,d.provideInjector)((0,l.createInsertLinkModal)("SilverStripe\\CMS\\Controllers\\CMSPageEditController","editorInternalLink"));a.default.entwine("ss",(e=>{e("textarea.htmleditor").entwine({openLinkInternalDialog(){let t=e(`#${f}`);t.length||(t=e(`<div id="${f}" />`),e("body").append(t)),t.addClass("insert-link__dialog-wrapper"),t.setElement(this),t.open()}}),e(`#${f}`).entwine({ReactRoot:null,renderModal(e){var n=this;const a=ss.store,s=this.getOriginalAttributes(),l=this.getRequireLinkText();let d=this.getReactRoot();d||(d=(0,r.createRoot)(this[0]),this.setReactRoot(d)),d.render(i.default.createElement(o.Provider,{store:a},i.default.createElement(g,{isOpen:e,onInsert:function(){return n.handleInsert(...arguments)},onClosed:()=>this.close(),title:t.default._t("CMS.LINK_PAGE","Link to a page"),bodyClassName:"modal__dialog",className:"insert-link__dialog-wrapper--internal",fileAttributes:s,identifier:"Admin.InsertLinkInternalModal",requireLinkText:l})))},buildAttributes(t){return{href:`${s.default.serialise({name:"sitetree_link",properties:{id:t.PageID}},!0)}${t.Anchor&&t.Anchor.length?`#${t.Anchor}`:""}`,target:t.TargetBlank?"_blank":"",title:t.Description}},getOriginalAttributes(){const t=this.getElement().getEditor(),n=e(t.getSelectedNode()),i=(n.attr("href")||"").split("#");if(!i[0])return{};const r=s.default.match("sitetree_link",!1,i[0]);return r?{PageID:r.properties.id?parseInt(r.properties.id,10):0,Anchor:i[1]||"",Description:n.attr("title"),TargetBlank:!!n.attr("target")}:{}}})})),tinymce.PluginManager.add(u,(t=>p.init(t)))}()}();