Add interface languages and improve themes and workspace controls for 0.1.36
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { tr } from '../i18n/index.ts';
|
||||
import { EditorView, WidgetType } from "@codemirror/view";
|
||||
import { isolateHistory } from "@codemirror/commands";
|
||||
import { imageControls, type ImageActions } from "./imageControls";
|
||||
@@ -48,9 +49,9 @@ export class ImagePreview extends WidgetType {
|
||||
report: this.context.report,
|
||||
swap: async image => {
|
||||
const before = view.state.doc;
|
||||
const path = (await requestText("Image path relative to this note, or https URL", image.dataset.mdSrc || ""))?.trim();
|
||||
const path = (await requestText(tr("Image path relative to this note, or https URL"), image.dataset.mdSrc || ""))?.trim();
|
||||
if (!path || !dom.isConnected || view.state.doc !== before) return;
|
||||
if (!isRemoteImage(path) && /^[a-z][a-z\d+.-]*:/i.test(path)) throw new Error("Choose a workspace image path or an http/https URL.");
|
||||
if (!isRemoteImage(path) && /^[a-z][a-z\d+.-]*:/i.test(path)) throw new Error(tr("Choose a workspace image path or an http/https URL."));
|
||||
await this.context.validate?.(path);
|
||||
if (!dom.isConnected || view.state.doc !== before) return;
|
||||
const target = path.replace(/[<>\s]/g, char => encodeURIComponent(char));
|
||||
@@ -63,7 +64,7 @@ export class ImagePreview extends WidgetType {
|
||||
if (!dom.querySelector("img")) {
|
||||
const edit = document.createElement("button");
|
||||
edit.type = "button"; edit.className = "image-action";
|
||||
const label = this.editing ? "Hide image source" : "Edit image source";
|
||||
const label = this.editing ? tr("Hide image source") : tr("Edit image source");
|
||||
edit.setAttribute("aria-label", label); edit.dataset.editorTooltip = label;
|
||||
edit.append(actionIcon("code"));
|
||||
edit.addEventListener("click", event => { event.preventDefault(); event.stopPropagation(); (this.editing ? actions.done : actions.edit)?.(); });
|
||||
|
||||
Reference in New Issue
Block a user