@riebeckite/plugin-excalidraw 0.0.12 → 0.0.14

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.
Files changed (3) hide show
  1. package/README.md +89 -89
  2. package/README_ja.md +48 -48
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -1,90 +1,90 @@
1
- # @riebeckite/plugin-excalidraw
2
-
3
- Excalidraw drawing rendering for Obsidian wikilinks.
4
-
5
- [日本語](./README_ja.md)
6
-
7
- ## Overview
8
-
9
- `excalidraw()` provides the `renderAttachment` hook that
10
- `@riebeckite/plugin-obsidian-markdown` uses when an embedded wikilink
11
- (`![[drawing.excalidraw]]`) resolves to an Excalidraw file. The plugin emits a
12
- placeholder figure carrying the drawing payload, and the client entry renders
13
- it to SVG.
14
-
15
- ## Usage
16
-
17
- ```ts
18
- import { defineConfig } from "@riebeckite/core";
19
- import { excalidraw } from "@riebeckite/plugin-excalidraw";
20
- import { obsidianMarkdown } from "@riebeckite/plugin-obsidian-markdown";
21
-
22
- export default defineConfig({
23
- // ...
24
- plugins: [obsidianMarkdown(), excalidraw()],
25
- });
26
- ```
27
-
28
- The plugin registers `style.css` and a client entry (`initExcalidraw`) that
29
- the app calls on page initialization.
30
-
31
- ## Supported formats
32
-
33
- ### `*.excalidraw` — plain JSON scene
34
-
35
- A compact Excalidraw export with `elements`, optional `appState`, and
36
- `files`.
37
-
38
- ### `*.excalidraw.md` — Obsidian Excalidraw drawing
39
-
40
- Obsidian "Excalidraw" plugin stores drawings in Markdown. The `## Drawing`
41
- fenced code block is extracted and supports both `json` and lz-string
42
- `compressed-json` variants.
43
-
44
- ## Behavior
45
-
46
- ### Build (`renderAttachment`)
47
-
48
- - Only handles embedded wikilinks (`![[...]]`) to paths ending in
49
- `.excalidraw` or `.excalidraw.md`; everything else returns `null` and falls
50
- through to the attachment plugin
51
- - Reads the file under `config.content.directory` (path-traversal safe)
52
- - Parses the scene and emits
53
-
54
- ```html
55
- <figure class="rr-excalidraw" data-excalidraw="pending" data-excalidraw-lazy="true">
56
- <div class="rr-excalidraw__canvas" role="img" aria-label="drawing.excalidraw"></div>
57
- <script type="application/json" class="rr-excalidraw__payload">{"elements":[...],"appState":{...},"files":{...}}</script>
58
- </figure>
59
- ```
60
-
61
- - Wikilink aliases can set a size: `![[drawing.excalidraw|800]]` (width) or
62
- `![[drawing.excalidraw|800x600]]` (width x height)
63
- - Missing files, invalid scenes, or out-of-directory paths render an error
64
- placeholder and log to the console
65
-
66
- ### Client (`initExcalidraw`)
67
-
68
- - Renders pending figures to SVG with `exportToSvg` from
69
- `@excalidraw/excalidraw`
70
- - Figures marked `data-excalidraw-lazy="false"` render immediately; the rest
71
- render when they scroll into view (`IntersectionObserver`, 200px margin)
72
- - Success → `data-excalidraw="ready"` (the SVG replaces the empty canvas)
73
- - Failure → `data-excalidraw="error"` plus a placeholder message
74
-
75
- ## Options
76
-
77
- | Option | Type | Default | Description |
78
- | ------ | ---- | ------- | ----------- |
79
- | `lazy` | `boolean` | `true` | Render lazily in the browser (as the figure enters the viewport) instead of immediately |
80
-
81
- ## Exports
82
-
83
- - `excalidraw(options?)` / `excalidrawPlugin` — plugin factory
84
- - Type: `ExcalidrawOptions`
85
-
86
- ## See also
87
-
88
- - [Plugin guide](../../../docs/en/plugin-system.md)
89
- - [`@riebeckite/plugin-obsidian-markdown`](../obsidian-markdown/README.md)
1
+ # @riebeckite/plugin-excalidraw
2
+
3
+ Excalidraw drawing rendering for Obsidian wikilinks.
4
+
5
+ [日本語](./README_ja.md)
6
+
7
+ ## Overview
8
+
9
+ `excalidraw()` provides the `renderAttachment` hook that
10
+ `@riebeckite/plugin-obsidian-markdown` uses when an embedded wikilink
11
+ (`![[drawing.excalidraw]]`) resolves to an Excalidraw file. The plugin emits a
12
+ placeholder figure carrying the drawing payload, and the client entry renders
13
+ it to SVG.
14
+
15
+ ## Usage
16
+
17
+ ```ts
18
+ import { defineConfig } from "@riebeckite/core";
19
+ import { excalidraw } from "@riebeckite/plugin-excalidraw";
20
+ import { obsidianMarkdown } from "@riebeckite/plugin-obsidian-markdown";
21
+
22
+ export default defineConfig({
23
+ // ...
24
+ plugins: [obsidianMarkdown(), excalidraw()],
25
+ });
26
+ ```
27
+
28
+ The plugin registers `style.css` and a client entry (`initExcalidraw`) that
29
+ the app calls on page initialization.
30
+
31
+ ## Supported formats
32
+
33
+ ### `*.excalidraw` — plain JSON scene
34
+
35
+ A compact Excalidraw export with `elements`, optional `appState`, and
36
+ `files`.
37
+
38
+ ### `*.excalidraw.md` — Obsidian Excalidraw drawing
39
+
40
+ Obsidian "Excalidraw" plugin stores drawings in Markdown. The `## Drawing`
41
+ fenced code block is extracted and supports both `json` and lz-string
42
+ `compressed-json` variants.
43
+
44
+ ## Behavior
45
+
46
+ ### Build (`renderAttachment`)
47
+
48
+ - Only handles embedded wikilinks (`![[...]]`) to paths ending in
49
+ `.excalidraw` or `.excalidraw.md`; everything else returns `null` and falls
50
+ through to the attachment plugin
51
+ - Reads the file under `config.content.directory` (path-traversal safe)
52
+ - Parses the scene and emits
53
+
54
+ ```html
55
+ <figure class="rr-excalidraw" data-excalidraw="pending" data-excalidraw-lazy="true">
56
+ <div class="rr-excalidraw__canvas" role="img" aria-label="drawing.excalidraw"></div>
57
+ <script type="application/json" class="rr-excalidraw__payload">{"elements":[...],"appState":{...},"files":{...}}</script>
58
+ </figure>
59
+ ```
60
+
61
+ - Wikilink aliases can set a size: `![[drawing.excalidraw|800]]` (width) or
62
+ `![[drawing.excalidraw|800x600]]` (width x height)
63
+ - Missing files, invalid scenes, or out-of-directory paths render an error
64
+ placeholder and log to the console
65
+
66
+ ### Client (`initExcalidraw`)
67
+
68
+ - Renders pending figures to SVG with `exportToSvg` from
69
+ `@excalidraw/excalidraw`
70
+ - Figures marked `data-excalidraw-lazy="false"` render immediately; the rest
71
+ render when they scroll into view (`IntersectionObserver`, 200px margin)
72
+ - Success → `data-excalidraw="ready"` (the SVG replaces the empty canvas)
73
+ - Failure → `data-excalidraw="error"` plus a placeholder message
74
+
75
+ ## Options
76
+
77
+ | Option | Type | Default | Description |
78
+ | ------ | ---- | ------- | ----------- |
79
+ | `lazy` | `boolean` | `true` | Render lazily in the browser (as the figure enters the viewport) instead of immediately |
80
+
81
+ ## Exports
82
+
83
+ - `excalidraw(options?)` / `excalidrawPlugin` — plugin factory
84
+ - Type: `ExcalidrawOptions`
85
+
86
+ ## See also
87
+
88
+ - [Plugin guide](../../../docs/en/reference/plugin-api.md)
89
+ - [`@riebeckite/plugin-obsidian-markdown`](../obsidian-markdown/README.md)
90
90
  - [`@riebeckite/plugin-attachment`](../attachment/README.md)
