mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 06:05:56 +00:00
1 line
3.7 KiB
JavaScript
1 line
3.7 KiB
JavaScript
!function(){"use strict";var e={803:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;t.default={ANCHORSELECTOR_CURRENT_FIELD:"ANCHORSELECTOR_CURRENT_FIELD",ANCHORSELECTOR_UPDATED:"ANCHORSELECTOR_UPDATED",ANCHORSELECTOR_UPDATING:"ANCHORSELECTOR_UPDATING",ANCHORSELECTOR_UPDATE_FAILED:"ANCHORSELECTOR_UPDATE_FAILED"}},979:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.beginUpdating=function(e){return{type:i.default.ANCHORSELECTOR_UPDATING,payload:{pageId:e}}},t.updateFailed=function(e){return{type:i.default.ANCHORSELECTOR_UPDATE_FAILED,payload:{pageId:e}}},t.updated=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{type:i.default.ANCHORSELECTOR_UPDATED,payload:{pageId:e,anchors:t,cacheResult:n}}},t.updatedCurrentField=function(e,t,n){return{type:i.default.ANCHORSELECTOR_CURRENT_FIELD,payload:{pageId:e,anchors:t,fieldID:n}}};var r,i=(r=n(803))&&r.__esModule?r:{default:r}},207:function(e){e.exports=Injector},127:function(e){e.exports=InsertLinkModal},594:function(e){e.exports=React},145:function(e){e.exports=ReactDomClient},40:function(e){e.exports=ReactRedux},502:function(e){e.exports=ShortcodeSerialiser},153:function(e){e.exports=TinyMCEActionRegistrar},815:function(e){e.exports=i18n},669:function(e){e.exports=jQuery}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}!function(){var e=c(n(815)),t=c(n(153)),r=c(n(594)),i=n(145),o=n(40),a=c(n(669)),d=c(n(502)),l=n(127),s=n(207),u=n(979);function c(e){return e&&e.__esModule?e:{default:e}}const p="sslinkanchor",f={init(n){t.default.addAction("sslink",{text:e.default._t("CMS.LINKLABEL_ANCHOR","Anchor on a page"),onAction:e=>e.execCommand(p),priority:60},n.getParam("editorIdentifier")).addCommandWithUrlTest(p,/^\[sitetree_link.+]#[^#\]]+$/),n.addCommand(p,(()=>{const e=(0,a.default)(`#${n.id}`).entwine("ss"),t=Number((0,a.default)("#Form_EditForm_ID").val()||0),r=(0,a.default)(n.getBody()).find("[id],[name]").toArray().map((e=>e.id||e.name));ss.store.dispatch((0,u.updatedCurrentField)(t,r,n.id)),e.openLinkAnchorDialog()}))}},E="insert-link__dialog-wrapper--anchor",R=(0,s.provideInjector)((0,l.createInsertLinkModal)("SilverStripe\\CMS\\Controllers\\CMSPageEditController","editorAnchorLink"));a.default.entwine("ss",(t=>{t("textarea.htmleditor").entwine({openLinkAnchorDialog(){let e=t(`#${E}`);e.length||(e=t(`<div id="${E}" />`),t("body").append(e)),e.addClass("insert-link__dialog-wrapper"),e.setElement(this),e.open()}}),t(`#${E}`).entwine({ReactRoot:null,renderModal(n){var a=this;const d=ss.store,l=this.getOriginalAttributes(),s=this.getRequireLinkText(),u=Number(t("#Form_EditForm_ID").val()||0);let c=this.getReactRoot();c||(c=(0,i.createRoot)(this[0]),this.setReactRoot(c)),c.render(r.default.createElement(o.Provider,{store:d},r.default.createElement(R,{isOpen:n,onInsert:function(){return a.handleInsert(...arguments)},onClosed:()=>this.close(),title:e.default._t("CMS.LINK_ANCHOR","Link to an anchor on a page"),bodyClassName:"modal__dialog",className:"insert-link__dialog-wrapper--anchor",fileAttributes:l,identifier:"Admin.InsertLinkAnchorModal",requireLinkText:s,currentPageID:u})))},buildAttributes(e){return{href:`${d.default.serialise({name:"sitetree_link",properties:{id:e.PageID}},!0)}${e.Anchor&&e.Anchor.length?`#${e.Anchor}`:""}`,target:e.TargetBlank?"_blank":"",title:e.Description}},getOriginalAttributes(){const e=this.getElement().getEditor(),n=t(e.getSelectedNode()),r=(n.attr("href")||"").split("#");if(!r[0])return{};const i=d.default.match("sitetree_link",!1,r[0]);return i?{PageID:i.properties.id?parseInt(i.properties.id,10):0,Anchor:r[1]||"",Description:n.attr("title"),TargetBlank:!!n.attr("target")}:{}}})})),tinymce.PluginManager.add(p,(e=>f.init(e)))}()}(); |