Skip to content

Commit 8a7e6db

Browse files
INT-3328: fix disabled property with ngmodel
1 parent 997c091 commit 8a7e6db

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

tinymce-angular-component/src/main/ts/editor/editor.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export class EditorComponent extends Events implements AfterViewInit, ControlVal
6868
@Input()
6969
public set readonly(val) {
7070
this._readonly = val;
71-
if (this._editor && this._editor.initialized) {
71+
if (this._editor) {
7272
setMode(this._editor, val ? 'readonly' : 'design');
7373
}
7474
}
@@ -80,7 +80,7 @@ export class EditorComponent extends Events implements AfterViewInit, ControlVal
8080
@Input()
8181
public set disabled(val) {
8282
this._disabled = val;
83-
if (this._editor && this._editor.initialized) {
83+
if (this._editor) {
8484
if (DisabledUtils.isDisabledOptionSupported()) {
8585
this._editor.options.set('disabled', val ?? false);
8686
} else {

tinymce-angular-component/src/test/ts/browser/DisabledPropertyTest.ts

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ import { Assertions } from '@ephox/agar';
22
import '../alien/InitTestEnvironment';
33

44
import { EditorComponent } from '../../../main/ts/public_api';
5-
import { describe, it } from '@ephox/bedrock-client';
5+
import { beforeEach, describe, it } from '@ephox/bedrock-client';
66
import { eachVersionContext, editorHook } from '../alien/TestHooks';
77
import { Editor } from 'tinymce';
8+
import { ComponentFixture, TestBed } from '@angular/core/testing';
9+
import { FormsModule } from '@angular/forms';
10+
import { Component, ViewChild } from '@angular/core';
811

912
describe('DisabledPropertyTest', () => {
1013
const getMode = (editor: Editor) => {
@@ -104,4 +107,35 @@ describe('DisabledPropertyTest', () => {
104107
assertDesignMode(editor);
105108
});
106109
});
110+
111+
eachVersionContext([ '7' ], () => {
112+
@Component({
113+
imports: [ FormsModule, EditorComponent ],
114+
template: `<editor [(ngModel)]="text" [disabled]="true" />`,
115+
standalone: true,
116+
selector: 'test-host-component'
117+
})
118+
class TestHostComponent {
119+
public text = '<h1>Hello World</h1>';
120+
@ViewChild(EditorComponent) public editorRef!: EditorComponent;
121+
}
122+
123+
let fixture: ComponentFixture<TestHostComponent>;
124+
let testHost: TestHostComponent;
125+
126+
beforeEach(async () => {
127+
await TestBed.configureTestingModule({
128+
imports: [ TestHostComponent ]
129+
}).compileComponents();
130+
131+
fixture = TestBed.createComponent(TestHostComponent);
132+
testHost = fixture.componentInstance;
133+
fixture.detectChanges();
134+
});
135+
136+
it('INT-3328: disabled property should work with [ngModel] when TinyMCE has been loaded before editor component has been created', () => {
137+
const tinyEditor = testHost.editorRef.editor;
138+
assertDisabledOption(tinyEditor!, true);
139+
});
140+
});
107141
});

0 commit comments

Comments
 (0)