@ckeditor/ckeditor5-source-editing 30.0.0 → 31.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/build/source-editing.js +1 -1
- package/build/translations/pl.js +1 -0
- package/lang/translations/pl.po +21 -0
- package/package.json +13 -13
- package/src/sourceediting.js +30 -14
- package/theme/sourceediting.css +7 -4
package/build/source-editing.js
CHANGED
@@ -2,4 +2,4 @@
|
|
2
2
|
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
|
3
3
|
* For licensing, see LICENSE.md.
|
4
4
|
*/
|
5
|
-
!function(e){const t=e.en=e.en||{};t.dictionary=Object.assign(t.dictionary||{},{Source:"Source"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})),window.CKEditor5=window.CKEditor5||{},window.CKEditor5.sourceEditing=function(e){var t={};function i(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)i.d(n,o,function(t){return e[t]}.bind(null,o));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=7)}([function(e,t,i){e.exports=i(2)("./src/core.js")},function(e,t,i){e.exports=i(2)("./src/utils.js")},function(e,t){e.exports=CKEditor5.dll},function(e,t,i){e.exports=i(2)("./src/ui.js")},function(e,t,i){var n=i(5),o=i(6);"string"==typeof(o=o.__esModule?o.default:o)&&(o=[[e.i,o,""]]);var r={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(o,r);e.exports=o.locals||{}},function(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),f={css:r[1],media:r[2],sourceMap:r[3]};-1!==u?(a[u].references++,a[u].updater(f)):a.push({identifier:l,updater:p(f,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 f(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 h=null,g=0;function p(e,t){var i,n,o;if(t.singleton){var r=g++;i=h||(h=c(t)),n=f.bind(null,i,r,!1),o=f.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}}}},function(e,t){e.exports='.ck-source-editing-area{display:inline-grid;width:100%;font-family:monospace}.ck-source-editing-area:after,.ck-source-editing-area textarea{grid-area:1/1;padding:var(--ck-spacing-large);margin:0;border:1px solid transparent;line-height:var(--ck-line-height-base);font-size:var(--ck-font-size-normal);white-space:pre-wrap}.ck-source-editing-area:after{content:attr(data-value) " ";visibility:hidden}.ck-source-editing-area textarea{resize:none;outline:none;overflow:hidden;border-color:var(--ck-color-base-border);border-radius:0}.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{outline:none;border:var(--ck-focus-ring);box-shadow:var(--ck-inner-shadow),0 0}'},function(e,t,i){"use strict";i.r(t),i.d(t,"SourceEditing",(function(){return d}));var n=i(0),o=i(3),r=i(1);function a(e){const t=[{name:"address",isVoid:!1},{name:"article",isVoid:!1},{name:"aside",isVoid:!1},{name:"blockquote",isVoid:!1},{name:"br",isVoid:!0},{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:"input",isVoid:!0},{name:"li",isVoid:!1},{name:"main",isVoid:!1},{name:"nav",isVoid:!1},{name:"ol",isVoid:!1},{name:"p",isVoid:!1},{name:"pre",isVoid:!1},{name:"section",isVoid:!1},{name:"table",isVoid:!1},{name:"tbody",isVoid:!1},{name:"td",isVoid:!1},{name:"textarea",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").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)?s(e,o++):function(e,t){return t.some(t=>new RegExp(`</${t.name}>`).test(e))}(e,t)?s(e,--o):s(e,o)).join("\n")}function s(e,t,i=" "){return`${i.repeat(t)}${e}`}i(4);class d extends n.Plugin{static get pluginName(){return"SourceEditing"}static get requires(){return[n.PendingActions]}constructor(e){super(e),this.set("isSourceEditingMode",!1),this._elementReplacer=new r.ElementReplacer,this._replacedRoots=new Map,this._dataFromRoots=new Map}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("sourceEditing",i=>{const r=new o.ButtonView(i);return r.set({label:t("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",e,"isReadOnly",e.plugins.get(n.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(e,"change:isReadOnly",(e,t,i)=>this._handleReadOnlyMode(i)))}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.")}_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 o=c(e.data.get({rootName:i})),a=Object(r.createElement)(n.ownerDocument,"textarea",{rows:"1"}),s=Object(r.createElement)(n.ownerDocument,"div",{class:"ck-source-editing-area","data-value":o},[a]);a.value=o,a.setSelectionRange(0,0),a.addEventListener("input",()=>{s.dataset.value=a.value}),t.change(e=>{const n=t.document.getRoot(i);e.addClass("ck-hidden",n)}),this._replacedRoots.set(i,s),this._elementReplacer.replace(n,s),this._dataFromRoots.set(i,o)}this._focusSourceEditing()}_hideSourceEditing(){const e=this.editor,t=e.editing.view,i={};for(const[e,n]of this._replacedRoots){const o=this._dataFromRoots.get(e),r=n.dataset.value;o!==r&&(i[e]=r),t.change(i=>{const n=t.document.getRoot(e);i.removeClass("ck-hidden",n)})}this._elementReplacer.restore(),this._replacedRoots.clear(),this._dataFromRoots.clear(),Object.keys(i).length&&e.data.set(i,{batchType:"default"}),e.editing.view.focus()}_focusSourceEditing(){const[e]=this._replacedRoots.values();e.querySelector("textarea").focus()}_disableCommands(){const e=this.editor;for(const t of e.commands.commands())t.forceDisabled("SourceEditingMode")}_enableCommands(){const e=this.editor;for(const t of e.commands.commands())t.clearForceDisabled("SourceEditingMode")}_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 c(e){return function(e){return e.startsWith("<")}(e)?a(e):e}}]);
|
5
|
+
!function(e){const t=e.en=e.en||{};t.dictionary=Object.assign(t.dictionary||{},{Source:"Source"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})),window.CKEditor5=window.CKEditor5||{},window.CKEditor5.sourceEditing=function(e){var t={};function i(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)i.d(n,o,function(t){return e[t]}.bind(null,o));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=7)}([function(e,t,i){e.exports=i(2)("./src/core.js")},function(e,t,i){e.exports=i(2)("./src/utils.js")},function(e,t){e.exports=CKEditor5.dll},function(e,t,i){e.exports=i(2)("./src/ui.js")},function(e,t,i){var n=i(5),o=i(6);"string"==typeof(o=o.__esModule?o.default:o)&&(o=[[e.i,o,""]]);var r={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(o,r);e.exports=o.locals||{}},function(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,u="".concat(d," ").concat(c);i[d]=c+1;var l=s(u),h={css:r[1],media:r[2],sourceMap:r[3]};-1!==l?(a[l].references++,a[l].updater(h)):a.push({identifier:u,updater:p(h,t),references:1}),n.push(u)}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 u,l=(u=[],function(e,t){return u[e]=t,u.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=l(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 f(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 m=null,g=0;function p(e,t){var i,n,o;if(t.singleton){var r=g++;i=m||(m=c(t)),n=h.bind(null,i,r,!1),o=h.bind(null,i,r,!0)}else i=c(t),n=f.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 u=s(i[c]);0===a[u].references&&(a[u].updater(),a.splice(u,1))}i=r}}}},function(e,t){e.exports='.ck-source-editing-area{position:relative}.ck-source-editing-area:after,.ck-source-editing-area textarea{padding:var(--ck-spacing-large);margin:0;border:1px solid transparent;line-height:var(--ck-line-height-base);font-size:var(--ck-font-size-normal);font-family:monospace;white-space:pre-wrap}.ck-source-editing-area:after{content:attr(data-value) " ";visibility:hidden;display:block}.ck-source-editing-area textarea{position:absolute;width:100%;height:100%;resize:none;outline:none;overflow:hidden;box-sizing:border-box;border-color:var(--ck-color-base-border);border-radius:0}.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{outline:none;border:var(--ck-focus-ring);box-shadow:var(--ck-inner-shadow),0 0}'},function(e,t,i){"use strict";i.r(t),i.d(t,"SourceEditing",(function(){return d}));var n=i(0),o=i(3),r=i(1);function a(e){const t=[{name:"address",isVoid:!1},{name:"article",isVoid:!1},{name:"aside",isVoid:!1},{name:"blockquote",isVoid:!1},{name:"br",isVoid:!0},{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:"input",isVoid:!0},{name:"li",isVoid:!1},{name:"main",isVoid:!1},{name:"nav",isVoid:!1},{name:"ol",isVoid:!1},{name:"p",isVoid:!1},{name:"pre",isVoid:!1},{name:"section",isVoid:!1},{name:"table",isVoid:!1},{name:"tbody",isVoid:!1},{name:"td",isVoid:!1},{name:"textarea",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").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)?s(e,o++):function(e,t){return t.some(t=>new RegExp(`</${t.name}>`).test(e))}(e,t)?s(e,--o):s(e,o)).join("\n")}function s(e,t,i=" "){return`${i.repeat(t)}${e}`}i(4);class d extends n.Plugin{static get pluginName(){return"SourceEditing"}static get requires(){return[n.PendingActions]}constructor(e){super(e),this.set("isSourceEditingMode",!1),this._elementReplacer=new r.ElementReplacer,this._replacedRoots=new Map,this._dataFromRoots=new Map}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("sourceEditing",i=>{const r=new o.ButtonView(i);return r.set({label:t("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",e,"isReadOnly",e.plugins.get(n.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(e,"change:isReadOnly",(e,t,i)=>this._handleReadOnlyMode(i))),e.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.")}_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 o=c(e.data.get({rootName:i})),a=Object(r.createElement)(n.ownerDocument,"textarea",{rows:"1"}),s=Object(r.createElement)(n.ownerDocument,"div",{class:"ck-source-editing-area","data-value":o},[a]);a.value=o,a.setSelectionRange(0,0),a.addEventListener("input",()=>{s.dataset.value=a.value}),t.change(e=>{const n=t.document.getRoot(i);e.addClass("ck-hidden",n)}),this._replacedRoots.set(i,s),this._elementReplacer.replace(n,s),this._dataFromRoots.set(i,o)}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()}_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)}Object.keys(t).length&&e.data.set(t,{batchType:"default"})}_focusSourceEditing(){const[e]=this._replacedRoots.values();e.querySelector("textarea").focus()}_disableCommands(){const e=this.editor;for(const t of e.commands.commands())t.forceDisabled("SourceEditingMode")}_enableCommands(){const e=this.editor;for(const t of e.commands.commands())t.clearForceDisabled("SourceEditingMode")}_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 c(e){return function(e){return e.startsWith("<")}(e)?a(e):e}}]);
|
@@ -0,0 +1 @@
|
|
1
|
+
!function(i){const n=i.pl=i.pl||{};n.dictionary=Object.assign(n.dictionary||{},{Source:"Źródło"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
|
2
|
+
#
|
3
|
+
# !!! IMPORTANT !!!
|
4
|
+
#
|
5
|
+
# Before you edit this file, please keep in mind that contributing to the project
|
6
|
+
# translations is possible ONLY via the Transifex online service.
|
7
|
+
#
|
8
|
+
# To submit your translations, visit https://www.transifex.com/ckeditor/ckeditor5.
|
9
|
+
#
|
10
|
+
# To learn more, check out the official contributor's guide:
|
11
|
+
# https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
|
12
|
+
#
|
13
|
+
msgid ""
|
14
|
+
msgstr ""
|
15
|
+
"Language-Team: Polish (https://www.transifex.com/ckeditor/teams/11143/pl/)\n"
|
16
|
+
"Language: pl\n"
|
17
|
+
"Plural-Forms: nplurals=4; plural=(n==1 ? 0 : (n%10>=2 && n%10<=4) && (n%100<12 || n%100>14) ? 1 : n!=1 && (n%10>=0 && n%10<=1) || (n%10>=5 && n%10<=9) || (n%100>=12 && n%100<=14) ? 2 : 3);\n"
|
18
|
+
|
19
|
+
msgctxt "The label of the source editing feature toolbar button."
|
20
|
+
msgid "Source"
|
21
|
+
msgstr "Źródło"
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ckeditor/ckeditor5-source-editing",
|
3
|
-
"version": "
|
3
|
+
"version": "31.0.0",
|
4
4
|
"description": "Source editing feature for CKEditor 5.",
|
5
5
|
"keywords": [
|
6
6
|
"ckeditor",
|
@@ -12,21 +12,21 @@
|
|
12
12
|
],
|
13
13
|
"main": "src/index.js",
|
14
14
|
"dependencies": {
|
15
|
-
"@ckeditor/ckeditor5-theme-lark": "^
|
16
|
-
"ckeditor5": "^
|
15
|
+
"@ckeditor/ckeditor5-theme-lark": "^31.0.0",
|
16
|
+
"ckeditor5": "^31.0.0"
|
17
17
|
},
|
18
18
|
"devDependencies": {
|
19
|
-
"@ckeditor/ckeditor5-core": "^
|
19
|
+
"@ckeditor/ckeditor5-core": "^31.0.0",
|
20
20
|
"@ckeditor/ckeditor5-dev-utils": "^25.4.0",
|
21
|
-
"@ckeditor/ckeditor5-editor-classic": "^
|
22
|
-
"@ckeditor/ckeditor5-engine": "^
|
23
|
-
"@ckeditor/ckeditor5-essentials": "^
|
24
|
-
"@ckeditor/ckeditor5-heading": "^
|
25
|
-
"@ckeditor/ckeditor5-markdown-gfm": "^
|
26
|
-
"@ckeditor/ckeditor5-paragraph": "^
|
27
|
-
"@ckeditor/ckeditor5-table": "^
|
28
|
-
"@ckeditor/ckeditor5-ui": "^
|
29
|
-
"@ckeditor/ckeditor5-utils": "^
|
21
|
+
"@ckeditor/ckeditor5-editor-classic": "^31.0.0",
|
22
|
+
"@ckeditor/ckeditor5-engine": "^31.0.0",
|
23
|
+
"@ckeditor/ckeditor5-essentials": "^31.0.0",
|
24
|
+
"@ckeditor/ckeditor5-heading": "^31.0.0",
|
25
|
+
"@ckeditor/ckeditor5-markdown-gfm": "^31.0.0",
|
26
|
+
"@ckeditor/ckeditor5-paragraph": "^31.0.0",
|
27
|
+
"@ckeditor/ckeditor5-table": "^31.0.0",
|
28
|
+
"@ckeditor/ckeditor5-ui": "^31.0.0",
|
29
|
+
"@ckeditor/ckeditor5-utils": "^31.0.0",
|
30
30
|
"webpack": "^4.43.0",
|
31
31
|
"webpack-cli": "^3.3.11"
|
32
32
|
},
|
package/src/sourceediting.js
CHANGED
@@ -154,6 +154,13 @@ export default class SourceEditing extends Plugin {
|
|
154
154
|
|
155
155
|
this.listenTo( editor, 'change:isReadOnly', ( evt, name, isReadOnly ) => this._handleReadOnlyMode( isReadOnly ) );
|
156
156
|
}
|
157
|
+
|
158
|
+
// Update the editor data while calling editor.getData() in the source editing mode.
|
159
|
+
editor.data.on( 'get', () => {
|
160
|
+
if ( this.isSourceEditingMode ) {
|
161
|
+
this._updateEditorData();
|
162
|
+
}
|
163
|
+
}, { priority: 'high' } );
|
157
164
|
}
|
158
165
|
|
159
166
|
/**
|
@@ -261,6 +268,29 @@ export default class SourceEditing extends Plugin {
|
|
261
268
|
const editor = this.editor;
|
262
269
|
const editingView = editor.editing.view;
|
263
270
|
|
271
|
+
this._updateEditorData();
|
272
|
+
|
273
|
+
editingView.change( writer => {
|
274
|
+
for ( const [ rootName ] of this._replacedRoots ) {
|
275
|
+
writer.removeClass( 'ck-hidden', editingView.document.getRoot( rootName ) );
|
276
|
+
}
|
277
|
+
} );
|
278
|
+
|
279
|
+
this._elementReplacer.restore();
|
280
|
+
|
281
|
+
this._replacedRoots.clear();
|
282
|
+
this._dataFromRoots.clear();
|
283
|
+
|
284
|
+
editingView.focus();
|
285
|
+
}
|
286
|
+
|
287
|
+
/**
|
288
|
+
* Updates the source data in all hidden editing roots.
|
289
|
+
*
|
290
|
+
* @private
|
291
|
+
*/
|
292
|
+
_updateEditorData() {
|
293
|
+
const editor = this.editor;
|
264
294
|
const data = {};
|
265
295
|
|
266
296
|
for ( const [ rootName, domSourceEditingElementWrapper ] of this._replacedRoots ) {
|
@@ -272,25 +302,11 @@ export default class SourceEditing extends Plugin {
|
|
272
302
|
if ( oldData !== newData ) {
|
273
303
|
data[ rootName ] = newData;
|
274
304
|
}
|
275
|
-
|
276
|
-
editingView.change( writer => {
|
277
|
-
const viewRoot = editingView.document.getRoot( rootName );
|
278
|
-
|
279
|
-
writer.removeClass( 'ck-hidden', viewRoot );
|
280
|
-
} );
|
281
305
|
}
|
282
306
|
|
283
|
-
this._elementReplacer.restore();
|
284
|
-
|
285
|
-
this._replacedRoots.clear();
|
286
|
-
|
287
|
-
this._dataFromRoots.clear();
|
288
|
-
|
289
307
|
if ( Object.keys( data ).length ) {
|
290
308
|
editor.data.set( data, { batchType: 'default' } );
|
291
309
|
}
|
292
|
-
|
293
|
-
editor.editing.view.focus();
|
294
310
|
}
|
295
311
|
|
296
312
|
/**
|
package/theme/sourceediting.css
CHANGED
@@ -8,31 +8,34 @@
|
|
8
8
|
@import "@ckeditor/ckeditor5-theme-lark/theme/mixins/_shadow.css";
|
9
9
|
|
10
10
|
.ck-source-editing-area {
|
11
|
-
|
12
|
-
width: 100%;
|
13
|
-
font-family: monospace;
|
11
|
+
position: relative;
|
14
12
|
}
|
15
13
|
|
16
14
|
.ck-source-editing-area::after,
|
17
15
|
.ck-source-editing-area textarea {
|
18
|
-
grid-area: 1/1;
|
19
16
|
padding: var(--ck-spacing-large);
|
20
17
|
margin: 0;
|
21
18
|
border: 1px solid transparent;
|
22
19
|
line-height: var(--ck-line-height-base);
|
23
20
|
font-size: var(--ck-font-size-normal);
|
21
|
+
font-family: monospace;
|
24
22
|
white-space: pre-wrap;
|
25
23
|
}
|
26
24
|
|
27
25
|
.ck-source-editing-area::after {
|
28
26
|
content: attr(data-value) " ";
|
29
27
|
visibility: hidden;
|
28
|
+
display: block;
|
30
29
|
}
|
31
30
|
|
32
31
|
.ck-source-editing-area textarea {
|
32
|
+
position: absolute;
|
33
|
+
width: 100%;
|
34
|
+
height: 100%;
|
33
35
|
resize: none;
|
34
36
|
outline: none;
|
35
37
|
overflow: hidden;
|
38
|
+
box-sizing: border-box;
|
36
39
|
|
37
40
|
border-color: var(--ck-color-base-border);
|
38
41
|
|