diff --git a/qt/aqt/editor.py b/qt/aqt/editor.py index e6db3b05f..f98e60d24 100644 --- a/qt/aqt/editor.py +++ b/qt/aqt/editor.py @@ -82,9 +82,7 @@ _html = """ }
-
- %s -
+
@@ -233,10 +231,13 @@ class Editor: _html % (bgcol, topbuts, tr.editing_show_duplicates()), css=[ "css/editor.css", + "css/editor-toolbar.css", ], js=[ "js/vendor/jquery.min.js", + "js/vendor/protobuf.min.js", "js/editor.js", + "js/editor-toolbar.js", ], context=self, default_css=False, diff --git a/ts/editor-toolbar/ButtonBar.svelte b/ts/editor-toolbar/ButtonBar.svelte new file mode 100644 index 000000000..fa8d980cb --- /dev/null +++ b/ts/editor-toolbar/ButtonBar.svelte @@ -0,0 +1,20 @@ + + + diff --git a/ts/editor-toolbar/ButtonBarOuter.svelte b/ts/editor-toolbar/ButtonBarOuter.svelte new file mode 100644 index 000000000..064d60c4c --- /dev/null +++ b/ts/editor-toolbar/ButtonBarOuter.svelte @@ -0,0 +1,17 @@ + + +
diff --git a/ts/editor-toolbar/ButtonItem.svelte b/ts/editor-toolbar/ButtonItem.svelte new file mode 100644 index 000000000..88b9f924b --- /dev/null +++ b/ts/editor-toolbar/ButtonItem.svelte @@ -0,0 +1,7 @@ + + +
  • diff --git a/ts/editor-toolbar/EditorToolbar.svelte b/ts/editor-toolbar/EditorToolbar.svelte index b433dc59f..e2231c458 100644 --- a/ts/editor-toolbar/EditorToolbar.svelte +++ b/ts/editor-toolbar/EditorToolbar.svelte @@ -1,10 +1,27 @@ - - + + + {#each leftButtons as leftButton} + {leftButton} + {/each} + -

    Test

    + + {#each rightButtons as rightButton} + + {/each} + +
    diff --git a/ts/editor-toolbar/LeftButton.svelte b/ts/editor-toolbar/LeftButton.svelte index e69de29bb..c2b9388d5 100644 --- a/ts/editor-toolbar/LeftButton.svelte +++ b/ts/editor-toolbar/LeftButton.svelte @@ -0,0 +1,20 @@ + + + + + + diff --git a/ts/editor-toolbar/RightButton.svelte b/ts/editor-toolbar/RightButton.svelte index e69de29bb..cf0803e39 100644 --- a/ts/editor-toolbar/RightButton.svelte +++ b/ts/editor-toolbar/RightButton.svelte @@ -0,0 +1,15 @@ + + + + + + + diff --git a/ts/editor-toolbar/_buttons.scss b/ts/editor-toolbar/_buttons.scss new file mode 100644 index 000000000..0ad2baf32 --- /dev/null +++ b/ts/editor-toolbar/_buttons.scss @@ -0,0 +1,51 @@ +.rainbow { + background-image: -webkit-gradient( + linear, + left top, + left bottom, + color-stop(0, #f77), + color-stop(50%, #7f7), + color-stop(100%, #77f) + ); +} + +button.linkb { + -webkit-appearance: none; + margin-bottom: -3px; + border: 0; + box-shadow: none; + padding: 0px 2px; + background: transparent; + + &:disabled { + opacity: 0.3; + cursor: not-allowed; + } + + .nightMode & > img { + filter: invert(180); + } +} + +button:focus { + outline: none; +} + +button.highlighted { + #topbutsleft & { + background-color: lightgrey; + + .nightMode & { + background: linear-gradient(0deg, #333333 0%, #434343 100%); + } + } + + #topbutsright & { + border-bottom: 3px solid black; + border-radius: 3px; + + .nightMode & { + border-bottom-color: white; + } + } +} diff --git a/ts/editor-toolbar/index.ts b/ts/editor-toolbar/index.ts index 2cf8f5122..20c838afb 100644 --- a/ts/editor-toolbar/index.ts +++ b/ts/editor-toolbar/index.ts @@ -1,19 +1,16 @@ import type { SvelteComponent } from "svelte"; -import { setupI18n } from "anki/i18n"; import { checkNightMode } from "anki/nightmode"; import EditorToolbarSvelte from "./EditorToolbar.svelte"; class EditorToolbar extends HTMLElement { component?: SvelteComponent; - async connectedCallback(): Promise { + connectedCallback(): void { const nightMode = checkNightMode(); - const i18n = await setupI18n(); this.component = new EditorToolbarSvelte({ target: this, props: { - i18n, nightMode, }, }); diff --git a/ts/editor/editor.scss b/ts/editor/editor.scss index a23c4bbfe..ce7081d47 100644 --- a/ts/editor/editor.scss +++ b/ts/editor/editor.scss @@ -29,97 +29,6 @@ padding: 0; } -#topbutsOuter { - display: flex; - flex-wrap: wrap; - justify-content: space-between; - - position: sticky; - top: 0; - left: 0; - z-index: 5; - padding: 2px; - - background: var(--bg-color); - font-size: 13px; -} - -.topbuts { - margin-bottom: 2px; - - & > * { - margin: 0 1px; - - &:first-child { - margin-left: 0; - } - - &:last-child { - margin-right: 0; - } - } -} - -.topbut { - display: inline-block; - width: 16px; - height: 16px; - margin-top: 4px; - vertical-align: -0.125em; -} - -.rainbow { - background-image: -webkit-gradient( - linear, - left top, - left bottom, - color-stop(0, #f77), - color-stop(50%, #7f7), - color-stop(100%, #77f) - ); -} - -button.linkb { - -webkit-appearance: none; - margin-bottom: -3px; - border: 0; - box-shadow: none; - padding: 0px 2px; - background: transparent; - - &:disabled { - opacity: 0.3; - cursor: not-allowed; - } - - .nightMode & > img { - filter: invert(180); - } -} - -button:focus { - outline: none; -} - -button.highlighted { - #topbutsleft & { - background-color: lightgrey; - - .nightMode & { - background: linear-gradient(0deg, #333333 0%, #434343 100%); - } - } - - #topbutsright & { - border-bottom: 3px solid black; - border-radius: 3px; - - .nightMode & { - border-bottom-color: white; - } - } -} - #dupes { position: sticky; bottom: 0;