2021-10-18 14:01:15 +02:00
|
|
|
<!--
|
|
|
|
Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
-->
|
|
|
|
<script context="module" lang="ts">
|
Move away from Bazel (#2202)
(for upgrading users, please see the notes at the bottom)
Bazel brought a lot of nice things to the table, such as rebuilds based on
content changes instead of modification times, caching of build products,
detection of incorrect build rules via a sandbox, and so on. Rewriting the build
in Bazel was also an opportunity to improve on the Makefile-based build we had
prior, which was pretty poor: most dependencies were external or not pinned, and
the build graph was poorly defined and mostly serialized. It was not uncommon
for fresh checkouts to fail due to floating dependencies, or for things to break
when trying to switch to an older commit.
For day-to-day development, I think Bazel served us reasonably well - we could
generally switch between branches while being confident that builds would be
correct and reasonably fast, and not require full rebuilds (except on Windows,
where the lack of a sandbox and the TS rules would cause build breakages when TS
files were renamed/removed).
Bazel achieves that reliability by defining rules for each programming language
that define how source files should be turned into outputs. For the rules to
work with Bazel's sandboxing approach, they often have to reimplement or
partially bypass the standard tools that each programming language provides. The
Rust rules call Rust's compiler directly for example, instead of using Cargo,
and the Python rules extract each PyPi package into a separate folder that gets
added to sys.path.
These separate language rules allow proper declaration of inputs and outputs,
and offer some advantages such as caching of build products and fine-grained
dependency installation. But they also bring some downsides:
- The rules don't always support use-cases/platforms that the standard language
tools do, meaning they need to be patched to be used. I've had to contribute a
number of patches to the Rust, Python and JS rules to unblock various issues.
- The dependencies we use with each language sometimes make assumptions that do
not hold in Bazel, meaning they either need to be pinned or patched, or the
language rules need to be adjusted to accommodate them.
I was hopeful that after the initial setup work, things would be relatively
smooth-sailing. Unfortunately, that has not proved to be the case. Things
frequently broke when dependencies or the language rules were updated, and I
began to get frustrated at the amount of Anki development time I was instead
spending on build system upkeep. It's now about 2 years since switching to
Bazel, and I think it's time to cut losses, and switch to something else that's
a better fit.
The new build system is based on a small build tool called Ninja, and some
custom Rust code in build/. This means that to build Anki, Bazel is no longer
required, but Ninja and Rust need to be installed on your system. Python and
Node toolchains are automatically downloaded like in Bazel.
This new build system should result in faster builds in some cases:
- Because we're using cargo to build now, Rust builds are able to take advantage
of pipelining and incremental debug builds, which we didn't have with Bazel.
It's also easier to override the default linker on Linux/macOS, which can
further improve speeds.
- External Rust crates are now built with opt=1, which improves performance
of debug builds.
- Esbuild is now used to transpile TypeScript, instead of invoking the TypeScript
compiler. This results in faster builds, by deferring typechecking to test/check
time, and by allowing more work to happen in parallel.
As an example of the differences, when testing with the mold linker on Linux,
adding a new message to tags.proto (which triggers a recompile of the bulk of
the Rust and TypeScript code) results in a compile that goes from about 22s on
Bazel to about 7s in the new system. With the standard linker, it's about 9s.
Some other changes of note:
- Our Rust workspace now uses cargo-hakari to ensure all packages agree on
available features, preventing unnecessary rebuilds.
- pylib/anki is now a PEP420 implicit namespace, avoiding the need to merge
source files and generated files into a single folder for running. By telling
VSCode about the extra search path, code completion now works with generated
files without needing to symlink them into the source folder.
- qt/aqt can't use PEP420 as it's difficult to get rid of aqt/__init__.py.
Instead, the generated files are now placed in a separate _aqt package that's
added to the path.
- ts/lib is now exposed as @tslib, so the source code and generated code can be
provided under the same namespace without a merging step.
- MyPy and PyLint are now invoked once for the entire codebase.
- dprint will be used to format TypeScript/json files in the future instead of
the slower prettier (currently turned off to avoid causing conflicts). It can
automatically defer to prettier when formatting Svelte files.
- svelte-check is now used for typechecking our Svelte code, which revealed a
few typing issues that went undetected with the old system.
- The Jest unit tests now work on Windows as well.
If you're upgrading from Bazel, updated usage instructions are in docs/development.md and docs/build.md. A summary of the changes:
- please remove node_modules and .bazel
- install rustup (https://rustup.rs/)
- install rsync if not already installed (on windows, use pacman - see docs/windows.md)
- install Ninja (unzip from https://github.com/ninja-build/ninja/releases/tag/v1.11.1 and
place on your path, or from your distro/homebrew if it's 1.10+)
- update .vscode/settings.json from .vscode.dist
2022-11-27 06:24:20 +01:00
|
|
|
import { registerPackage } from "@tslib/runtime-require";
|
2022-11-28 00:17:39 +01:00
|
|
|
|
2022-02-25 02:14:26 +01:00
|
|
|
import lifecycleHooks from "../../sveltelib/lifecycle-hooks";
|
|
|
|
import type { CodeMirrorAPI } from "../CodeMirror.svelte";
|
2022-05-13 05:02:03 +02:00
|
|
|
import type { EditingInputAPI, FocusableInputAPI } from "../EditingArea.svelte";
|
2021-10-18 14:01:15 +02:00
|
|
|
|
|
|
|
export interface PlainTextInputAPI extends EditingInputAPI {
|
|
|
|
name: "plain-text";
|
|
|
|
moveCaretToEnd(): void;
|
|
|
|
toggle(): boolean;
|
2022-02-25 02:14:26 +01:00
|
|
|
codeMirror: CodeMirrorAPI;
|
2021-10-18 14:01:15 +02:00
|
|
|
}
|
2022-01-08 02:46:01 +01:00
|
|
|
|
|
|
|
export const parsingInstructions: string[] = [];
|
2022-10-03 05:14:57 +02:00
|
|
|
export const closeHTMLTags = writable(true);
|
2022-02-25 02:14:26 +01:00
|
|
|
|
|
|
|
const [lifecycle, instances, setupLifecycleHooks] =
|
|
|
|
lifecycleHooks<PlainTextInputAPI>();
|
|
|
|
|
|
|
|
registerPackage("anki/PlainTextInput", {
|
|
|
|
lifecycle,
|
|
|
|
instances,
|
|
|
|
});
|
2021-10-18 14:01:15 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<script lang="ts">
|
Move away from Bazel (#2202)
(for upgrading users, please see the notes at the bottom)
Bazel brought a lot of nice things to the table, such as rebuilds based on
content changes instead of modification times, caching of build products,
detection of incorrect build rules via a sandbox, and so on. Rewriting the build
in Bazel was also an opportunity to improve on the Makefile-based build we had
prior, which was pretty poor: most dependencies were external or not pinned, and
the build graph was poorly defined and mostly serialized. It was not uncommon
for fresh checkouts to fail due to floating dependencies, or for things to break
when trying to switch to an older commit.
For day-to-day development, I think Bazel served us reasonably well - we could
generally switch between branches while being confident that builds would be
correct and reasonably fast, and not require full rebuilds (except on Windows,
where the lack of a sandbox and the TS rules would cause build breakages when TS
files were renamed/removed).
Bazel achieves that reliability by defining rules for each programming language
that define how source files should be turned into outputs. For the rules to
work with Bazel's sandboxing approach, they often have to reimplement or
partially bypass the standard tools that each programming language provides. The
Rust rules call Rust's compiler directly for example, instead of using Cargo,
and the Python rules extract each PyPi package into a separate folder that gets
added to sys.path.
These separate language rules allow proper declaration of inputs and outputs,
and offer some advantages such as caching of build products and fine-grained
dependency installation. But they also bring some downsides:
- The rules don't always support use-cases/platforms that the standard language
tools do, meaning they need to be patched to be used. I've had to contribute a
number of patches to the Rust, Python and JS rules to unblock various issues.
- The dependencies we use with each language sometimes make assumptions that do
not hold in Bazel, meaning they either need to be pinned or patched, or the
language rules need to be adjusted to accommodate them.
I was hopeful that after the initial setup work, things would be relatively
smooth-sailing. Unfortunately, that has not proved to be the case. Things
frequently broke when dependencies or the language rules were updated, and I
began to get frustrated at the amount of Anki development time I was instead
spending on build system upkeep. It's now about 2 years since switching to
Bazel, and I think it's time to cut losses, and switch to something else that's
a better fit.
The new build system is based on a small build tool called Ninja, and some
custom Rust code in build/. This means that to build Anki, Bazel is no longer
required, but Ninja and Rust need to be installed on your system. Python and
Node toolchains are automatically downloaded like in Bazel.
This new build system should result in faster builds in some cases:
- Because we're using cargo to build now, Rust builds are able to take advantage
of pipelining and incremental debug builds, which we didn't have with Bazel.
It's also easier to override the default linker on Linux/macOS, which can
further improve speeds.
- External Rust crates are now built with opt=1, which improves performance
of debug builds.
- Esbuild is now used to transpile TypeScript, instead of invoking the TypeScript
compiler. This results in faster builds, by deferring typechecking to test/check
time, and by allowing more work to happen in parallel.
As an example of the differences, when testing with the mold linker on Linux,
adding a new message to tags.proto (which triggers a recompile of the bulk of
the Rust and TypeScript code) results in a compile that goes from about 22s on
Bazel to about 7s in the new system. With the standard linker, it's about 9s.
Some other changes of note:
- Our Rust workspace now uses cargo-hakari to ensure all packages agree on
available features, preventing unnecessary rebuilds.
- pylib/anki is now a PEP420 implicit namespace, avoiding the need to merge
source files and generated files into a single folder for running. By telling
VSCode about the extra search path, code completion now works with generated
files without needing to symlink them into the source folder.
- qt/aqt can't use PEP420 as it's difficult to get rid of aqt/__init__.py.
Instead, the generated files are now placed in a separate _aqt package that's
added to the path.
- ts/lib is now exposed as @tslib, so the source code and generated code can be
provided under the same namespace without a merging step.
- MyPy and PyLint are now invoked once for the entire codebase.
- dprint will be used to format TypeScript/json files in the future instead of
the slower prettier (currently turned off to avoid causing conflicts). It can
automatically defer to prettier when formatting Svelte files.
- svelte-check is now used for typechecking our Svelte code, which revealed a
few typing issues that went undetected with the old system.
- The Jest unit tests now work on Windows as well.
If you're upgrading from Bazel, updated usage instructions are in docs/development.md and docs/build.md. A summary of the changes:
- please remove node_modules and .bazel
- install rustup (https://rustup.rs/)
- install rsync if not already installed (on windows, use pacman - see docs/windows.md)
- install Ninja (unzip from https://github.com/ninja-build/ninja/releases/tag/v1.11.1 and
place on your path, or from your distro/homebrew if it's 1.10+)
- update .vscode/settings.json from .vscode.dist
2022-11-27 06:24:20 +01:00
|
|
|
import { singleCallback } from "@tslib/typing";
|
2022-02-04 09:36:34 +01:00
|
|
|
import { onMount, tick } from "svelte";
|
2021-10-18 14:01:15 +02:00
|
|
|
import { writable } from "svelte/store";
|
2022-11-28 00:17:39 +01:00
|
|
|
|
2022-01-24 02:43:09 +01:00
|
|
|
import { pageTheme } from "../../sveltelib/theme";
|
2022-02-04 09:36:34 +01:00
|
|
|
import { baseOptions, gutterOptions, htmlanki } from "../code-mirror";
|
|
|
|
import CodeMirror from "../CodeMirror.svelte";
|
|
|
|
import { context as editingAreaContext } from "../EditingArea.svelte";
|
2023-04-22 08:08:25 +02:00
|
|
|
import { Flag } from "../helpers";
|
2022-02-25 01:59:06 +01:00
|
|
|
import { context as noteEditorContext } from "../NoteEditor.svelte";
|
2022-02-25 02:14:26 +01:00
|
|
|
import removeProhibitedTags from "./remove-prohibited";
|
2022-03-31 03:17:13 +02:00
|
|
|
import { storedToUndecorated, undecoratedToStored } from "./transform";
|
2021-10-18 14:01:15 +02:00
|
|
|
|
2022-09-05 09:20:00 +02:00
|
|
|
export let hidden = false;
|
2023-04-22 08:08:25 +02:00
|
|
|
export const focusFlag = new Flag();
|
2022-05-13 05:02:03 +02:00
|
|
|
|
2022-10-03 05:14:57 +02:00
|
|
|
$: configuration = {
|
2021-10-18 14:01:15 +02:00
|
|
|
mode: htmlanki,
|
|
|
|
...baseOptions,
|
|
|
|
...gutterOptions,
|
2022-10-03 05:14:57 +02:00
|
|
|
...{ autoCloseTags: $closeHTMLTags },
|
2021-10-18 14:01:15 +02:00
|
|
|
};
|
|
|
|
|
2022-02-25 01:59:06 +01:00
|
|
|
const { focusedInput } = noteEditorContext.get();
|
2022-02-03 05:52:11 +01:00
|
|
|
const { editingInputs, content } = editingAreaContext.get();
|
2021-10-18 14:01:15 +02:00
|
|
|
const code = writable($content);
|
|
|
|
|
2022-03-31 03:17:13 +02:00
|
|
|
let codeMirror = {} as CodeMirrorAPI;
|
|
|
|
|
|
|
|
async function focus(): Promise<void> {
|
|
|
|
const editor = await codeMirror.editor;
|
|
|
|
editor.focus();
|
2021-10-18 14:01:15 +02:00
|
|
|
}
|
|
|
|
|
2022-03-31 03:17:13 +02:00
|
|
|
async function moveCaretToEnd(): Promise<void> {
|
|
|
|
const editor = await codeMirror.editor;
|
|
|
|
editor.setCursor(editor.lineCount(), 0);
|
2022-02-05 06:58:31 +01:00
|
|
|
}
|
|
|
|
|
2022-03-31 03:17:13 +02:00
|
|
|
async function refocus(): Promise<void> {
|
|
|
|
const editor = (await codeMirror.editor) as any;
|
|
|
|
editor.display.input.blur();
|
|
|
|
|
2021-10-18 14:01:15 +02:00
|
|
|
focus();
|
2022-02-05 06:58:31 +01:00
|
|
|
moveCaretToEnd();
|
2021-10-18 14:01:15 +02:00
|
|
|
}
|
|
|
|
|
2021-12-13 05:00:35 +01:00
|
|
|
function toggle(): boolean {
|
|
|
|
hidden = !hidden;
|
|
|
|
return hidden;
|
|
|
|
}
|
|
|
|
|
2022-05-13 05:02:03 +02:00
|
|
|
async function getInputAPI(target: EventTarget): Promise<FocusableInputAPI | null> {
|
|
|
|
const editor = (await codeMirror.editor) as any;
|
|
|
|
|
|
|
|
if (target === editor.display.input.textarea) {
|
|
|
|
return api;
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2022-03-31 03:17:13 +02:00
|
|
|
export const api: PlainTextInputAPI = {
|
2021-10-18 14:01:15 +02:00
|
|
|
name: "plain-text",
|
|
|
|
focus,
|
|
|
|
focusable: !hidden,
|
|
|
|
moveCaretToEnd,
|
|
|
|
refocus,
|
2021-12-13 05:00:35 +01:00
|
|
|
toggle,
|
2022-05-13 05:02:03 +02:00
|
|
|
getInputAPI,
|
2022-02-25 02:14:26 +01:00
|
|
|
codeMirror,
|
2022-03-31 03:17:13 +02:00
|
|
|
};
|
2021-10-18 14:01:15 +02:00
|
|
|
|
2022-03-31 03:17:13 +02:00
|
|
|
/**
|
|
|
|
* Communicate to editing area that input is not focusable
|
|
|
|
*/
|
|
|
|
function pushUpdate(isFocusable: boolean): void {
|
|
|
|
api.focusable = isFocusable;
|
2021-10-18 14:01:15 +02:00
|
|
|
$editingInputs = $editingInputs;
|
|
|
|
}
|
|
|
|
|
2022-03-31 03:17:13 +02:00
|
|
|
async function refresh(): Promise<void> {
|
|
|
|
const editor = await codeMirror.editor;
|
|
|
|
editor.refresh();
|
2021-10-18 14:01:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$: {
|
2022-03-31 03:17:13 +02:00
|
|
|
pushUpdate(!hidden);
|
2023-04-22 08:08:25 +02:00
|
|
|
tick().then(() => {
|
|
|
|
refresh();
|
|
|
|
if (focusFlag.checkAndReset()) {
|
|
|
|
refocus();
|
|
|
|
}
|
|
|
|
});
|
2021-10-18 14:01:15 +02:00
|
|
|
}
|
|
|
|
|
2022-03-31 03:17:13 +02:00
|
|
|
function onChange({ detail: html }: CustomEvent<string>): void {
|
|
|
|
code.set(removeProhibitedTags(html));
|
2022-02-25 02:14:26 +01:00
|
|
|
}
|
|
|
|
|
2021-10-18 14:01:15 +02:00
|
|
|
onMount(() => {
|
|
|
|
$editingInputs.push(api);
|
|
|
|
$editingInputs = $editingInputs;
|
|
|
|
|
2022-03-31 03:17:13 +02:00
|
|
|
return singleCallback(
|
|
|
|
content.subscribe((html: string): void =>
|
|
|
|
/* We call `removeProhibitedTags` here, because content might
|
|
|
|
* have been changed outside the editor, and we need to parse
|
|
|
|
* it to get the "neutral" value. Otherwise, there might be
|
|
|
|
* conflicts with other editing inputs */
|
|
|
|
code.set(removeProhibitedTags(storedToUndecorated(html))),
|
|
|
|
),
|
|
|
|
code.subscribe((html: string): void =>
|
|
|
|
content.set(undecoratedToStored(html)),
|
|
|
|
),
|
|
|
|
);
|
2021-10-18 14:01:15 +02:00
|
|
|
});
|
2022-02-25 02:14:26 +01:00
|
|
|
|
|
|
|
setupLifecycleHooks(api);
|
2021-10-18 14:01:15 +02:00
|
|
|
</script>
|
|
|
|
|
2022-01-10 03:51:50 +01:00
|
|
|
<div
|
|
|
|
class="plain-text-input"
|
|
|
|
class:light-theme={!$pageTheme.isDark}
|
2022-02-25 01:59:06 +01:00
|
|
|
on:focusin={() => ($focusedInput = api)}
|
2022-09-05 09:20:00 +02:00
|
|
|
{hidden}
|
2022-01-10 03:51:50 +01:00
|
|
|
>
|
2022-04-09 05:25:54 +02:00
|
|
|
<CodeMirror
|
|
|
|
{configuration}
|
|
|
|
{code}
|
|
|
|
{hidden}
|
|
|
|
bind:api={codeMirror}
|
|
|
|
on:change={onChange}
|
|
|
|
/>
|
2021-10-18 14:01:15 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<style lang="scss">
|
2022-01-08 02:46:01 +01:00
|
|
|
.plain-text-input {
|
2022-10-27 01:11:36 +02:00
|
|
|
height: 100%;
|
2022-08-31 15:34:39 +02:00
|
|
|
|
2022-09-13 06:20:26 +02:00
|
|
|
:global(.CodeMirror) {
|
2022-10-27 01:11:36 +02:00
|
|
|
height: 100%;
|
Introduce new color palette using Sass maps (#2016)
* Remove --medium-border variable
* Implement color palette using Sass maps
I hand-picked the gray tones, the other colors are from the Tailwind CSS v3 palette.
Significant changes:
- light theme is brighter
- dark theme is darker
- borders are softer
I also deleted some platform- and night-mode-specific code.
* Use custom colors for note view switch
* Use same placeholder color for all inputs
* Skew color palette for more dark values
by removing gray[3], which wasn't used anywhere. Slight adjustments were made to the darker tones.
* Adjust frame- window- and border colors
* Give deck browser entries --frame-bg as background color
* Define styling for QComboBox and QLineEdit globally
* Experiment with CSS filter for inline-colors
Inside darker inputs, some colors like dark blue will be hard to read, so we could try to improve text-color contrast with global adjustments depending on the theme.
* Use different map structure for _vars.scss
after @hgiesel's idea: https://github.com/ankitects/anki/pull/2016#discussion_r947087871
* Move custom QLineEdit styles out of searchbar.py
* Merge branch 'main' into color-palette
* Revert QComboBox stylesheet override
* Align gray color palette more with macOS
* Adjust light theme
* Use --slightly-grey-text for options tab color
* Replace gray tones with more neutral values
* Improve categorization of global colors
by renaming almost all of them and sorting them into separate maps.
* Saturate highlight-bg in light theme
* Tweak gray tones
* Adjust box-shadow of EditingArea to make fields look inset
* Add Sass functions to access color palette and semantic variables
in response to https://github.com/ankitects/anki/pull/2016#issuecomment-1220571076
* Showcase use of access functions in several locations
@hgiesel in buttons.scss I access the color palette directly. Is this what you meant by "... keep it local to the component, and possibly make it global at a later time ..."?
* Fix focus box shadow transition and remove default shadow for a cleaner look
I couldn't quite get the inset look the way I wanted, because inset box-shadows do not respect the border radius, therefore causing aliasing.
* Tweak light theme border and shadow colors
* Add functions and colors to base_lib
* Add vars_lib as dependency to base_lib and button_mixins_lib
* Improve uses of default-themed variables
* Use old --frame-bg color and use darker tone for canvas-default
* Return CSS var by default and add palette-of function for raw value
* Showcase use of palette-of function
The #{...} syntax is required only because the use cases are CSS var definitions. In other cases a simple palette-of(keyword, theme) would suffice.
* Light theme: decrease brightness of canvas-default and adjust fg-default
* Use canvas-inset variable for switch knob
* Adjust light theme
* Add back box-shadow to EditingArea
* Light theme: darken background and flatten transition
also set hue and saturation of gray-8 to 0 (like all the other grays).
* Reduce flag colors to single default value
* Tweak card/note accent colors
* Experiment with inset look for fields again
Is this too dark in night mode? It's the same color used for all other text inputs.
* Dark theme: make border-default one shade darker
* Tweak inset shadow color
* Dark theme: make border-faint darker than canvas-default
meaning two shades darker than it currently was.
* Fix PlainTextInput not expanding
* Dark theme: use less saturated flag colors
* Adjust gray tones
* Fix nested variables not getting extracted correctly
* Rename canvas-outset to canvas-elevated
* Light theme: darken canvas-default
* Make canvas-elevated a bit darker
* Rename variables and use them in various components
* Refactor button mixins
* Remove fusion vars from Anki
* Adjust button gradients
* Refactor button mixins
* Fix deck browser table td background color
* Use color function in buttons.scss
* Rework QTabWidget stylesheet
* Fix crash on browser open
* Perfect QTableView header
* Fix bottom toolbar button gradient
* Fix focus outline of bottom toolbar buttons
* Fix custom webview scrollbar
* Fix uses of vars in various webviews
The command @use vars as * lead to repeated inclusion of the CSS vars.
* Enable primary button color with mixin
* Run prettier
* Fix Python code style issues
* Tweak colors
* Lighten scrollbar shades in light theme
* Fix code style issues caused by merge
* Fix harsh border color in editor
caused by leftover --medium-border variables, probably introduced with a merge commit.
* Compile Sass before extracting Python colors/props
This means the Python side doesn't need to worry about the map structure and Sass functions, just copy the output CSS values.
* Desaturate primary button colors by 10%
* Convert accidentally capitalized variable names to lowercase
* Simplify color definitions with qcolor function
* Remove default border-focus variable
* Remove redundant colon
* Apply custom scrollbar CSS only on Windows and Linux
* Make border-subtle color brighter than background in dark theme
* Make border-subtle color a shade brighter in light theme
* Use border-subtle for NoteEditor and EditorToolbar border
* Small patches
2022-09-16 06:11:18 +02:00
|
|
|
background: var(--canvas-code);
|
2022-11-05 01:58:04 +01:00
|
|
|
padding-inline: 4px;
|
2022-01-08 02:46:01 +01:00
|
|
|
}
|
2022-09-05 09:20:00 +02:00
|
|
|
|
2022-01-10 03:51:50 +01:00
|
|
|
:global(.CodeMirror-lines) {
|
Field redesign (#2002)
* Adjust size of legacy buttons
* Revert "Adjust size of legacy buttons"
This reverts commit fb888fe1db9050c34b1a7b0820e6da5ac91ccee6.
* Remove unused function from #1476
* Use outline version for tag icon
* Add chevron icons
* Remove code icons, keep one pin icon version
* Add code-bg color
* Redesign fields
* Remove unused import
* Fix imports
* Move PlainTextBadge between editing inputs
where it belongs :)
* Make whole separator line clickable
* Fix transition
and format
* Don't show toggle when field is collapsed
* Show toggle only on hover
for mobile I'd like to implement a swipe mechanism.
* Use tweened SVG for triangle instead of CSS hack
* Implement more obvious HTML toggle on bottom right
* Reduce field height by a few pixels
* Reduce field height by two pixels
* Show HTML toggle when PlainTextInput is active, regardless of hover/focus
* Remove RichTextBadge.svelte
* Create separate collapsed field state
this means users can collapse fields with the HTML editor open and it will stay open when the field is expanded again.
* Add slide out animation to EditingArea, RichTextInput and PlainTextInput
only for collapsing, because it is choppy on expansion (common issue with Svelte transitions).
* Fix aliasing issue on focused field corners
* Make StickyBadge feel more responsive
* Move StickyBadge closer to field border
* Adjust field gutter/margins
* Make LabelContainer sticky
to make field operations accessible on fields with a lot of content.
* Add back html icons, remove visual editor icons
* Revert "Add code-bg color"
This reverts commit 4200f354193710b3acd9bcf84b67958e200ddcdb.
* Add rich text icon, remove strikethrough code icon
* Revert PlainTextBadge to original position
* Adjust margins in FieldState
* Rename PlainTextBadge to SecondaryInputBadge
in preparation for #1987
* Run eslint and prettier
* Make whole LabelContainer clickable area for collapse/expand
* Revert "Add slide out animation to EditingArea, RichTextInput and PlainTextInput"
This reverts commit 9a2b3410d0ead37ae1da408d68e14507a058a613.
* Fix error on collapse/expansion
this was caused by the {#if} blocks, which resulted in the deletion of original EditingAreas.
* Refocus when toggling chevron and secondary input badge
* Revert "Revert "Add code-bg color""
This reverts commit 1cfd3bda65354ab90c1ab4cbbef47596a1be8754.
* Use single rotating chevron icon and make it RTL-compatible
* Remove redundant CSS transition rule
* Introduce animated Collapsible component and fix refocus on toggle
* Do not try to force repaint, as it is not required
* Remove RTL store from LabelContainer
the direction is already applied globally.
* Collapse secondary input with field
* Add focusedField to NoteEditorAPI
* Replace :global CSS selector with class .visible
thus removing the assumption that the component is used inside an EditorField.
https://github.com/ankitects/anki/pull/2002#discussion_r944876448
* Use named function syntax instead of function expressions
* Add explanation comment
* Remove unnecessary :bind directive
* Create CollapseBadge component
* Move :global selector into .plain-text-input
* Add comment explaining box-shadow pseudo-element
* Move Collapsible from EditingArea, PlainTextInput and RichTextInput into user components
* Rename SecondaryInputBadge to PlainTextBadge and remove generalization logic
I kept the rich text icon inside icons.ts for future use.
* Sort imports
* Fix background-color for duplicates not showing
with yet another pseudo-element :)
The pseudo-element that covers up field borders on scroll caused this issue. Fighting fire with fire here.
* Increase size of plain text toggle to original value again
This makes the clickable area a bit bigger and looks slightly more consistent with StickyBadge.
* Scrap pseudo-element mess in LabelContainer and tackle the actual issue
* Add class .visible to StickyBadge too
This introduces a peculiar bug: The active prop of StickyBadge resets to false when the mouse leaves the field - regardless of the actual back-end value.
* Fix sticky badge resetting on mouseleave/blur
* Apply overflow: hidden only during transition
fixes MathJax handle getting cut off by fields
* Remove unused variable
* Fix visual bug caused by overflow:hidden not applying in time
I tried several asynchronous approaches, but they all caused issues: either they prevented the CSS transition or they made field inputs lose focus.
In the end I resorted to direct, synchronous DOM-manipulation and added an explanatory comment.
* Decrease Collapsible load time by blocking first transition
I noticed the sliding animation has a hefty performance impact when a large number of fields is loaded simultaneously.
Blocking the first transition (which isn't even visible) results in a big boost in load time.
* Replace usages of gap with margins for children
* Revert unnecessary removal of grid-gap definition
* Correct comments about flex-gap property
mistook that for grid-gap.
* Resolve style issues
* Add minimum targets to gap comment
Co-authored-by: Henrik Giesel <hengiesel@gmail.com>
2022-08-19 02:02:28 +02:00
|
|
|
padding: 8px 0;
|
2022-01-08 02:46:01 +01:00
|
|
|
}
|
2022-11-05 01:58:04 +01:00
|
|
|
|
|
|
|
:global(.CodeMirror-gutters) {
|
|
|
|
background: var(--canvas-code);
|
|
|
|
}
|
2021-10-18 14:01:15 +02:00
|
|
|
}
|
|
|
|
</style>
|