diff --git a/custom/modules/emmr_transcribe/emmr_transcribe.ckeditor5.yml b/custom/modules/emmr_transcribe/emmr_transcribe.ckeditor5.yml index 7a4f8e0..3bc5467 100644 --- a/custom/modules/emmr_transcribe/emmr_transcribe.ckeditor5.yml +++ b/custom/modules/emmr_transcribe/emmr_transcribe.ckeditor5.yml @@ -45,10 +45,10 @@ emmr_transcribe_plugins: - - - - - - - - + - # *Additional configuration properties* # conditions: for setting additional criteria that must be met for the # plugin to be active. diff --git a/custom/modules/emmr_transcribe/js/build/transReplace.js b/custom/modules/emmr_transcribe/js/build/transReplace.js index 3e467a9..49823dc 100644 --- a/custom/modules/emmr_transcribe/js/build/transReplace.js +++ b/custom/modules/emmr_transcribe/js/build/transReplace.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.transReplace=t())}(self,(()=>(()=>{var e={"ckeditor5/src/core.js":(e,t,n)=>{e.exports=n("dll-reference CKEditor5.dll")("./src/core.js")},"ckeditor5/src/ui.js":(e,t,n)=>{e.exports=n("dll-reference CKEditor5.dll")("./src/ui.js")},"ckeditor5/src/widget.js":(e,t,n)=>{e.exports=n("dll-reference CKEditor5.dll")("./src/widget.js")},"dll-reference CKEditor5.dll":e=>{"use strict";e.exports=CKEditor5.dll}},t={};function n(r){var s=t[r];if(void 0!==s)return s.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var r={};return(()=>{"use strict";n.d(r,{default:()=>c});var e=n("ckeditor5/src/core.js"),t=n("ckeditor5/src/widget.js");class s extends e.Command{execute(){const{model:e}=this.editor,{selection:t}=e.document,n=t.getFirstRange().getItems().next().value.data;e.change((t=>{e.insertContent(function(e,t){alert(t);const n=e.createElement("transReplace"),r=e.createElement("transReplaceOld");e.appendText("^",{},r);const s=e.createElement("transReplaceText");let a=prompt("Enter transcription replacement text");return e.appendText(a,{},s),e.append(r,n),e.append(s,n),n}(t,n))}))}refresh(){const{model:e}=this.editor,{selection:t}=e.document,n=e.schema.findAllowedParent(t.getFirstPosition(),"transReplace");this.isEnabled=null!==n}}class a extends e.Plugin{static get requires(){return[t.Widget]}init(){this._defineSchema(),this._defineConverters(),this.editor.commands.add("insertTransReplace",new s(this.editor))}_defineSchema(){const e=this.editor.model.schema;e.register("transReplace",{isObject:!0,allowWhere:"$block"}),e.register("transReplaceOld",{isLimit:!0,allowIn:"transReplace",allowContentOf:"$block"}),e.register("transReplaceText",{isLimit:!0,allowIn:"transReplace",allowContentOf:"$root"}),e.addChildCheck(((e,t)=>{if(e.startsWith("trans")&&"transReplace"===t.name)return!1}))}_defineConverters(){const{conversion:e}=this.editor;e.for("upcast").elementToElement({model:"transReplace",view:{name:"trxnrep"}}),e.for("upcast").elementToElement({model:"transReplaceOld",view:{name:"span",classes:"trxn-caret"}}),e.for("upcast").elementToElement({model:"transReplaceText",view:{name:"span",classes:"trxn-text"}}),e.for("dataDowncast").elementToElement({model:"transReplace",view:{name:"trxnrep"}}),e.for("dataDowncast").elementToElement({model:"transReplaceOld",view:{name:"span",classes:"trxn-caret"}}),e.for("dataDowncast").elementToElement({model:"transReplaceText",view:{name:"span",classes:"trxn-text"}}),e.for("editingDowncast").elementToElement({model:"transReplace",view:(e,{writer:n})=>{const r=n.createContainerElement("trxnrep",{});return(0,t.toWidget)(r,n,{label:"Transcription replacement widget"})}}),e.for("editingDowncast").elementToElement({model:"transReplaceOld",view:(e,{writer:n})=>{const r=n.createContainerElement("span",{class:"trxn-caret"});return(0,t.toWidget)(r,n)}}),e.for("editingDowncast").elementToElement({model:"transReplaceText",view:(e,{writer:n})=>{const r=n.createEditableElement("span",{class:"trxn-text"});return(0,t.toWidgetEditable)(r,n)}})}}var o=n("ckeditor5/src/ui.js");class l extends e.Plugin{init(){const e=this.editor;e.ui.componentFactory.add("transReplace",(t=>{const n=e.commands.get("insertTransReplace"),r=new o.ButtonView(t);return r.set({label:e.t("Transcription Replace"),icon:'\n',tooltip:!0}),r.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(r,"execute",(()=>e.execute("insertTransReplace"))),r}))}}class i extends e.Plugin{static get requires(){return[a,l]}}const c={TransReplace:i}})(),r=r.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.transReplace=t())}(self,(()=>(()=>{var e={"ckeditor5/src/core.js":(e,t,n)=>{e.exports=n("dll-reference CKEditor5.dll")("./src/core.js")},"ckeditor5/src/ui.js":(e,t,n)=>{e.exports=n("dll-reference CKEditor5.dll")("./src/ui.js")},"ckeditor5/src/widget.js":(e,t,n)=>{e.exports=n("dll-reference CKEditor5.dll")("./src/widget.js")},"dll-reference CKEditor5.dll":e=>{"use strict";e.exports=CKEditor5.dll}},t={};function n(r){var s=t[r];if(void 0!==s)return s.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var r={};return(()=>{"use strict";n.d(r,{default:()=>c});var e=n("ckeditor5/src/core.js"),t=n("ckeditor5/src/widget.js");class s extends e.Command{execute(){const{model:e}=this.editor,{selection:t}=e.document,n=t.getFirstRange().getItems().next().value.data;e.change((t=>{e.insertContent(function(e,t){const n=e.createElement("transReplace"),r=e.createElement("transReplaceOld");e.appendText(t,{},r);const s=e.createElement("transReplaceText");let o=prompt("Enter transcription replacement text");return e.appendText(o,{},s),e.append(s,n),e.append(r,n),n}(t,n))}))}refresh(){const{model:e}=this.editor,{selection:t}=e.document,n=e.schema.findAllowedParent(t.getFirstPosition(),"transReplace");this.isEnabled=null!==n}}class o extends e.Plugin{static get requires(){return[t.Widget]}init(){this._defineSchema(),this._defineConverters(),this.editor.commands.add("insertTransReplace",new s(this.editor))}_defineSchema(){const e=this.editor.model.schema;e.register("transReplace",{isObject:!0,allowWhere:"$block"}),e.register("transReplaceOld",{isLimit:!0,allowIn:"transReplace",allowContentOf:"$block"}),e.register("transReplaceText",{isLimit:!0,allowIn:"transReplace",allowContentOf:"$root"}),e.addChildCheck(((e,t)=>{if(e.startsWith("trans")&&"transReplace"===t.name)return!1}))}_defineConverters(){const{conversion:e}=this.editor;e.for("upcast").elementToElement({model:"transReplace",view:{name:"trxnrep"}}),e.for("upcast").elementToElement({model:"transReplaceOld",view:{name:"s",classes:"trxn-replaced"}}),e.for("upcast").elementToElement({model:"transReplaceText",view:{name:"span",classes:"trxn-text"}}),e.for("dataDowncast").elementToElement({model:"transReplace",view:{name:"trxnrep"}}),e.for("dataDowncast").elementToElement({model:"transReplaceOld",view:{name:"s",classes:"trxn-replaced"}}),e.for("dataDowncast").elementToElement({model:"transReplaceText",view:{name:"span",classes:"trxn-text"}}),e.for("editingDowncast").elementToElement({model:"transReplace",view:(e,{writer:n})=>{const r=n.createContainerElement("trxnrep",{});return(0,t.toWidget)(r,n,{label:"Transcription replacement widget"})}}),e.for("editingDowncast").elementToElement({model:"transReplaceOld",view:(e,{writer:n})=>{const r=n.createContainerElement("s",{class:"trxn-replaced"});return(0,t.toWidget)(r,n)}}),e.for("editingDowncast").elementToElement({model:"transReplaceText",view:(e,{writer:n})=>{const r=n.createEditableElement("span",{class:"trxn-text"});return(0,t.toWidgetEditable)(r,n)}})}}var a=n("ckeditor5/src/ui.js");class l extends e.Plugin{init(){const e=this.editor;e.ui.componentFactory.add("transReplace",(t=>{const n=e.commands.get("insertTransReplace"),r=new a.ButtonView(t);return r.set({label:e.t("Transcription Replace"),icon:'\n',tooltip:!0}),r.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(r,"execute",(()=>e.execute("insertTransReplace"))),r}))}}class i extends e.Plugin{static get requires(){return[o,l]}}const c={TransReplace:i}})(),r=r.default})())); \ No newline at end of file diff --git a/custom/modules/emmr_transcribe/js/ckeditor5_plugins/transReplace/src/inserttransreplacecommand.js b/custom/modules/emmr_transcribe/js/ckeditor5_plugins/transReplace/src/inserttransreplacecommand.js index 7dad9d6..961e6b5 100644 --- a/custom/modules/emmr_transcribe/js/ckeditor5_plugins/transReplace/src/inserttransreplacecommand.js +++ b/custom/modules/emmr_transcribe/js/ckeditor5_plugins/transReplace/src/inserttransreplacecommand.js @@ -39,20 +39,19 @@ export default class InsertTransReplaceCommand extends Command { } function createTransReplace(writer, selected) { - alert(selected); // Create instances of the three elements registered with the editor in // transreplaceediting.js. const transReplace = writer.createElement('transReplace'); const transReplaceOld = writer.createElement('transReplaceOld'); - writer.appendText('^', {}, transReplaceOld); + writer.appendText(selected, {}, transReplaceOld); const transReplaceText = writer.createElement('transReplaceText'); let replaceText = prompt("Enter transcription replacement text"); writer.appendText(replaceText, {}, transReplaceText); // Append the title and description elements to the transReplace, which matches // the parent/child relationship as defined in their schemas. - writer.append(transReplaceOld, transReplace); writer.append(transReplaceText, transReplace); + writer.append(transReplaceOld, transReplace); // Return the element to be added to the editor. return transReplace; diff --git a/custom/modules/emmr_transcribe/js/ckeditor5_plugins/transReplace/src/transreplaceediting.js b/custom/modules/emmr_transcribe/js/ckeditor5_plugins/transReplace/src/transreplaceediting.js index 41b69f1..a74ce18 100644 --- a/custom/modules/emmr_transcribe/js/ckeditor5_plugins/transReplace/src/transreplaceediting.js +++ b/custom/modules/emmr_transcribe/js/ckeditor5_plugins/transReplace/src/transreplaceediting.js @@ -12,14 +12,14 @@ import InsertTransReplaceCommand from './inserttransreplacecommand'; * * CKEditor 5 internally interacts with transReplace as this model: * - * * + * * * * Which is converted for the browser/user as this markup * - * * + * * * * This file has the logic for defining the transReplace model, and for how it is @@ -42,8 +42,8 @@ export default class TransReplaceEditing extends Plugin { /* * This registers the structure that will be seen by CKEditor 5 as * - * * + * * * * The logic in _defineConverters() will determine how this is converted to @@ -110,15 +110,15 @@ export default class TransReplaceEditing extends Plugin { }, }); - // If is present in the existing markup + // If is present in the existing markup // processed by CKEditor, then CKEditor recognizes and loads it as a // model, provided it is a child element of , // as required by the schema. conversion.for('upcast').elementToElement({ model: 'transReplaceOld', view: { - name: 'span', - classes: 'trxn-caret', + name: 's', + classes: 'trxn-replaced', }, }); @@ -147,12 +147,12 @@ export default class TransReplaceEditing extends Plugin { }); // Instances of are saved as - // {{inner content}}. + // {{inner content}}. conversion.for('dataDowncast').elementToElement({ model: 'transReplaceOld', view: { - name: 'span', - classes: 'trxn-caret', + name: 's', + classes: 'trxn-replaced', }, }); @@ -181,13 +181,13 @@ export default class TransReplaceEditing extends Plugin { }, }); - // Convert the model into an editable widget. + // Convert the model into an editable widget. conversion.for('editingDowncast').elementToElement({ model: 'transReplaceOld', view: (modelElement, { writer: viewWriter }) => { - const span = viewWriter.createContainerElement('span', + const span = viewWriter.createContainerElement('s', { - class: 'trxn-caret' + class: 'trxn-replaced' }); return toWidget(span, viewWriter); }, diff --git a/custom/themes/emmr_lib_unb_ca/src/scss/style.scss b/custom/themes/emmr_lib_unb_ca/src/scss/style.scss index e05eee3..69c0b02 100644 --- a/custom/themes/emmr_lib_unb_ca/src/scss/style.scss +++ b/custom/themes/emmr_lib_unb_ca/src/scss/style.scss @@ -652,7 +652,8 @@ h1.page-header > a { } /* Transcription */ -trxnin, trxnin + p, p:has(+ trxnin) { +trxnin, trxnin + p, p:has(+ trxnin), +trxnrep, trxnrep + p, p:has(+ trxnrep) { display: inline; }