mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-23 12:45:51 +08:00
refactor(editor): move floating toolbar config into this repo
This commit is contained in:
parent
2ac5e860b1
commit
aad38fdd21
2
libraries/ckeditor/ckeditor.js
vendored
2
libraries/ckeditor/ckeditor.js
vendored
File diff suppressed because one or more lines are too long
2
libraries/ckeditor/ckeditor.js.map
vendored
2
libraries/ckeditor/ckeditor.js.map
vendored
File diff suppressed because one or more lines are too long
@ -1,10 +1,19 @@
|
|||||||
export function buildToolbarConfig() {
|
import options from "../../../services/options.js";
|
||||||
return buildClassicToolbar();
|
import utils from "../../../services/utils.js";
|
||||||
|
|
||||||
|
export function buildToolbarConfig(isClassicToolbar: boolean) {
|
||||||
|
if (isClassicToolbar) {
|
||||||
|
const multilineToolbar = utils.isDesktop() && options.get("textNoteEditorMultilineToolbar") === "true"
|
||||||
|
return buildClassicToolbar(multilineToolbar);
|
||||||
|
} else {
|
||||||
|
return buildFloatingToolbar();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildClassicToolbar() {
|
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 {
|
||||||
|
toolbar: {
|
||||||
items: [
|
items: [
|
||||||
'heading',
|
'heading',
|
||||||
'fontSize',
|
'fontSize',
|
||||||
@ -56,6 +65,60 @@ function buildClassicToolbar() {
|
|||||||
'markdownImport',
|
'markdownImport',
|
||||||
'cuttonote',
|
'cuttonote',
|
||||||
'findAndReplace'
|
'findAndReplace'
|
||||||
|
],
|
||||||
|
shouldNotGroupWhenFull: multilineToolbar
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildFloatingToolbar() {
|
||||||
|
return {
|
||||||
|
toolbar: {
|
||||||
|
items: [
|
||||||
|
'fontSize',
|
||||||
|
'bold',
|
||||||
|
'italic',
|
||||||
|
'underline',
|
||||||
|
'strikethrough',
|
||||||
|
'superscript',
|
||||||
|
'subscript',
|
||||||
|
'fontColor',
|
||||||
|
'fontBackgroundColor',
|
||||||
|
'code',
|
||||||
|
'link',
|
||||||
|
'removeFormat',
|
||||||
|
'internallink',
|
||||||
|
'cuttonote'
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
|
|
||||||
|
blockToolbar: [
|
||||||
|
'heading',
|
||||||
|
'|',
|
||||||
|
'bulletedList', 'numberedList', 'todoList',
|
||||||
|
'|',
|
||||||
|
'blockQuote', 'codeBlock', 'insertTable',
|
||||||
|
'footnote',
|
||||||
|
{
|
||||||
|
label: "Insert",
|
||||||
|
icon: "plus",
|
||||||
|
items: [
|
||||||
|
'internallink',
|
||||||
|
'includeNote',
|
||||||
|
'|',
|
||||||
|
'math',
|
||||||
|
'mermaid',
|
||||||
|
'horizontalLine',
|
||||||
|
'pageBreak'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
'|',
|
||||||
|
'outdent', 'indent',
|
||||||
|
'|',
|
||||||
|
'imageUpload',
|
||||||
|
'markdownImport',
|
||||||
|
'specialCharacters',
|
||||||
|
'findAndReplace'
|
||||||
|
]
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -184,17 +184,10 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
|
|||||||
|
|
||||||
this.watchdog.setCreator(async (elementOrData, editorConfig) => {
|
this.watchdog.setCreator(async (elementOrData, editorConfig) => {
|
||||||
logInfo("Creating new CKEditor");
|
logInfo("Creating new CKEditor");
|
||||||
const extraOpts = {};
|
|
||||||
if (isClassicEditor) {
|
|
||||||
extraOpts.toolbar = {
|
|
||||||
...buildToolbarConfig(),
|
|
||||||
shouldNotGroupWhenFull: utils.isDesktop() && options.get("textNoteEditorMultilineToolbar") === "true"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const editor = await editorClass.create(elementOrData, {
|
const editor = await editorClass.create(elementOrData, {
|
||||||
...editorConfig,
|
...editorConfig,
|
||||||
...extraOpts,
|
...buildToolbarConfig(),
|
||||||
htmlSupport: {
|
htmlSupport: {
|
||||||
allow: JSON.parse(options.get("allowedHtmlTags")),
|
allow: JSON.parse(options.get("allowedHtmlTags")),
|
||||||
styles: true,
|
styles: true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user