Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

@joe-baudisch joe-baudisch Jul 21, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const cursor = this._editor.selection.getBookmark(3) as any
if (cursor['start'] && cursor['start'].startsWith('text()')) {
// do nothing because the cursor initially jumps back to first line with 'text()'
// while pasting in text from outside; moving to this bookmark after set content
// creates this cursor jump which should be avoided;
// if you paste in text from inside the editor or write text by keyboard
// the cursor starts with a paragraph tag created by TMCE like
// 'p[element_index]/text()[0]'
} else {
this._editor.setContent(isNullOrUndefined(value) ? '' : value);
try {
this._editor.selection.moveToBookmark(cursor);
} catch (e) {
/* ignore */
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ export class EditorComponent extends Events implements AfterViewInit, ControlVal

public writeValue(value: string | null): void {
if (this._editor && this._editor.initialized) {
const cursor = this._editor.selection.getBookmark(3);
this._editor.setContent(isNullOrUndefined(value) ? '' : value);
this._editor.selection.moveToBookmark(cursor);
} else {
this.initialValue = value === null ? undefined : value;
}
Expand Down