@ckeditor/ckeditor5-editor-classic
Version:
Classic editor implementation for CKEditor 5.
4 lines • 11.4 kB
JavaScript
/*!
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md.
*/(()=>{var e={21:e=>{"use strict";e.exports=function(e,t){Object.keys(t).forEach(function(i){e.setAttribute(i,t[i])})}},51:e=>{"use strict";e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},128:e=>{"use strict";var t={};e.exports=function(e,i){var o=function(e){if(void 0===t[e]){var i=document.querySelector(e);if(window.HTMLIFrameElement&&i instanceof window.HTMLIFrameElement)try{i=i.contentDocument.head}catch(e){i=null}t[e]=i}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(i)}},237:e=>{"use strict";e.exports=CKEditor5.dll},311:(e,t,i)=>{e.exports=i(237)("./src/ui.js")},584:(e,t,i)=>{e.exports=i(237)("./src/utils.js")},591:e=>{"use strict";var t=[];function i(e){for(var i=-1,o=0;o<t.length;o++)if(t[o].identifier===e){i=o;break}return i}function o(e,o){for(var n={},s=[],a=0;a<e.length;a++){var c=e[a],l=o.base?c[0]+o.base:c[0],d=n[l]||0,u="".concat(l," ").concat(d);n[l]=d+1;var h=i(u),p={css:c[1],media:c[2],sourceMap:c[3],supports:c[4],layer:c[5]};if(-1!==h)t[h].references++,t[h].updater(p);else{var f=r(p,o);o.byIndex=a,t.splice(a,0,{identifier:u,updater:f,references:1})}s.push(u)}return s}function r(e,t){var i=t.domAPI(t);i.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;i.update(e=t)}else i.remove()}}e.exports=function(e,r){var n=o(e=e||[],r=r||{});return function(e){e=e||[];for(var s=0;s<n.length;s++){var a=i(n[s]);t[a].references--}for(var c=o(e,r),l=0;l<n.length;l++){var d=i(n[l]);0===t[d].references&&(t[d].updater(),t.splice(d,1))}n=c}}},639:e=>{"use strict";var t,i=(t=[],function(e,i){return t[e]=i,t.filter(Boolean).join("\n")});function o(e,t,o,r){var n;if(o)n="";else{n="",r.supports&&(n+="@supports (".concat(r.supports,") {")),r.media&&(n+="@media ".concat(r.media," {"));var s=void 0!==r.layer;s&&(n+="@layer".concat(r.layer.length>0?" ".concat(r.layer):""," {")),n+=r.css,s&&(n+="}"),r.media&&(n+="}"),r.supports&&(n+="}")}if(e.styleSheet)e.styleSheet.cssText=i(t,n);else{var a=document.createTextNode(n),c=e.childNodes;c[t]&&e.removeChild(c[t]),c.length?e.insertBefore(a,c[t]):e.appendChild(a)}}var r={singleton:null,singletonCounter:0};e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=r.singletonCounter++,i=r.singleton||(r.singleton=e.insertStyleElement(e));return{update:function(e){o(i,t,!1,e)},remove:function(e){o(i,t,!0,e)}}}},662:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var o=i(758),r=i.n(o),n=i(935),s=i.n(n)()(r());s.push([e.id,".ck.ck-editor{position:relative}.ck.ck-editor .ck-editor__top .ck-sticky-panel .ck-toolbar{z-index:var(--ck-z-panel)}.ck.ck-editor__top .ck-sticky-panel .ck-sticky-panel__content{border:solid var(--ck-color-base-border);border-radius:0;border-width:1px 1px 0}.ck-rounded-corners .ck.ck-editor__top .ck-sticky-panel .ck-sticky-panel__content,.ck.ck-editor__top .ck-sticky-panel .ck-sticky-panel__content.ck-rounded-corners{border-radius:var(--ck-border-radius);border-bottom-left-radius:0;border-bottom-right-radius:0}.ck.ck-editor__top .ck-sticky-panel .ck-sticky-panel__content.ck-sticky-panel__content_sticky{border-bottom-width:1px}.ck.ck-editor__top .ck-sticky-panel .ck-sticky-panel__content .ck-menu-bar{border:0;border-bottom:1px solid var(--ck-color-base-border)}.ck.ck-editor__top .ck-sticky-panel .ck-sticky-panel__content .ck-toolbar{border:0}.ck.ck-editor__main>.ck-editor__editable{background:var(--ck-color-base-background);border-radius:0}.ck-rounded-corners .ck.ck-editor__main>.ck-editor__editable,.ck.ck-editor__main>.ck-editor__editable.ck-rounded-corners{border-radius:var(--ck-border-radius);border-top-left-radius:0;border-top-right-radius:0}.ck.ck-editor__main>.ck-editor__editable:not(.ck-focused){border-color:var(--ck-color-base-border)}",""]);const a=s},758:e=>{"use strict";e.exports=function(e){return e[1]}},782:(e,t,i)=>{e.exports=i(237)("./src/core.js")},783:(e,t,i)=>{e.exports=i(237)("./src/engine.js")},935:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var i="",o=void 0!==t[5];return t[4]&&(i+="@supports (".concat(t[4],") {")),t[2]&&(i+="@media ".concat(t[2]," {")),o&&(i+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),i+=e(t),o&&(i+="}"),t[2]&&(i+="}"),t[4]&&(i+="}"),i}).join("")},t.i=function(e,i,o,r,n){"string"==typeof e&&(e=[[null,e,void 0]]);var s={};if(o)for(var a=0;a<this.length;a++){var c=this[a][0];null!=c&&(s[c]=!0)}for(var l=0;l<e.length;l++){var d=[].concat(e[l]);o&&s[d[0]]||(void 0!==n&&(void 0===d[5]||(d[1]="@layer".concat(d[5].length>0?" ".concat(d[5]):""," {").concat(d[1],"}")),d[5]=n),i&&(d[2]?(d[1]="@media ".concat(d[2]," {").concat(d[1],"}"),d[2]=i):d[2]=i),r&&(d[4]?(d[1]="@supports (".concat(d[4],") {").concat(d[1],"}"),d[4]=r):d[4]="".concat(r)),t.push(d))}},t}}},t={};function i(o){var r=t[o];if(void 0!==r)return r.exports;var n=t[o]={id:o,exports:{}};return e[o](n,n.exports,i),n.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})};var o={};(()=>{"use strict";i.r(o),i.d(o,{ClassicEditor:()=>w,ClassicEditorUI:()=>n,ClassicEditorUIView:()=>k});var e=i(311),t=i(783),r=i(584);class n extends e.EditorUI{view;_toolbarConfig;_elementReplacer;constructor(t,i){super(t),this.view=i,this._toolbarConfig=(0,e.normalizeToolbarConfig)(t.config.get("toolbar")),this._elementReplacer=new r.ElementReplacer,this.listenTo(t.editing.view,"scrollToTheSelection",this._handleScrollToTheSelectionWithStickyPanel.bind(this))}get element(){return this.view.element}init(e){const t=this.editor,i=this.view,o=t.editing.view,r=i.editable,n=o.document.getRoot();r.name=n.rootName,i.render();const s=r.element;this.setEditableElement(r.name,s),i.editable.bind("isFocused").to(this.focusTracker),o.attachDomRoot(s),e&&this._elementReplacer.replace(e,this.element),this._initPlaceholder(),this._initToolbar(),i.menuBarView&&this.initMenuBar(i.menuBarView),this._initDialogPluginIntegration(),this._initContextualBalloonIntegration(),this.fire("ready")}destroy(){super.destroy();const e=this.view,t=this.editor.editing.view;this._elementReplacer.restore(),t.getDomRoot(e.editable.name)&&t.detachDomRoot(e.editable.name),e.destroy()}_initToolbar(){const e=this.view;e.stickyPanel.bind("isActive").to(this.focusTracker,"isFocused"),e.stickyPanel.limiterElement=e.element,e.stickyPanel.bind("viewportTopOffset").to(this,"viewportOffset",({visualTop:e})=>e||0),e.toolbar.fillFromConfig(this._toolbarConfig,this.componentFactory),this.addToolbar(e.toolbar)}_initPlaceholder(){const e=this.editor,i=e.editing.view,o=i.document.getRoot(),r=e.sourceElement;let n;const s=e.config.get("placeholder");s&&(n="string"==typeof s?s:s[this.view.editable.name]),!n&&r&&"textarea"===r.tagName.toLowerCase()&&(n=r.getAttribute("placeholder")),n&&(o.placeholder=n),(0,t.enableViewPlaceholder)({view:i,element:o,isDirectHost:!1,keepOnFocus:!0})}_initContextualBalloonIntegration(){if(!this.editor.plugins.has("ContextualBalloon"))return;const{stickyPanel:e}=this.view,t=this.editor.plugins.get("ContextualBalloon");t.on("getPositionOptions",t=>{const i=t.return;if(!i||!e.isSticky||!e.element)return;const o=new r.Rect(e.element).height,n="function"==typeof i.target?i.target():i.target,s="function"==typeof i.limiter?i.limiter():i.limiter;if(n&&s&&new r.Rect(n).height>=new r.Rect(s).height-o)return;const a={...i.viewportOffsetConfig},c=(a.top||0)+o;t.return={...i,viewportOffsetConfig:{...a,top:c}}},{priority:"low"});const i=()=>{t.visibleView&&t.updatePosition()};this.listenTo(e,"change:isSticky",i),this.listenTo(this.editor.ui,"change:viewportOffset",i)}_handleScrollToTheSelectionWithStickyPanel(e,t,i){const o=this.view.stickyPanel;if(o.isSticky){const e=new r.Rect(o.element).height;t.viewportOffset.top+=e}else{const e=()=>{this.editor.editing.view.scrollToTheSelection(i)};this.listenTo(o,"change:isSticky",e),setTimeout(()=>{this.stopListening(o,"change:isSticky",e)},20)}}_initDialogPluginIntegration(){if(!this.editor.plugins.has("Dialog"))return;const t=this.view.stickyPanel,i=this.editor.plugins.get("Dialog");i.on("show",()=>{const o=i.view;o.on("moveTo",(i,n)=>{if(!t.isSticky||o.wasMoved||o.isModal)return;const s=new r.Rect(t.contentPanelElement);n[1]<s.bottom+e.DialogView.defaultOffset&&(n[1]=s.bottom+e.DialogView.defaultOffset)},{priority:"high"})},{priority:"low"})}}var s=i(591),a=i.n(s),c=i(639),l=i.n(c),d=i(128),u=i.n(d),h=i(21),p=i.n(h),f=i(51),b=i.n(f),g=i(662),m={attributes:{"data-cke":!0}};m.setAttributes=p(),m.insert=u().bind(null,"head"),m.domAPI=l(),m.insertStyleElement=b();a()(g.A,m);g.A&&g.A.locals&&g.A.locals;class k extends e.BoxedEditorUIView{stickyPanel;toolbar;editable;constructor(t,i,o={}){super(t),this.stickyPanel=new e.StickyPanelView(t),this.toolbar=new e.ToolbarView(t,{shouldGroupWhenFull:o.shouldToolbarGroupWhenFull}),o.useMenuBar&&(this.menuBarView=new e.MenuBarView(t)),this.editable=new e.InlineEditableUIView(t,i,void 0,{label:o.label})}render(){super.render(),this.menuBarView?this.stickyPanel.content.addMany([this.menuBarView,this.toolbar]):this.stickyPanel.content.add(this.toolbar),this.top.add(this.stickyPanel),this.main.add(this.editable)}}var v=i(782);function y(e){return function(e){return"object"==typeof e&&null!==e}(e)&&1===e.nodeType&&!function(e){if("object"!=typeof e)return!1;if(null==e)return!1;if(null===Object.getPrototypeOf(e))return!0;if("[object Object]"!==Object.prototype.toString.call(e)){const t=e[Symbol.toStringTag];return null!=t&&(!!Object.getOwnPropertyDescriptor(e,Symbol.toStringTag)?.writable&&e.toString()===`[object ${t}]`)}let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}(e)}class w extends((0,v.ElementApiMixin)(v.Editor)){static get editorName(){return"ClassicEditor"}ui;constructor(e,t={}){if(!_(e)&&void 0!==t.initialData)throw new r.CKEditorError("editor-create-initial-data",null);super(t),this.config.define("menuBar.isVisible",!1),void 0===this.config.get("initialData")&&this.config.set("initialData",function(e){return _(e)?(0,r.getDataFromElement)(e):e}(e)),_(e)&&(this.sourceElement=e),this.model.document.createRoot();const i=!this.config.get("toolbar.shouldNotGroupWhenFull"),o=this.config.get("menuBar"),s=new k(this.locale,this.editing.view,{shouldToolbarGroupWhenFull:i,useMenuBar:o.isVisible,label:this.config.get("label")});this.ui=new n(this,s),(0,v.attachToForm)(this)}destroy(){return this.sourceElement&&this.updateSourceElement(),this.ui.destroy(),super.destroy()}static create(e,t={}){return new Promise(i=>{const o=new this(e,t);i(o.initPlugins().then(()=>o.ui.init(_(e)?e:null)).then(()=>o.data.init(o.config.get("initialData"))).then(()=>o.fire("ready")).then(()=>o))})}}function _(e){return y(e)}})(),(window.CKEditor5=window.CKEditor5||{}).editorClassic=o})();