30bbbaf00b
* Make eslint sort our imports * fix missing deps in eslint rule (dae) Caught on Linux due to the stricter sandboxing * Remove exports-last eslint rule (for now?) * Adjust browserslist settings - We use ResizeObserver which is not supported in browsers like KaiOS, Baidu or Android UC * Raise minimum iOS version 13.4 - It's the first version that supports ResizeObserver * Apply new eslint rules to sort imports
52 lines
1.4 KiB
Svelte
52 lines
1.4 KiB
Svelte
<!--
|
|
Copyright: Ankitects Pty Ltd and contributors
|
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
-->
|
|
<script lang="ts">
|
|
import { onDestroy, onMount } from "svelte";
|
|
|
|
import { bridgeCommand } from "../lib/bridgecommand";
|
|
import { registerShortcut } from "../lib/shortcuts";
|
|
import type { NoteEditorAPI } from "./NoteEditor.svelte";
|
|
import NoteEditor from "./NoteEditor.svelte";
|
|
import StickyBadge from "./StickyBadge.svelte";
|
|
|
|
const api: Partial<NoteEditorAPI> = {};
|
|
let noteEditor: NoteEditor;
|
|
|
|
export let uiResolve: (api: NoteEditorAPI) => void;
|
|
|
|
$: if (noteEditor) {
|
|
uiResolve(api as NoteEditorAPI);
|
|
}
|
|
|
|
let stickies: boolean[] = [];
|
|
|
|
function setSticky(stckies: boolean[]): void {
|
|
stickies = stckies;
|
|
}
|
|
|
|
function toggleStickyAll(): void {
|
|
bridgeCommand("toggleStickyAll", (values: boolean[]) => (stickies = values));
|
|
}
|
|
|
|
let deregisterSticky: () => void;
|
|
export function activateStickyShortcuts() {
|
|
deregisterSticky = registerShortcut(toggleStickyAll, "Shift+F9");
|
|
}
|
|
|
|
onMount(() => {
|
|
Object.assign(globalThis, {
|
|
setSticky,
|
|
});
|
|
});
|
|
|
|
onDestroy(() => deregisterSticky);
|
|
</script>
|
|
|
|
<NoteEditor bind:this={noteEditor} {api}>
|
|
<svelte:fragment slot="field-state" let:index>
|
|
<StickyBadge active={stickies[index]} {index} />
|
|
</svelte:fragment>
|
|
</NoteEditor>
|