Skip to content

Commit 99d30a0

Browse files
joe baudischWojian Wang
authored andcommitted
integrating cursor fix
https: //github.com/tinymce/tinymce-angular/pull/371/commits/3c7808e44637cf63977adea04f5eebbfb189db83 Change-Id: I18e9bd812bb5f9e99765c2d8d9bb5fad199956f4 Reviewed-on: https://forge.frm2.tum.de/review/c/mlz/eln/frontend/+/36616 Reviewed-by: Wojian Wang <wojian.wang@frm2.tum.de> Tested-by: Wojian Wang <wojian.wang@frm2.tum.de>
1 parent 1d02e77 commit 99d30a0

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

libs/wysiwyg-editor/src/lib/components/wysiwyg-editor/wysiwyg-editor.component.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { BehaviorSubject } from 'rxjs';
1111
import {ControlValueAccessor, NgControl} from '@angular/forms';
1212
import {EditorComponent} from '@tinymce/tinymce-angular';
1313

14+
1415
@Component({
1516
selector: 'eworkbench-wysiwyg-editor',
1617
templateUrl: './wysiwyg-editor.component.html',
@@ -124,9 +125,13 @@ export class WysiwygEditorComponent implements ControlValueAccessor, OnInit, Aft
124125
this.editor?.editor.mode.set(this.disabledSubject.value ? 'readonly' : 'design');
125126
}
126127

127-
public writeValue(value: string | null): void {
128-
if (this.ngControl.value !== value) {
129-
this.onChanged(value);
128+
public writeValue(value: string): void {
129+
if (this.editor && this.editor.editor.initialized) {
130+
const cursor = this.editor.editor.selection.getBookmark(3);
131+
this.editor.editor.setContent(value);
132+
this.editor.editor.selection.moveToBookmark(cursor);
133+
} else {
134+
this.initialValue = value === null ? undefined : value;
130135
}
131136
}
132137

0 commit comments

Comments
 (0)