package/README_ja.md CHANGED
@@ -1,48 +1,48 @@
1
- # @riebeckite/plugin-excalidraw
2
-
3
- Obsidian の Excalidraw 埋め込みを SVG として表示するプラグインです。
4
-
5
- [English](./README.md)
6
-
7
- ## できること
8
-
9
- `![[drawing.excalidraw]]` のような埋め込みウィキリンクを検出し、図のデータを含むプレースホルダーを出力します。ブラウザ側の `initExcalidraw` が、そのプレースホルダーを SVG に置き換えます。通常のリンクや対象外のファイルは処理せず、添付ファイル用のレンダラーに任せます。
10
-
11
- ## 設定
12
-
13
- ```ts
14
- import { defineConfig } from "@riebeckite/core";
15
- import { excalidraw } from "@riebeckite/plugin-excalidraw";
16
- import { obsidianMarkdown } from "@riebeckite/plugin-obsidian-markdown";
17
-
18
- export default defineConfig({
19
- // ...
20
- plugins: [obsidianMarkdown(), excalidraw()],
21
- });
22
- ```
23
-
24
- ## 読み込めるファイル
25
-
26
- - `*.excalidraw` — `elements`、任意の `appState` と `files` を持つ JSON シーン
27
- - `*.excalidraw.md` — Obsidian Excalidraw が保存する Markdown。`## Drawing` 内の `json` と `compressed-json` を読み取ります。
28
-
29
- `![[drawing.excalidraw|800]]` なら幅を、`![[drawing.excalidraw|800x600]]` なら幅と高さを指定できます。ファイルがない、内容が不正、またはコンテンツディレクトリ外を指す場合は、エラー用プレースホルダーを表示します。
30
-
31
- ## 描画のタイミング
32
-
33
- 既定では、図が表示領域の近くに入ってから描画します。`IntersectionObserver` が使えない環境を含め、描画に失敗した要素は `data-excalidraw="error"` になり、エラー表示へ切り替わります。
34
-
35
- | オプション | 型 | 既定値 | 内容 |
36
- | --- | --- | --- | --- |
37
- | `lazy` | `boolean` | `true` | 表示領域に近づいてから SVG を描画するか |
38
-
39
- ## 公開 API
40
-
41
- - `excalidraw(options?)` / `excalidrawPlugin` — プラグインファクトリ
42
- - `ExcalidrawOptions` — オプションの型
43
-
44
- ## 関連資料
45
-
46
- - [プラグインシステム](../../../docs/ja/plugin-system.md)
47
- - [`@riebeckite/plugin-obsidian-markdown`](../obsidian-markdown/README_ja.md)
48
- - [`@riebeckite/plugin-attachment`](../attachment/README_ja.md)
1
+ # @riebeckite/plugin-excalidraw
2
+
3
+ Obsidian の Excalidraw 埋め込みを SVG として表示するプラグインです。
4
+
5
+ [English](./README.md)
6
+
7
+ ## できること
8
+
9
+ `![[drawing.excalidraw]]` のような埋め込みウィキリンクを検出し、図のデータを含むプレースホルダーを出力します。ブラウザ側の `initExcalidraw` が、そのプレースホルダーを SVG に置き換えます。通常のリンクや対象外のファイルは処理せず、添付ファイル用のレンダラーに任せます。
10
+
11
+ ## 設定
12
+
13
+ ```ts
14
+ import { defineConfig } from "@riebeckite/core";
15
+ import { excalidraw } from "@riebeckite/plugin-excalidraw";
16
+ import { obsidianMarkdown } from "@riebeckite/plugin-obsidian-markdown";
17
+
18
+ export default defineConfig({
19
+ // ...
20
+ plugins: [obsidianMarkdown(), excalidraw()],
21
+ });
22
+ ```
23
+
24
+ ## 読み込めるファイル
25
+
26
+ - `*.excalidraw` — `elements`、任意の `appState` と `files` を持つ JSON シーン
27
+ - `*.excalidraw.md` — Obsidian Excalidraw が保存する Markdown。`## Drawing` 内の `json` と `compressed-json` を読み取ります。
28
+
29
+ `![[drawing.excalidraw|800]]` なら幅を、`![[drawing.excalidraw|800x600]]` なら幅と高さを指定できます。ファイルがない、内容が不正、またはコンテンツディレクトリ外を指す場合は、エラー用プレースホルダーを表示します。
30
+
31
+ ## 描画のタイミング
32
+
33
+ 既定では、図が表示領域の近くに入ってから描画します。`IntersectionObserver` が使えない環境を含め、描画に失敗した要素は `data-excalidraw="error"` になり、エラー表示へ切り替わります。
34
+
35
+ | オプション | 型 | 既定値 | 内容 |
36
+ | --- | --- | --- | --- |
37
+ | `lazy` | `boolean` | `true` | 表示領域に近づいてから SVG を描画するか |
38
+
39
+ ## 公開 API
40
+
41
+ - `excalidraw(options?)` / `excalidrawPlugin` — プラグインファクトリ
42
+ - `ExcalidrawOptions` — オプションの型
43
+
44
+ ## 関連資料
45
+
46
+ - [プラグインシステム](../../../docs/ja/reference/plugin-api.md)
47
+ - [`@riebeckite/plugin-obsidian-markdown`](../obsidian-markdown/README_ja.md)
48
+ - [`@riebeckite/plugin-attachment`](../attachment/README_ja.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/plugin-excalidraw",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -24,7 +24,7 @@
24
24
  "@excalidraw/excalidraw": "^0.18.0",
25
25
  "lz-string": "^1.5.0",
26
26
  "unist-util-visit": "^5.0.0",
27
- "@riebeckite/core": "0.0.12"
27
+ "@riebeckite/core": "0.0.14"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/mdast": "^4.0.4"