set customName only on user input
This commit is contained in:
parent
e6e7d7d158
commit
54605c838b
14
edit/edit.js
14
edit/edit.js
|
@ -84,7 +84,7 @@ lazyInit();
|
||||||
nameEl.placeholder = t(usercss ? 'usercssEditorNamePlaceholder' : 'styleMissingName');
|
nameEl.placeholder = t(usercss ? 'usercssEditorNamePlaceholder' : 'styleMissingName');
|
||||||
nameEl.title = isCustomName ? t('customNameHint') : '';
|
nameEl.title = isCustomName ? t('customNameHint') : '';
|
||||||
nameEl.addEventListener('input', () => {
|
nameEl.addEventListener('input', () => {
|
||||||
updateName();
|
updateName(true);
|
||||||
resetEl.hidden = false;
|
resetEl.hidden = false;
|
||||||
});
|
});
|
||||||
resetEl.hidden = !style.customName;
|
resetEl.hidden = !style.customName;
|
||||||
|
@ -95,7 +95,7 @@ lazyInit();
|
||||||
// trying to make it undoable via Ctrl-Z
|
// trying to make it undoable via Ctrl-Z
|
||||||
if (!document.execCommand('insertText', false, style.name)) {
|
if (!document.execCommand('insertText', false, style.name)) {
|
||||||
nameEl.value = style.name;
|
nameEl.value = style.name;
|
||||||
updateName();
|
updateName(true);
|
||||||
}
|
}
|
||||||
style.customName = null; // to delete it from db
|
style.customName = null; // to delete it from db
|
||||||
resetEl.hidden = true;
|
resetEl.hidden = true;
|
||||||
|
@ -213,11 +213,13 @@ lazyInit();
|
||||||
editor.updateLivePreview();
|
editor.updateLivePreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateName() {
|
function updateName(isUserInput) {
|
||||||
if (!editor) return;
|
if (!editor) return;
|
||||||
const {value} = $('#name');
|
if (isUserInput) {
|
||||||
dirty.modify('name', style[nameTarget] || style.name, value);
|
const {value} = $('#name');
|
||||||
style[nameTarget] = value;
|
dirty.modify('name', style[nameTarget] || style.name, value);
|
||||||
|
style[nameTarget] = value;
|
||||||
|
}
|
||||||
updateTitle({});
|
updateTitle({});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user