improved HtmlEditor html source handling

This commit is contained in:
the-djmaze 2022-09-27 11:21:47 +02:00
parent 88f7b3d345
commit c64ec1b2d8
2 changed files with 5 additions and 7 deletions

View file

@ -476,7 +476,7 @@ class SquireUI
}
getData() {
return trimLines(this.squire.getHTML());
return 'source' == this.mode ? this.plain.value : trimLines(this.squire.getHTML());
}
setData(html) {

View file

@ -52,7 +52,7 @@ Object.assign(ko.bindingHandlers, {
fUpdateEditorValue();
};
if (ko.isObservable(fValue) && HtmlEditor) {
if (ko.isObservable(fValue)) {
editor = new HtmlEditor(element, fUpdateKoValue, fOnReady, fUpdateKoValue);
fValue.__fetchEditorValue = fUpdateKoValue;
@ -81,11 +81,9 @@ Object.assign(ko.bindingHandlers, {
onChange: value => fValue(value)
});
if (focused) {
focused.subscribe(value =>
element.addresses[value ? 'focus' : 'blur']()
);
}
focused?.subscribe(value =>
element.addresses[value ? 'focus' : 'blur']()
);
},
update: (element, fValueAccessor) => {
element.addresses.value = ko.unwrap(fValueAccessor());