ckeditor5 1.31.7 → 1.32.0

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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +34 -12
  3. data/lib/ckeditor5/rails/assets/webcomponent_bundle.rb +2 -21
  4. data/lib/ckeditor5/rails/version.rb +2 -2
  5. data/npm_package/dist/index.cjs +2 -0
  6. data/npm_package/dist/index.cjs.map +1 -0
  7. data/npm_package/dist/index.d.ts +1 -0
  8. data/npm_package/dist/index.mjs +723 -0
  9. data/npm_package/dist/index.mjs.map +1 -0
  10. data/npm_package/dist/src/components/context.d.ts +24 -0
  11. data/npm_package/dist/src/components/context.d.ts.map +1 -0
  12. data/npm_package/dist/src/components/editable.d.ts +34 -0
  13. data/npm_package/dist/src/components/editable.d.ts.map +1 -0
  14. data/npm_package/dist/src/components/editor/editor.d.ts +79 -0
  15. data/npm_package/dist/src/components/editor/editor.d.ts.map +1 -0
  16. data/npm_package/dist/src/components/editor/index.d.ts +3 -0
  17. data/npm_package/dist/src/components/editor/index.d.ts.map +1 -0
  18. data/npm_package/dist/src/components/editor/multiroot-editables-tracker.d.ts +36 -0
  19. data/npm_package/dist/src/components/editor/multiroot-editables-tracker.d.ts.map +1 -0
  20. data/npm_package/dist/src/components/index.d.ts +5 -0
  21. data/npm_package/dist/src/components/index.d.ts.map +1 -0
  22. data/npm_package/dist/src/components/ui-part.d.ts +2 -0
  23. data/npm_package/dist/src/components/ui-part.d.ts.map +1 -0
  24. data/npm_package/dist/src/helpers/exec-if-dom-ready.d.ts +7 -0
  25. data/npm_package/dist/src/helpers/exec-if-dom-ready.d.ts.map +1 -0
  26. data/npm_package/dist/src/helpers/index.d.ts +8 -0
  27. data/npm_package/dist/src/helpers/index.d.ts.map +1 -0
  28. data/npm_package/dist/src/helpers/inject-script.d.ts +8 -0
  29. data/npm_package/dist/src/helpers/inject-script.d.ts.map +1 -0
  30. data/npm_package/dist/src/helpers/is-safe-key.d.ts +8 -0
  31. data/npm_package/dist/src/helpers/is-safe-key.d.ts.map +1 -0
  32. data/npm_package/dist/src/helpers/load-async-css.d.ts +9 -0
  33. data/npm_package/dist/src/helpers/load-async-css.d.ts.map +1 -0
  34. data/npm_package/dist/src/helpers/load-async-imports.d.ts +25 -0
  35. data/npm_package/dist/src/helpers/load-async-imports.d.ts.map +1 -0
  36. data/npm_package/dist/src/helpers/resolve-config-element-references.d.ts +9 -0
  37. data/npm_package/dist/src/helpers/resolve-config-element-references.d.ts.map +1 -0
  38. data/npm_package/dist/src/helpers/uid.d.ts +7 -0
  39. data/npm_package/dist/src/helpers/uid.d.ts.map +1 -0
  40. data/npm_package/dist/src/index.d.ts +1 -0
  41. data/npm_package/dist/src/index.d.ts.map +1 -0
  42. data/npm_package/dist/vite.config.d.ts +3 -0
  43. data/npm_package/dist/vite.config.d.ts.map +1 -0
  44. data/npm_package/package.json +37 -0
  45. metadata +42 -7
  46. data/lib/ckeditor5/rails/assets/webcomponents/components/context.mjs +0 -123
  47. data/lib/ckeditor5/rails/assets/webcomponents/components/editable.mjs +0 -113
  48. data/lib/ckeditor5/rails/assets/webcomponents/components/editor.mjs +0 -778
  49. data/lib/ckeditor5/rails/assets/webcomponents/components/ui-part.mjs +0 -26
  50. data/lib/ckeditor5/rails/assets/webcomponents/utils.mjs +0 -235
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82acd8aed3945b110526357e8a2d81537723e8fedf0f0afd77a3023d10564a4b
4
- data.tar.gz: e7828da93ca6b2e189f49479d8cd6df9b072f107f618561c152ff6c8921a4641
3
+ metadata.gz: 5711a81301ba8f51e8774c9d6434d5cb7e644ab075b47f60f15ce4f7338abc9d
4
+ data.tar.gz: 27b1158764a5a9c8e8ccbb6beac060708dcec3935e0a54d79df46ab590a430d3
5
5
  SHA512:
6
- metadata.gz: b6cc7d2ca37aad69c87fbd5aaf3a0d98f9bc6630bba20734c1b920819a29f306ddb329a6889162dc9a36302f872f0e6b061ad9ee5c12c5783fc4374298369c26
7
- data.tar.gz: 5086896ab0ffd866de5c0b5213dff6a058e5891ba58eb66cdd65a3ae71606ad3f49293143100b52b9a6aa0f2a974f9001b75c7f211ef5eaf41c4c9aadcc252ed
6
+ metadata.gz: 1a348d16c7aaaf78e872494d173bc54b41390c84cede1616ff7009c68fc7e89e0a5b8bab07c0045101f054cced1281b3fa0c174c1fd41aea7c1707355518b991
7
+ data.tar.gz: b6a720b5b222742a543cb6a95774f2aac90694adb2dd3450a1c3656728289e2b7ee95033917cf1a3f13b5de9548a0bdb7d96981f62ed258f8708f5ebafe31f98
data/README.md CHANGED
@@ -13,7 +13,7 @@ CKEditor 5 Ruby on Rails integration gem. Provides seamless integration of CKEdi
13
13
  **Requirements:**
14
14
  * Ruby >= 2.5
15
15
  * Rails >= 5.0
16
-
16
+
17
17
  > [!IMPORTANT]
