@14ch/svelte-md-outliner 0.0.18 → 0.0.19
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 +20 -0
- package/dist/assets/styles/editor.css +0 -1
- package/dist/assets/styles/theme.css +2 -3
- package/dist/messages/en.js +1 -1
- package/dist/messages/ja.js +1 -1
- package/dist/operations/autoformat.d.ts +1 -1
- package/dist/operations/autoformat.js +20 -32
- package/dist/operations/commands/block.d.ts +19 -1
- package/dist/operations/commands/block.js +40 -0
- package/dist/operations/commands/fencedBlock.d.ts +21 -0
- package/dist/operations/commands/fencedBlock.js +49 -0
- package/dist/operations/keymap/coreActions.js +4 -4
- 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,26 @@ 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.19] - 2026-10-04
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Quoted text is drawn in the body text colour. It used to be a step lighter,
|
|
13
|
+
which made a quotation harder to read than the text around it; the vertical
|
|
14
|
+
bar is what marks the block. The `--markdown-editor-quote-text` custom
|
|
15
|
+
property is gone — quoted text follows `--markdown-editor-text` now.
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- Typing ``` or `>` on a list item line no longer leaves the bullet behind.
|
|
20
|
+
Only the kind of the line changed, so you got a bulleted code block or
|
|
21
|
+
quotation — a shape that cannot be written back: saving and reloading turned
|
|
22
|
+
it into an extra empty item. The same conversion from the menu already
|
|
23
|
+
dropped the item, and both behave the same now. Typing `>` inside a quotation
|
|
24
|
+
still nests it, and blocks that sit after an item's own text are untouched.
|
|
25
|
+
- Pressing Enter after a fence opens a code block, not only a diagram one.
|
|
26
|
+
```mermaid converted on Enter while ```ts, or a bare ```, waited for a space.
|
|
27
|
+
|
|
8
28
|
## [0.0.18] - 2026-09-28
|
|
9
29
|
|
|
10
30
|
### Fixed
|
|
@@ -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);
|
package/dist/messages/en.js
CHANGED
|
@@ -64,7 +64,7 @@ export const en = {
|
|
|
64
64
|
'document.undo': 'Undo',
|
|
65
65
|
'document.redo': 'Redo',
|
|
66
66
|
'editing.escapeTab': 'Release Tab so it moves focus',
|
|
67
|
-
'editing.
|
|
67
|
+
'editing.fencedBlockOnEnter': 'At the start of a line, turn ``` into a code or diagram block',
|
|
68
68
|
'editing.splitListItem': 'New list item',
|
|
69
69
|
'editing.undoInputRule': 'Undo the last automatic formatting',
|
|
70
70
|
'editing.dissolveHeading': 'At the start of a heading, drop it and join the section above',
|
package/dist/messages/ja.js
CHANGED
|
@@ -69,7 +69,7 @@ export const ja = {
|
|
|
69
69
|
'document.undo': '取り消し',
|
|
70
70
|
'document.redo': 'やり直し',
|
|
71
71
|
'editing.escapeTab': 'Tab でフォーカスを移せる状態にする',
|
|
72
|
-
'editing.
|
|
72
|
+
'editing.fencedBlockOnEnter': '行頭の ``` をコードや図のブロックにする',
|
|
73
73
|
'editing.splitListItem': '新しい項目',
|
|
74
74
|
'editing.undoInputRule': '直前の自動変換を取り消す',
|
|
75
75
|
'editing.dissolveHeading': '見出しの先頭で押すと、見出しをやめて前のセクションへ繋げる',
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { wrapIn } from 'prosemirror-commands';
|
|
2
|
+
import { InputRule } from 'prosemirror-inputrules';
|
|
2
3
|
import { wrappingListInputRule } from 'prosemirror-flat-list';
|
|
3
|
-
import { EditorState, TextSelection } from 'prosemirror-state';
|
|
4
4
|
import { outlineSchema } from '../models/document/schema';
|
|
5
|
-
import { setBlockKind } from './commands/block';
|
|
5
|
+
import { changeLine, convertFromMarkup, setBlockKind } from './commands/block';
|
|
6
|
+
import { toFencedBlock } from './commands/fencedBlock';
|
|
6
7
|
/**
|
|
7
8
|
* 記法を打つと書式になる(オートフォーマット)。
|
|
8
9
|
*
|
|
@@ -10,7 +11,7 @@ import { setBlockKind } from './commands/block';
|
|
|
10
11
|
*/
|
|
11
12
|
export const autoformatRules = [
|
|
12
13
|
// 行頭の `#` は個数を問わない。レベルは構造上の深さから決まるため
|
|
13
|
-
new InputRule(/^#{1,6}\s$/, (state, _match, start, end) =>
|
|
14
|
+
new InputRule(/^#{1,6}\s$/, (state, _match, start, end) => convertFromMarkup(state, start, end, setBlockKind('heading'))),
|
|
14
15
|
// 種別はマークダウンで表せるものだけを作る。ライブラリが用意する一式には
|
|
15
16
|
// 折りたたみ用の種別が含まれており、そのままでは書き出せない項目ができてしまう
|
|
16
17
|
wrappingListInputRule(/^\s?[*-]\s$/, { kind: 'bullet' }),
|
|
@@ -22,10 +23,21 @@ export const autoformatRules = [
|
|
|
22
23
|
kind: 'task',
|
|
23
24
|
checked: /[Xx]/.test(match[1])
|
|
24
25
|
})),
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
/**
|
|
27
|
+
* 引用。**項目の行で打たれたら、項目を解いてから包む**(→ `changeLine`)。
|
|
28
|
+
* 項目の中に残すと「中黒の付いた引用」になり、読み直したときに項目の行が 1 つ増える。
|
|
29
|
+
* 引用の中で打てば引用が入れ子になる(包む操作のままである)。
|
|
30
|
+
*/
|
|
31
|
+
new InputRule(/^\s?>\s$/, (state, _match, start, end) => convertFromMarkup(state, start, end, changeLine(wrapIn(outlineSchema.nodes.blockquote)))),
|
|
32
|
+
/**
|
|
33
|
+
* フェンスの記法。**末尾の空白は言語名の打ち終わりの合図である。**
|
|
34
|
+
* 無いと ` ``` ` を打った時点で変換され、言語名を打つ場所が残らない。
|
|
35
|
+
*
|
|
36
|
+
* 行き先(コードブロックか図のブロックか)と、項目の行で打たれたときの扱いは
|
|
37
|
+
* `toFencedBlock` が持つ。入力規則は文字入力でしか発火しないため、**改行での変換は
|
|
38
|
+
* ここでは起きない**(→ キー割り当ての `editing.fencedBlockOnEnter`)。
|
|
39
|
+
*/
|
|
40
|
+
new InputRule(/^```([a-zA-Z0-9_+#-]*)\s$/, (state, match, start, end) => convertFromMarkup(state, start, end, toFencedBlock(match[1] ?? ''))),
|
|
29
41
|
new InputRule(/^(?:---|___|\*\*\*)$/, (state, _match, start, end) => state.tr.replaceWith(start, end, outlineSchema.nodes.horizontal_rule.create())),
|
|
30
42
|
/**
|
|
31
43
|
* 打った画像記法を、閉じ括弧まで打ち終えた時点で画像にする。
|
|
@@ -49,30 +61,6 @@ export const autoformatRules = [
|
|
|
49
61
|
markInputRule(/(~~([^~]+)~~)$/, outlineSchema.marks.strikethrough),
|
|
50
62
|
markInputRule(/(`([^`]+)`)$/, outlineSchema.marks.code)
|
|
51
63
|
];
|
|
52
|
-
/** 記法の文字を消してから見出しへ変換し、1 つの取り消し単位にまとめる */
|
|
53
|
-
function headingFromMarkup(state, start, end) {
|
|
54
|
-
const stripped = state.tr.delete(start, end);
|
|
55
|
-
// プラグインを持たない状態で変換を組み立てる。`state.apply` を使うと、
|
|
56
|
-
// 表や箇条書きの整合を取るプラグインが文書をさらに変えることがあり、
|
|
57
|
-
// その文書に対して作った手順を元の文書へ当てられなくなる
|
|
58
|
-
const base = EditorState.create({
|
|
59
|
-
schema: outlineSchema,
|
|
60
|
-
doc: stripped.doc,
|
|
61
|
-
selection: stripped.selection
|
|
62
|
-
});
|
|
63
|
-
let converted;
|
|
64
|
-
setBlockKind('heading')(base, (tr) => {
|
|
65
|
-
converted = tr;
|
|
66
|
-
});
|
|
67
|
-
if (!converted)
|
|
68
|
-
return null;
|
|
69
|
-
const merged = state.tr.delete(start, end);
|
|
70
|
-
for (const step of converted.steps)
|
|
71
|
-
merged.step(step);
|
|
72
|
-
// 位置は同じだが、選択は今の文書のものへ作り直す必要がある
|
|
73
|
-
merged.setSelection(TextSelection.near(merged.doc.resolve(converted.selection.from)));
|
|
74
|
-
return merged;
|
|
75
|
-
}
|
|
76
64
|
/**
|
|
77
65
|
* 閉じ記号の入力で、その範囲に文字装飾を適用する。
|
|
78
66
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { EditorState, type Transaction } from 'prosemirror-state';
|
|
2
2
|
import type { BlockKind } from '../../models/document/document.types';
|
|
3
3
|
import type { EditorCommand } from '../operations.types';
|
|
4
4
|
/**
|
|
@@ -8,6 +8,24 @@ import type { EditorCommand } from '../operations.types';
|
|
|
8
8
|
* 箇条書きのツリーと見出しのツリーを行き来する手段はここが担う。
|
|
9
9
|
*/
|
|
10
10
|
export declare function setBlockKind(kind: BlockKind): EditorCommand;
|
|
11
|
+
/**
|
|
12
|
+
* 行そのものを別の種別にする変換を、**文脈に合わせて**当てる。
|
|
13
|
+
*
|
|
14
|
+
* - 項目の行では、項目を解いてから変える(→ `outOfList`)
|
|
15
|
+
* - 項目の本文より後ろのブロックでは、そのブロックだけを変える(→ `blockKindInItem`)
|
|
16
|
+
*
|
|
17
|
+
* 種別の一覧(`BlockKind`)に無い行き先——言語を持つコードブロック・Mermaid ブロック——を
|
|
18
|
+
* 打った記法から作るための入口であり、振り分けの規則は `setBlockKind` と同じものである。
|
|
19
|
+
*/
|
|
20
|
+
export declare function changeLine(command: EditorCommand): EditorCommand;
|
|
21
|
+
/**
|
|
22
|
+
* 打った記法の文字を消してから変換を当て、1 つの取り消し単位にまとめる。
|
|
23
|
+
*
|
|
24
|
+
* プラグインを持たない状態で変換を組み立てる。`state.apply` を使うと、表や箇条書きの
|
|
25
|
+
* 整合を取るプラグインが文書をさらに変えることがあり、その文書に対して作った手順を
|
|
26
|
+
* 元の文書へ当てられなくなる。
|
|
27
|
+
*/
|
|
28
|
+
export declare function convertFromMarkup(state: EditorState, start: number, end: number, command: EditorCommand): Transaction | null;
|
|
11
29
|
/**
|
|
12
30
|
* 見出しとリスト項目を行き来する。
|
|
13
31
|
*
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { chainCommands, lift, setBlockType, wrapIn } from 'prosemirror-commands';
|
|
2
|
+
import { EditorState, TextSelection } from 'prosemirror-state';
|
|
2
3
|
import { outlineSchema } from '../../models/document/schema';
|
|
3
4
|
import { setCursor } from '../transaction';
|
|
4
5
|
import { blockInsideItem, blockToListItem, itemToParagraph, listCommands } from './list';
|
|
@@ -53,6 +54,45 @@ function blockKindInItem(kind) {
|
|
|
53
54
|
return chainCommands(setBlockType(n.paragraph), lift)(state, dispatch, view);
|
|
54
55
|
};
|
|
55
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* 行そのものを別の種別にする変換を、**文脈に合わせて**当てる。
|
|
59
|
+
*
|
|
60
|
+
* - 項目の行では、項目を解いてから変える(→ `outOfList`)
|
|
61
|
+
* - 項目の本文より後ろのブロックでは、そのブロックだけを変える(→ `blockKindInItem`)
|
|
62
|
+
*
|
|
63
|
+
* 種別の一覧(`BlockKind`)に無い行き先——言語を持つコードブロック・Mermaid ブロック——を
|
|
64
|
+
* 打った記法から作るための入口であり、振り分けの規則は `setBlockKind` と同じものである。
|
|
65
|
+
*/
|
|
66
|
+
export function changeLine(command) {
|
|
67
|
+
return (state, dispatch, view) => (blockInsideItem(state) ? command : outOfList(command))(state, dispatch, view);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* 打った記法の文字を消してから変換を当て、1 つの取り消し単位にまとめる。
|
|
71
|
+
*
|
|
72
|
+
* プラグインを持たない状態で変換を組み立てる。`state.apply` を使うと、表や箇条書きの
|
|
73
|
+
* 整合を取るプラグインが文書をさらに変えることがあり、その文書に対して作った手順を
|
|
74
|
+
* 元の文書へ当てられなくなる。
|
|
75
|
+
*/
|
|
76
|
+
export function convertFromMarkup(state, start, end, command) {
|
|
77
|
+
const stripped = state.tr.delete(start, end);
|
|
78
|
+
const base = EditorState.create({
|
|
79
|
+
schema: outlineSchema,
|
|
80
|
+
doc: stripped.doc,
|
|
81
|
+
selection: stripped.selection
|
|
82
|
+
});
|
|
83
|
+
let converted;
|
|
84
|
+
command(base, (tr) => {
|
|
85
|
+
converted = tr;
|
|
86
|
+
});
|
|
87
|
+
if (!converted)
|
|
88
|
+
return null;
|
|
89
|
+
const merged = state.tr.delete(start, end);
|
|
90
|
+
for (const step of converted.steps)
|
|
91
|
+
merged.step(step);
|
|
92
|
+
// 位置は同じだが、選択は今の文書のものへ作り直す必要がある
|
|
93
|
+
merged.setSelection(TextSelection.near(merged.doc.resolve(converted.selection.from)));
|
|
94
|
+
return merged;
|
|
95
|
+
}
|
|
56
96
|
/**
|
|
57
97
|
* 見出しとリスト項目を行き来する。
|
|
58
98
|
*
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { EditorCommand } from '../operations.types';
|
|
2
|
+
/**
|
|
3
|
+
* フェンスの記法が作るブロックにする。
|
|
4
|
+
*
|
|
5
|
+
* **完全一致の `mermaid` だけが図のブロック**で、それ以外は言語名を持つコードブロックに
|
|
6
|
+
* なる。この振り分けは読み込み(→ `parser.ts`)と同じであり、記法から行き先を決める
|
|
7
|
+
* 判断を 2 つに分けない。
|
|
8
|
+
*
|
|
9
|
+
* 項目の行で打たれたときに項目を解くのは `changeLine` の役目である。フェンスのブロックは
|
|
10
|
+
* 項目の行になれない(→ `parser.ts` の `withOwnLine`)ため、項目を残すと「中黒の付いた
|
|
11
|
+
* コードブロック」になり、読み直したときに項目の行が 1 つ増える。
|
|
12
|
+
*/
|
|
13
|
+
export declare function toFencedBlock(language: string): EditorCommand;
|
|
14
|
+
/**
|
|
15
|
+
* 行頭からの ` ``` `(+言語名)に続く改行で、フェンスのブロックを作る。
|
|
16
|
+
*
|
|
17
|
+
* 空白での変換は autoformat の入力規則が受け持つが、入力規則は文字入力でのみ発火し、
|
|
18
|
+
* Enter では発火しない。**改行の側はこの命令しか受け持てない。**
|
|
19
|
+
* カーソルより後ろの文字は、変換後のブロックの中身として残る。
|
|
20
|
+
*/
|
|
21
|
+
export declare const fencedBlockOnEnter: EditorCommand;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { setBlockType } from 'prosemirror-commands';
|
|
2
|
+
import { outlineSchema } from '../../models/document/schema';
|
|
3
|
+
import { changeLine, convertFromMarkup } from './block';
|
|
4
|
+
const n = outlineSchema.nodes;
|
|
5
|
+
/**
|
|
6
|
+
* 行頭からカーソルまでがフェンスの記法だけか。言語名に使える文字は autoformat の
|
|
7
|
+
* 入力規則と同じものにする(打ち終わりの合図だけが違う)。
|
|
8
|
+
*/
|
|
9
|
+
const FENCE = /^```([a-zA-Z0-9_+#-]*)$/;
|
|
10
|
+
/**
|
|
11
|
+
* フェンスの記法が作るブロックにする。
|
|
12
|
+
*
|
|
13
|
+
* **完全一致の `mermaid` だけが図のブロック**で、それ以外は言語名を持つコードブロックに
|
|
14
|
+
* なる。この振り分けは読み込み(→ `parser.ts`)と同じであり、記法から行き先を決める
|
|
15
|
+
* 判断を 2 つに分けない。
|
|
16
|
+
*
|
|
17
|
+
* 項目の行で打たれたときに項目を解くのは `changeLine` の役目である。フェンスのブロックは
|
|
18
|
+
* 項目の行になれない(→ `parser.ts` の `withOwnLine`)ため、項目を残すと「中黒の付いた
|
|
19
|
+
* コードブロック」になり、読み直したときに項目の行が 1 つ増える。
|
|
20
|
+
*/
|
|
21
|
+
export function toFencedBlock(language) {
|
|
22
|
+
return changeLine(language === 'mermaid'
|
|
23
|
+
? setBlockType(n.mermaid_block)
|
|
24
|
+
: setBlockType(n.code_block, { language }));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 行頭からの ` ``` `(+言語名)に続く改行で、フェンスのブロックを作る。
|
|
28
|
+
*
|
|
29
|
+
* 空白での変換は autoformat の入力規則が受け持つが、入力規則は文字入力でのみ発火し、
|
|
30
|
+
* Enter では発火しない。**改行の側はこの命令しか受け持てない。**
|
|
31
|
+
* カーソルより後ろの文字は、変換後のブロックの中身として残る。
|
|
32
|
+
*/
|
|
33
|
+
export const fencedBlockOnEnter = (state, dispatch) => {
|
|
34
|
+
const { $from, empty } = state.selection;
|
|
35
|
+
if (!empty)
|
|
36
|
+
return false;
|
|
37
|
+
const parent = $from.parent;
|
|
38
|
+
if (!parent.isTextblock || parent.type.spec.code)
|
|
39
|
+
return false;
|
|
40
|
+
const language = FENCE.exec(parent.textBetween(0, $from.parentOffset))?.[1];
|
|
41
|
+
if (language === undefined)
|
|
42
|
+
return false;
|
|
43
|
+
// 記法は行頭からカーソルまで。位置で消すので、文字として読めないものが混じっても残らない
|
|
44
|
+
const converted = convertFromMarkup(state, $from.start(), $from.pos, toFencedBlock(language));
|
|
45
|
+
if (!converted)
|
|
46
|
+
return false;
|
|
47
|
+
dispatch?.(converted.scrollIntoView());
|
|
48
|
+
return true;
|
|
49
|
+
};
|
|
@@ -4,11 +4,11 @@ import { undoInputRule } from 'prosemirror-inputrules';
|
|
|
4
4
|
import { outlineSchema } from '../../models/document/schema';
|
|
5
5
|
import { isInCodeBlock } from '../commands/codeBlock';
|
|
6
6
|
import { inTable, liftByContext, moveByContext, sectionCommands, sinkByContext } from '../commands/element';
|
|
7
|
+
import { fencedBlockOnEnter } from '../commands/fencedBlock';
|
|
7
8
|
import { holdBackspaceAtFrontMatter } from '../commands/frontMatter';
|
|
8
9
|
import { insertLineBreak } from '../commands/lineBreak';
|
|
9
10
|
import { toggleLink } from '../commands/link';
|
|
10
11
|
import { blockInsideItem, listCommands } from '../commands/list';
|
|
11
|
-
import { mermaidBlockOnEnter } from '../commands/mermaidBlock';
|
|
12
12
|
import { dissolveHeadingAtStart, insertHeadingBefore, insertSectionAfter, removeEmptyLeadingBlock, removeUnjoinableEmptyBlock, targetSection } from '../commands/section';
|
|
13
13
|
import { requiredSelectionBlock } from '../commands/selectedBlock';
|
|
14
14
|
import { tableCommands } from '../commands/table';
|
|
@@ -348,15 +348,15 @@ export const coreActions = [
|
|
|
348
348
|
command: enterTabEscape
|
|
349
349
|
},
|
|
350
350
|
{
|
|
351
|
-
// 行頭の ```
|
|
351
|
+
// 行頭の ``` に続く改行での変換(改行側。空白側は InputRule)。
|
|
352
352
|
// 項目の中の段落でも働くよう、Enter の並びで splitListItem より前に置く
|
|
353
|
-
id: 'editing.
|
|
353
|
+
id: 'editing.fencedBlockOnEnter',
|
|
354
354
|
category: 'format',
|
|
355
355
|
scope: 'input',
|
|
356
356
|
listed: false,
|
|
357
357
|
changesDocument: true,
|
|
358
358
|
keys: [{ key: 'Enter' }],
|
|
359
|
-
command:
|
|
359
|
+
command: fencedBlockOnEnter
|
|
360
360
|
},
|
|
361
361
|
{
|
|
362
362
|
id: 'editing.splitListItem',
|
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.19",
|
|
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.",
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { EditorCommand } from '../operations.types';
|
|
2
|
-
/**
|
|
3
|
-
* 行頭からの ` ```mermaid ` に続く改行で、Mermaid ブロックを作る。
|
|
4
|
-
*
|
|
5
|
-
* 空白での変換は autoformat の InputRule が受け持つが、InputRule は文字入力でのみ
|
|
6
|
-
* 発火し、Enter では発火しない。改行の側だけをこの命令が受け持つ。
|
|
7
|
-
* カーソルより後ろの文字は、変換後のブロックのソースとして残る。
|
|
8
|
-
*/
|
|
9
|
-
export declare const mermaidBlockOnEnter: EditorCommand;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { outlineSchema } from '../../models/document/schema';
|
|
2
|
-
/**
|
|
3
|
-
* 行頭からの ` ```mermaid ` に続く改行で、Mermaid ブロックを作る。
|
|
4
|
-
*
|
|
5
|
-
* 空白での変換は autoformat の InputRule が受け持つが、InputRule は文字入力でのみ
|
|
6
|
-
* 発火し、Enter では発火しない。改行の側だけをこの命令が受け持つ。
|
|
7
|
-
* カーソルより後ろの文字は、変換後のブロックのソースとして残る。
|
|
8
|
-
*/
|
|
9
|
-
export const mermaidBlockOnEnter = (state, dispatch) => {
|
|
10
|
-
const { $from, empty } = state.selection;
|
|
11
|
-
if (!empty)
|
|
12
|
-
return false;
|
|
13
|
-
const parent = $from.parent;
|
|
14
|
-
if (!parent.isTextblock || parent.type.spec.code)
|
|
15
|
-
return false;
|
|
16
|
-
if (parent.textBetween(0, $from.parentOffset) !== '```mermaid')
|
|
17
|
-
return false;
|
|
18
|
-
const start = $from.start();
|
|
19
|
-
const $start = state.doc.resolve(start);
|
|
20
|
-
const type = outlineSchema.nodes.mermaid_block;
|
|
21
|
-
if (!$start.node(-1).canReplaceWith($start.index(-1), $start.indexAfter(-1), type))
|
|
22
|
-
return false;
|
|
23
|
-
dispatch?.(state.tr
|
|
24
|
-
.delete(start, start + '```mermaid'.length)
|
|
25
|
-
.setBlockType(start, start, type)
|
|
26
|
-
.scrollIntoView());
|
|
27
|
-
return true;
|
|
28
|
-
};
|