@riebeckite/plugin-excalidraw 0.0.31 → 0.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/README_ja.md +2 -2
- package/dist/client.js +9 -6
- package/dist/index.d.ts +0 -1
- package/dist/index.js +5 -4
- package/dist/src/client_init.d.ts +6 -1
- package/package.json +3 -3
package/README.md
CHANGED
package/README_ja.md
CHANGED
|
@@ -50,7 +50,7 @@ export default defineConfig({
|
|
|
50
50
|
|
|
51
51
|
## 単体ページとしての表示
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
Markdown として保存された Excalidraw の描画は、通常の Markdown ページではなく専用ページとして表示されます。プラグインはページ型(`excalidraw-document`)を登録し、パーマリンク末尾の `.excalidraw` を除いたパスを引き受けます。
|
|
54
54
|
|
|
55
55
|
- 判定: slug が `.excalidraw` で終わる(`*.excalidraw.md`)、または frontmatter に `excalidraw-plugin: parsed` がある
|
|
56
56
|
- `drawing.excalidraw.md`(パーマリンク `/drawing.excalidraw`)は `/drawing` で表示される
|
|
@@ -60,7 +60,7 @@ Excalidraw の描画である Markdown エントリは、通常の Markdown ペ
|
|
|
60
60
|
|
|
61
61
|
## 公開 API
|
|
62
62
|
|
|
63
|
-
- `excalidraw(options?)` / `
|
|
63
|
+
- `excalidraw(options?)` / `excalidraw`:プラグインファクトリ
|
|
64
64
|
- `ExcalidrawOptions`:オプションの型
|
|
65
65
|
|
|
66
66
|
## 関連資料
|
package/dist/client.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// src/client_init.ts
|
|
2
|
-
function initExcalidraw() {
|
|
2
|
+
function initExcalidraw(context = {}) {
|
|
3
|
+
const root = context.root ?? document;
|
|
3
4
|
const figures = Array.from(
|
|
4
|
-
|
|
5
|
+
root.querySelectorAll(
|
|
5
6
|
'.rr-excalidraw[data-excalidraw="pending"]'
|
|
6
7
|
)
|
|
7
8
|
);
|
|
@@ -9,13 +10,13 @@ function initExcalidraw() {
|
|
|
9
10
|
const immediate = figures.filter(
|
|
10
11
|
(figure) => figure.dataset.excalidrawLazy === "false"
|
|
11
12
|
);
|
|
12
|
-
for (const figure of immediate) void renderFigure(figure);
|
|
13
|
+
for (const figure of immediate) void renderFigure(figure, context.signal);
|
|
13
14
|
const lazy = figures.filter(
|
|
14
15
|
(figure) => figure.dataset.excalidrawLazy !== "false"
|
|
15
16
|
);
|
|
16
17
|
if (lazy.length === 0) return;
|
|
17
18
|
if (!("IntersectionObserver" in window)) {
|
|
18
|
-
for (const figure of lazy) void renderFigure(figure);
|
|
19
|
+
for (const figure of lazy) void renderFigure(figure, context.signal);
|
|
19
20
|
return;
|
|
20
21
|
}
|
|
21
22
|
const observer = new IntersectionObserver(
|
|
@@ -24,14 +25,15 @@ function initExcalidraw() {
|
|
|
24
25
|
if (!entry.isIntersecting) continue;
|
|
25
26
|
const figure = entry.target;
|
|
26
27
|
observer.unobserve(figure);
|
|
27
|
-
void renderFigure(figure);
|
|
28
|
+
void renderFigure(figure, context.signal);
|
|
28
29
|
}
|
|
29
30
|
},
|
|
30
31
|
{ rootMargin: "200px" }
|
|
31
32
|
);
|
|
32
33
|
for (const figure of lazy) observer.observe(figure);
|
|
34
|
+
return () => observer.disconnect();
|
|
33
35
|
}
|
|
34
|
-
async function renderFigure(figure) {
|
|
36
|
+
async function renderFigure(figure, signal) {
|
|
35
37
|
const canvas = figure.querySelector(".rr-excalidraw__canvas");
|
|
36
38
|
const payloadScript = figure.querySelector(
|
|
37
39
|
".rr-excalidraw__payload"
|
|
@@ -48,6 +50,7 @@ async function renderFigure(figure) {
|
|
|
48
50
|
},
|
|
49
51
|
files: payload.files
|
|
50
52
|
});
|
|
53
|
+
if (signal?.aborted || !figure.isConnected) return;
|
|
51
54
|
svg.removeAttribute("width");
|
|
52
55
|
svg.removeAttribute("height");
|
|
53
56
|
svg.setAttribute("role", "img");
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { ExcalidrawOptions } from "./src/types.js";
|
|
2
2
|
export type { ExcalidrawOptions } from "./src/types.js";
|
|
3
3
|
export declare function excalidraw(options?: ExcalidrawOptions): import("@riebeckite/core").RiebeckitePlugin<ExcalidrawOptions>;
|
|
4
|
-
export declare const excalidrawPlugin: typeof excalidraw;
|
package/dist/index.js
CHANGED
|
@@ -184,12 +184,14 @@ function excalidraw(options = {}) {
|
|
|
184
184
|
createClientEntry(
|
|
185
185
|
PLUGIN_NAME,
|
|
186
186
|
"@riebeckite/plugin-excalidraw/client",
|
|
187
|
-
"initExcalidraw"
|
|
187
|
+
"initExcalidraw",
|
|
188
|
+
void 0,
|
|
189
|
+
void 0,
|
|
190
|
+
"context"
|
|
188
191
|
)
|
|
189
192
|
]
|
|
190
193
|
});
|
|
191
194
|
}
|
|
192
|
-
var excalidrawPlugin = excalidraw;
|
|
193
195
|
async function renderAttachment(context, options) {
|
|
194
196
|
if (context.kind !== "attachment") return null;
|
|
195
197
|
if (!isExcalidrawPath(context.path)) return null;
|
|
@@ -476,6 +478,5 @@ function getFileName(contentPath) {
|
|
|
476
478
|
return contentPath.split("/").at(-1) ?? contentPath;
|
|
477
479
|
}
|
|
478
480
|
export {
|
|
479
|
-
excalidraw
|
|
480
|
-
excalidrawPlugin
|
|
481
|
+
excalidraw
|
|
481
482
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riebeckite/plugin-excalidraw",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.33",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@excalidraw/excalidraw": "^0.18.0",
|
|
25
|
+
"@riebeckite/core": "0.0.33",
|
|
25
26
|
"lz-string": "^1.5.0",
|
|
26
|
-
"unist-util-visit": "^5.0.0"
|
|
27
|
-
"@riebeckite/core": "0.0.31"
|
|
27
|
+
"unist-util-visit": "^5.0.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/mdast": "^4.0.4",
|