@14ch/svelte-md-outliner 0.0.15 → 0.0.17
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 +26 -0
- package/dist/components/EditorSurface.svelte +1 -36
- package/dist/components/EditorSurface.svelte.d.ts +0 -7
- package/dist/components/serverPlaceholder.d.ts +7 -0
- package/dist/components/serverPlaceholder.js +37 -0
- package/dist/models/markdown/serializer.js +13 -4
- package/dist/operations/plugins/editorFocus.d.ts +20 -0
- package/dist/operations/plugins/editorFocus.js +66 -0
- package/dist/operations/plugins/frontMatterView.js +8 -4
- package/dist/operations/plugins/mermaidView.js +8 -3
- package/dist/operations/plugins/tablePaste.js +8 -1
- package/dist/states/editorSession.js +3 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,32 @@ 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.17] - 2026-09-25
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Text copied from a table's body cell can be pasted outside the table again.
|
|
13
|
+
The paste did nothing at all, while text copied from a header cell pasted
|
|
14
|
+
fine — which made it look as though body rows were special. Both behave the
|
|
15
|
+
same now.
|
|
16
|
+
- Indentation after a line break inside a table cell survives saving. Pressing
|
|
17
|
+
Shift+Enter in a cell and indenting the next line — the usual way to fake a
|
|
18
|
+
bulleted list inside a cell — lost those leading spaces every time the
|
|
19
|
+
document was written out. Whitespace at the very start and end of a cell is
|
|
20
|
+
still dropped, because a GFM table discards it and it cannot be written back.
|
|
21
|
+
|
|
22
|
+
## [0.0.16] - 2026-09-24
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
|
|
26
|
+
- Front matter and Mermaid blocks now leave their editing view when the editor
|
|
27
|
+
loses focus. The switch was tied to where the selection sat, and the editor
|
|
28
|
+
keeps that selection after a blur, so clicking away left the front matter
|
|
29
|
+
showing its input surface and raw timestamps, and a Mermaid block showing its
|
|
30
|
+
source instead of the diagram — with no caret anywhere on screen. Focus is now
|
|
31
|
+
part of that judgement, so the surface, the readable dates and the diagram all
|
|
32
|
+
come back together.
|
|
33
|
+
|
|
8
34
|
## [0.0.15] - 2026-09-20
|
|
9
35
|
|
|
10
36
|
### Fixed
|
|
@@ -1,41 +1,6 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
/**
|
|
3
|
-
* サーバー側で描画されたときの代わりの表示。
|
|
4
|
-
*
|
|
5
|
-
* `EditorView` はブラウザの DOM を必要とするため、サーバー側では編集機能が成立しない。
|
|
6
|
-
* ただし利用者はページ全体をサーバーで描画するため、ここを通ること自体は正常な使い方である。
|
|
7
|
-
* したがって「例外を投げない」だけでは足りず、動かないことに開発者が気づける必要がある。
|
|
8
|
-
*
|
|
9
|
-
* 警告は 1 プロセスにつき 1 度だけ出す。
|
|
10
|
-
*
|
|
11
|
-
* ここだけモジュールスコープの可変状態を許す。インスタンス間の干渉を防ぐという
|
|
12
|
-
* 制約の趣旨に照らし、ログ出力の抑制はエディタの振る舞いにも状態にも影響しないためである。
|
|
13
|
-
*/
|
|
14
|
-
let warned = false;
|
|
15
|
-
|
|
16
|
-
const MESSAGE = '[markdown-editor] SSR/SSG ではエディタを初期化できません。';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* 代わりの表示であることを示す印を返す。編集の仕組みができていれば付けない。
|
|
20
|
-
*
|
|
21
|
-
* 判定を「描画される属性の値」として行うのは、そこが確実に評価される場所だからである
|
|
22
|
-
* (`<script>` に直に書いた文は、サーバー側の描画では実行されないことがある)。
|
|
23
|
-
*/
|
|
24
|
-
export function serverPlaceholderMark(hasSession: boolean): string | undefined {
|
|
25
|
-
if (hasSession) return undefined;
|
|
26
|
-
if (typeof document === 'undefined') warnOnce();
|
|
27
|
-
return 'true';
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function warnOnce(): void {
|
|
31
|
-
if (warned) return;
|
|
32
|
-
warned = true;
|
|
33
|
-
console.warn(MESSAGE);
|
|
34
|
-
}
|
|
35
|
-
</script>
|
|
36
|
-
|
|
37
1
|
<script lang="ts">
|
|
38
2
|
import { untrack } from 'svelte';
|
|
3
|
+
import { serverPlaceholderMark } from './serverPlaceholder';
|
|
39
4
|
import { createEditorSession } from '../states/editorSession';
|
|
40
5
|
import type {
|
|
41
6
|
EditorPresentation,
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 代わりの表示であることを示す印を返す。編集の仕組みができていれば付けない。
|
|
3
|
-
*
|
|
4
|
-
* 判定を「描画される属性の値」として行うのは、そこが確実に評価される場所だからである
|
|
5
|
-
* (`<script>` に直に書いた文は、サーバー側の描画では実行されないことがある)。
|
|
6
|
-
*/
|
|
7
|
-
export declare function serverPlaceholderMark(hasSession: boolean): string | undefined;
|
|
8
1
|
import type { EditorPresentation, EditorSession, EditorSessionOptions } from '../states/editorSession.types';
|
|
9
2
|
interface Props {
|
|
10
3
|
options: EditorSessionOptions;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* サーバー側で描画されたときの代わりの表示。
|
|
3
|
+
*
|
|
4
|
+
* `EditorView` はブラウザの DOM を必要とするため、サーバー側では編集機能が成立しない。
|
|
5
|
+
* ただし利用者はページ全体をサーバーで描画するため、ここを通ること自体は正常な使い方である。
|
|
6
|
+
* したがって「例外を投げない」だけでは足りず、動かないことに開発者が気づける必要がある。
|
|
7
|
+
*
|
|
8
|
+
* 警告は 1 プロセスにつき 1 度だけ出す。
|
|
9
|
+
*
|
|
10
|
+
* ここだけモジュールスコープの可変状態を許す。インスタンス間の干渉を防ぐという
|
|
11
|
+
* 制約の趣旨に照らし、ログ出力の抑制はエディタの振る舞いにも状態にも影響しないためである。
|
|
12
|
+
*
|
|
13
|
+
* **編集エリアの部品(`EditorSurface.svelte`)から切り出して、ここに置く。**
|
|
14
|
+
* 「1 プロセスに 1 度」を数え直すには読み込み直すしかなく、部品に置くと編集基盤
|
|
15
|
+
* まるごとを読み込み直すことになって、確認が実行時間で頭打ちになっていた。
|
|
16
|
+
*/
|
|
17
|
+
let warned = false;
|
|
18
|
+
const MESSAGE = '[svelte-md-outliner] SSR/SSG ではエディタを初期化できません。';
|
|
19
|
+
/**
|
|
20
|
+
* 代わりの表示であることを示す印を返す。編集の仕組みができていれば付けない。
|
|
21
|
+
*
|
|
22
|
+
* 判定を「描画される属性の値」として行うのは、そこが確実に評価される場所だからである
|
|
23
|
+
* (`<script>` に直に書いた文は、サーバー側の描画では実行されないことがある)。
|
|
24
|
+
*/
|
|
25
|
+
export function serverPlaceholderMark(hasSession) {
|
|
26
|
+
if (hasSession)
|
|
27
|
+
return undefined;
|
|
28
|
+
if (typeof document === 'undefined')
|
|
29
|
+
warnOnce();
|
|
30
|
+
return 'true';
|
|
31
|
+
}
|
|
32
|
+
function warnOnce() {
|
|
33
|
+
if (warned)
|
|
34
|
+
return;
|
|
35
|
+
warned = true;
|
|
36
|
+
console.warn(MESSAGE);
|
|
37
|
+
}
|
|
@@ -118,7 +118,7 @@ function writeSections(parent, depth) {
|
|
|
118
118
|
flush();
|
|
119
119
|
const level = Math.min(depth, MAX_HEADING_LEVEL);
|
|
120
120
|
// タイトルが空の見出し(まだ書いていない見出し)では、記号の後ろに空白を残さない
|
|
121
|
-
const title = writeInline(child.content);
|
|
121
|
+
const title = writeInline(child.content).trim();
|
|
122
122
|
parts.push(title ? `${'#'.repeat(level)} ${title}` : '#'.repeat(level));
|
|
123
123
|
return;
|
|
124
124
|
}
|
|
@@ -133,16 +133,19 @@ function writeBlocks(content) {
|
|
|
133
133
|
.replace(/\n+$/, '');
|
|
134
134
|
}
|
|
135
135
|
function writeInline(content) {
|
|
136
|
-
return writeBlocks(Fragment.from(n.paragraph.create(null, content)))
|
|
136
|
+
return writeBlocks(Fragment.from(n.paragraph.create(null, content)));
|
|
137
137
|
}
|
|
138
138
|
/**
|
|
139
139
|
* 行(テキストブロック)の中身を書き出す。**改行の記法は行の側が決める**
|
|
140
140
|
* (→ スキーマの `htmlLineBreak`)。
|
|
141
|
+
*
|
|
142
|
+
* 行の前後の空白は落とす。**記法として書けないためである**——行頭の空白は読み込みで
|
|
143
|
+
* 捨てられ(段落は 3 つまで無視、表のマス目は前後を無条件に捨てる)、書いても戻らない。
|
|
141
144
|
*/
|
|
142
145
|
function writeLine(line) {
|
|
143
146
|
return line.type.spec.htmlLineBreak
|
|
144
147
|
? writeHtmlBreakLine(line.content)
|
|
145
|
-
: writeInline(line.content);
|
|
148
|
+
: writeInline(line.content).trim();
|
|
146
149
|
}
|
|
147
150
|
/**
|
|
148
151
|
* 改行を `<br>` で書く行。**改行で区切って、区切りごとに書き出す。**
|
|
@@ -150,6 +153,12 @@ function writeLine(line) {
|
|
|
150
153
|
* `hard_break` の書き出し(行末の `\`)へ回さないのは、行末が来ないためである——
|
|
151
154
|
* セルは 1 行で、続きは同じ行に並ぶ。区切って書けば、改行の次の文字が行頭に来ないことも
|
|
152
155
|
* そのまま表れる(行頭の記号のエスケープが要らない)。
|
|
156
|
+
*
|
|
157
|
+
* **落とす空白は、つないだ全体の前後だけである。** 区切りごとに落とすと、`<br>` の次の
|
|
158
|
+
* 行頭の空白まで消える。セルの中で改行して字下げする書き方(擬似的な箇条書き)が
|
|
159
|
+
* 保存で崩れていた(利用者の指摘、2026-09-25)。読み込みは `<br>` の前後の空白を
|
|
160
|
+
* そのまま保つので、**書ける空白を書かずに捨てていただけである。** 全体の前後だけは
|
|
161
|
+
* GFM の表が無条件に捨てるため、書いても戻らない。
|
|
153
162
|
*/
|
|
154
163
|
function writeHtmlBreakLine(content) {
|
|
155
164
|
const parts = [];
|
|
@@ -165,7 +174,7 @@ function writeHtmlBreakLine(content) {
|
|
|
165
174
|
pending.push(child);
|
|
166
175
|
});
|
|
167
176
|
flush();
|
|
168
|
-
return parts.join('<br>');
|
|
177
|
+
return parts.join('<br>').trim();
|
|
169
178
|
}
|
|
170
179
|
const serializeParagraph = (state, node) => {
|
|
171
180
|
state.renderInline(node);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Plugin, type EditorState } from 'prosemirror-state';
|
|
2
|
+
/**
|
|
3
|
+
* 編集基盤が焦点を持っているかを state へ写す。
|
|
4
|
+
*
|
|
5
|
+
* **焦点の移動は transaction を伴わない。** decoration が計算し直されるのは state が
|
|
6
|
+
* 更新されたときだけなので、焦点だけを見て見せ方を変える仕組みは、その時点で自分から
|
|
7
|
+
* state を動かさないかぎり画面へ届かない。ここで焦点を受け、印だけの transaction に
|
|
8
|
+
* 写すことで、焦点を見る側は state を読むだけで済む。
|
|
9
|
+
*
|
|
10
|
+
* 保持する値を closure にも置くのは、文書の差し替え(`resetDocument`)で state を
|
|
11
|
+
* 作り直しても焦点は動かないためである。作り直しのたびに「焦点が無い」へ戻すと、
|
|
12
|
+
* その後クリックで中へ入っても焦点の移動が起きず、見せ方が変わらないままになる。
|
|
13
|
+
*/
|
|
14
|
+
export declare function editorFocusPlugin(): Plugin;
|
|
15
|
+
/**
|
|
16
|
+
* 焦点の有無を読む。**無い場合を作らない。** このプラグインを置き忘れた state は
|
|
17
|
+
* 組み立ての誤りであり、「焦点が無い」として読むと、編集中の見せ方が永久に出ない
|
|
18
|
+
* という分かりにくい形で現れる
|
|
19
|
+
*/
|
|
20
|
+
export declare function isEditorFocused(state: EditorState): boolean;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
2
|
+
const editorFocusKey = new PluginKey('editorFocus');
|
|
3
|
+
/**
|
|
4
|
+
* 編集基盤が焦点を持っているかを state へ写す。
|
|
5
|
+
*
|
|
6
|
+
* **焦点の移動は transaction を伴わない。** decoration が計算し直されるのは state が
|
|
7
|
+
* 更新されたときだけなので、焦点だけを見て見せ方を変える仕組みは、その時点で自分から
|
|
8
|
+
* state を動かさないかぎり画面へ届かない。ここで焦点を受け、印だけの transaction に
|
|
9
|
+
* 写すことで、焦点を見る側は state を読むだけで済む。
|
|
10
|
+
*
|
|
11
|
+
* 保持する値を closure にも置くのは、文書の差し替え(`resetDocument`)で state を
|
|
12
|
+
* 作り直しても焦点は動かないためである。作り直しのたびに「焦点が無い」へ戻すと、
|
|
13
|
+
* その後クリックで中へ入っても焦点の移動が起きず、見せ方が変わらないままになる。
|
|
14
|
+
*/
|
|
15
|
+
export function editorFocusPlugin() {
|
|
16
|
+
let focused = false;
|
|
17
|
+
return new Plugin({
|
|
18
|
+
key: editorFocusKey,
|
|
19
|
+
state: {
|
|
20
|
+
init: () => focused,
|
|
21
|
+
apply: (tr, current) => tr.getMeta(editorFocusKey) ?? current
|
|
22
|
+
},
|
|
23
|
+
props: {
|
|
24
|
+
handleDOMEvents: {
|
|
25
|
+
focus: (view) => {
|
|
26
|
+
focused = true;
|
|
27
|
+
syncLater(view, true);
|
|
28
|
+
return false;
|
|
29
|
+
},
|
|
30
|
+
blur: (view) => {
|
|
31
|
+
focused = false;
|
|
32
|
+
syncLater(view, false);
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 焦点を state へ写す。**その場では投げず、1 周置く。**
|
|
41
|
+
*
|
|
42
|
+
* 焦点は編集基盤が画面を更新している最中にも動く(DOM へ選択を置くと、その要素へ
|
|
43
|
+
* 焦点が移る)。更新の最中に transaction を投げると更新が入れ子になり、1 回の移動の
|
|
44
|
+
* 結果を見てから判断する仕組み(`requiredSelectionEntry` の持ち越しなど)が、
|
|
45
|
+
* 見るべき transaction を取り違える。
|
|
46
|
+
*/
|
|
47
|
+
function syncLater(view, next) {
|
|
48
|
+
queueMicrotask(() => {
|
|
49
|
+
if (view.isDestroyed)
|
|
50
|
+
return;
|
|
51
|
+
if (isEditorFocused(view.state) === next)
|
|
52
|
+
return;
|
|
53
|
+
view.dispatch(view.state.tr.setMeta(editorFocusKey, next));
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* 焦点の有無を読む。**無い場合を作らない。** このプラグインを置き忘れた state は
|
|
58
|
+
* 組み立ての誤りであり、「焦点が無い」として読むと、編集中の見せ方が永久に出ない
|
|
59
|
+
* という分かりにくい形で現れる
|
|
60
|
+
*/
|
|
61
|
+
export function isEditorFocused(state) {
|
|
62
|
+
const focused = editorFocusKey.getState(state);
|
|
63
|
+
if (focused === undefined)
|
|
64
|
+
throw new Error('editorFocusPlugin が state に無い');
|
|
65
|
+
return focused;
|
|
66
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Plugin } from 'prosemirror-state';
|
|
2
2
|
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
3
3
|
import { outlineSchema } from '../../models/document/schema';
|
|
4
|
+
import { isEditorFocused } from './editorFocus';
|
|
4
5
|
import { findDateText } from '../../utils/dateText';
|
|
5
6
|
const FRONT_MATTER = outlineSchema.nodes.front_matter;
|
|
6
7
|
/**
|
|
@@ -26,7 +27,7 @@ const FRONT_MATTER = outlineSchema.nodes.front_matter;
|
|
|
26
27
|
export function frontMatterViewPlugin(getDisplay) {
|
|
27
28
|
return new Plugin({
|
|
28
29
|
props: {
|
|
29
|
-
decorations: (state) => decorationsFor(state, getDisplay()),
|
|
30
|
+
decorations: (state) => decorationsFor(state, getDisplay(), isEditorFocused(state)),
|
|
30
31
|
nodeViews: {
|
|
31
32
|
front_matter: (node, view, _getPos, decorations) => new FrontMatterView(node, view, getDisplay, decorations)
|
|
32
33
|
}
|
|
@@ -40,16 +41,19 @@ const RAW_CLASS = 'markdown-editor__front-matter-raw';
|
|
|
40
41
|
/**
|
|
41
42
|
* 編集中のフラグと、日時の置き換えを組み立てる。
|
|
42
43
|
*
|
|
43
|
-
*
|
|
44
|
+
* 「カーソルがフロントマターの中」の判定はここに閉じ、NodeView は印を class へ写すだけに
|
|
44
45
|
* する。日時の置き換えは、その印が付かないあいだ(=読むあいだ)だけ当てる。
|
|
46
|
+
*
|
|
47
|
+
* **焦点を失えばカーソルは消える。** 選択は state に残るが、書き手から見ればそこに
|
|
48
|
+
* カーソルは無く、入力欄の面だけが居座って見える。焦点も条件に入れる。
|
|
45
49
|
*/
|
|
46
|
-
function decorationsFor(state, display) {
|
|
50
|
+
function decorationsFor(state, display, focused) {
|
|
47
51
|
const front = state.doc.child(0);
|
|
48
52
|
if (front.type !== FRONT_MATTER)
|
|
49
53
|
return DecorationSet.empty;
|
|
50
54
|
const { $from, $to } = state.selection;
|
|
51
55
|
const inside = $from.parent.type === FRONT_MATTER && $from.sameParent($to);
|
|
52
|
-
if (inside && display.editable) {
|
|
56
|
+
if (inside && display.editable && focused) {
|
|
53
57
|
return DecorationSet.create(state.doc, [
|
|
54
58
|
Decoration.node($from.before(), $from.after(), {}, { frontMatterEditing: true })
|
|
55
59
|
]);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Plugin } from 'prosemirror-state';
|
|
2
2
|
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
3
3
|
import { outlineSchema } from '../../models/document/schema';
|
|
4
|
+
import { isEditorFocused } from './editorFocus';
|
|
4
5
|
const MERMAID_BLOCK = outlineSchema.nodes.mermaid_block;
|
|
5
6
|
// --- mermaid の遅延読み込み ---
|
|
6
7
|
//
|
|
@@ -39,7 +40,7 @@ export function mermaidLoadStarted() {
|
|
|
39
40
|
export function mermaidViewPlugin(getText) {
|
|
40
41
|
return new Plugin({
|
|
41
42
|
props: {
|
|
42
|
-
decorations: editingDecorations,
|
|
43
|
+
decorations: (state) => editingDecorations(state, isEditorFocused(state)),
|
|
43
44
|
nodeViews: {
|
|
44
45
|
mermaid_block: (node, view, _getPos, decorations) => new MermaidBlockView(node, view, getText, decorations)
|
|
45
46
|
}
|
|
@@ -48,12 +49,16 @@ export function mermaidViewPlugin(getText) {
|
|
|
48
49
|
}
|
|
49
50
|
const EDITING_CLASS = 'markdown-editor__mermaid-block--editing';
|
|
50
51
|
/**
|
|
51
|
-
*
|
|
52
|
+
* 「カーソルがブロックの中」の Mermaid ブロックへ編集中のフラグ(spec のみの装飾)を当てる。
|
|
52
53
|
* 判定はここに閉じ、NodeView は印を class に写すだけにする。
|
|
54
|
+
* **焦点を失えばカーソルは消える。** 選択は state に残るが、書き手から見ればそこに
|
|
55
|
+
* カーソルは無く、図に戻すのが筋である。焦点も条件に入れる。
|
|
53
56
|
* attrs に class を入れると編集基盤が直接 DOM へ当ててしまい、
|
|
54
57
|
* 読み取り専用の判定(NodeView 側)を通れないため、attrs は空にする。
|
|
55
58
|
*/
|
|
56
|
-
function editingDecorations(state) {
|
|
59
|
+
function editingDecorations(state, focused) {
|
|
60
|
+
if (!focused)
|
|
61
|
+
return DecorationSet.empty;
|
|
57
62
|
const { $from, $to } = state.selection;
|
|
58
63
|
if ($from.parent.type !== MERMAID_BLOCK || !$from.sameParent($to))
|
|
59
64
|
return DecorationSet.empty;
|
|
@@ -29,6 +29,13 @@ export function tablePastePlugin() {
|
|
|
29
29
|
*
|
|
30
30
|
* 直すものが 1 つも無ければ、渡された文字列をそのまま返す。読み直して書き出すと、
|
|
31
31
|
* 直す必要の無い HTML まで別の文字列になる。
|
|
32
|
+
*
|
|
33
|
+
* **書き出す形は、受け取った形と同じ「中身の並び」にする。** 文書ごと書き出すと
|
|
34
|
+
* `<html>` で始まる文字列になり、実行環境がコピーの先頭へ付ける `<meta charset>` が
|
|
35
|
+
* `<head>` の中へ移る。編集基盤は**文字列の先頭の `<meta>` しか外さない**ため、外され
|
|
36
|
+
* ないまま残った `<meta>` が、読み込んだ入れ物の最初の要素になる。編集基盤はそこから
|
|
37
|
+
* `data-pm-slice` の包みの数だけ内側へ降りるので、表ではなく `<meta>` の中へ降り、
|
|
38
|
+
* **貼り付けた内容がまるごと消える**(利用者の指摘、2026-09-25)。
|
|
32
39
|
*/
|
|
33
40
|
function rewrite(html, view) {
|
|
34
41
|
const doc = new DOMParser().parseFromString(html, 'text/html');
|
|
@@ -48,7 +55,7 @@ function rewrite(html, view) {
|
|
|
48
55
|
cell.innerHTML = lines.join('<br>');
|
|
49
56
|
rewritten = true;
|
|
50
57
|
}
|
|
51
|
-
return rewritten ? doc.
|
|
58
|
+
return rewritten ? doc.head.innerHTML + doc.body.innerHTML : html;
|
|
52
59
|
}
|
|
53
60
|
/**
|
|
54
61
|
* 貼り先から、マス目の種別を決める。
|
|
@@ -14,6 +14,7 @@ import { imagePastePlugin } from '../operations/plugins/imagePaste';
|
|
|
14
14
|
import { imageViewPlugin } from '../operations/plugins/imageView';
|
|
15
15
|
import { blockHandlePlugin } from '../operations/plugins/blockHandle';
|
|
16
16
|
import { frontMatterGuardPlugin } from '../operations/plugins/frontMatterGuard';
|
|
17
|
+
import { editorFocusPlugin } from '../operations/plugins/editorFocus';
|
|
17
18
|
import { frontMatterViewPlugin } from '../operations/plugins/frontMatterView';
|
|
18
19
|
import { headingLevelPlugin } from '../operations/plugins/headingLevel';
|
|
19
20
|
import { listStructurePlugin } from '../operations/plugins/listStructure';
|
|
@@ -86,6 +87,8 @@ export function createEditorSession(element, options) {
|
|
|
86
87
|
// `appendTransaction` を回すため、他が足した書き換えもここを通る
|
|
87
88
|
headingLevelPlugin(),
|
|
88
89
|
sectionViewPlugin(),
|
|
90
|
+
// 焦点の有無を state へ写す。見せ方を焦点で変えるもの(下の 2 つ)が読む
|
|
91
|
+
editorFocusPlugin(),
|
|
89
92
|
// NodeView を持つ表示の仕組み。どうしも相互作用しないため、同じ場所へまとめる。
|
|
90
93
|
// 文言は表示を更新するたびに読み直す(差し替えの反映は次の表示更新から)
|
|
91
94
|
frontMatterViewPlugin(() => ({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@14ch/svelte-md-outliner",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "An outliner-style Markdown editor for Svelte 5. Headings form a real section tree you can fold, focus, and re-nest from the keyboard.",
|