Big refactors and fixes

* Query regen
* Fix anchor completion
* Dependency fixes
* Changelog update
This commit is contained in:
Zef Hemel
2023-07-02 11:25:32 +02:00
committed by GitHub
parent fee2c5928e
commit 7c825348b2
74 changed files with 935 additions and 567 deletions
+8 -10
View File
@@ -8,6 +8,7 @@ import {
import { decoratorStateField } from "./util.ts";
import type { Space } from "../space.ts";
import type { Editor } from "../editor.tsx";
class InlineImageWidget extends WidgetType {
constructor(
@@ -39,13 +40,7 @@ class InlineImageWidget extends WidgetType {
this.space.setCachedImageHeight(this.url, img.height);
}
};
if (this.url.startsWith("http")) {
img.src = this.url;
} else {
// This is an attachment image, rewrite the URL a little
img.src = `/.fs/${decodeURIComponent(this.url)}`;
}
img.src = this.url;
img.alt = this.title;
img.title = this.title;
img.style.display = "block";
@@ -58,7 +53,7 @@ class InlineImageWidget extends WidgetType {
}
}
export function inlineImagesPlugin(space: Space) {
export function inlineImagesPlugin(editor: Editor) {
return decoratorStateField((state: EditorState) => {
const widgets: Range<Decoration>[] = [];
const imageRegex = /!\[(?<title>[^\]]*)\]\((?<url>.+)\)/;
@@ -76,11 +71,14 @@ export function inlineImagesPlugin(space: Space) {
return;
}
const url = imageRexexResult.groups.url;
let url = imageRexexResult.groups.url;
const title = imageRexexResult.groups.title;
if (url.indexOf("://") === -1) {
url = `/.fs/${url}`;
}
widgets.push(
Decoration.widget({
widget: new InlineImageWidget(url, title, space),
widget: new InlineImageWidget(url, title, editor.space),
block: true,
}).range(node.to),
);