diff --git a/build/configure/src/aqt.rs b/build/configure/src/aqt.rs
index 5b2b8ec49..80f7462f5 100644
--- a/build/configure/src/aqt.rs
+++ b/build/configure/src/aqt.rs
@@ -148,10 +148,8 @@ fn build_css(build: &mut Build) -> Result<()> {
},
)?;
}
- let other_ts_css = build.inputs_with_suffix(
- inputs![":ts:editor", ":ts:editable", ":ts:reviewer:reviewer.css"],
- ".css",
- );
+ let other_ts_css =
+ build.inputs_with_suffix(inputs![":ts:editable", ":ts:reviewer:reviewer.css"], ".css");
build.add_action(
"qt:aqt:data:web:css",
CopyFiles {
@@ -192,10 +190,8 @@ fn build_js(build: &mut Build) -> Result<()> {
inputs: files,
},
)?;
- let files_from_ts = build.inputs_with_suffix(
- inputs![":ts:editor", ":ts:reviewer:reviewer.js", ":ts:mathjax"],
- ".js",
- );
+ let files_from_ts =
+ build.inputs_with_suffix(inputs![":ts:reviewer:reviewer.js", ":ts:mathjax"], ".js");
build.add_action(
"qt:aqt:data:web:js",
CopyFiles {
diff --git a/build/configure/src/web.rs b/build/configure/src/web.rs
index ef2d268bb..2e5411c41 100644
--- a/build/configure/src/web.rs
+++ b/build/configure/src/web.rs
@@ -29,7 +29,6 @@ pub fn build_and_check_web(build: &mut Build) -> Result<()> {
build_sveltekit(build)?;
declare_and_check_other_libraries(build)?;
build_and_check_pages(build)?;
- build_and_check_editor(build)?;
build_and_check_reviewer(build)?;
build_and_check_mathjax(build)?;
check_web(build)?;
@@ -170,7 +169,7 @@ fn declare_and_check_other_libraries(build: &mut Build) -> Result<()> {
"components",
inputs![":ts:lib", ":ts:sveltelib", glob!("ts/components/**")],
),
- ("html-filter", inputs![glob!("ts/html-filter/**")]),
+ ("html-filter", inputs![glob!("ts/lib/html-filter/**")]),
] {
let library_with_ts = format!("ts:{library}");
build.add_dependency(&library_with_ts, inputs.clone());
@@ -187,7 +186,7 @@ fn build_and_check_pages(build: &mut Build) -> Result<()> {
let entrypoint = if html {
format!("ts/routes/{name}/index.ts")
} else {
- format!("ts/{name}/index.ts")
+ format!("ts/lib/{name}/index.ts")
};
build.add_action(
&group,
@@ -208,7 +207,6 @@ fn build_and_check_pages(build: &mut Build) -> Result<()> {
"editable",
false,
inputs![
- //
":ts:lib",
":ts:components",
":ts:domlib",
@@ -232,33 +230,6 @@ fn build_and_check_pages(build: &mut Build) -> Result<()> {
Ok(())
}
-fn build_and_check_editor(build: &mut Build) -> Result<()> {
- let editor_deps = inputs![
- //
- ":ts:lib",
- ":ts:components",
- ":ts:domlib",
- ":ts:sveltelib",
- ":ts:html-filter",
- ":sass",
- ":sveltekit",
- glob!("ts/{editable,editor,routes/image-occlusion}/**")
- ];
-
- build.add_action(
- "ts:editor",
- EsbuildScript {
- script: "ts/bundle_svelte.mjs".into(),
- entrypoint: "ts/editor/index.ts".into(),
- output_stem: "ts/editor/editor",
- deps: editor_deps.clone(),
- extra_exts: &["css"],
- },
- )?;
-
- Ok(())
-}
-
fn build_and_check_reviewer(build: &mut Build) -> Result<()> {
let reviewer_deps = inputs![
":ts:lib",
diff --git a/proto/anki/frontend.proto b/proto/anki/frontend.proto
index 95b929c5c..9bf50d8e2 100644
--- a/proto/anki/frontend.proto
+++ b/proto/anki/frontend.proto
@@ -27,6 +27,8 @@ service FrontendService {
rpc deckOptionsRequireClose(generic.Empty) returns (generic.Empty);
// Warns python that the deck option web view is ready to receive requests.
rpc deckOptionsReady(generic.Empty) returns (generic.Empty);
+
+ rpc editorReady(generic.Empty) returns (generic.Empty);
}
service BackendFrontendService {}
diff --git a/qt/aqt/editor.py b/qt/aqt/editor.py
index c1eb14b18..ead8e1df4 100644
--- a/qt/aqt/editor.py
+++ b/qt/aqt/editor.py
@@ -107,6 +107,17 @@ class EditorState(Enum):
IO_FIELDS = 3
+def on_editor_ready(func: Callable) -> Callable:
+ @functools.wraps(func)
+ def decorated(self: Editor, *args: Any, **kwargs: Any) -> None:
+ if self._ready:
+ func(self, *args, **kwargs)
+ else:
+ self._ready_callbacks.append(lambda: func(self, *args, **kwargs))
+
+ return decorated
+
+
class Editor:
"""The screen that embeds an editing widget should listen for changes via
the `operation_did_execute` hook, and call set_note() when the editor needs
@@ -146,12 +157,14 @@ class Editor:
self.state: EditorState = EditorState.INITIAL
# used for the io mask editor's context menu
self.last_io_image_path: str | None = None
+ self._ready = False
+ self._ready_callbacks: list[Callable[[], None]] = []
self._init_links()
self.setupOuter()
self.add_webview()
self.setupWeb()
self.setupShortcuts()
- gui_hooks.editor_did_init(self)
+ # gui_hooks.editor_did_init(self)
# Initial setup
############################################################
@@ -175,21 +188,9 @@ class Editor:
mode = "browse"
else:
mode = "review"
+ self.web.load_sveltekit_page(f"editor/?mode={mode}")
- # then load page
- self.web.stdHtml(
- "",
- css=["css/editor.css"],
- js=[
- "js/mathjax.js",
- "js/editor.js",
- ],
- context=self,
- default_css=False,
- )
- self.web.eval(f"setupEditor('{mode}')")
- self.web.show()
-
+ def _set_ready(self) -> None:
lefttopbtns: list[str] = []
gui_hooks.editor_did_init_left_buttons(lefttopbtns, self)
@@ -218,6 +219,10 @@ require("anki/ui").loaded.then(() => require("anki/NoteEditor").instances[0].too
)
self.web.eval(f"{lefttopbtns_js} {righttopbtns_js}")
+ gui_hooks.editor_did_init(self)
+ self._ready = True
+ for cb in self._ready_callbacks:
+ cb()
# Top buttons
######################################################################
@@ -543,6 +548,7 @@ require("anki/ui").loaded.then(() => require("anki/NoteEditor").instances[0].too
def loadNoteKeepingFocus(self) -> None:
self.loadNote(self.currentField)
+ @on_editor_ready
def loadNote(self, focusTo: int | None = None) -> None:
if not self.note:
return
diff --git a/qt/aqt/mediasrv.py b/qt/aqt/mediasrv.py
index 203f23ef9..45caef008 100644
--- a/qt/aqt/mediasrv.py
+++ b/qt/aqt/mediasrv.py
@@ -337,6 +337,7 @@ def is_sveltekit_page(path: str) -> bool:
"import-csv",
"import-page",
"image-occlusion",
+ "editor",
]
@@ -602,6 +603,18 @@ def deck_options_ready() -> bytes:
return b""
+def editor_ready() -> bytes:
+ from aqt.editor import Editor
+
+ def handle_on_main() -> None:
+ window = aqt.mw.app.activeWindow()
+ if isinstance(getattr(window, "editor"), Editor):
+ window.editor._set_ready() # type: ignore
+
+ aqt.mw.taskman.run_on_main(handle_on_main)
+ return b""
+
+
post_handler_list = [
congrats_info,
get_deck_configs_for_update,
@@ -617,6 +630,7 @@ post_handler_list = [
search_in_browser,
deck_options_require_close,
deck_options_ready,
+ editor_ready,
]
diff --git a/ts/editor/index.ts b/ts/editor/index.ts
deleted file mode 100644
index bd8fc9029..000000000
--- a/ts/editor/index.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-// Copyright: Ankitects Pty Ltd and contributors
-// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-
-import { globalExport } from "@tslib/globals";
-
-import * as base from "./base";
-
-globalExport(base);
diff --git a/ts/editable/ContentEditable.svelte b/ts/lib/editable/ContentEditable.svelte
similarity index 100%
rename from ts/editable/ContentEditable.svelte
rename to ts/lib/editable/ContentEditable.svelte
diff --git a/ts/editable/Mathjax.svelte b/ts/lib/editable/Mathjax.svelte
similarity index 100%
rename from ts/editable/Mathjax.svelte
rename to ts/lib/editable/Mathjax.svelte
diff --git a/ts/editable/change-timer.ts b/ts/lib/editable/change-timer.ts
similarity index 100%
rename from ts/editable/change-timer.ts
rename to ts/lib/editable/change-timer.ts
diff --git a/ts/editable/content-editable.ts b/ts/lib/editable/content-editable.ts
similarity index 100%
rename from ts/editable/content-editable.ts
rename to ts/lib/editable/content-editable.ts
diff --git a/ts/editable/decorated.ts b/ts/lib/editable/decorated.ts
similarity index 100%
rename from ts/editable/decorated.ts
rename to ts/lib/editable/decorated.ts
diff --git a/ts/editable/editable-base.scss b/ts/lib/editable/editable-base.scss
similarity index 96%
rename from ts/editable/editable-base.scss
rename to ts/lib/editable/editable-base.scss
index 3cfaa63b4..e2cfb77d8 100644
--- a/ts/editable/editable-base.scss
+++ b/ts/lib/editable/editable-base.scss
@@ -1,4 +1,4 @@
-@use "../lib/sass/scrollbar";
+@use "../sass/scrollbar";
* {
max-width: 100%;
diff --git a/ts/editable/frame-element.ts b/ts/lib/editable/frame-element.ts
similarity index 100%
rename from ts/editable/frame-element.ts
rename to ts/lib/editable/frame-element.ts
diff --git a/ts/editable/frame-handle.ts b/ts/lib/editable/frame-handle.ts
similarity index 100%
rename from ts/editable/frame-handle.ts
rename to ts/lib/editable/frame-handle.ts
diff --git a/ts/editable/index.ts b/ts/lib/editable/index.ts
similarity index 100%
rename from ts/editable/index.ts
rename to ts/lib/editable/index.ts
diff --git a/ts/editable/mathjax-element.svelte.ts b/ts/lib/editable/mathjax-element.svelte.ts
similarity index 100%
rename from ts/editable/mathjax-element.svelte.ts
rename to ts/lib/editable/mathjax-element.svelte.ts
diff --git a/ts/editable/mathjax.ts b/ts/lib/editable/mathjax.ts
similarity index 100%
rename from ts/editable/mathjax.ts
rename to ts/lib/editable/mathjax.ts
diff --git a/ts/html-filter/element.ts b/ts/lib/html-filter/element.ts
similarity index 100%
rename from ts/html-filter/element.ts
rename to ts/lib/html-filter/element.ts
diff --git a/ts/html-filter/helpers.ts b/ts/lib/html-filter/helpers.ts
similarity index 100%
rename from ts/html-filter/helpers.ts
rename to ts/lib/html-filter/helpers.ts
diff --git a/ts/html-filter/index.test.ts b/ts/lib/html-filter/index.test.ts
similarity index 100%
rename from ts/html-filter/index.test.ts
rename to ts/lib/html-filter/index.test.ts
diff --git a/ts/html-filter/index.ts b/ts/lib/html-filter/index.ts
similarity index 100%
rename from ts/html-filter/index.ts
rename to ts/lib/html-filter/index.ts
diff --git a/ts/html-filter/node.ts b/ts/lib/html-filter/node.ts
similarity index 100%
rename from ts/html-filter/node.ts
rename to ts/lib/html-filter/node.ts
diff --git a/ts/html-filter/styling.ts b/ts/lib/html-filter/styling.ts
similarity index 100%
rename from ts/html-filter/styling.ts
rename to ts/lib/html-filter/styling.ts
diff --git a/ts/routes/editor/+page.svelte b/ts/routes/editor/+page.svelte
new file mode 100644
index 000000000..2130ad26e
--- /dev/null
+++ b/ts/routes/editor/+page.svelte
@@ -0,0 +1,23 @@
+
+
diff --git a/ts/editor/BrowserEditor.svelte b/ts/routes/editor/BrowserEditor.svelte
similarity index 100%
rename from ts/editor/BrowserEditor.svelte
rename to ts/routes/editor/BrowserEditor.svelte
diff --git a/ts/editor/ClozeButtons.svelte b/ts/routes/editor/ClozeButtons.svelte
similarity index 100%
rename from ts/editor/ClozeButtons.svelte
rename to ts/routes/editor/ClozeButtons.svelte
diff --git a/ts/editor/CodeMirror.svelte b/ts/routes/editor/CodeMirror.svelte
similarity index 100%
rename from ts/editor/CodeMirror.svelte
rename to ts/routes/editor/CodeMirror.svelte
diff --git a/ts/editor/CollapseBadge.svelte b/ts/routes/editor/CollapseBadge.svelte
similarity index 100%
rename from ts/editor/CollapseBadge.svelte
rename to ts/routes/editor/CollapseBadge.svelte
diff --git a/ts/editor/CollapseLabel.svelte b/ts/routes/editor/CollapseLabel.svelte
similarity index 100%
rename from ts/editor/CollapseLabel.svelte
rename to ts/routes/editor/CollapseLabel.svelte
diff --git a/ts/editor/DuplicateLink.svelte b/ts/routes/editor/DuplicateLink.svelte
similarity index 100%
rename from ts/editor/DuplicateLink.svelte
rename to ts/routes/editor/DuplicateLink.svelte
diff --git a/ts/editor/EditingArea.svelte b/ts/routes/editor/EditingArea.svelte
similarity index 100%
rename from ts/editor/EditingArea.svelte
rename to ts/routes/editor/EditingArea.svelte
diff --git a/ts/editor/EditorField.svelte b/ts/routes/editor/EditorField.svelte
similarity index 100%
rename from ts/editor/EditorField.svelte
rename to ts/routes/editor/EditorField.svelte
diff --git a/ts/editor/FieldDescription.svelte b/ts/routes/editor/FieldDescription.svelte
similarity index 100%
rename from ts/editor/FieldDescription.svelte
rename to ts/routes/editor/FieldDescription.svelte
diff --git a/ts/editor/FieldState.svelte b/ts/routes/editor/FieldState.svelte
similarity index 100%
rename from ts/editor/FieldState.svelte
rename to ts/routes/editor/FieldState.svelte
diff --git a/ts/editor/Fields.svelte b/ts/routes/editor/Fields.svelte
similarity index 100%
rename from ts/editor/Fields.svelte
rename to ts/routes/editor/Fields.svelte
diff --git a/ts/editor/HandleBackground.svelte b/ts/routes/editor/HandleBackground.svelte
similarity index 100%
rename from ts/editor/HandleBackground.svelte
rename to ts/routes/editor/HandleBackground.svelte
diff --git a/ts/editor/HandleControl.svelte b/ts/routes/editor/HandleControl.svelte
similarity index 100%
rename from ts/editor/HandleControl.svelte
rename to ts/routes/editor/HandleControl.svelte
diff --git a/ts/editor/HandleLabel.svelte b/ts/routes/editor/HandleLabel.svelte
similarity index 100%
rename from ts/editor/HandleLabel.svelte
rename to ts/routes/editor/HandleLabel.svelte
diff --git a/ts/editor/LabelContainer.svelte b/ts/routes/editor/LabelContainer.svelte
similarity index 100%
rename from ts/editor/LabelContainer.svelte
rename to ts/routes/editor/LabelContainer.svelte
diff --git a/ts/editor/LabelName.svelte b/ts/routes/editor/LabelName.svelte
similarity index 100%
rename from ts/editor/LabelName.svelte
rename to ts/routes/editor/LabelName.svelte
diff --git a/ts/editor/NoteCreator.svelte b/ts/routes/editor/NoteCreator.svelte
similarity index 100%
rename from ts/editor/NoteCreator.svelte
rename to ts/routes/editor/NoteCreator.svelte
diff --git a/ts/editor/NoteEditor.svelte b/ts/routes/editor/NoteEditor.svelte
similarity index 98%
rename from ts/editor/NoteEditor.svelte
rename to ts/routes/editor/NoteEditor.svelte
index 17ced575b..98bd7c989 100644
--- a/ts/editor/NoteEditor.svelte
+++ b/ts/routes/editor/NoteEditor.svelte
@@ -57,8 +57,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import {
type ImageLoadedEvent,
resetIOImage,
- } from "../routes/image-occlusion/mask-editor";
- import { ChangeTimer } from "../editable/change-timer";
+ } from "../image-occlusion/mask-editor";
+ import { ChangeTimer } from "$lib/editable/change-timer";
import { clearableArray } from "./destroyable";
import DuplicateLink from "./DuplicateLink.svelte";
import EditorToolbar from "./editor-toolbar";
@@ -417,16 +417,16 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import Shortcut from "$lib/components/Shortcut.svelte";
- import { mathjaxConfig } from "../editable/mathjax-element.svelte";
- import ImageOcclusionPage from "../routes/image-occlusion/ImageOcclusionPage.svelte";
- import ImageOcclusionPicker from "../routes/image-occlusion/ImageOcclusionPicker.svelte";
- import type { IOMode } from "../routes/image-occlusion/lib";
- import { exportShapesToClozeDeletions } from "../routes/image-occlusion/shapes/to-cloze";
+ import { mathjaxConfig } from "$lib/editable/mathjax-element.svelte";
+ import ImageOcclusionPage from "../image-occlusion/ImageOcclusionPage.svelte";
+ import ImageOcclusionPicker from "../image-occlusion/ImageOcclusionPicker.svelte";
+ import type { IOMode } from "../image-occlusion/lib";
+ import { exportShapesToClozeDeletions } from "../image-occlusion/shapes/to-cloze";
import {
hideAllGuessOne,
ioImageLoadedStore,
ioMaskEditorVisible,
- } from "../routes/image-occlusion/store";
+ } from "../image-occlusion/store";
import CollapseLabel from "./CollapseLabel.svelte";
import * as oldEditorAdapter from "./old-editor-adapter";
diff --git a/ts/editor/Notification.svelte b/ts/routes/editor/Notification.svelte
similarity index 100%
rename from ts/editor/Notification.svelte
rename to ts/routes/editor/Notification.svelte
diff --git a/ts/editor/PlainTextBadge.svelte b/ts/routes/editor/PlainTextBadge.svelte
similarity index 100%
rename from ts/editor/PlainTextBadge.svelte
rename to ts/routes/editor/PlainTextBadge.svelte
diff --git a/ts/editor/PreviewButton.svelte b/ts/routes/editor/PreviewButton.svelte
similarity index 100%
rename from ts/editor/PreviewButton.svelte
rename to ts/routes/editor/PreviewButton.svelte
diff --git a/ts/editor/ReviewerEditor.svelte b/ts/routes/editor/ReviewerEditor.svelte
similarity index 100%
rename from ts/editor/ReviewerEditor.svelte
rename to ts/routes/editor/ReviewerEditor.svelte
diff --git a/ts/editor/RichTextBadge.svelte b/ts/routes/editor/RichTextBadge.svelte
similarity index 100%
rename from ts/editor/RichTextBadge.svelte
rename to ts/routes/editor/RichTextBadge.svelte
diff --git a/ts/editor/StickyBadge.svelte b/ts/routes/editor/StickyBadge.svelte
similarity index 100%
rename from ts/editor/StickyBadge.svelte
rename to ts/routes/editor/StickyBadge.svelte
diff --git a/ts/routes/editor/[noteId]/+page.svelte b/ts/routes/editor/[noteId]/+page.svelte
deleted file mode 100644
index 995cede15..000000000
--- a/ts/routes/editor/[noteId]/+page.svelte
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
{data.noteId}
diff --git a/ts/routes/editor/[noteId]/+page.ts b/ts/routes/editor/[noteId]/+page.ts
deleted file mode 100644
index 66e82b2cd..000000000
--- a/ts/routes/editor/[noteId]/+page.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright: Ankitects Pty Ltd and contributors
-// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-
-import type { PageLoad } from "./$types";
-
-export const load = (async ({ params }) => {
- const noteId = BigInt(params.noteId);
-
- return { noteId };
-}) satisfies PageLoad;
diff --git a/ts/editor/base.ts b/ts/routes/editor/base.ts
similarity index 91%
rename from ts/editor/base.ts
rename to ts/routes/editor/base.ts
index c21a64811..bfc4a9183 100644
--- a/ts/editor/base.ts
+++ b/ts/routes/editor/base.ts
@@ -34,6 +34,7 @@ declare global {
import { ModuleName } from "@tslib/i18n";
import { mount } from "svelte";
+import type { EditorMode } from "./types";
export const editorModules = [
ModuleName.EDITING,
@@ -70,16 +71,16 @@ async function setupReviewerEditor(): Promise {
mount(ReviewerEditor, { target: document.body, props: { uiResolve } });
}
-export function setupEditor(mode: "add" | "browse" | "review") {
+export async function setupEditor(mode: EditorMode) {
switch (mode) {
case "add":
- setupNoteCreator();
+ await setupNoteCreator();
break;
case "browse":
- setupBrowserEditor();
+ await setupBrowserEditor();
break;
case "review":
- setupReviewerEditor();
+ await setupReviewerEditor();
break;
default:
alert("unexpected editor type");
diff --git a/ts/editor/code-mirror.ts b/ts/routes/editor/code-mirror.ts
similarity index 100%
rename from ts/editor/code-mirror.ts
rename to ts/routes/editor/code-mirror.ts
diff --git a/ts/editor/decorated-elements.ts b/ts/routes/editor/decorated-elements.ts
similarity index 78%
rename from ts/editor/decorated-elements.ts
rename to ts/routes/editor/decorated-elements.ts
index 6eb603897..e2257b3a8 100644
--- a/ts/editor/decorated-elements.ts
+++ b/ts/routes/editor/decorated-elements.ts
@@ -3,10 +3,10 @@
import { BLOCK_ELEMENTS } from "@tslib/dom";
-import { CustomElementArray } from "../editable/decorated";
-import { FrameElement } from "../editable/frame-element";
-import { FrameEnd, FrameStart } from "../editable/frame-handle";
-import { Mathjax } from "../editable/mathjax-element.svelte";
+import { CustomElementArray } from "$lib/editable/decorated";
+import { FrameElement } from "$lib/editable/frame-element";
+import { FrameEnd, FrameStart } from "$lib/editable/frame-handle";
+import { Mathjax } from "$lib/editable/mathjax-element.svelte";
import { parsingInstructions } from "./plain-text-input";
const decoratedElements = new CustomElementArray();
diff --git a/ts/editor/destroyable.ts b/ts/routes/editor/destroyable.ts
similarity index 100%
rename from ts/editor/destroyable.ts
rename to ts/routes/editor/destroyable.ts
diff --git a/ts/editor/editor-base.scss b/ts/routes/editor/editor-base.scss
similarity index 100%
rename from ts/editor/editor-base.scss
rename to ts/routes/editor/editor-base.scss
diff --git a/ts/editor/editor-toolbar/AddonButtons.svelte b/ts/routes/editor/editor-toolbar/AddonButtons.svelte
similarity index 100%
rename from ts/editor/editor-toolbar/AddonButtons.svelte
rename to ts/routes/editor/editor-toolbar/AddonButtons.svelte
diff --git a/ts/editor/editor-toolbar/BlockButtons.svelte b/ts/routes/editor/editor-toolbar/BlockButtons.svelte
similarity index 100%
rename from ts/editor/editor-toolbar/BlockButtons.svelte
rename to ts/routes/editor/editor-toolbar/BlockButtons.svelte
diff --git a/ts/editor/editor-toolbar/BoldButton.svelte b/ts/routes/editor/editor-toolbar/BoldButton.svelte
similarity index 100%
rename from ts/editor/editor-toolbar/BoldButton.svelte
rename to ts/routes/editor/editor-toolbar/BoldButton.svelte
diff --git a/ts/editor/editor-toolbar/ColorPicker.svelte b/ts/routes/editor/editor-toolbar/ColorPicker.svelte
similarity index 100%
rename from ts/editor/editor-toolbar/ColorPicker.svelte
rename to ts/routes/editor/editor-toolbar/ColorPicker.svelte
diff --git a/ts/editor/editor-toolbar/CommandIconButton.svelte b/ts/routes/editor/editor-toolbar/CommandIconButton.svelte
similarity index 100%
rename from ts/editor/editor-toolbar/CommandIconButton.svelte
rename to ts/routes/editor/editor-toolbar/CommandIconButton.svelte
diff --git a/ts/editor/editor-toolbar/EditorToolbar.svelte b/ts/routes/editor/editor-toolbar/EditorToolbar.svelte
similarity index 100%
rename from ts/editor/editor-toolbar/EditorToolbar.svelte
rename to ts/routes/editor/editor-toolbar/EditorToolbar.svelte
diff --git a/ts/editor/editor-toolbar/HighlightColorButton.svelte b/ts/routes/editor/editor-toolbar/HighlightColorButton.svelte
similarity index 100%
rename from ts/editor/editor-toolbar/HighlightColorButton.svelte
rename to ts/routes/editor/editor-toolbar/HighlightColorButton.svelte
diff --git a/ts/editor/editor-toolbar/ImageOcclusionButton.svelte b/ts/routes/editor/editor-toolbar/ImageOcclusionButton.svelte
similarity index 94%
rename from ts/editor/editor-toolbar/ImageOcclusionButton.svelte
rename to ts/routes/editor/editor-toolbar/ImageOcclusionButton.svelte
index c9e8bc6fd..712ed9676 100644
--- a/ts/editor/editor-toolbar/ImageOcclusionButton.svelte
+++ b/ts/routes/editor/editor-toolbar/ImageOcclusionButton.svelte
@@ -20,8 +20,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import {
ioImageLoadedStore,
ioMaskEditorVisible,
- } from "../../routes/image-occlusion/store";
- import { toggleMaskEditorKeyCombination } from "../../routes/image-occlusion/tools/shortcuts";
+ } from "../../image-occlusion/store";
+ import { toggleMaskEditorKeyCombination } from "../../image-occlusion/tools/shortcuts";
export let api = {};
diff --git a/ts/editor/editor-toolbar/InlineButtons.svelte b/ts/routes/editor/editor-toolbar/InlineButtons.svelte
similarity index 100%
rename from ts/editor/editor-toolbar/InlineButtons.svelte
rename to ts/routes/editor/editor-toolbar/InlineButtons.svelte
diff --git a/ts/editor/editor-toolbar/ItalicButton.svelte b/ts/routes/editor/editor-toolbar/ItalicButton.svelte
similarity index 100%
rename from ts/editor/editor-toolbar/ItalicButton.svelte
rename to ts/routes/editor/editor-toolbar/ItalicButton.svelte
diff --git a/ts/editor/editor-toolbar/LatexButton.svelte b/ts/routes/editor/editor-toolbar/LatexButton.svelte
similarity index 98%
rename from ts/editor/editor-toolbar/LatexButton.svelte
rename to ts/routes/editor/editor-toolbar/LatexButton.svelte
index 1d0df1f2e..78731fa81 100644
--- a/ts/editor/editor-toolbar/LatexButton.svelte
+++ b/ts/routes/editor/editor-toolbar/LatexButton.svelte
@@ -15,7 +15,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import Shortcut from "$lib/components/Shortcut.svelte";
import WithFloating from "$lib/components/WithFloating.svelte";
- import { mathjaxConfig } from "../../editable/mathjax-element.svelte";
+ import { mathjaxConfig } from "$lib/editable/mathjax-element.svelte";
import { context as noteEditorContext } from "../NoteEditor.svelte";
import type { RichTextInputAPI } from "../rich-text-input";
import { editingInputIsRichText } from "../rich-text-input";
diff --git a/ts/editor/editor-toolbar/NotetypeButtons.svelte b/ts/routes/editor/editor-toolbar/NotetypeButtons.svelte
similarity index 100%
rename from ts/editor/editor-toolbar/NotetypeButtons.svelte
rename to ts/routes/editor/editor-toolbar/NotetypeButtons.svelte
diff --git a/ts/editor/editor-toolbar/OptionsButton.svelte b/ts/routes/editor/editor-toolbar/OptionsButton.svelte
similarity index 97%
rename from ts/editor/editor-toolbar/OptionsButton.svelte
rename to ts/routes/editor/editor-toolbar/OptionsButton.svelte
index 0f4e346ae..b3c54ed0f 100644
--- a/ts/editor/editor-toolbar/OptionsButton.svelte
+++ b/ts/routes/editor/editor-toolbar/OptionsButton.svelte
@@ -14,7 +14,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import Popover from "$lib/components/Popover.svelte";
import WithFloating from "$lib/components/WithFloating.svelte";
- import { mathjaxConfig } from "../../editable/mathjax-element.svelte";
+ import { mathjaxConfig } from "$lib/editable/mathjax-element.svelte";
import { shrinkImagesByDefault } from "../image-overlay/ImageOverlay.svelte";
import { closeHTMLTags } from "../plain-text-input/PlainTextInput.svelte";
diff --git a/ts/editor/editor-toolbar/OptionsButtons.svelte b/ts/routes/editor/editor-toolbar/OptionsButtons.svelte
similarity index 100%
rename from ts/editor/editor-toolbar/OptionsButtons.svelte
rename to ts/routes/editor/editor-toolbar/OptionsButtons.svelte
diff --git a/ts/editor/editor-toolbar/RemoveFormatButton.svelte b/ts/routes/editor/editor-toolbar/RemoveFormatButton.svelte
similarity index 100%
rename from ts/editor/editor-toolbar/RemoveFormatButton.svelte
rename to ts/routes/editor/editor-toolbar/RemoveFormatButton.svelte
diff --git a/ts/editor/editor-toolbar/RichTextClozeButtons.svelte b/ts/routes/editor/editor-toolbar/RichTextClozeButtons.svelte
similarity index 100%
rename from ts/editor/editor-toolbar/RichTextClozeButtons.svelte
rename to ts/routes/editor/editor-toolbar/RichTextClozeButtons.svelte
diff --git a/ts/editor/editor-toolbar/SubscriptButton.svelte b/ts/routes/editor/editor-toolbar/SubscriptButton.svelte
similarity index 100%
rename from ts/editor/editor-toolbar/SubscriptButton.svelte
rename to ts/routes/editor/editor-toolbar/SubscriptButton.svelte
diff --git a/ts/editor/editor-toolbar/SuperscriptButton.svelte b/ts/routes/editor/editor-toolbar/SuperscriptButton.svelte
similarity index 100%
rename from ts/editor/editor-toolbar/SuperscriptButton.svelte
rename to ts/routes/editor/editor-toolbar/SuperscriptButton.svelte
diff --git a/ts/editor/editor-toolbar/TemplateButtons.svelte b/ts/routes/editor/editor-toolbar/TemplateButtons.svelte
similarity index 100%
rename from ts/editor/editor-toolbar/TemplateButtons.svelte
rename to ts/routes/editor/editor-toolbar/TemplateButtons.svelte
diff --git a/ts/editor/editor-toolbar/TextAttributeButton.svelte b/ts/routes/editor/editor-toolbar/TextAttributeButton.svelte
similarity index 100%
rename from ts/editor/editor-toolbar/TextAttributeButton.svelte
rename to ts/routes/editor/editor-toolbar/TextAttributeButton.svelte
diff --git a/ts/editor/editor-toolbar/TextColorButton.svelte b/ts/routes/editor/editor-toolbar/TextColorButton.svelte
similarity index 100%
rename from ts/editor/editor-toolbar/TextColorButton.svelte
rename to ts/routes/editor/editor-toolbar/TextColorButton.svelte
diff --git a/ts/editor/editor-toolbar/UnderlineButton.svelte b/ts/routes/editor/editor-toolbar/UnderlineButton.svelte
similarity index 100%
rename from ts/editor/editor-toolbar/UnderlineButton.svelte
rename to ts/routes/editor/editor-toolbar/UnderlineButton.svelte
diff --git a/ts/editor/editor-toolbar/WithColorHelper.svelte b/ts/routes/editor/editor-toolbar/WithColorHelper.svelte
similarity index 100%
rename from ts/editor/editor-toolbar/WithColorHelper.svelte
rename to ts/routes/editor/editor-toolbar/WithColorHelper.svelte
diff --git a/ts/editor/editor-toolbar/index.ts b/ts/routes/editor/editor-toolbar/index.ts
similarity index 100%
rename from ts/editor/editor-toolbar/index.ts
rename to ts/routes/editor/editor-toolbar/index.ts
diff --git a/ts/editor/helpers.ts b/ts/routes/editor/helpers.ts
similarity index 100%
rename from ts/editor/helpers.ts
rename to ts/routes/editor/helpers.ts
diff --git a/ts/editor/image-overlay/FloatButtons.svelte b/ts/routes/editor/image-overlay/FloatButtons.svelte
similarity index 100%
rename from ts/editor/image-overlay/FloatButtons.svelte
rename to ts/routes/editor/image-overlay/FloatButtons.svelte
diff --git a/ts/editor/image-overlay/ImageOverlay.svelte b/ts/routes/editor/image-overlay/ImageOverlay.svelte
similarity index 100%
rename from ts/editor/image-overlay/ImageOverlay.svelte
rename to ts/routes/editor/image-overlay/ImageOverlay.svelte
diff --git a/ts/editor/image-overlay/SizeSelect.svelte b/ts/routes/editor/image-overlay/SizeSelect.svelte
similarity index 100%
rename from ts/editor/image-overlay/SizeSelect.svelte
rename to ts/routes/editor/image-overlay/SizeSelect.svelte
diff --git a/ts/editor/image-overlay/index.ts b/ts/routes/editor/image-overlay/index.ts
similarity index 100%
rename from ts/editor/image-overlay/index.ts
rename to ts/routes/editor/image-overlay/index.ts
diff --git a/ts/editor/legacy.scss b/ts/routes/editor/legacy.scss
similarity index 100%
rename from ts/editor/legacy.scss
rename to ts/routes/editor/legacy.scss
diff --git a/ts/editor/mathjax-overlay/MathjaxButtons.svelte b/ts/routes/editor/mathjax-overlay/MathjaxButtons.svelte
similarity index 100%
rename from ts/editor/mathjax-overlay/MathjaxButtons.svelte
rename to ts/routes/editor/mathjax-overlay/MathjaxButtons.svelte
diff --git a/ts/editor/mathjax-overlay/MathjaxEditor.svelte b/ts/routes/editor/mathjax-overlay/MathjaxEditor.svelte
similarity index 100%
rename from ts/editor/mathjax-overlay/MathjaxEditor.svelte
rename to ts/routes/editor/mathjax-overlay/MathjaxEditor.svelte
diff --git a/ts/editor/mathjax-overlay/MathjaxOverlay.svelte b/ts/routes/editor/mathjax-overlay/MathjaxOverlay.svelte
similarity index 98%
rename from ts/editor/mathjax-overlay/MathjaxOverlay.svelte
rename to ts/routes/editor/mathjax-overlay/MathjaxOverlay.svelte
index 5442fd05c..09fe33a5e 100644
--- a/ts/editor/mathjax-overlay/MathjaxOverlay.svelte
+++ b/ts/routes/editor/mathjax-overlay/MathjaxOverlay.svelte
@@ -19,8 +19,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import { placeCaretAfter } from "$lib/domlib/place-caret";
import { isComposing } from "$lib/sveltelib/composition";
- import { escapeSomeEntities, unescapeSomeEntities } from "../../editable/mathjax";
- import { Mathjax } from "../../editable/mathjax-element.svelte";
+ import { escapeSomeEntities, unescapeSomeEntities } from "$lib/editable/mathjax";
+ import { Mathjax } from "$lib/editable/mathjax-element.svelte";
import type { EditingInputAPI } from "../EditingArea.svelte";
import HandleBackground from "../HandleBackground.svelte";
import { context } from "../NoteEditor.svelte";
diff --git a/ts/editor/mathjax-overlay/index.ts b/ts/routes/editor/mathjax-overlay/index.ts
similarity index 100%
rename from ts/editor/mathjax-overlay/index.ts
rename to ts/routes/editor/mathjax-overlay/index.ts
diff --git a/ts/editor/old-editor-adapter.ts b/ts/routes/editor/old-editor-adapter.ts
similarity index 93%
rename from ts/editor/old-editor-adapter.ts
rename to ts/routes/editor/old-editor-adapter.ts
index 6b6dcad82..260164116 100644
--- a/ts/editor/old-editor-adapter.ts
+++ b/ts/routes/editor/old-editor-adapter.ts
@@ -4,7 +4,7 @@
import { updateAllState } from "$lib/components/WithState.svelte";
import { execCommand } from "$lib/domlib";
-import { filterHTML } from "../html-filter";
+import { filterHTML } from "$lib/html-filter";
export function pasteHTML(
html: string,
diff --git a/ts/editor/plain-text-input/PlainTextInput.svelte b/ts/routes/editor/plain-text-input/PlainTextInput.svelte
similarity index 100%
rename from ts/editor/plain-text-input/PlainTextInput.svelte
rename to ts/routes/editor/plain-text-input/PlainTextInput.svelte
diff --git a/ts/editor/plain-text-input/index.ts b/ts/routes/editor/plain-text-input/index.ts
similarity index 100%
rename from ts/editor/plain-text-input/index.ts
rename to ts/routes/editor/plain-text-input/index.ts
diff --git a/ts/editor/plain-text-input/remove-prohibited.ts b/ts/routes/editor/plain-text-input/remove-prohibited.ts
similarity index 100%
rename from ts/editor/plain-text-input/remove-prohibited.ts
rename to ts/routes/editor/plain-text-input/remove-prohibited.ts
diff --git a/ts/editor/plain-text-input/transform.ts b/ts/routes/editor/plain-text-input/transform.ts
similarity index 100%
rename from ts/editor/plain-text-input/transform.ts
rename to ts/routes/editor/plain-text-input/transform.ts
diff --git a/ts/editor/rich-text-input/CustomStyles.svelte b/ts/routes/editor/rich-text-input/CustomStyles.svelte
similarity index 100%
rename from ts/editor/rich-text-input/CustomStyles.svelte
rename to ts/routes/editor/rich-text-input/CustomStyles.svelte
diff --git a/ts/editor/rich-text-input/RichTextInput.svelte b/ts/routes/editor/rich-text-input/RichTextInput.svelte
similarity index 98%
rename from ts/editor/rich-text-input/RichTextInput.svelte
rename to ts/routes/editor/rich-text-input/RichTextInput.svelte
index 88549aefc..0d6d0993a 100644
--- a/ts/editor/rich-text-input/RichTextInput.svelte
+++ b/ts/routes/editor/rich-text-input/RichTextInput.svelte
@@ -7,7 +7,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import type { InputHandlerAPI } from "$lib/sveltelib/input-handler";
- import type { ContentEditableAPI } from "../../editable/ContentEditable.svelte";
+ import type { ContentEditableAPI } from "$lib/editable/ContentEditable.svelte";
import type { EditingInputAPI, FocusableInputAPI } from "../EditingArea.svelte";
import type { SurroundedAPI } from "../surround";
@@ -74,7 +74,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import useInputHandler from "$lib/sveltelib/input-handler";
import { pageTheme } from "$lib/sveltelib/theme";
- import ContentEditable from "../../editable/ContentEditable.svelte";
+ import ContentEditable from "$lib/editable/ContentEditable.svelte";
import { context as editingAreaContext } from "../EditingArea.svelte";
import { Flag } from "../helpers";
import { context as noteEditorContext } from "../NoteEditor.svelte";
diff --git a/ts/editor/rich-text-input/RichTextStyles.svelte b/ts/routes/editor/rich-text-input/RichTextStyles.svelte
similarity index 100%
rename from ts/editor/rich-text-input/RichTextStyles.svelte
rename to ts/routes/editor/rich-text-input/RichTextStyles.svelte
diff --git a/ts/editor/rich-text-input/StyleLink.svelte b/ts/routes/editor/rich-text-input/StyleLink.svelte
similarity index 100%
rename from ts/editor/rich-text-input/StyleLink.svelte
rename to ts/routes/editor/rich-text-input/StyleLink.svelte
diff --git a/ts/editor/rich-text-input/StyleTag.svelte b/ts/routes/editor/rich-text-input/StyleTag.svelte
similarity index 100%
rename from ts/editor/rich-text-input/StyleTag.svelte
rename to ts/routes/editor/rich-text-input/StyleTag.svelte
diff --git a/ts/editor/rich-text-input/index.ts b/ts/routes/editor/rich-text-input/index.ts
similarity index 100%
rename from ts/editor/rich-text-input/index.ts
rename to ts/routes/editor/rich-text-input/index.ts
diff --git a/ts/editor/rich-text-input/normalizing-node-store.ts b/ts/routes/editor/rich-text-input/normalizing-node-store.ts
similarity index 92%
rename from ts/editor/rich-text-input/normalizing-node-store.ts
rename to ts/routes/editor/rich-text-input/normalizing-node-store.ts
index 197322faf..9b1cd2d0a 100644
--- a/ts/editor/rich-text-input/normalizing-node-store.ts
+++ b/ts/routes/editor/rich-text-input/normalizing-node-store.ts
@@ -4,7 +4,7 @@
import type { NodeStore } from "$lib/sveltelib/node-store";
import { nodeStore } from "$lib/sveltelib/node-store";
-import type { DecoratedElement } from "../../editable/decorated";
+import type { DecoratedElement } from "$lib/editable/decorated";
import { decoratedElements } from "../decorated-elements";
function normalizeFragment(fragment: DocumentFragment): void {
diff --git a/ts/editor/rich-text-input/rich-text-resolve.ts b/ts/routes/editor/rich-text-input/rich-text-resolve.ts
similarity index 100%
rename from ts/editor/rich-text-input/rich-text-resolve.ts
rename to ts/routes/editor/rich-text-input/rich-text-resolve.ts
diff --git a/ts/editor/rich-text-input/transform.ts b/ts/routes/editor/rich-text-input/transform.ts
similarity index 100%
rename from ts/editor/rich-text-input/transform.ts
rename to ts/routes/editor/rich-text-input/transform.ts
diff --git a/ts/editor/surround.ts b/ts/routes/editor/surround.ts
similarity index 100%
rename from ts/editor/surround.ts
rename to ts/routes/editor/surround.ts
diff --git a/ts/editor/types.ts b/ts/routes/editor/types.ts
similarity index 92%
rename from ts/editor/types.ts
rename to ts/routes/editor/types.ts
index 14cece175..4ce9fd730 100644
--- a/ts/editor/types.ts
+++ b/ts/routes/editor/types.ts
@@ -27,3 +27,5 @@ export enum EditorState {
ImageOcclusionMasks = 2,
ImageOcclusionFields = 3,
}
+
+export type EditorMode = "add" | "browse" | "review";
diff --git a/ts/routes/tmp/_page.ts b/ts/routes/tmp/_page.ts
index 185bba104..f68486ecf 100644
--- a/ts/routes/tmp/_page.ts
+++ b/ts/routes/tmp/_page.ts
@@ -2,5 +2,4 @@
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
// this route pulls in code that's currently bundled separately, so that
// errors in it get caught by svelte-check
-import * as _editor from "$lib/../editor";
import * as _reviewer from "$lib/../reviewer";