mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-18 17:31:53 +08:00
feat(mobile): flatten editing toolbar
This commit is contained in:
parent
326c409e47
commit
4f09f1a266
@ -102,7 +102,9 @@ export function buildConfig() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function buildToolbarConfig(isClassicToolbar: boolean) {
|
export function buildToolbarConfig(isClassicToolbar: boolean) {
|
||||||
if (isClassicToolbar) {
|
if (utils.isMobile()) {
|
||||||
|
return buildMobileToolbar();
|
||||||
|
} else if (isClassicToolbar) {
|
||||||
const multilineToolbar = utils.isDesktop() && options.get("textNoteEditorMultilineToolbar") === "true";
|
const multilineToolbar = utils.isDesktop() && options.get("textNoteEditorMultilineToolbar") === "true";
|
||||||
return buildClassicToolbar(multilineToolbar);
|
return buildClassicToolbar(multilineToolbar);
|
||||||
} else {
|
} else {
|
||||||
@ -110,6 +112,29 @@ export function buildToolbarConfig(isClassicToolbar: boolean) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function buildMobileToolbar() {
|
||||||
|
const classicConfig = buildClassicToolbar(false);
|
||||||
|
const items = [];
|
||||||
|
|
||||||
|
for (const item of classicConfig.toolbar.items) {
|
||||||
|
if (typeof item === "object" && "items" in item) {
|
||||||
|
for (const subitem of item.items) {
|
||||||
|
items.push(subitem);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
items.push(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
...classicConfig,
|
||||||
|
toolbar: {
|
||||||
|
...classicConfig.toolbar,
|
||||||
|
items
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function buildClassicToolbar(multilineToolbar: boolean) {
|
export function buildClassicToolbar(multilineToolbar: boolean) {
|
||||||
// For nested toolbars, refer to https://ckeditor.com/docs/ckeditor5/latest/getting-started/setup/toolbar.html#grouping-toolbar-items-in-dropdowns-nested-toolbars.
|
// For nested toolbars, refer to https://ckeditor.com/docs/ckeditor5/latest/getting-started/setup/toolbar.html#grouping-toolbar-items-in-dropdowns-nested-toolbars.
|
||||||
return {
|
return {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user