mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-12 20:02:28 +08:00
Merge remote-tracking branch 'origin/master' into develop
This commit is contained in:
commit
edc6b983ac
@ -31,13 +31,26 @@ const TPL = `\
|
|||||||
align-items: flex-end;
|
align-items: flex-end;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
left: 0;
|
||||||
bottom: 0;
|
|
||||||
right: 0;
|
right: 0;
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
|
overscroll-behavior: none;
|
||||||
z-index: 500;
|
z-index: 500;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 991px) {
|
||||||
|
body.mobile .classic-toolbar-widget.visible {
|
||||||
|
bottom: calc(var(--tab-bar-height) + var(--launcher-pane-height) + var(--mobile-bottom-offset));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 991px) {
|
||||||
|
body.mobile .classic-toolbar-widget.visible {
|
||||||
|
bottom: 0;
|
||||||
|
left: 25%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
body.mobile .classic-toolbar-widget.dropdown-active {
|
body.mobile .classic-toolbar-widget.dropdown-active {
|
||||||
height: 50vh;
|
height: 50vh;
|
||||||
}
|
}
|
||||||
@ -64,6 +77,9 @@ const TPL = `\
|
|||||||
* The ribbon item is active by default for text notes, as long as they are not in read-only mode.
|
* The ribbon item is active by default for text notes, as long as they are not in read-only mode.
|
||||||
*/
|
*/
|
||||||
export default class ClassicEditorToolbar extends NoteContextAwareWidget {
|
export default class ClassicEditorToolbar extends NoteContextAwareWidget {
|
||||||
|
|
||||||
|
private observer: MutationObserver;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.observer = new MutationObserver((e) => this.#onDropdownStateChanged(e));
|
this.observer = new MutationObserver((e) => this.#onDropdownStateChanged(e));
|
||||||
@ -83,7 +99,7 @@ export default class ClassicEditorToolbar extends NoteContextAwareWidget {
|
|||||||
|
|
||||||
if (utils.isMobile()) {
|
if (utils.isMobile()) {
|
||||||
// The virtual keyboard obscures the editing toolbar so we have to reposition by calculating the height of the keyboard.
|
// The virtual keyboard obscures the editing toolbar so we have to reposition by calculating the height of the keyboard.
|
||||||
window.visualViewport.addEventListener("resize", () => this.#adjustPosition());
|
window.visualViewport?.addEventListener("resize", () => this.#adjustPosition());
|
||||||
window.addEventListener("scroll", () => this.#adjustPosition());
|
window.addEventListener("scroll", () => this.#adjustPosition());
|
||||||
|
|
||||||
// Observe when a dropdown is expanded to apply a style that allows the dropdown to be visible, since we can't have the element both visible and the toolbar scrollable.
|
// Observe when a dropdown is expanded to apply a style that allows the dropdown to be visible, since we can't have the element both visible and the toolbar scrollable.
|
||||||
@ -95,13 +111,13 @@ export default class ClassicEditorToolbar extends NoteContextAwareWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#onDropdownStateChanged(e) {
|
#onDropdownStateChanged(e: MutationRecord[]) {
|
||||||
const dropdownActive = e.map((e) => e.target.ariaExpanded === "true").reduce((acc, e) => acc && e);
|
const dropdownActive = e.map((e) => (e.target as any).ariaExpanded === "true").reduce((acc, e) => acc && e);
|
||||||
this.$widget[0].classList.toggle("dropdown-active", dropdownActive);
|
this.$widget[0].classList.toggle("dropdown-active", dropdownActive);
|
||||||
}
|
}
|
||||||
|
|
||||||
#adjustPosition() {
|
#adjustPosition() {
|
||||||
let bottom = window.innerHeight - window.visualViewport.height;
|
let bottom = window.innerHeight - (window.visualViewport?.height || 0);
|
||||||
|
|
||||||
if (bottom === 0) {
|
if (bottom === 0) {
|
||||||
// The keyboard is not visible, align it to the launcher bar instead.
|
// The keyboard is not visible, align it to the launcher bar instead.
|
||||||
@ -121,18 +137,25 @@ export default class ClassicEditorToolbar extends NoteContextAwareWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async #shouldDisplay() {
|
async #shouldDisplay() {
|
||||||
if (options.get("textNoteEditorType") !== "ckeditor-classic") {
|
if (utils.isDesktop() && options.get("textNoteEditorType") !== "ckeditor-classic") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.note.type !== "text") {
|
if (!this.note || this.note.type !== "text") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await this.noteContext.isReadOnly()) {
|
if (await this.noteContext?.isReadOnly()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async refreshWithNote() {
|
||||||
|
if (utils.isMobile()) {
|
||||||
|
this.toggleExt(await this.#shouldDisplay());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -136,7 +136,7 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
|
|||||||
|
|
||||||
async initEditor() {
|
async initEditor() {
|
||||||
await libraryLoader.requireLibrary(libraryLoader.CKEDITOR);
|
await libraryLoader.requireLibrary(libraryLoader.CKEDITOR);
|
||||||
const isClassicEditor = options.get("textNoteEditorType") === "ckeditor-classic";
|
const isClassicEditor = utils.isMobile() || options.get("textNoteEditorType") === "ckeditor-classic";
|
||||||
const editorClass = isClassicEditor ? CKEditor.DecoupledEditor : CKEditor.BalloonEditor;
|
const editorClass = isClassicEditor ? CKEditor.DecoupledEditor : CKEditor.BalloonEditor;
|
||||||
|
|
||||||
const codeBlockLanguages = buildListOfLanguages();
|
const codeBlockLanguages = buildListOfLanguages();
|
||||||
@ -186,7 +186,7 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
|
|||||||
const extraOpts = {};
|
const extraOpts = {};
|
||||||
if (isClassicEditor) {
|
if (isClassicEditor) {
|
||||||
extraOpts.toolbar = {
|
extraOpts.toolbar = {
|
||||||
shouldNotGroupWhenFull: options.get("textNoteEditorMultilineToolbar") === "true"
|
shouldNotGroupWhenFull: utils.isDesktop() && options.get("textNoteEditorMultilineToolbar") === "true"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,14 +230,7 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
|
|||||||
$classicToolbarWidget[0].appendChild(editor.ui.view.toolbar.element);
|
$classicToolbarWidget[0].appendChild(editor.ui.view.toolbar.element);
|
||||||
|
|
||||||
if (utils.isMobile()) {
|
if (utils.isMobile()) {
|
||||||
this.$editor.on("focus", (e) => {
|
$classicToolbarWidget.addClass("visible");
|
||||||
$classicToolbarWidget.addClass("visible");
|
|
||||||
});
|
|
||||||
|
|
||||||
// Hide the formatting toolbar
|
|
||||||
this.$editor.on("focusout", (e) => {
|
|
||||||
this.$editor[0].focus();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,6 +45,8 @@ body {
|
|||||||
--native-titlebar-foreground: var(--main-text-color);
|
--native-titlebar-foreground: var(--main-text-color);
|
||||||
--native-titlebar-darwin-x-offset: 10;
|
--native-titlebar-darwin-x-offset: 10;
|
||||||
--native-titlebar-darwin-y-offset: 12;
|
--native-titlebar-darwin-y-offset: 12;
|
||||||
|
--launcher-pane-height: 53px;
|
||||||
|
--tab-bar-height: 40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.mobile .desktop-only {
|
body.mobile .desktop-only {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user