Skip to content

Commit 2f23731

Browse files
TINY-11911: Added new option and increased minor version.
1 parent fc82bda commit 2f23731

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@
4949
"webpack": "^5.75.0"
5050
},
5151
"dependencies": {},
52-
"version": "2.1.1-rc",
52+
"version": "2.2.1-rc",
5353
"name": "@tinymce/tinymce-webcomponent"
5454
}

src/main/ts/component/Editor.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ const configAttributes: Record<string, (v: string) => unknown> = {
7474
icons: parseString, // name of icon pack eg. 'material'
7575
icons_url: parseString, // url to icon pack js
7676
promotion: parseBooleanOrString, // boolean
77+
disabled: parseBooleanOrString, // boolean
7778
};
7879

7980
const configRenames: Record<string, string> = {
@@ -108,7 +109,7 @@ class TinyMceEditor extends HTMLElement {
108109
'on-ObjectSelected', 'on-SetContent', 'on-Show', 'on-Submit', 'on-Undo',
109110
'on-VisualAid' ];
110111

111-
return [ 'form', 'readonly', 'autofocus', 'placeholder' ].concat(nativeEvents).concat(tinyEvents);
112+
return [ 'form', 'readonly', 'autofocus', 'placeholder', 'disabled' ].concat(nativeEvents).concat(tinyEvents);
112113
}
113114

114115
constructor() {
@@ -355,6 +356,32 @@ class TinyMceEditor extends HTMLElement {
355356
}
356357
}
357358

359+
get disabled(): boolean {
360+
if (this._editor) {
361+
return this._editor.mode.get() === 'disabled';
362+
} else {
363+
return this.hasAttribute('disabled');
364+
}
365+
}
366+
367+
set disabled(value: boolean) {
368+
if (value) {
369+
if (this._editor && this._editor.mode.get() !== 'disabled') {
370+
this._editor.mode.set('disabled');
371+
}
372+
if (!this.hasAttribute('disabled')) {
373+
this.setAttribute('disabled', '');
374+
}
375+
} else {
376+
if (this._editor && this._editor.mode.get() === 'disabled') {
377+
this._editor.mode.set('design');
378+
}
379+
if (this.hasAttribute('disabled')) {
380+
this.removeAttribute('disabled');
381+
}
382+
}
383+
}
384+
358385
get placeholder(): string | null {
359386
return this.getAttribute('placeholder');
360387
}

0 commit comments

Comments
 (0)