@14ch/svelte-md-outliner 0.0.18 → 0.0.20
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 +41 -0
- package/README.ja.md +47 -24
- package/README.md +47 -24
- package/dist/assets/styles/editor.css +42 -3
- package/dist/assets/styles/theme.css +2 -3
- package/dist/components/ContextMenu.svelte +1 -1
- package/dist/components/EditorSurface.svelte +2 -2
- package/dist/components/MarkdownEditor.svelte +69 -17
- package/dist/components/MarkdownEditor.svelte.d.ts +16 -3
- package/dist/components/ShortcutHelpDialog.svelte +3 -3
- package/dist/index.d.ts +12 -4
- package/dist/index.js +4 -2
- package/dist/markdown.d.ts +2 -0
- package/dist/markdown.js +1 -0
- package/dist/messages/en.js +1 -1
- package/dist/messages/index.d.ts +2 -2
- package/dist/messages/index.js +2 -2
- package/dist/messages/ja.js +1 -1
- package/dist/models/document/bodySelection.js +1 -1
- package/dist/models/document/schema.d.ts +10 -1
- package/dist/models/document/schema.js +13 -2
- package/dist/models/document/sectionTree.d.ts +1 -1
- package/dist/models/document/sectionTree.js +2 -2
- package/dist/models/markdown/normalize.d.ts +20 -0
- package/dist/models/markdown/normalize.js +25 -0
- package/dist/models/markdown/parser.js +8 -6
- package/dist/models/markdown/serializer.js +12 -11
- package/dist/models/viewState/viewStateCodec.d.ts +1 -1
- package/dist/models/viewState/viewStateCodec.js +3 -3
- package/dist/operations/autoformat.d.ts +1 -1
- package/dist/operations/autoformat.js +21 -33
- package/dist/operations/commands/block.d.ts +19 -1
- package/dist/operations/commands/block.js +44 -4
- package/dist/operations/commands/element.js +9 -9
- package/dist/operations/commands/fencedBlock.d.ts +21 -0
- package/dist/operations/commands/fencedBlock.js +49 -0
- package/dist/operations/commands/frontMatter.js +5 -5
- package/dist/operations/commands/lineBreak.js +1 -1
- package/dist/operations/commands/link.js +1 -1
- package/dist/operations/commands/list.js +59 -6
- package/dist/operations/commands/section.d.ts +1 -1
- package/dist/operations/commands/section.js +5 -5
- package/dist/operations/commands/sectionFold.d.ts +1 -1
- package/dist/operations/commands/sectionFold.js +5 -5
- package/dist/operations/commands/sectionJump.js +2 -2
- package/dist/operations/commands/selectedBlock.js +3 -3
- package/dist/operations/commands/table.js +43 -2
- package/dist/operations/documentDiff.d.ts +12 -0
- package/dist/operations/documentDiff.js +191 -0
- package/dist/operations/keymap/assemble.js +5 -5
- package/dist/operations/keymap/coreActions.js +16 -16
- package/dist/operations/keymap/menuItems.js +2 -2
- package/dist/operations/keymap/shortcutKeys.js +1 -1
- package/dist/operations/keymap/viewActions.js +5 -5
- package/dist/operations/plugins/blockHandle.js +1 -1
- package/dist/operations/plugins/compositionState.d.ts +30 -0
- package/dist/operations/plugins/compositionState.js +65 -0
- package/dist/operations/plugins/contextMenu.js +2 -2
- package/dist/operations/plugins/focus.js +19 -8
- package/dist/operations/plugins/foldClick.js +1 -1
- package/dist/operations/plugins/foldGuard.js +2 -2
- package/dist/operations/plugins/frontMatterGuard.js +4 -4
- package/dist/operations/plugins/frontMatterView.js +3 -3
- package/dist/operations/plugins/headingLevel.js +1 -1
- package/dist/operations/plugins/imagePaste.js +2 -2
- package/dist/operations/plugins/imageView.js +1 -1
- package/dist/operations/plugins/linkPaste.js +2 -2
- package/dist/operations/plugins/listStructure.js +1 -1
- package/dist/operations/plugins/markdownClipboard.js +8 -8
- package/dist/operations/plugins/mermaidView.js +2 -2
- package/dist/operations/plugins/requiredSelectionEntry.js +1 -1
- package/dist/operations/plugins/sectionView.js +1 -1
- package/dist/operations/plugins/tableHandles.js +2 -2
- package/dist/operations/transactionOrigin.d.ts +9 -5
- package/dist/operations/transactionOrigin.js +2 -1
- package/dist/states/contextMenuController.svelte.js +5 -5
- package/dist/states/editorSession.js +69 -50
- package/dist/states/editorSession.types.d.ts +41 -3
- package/dist/states/outlineViewController.svelte.d.ts +1 -7
- package/dist/states/outlineViewController.svelte.js +7 -22
- package/package.json +1 -1
- package/dist/operations/commands/mermaidBlock.d.ts +0 -9
- package/dist/operations/commands/mermaidBlock.js +0 -28
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,47 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.0.20] - 2026-10-09
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Collaborative editing: another writer's changes can be applied to a document
|
|
13
|
+
the user is editing.
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- **Breaking:** `resetDocument` returns `{ kind: 'not-ready' }` before the editor
|
|
18
|
+
has mounted, where it used to return `{ kind: 'invalid-structure', detail }`.
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- A long code line or URL no longer widens the document past its container.
|
|
23
|
+
- Making a list no longer puts a bullet on a code block, table or rule in the
|
|
24
|
+
selection.
|
|
25
|
+
- A blank line at the end of a code block no longer reappears on reopen.
|
|
26
|
+
- Shift-arrowing into a table no longer clears the selection outside it.
|
|
27
|
+
|
|
28
|
+
## [0.0.19] - 2026-10-04
|
|
29
|
+
|
|
30
|
+
### Changed
|
|
31
|
+
|
|
32
|
+
- Quoted text is drawn in the body text colour. It used to be a step lighter,
|
|
33
|
+
which made a quotation harder to read than the text around it; the vertical
|
|
34
|
+
bar is what marks the block. The `--markdown-editor-quote-text` custom
|
|
35
|
+
property is gone — quoted text follows `--markdown-editor-text` now.
|
|
36
|
+
|
|
37
|
+
### Fixed
|
|
38
|
+
|
|
39
|
+
- Typing ``` or `>` on a list item line no longer leaves the bullet behind.
|
|
40
|
+
Only the kind of the line changed, so you got a bulleted code block or
|
|
41
|
+
quotation — a shape that cannot be written back: saving and reloading turned
|
|
42
|
+
it into an extra empty item. The same conversion from the menu already
|
|
43
|
+
dropped the item, and both behave the same now. Typing `>` inside a quotation
|
|
44
|
+
still nests it, and blocks that sit after an item's own text are untouched.
|
|
45
|
+
- Pressing Enter after a fence opens a code block, not only a diagram one.
|
|
46
|
+
A fence that named `mermaid` converted on Enter, while one that named `ts`
|
|
47
|
+
— or a fence with no language at all — waited for a space.
|
|
48
|
+
|
|
8
49
|
## [0.0.18] - 2026-09-28
|
|
9
50
|
|
|
10
51
|
### Fixed
|
package/README.ja.md
CHANGED
|
@@ -51,26 +51,28 @@ 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` | `''` | 本文のマークダウン(`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 を返す
|
|
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 を返す |
|
|
71
71
|
|
|
72
72
|
`viewState` は**今どう見ているか**であって、文書の内容ではない。このモジュールは何も保存しないので、保存先は利用側が決める(保存しなくてもよい)。
|
|
73
73
|
|
|
74
|
+
かな漢字変換の最中は、外から書き込むもの(`value`・`replaceMarkdown`・`applyRemoteChange`・`writeFrontMatterFields`)がいずれも当たらない。確定した文字を消さないための規則である。変換中に渡した `value` は変換が済んでから当たり、メソッドは `'deferred'` を返す(当て直す時機は利用側が決める)。
|
|
75
|
+
|
|
74
76
|
### 画像
|
|
75
77
|
|
|
76
78
|
`` は実際の画像として描かれる。画像を貼り付けると `uploadImage` が生の `File` を受け取り、返した URL が画像記法として貼り付け位置へ入る。どこへ保存するか、どの形式と大きさを受け入れるか、中身をどう無害化するか(SVG など)は**すべて利用側の裁量**である。モジュールが見るのは「クリップボードに画像ファイルがあるか」だけで、保存は一切持たない。
|
|
@@ -103,13 +105,19 @@ const fr: EditorMessages = { ...en, editorLabel: 'Éditeur' /* … */ };
|
|
|
103
105
|
<button onclick={() => editor?.resetDocument('# 別の文書\n')}>開き直す</button>
|
|
104
106
|
```
|
|
105
107
|
|
|
106
|
-
| |
|
|
107
|
-
| -------------------------------- |
|
|
108
|
-
| `getMarkdown()` | 現在のマークダウン
|
|
109
|
-
| `getViewState()` | 現在の表示状態
|
|
110
|
-
| `resetDocument(markdown)` | 文書を入れ替え、取り消し履歴を初期化する
|
|
111
|
-
| `
|
|
112
|
-
| `
|
|
108
|
+
| | |
|
|
109
|
+
| -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
110
|
+
| `getMarkdown()` | 現在のマークダウン |
|
|
111
|
+
| `getViewState()` | 現在の表示状態 |
|
|
112
|
+
| `resetDocument(markdown)` | 文書を入れ替え、取り消し履歴を初期化する |
|
|
113
|
+
| `replaceMarkdown(markdown)` | 本文を置き換える。利用者の操作として**取り消せる**(取り込みなど) |
|
|
114
|
+
| `applyRemoteChange(markdown)` | 他の書き手の変更を反映する。**取り消し履歴に積まず**、変わった箇所だけを当てる(ほかの場所のカーソル・取り消しの手順・折りたたみは動かない) |
|
|
115
|
+
| `writeFrontMatterFields(fields)` | 取り消し履歴・カーソル・選択・本文に触れずに項目を書く。編集中の項目への書き込みは見送る |
|
|
116
|
+
| `focus()` | 編集エリアへフォーカスする |
|
|
117
|
+
|
|
118
|
+
`replaceMarkdown` と `applyRemoteChange` は `Result<ApplyOutcome, MarkdownWriteError>` を返す。`ApplyOutcome.status` は `'applied'`・`'unchanged'`(内容が同じだった)・`'deferred'`(変換が済むまで見送った。失敗ではないので、好きな時機に呼び直す)で、`ApplyOutcome.markdown` は正規化した後の本文である(読み戻しが要らない)。
|
|
119
|
+
|
|
120
|
+
本文を受け取る 3 つの命令(`resetDocument` を含む)は、失敗を `MarkdownWriteError` で返す。本文が読めなかったか、エディタがまだ用意できていない(`{ kind: 'not-ready' }`)かのどちらかである。
|
|
113
121
|
|
|
114
122
|
## キーボード
|
|
115
123
|
|
|
@@ -180,9 +188,24 @@ const blocks = readBodyBlocks(readBody(markdown));
|
|
|
180
188
|
| `readBodyBlocks(body)` | 本文のブロック一覧(種別・本文中の位置・見出しのパス) |
|
|
181
189
|
| `readPlainText(markdown)` | インライン記法を取り除いたテキスト |
|
|
182
190
|
| `writeFrontMatterFields(markdown, fields)` | フロントマターへの書き込み。区切り・クォート・挿入位置は内部で処理する |
|
|
191
|
+
| `normalizeMarkdown(markdown)` | 書き方を正準形へ揃える。`Result<string, MarkdownParseError>` を返す |
|
|
183
192
|
|
|
184
193
|
**値は文字列のまま返し、型として解釈しない。** これが、このモジュールを YAML の解析器として使い始めないための境界である。
|
|
185
194
|
|
|
195
|
+
### 別の経路で書かれた本文と突き合わせる
|
|
196
|
+
|
|
197
|
+
`normalizeMarkdown` は**意味を変えずに書き方だけを揃える**。`*` は `-` に、下線の見出しは `#` に、表の区切りは間隔のそろった形に、番号付きの項目は振り直され、余分な空行と `\r\n` は落ち、末尾の改行は 1 つになる。2 回通しても変わらない。
|
|
198
|
+
|
|
199
|
+
**約束は、エディタを通した本文と文字列として一致することである。** 読み込み直後の `getMarkdown()`、`resetDocument` の後、`replaceMarkdown` / `applyRemoteChange` の戻り値の `markdown`——どれも同じ文字列になる。したがって、出どころの違う本文を突き合わせる・統合するときは(エージェントが書いた本文、マイグレーションが書いた行、古い版のアプリが書いたもの)、先に全部これを通す。通さないと、書き方の違いだけでほぼ全行が「変更あり」に見える。
|
|
200
|
+
|
|
201
|
+
```ts
|
|
202
|
+
import { normalizeMarkdown } from '@14ch/svelte-md-outliner/markdown';
|
|
203
|
+
|
|
204
|
+
const theirs = normalizeMarkdown(fromServer);
|
|
205
|
+
if (!theirs.ok) return; // 読み取れなかった
|
|
206
|
+
const merged = merge(base, mine, theirs.value); // mine はすでに正準形
|
|
207
|
+
```
|
|
208
|
+
|
|
186
209
|
## 知っておく制約
|
|
187
210
|
|
|
188
211
|
- **シングルトンの状態を持たない。** 同じページに複数置いても互いに干渉しない
|
package/README.md
CHANGED
|
@@ -51,26 +51,28 @@ 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 | 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
|
|
54
|
+
| | Type | Default | |
|
|
55
|
+
| ------------------- | ----------------------------------------- | -------- | -------------------------------------------------------------- |
|
|
56
|
+
| `value` | `string` | `''` | Markdown source (bindable). Applied as an undoable replacement |
|
|
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 |
|
|
71
71
|
|
|
72
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.
|
|
73
73
|
|
|
74
|
+
While the user is in the middle of IME composition, anything written from outside — `value`, `replaceMarkdown`, `applyRemoteChange`, `writeFrontMatterFields` — is held back so that committed characters are never swallowed. A `value` you set during composition is applied once the composition settles; the methods return `'deferred'` and leave retrying to you.
|
|
75
|
+
|
|
74
76
|
### Images
|
|
75
77
|
|
|
76
78
|
`` 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.
|
|
@@ -103,13 +105,19 @@ Modifier symbols (`⌘` and friends) follow the platform, not the language.
|
|
|
103
105
|
<button onclick={() => editor?.resetDocument('# Another document\n')}>Open another</button>
|
|
104
106
|
```
|
|
105
107
|
|
|
106
|
-
| |
|
|
107
|
-
| -------------------------------- |
|
|
108
|
-
| `getMarkdown()` | Current Markdown
|
|
109
|
-
| `getViewState()` | Current view state
|
|
110
|
-
| `resetDocument(markdown)` | Replace the document and clear undo history
|
|
111
|
-
| `
|
|
112
|
-
| `
|
|
108
|
+
| | |
|
|
109
|
+
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
110
|
+
| `getMarkdown()` | Current Markdown |
|
|
111
|
+
| `getViewState()` | Current view state |
|
|
112
|
+
| `resetDocument(markdown)` | Replace the document and clear undo history |
|
|
113
|
+
| `replaceMarkdown(markdown)` | Replace the body as a user action. **Undoable**, like importing a file |
|
|
114
|
+
| `applyRemoteChange(markdown)` | Apply another writer's changes. **Not added to undo history**; only the changed spots are replaced, so cursor, undo steps and folds elsewhere stay put |
|
|
115
|
+
| `writeFrontMatterFields(fields)` | Write front matter without touching undo history, cursor, selection or body. Skips while the user edits that entry |
|
|
116
|
+
| `focus()` | Focus the editing surface |
|
|
117
|
+
|
|
118
|
+
Both `replaceMarkdown` and `applyRemoteChange` return `Result<ApplyOutcome, MarkdownWriteError>`. `ApplyOutcome.status` is `'applied'`, `'unchanged'` (the text was already identical) or `'deferred'` (held back until IME composition settles — not a failure; call again when you like), and `ApplyOutcome.markdown` is the normalized text, so you do not need to read it back.
|
|
119
|
+
|
|
120
|
+
All three commands that take Markdown — including `resetDocument` — report a failure as `MarkdownWriteError`: either the text could not be read, or `{ kind: 'not-ready' }` because the editor is not mounted yet.
|
|
113
121
|
|
|
114
122
|
## Keyboard
|
|
115
123
|
|
|
@@ -180,9 +188,24 @@ const blocks = readBodyBlocks(readBody(markdown));
|
|
|
180
188
|
| `readBodyBlocks(body)` | Top-level blocks: kind, offsets within the body, heading path |
|
|
181
189
|
| `readPlainText(markdown)` | Readable text with inline markup stripped |
|
|
182
190
|
| `writeFrontMatterFields(markdown, fields)` | Write entries; delimiters, quoting and placement are handled for you |
|
|
191
|
+
| `normalizeMarkdown(markdown)` | Canonical spelling. Returns `Result<string, MarkdownParseError>` |
|
|
183
192
|
|
|
184
193
|
Values come back as strings and are never coerced. That boundary keeps this module from turning into a YAML parser.
|
|
185
194
|
|
|
195
|
+
### Comparing text that came from somewhere else
|
|
196
|
+
|
|
197
|
+
`normalizeMarkdown` settles spelling without changing meaning: `*` becomes `-`, setext headings become `#`, table delimiters get even spacing, ordered items get renumbered, stray blank lines and `\r\n` go away, and the text ends with exactly one newline. Running it twice changes nothing.
|
|
198
|
+
|
|
199
|
+
**What it guarantees is a string match with text that went through the editor** — `getMarkdown()` right after loading, after `resetDocument`, and the `markdown` returned by `replaceMarkdown` / `applyRemoteChange` all produce the same string. So if you diff or merge text from two sources — a file an agent wrote, a row a migration left behind, an older version of your own app — put every side through this first. Otherwise spelling alone makes nearly every line look changed.
|
|
200
|
+
|
|
201
|
+
```ts
|
|
202
|
+
import { normalizeMarkdown } from '@14ch/svelte-md-outliner/markdown';
|
|
203
|
+
|
|
204
|
+
const theirs = normalizeMarkdown(fromServer);
|
|
205
|
+
if (!theirs.ok) return; // the text could not be read
|
|
206
|
+
const merged = merge(base, mine, theirs.value); // mine is already canonical
|
|
207
|
+
```
|
|
208
|
+
|
|
186
209
|
## Constraints worth knowing
|
|
187
210
|
|
|
188
211
|
- **No singleton state.** Several editors on one page never interfere.
|
|
@@ -176,6 +176,27 @@
|
|
|
176
176
|
flex: 1 0 auto;
|
|
177
177
|
min-height: 100%;
|
|
178
178
|
|
|
179
|
+
/**
|
|
180
|
+
* **幅は置いた先の箱が決める。中身に決めさせない。**
|
|
181
|
+
*
|
|
182
|
+
* 上の `flex` は高さの話として書いたものだが、置いた先が flex の**行**なら同じ宣言が
|
|
183
|
+
* 横に効き、「縮めない(`flex-shrink: 0`)× 中身のぶんの基準(`flex-basis: auto`)」で
|
|
184
|
+
* 箱より広い面ができる。grid では自動の最低幅(`min-width: auto`)が中身の最低幅に
|
|
185
|
+
* なって同じことが起きる。**どちらも横に長いコードブロック 1 つで起こる**
|
|
186
|
+
* (`white-space: pre` の行は折れないため、長い行がそのまま最低幅になる)。
|
|
187
|
+
*
|
|
188
|
+
* 2 つ要る。`max-width` は flex の行の基準を箱の幅で抑え、`min-width` は grid の
|
|
189
|
+
* 最低幅を外す(最低幅は最大幅に勝つので、片方だけでは止まらない)。
|
|
190
|
+
* 高さの受け渡しには触らない——`max-width: 100%` は箱いっぱいであり、面は狭めない。
|
|
191
|
+
*
|
|
192
|
+
* **ここで抑えられるのは、面そのものが flex / grid の子である場合だけである。**
|
|
193
|
+
* 中身の最低幅はその外へも伝わるため(`max-width` の百分率は最低幅の計算では
|
|
194
|
+
* 無視される)、置いた先が包みを 1 枚挟めばその包みが縮まなくなる。幅を中身から
|
|
195
|
+
* 切り離すのは中身の側の役目である(→ コードブロックの `> code`、面の `overflow-wrap`)。
|
|
196
|
+
*/
|
|
197
|
+
min-width: 0;
|
|
198
|
+
max-width: 100%;
|
|
199
|
+
|
|
179
200
|
color: var(--markdown-editor-text);
|
|
180
201
|
font-family: var(--markdown-editor-font);
|
|
181
202
|
line-height: var(--markdown-editor-line-height);
|
|
@@ -284,7 +305,14 @@
|
|
|
284
305
|
*/
|
|
285
306
|
cursor: default;
|
|
286
307
|
white-space: pre-wrap;
|
|
287
|
-
|
|
308
|
+
/**
|
|
309
|
+
* 切れ目の無い長い文字列(URL など)を、必要なら途中で折る。
|
|
310
|
+
*
|
|
311
|
+
* **`anywhere` は最低幅(min-content)の計算にも効く。** `break-word` では
|
|
312
|
+
* 折り返しはするが最低幅が縮まないため、長い URL 1 つで編集エリアが
|
|
313
|
+
* 置いた先の箱より広くなる(表のセルが同じ理由で同じ指定を採っている)。
|
|
314
|
+
*/
|
|
315
|
+
overflow-wrap: anywhere;
|
|
288
316
|
}
|
|
289
317
|
|
|
290
318
|
/**
|
|
@@ -845,7 +873,6 @@
|
|
|
845
873
|
position: relative;
|
|
846
874
|
margin: var(--markdown-editor-block-gap) 0;
|
|
847
875
|
padding-left: calc(1em + var(--markdown-editor-quote-bar));
|
|
848
|
-
color: var(--markdown-editor-quote-text);
|
|
849
876
|
}
|
|
850
877
|
|
|
851
878
|
.markdown-editor__blockquote::after {
|
|
@@ -883,6 +910,17 @@
|
|
|
883
910
|
.markdown-editor__code-block > code {
|
|
884
911
|
display: block;
|
|
885
912
|
overflow-x: auto;
|
|
913
|
+
/**
|
|
914
|
+
* **中身の幅を外へ伝えない。** 折り返さない行(`white-space: pre`)はそのまま
|
|
915
|
+
* 最低幅(min-content)になり、面・編集エリア・置いた先の箱まで押し広げる。
|
|
916
|
+
* `max-width` では止まらない——百分率は最低幅の計算では無視されるため、
|
|
917
|
+
* 置いた先が flex / grid なら長いコード 1 行で文書全体が横に伸びる
|
|
918
|
+
* (利用者の指摘、2026-10-06)。
|
|
919
|
+
*
|
|
920
|
+
* 幅を中身から切り離せば、収まらない行はこの箱の中で横に送られる。
|
|
921
|
+
* 折り返しはしない——コードの行は書いたとおりの行である。
|
|
922
|
+
*/
|
|
923
|
+
contain: inline-size;
|
|
886
924
|
font-family: inherit;
|
|
887
925
|
}
|
|
888
926
|
|
|
@@ -1082,10 +1120,11 @@
|
|
|
1082
1120
|
margin: 0 0 0.75em;
|
|
1083
1121
|
}
|
|
1084
1122
|
|
|
1085
|
-
/* 中の `code`
|
|
1123
|
+
/* 中の `code` の縮みを止め、幅を外へ伝えない(→ コードブロックの `> code`) */
|
|
1086
1124
|
.markdown-editor__mermaid-source > code {
|
|
1087
1125
|
display: block;
|
|
1088
1126
|
overflow-x: auto;
|
|
1127
|
+
contain: inline-size;
|
|
1089
1128
|
font-family: inherit;
|
|
1090
1129
|
}
|
|
1091
1130
|
|
|
@@ -163,7 +163,7 @@
|
|
|
163
163
|
*/
|
|
164
164
|
/* 本文の文字。透かしても十分に濃い */
|
|
165
165
|
--markdown-editor-text: var(--markdown-editor-base-800-transparent);
|
|
166
|
-
/*
|
|
166
|
+
/* 一段引いた文字(最下位の見出し・添えの一行・読むあいだのメタ情報) */
|
|
167
167
|
--markdown-editor-text-subtle: var(--markdown-editor-base-500-transparent);
|
|
168
168
|
/**
|
|
169
169
|
* 線の色。**3 段のはしごで持つ。**
|
|
@@ -253,9 +253,8 @@
|
|
|
253
253
|
--markdown-editor-section-guide: var(--markdown-editor-guide);
|
|
254
254
|
--markdown-editor-list-guide: var(--markdown-editor-guide);
|
|
255
255
|
|
|
256
|
-
/*
|
|
256
|
+
/* 引用。文字は本文と同じ濃さで読む(引いた色では読みにくい)。区別は縦棒が担う */
|
|
257
257
|
--markdown-editor-quote-bar-color: var(--markdown-editor-border);
|
|
258
|
-
--markdown-editor-quote-text: var(--markdown-editor-text-subtle);
|
|
259
258
|
|
|
260
259
|
/* 水平線 */
|
|
261
260
|
--markdown-editor-rule-color: var(--markdown-editor-border);
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { tick } from 'svelte';
|
|
10
10
|
|
|
11
11
|
import type { EditorMessages } from '../messages/messages.types';
|
|
12
|
-
import { formatShortcutKeys } from '../operations/keymap/shortcutKeys';
|
|
12
|
+
import { formatShortcutKeys } from '../operations/keymap/shortcutKeys.js';
|
|
13
13
|
import type { EditorAction, ShortcutCategory } from '../operations/operations.types';
|
|
14
14
|
import type { ContextMenuController } from '../states/contextMenuController.svelte';
|
|
15
15
|
import Popup from './internal/Popup.svelte';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { untrack } from 'svelte';
|
|
3
|
-
import { serverPlaceholderMark } from './serverPlaceholder';
|
|
4
|
-
import { createEditorSession } from '../states/editorSession';
|
|
3
|
+
import { serverPlaceholderMark } from './serverPlaceholder.js';
|
|
4
|
+
import { createEditorSession } from '../states/editorSession.js';
|
|
5
5
|
import type {
|
|
6
6
|
EditorPresentation,
|
|
7
7
|
EditorSession,
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
import type {
|
|
5
5
|
FrontMatterFields,
|
|
6
6
|
FrontMatterWriteError,
|
|
7
|
-
FrontMatterWriteOutcome
|
|
8
|
-
MarkdownParseError
|
|
7
|
+
FrontMatterWriteOutcome
|
|
9
8
|
} from '../models/markdown/markdown.types';
|
|
10
9
|
import type { Result } from '../utils/result.types';
|
|
11
10
|
import type { ViewState } from '../models/viewState/viewState.types';
|
|
11
|
+
import type { ApplyOutcome, MarkdownWriteError } from '../states/editorSession.types';
|
|
12
12
|
|
|
13
13
|
export interface MarkdownEditorProps {
|
|
14
14
|
/**
|
|
@@ -141,7 +141,17 @@
|
|
|
141
141
|
* 文書全体を入れ替え、取り消し履歴を初期化する(別の文書を開く用途)。
|
|
142
142
|
* バインドされた値を新しい文書の Markdown で更新し、`onChange` を発火する。
|
|
143
143
|
*/
|
|
144
|
-
resetDocument(markdown: string): Result<void,
|
|
144
|
+
resetDocument(markdown: string): Result<void, MarkdownWriteError>;
|
|
145
|
+
/**
|
|
146
|
+
* 本文を置き換える。利用者の操作として**取り消せる**。
|
|
147
|
+
* OPML の取り込みのように、利用者が起こした置き換えに使う。
|
|
148
|
+
*/
|
|
149
|
+
replaceMarkdown(markdown: string): Result<ApplyOutcome, MarkdownWriteError>;
|
|
150
|
+
/**
|
|
151
|
+
* 他の書き手の変更を反映する。**取り消し履歴に積まず**、変わった箇所だけを当てる。
|
|
152
|
+
* 変わっていない箇所のカーソル・取り消しの手順・折りたたみは動かない。
|
|
153
|
+
*/
|
|
154
|
+
applyRemoteChange(markdown: string): Result<ApplyOutcome, MarkdownWriteError>;
|
|
145
155
|
/**
|
|
146
156
|
* フロントマターへ項目を書き込む。キーと JSON の値を渡し、記法はモジュールが持つ。
|
|
147
157
|
*
|
|
@@ -157,10 +167,20 @@
|
|
|
157
167
|
}
|
|
158
168
|
</script>
|
|
159
169
|
|
|
170
|
+
<!--
|
|
171
|
+
本文を当てる命令を 2 つに分けているのは、**約束が違う**ためである。`replaceMarkdown` は
|
|
172
|
+
取り消せることを、`applyRemoteChange` は履歴に積まないことを約束する。1 つの命令に種類を
|
|
173
|
+
渡す形だと、どちらの約束が効くかが引数の値に隠れ、型と doc で書き分けられない。
|
|
174
|
+
|
|
175
|
+
どちらも、かな漢字変換で確定した文字が入りきるまでは当てず `'deferred'` を返す。
|
|
176
|
+
**変換の状態を問い合わせる口は置かない。** 置くと、利用側が自分で分岐を書くことになり、
|
|
177
|
+
「確定した文字が入りきるまで当てない」判断が 2 か所に生まれる。見送りの戻り値で足りる。
|
|
178
|
+
-->
|
|
179
|
+
|
|
160
180
|
<script lang="ts">
|
|
161
181
|
import { untrack } from 'svelte';
|
|
162
|
-
import { resolveMessages } from '../messages';
|
|
163
|
-
import { EMPTY_VIEW_STATE, isSameViewState } from '../models/viewState/viewStateCodec';
|
|
182
|
+
import { resolveMessages } from '../messages/index.js';
|
|
183
|
+
import { EMPTY_VIEW_STATE, isSameViewState } from '../models/viewState/viewStateCodec.js';
|
|
164
184
|
import { createContextMenuController } from '../states/contextMenuController.svelte';
|
|
165
185
|
import { createOutlineViewController } from '../states/outlineViewController.svelte';
|
|
166
186
|
import type { EditorSession } from '../states/editorSession.types';
|
|
@@ -193,6 +213,14 @@
|
|
|
193
213
|
|
|
194
214
|
let session: EditorSession | null = $state(null);
|
|
195
215
|
|
|
216
|
+
/**
|
|
217
|
+
* 見送った `value` の適用が残っているか。
|
|
218
|
+
*
|
|
219
|
+
* **本文は控えない。** 当て直すときはその時点の `value` と現在の本文を突き合わせる。
|
|
220
|
+
* 控えると、書き込みと読み出しが別の経路に分かれて食い違う。
|
|
221
|
+
*/
|
|
222
|
+
let valueDeferred = false;
|
|
223
|
+
|
|
196
224
|
// --- 導出 ---
|
|
197
225
|
|
|
198
226
|
const text = $derived(resolveMessages(lang, messages));
|
|
@@ -283,6 +311,11 @@
|
|
|
283
311
|
publishViewState();
|
|
284
312
|
|
|
285
313
|
if (!docChanged) return;
|
|
314
|
+
// 見送っていた `value` を当て直す。**この購読をそのまま引き金にする**——
|
|
315
|
+
// 確定した文字が文書へ入るときには Transaction が立ち、購読は内容が変わったかの
|
|
316
|
+
// 判定より前に呼ばれる。当たればその適用の通知が束縛された値を更新する
|
|
317
|
+
if (valueDeferred && applyValue(value)) return;
|
|
318
|
+
|
|
286
319
|
value = markdown;
|
|
287
320
|
onChange?.(markdown);
|
|
288
321
|
});
|
|
@@ -312,25 +345,36 @@
|
|
|
312
345
|
onViewStateChange?.(current);
|
|
313
346
|
}
|
|
314
347
|
|
|
348
|
+
/**
|
|
349
|
+
* 渡された本文を当てる。当てたなら真を返す。
|
|
350
|
+
*
|
|
351
|
+
* 変換の確定した文字が入りきるまでは当たらない。そのときは見送りを控えておき、
|
|
352
|
+
* 次に文書が変わったときに**その時点の `value`** で当て直す。
|
|
353
|
+
*/
|
|
354
|
+
function applyValue(next: string): boolean {
|
|
355
|
+
if (!session || next === session.getMarkdown()) {
|
|
356
|
+
valueDeferred = false;
|
|
357
|
+
return false;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
const result = session.applyMarkdown(next, 'replacement');
|
|
361
|
+
valueDeferred = result.ok && result.value.status === 'deferred';
|
|
362
|
+
return result.ok && result.value.status === 'applied';
|
|
363
|
+
}
|
|
364
|
+
|
|
315
365
|
// --- 外からの変更に追随する ---
|
|
316
366
|
|
|
317
367
|
/**
|
|
318
|
-
*
|
|
368
|
+
* 本文を変わった箇所ごとの置き換えとして当てる。取り消せる置き換えとして扱う。
|
|
319
369
|
*
|
|
320
370
|
* 「自身が直近に書き込んだ値」はセッションが持っている内容そのものなので、それと突き合わせる。
|
|
321
371
|
* 別の変数に控えておく作りにすると、書き込みと読み出しが別の経路(購読の中と効果の中)に
|
|
322
372
|
* 分かれるぶん食い違いが起きやすく、外部変更として扱い直す往復が止まらなくなる。
|
|
323
|
-
*
|
|
324
|
-
* 差分適用は変更範囲のノードを作り直すため、そのままでは間にあるセクションの
|
|
325
|
-
* 折りたたみまで失われる。控えて当て直す(`preserveFolds`)。
|
|
326
373
|
*/
|
|
327
374
|
$effect(() => {
|
|
328
375
|
const next = value;
|
|
329
376
|
if (!session) return;
|
|
330
|
-
untrack(() =>
|
|
331
|
-
if (!session || next === session.getMarkdown()) return;
|
|
332
|
-
controller.preserveFolds(() => session!.applyMarkdown(next));
|
|
333
|
-
});
|
|
377
|
+
untrack(() => applyValue(next));
|
|
334
378
|
});
|
|
335
379
|
|
|
336
380
|
/**
|
|
@@ -358,13 +402,21 @@
|
|
|
358
402
|
return controller.getViewState();
|
|
359
403
|
}
|
|
360
404
|
|
|
361
|
-
export function resetDocument(markdown: string): Result<void,
|
|
362
|
-
if (!session) {
|
|
363
|
-
return { ok: false, error: { kind: 'invalid-structure', detail: 'まだ準備できていない' } };
|
|
364
|
-
}
|
|
405
|
+
export function resetDocument(markdown: string): Result<void, MarkdownWriteError> {
|
|
406
|
+
if (!session) return { ok: false, error: { kind: 'not-ready' } };
|
|
365
407
|
return session.resetDocument(markdown);
|
|
366
408
|
}
|
|
367
409
|
|
|
410
|
+
export function replaceMarkdown(markdown: string): Result<ApplyOutcome, MarkdownWriteError> {
|
|
411
|
+
if (!session) return { ok: false, error: { kind: 'not-ready' } };
|
|
412
|
+
return session.applyMarkdown(markdown, 'replacement');
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
export function applyRemoteChange(markdown: string): Result<ApplyOutcome, MarkdownWriteError> {
|
|
416
|
+
if (!session) return { ok: false, error: { kind: 'not-ready' } };
|
|
417
|
+
return session.applyMarkdown(markdown, 'remote');
|
|
418
|
+
}
|
|
419
|
+
|
|
368
420
|
export function writeFrontMatterFields(
|
|
369
421
|
fields: FrontMatterFields
|
|
370
422
|
): Result<FrontMatterWriteOutcome, FrontMatterWriteError> {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { EditorLang, EditorMessagesOverride } from '../messages/messages.types';
|
|
2
2
|
import type { ImageUpload } from '../operations/plugins/imagePaste';
|
|
3
|
-
import type { FrontMatterFields, FrontMatterWriteError, FrontMatterWriteOutcome
|
|
3
|
+
import type { FrontMatterFields, FrontMatterWriteError, FrontMatterWriteOutcome } from '../models/markdown/markdown.types';
|
|
4
4
|
import type { Result } from '../utils/result.types';
|
|
5
5
|
import type { ViewState } from '../models/viewState/viewState.types';
|
|
6
|
+
import type { ApplyOutcome, MarkdownWriteError } from '../states/editorSession.types';
|
|
6
7
|
export interface MarkdownEditorProps {
|
|
7
8
|
/**
|
|
8
9
|
* 本文の Markdown。`bind:value` で双方向に扱う。
|
|
@@ -111,7 +112,17 @@ export interface MarkdownEditorApi {
|
|
|
111
112
|
* 文書全体を入れ替え、取り消し履歴を初期化する(別の文書を開く用途)。
|
|
112
113
|
* バインドされた値を新しい文書の Markdown で更新し、`onChange` を発火する。
|
|
113
114
|
*/
|
|
114
|
-
resetDocument(markdown: string): Result<void,
|
|
115
|
+
resetDocument(markdown: string): Result<void, MarkdownWriteError>;
|
|
116
|
+
/**
|
|
117
|
+
* 本文を置き換える。利用者の操作として**取り消せる**。
|
|
118
|
+
* OPML の取り込みのように、利用者が起こした置き換えに使う。
|
|
119
|
+
*/
|
|
120
|
+
replaceMarkdown(markdown: string): Result<ApplyOutcome, MarkdownWriteError>;
|
|
121
|
+
/**
|
|
122
|
+
* 他の書き手の変更を反映する。**取り消し履歴に積まず**、変わった箇所だけを当てる。
|
|
123
|
+
* 変わっていない箇所のカーソル・取り消しの手順・折りたたみは動かない。
|
|
124
|
+
*/
|
|
125
|
+
applyRemoteChange(markdown: string): Result<ApplyOutcome, MarkdownWriteError>;
|
|
115
126
|
/**
|
|
116
127
|
* フロントマターへ項目を書き込む。キーと JSON の値を渡し、記法はモジュールが持つ。
|
|
117
128
|
*
|
|
@@ -126,7 +137,9 @@ export interface MarkdownEditorApi {
|
|
|
126
137
|
declare const MarkdownEditor: import("svelte").Component<MarkdownEditorProps, {
|
|
127
138
|
getMarkdown: () => string;
|
|
128
139
|
getViewState: () => ViewState;
|
|
129
|
-
resetDocument: (markdown: string) => Result<void,
|
|
140
|
+
resetDocument: (markdown: string) => Result<void, MarkdownWriteError>;
|
|
141
|
+
replaceMarkdown: (markdown: string) => Result<ApplyOutcome, MarkdownWriteError>;
|
|
142
|
+
applyRemoteChange: (markdown: string) => Result<ApplyOutcome, MarkdownWriteError>;
|
|
130
143
|
writeFrontMatterFields: (fields: FrontMatterFields) => Result<FrontMatterWriteOutcome, FrontMatterWriteError>;
|
|
131
144
|
focus: () => void;
|
|
132
145
|
}, "value" | "viewState">;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { EditorMessages } from '../messages/messages.types';
|
|
3
|
-
import { editorKeymap } from '../operations/keymap/assemble';
|
|
4
|
-
import { SHORTCUT_CATEGORY_ORDER } from '../operations/keymap/menuItems';
|
|
5
|
-
import { formatAllShortcutKeys } from '../operations/keymap/shortcutKeys';
|
|
3
|
+
import { editorKeymap } from '../operations/keymap/assemble.js';
|
|
4
|
+
import { SHORTCUT_CATEGORY_ORDER } from '../operations/keymap/menuItems.js';
|
|
5
|
+
import { formatAllShortcutKeys } from '../operations/keymap/shortcutKeys.js';
|
|
6
6
|
import type { EditorAction } from '../operations/operations.types';
|
|
7
7
|
import Dialog from './internal/Dialog.svelte';
|
|
8
8
|
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export { default as MarkdownEditor } from './components/MarkdownEditor.svelte';
|
|
8
8
|
export type { MarkdownEditorProps, MarkdownEditorApi } from './components/MarkdownEditor.svelte';
|
|
9
|
-
export { en, ja } from './messages';
|
|
9
|
+
export { en, ja } from './messages/index.js';
|
|
10
10
|
export type { EditorMessages, EditorMessagesOverride, EditorLang, EditorShortcutCategory } from './messages/messages.types';
|
|
11
11
|
/**
|
|
12
12
|
* 貼り付けられた画像の引き受け先の型(`MarkdownEditor` の `uploadImage` に渡す)。
|
|
@@ -14,9 +14,18 @@ export type { EditorMessages, EditorMessagesOverride, EditorLang, EditorShortcut
|
|
|
14
14
|
*/
|
|
15
15
|
export type { ImageUpload } from './operations/plugins/imagePaste';
|
|
16
16
|
export type { ViewState, ViewSectionRef } from './models/viewState/viewState.types';
|
|
17
|
+
/**
|
|
18
|
+
* 外から本文を当てる命令(`replaceMarkdown` / `applyRemoteChange`)の戻り値に現れる型。
|
|
19
|
+
*
|
|
20
|
+
* 適用の種類を表す型は公開しない。公開面では**名前が約束を運ぶ**ため、
|
|
21
|
+
* 利用側が種類の値を扱う場所が無い。
|
|
22
|
+
*/
|
|
23
|
+
export type { ApplyOutcome, ApplyStatus, MarkdownWriteError } from './states/editorSession.types';
|
|
17
24
|
/**
|
|
18
25
|
* マークダウン文字列を、エディタを置かずに読み書きするための純関数。
|
|
19
26
|
*
|
|
27
|
+
* - `normalizeMarkdown`: 書き方を正準形へ揃える。**エディタを通した本文と文字列として
|
|
28
|
+
* 一致する**ため、別の経路で書かれた本文と突き合わせる前に通す
|
|
20
29
|
* - `readFrontMatterField`: 指定した項目の値。一覧のような場所でタイトルを出すために使う
|
|
21
30
|
* - `readFrontMatterFields`: フロントマターの全項目。何が書かれているかをキーを知らずに読む
|
|
22
31
|
* - `readBody`: フロントマターを除いた本文
|
|
@@ -32,6 +41,5 @@ export type { ViewState, ViewSectionRef } from './models/viewState/viewState.typ
|
|
|
32
41
|
* 項目の値は文字列のまま返し、**型として解釈しない**。これが、利用者がモジュールを
|
|
33
42
|
* YAML の解析器として扱い始めるのを避けるための境界である。
|
|
34
43
|
*/
|
|
35
|
-
export { readBody, readBodyBlocks, readFrontMatterField, readFrontMatterFields, readPlainText, writeFrontMatterFields } from './markdown';
|
|
36
|
-
export type { FrontMatterFields, FrontMatterValues, FrontMatterWriteError, FrontMatterWriteOutcome, JsonValue, MarkdownBlock, MarkdownBlockKind, Result } from './markdown';
|
|
37
|
-
export type { MarkdownParseError } from './models/markdown/markdown.types';
|
|
44
|
+
export { normalizeMarkdown, readBody, readBodyBlocks, readFrontMatterField, readFrontMatterFields, readPlainText, writeFrontMatterFields } from './markdown.js';
|
|
45
|
+
export type { FrontMatterFields, FrontMatterValues, FrontMatterWriteError, FrontMatterWriteOutcome, JsonValue, MarkdownBlock, MarkdownBlockKind, MarkdownParseError, Result } from './markdown';
|