@ckeditor/ckeditor5-source-editing 40.2.0 → 41.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. package/LICENSE.md +1 -1
  2. package/build/source-editing.js +2 -2
  3. package/lang/translations/ar.po +1 -1
  4. package/lang/translations/bg.po +1 -1
  5. package/lang/translations/bn.po +1 -1
  6. package/lang/translations/ca.po +1 -1
  7. package/lang/translations/cs.po +1 -1
  8. package/lang/translations/da.po +1 -1
  9. package/lang/translations/de.po +1 -1
  10. package/lang/translations/el.po +1 -1
  11. package/lang/translations/en-au.po +1 -1
  12. package/lang/translations/en.po +1 -1
  13. package/lang/translations/es.po +1 -1
  14. package/lang/translations/et.po +1 -1
  15. package/lang/translations/fi.po +1 -1
  16. package/lang/translations/fr.po +1 -1
  17. package/lang/translations/gl.po +1 -1
  18. package/lang/translations/he.po +1 -1
  19. package/lang/translations/hi.po +1 -1
  20. package/lang/translations/hr.po +1 -1
  21. package/lang/translations/hu.po +1 -1
  22. package/lang/translations/id.po +1 -1
  23. package/lang/translations/it.po +1 -1
  24. package/lang/translations/ja.po +1 -1
  25. package/lang/translations/ko.po +1 -1
  26. package/lang/translations/lt.po +1 -1
  27. package/lang/translations/lv.po +1 -1
  28. package/lang/translations/ms.po +1 -1
  29. package/lang/translations/nl.po +1 -1
  30. package/lang/translations/no.po +1 -1
  31. package/lang/translations/pl.po +1 -1
  32. package/lang/translations/pt-br.po +1 -1
  33. package/lang/translations/pt.po +1 -1
  34. package/lang/translations/ro.po +1 -1
  35. package/lang/translations/ru.po +1 -1
  36. package/lang/translations/sk.po +1 -1
  37. package/lang/translations/sr-latn.po +1 -1
  38. package/lang/translations/sr.po +1 -1
  39. package/lang/translations/sv.po +1 -1
  40. package/lang/translations/th.po +1 -1
  41. package/lang/translations/tr.po +1 -1
  42. package/lang/translations/ug.po +1 -1
  43. package/lang/translations/uk.po +1 -1
  44. package/lang/translations/ur.po +1 -1
  45. package/lang/translations/vi.po +1 -1
  46. package/lang/translations/zh-cn.po +1 -1
  47. package/lang/translations/zh.po +1 -1
  48. package/package.json +4 -3
  49. package/src/augmentation.d.ts +10 -2
  50. package/src/augmentation.js +1 -1
  51. package/src/index.d.ts +4 -3
  52. package/src/index.js +3 -3
  53. package/src/sourceediting.d.ts +7 -6
  54. package/src/sourceediting.js +59 -29
  55. package/src/sourceeditingconfig.d.ts +34 -0
  56. package/src/sourceeditingconfig.js +5 -0
  57. package/src/utils/formathtml.d.ts +1 -1
  58. package/src/utils/formathtml.js +1 -1
  59. package/theme/sourceediting.css +1 -1
package/LICENSE.md CHANGED
@@ -2,7 +2,7 @@ Software License Agreement
2
2
  ==========================
3
3
 
4
4
  **CKEditor&nbsp;5 source editing feature** – https://github.com/ckeditor/ckeditor5-source-editing <br>
