@ckeditor/ckeditor5-heading 47.4.0-alpha.4 → 47.4.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/heading.js CHANGED
@@ -2,4 +2,4 @@
2
2
  /*!
3
3
  * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
4
4
  * For licensing, see LICENSE.md.
5
- */(()=>{var e={163:e=>{"use strict";e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},179:(e,t,n)=>{e.exports=n(237)("./src/paragraph.js")},237:e=>{"use strict";e.exports=CKEditor5.dll},305:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var n="",o=void 0!==t[5];return t[4]&&(n+="@supports (".concat(t[4],") {")),t[2]&&(n+="@media ".concat(t[2]," {")),o&&(n+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),n+=e(t),o&&(n+="}"),t[2]&&(n+="}"),t[4]&&(n+="}"),n}).join("")},t.i=function(e,n,o,i,r){"string"==typeof e&&(e=[[null,e,void 0]]);var a={};if(o)for(var s=0;s<this.length;s++){var c=this[s][0];null!=c&&(a[c]=!0)}for(var d=0;d<e.length;d++){var l=[].concat(e[d]);o&&a[l[0]]||(void 0!==r&&(void 0===l[5]||(l[1]="@layer".concat(l[5].length>0?" ".concat(l[5]):""," {").concat(l[1],"}")),l[5]=r),n&&(l[2]?(l[1]="@media ".concat(l[2]," {").concat(l[1],"}"),l[2]=n):l[2]=n),i&&(l[4]?(l[1]="@supports (".concat(l[4],") {").concat(l[1],"}"),l[4]=i):l[4]="".concat(i)),t.push(l))}},t}},311:(e,t,n)=>{e.exports=n(237)("./src/ui.js")},349:(e,t,n)=>{"use strict";n.d(t,{A:()=>s});var o=n(792),i=n.n(o),r=n(305),a=n.n(r)()(i());a.push([e.id,".ck.ck-heading_heading1 .ck-button__label{font-size:20px}.ck.ck-heading_heading2 .ck-button__label{font-size:17px}.ck.ck-heading_heading3 .ck-button__label{font-size:14px}.ck[class*=ck-heading_heading]{font-weight:700}.ck.ck-dropdown.ck-heading-dropdown .ck-dropdown__button .ck-button__label{width:8em}.ck.ck-dropdown.ck-heading-dropdown .ck-dropdown__panel .ck-list__item{min-width:18em}",""]);const s=a},355:(e,t,n)=>{e.exports=n(237)("./src/icons.js")},424:e=>{"use strict";var t={};e.exports=function(e,n){var o=function(e){if(void 0===t[e]){var n=document.querySelector(e);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}t[e]=n}return t[e]}(e);if(!o)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");o.appendChild(n)}},517:e=>{"use strict";e.exports=function(e,t){Object.keys(t).forEach(function(n){e.setAttribute(n,t[n])})}},584:(e,t,n)=>{e.exports=n(237)("./src/utils.js")},719:e=>{"use strict";var t=[];function n(e){for(var n=-1,o=0;o<t.length;o++)if(t[o].identifier===e){n=o;break}return n}function o(e,o){for(var r={},a=[],s=0;s<e.length;s++){var c=e[s],d=o.base?c[0]+o.base:c[0],l=r[d]||0,u="".concat(d," ").concat(l);r[d]=l+1;var m=n(u),g={css:c[1],media:c[2],sourceMap:c[3],supports:c[4],layer:c[5]};if(-1!==m)t[m].references++,t[m].updater(g);else{var h=i(g,o);o.byIndex=s,t.splice(s,0,{identifier:u,updater:h,references:1})}a.push(u)}return a}function i(e,t){var n=t.domAPI(t);n.update(e);return function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap&&t.supports===e.supports&&t.layer===e.layer)return;n.update(e=t)}else n.remove()}}e.exports=function(e,i){var r=o(e=e||[],i=i||{});return function(e){e=e||[];for(var a=0;a<r.length;a++){var s=n(r[a]);t[s].references--}for(var c=o(e,i),d=0;d<r.length;d++){var l=n(r[d]);0===t[l].references&&(t[l].updater(),t.splice(l,1))}r=c}}},782:(e,t,n)=>{e.exports=n(237)("./src/core.js")},783:(e,t,n)=>{e.exports=n(237)("./src/engine.js")},792:e=>{"use strict";e.exports=function(e){return e[1]}},863:e=>{"use strict";var t,n=(t=[],function(e,n){return t[e]=n,t.filter(Boolean).join("\n")});function o(e,t,o,i){var r;if(o)r="";else{r="",i.supports&&(r+="@supports (".concat(i.supports,") {")),i.media&&(r+="@media ".concat(i.media," {"));var a=void 0!==i.layer;a&&(r+="@layer".concat(i.layer.length>0?" ".concat(i.layer):""," {")),r+=i.css,a&&(r+="}"),i.media&&(r+="}"),i.supports&&(r+="}")}if(e.styleSheet)e.styleSheet.cssText=n(t,r);else{var s=document.createTextNode(r),c=e.childNodes;c[t]&&e.removeChild(c[t]),c.length?e.insertBefore(s,c[t]):e.appendChild(s)}}var i={singleton:null,singletonCounter:0};e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=i.singletonCounter++,n=i.singleton||(i.singleton=e.insertStyleElement(e));return{update:function(e){o(n,t,!1,e)},remove:function(e){o(n,t,!0,e)}}}}},t={};function n(o){var i=t[o];if(void 0!==i)return i.exports;var r=t[o]={id:o,exports:{}};return e[o](r,r.exports,n),r.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};(()=>{"use strict";n.r(o),n.d(o,{Heading:()=>P,HeadingButtonsUI:()=>T,HeadingCommand:()=>r,HeadingEditing:()=>c,HeadingUI:()=>_,Title:()=>I,_getLocalizedHeadingOptions:()=>l});var e=n(782),t=n(179),i=n(584);class r extends e.Command{modelElements;constructor(e,t){super(e),this.modelElements=t}refresh(){const e=(0,i.first)(this.editor.model.document.selection.getSelectedBlocks());this.value=!!e&&this.modelElements.includes(e.name)&&e.name,this.isEnabled=!!e&&this.modelElements.some(t=>a(e,t,this.editor.model.schema))}execute(e){const t=this.editor.model,n=t.document,o=e.value;t.change(e=>{const i=Array.from(n.selection.getSelectedBlocks()).filter(e=>a(e,o,t.schema));for(const t of i)t.is("element",o)||e.rename(t,o)})}}function a(e,t,n){return n.checkChild(e.parent,t)&&!n.isObject(e)}const s="paragraph";class c extends e.Plugin{static get pluginName(){return"HeadingEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("heading",{options:[{model:"paragraph",title:"Paragraph",class:"ck-heading_paragraph"},{model:"heading1",view:"h2",title:"Heading 1",class:"ck-heading_heading1"},{model:"heading2",view:"h3",title:"Heading 2",class:"ck-heading_heading2"},{model:"heading3",view:"h4",title:"Heading 3",class:"ck-heading_heading3"}]})}static get requires(){return[t.Paragraph]}init(){const e=this.editor,t=e.config.get("heading.options"),n=[];for(const o of t)"paragraph"!==o.model&&(e.model.schema.register(o.model,{inheritAllFrom:"$block"}),e.conversion.elementToElement(o),n.push(o.model));this._addDefaultH1Conversion(e),e.commands.add("heading",new r(e,n))}afterInit(){const e=this.editor,t=e.commands.get("enter"),n=e.config.get("heading.options");t&&this.listenTo(t,"afterExecute",(t,o)=>{const i=e.model.document.selection.getFirstPosition().parent;n.some(e=>i.is("element",e.model))&&!i.is("element",s)&&0===i.childCount&&o.writer.rename(i,s)})}_addDefaultH1Conversion(e){e.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:i.priorities.low+1})}}var d=n(311);function l(e){const t=e.t,n={Paragraph:t("Paragraph"),"Heading 1":t("Heading 1"),"Heading 2":t("Heading 2"),"Heading 3":t("Heading 3"),"Heading 4":t("Heading 4"),"Heading 5":t("Heading 5"),"Heading 6":t("Heading 6")};return e.config.get("heading.options").map(e=>{const t=n[e.title];return t&&t!=e.title&&(e.title=t),e})}var u=n(719),m=n.n(u),g=n(863),h=n.n(g),p=n(424),f=n.n(p),v=n(517),w=n.n(v),b=n(163),y=n.n(b),x=n(349),H={attributes:{"data-cke":!0}};H.setAttributes=w(),H.insert=f().bind(null,"head"),H.domAPI=h(),H.insertStyleElement=y();m()(x.A,H);x.A&&x.A.locals&&x.A.locals;class _ extends e.Plugin{static get pluginName(){return"HeadingUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,n=l(e),o=t("Choose heading"),r=t("Heading");e.ui.componentFactory.add("heading",t=>{const a={},s=new i.Collection,c=e.commands.get("heading"),l=e.commands.get("paragraph"),u=[c];for(const e of n){const t={type:"button",model:new d.UIModel({label:e.title,class:e.class,role:"menuitemradio",withText:!0})};"paragraph"===e.model?(t.model.bind("isOn").to(l,"value"),t.model.set("commandName","paragraph"),u.push(l)):(t.model.bind("isOn").to(c,"value",t=>t===e.model),t.model.set({commandName:"heading",commandValue:e.model})),s.add(t),a[e.model]=e.title}const m=(0,d.createDropdown)(t);return(0,d.addListToDropdown)(m,s,{ariaLabel:r,role:"menu"}),m.buttonView.set({ariaLabel:r,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:r}),m.extendTemplate({attributes:{class:["ck-heading-dropdown"]}}),m.bind("isEnabled").toMany(u,"isEnabled",(...e)=>e.some(e=>e)),m.buttonView.bind("label").to(c,"value",l,"value",(e,t)=>{const n=t?"paragraph":e;return"boolean"==typeof n?o:a[n]?a[n]:o}),m.buttonView.bind("ariaLabel").to(c,"value",l,"value",(e,t)=>{const n=t?"paragraph":e;return"boolean"==typeof n?r:a[n]?`${a[n]}, ${r}`:r}),this.listenTo(m,"execute",t=>{const{commandName:n,commandValue:o}=t.source;e.execute(n,o?{value:o}:void 0),e.editing.view.focus()}),m}),e.ui.componentFactory.add("menuBar:heading",o=>{const i=new d.MenuBarMenuView(o),r=e.commands.get("heading"),a=e.commands.get("paragraph"),s=[r],c=new d.MenuBarMenuListView(o);i.set({class:"ck-heading-dropdown"}),c.set({ariaLabel:t("Heading"),role:"menu"}),i.buttonView.set({label:t("Heading")}),i.panelView.children.add(c);for(const t of n){const n=new d.MenuBarMenuListItemView(o,i),l=new d.MenuBarMenuListItemButtonView(o);n.children.add(l),c.items.add(n),l.set({isToggleable:!0,label:t.title,role:"menuitemradio",class:t.class}),l.delegate("execute").to(i),l.on("execute",()=>{const n="paragraph"===t.model?"paragraph":"heading";e.execute(n,{value:t.model}),e.editing.view.focus()}),"paragraph"===t.model?(l.bind("isOn").to(a,"value"),s.push(a)):l.bind("isOn").to(r,"value",e=>e===t.model)}return i.bind("isEnabled").toMany(s,"isEnabled",(...e)=>e.some(e=>e)),i})}}class P extends e.Plugin{static get requires(){return[c,_]}static get pluginName(){return"Heading"}static get isOfficialPlugin(){return!0}}var E=n(355);const C=(()=>({heading1:E.IconHeading1,heading2:E.IconHeading2,heading3:E.IconHeading3,heading4:E.IconHeading4,heading5:E.IconHeading5,heading6:E.IconHeading6}))();class T extends e.Plugin{init(){l(this.editor).filter(e=>"paragraph"!==e.model).map(e=>this._createButton(e))}_createButton(e){const t=this.editor;t.ui.componentFactory.add(e.model,n=>{const o=new d.ButtonView(n),i=t.commands.get("heading");return o.label=e.title,o.icon=e.icon||C[e.model],o.tooltip=!0,o.isToggleable=!0,o.bind("isEnabled").to(i),o.bind("isOn").to(i,"value",t=>t==e.model),o.on("execute",()=>{t.execute("heading",{value:e.model}),t.editing.view.focus()}),o})}}var k=n(783);const A=new Set(["paragraph","heading1","heading2","heading3","heading4","heading5","heading6"]);class I extends e.Plugin{_bodyPlaceholder=new Map;static get pluginName(){return"Title"}static get isOfficialPlugin(){return!0}static get requires(){return["Paragraph"]}init(){const e=this.editor,t=e.model;t.schema.register("title",{isBlock:!0,allowIn:"$root"}),t.schema.register("title-content",{isBlock:!0,allowIn:"title",allowAttributes:["alignment"]}),t.schema.extend("$text",{allowIn:"title-content"}),t.schema.addAttributeCheck(e=>{if(e.endsWith("title-content $text"))return!1}),e.editing.mapper.on("modelToViewPosition",B(e.editing.view)),e.data.mapper.on("modelToViewPosition",B(e.editing.view)),e.conversion.for("downcast").elementToElement({model:"title-content",view:"h1"}),e.conversion.for("downcast").add(e=>e.on("insert:title",(e,t,n)=>{n.consumable.consume(t.item,e.name)})),e.conversion.for("downcast").add(e=>{e.on("attribute",(e,t,n)=>{if(!t.item.is("element","title"))return;const o=t.item;if(!n.consumable.consume(o,e.name))return;const i=o.getChild(0);n.convertItem(i);const r=n.mapper.toViewElement(i),a=t.attributeKey,s=t.attributeNewValue;null!==s?n.writer.setAttribute(a,s,r):n.writer.removeAttribute(a,r)})}),e.data.upcastDispatcher.on("element:h1",O,{priority:"high"}),e.data.upcastDispatcher.on("element:h2",O,{priority:"high"}),e.data.upcastDispatcher.on("element:h3",O,{priority:"high"}),t.document.registerPostFixer(e=>this._fixTitleContent(e)),t.document.registerPostFixer(e=>this._fixTitleElement(e)),t.document.registerPostFixer(e=>this._fixBodyElement(e)),t.document.registerPostFixer(e=>this._fixExtraParagraph(e)),this._attachPlaceholders(),this._attachTabPressHandling()}getTitle(e={}){const t=e.rootName?e.rootName:void 0,n=this._getTitleElement(t).getChild(0);return this.editor.data.stringify(n,e)}getBody(e={}){const t=this.editor,n=t.data,o=t.model,i=e.rootName?e.rootName:void 0,r=t.model.document.getRoot(i),a=t.editing.view,s=new k.ViewDowncastWriter(a.document),c=o.createRangeIn(r),d=s.createDocumentFragment(),l=o.createPositionAfter(r.getChild(0)),u=o.createRange(l,o.createPositionAt(r,"end")),m=new Map;for(const e of o.markers){const t=u.getIntersection(e.getRange());t&&m.set(e.name,t)}return n.mapper.clearBindings(),n.mapper.bindElements(r,d),n.downcastDispatcher.convert(c,m,s,e),s.remove(s.createRangeOn(d.getChild(0))),t.data.processor.toData(d)}_getTitleElement(e){const t=this.editor.model.document.getRoot(e);for(const e of t.getChildren())if(N(e))return e}_fixTitleContent(e){let t=!1;for(const n of this.editor.model.document.getRootNames()){const o=this._getTitleElement(n);if(!o||1===o.maxOffset)continue;const i=Array.from(o.getChildren());i.shift();for(const t of i)e.move(e.createRangeOn(t),o,"after"),e.rename(t,"paragraph");t=!0}return t}_fixTitleElement(e){let t=!1;const n=this.editor.model;for(const o of this.editor.model.document.getRoots()){const i=Array.from(o.getChildren()).filter(N),r=i[0],a=o.getChild(0);if(a.is("element","title"))i.length>1&&(V(i,e,n),t=!0);else{if(!r&&!A.has(a.name)){const n=e.createElement("title");e.insert(n,o),e.insertElement("title-content",n),t=!0;continue}A.has(a.name)?S(a,e,n):e.move(e.createRangeOn(r),o,0),V(i,e,n),t=!0}}return t}_fixBodyElement(e){let t=!1;for(const n of this.editor.model.document.getRootNames()){const o=this.editor.model.document.getRoot(n);if(o.childCount<2){const i=e.createElement("paragraph");e.insert(i,o,1),this._bodyPlaceholder.set(n,i),t=!0}}return t}_fixExtraParagraph(e){let t=!1;for(const n of this.editor.model.document.getRootNames()){const o=this.editor.model.document.getRoot(n),i=this._bodyPlaceholder.get(n);R(i,o)&&(this._bodyPlaceholder.delete(n),e.remove(i),t=!0)}return t}_attachPlaceholders(){const e=this.editor,t=e.t,n=e.editing.view,o=e.sourceElement,i=e.config.get("title.placeholder")||t("Type your title"),r=e.config.get("placeholder")||o&&"textarea"===o.tagName.toLowerCase()&&o.getAttribute("placeholder")||t("Type or paste your content here.");e.editing.downcastDispatcher.on("insert:title-content",(e,t,o)=>{const r=o.mapper.toViewElement(t.item);r.placeholder=i,(0,k.enableViewPlaceholder)({view:n,element:r,keepOnFocus:!0})});const a=new Map;n.document.registerPostFixer(e=>{let t=!1;for(const o of n.document.roots){if(o.isEmpty)continue;const n=o.getChild(1),i=a.get(o.rootName);n!==i&&(i&&((0,k.hideViewPlaceholder)(e,i),e.removeAttribute("data-placeholder",i)),e.setAttribute("data-placeholder",r,n),a.set(o.rootName,n),t=!0),t=(0,k.needsViewPlaceholder)(n,!0)&&2===o.childCount&&"p"===n.name?!!(0,k.showViewPlaceholder)(e,n)||t:!!(0,k.hideViewPlaceholder)(e,n)||t}return t})}_attachTabPressHandling(){const e=this.editor,t=e.model;e.keystrokes.set("TAB",(e,n)=>{t.change(e=>{const o=t.document.selection,i=Array.from(o.getSelectedBlocks());if(1===i.length&&i[0].is("element","title-content")){const t=o.getFirstPosition().root.getChild(1);e.setSelection(t,0),n()}})}),e.keystrokes.set("SHIFT + TAB",(n,o)=>{t.change(n=>{const r=t.document.selection;if(!r.isCollapsed)return;const a=(0,i.first)(r.getSelectedBlocks()),s=r.getFirstPosition(),c=e.model.document.getRoot(s.root.rootName),d=c.getChild(0);a===c.getChild(1)&&s.isAtStart&&(n.setSelection(d.getChild(0),0),o())})})}}function O(e,t,n){const o=t.modelCursor,i=t.viewItem;if(!o.isAtStart||!o.parent.is("element","$root"))return;if(!n.consumable.consume(i,{name:!0}))return;const r=n.writer,a=r.createElement("title"),s=r.createElement("title-content");r.append(s,a),r.insert(a,o),n.convertChildren(i,s),n.updateConversionResult(a,t)}function B(e){return(t,n)=>{const o=n.modelPosition.parent;if(!o.is("element","title"))return;const i=o.parent,r=n.mapper.toViewElement(i);n.viewPosition=e.createPositionAt(r,0),t.stop()}}function N(e){return e.is("element","title")}function S(e,t,n){const o=t.createElement("title");t.insert(o,e,"before"),t.insert(e,o,0),t.rename(e,"title-content"),n.schema.removeDisallowedAttributes([e],t)}function V(e,t,n){let o=!1;for(const i of e)0!==i.index&&(M(i,t,n),o=!0);return o}function M(e,t,n){const o=e.getChild(0);o.isEmpty?t.remove(e):(t.move(t.createRangeOn(o),e,"before"),t.rename(o,"paragraph"),t.remove(e),n.schema.removeDisallowedAttributes([o],t))}function R(e,t){return!(!e||!e.is("element","paragraph")||e.childCount)&&!(t.childCount<=2||t.getChild(t.childCount-1)!==e)}})(),(window.CKEditor5=window.CKEditor5||{}).heading=o})();
5
+ */(()=>{var e={163:e=>{"use strict";e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},179:(e,t,n)=>{e.exports=n(237)("./src/paragraph.js")},237:e=>{"use strict";e.exports=CKEditor5.dll},305:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var n="",o=void 0!==t[5];return t[4]&&(n+="@supports (".concat(t[4],") {")),t[2]&&(n+="@media ".concat(t[2]," {")),o&&(n+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),n+=e(t),o&&(n+="}"),t[2]&&(n+="}"),t[4]&&(n+="}"),n}).join("")},t.i=function(e,n,o,i,a){"string"==typeof e&&(e=[[null,e,void 0]]);var r={};if(o)for(var s=0;s<this.length;s++){var d=this[s][0];null!=d&&(r[d]=!0)}for(var c=0;c<e.length;c++){var l=[].concat(e[c]);o&&r[l[0]]||(void 0!==a&&(void 0===l[5]||(l[1]="@layer".concat(l[5].length>0?" ".concat(l[5]):""," {").concat(l[1],"}")),l[5]=a),n&&(l[2]?(l[1]="@media ".concat(l[2]," {").concat(l[1],"}"),l[2]=n):l[2]=n),i&&(l[4]?(l[1]="@supports (".concat(l[4],") {").concat(l[1],"}"),l[4]=i):l[4]="".concat(i)),t.push(l))}},t}},311:(e,t,n)=>{e.exports=n(237)("./src/ui.js")},349:(e,t,n)=>{"use strict";n.d(t,{A:()=>s});var o=n(792),i=n.n(o),a=n(305),r=n.n(a)()(i());r.push([e.id,".ck.ck-heading_heading1 .ck-button__label{font-size:20px}.ck.ck-heading_heading2 .ck-button__label{font-size:17px}.ck.ck-heading_heading3 .ck-button__label{font-size:14px}.ck[class*=ck-heading_heading]{font-weight:700}.ck.ck-dropdown.ck-heading-dropdown .ck-dropdown__button .ck-button__label{width:8em}.ck.ck-dropdown.ck-heading-dropdown .ck-dropdown__panel .ck-list__item{min-width:18em}",""]);const s=r},355:(e,t,n)=>{e.exports=n(237)("./src/icons.js")},424:e=>{"use strict";var t={};e.exports=function(e,n){var o=function(e){if(void 0===t[e]){var n=document.querySelector(e);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}t[e]=n}return t[e]}(e);if(!o)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");o.appendChild(n)}},517:e=>{"use strict";e.exports=function(e,t){Object.keys(t).forEach(function(n){e.setAttribute(n,t[n])})}},584:(e,t,n)=>{e.exports=n(237)("./src/utils.js")},719:e=>{"use strict";var t=[];function n(e){for(var n=-1,o=0;o<t.length;o++)if(t[o].identifier===e){n=o;break}return n}function o(e,o){for(var a={},r=[],s=0;s<e.length;s++){var d=e[s],c=o.base?d[0]+o.base:d[0],l=a[c]||0,u="".concat(c," ").concat(l);a[c]=l+1;var g=n(u),m={css:d[1],media:d[2],sourceMap:d[3],supports:d[4],layer:d[5]};if(-1!==g)t[g].references++,t[g].updater(m);else{var h=i(m,o);o.byIndex=s,t.splice(s,0,{identifier:u,updater:h,references:1})}r.push(u)}return r}function i(e,t){var n=t.domAPI(t);n.update(e);return function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap&&t.supports===e.supports&&t.layer===e.layer)return;n.update(e=t)}else n.remove()}}e.exports=function(e,i){var a=o(e=e||[],i=i||{});return function(e){e=e||[];for(var r=0;r<a.length;r++){var s=n(a[r]);t[s].references--}for(var d=o(e,i),c=0;c<a.length;c++){var l=n(a[c]);0===t[l].references&&(t[l].updater(),t.splice(l,1))}a=d}}},782:(e,t,n)=>{e.exports=n(237)("./src/core.js")},783:(e,t,n)=>{e.exports=n(237)("./src/engine.js")},792:e=>{"use strict";e.exports=function(e){return e[1]}},863:e=>{"use strict";var t,n=(t=[],function(e,n){return t[e]=n,t.filter(Boolean).join("\n")});function o(e,t,o,i){var a;if(o)a="";else{a="",i.supports&&(a+="@supports (".concat(i.supports,") {")),i.media&&(a+="@media ".concat(i.media," {"));var r=void 0!==i.layer;r&&(a+="@layer".concat(i.layer.length>0?" ".concat(i.layer):""," {")),a+=i.css,r&&(a+="}"),i.media&&(a+="}"),i.supports&&(a+="}")}if(e.styleSheet)e.styleSheet.cssText=n(t,a);else{var s=document.createTextNode(a),d=e.childNodes;d[t]&&e.removeChild(d[t]),d.length?e.insertBefore(s,d[t]):e.appendChild(s)}}var i={singleton:null,singletonCounter:0};e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=i.singletonCounter++,n=i.singleton||(i.singleton=e.insertStyleElement(e));return{update:function(e){o(n,t,!1,e)},remove:function(e){o(n,t,!0,e)}}}}},t={};function n(o){var i=t[o];if(void 0!==i)return i.exports;var a=t[o]={id:o,exports:{}};return e[o](a,a.exports,n),a.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};(()=>{"use strict";n.r(o),n.d(o,{Heading:()=>P,HeadingButtonsUI:()=>T,HeadingCommand:()=>a,HeadingEditing:()=>d,HeadingUI:()=>_,Title:()=>I,_getLocalizedHeadingOptions:()=>l});var e=n(782),t=n(179),i=n(584);class a extends e.Command{modelElements;constructor(e,t){super(e),this.modelElements=t}refresh(){const e=(0,i.first)(this.editor.model.document.selection.getSelectedBlocks());this.value=!!e&&this.modelElements.includes(e.name)&&e.name,this.isEnabled=!!e&&this.modelElements.some(t=>r(e,t,this.editor.model.schema))}execute(e){const t=this.editor.model,n=t.document,o=e.value;t.change(e=>{const i=Array.from(n.selection.getSelectedBlocks()).filter(e=>r(e,o,t.schema));for(const t of i)t.is("element",o)||e.rename(t,o)})}}function r(e,t,n){return n.checkChild(e.parent,t)&&!n.isObject(e)}const s="paragraph";class d extends e.Plugin{static get pluginName(){return"HeadingEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("heading",{options:[{model:"paragraph",title:"Paragraph",class:"ck-heading_paragraph"},{model:"heading1",view:"h2",title:"Heading 1",class:"ck-heading_heading1"},{model:"heading2",view:"h3",title:"Heading 2",class:"ck-heading_heading2"},{model:"heading3",view:"h4",title:"Heading 3",class:"ck-heading_heading3"}]})}static get requires(){return[t.Paragraph]}init(){const e=this.editor,t=e.config.get("heading.options"),n=[];for(const o of t)"paragraph"!==o.model&&(e.model.schema.register(o.model,{inheritAllFrom:"$block"}),e.conversion.elementToElement(o),n.push(o.model));this._addDefaultH1Conversion(e),e.commands.add("heading",new a(e,n))}afterInit(){const e=this.editor,t=e.commands.get("enter"),n=e.config.get("heading.options");t&&this.listenTo(t,"afterExecute",(t,o)=>{const i=e.model.document.selection.getFirstPosition().parent;n.some(e=>i.is("element",e.model))&&!i.is("element",s)&&0===i.childCount&&o.writer.rename(i,s)})}_addDefaultH1Conversion(e){e.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:i.priorities.low+1})}}var c=n(311);function l(e){const t=e.t,n={Paragraph:t("Paragraph"),"Heading 1":t("Heading 1"),"Heading 2":t("Heading 2"),"Heading 3":t("Heading 3"),"Heading 4":t("Heading 4"),"Heading 5":t("Heading 5"),"Heading 6":t("Heading 6")};return e.config.get("heading.options").map(e=>{const t=n[e.title];return t&&t!=e.title&&(e.title=t),e})}var u=n(719),g=n.n(u),m=n(863),h=n.n(m),p=n(424),f=n.n(p),v=n(517),w=n.n(v),b=n(163),y=n.n(b),x=n(349),H={attributes:{"data-cke":!0}};H.setAttributes=w(),H.insert=f().bind(null,"head"),H.domAPI=h(),H.insertStyleElement=y();g()(x.A,H);x.A&&x.A.locals&&x.A.locals;class _ extends e.Plugin{static get pluginName(){return"HeadingUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,n=l(e),o=t("Choose heading"),a=t("Heading");e.ui.componentFactory.add("heading",t=>{const r={},s=new i.Collection,d=e.commands.get("heading"),l=e.commands.get("paragraph"),u=[d];for(const e of n){const t={type:"button",model:new c.UIModel({label:e.title,class:e.class,role:"menuitemradio",withText:!0})};"paragraph"===e.model?(t.model.bind("isOn").to(l,"value"),t.model.set("commandName","paragraph"),u.push(l)):(t.model.bind("isOn").to(d,"value",t=>t===e.model),t.model.set({commandName:"heading",commandValue:e.model})),s.add(t),r[e.model]=e.title}const g=(0,c.createDropdown)(t);return(0,c.addListToDropdown)(g,s,{ariaLabel:a,role:"menu"}),g.buttonView.set({ariaLabel:a,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:a}),g.extendTemplate({attributes:{class:["ck-heading-dropdown"]}}),g.bind("isEnabled").toMany(u,"isEnabled",(...e)=>e.some(e=>e)),g.buttonView.bind("label").to(d,"value",l,"value",(e,t)=>{const n=t?"paragraph":e;return"boolean"==typeof n?o:r[n]?r[n]:o}),g.buttonView.bind("ariaLabel").to(d,"value",l,"value",(e,t)=>{const n=t?"paragraph":e;return"boolean"==typeof n?a:r[n]?`${r[n]}, ${a}`:a}),this.listenTo(g,"execute",t=>{const{commandName:n,commandValue:o}=t.source;e.execute(n,o?{value:o}:void 0),e.editing.view.focus()}),g}),e.ui.componentFactory.add("menuBar:heading",o=>{const i=new c.MenuBarMenuView(o),a=e.commands.get("heading"),r=e.commands.get("paragraph"),s=[a],d=new c.MenuBarMenuListView(o);i.set({class:"ck-heading-dropdown"}),d.set({ariaLabel:t("Heading"),role:"menu"}),i.buttonView.set({label:t("Heading")}),i.panelView.children.add(d);for(const t of n){const n=new c.MenuBarMenuListItemView(o,i),l=new c.MenuBarMenuListItemButtonView(o);n.children.add(l),d.items.add(n),l.set({isToggleable:!0,label:t.title,role:"menuitemradio",class:t.class}),l.delegate("execute").to(i),l.on("execute",()=>{const n="paragraph"===t.model?"paragraph":"heading";e.execute(n,{value:t.model}),e.editing.view.focus()}),"paragraph"===t.model?(l.bind("isOn").to(r,"value"),s.push(r)):l.bind("isOn").to(a,"value",e=>e===t.model)}return i.bind("isEnabled").toMany(s,"isEnabled",(...e)=>e.some(e=>e)),i})}}class P extends e.Plugin{static get requires(){return[d,_]}static get pluginName(){return"Heading"}static get isOfficialPlugin(){return!0}}var E=n(355);const C=(()=>({heading1:E.IconHeading1,heading2:E.IconHeading2,heading3:E.IconHeading3,heading4:E.IconHeading4,heading5:E.IconHeading5,heading6:E.IconHeading6}))();class T extends e.Plugin{init(){l(this.editor).filter(e=>"paragraph"!==e.model).map(e=>this._createButton(e))}_createButton(e){const t=this.editor;t.ui.componentFactory.add(e.model,n=>{const o=new c.ButtonView(n),i=t.commands.get("heading");return o.label=e.title,o.icon=e.icon||C[e.model],o.tooltip=!0,o.isToggleable=!0,o.bind("isEnabled").to(i),o.bind("isOn").to(i,"value",t=>t==e.model),o.on("execute",()=>{t.execute("heading",{value:e.model}),t.editing.view.focus()}),o})}}var k=n(783);const A=new Set(["paragraph","heading1","heading2","heading3","heading4","heading5","heading6"]);class I extends e.Plugin{_bodyPlaceholder=new Map;static get pluginName(){return"Title"}static get isOfficialPlugin(){return!0}static get requires(){return["Paragraph"]}init(){const e=this.editor,t=e.model;t.schema.register("title",{isBlock:!0,allowIn:"$root"}),t.schema.register("title-content",{isBlock:!0,allowIn:"title",allowAttributes:["alignment"]}),t.schema.extend("$text",{allowIn:"title-content"}),t.schema.addAttributeCheck(e=>{if(e.endsWith("title-content $text"))return!1}),e.editing.mapper.on("modelToViewPosition",B(e.editing.view)),e.data.mapper.on("modelToViewPosition",B(e.editing.view)),e.conversion.for("downcast").elementToElement({model:"title-content",view:"h1"}),e.conversion.for("downcast").add(e=>e.on("insert:title",(e,t,n)=>{n.consumable.consume(t.item,e.name)})),e.data.upcastDispatcher.on("element:h1",O,{priority:"high"}),e.data.upcastDispatcher.on("element:h2",O,{priority:"high"}),e.data.upcastDispatcher.on("element:h3",O,{priority:"high"}),t.document.registerPostFixer(e=>this._fixTitleContent(e)),t.document.registerPostFixer(e=>this._fixTitleElement(e)),t.document.registerPostFixer(e=>this._fixBodyElement(e)),t.document.registerPostFixer(e=>this._fixExtraParagraph(e)),this._attachPlaceholders(),this._attachTabPressHandling()}getTitle(e={}){const t=e.rootName?e.rootName:void 0,n=this._getTitleElement(t).getChild(0);return this.editor.data.stringify(n,e)}getBody(e={}){const t=this.editor,n=t.data,o=t.model,i=e.rootName?e.rootName:void 0,a=t.model.document.getRoot(i),r=t.editing.view,s=new k.ViewDowncastWriter(r.document),d=o.createRangeIn(a),c=s.createDocumentFragment(),l=o.createPositionAfter(a.getChild(0)),u=o.createRange(l,o.createPositionAt(a,"end")),g=new Map;for(const e of o.markers){const t=u.getIntersection(e.getRange());t&&g.set(e.name,t)}return n.mapper.clearBindings(),n.mapper.bindElements(a,c),n.downcastDispatcher.convert(d,g,s,e),s.remove(s.createRangeOn(c.getChild(0))),t.data.processor.toData(c)}_getTitleElement(e){const t=this.editor.model.document.getRoot(e);for(const e of t.getChildren())if(S(e))return e}_fixTitleContent(e){let t=!1;for(const n of this.editor.model.document.getRootNames()){const o=this._getTitleElement(n);if(!o||1===o.maxOffset)continue;const i=Array.from(o.getChildren());i.shift();for(const t of i)e.move(e.createRangeOn(t),o,"after"),e.rename(t,"paragraph");t=!0}return t}_fixTitleElement(e){let t=!1;const n=this.editor.model;for(const o of this.editor.model.document.getRoots()){const i=Array.from(o.getChildren()).filter(S),a=i[0],r=o.getChild(0);if(r.is("element","title"))i.length>1&&(M(i,e,n),t=!0);else{if(!a&&!A.has(r.name)){const n=e.createElement("title");e.insert(n,o),e.insertElement("title-content",n),t=!0;continue}A.has(r.name)?N(r,e,n):e.move(e.createRangeOn(a),o,0),M(i,e,n),t=!0}}return t}_fixBodyElement(e){let t=!1;for(const n of this.editor.model.document.getRootNames()){const o=this.editor.model.document.getRoot(n);if(o.childCount<2){const i=e.createElement("paragraph");e.insert(i,o,1),this._bodyPlaceholder.set(n,i),t=!0}}return t}_fixExtraParagraph(e){let t=!1;for(const n of this.editor.model.document.getRootNames()){const o=this.editor.model.document.getRoot(n),i=this._bodyPlaceholder.get(n);R(i,o)&&(this._bodyPlaceholder.delete(n),e.remove(i),t=!0)}return t}_attachPlaceholders(){const e=this.editor,t=e.t,n=e.editing.view,o=e.sourceElement,i=e.config.get("title.placeholder")||t("Type your title"),a=e.config.get("placeholder")||o&&"textarea"===o.tagName.toLowerCase()&&o.getAttribute("placeholder")||t("Type or paste your content here.");e.editing.downcastDispatcher.on("insert:title-content",(e,t,o)=>{const a=o.mapper.toViewElement(t.item);a.placeholder=i,(0,k.enableViewPlaceholder)({view:n,element:a,keepOnFocus:!0})});const r=new Map;n.document.registerPostFixer(e=>{let t=!1;for(const o of n.document.roots){if(o.isEmpty)continue;const n=o.getChild(1),i=r.get(o.rootName);n!==i&&(i&&((0,k.hideViewPlaceholder)(e,i),e.removeAttribute("data-placeholder",i)),e.setAttribute("data-placeholder",a,n),r.set(o.rootName,n),t=!0),t=(0,k.needsViewPlaceholder)(n,!0)&&2===o.childCount&&"p"===n.name?!!(0,k.showViewPlaceholder)(e,n)||t:!!(0,k.hideViewPlaceholder)(e,n)||t}return t})}_attachTabPressHandling(){const e=this.editor,t=e.model;e.keystrokes.set("TAB",(e,n)=>{t.change(e=>{const o=t.document.selection,i=Array.from(o.getSelectedBlocks());if(1===i.length&&i[0].is("element","title-content")){const t=o.getFirstPosition().root.getChild(1);e.setSelection(t,0),n()}})}),e.keystrokes.set("SHIFT + TAB",(n,o)=>{t.change(n=>{const a=t.document.selection;if(!a.isCollapsed)return;const r=(0,i.first)(a.getSelectedBlocks()),s=a.getFirstPosition(),d=e.model.document.getRoot(s.root.rootName),c=d.getChild(0);r===d.getChild(1)&&s.isAtStart&&(n.setSelection(c.getChild(0),0),o())})})}}function O(e,t,n){const o=t.modelCursor,i=t.viewItem;if(!o.isAtStart||!o.parent.is("element","$root"))return;if(!n.consumable.consume(i,{name:!0}))return;const a=n.writer,r=a.createElement("title"),s=a.createElement("title-content");a.append(s,r),a.insert(r,o),n.convertChildren(i,s),n.updateConversionResult(r,t)}function B(e){return(t,n)=>{const o=n.modelPosition.parent;if(!o.is("element","title"))return;const i=o.parent,a=n.mapper.toViewElement(i);n.viewPosition=e.createPositionAt(a,0),t.stop()}}function S(e){return e.is("element","title")}function N(e,t,n){const o=t.createElement("title");t.insert(o,e,"before"),t.insert(e,o,0),t.rename(e,"title-content"),n.schema.removeDisallowedAttributes([e],t)}function M(e,t,n){let o=!1;for(const i of e)0!==i.index&&(V(i,t,n),o=!0);return o}function V(e,t,n){const o=e.getChild(0);o.isEmpty?t.remove(e):(t.move(t.createRangeOn(o),e,"before"),t.rename(o,"paragraph"),t.remove(e),n.schema.removeDisallowedAttributes([o],t))}function R(e,t){return!(!e||!e.is("element","paragraph")||e.childCount)&&!(t.childCount<=2||t.getChild(t.childCount-1)!==e)}})(),(window.CKEditor5=window.CKEditor5||{}).heading=o})();
package/dist/index.js CHANGED
@@ -473,7 +473,7 @@ const defaultIcons = /* #__PURE__ */ (()=>({
473
473
  }
474
474
 
475
475
  // A list of element names that should be treated by the Title plugin as title-like.
476
- // This means that an element of a type from this list will be changed to a `title` element
476
+ // This means that an element of a type from this list will be changed to a title element
477
477
  // when it is the first element in the root.
478
478
  const titleLikeElements = new Set([
479
479
  'paragraph',
@@ -515,7 +515,7 @@ const titleLikeElements = new Set([
515
515
  */ init() {
516
516
  const editor = this.editor;
517
517
  const model = editor.model;
518
- // To use the schema for disabling some features when the selection is inside the `title` element
518
+ // To use the schema for disabling some features when the selection is inside the title element
519
519
  // it is needed to create the following structure:
520
520
  //
521
521
  // <title>
@@ -537,13 +537,13 @@ const titleLikeElements = new Set([
537
537
  model.schema.extend('$text', {
538
538
  allowIn: 'title-content'
539
539
  });
540
- // Disallow all attributes in `title-content` `$text`.
540
+ // Disallow all attributes in `title-content`.
541
541
  model.schema.addAttributeCheck((context)=>{
542
542
  if (context.endsWith('title-content $text')) {
543
543
  return false;
544
544
  }
545
545
  });
546
- // Because `title` is represented by two elements (`title` and `title-content`) in the model
546
+ // Because `title` is represented by two elements in the model
547
547
  // but only one in the view, it is needed to adjust Mapper.
548
548
  editor.editing.mapper.on('modelToViewPosition', mapModelPositionToView(editor.editing.view));
549
549
  editor.data.mapper.on('modelToViewPosition', mapModelPositionToView(editor.editing.view));
@@ -555,36 +555,6 @@ const titleLikeElements = new Set([
555
555
  editor.conversion.for('downcast').add((dispatcher)=>dispatcher.on('insert:title', (evt, data, conversionApi)=>{
556
556
  conversionApi.consumable.consume(data.item, evt.name);
557
557
  }));
558
- // This converter intercepts attribute changes on `title` and redirects them to `title-content`.
559
- //
560
- // The `title` element in the model doesn't have a corresponding view element, only `title-content`
561
- // is converted to `<h1>`. Setting an attribute on `title` would cause a downcast conversion error
562
- // because there's no view element to apply it to.
563
- editor.conversion.for('downcast').add((dispatcher)=>{
564
- dispatcher.on('attribute', (evt, data, conversionApi)=>{
565
- // Only process if the attribute change is on a `title` element.
566
- if (!data.item.is('element', 'title')) {
567
- return;
568
- }
569
- const titleElement = data.item;
570
- if (!conversionApi.consumable.consume(titleElement, evt.name)) {
571
- return;
572
- }
573
- const titleContentElement = titleElement.getChild(0);
574
- // Ensure the `title-content` element is converted to view first.
575
- // This is needed because attribute conversion might run before insert conversion.
576
- conversionApi.convertItem(titleContentElement);
577
- const viewElement = conversionApi.mapper.toViewElement(titleContentElement);
578
- const attributeKey = data.attributeKey;
579
- const attributeNewValue = data.attributeNewValue;
580
- // Apply the attribute to the view element.
581
- if (attributeNewValue !== null) {
582
- conversionApi.writer.setAttribute(attributeKey, attributeNewValue, viewElement);
583
- } else {
584
- conversionApi.writer.removeAttribute(attributeKey, viewElement);
585
- }
586
- });
587
- });
588
558
  // Custom converter is used for data v -> m conversion to avoid calling post-fixer when setting data.
589
559
  // See https://github.com/ckeditor/ckeditor5/issues/2036.
590
560
  editor.data.upcastDispatcher.on('element:h1', dataViewModelH1Insertion, {
@@ -611,10 +581,10 @@ const titleLikeElements = new Set([
611
581
  }
612
582
  /**
613
583
  * Returns the title of the document. Note that because this plugin does not allow any formatting inside
614
- * the `title` element, the output of this method will be a plain text, with no HTML tags.
584
+ * the title element, the output of this method will be a plain text, with no HTML tags.
615
585
  *
616
586
  * It is not recommended to use this method together with features that insert markers to the
617
- * data output, like comments or track changes features. If such markers start in the `title` and end in the
587
+ * data output, like comments or track changes features. If such markers start in the title and end in the
618
588
  * body, the result of this method might be incorrect.
619
589
  *
620
590
  * @param options Additional configuration passed to the conversion process.
@@ -660,7 +630,7 @@ const titleLikeElements = new Set([
660
630
  data.mapper.clearBindings();
661
631
  data.mapper.bindElements(root, viewDocumentFragment);
662
632
  data.downcastDispatcher.convert(rootRange, markers, viewWriter, options);
663
- // Remove `title` element from view.
633
+ // Remove title element from view.
664
634
  viewWriter.remove(viewWriter.createRangeOn(viewDocumentFragment.getChild(0)));
665
635
  // view -> data
666
636
  return editor.data.processor.toData(viewDocumentFragment);
@@ -699,8 +669,8 @@ const titleLikeElements = new Set([
699
669
  return changed;
700
670
  }
701
671
  /**
702
- * Model post-fixer callback that creates a `title` element when it is missing,
703
- * takes care of the correct position of it and removes additional `title` elements.
672
+ * Model post-fixer callback that creates a title element when it is missing,
673
+ * takes care of the correct position of it and removes additional title elements.
704
674
  */ _fixTitleElement(writer) {
705
675
  let changed = false;
706
676
  const model = this.editor.model;
@@ -708,7 +678,7 @@ const titleLikeElements = new Set([
708
678
  const titleElements = Array.from(modelRoot.getChildren()).filter(isTitle);
709
679
  const firstTitleElement = titleElements[0];
710
680
  const firstRootChild = modelRoot.getChild(0);
711
- // When `title` element is at the beginning of the document then try to fix additional `title` elements (if there are any).
681
+ // When title element is at the beginning of the document then try to fix additional title elements (if there are any).
712
682
  if (firstRootChild.is('element', 'title')) {
713
683
  if (titleElements.length > 1) {
714
684
  fixAdditionalTitleElements(titleElements, writer, model);
@@ -726,10 +696,10 @@ const titleLikeElements = new Set([
726
696
  continue;
727
697
  }
728
698
  if (titleLikeElements.has(firstRootChild.name)) {
729
- // Change the first element in the document to the `title` if it can be changed (is title-like).
699
+ // Change the first element in the document to the title if it can be changed (is title-like).
730
700
  changeElementToTitle(firstRootChild, writer, model);
731
701
  } else {
732
- // Otherwise, move the first occurrence of the `title` element to the beginning of the document.
702
+ // Otherwise, move the first occurrence of the title element to the beginning of the document.
733
703
  writer.move(writer.createRangeOn(firstTitleElement), modelRoot, 0);
734
704
  }
735
705
  fixAdditionalTitleElements(titleElements, writer, model);
@@ -778,7 +748,7 @@ const titleLikeElements = new Set([
778
748
  const sourceElement = editor.sourceElement;
779
749
  const titlePlaceholder = editor.config.get('title.placeholder') || t('Type your title');
780
750
  const bodyPlaceholder = editor.config.get('placeholder') || sourceElement && sourceElement.tagName.toLowerCase() === 'textarea' && sourceElement.getAttribute('placeholder') || t('Type or paste your content here.');
781
- // Attach placeholder to the view `title-content` element.
751
+ // Attach placeholder to the view title element.
782
752
  editor.editing.downcastDispatcher.on('insert:title-content', (evt, data, conversionApi)=>{
783
753
  const element = conversionApi.mapper.toViewElement(data.item);
784
754
  element.placeholder = titlePlaceholder;
@@ -788,8 +758,8 @@ const titleLikeElements = new Set([
788
758
  keepOnFocus: true
789
759
  });
790
760
  });
791
- // Attach placeholder to first element after a `title` element and remove it if it's not needed anymore.
792
- // First element after `title` can change, so we need to observe all changes keep placeholder in sync.
761
+ // Attach placeholder to first element after a title element and remove it if it's not needed anymore.
762
+ // First element after title can change, so we need to observe all changes keep placeholder in sync.
793
763
  const bodyViewElements = new Map();
794
764
  // This post-fixer runs after the model post-fixer, so we can assume that the second child in view root will always exist.
795
765
  view.document.registerPostFixer((writer)=>{
@@ -863,7 +833,7 @@ const titleLikeElements = new Set([
863
833
  }
864
834
  }
865
835
  /**
866
- * A view-to-model converter for the `h1` that appears at the beginning of the document (a `title` element).
836
+ * A view-to-model converter for the h1 that appears at the beginning of the document (a title element).
867
837
  *
868
838
  * @see module:engine/conversion/upcastdispatcher~UpcastDispatcher#event:element
869
839
  * @param evt An object containing information about the fired event.
@@ -912,7 +882,7 @@ const titleLikeElements = new Set([
912
882
  return element.is('element', 'title');
913
883
  }
914
884
  /**
915
- * Changes the given element to the `title` element.
885
+ * Changes the given element to the title element.
916
886
  */ function changeElementToTitle(element, writer, model) {
917
887
  const title = writer.createElement('title');
918
888
  writer.insert(title, element, 'before');
@@ -923,7 +893,7 @@ const titleLikeElements = new Set([
923
893
  ], writer);
924
894
  }
925
895
  /**
926
- * Loops over the list of `title` elements and fixes additional ones.
896
+ * Loops over the list of title elements and fixes additional ones.
927
897
  *
928
898
  * @returns Returns true when there was any change. Returns false otherwise.
929
899
  */ function fixAdditionalTitleElements(titleElements, writer, model) {
@@ -937,11 +907,11 @@ const titleLikeElements = new Set([
937
907
  return hasChanged;
938
908
  }
939
909
  /**
940
- * Changes given `title` element to a paragraph or removes it when it is empty.
910
+ * Changes given title element to a paragraph or removes it when it is empty.
941
911
  */ function fixTitleElement(title, writer, model) {
942
912
  const child = title.getChild(0);
943
- // Empty `title` should be removed.
944
- // It is created as a result of pasting to the `title` element.
913
+ // Empty title should be removed.
914
+ // It is created as a result of pasting to the title element.
945
915
  if (child.isEmpty) {
946
916
  writer.remove(title);
947
917
  return;