question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

disabling formgroup with tinymce in material tab gives 'node cannot be null or undefined' bug.

See original GitHub issue

What is the current behavior? I am using my tinymce editor with form-group reactive forms. As per the standard functional flow in my component there is a global Redux state for progress bar with boolean value which gets set in HTTP interceptor accordingly. I subscribe to it and disable the form group when progress bar (means API call is in progress) is true and enable it when set to false. This piece of functionality have created subtle multiple bugs in my component. Getting ‘node cannot be null or undefined’ error, form-group with tinymce getting dirty automatically when changing tab, other form fields in form-group also not getting disabled in UI.

What is the expected behavior?

Expected behavior was to disable a whole formgroup without any repercussions.

Which versions of TinyMCE/TinyMCE-Angular, and which browser / OS are affected by this issue? Did this work in previous versions of TinyMCE or TinyMCE-Angular?

I am using version “@tinymce/tinymce-angular”: “^3.5.0” and “tinymce”: “^5.2.0”

below is my code:

<editor formControlName="inputEditor" [init]="defaultConfig"></editor>

private _disableFormsDuringProgress() { this.progressBar$.subscribe(res => { if (res) { this.emailForm.disable(); } else { this.emailForm.enable(); } }); }

public defaultConfig: any = { height: 700, base_url: '/tinymce', // Root for resources suffix: '.min', plugins: [ 'advlist autolink link image lists charmap print hr anchor pagebreak', 'searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking', 'table emoticons template paste help' ], browser_spellcheck: true, toolbar: 'undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify |' + ' bullist numlist outdent indent | link image | print media fullpage | ' + 'forecolor backcolor emoticons | help', menubar: 'file edit view insert format tools table help', branding: false, setup: (editor: any) => { this.editor = editor; this.editor.on('init', () => { this.editorLoaded = true; }); } };

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
airasyaqubcommented, Sep 9, 2020

@nischi the workaround I have implemented is to separate template and TS code and then manually update form control values with help of editor built in events. Here is the code

template

<div [hidden]="editorLoaded === false">
	<editor [disabled]="(progressBar$ | async)" [init]="defaultConfig"></editor>
	<mat-error *ngIf="emailForm.controls.inputEditor.invalid">
		Please enter email body without any script tag.
	</mat-error>
</div>

TS code

	public defaultConfig: any = {
		height: 700,
		base_url: '/tinymce', // Root for resources
		suffix: '.min',
		plugins: [
			'advlist autolink link image lists charmap print hr anchor pagebreak',
			'searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking',
			'table emoticons template paste help'
		],
		browser_spellcheck: true,
		toolbar: 'undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify |' +
			' bullist numlist outdent indent | link image | print media fullpage | ' +
			'forecolor backcolor emoticons | help',
		menubar: 'file edit view insert format tools table help',
		branding: false,
		setup: (editor: any) => {
			this.logService.debug('editor ===>', editor);
			this.editor = editor;
			editor.on('init', () => {
				this.editorLoaded = true;
				this.editor.setContent(this.emailForm.get('inputEditor').value);
			});

			// Change removed
			editor.on('Paste input Undo Redo keyup', function (e) {
				this.emailForm.get('inputEditor').setValue(this.editor.getContent());
				this.emailForm.get('inputEditor').updateValueAndValidity();
				this.emailForm.get('inputEditor').markAsDirty();
			}.bind(this));
		}
	};
1reaction
jscascacommented, Jun 24, 2020

We are still working on how to fix this issue. Sorry it’s taking so long

Read more comments on GitHub >

github_iconTop Results From Across the Web

TinyMCE not working: possible causes and fixes
There are a couple of possible reasons of TinyMCE not working - you can fix those easily and we prepared detailed instructions for...
Read more >
Angular mat-tab-group and tinyMCE - Stack Overflow
A simple solution is to lazy-load the mat-tab content. This forces the tab content (and tinyMCE) to be rebuild when you change tabs:...
Read more >
angular-formly
Custom link and controller functions per type and/or field, giving maximum control, without having to create a custom directive to add functionality.
Read more >
angular/angular - Gitter
@ghetolay I have no formGroup, nor formControlName, and I subscribe to the FormControl.valueChanges as if it were a formGroup, formArray, etc.
Read more >
Open Source Used In MSX Cloud UTD Service Pack 3.9.0
1.172 libgpg-error 1.26-2 ... 1.748 tinymce 5.2.0 ... that such additional attribution notices cannot be construed as modifying the License.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found