5
- Copyright (c) 2003–2023, [CKSource Holding sp. z o.o.](https://cksource.com) All rights reserved.
5
+ Copyright (c) 2003–2024, [CKSource Holding sp. z o.o.](https://cksource.com) All rights reserved.
6
6
 
7
7
  Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html).
8
8
 
@@ -1,5 +1,5 @@
1
1
  !function(e){const t=e.en=e.en||{};t.dictionary=Object.assign(t.dictionary||{},{Source:"Source"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})),
2
2
  /*!
3
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
4
4
  * For licensing, see LICENSE.md.
5
- */(()=>{var e={40:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});var n=i(609),o=i.n(n)()((function(e){return e[1]}));o.push([e.id,'.ck-source-editing-area{overflow:hidden;position:relative}.ck-source-editing-area textarea,.ck-source-editing-area:after{border:1px solid transparent;font-family:monospace;font-size:var(--ck-font-size-normal);line-height:var(--ck-line-height-base);margin:0;padding:var(--ck-spacing-large);white-space:pre-wrap}.ck-source-editing-area:after{content:attr(data-value) " ";display:block;visibility:hidden}.ck-source-editing-area textarea{border-color:var(--ck-color-base-border);border-radius:0;box-sizing:border-box;height:100%;outline:none;overflow:hidden;position:absolute;resize:none;width:100%}.ck-rounded-corners .ck-source-editing-area textarea,.ck-source-editing-area textarea.ck-rounded-corners{border-radius:var(--ck-border-radius);border-top-left-radius:0;border-top-right-radius:0}.ck-source-editing-area textarea:not([readonly]):focus{border:var(--ck-focus-ring);box-shadow:var(--ck-inner-shadow),0 0;outline:none}',""]);const r=o},609:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var i=e(t);return t[2]?"@media ".concat(t[2]," {").concat(i,"}"):i})).join("")},t.i=function(e,i,n){"string"==typeof e&&(e=[[null,e,""]]);var o={};if(n)for(var r=0;r<this.length;r++){var a=this[r][0];null!=a&&(o[a]=!0)}for(var s=0;s<e.length;s++){var d=[].concat(e[s]);n&&o[d[0]]||(i&&(d[2]?d[2]="".concat(i," and ").concat(d[2]):d[2]=i),t.push(d))}},t}},62:(e,t,i)=>{"use strict";var n,o=function(){return void 0===n&&(n=Boolean(window&&document&&document.all&&!window.atob)),n},r=function(){var e={};return function(t){if(void 0===e[t]){var i=document.querySelector(t);if(window.HTMLIFrameElement&&i instanceof window.HTMLIFrameElement)try{i=i.contentDocument.head}catch(e){i=null}e[t]=i}return e[t]}}(),a=[];function s(e){for(var t=-1,i=0;i<a.length;i++)if(a[i].identifier===e){t=i;break}return t}function d(e,t){for(var i={},n=[],o=0;o<e.length;o++){var r=e[o],d=t.base?r[0]+t.base:r[0],c=i[d]||0,l="".concat(d," ").concat(c);i[d]=c+1;var u=s(l),h={css:r[1],media:r[2],sourceMap:r[3]};-1!==u?(a[u].references++,a[u].updater(h)):a.push({identifier:l,updater:p(h,t),references:1}),n.push(l)}return n}function c(e){var t=document.createElement("style"),n=e.attributes||{};if(void 0===n.nonce){var o=i.nc;o&&(n.nonce=o)}if(Object.keys(n).forEach((function(e){t.setAttribute(e,n[e])})),"function"==typeof e.insert)e.insert(t);else{var a=r(e.insert||"head");if(!a)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");a.appendChild(t)}return t}var l,u=(l=[],function(e,t){return l[e]=t,l.filter(Boolean).join("\n")});function h(e,t,i,n){var o=i?"":n.media?"@media ".concat(n.media," {").concat(n.css,"}"):n.css;if(e.styleSheet)e.styleSheet.cssText=u(t,o);else{var r=document.createTextNode(o),a=e.childNodes;a[t]&&e.removeChild(a[t]),a.length?e.insertBefore(r,a[t]):e.appendChild(r)}}function m(e,t,i){var n=i.css,o=i.media,r=i.sourceMap;if(o?e.setAttribute("media",o):e.removeAttribute("media"),r&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}var f=null,g=0;function p(e,t){var i,n,o;if(t.singleton){var r=g++;i=f||(f=c(t)),n=h.bind(null,i,r,!1),o=h.bind(null,i,r,!0)}else i=c(t),n=m.bind(null,i,t),o=function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(i)};return n(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;n(e=t)}else o()}}e.exports=function(e,t){(t=t||{}).singleton||"boolean"==typeof t.singleton||(t.singleton=o());var i=d(e=e||[],t);return function(e){if(e=e||[],"[object Array]"===Object.prototype.toString.call(e)){for(var n=0;n<i.length;n++){var o=s(i[n]);a[o].references--}for(var r=d(e,t),c=0;c<i.length;c++){var l=s(i[c]);0===a[l].references&&(a[l].updater(),a.splice(l,1))}i=r}}}},704:(e,t,i)=>{e.exports=i(79)("./src/core.js")},273:(e,t,i)=>{e.exports=i(79)("./src/ui.js")},209:(e,t,i)=>{e.exports=i(79)("./src/utils.js")},79:e=>{"use strict";e.exports=CKEditor5.dll}},t={};function i(n){var o=t[n];if(void 0!==o)return o.exports;var r=t[n]={id:n,exports:{}};return e[n](r,r.exports,i),r.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.nc=void 0;var n={};(()=>{"use strict";i.r(n),i.d(n,{SourceEditing:()=>h});var e=i(704),t=i(273),o=i(209);function r(e){const t=[{name:"address",isVoid:!1},{name:"article",isVoid:!1},{name:"aside",isVoid:!1},{name:"blockquote",isVoid:!1},{name:"details",isVoid:!1},{name:"dialog",isVoid:!1},{name:"dd",isVoid:!1},{name:"div",isVoid:!1},{name:"dl",isVoid:!1},{name:"dt",isVoid:!1},{name:"fieldset",isVoid:!1},{name:"figcaption",isVoid:!1},{name:"figure",isVoid:!1},{name:"footer",isVoid:!1},{name:"form",isVoid:!1},{name:"h1",isVoid:!1},{name:"h2",isVoid:!1},{name:"h3",isVoid:!1},{name:"h4",isVoid:!1},{name:"h5",isVoid:!1},{name:"h6",isVoid:!1},{name:"header",isVoid:!1},{name:"hgroup",isVoid:!1},{name:"hr",isVoid:!0},{name:"li",isVoid:!1},{name:"main",isVoid:!1},{name:"nav",isVoid:!1},{name:"ol",isVoid:!1},{name:"p",isVoid:!1},{name:"section",isVoid:!1},{name:"table",isVoid:!1},{name:"tbody",isVoid:!1},{name:"td",isVoid:!1},{name:"th",isVoid:!1},{name:"thead",isVoid:!1},{name:"tr",isVoid:!1},{name:"ul",isVoid:!1}],i=t.map((e=>e.name)).join("|"),n=e.replace(new RegExp(`</?(${i})( .*?)?>`,"g"),"\n$&\n").replace(/<br[^>]*>/g,"$&\n").split("\n");let o=0;return n.filter((e=>e.length)).map((e=>function(e,t){return t.some((t=>!t.isVoid&&!!new RegExp(`<${t.name}( .*?)?>`).test(e)))}(e,t)?a(e,o++):function(e,t){return t.some((t=>new RegExp(`</${t.name}>`).test(e)))}(e,t)?a(e,--o):a(e,o))).join("\n")}function a(e,t,i=" "){return`${i.repeat(Math.max(0,t))}${e}`}var s=i(62),d=i.n(s),c=i(40),l={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()(c.Z,l);c.Z.locals;const u="SourceEditingMode";class h extends e.Plugin{static get pluginName(){return"SourceEditing"}static get requires(){return[e.PendingActions]}constructor(e){super(e),this.set("isSourceEditingMode",!1),this._elementReplacer=new o.ElementReplacer,this._replacedRoots=new Map,this._dataFromRoots=new Map}init(){const i=this.editor,n=i.t;i.ui.componentFactory.add("sourceEditing",(o=>{const r=new t.ButtonView(o);return r.set({label:n("Source"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m12.5 0 5 4.5v15.003h-16V0h11zM3 1.5v3.25l-1.497 1-.003 8 1.5 1v3.254L7.685 18l-.001 1.504H17.5V8.002L16 9.428l-.004-4.22-4.222-3.692L3 1.5z"/><path d="M4.06 6.64a.75.75 0 0 1 .958 1.15l-.085.07L2.29 9.75l2.646 1.89c.302.216.4.62.232.951l-.058.095a.75.75 0 0 1-.951.232l-.095-.058-3.5-2.5V9.14l3.496-2.5zm4.194 6.22a.75.75 0 0 1-.958-1.149l.085-.07 2.643-1.89-2.646-1.89a.75.75 0 0 1-.232-.952l.058-.095a.75.75 0 0 1 .95-.232l.096.058 3.5 2.5v1.22l-3.496 2.5zm7.644-.836 2.122 2.122-5.825 5.809-2.125-.005.003-2.116zm2.539-1.847 1.414 1.414a.5.5 0 0 1 0 .707l-1.06 1.06-2.122-2.12 1.061-1.061a.5.5 0 0 1 .707 0z"/></svg>',tooltip:!0,withText:!0,class:"ck-source-editing-button"}),r.bind("isOn").to(this,"isSourceEditingMode"),r.bind("isEnabled").to(this,"isEnabled",i,"isReadOnly",i.plugins.get(e.PendingActions),"hasAny",((e,t,i)=>!!e&&(!t&&!i))),this.listenTo(r,"execute",(()=>{this.isSourceEditingMode=!this.isSourceEditingMode})),r})),this._isAllowedToHandleSourceEditingMode()&&(this.on("change:isSourceEditingMode",((e,t,i)=>{i?(this._showSourceEditing(),this._disableCommands()):(this._hideSourceEditing(),this._enableCommands())})),this.on("change:isEnabled",((e,t,i)=>this._handleReadOnlyMode(!i))),this.listenTo(i,"change:isReadOnly",((e,t,i)=>this._handleReadOnlyMode(i)))),i.data.on("get",(()=>{this.isSourceEditingMode&&this.updateEditorData()}),{priority:"high"})}afterInit(){const e=this.editor;["RealTimeCollaborativeEditing","CommentsEditing","TrackChangesEditing","RevisionHistory"].some((t=>e.plugins.has(t)))&&console.warn("You initialized the editor with the source editing feature and at least one of the collaboration features. Please be advised that the source editing feature may not work, and be careful when editing document source that contains markers created by the collaboration features."),e.plugins.has("RestrictedEditingModeEditing")&&console.warn("You initialized the editor with the source editing feature and restricted editing feature. Please be advised that the source editing feature may not work, and be careful when editing document source that contains markers created by the restricted editing feature.")}updateEditorData(){const e=this.editor,t={};for(const[e,i]of this._replacedRoots){const n=this._dataFromRoots.get(e),o=i.dataset.value;n!==o&&(t[e]=o,this._dataFromRoots.set(e,o))}Object.keys(t).length&&e.data.set(t,{batchType:{isUndoable:!0}})}_showSourceEditing(){const e=this.editor,t=e.editing.view,i=e.model;i.change((e=>{e.setSelection(null),e.removeSelectionAttribute(i.document.selection.getAttributeKeys())}));for(const[i,n]of t.domRoots){const r=m(e.data.get({rootName:i})),a=(0,o.createElement)(n.ownerDocument,"textarea",{rows:"1","aria-label":"Source code editing area"}),s=(0,o.createElement)(n.ownerDocument,"div",{class:"ck-source-editing-area","data-value":r},[a]);a.value=r,a.setSelectionRange(0,0),a.addEventListener("input",(()=>{s.dataset.value=a.value,e.ui.update()})),t.change((e=>{const n=t.document.getRoot(i);e.addClass("ck-hidden",n)})),e.ui.setEditableElement("sourceEditing:"+i,a),this._replacedRoots.set(i,s),this._elementReplacer.replace(n,s),this._dataFromRoots.set(i,r)}this._focusSourceEditing()}_hideSourceEditing(){const e=this.editor.editing.view;this.updateEditorData(),e.change((t=>{for(const[i]of this._replacedRoots)t.removeClass("ck-hidden",e.document.getRoot(i))})),this._elementReplacer.restore(),this._replacedRoots.clear(),this._dataFromRoots.clear(),e.focus()}_focusSourceEditing(){const e=this.editor,[t]=this._replacedRoots.values(),i=t.querySelector("textarea");e.editing.view.document.isFocused=!1,i.focus()}_disableCommands(){const e=this.editor;for(const t of e.commands.commands())t.forceDisabled(u)}_enableCommands(){const e=this.editor;for(const t of e.commands.commands())t.clearForceDisabled(u)}_handleReadOnlyMode(e){if(this.isSourceEditingMode)for(const[,t]of this._replacedRoots)t.querySelector("textarea").readOnly=e}_isAllowedToHandleSourceEditingMode(){const e=this.editor.ui.view.editable;return e&&!e.hasExternalElement}}function m(e){return function(e){return e.startsWith("<")}(e)?r(e):e}})(),(window.CKEditor5=window.CKEditor5||{}).sourceEditing=n})();
5
+ */(()=>{var e={264:(e,t,i)=>{"use strict";i.d(t,{c:()=>r});var o=i(849),n=i.n(o)()((function(e){return e[1]}));n.push([e.id,'.ck-source-editing-area{overflow:hidden;position:relative}.ck-source-editing-area textarea,.ck-source-editing-area:after{border:1px solid transparent;font-family:monospace;font-size:var(--ck-font-size-normal);line-height:var(--ck-line-height-base);margin:0;padding:var(--ck-spacing-large);white-space:pre-wrap}.ck-source-editing-area:after{content:attr(data-value) " ";display:block;visibility:hidden}.ck-source-editing-area textarea{border-color:var(--ck-color-base-border);border-radius:0;box-sizing:border-box;height:100%;outline:none;overflow:hidden;position:absolute;resize:none;width:100%}.ck-rounded-corners .ck-source-editing-area textarea,.ck-source-editing-area textarea.ck-rounded-corners{border-radius:var(--ck-border-radius);border-top-left-radius:0;border-top-right-radius:0}.ck-source-editing-area textarea:not([readonly]):focus{border:var(--ck-focus-ring);box-shadow:var(--ck-inner-shadow),0 0;outline:none}',""]);const r=n},849:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var i=e(t);return t[2]?"@media ".concat(t[2]," {").concat(i,"}"):i})).join("")},t.i=function(e,i,o){"string"==typeof e&&(e=[[null,e,""]]);var n={};if(o)for(var r=0;r<this.length;r++){var a=this[r][0];null!=a&&(n[a]=!0)}for(var s=0;s<e.length;s++){var d=[].concat(e[s]);o&&n[d[0]]||(i&&(d[2]?d[2]="".concat(i," and ").concat(d[2]):d[2]=i),t.push(d))}},t}},108:(e,t,i)=>{"use strict";var o,n=function(){return void 0===o&&(o=Boolean(window&&document&&document.all&&!window.atob)),o},r=function(){var e={};return function(t){if(void 0===e[t]){var i=document.querySelector(t);if(window.HTMLIFrameElement&&i instanceof window.HTMLIFrameElement)try{i=i.contentDocument.head}catch(e){i=null}e[t]=i}return e[t]}}(),a=[];function s(e){for(var t=-1,i=0;i<a.length;i++)if(a[i].identifier===e){t=i;break}return t}function d(e,t){for(var i={},o=[],n=0;n<e.length;n++){var r=e[n],d=t.base?r[0]+t.base:r[0],c=i[d]||0,l="".concat(d," ").concat(c);i[d]=c+1;var u=s(l),h={css:r[1],media:r[2],sourceMap:r[3]};-1!==u?(a[u].references++,a[u].updater(h)):a.push({identifier:l,updater:p(h,t),references:1}),o.push(l)}return o}function c(e){var t=document.createElement("style"),o=e.attributes||{};if(void 0===o.nonce){var n=i.nc;n&&(o.nonce=n)}if(Object.keys(o).forEach((function(e){t.setAttribute(e,o[e])})),"function"==typeof e.insert)e.insert(t);else{var a=r(e.insert||"head");if(!a)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");a.appendChild(t)}return t}var l,u=(l=[],function(e,t){return l[e]=t,l.filter(Boolean).join("\n")});function h(e,t,i,o){var n=i?"":o.media?"@media ".concat(o.media," {").concat(o.css,"}"):o.css;if(e.styleSheet)e.styleSheet.cssText=u(t,n);else{var r=document.createTextNode(n),a=e.childNodes;a[t]&&e.removeChild(a[t]),a.length?e.insertBefore(r,a[t]):e.appendChild(r)}}function m(e,t,i){var o=i.css,n=i.media,r=i.sourceMap;if(n?e.setAttribute("media",n):e.removeAttribute("media"),r&&"undefined"!=typeof btoa&&(o+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),e.styleSheet)e.styleSheet.cssText=o;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(o))}}var g=null,f=0;function p(e,t){var i,o,n;if(t.singleton){var r=f++;i=g||(g=c(t)),o=h.bind(null,i,r,!1),n=h.bind(null,i,r,!0)}else i=c(t),o=m.bind(null,i,t),n=function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(i)};return o(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;o(e=t)}else n()}}e.exports=function(e,t){(t=t||{}).singleton||"boolean"==typeof t.singleton||(t.singleton=n());var i=d(e=e||[],t);return function(e){if(e=e||[],"[object Array]"===Object.prototype.toString.call(e)){for(var o=0;o<i.length;o++){var n=s(i[o]);a[n].references--}for(var r=d(e,t),c=0;c<i.length;c++){var l=s(i[c]);0===a[l].references&&(a[l].updater(),a.splice(l,1))}i=r}}}},968:(e,t,i)=>{e.exports=i(672)("./src/core.js")},348:(e,t,i)=>{e.exports=i(672)("./src/ui.js")},316:(e,t,i)=>{e.exports=i(672)("./src/utils.js")},672:e=>{"use strict";e.exports=CKEditor5.dll}},t={};function i(o){var n=t[o];if(void 0!==n)return n.exports;var r=t[o]={id:o,exports:{}};return e[o](r,r.exports,i),r.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var o in t)i.o(t,o)&&!i.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.nc=void 0;var o={};(()=>{"use strict";i.r(o),i.d(o,{SourceEditing:()=>h});var e=i(968),t=i(348),n=i(316);function r(e){const t=[{name:"address",isVoid:!1},{name:"article",isVoid:!1},{name:"aside",isVoid:!1},{name:"blockquote",isVoid:!1},{name:"details",isVoid:!1},{name:"dialog",isVoid:!1},{name:"dd",isVoid:!1},{name:"div",isVoid:!1},{name:"dl",isVoid:!1},{name:"dt",isVoid:!1},{name:"fieldset",isVoid:!1},{name:"figcaption",isVoid:!1},{name:"figure",isVoid:!1},{name:"footer",isVoid:!1},{name:"form",isVoid:!1},{name:"h1",isVoid:!1},{name:"h2",isVoid:!1},{name:"h3",isVoid:!1},{name:"h4",isVoid:!1},{name:"h5",isVoid:!1},{name:"h6",isVoid:!1},{name:"header",isVoid:!1},{name:"hgroup",isVoid:!1},{name:"hr",isVoid:!0},{name:"li",isVoid:!1},{name:"main",isVoid:!1},{name:"nav",isVoid:!1},{name:"ol",isVoid:!1},{name:"p",isVoid:!1},{name:"section",isVoid:!1},{name:"table",isVoid:!1},{name:"tbody",isVoid:!1},{name:"td",isVoid:!1},{name:"th",isVoid:!1},{name:"thead",isVoid:!1},{name:"tr",isVoid:!1},{name:"ul",isVoid:!1}],i=t.map((e=>e.name)).join("|"),o=e.replace(new RegExp(`</?(${i})( .*?)?>`,"g"),"\n$&\n").replace(/<br[^>]*>/g,"$&\n").split("\n");let n=0;return o.filter((e=>e.length)).map((e=>function(e,t){return t.some((t=>!t.isVoid&&!!new RegExp(`<${t.name}( .*?)?>`).test(e)))}(e,t)?a(e,n++):function(e,t){return t.some((t=>new RegExp(`</${t.name}>`).test(e)))}(e,t)?a(e,--n):a(e,n))).join("\n")}function a(e,t,i=" "){return`${i.repeat(Math.max(0,t))}${e}`}var s=i(108),d=i.n(s),c=i(264),l={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()(c.c,l);c.c.locals;const u="SourceEditingMode";class h extends e.Plugin{static get pluginName(){return"SourceEditing"}static get requires(){return[e.PendingActions]}constructor(e){super(e),this.set("isSourceEditingMode",!1),this._elementReplacer=new n.ElementReplacer,this._replacedRoots=new Map,this._dataFromRoots=new Map,e.config.define("sourceEditing.allowCollaborationFeatures",!1)}init(){this._checkCompatibility();const i=this.editor,o=i.t;i.ui.componentFactory.add("sourceEditing",(n=>{const r=new t.ButtonView(n);return r.set({label:o("Source"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m12.5 0 5 4.5v15.003h-16V0h11zM3 1.5v3.25l-1.497 1-.003 8 1.5 1v3.254L7.685 18l-.001 1.504H17.5V8.002L16 9.428l-.004-4.22-4.222-3.692L3 1.5z"/><path d="M4.06 6.64a.75.75 0 0 1 .958 1.15l-.085.07L2.29 9.75l2.646 1.89c.302.216.4.62.232.951l-.058.095a.75.75 0 0 1-.951.232l-.095-.058-3.5-2.5V9.14l3.496-2.5zm4.194 6.22a.75.75 0 0 1-.958-1.149l.085-.07 2.643-1.89-2.646-1.89a.75.75 0 0 1-.232-.952l.058-.095a.75.75 0 0 1 .95-.232l.096.058 3.5 2.5v1.22l-3.496 2.5zm7.644-.836 2.122 2.122-5.825 5.809-2.125-.005.003-2.116zm2.539-1.847 1.414 1.414a.5.5 0 0 1 0 .707l-1.06 1.06-2.122-2.12 1.061-1.061a.5.5 0 0 1 .707 0z"/></svg>',tooltip:!0,withText:!0,class:"ck-source-editing-button"}),r.bind("isOn").to(this,"isSourceEditingMode"),r.bind("isEnabled").to(this,"isEnabled",i,"isReadOnly",i.plugins.get(e.PendingActions),"hasAny",((e,t,i)=>!!e&&(!t&&!i))),this.listenTo(r,"execute",(()=>{this.isSourceEditingMode=!this.isSourceEditingMode})),r})),this._isAllowedToHandleSourceEditingMode()&&(this.on("change:isSourceEditingMode",((e,t,i)=>{i?(this._hideVisibleDialog(),this._showSourceEditing(),this._disableCommands()):(this._hideSourceEditing(),this._enableCommands())})),this.on("change:isEnabled",((e,t,i)=>this._handleReadOnlyMode(!i))),this.listenTo(i,"change:isReadOnly",((e,t,i)=>this._handleReadOnlyMode(i)))),i.data.on("get",(()=>{this.isSourceEditingMode&&this.updateEditorData()}),{priority:"high"})}updateEditorData(){const e=this.editor,t={};for(const[e,i]of this._replacedRoots){const o=this._dataFromRoots.get(e),n=i.dataset.value;o!==n&&(t[e]=n,this._dataFromRoots.set(e,n))}Object.keys(t).length&&e.data.set(t,{batchType:{isUndoable:!0},suppressErrorInCollaboration:!0})}_checkCompatibility(){const e=this.editor,t=e.config.get("sourceEditing.allowCollaborationFeatures");if(!t&&e.plugins.has("RealTimeCollaborativeEditing"))throw new n.CKEditorError("source-editing-incompatible-with-real-time-collaboration",null);!t&&["CommentsEditing","TrackChangesEditing","RevisionHistory"].some((t=>e.plugins.has(t)))&&console.warn("You initialized the editor with the source editing feature and at least one of the collaboration features. Please be advised that the source editing feature may not work, and be careful when editing document source that contains markers created by the collaboration features."),e.plugins.has("RestrictedEditingModeEditing")&&console.warn("You initialized the editor with the source editing feature and restricted editing feature. Please be advised that the source editing feature may not work, and be careful when editing document source that contains markers created by the restricted editing feature.")}_showSourceEditing(){const e=this.editor,t=e.editing.view,i=e.model;i.change((e=>{e.setSelection(null),e.removeSelectionAttribute(i.document.selection.getAttributeKeys())}));for(const[i,o]of t.domRoots){const r=m(e.data.get({rootName:i})),a=(0,n.createElement)(o.ownerDocument,"textarea",{rows:"1","aria-label":"Source code editing area"}),s=(0,n.createElement)(o.ownerDocument,"div",{class:"ck-source-editing-area","data-value":r},[a]);a.value=r,a.setSelectionRange(0,0),a.addEventListener("input",(()=>{s.dataset.value=a.value,e.ui.update()})),t.change((e=>{const o=t.document.getRoot(i);e.addClass("ck-hidden",o)})),e.ui.setEditableElement("sourceEditing:"+i,a),this._replacedRoots.set(i,s),this._elementReplacer.replace(o,s),this._dataFromRoots.set(i,r)}this._focusSourceEditing()}_hideSourceEditing(){const e=this.editor.editing.view;this.updateEditorData(),e.change((t=>{for(const[i]of this._replacedRoots)t.removeClass("ck-hidden",e.document.getRoot(i))})),this._elementReplacer.restore(),this._replacedRoots.clear(),this._dataFromRoots.clear(),e.focus()}_focusSourceEditing(){const e=this.editor,[t]=this._replacedRoots.values(),i=t.querySelector("textarea");e.editing.view.document.isFocused=!1,i.focus()}_disableCommands(){const e=this.editor;for(const t of e.commands.commands())t.forceDisabled(u)}_enableCommands(){const e=this.editor;for(const t of e.commands.commands())t.clearForceDisabled(u)}_handleReadOnlyMode(e){if(this.isSourceEditingMode)for(const[,t]of this._replacedRoots)t.querySelector("textarea").readOnly=e}_isAllowedToHandleSourceEditingMode(){const e=this.editor.ui.view.editable;return e&&!e.hasExternalElement}_hideVisibleDialog(){if(this.editor.plugins.has("Dialog")){const e=this.editor.plugins.get("Dialog");e.isOpen&&e.hide()}}}function m(e){return function(e){return e.startsWith("<")}(e)?r(e):e}})(),(window.CKEditor5=window.CKEditor5||{}).sourceEditing=o})();
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-source-editing",
3
- "version": "40.2.0",
3
+ "version": "41.1.0",
4
4
  "description": "Source editing feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -10,10 +10,11 @@
10
10
  "ckeditor5-plugin",
11
11
  "ckeditor5-dll"
12
12
  ],
13
+ "type": "module",
13
14
  "main": "src/index.js",
14
15
  "dependencies": {
15
- "@ckeditor/ckeditor5-theme-lark": "40.2.0",
16
- "ckeditor5": "40.2.0"
16
+ "@ckeditor/ckeditor5-theme-lark": "41.1.0",
17
+ "ckeditor5": "41.1.0"
17
18
  },
18
19
  "author": "CKSource (http://cksource.com/)",
19
20
  "license": "GPL-2.0-or-later",
@@ -1,9 +1,17 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
- import type { SourceEditing } from './index';
5
+ import type { SourceEditing, SourceEditingConfig } from './index.js';
6
6
  declare module '@ckeditor/ckeditor5-core' {
7
+ interface EditorConfig {
8
+ /**
9
+ * The configuration of the source editing feature.
10
+ *
11
+ * Read more in {@link module:source-editing/sourceeditingconfig~SourceEditingConfig}.
12
+ */
13
+ sourceEditing?: SourceEditingConfig;
14
+ }
7
15
  interface PluginsMap {
8
16
  [SourceEditing.pluginName]: SourceEditing;
9
17
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
  export {};
package/src/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
  /**
6
6
  * @module source-editing
7
7
  */
8
- export { default as SourceEditing } from './sourceediting';
9
- import './augmentation';
8
+ export { default as SourceEditing } from './sourceediting.js';
9
+ export type { SourceEditingConfig } from './sourceeditingconfig.js';
10
+ import './augmentation.js';
package/src/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
  /**
6
6
  * @module source-editing
7
7
  */
8
- export { default as SourceEditing } from './sourceediting';
9
- import './augmentation';
8
+ export { default as SourceEditing } from './sourceediting.js';
9
+ import './augmentation.js';
@@ -1,11 +1,11 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
  /**
6
6
  * @module source-editing/sourceediting
7
7
  */
8
- import { type Editor, Plugin, PendingActions } from 'ckeditor5/src/core';
8
+ import { type Editor, Plugin, PendingActions } from 'ckeditor5/src/core.js';
9
9
  import '../theme/sourceediting.css';
10
10
  /**
11
11
  * The source editing feature.
@@ -50,14 +50,11 @@ export default class SourceEditing extends Plugin {
50
50
  * @inheritDoc
51
51
  */
52
52
  init(): void;
53
- /**
54
- * @inheritDoc
55
- */
56
- afterInit(): void;
57
53
  /**
58
54
  * Updates the source data in all hidden editing roots.
59
55
  */
60
56
  updateEditorData(): void;
57
+ private _checkCompatibility;
61
58
  /**
62
59
  * Creates source editing wrappers that replace each editing root. Each wrapper contains the document source from the corresponding
63
60
  * root.
@@ -99,4 +96,8 @@ export default class SourceEditing extends Plugin {
99
96
  * for the {@link module:editor-classic/classiceditor~ClassicEditor classic editor}.
100
97
  */
101
98
  private _isAllowedToHandleSourceEditingMode;
99
+ /**
100
+ * If any {@link module:ui/dialog/dialogview~DialogView editor dialog} is currently visible, hide it.
101
+ */
102
+ private _hideVisibleDialog;
102
103
  }
@@ -1,15 +1,15 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
  /**
6
6
  * @module source-editing/sourceediting
7
7
  */
8
8
  /* global console */
9
- import { Plugin, PendingActions } from 'ckeditor5/src/core';
10
- import { ButtonView } from 'ckeditor5/src/ui';
11
- import { createElement, ElementReplacer } from 'ckeditor5/src/utils';
12
- import { formatHtml } from './utils/formathtml';
9
+ import { Plugin, PendingActions } from 'ckeditor5/src/core.js';
10
+ import { ButtonView } from 'ckeditor5/src/ui.js';
11
+ import { CKEditorError, createElement, ElementReplacer } from 'ckeditor5/src/utils.js';
12
+ import { formatHtml } from './utils/formathtml.js';
13
13
  import '../theme/sourceediting.css';
14
14
  import sourceEditingIcon from '../theme/icons/source-editing.svg';
15
15
  const COMMAND_FORCE_DISABLE_ID = 'SourceEditingMode';
@@ -43,11 +43,13 @@ export default class SourceEditing extends Plugin {
43
43
  this._elementReplacer = new ElementReplacer();
44
44
  this._replacedRoots = new Map();
45
45
  this._dataFromRoots = new Map();
46
+ editor.config.define('sourceEditing.allowCollaborationFeatures', false);
46
47
  }
47
48
  /**
48
49
  * @inheritDoc
49
50
  */
50
51
  init() {
52
+ this._checkCompatibility();
51
53
  const editor = this.editor;
52
54
  const t = editor.t;
53
55
  editor.ui.componentFactory.add('sourceEditing', locale => {
@@ -87,6 +89,7 @@ export default class SourceEditing extends Plugin {
87
89
  if (this._isAllowedToHandleSourceEditingMode()) {
88
90
  this.on('change:isSourceEditingMode', (evt, name, isSourceEditingMode) => {
89
91
  if (isSourceEditingMode) {
92
+ this._hideVisibleDialog();
90
93
  this._showSourceEditing();
91
94
  this._disableCommands();
92
95
  }
@@ -106,18 +109,54 @@ export default class SourceEditing extends Plugin {
106
109
  }, { priority: 'high' });
107
110
  }
108
111
  /**
109
- * @inheritDoc
112
+ * Updates the source data in all hidden editing roots.
110
113
  */
111
- afterInit() {
114
+ updateEditorData() {
115
+ const editor = this.editor;
116
+ const data = {};
117
+ for (const [rootName, domSourceEditingElementWrapper] of this._replacedRoots) {
118
+ const oldData = this._dataFromRoots.get(rootName);
119
+ const newData = domSourceEditingElementWrapper.dataset.value;
120
+ // Do not set the data unless some changes have been made in the meantime.
121
+ // This prevents empty undo steps after switching to the normal editor.
122
+ if (oldData !== newData) {
123
+ data[rootName] = newData;
124
+ this._dataFromRoots.set(rootName, newData);
125
+ }
126
+ }
127
+ if (Object.keys(data).length) {
128
+ editor.data.set(data, { batchType: { isUndoable: true }, suppressErrorInCollaboration: true });
129
+ }
130
+ }
131
+ _checkCompatibility() {
112
132
  const editor = this.editor;
133
+ const allowCollaboration = editor.config.get('sourceEditing.allowCollaborationFeatures');
134
+ if (!allowCollaboration && editor.plugins.has('RealTimeCollaborativeEditing')) {
135
+ /**
136
+ * Source editing feature is not fully compatible with real-time collaboration,
137
+ * and using it may lead to data loss. Please read
138
+ * {@glink features/source-editing#limitations-and-incompatibility source editing feature guide} to learn more.
139
+ *
140
+ * If you understand the possible risk of data loss, you can enable the source editing
141
+ * by setting the
142
+ * {@link module:source-editing/sourceeditingconfig~SourceEditingConfig#allowCollaborationFeatures}
143
+ * configuration flag to `true`.
144
+ *
145
+ * @error source-editing-incompatible-with-real-time-collaboration
146
+ */
147
+ throw new CKEditorError('source-editing-incompatible-with-real-time-collaboration', null);
148
+ }
113
149
  const collaborationPluginNamesToWarn = [
114
- 'RealTimeCollaborativeEditing',
115
150
  'CommentsEditing',
116
151
  'TrackChangesEditing',
117
152
  'RevisionHistory'
118
153
  ];
119
154
  // Currently, the basic integration with Collaboration Features is to display a warning in the console.
120
- if (collaborationPluginNamesToWarn.some(pluginName => editor.plugins.has(pluginName))) {
155
+ //
156
+ // If `allowCollaboration` flag is set, do not show these warnings. If the flag is set, we assume that the integrator read
157
+ // appropriate section of the guide so there's no use to spam the console with warnings.
158
+ //
159
+ if (!allowCollaboration && collaborationPluginNamesToWarn.some(pluginName => editor.plugins.has(pluginName))) {
121
160
  console.warn('You initialized the editor with the source editing feature and at least one of the collaboration features. ' +
122
161
  'Please be advised that the source editing feature may not work, and be careful when editing document source ' +
123
162
  'that contains markers created by the collaboration features.');
@@ -129,26 +168,6 @@ export default class SourceEditing extends Plugin {
129
168
  'that contains markers created by the restricted editing feature.');
130
169
  }
131
170
  }
132
- /**
133
- * Updates the source data in all hidden editing roots.
134
- */
135
- updateEditorData() {
136
- const editor = this.editor;
137
- const data = {};
138
- for (const [rootName, domSourceEditingElementWrapper] of this._replacedRoots) {
139
- const oldData = this._dataFromRoots.get(rootName);
140
- const newData = domSourceEditingElementWrapper.dataset.value;
141
- // Do not set the data unless some changes have been made in the meantime.
142
- // This prevents empty undo steps after switching to the normal editor.
143
- if (oldData !== newData) {
144
- data[rootName] = newData;
145
- this._dataFromRoots.set(rootName, newData);
146
- }
147
- }
148
- if (Object.keys(data).length) {
149
- editor.data.set(data, { batchType: { isUndoable: true } });
150
- }
151
- }
152
171
  /**
153
172
  * Creates source editing wrappers that replace each editing root. Each wrapper contains the document source from the corresponding
154
173
  * root.
@@ -275,6 +294,17 @@ export default class SourceEditing extends Plugin {
275
294
  // Checks, if the editor's editable belongs to the editor's DOM tree.
276
295
  return editable && !editable.hasExternalElement;
277
296
  }
297
+ /**
298
+ * If any {@link module:ui/dialog/dialogview~DialogView editor dialog} is currently visible, hide it.
299
+ */
300
+ _hideVisibleDialog() {
301
+ if (this.editor.plugins.has('Dialog')) {
302
+ const dialogPlugin = this.editor.plugins.get('Dialog');
303
+ if (dialogPlugin.isOpen) {
304
+ dialogPlugin.hide();
305
+ }
306
+ }
307
+ }
278
308
  }
279
309
  /**
280
310
  * Formats the content for a better readability.
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module source-editing/sourceeditingconfig
7
+ */
8
+ /**
9
+ * The configuration of the source editing feature.
10
+ *
11
+ * ```ts
12
+ * ClassicEditor
13
+ * .create( {
14
+ * sourceEditing: {
15
+ * allowCollaborationFeatures: true
16
+ * }
17
+ * } )
18
+ * .then( ... )
19
+ * .catch( ... );
20
+ * ```
21
+ *
22
+ * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
23
+ */
24
+ export interface SourceEditingConfig {
25
+ /**
26
+ * Set to `true` to enable source editing feature for real-time collaboration.
27
+ *
28
+ * Please note that source editing feature is not fully compatible with real-time collaboration and using it may lead to data loss.
29
+ * {@glink features/source-editing#limitations-and-incompatibility Read more}.
30
+ *
31
+ * @default false
32
+ */
33
+ allowCollaborationFeatures?: boolean;
34
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ export {};
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
2
+ * Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5