From 457618b6ca0422ac1961efbded2ffd169768ded9 Mon Sep 17 00:00:00 2001 From: TobiasTao <952530904@qq.com> Date: Sat, 15 May 2021 16:55:31 +0800 Subject: [PATCH] :sparkles: better editor layout --- media/main.css | 19 +++++----- media/main.js | 94 +++++++++++++++++++++++++++----------------------- 2 files changed, 60 insertions(+), 53 deletions(-) diff --git a/media/main.css b/media/main.css index 6063881..767de91 100644 --- a/media/main.css +++ b/media/main.css @@ -1,24 +1,23 @@ #vditor { - border: none; - padding-top: 30px; - height: 100vh; + border: none; + height: 100vh; } .vditor-reset { - font-size: 20px; - padding: 0 10% !important; + font-size: 20px; + padding: 0 5% !important; } .vditor-toolbar { - border: none; - background-color: transparent; + border: none; + background-color: transparent; } .vditor-outline { - border: none; - background-color: transparent; + border: none; + background-color: transparent; } .vditor-outline__title { - border: none; + border: none; } diff --git a/media/main.js b/media/main.js index cf699b3..27f2f14 100644 --- a/media/main.js +++ b/media/main.js @@ -11,6 +11,56 @@ const saveIcon = ''; + let toolbar = [ + 'emoji', + 'headings', + 'bold', + 'italic', + 'strike', + 'link', + '|', + 'list', + 'ordered-list', + 'check', + 'outdent', + 'indent', + '|', + 'quote', + 'line', + 'code', + 'inline-code', + 'insert-before', + 'insert-after', + '|', + 'table', + '|', + 'undo', + 'redo', + '|', + 'outline', + 'edit-mode', + { + name: 'save', + tipPosition: 'n', + tip: 'save', + icon: saveIcon, + className: 'right', + click: () => { + saveDoc(); + } + }, + { + name: 'more', + toolbar: ['both', 'preview', 'devtools'] + } + ].map((menuItem) => { + if (typeof menuItem === 'string') { + menuItem = { name: menuItem }; + } + menuItem.tipPosition = 's'; + return menuItem; + }); + let linkBase = ''; let editorTheme = {}; let imgConfig = {}; @@ -26,49 +76,7 @@ postition: 'left' }, cache: { enable: false }, - toolbar: [ - 'emoji', - 'headings', - 'bold', - 'italic', - 'strike', - 'link', - '|', - 'list', - 'ordered-list', - 'check', - 'outdent', - 'indent', - '|', - 'quote', - 'line', - 'code', - 'inline-code', - 'insert-before', - 'insert-after', - '|', - 'table', - '|', - 'undo', - 'redo', - '|', - 'outline', - 'edit-mode', - { - name: 'save', - tipPosition: 'n', - tip: 'save', - icon: saveIcon, - className: 'right', - click: () => { - saveDoc(); - } - }, - { - name: 'more', - toolbar: ['both', 'preview', 'devtools'] - } - ], + toolbar: toolbar, toolbarConfig: { pin: true },