@14ch/svelte-md-outliner 0.0.1 → 0.0.3
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/CHANGELOG.md +73 -0
- package/LICENSE +21 -0
- package/README.ja.md +33 -17
- package/README.md +33 -17
- package/dist/assets/styles/editor.css +77 -3
- package/dist/assets/styles/theme.css +4 -0
- package/dist/components/ContextMenu.svelte +12 -3
- package/dist/components/MarkdownEditor.svelte +26 -2
- package/dist/components/MarkdownEditor.svelte.d.ts +15 -0
- package/dist/index.d.ts +5 -0
- package/dist/messages/en.js +3 -1
- package/dist/messages/index.js +2 -0
- package/dist/messages/ja.js +3 -1
- package/dist/messages/messages.types.d.ts +6 -0
- package/dist/models/document/document.types.d.ts +7 -0
- package/dist/models/document/schema.js +98 -18
- package/dist/models/document/sectionTree.d.ts +9 -0
- package/dist/models/document/sectionTree.js +12 -0
- package/dist/models/markdown/parser.js +26 -19
- package/dist/models/markdown/serializer.js +65 -6
- package/dist/models/viewState/viewStateCodec.js +2 -2
- package/dist/operations/autoformat.js +17 -0
- package/dist/operations/commands/lineBreak.d.ts +3 -3
- package/dist/operations/commands/lineBreak.js +3 -3
- package/dist/operations/keymap/coreActions.js +2 -2
- package/dist/operations/keymap/viewActions.js +25 -1
- package/dist/operations/plugins/focus.js +2 -2
- package/dist/operations/plugins/imagePaste.d.ts +26 -0
- package/dist/operations/plugins/imagePaste.js +178 -0
- package/dist/operations/plugins/imageView.d.ts +16 -0
- package/dist/operations/plugins/imageView.js +102 -0
- package/dist/states/editorSession.js +25 -2
- package/dist/states/editorSession.types.d.ts +17 -0
- package/package.json +6 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.0.3] - 2026-09-02
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Images are drawn as images. ``, `` and the
|
|
13
|
+
reference form are read as image nodes and written back as image notation.
|
|
14
|
+
They go anywhere text goes, including headings and table cells, and typing the
|
|
15
|
+
notation converts it as you close the bracket.
|
|
16
|
+
- `uploadImage` prop: paste an image and you are handed the raw `File`; the URL
|
|
17
|
+
you return is inserted at the paste position. Storage, formats, size limits and
|
|
18
|
+
sanitizing are yours. Reject or resolve with `null` to decline — the document
|
|
19
|
+
is not touched until you answer, and declining leaves it as it was.
|
|
20
|
+
- CSS custom properties for images: `--markdown-editor-image-max-height`,
|
|
21
|
+
`--markdown-editor-image-status-background`,
|
|
22
|
+
`--markdown-editor-image-status-text`.
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
|
|
26
|
+
- `EditorMessages` has two new required entries, `imageUploading` and
|
|
27
|
+
`imageLoadError`. Breaking if you supply a whole language set; partial
|
|
28
|
+
overrides are unaffected.
|
|
29
|
+
- Saved `viewState` entries for headings containing an image are discarded on
|
|
30
|
+
load, since a heading's text now spells an image as its alt text.
|
|
31
|
+
|
|
32
|
+
### Fixed
|
|
33
|
+
|
|
34
|
+
- Image notation no longer breaks when you save. `` used to come
|
|
35
|
+
back as `!\[alt\](img.png)` and never recover.
|
|
36
|
+
- Images copied from a browser are no longer silently dropped. Without
|
|
37
|
+
`uploadImage` they keep pointing at their original URL.
|
|
38
|
+
|
|
39
|
+
## [0.0.2] - 2026-09-01
|
|
40
|
+
|
|
41
|
+
### Added
|
|
42
|
+
|
|
43
|
+
- Tables: `Shift+Enter` inserts a line break inside a cell. It is written as
|
|
44
|
+
`<br>` in Markdown and read back as a line break.
|
|
45
|
+
|
|
46
|
+
### Fixed
|
|
47
|
+
|
|
48
|
+
- You can now write below a table, quote, code block or Mermaid block that sits
|
|
49
|
+
at the end of the document (and above one that starts the document). Pressing
|
|
50
|
+
the down arrow from the end of such a block puts the cursor outside it, and
|
|
51
|
+
typing there creates a paragraph.
|
|
52
|
+
- The context menu's fold entry no longer folds an outer section. It is offered
|
|
53
|
+
only when the item the menu points at can itself be folded (a heading or a
|
|
54
|
+
list item), not when the cursor is in a paragraph, table, code block or quote.
|
|
55
|
+
The keyboard shortcut is unchanged.
|
|
56
|
+
- In the context menu, hovering an item with the pointer no longer makes it the
|
|
57
|
+
target of `Enter`. Only an item chosen with the arrow keys is activated.
|
|
58
|
+
|
|
59
|
+
## [0.0.1] - 2026-08-30
|
|
60
|
+
|
|
61
|
+
### Added
|
|
62
|
+
|
|
63
|
+
- Initial release of `@14ch/svelte-md-outliner`.
|
|
64
|
+
- `MarkdownEditor` component: an outline editor where headings form a real
|
|
65
|
+
nested hierarchy you can fold, focus, and re-nest from the keyboard.
|
|
66
|
+
- Markdown input rules for headings, lists, task lists, quotes, emphasis and
|
|
67
|
+
inline code, applied as you type.
|
|
68
|
+
- Tables, Mermaid diagrams and front matter.
|
|
69
|
+
- Built-in context menu and shortcut sheet, both of which can be turned off.
|
|
70
|
+
- Replaceable strings (English and Japanese bundled) and a theme exposed as CSS
|
|
71
|
+
custom properties.
|
|
72
|
+
- `@14ch/svelte-md-outliner/markdown`: read and write front matter, body blocks
|
|
73
|
+
and plain text without mounting an editor.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 iyodatakashi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.ja.md
CHANGED
|
@@ -51,25 +51,41 @@ import '@14ch/svelte-md-outliner/styles/editor.css';
|
|
|
51
51
|
<MarkdownEditor bind:value bind:viewState label="議事録" maxWidth="42rem" />
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
| | 型
|
|
55
|
-
| ------------------- |
|
|
56
|
-
| `value` | `string`
|
|
57
|
-
| `onChange` | `(markdown: string) => void`
|
|
58
|
-
| `viewState` | `ViewState`
|
|
59
|
-
| `onViewStateChange` | `(viewState: ViewState) => void`
|
|
60
|
-
| `label` | `string`
|
|
61
|
-
| `readonly` | `boolean`
|
|
62
|
-
| `autofocus` | `boolean`
|
|
63
|
-
| `class` | `string`
|
|
64
|
-
| `padding` | `string`
|
|
65
|
-
| `maxWidth` | `string`
|
|
66
|
-
| `lang` | `'en' \| 'ja'`
|
|
67
|
-
| `messages` | `EditorMessagesOverride`
|
|
68
|
-
| `shortcutHelp` | `boolean`
|
|
69
|
-
| `contextMenu` | `boolean`
|
|
54
|
+
| | 型 | 既定 | |
|
|
55
|
+
| ------------------- | ----------------------------------------- | ---------- | ------------------------------------------------------ |
|
|
56
|
+
| `value` | `string` | `''` | 本文のマークダウン(`bind:` 可) |
|
|
57
|
+
| `onChange` | `(markdown: string) => void` | — | `bind:value` を使うなら不要 |
|
|
58
|
+
| `viewState` | `ViewState` | — | どの見出しを畳んでいるか、どこをフォーカスしているか |
|
|
59
|
+
| `onViewStateChange` | `(viewState: ViewState) => void` | — | `bind:viewState` を使うなら不要 |
|
|
60
|
+
| `label` | `string` | 内蔵の文言 | 編集エリアのアクセシブルネーム |
|
|
61
|
+
| `readonly` | `boolean` | `false` | 入力・編集コマンド・貼り付けを受け付けない |
|
|
62
|
+
| `autofocus` | `boolean` | `false` | マウント時にフォーカスする |
|
|
63
|
+
| `class` | `string` | `''` | 追加のクラス名 |
|
|
64
|
+
| `padding` | `string` | トークン | CSS の `padding` と同じ書き方 |
|
|
65
|
+
| `maxWidth` | `string` | トークン | 行の長さ。**クリックできる範囲は元の幅のまま** |
|
|
66
|
+
| `lang` | `'en' \| 'ja'` | `'en'` | 同梱の言語 |
|
|
67
|
+
| `messages` | `EditorMessagesOverride` | — | 文字列の差し替え。同梱しない言語は一式を渡す |
|
|
68
|
+
| `shortcutHelp` | `boolean` | `true` | 組み込みのショートカット一覧(`Mod-Alt-/`) |
|
|
69
|
+
| `contextMenu` | `boolean` | `true` | 組み込みのコンテキストメニュー(右クリック / `Mod-/`) |
|
|
70
|
+
| `uploadImage` | `(file: File) => Promise<string \| null>` | — | 貼り付けられた画像を引き受け、表示に使う URL を返す |
|
|
70
71
|
|
|
71
72
|
`viewState` は**今どう見ているか**であって、文書の内容ではない。このモジュールは何も保存しないので、保存先は利用側が決める(保存しなくてもよい)。
|
|
72
73
|
|
|
74
|
+
### 画像
|
|
75
|
+
|
|
76
|
+
`` は実際の画像として描かれる。画像を貼り付けると `uploadImage` が生の `File` を受け取り、返した URL が画像記法として貼り付け位置へ入る。どこへ保存するか、どの形式と大きさを受け入れるか、中身をどう無害化するか(SVG など)は**すべて利用側の裁量**である。モジュールが見るのは「クリップボードに画像ファイルがあるか」だけで、保存は一切持たない。
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
const uploadImage = async (file: File) => {
|
|
80
|
+
const url = await myStorage.put(file); // 断るときは null を返す
|
|
81
|
+
return url;
|
|
82
|
+
};
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
待っているあいだは貼り付け位置に印が出るだけで、**文書は 1 文字も変わらない**。失敗すれば印が消え、貼り付けが無かった状態のまま残る。`uploadImage` を渡さなければ従来の貼り付けが働き、読み取り専用のあいだは呼ばれない。
|
|
86
|
+
|
|
87
|
+
**画像を描くと、その先へ取りに行く。** 外部の URL が書かれた文書は、表示のたびにその先へ取得が飛ぶ(記法を描く以上避けられない)。
|
|
88
|
+
|
|
73
89
|
同梱していない言語は、同梱の一式を土台にする。
|
|
74
90
|
|
|
75
91
|
```ts
|
|
@@ -187,4 +203,4 @@ npm run lint # 整形と静的解析
|
|
|
187
203
|
|
|
188
204
|
## ライセンス
|
|
189
205
|
|
|
190
|
-
MIT
|
|
206
|
+
[MIT](LICENSE)
|
package/README.md
CHANGED
|
@@ -51,25 +51,41 @@ import '@14ch/svelte-md-outliner/styles/editor.css';
|
|
|
51
51
|
<MarkdownEditor bind:value bind:viewState label="Meeting notes" maxWidth="42rem" />
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
| | Type
|
|
55
|
-
| ------------------- |
|
|
56
|
-
| `value` | `string`
|
|
57
|
-
| `onChange` | `(markdown: string) => void`
|
|
58
|
-
| `viewState` | `ViewState`
|
|
59
|
-
| `onViewStateChange` | `(viewState: ViewState) => void`
|
|
60
|
-
| `label` | `string`
|
|
61
|
-
| `readonly` | `boolean`
|
|
62
|
-
| `autofocus` | `boolean`
|
|
63
|
-
| `class` | `string`
|
|
64
|
-
| `padding` | `string`
|
|
65
|
-
| `maxWidth` | `string`
|
|
66
|
-
| `lang` | `'en' \| 'ja'`
|
|
67
|
-
| `messages` | `EditorMessagesOverride`
|
|
68
|
-
| `shortcutHelp` | `boolean`
|
|
69
|
-
| `contextMenu` | `boolean`
|
|
54
|
+
| | Type | Default | |
|
|
55
|
+
| ------------------- | ----------------------------------------- | -------- | ----------------------------------------------------------- |
|
|
56
|
+
| `value` | `string` | `''` | Markdown source (bindable) |
|
|
57
|
+
| `onChange` | `(markdown: string) => void` | — | Not needed when you use `bind:value` |
|
|
58
|
+
| `viewState` | `ViewState` | — | Which headings are folded, which section is zoomed |
|
|
59
|
+
| `onViewStateChange` | `(viewState: ViewState) => void` | — | Not needed when you use `bind:viewState` |
|
|
60
|
+
| `label` | `string` | built-in | Accessible name for the editing surface |
|
|
61
|
+
| `readonly` | `boolean` | `false` | Rejects typing, commands and pastes |
|
|
62
|
+
| `autofocus` | `boolean` | `false` | Focus on mount |
|
|
63
|
+
| `class` | `string` | `''` | Extra class names |
|
|
64
|
+
| `padding` | `string` | token | Written exactly like CSS `padding` |
|
|
65
|
+
| `maxWidth` | `string` | token | Line length. **The clickable surface keeps the full width** |
|
|
66
|
+
| `lang` | `'en' \| 'ja'` | `'en'` | Bundled UI language |
|
|
67
|
+
| `messages` | `EditorMessagesOverride` | — | Replace individual strings, or supply a whole language |
|
|
68
|
+
| `shortcutHelp` | `boolean` | `true` | Built-in shortcut sheet (`Mod-Alt-/`) |
|
|
69
|
+
| `contextMenu` | `boolean` | `true` | Built-in context menu (right click / `Mod-/`) |
|
|
70
|
+
| `uploadImage` | `(file: File) => Promise<string \| null>` | — | Takes a pasted image, returns the URL to display |
|
|
70
71
|
|
|
71
72
|
`viewState` is **how you are looking at the document**, not its content. This module stores nothing, so persist it wherever you like — or not at all.
|
|
72
73
|
|
|
74
|
+
### Images
|
|
75
|
+
|
|
76
|
+
`` is rendered as a real image. Paste an image and `uploadImage` receives the raw `File`; the URL you return is inserted as image notation at the paste position. Where the bytes go, which formats and sizes you accept, and how you sanitize them (SVG, for instance) are all yours — this module only checks whether the clipboard holds an image file, and never stores anything itself.
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
const uploadImage = async (file: File) => {
|
|
80
|
+
const url = await myStorage.put(file); // or return null to reject the paste
|
|
81
|
+
return url;
|
|
82
|
+
};
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
While it waits, a marker is shown at the paste position and **the document is not touched**; a failure removes the marker and leaves the document exactly as it was. Without `uploadImage` the paste falls through to the ordinary one. Pastes are ignored entirely while `readonly`.
|
|
86
|
+
|
|
87
|
+
**Rendering an image fetches it.** A document that names an external URL will request it from that host every time it is shown — that is what drawing image notation means.
|
|
88
|
+
|
|
73
89
|
For a language that is not bundled, start from a bundled set:
|
|
74
90
|
|
|
75
91
|
```ts
|
|
@@ -187,4 +203,4 @@ Specifications live in `.kiro/specs/`, conventions in `.kiro/steering/` (Japanes
|
|
|
187
203
|
|
|
188
204
|
## License
|
|
189
205
|
|
|
190
|
-
MIT
|
|
206
|
+
[MIT](LICENSE)
|
|
@@ -133,6 +133,11 @@
|
|
|
133
133
|
--markdown-editor-breadcrumb-separator: '>';
|
|
134
134
|
--markdown-editor-front-matter-padding: 0.4em 0.8em;
|
|
135
135
|
--markdown-editor-mermaid-min-height: 2.5em;
|
|
136
|
+
/**
|
|
137
|
+
* 画像の高さの上限。**縦に長い画像 1 枚で画面が埋まらないようにする。**
|
|
138
|
+
* 横は本文の幅を超えない(`max-width: 100%`)ので、上限を持つのは高さだけでよい。
|
|
139
|
+
*/
|
|
140
|
+
--markdown-editor-image-max-height: 20em;
|
|
136
141
|
}
|
|
137
142
|
|
|
138
143
|
/**
|
|
@@ -1054,6 +1059,54 @@
|
|
|
1054
1059
|
|
|
1055
1060
|
/* --- インライン --- */
|
|
1056
1061
|
|
|
1062
|
+
/**
|
|
1063
|
+
* 画像。**版面を崩さない**(要件 2.4)——本文の幅を超えず、縦に長い 1 枚で画面を埋めない。
|
|
1064
|
+
*
|
|
1065
|
+
* 包む要素を置くのは、画像の隣に状態の一行を出すためである(画像そのものは replaced 要素
|
|
1066
|
+
* なので、擬似要素を持てない)。素の描き出し(スキーマの `toDOM`)は包む要素を持たず、
|
|
1067
|
+
* `img` が直に `markdown-editor__image-preview` を名乗る。
|
|
1068
|
+
*/
|
|
1069
|
+
.markdown-editor__image {
|
|
1070
|
+
display: inline-block;
|
|
1071
|
+
max-width: 100%;
|
|
1072
|
+
/* 行の下端にそろえる(既定の baseline だと、行の下に文字の下ぶんの隙間ができる) */
|
|
1073
|
+
vertical-align: bottom;
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
.markdown-editor__image-preview {
|
|
1077
|
+
display: block;
|
|
1078
|
+
max-width: 100%;
|
|
1079
|
+
max-height: var(--markdown-editor-image-max-height);
|
|
1080
|
+
/* 上限で片方が縮んだときも、縦横の比を保つ */
|
|
1081
|
+
object-fit: contain;
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
/* 読み込めなかった画像の枠(実行環境が出す壊れた画像の印)は出さない。一行で伝える */
|
|
1085
|
+
.markdown-editor__image--failed .markdown-editor__image-preview {
|
|
1086
|
+
display: none;
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
/**
|
|
1090
|
+
* 引き受けを待っているあいだの印と、読み込みに失敗したことの一行。
|
|
1091
|
+
* **地の文と区別できる控えめな面で示す**(Mermaid の状態表示と同じ作法)。
|
|
1092
|
+
*
|
|
1093
|
+
* 印(`--placeholder`)は文書に何も入れずに置かれる目印であり、書き出しには現れない
|
|
1094
|
+
* (→ `imagePaste.ts`)。見た目は失敗の一行と同じもので足りる。
|
|
1095
|
+
*/
|
|
1096
|
+
.markdown-editor__image-status,
|
|
1097
|
+
.markdown-editor__image-placeholder {
|
|
1098
|
+
display: inline-block;
|
|
1099
|
+
padding: 0.15em 0.5em;
|
|
1100
|
+
background: var(--markdown-editor-image-status-background);
|
|
1101
|
+
color: var(--markdown-editor-image-status-text);
|
|
1102
|
+
font-size: var(--markdown-editor-font-size-sm);
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
/* 読み込めた画像では、状態の一行は場所を取らない */
|
|
1106
|
+
.markdown-editor__image-status:empty {
|
|
1107
|
+
display: none;
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1057
1110
|
/**
|
|
1058
1111
|
* 脚注のマーカー(`[^1]`)。**上付きの小さなマーカーとして描くだけ**で、注へ飛ぶ仕掛けは持たない
|
|
1059
1112
|
* (→ `docs/backlog.md` C13)。文字そのものは記法の原文のままなので、選んで消せば
|
|
@@ -1425,10 +1478,31 @@
|
|
|
1425
1478
|
|
|
1426
1479
|
/* --- 表や区切りの前後に立つカーソル --- */
|
|
1427
1480
|
|
|
1481
|
+
/**
|
|
1482
|
+
* 文字の入らない選択(前後に立つカーソル・ブロックを指した状態)のあいだは、
|
|
1483
|
+
* **実行環境が描くカーソルと選択の敷き色を出さない。**
|
|
1484
|
+
*
|
|
1485
|
+
* 編集基盤は `ProseMirror-hideselection` を付けるだけで、見た目は同梱の CSS が持つ。
|
|
1486
|
+
* 読み込ませない方針のため、本体の規則をここに置く(置かなければ、表の下に立てた
|
|
1487
|
+
* カーソルの傍らに実行環境のカーソルが並んで点滅する)。
|
|
1488
|
+
*/
|
|
1489
|
+
.markdown-editor__surface.ProseMirror-hideselection {
|
|
1490
|
+
caret-color: transparent;
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
.markdown-editor__surface.ProseMirror-hideselection *::selection {
|
|
1494
|
+
background: transparent;
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1428
1497
|
/**
|
|
1429
1498
|
* 編集基盤は印を中身のない `div` として置くだけで、見た目を一切持たない。
|
|
1430
1499
|
* 同梱の CSS を読み込ませない方針のため、本体の規則をここに置く
|
|
1431
1500
|
* (置かなければ、表の前後へカーソルを移しても画面には何も出ない)。
|
|
1501
|
+
*
|
|
1502
|
+
* **文字を打つときのカーソルと同じ見た目にする。** 同梱の CSS は横棒で描くが、
|
|
1503
|
+
* 書き手から見てこれは「次に打つ場所」であって、別の何かではない。横棒だと
|
|
1504
|
+
* 区切り線のように見え、点滅する意味も読み取れない(利用者の報告、2026-09-01)。
|
|
1505
|
+
* 太さ・色・点滅を実行環境のカーソルに合わせ、高さは 1 行ぶんにする。
|
|
1432
1506
|
*/
|
|
1433
1507
|
.markdown-editor__surface .ProseMirror-gapcursor {
|
|
1434
1508
|
display: block;
|
|
@@ -1440,9 +1514,9 @@
|
|
|
1440
1514
|
content: '';
|
|
1441
1515
|
display: block;
|
|
1442
1516
|
position: absolute;
|
|
1443
|
-
top:
|
|
1444
|
-
|
|
1445
|
-
border-
|
|
1517
|
+
top: 0;
|
|
1518
|
+
height: 1.2em;
|
|
1519
|
+
border-left: 1px solid var(--markdown-editor-gapcursor-color);
|
|
1446
1520
|
animation: markdown-editor-gapcursor-blink 1.1s steps(2, start) infinite;
|
|
1447
1521
|
}
|
|
1448
1522
|
|
|
@@ -304,6 +304,10 @@
|
|
|
304
304
|
/* 中身が空のときに出すブロックの名前。ファイルには無い文字列なので、値より薄く出す */
|
|
305
305
|
--markdown-editor-front-matter-label: var(--markdown-editor-text-subtle);
|
|
306
306
|
|
|
307
|
+
/* 引き受けを待っているあいだ・画像を出せなかったときに出す一行 */
|
|
308
|
+
--markdown-editor-image-status-background: var(--markdown-editor-surface-accent);
|
|
309
|
+
--markdown-editor-image-status-text: var(--markdown-editor-text-subtle);
|
|
310
|
+
|
|
307
311
|
/* Mermaid ブロックの図の表示領域 */
|
|
308
312
|
--markdown-editor-mermaid-background: var(--markdown-editor-surface-accent);
|
|
309
313
|
/* 図を描けないあいだ・描けなかったときに出す一行 */
|
|
@@ -139,7 +139,14 @@
|
|
|
139
139
|
</li>
|
|
140
140
|
{#each group.items as item (item.action.id)}
|
|
141
141
|
<li class="markdown-editor-context-menu__row">
|
|
142
|
-
<!--
|
|
142
|
+
<!--
|
|
143
|
+
実行できない操作はそもそも並ばない(無効として残さない)。
|
|
144
|
+
|
|
145
|
+
**ポインタを乗せただけでは選ばない。** 押せば実行できるので、乗せることが
|
|
146
|
+
決定の対象になる必要はない。メニューは押した位置に開くため、乗せた項目を
|
|
147
|
+
選ぶ形にすると、**ポインタを動かしていないのにその項目が決定の対象になる**
|
|
148
|
+
(キーで開いた直後にそのまま `Enter` を押すと、選んだ覚えのない操作が走る)。
|
|
149
|
+
-->
|
|
143
150
|
<button
|
|
144
151
|
bind:this={itemRefs[item.index]}
|
|
145
152
|
type="button"
|
|
@@ -150,7 +157,6 @@
|
|
|
150
157
|
class:markdown-editor-context-menu__item--active={item.index ===
|
|
151
158
|
controller.activeIndex}
|
|
152
159
|
onclick={() => execute(item.action)}
|
|
153
|
-
onmouseenter={() => controller.setActive(item.index)}
|
|
154
160
|
onfocus={() => controller.setActive(item.index)}
|
|
155
161
|
>
|
|
156
162
|
<span class="markdown-editor-context-menu__description">{item.description}</span>
|
|
@@ -248,9 +254,12 @@
|
|
|
248
254
|
}
|
|
249
255
|
|
|
250
256
|
/**
|
|
251
|
-
*
|
|
257
|
+
* **乗っている項目と選んでいる項目は同じ敷き色にする。**
|
|
252
258
|
* ポインタで乗ることとキーで選ぶことは同じ「いまこれ」であり、2 通りに見せない。
|
|
253
259
|
* 触れる入力しかない環境では `:hover` が居座るため、囲って外す。
|
|
260
|
+
*
|
|
261
|
+
* 決定(`Enter`)の対象になるのはキーで選んだ方だけである。そちらは実フォーカスを
|
|
262
|
+
* 持つため輪郭が付き(下の `:focus-visible`)、両方が見えていても見分けられる。
|
|
254
263
|
*/
|
|
255
264
|
@media (hover: hover) {
|
|
256
265
|
.markdown-editor-context-menu__item:hover,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import type { EditorLang, EditorMessagesOverride } from '../messages/messages.types';
|
|
3
|
+
import type { ImageUpload } from '../operations/plugins/imagePaste';
|
|
3
4
|
import type {
|
|
4
5
|
FrontMatterFields,
|
|
5
6
|
FrontMatterWriteError,
|
|
@@ -74,6 +75,20 @@
|
|
|
74
75
|
* 使わない設定では、右クリックに対して実行環境の既定のメニューを妨げない。
|
|
75
76
|
*/
|
|
76
77
|
contextMenu?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* 貼り付けられた画像を引き受け、**表示に使う URL を返す**。
|
|
80
|
+
*
|
|
81
|
+
* 保存先・形式やサイズの判定・内容の無害化・アクセス制御は、すべて呼び出し側の
|
|
82
|
+
* 裁量である。モジュールが見るのは「クリップボードに画像ファイルがあるか」だけで、
|
|
83
|
+
* 受け取った `File` は加工せずそのまま渡す。
|
|
84
|
+
*
|
|
85
|
+
* 失敗は reject するか `null` で解決する。どちらでも、待っているあいだの表示が
|
|
86
|
+
* 消えて**文書は貼り付けが無かったまま**になる。
|
|
87
|
+
*
|
|
88
|
+
* 渡さなければ、画像の貼り付けに対して何もしない(従来どおりの貼り付けが働く)。
|
|
89
|
+
* 読み取り専用のあいだは呼ばれない。
|
|
90
|
+
*/
|
|
91
|
+
uploadImage?: ImageUpload;
|
|
77
92
|
}
|
|
78
93
|
|
|
79
94
|
/** `padding` を四辺へ展開したもの。CSS 側へは辺ごとに渡す(→ `expandPadding`) */
|
|
@@ -170,7 +185,8 @@
|
|
|
170
185
|
viewState = $bindable(),
|
|
171
186
|
onViewStateChange,
|
|
172
187
|
shortcutHelp = true,
|
|
173
|
-
contextMenu = true
|
|
188
|
+
contextMenu = true,
|
|
189
|
+
uploadImage
|
|
174
190
|
}: MarkdownEditorProps = $props();
|
|
175
191
|
|
|
176
192
|
// --- 状態 ---
|
|
@@ -189,12 +205,14 @@
|
|
|
189
205
|
loadError: text.mermaidLoadError
|
|
190
206
|
});
|
|
191
207
|
const frontMatterText = $derived(text.frontMatterLabel);
|
|
208
|
+
const imageText = $derived({ uploading: text.imageUploading, loadError: text.imageLoadError });
|
|
192
209
|
const presentation = $derived({
|
|
193
210
|
readonly,
|
|
194
211
|
label: accessibleName,
|
|
195
212
|
lang,
|
|
196
213
|
mermaidText,
|
|
197
|
-
frontMatterText
|
|
214
|
+
frontMatterText,
|
|
215
|
+
imageText
|
|
198
216
|
});
|
|
199
217
|
|
|
200
218
|
// --- 1 度だけ組み立てるもの ---
|
|
@@ -232,6 +250,12 @@
|
|
|
232
250
|
lang: untrack(() => lang),
|
|
233
251
|
mermaidText: untrack(() => mermaidText),
|
|
234
252
|
frontMatterText: untrack(() => frontMatterText),
|
|
253
|
+
imageText: untrack(() => imageText),
|
|
254
|
+
/**
|
|
255
|
+
* 引き受け先は**値ではなく「呼ぶ時点で読む形」で渡す。** prop が後から変わっても
|
|
256
|
+
* 呼ぶ時点の値が使われ、表示の組み直し(`view.setProps`)も起きない。
|
|
257
|
+
*/
|
|
258
|
+
imageUpload: () => uploadImage,
|
|
235
259
|
extensions: [controller.extension, menuController.extension]
|
|
236
260
|
};
|
|
237
261
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { EditorLang, EditorMessagesOverride } from '../messages/messages.types';
|
|
2
|
+
import type { ImageUpload } from '../operations/plugins/imagePaste';
|
|
2
3
|
import type { FrontMatterFields, FrontMatterWriteError, FrontMatterWriteOutcome, MarkdownParseError } from '../models/markdown/markdown.types';
|
|
3
4
|
import type { Result } from '../utils/result.types';
|
|
4
5
|
import type { ViewState } from '../models/viewState/viewState.types';
|
|
@@ -67,6 +68,20 @@ export interface MarkdownEditorProps {
|
|
|
67
68
|
* 使わない設定では、右クリックに対して実行環境の既定のメニューを妨げない。
|
|
68
69
|
*/
|
|
69
70
|
contextMenu?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* 貼り付けられた画像を引き受け、**表示に使う URL を返す**。
|
|
73
|
+
*
|
|
74
|
+
* 保存先・形式やサイズの判定・内容の無害化・アクセス制御は、すべて呼び出し側の
|
|
75
|
+
* 裁量である。モジュールが見るのは「クリップボードに画像ファイルがあるか」だけで、
|
|
76
|
+
* 受け取った `File` は加工せずそのまま渡す。
|
|
77
|
+
*
|
|
78
|
+
* 失敗は reject するか `null` で解決する。どちらでも、待っているあいだの表示が
|
|
79
|
+
* 消えて**文書は貼り付けが無かったまま**になる。
|
|
80
|
+
*
|
|
81
|
+
* 渡さなければ、画像の貼り付けに対して何もしない(従来どおりの貼り付けが働く)。
|
|
82
|
+
* 読み取り専用のあいだは呼ばれない。
|
|
83
|
+
*/
|
|
84
|
+
uploadImage?: ImageUpload;
|
|
70
85
|
}
|
|
71
86
|
/** `padding` を四辺へ展開したもの。CSS 側へは辺ごとに渡す(→ `expandPadding`) */
|
|
72
87
|
export interface EditorPadding {
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,11 @@ export { default as MarkdownEditor } from './components/MarkdownEditor.svelte';
|
|
|
8
8
|
export type { MarkdownEditorProps, MarkdownEditorApi } from './components/MarkdownEditor.svelte';
|
|
9
9
|
export { en, ja } from './messages';
|
|
10
10
|
export type { EditorMessages, EditorMessagesOverride, EditorLang, EditorShortcutCategory } from './messages/messages.types';
|
|
11
|
+
/**
|
|
12
|
+
* 貼り付けられた画像の引き受け先の型(`MarkdownEditor` の `uploadImage` に渡す)。
|
|
13
|
+
* `File` を受け取り、表示に使う URL を返す。失敗は reject か `null` で表す。
|
|
14
|
+
*/
|
|
15
|
+
export type { ImageUpload } from './operations/plugins/imagePaste';
|
|
11
16
|
export type { ViewState, ViewSectionRef } from './models/viewState/viewState.types';
|
|
12
17
|
/**
|
|
13
18
|
* マークダウン文字列を、エディタを置かずに読み書きするための純関数。
|
package/dist/messages/en.js
CHANGED
|
@@ -9,6 +9,8 @@ export const en = {
|
|
|
9
9
|
mermaidLoading: 'Loading diagram renderer…',
|
|
10
10
|
mermaidRenderError: 'This source cannot be rendered as a diagram',
|
|
11
11
|
mermaidLoadError: 'Failed to load the diagram renderer',
|
|
12
|
+
imageUploading: 'Uploading image…',
|
|
13
|
+
imageLoadError: 'Failed to load the image',
|
|
12
14
|
frontMatterLabel: 'Front Matter',
|
|
13
15
|
shortcutCategories: {
|
|
14
16
|
edit: 'Edit',
|
|
@@ -66,7 +68,7 @@ export const en = {
|
|
|
66
68
|
'editing.dissolveHeading': 'At the start of a heading, drop it and join the section above',
|
|
67
69
|
'editing.insertHeadingBefore': 'At the start of a heading, insert an empty heading above it',
|
|
68
70
|
'editing.insertSectionAfter': 'Add an empty heading below the section you are in',
|
|
69
|
-
'editing.insertLineBreak': 'Break the line without starting a new paragraph (not in headings
|
|
71
|
+
'editing.insertLineBreak': 'Break the line without starting a new paragraph (not in headings)',
|
|
70
72
|
'format.toggleTask': 'Toggle task done',
|
|
71
73
|
'format.bold': 'Bold',
|
|
72
74
|
'format.italic': 'Italic',
|
package/dist/messages/index.js
CHANGED
|
@@ -26,6 +26,8 @@ export function resolveMessages(lang = DEFAULT_LANG, overrides) {
|
|
|
26
26
|
mermaidLoading: overrides.mermaidLoading ?? base.mermaidLoading,
|
|
27
27
|
mermaidRenderError: overrides.mermaidRenderError ?? base.mermaidRenderError,
|
|
28
28
|
mermaidLoadError: overrides.mermaidLoadError ?? base.mermaidLoadError,
|
|
29
|
+
imageUploading: overrides.imageUploading ?? base.imageUploading,
|
|
30
|
+
imageLoadError: overrides.imageLoadError ?? base.imageLoadError,
|
|
29
31
|
frontMatterLabel: overrides.frontMatterLabel ?? base.frontMatterLabel
|
|
30
32
|
};
|
|
31
33
|
}
|
package/dist/messages/ja.js
CHANGED
|
@@ -9,6 +9,8 @@ export const ja = {
|
|
|
9
9
|
mermaidLoading: '図の描画機能を読み込んでいます…',
|
|
10
10
|
mermaidRenderError: 'この内容では図を描画できません',
|
|
11
11
|
mermaidLoadError: '図の描画機能を読み込めませんでした',
|
|
12
|
+
imageUploading: '画像を読み込んでいます…',
|
|
13
|
+
imageLoadError: '画像を表示できませんでした',
|
|
12
14
|
frontMatterLabel: 'Front Matter',
|
|
13
15
|
shortcutCategories: {
|
|
14
16
|
// グループは利用者の意図で分ける。「ブロックの操作」のような総称は使わない
|
|
@@ -71,7 +73,7 @@ export const ja = {
|
|
|
71
73
|
'editing.dissolveHeading': '見出しの先頭で押すと、見出しをやめて前のセクションへ繋げる',
|
|
72
74
|
'editing.insertHeadingBefore': '見出しの先頭で押すと、空の見出しを上に足す',
|
|
73
75
|
'editing.insertSectionAfter': 'いまいるセクションの下に、空の見出しを足す',
|
|
74
|
-
'editing.insertLineBreak': '
|
|
76
|
+
'editing.insertLineBreak': '段落を分けずに改行する(見出しの中ではできない)',
|
|
75
77
|
'format.toggleTask': 'チェックの切り替え',
|
|
76
78
|
'format.bold': '強調',
|
|
77
79
|
'format.italic': '斜体',
|
|
@@ -32,6 +32,10 @@ export interface EditorMessages {
|
|
|
32
32
|
readonly mermaidRenderError: string;
|
|
33
33
|
/** 描画ライブラリの読み込みに失敗したことを伝える表示 */
|
|
34
34
|
readonly mermaidLoadError: string;
|
|
35
|
+
/** 貼り付けた画像の引き受けを待っているあいだの表示 */
|
|
36
|
+
readonly imageUploading: string;
|
|
37
|
+
/** 画像の読み込みに失敗したことを伝える表示 */
|
|
38
|
+
readonly imageLoadError: string;
|
|
35
39
|
/**
|
|
36
40
|
* フロントマターにタイトルが無いときに、その場所へ薄く出す名前。
|
|
37
41
|
* 状態の説明(「未設定です」)ではなく、**そこが何であるか**の表示である
|
|
@@ -55,5 +59,7 @@ export interface EditorMessagesOverride {
|
|
|
55
59
|
readonly mermaidLoading?: string;
|
|
56
60
|
readonly mermaidRenderError?: string;
|
|
57
61
|
readonly mermaidLoadError?: string;
|
|
62
|
+
readonly imageUploading?: string;
|
|
63
|
+
readonly imageLoadError?: string;
|
|
58
64
|
readonly frontMatterLabel?: string;
|
|
59
65
|
}
|
|
@@ -7,6 +7,13 @@ export declare function isHeadingLevel(value: unknown): value is HeadingLevel;
|
|
|
7
7
|
export interface HeadingAttrs {
|
|
8
8
|
readonly level: HeadingLevel;
|
|
9
9
|
}
|
|
10
|
+
/** 画像の属性。**記法に書かれているものだけ**を持つ(→ スキーマの `image`) */
|
|
11
|
+
export interface ImageAttributes {
|
|
12
|
+
readonly src: string;
|
|
13
|
+
readonly alt: string;
|
|
14
|
+
/** 記法にタイトルが無ければ null */
|
|
15
|
+
readonly title: string | null;
|
|
16
|
+
}
|
|
10
17
|
/** 原文のまま保持する記法(HTML ブロックなど)を格納する */
|
|
11
18
|
export interface UnknownBlockAttrs {
|
|
12
19
|
readonly source: string;
|