mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-18 00:02:28 +08:00
feat(classic-toolbar): allow user to toggle multiline toolbar
This commit is contained in:
parent
65deec5861
commit
f30c35f0f2
@ -176,8 +176,16 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.watchdog.setCreator(async (elementOrData, editorConfig) => {
|
this.watchdog.setCreator(async (elementOrData, editorConfig) => {
|
||||||
|
const extraOpts = {};
|
||||||
|
if (isClassicEditor) {
|
||||||
|
extraOpts.toolbar = {
|
||||||
|
shouldNotGroupWhenFull: options.get("textNoteEditorMultilineToolbar") === "true"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const editor = await editorClass.create(elementOrData, {
|
const editor = await editorClass.create(elementOrData, {
|
||||||
...editorConfig,
|
...editorConfig,
|
||||||
|
...extraOpts,
|
||||||
htmlSupport: {
|
htmlSupport: {
|
||||||
allow: JSON.parse(options.get("allowedHtmlTags")),
|
allow: JSON.parse(options.get("allowedHtmlTags")),
|
||||||
styles: true,
|
styles: true,
|
||||||
|
@ -3,7 +3,7 @@ import utils from "../../../../services/utils.js";
|
|||||||
import OptionsWidget from "../options_widget.js";
|
import OptionsWidget from "../options_widget.js";
|
||||||
|
|
||||||
const TPL = `
|
const TPL = `
|
||||||
<div class="options-section">
|
<div class="options-section formatting-toolbar">
|
||||||
<h4>${t("editing.editor_type.label")}</h4>
|
<h4>${t("editing.editor_type.label")}</h4>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
@ -20,9 +20,23 @@ const TPL = `
|
|||||||
<strong>${t("editing.editor_type.fixed.title")}</strong>
|
<strong>${t("editing.editor_type.fixed.title")}</strong>
|
||||||
- ${t("editing.editor_type.fixed.description")}
|
- ${t("editing.editor_type.fixed.description")}
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" name="multiline-toolbar" />
|
||||||
|
Display the toolbar on multiple lines if it doesn't fit.
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>`;
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.formatting-toolbar div > div {
|
||||||
|
margin-left: 1em;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
`;
|
||||||
|
|
||||||
export default class EditorOptions extends OptionsWidget {
|
export default class EditorOptions extends OptionsWidget {
|
||||||
doRender() {
|
doRender() {
|
||||||
@ -33,10 +47,14 @@ export default class EditorOptions extends OptionsWidget {
|
|||||||
await this.updateOption('textNoteEditorType', newEditorType);
|
await this.updateOption('textNoteEditorType', newEditorType);
|
||||||
utils.reloadFrontendApp("editor type change");
|
utils.reloadFrontendApp("editor type change");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.$multilineToolbarCheckbox = this.$widget.find('input[name="multiline-toolbar"]');
|
||||||
|
this.$multilineToolbarCheckbox.on("change", () => this.updateCheckboxOption("textNoteEditorMultilineToolbar", this.$multilineToolbarCheckbox));
|
||||||
}
|
}
|
||||||
|
|
||||||
async optionsLoaded(options) {
|
async optionsLoaded(options) {
|
||||||
this.$widget.find(`input[name="editor-type"][value="${options.textNoteEditorType}"]`)
|
this.$widget.find(`input[name="editor-type"][value="${options.textNoteEditorType}"]`)
|
||||||
.prop("checked", "true");
|
.prop("checked", "true");
|
||||||
|
this.setCheckboxState(this.$multilineToolbarCheckbox, options.textNoteEditorMultilineToolbar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,7 @@ const ALLOWED_OPTIONS = new Set([
|
|||||||
'locale',
|
'locale',
|
||||||
'firstDayOfWeek',
|
'firstDayOfWeek',
|
||||||
'textNoteEditorType',
|
'textNoteEditorType',
|
||||||
|
'textNoteEditorMultilineToolbar',
|
||||||
'layoutOrientation',
|
'layoutOrientation',
|
||||||
'backgroundEffects',
|
'backgroundEffects',
|
||||||
'allowedHtmlTags' // Allow configuring HTML import tags
|
'allowedHtmlTags' // Allow configuring HTML import tags
|
||||||
|
@ -134,6 +134,7 @@ const defaultOptions: DefaultOption[] = [
|
|||||||
|
|
||||||
// Text note configuration
|
// Text note configuration
|
||||||
{ name: "textNoteEditorType", value: "ckeditor-balloon", isSynced: true },
|
{ name: "textNoteEditorType", value: "ckeditor-balloon", isSynced: true },
|
||||||
|
{ name: "textNoteEditorMultilineToolbar", value: "false", isSynced: true },
|
||||||
|
|
||||||
// HTML import configuration
|
// HTML import configuration
|
||||||
{ name: "layoutOrientation", value: "vertical", isSynced: false },
|
{ name: "layoutOrientation", value: "vertical", isSynced: false },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user