From 4b9c7072cc405a7af9094bc435030d056dcdf5ab Mon Sep 17 00:00:00 2001 From: James O'Toole Date: Fri, 28 Jun 2024 16:43:36 -0700 Subject: [PATCH] Update upcast for columns --- js/build/ubcColumnsFour.js | 2 +- js/build/ubcColumnsThree.js | 2 +- js/build/ubcColumnsTwo.js | 2 +- .../ubcColumnsFour/src/ubccolumnsfourcommand.js | 8 ++++---- .../ubcColumnsFour/src/ubccolumnsfourediting.js | 6 +++++- .../ubcColumnsThree/src/ubccolumnsthreecommand.js | 6 +++--- .../ubcColumnsThree/src/ubccolumnsthreeediting.js | 6 +++++- .../ubcColumnsTwo/src/ubccolumnstwocommand.js | 4 ++-- .../ubcColumnsTwo/src/ubccolumnstwoediting.js | 6 +++++- 9 files changed, 27 insertions(+), 15 deletions(-) diff --git a/js/build/ubcColumnsFour.js b/js/build/ubcColumnsFour.js index ec3031c..3d35712 100644 --- a/js/build/ubcColumnsFour.js +++ b/js/build/ubcColumnsFour.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.CKEditor5=t():(e.CKEditor5=e.CKEditor5||{},e.CKEditor5.ubcColumnsFour=t())}(self,(()=>(()=>{var e={"ckeditor5/src/core.js":(e,t,o)=>{e.exports=o("dll-reference CKEditor5.dll")("./src/core.js")},"ckeditor5/src/ui.js":(e,t,o)=>{e.exports=o("dll-reference CKEditor5.dll")("./src/ui.js")},"ckeditor5/src/utils.js":(e,t,o)=>{e.exports=o("dll-reference CKEditor5.dll")("./src/utils.js")},"ckeditor5/src/widget.js":(e,t,o)=>{e.exports=o("dll-reference CKEditor5.dll")("./src/widget.js")},"dll-reference CKEditor5.dll":e=>{"use strict";e.exports=CKEditor5.dll}},t={};function o(s){var n=t[s];if(void 0!==n)return n.exports;var r=t[s]={exports:{}};return e[s](r,r.exports,o),r.exports}o.d=(e,t)=>{for(var s in t)o.o(t,s)&&!o.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var s={};return(()=>{"use strict";o.d(s,{default:()=>K});var e=o("ckeditor5/src/core.js"),t=o("ckeditor5/src/widget.js");const n=document.querySelector('[data-drupal-selector="drupal-settings-json"]').innerHTML,r=JSON.parse(n),i=(r.ubcCkeditorWidgets.backgroundColors,r.ubcCkeditorWidgets.gapStyles),l=r.ubcCkeditorWidgets.marginStyles,u=(r.ubcCkeditorWidgets.paddingStyles,r.ubcCkeditorWidgets.tableStyles,r.ubcCkeditorWidgets.threeColumnLayoutStyles,r.ubcCkeditorWidgets.twoColumnLayoutStyles,r.ubcCkeditorWidgets.widthStyles,{marginclass:"my-6",gapclass:"gap-6",keylineclass:"widget-keyline-none"}),c={gapclass:"gap-6"};class a extends e.Command{constructor(e,t){super(e),this.attributeName=t}execute(){const e=this.editor,t=this.editor.model,o=e.model.document.selection,s=o.getSelectedElement();let n="";n=s&&s.is("element","ubcColumnsFour")?s:o.getFirstPosition().findAncestor("ubcColumnsFour"),t.change((e=>{t.insertContent(function(e){const t=e.createElement("ubcColumnsFour",u,{class:"widget-column-options widget-columns-4 align-equal"}),o=e.createElement("ubcColumnsFourColumn",{class:"widget-region-one"}),s=e.createElement("ubcColumnsFourColumn",{class:"widget-region-two"}),n=e.createElement("ubcColumnsFourColumn",{class:"widget-region-three"}),r=e.createElement("ubcColumnsFourColumn",{class:"widget-region-four"}),i=e.createElement("ubcColumnsFourWrapper",c,{class:"widget--md--grid"});return e.append(i,t),e.append(o,i),e.appendElement("paragraph",o),e.append(s,i),e.appendElement("paragraph",s),e.append(n,i),e.appendElement("paragraph",n),e.append(r,i),e.appendElement("paragraph",r),t}(e))}))}refresh(){const{model:e}=this.editor,{selection:t}=e.document,o=t.getFirstPosition().findAncestor("ubcColumnsFour"),s=e.schema.findAllowedParent(t.getFirstPosition(),"ubcColumnsFour");this.isEnabled=null!==s,this.value=!!o}}class d extends e.Plugin{static get requires(){return[t.Widget]}constructor(e){super(e)}init(){const e=this.editor;e.conversion.attributeToAttribute({model:"class",view:"class"}),this._defineSchema(),this._defineConverters(),e.commands.add("ubcColumnsFour",new a(e))}_defineSchema(){const e=this.editor.model.schema;e.register("ubcColumnsFour",{isObject:!0,allowWhere:"$block",allowChildren:["ubcColumnsFourWrapper"]}),e.register("ubcColumnsFourWrapper",{isLimit:!0,allowIn:"ubcColumnsFour",allowChildren:["ubcColumnsFourColumn"]}),e.register("ubcColumnsFourColumn",{isLimit:!0,allowIn:"ubcColumnsFour",allowContentOf:"$root",allowAttributes:"class"}),e.addChildCheck(((e,t)=>{}))}_defineConverters(){const{conversion:e}=this.editor;e.for("upcast").elementToElement({model:"ubcColumnsFour",view:{name:"div",classes:["widget-columns-4"]}}),e.for("upcast").elementToElement({model:"ubcColumnsFourWrapper",view:{name:"div"}}),e.for("upcast").elementToElement({model:"ubcColumnsFourColumn",view:{name:"div",classes:["first-child--mt-0"]}}),e.for("dataDowncast").elementToElement({model:"ubcColumnsFour",view:(e,{writer:t})=>t.createContainerElement("div",{class:"widget-column-options widget-columns-4 align-equal"})}),e.for("dataDowncast").elementToElement({model:"ubcColumnsFourWrapper",view:(e,{writer:t})=>t.createContainerElement("div",{class:"widget--md--grid"})}),e.for("dataDowncast").elementToElement({model:"ubcColumnsFourColumn",view:(e,{writer:t})=>t.createContainerElement("div",{class:"first-child--mt-0"})}),e.for("editingDowncast").elementToElement({model:"ubcColumnsFour",view:(e,{writer:o})=>{const s=o.createContainerElement("div",{class:"widget-column-options widget-columns-4 align-equal"});return(0,t.toWidget)(s,o,{label:"UBC Four Columns widget",hasSelectionHandle:!0})}}),e.for("editingDowncast").elementToElement({model:"ubcColumnsFourWrapper",view:(e,{writer:o})=>{const s=o.createEditableElement("div",{class:"widget--md--grid"});return(0,t.toWidgetEditable)(s,o)}}),e.for("editingDowncast").elementToElement({model:"ubcColumnsFourColumn",view:(e,{writer:o})=>{const s=o.createEditableElement("div",{class:"first-child--mt-0"});return(0,t.toWidgetEditable)(s,o)}})}}var m=o("ckeditor5/src/ui.js");class g extends e.Plugin{static get requires(){return[m.ContextualBalloon]}init(){const e=this.editor;e.ui.componentFactory.add("ubcColumnsFour",(t=>{const o=e.commands.get("ubcColumnsFour"),s=new m.ButtonView(t);return s.set({label:e.t("Four Columns"),icon:'',tooltip:!0,class:"cke5-ubccolumnsfour-insert-button"}),s.bind("isOn","isEnabled").to(o,"value","isEnabled"),this.listenTo(s,"execute",(()=>e.execute("ubcColumnsFour"))),s}))}}function b(e){const t=e.getSelectedElement();return t&&C(t)?t:null}function p(e){const t=e.getFirstPosition();if(!t)return null;let o=t.parent;for(;o;){if(o.is("element")&&C(o))return o;o=o.parent}return null}function C(e){return!!e.hasClass("widget-columns-4")&&(0,t.isWidget)(e)}class w extends e.Plugin{static get requires(){return[t.WidgetToolbarRepository]}static get pluginName(){return"UbcColumnsFourToolbar"}afterInit(){const e=this.editor,o=e.plugins.get(t.WidgetToolbarRepository),s=e.config.get("ubcColumnsFour.contentToolbar"),n=e.config.get("ubcColumnsFour.tableToolbar");s&&o.register("ubcColumnsFourContent",{ariaLabel:e.t("Four Columns toolbar"),items:s,getRelatedElement:p}),n&&o.register("ubcColumnsFour",{ariaLabel:e.t("Four Columns toolbar"),items:n,getRelatedElement:b})}}class h extends e.Command{constructor(e){super(e)}execute(e={}){const{editor:t}=this,{model:o}=this.editor,{selection:s}=t.model.document,n=s.getSelectedElement();let r="";const i=e.value,l="gapclass";r=n&&n.is("element","ubcColumnsFour")?n.getChild(0):s.getFirstPosition().findAncestor("ubcColumnsFour").getChild(0),o.change((e=>{if(s.isCollapsed)i?e.setAttribute(l,i,r):e.removeAttribute(l,r);else{const t=o.schema.getValidRanges(s.getRanges(),l);for(const o of t)i?(e.setAttribute(l,i,o),this.value=i):e.removeAttribute(l,o)}}))}refresh(){const{model:e}=this.editor,{selection:t}=e.document,o=t.getFirstPosition().findAncestor("ubcColumnsFour"),s=e.schema.findAllowedParent(t.getFirstPosition(),"ubcColumnsFour");this.isEnabled=null!==s,this.value=!!o&&o.getChild(0).getAttribute("gapclass")}}class v extends e.Plugin{static get requires(){return[t.Widget]}static get pluginName(){return"UbcColumnsFourGapEditing"}constructor(e){super(e)}init(){const{editor:e}=this;this._defineConverters(),e.model.schema.extend("ubcColumnsFourWrapper",{allowAttributes:"gapclass"}),e.conversion.attributeToAttribute({model:"gapclass",view:"class"}),e.commands.add("ubcColumnsFourGap",new h(e))}_defineConverters(){const{conversion:e}=this.editor;e.for("upcast").attributeToAttribute({view:{key:"class",value:/\bgap-[\S]+/},model:{key:"gapclass",value:e=>e.getAttribute("class").match(/\bgap-([\S]+)/)[0]}}),e.for("downcast").attributeToAttribute({model:"gapclass",view:e=>({key:"class",value:e})})}}var f=o("ckeditor5/src/utils.js");class F extends e.Plugin{static get pluginName(){return"UbcColumnsFourGapUI"}init(){const e=this.editor,t=e.t;i.map((e=>e)).value;const o=e.commands.get("ubcColumnsFourGap");e.ui.componentFactory.add("ubcColumnsFourGapOptions",(s=>{const n=(0,m.createDropdown)(s);return(0,m.addListToDropdown)(n,function(e,t){const o=new f.Collection,s="ubcColumnsFourGap";let n=i.map((e=>e));for(const e of n){const n={type:"button",model:new m.ViewModel({commandName:s,commandParam:e.value,label:e.label,withText:!0})};n.model.bind("isOn").to(t,"value",(t=>t===e.value||!(!t||!e.value)&&t.toLowerCase()===e.value.toLowerCase())),o.add(n)}return o}(0,o)),n.buttonView.set({label:t("Gap"),tooltip:!0,withText:!0,class:"cke5-ubccolumnsfour-gap-insert-button"}),n.extendTemplate({attributes:{class:"ck-gap-options-dropdown"}}),n.bind("isEnabled").to(o),this.listenTo(n,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),n}))}}class y extends e.Plugin{static get requires(){return[v,F]}static get pluginName(){return"UbcColumnsFourGap"}}class E extends e.Command{constructor(e){super(e)}execute(e={}){const{editor:t}=this,{model:o}=this.editor,{selection:s}=t.model.document,n=s.getSelectedElement();let r="";const i="keylineclass";r=n&&n.is("element","ubcColumnsFour")?n:s.getFirstPosition().findAncestor("ubcColumnsFour");let l=r.getAttribute(i);o.change((e=>{"widget-keylines"===l?(e.setAttribute(i,"widget-keyline-none",r),this.isOn=!1):(e.setAttribute(i,"widget-keylines",r),this.isOn=!0)}))}refresh(){const{model:e}=this.editor,{selection:t}=e.document,o=t.getFirstPosition().findAncestor("ubcColumnsFour"),s=e.schema.findAllowedParent(t.getFirstPosition(),"ubcColumnsFour");this.isEnabled=null!==s,this.value=!!o&&o.getAttribute("keylineclass")}}class x extends e.Plugin{static get requires(){return[t.Widget]}static get pluginName(){return"UbcColumnsFourKeylineEditing"}constructor(e){super(e)}init(){const{editor:e}=this;this._defineConverters(),e.model.schema.extend("ubcColumnsFour",{allowAttributes:"keylineclass"}),e.conversion.attributeToAttribute({model:"keylineclass",view:"class"}),e.commands.add("ubcColumnsFourKeyline",new E(e))}_defineConverters(){const{conversion:e}=this.editor;e.for("upcast").attributeToAttribute({view:{key:"class",value:/widget-keyline[\S]+/},model:{key:"keylineclass",value:e=>e.getAttribute("class").match(/widget-keyline([\S]+)/)[0]}}),e.for("downcast").attributeToAttribute({model:"shadowclass",view:e=>({key:"class",value:e})})}}class k extends e.Plugin{static get requires(){return[m.ContextualBalloon]}static get pluginName(){return"UbcColumnsFourKeylineUI"}init(){const e=this.editor;e.ui.componentFactory.add("ubcColumnsFourKeylineToggle",(t=>{const o=e.commands.get("ubcColumnsFourKeyline"),s=new m.ButtonView(t);return s.set({label:e.t("Toggle Keylines"),tooltip:!0,withText:!0,class:"cke5-ubccolumnsfour-keyline-insert-button"}),s.bind("isEnabled").to(o),s.bind("isOn").to(o),this.listenTo(s,"execute",(()=>e.execute("ubcColumnsFourKeyline"))),s}))}}class A extends e.Plugin{static get requires(){return[x,k]}static get pluginName(){return"UbcColumnsFourKeyline"}}class T extends e.Command{constructor(e){super(e)}execute(e={}){const{editor:t}=this,{model:o}=this.editor,{selection:s}=t.model.document,n=s.getSelectedElement();let r="";const i=e.value,l="marginclass";r=n&&n.is("element","ubcColumnsFour")?n:s.getFirstPosition().findAncestor("ubcColumnsFour"),o.change((e=>{if(s.isCollapsed)i?e.setAttribute(l,i,r):e.removeAttribute(l,r);else{const t=o.schema.getValidRanges(s.getRanges(),l);for(const o of t)i?e.setAttribute(l,i,o):e.removeAttribute(l,o)}}))}refresh(){const{model:e}=this.editor,{selection:t}=e.document,o=t.getFirstPosition().findAncestor("ubcColumnsFour"),s=e.schema.findAllowedParent(t.getFirstPosition(),"ubcColumnsFour");this.isEnabled=null!==s,this.value=!!o&&o.getAttribute("marginclass")}}class P extends e.Plugin{static get requires(){return[t.Widget]}static get pluginName(){return"UbcColumnsFourMarginEditing"}constructor(e){super(e)}init(){const{editor:e}=this;this._defineConverters(),e.model.schema.extend("ubcColumnsFour",{allowAttributes:"marginclass"}),e.conversion.attributeToAttribute({model:"marginclass",view:"class"}),e.commands.add("ubcColumnsFourMargin",new T(e))}_defineConverters(){const{conversion:e}=this.editor;e.for("upcast").attributeToAttribute({view:{key:"class",value:/\bmy-[\S]+/},model:{key:"marginclass",value:e=>e.getAttribute("class").match(/\bmy-([\S]+)/)[0]}}),e.for("downcast").attributeToAttribute({model:"marginclass",view:e=>({key:"class",value:e})})}}class W extends e.Plugin{static get pluginName(){return"UbcColumnsFourMarginUI"}init(){const e=this.editor,t=e.t;l.map((e=>e)).value;const o=e.commands.get("ubcColumnsFourMargin");e.ui.componentFactory.add("ubcColumnsFourMarginOptions",(s=>{const n=(0,m.createDropdown)(s);return(0,m.addListToDropdown)(n,function(e,t){const o=new f.Collection,s="ubcColumnsFourMargin";let n=l.map((e=>e));for(const e of n){const n={type:"button",model:new m.ViewModel({commandName:s,commandParam:e.value,label:e.label,withText:!0})};n.model.bind("isOn").to(t,"value",(t=>t===e.value||!(!t||!e.value)&&t.toLowerCase()===e.value.toLowerCase())),o.add(n)}return o}(0,o)),n.buttonView.set({label:t("Margin"),tooltip:!0,withText:!0,class:"cke5-ubccolumnsfour-margin-insert-button"}),n.extendTemplate({attributes:{class:"ck-margin-options-dropdown"}}),n.bind("isEnabled").to(o),this.listenTo(n,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),n}))}}class S extends e.Plugin{static get requires(){return[P,W]}static get pluginName(){return"UbcColumnsFourMargin"}}class j extends e.Plugin{static get requires(){return[d,g,w,y,S,A]}}const K={UbcColumnsFour:j}})(),s=s.default})())); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.CKEditor5=t():(e.CKEditor5=e.CKEditor5||{},e.CKEditor5.ubcColumnsFour=t())}(self,(()=>(()=>{var e={"ckeditor5/src/core.js":(e,t,o)=>{e.exports=o("dll-reference CKEditor5.dll")("./src/core.js")},"ckeditor5/src/ui.js":(e,t,o)=>{e.exports=o("dll-reference CKEditor5.dll")("./src/ui.js")},"ckeditor5/src/utils.js":(e,t,o)=>{e.exports=o("dll-reference CKEditor5.dll")("./src/utils.js")},"ckeditor5/src/widget.js":(e,t,o)=>{e.exports=o("dll-reference CKEditor5.dll")("./src/widget.js")},"dll-reference CKEditor5.dll":e=>{"use strict";e.exports=CKEditor5.dll}},t={};function o(s){var n=t[s];if(void 0!==n)return n.exports;var i=t[s]={exports:{}};return e[s](i,i.exports,o),i.exports}o.d=(e,t)=>{for(var s in t)o.o(t,s)&&!o.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var s={};return(()=>{"use strict";o.d(s,{default:()=>K});var e=o("ckeditor5/src/core.js"),t=o("ckeditor5/src/widget.js");const n=document.querySelector('[data-drupal-selector="drupal-settings-json"]').innerHTML,i=JSON.parse(n),r=(i.ubcCkeditorWidgets.backgroundColors,i.ubcCkeditorWidgets.gapStyles),l=i.ubcCkeditorWidgets.marginStyles,u=(i.ubcCkeditorWidgets.paddingStyles,i.ubcCkeditorWidgets.tableStyles,i.ubcCkeditorWidgets.threeColumnLayoutStyles,i.ubcCkeditorWidgets.twoColumnLayoutStyles,i.ubcCkeditorWidgets.widthStyles,{marginclass:"my-6",gapclass:"gap-6",keylineclass:"widget-keyline-none"}),c={gapclass:"gap-6"};class a extends e.Command{constructor(e,t){super(e),this.attributeName=t}execute(){const e=this.editor,t=this.editor.model,o=e.model.document.selection,s=o.getSelectedElement();let n="";n=s&&s.is("element","ubcColumnsFour")?s:o.getFirstPosition().findAncestor("ubcColumnsFour"),t.change((e=>{t.insertContent(function(e){const t=e.createElement("ubcColumnsFour",u,{class:"widget-column-options widget-columns-4 align-equal"}),o=e.createElement("ubcColumnsFourColumn",{class:"widget-region-one first-child--mt-0"}),s=e.createElement("ubcColumnsFourColumn",{class:"widget-region-two first-child--mt-0"}),n=e.createElement("ubcColumnsFourColumn",{class:"widget-region-three first-child--mt-0"}),i=e.createElement("ubcColumnsFourColumn",{class:"widget-region-four first-child--mt-0"}),r=e.createElement("ubcColumnsFourWrapper",c,{class:"widget--md--grid"});return e.append(r,t),e.append(o,r),e.appendElement("paragraph",o),e.append(s,r),e.appendElement("paragraph",s),e.append(n,r),e.appendElement("paragraph",n),e.append(i,r),e.appendElement("paragraph",i),t}(e))}))}refresh(){const{model:e}=this.editor,{selection:t}=e.document,o=t.getFirstPosition().findAncestor("ubcColumnsFour"),s=e.schema.findAllowedParent(t.getFirstPosition(),"ubcColumnsFour");this.isEnabled=null!==s,this.value=!!o}}class d extends e.Plugin{static get requires(){return[t.Widget]}constructor(e){super(e)}init(){const e=this.editor;e.conversion.attributeToAttribute({model:"class",view:"class"}),this._defineSchema(),this._defineConverters(),e.commands.add("ubcColumnsFour",new a(e))}_defineSchema(){const e=this.editor.model.schema;e.register("ubcColumnsFour",{isObject:!0,allowWhere:"$block",allowChildren:["ubcColumnsFourWrapper"]}),e.register("ubcColumnsFourWrapper",{isLimit:!0,allowIn:"ubcColumnsFour",allowChildren:["ubcColumnsFourColumn"]}),e.register("ubcColumnsFourColumn",{isLimit:!0,allowIn:"ubcColumnsFour",allowContentOf:"$root",allowAttributes:"class"}),e.addChildCheck(((e,t)=>{}))}_defineConverters(){const{conversion:e}=this.editor;e.for("upcast").elementToElement({model:"ubcColumnsFour",view:{name:"div",classes:["widget-columns-4"]}}),e.for("upcast").elementToElement({model:"ubcColumnsFourWrapper",view:{name:"div"}}),e.for("upcast").elementToElement({model:(e,{writer:t})=>t.createElement("ubcColumnsFourColumn",{class:e.getAttribute("class")}),view:{name:"div",classes:["first-child--mt-0"]}}),e.for("dataDowncast").elementToElement({model:"ubcColumnsFour",view:(e,{writer:t})=>t.createContainerElement("div",{class:"widget-column-options widget-columns-4 align-equal"})}),e.for("dataDowncast").elementToElement({model:"ubcColumnsFourWrapper",view:(e,{writer:t})=>t.createContainerElement("div",{class:"widget--md--grid"})}),e.for("dataDowncast").elementToElement({model:"ubcColumnsFourColumn",view:(e,{writer:t})=>t.createContainerElement("div",{class:"first-child--mt-0"})}),e.for("editingDowncast").elementToElement({model:"ubcColumnsFour",view:(e,{writer:o})=>{const s=o.createContainerElement("div",{class:"widget-column-options widget-columns-4 align-equal"});return(0,t.toWidget)(s,o,{label:"UBC Four Columns widget",hasSelectionHandle:!0})}}),e.for("editingDowncast").elementToElement({model:"ubcColumnsFourWrapper",view:(e,{writer:o})=>{const s=o.createEditableElement("div",{class:"widget--md--grid"});return(0,t.toWidgetEditable)(s,o)}}),e.for("editingDowncast").elementToElement({model:"ubcColumnsFourColumn",view:(e,{writer:o})=>{const s=o.createEditableElement("div",{class:"first-child--mt-0"});return(0,t.toWidgetEditable)(s,o)}})}}var m=o("ckeditor5/src/ui.js");class g extends e.Plugin{static get requires(){return[m.ContextualBalloon]}init(){const e=this.editor;e.ui.componentFactory.add("ubcColumnsFour",(t=>{const o=e.commands.get("ubcColumnsFour"),s=new m.ButtonView(t);return s.set({label:e.t("Four Columns"),icon:'',tooltip:!0,class:"cke5-ubccolumnsfour-insert-button"}),s.bind("isOn","isEnabled").to(o,"value","isEnabled"),this.listenTo(s,"execute",(()=>e.execute("ubcColumnsFour"))),s}))}}function b(e){const t=e.getSelectedElement();return t&&C(t)?t:null}function p(e){const t=e.getFirstPosition();if(!t)return null;let o=t.parent;for(;o;){if(o.is("element")&&C(o))return o;o=o.parent}return null}function C(e){return!!e.hasClass("widget-columns-4")&&(0,t.isWidget)(e)}class w extends e.Plugin{static get requires(){return[t.WidgetToolbarRepository]}static get pluginName(){return"UbcColumnsFourToolbar"}afterInit(){const e=this.editor,o=e.plugins.get(t.WidgetToolbarRepository),s=e.config.get("ubcColumnsFour.contentToolbar"),n=e.config.get("ubcColumnsFour.tableToolbar");s&&o.register("ubcColumnsFourContent",{ariaLabel:e.t("Four Columns toolbar"),items:s,getRelatedElement:p}),n&&o.register("ubcColumnsFour",{ariaLabel:e.t("Four Columns toolbar"),items:n,getRelatedElement:b})}}class h extends e.Command{constructor(e){super(e)}execute(e={}){const{editor:t}=this,{model:o}=this.editor,{selection:s}=t.model.document,n=s.getSelectedElement();let i="";const r=e.value,l="gapclass";i=n&&n.is("element","ubcColumnsFour")?n.getChild(0):s.getFirstPosition().findAncestor("ubcColumnsFour").getChild(0),o.change((e=>{if(s.isCollapsed)r?e.setAttribute(l,r,i):e.removeAttribute(l,i);else{const t=o.schema.getValidRanges(s.getRanges(),l);for(const o of t)r?(e.setAttribute(l,r,o),this.value=r):e.removeAttribute(l,o)}}))}refresh(){const{model:e}=this.editor,{selection:t}=e.document,o=t.getFirstPosition().findAncestor("ubcColumnsFour"),s=e.schema.findAllowedParent(t.getFirstPosition(),"ubcColumnsFour");this.isEnabled=null!==s,this.value=!!o&&o.getChild(0).getAttribute("gapclass")}}class f extends e.Plugin{static get requires(){return[t.Widget]}static get pluginName(){return"UbcColumnsFourGapEditing"}constructor(e){super(e)}init(){const{editor:e}=this;this._defineConverters(),e.model.schema.extend("ubcColumnsFourWrapper",{allowAttributes:"gapclass"}),e.conversion.attributeToAttribute({model:"gapclass",view:"class"}),e.commands.add("ubcColumnsFourGap",new h(e))}_defineConverters(){const{conversion:e}=this.editor;e.for("upcast").attributeToAttribute({view:{key:"class",value:/\bgap-[\S]+/},model:{key:"gapclass",value:e=>e.getAttribute("class").match(/\bgap-([\S]+)/)[0]}}),e.for("downcast").attributeToAttribute({model:"gapclass",view:e=>({key:"class",value:e})})}}var v=o("ckeditor5/src/utils.js");class F extends e.Plugin{static get pluginName(){return"UbcColumnsFourGapUI"}init(){const e=this.editor,t=e.t;r.map((e=>e)).value;const o=e.commands.get("ubcColumnsFourGap");e.ui.componentFactory.add("ubcColumnsFourGapOptions",(s=>{const n=(0,m.createDropdown)(s);return(0,m.addListToDropdown)(n,function(e,t){const o=new v.Collection,s="ubcColumnsFourGap";let n=r.map((e=>e));for(const e of n){const n={type:"button",model:new m.ViewModel({commandName:s,commandParam:e.value,label:e.label,withText:!0})};n.model.bind("isOn").to(t,"value",(t=>t===e.value||!(!t||!e.value)&&t.toLowerCase()===e.value.toLowerCase())),o.add(n)}return o}(0,o)),n.buttonView.set({label:t("Gap"),tooltip:!0,withText:!0,class:"cke5-ubccolumnsfour-gap-insert-button"}),n.extendTemplate({attributes:{class:"ck-gap-options-dropdown"}}),n.bind("isEnabled").to(o),this.listenTo(n,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),n}))}}class E extends e.Plugin{static get requires(){return[f,F]}static get pluginName(){return"UbcColumnsFourGap"}}class y extends e.Command{constructor(e){super(e)}execute(e={}){const{editor:t}=this,{model:o}=this.editor,{selection:s}=t.model.document,n=s.getSelectedElement();let i="";const r="keylineclass";i=n&&n.is("element","ubcColumnsFour")?n:s.getFirstPosition().findAncestor("ubcColumnsFour");let l=i.getAttribute(r);o.change((e=>{"widget-keylines"===l?(e.setAttribute(r,"widget-keyline-none",i),this.isOn=!1):(e.setAttribute(r,"widget-keylines",i),this.isOn=!0)}))}refresh(){const{model:e}=this.editor,{selection:t}=e.document,o=t.getFirstPosition().findAncestor("ubcColumnsFour"),s=e.schema.findAllowedParent(t.getFirstPosition(),"ubcColumnsFour");this.isEnabled=null!==s,this.value=!!o&&o.getAttribute("keylineclass")}}class x extends e.Plugin{static get requires(){return[t.Widget]}static get pluginName(){return"UbcColumnsFourKeylineEditing"}constructor(e){super(e)}init(){const{editor:e}=this;this._defineConverters(),e.model.schema.extend("ubcColumnsFour",{allowAttributes:"keylineclass"}),e.conversion.attributeToAttribute({model:"keylineclass",view:"class"}),e.commands.add("ubcColumnsFourKeyline",new y(e))}_defineConverters(){const{conversion:e}=this.editor;e.for("upcast").attributeToAttribute({view:{key:"class",value:/widget-keyline[\S]+/},model:{key:"keylineclass",value:e=>e.getAttribute("class").match(/widget-keyline([\S]+)/)[0]}}),e.for("downcast").attributeToAttribute({model:"shadowclass",view:e=>({key:"class",value:e})})}}class k extends e.Plugin{static get requires(){return[m.ContextualBalloon]}static get pluginName(){return"UbcColumnsFourKeylineUI"}init(){const e=this.editor;e.ui.componentFactory.add("ubcColumnsFourKeylineToggle",(t=>{const o=e.commands.get("ubcColumnsFourKeyline"),s=new m.ButtonView(t);return s.set({label:e.t("Toggle Keylines"),tooltip:!0,withText:!0,class:"cke5-ubccolumnsfour-keyline-insert-button"}),s.bind("isEnabled").to(o),s.bind("isOn").to(o),this.listenTo(s,"execute",(()=>e.execute("ubcColumnsFourKeyline"))),s}))}}class A extends e.Plugin{static get requires(){return[x,k]}static get pluginName(){return"UbcColumnsFourKeyline"}}class T extends e.Command{constructor(e){super(e)}execute(e={}){const{editor:t}=this,{model:o}=this.editor,{selection:s}=t.model.document,n=s.getSelectedElement();let i="";const r=e.value,l="marginclass";i=n&&n.is("element","ubcColumnsFour")?n:s.getFirstPosition().findAncestor("ubcColumnsFour"),o.change((e=>{if(s.isCollapsed)r?e.setAttribute(l,r,i):e.removeAttribute(l,i);else{const t=o.schema.getValidRanges(s.getRanges(),l);for(const o of t)r?e.setAttribute(l,r,o):e.removeAttribute(l,o)}}))}refresh(){const{model:e}=this.editor,{selection:t}=e.document,o=t.getFirstPosition().findAncestor("ubcColumnsFour"),s=e.schema.findAllowedParent(t.getFirstPosition(),"ubcColumnsFour");this.isEnabled=null!==s,this.value=!!o&&o.getAttribute("marginclass")}}class P extends e.Plugin{static get requires(){return[t.Widget]}static get pluginName(){return"UbcColumnsFourMarginEditing"}constructor(e){super(e)}init(){const{editor:e}=this;this._defineConverters(),e.model.schema.extend("ubcColumnsFour",{allowAttributes:"marginclass"}),e.conversion.attributeToAttribute({model:"marginclass",view:"class"}),e.commands.add("ubcColumnsFourMargin",new T(e))}_defineConverters(){const{conversion:e}=this.editor;e.for("upcast").attributeToAttribute({view:{key:"class",value:/\bmy-[\S]+/},model:{key:"marginclass",value:e=>e.getAttribute("class").match(/\bmy-([\S]+)/)[0]}}),e.for("downcast").attributeToAttribute({model:"marginclass",view:e=>({key:"class",value:e})})}}class W extends e.Plugin{static get pluginName(){return"UbcColumnsFourMarginUI"}init(){const e=this.editor,t=e.t;l.map((e=>e)).value;const o=e.commands.get("ubcColumnsFourMargin");e.ui.componentFactory.add("ubcColumnsFourMarginOptions",(s=>{const n=(0,m.createDropdown)(s);return(0,m.addListToDropdown)(n,function(e,t){const o=new v.Collection,s="ubcColumnsFourMargin";let n=l.map((e=>e));for(const e of n){const n={type:"button",model:new m.ViewModel({commandName:s,commandParam:e.value,label:e.label,withText:!0})};n.model.bind("isOn").to(t,"value",(t=>t===e.value||!(!t||!e.value)&&t.toLowerCase()===e.value.toLowerCase())),o.add(n)}return o}(0,o)),n.buttonView.set({label:t("Margin"),tooltip:!0,withText:!0,class:"cke5-ubccolumnsfour-margin-insert-button"}),n.extendTemplate({attributes:{class:"ck-margin-options-dropdown"}}),n.bind("isEnabled").to(o),this.listenTo(n,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),n}))}}class S extends e.Plugin{static get requires(){return[P,W]}static get pluginName(){return"UbcColumnsFourMargin"}}class j extends e.Plugin{static get requires(){return[d,g,w,E,S,A]}}const K={UbcColumnsFour:j}})(),s=s.default})())); \ No newline at end of file diff --git a/js/build/ubcColumnsThree.js b/js/build/ubcColumnsThree.js index 8528590..1eb715f 100644 --- a/js/build/ubcColumnsThree.js +++ b/js/build/ubcColumnsThree.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.CKEditor5=t():(e.CKEditor5=e.CKEditor5||{},e.CKEditor5.ubcColumnsThree=t())}(self,(()=>(()=>{var e={"ckeditor5/src/core.js":(e,t,s)=>{e.exports=s("dll-reference CKEditor5.dll")("./src/core.js")},"ckeditor5/src/ui.js":(e,t,s)=>{e.exports=s("dll-reference CKEditor5.dll")("./src/ui.js")},"ckeditor5/src/utils.js":(e,t,s)=>{e.exports=s("dll-reference CKEditor5.dll")("./src/utils.js")},"ckeditor5/src/widget.js":(e,t,s)=>{e.exports=s("dll-reference CKEditor5.dll")("./src/widget.js")},"dll-reference CKEditor5.dll":e=>{"use strict";e.exports=CKEditor5.dll}},t={};function s(o){var n=t[o];if(void 0!==n)return n.exports;var i=t[o]={exports:{}};return e[o](i,i.exports,s),i.exports}s.d=(e,t)=>{for(var o in t)s.o(t,o)&&!s.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var o={};return(()=>{"use strict";s.d(o,{default:()=>q});var e=s("ckeditor5/src/core.js"),t=s("ckeditor5/src/widget.js");const n=document.querySelector('[data-drupal-selector="drupal-settings-json"]').innerHTML,i=JSON.parse(n),r=(i.ubcCkeditorWidgets.backgroundColors,i.ubcCkeditorWidgets.gapStyles),l=i.ubcCkeditorWidgets.marginStyles,c=(i.ubcCkeditorWidgets.paddingStyles,i.ubcCkeditorWidgets.tableStyles,i.ubcCkeditorWidgets.threeColumnLayoutStyles),a=(i.ubcCkeditorWidgets.twoColumnLayoutStyles,i.ubcCkeditorWidgets.widthStyles,{layoutcol3class:"align-equal",marginclass:"my-6",gapclass:"gap-6",keylineclass:"widget-keyline-none"}),u={gapclass:"gap-6"};class d extends e.Command{constructor(e,t){super(e),this.attributeName=t}execute(){const e=this.editor,t=this.editor.model,s=e.model.document.selection,o=s.getSelectedElement();let n="";n=o&&o.is("element","ubcColumnsThree")?o:s.getFirstPosition().findAncestor("ubcColumnsThree"),t.change((e=>{t.insertContent(function(e){const t=e.createElement("ubcColumnsThree",a,{class:"widget-column-options widget-columns-3"}),s=e.createElement("ubcColumnsThreeColumn",{class:"widget-region-one"}),o=e.createElement("ubcColumnsThreeColumn",{class:"widget-region-two"}),n=e.createElement("ubcColumnsThreeColumn",{class:"widget-region-three"}),i=e.createElement("ubcColumnsThreeWrapper",u,{class:"widget--md--grid"});return e.append(i,t),e.append(s,i),e.appendElement("paragraph",s),e.append(o,i),e.appendElement("paragraph",o),e.append(n,i),e.appendElement("paragraph",n),t}(e))}))}refresh(){const{model:e}=this.editor,{selection:t}=e.document,s=t.getFirstPosition().findAncestor("ubcColumnsThree"),o=e.schema.findAllowedParent(t.getFirstPosition(),"ubcColumnsThree");this.isEnabled=null!==o,this.value=!!s}}class m extends e.Plugin{static get requires(){return[t.Widget]}constructor(e){super(e)}init(){const e=this.editor;e.conversion.attributeToAttribute({model:"class",view:"class"}),this._defineSchema(),this._defineConverters(),e.commands.add("ubcColumnsThree",new d(e))}_defineSchema(){const e=this.editor.model.schema;e.register("ubcColumnsThree",{isObject:!0,allowWhere:"$block",allowChildren:["ubcColumnsThreeColumn"]}),e.register("ubcColumnsThreeWrapper",{isLimit:!0,allowIn:"ubcColumnsThree",allowChildren:["ubcColumnsThreeColumn"]}),e.register("ubcColumnsThreeColumn",{isLimit:!0,allowIn:"ubcColumnsThree",allowAttributes:"class",allowContentOf:"$root"}),e.addChildCheck(((e,t)=>{}))}_defineConverters(){const{conversion:e}=this.editor;e.for("upcast").elementToElement({model:"ubcColumnsThree",view:{name:"div",classes:["widget-columns-3"]}}),e.for("upcast").elementToElement({model:"ubcColumnsThreeWrapper",view:{name:"div",classes:"widget--md--grid"}}),e.for("upcast").elementToElement({model:"ubcColumnsThreeColumn",view:{name:"div",classes:["first-child--mt-0"]}}),e.for("dataDowncast").elementToElement({model:"ubcColumnsThree",view:(e,{writer:t})=>t.createContainerElement("div",{class:"widget-column-options widget-columns-3"})}),e.for("dataDowncast").elementToElement({model:"ubcColumnsThreeWrapper",view:(e,{writer:t})=>t.createContainerElement("div",{class:"widget--md--grid"})}),e.for("dataDowncast").elementToElement({model:"ubcColumnsThreeColumn",view:(e,{writer:t})=>t.createContainerElement("div",{class:"first-child--mt-0"})}),e.for("editingDowncast").elementToElement({model:"ubcColumnsThree",view:(e,{writer:s})=>{const o=s.createContainerElement("div",{class:"widget-column-options widget-columns-3"});return(0,t.toWidget)(o,s,{label:"UBC Three Columns widget",hasSelectionHandle:!0})}}),e.for("editingDowncast").elementToElement({model:"ubcColumnsThreeWrapper",view:(e,{writer:s})=>{const o=s.createEditableElement("div",{class:"widget--md--grid"});return(0,t.toWidgetEditable)(o,s)}}),e.for("editingDowncast").elementToElement({model:"ubcColumnsThreeColumn",view:(e,{writer:s})=>{const o=s.createEditableElement("div",{class:"first-child--mt-0"});return(0,t.toWidgetEditable)(o,s)}})}}var g=s("ckeditor5/src/ui.js");class b extends e.Plugin{static get requires(){return[g.ContextualBalloon]}init(){const e=this.editor;e.ui.componentFactory.add("ubcColumnsThree",(t=>{const s=e.commands.get("ubcColumnsThree"),o=new g.ButtonView(t);return o.set({label:e.t("Three Columns"),icon:'',tooltip:!0,class:"cke5-ubccolumnsthree-insert-button"}),o.bind("isOn","isEnabled").to(s,"value","isEnabled"),this.listenTo(o,"execute",(()=>e.execute("ubcColumnsThree"))),o}))}}function h(e){const t=e.getSelectedElement();return t&&p(t)?t:null}function C(e){const t=e.getFirstPosition();if(!t)return null;let s=t.parent;for(;s;){if(s.is("element")&&p(s))return s;s=s.parent}return null}function p(e){return!!e.hasClass("widget-columns-3")&&(0,t.isWidget)(e)}class T extends e.Plugin{static get requires(){return[t.WidgetToolbarRepository]}static get pluginName(){return"UbcColumnsThreeToolbar"}afterInit(){const e=this.editor,s=e.plugins.get(t.WidgetToolbarRepository),o=e.config.get("ubcColumnsThree.contentToolbar"),n=e.config.get("ubcColumnsThree.tableToolbar");o&&s.register("ubcColumnsThreeContent",{ariaLabel:e.t("Three Columns toolbar"),items:o,getRelatedElement:C}),n&&s.register("ubcColumnsThree",{ariaLabel:e.t("Three Columns toolbar"),items:n,getRelatedElement:h})}}class w extends e.Command{constructor(e){super(e)}execute(e={}){const{editor:t}=this,{model:s}=this.editor,{selection:o}=t.model.document,n=o.getSelectedElement();let i="";const r=e.value,l="gapclass";i=n&&n.is("element","ubcColumnsThree")?n.getChild(0):o.getFirstPosition().findAncestor("ubcColumnsThree").getChild(0),s.change((e=>{if(o.isCollapsed)r?e.setAttribute(l,r,i):e.removeAttribute(l,i);else{const t=s.schema.getValidRanges(o.getRanges(),l);for(const s of t)r?(e.setAttribute(l,r,s),this.value=r):e.removeAttribute(l,s)}}))}refresh(){const{model:e}=this.editor,{selection:t}=e.document,s=t.getFirstPosition().findAncestor("ubcColumnsThree"),o=e.schema.findAllowedParent(t.getFirstPosition(),"ubcColumnsThree");this.isEnabled=null!==o,this.value=!!s&&s.getChild(0).getAttribute("gapclass")}}class v extends e.Plugin{static get requires(){return[t.Widget]}static get pluginName(){return"UbcColumnsThreeGapEditing"}constructor(e){super(e)}init(){const{editor:e}=this;this._defineConverters(),e.model.schema.extend("ubcColumnsThreeWrapper",{allowAttributes:"gapclass"}),e.conversion.attributeToAttribute({model:"gapclass",view:"class"}),e.commands.add("ubcColumnsThreeGap",new w(e))}_defineConverters(){const{conversion:e}=this.editor;e.for("upcast").attributeToAttribute({view:{key:"class",value:/\bgap-[\S]+/},model:{key:"gapclass",value:e=>e.getAttribute("class").match(/\bgap-([\S]+)/)[0]}}),e.for("downcast").attributeToAttribute({model:"gapclass",view:e=>({key:"class",value:e})})}}var f=s("ckeditor5/src/utils.js");class y extends e.Plugin{static get pluginName(){return"UbcColumnsThreeGapUI"}init(){const e=this.editor,t=e.t;r.map((e=>e)).value;const s=e.commands.get("ubcColumnsThreeGap");e.ui.componentFactory.add("ubcColumnsThreeGapOptions",(o=>{const n=(0,g.createDropdown)(o);return(0,g.addListToDropdown)(n,function(e,t){const s=new f.Collection,o="ubcColumnsThreeGap";let n=r.map((e=>e));for(const e of n){const n={type:"button",model:new g.ViewModel({commandName:o,commandParam:e.value,label:e.label,withText:!0})};n.model.bind("isOn").to(t,"value",(t=>t===e.value||!(!t||!e.value)&&t.toLowerCase()===e.value.toLowerCase())),s.add(n)}return s}(0,s)),n.buttonView.set({label:t("Gap"),tooltip:!0,withText:!0,class:"cke5-ubccolumnsthree-gap-insert-button"}),n.extendTemplate({attributes:{class:"ck-gap-options-dropdown"}}),n.bind("isEnabled").to(s),this.listenTo(n,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),n}))}}class x extends e.Plugin{static get requires(){return[v,y]}static get pluginName(){return"UbcColumnsThreeGap"}}class E extends e.Command{constructor(e){super(e)}execute(e={}){const{editor:t}=this,{model:s}=this.editor,{selection:o}=t.model.document,n=o.getSelectedElement();let i="";const r="keylineclass";i=n&&n.is("element","ubcColumnsThree")?n:o.getFirstPosition().findAncestor("ubcColumnsThree");let l=i.getAttribute(r);s.change((e=>{"widget-keylines"===l?(e.setAttribute(r,"widget-keyline-none",i),this.isOn=!1):(e.setAttribute(r,"widget-keylines",i),this.isOn=!0)}))}refresh(){const{model:e}=this.editor,{selection:t}=e.document,s=t.getFirstPosition().findAncestor("ubcColumnsThree"),o=e.schema.findAllowedParent(t.getFirstPosition(),"ubcColumnsThree");this.isEnabled=null!==o,this.value=!!s&&s.getAttribute("keylineclass")}}class A extends e.Plugin{static get requires(){return[t.Widget]}static get pluginName(){return"UbcColumnsThreeKeylineEditing"}constructor(e){super(e)}init(){const{editor:e}=this;this._defineConverters(),e.model.schema.extend("ubcColumnsThree",{allowAttributes:"keylineclass"}),e.conversion.attributeToAttribute({model:"keylineclass",view:"class"}),e.commands.add("ubcColumnsThreeKeyline",new E(e))}_defineConverters(){const{conversion:e}=this.editor;e.for("upcast").attributeToAttribute({view:{key:"class",value:/widget-keyline[\S]+/},model:{key:"keylineclass",value:e=>e.getAttribute("class").match(/widget-keyline([\S]+)/)[0]}}),e.for("downcast").attributeToAttribute({model:"keylineclass",view:e=>({key:"class",value:e})})}}class k extends e.Plugin{static get requires(){return[g.ContextualBalloon]}static get pluginName(){return"UbcColumnsThreeKeylineUI"}init(){const e=this.editor;e.ui.componentFactory.add("ubcColumnsThreeKeylineToggle",(t=>{const s=e.commands.get("ubcColumnsThreeKeyline"),o=new g.ButtonView(t);return o.set({label:e.t("Toggle Keylines"),tooltip:!0,withText:!0,class:"cke5-ubccolumnsthree-keyline-insert-button"}),o.bind("isEnabled").to(s),o.bind("isOn").to(s),this.listenTo(o,"execute",(()=>e.execute("ubcColumnsThreeKeyline"))),o}))}}class P extends e.Plugin{static get requires(){return[A,k]}static get pluginName(){return"UbcColumnsThreeKeyline"}}class S extends e.Command{constructor(e){super(e)}execute(e={}){const{editor:t}=this,{model:s}=this.editor,{selection:o}=t.model.document,n=o.getSelectedElement();let i="";const r=e.value,l="marginclass";i=n&&n.is("element","ubcColumnsThree")?n:o.getFirstPosition().findAncestor("ubcColumnsThree"),s.change((e=>{if(o.isCollapsed)r?e.setAttribute(l,r,i):e.removeAttribute(l,i);else{const t=s.schema.getValidRanges(o.getRanges(),l);for(const s of t)r?e.setAttribute(l,r,s):e.removeAttribute(l,s)}}))}refresh(){const{model:e}=this.editor,{selection:t}=e.document,s=t.getFirstPosition().findAncestor("ubcColumnsThree"),o=e.schema.findAllowedParent(t.getFirstPosition(),"ubcColumnsThree");this.isEnabled=null!==o,this.value=!!s&&s.getAttribute("marginclass")}}class W extends e.Plugin{static get requires(){return[t.Widget]}static get pluginName(){return"UbcColumnsThreeMarginEditing"}constructor(e){super(e)}init(){const{editor:e}=this;this._defineConverters(),e.model.schema.extend("ubcColumnsThree",{allowAttributes:"marginclass"}),e.conversion.attributeToAttribute({model:"marginclass",view:"class"}),e.commands.add("ubcColumnsThreeMargin",new S(e))}_defineConverters(){const{conversion:e}=this.editor;e.for("upcast").attributeToAttribute({view:{key:"class",value:/\bmy-[\S]+/},model:{key:"marginclass",value:e=>e.getAttribute("class").match(/\bmy-([\S]+)/)[0]}}),e.for("downcast").attributeToAttribute({model:"marginclass",view:e=>({key:"class",value:e})})}}class L extends e.Plugin{static get pluginName(){return"UbcColumnsThreeMarginUI"}init(){const e=this.editor,t=e.t;l.map((e=>e)).value;const s=e.commands.get("ubcColumnsThreeMargin");e.ui.componentFactory.add("ubcColumnsThreeMarginOptions",(o=>{const n=(0,g.createDropdown)(o);return(0,g.addListToDropdown)(n,function(e,t){const s=new f.Collection,o="ubcColumnsThreeMargin";let n=l.map((e=>e));for(const e of n){const n={type:"button",model:new g.ViewModel({commandName:o,commandParam:e.value,label:e.label,withText:!0})};n.model.bind("isOn").to(t,"value",(t=>t===e.value||!(!t||!e.value)&&t.toLowerCase()===e.value.toLowerCase())),s.add(n)}return s}(0,s)),n.buttonView.set({label:t("Margin"),tooltip:!0,withText:!0,class:"cke5-ubccolumnsthree-margin-insert-button"}),n.extendTemplate({attributes:{class:"ck-margin-options-dropdown"}}),n.bind("isEnabled").to(s),this.listenTo(n,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),n}))}}class F extends e.Plugin{static get requires(){return[W,L]}static get pluginName(){return"UbcColumnsThreeMargin"}}class N extends e.Command{constructor(e){super(e)}execute(e={}){const{editor:t}=this,{model:s}=this.editor,{selection:o}=t.model.document,n=o.getSelectedElement();let i="";const r=e.value,l="layoutcol3class";i=n&&n.is("element","ubcColumnsThree")?n:o.getFirstPosition().findAncestor("ubcColumnsThree"),s.change((e=>{if(o.isCollapsed)r?e.setAttribute(l,r,i):e.removeAttribute(l,i);else{const t=s.schema.getValidRanges(o.getRanges(),l);for(const s of t)r?e.setAttribute(l,r,s):e.removeAttribute(l,s)}}))}refresh(){const{model:e}=this.editor,{selection:t}=e.document,s=t.getFirstPosition().findAncestor("ubcColumnsThree"),o=e.schema.findAllowedParent(t.getFirstPosition(),"ubcColumnsThree");this.isEnabled=null!==o,this.value=!!s&&s.getAttribute("layoutcol3class")}}class j extends e.Plugin{static get requires(){return[t.Widget]}static get pluginName(){return"UbcColumnsThreeLayoutEditing"}constructor(e){super(e)}init(){const{editor:e}=this;this._defineConverters(),e.model.schema.extend("ubcColumnsThree",{allowAttributes:"layoutcol3class"}),e.conversion.attributeToAttribute({model:"layoutcol3class",view:"class"}),e.commands.add("ubcColumnsThreeLayout",new N(e))}_defineConverters(){const{conversion:e}=this.editor;e.for("upcast").attributeToAttribute({view:{key:"class",value:/\balign-[\S]+/},model:{key:"layoutcol3class",value:e=>e.getAttribute("class").match(/\balign-([\S]+)/)[0]}}),e.for("downcast").attributeToAttribute({model:"layoutcol3class",view:e=>({key:"class",value:e})})}}class U extends e.Plugin{static get pluginName(){return"UbcColumnsThreeLayoutUI"}init(){const e=this.editor,t=e.t;c.map((e=>e)).value;const s=e.commands.get("ubcColumnsThreeLayout");e.ui.componentFactory.add("ubcColumnsThreeLayoutOptions",(o=>{const n=(0,g.createDropdown)(o);return(0,g.addListToDropdown)(n,function(e,t){const s=new f.Collection,o="ubcColumnsThreeLayout";let n=c.map((e=>e));for(const e of n){const n={type:"button",model:new g.ViewModel({commandName:o,commandParam:e.value,label:e.label,withText:!0})};n.model.bind("isOn").to(t,"value",(t=>t===e.value||!(!t||!e.value)&&t.toLowerCase()===e.value.toLowerCase())),s.add(n)}return s}(0,s)),n.buttonView.set({label:t("Layout Options"),tooltip:!0,withText:!0,class:"cke5-ubccolumnsthree-layout-insert-button"}),n.extendTemplate({attributes:{class:"ck-3column-options-dropdown"}}),n.bind("isEnabled").to(s),this.listenTo(n,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),n}))}}class K extends e.Plugin{static get requires(){return[j,U]}static get pluginName(){return"UbcColumnsThreeLayout"}}class O extends e.Plugin{static get requires(){return[m,b,T,x,P,F,K]}}const q={UbcColumnsThree:O}})(),o=o.default})())); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.CKEditor5=t():(e.CKEditor5=e.CKEditor5||{},e.CKEditor5.ubcColumnsThree=t())}(self,(()=>(()=>{var e={"ckeditor5/src/core.js":(e,t,s)=>{e.exports=s("dll-reference CKEditor5.dll")("./src/core.js")},"ckeditor5/src/ui.js":(e,t,s)=>{e.exports=s("dll-reference CKEditor5.dll")("./src/ui.js")},"ckeditor5/src/utils.js":(e,t,s)=>{e.exports=s("dll-reference CKEditor5.dll")("./src/utils.js")},"ckeditor5/src/widget.js":(e,t,s)=>{e.exports=s("dll-reference CKEditor5.dll")("./src/widget.js")},"dll-reference CKEditor5.dll":e=>{"use strict";e.exports=CKEditor5.dll}},t={};function s(o){var n=t[o];if(void 0!==n)return n.exports;var i=t[o]={exports:{}};return e[o](i,i.exports,s),i.exports}s.d=(e,t)=>{for(var o in t)s.o(t,o)&&!s.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var o={};return(()=>{"use strict";s.d(o,{default:()=>q});var e=s("ckeditor5/src/core.js"),t=s("ckeditor5/src/widget.js");const n=document.querySelector('[data-drupal-selector="drupal-settings-json"]').innerHTML,i=JSON.parse(n),r=(i.ubcCkeditorWidgets.backgroundColors,i.ubcCkeditorWidgets.gapStyles),l=i.ubcCkeditorWidgets.marginStyles,c=(i.ubcCkeditorWidgets.paddingStyles,i.ubcCkeditorWidgets.tableStyles,i.ubcCkeditorWidgets.threeColumnLayoutStyles),a=(i.ubcCkeditorWidgets.twoColumnLayoutStyles,i.ubcCkeditorWidgets.widthStyles,{layoutcol3class:"align-equal",marginclass:"my-6",gapclass:"gap-6",keylineclass:"widget-keyline-none"}),u={gapclass:"gap-6"};class d extends e.Command{constructor(e,t){super(e),this.attributeName=t}execute(){const e=this.editor,t=this.editor.model,s=e.model.document.selection,o=s.getSelectedElement();let n="";n=o&&o.is("element","ubcColumnsThree")?o:s.getFirstPosition().findAncestor("ubcColumnsThree"),t.change((e=>{t.insertContent(function(e){const t=e.createElement("ubcColumnsThree",a,{class:"widget-column-options widget-columns-3"}),s=e.createElement("ubcColumnsThreeColumn",{class:"widget-region-one first-child--mt-0"}),o=e.createElement("ubcColumnsThreeColumn",{class:"widget-region-two first-child--mt-0"}),n=e.createElement("ubcColumnsThreeColumn",{class:"widget-region-three first-child--mt-0"}),i=e.createElement("ubcColumnsThreeWrapper",u,{class:"widget--md--grid"});return e.append(i,t),e.append(s,i),e.appendElement("paragraph",s),e.append(o,i),e.appendElement("paragraph",o),e.append(n,i),e.appendElement("paragraph",n),t}(e))}))}refresh(){const{model:e}=this.editor,{selection:t}=e.document,s=t.getFirstPosition().findAncestor("ubcColumnsThree"),o=e.schema.findAllowedParent(t.getFirstPosition(),"ubcColumnsThree");this.isEnabled=null!==o,this.value=!!s}}class m extends e.Plugin{static get requires(){return[t.Widget]}constructor(e){super(e)}init(){const e=this.editor;e.conversion.attributeToAttribute({model:"class",view:"class"}),this._defineSchema(),this._defineConverters(),e.commands.add("ubcColumnsThree",new d(e))}_defineSchema(){const e=this.editor.model.schema;e.register("ubcColumnsThree",{isObject:!0,allowWhere:"$block",allowChildren:["ubcColumnsThreeColumn"]}),e.register("ubcColumnsThreeWrapper",{isLimit:!0,allowIn:"ubcColumnsThree",allowChildren:["ubcColumnsThreeColumn"]}),e.register("ubcColumnsThreeColumn",{isLimit:!0,allowIn:"ubcColumnsThree",allowAttributes:"class",allowContentOf:"$root"}),e.addChildCheck(((e,t)=>{}))}_defineConverters(){const{conversion:e}=this.editor;e.for("upcast").elementToElement({model:"ubcColumnsThree",view:{name:"div",classes:["widget-columns-3"]}}),e.for("upcast").elementToElement({model:"ubcColumnsThreeWrapper",view:{name:"div",classes:"widget--md--grid"}}),e.for("upcast").elementToElement({model:(e,{writer:t})=>t.createElement("ubcColumnsThreeColumn",{class:e.getAttribute("class")}),view:{name:"div",classes:["first-child--mt-0"]}}),e.for("dataDowncast").elementToElement({model:"ubcColumnsThree",view:(e,{writer:t})=>t.createContainerElement("div",{class:"widget-column-options widget-columns-3"})}),e.for("dataDowncast").elementToElement({model:"ubcColumnsThreeWrapper",view:(e,{writer:t})=>t.createContainerElement("div",{class:"widget--md--grid"})}),e.for("dataDowncast").elementToElement({model:"ubcColumnsThreeColumn",view:(e,{writer:t})=>t.createContainerElement("div",{class:"first-child--mt-0"})}),e.for("editingDowncast").elementToElement({model:"ubcColumnsThree",view:(e,{writer:s})=>{const o=s.createContainerElement("div",{class:"widget-column-options widget-columns-3"});return(0,t.toWidget)(o,s,{label:"UBC Three Columns widget",hasSelectionHandle:!0})}}),e.for("editingDowncast").elementToElement({model:"ubcColumnsThreeWrapper",view:(e,{writer:s})=>{const o=s.createEditableElement("div",{class:"widget--md--grid"});return(0,t.toWidgetEditable)(o,s)}}),e.for("editingDowncast").elementToElement({model:"ubcColumnsThreeColumn",view:(e,{writer:s})=>{const o=s.createEditableElement("div",{class:"first-child--mt-0"});return(0,t.toWidgetEditable)(o,s)}})}}var g=s("ckeditor5/src/ui.js");class b extends e.Plugin{static get requires(){return[g.ContextualBalloon]}init(){const e=this.editor;e.ui.componentFactory.add("ubcColumnsThree",(t=>{const s=e.commands.get("ubcColumnsThree"),o=new g.ButtonView(t);return o.set({label:e.t("Three Columns"),icon:'',tooltip:!0,class:"cke5-ubccolumnsthree-insert-button"}),o.bind("isOn","isEnabled").to(s,"value","isEnabled"),this.listenTo(o,"execute",(()=>e.execute("ubcColumnsThree"))),o}))}}function h(e){const t=e.getSelectedElement();return t&&p(t)?t:null}function C(e){const t=e.getFirstPosition();if(!t)return null;let s=t.parent;for(;s;){if(s.is("element")&&p(s))return s;s=s.parent}return null}function p(e){return!!e.hasClass("widget-columns-3")&&(0,t.isWidget)(e)}class T extends e.Plugin{static get requires(){return[t.WidgetToolbarRepository]}static get pluginName(){return"UbcColumnsThreeToolbar"}afterInit(){const e=this.editor,s=e.plugins.get(t.WidgetToolbarRepository),o=e.config.get("ubcColumnsThree.contentToolbar"),n=e.config.get("ubcColumnsThree.tableToolbar");o&&s.register("ubcColumnsThreeContent",{ariaLabel:e.t("Three Columns toolbar"),items:o,getRelatedElement:C}),n&&s.register("ubcColumnsThree",{ariaLabel:e.t("Three Columns toolbar"),items:n,getRelatedElement:h})}}class w extends e.Command{constructor(e){super(e)}execute(e={}){const{editor:t}=this,{model:s}=this.editor,{selection:o}=t.model.document,n=o.getSelectedElement();let i="";const r=e.value,l="gapclass";i=n&&n.is("element","ubcColumnsThree")?n.getChild(0):o.getFirstPosition().findAncestor("ubcColumnsThree").getChild(0),s.change((e=>{if(o.isCollapsed)r?e.setAttribute(l,r,i):e.removeAttribute(l,i);else{const t=s.schema.getValidRanges(o.getRanges(),l);for(const s of t)r?(e.setAttribute(l,r,s),this.value=r):e.removeAttribute(l,s)}}))}refresh(){const{model:e}=this.editor,{selection:t}=e.document,s=t.getFirstPosition().findAncestor("ubcColumnsThree"),o=e.schema.findAllowedParent(t.getFirstPosition(),"ubcColumnsThree");this.isEnabled=null!==o,this.value=!!s&&s.getChild(0).getAttribute("gapclass")}}class v extends e.Plugin{static get requires(){return[t.Widget]}static get pluginName(){return"UbcColumnsThreeGapEditing"}constructor(e){super(e)}init(){const{editor:e}=this;this._defineConverters(),e.model.schema.extend("ubcColumnsThreeWrapper",{allowAttributes:"gapclass"}),e.conversion.attributeToAttribute({model:"gapclass",view:"class"}),e.commands.add("ubcColumnsThreeGap",new w(e))}_defineConverters(){const{conversion:e}=this.editor;e.for("upcast").attributeToAttribute({view:{key:"class",value:/\bgap-[\S]+/},model:{key:"gapclass",value:e=>e.getAttribute("class").match(/\bgap-([\S]+)/)[0]}}),e.for("downcast").attributeToAttribute({model:"gapclass",view:e=>({key:"class",value:e})})}}var f=s("ckeditor5/src/utils.js");class y extends e.Plugin{static get pluginName(){return"UbcColumnsThreeGapUI"}init(){const e=this.editor,t=e.t;r.map((e=>e)).value;const s=e.commands.get("ubcColumnsThreeGap");e.ui.componentFactory.add("ubcColumnsThreeGapOptions",(o=>{const n=(0,g.createDropdown)(o);return(0,g.addListToDropdown)(n,function(e,t){const s=new f.Collection,o="ubcColumnsThreeGap";let n=r.map((e=>e));for(const e of n){const n={type:"button",model:new g.ViewModel({commandName:o,commandParam:e.value,label:e.label,withText:!0})};n.model.bind("isOn").to(t,"value",(t=>t===e.value||!(!t||!e.value)&&t.toLowerCase()===e.value.toLowerCase())),s.add(n)}return s}(0,s)),n.buttonView.set({label:t("Gap"),tooltip:!0,withText:!0,class:"cke5-ubccolumnsthree-gap-insert-button"}),n.extendTemplate({attributes:{class:"ck-gap-options-dropdown"}}),n.bind("isEnabled").to(s),this.listenTo(n,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),n}))}}class x extends e.Plugin{static get requires(){return[v,y]}static get pluginName(){return"UbcColumnsThreeGap"}}class E extends e.Command{constructor(e){super(e)}execute(e={}){const{editor:t}=this,{model:s}=this.editor,{selection:o}=t.model.document,n=o.getSelectedElement();let i="";const r="keylineclass";i=n&&n.is("element","ubcColumnsThree")?n:o.getFirstPosition().findAncestor("ubcColumnsThree");let l=i.getAttribute(r);s.change((e=>{"widget-keylines"===l?(e.setAttribute(r,"widget-keyline-none",i),this.isOn=!1):(e.setAttribute(r,"widget-keylines",i),this.isOn=!0)}))}refresh(){const{model:e}=this.editor,{selection:t}=e.document,s=t.getFirstPosition().findAncestor("ubcColumnsThree"),o=e.schema.findAllowedParent(t.getFirstPosition(),"ubcColumnsThree");this.isEnabled=null!==o,this.value=!!s&&s.getAttribute("keylineclass")}}class A extends e.Plugin{static get requires(){return[t.Widget]}static get pluginName(){return"UbcColumnsThreeKeylineEditing"}constructor(e){super(e)}init(){const{editor:e}=this;this._defineConverters(),e.model.schema.extend("ubcColumnsThree",{allowAttributes:"keylineclass"}),e.conversion.attributeToAttribute({model:"keylineclass",view:"class"}),e.commands.add("ubcColumnsThreeKeyline",new E(e))}_defineConverters(){const{conversion:e}=this.editor;e.for("upcast").attributeToAttribute({view:{key:"class",value:/widget-keyline[\S]+/},model:{key:"keylineclass",value:e=>e.getAttribute("class").match(/widget-keyline([\S]+)/)[0]}}),e.for("downcast").attributeToAttribute({model:"keylineclass",view:e=>({key:"class",value:e})})}}class k extends e.Plugin{static get requires(){return[g.ContextualBalloon]}static get pluginName(){return"UbcColumnsThreeKeylineUI"}init(){const e=this.editor;e.ui.componentFactory.add("ubcColumnsThreeKeylineToggle",(t=>{const s=e.commands.get("ubcColumnsThreeKeyline"),o=new g.ButtonView(t);return o.set({label:e.t("Toggle Keylines"),tooltip:!0,withText:!0,class:"cke5-ubccolumnsthree-keyline-insert-button"}),o.bind("isEnabled").to(s),o.bind("isOn").to(s),this.listenTo(o,"execute",(()=>e.execute("ubcColumnsThreeKeyline"))),o}))}}class P extends e.Plugin{static get requires(){return[A,k]}static get pluginName(){return"UbcColumnsThreeKeyline"}}class S extends e.Command{constructor(e){super(e)}execute(e={}){const{editor:t}=this,{model:s}=this.editor,{selection:o}=t.model.document,n=o.getSelectedElement();let i="";const r=e.value,l="marginclass";i=n&&n.is("element","ubcColumnsThree")?n:o.getFirstPosition().findAncestor("ubcColumnsThree"),s.change((e=>{if(o.isCollapsed)r?e.setAttribute(l,r,i):e.removeAttribute(l,i);else{const t=s.schema.getValidRanges(o.getRanges(),l);for(const s of t)r?e.setAttribute(l,r,s):e.removeAttribute(l,s)}}))}refresh(){const{model:e}=this.editor,{selection:t}=e.document,s=t.getFirstPosition().findAncestor("ubcColumnsThree"),o=e.schema.findAllowedParent(t.getFirstPosition(),"ubcColumnsThree");this.isEnabled=null!==o,this.value=!!s&&s.getAttribute("marginclass")}}class W extends e.Plugin{static get requires(){return[t.Widget]}static get pluginName(){return"UbcColumnsThreeMarginEditing"}constructor(e){super(e)}init(){const{editor:e}=this;this._defineConverters(),e.model.schema.extend("ubcColumnsThree",{allowAttributes:"marginclass"}),e.conversion.attributeToAttribute({model:"marginclass",view:"class"}),e.commands.add("ubcColumnsThreeMargin",new S(e))}_defineConverters(){const{conversion:e}=this.editor;e.for("upcast").attributeToAttribute({view:{key:"class",value:/\bmy-[\S]+/},model:{key:"marginclass",value:e=>e.getAttribute("class").match(/\bmy-([\S]+)/)[0]}}),e.for("downcast").attributeToAttribute({model:"marginclass",view:e=>({key:"class",value:e})})}}class L extends e.Plugin{static get pluginName(){return"UbcColumnsThreeMarginUI"}init(){const e=this.editor,t=e.t;l.map((e=>e)).value;const s=e.commands.get("ubcColumnsThreeMargin");e.ui.componentFactory.add("ubcColumnsThreeMarginOptions",(o=>{const n=(0,g.createDropdown)(o);return(0,g.addListToDropdown)(n,function(e,t){const s=new f.Collection,o="ubcColumnsThreeMargin";let n=l.map((e=>e));for(const e of n){const n={type:"button",model:new g.ViewModel({commandName:o,commandParam:e.value,label:e.label,withText:!0})};n.model.bind("isOn").to(t,"value",(t=>t===e.value||!(!t||!e.value)&&t.toLowerCase()===e.value.toLowerCase())),s.add(n)}return s}(0,s)),n.buttonView.set({label:t("Margin"),tooltip:!0,withText:!0,class:"cke5-ubccolumnsthree-margin-insert-button"}),n.extendTemplate({attributes:{class:"ck-margin-options-dropdown"}}),n.bind("isEnabled").to(s),this.listenTo(n,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),n}))}}class F extends e.Plugin{static get requires(){return[W,L]}static get pluginName(){return"UbcColumnsThreeMargin"}}class N extends e.Command{constructor(e){super(e)}execute(e={}){const{editor:t}=this,{model:s}=this.editor,{selection:o}=t.model.document,n=o.getSelectedElement();let i="";const r=e.value,l="layoutcol3class";i=n&&n.is("element","ubcColumnsThree")?n:o.getFirstPosition().findAncestor("ubcColumnsThree"),s.change((e=>{if(o.isCollapsed)r?e.setAttribute(l,r,i):e.removeAttribute(l,i);else{const t=s.schema.getValidRanges(o.getRanges(),l);for(const s of t)r?e.setAttribute(l,r,s):e.removeAttribute(l,s)}}))}refresh(){const{model:e}=this.editor,{selection:t}=e.document,s=t.getFirstPosition().findAncestor("ubcColumnsThree"),o=e.schema.findAllowedParent(t.getFirstPosition(),"ubcColumnsThree");this.isEnabled=null!==o,this.value=!!s&&s.getAttribute("layoutcol3class")}}class j extends e.Plugin{static get requires(){return[t.Widget]}static get pluginName(){return"UbcColumnsThreeLayoutEditing"}constructor(e){super(e)}init(){const{editor:e}=this;this._defineConverters(),e.model.schema.extend("ubcColumnsThree",{allowAttributes:"layoutcol3class"}),e.conversion.attributeToAttribute({model:"layoutcol3class",view:"class"}),e.commands.add("ubcColumnsThreeLayout",new N(e))}_defineConverters(){const{conversion:e}=this.editor;e.for("upcast").attributeToAttribute({view:{key:"class",value:/\balign-[\S]+/},model:{key:"layoutcol3class",value:e=>e.getAttribute("class").match(/\balign-([\S]+)/)[0]}}),e.for("downcast").attributeToAttribute({model:"layoutcol3class",view:e=>({key:"class",value:e})})}}class U extends e.Plugin{static get pluginName(){return"UbcColumnsThreeLayoutUI"}init(){const e=this.editor,t=e.t;c.map((e=>e)).value;const s=e.commands.get("ubcColumnsThreeLayout");e.ui.componentFactory.add("ubcColumnsThreeLayoutOptions",(o=>{const n=(0,g.createDropdown)(o);return(0,g.addListToDropdown)(n,function(e,t){const s=new f.Collection,o="ubcColumnsThreeLayout";let n=c.map((e=>e));for(const e of n){const n={type:"button",model:new g.ViewModel({commandName:o,commandParam:e.value,label:e.label,withText:!0})};n.model.bind("isOn").to(t,"value",(t=>t===e.value||!(!t||!e.value)&&t.toLowerCase()===e.value.toLowerCase())),s.add(n)}return s}(0,s)),n.buttonView.set({label:t("Layout Options"),tooltip:!0,withText:!0,class:"cke5-ubccolumnsthree-layout-insert-button"}),n.extendTemplate({attributes:{class:"ck-3column-options-dropdown"}}),n.bind("isEnabled").to(s),this.listenTo(n,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),n}))}}class K extends e.Plugin{static get requires(){return[j,U]}static get pluginName(){return"UbcColumnsThreeLayout"}}class O extends e.Plugin{static get requires(){return[m,b,T,x,P,F,K]}}const q={UbcColumnsThree:O}})(),o=o.default})())); \ No newline at end of file diff --git a/js/build/ubcColumnsTwo.js b/js/build/ubcColumnsTwo.js index 249b3d2..7f345b0 100644 --- a/js/build/ubcColumnsTwo.js +++ b/js/build/ubcColumnsTwo.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.CKEditor5=t():(e.CKEditor5=e.CKEditor5||{},e.CKEditor5.ubcColumnsTwo=t())}(self,(()=>(()=>{var e={"ckeditor5/src/core.js":(e,t,o)=>{e.exports=o("dll-reference CKEditor5.dll")("./src/core.js")},"ckeditor5/src/ui.js":(e,t,o)=>{e.exports=o("dll-reference CKEditor5.dll")("./src/ui.js")},"ckeditor5/src/utils.js":(e,t,o)=>{e.exports=o("dll-reference CKEditor5.dll")("./src/utils.js")},"ckeditor5/src/widget.js":(e,t,o)=>{e.exports=o("dll-reference CKEditor5.dll")("./src/widget.js")},"dll-reference CKEditor5.dll":e=>{"use strict";e.exports=CKEditor5.dll}},t={};function o(s){var n=t[s];if(void 0!==n)return n.exports;var i=t[s]={exports:{}};return e[s](i,i.exports,o),i.exports}o.d=(e,t)=>{for(var s in t)o.o(t,s)&&!o.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var s={};return(()=>{"use strict";o.d(s,{default:()=>q});var e=o("ckeditor5/src/core.js"),t=o("ckeditor5/src/widget.js");const n=document.querySelector('[data-drupal-selector="drupal-settings-json"]').innerHTML,i=JSON.parse(n),l=(i.ubcCkeditorWidgets.backgroundColors,i.ubcCkeditorWidgets.gapStyles),r=i.ubcCkeditorWidgets.marginStyles,c=(i.ubcCkeditorWidgets.paddingStyles,i.ubcCkeditorWidgets.tableStyles,i.ubcCkeditorWidgets.threeColumnLayoutStyles,i.ubcCkeditorWidgets.twoColumnLayoutStyles),a=(i.ubcCkeditorWidgets.widthStyles,{layoutcolclass:"align-equal",marginclass:"my-6",keylineclass:"widget-keyline-none"}),u={gapclass:"gap-6"};class d extends e.Command{constructor(e,t){super(e),this.attributeName=t}execute(){const e=this.editor,t=this.editor.model,o=e.model.document.selection,s=o.getSelectedElement();let n="";n=s&&s.is("element","ubcColumnsTwo")?s:o.getFirstPosition().findAncestor("ubcColumnsTwo"),t.change((e=>{t.insertContent(function(e){const t=e.createElement("ubcColumnsTwo",a,{class:"widget-column-options widget-columns-2"}),o=e.createElement("ubcColumnsTwoColumn",{class:"widget-region-one"}),s=e.createElement("ubcColumnsTwoColumn",{class:"widget-region-two"}),n=e.createElement("ubcColumnsTwoWrapper",u,{class:"widget--md--grid"});return e.append(n,t),e.append(o,n),e.appendElement("paragraph",o),e.append(s,n),e.appendElement("paragraph",s),t}(e))}))}refresh(){const{model:e}=this.editor,{selection:t}=e.document,o=t.getFirstPosition().findAncestor("ubcColumnsTwo"),s=e.schema.findAllowedParent(t.getFirstPosition(),"ubcColumnsTwo");this.isEnabled=null!==s,this.value=!!o}}class m extends e.Plugin{static get requires(){return[t.Widget]}constructor(e){super(e)}init(){const e=this.editor;e.conversion.attributeToAttribute({model:"class",view:"class"}),this._defineSchema(),this._defineConverters(),e.commands.add("ubcColumnsTwo",new d(e))}_defineSchema(){const e=this.editor.model.schema;e.register("ubcColumnsTwo",{isObject:!0,allowWhere:"$block",allowChildren:["ubcColumnsTwoWrapper"]}),e.register("ubcColumnsTwoWrapper",{isLimit:!0,allowIn:"ubcColumnsTwo",allowChildren:["ubcColumnsTwoColumn"]}),e.register("ubcColumnsTwoColumn",{isLimit:!0,allowIn:"ubcColumnsTwo",allowAttributes:"class",allowContentOf:"$root"}),e.addChildCheck(((e,t)=>{}))}_defineConverters(){const{conversion:e}=this.editor;e.for("upcast").elementToElement({model:"ubcColumnsTwo",view:{name:"div",classes:["widget-columns-2"]}}),e.for("upcast").elementToElement({model:"ubcColumnsTwoWrapper",view:{name:"div",classes:"widget--md--grid"}}),e.for("upcast").elementToElement({model:"ubcColumnsTwoColumn",view:{name:"div",classes:["first-child--mt-0"]}}),e.for("dataDowncast").elementToElement({model:"ubcColumnsTwo",view:(e,{writer:t})=>t.createContainerElement("div",{class:"widget-column-options widget-columns-2"})}),e.for("dataDowncast").elementToElement({model:"ubcColumnsTwoWrapper",view:(e,{writer:t})=>t.createContainerElement("div",{class:"widget--md--grid"})}),e.for("dataDowncast").elementToElement({model:"ubcColumnsTwoColumn",view:(e,{writer:t})=>t.createContainerElement("div",{class:"first-child--mt-0"})}),e.for("editingDowncast").elementToElement({model:"ubcColumnsTwo",view:(e,{writer:o})=>{const s=o.createContainerElement("div",{class:"widget-column-options widget-columns-2"});return(0,t.toWidget)(s,o,{label:"UBC Two Columns widget",hasSelectionHandle:!0})}}),e.for("editingDowncast").elementToElement({model:"ubcColumnsTwoWrapper",view:(e,{writer:o})=>{const s=o.createEditableElement("div",{class:"widget--md--grid"});return(0,t.toWidgetEditable)(s,o)}}),e.for("editingDowncast").elementToElement({model:"ubcColumnsTwoColumn",view:(e,{writer:o})=>{const s=o.createEditableElement("div",{class:"first-child--mt-0"});return(0,t.toWidgetEditable)(s,o)}})}}var g=o("ckeditor5/src/ui.js");class b extends e.Plugin{static get requires(){return[g.ContextualBalloon]}init(){const e=this.editor;e.ui.componentFactory.add("ubcColumnsTwo",(t=>{const o=e.commands.get("ubcColumnsTwo"),s=new g.ButtonView(t);return s.set({label:e.t("Two Columns"),icon:'',tooltip:!0,class:"cke5-ubccolumnstwo-insert-button"}),s.bind("isOn","isEnabled").to(o,"value","isEnabled"),this.listenTo(s,"execute",(()=>e.execute("ubcColumnsTwo"))),s}))}}function w(e){const t=e.getSelectedElement();return t&&p(t)?t:null}function C(e){const t=e.getFirstPosition();if(!t)return null;let o=t.parent;for(;o;){if(o.is("element")&&p(o))return o;o=o.parent}return null}function p(e){return!!e.hasClass("widget-columns-2")&&(0,t.isWidget)(e)}class T extends e.Plugin{static get requires(){return[t.WidgetToolbarRepository]}static get pluginName(){return"UbcColumnsTwoToolbar"}afterInit(){const e=this.editor,o=e.plugins.get(t.WidgetToolbarRepository),s=e.config.get("ubcColumnsTwo.contentToolbar"),n=e.config.get("ubcColumnsTwo.tableToolbar");s&&o.register("ubcColumnsTwoContent",{ariaLabel:e.t("Two Columns toolbar"),items:s,getRelatedElement:C}),n&&o.register("ubcColumnsTwo",{ariaLabel:e.t("Two Columns toolbar"),items:n,getRelatedElement:w})}}class h extends e.Command{constructor(e){super(e)}execute(e={}){const{editor:t}=this,{model:o}=this.editor,{selection:s}=t.model.document,n=s.getSelectedElement();let i="";const l=e.value,r="gapclass";i=n&&n.is("element","ubcColumnsTwo")?n.getChild(0):s.getFirstPosition().findAncestor("ubcColumnsTwo").getChild(0),o.change((e=>{if(s.isCollapsed)l?e.setAttribute(r,l,i):e.removeAttribute(r,i);else{const t=o.schema.getValidRanges(s.getRanges(),r);for(const o of t)l?(e.setAttribute(r,l,o),this.value=l):e.removeAttribute(r,o)}}))}refresh(){const{model:e}=this.editor,{selection:t}=e.document,o=t.getFirstPosition().findAncestor("ubcColumnsTwo"),s=e.schema.findAllowedParent(t.getFirstPosition(),"ubcColumnsTwo");this.isEnabled=null!==s,this.value=!!o&&o.getChild(0).getAttribute("gapclass")}}class v extends e.Plugin{static get requires(){return[t.Widget]}static get pluginName(){return"UbcColumnsTwoGapEditing"}constructor(e){super(e)}init(){const{editor:e}=this;this._defineConverters(),e.model.schema.extend("ubcColumnsTwoWrapper",{allowAttributes:"gapclass"}),e.conversion.attributeToAttribute({model:"gapclass",view:"class"}),e.commands.add("ubcColumnsTwoGap",new h(e))}_defineConverters(){const{conversion:e}=this.editor;e.for("upcast").attributeToAttribute({view:{key:"class",value:/\bgap-[\S]+/},model:{key:"gapclass",value:e=>e.getAttribute("class").match(/\bgap-([\S]+)/)[0]}}),e.for("downcast").attributeToAttribute({model:"gapclass",view:e=>({key:"class",value:e})})}}var f=o("ckeditor5/src/utils.js");class y extends e.Plugin{static get pluginName(){return"UbcColumnsTwoGapUI"}init(){const e=this.editor,t=e.t;l.map((e=>e)).value;const o=e.commands.get("ubcColumnsTwoGap");e.ui.componentFactory.add("ubcColumnsTwoGapOptions",(s=>{const n=(0,g.createDropdown)(s);return(0,g.addListToDropdown)(n,function(e,t){const o=new f.Collection,s="ubcColumnsTwoGap";let n=l.map((e=>e));for(const e of n){const n={type:"button",model:new g.ViewModel({commandName:s,commandParam:e.value,label:e.label,withText:!0})};n.model.bind("isOn").to(t,"value",(t=>t===e.value||!(!t||!e.value)&&t.toLowerCase()===e.value.toLowerCase())),o.add(n)}return o}(0,o)),n.buttonView.set({label:t("Gap"),tooltip:!0,withText:!0,class:"cke5-ubccolumnstwo-gap-insert-button"}),n.extendTemplate({attributes:{class:"ck-gap-options-dropdown"}}),n.bind("isEnabled").to(o),this.listenTo(n,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),n}))}}class x extends e.Plugin{static get requires(){return[v,y]}static get pluginName(){return"UbcColumnsTwoGap"}}class E extends e.Command{constructor(e){super(e)}execute(e={}){const{editor:t}=this,{model:o}=this.editor,{selection:s}=t.model.document,n=s.getSelectedElement();let i="";const l="keylineclass";i=n&&n.is("element","ubcColumnsTwo")?n:s.getFirstPosition().findAncestor("ubcColumnsTwo");let r=i.getAttribute(l);o.change((e=>{"widget-keylines"===r?(e.setAttribute(l,"widget-keyline-none",i),this.isOn=!1):(e.setAttribute(l,"widget-keylines",i),this.isOn=!0)}))}refresh(){const{model:e}=this.editor,{selection:t}=e.document,o=t.getFirstPosition().findAncestor("ubcColumnsTwo"),s=e.schema.findAllowedParent(t.getFirstPosition(),"ubcColumnsTwo");this.isEnabled=null!==s,this.value=!!o&&o.getAttribute("keylineclass")}}class A extends e.Plugin{static get requires(){return[t.Widget]}static get pluginName(){return"UbcColumnsTwoKeylineEditing"}constructor(e){super(e)}init(){const{editor:e}=this;this._defineConverters(),e.model.schema.extend("ubcColumnsTwo",{allowAttributes:"keylineclass"}),e.conversion.attributeToAttribute({model:"keylineclass",view:"class"}),e.commands.add("ubcColumnsTwoKeyline",new E(e))}_defineConverters(){const{conversion:e}=this.editor;e.for("upcast").attributeToAttribute({view:{key:"class",value:/widget-keyline[\S]+/},model:{key:"keylineclass",value:e=>e.getAttribute("class").match(/widget-keyline([\S]+)/)[0]}}),e.for("downcast").attributeToAttribute({model:"keylineclass",view:e=>({key:"class",value:e})})}}class k extends e.Plugin{static get requires(){return[g.ContextualBalloon]}static get pluginName(){return"UbcColumnsTwoKeylineUI"}init(){const e=this.editor;e.ui.componentFactory.add("ubcColumnsTwoKeylineToggle",(t=>{const o=e.commands.get("ubcColumnsTwoKeyline"),s=new g.ButtonView(t);return s.set({label:e.t("Toggle Keylines"),tooltip:!0,withText:!0,class:"cke5-ubccolumnstwo-keyline-insert-button"}),s.bind("isEnabled").to(o),s.bind("isOn").to(o),this.listenTo(s,"execute",(()=>e.execute("ubcColumnsTwoKeyline"))),s}))}}class P extends e.Plugin{static get requires(){return[A,k]}static get pluginName(){return"UbcColumnsTwoKeyline"}}class W extends e.Command{constructor(e){super(e)}execute(e={}){const{editor:t}=this,{model:o}=this.editor,{selection:s}=t.model.document,n=s.getSelectedElement();let i="";const l=e.value,r="marginclass";i=n&&n.is("element","ubcColumnsTwo")?n:s.getFirstPosition().findAncestor("ubcColumnsTwo"),o.change((e=>{if(s.isCollapsed)l?e.setAttribute(r,l,i):e.removeAttribute(r,i);else{const t=o.schema.getValidRanges(s.getRanges(),r);for(const o of t)l?e.setAttribute(r,l,o):e.removeAttribute(r,o)}}))}refresh(){const{model:e}=this.editor,{selection:t}=e.document,o=t.getFirstPosition().findAncestor("ubcColumnsTwo"),s=e.schema.findAllowedParent(t.getFirstPosition(),"ubcColumnsTwo");this.isEnabled=null!==s,this.value=!!o&&o.getAttribute("marginclass")}}class S extends e.Plugin{static get requires(){return[t.Widget]}static get pluginName(){return"UbcColumnsTwoMarginEditing"}constructor(e){super(e)}init(){const{editor:e}=this;this._defineConverters(),e.model.schema.extend("ubcColumnsTwo",{allowAttributes:"marginclass"}),e.conversion.attributeToAttribute({model:"marginclass",view:"class"}),e.commands.add("ubcColumnsTwoMargin",new W(e))}_defineConverters(){const{conversion:e}=this.editor;e.for("upcast").attributeToAttribute({view:{key:"class",value:/\bmy-[\S]+/},model:{key:"marginclass",value:e=>e.getAttribute("class").match(/\bmy-([\S]+)/)[0]}}),e.for("downcast").attributeToAttribute({model:"marginclass",view:e=>({key:"class",value:e})})}}class L extends e.Plugin{static get pluginName(){return"UbcColumnsTwoMarginUI"}init(){const e=this.editor,t=e.t;r.map((e=>e)).value;const o=e.commands.get("ubcColumnsTwoMargin");e.ui.componentFactory.add("ubcColumnsTwoMarginOptions",(s=>{const n=(0,g.createDropdown)(s);return(0,g.addListToDropdown)(n,function(e,t){const o=new f.Collection,s="ubcColumnsTwoMargin";let n=r.map((e=>e));for(const e of n){const n={type:"button",model:new g.ViewModel({commandName:s,commandParam:e.value,label:e.label,withText:!0})};n.model.bind("isOn").to(t,"value",(t=>t===e.value||!(!t||!e.value)&&t.toLowerCase()===e.value.toLowerCase())),o.add(n)}return o}(0,o)),n.buttonView.set({label:t("Margin"),tooltip:!0,withText:!0,class:"cke5-ubccolumnstwo-margin-insert-button"}),n.extendTemplate({attributes:{class:"ck-margin-options-dropdown"}}),n.bind("isEnabled").to(o),this.listenTo(n,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),n}))}}class F extends e.Plugin{static get requires(){return[S,L]}static get pluginName(){return"UbcColumnsTwoMargin"}}class N extends e.Command{constructor(e){super(e)}execute(e={}){const{editor:t}=this,{model:o}=this.editor,{selection:s}=t.model.document,n=s.getSelectedElement();let i="";const l=e.value,r="layoutcolclass";i=n&&n.is("element","ubcColumnsTwo")?n:s.getFirstPosition().findAncestor("ubcColumnsTwo"),o.change((e=>{if(s.isCollapsed)l?e.setAttribute(r,l,i):e.removeAttribute(r,i);else{const t=o.schema.getValidRanges(s.getRanges(),r);for(const o of t)l?(e.setAttribute(r,l,o),this.value=l):e.removeAttribute(r,o)}}))}refresh(){const{model:e}=this.editor,{selection:t}=e.document,o=t.getFirstPosition().findAncestor("ubcColumnsTwo"),s=e.schema.findAllowedParent(t.getFirstPosition(),"ubcColumnsTwo");this.isEnabled=null!==s,this.value=!!o&&o.getAttribute("layoutcolclass")}}class j extends e.Plugin{static get requires(){return[t.Widget]}static get pluginName(){return"UbcColumnsTwoLayoutEditing"}constructor(e){super(e)}init(){const{editor:e}=this;this._defineConverters(),e.model.schema.extend("ubcColumnsTwo",{allowAttributes:"layoutcolclass"}),e.conversion.attributeToAttribute({model:"layoutcolclass",view:"class"}),e.commands.add("ubcColumnsTwoLayout",new N(e))}_defineConverters(){const{conversion:e}=this.editor;e.for("upcast").attributeToAttribute({view:{key:"class",value:/\balign-[\S]+/},model:{key:"layoutcolclass",value:e=>e.getAttribute("class").match(/\balign-([\S]+)/)[0]}}),e.for("downcast").attributeToAttribute({model:"layoutcolclass",view:e=>({key:"class",value:e})})}}class U extends e.Plugin{static get pluginName(){return"UbcColumnsTwoLayoutUI"}init(){const e=this.editor,t=e.t,o=c.map((e=>e)),s=e.commands.get("ubcColumnsTwoLayout");e.ui.componentFactory.add("ubcColumnsTwoLayoutOptions",(n=>{const i=(0,g.createDropdown)(n);return(0,g.addListToDropdown)(i,function(e,t){const o=new f.Collection,s="ubcColumnsTwoLayout";for(const n of e){const e={type:"button",model:new g.ViewModel({commandName:s,commandParam:n.value,label:n.label,withText:!0})};e.model.bind("isOn").to(t,"value",(e=>e===n.value)),o.add(e)}return o}(o,s)),i.buttonView.set({label:t("Layout Options"),tooltip:!0,withText:!0,class:"cke5-ubccolumnstwo-layout-insert-button"}),i.extendTemplate({attributes:{class:"ck-3column-options-dropdown"}}),i.bind("isEnabled").to(s),this.listenTo(i,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),i}))}}class K extends e.Plugin{static get requires(){return[j,U]}static get pluginName(){return"UbcColumnsTwoLayout"}}class O extends e.Plugin{static get requires(){return[m,b,T,x,P,F,K]}}const q={UbcColumnsTwo:O}})(),s=s.default})())); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.CKEditor5=t():(e.CKEditor5=e.CKEditor5||{},e.CKEditor5.ubcColumnsTwo=t())}(self,(()=>(()=>{var e={"ckeditor5/src/core.js":(e,t,o)=>{e.exports=o("dll-reference CKEditor5.dll")("./src/core.js")},"ckeditor5/src/ui.js":(e,t,o)=>{e.exports=o("dll-reference CKEditor5.dll")("./src/ui.js")},"ckeditor5/src/utils.js":(e,t,o)=>{e.exports=o("dll-reference CKEditor5.dll")("./src/utils.js")},"ckeditor5/src/widget.js":(e,t,o)=>{e.exports=o("dll-reference CKEditor5.dll")("./src/widget.js")},"dll-reference CKEditor5.dll":e=>{"use strict";e.exports=CKEditor5.dll}},t={};function o(s){var n=t[s];if(void 0!==n)return n.exports;var i=t[s]={exports:{}};return e[s](i,i.exports,o),i.exports}o.d=(e,t)=>{for(var s in t)o.o(t,s)&&!o.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var s={};return(()=>{"use strict";o.d(s,{default:()=>q});var e=o("ckeditor5/src/core.js"),t=o("ckeditor5/src/widget.js");const n=document.querySelector('[data-drupal-selector="drupal-settings-json"]').innerHTML,i=JSON.parse(n),l=(i.ubcCkeditorWidgets.backgroundColors,i.ubcCkeditorWidgets.gapStyles),r=i.ubcCkeditorWidgets.marginStyles,c=(i.ubcCkeditorWidgets.paddingStyles,i.ubcCkeditorWidgets.tableStyles,i.ubcCkeditorWidgets.threeColumnLayoutStyles,i.ubcCkeditorWidgets.twoColumnLayoutStyles),a=(i.ubcCkeditorWidgets.widthStyles,{layoutcolclass:"align-equal",marginclass:"my-6",keylineclass:"widget-keyline-none"}),u={gapclass:"gap-6"};class d extends e.Command{constructor(e,t){super(e),this.attributeName=t}execute(){const e=this.editor,t=this.editor.model,o=e.model.document.selection,s=o.getSelectedElement();let n="";n=s&&s.is("element","ubcColumnsTwo")?s:o.getFirstPosition().findAncestor("ubcColumnsTwo"),t.change((e=>{t.insertContent(function(e){const t=e.createElement("ubcColumnsTwo",a,{class:"widget-column-options widget-columns-2"}),o=e.createElement("ubcColumnsTwoColumn",{class:"widget-region-one first-child--mt-0"}),s=e.createElement("ubcColumnsTwoColumn",{class:"widget-region-two first-child--mt-0"}),n=e.createElement("ubcColumnsTwoWrapper",u,{class:"widget--md--grid"});return e.append(n,t),e.append(o,n),e.appendElement("paragraph",o),e.append(s,n),e.appendElement("paragraph",s),t}(e))}))}refresh(){const{model:e}=this.editor,{selection:t}=e.document,o=t.getFirstPosition().findAncestor("ubcColumnsTwo"),s=e.schema.findAllowedParent(t.getFirstPosition(),"ubcColumnsTwo");this.isEnabled=null!==s,this.value=!!o}}class m extends e.Plugin{static get requires(){return[t.Widget]}constructor(e){super(e)}init(){const e=this.editor;e.conversion.attributeToAttribute({model:"class",view:"class"}),this._defineSchema(),this._defineConverters(),e.commands.add("ubcColumnsTwo",new d(e))}_defineSchema(){const e=this.editor.model.schema;e.register("ubcColumnsTwo",{isObject:!0,allowWhere:"$block",allowChildren:["ubcColumnsTwoWrapper"]}),e.register("ubcColumnsTwoWrapper",{isLimit:!0,allowIn:"ubcColumnsTwo",allowChildren:["ubcColumnsTwoColumn"]}),e.register("ubcColumnsTwoColumn",{isLimit:!0,allowIn:"ubcColumnsTwo",allowAttributes:"class",allowContentOf:"$root"}),e.addChildCheck(((e,t)=>{}))}_defineConverters(){const{conversion:e}=this.editor;e.for("upcast").elementToElement({model:"ubcColumnsTwo",view:{name:"div",classes:["widget-columns-2"]}}),e.for("upcast").elementToElement({model:"ubcColumnsTwoWrapper",view:{name:"div",classes:"widget--md--grid"}}),e.for("upcast").elementToElement({model:(e,{writer:t})=>t.createElement("ubcColumnsTwoColumn",{class:e.getAttribute("class")}),view:{name:"div",classes:["first-child--mt-0"]}}),e.for("dataDowncast").elementToElement({model:"ubcColumnsTwo",view:(e,{writer:t})=>t.createContainerElement("div",{class:"widget-column-options widget-columns-2"})}),e.for("dataDowncast").elementToElement({model:"ubcColumnsTwoWrapper",view:(e,{writer:t})=>t.createContainerElement("div",{class:"widget--md--grid"})}),e.for("dataDowncast").elementToElement({model:"ubcColumnsTwoColumn",view:(e,{writer:t})=>t.createContainerElement("div",{class:"first-child--mt-0"})}),e.for("editingDowncast").elementToElement({model:"ubcColumnsTwo",view:(e,{writer:o})=>{const s=o.createContainerElement("div",{class:"widget-column-options widget-columns-2"});return(0,t.toWidget)(s,o,{label:"UBC Two Columns widget",hasSelectionHandle:!0})}}),e.for("editingDowncast").elementToElement({model:"ubcColumnsTwoWrapper",view:(e,{writer:o})=>{const s=o.createEditableElement("div",{class:"widget--md--grid"});return(0,t.toWidgetEditable)(s,o)}}),e.for("editingDowncast").elementToElement({model:"ubcColumnsTwoColumn",view:(e,{writer:o})=>{const s=o.createEditableElement("div",{class:"first-child--mt-0"});return(0,t.toWidgetEditable)(s,o)}})}}var g=o("ckeditor5/src/ui.js");class b extends e.Plugin{static get requires(){return[g.ContextualBalloon]}init(){const e=this.editor;e.ui.componentFactory.add("ubcColumnsTwo",(t=>{const o=e.commands.get("ubcColumnsTwo"),s=new g.ButtonView(t);return s.set({label:e.t("Two Columns"),icon:'',tooltip:!0,class:"cke5-ubccolumnstwo-insert-button"}),s.bind("isOn","isEnabled").to(o,"value","isEnabled"),this.listenTo(s,"execute",(()=>e.execute("ubcColumnsTwo"))),s}))}}function w(e){const t=e.getSelectedElement();return t&&p(t)?t:null}function C(e){const t=e.getFirstPosition();if(!t)return null;let o=t.parent;for(;o;){if(o.is("element")&&p(o))return o;o=o.parent}return null}function p(e){return!!e.hasClass("widget-columns-2")&&(0,t.isWidget)(e)}class T extends e.Plugin{static get requires(){return[t.WidgetToolbarRepository]}static get pluginName(){return"UbcColumnsTwoToolbar"}afterInit(){const e=this.editor,o=e.plugins.get(t.WidgetToolbarRepository),s=e.config.get("ubcColumnsTwo.contentToolbar"),n=e.config.get("ubcColumnsTwo.tableToolbar");s&&o.register("ubcColumnsTwoContent",{ariaLabel:e.t("Two Columns toolbar"),items:s,getRelatedElement:C}),n&&o.register("ubcColumnsTwo",{ariaLabel:e.t("Two Columns toolbar"),items:n,getRelatedElement:w})}}class h extends e.Command{constructor(e){super(e)}execute(e={}){const{editor:t}=this,{model:o}=this.editor,{selection:s}=t.model.document,n=s.getSelectedElement();let i="";const l=e.value,r="gapclass";i=n&&n.is("element","ubcColumnsTwo")?n.getChild(0):s.getFirstPosition().findAncestor("ubcColumnsTwo").getChild(0),o.change((e=>{if(s.isCollapsed)l?e.setAttribute(r,l,i):e.removeAttribute(r,i);else{const t=o.schema.getValidRanges(s.getRanges(),r);for(const o of t)l?(e.setAttribute(r,l,o),this.value=l):e.removeAttribute(r,o)}}))}refresh(){const{model:e}=this.editor,{selection:t}=e.document,o=t.getFirstPosition().findAncestor("ubcColumnsTwo"),s=e.schema.findAllowedParent(t.getFirstPosition(),"ubcColumnsTwo");this.isEnabled=null!==s,this.value=!!o&&o.getChild(0).getAttribute("gapclass")}}class v extends e.Plugin{static get requires(){return[t.Widget]}static get pluginName(){return"UbcColumnsTwoGapEditing"}constructor(e){super(e)}init(){const{editor:e}=this;this._defineConverters(),e.model.schema.extend("ubcColumnsTwoWrapper",{allowAttributes:"gapclass"}),e.conversion.attributeToAttribute({model:"gapclass",view:"class"}),e.commands.add("ubcColumnsTwoGap",new h(e))}_defineConverters(){const{conversion:e}=this.editor;e.for("upcast").attributeToAttribute({view:{key:"class",value:/\bgap-[\S]+/},model:{key:"gapclass",value:e=>e.getAttribute("class").match(/\bgap-([\S]+)/)[0]}}),e.for("downcast").attributeToAttribute({model:"gapclass",view:e=>({key:"class",value:e})})}}var f=o("ckeditor5/src/utils.js");class y extends e.Plugin{static get pluginName(){return"UbcColumnsTwoGapUI"}init(){const e=this.editor,t=e.t;l.map((e=>e)).value;const o=e.commands.get("ubcColumnsTwoGap");e.ui.componentFactory.add("ubcColumnsTwoGapOptions",(s=>{const n=(0,g.createDropdown)(s);return(0,g.addListToDropdown)(n,function(e,t){const o=new f.Collection,s="ubcColumnsTwoGap";let n=l.map((e=>e));for(const e of n){const n={type:"button",model:new g.ViewModel({commandName:s,commandParam:e.value,label:e.label,withText:!0})};n.model.bind("isOn").to(t,"value",(t=>t===e.value||!(!t||!e.value)&&t.toLowerCase()===e.value.toLowerCase())),o.add(n)}return o}(0,o)),n.buttonView.set({label:t("Gap"),tooltip:!0,withText:!0,class:"cke5-ubccolumnstwo-gap-insert-button"}),n.extendTemplate({attributes:{class:"ck-gap-options-dropdown"}}),n.bind("isEnabled").to(o),this.listenTo(n,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),n}))}}class x extends e.Plugin{static get requires(){return[v,y]}static get pluginName(){return"UbcColumnsTwoGap"}}class E extends e.Command{constructor(e){super(e)}execute(e={}){const{editor:t}=this,{model:o}=this.editor,{selection:s}=t.model.document,n=s.getSelectedElement();let i="";const l="keylineclass";i=n&&n.is("element","ubcColumnsTwo")?n:s.getFirstPosition().findAncestor("ubcColumnsTwo");let r=i.getAttribute(l);o.change((e=>{"widget-keylines"===r?(e.setAttribute(l,"widget-keyline-none",i),this.isOn=!1):(e.setAttribute(l,"widget-keylines",i),this.isOn=!0)}))}refresh(){const{model:e}=this.editor,{selection:t}=e.document,o=t.getFirstPosition().findAncestor("ubcColumnsTwo"),s=e.schema.findAllowedParent(t.getFirstPosition(),"ubcColumnsTwo");this.isEnabled=null!==s,this.value=!!o&&o.getAttribute("keylineclass")}}class A extends e.Plugin{static get requires(){return[t.Widget]}static get pluginName(){return"UbcColumnsTwoKeylineEditing"}constructor(e){super(e)}init(){const{editor:e}=this;this._defineConverters(),e.model.schema.extend("ubcColumnsTwo",{allowAttributes:"keylineclass"}),e.conversion.attributeToAttribute({model:"keylineclass",view:"class"}),e.commands.add("ubcColumnsTwoKeyline",new E(e))}_defineConverters(){const{conversion:e}=this.editor;e.for("upcast").attributeToAttribute({view:{key:"class",value:/widget-keyline[\S]+/},model:{key:"keylineclass",value:e=>e.getAttribute("class").match(/widget-keyline([\S]+)/)[0]}}),e.for("downcast").attributeToAttribute({model:"keylineclass",view:e=>({key:"class",value:e})})}}class k extends e.Plugin{static get requires(){return[g.ContextualBalloon]}static get pluginName(){return"UbcColumnsTwoKeylineUI"}init(){const e=this.editor;e.ui.componentFactory.add("ubcColumnsTwoKeylineToggle",(t=>{const o=e.commands.get("ubcColumnsTwoKeyline"),s=new g.ButtonView(t);return s.set({label:e.t("Toggle Keylines"),tooltip:!0,withText:!0,class:"cke5-ubccolumnstwo-keyline-insert-button"}),s.bind("isEnabled").to(o),s.bind("isOn").to(o),this.listenTo(s,"execute",(()=>e.execute("ubcColumnsTwoKeyline"))),s}))}}class P extends e.Plugin{static get requires(){return[A,k]}static get pluginName(){return"UbcColumnsTwoKeyline"}}class W extends e.Command{constructor(e){super(e)}execute(e={}){const{editor:t}=this,{model:o}=this.editor,{selection:s}=t.model.document,n=s.getSelectedElement();let i="";const l=e.value,r="marginclass";i=n&&n.is("element","ubcColumnsTwo")?n:s.getFirstPosition().findAncestor("ubcColumnsTwo"),o.change((e=>{if(s.isCollapsed)l?e.setAttribute(r,l,i):e.removeAttribute(r,i);else{const t=o.schema.getValidRanges(s.getRanges(),r);for(const o of t)l?e.setAttribute(r,l,o):e.removeAttribute(r,o)}}))}refresh(){const{model:e}=this.editor,{selection:t}=e.document,o=t.getFirstPosition().findAncestor("ubcColumnsTwo"),s=e.schema.findAllowedParent(t.getFirstPosition(),"ubcColumnsTwo");this.isEnabled=null!==s,this.value=!!o&&o.getAttribute("marginclass")}}class S extends e.Plugin{static get requires(){return[t.Widget]}static get pluginName(){return"UbcColumnsTwoMarginEditing"}constructor(e){super(e)}init(){const{editor:e}=this;this._defineConverters(),e.model.schema.extend("ubcColumnsTwo",{allowAttributes:"marginclass"}),e.conversion.attributeToAttribute({model:"marginclass",view:"class"}),e.commands.add("ubcColumnsTwoMargin",new W(e))}_defineConverters(){const{conversion:e}=this.editor;e.for("upcast").attributeToAttribute({view:{key:"class",value:/\bmy-[\S]+/},model:{key:"marginclass",value:e=>e.getAttribute("class").match(/\bmy-([\S]+)/)[0]}}),e.for("downcast").attributeToAttribute({model:"marginclass",view:e=>({key:"class",value:e})})}}class L extends e.Plugin{static get pluginName(){return"UbcColumnsTwoMarginUI"}init(){const e=this.editor,t=e.t;r.map((e=>e)).value;const o=e.commands.get("ubcColumnsTwoMargin");e.ui.componentFactory.add("ubcColumnsTwoMarginOptions",(s=>{const n=(0,g.createDropdown)(s);return(0,g.addListToDropdown)(n,function(e,t){const o=new f.Collection,s="ubcColumnsTwoMargin";let n=r.map((e=>e));for(const e of n){const n={type:"button",model:new g.ViewModel({commandName:s,commandParam:e.value,label:e.label,withText:!0})};n.model.bind("isOn").to(t,"value",(t=>t===e.value||!(!t||!e.value)&&t.toLowerCase()===e.value.toLowerCase())),o.add(n)}return o}(0,o)),n.buttonView.set({label:t("Margin"),tooltip:!0,withText:!0,class:"cke5-ubccolumnstwo-margin-insert-button"}),n.extendTemplate({attributes:{class:"ck-margin-options-dropdown"}}),n.bind("isEnabled").to(o),this.listenTo(n,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),n}))}}class F extends e.Plugin{static get requires(){return[S,L]}static get pluginName(){return"UbcColumnsTwoMargin"}}class N extends e.Command{constructor(e){super(e)}execute(e={}){const{editor:t}=this,{model:o}=this.editor,{selection:s}=t.model.document,n=s.getSelectedElement();let i="";const l=e.value,r="layoutcolclass";i=n&&n.is("element","ubcColumnsTwo")?n:s.getFirstPosition().findAncestor("ubcColumnsTwo"),o.change((e=>{if(s.isCollapsed)l?e.setAttribute(r,l,i):e.removeAttribute(r,i);else{const t=o.schema.getValidRanges(s.getRanges(),r);for(const o of t)l?(e.setAttribute(r,l,o),this.value=l):e.removeAttribute(r,o)}}))}refresh(){const{model:e}=this.editor,{selection:t}=e.document,o=t.getFirstPosition().findAncestor("ubcColumnsTwo"),s=e.schema.findAllowedParent(t.getFirstPosition(),"ubcColumnsTwo");this.isEnabled=null!==s,this.value=!!o&&o.getAttribute("layoutcolclass")}}class j extends e.Plugin{static get requires(){return[t.Widget]}static get pluginName(){return"UbcColumnsTwoLayoutEditing"}constructor(e){super(e)}init(){const{editor:e}=this;this._defineConverters(),e.model.schema.extend("ubcColumnsTwo",{allowAttributes:"layoutcolclass"}),e.conversion.attributeToAttribute({model:"layoutcolclass",view:"class"}),e.commands.add("ubcColumnsTwoLayout",new N(e))}_defineConverters(){const{conversion:e}=this.editor;e.for("upcast").attributeToAttribute({view:{key:"class",value:/\balign-[\S]+/},model:{key:"layoutcolclass",value:e=>e.getAttribute("class").match(/\balign-([\S]+)/)[0]}}),e.for("downcast").attributeToAttribute({model:"layoutcolclass",view:e=>({key:"class",value:e})})}}class U extends e.Plugin{static get pluginName(){return"UbcColumnsTwoLayoutUI"}init(){const e=this.editor,t=e.t,o=c.map((e=>e)),s=e.commands.get("ubcColumnsTwoLayout");e.ui.componentFactory.add("ubcColumnsTwoLayoutOptions",(n=>{const i=(0,g.createDropdown)(n);return(0,g.addListToDropdown)(i,function(e,t){const o=new f.Collection,s="ubcColumnsTwoLayout";for(const n of e){const e={type:"button",model:new g.ViewModel({commandName:s,commandParam:n.value,label:n.label,withText:!0})};e.model.bind("isOn").to(t,"value",(e=>e===n.value)),o.add(e)}return o}(o,s)),i.buttonView.set({label:t("Layout Options"),tooltip:!0,withText:!0,class:"cke5-ubccolumnstwo-layout-insert-button"}),i.extendTemplate({attributes:{class:"ck-3column-options-dropdown"}}),i.bind("isEnabled").to(s),this.listenTo(i,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),i}))}}class K extends e.Plugin{static get requires(){return[j,U]}static get pluginName(){return"UbcColumnsTwoLayout"}}class O extends e.Plugin{static get requires(){return[m,b,T,x,P,F,K]}}const q={UbcColumnsTwo:O}})(),s=s.default})())); \ No newline at end of file diff --git a/js/ckeditor5_plugins/ubcColumnsFour/src/ubccolumnsfourcommand.js b/js/ckeditor5_plugins/ubcColumnsFour/src/ubccolumnsfourcommand.js index 64a420a..1cd2d8a 100644 --- a/js/ckeditor5_plugins/ubcColumnsFour/src/ubccolumnsfourcommand.js +++ b/js/ckeditor5_plugins/ubcColumnsFour/src/ubccolumnsfourcommand.js @@ -77,16 +77,16 @@ function createUbcColumnsFour(writer) { class: 'widget-column-options widget-columns-4 align-equal' }); const firstColumn = writer.createElement('ubcColumnsFourColumn', { - class: 'widget-region-one' + class: 'widget-region-one first-child--mt-0' }); const secondColumn = writer.createElement('ubcColumnsFourColumn', { - class: 'widget-region-two' + class: 'widget-region-two first-child--mt-0' }); const thirdColumn = writer.createElement('ubcColumnsFourColumn', { - class: 'widget-region-three' + class: 'widget-region-three first-child--mt-0' }); const fourthColumn = writer.createElement('ubcColumnsFourColumn', { - class: 'widget-region-four' + class: 'widget-region-four first-child--mt-0' }); const wrapper = writer.createElement('ubcColumnsFourWrapper', defaultColumnsGapStyle, { class: 'widget--md--grid' diff --git a/js/ckeditor5_plugins/ubcColumnsFour/src/ubccolumnsfourediting.js b/js/ckeditor5_plugins/ubcColumnsFour/src/ubccolumnsfourediting.js index 37a6a14..f8a07ca 100644 --- a/js/ckeditor5_plugins/ubcColumnsFour/src/ubccolumnsfourediting.js +++ b/js/ckeditor5_plugins/ubcColumnsFour/src/ubccolumnsfourediting.js @@ -164,7 +164,11 @@ export default class UbcColumnsFourEditing extends Plugin { // model, provided it is a child element of , // as required by the schema. conversion.for('upcast').elementToElement({ - model: 'ubcColumnsFourColumn', + model: (viewElement, { writer }) => { + return writer.createElement('ubcColumnsFourColumn', { + class: viewElement.getAttribute('class') + }); + }, view: { name: 'div', classes: ['first-child--mt-0'], diff --git a/js/ckeditor5_plugins/ubcColumnsThree/src/ubccolumnsthreecommand.js b/js/ckeditor5_plugins/ubcColumnsThree/src/ubccolumnsthreecommand.js index c5fcf2c..726999e 100644 --- a/js/ckeditor5_plugins/ubcColumnsThree/src/ubccolumnsthreecommand.js +++ b/js/ckeditor5_plugins/ubcColumnsThree/src/ubccolumnsthreecommand.js @@ -77,13 +77,13 @@ function createUbcColumnsThree(writer) { class: 'widget-column-options widget-columns-3' }); const firstColumn = writer.createElement('ubcColumnsThreeColumn', { - class: 'widget-region-one' + class: 'widget-region-one first-child--mt-0' }); const secondColumn = writer.createElement('ubcColumnsThreeColumn', { - class: 'widget-region-two' + class: 'widget-region-two first-child--mt-0' }); const thirdColumn = writer.createElement('ubcColumnsThreeColumn', { - class: 'widget-region-three' + class: 'widget-region-three first-child--mt-0' }); const wrapper = writer.createElement('ubcColumnsThreeWrapper', defaultColumnsGapStyle, { class: 'widget--md--grid' diff --git a/js/ckeditor5_plugins/ubcColumnsThree/src/ubccolumnsthreeediting.js b/js/ckeditor5_plugins/ubcColumnsThree/src/ubccolumnsthreeediting.js index 0805dbc..1d36b87 100644 --- a/js/ckeditor5_plugins/ubcColumnsThree/src/ubccolumnsthreeediting.js +++ b/js/ckeditor5_plugins/ubcColumnsThree/src/ubccolumnsthreeediting.js @@ -159,7 +159,11 @@ export default class UbcColumnsThreeEditing extends Plugin { // model, provided it is a child element of , // as required by the schema. conversion.for('upcast').elementToElement({ - model: 'ubcColumnsThreeColumn', + model: (viewElement, { writer }) => { + return writer.createElement('ubcColumnsThreeColumn', { + class: viewElement.getAttribute('class') + }); + }, view: { name: 'div', classes: ['first-child--mt-0'], diff --git a/js/ckeditor5_plugins/ubcColumnsTwo/src/ubccolumnstwocommand.js b/js/ckeditor5_plugins/ubcColumnsTwo/src/ubccolumnstwocommand.js index 271f223..e136d24 100644 --- a/js/ckeditor5_plugins/ubcColumnsTwo/src/ubccolumnstwocommand.js +++ b/js/ckeditor5_plugins/ubcColumnsTwo/src/ubccolumnstwocommand.js @@ -78,10 +78,10 @@ function createUbcColumnsTwo(writer) { class: 'widget-column-options widget-columns-2' }); const firstColumn = writer.createElement('ubcColumnsTwoColumn', { - class: 'widget-region-one' + class: 'widget-region-one first-child--mt-0' }); const secondColumn = writer.createElement('ubcColumnsTwoColumn', { - class: 'widget-region-two' + class: 'widget-region-two first-child--mt-0' }); const wrapper = writer.createElement('ubcColumnsTwoWrapper', defaultColumnsGapStyle, { class: 'widget--md--grid' diff --git a/js/ckeditor5_plugins/ubcColumnsTwo/src/ubccolumnstwoediting.js b/js/ckeditor5_plugins/ubcColumnsTwo/src/ubccolumnstwoediting.js index 5cbdd77..c1fa891 100644 --- a/js/ckeditor5_plugins/ubcColumnsTwo/src/ubccolumnstwoediting.js +++ b/js/ckeditor5_plugins/ubcColumnsTwo/src/ubccolumnstwoediting.js @@ -155,7 +155,11 @@ export default class UbcColumnsTwoEditing extends Plugin { // model, provided it is a child element of , // as required by the schema. conversion.for('upcast').elementToElement({ - model: 'ubcColumnsTwoColumn', + model: (viewElement, { writer }) => { + return writer.createElement('ubcColumnsTwoColumn', { + class: viewElement.getAttribute('class') + }); + }, view: { name: 'div', classes: ['first-child--mt-0'],