mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-09-06 17:51:17 +02:00
1 line
4.0 KiB
JavaScript
1 line
4.0 KiB
JavaScript
!function(){"use strict";var e={5964: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"}},9447:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.beginUpdating=function(e){return{type:o.default.ANCHORSELECTOR_UPDATING,payload:{pageId:e}}},t.updateFailed=function(e){return{type:o.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:o.default.ANCHORSELECTOR_UPDATED,payload:{pageId:e,anchors:t,cacheResult:n}}},t.updatedCurrentField=function(e,t,n){return{type:o.default.ANCHORSELECTOR_CURRENT_FIELD,payload:{pageId:e,anchors:t,fieldID:n}}};var r,o=(r=n(5964))&&r.__esModule?r:{default:r}},745:function(e,t,n){var r=n(394);t.createRoot=r.createRoot,t.hydrateRoot=r.hydrateRoot},2939:function(e){e.exports=ApolloClient},6648:function(e){e.exports=Injector},3595:function(e){e.exports=InsertLinkModal},7363:function(e){e.exports=React},394:function(e){e.exports=ReactDom},1624:function(e){e.exports=ReactRedux},5265:function(e){e.exports=ShortcodeSerialiser},2196:function(e){e.exports=TinyMCEActionRegistrar},4754:function(e){e.exports=i18n},5311:function(e){e.exports=jQuery}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}!function(){var e=p(n(4754)),t=p(n(2196)),r=p(n(7363)),o=n(745),i=n(2939),a=n(1624),d=p(n(5311)),l=p(n(5265)),s=n(3595),c=n(6648),u=n(9447);function p(e){return e&&e.__esModule?e:{default:e}}const f="sslinkanchor";t.default.addAction("sslink",{text:e.default._t("CMS.LINKLABEL_ANCHOR","Anchor on a page"),onAction:e=>e.execCommand(f),priority:60},editorIdentifier).addCommandWithUrlTest(f,/^\[sitetree_link.+]#[^#\]]+$/);const E={init(e){e.addCommand(f,(()=>{const t=(0,d.default)(`#${e.id}`).entwine("ss"),n=Number((0,d.default)("#Form_EditForm_ID").val()||0),r=(0,d.default)(e.getBody()).find("[id],[name]").toArray().map((e=>e.id||e.name));ss.store.dispatch((0,u.updatedCurrentField)(n,r,e.id)),t.openLinkAnchorDialog()}))}},R="insert-link__dialog-wrapper--anchor",A=(0,c.provideInjector)((0,s.createInsertLinkModal)("SilverStripe\\CMS\\Controllers\\CMSPageEditController","editorAnchorLink"));d.default.entwine("ss",(t=>{t("textarea.htmleditor").entwine({openLinkAnchorDialog(){let e=t(`#${R}`);e.length||(e=t(`<div id="${R}" />`),t("body").append(e)),e.addClass("insert-link__dialog-wrapper"),e.setElement(this),e.open()}}),t(`#${R}`).entwine({ReactRoot:null,renderModal(n){var d=this;const l=ss.store,s=ss.apolloClient,c=this.getOriginalAttributes(),u=this.getElement().getEditor(),p=u.getInstance().selection,f=u.getSelection(),E="A"!==p.getNode().tagName&&""===f.trim(),R=Number(t("#Form_EditForm_ID").val()||0);let C=this.getReactRoot();C||(C=(0,o.createRoot)(this[0]),this.setReactRoot(C)),C.render(r.default.createElement(i.ApolloProvider,{client:s},r.default.createElement(a.Provider,{store:l},r.default.createElement(A,{isOpen:n,onInsert:function(){return d.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:c,identifier:"Admin.InsertLinkAnchorModal",requireLinkText:E,currentPageID:R}))))},buildAttributes(e){return{href:`${l.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 o=l.default.match("sitetree_link",!1,r[0]);return o?{PageID:o.properties.id?parseInt(o.properties.id,10):0,Anchor:r[1]||"",Description:n.attr("title"),TargetBlank:!!n.attr("target")}:{}}})})),tinymce.PluginManager.add(f,(e=>E.init(e)))}()}(); |