18
18
  > This gem is unofficial and not maintained by CKSource. For official CKEditor 5 documentation, visit [ckeditor.com](https://ckeditor.com/docs/ckeditor5/latest/). If you encounter any issues in editor, please report them on the [GitHub repository](https://github.com/ckeditor/ckeditor5/issues).
19
19
 
@@ -21,6 +21,17 @@ CKEditor 5 Ruby on Rails integration gem. Provides seamless integration of CKEdi
21
21
  <img src="docs/intro-classic-editor.png" alt="CKEditor 5 Classic Editor in Ruby on Rails application">
22
22
  </p>
23
23
 
24
+ ## Psst... 👀
25
+
26
+ If you're looking for similar stuff, check these out:
27
+
28
+ * [ckeditor5-phoenix](https://github.com/Mati365/ckeditor5-phoenix)
29
+ Seamless CKEditor 5 integration for Phoenix Framework. Plug & play support for LiveView forms with dynamic content, localization, and custom builds.
30
+
31
+ * [ckeditor5-livewire](https://github.com/Mati365/ckeditor5-livewire)
32
+ Drop-in CKEditor 5 solution for Laravel + Livewire apps. Works great with Blade forms too. Includes JS hooks, flexible config, and easy customization.
33
+
34
+
24
35
  ## Installation 🛠️
25
36
 
26
37
  Add this line to your application's Gemfile:
@@ -91,7 +102,7 @@ CKEditor5::Rails.configure do
91
102
 
92
103
  # Optionally, you can specify version of CKEditor 5 to use.
93
104
  # If it's not specified the default version specified in the gem will be used.
94
- # version '46.0.0'
105
+ # version '46.0.1'
95
106
 
96
107
  # Upload images to the server using the simple upload adapter, instead of Base64 encoding.
97
108
  # simple_upload_adapter
@@ -123,6 +134,7 @@ For extending CKEditor's functionality, refer to the [plugins directory](https:/
123
134
  ## Table of Contents 📚
124
135
 
125
136
  - [CKEditor 5 Rails Integration ✨](#ckeditor-5-rails-integration-)
137
+ - [Psst... 👀](#psst-)
126
138
  - [Installation 🛠️](#installation-️)
127
139
  - [Try Demos! 🎮 ✨](#try-demos--)
128
140
  - [Table of Contents 📚](#table-of-contents-)
@@ -201,6 +213,7 @@ For extending CKEditor's functionality, refer to the [plugins directory](https:/
201
213
  - [`editor-change` event](#editor-change-event)
202
214
  - [Inline event handling](#inline-event-handling)
203
215
  - [Gem Development 🛠](#gem-development-)
216
+ - [Building NPM package 📦](#building-npm-package-)
204
217
  - [Running tests 🧪](#running-tests-)
205
218
  - [Trademarks 📜](#trademarks-)
206
219
  - [License 📜](#license-)
@@ -216,7 +229,7 @@ You can create your own by defining it in the `config/initializers/ckeditor5.rb`
216
229
 
217
230
  CKEditor5::Rails.configure do
218
231
  # It's possible to override the default preset right in the initializer.
219
- version '46.0.0'
232
+ version '46.0.1'
220
233
 
221
234
  # New presets inherit properties from the default preset defined in the initializer.
222
235
  # In this example, the custom preset inherits everything from default but disables the menubar:
@@ -226,7 +239,7 @@ CKEditor5::Rails.configure do
226
239
 
227
240
  # In order to define preset from scratch, you can use the `inherit: false` option.
228
241
  presets.define :blank_preset, inherit: false do
229
- version '46.0.0'
242
+ version '46.0.1'
230
243
 
231
244
  # It tells the integration to fetch the newest security patches and bug fixes.
232
245
  # It may be disabled, but it's highly recommended to keep it enabled to avoid
@@ -348,7 +361,7 @@ Defines the version of CKEditor 5 to be used. The example below shows how to set
348
361
  CKEditor5::Rails.configure do
349
362
  # ... other configuration
350
363
 
351
- version '46.0.0'
364
+ version '46.0.1'
352
365
  end
353
366
  ```
354
367
 
@@ -360,7 +373,7 @@ In order to disable default patches, you can pass the `apply_patches: false` key
360
373
  CKEditor5::Rails.configure do
361
374
  # ... other configuration
362
375
 
363
- version '46.0.0', apply_patches: false
376
+ version '46.0.1', apply_patches: false
364
377
  end
365
378
  ```
366
379
 
@@ -1340,7 +1353,7 @@ It may be useful when you want to define a preset based on the current user or r
1340
1353
  class ApplicationController < ActionController::Base
1341
1354
  def show
1342
1355
  @preset = ckeditor5_preset do
1343
- version '46.0.0'
1356
+ version '46.0.1'
1344
1357
 
1345
1358
  toolbar :sourceEditing, :|, :bold, :italic, :underline, :strikethrough,
1346
1359
  :subscript, :superscript, :removeFormat, :|, :bulletedList, :numberedList,
@@ -1375,7 +1388,7 @@ If you want to override the preset defined in the initializer, you can search fo
1375
1388
  class ApplicationController < ActionController::Base
1376
1389
  def show
1377
1390
  @preset = ckeditor5_preset(:default).override do
1378
- version '46.0.0'
1391
+ version '46.0.1'
1379
1392
 
1380
1393
  toolbar :sourceEditing, :|, :bold, :italic, :underline, :strikethrough,
1381
1394
  :subscript, :superscript, :removeFormat, :|, :bulletedList, :numberedList,
@@ -1548,7 +1561,7 @@ In that scenario it's recommended to add `gpl` method to the initializer along w
1548
1561
 
1549
1562
  CKEditor5::Rails.configure do
1550
1563
  gpl
1551
- version '46.0.0'
1564
+ version '46.0.1'
1552
1565
  end
1553
1566
  ```
1554
1567
 
@@ -1917,13 +1930,13 @@ For example:
1917
1930
  ⚠️ Direct access of `instance` property of the web component. Keep in mind it's unsafe and may cause issues if the editor is not loaded yet.
1918
1931
 
1919
1932
  ```js
1920
- document.getElementById('editor').instance
1933
+ document.getElementById('editor').instance;
1921
1934
  ```
1922
1935
 
1923
1936
  👌 Accessing the editor instance using `instancePromise` property. It's a promise that resolves to the editor instance when the editor is ready.
1924
1937
 
1925
1938
  ```js
1926
- document.getElementById('editor').instancePromise.then(editor => {
1939
+ document.getElementById('editor').instancePromise.then((editor) => {
1927
1940
  console.log(editor);
1928
1941
  });
1929
1942
  ```
@@ -1931,7 +1944,7 @@ document.getElementById('editor').instancePromise.then(editor => {
1931
1944
  ✅ Accessing the editor through the `runAfterEditorReady` helper method. It's a safe way to access the editor instance when the editor is ready.
1932
1945
 
1933
1946
  ```js
1934
- document.getElementById('editor').runAfterEditorReady(editor => {
1947
+ document.getElementById('editor').runAfterEditorReady((editor) => {
1935
1948
  console.log(editor);
1936
1949
  });
1937
1950
  ```
@@ -2331,9 +2344,18 @@ If you want to contribute to the gem, you can clone the repository and run the f
2331
2344
  ```sh
2332
2345
  gem install bundler -v 2.5.22
2333
2346
  bundle install
2347
+ npm install
2334
2348
  bundle exec guard -g rails
2335
2349
  ```
2336
2350
 
2351
+ ### Building NPM package 📦
2352
+
2353
+ To build the NPM package, you can run the following command:
2354
+
2355
+ ```sh
2356
+ npm run build
2357
+ ```
2358
+
2337
2359
  ### Running tests 🧪
2338
2360
 
2339
2361
  You can run the tests using the following command:
@@ -8,33 +8,14 @@ module CKEditor5::Rails::Assets
8
8
  include ActionView::Helpers::TagHelper
9
9
  include Singleton
10
10
 
11
- WEBCOMPONENTS_PATH = File.join(__dir__, 'webcomponents')
12
- WEBCOMPONENTS_MODULES = [
13
- 'utils.mjs',
14
- 'components/editable.mjs',
15
- 'components/ui-part.mjs',
16
- 'components/editor.mjs',
17
- 'components/context.mjs'
18
- ].freeze
11
+ NPM_PACKAGE_PATH = File.join(__dir__, '..', '..', '..', '..', 'npm_package').freeze
19
12
 
20
13
  def source
21
- @source ||= compress_source(raw_source)
14
+ @source ||= File.read(File.join(NPM_PACKAGE_PATH, 'dist/index.cjs')).html_safe
22
15
  end
23
16
 
24
17
  def to_html(nonce: nil)
25
18
  tag.script(source, type: 'module', nonce: nonce)
26
19
  end
27
-
28
- private
29
-
30
- def raw_source
31
- @raw_source ||= WEBCOMPONENTS_MODULES.map do |file|
32
- File.read(File.join(WEBCOMPONENTS_PATH, file))
33
- end.join("\n")
34
- end
35
-
36
- def compress_source(code)
37
- Terser.new(compress: true, mangle: true).compile(code).html_safe
38
- end
39
20
  end
40
21
  end
@@ -2,8 +2,8 @@
2
2
 
3
3
  module CKEditor5
4
4
  module Rails
5
- VERSION = '1.31.7'
5
+ VERSION = '1.32.0'
6
6
 
7
- DEFAULT_CKEDITOR_VERSION = '46.0.0'
7
+ DEFAULT_CKEDITOR_VERSION = '46.0.1'
8
8
  end
9
9
  end
@@ -0,0 +1,2 @@
1
+ "use strict";var C=Object.create;var w=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var P=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty;var k=(s,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of x(t))!S.call(s,n)&&n!==e&&w(s,n,{get:()=>t[n],enumerable:!(i=A(t,n))||i.enumerable});return s};var g=(s,t,e)=>(e=s!=null?C(P(s)):{},k(t||!s||!s.__esModule?w(e,"default",{value:s,enumerable:!0}):e,s));function p(s){switch(document.readyState){case"loading":document.addEventListener("DOMContentLoaded",s,{once:!0});break;case"interactive":case"complete":setTimeout(s,0);break;default:console.warn("Unexpected document.readyState:",document.readyState),setTimeout(s,0)}}const b=new Map;function R(s){if(b.has(s))return b.get(s);const t=new Promise((e,i)=>{const n=document.createElement("script");n.src=s,n.onload=e,n.onerror=i,document.head.appendChild(n)});return b.set(s,t),t}function M(s){return typeof s=="string"&&s!=="__proto__"&&s!=="constructor"&&s!=="prototype"}function $(s){return Array.from(document.styleSheets).some(t=>t.href===s||t.href===new URL(s,window.location.href).href)}function y(s=[]){const t=s.map(e=>new Promise((i,n)=>{if($(e)){i();return}const r=document.createElement("link");r.rel="stylesheet",r.href=e,r.onerror=n,r.onload=()=>i(),document.head.appendChild(r)}));return Promise.all(t)}function h(s=[]){const t=async({url:i,import_name:n,import_as:r,window_name:o,stylesheets:a})=>{if(a?.length&&await y(a),o){let l=function(){return Object.prototype.hasOwnProperty.call(window,o)};if(i&&!l()&&await R(i),l()||window.dispatchEvent(new CustomEvent(`ckeditor:request-cjs-plugin:${o}`)),!l())throw new Error(`Plugin window['${o}'] not found in global scope. Please ensure the plugin is loaded before CKEditor initialization.`);return window[o]}const c=await import(n),d=c[r||"default"];if(!d)throw new Error(`Plugin "${r||"default"}" not found in the ESM module "${n}"! Available imports: ${Object.keys(c).join(", ")}! Consider changing "import_as" value.`);return d};function e(i){return t(typeof i=="string"?{import_name:"ckeditor5",import_as:i}:i)}return Promise.all(s.map(e))}function u(s){if(!s||typeof s!="object")return s;if(Array.isArray(s))return s.map(i=>u(i));const t=s;if(t.$element&&typeof t.$element=="string"){const i=document.querySelector(t.$element);return i||console.warn(`Element not found for selector: ${t.$element}`),i||null}const e=Object.create(null);for(const[i,n]of Object.entries(s))e[i]=u(n);return e}function I(){return Math.random().toString(36).substring(2)}class T extends HTMLElement{instance=null;instancePromise=Promise.withResolvers();#e=new Set;static get observedAttributes(){return["plugins","config"]}async connectedCallback(){try{p(()=>this.#t())}catch(t){console.error("Failed to initialize context:",t),this.dispatchEvent(new CustomEvent("context-error",{detail:t}))}}async attributeChangedCallback(t,e,i){e!==null&&e!==i&&await this.#t()}async disconnectedCallback(){this.instance&&(await this.instance.destroy(),this.instance=null)}registerEditor(t){this.#e.add(t)}unregisterEditor(t){this.#e.delete(t)}async#t(){this.instance&&(this.instancePromise=Promise.withResolvers(),await this.instance.destroy(),this.instance=null),window.dispatchEvent(new CustomEvent("ckeditor:context:attach:before",{detail:{element:this}}));const{Context:t,ContextWatchdog:e}=await import("ckeditor5"),i=await this.#i(),n=this.#s();window.dispatchEvent(new CustomEvent("ckeditor:context:attach",{detail:{config:n,element:this}})),this.instance=new e(t,{crashNumberLimit:10}),await this.instance.create({...n,plugins:i}),this.instance.on("itemError",(...r)=>{console.error("Context item error:",...r)}),this.instancePromise.resolve(this.instance),this.dispatchEvent(new CustomEvent("context-ready",{detail:this.instance})),await Promise.all([...this.#e].map(r=>r.reinitializeEditor()))}async#i(){const t=this.getAttribute("plugins");return h(t?JSON.parse(t):[])}#s(){const t=JSON.parse(this.getAttribute("config")||"{}");return u(t)}}customElements.define("ckeditor-context-component",T);class L extends HTMLElement{static get observedAttributes(){return["name"]}get name(){return this.getAttribute("name")||"editable"}get editableElement(){return this.querySelector("div")}connectedCallback(){p(()=>{const t=this.#e();if(!t)throw new Error("ckeditor-editable-component must be a child of ckeditor-component");if(this.innerHTML=`<div>${this.innerHTML}</div>`,this.style.display="block",t.isDecoupled())t.runAfterEditorReady(e=>{this.appendChild(e.ui.view[this.name].element)});else{if(!this.name)throw new Error('Editable component missing required "name" attribute');t.editables[this.name]=this}})}attributeChangedCallback(t,e,i){if(e!==i)if(t==="name"){if(!e)return;const n=this.#e();n&&(n.editables[i]=n.editables[e],delete n.editables[e])}else this.editableElement.setAttribute(t,i)}disconnectedCallback(){const t=this.#e();t&&delete t.editables[this.name]}#e(){return this.closest("ckeditor-component")||document.body.querySelector("ckeditor-component")}}customElements.define("ckeditor-editable-component",L);class E{#e;#t;constructor(t,e={}){return this.#e=t,this.#t=e,new Proxy(this,{get(i,n){return typeof i[n]=="function"?i[n].bind(i):i.#t[n]},set(i,n,r){return i.#t[n]!==r&&(i.attachRoot(n,r),i.#t[n]=r),!0},deleteProperty(i,n){return i.detachRoot(n),delete i.#t[n],!0}})}async attachRoot(t,e){return await this.detachRoot(t),this.#e.runAfterEditorReady(i=>{const{ui:n,editing:r,model:o}=i;i.addRoot(t,{isUndoable:!1,data:e.innerHTML});const a=o.document.getRoot(t);n.getEditableElement(t)&&i.detachEditable(a);const c=n.view.createEditable(t,e);n.addEditable(c),r.view.forceRender()})}async detachRoot(t){return this.#e.runAfterEditorReady(e=>{const i=e.model.document.getRoot(t);i&&(e.detachEditable(i),e.detachRoot(t,!0))})}getAll(){return this.#t}}class m extends HTMLElement{instancePromise=Promise.withResolvers();watchdog=null;instance=null;editables=Object.create({});#e="";#t=null;#i=null;#s=null;static get observedAttributes(){return["config","plugins","translations","type"]}static get inputAttributes(){return["name","required","value"]}get oneditorchange(){return this.#r("editorchange")}set oneditorchange(t){this.#o("editorchange",t)}get oneditorready(){return this.#r("editorready")}set oneditorready(t){this.#o("editorready",t)}get oneditorerror(){return this.#r("editorerror")}set oneditorerror(t){this.#o("editorerror",t)}#r(t){if(this.hasAttribute(`on${t}`)){const e=this.getAttribute(`on${t}`);if(!M(e))throw new Error(`Unsafe event handler attribute value: ${e}`);return window[e]||new Function("event",e)}return this[`#${t}Handler`]}#o(t,e){typeof e=="string"?this.setAttribute(`on${t}`,e):(this.removeAttribute(`on${t}`),this[`#${t}Handler`]=e)}connectedCallback(){this.#t=this.closest("ckeditor-context-component"),this.#e=this.innerHTML;try{p(async()=>{this.#t&&(await this.#t.instancePromise.promise,this.#t.registerEditor(this)),await this.reinitializeEditor()})}catch(t){console.error("Failed to initialize editor:",t);const e=new CustomEvent("editor-error",{detail:t});this.dispatchEvent(e),this.oneditorerror?.(e)}}async attributeChangedCallback(t,e,i){e!==null&&e!==i&&m.observedAttributes.includes(t)&&this.isConnected&&await this.reinitializeEditor()}async disconnectedCallback(){this.#t&&this.#t.unregisterEditor(this);try{await this.#d()}catch(t){console.error("Failed to destroy editor:",t)}}runAfterEditorReady(t){return this.instance?Promise.resolve(t(this.instance)):this.instancePromise.promise.then(t)}get#n(){switch(this.getAttribute("type")){case"ClassicEditor":return"textarea";default:return"div"}}get#a(){return this.#t?.instance}async#d(){this.#i&&await this.#a.remove(this.#i),await this.instance?.destroy(),this.watchdog?.destroy()}#l(){const t=JSON.parse(this.getAttribute("config")||"{}");return u(t)}async#u(t){await Promise.all([this.#b(),this.#w()]);let e=t;t instanceof E?e=t.getAll():typeof t!="string"&&(e=t.main);const i={...e instanceof HTMLElement&&{element:e},...typeof e=="string"&&{data:e},...e instanceof Object&&{editables:e}};window.dispatchEvent(new CustomEvent("ckeditor:attach:before",{detail:i}));const n=await this.#v(),[r,o]=await Promise.all([this.#y(),this.#E()]),a={...this.#l(),...o.length&&{translations:o},plugins:r};window.dispatchEvent(new CustomEvent("ckeditor:attach",{detail:{config:a,...i}})),console.warn("Initializing CKEditor with:",{config:a,watchdog:this.hasWatchdog(),context:this.#t});let c=null,d=null,l=null;if(this.#t)l=I(),await this.#a.add({creator:(f,v)=>n.create(f,v),id:l,sourceElementOrData:e,type:"editor",config:a}),d=this.#a.getItem(l);else if(this.hasWatchdog()){const{EditorWatchdog:f}=await import("ckeditor5");c=new f(n),await c.create(e,a),d=c.editor}else d=await n.create(e,a);return console.warn("CKEditor initialized:",{instance:d,watchdog:c,config:d.config._config}),{contextId:l,instance:d,watchdog:c}}async reinitializeEditor(){this.instance&&(this.instancePromise=Promise.withResolvers(),await this.#d(),this.instance=null),this.style.display="block",!this.isMultiroot()&&!this.isDecoupled()&&(this.innerHTML=`<${this.#n}>${this.#e}</${this.#n}>`,this.#p()),this.isMultiroot()?this.editables=new E(this,this.#h()):this.isDecoupled()?this.editables=null:this.editables=this.#h();try{const{watchdog:t,instance:e,contextId:i}=await this.#u(this.editables||this.#l().initialData||"");this.watchdog=t,this.instance=e,this.#i=i,this.#f(),this.#g(),this.#m(),this.instancePromise.resolve(this.instance);const n=new CustomEvent("editor-ready",{detail:this.instance});this.dispatchEvent(n),this.oneditorready?.(n)}catch(t){throw this.instancePromise.reject(t),t}}#m(){const t=i=>this.instance.getData({rootName:i}),e=()=>this.instance?.model.document.getRootNames().reduce((i,n)=>({...i,[n]:t(n)}),{});this.instance?.model.document.on("change:data",()=>{const i=new CustomEvent("editor-change",{detail:{editor:this.instance,data:e()},bubbles:!0});this.dispatchEvent(i),this.oneditorchange?.(i)})}isClassic(){return this.getAttribute("type")==="ClassicEditor"}isBallon(){return this.getAttribute("type")==="BalloonEditor"}isMultiroot(){return this.getAttribute("type")==="MultiRootEditor"}isDecoupled(){return this.getAttribute("type")==="DecoupledEditor"}hasWatchdog(){return this.getAttribute("watchdog")==="true"}#h(){if(this.isDecoupled())return{};if(this.isMultiroot())return[...this.querySelectorAll("ckeditor-editable-component")].reduce((i,n)=>{if(!n.name)throw new Error('Editable component missing required "name" attribute');return i[n.name]=n,i},Object.create(null));const t=this.querySelector(this.#n);if(!t)throw new Error(`No ${this.#n} element found`);return{main:t}}#p(){const t=this.querySelector("textarea");if(t)for(const e of m.inputAttributes)this.hasAttribute(e)&&t.setAttribute(e,this.getAttribute(e))}#f(){if(!this.instance)return;const t=this.querySelector("textarea");if(!t)return;const e=()=>{this.style.position="relative",t.innerHTML="",t.value=this.instance.getData(),t.tabIndex=-1,Object.assign(t.style,{display:"flex",position:"absolute",bottom:"0",left:"50%",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",margin:"0",padding:"0",border:"none"})};e(),this.instance.model.document.on("change:data",()=>{t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})),e()})}#g(){if(!this.isClassic()&&!this.isBallon())return;const{instance:t}=this,e=Number.parseInt(this.getAttribute("editable-height"),10);Number.isNaN(e)||t.editing.view.change(i=>{i.setStyle("height",`${e}px`,t.editing.view.document.getRoot())})}#c(){return this.#s||=JSON.parse(this.getAttribute("bundle"))}async#b(){await y(this.#c().stylesheets||[])}async#w(){const t=(this.#c().scripts||[]).filter(e=>!!e.window_name);await h(t)}async#E(){const t=this.#c().scripts.filter(e=>e.translation);return h(t)}async#y(){const t=this.getAttribute("plugins"),i=(t?JSON.parse(t):[]).map(n=>typeof n=="string"?{import_name:"ckeditor5",import_as:n}:n);return h(i)}async#v(){const t=await import("ckeditor5"),e=this.getAttribute("type");if(!e||!Object.prototype.hasOwnProperty.call(t,e))throw new Error(`Invalid editor type: ${e}`);return t[e]}}customElements.define("ckeditor-component",m);class O extends HTMLElement{connectedCallback(){p(async()=>{const t=this.getAttribute("name"),e=await this.#e().instancePromise.promise;this.appendChild(e.ui.view[t].element)})}#e(){return this.closest("ckeditor-component")||document.body.querySelector("ckeditor-component")}}customElements.define("ckeditor-ui-part-component",O);
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/helpers/exec-if-dom-ready.ts","../src/helpers/inject-script.ts","../src/helpers/is-safe-key.ts","../src/helpers/load-async-css.ts","../src/helpers/load-async-imports.ts","../src/helpers/resolve-config-element-references.ts","../src/helpers/uid.ts","../src/components/context.ts","../src/components/editable.ts","../src/components/editor/multiroot-editables-tracker.ts","../src/components/editor/editor.ts","../src/components/ui-part.ts"],"sourcesContent":["/**\n * Executes callback when DOM is ready.\n *\n * @param callback - Function to execute when DOM is ready.\n */\nexport function execIfDOMReady(callback: VoidFunction) {\n switch (document.readyState) {\n case 'loading':\n document.addEventListener('DOMContentLoaded', callback, { once: true });\n break;\n\n case 'interactive':\n case 'complete':\n setTimeout(callback, 0);\n break;\n\n default:\n console.warn('Unexpected document.readyState:', document.readyState);\n setTimeout(callback, 0);\n }\n}\n","const SCRIPT_LOAD_PROMISES = new Map();\n\n/**\n * Dynamically loads script files based on configuration.\n * Uses caching to avoid loading the same script multiple times.\n *\n * @param url - URL of the script to load\n */\nexport function injectScript(url: string) {\n if (SCRIPT_LOAD_PROMISES.has(url)) {\n return SCRIPT_LOAD_PROMISES.get(url);\n }\n\n const promise = new Promise((resolve, reject) => {\n const script = document.createElement('script');\n script.src = url;\n script.onload = resolve;\n script.onerror = reject;\n\n document.head.appendChild(script);\n });\n\n SCRIPT_LOAD_PROMISES.set(url, promise);\n return promise;\n}\n","/**\n * Checks if a key is safe to use in configuration objects to prevent prototype pollution\n *\n * @param key - Key name to check\n * @returns True if key is safe to use\n */\nexport function isSafeKey(key: string) {\n return (\n typeof key === 'string'\n && key !== '__proto__'\n && key !== 'constructor'\n && key !== 'prototype'\n );\n}\n","/**\n * Checks if stylesheet with given href already exists in document\n *\n * @param href - Stylesheet URL to check\n * @returns True if stylesheet already exists\n */\nfunction stylesheetExists(href: string) {\n return Array\n .from(document.styleSheets)\n .some(sheet =>\n sheet.href === href || sheet.href === new URL(href, window.location.href).href,\n );\n}\n\n/**\n * Dynamically loads CSS files based on configuration\n *\n * @param stylesheets - Array of CSS file URLs to load\n * @returns Array of promises for each CSS file load\n * @throws When CSS file loading fails\n */\nexport function loadAsyncCSS(stylesheets: string[] = []) {\n const promises = stylesheets.map(href =>\n new Promise<void>((resolve, reject) => {\n if (stylesheetExists(href)) {\n resolve();\n return;\n }\n\n const link = document.createElement('link');\n link.rel = 'stylesheet';\n link.href = href;\n\n link.onerror = reject;\n link.onload = () => resolve();\n\n document.head.appendChild(link);\n }),\n );\n\n return Promise.all(promises);\n}\n","import { injectScript } from './inject-script';\nimport { loadAsyncCSS } from './load-async-css';\n\n/**\n * Dynamically imports modules based on configuration\n *\n * @param imports - Array of import configurations\n * @param imports[].name - Name of inline plugin (for inline type)\n * @param imports[].code - Source code of inline plugin (for inline type)\n * @param imports[].import_name - Module path to import (for external type)\n * @param imports[].import_as - Name to import as (for external type)\n * @param imports[].window_name - Global window object name (for external type)\n * @param imports[].type - Type of import\n * @returns Array of loaded modules\n * @throws When plugin loading fails\n */\nexport function loadAsyncImports(imports: Array<AsyncImportRawDescription | string> = []) {\n const loadExternalPlugin = async ({ url, import_name, import_as, window_name, stylesheets }: AsyncImportRawDescription) => {\n if (stylesheets?.length) {\n await loadAsyncCSS(stylesheets);\n }\n\n if (window_name) {\n function isScriptPresent() {\n return Object.prototype.hasOwnProperty.call(window, window_name!);\n }\n\n if (url && !isScriptPresent()) {\n await injectScript(url);\n }\n\n if (!isScriptPresent()) {\n window.dispatchEvent(\n new CustomEvent(`ckeditor:request-cjs-plugin:${window_name}`),\n );\n }\n\n if (!isScriptPresent()) {\n throw new Error(\n `Plugin window['${window_name}'] not found in global scope. `\n + 'Please ensure the plugin is loaded before CKEditor initialization.',\n );\n }\n\n return (window as any)[window_name!];\n }\n\n const module = await import(import_name!);\n const imported = module[import_as || 'default'];\n\n if (!imported) {\n throw new Error(\n `Plugin \"${import_as || 'default'}\" not found in the ESM module `\n + `\"${import_name}\"! Available imports: ${Object.keys(module).join(', ')}! `\n + 'Consider changing \"import_as\" value.',\n );\n }\n\n return imported;\n };\n\n function uncompressImport(pkg: any) {\n if (typeof pkg === 'string') {\n return loadExternalPlugin({ import_name: 'ckeditor5', import_as: pkg });\n }\n\n return loadExternalPlugin(pkg);\n }\n\n return Promise.all(imports.map(uncompressImport));\n}\n\n/**\n * Type definition for plugin raw descriptor\n */\nexport type AsyncImportRawDescription = {\n url?: string;\n import_name?: string;\n import_as?: string;\n window_name?: string;\n stylesheets?: string[];\n};\n","/**\n * Resolves element references in configuration object.\n * Looks for objects with { $element: \"selector\" } format and replaces them with actual DOM elements.\n *\n * @param obj - Configuration object to process\n * @returns Processed configuration object with resolved element references\n */\nexport function resolveConfigElementReferences<T>(obj: T): T {\n if (!obj || typeof obj !== 'object') {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map(item => resolveConfigElementReferences(item)) as T;\n }\n\n const anyObj = obj as any;\n\n if (anyObj.$element && typeof anyObj.$element === 'string') {\n const element = document.querySelector(anyObj.$element);\n\n if (!element) {\n console.warn(`Element not found for selector: ${anyObj.$element}`);\n }\n\n return (element || null) as T;\n }\n\n const result = Object.create(null);\n\n for (const [key, value] of Object.entries(obj)) {\n result[key] = resolveConfigElementReferences(value);\n }\n\n return result as T;\n}\n","/**\n * Generates a unique identifier string\n *\n * @returns Random string that can be used as unique identifier\n */\nexport function uid() {\n return Math.random().toString(36).substring(2);\n}\n","import type { ContextWatchdog } from 'ckeditor5';\n\nimport { execIfDOMReady, loadAsyncImports, resolveConfigElementReferences } from 'src/helpers';\n\nimport type { CKEditorComponent } from './editor';\n\nexport class CKEditorContextComponent extends HTMLElement {\n instance: ContextWatchdog | null = null;\n\n instancePromise = Promise.withResolvers<ContextWatchdog>();\n\n #connectedEditors = new Set<CKEditorComponent>();\n\n static get observedAttributes() {\n return ['plugins', 'config'];\n }\n\n async connectedCallback() {\n try {\n execIfDOMReady(() => this.#initializeContext());\n }\n catch (error) {\n console.error('Failed to initialize context:', error);\n this.dispatchEvent(new CustomEvent('context-error', { detail: error }));\n }\n }\n\n async attributeChangedCallback(_: unknown, oldValue: string | null, newValue: string | null) {\n if (oldValue !== null && oldValue !== newValue) {\n await this.#initializeContext();\n }\n }\n\n async disconnectedCallback() {\n if (this.instance) {\n await this.instance.destroy();\n this.instance = null;\n }\n }\n\n /**\n * Register editor component with this context\n *\n * @param editor - Editor component to register.\n */\n registerEditor(editor: CKEditorComponent) {\n this.#connectedEditors.add(editor);\n }\n\n /**\n * Unregister editor component from this context\n *\n * @param editor - Editor component to unregister\n */\n unregisterEditor(editor: CKEditorComponent) {\n this.#connectedEditors.delete(editor);\n }\n\n /**\n * Initialize CKEditor context with shared configuration\n *\n * @private\n */\n async #initializeContext() {\n if (this.instance) {\n this.instancePromise = Promise.withResolvers<ContextWatchdog>();\n\n await this.instance.destroy();\n\n this.instance = null;\n }\n\n // Broadcast context initialization event\n window.dispatchEvent(\n new CustomEvent('ckeditor:context:attach:before', { detail: { element: this } }),\n );\n\n const { Context, ContextWatchdog } = await import('ckeditor5');\n const plugins = await this.#getPlugins();\n const config = this.#getConfig();\n\n // Broadcast context mounting event with configuration\n window.dispatchEvent(\n new CustomEvent('ckeditor:context:attach', { detail: { config, element: this } }),\n );\n\n this.instance = new ContextWatchdog(Context, {\n crashNumberLimit: 10,\n });\n\n await this.instance.create({\n ...config,\n plugins,\n });\n\n this.instance.on('itemError', (...args) => {\n console.error('Context item error:', ...args);\n });\n\n this.instancePromise.resolve(this.instance);\n this.dispatchEvent(new CustomEvent('context-ready', { detail: this.instance }));\n\n // Reinitialize connected editors.\n await Promise.all(\n [...this.#connectedEditors].map(editor => editor.reinitializeEditor()),\n );\n }\n\n async #getPlugins() {\n const raw = this.getAttribute('plugins');\n\n return loadAsyncImports(raw ? JSON.parse(raw) : []);\n }\n\n /**\n * Gets context configuration with resolved element references.\n *\n * @private\n */\n #getConfig() {\n const config = JSON.parse(this.getAttribute('config') || '{}');\n\n return resolveConfigElementReferences(config);\n }\n}\n\ncustomElements.define('ckeditor-context-component', CKEditorContextComponent);\n","import type { CKEditorComponent } from './editor';\n\nimport { execIfDOMReady } from '../helpers/exec-if-dom-ready';\n\nexport class CKEditorEditableComponent extends HTMLElement {\n /**\n * List of attributes that trigger updates when changed\n *\n * @static\n * @returns {string[]} Array of attribute names to observe\n */\n static get observedAttributes() {\n return ['name'];\n }\n\n /**\n * Gets the name of this editable region\n */\n get name() {\n return this.getAttribute('name') || 'editable';\n }\n\n /**\n * Gets the actual editable DOM element.\n */\n get editableElement() {\n return this.querySelector('div')!;\n }\n\n /**\n * Lifecycle callback when element is added to DOM\n * Sets up the editable element and registers it with the parent editor\n */\n connectedCallback() {\n execIfDOMReady(() => {\n const editorComponent = this.#queryEditorElement();\n\n if (!editorComponent) {\n throw new Error('ckeditor-editable-component must be a child of ckeditor-component');\n }\n\n this.innerHTML = `<div>${this.innerHTML}</div>`;\n this.style.display = 'block';\n\n if (editorComponent.isDecoupled()) {\n editorComponent.runAfterEditorReady((editor) => {\n this.appendChild((editor.ui.view as any)[this.name].element);\n });\n }\n else {\n if (!this.name) {\n throw new Error('Editable component missing required \"name\" attribute');\n }\n\n editorComponent.editables![this.name] = this;\n }\n });\n }\n\n /**\n * Lifecycle callback for attribute changes\n * Handles name changes and propagates other attributes to editable element\n */\n attributeChangedCallback(name: string, oldValue: string, newValue: string) {\n if (oldValue === newValue) {\n return;\n }\n\n if (name === 'name') {\n if (!oldValue) {\n return;\n }\n\n const editorComponent = this.#queryEditorElement();\n\n if (editorComponent) {\n editorComponent.editables![newValue] = editorComponent.editables![oldValue]!;\n delete editorComponent.editables![oldValue];\n }\n }\n else {\n this.editableElement.setAttribute(name, newValue!);\n }\n }\n\n /**\n * Lifecycle callback when element is removed\n * Un-registers this editable from the parent editor\n */\n disconnectedCallback() {\n const editorComponent = this.#queryEditorElement();\n\n if (editorComponent) {\n delete editorComponent.editables![this.name];\n }\n }\n\n /**\n * Finds the parent editor component\n */\n #queryEditorElement(): CKEditorComponent | null {\n return this.closest('ckeditor-component') || document.body.querySelector('ckeditor-component');\n }\n}\n\ncustomElements.define('ckeditor-editable-component', CKEditorEditableComponent);\n","import type { MultiRootEditor } from 'ckeditor5';\n\nimport type { CKEditorComponent } from './editor';\n\nexport class CKEditorMultiRootEditablesTracker {\n #editorElement: CKEditorComponent;\n #editables: Record<string, HTMLElement>;\n\n /**\n * Creates new tracker instance wrapped in a Proxy for dynamic property access\n *\n * @param editorElement - Parent editor component reference\n * @param initialEditables - Initial editable elements\n * @returns Proxy wrapping the tracker\n */\n constructor(\n editorElement: CKEditorComponent,\n initialEditables: Record<string, HTMLElement> = {},\n ) {\n this.#editorElement = editorElement;\n this.#editables = initialEditables;\n\n return new Proxy(this, {\n /**\n * Handles property access, returns class methods or editable elements\n *\n * @param target - The tracker instance\n * @param name - Property name being accessed\n */\n get(target: CKEditorMultiRootEditablesTracker, name: string) {\n if (typeof (target as any)[name] === 'function') {\n return (target as any)[name].bind(target);\n }\n\n return target.#editables[name];\n },\n\n /**\n * Handles setting new editable elements, triggers root attachment\n *\n * @param target - The tracker instance\n * @param name - Name of the editable root\n * @param element - Element to attach as editable\n */\n set(target: CKEditorMultiRootEditablesTracker, name: string, element: HTMLElement) {\n if (target.#editables[name] !== element) {\n void target.attachRoot(name, element);\n target.#editables[name] = element;\n }\n return true;\n },\n\n /**\n * Handles removing editable elements, triggers root detachment\n *\n * @param target - The tracker instance\n * @param name - Name of the root to remove\n */\n deleteProperty(target: CKEditorMultiRootEditablesTracker, name: string) {\n void target.detachRoot(name);\n delete target.#editables[name];\n\n return true;\n },\n });\n }\n\n /**\n * Attaches a new editable root to the editor.\n * Creates new editor root and binds UI elements.\n *\n * @param name - Name of the editable root\n * @param element - DOM element to use as editable\n * @returns Resolves when root is attached\n */\n async attachRoot(name: string, element: HTMLElement) {\n await this.detachRoot(name);\n\n return this.#editorElement.runAfterEditorReady<MultiRootEditor>((editor) => {\n const { ui, editing, model } = editor;\n\n editor.addRoot(name, {\n isUndoable: false,\n data: element.innerHTML,\n });\n\n const root = model.document.getRoot(name);\n\n if (ui.getEditableElement(name)) {\n editor.detachEditable(root!);\n }\n\n const editable = ui.view.createEditable(name, element);\n ui.addEditable(editable);\n editing.view.forceRender();\n });\n }\n\n /**\n * Detaches an editable root from the editor.\n * Removes editor root and cleans up UI bindings.\n *\n * @param name - Name of root to detach\n * @returns Resolves when root is detached\n */\n async detachRoot(name: string) {\n return this.#editorElement.runAfterEditorReady<MultiRootEditor>((editor) => {\n const root = editor.model.document.getRoot(name);\n\n if (root) {\n editor.detachEditable(root);\n editor.detachRoot(name, true);\n }\n });\n }\n\n /**\n * Gets all currently tracked editable elements\n *\n * @returns Map of all editable elements\n */\n getAll() {\n return this.#editables;\n }\n}\n","import type { Editor, EditorWatchdog, Watchdog } from 'ckeditor5';\n\nimport type { AsyncImportRawDescription } from '../../helpers';\nimport type { CKEditorContextComponent } from '../context';\nimport type { CKEditorEditableComponent } from '../editable';\n\nimport {\n execIfDOMReady,\n isSafeKey,\n loadAsyncCSS,\n loadAsyncImports,\n resolveConfigElementReferences,\n uid,\n} from '../../helpers';\nimport { CKEditorMultiRootEditablesTracker } from './multiroot-editables-tracker';\n\nexport class CKEditorComponent extends HTMLElement {\n instancePromise = Promise.withResolvers<Editor>();\n\n watchdog: Watchdog | null = null;\n\n instance: Editor | null = null;\n\n editables: Record<string, HTMLElement> | null = Object.create({});\n\n #initialHTML: string = '';\n\n #context: CKEditorContextComponent | null = null;\n\n #contextEditorId: string | null = null;\n\n #bundle: object | null = null;\n\n /**\n * List of attributes that trigger updates when changed.\n */\n static get observedAttributes() {\n return ['config', 'plugins', 'translations', 'type'];\n }\n\n /**\n * List of input attributes that trigger updates when changed.\n */\n static get inputAttributes() {\n return ['name', 'required', 'value'];\n }\n\n get oneditorchange() {\n return this.#getEventHandler('editorchange');\n }\n\n set oneditorchange(handler) {\n this.#setEventHandler('editorchange', handler);\n }\n\n get oneditorready() {\n return this.#getEventHandler('editorready');\n }\n\n set oneditorready(handler) {\n this.#setEventHandler('editorready', handler);\n }\n\n get oneditorerror() {\n return this.#getEventHandler('editorerror');\n }\n\n set oneditorerror(handler) {\n this.#setEventHandler('editorerror', handler);\n }\n\n /**\n * Gets event handler function from attribute or property\n *\n * @private\n * @param name - Event name without 'on' prefix\n * @returns Event handler or null\n */\n #getEventHandler(name: string): Function | null {\n if (this.hasAttribute(`on${name}`)) {\n const handler = this.getAttribute(`on${name}`)!;\n\n if (!isSafeKey(handler)) {\n throw new Error(`Unsafe event handler attribute value: ${handler}`);\n }\n\n // eslint-disable-next-line no-new-func\n return (window as any)[handler] || new Function('event', handler);\n }\n return (this as any)[`#${name}Handler`];\n }\n\n /**\n * Sets event handler function\n *\n * @private\n * @param name - Event name without 'on' prefix\n * @param handler - Event handler\n */\n #setEventHandler(name: string, handler: Function | null) {\n if (typeof handler === 'string') {\n this.setAttribute(`on${name}`, handler);\n }\n else {\n this.removeAttribute(`on${name}`);\n (this as any)[`#${name}Handler`] = handler;\n }\n }\n\n /**\n * Lifecycle callback when element is connected to DOM\n * Initializes the editor when DOM is ready\n *\n * @protected\n */\n connectedCallback() {\n this.#context = this.closest('ckeditor-context-component');\n this.#initialHTML = this.innerHTML;\n\n try {\n execIfDOMReady(async () => {\n if (this.#context) {\n await this.#context.instancePromise.promise;\n this.#context.registerEditor(this);\n }\n\n await this.reinitializeEditor();\n });\n }\n catch (error) {\n console.error('Failed to initialize editor:', error);\n\n const event = new CustomEvent('editor-error', { detail: error });\n\n this.dispatchEvent(event);\n this.oneditorerror?.(event);\n }\n }\n\n /**\n * Handles attribute changes and reinitializes editor if needed\n *\n * @protected\n * @param name - Name of changed attribute\n * @param oldValue - Previous attribute value\n * @param newValue - New attribute value\n */\n async attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {\n if (oldValue !== null\n && oldValue !== newValue\n && CKEditorComponent.observedAttributes.includes(name) && this.isConnected) {\n await this.reinitializeEditor();\n }\n }\n\n /**\n * Lifecycle callback when element is removed from DOM\n * Destroys the editor instance\n * @protected\n */\n async disconnectedCallback() {\n if (this.#context) {\n this.#context.unregisterEditor(this);\n }\n\n try {\n await this.#destroy();\n }\n catch (error) {\n console.error('Failed to destroy editor:', error);\n }\n }\n\n /**\n * Runs a callback after the editor is ready. It waits for editor\n * initialization if needed.\n *\n * @param callback - Callback to run\n */\n runAfterEditorReady<E extends Editor>(callback: (editor: E) => void): Promise<void> {\n if (this.instance) {\n return Promise.resolve(callback(this.instance as unknown as E));\n }\n\n return this.instancePromise.promise.then(callback as unknown as any);\n }\n\n /**\n * Determines appropriate editor element tag based on editor type\n */\n get #editorElementTag() {\n switch (this.getAttribute('type')) {\n case 'ClassicEditor':\n return 'textarea';\n\n default:\n return 'div';\n }\n }\n\n /**\n * Gets the CKEditor context instance if available.\n */\n get #contextWatchdog() {\n return this.#context?.instance;\n }\n\n /**\n * Destroys the editor instance and watchdog if available\n */\n async #destroy() {\n if (this.#contextEditorId) {\n await this.#contextWatchdog!.remove(this.#contextEditorId);\n }\n\n await this.instance?.destroy();\n this.watchdog?.destroy();\n }\n\n /**\n * Gets editor configuration with resolved element references\n */\n #getConfig() {\n const config = JSON.parse(this.getAttribute('config') || '{}');\n\n return resolveConfigElementReferences(config);\n }\n\n /**\n * Creates a new CKEditor instance\n */\n async #initializeEditor(editablesOrContent: Record<string, HTMLElement | string> | CKEditorMultiRootEditablesTracker | string | HTMLElement) {\n await Promise.all([\n this.#ensureStylesheetsInjected(),\n this.#ensureWindowScriptsInjected(),\n ]);\n\n // Depending on the type of the editor the content supplied on the first\n // argument is different. For ClassicEditor it's a element or string, for MultiRootEditor\n // it's an object with editables, for DecoupledEditor it's string.\n let content: any = editablesOrContent;\n\n if (editablesOrContent instanceof CKEditorMultiRootEditablesTracker) {\n content = editablesOrContent.getAll();\n }\n else if (typeof editablesOrContent !== 'string') {\n content = (editablesOrContent as any)['main'];\n }\n\n // Broadcast editor initialization event. It's good time to load add inline window plugins.\n const beforeInitEventDetails = {\n ...content instanceof HTMLElement && { element: content },\n ...typeof content === 'string' && { data: content },\n ...content instanceof Object && { editables: content },\n };\n\n window.dispatchEvent(\n new CustomEvent('ckeditor:attach:before', { detail: beforeInitEventDetails }),\n );\n\n // Start fetching constructor.\n const Editor = await this.#getEditorConstructor();\n const [plugins, translations] = await Promise.all([\n this.#getPlugins(),\n this.#getTranslations(),\n ]);\n\n const config = {\n ...this.#getConfig(),\n ...translations.length && {\n translations,\n },\n plugins,\n };\n\n // Broadcast editor mounting event. It's good time to map configuration.\n window.dispatchEvent(\n new CustomEvent('ckeditor:attach', { detail: { config, ...beforeInitEventDetails } }),\n );\n\n console.warn('Initializing CKEditor with:', { config, watchdog: this.hasWatchdog(), context: this.#context });\n\n // Initialize watchdog if needed\n let watchdog: EditorWatchdog | null = null;\n let instance: Editor | null = null;\n let contextId: string | null = null;\n\n if (this.#context) {\n contextId = uid();\n\n await this.#contextWatchdog!.add({\n creator: (_element, _config) => Editor.create(_element, _config),\n id: contextId,\n sourceElementOrData: content,\n type: 'editor',\n config,\n });\n\n instance = this.#contextWatchdog!.getItem(contextId) as Editor;\n }\n else if (this.hasWatchdog()) {\n // Let's create use with plain watchdog.\n const { EditorWatchdog } = await import('ckeditor5');\n watchdog = new EditorWatchdog(Editor);\n\n await watchdog.create(content, config);\n\n instance = watchdog.editor;\n }\n else {\n // Let's create the editor without watchdog.\n instance = await Editor.create(content, config);\n }\n\n console.warn('CKEditor initialized:', {\n instance,\n watchdog,\n config: (instance!.config as any)._config,\n });\n\n return {\n contextId,\n instance,\n watchdog,\n };\n }\n\n /**\n * Re-initializes the editor by destroying existing instance and creating new one\n *\n * @private\n * @returns {Promise<void>}\n */\n async reinitializeEditor() {\n if (this.instance) {\n this.instancePromise = Promise.withResolvers();\n\n await this.#destroy();\n\n this.instance = null;\n }\n\n this.style.display = 'block';\n\n if (!this.isMultiroot() && !this.isDecoupled()) {\n this.innerHTML = `<${this.#editorElementTag}>${this.#initialHTML}</${this.#editorElementTag}>`;\n this.#assignInputAttributes();\n }\n\n // Let's track changes in editables if it's a multiroot editor.\n if (this.isMultiroot()) {\n this.editables = new CKEditorMultiRootEditablesTracker(this, this.#queryEditables()) as unknown as Record<string, HTMLElement>;\n }\n else if (this.isDecoupled()) {\n this.editables = null;\n }\n else {\n this.editables = this.#queryEditables();\n }\n\n try {\n const { watchdog, instance, contextId } = await this.#initializeEditor(this.editables || this.#getConfig().initialData || '');\n\n this.watchdog = watchdog;\n this.instance = instance!;\n this.#contextEditorId = contextId;\n\n this.#setupContentSync();\n this.#setupEditableHeight();\n this.#setupDataChangeListener();\n\n this.instancePromise.resolve(this.instance!);\n\n // Broadcast editor ready event\n const event = new CustomEvent('editor-ready', { detail: this.instance });\n\n this.dispatchEvent(event);\n this.oneditorready?.(event);\n }\n catch (err) {\n this.instancePromise.reject(err);\n throw err;\n }\n }\n\n /**\n * Sets up data change listener that broadcasts content changes\n */\n #setupDataChangeListener() {\n const getRootContent = (rootName: string) => this.instance!.getData({ rootName });\n const getAllRoots = () =>\n this.instance?.model.document\n .getRootNames()\n .reduce((acc, rootName) => ({\n ...acc,\n [rootName]: getRootContent(rootName),\n }), {});\n\n this.instance?.model.document.on('change:data', () => {\n const event = new CustomEvent('editor-change', {\n detail: {\n editor: this.instance,\n data: getAllRoots(),\n },\n bubbles: true,\n });\n\n this.dispatchEvent(event);\n this.oneditorchange?.(event);\n });\n }\n\n /**\n * Checks if current editor is classic type\n */\n isClassic() {\n return this.getAttribute('type') === 'ClassicEditor';\n }\n\n /**\n * Checks if current editor is balloon type\n */\n isBallon() {\n return this.getAttribute('type') === 'BalloonEditor';\n }\n\n /**\n * Checks if current editor is multiroot type\n */\n isMultiroot() {\n return this.getAttribute('type') === 'MultiRootEditor';\n }\n\n /**\n * Checks if current editor is decoupled type\n */\n isDecoupled() {\n return this.getAttribute('type') === 'DecoupledEditor';\n }\n\n /**\n * Checks if current editor has watchdog enabled\n */\n hasWatchdog() {\n return this.getAttribute('watchdog') === 'true';\n }\n\n /**\n * Queries and validates editable elements\n */\n #queryEditables() {\n if (this.isDecoupled()) {\n return {};\n }\n\n if (this.isMultiroot()) {\n const editables = [...this.querySelectorAll('ckeditor-editable-component')] as CKEditorEditableComponent[];\n\n return editables.reduce((acc, element) => {\n if (!element.name) {\n throw new Error('Editable component missing required \"name\" attribute');\n }\n acc[element.name] = element;\n return acc;\n }, Object.create(null));\n }\n\n const mainEditable = this.querySelector(this.#editorElementTag);\n\n if (!mainEditable) {\n throw new Error(`No ${this.#editorElementTag} element found`);\n }\n\n return { main: mainEditable };\n }\n\n /**\n * Copies input-related attributes from component to the main editable element\n *\n * @private\n */\n #assignInputAttributes() {\n const textarea = this.querySelector('textarea');\n\n if (!textarea) {\n return;\n }\n\n for (const attr of CKEditorComponent.inputAttributes) {\n if (this.hasAttribute(attr)) {\n textarea.setAttribute(attr, this.getAttribute(attr)!);\n }\n }\n }\n\n /**\n * Sets up content sync between editor and textarea element.\n *\n * @private\n */\n #setupContentSync() {\n if (!this.instance) {\n return;\n }\n\n const textarea = this.querySelector('textarea');\n\n if (!textarea) {\n return;\n }\n\n // Initial sync\n const syncInput = () => {\n this.style.position = 'relative';\n\n textarea.innerHTML = '';\n textarea.value = this.instance!.getData();\n textarea.tabIndex = -1;\n\n Object.assign(textarea.style, {\n display: 'flex',\n position: 'absolute',\n bottom: '0',\n left: '50%',\n width: '1px',\n height: '1px',\n opacity: '0',\n pointerEvents: 'none',\n margin: '0',\n padding: '0',\n border: 'none',\n });\n };\n\n syncInput();\n\n // Listen for changes\n this.instance.model.document.on('change:data', () => {\n textarea.dispatchEvent(new Event('input', { bubbles: true }));\n textarea.dispatchEvent(new Event('change', { bubbles: true }));\n\n syncInput();\n });\n }\n\n /**\n * Sets up editable height for ClassicEditor\n *\n * @private\n */\n #setupEditableHeight() {\n if (!this.isClassic() && !this.isBallon()) {\n return;\n }\n\n const { instance } = this;\n const height = Number.parseInt(this.getAttribute('editable-height')!, 10);\n\n if (Number.isNaN(height)) {\n return;\n }\n\n instance!.editing.view.change((writer) => {\n writer.setStyle('height', `${height}px`, instance!.editing.view.document.getRoot()!);\n });\n }\n\n /**\n * Gets bundle JSON description from translations attribute\n */\n #getBundle(): BundleDescription {\n return this.#bundle ||= JSON.parse(this.getAttribute('bundle')!);\n }\n\n /**\n * Checks if all required stylesheets are injected. If not, inject.\n */\n async #ensureStylesheetsInjected() {\n await loadAsyncCSS(this.#getBundle().stylesheets || []);\n }\n\n /**\n * Checks if all required scripts are injected. If not, inject.\n */\n async #ensureWindowScriptsInjected() {\n const windowScripts = (this.#getBundle().scripts || []).filter(script => !!script.window_name);\n\n await loadAsyncImports(windowScripts);\n }\n\n /**\n * Loads translation modules\n */\n async #getTranslations() {\n const translations = this.#getBundle().scripts.filter(script => script.translation);\n\n return loadAsyncImports(translations);\n }\n\n /**\n * Loads plugin modules\n */\n async #getPlugins() {\n const raw = this.getAttribute('plugins');\n const items = raw ? JSON.parse(raw) : [];\n const mappedItems = items.map((item: any) =>\n typeof item === 'string'\n ? { import_name: 'ckeditor5', import_as: item }\n : item,\n );\n\n return loadAsyncImports(mappedItems);\n }\n\n /**\n * Gets editor constructor based on type attribute\n */\n async #getEditorConstructor() {\n const CKEditor = await import('ckeditor5');\n const editorType = this.getAttribute('type');\n\n if (!editorType || !Object.prototype.hasOwnProperty.call(CKEditor, editorType)) {\n throw new Error(`Invalid editor type: ${editorType}`);\n }\n\n return (CKEditor as any)[editorType] as EditorConstructor;\n }\n}\n\ntype EditorConstructor = {\n create: (...args: any[]) => Promise<Editor>;\n};\n\ntype BundleDescription = {\n stylesheets: string[];\n scripts: Array<AsyncImportRawDescription & {\n translation?: boolean;\n }>;\n};\n\ncustomElements.define('ckeditor-component', CKEditorComponent);\n","import type { CKEditorComponent } from './editor';\n\nimport { execIfDOMReady } from '../helpers';\n\nclass CKEditorUIPartComponent extends HTMLElement {\n /**\n * Lifecycle callback when element is added to DOM.\n * Adds the toolbar to the editor UI.\n */\n connectedCallback() {\n execIfDOMReady(async () => {\n const uiPart = this.getAttribute('name')!;\n const editor = await this.#queryEditorElement()!.instancePromise.promise;\n\n this.appendChild((editor.ui.view as any)[uiPart].element);\n });\n }\n\n /**\n * Finds the parent editor component.\n */\n #queryEditorElement(): CKEditorComponent | null {\n return this.closest('ckeditor-component') || document.body.querySelector('ckeditor-component');\n }\n}\n\ncustomElements.define('ckeditor-ui-part-component', CKEditorUIPartComponent);\n"],"names":["execIfDOMReady","callback","SCRIPT_LOAD_PROMISES","injectScript","url","promise","resolve","reject","script","isSafeKey","key","stylesheetExists","href","sheet","loadAsyncCSS","stylesheets","promises","link","loadAsyncImports","imports","loadExternalPlugin","import_name","import_as","window_name","isScriptPresent","module","imported","uncompressImport","pkg","resolveConfigElementReferences","obj","item","anyObj","element","result","value","uid","CKEditorContextComponent","#connectedEditors","#initializeContext","error","_","oldValue","newValue","editor","Context","ContextWatchdog","plugins","#getPlugins","config","#getConfig","args","raw","CKEditorEditableComponent","editorComponent","#queryEditorElement","name","CKEditorMultiRootEditablesTracker","#editorElement","#editables","editorElement","initialEditables","target","ui","editing","model","root","editable","CKEditorComponent","#initialHTML","#context","#contextEditorId","#bundle","#getEventHandler","handler","#setEventHandler","event","#destroy","#editorElementTag","#contextWatchdog","#initializeEditor","editablesOrContent","#ensureStylesheetsInjected","#ensureWindowScriptsInjected","content","beforeInitEventDetails","Editor","#getEditorConstructor","translations","#getTranslations","watchdog","instance","contextId","_element","_config","EditorWatchdog","#assignInputAttributes","#queryEditables","#setupContentSync","#setupEditableHeight","#setupDataChangeListener","err","getRootContent","rootName","getAllRoots","acc","mainEditable","textarea","attr","syncInput","height","writer","#getBundle","windowScripts","mappedItems","CKEditor","editorType","CKEditorUIPartComponent","uiPart"],"mappings":"wdAKO,SAASA,EAAeC,EAAwB,CACrD,OAAQ,SAAS,WAAA,CACf,IAAK,UACH,SAAS,iBAAiB,mBAAoBA,EAAU,CAAE,KAAM,GAAM,EACtE,MAEF,IAAK,cACL,IAAK,WACH,WAAWA,EAAU,CAAC,EACtB,MAEF,Q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