@riebeckite/plugin-sidenotes 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.
- package/README.md +124 -124
- package/README_ja.md +128 -128
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,124 +1,124 @@
|
|
|
1
|
-
# @riebeckite/plugin-sidenotes
|
|
2
|
-
|
|
3
|
-
Tufte-style side notes for Riebeckite. Authors keep writing ordinary GFM
|
|
4
|
-
footnotes (`[^1]` and `[^1]: text`); the plugin rewrites the generated
|
|
5
|
-
footnote markup into an inline reference plus a note that renders as a margin
|
|
6
|
-
note on desktop and as a tap-open popover on mobile.
|
|
7
|
-
|
|
8
|
-
[日本語](./README_ja.md)
|
|
9
|
-
|
|
10
|
-
## Overview
|
|
11
|
-
|
|
12
|
-
The plugin registers a rehype plugin that rewrites the footnote markup the
|
|
13
|
-
core pipeline produces from `remark-gfm`:
|
|
14
|
-
|
|
15
|
-
- Each footnote reference becomes a `sup` with a small reference link
|
|
16
|
-
(`[data-rr-sidenotes-ref]`) that keeps its `href="#fn-…"` target, so the
|
|
17
|
-
footnote stays reachable with plain browser navigation.
|
|
18
|
-
- Each footnote definition becomes a `.rr-sidenotes__note` aside next to the
|
|
19
|
-
reference: a static **margin note** on desktop (`@media (min-width: 48rem)`)
|
|
20
|
-
and a **popover** on mobile (`@media (max-width: 48rem)`).
|
|
21
|
-
- The trailing footnote definitions section is kept (it is the link target
|
|
22
|
-
on mobile and the no-JavaScript fallback) and hidden on desktop, where the
|
|
23
|
-
margin notes are always visible.
|
|
24
|
-
|
|
25
|
-
A small client entry (`initSidenotes`) toggles the mobile popover: tap to
|
|
26
|
-
open/close, `Escape` to close, and click outside to close. It ignores the page
|
|
27
|
-
when `(min-width: 48rem)` matches — desktop margin notes need no JavaScript.
|
|
28
|
-
|
|
29
|
-
## Usage
|
|
30
|
-
|
|
31
|
-
```ts
|
|
32
|
-
import { defineConfig } from "@riebeckite/core";
|
|
33
|
-
import { sidenotes } from "@riebeckite/plugin-sidenotes";
|
|
34
|
-
|
|
35
|
-
export default defineConfig({
|
|
36
|
-
// ...
|
|
37
|
-
plugins: [sidenotes()],
|
|
38
|
-
});
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
Write normal GFM footnotes:
|
|
42
|
-
|
|
43
|
-
```md
|
|
44
|
-
Riebeckite renders margin notes at the side of the text.[^1]
|
|
45
|
-
|
|
46
|
-
[^1]: The note text appears beside the reference on desktop and in a popover on mobile.
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## Options
|
|
50
|
-
|
|
51
|
-
| Option | Type | Default | Description |
|
|
52
|
-
| ------ | ---- | ------- | ----------- |
|
|
53
|
-
| `className` | `string` | `""` | Extra CSS class on each sidenote root |
|
|
54
|
-
| `ariaLabel` | `string` | `"Sidenote"` | Accessible name prefix for each note (`"Sidenote 1"`) |
|
|
55
|
-
| `openLabel` | `string` | `"Footnote"` | Accessible label prefix for a closed reference (`"Footnote 1"`) |
|
|
56
|
-
| `closeLabel` | `string` | `"Close sidenote"` | Accessible label prefix for an open reference (`"Close sidenote 1"`) |
|
|
57
|
-
| `popoverAlignment` | `"bottom" \| "end"` | `"bottom"` | Where the mobile popover is anchored |
|
|
58
|
-
|
|
59
|
-
```ts
|
|
60
|
-
sidenotes({
|
|
61
|
-
ariaLabel: "Note",
|
|
62
|
-
popoverAlignment: "end",
|
|
63
|
-
});
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## Output
|
|
67
|
-
|
|
68
|
-
```html
|
|
69
|
-
<p>
|
|
70
|
-
Riebeckite renders margin notes here.<sup class="rr-sidenotes__ref">
|
|
71
|
-
<a href="#user-content-fn-1" id="user-content-fnref-1" class="rr-sidenotes__toggle"
|
|
72
|
-
data-rr-sidenotes-ref aria-expanded="false" aria-controls="rr-sidenotes-1"
|
|
73
|
-
aria-label="Footnote 1">1</a></sup>
|
|
74
|
-
</p>
|
|
75
|
-
<aside class="rr-sidenotes__note rr-sidenotes__note--popover-bottom" id="rr-sidenotes-1"
|
|
76
|
-
data-rr-sidenotes-note aria-label="Sidenote 1" tabindex="-1">
|
|
77
|
-
<span class="rr-sidenotes__index" aria-hidden="true">1</span>
|
|
78
|
-
<div class="rr-sidenotes__body"><p>The note text appears beside the reference.</p></div>
|
|
79
|
-
</aside>
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
## Accessibility
|
|
83
|
-
|
|
84
|
-
- The reference is a real link (`href="#user-content-fn-…"`) with `aria-expanded`
|
|
85
|
-
and `aria-controls`; the client toggles `aria-expanded` and swaps the label
|
|
86
|
-
between `openLabel` and `closeLabel`.
|
|
87
|
-
- The popover is labelled with `aria-label` and receives focus (`tabindex="-1"`)
|
|
88
|
-
when opened via a script.
|
|
89
|
-
- Without JavaScript, tapping the reference jumps to the footnote definitions
|
|
90
|
-
as in ordinary GFM output.
|
|
91
|
-
|
|
92
|
-
## Style
|
|
93
|
-
|
|
94
|
-
The package ships `style.css`. Register it like any other plugin stylesheet:
|
|
95
|
-
|
|
96
|
-
```ts
|
|
97
|
-
import "@riebeckite/plugin-sidenotes/style.css";
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
Stable hooks follow the `rr-sidenotes` convention: `rr-sidenotes__toggle`,
|
|
101
|
-
`rr-sidenotes__note`, `rr-sidenotes__index`, `rr-sidenotes__body`,
|
|
102
|
-
`rr-sidenotes__footnotes`, plus the `rr-sidenotes__note--open` modifier.
|
|
103
|
-
|
|
104
|
-
## Exports
|
|
105
|
-
|
|
106
|
-
- `sidenotes(options?)` — plugin factory
|
|
107
|
-
- `sidenotesPlugin` — alias of `sidenotes`
|
|
108
|
-
- `rehypeSidenotes(options?)` — the rehype transformer
|
|
109
|
-
- `resolveSidenotesOptions(options?)` — apply option defaults
|
|
110
|
-
- `renderSidenotesReference(input)` / `renderSidenotesNote(input)` — HTML builders
|
|
111
|
-
- `initSidenotes(options?)` — client popover initializer
|
|
112
|
-
- Types: `SidenotesOptions`, `ResolvedSidenotesOptions`, `SidenotesClientOptions`
|
|
113
|
-
|
|
114
|
-
## Limitations
|
|
115
|
-
|
|
116
|
-
- Footnotes that reuse the same definition share one margin note and popover.
|
|
117
|
-
- The footnote definitions section is hidden on desktop; margins must have
|
|
118
|
-
room for the notes, and themes can restyle `.rr-sidenotes__note` freely.
|
|
119
|
-
- Notes inside tables or deeply nested inline markup are placed after the
|
|
120
|
-
nearest block ancestor, so their vertical position is approximate.
|
|
121
|
-
|
|
122
|
-
## See also
|
|
123
|
-
|
|
124
|
-
- [Plugin guide](../../../docs/en/plugin-
|
|
1
|
+
# @riebeckite/plugin-sidenotes
|
|
2
|
+
|
|
3
|
+
Tufte-style side notes for Riebeckite. Authors keep writing ordinary GFM
|
|
4
|
+
footnotes (`[^1]` and `[^1]: text`); the plugin rewrites the generated
|
|
5
|
+
footnote markup into an inline reference plus a note that renders as a margin
|
|
6
|
+
note on desktop and as a tap-open popover on mobile.
|
|
7
|
+
|
|
8
|
+
[日本語](./README_ja.md)
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
The plugin registers a rehype plugin that rewrites the footnote markup the
|
|
13
|
+
core pipeline produces from `remark-gfm`:
|
|
14
|
+
|
|
15
|
+
- Each footnote reference becomes a `sup` with a small reference link
|
|
16
|
+
(`[data-rr-sidenotes-ref]`) that keeps its `href="#fn-…"` target, so the
|
|
17
|
+
footnote stays reachable with plain browser navigation.
|
|
18
|
+
- Each footnote definition becomes a `.rr-sidenotes__note` aside next to the
|
|
19
|
+
reference: a static **margin note** on desktop (`@media (min-width: 48rem)`)
|
|
20
|
+
and a **popover** on mobile (`@media (max-width: 48rem)`).
|
|
21
|
+
- The trailing footnote definitions section is kept (it is the link target
|
|
22
|
+
on mobile and the no-JavaScript fallback) and hidden on desktop, where the
|
|
23
|
+
margin notes are always visible.
|
|
24
|
+
|
|
25
|
+
A small client entry (`initSidenotes`) toggles the mobile popover: tap to
|
|
26
|
+
open/close, `Escape` to close, and click outside to close. It ignores the page
|
|
27
|
+
when `(min-width: 48rem)` matches — desktop margin notes need no JavaScript.
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { defineConfig } from "@riebeckite/core";
|
|
33
|
+
import { sidenotes } from "@riebeckite/plugin-sidenotes";
|
|
34
|
+
|
|
35
|
+
export default defineConfig({
|
|
36
|
+
// ...
|
|
37
|
+
plugins: [sidenotes()],
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Write normal GFM footnotes:
|
|
42
|
+
|
|
43
|
+
```md
|
|
44
|
+
Riebeckite renders margin notes at the side of the text.[^1]
|
|
45
|
+
|
|
46
|
+
[^1]: The note text appears beside the reference on desktop and in a popover on mobile.
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Options
|
|
50
|
+
|
|
51
|
+
| Option | Type | Default | Description |
|
|
52
|
+
| ------ | ---- | ------- | ----------- |
|
|
53
|
+
| `className` | `string` | `""` | Extra CSS class on each sidenote root |
|
|
54
|
+
| `ariaLabel` | `string` | `"Sidenote"` | Accessible name prefix for each note (`"Sidenote 1"`) |
|
|
55
|
+
| `openLabel` | `string` | `"Footnote"` | Accessible label prefix for a closed reference (`"Footnote 1"`) |
|
|
56
|
+
| `closeLabel` | `string` | `"Close sidenote"` | Accessible label prefix for an open reference (`"Close sidenote 1"`) |
|
|
57
|
+
| `popoverAlignment` | `"bottom" \| "end"` | `"bottom"` | Where the mobile popover is anchored |
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
sidenotes({
|
|
61
|
+
ariaLabel: "Note",
|
|
62
|
+
popoverAlignment: "end",
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Output
|
|
67
|
+
|
|
68
|
+
```html
|
|
69
|
+
<p>
|
|
70
|
+
Riebeckite renders margin notes here.<sup class="rr-sidenotes__ref">
|
|
71
|
+
<a href="#user-content-fn-1" id="user-content-fnref-1" class="rr-sidenotes__toggle"
|
|
72
|
+
data-rr-sidenotes-ref aria-expanded="false" aria-controls="rr-sidenotes-1"
|
|
73
|
+
aria-label="Footnote 1">1</a></sup>
|
|
74
|
+
</p>
|
|
75
|
+
<aside class="rr-sidenotes__note rr-sidenotes__note--popover-bottom" id="rr-sidenotes-1"
|
|
76
|
+
data-rr-sidenotes-note aria-label="Sidenote 1" tabindex="-1">
|
|
77
|
+
<span class="rr-sidenotes__index" aria-hidden="true">1</span>
|
|
78
|
+
<div class="rr-sidenotes__body"><p>The note text appears beside the reference.</p></div>
|
|
79
|
+
</aside>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Accessibility
|
|
83
|
+
|
|
84
|
+
- The reference is a real link (`href="#user-content-fn-…"`) with `aria-expanded`
|
|
85
|
+
and `aria-controls`; the client toggles `aria-expanded` and swaps the label
|
|
86
|
+
between `openLabel` and `closeLabel`.
|
|
87
|
+
- The popover is labelled with `aria-label` and receives focus (`tabindex="-1"`)
|
|
88
|
+
when opened via a script.
|
|
89
|
+
- Without JavaScript, tapping the reference jumps to the footnote definitions
|
|
90
|
+
as in ordinary GFM output.
|
|
91
|
+
|
|
92
|
+
## Style
|
|
93
|
+
|
|
94
|
+
The package ships `style.css`. Register it like any other plugin stylesheet:
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
import "@riebeckite/plugin-sidenotes/style.css";
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Stable hooks follow the `rr-sidenotes` convention: `rr-sidenotes__toggle`,
|
|
101
|
+
`rr-sidenotes__note`, `rr-sidenotes__index`, `rr-sidenotes__body`,
|
|
102
|
+
`rr-sidenotes__footnotes`, plus the `rr-sidenotes__note--open` modifier.
|
|
103
|
+
|
|
104
|
+
## Exports
|
|
105
|
+
|
|
106
|
+
- `sidenotes(options?)` — plugin factory
|
|
107
|
+
- `sidenotesPlugin` — alias of `sidenotes`
|
|
108
|
+
- `rehypeSidenotes(options?)` — the rehype transformer
|
|
109
|
+
- `resolveSidenotesOptions(options?)` — apply option defaults
|
|
110
|
+
- `renderSidenotesReference(input)` / `renderSidenotesNote(input)` — HTML builders
|
|
111
|
+
- `initSidenotes(options?)` — client popover initializer
|
|
112
|
+
- Types: `SidenotesOptions`, `ResolvedSidenotesOptions`, `SidenotesClientOptions`
|
|
113
|
+
|
|
114
|
+
## Limitations
|
|
115
|
+
|
|
116
|
+
- Footnotes that reuse the same definition share one margin note and popover.
|
|
117
|
+
- The footnote definitions section is hidden on desktop; margins must have
|
|
118
|
+
room for the notes, and themes can restyle `.rr-sidenotes__note` freely.
|
|
119
|
+
- Notes inside tables or deeply nested inline markup are placed after the
|
|
120
|
+
nearest block ancestor, so their vertical position is approximate.
|
|
121
|
+
|
|
122
|
+
## See also
|
|
123
|
+
|
|
124
|
+
- [Plugin guide](../../../docs/en/reference/plugin-api.md)
|
package/README_ja.md
CHANGED
|
@@ -1,128 +1,128 @@
|
|
|
1
|
-
# @riebeckite/plugin-sidenotes
|
|
2
|
-
|
|
3
|
-
Riebeckite 用の Tufte スタイルのサイドノート・プラグインです。執筆者は通常の
|
|
4
|
-
GFM 脚注(`[^1]` と `[^1]: 本文`)をそのまま書き続けます。プラグインが生成
|
|
5
|
-
された脚注マークアップを、インラインの参照リンクと、デスクトップではマージン
|
|
6
|
-
ノート、モバイルではタップで開くポップオーバーとして表示されるノートに書き
|
|
7
|
-
換えます。
|
|
8
|
-
|
|
9
|
-
[English](./README.md)
|
|
10
|
-
|
|
11
|
-
## 仕組み
|
|
12
|
-
|
|
13
|
-
このプラグインは、`remark-gfm` の出力をコアのパイプラインが脚注マークアップ
|
|
14
|
-
に変換したものを、rehype プラグインで書き換えます。
|
|
15
|
-
|
|
16
|
-
- 脚注参照は `[data-rr-sidenotes-ref]` を持つ小さな参照リンク付きの `sup`
|
|
17
|
-
になり、`href="#fn-…"` のリンク先は保持されます。通常のブラウザのリンク
|
|
18
|
-
遷移でも脚注に到達できます。
|
|
19
|
-
- 脚注定義は参照のそばの `.rr-sidenotes__note` の aside になります。
|
|
20
|
-
デスクトップ(`@media (min-width: 48rem)`)では常時表示の**マージンノート**、
|
|
21
|
-
モバイル(`@media (max-width: 48rem)`)では**ポップオーバー**として表示
|
|
22
|
-
されます。
|
|
23
|
-
- 文末の脚注定義セクションは残します(モバイルではリンク先、JavaScript が
|
|
24
|
-
無効な場合のフォールバックになります)。マージンノートが常に見える
|
|
25
|
-
デスクトップでは非表示にします。
|
|
26
|
-
|
|
27
|
-
クライアントエントリ(`initSidenotes`)がモバイルのポップオーバーを切り替え
|
|
28
|
-
ます。タップで開閉、`Escape` で閉じる、外側のクリックで閉じる、という動作です。
|
|
29
|
-
`(min-width: 48rem)` に一致するときは動作しません。デスクトップのマージン
|
|
30
|
-
ノートに JavaScript は不要です。
|
|
31
|
-
|
|
32
|
-
## 使い方
|
|
33
|
-
|
|
34
|
-
```ts
|
|
35
|
-
import { defineConfig } from "@riebeckite/core";
|
|
36
|
-
import { sidenotes } from "@riebeckite/plugin-sidenotes";
|
|
37
|
-
|
|
38
|
-
export default defineConfig({
|
|
39
|
-
// ...
|
|
40
|
-
plugins: [sidenotes()],
|
|
41
|
-
});
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
通常の GFM 脚注を書くだけです。
|
|
45
|
-
|
|
46
|
-
```md
|
|
47
|
-
Riebeckite は本文の横にマージンノートを表示します。[^1]
|
|
48
|
-
|
|
49
|
-
[^1]: デスクトップでは参照の横に、モバイルではポップオーバーでノートが表示されます。
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## オプション
|
|
53
|
-
|
|
54
|
-
| オプション | 型 | 既定値 | 説明 |
|
|
55
|
-
| ---------- | -- | ------ | ---- |
|
|
56
|
-
| `className` | `string` | `""` | 各サイドノートのルートに追加する CSS クラス |
|
|
57
|
-
| `ariaLabel` | `string` | `"Sidenote"` | 各ノートのアクセシブル名の接頭辞(`"Sidenote 1"` の形) |
|
|
58
|
-
| `openLabel` | `string` | `"Footnote"` | 閉じた参照リンクのアクセシブル名の接頭辞(`"Footnote 1"`) |
|
|
59
|
-
| `closeLabel` | `string` | `"Close sidenote"` | 開いた参照リンクのアクセシブル名の接頭辞(`"Close sidenote 1"`) |
|
|
60
|
-
| `popoverAlignment` | `"bottom" \| "end"` | `"bottom"` | モバイルのポップオーバーの表示位置 |
|
|
61
|
-
|
|
62
|
-
```ts
|
|
63
|
-
sidenotes({
|
|
64
|
-
ariaLabel: "注記",
|
|
65
|
-
popoverAlignment: "end",
|
|
66
|
-
});
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
## 出力
|
|
70
|
-
|
|
71
|
-
```html
|
|
72
|
-
<p>
|
|
73
|
-
Riebeckite は本文の横にマージンノートを表示します。<sup class="rr-sidenotes__ref">
|
|
74
|
-
<a href="#user-content-fn-1" id="user-content-fnref-1" class="rr-sidenotes__toggle"
|
|
75
|
-
data-rr-sidenotes-ref aria-expanded="false" aria-controls="rr-sidenotes-1"
|
|
76
|
-
aria-label="Footnote 1">1</a></sup>
|
|
77
|
-
</p>
|
|
78
|
-
<aside class="rr-sidenotes__note rr-sidenotes__note--popover-bottom" id="rr-sidenotes-1"
|
|
79
|
-
data-rr-sidenotes-note aria-label="Sidenote 1" tabindex="-1">
|
|
80
|
-
<span class="rr-sidenotes__index" aria-hidden="true">1</span>
|
|
81
|
-
<div class="rr-sidenotes__body"><p>デスクトップでは参照の横に表示されます。</p></div>
|
|
82
|
-
</aside>
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
## アクセシビリティ
|
|
86
|
-
|
|
87
|
-
- 参照リンクは実際のリンク(`href="#user-content-fn-…"`)で、`aria-expanded`
|
|
88
|
-
と `aria-controls` を持ちます。クライアントは `aria-expanded` を切り替え、
|
|
89
|
-
`openLabel` と `closeLabel` の間でラベルを差し替えます。
|
|
90
|
-
- ポップオーバーは `aria-label` でラベル付けされ、開いたときは
|
|
91
|
-
`tabindex="-1"` によりフォーカスを受け取ります。
|
|
92
|
-
- JavaScript が無効でも、タップで通常の GFM と同じように脚注定義へジャンプ
|
|
93
|
-
します。
|
|
94
|
-
|
|
95
|
-
## スタイル
|
|
96
|
-
|
|
97
|
-
パッケージに `style.css` が含まれます。他のプラグインと同じように読み込みます。
|
|
98
|
-
|
|
99
|
-
```ts
|
|
100
|
-
import "@riebeckite/plugin-sidenotes/style.css";
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
安定フックは `rr-sidenotes` 規約に従います。`rr-sidenotes__toggle`、
|
|
104
|
-
`rr-sidenotes__note`、`rr-sidenotes__index`、`rr-sidenotes__body`、
|
|
105
|
-
`rr-sidenotes__footnotes`、そして `rr-sidenotes__note--open` 修飾子です。
|
|
106
|
-
|
|
107
|
-
## エクスポート
|
|
108
|
-
|
|
109
|
-
- `sidenotes(options?)` — プラグインファクトリ
|
|
110
|
-
- `sidenotesPlugin` — `sidenotes` のエイリアス
|
|
111
|
-
- `rehypeSidenotes(options?)` — rehype トランスフォーマー
|
|
112
|
-
- `resolveSidenotesOptions(options?)` — オプションの既定値を適用する
|
|
113
|
-
- `renderSidenotesReference(input)` / `renderSidenotesNote(input)` — HTML 生成関数
|
|
114
|
-
- `initSidenotes(options?)` — クライアントのポップオーバー初期化関数
|
|
115
|
-
- 型: `SidenotesOptions`, `ResolvedSidenotesOptions`, `SidenotesClientOptions`
|
|
116
|
-
|
|
117
|
-
## 制約
|
|
118
|
-
|
|
119
|
-
- 同じ定義を再利用した脚注は、1 つのマージンノートとポップオーバーを共有
|
|
120
|
-
します。
|
|
121
|
-
- デスクトップでは脚注定義セクションを非表示にします。ノートを置くための
|
|
122
|
-
余白が必要です。テーマは `.rr-sidenotes__note` を自由に再スタイルできます。
|
|
123
|
-
- テーブル内や深く入れ子になったインライン要素の中の注は、最も近いブロック
|
|
124
|
-
要素の後ろに置かれるため、縦位置はおおよその位置になります。
|
|
125
|
-
|
|
126
|
-
## ????
|
|
127
|
-
|
|
128
|
-
- [?????????](../../../docs/ja/plugin-
|
|
1
|
+
# @riebeckite/plugin-sidenotes
|
|
2
|
+
|
|
3
|
+
Riebeckite 用の Tufte スタイルのサイドノート・プラグインです。執筆者は通常の
|
|
4
|
+
GFM 脚注(`[^1]` と `[^1]: 本文`)をそのまま書き続けます。プラグインが生成
|
|
5
|
+
された脚注マークアップを、インラインの参照リンクと、デスクトップではマージン
|
|
6
|
+
ノート、モバイルではタップで開くポップオーバーとして表示されるノートに書き
|
|
7
|
+
換えます。
|
|
8
|
+
|
|
9
|
+
[English](./README.md)
|
|
10
|
+
|
|
11
|
+
## 仕組み
|
|
12
|
+
|
|
13
|
+
このプラグインは、`remark-gfm` の出力をコアのパイプラインが脚注マークアップ
|
|
14
|
+
に変換したものを、rehype プラグインで書き換えます。
|
|
15
|
+
|
|
16
|
+
- 脚注参照は `[data-rr-sidenotes-ref]` を持つ小さな参照リンク付きの `sup`
|
|
17
|
+
になり、`href="#fn-…"` のリンク先は保持されます。通常のブラウザのリンク
|
|
18
|
+
遷移でも脚注に到達できます。
|
|
19
|
+
- 脚注定義は参照のそばの `.rr-sidenotes__note` の aside になります。
|
|
20
|
+
デスクトップ(`@media (min-width: 48rem)`)では常時表示の**マージンノート**、
|
|
21
|
+
モバイル(`@media (max-width: 48rem)`)では**ポップオーバー**として表示
|
|
22
|
+
されます。
|
|
23
|
+
- 文末の脚注定義セクションは残します(モバイルではリンク先、JavaScript が
|
|
24
|
+
無効な場合のフォールバックになります)。マージンノートが常に見える
|
|
25
|
+
デスクトップでは非表示にします。
|
|
26
|
+
|
|
27
|
+
クライアントエントリ(`initSidenotes`)がモバイルのポップオーバーを切り替え
|
|
28
|
+
ます。タップで開閉、`Escape` で閉じる、外側のクリックで閉じる、という動作です。
|
|
29
|
+
`(min-width: 48rem)` に一致するときは動作しません。デスクトップのマージン
|
|
30
|
+
ノートに JavaScript は不要です。
|
|
31
|
+
|
|
32
|
+
## 使い方
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { defineConfig } from "@riebeckite/core";
|
|
36
|
+
import { sidenotes } from "@riebeckite/plugin-sidenotes";
|
|
37
|
+
|
|
38
|
+
export default defineConfig({
|
|
39
|
+
// ...
|
|
40
|
+
plugins: [sidenotes()],
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
通常の GFM 脚注を書くだけです。
|
|
45
|
+
|
|
46
|
+
```md
|
|
47
|
+
Riebeckite は本文の横にマージンノートを表示します。[^1]
|
|
48
|
+
|
|
49
|
+
[^1]: デスクトップでは参照の横に、モバイルではポップオーバーでノートが表示されます。
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## オプション
|
|
53
|
+
|
|
54
|
+
| オプション | 型 | 既定値 | 説明 |
|
|
55
|
+
| ---------- | -- | ------ | ---- |
|
|
56
|
+
| `className` | `string` | `""` | 各サイドノートのルートに追加する CSS クラス |
|
|
57
|
+
| `ariaLabel` | `string` | `"Sidenote"` | 各ノートのアクセシブル名の接頭辞(`"Sidenote 1"` の形) |
|
|
58
|
+
| `openLabel` | `string` | `"Footnote"` | 閉じた参照リンクのアクセシブル名の接頭辞(`"Footnote 1"`) |
|
|
59
|
+
| `closeLabel` | `string` | `"Close sidenote"` | 開いた参照リンクのアクセシブル名の接頭辞(`"Close sidenote 1"`) |
|
|
60
|
+
| `popoverAlignment` | `"bottom" \| "end"` | `"bottom"` | モバイルのポップオーバーの表示位置 |
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
sidenotes({
|
|
64
|
+
ariaLabel: "注記",
|
|
65
|
+
popoverAlignment: "end",
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## 出力
|
|
70
|
+
|
|
71
|
+
```html
|
|
72
|
+
<p>
|
|
73
|
+
Riebeckite は本文の横にマージンノートを表示します。<sup class="rr-sidenotes__ref">
|
|
74
|
+
<a href="#user-content-fn-1" id="user-content-fnref-1" class="rr-sidenotes__toggle"
|
|
75
|
+
data-rr-sidenotes-ref aria-expanded="false" aria-controls="rr-sidenotes-1"
|
|
76
|
+
aria-label="Footnote 1">1</a></sup>
|
|
77
|
+
</p>
|
|
78
|
+
<aside class="rr-sidenotes__note rr-sidenotes__note--popover-bottom" id="rr-sidenotes-1"
|
|
79
|
+
data-rr-sidenotes-note aria-label="Sidenote 1" tabindex="-1">
|
|
80
|
+
<span class="rr-sidenotes__index" aria-hidden="true">1</span>
|
|
81
|
+
<div class="rr-sidenotes__body"><p>デスクトップでは参照の横に表示されます。</p></div>
|
|
82
|
+
</aside>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## アクセシビリティ
|
|
86
|
+
|
|
87
|
+
- 参照リンクは実際のリンク(`href="#user-content-fn-…"`)で、`aria-expanded`
|
|
88
|
+
と `aria-controls` を持ちます。クライアントは `aria-expanded` を切り替え、
|
|
89
|
+
`openLabel` と `closeLabel` の間でラベルを差し替えます。
|
|
90
|
+
- ポップオーバーは `aria-label` でラベル付けされ、開いたときは
|
|
91
|
+
`tabindex="-1"` によりフォーカスを受け取ります。
|
|
92
|
+
- JavaScript が無効でも、タップで通常の GFM と同じように脚注定義へジャンプ
|
|
93
|
+
します。
|
|
94
|
+
|
|
95
|
+
## スタイル
|
|
96
|
+
|
|
97
|
+
パッケージに `style.css` が含まれます。他のプラグインと同じように読み込みます。
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
import "@riebeckite/plugin-sidenotes/style.css";
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
安定フックは `rr-sidenotes` 規約に従います。`rr-sidenotes__toggle`、
|
|
104
|
+
`rr-sidenotes__note`、`rr-sidenotes__index`、`rr-sidenotes__body`、
|
|
105
|
+
`rr-sidenotes__footnotes`、そして `rr-sidenotes__note--open` 修飾子です。
|
|
106
|
+
|
|
107
|
+
## エクスポート
|
|
108
|
+
|
|
109
|
+
- `sidenotes(options?)` — プラグインファクトリ
|
|
110
|
+
- `sidenotesPlugin` — `sidenotes` のエイリアス
|
|
111
|
+
- `rehypeSidenotes(options?)` — rehype トランスフォーマー
|
|
112
|
+
- `resolveSidenotesOptions(options?)` — オプションの既定値を適用する
|
|
113
|
+
- `renderSidenotesReference(input)` / `renderSidenotesNote(input)` — HTML 生成関数
|
|
114
|
+
- `initSidenotes(options?)` — クライアントのポップオーバー初期化関数
|
|
115
|
+
- 型: `SidenotesOptions`, `ResolvedSidenotesOptions`, `SidenotesClientOptions`
|
|
116
|
+
|
|
117
|
+
## 制約
|
|
118
|
+
|
|
119
|
+
- 同じ定義を再利用した脚注は、1 つのマージンノートとポップオーバーを共有
|
|
120
|
+
します。
|
|
121
|
+
- デスクトップでは脚注定義セクションを非表示にします。ノートを置くための
|
|
122
|
+
余白が必要です。テーマは `.rr-sidenotes__note` を自由に再スタイルできます。
|
|
123
|
+
- テーブル内や深く入れ子になったインライン要素の中の注は、最も近いブロック
|
|
124
|
+
要素の後ろに置かれるため、縦位置はおおよその位置になります。
|
|
125
|
+
|
|
126
|
+
## ????
|
|
127
|
+
|
|
128
|
+
- [?????????](../../../docs/ja/reference/plugin-api.md)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riebeckite/plugin-sidenotes",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"./style.css": "./style.css"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@riebeckite/core": "0.0.
|
|
24
|
+
"@riebeckite/core": "0.0.14"
|
|
25
25
|
},
|
|
26
26
|
"publishConfig": {
|
|
27
27
|
"access": "public"
|