@14ch/svelte-md-outliner 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +190 -0
- package/README.md +190 -0
- package/dist/assets/styles/editor.css +1459 -0
- package/dist/assets/styles/theme.css +486 -0
- package/dist/components/ContextMenu.svelte +279 -0
- package/dist/components/ContextMenu.svelte.d.ts +9 -0
- package/dist/components/EditorSurface.svelte +99 -0
- package/dist/components/EditorSurface.svelte.d.ts +16 -0
- package/dist/components/FocusBreadcrumb.svelte +138 -0
- package/dist/components/FocusBreadcrumb.svelte.d.ts +16 -0
- package/dist/components/MarkdownEditor.svelte +393 -0
- package/dist/components/MarkdownEditor.svelte.d.ts +119 -0
- package/dist/components/ShortcutHelpDialog.svelte +155 -0
- package/dist/components/ShortcutHelpDialog.svelte.d.ts +12 -0
- package/dist/components/internal/Dialog.svelte +157 -0
- package/dist/components/internal/Dialog.svelte.d.ts +23 -0
- package/dist/components/internal/Modal.svelte +181 -0
- package/dist/components/internal/Modal.svelte.d.ts +18 -0
- package/dist/components/internal/Popup.svelte +248 -0
- package/dist/components/internal/Popup.svelte.d.ts +26 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +28 -0
- package/dist/markdown.d.ts +13 -0
- package/dist/markdown.js +10 -0
- package/dist/messages/en.d.ts +2 -0
- package/dist/messages/en.js +107 -0
- package/dist/messages/index.d.ts +13 -0
- package/dist/messages/index.js +31 -0
- package/dist/messages/ja.d.ts +2 -0
- package/dist/messages/ja.js +112 -0
- package/dist/messages/messages.types.d.ts +59 -0
- package/dist/messages/messages.types.js +1 -0
- package/dist/models/document/bodySelection.d.ts +32 -0
- package/dist/models/document/bodySelection.js +43 -0
- package/dist/models/document/document.types.d.ts +27 -0
- package/dist/models/document/document.types.js +8 -0
- package/dist/models/document/foldable.d.ts +18 -0
- package/dist/models/document/foldable.js +21 -0
- package/dist/models/document/schema.d.ts +2 -0
- package/dist/models/document/schema.js +428 -0
- package/dist/models/document/sectionTree.d.ts +15 -0
- package/dist/models/document/sectionTree.js +123 -0
- package/dist/models/markdown/blockOutline.d.ts +9 -0
- package/dist/models/markdown/blockOutline.js +82 -0
- package/dist/models/markdown/frontMatter.d.ts +98 -0
- package/dist/models/markdown/frontMatter.js +300 -0
- package/dist/models/markdown/markdown.types.d.ts +60 -0
- package/dist/models/markdown/markdown.types.js +1 -0
- package/dist/models/markdown/markdownIt.d.ts +1 -0
- package/dist/models/markdown/markdownIt.js +92 -0
- package/dist/models/markdown/parser.d.ts +4 -0
- package/dist/models/markdown/parser.js +505 -0
- package/dist/models/markdown/plainText.d.ts +1 -0
- package/dist/models/markdown/plainText.js +25 -0
- package/dist/models/markdown/serializer.d.ts +17 -0
- package/dist/models/markdown/serializer.js +453 -0
- package/dist/models/viewState/viewState.types.d.ts +38 -0
- package/dist/models/viewState/viewState.types.js +17 -0
- package/dist/models/viewState/viewStateCodec.d.ts +31 -0
- package/dist/models/viewState/viewStateCodec.js +173 -0
- package/dist/operations/autoformat.d.ts +9 -0
- package/dist/operations/autoformat.js +86 -0
- package/dist/operations/commands/block.d.ts +24 -0
- package/dist/operations/commands/block.js +139 -0
- package/dist/operations/commands/codeBlock.d.ts +7 -0
- package/dist/operations/commands/codeBlock.js +26 -0
- package/dist/operations/commands/element.d.ts +67 -0
- package/dist/operations/commands/element.js +269 -0
- package/dist/operations/commands/frontMatter.d.ts +35 -0
- package/dist/operations/commands/frontMatter.js +120 -0
- package/dist/operations/commands/lineBreak.d.ts +9 -0
- package/dist/operations/commands/lineBreak.js +16 -0
- package/dist/operations/commands/link.d.ts +7 -0
- package/dist/operations/commands/link.js +21 -0
- package/dist/operations/commands/list.d.ts +126 -0
- package/dist/operations/commands/list.js +652 -0
- package/dist/operations/commands/mermaidBlock.d.ts +9 -0
- package/dist/operations/commands/mermaidBlock.js +28 -0
- package/dist/operations/commands/section.d.ts +217 -0
- package/dist/operations/commands/section.js +865 -0
- package/dist/operations/commands/sectionFold.d.ts +36 -0
- package/dist/operations/commands/sectionFold.js +219 -0
- package/dist/operations/commands/sectionJump.d.ts +8 -0
- package/dist/operations/commands/sectionJump.js +144 -0
- package/dist/operations/commands/selectedBlock.d.ts +37 -0
- package/dist/operations/commands/selectedBlock.js +170 -0
- package/dist/operations/commands/table.d.ts +64 -0
- package/dist/operations/commands/table.js +437 -0
- package/dist/operations/keymap/assemble.d.ts +22 -0
- package/dist/operations/keymap/assemble.js +165 -0
- package/dist/operations/keymap/coreActions.d.ts +2 -0
- package/dist/operations/keymap/coreActions.js +711 -0
- package/dist/operations/keymap/menuItems.d.ts +52 -0
- package/dist/operations/keymap/menuItems.js +114 -0
- package/dist/operations/keymap/shortcutKeys.d.ts +42 -0
- package/dist/operations/keymap/shortcutKeys.js +114 -0
- package/dist/operations/keymap/viewActions.d.ts +30 -0
- package/dist/operations/keymap/viewActions.js +182 -0
- package/dist/operations/operations.types.d.ts +121 -0
- package/dist/operations/operations.types.js +1 -0
- package/dist/operations/plugins/blockHandle.d.ts +25 -0
- package/dist/operations/plugins/blockHandle.js +112 -0
- package/dist/operations/plugins/contextMenu.d.ts +33 -0
- package/dist/operations/plugins/contextMenu.js +204 -0
- package/dist/operations/plugins/focus.d.ts +39 -0
- package/dist/operations/plugins/focus.js +350 -0
- package/dist/operations/plugins/foldClick.d.ts +11 -0
- package/dist/operations/plugins/foldClick.js +117 -0
- package/dist/operations/plugins/foldGuard.d.ts +15 -0
- package/dist/operations/plugins/foldGuard.js +31 -0
- package/dist/operations/plugins/frontMatterGuard.d.ts +21 -0
- package/dist/operations/plugins/frontMatterGuard.js +150 -0
- package/dist/operations/plugins/frontMatterView.d.ts +34 -0
- package/dist/operations/plugins/frontMatterView.js +137 -0
- package/dist/operations/plugins/linkPaste.d.ts +3 -0
- package/dist/operations/plugins/linkPaste.js +20 -0
- package/dist/operations/plugins/listStructure.d.ts +13 -0
- package/dist/operations/plugins/listStructure.js +18 -0
- package/dist/operations/plugins/markdownClipboard.d.ts +8 -0
- package/dist/operations/plugins/markdownClipboard.js +208 -0
- package/dist/operations/plugins/mermaidView.d.ts +20 -0
- package/dist/operations/plugins/mermaidView.js +206 -0
- package/dist/operations/plugins/requiredSelectionEntry.d.ts +10 -0
- package/dist/operations/plugins/requiredSelectionEntry.js +124 -0
- package/dist/operations/plugins/sectionView.d.ts +12 -0
- package/dist/operations/plugins/sectionView.js +44 -0
- package/dist/operations/plugins/tabEscape.d.ts +21 -0
- package/dist/operations/plugins/tabEscape.js +41 -0
- package/dist/operations/plugins/tableHandles.d.ts +24 -0
- package/dist/operations/plugins/tableHandles.js +89 -0
- package/dist/operations/transaction.d.ts +26 -0
- package/dist/operations/transaction.js +51 -0
- package/dist/operations/transactionOrigin.d.ts +17 -0
- package/dist/operations/transactionOrigin.js +9 -0
- package/dist/states/contextMenuController.svelte.d.ts +57 -0
- package/dist/states/contextMenuController.svelte.js +206 -0
- package/dist/states/editorSession.d.ts +12 -0
- package/dist/states/editorSession.js +268 -0
- package/dist/states/editorSession.types.d.ts +57 -0
- package/dist/states/editorSession.types.js +1 -0
- package/dist/states/outlineViewController.svelte.d.ts +52 -0
- package/dist/states/outlineViewController.svelte.js +134 -0
- package/dist/utils/dateText.d.ts +25 -0
- package/dist/utils/dateText.js +71 -0
- package/dist/utils/geometry.types.d.ts +13 -0
- package/dist/utils/geometry.types.js +1 -0
- package/dist/utils/json.types.d.ts +4 -0
- package/dist/utils/json.types.js +1 -0
- package/dist/utils/platform.d.ts +8 -0
- package/dist/utils/platform.js +10 -0
- package/dist/utils/result.types.d.ts +7 -0
- package/dist/utils/result.types.js +1 -0
- package/package.json +109 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 公開 API のエントリ。
|
|
3
|
+
*
|
|
4
|
+
* ここから export したものだけが利用者に見える。文書モデル(ProseMirror のスキーマ・
|
|
5
|
+
* プラグイン・コマンド)は内部実装であり、公開しない。export したものは互換性の約束になる。
|
|
6
|
+
*/
|
|
7
|
+
export { default as MarkdownEditor } from './components/MarkdownEditor.svelte';
|
|
8
|
+
// 表示文言(同梱の辞書と型)。独自の言語を作るときは既定を土台にできる
|
|
9
|
+
export { en, ja } from './messages';
|
|
10
|
+
/**
|
|
11
|
+
* マークダウン文字列を、エディタを置かずに読み書きするための純関数。
|
|
12
|
+
*
|
|
13
|
+
* - `readFrontMatterField`: 指定した項目の値。一覧のような場所でタイトルを出すために使う
|
|
14
|
+
* - `readFrontMatterFields`: フロントマターの全項目。何が書かれているかをキーを知らずに読む
|
|
15
|
+
* - `readBody`: フロントマターを除いた本文
|
|
16
|
+
* - `readBodyBlocks`: 本文のブロックの並び。種別・本文の中での範囲・見出しの経路を返す
|
|
17
|
+
* - `readPlainText`: インラインの記法を落とした読める文字列
|
|
18
|
+
* - `writeFrontMatterFields`: 項目の書き込み。キーと JSON の値を渡し、区切り・引用・
|
|
19
|
+
* 改行・差し込む位置はモジュールが持つ
|
|
20
|
+
*
|
|
21
|
+
* **どれも「マークダウンをどう読むか」の規則である。** 利用側に書けば同じ解釈が 2 か所に
|
|
22
|
+
* 生まれる——何をフロントマターと見なすかの素朴な規則は水平線で始まる文書を食い、記法を
|
|
23
|
+
* 落とす正規表現の表は入れ子の記法とエスケープで取りこぼす。
|
|
24
|
+
*
|
|
25
|
+
* 項目の値は文字列のまま返し、**型として解釈しない**。これが、利用者がモジュールを
|
|
26
|
+
* YAML の解析器として扱い始めるのを避けるための境界である。
|
|
27
|
+
*/
|
|
28
|
+
export { readBody, readBodyBlocks, readFrontMatterField, readFrontMatterFields, readPlainText, writeFrontMatterFields } from './markdown';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* エディタを置かずにマークダウン文字列を読み書きするための入口。
|
|
3
|
+
*
|
|
4
|
+
* `index.ts` はコンポーネントを出すため、読み込むと `.svelte` を辿る。素の Node
|
|
5
|
+
* (移行スクリプト・一覧を作る処理など)はそこを通れないので、**純関数だけの入口**を
|
|
6
|
+
* 別に置く。中身は `index.ts` が出すものと同じで、こちらが公開の一覧を持つ。
|
|
7
|
+
*/
|
|
8
|
+
export { readBody, readFrontMatterField, readFrontMatterFields, writeFrontMatterFields } from './models/markdown/frontMatter.js';
|
|
9
|
+
export { readBodyBlocks } from './models/markdown/blockOutline.js';
|
|
10
|
+
export { readPlainText } from './models/markdown/plainText.js';
|
|
11
|
+
export type { FrontMatterFields, FrontMatterValues, FrontMatterWriteError, FrontMatterWriteOutcome, MarkdownBlock, MarkdownBlockKind } from './models/markdown/markdown.types';
|
|
12
|
+
export type { JsonValue } from './utils/json.types';
|
|
13
|
+
export type { Result } from './utils/result.types';
|
package/dist/markdown.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* エディタを置かずにマークダウン文字列を読み書きするための入口。
|
|
3
|
+
*
|
|
4
|
+
* `index.ts` はコンポーネントを出すため、読み込むと `.svelte` を辿る。素の Node
|
|
5
|
+
* (移行スクリプト・一覧を作る処理など)はそこを通れないので、**純関数だけの入口**を
|
|
6
|
+
* 別に置く。中身は `index.ts` が出すものと同じで、こちらが公開の一覧を持つ。
|
|
7
|
+
*/
|
|
8
|
+
export { readBody, readFrontMatterField, readFrontMatterFields, writeFrontMatterFields } from './models/markdown/frontMatter.js';
|
|
9
|
+
export { readBodyBlocks } from './models/markdown/blockOutline.js';
|
|
10
|
+
export { readPlainText } from './models/markdown/plainText.js';
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
export const en = {
|
|
2
|
+
editorLabel: 'Markdown editor',
|
|
3
|
+
readonlyState: 'Read only',
|
|
4
|
+
focusBreadcrumbLabel: 'Focused outline path',
|
|
5
|
+
focusClear: 'Show whole document',
|
|
6
|
+
shortcutHelpTitle: 'Keyboard shortcuts',
|
|
7
|
+
contextMenuLabel: 'Actions menu',
|
|
8
|
+
mermaidEmpty: 'Empty Mermaid diagram',
|
|
9
|
+
mermaidLoading: 'Loading diagram renderer…',
|
|
10
|
+
mermaidRenderError: 'This source cannot be rendered as a diagram',
|
|
11
|
+
mermaidLoadError: 'Failed to load the diagram renderer',
|
|
12
|
+
frontMatterLabel: 'Front Matter',
|
|
13
|
+
shortcutCategories: {
|
|
14
|
+
edit: 'Edit',
|
|
15
|
+
subtree: 'Move',
|
|
16
|
+
convert: 'Turn into',
|
|
17
|
+
insert: 'Insert',
|
|
18
|
+
// Entries stay even when unused: category values can be added but never removed
|
|
19
|
+
hierarchy: 'Outline level',
|
|
20
|
+
table: 'Tables',
|
|
21
|
+
format: 'Formatting',
|
|
22
|
+
document: 'Document',
|
|
23
|
+
view: 'View'
|
|
24
|
+
},
|
|
25
|
+
shortcuts: {
|
|
26
|
+
'hierarchy.sink': 'Move one level deeper',
|
|
27
|
+
'hierarchy.lift': 'Move one level shallower',
|
|
28
|
+
'hierarchy.sink.heading': 'Demote the heading',
|
|
29
|
+
'hierarchy.lift.heading': 'Promote the heading',
|
|
30
|
+
'hierarchy.sink.indent': 'Indent',
|
|
31
|
+
'hierarchy.lift.indent': 'Outdent',
|
|
32
|
+
'hierarchy.sink.intoItem': 'Move into the list item',
|
|
33
|
+
'hierarchy.lift.outOfItem': 'Move out of the list item',
|
|
34
|
+
'subtree.moveUp': 'Move up',
|
|
35
|
+
'subtree.moveDown': 'Move down',
|
|
36
|
+
'subtree.duplicate': 'Duplicate',
|
|
37
|
+
'subtree.delete': 'Delete',
|
|
38
|
+
// Keys that mean two things depending on context say so in the description
|
|
39
|
+
'table.create': 'Insert a table',
|
|
40
|
+
'table.insertRowBefore': 'In a table, insert a row above',
|
|
41
|
+
'table.insertRowBefore.inTable': 'Insert row above',
|
|
42
|
+
'table.insertRowAfter': 'In a table, insert a row below',
|
|
43
|
+
'table.insertRowAfter.inTable': 'Insert row below',
|
|
44
|
+
'table.insertColumnBefore': 'Insert a column to the left',
|
|
45
|
+
'table.insertColumnAfter': 'Insert a column to the right',
|
|
46
|
+
'table.deleteSelected': 'In a table, delete the row, column, or table',
|
|
47
|
+
'table.deleteSelected.inTable': 'Delete row, column, or table',
|
|
48
|
+
'table.deleteRowOrColumn': 'When a whole row or column is selected, delete it',
|
|
49
|
+
'table.deleteRowOrColumn.inTable': 'Delete the selected rows or columns',
|
|
50
|
+
'table.moveRowUp': 'In a table, move the row up',
|
|
51
|
+
'table.moveRowUp.inTable': 'Move row up',
|
|
52
|
+
'table.moveRowDown': 'In a table, move the row down',
|
|
53
|
+
'table.moveRowDown.inTable': 'Move row down',
|
|
54
|
+
'table.moveColumnLeft': 'In a table, move the column left',
|
|
55
|
+
'table.moveColumnLeft.inTable': 'Move column left',
|
|
56
|
+
'table.moveColumnRight': 'In a table, move the column right',
|
|
57
|
+
'table.moveColumnRight.inTable': 'Move column right',
|
|
58
|
+
'table.alignLeftward': 'Shift column alignment leftward',
|
|
59
|
+
'table.alignRightward': 'Shift column alignment rightward',
|
|
60
|
+
'document.undo': 'Undo',
|
|
61
|
+
'document.redo': 'Redo',
|
|
62
|
+
'editing.escapeTab': 'Release Tab so it moves focus',
|
|
63
|
+
'editing.mermaidBlockOnEnter': 'At the start of a line, turn ```mermaid into a diagram block',
|
|
64
|
+
'editing.splitListItem': 'New list item',
|
|
65
|
+
'editing.undoInputRule': 'Undo the last automatic formatting',
|
|
66
|
+
'editing.dissolveHeading': 'At the start of a heading, drop it and join the section above',
|
|
67
|
+
'editing.insertHeadingBefore': 'At the start of a heading, insert an empty heading above it',
|
|
68
|
+
'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 or tables)',
|
|
70
|
+
'format.toggleTask': 'Toggle task done',
|
|
71
|
+
'format.bold': 'Bold',
|
|
72
|
+
'format.italic': 'Italic',
|
|
73
|
+
'format.code': 'Inline code',
|
|
74
|
+
'format.strikethrough': 'Strikethrough',
|
|
75
|
+
'format.link': 'Link',
|
|
76
|
+
// The list is a dictionary of everything that can happen; ids with a trailing
|
|
77
|
+
// `.` part are the direction the context menu shows for a known target
|
|
78
|
+
'format.heading': 'Turn into a heading, or back into a list item',
|
|
79
|
+
'format.heading.toHeading': 'Turn into a heading',
|
|
80
|
+
'format.heading.toListItem': 'Turn back into a list item',
|
|
81
|
+
'format.paragraph': 'Turn into a paragraph',
|
|
82
|
+
'format.bulletList': 'Turn into a bulleted list',
|
|
83
|
+
'format.orderedList': 'Turn into a numbered list',
|
|
84
|
+
'format.taskList': 'Turn into a task list',
|
|
85
|
+
'format.blockquote': 'Turn into a quote',
|
|
86
|
+
'format.codeBlock': 'Turn into a code block',
|
|
87
|
+
'view.toggleFold': 'Fold or unfold',
|
|
88
|
+
'view.toggleFold.fold': 'Fold',
|
|
89
|
+
'view.toggleFold.unfold': 'Unfold',
|
|
90
|
+
'view.foldAll': 'Fold everything',
|
|
91
|
+
'view.unfoldAll': 'Unfold everything',
|
|
92
|
+
'view.foldToLevel1': 'Show down to heading level 1',
|
|
93
|
+
'view.foldToLevel2': 'Show down to heading level 2',
|
|
94
|
+
'view.foldToLevel3': 'Show down to heading level 3',
|
|
95
|
+
'view.foldToLevel4': 'Show down to heading level 4',
|
|
96
|
+
'view.foldToLevel5': 'Show down to heading level 5',
|
|
97
|
+
'view.foldToLevel6': 'Show down to heading level 6',
|
|
98
|
+
'view.jumpPrevHeading': 'Go to the previous heading',
|
|
99
|
+
'view.jumpNextHeading': 'Go to the next heading',
|
|
100
|
+
'view.jumpPrevSameLevel': 'Go to the previous heading at the same level',
|
|
101
|
+
'view.jumpNextSameLevel': 'Go to the next heading at the same level',
|
|
102
|
+
'view.focusSection': 'Show only this section',
|
|
103
|
+
'view.clearFocus': 'Show the whole document',
|
|
104
|
+
'view.shortcutHelp': 'Show or hide the shortcut list',
|
|
105
|
+
'view.contextMenu': 'Show the actions available here'
|
|
106
|
+
}
|
|
107
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { en } from './en';
|
|
2
|
+
import { ja } from './ja';
|
|
3
|
+
import type { EditorLang, EditorMessages, EditorMessagesOverride } from './messages.types';
|
|
4
|
+
export { en, ja };
|
|
5
|
+
export type { EditorLang, EditorMessages, EditorMessagesOverride, EditorShortcutCategory } from './messages.types';
|
|
6
|
+
export declare const DEFAULT_LANG: EditorLang;
|
|
7
|
+
/**
|
|
8
|
+
* 表示文字列を決める。
|
|
9
|
+
*
|
|
10
|
+
* `lang` で選んだ一式の上に `overrides` を重ねる。一部だけ渡された場合、
|
|
11
|
+
* 残りは選んだ言語の文字列で埋まる。同梱していない言語は一式を渡して使う。
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveMessages(lang?: EditorLang, overrides?: EditorMessagesOverride): EditorMessages;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { en } from './en';
|
|
2
|
+
import { ja } from './ja';
|
|
3
|
+
export { en, ja };
|
|
4
|
+
const bundled = { en, ja };
|
|
5
|
+
export const DEFAULT_LANG = 'en';
|
|
6
|
+
/**
|
|
7
|
+
* 表示文字列を決める。
|
|
8
|
+
*
|
|
9
|
+
* `lang` で選んだ一式の上に `overrides` を重ねる。一部だけ渡された場合、
|
|
10
|
+
* 残りは選んだ言語の文字列で埋まる。同梱していない言語は一式を渡して使う。
|
|
11
|
+
*/
|
|
12
|
+
export function resolveMessages(lang = DEFAULT_LANG, overrides) {
|
|
13
|
+
const base = bundled[lang] ?? bundled[DEFAULT_LANG];
|
|
14
|
+
if (!overrides)
|
|
15
|
+
return base;
|
|
16
|
+
return {
|
|
17
|
+
editorLabel: overrides.editorLabel ?? base.editorLabel,
|
|
18
|
+
readonlyState: overrides.readonlyState ?? base.readonlyState,
|
|
19
|
+
focusBreadcrumbLabel: overrides.focusBreadcrumbLabel ?? base.focusBreadcrumbLabel,
|
|
20
|
+
focusClear: overrides.focusClear ?? base.focusClear,
|
|
21
|
+
shortcutHelpTitle: overrides.shortcutHelpTitle ?? base.shortcutHelpTitle,
|
|
22
|
+
contextMenuLabel: overrides.contextMenuLabel ?? base.contextMenuLabel,
|
|
23
|
+
shortcuts: { ...base.shortcuts, ...overrides.shortcuts },
|
|
24
|
+
shortcutCategories: { ...base.shortcutCategories, ...overrides.shortcutCategories },
|
|
25
|
+
mermaidEmpty: overrides.mermaidEmpty ?? base.mermaidEmpty,
|
|
26
|
+
mermaidLoading: overrides.mermaidLoading ?? base.mermaidLoading,
|
|
27
|
+
mermaidRenderError: overrides.mermaidRenderError ?? base.mermaidRenderError,
|
|
28
|
+
mermaidLoadError: overrides.mermaidLoadError ?? base.mermaidLoadError,
|
|
29
|
+
frontMatterLabel: overrides.frontMatterLabel ?? base.frontMatterLabel
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
export const ja = {
|
|
2
|
+
editorLabel: 'マークダウンエディター',
|
|
3
|
+
readonlyState: '読み取り専用',
|
|
4
|
+
focusBreadcrumbLabel: '表示中の階層',
|
|
5
|
+
focusClear: '全体を表示',
|
|
6
|
+
shortcutHelpTitle: 'キーボードショートカット',
|
|
7
|
+
contextMenuLabel: '操作メニュー',
|
|
8
|
+
mermaidEmpty: '空の Mermaid 図です',
|
|
9
|
+
mermaidLoading: '図の描画機能を読み込んでいます…',
|
|
10
|
+
mermaidRenderError: 'この内容では図を描画できません',
|
|
11
|
+
mermaidLoadError: '図の描画機能を読み込めませんでした',
|
|
12
|
+
frontMatterLabel: 'Front Matter',
|
|
13
|
+
shortcutCategories: {
|
|
14
|
+
// グループは利用者の意図で分ける。「ブロックの操作」のような総称は使わない
|
|
15
|
+
// (メニューに並ぶものはすべてブロックの操作であり、何も区別しないため)
|
|
16
|
+
edit: '編集',
|
|
17
|
+
subtree: '移動',
|
|
18
|
+
convert: '変換',
|
|
19
|
+
insert: '挿入',
|
|
20
|
+
// 使う宣言が無くなった分類も**項目は消さない**(値は追加できるが削除はできない)
|
|
21
|
+
hierarchy: '階層',
|
|
22
|
+
table: '表',
|
|
23
|
+
format: '書式',
|
|
24
|
+
document: '文書',
|
|
25
|
+
view: '表示'
|
|
26
|
+
},
|
|
27
|
+
shortcuts: {
|
|
28
|
+
'hierarchy.sink': '1 段深くする',
|
|
29
|
+
'hierarchy.lift': '1 段浅くする',
|
|
30
|
+
// `.` を継ぎ足した id は、コンテキストメニューが出す「この場で起きること」の説明
|
|
31
|
+
'hierarchy.sink.heading': '見出しのレベルを下げる',
|
|
32
|
+
'hierarchy.lift.heading': '見出しのレベルを上げる',
|
|
33
|
+
'hierarchy.sink.indent': 'インデント',
|
|
34
|
+
'hierarchy.lift.indent': 'インデントを解除',
|
|
35
|
+
'hierarchy.sink.intoItem': 'リスト項目の中へ入れる',
|
|
36
|
+
'hierarchy.lift.outOfItem': 'リスト項目の外へ出す',
|
|
37
|
+
'subtree.moveUp': '上へ移動',
|
|
38
|
+
'subtree.moveDown': '下へ移動',
|
|
39
|
+
'subtree.duplicate': '複製',
|
|
40
|
+
'subtree.delete': '削除',
|
|
41
|
+
// 同じキーが文脈で 2 つの意味を持つものは、条件が読み取れる文言にする
|
|
42
|
+
// 表は書かれた内容の変換ではなく、空の表を作ってから埋める
|
|
43
|
+
'table.create': '表を挿入',
|
|
44
|
+
// メニューは表の中でしか出ない。一覧の「表の中では」は繰り返さない
|
|
45
|
+
'table.insertRowBefore': '表の中では、上に行を挿入',
|
|
46
|
+
'table.insertRowBefore.inTable': '上に行を挿入',
|
|
47
|
+
'table.insertRowAfter': '表の中では、下に行を挿入',
|
|
48
|
+
'table.insertRowAfter.inTable': '下に行を挿入',
|
|
49
|
+
'table.insertColumnBefore': '左に列を挿入',
|
|
50
|
+
'table.insertColumnAfter': '右に列を挿入',
|
|
51
|
+
'table.deleteSelected': '表の中では、行・列・表を削除',
|
|
52
|
+
'table.deleteSelected.inTable': '行・列・表を削除',
|
|
53
|
+
'table.deleteRowOrColumn': '行や列を丸ごと選んでいるとき、それを削除',
|
|
54
|
+
'table.deleteRowOrColumn.inTable': '選んだ行や列を削除',
|
|
55
|
+
'table.moveRowUp': '表の中では、行を上へ移動',
|
|
56
|
+
'table.moveRowUp.inTable': '行を上へ移動',
|
|
57
|
+
'table.moveRowDown': '表の中では、行を下へ移動',
|
|
58
|
+
'table.moveRowDown.inTable': '行を下へ移動',
|
|
59
|
+
'table.moveColumnLeft': '表の中では、列を左へ移動',
|
|
60
|
+
'table.moveColumnLeft.inTable': '列を左へ移動',
|
|
61
|
+
'table.moveColumnRight': '表の中では、列を右へ移動',
|
|
62
|
+
'table.moveColumnRight.inTable': '列を右へ移動',
|
|
63
|
+
'table.alignLeftward': '列の配置を左方向へ動かす',
|
|
64
|
+
'table.alignRightward': '列の配置を右方向へ動かす',
|
|
65
|
+
'document.undo': '取り消し',
|
|
66
|
+
'document.redo': 'やり直し',
|
|
67
|
+
'editing.escapeTab': 'Tab でフォーカスを移せる状態にする',
|
|
68
|
+
'editing.mermaidBlockOnEnter': '行頭の ```mermaid を図のブロックにする',
|
|
69
|
+
'editing.splitListItem': '新しい項目',
|
|
70
|
+
'editing.undoInputRule': '直前の自動変換を取り消す',
|
|
71
|
+
'editing.dissolveHeading': '見出しの先頭で押すと、見出しをやめて前のセクションへ繋げる',
|
|
72
|
+
'editing.insertHeadingBefore': '見出しの先頭で押すと、空の見出しを上に足す',
|
|
73
|
+
'editing.insertSectionAfter': 'いまいるセクションの下に、空の見出しを足す',
|
|
74
|
+
'editing.insertLineBreak': '段落を分けずに改行する(見出し・表の中ではできない)',
|
|
75
|
+
'format.toggleTask': 'チェックの切り替え',
|
|
76
|
+
'format.bold': '強調',
|
|
77
|
+
'format.italic': '斜体',
|
|
78
|
+
'format.code': 'インラインコード',
|
|
79
|
+
'format.strikethrough': '取り消し線',
|
|
80
|
+
'format.link': 'リンク',
|
|
81
|
+
// 一覧は起きうることを全部載せる辞書。`.` を継ぎ足した id は、対象が決まっている
|
|
82
|
+
// コンテキストメニューが引く「いま起きる向き」の説明である
|
|
83
|
+
'format.heading': '見出しにする/リスト項目に戻す',
|
|
84
|
+
'format.heading.toHeading': '見出しにする',
|
|
85
|
+
'format.heading.toListItem': 'リスト項目に戻す',
|
|
86
|
+
'format.paragraph': '段落にする',
|
|
87
|
+
'format.bulletList': '箇条書きにする',
|
|
88
|
+
'format.orderedList': '番号付きにする',
|
|
89
|
+
'format.taskList': 'チェック項目にする',
|
|
90
|
+
'format.blockquote': '引用にする',
|
|
91
|
+
'format.codeBlock': 'コードブロックにする',
|
|
92
|
+
'view.toggleFold': '畳む/展開する',
|
|
93
|
+
'view.toggleFold.fold': '畳む',
|
|
94
|
+
'view.toggleFold.unfold': '展開する',
|
|
95
|
+
'view.foldAll': 'すべて畳む',
|
|
96
|
+
'view.unfoldAll': 'すべて展開する',
|
|
97
|
+
'view.foldToLevel1': '見出し 1 の高さまで畳む',
|
|
98
|
+
'view.foldToLevel2': '見出し 2 の高さまで畳む',
|
|
99
|
+
'view.foldToLevel3': '見出し 3 の高さまで畳む',
|
|
100
|
+
'view.foldToLevel4': '見出し 4 の高さまで畳む',
|
|
101
|
+
'view.foldToLevel5': '見出し 5 の高さまで畳む',
|
|
102
|
+
'view.foldToLevel6': '見出し 6 の高さまで畳む',
|
|
103
|
+
'view.jumpPrevHeading': '前の見出しへ移動',
|
|
104
|
+
'view.jumpNextHeading': '次の見出しへ移動',
|
|
105
|
+
'view.jumpPrevSameLevel': '同じ階層の前の見出しへ移動',
|
|
106
|
+
'view.jumpNextSameLevel': '同じ階層の次の見出しへ移動',
|
|
107
|
+
'view.focusSection': 'このセクションだけを表示',
|
|
108
|
+
'view.clearFocus': '全体の表示に戻す',
|
|
109
|
+
'view.shortcutHelp': 'ショートカット一覧の表示/非表示',
|
|
110
|
+
'view.contextMenu': 'この位置で使える操作を表示'
|
|
111
|
+
}
|
|
112
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/** 同梱している言語 */
|
|
2
|
+
export type EditorLang = 'en' | 'ja';
|
|
3
|
+
/** ショートカットの分類。値は追加できるが削除しない(網羅指定している利用者を壊さない) */
|
|
4
|
+
export type EditorShortcutCategory = 'edit' | 'subtree' | 'convert' | 'insert' | 'hierarchy' | 'table' | 'format' | 'document' | 'view';
|
|
5
|
+
/**
|
|
6
|
+
* モジュールが出すすべての文字列。既定値を同梱し、利用者が部分的に差し替える。
|
|
7
|
+
*
|
|
8
|
+
* 修飾キーの表記(macOS の ⌘ など)はここに含めない。言語ではなく実行環境で決まるためである。
|
|
9
|
+
*/
|
|
10
|
+
export interface EditorMessages {
|
|
11
|
+
/** 編集エリアの既定のラベル */
|
|
12
|
+
readonly editorLabel: string;
|
|
13
|
+
/** 読み取り専用であることの説明 */
|
|
14
|
+
readonly readonlyState: string;
|
|
15
|
+
/** フォーカス中の階層位置を示す領域の名前 */
|
|
16
|
+
readonly focusBreadcrumbLabel: string;
|
|
17
|
+
/** フォーカスを解いて全体表示へ戻す操作のラベル */
|
|
18
|
+
readonly focusClear: string;
|
|
19
|
+
/** ショートカット一覧のタイトル */
|
|
20
|
+
readonly shortcutHelpTitle: string;
|
|
21
|
+
/** コンテキストメニューのアクセシブルな名前 */
|
|
22
|
+
readonly contextMenuLabel: string;
|
|
23
|
+
/** ショートカットの説明(操作 id をキーとする) */
|
|
24
|
+
readonly shortcuts: Readonly<Record<string, string>>;
|
|
25
|
+
/** ショートカットの分類の見出し */
|
|
26
|
+
readonly shortcutCategories: Readonly<Record<EditorShortcutCategory, string>>;
|
|
27
|
+
/** Mermaid ブロックが空であることを伝える表示 */
|
|
28
|
+
readonly mermaidEmpty: string;
|
|
29
|
+
/** 描画ライブラリを読み込んでいる間の表示 */
|
|
30
|
+
readonly mermaidLoading: string;
|
|
31
|
+
/** ソースが描画できないことを伝える表示 */
|
|
32
|
+
readonly mermaidRenderError: string;
|
|
33
|
+
/** 描画ライブラリの読み込みに失敗したことを伝える表示 */
|
|
34
|
+
readonly mermaidLoadError: string;
|
|
35
|
+
/**
|
|
36
|
+
* フロントマターにタイトルが無いときに、その場所へ薄く出す名前。
|
|
37
|
+
* 状態の説明(「未設定です」)ではなく、**そこが何であるか**の表示である
|
|
38
|
+
*/
|
|
39
|
+
readonly frontMatterLabel: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 文字列の部分的な差し替え。
|
|
43
|
+
* 入れ子の一覧も一部だけ指定でき、指定しなかった項目は選んだ言語の文字列で埋まる。
|
|
44
|
+
*/
|
|
45
|
+
export interface EditorMessagesOverride {
|
|
46
|
+
readonly editorLabel?: string;
|
|
47
|
+
readonly readonlyState?: string;
|
|
48
|
+
readonly focusBreadcrumbLabel?: string;
|
|
49
|
+
readonly focusClear?: string;
|
|
50
|
+
readonly shortcutHelpTitle?: string;
|
|
51
|
+
readonly contextMenuLabel?: string;
|
|
52
|
+
readonly shortcuts?: Readonly<Record<string, string>>;
|
|
53
|
+
readonly shortcutCategories?: Readonly<Partial<Record<EditorShortcutCategory, string>>>;
|
|
54
|
+
readonly mermaidEmpty?: string;
|
|
55
|
+
readonly mermaidLoading?: string;
|
|
56
|
+
readonly mermaidRenderError?: string;
|
|
57
|
+
readonly mermaidLoadError?: string;
|
|
58
|
+
readonly frontMatterLabel?: string;
|
|
59
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Node } from 'prosemirror-model';
|
|
2
|
+
import { Selection } from 'prosemirror-state';
|
|
3
|
+
/**
|
|
4
|
+
* 文書を開いた直後に置く選択。フロントマターの後ろの、本文の先頭。
|
|
5
|
+
*
|
|
6
|
+
* **位置の数値ではなく選択そのものを返す。** 本文に文字を置ける位置が無い形がありうる
|
|
7
|
+
* ため——フロントマターの後ろが水平線だけの文書では、`intro_section` の中身が水平線 1 つで、
|
|
8
|
+
* 文字を置ける位置が存在しない。もっとも近い有効な選択を求めれば、その場合は水平線を指す
|
|
9
|
+
* 選択になり、行き先が無くなる経路が消える。
|
|
10
|
+
*
|
|
11
|
+
* 本文が空でないことは content 式が保証するので、返せる選択は必ず存在する。
|
|
12
|
+
*/
|
|
13
|
+
export declare function bodySelection(doc: Node): Selection;
|
|
14
|
+
/**
|
|
15
|
+
* 本文の始まる位置。文書の先頭は必ずフロントマターなので、その次から本文になる。
|
|
16
|
+
*
|
|
17
|
+
* 位置を数える側が「先頭がフロントマターであること」を各所で知らずに済むよう、
|
|
18
|
+
* 導出をここ 1 か所に置く。
|
|
19
|
+
*/
|
|
20
|
+
export declare function bodyStart(doc: Node): number;
|
|
21
|
+
/**
|
|
22
|
+
* フロントマターの中身が始まる位置。領域が無ければ `null`。
|
|
23
|
+
*
|
|
24
|
+
* 中身は 1 つのテキストとして持つため、中身の中の文字数 `i` は文書上の
|
|
25
|
+
* `frontMatterContentStart(doc) + i` にそのまま対応する。`bodyStart` と同じ理由で
|
|
26
|
+
* ここに置く——位置を数える側が「先頭がフロントマターであること」を知らずに済む。
|
|
27
|
+
*/
|
|
28
|
+
export declare function frontMatterContentStart(doc: Node): number | null;
|
|
29
|
+
/** 本文の最初の子の添字。先頭がフロントマターなら 1 */
|
|
30
|
+
export declare function bodyIndex(doc: Node): number;
|
|
31
|
+
/** 本文の子の数(フロントマターを数えない) */
|
|
32
|
+
export declare function bodyCount(doc: Node): number;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Selection } from 'prosemirror-state';
|
|
2
|
+
import { outlineSchema } from './schema';
|
|
3
|
+
/**
|
|
4
|
+
* 文書を開いた直後に置く選択。フロントマターの後ろの、本文の先頭。
|
|
5
|
+
*
|
|
6
|
+
* **位置の数値ではなく選択そのものを返す。** 本文に文字を置ける位置が無い形がありうる
|
|
7
|
+
* ため——フロントマターの後ろが水平線だけの文書では、`intro_section` の中身が水平線 1 つで、
|
|
8
|
+
* 文字を置ける位置が存在しない。もっとも近い有効な選択を求めれば、その場合は水平線を指す
|
|
9
|
+
* 選択になり、行き先が無くなる経路が消える。
|
|
10
|
+
*
|
|
11
|
+
* 本文が空でないことは content 式が保証するので、返せる選択は必ず存在する。
|
|
12
|
+
*/
|
|
13
|
+
export function bodySelection(doc) {
|
|
14
|
+
return Selection.near(doc.resolve(bodyStart(doc)), 1);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 本文の始まる位置。文書の先頭は必ずフロントマターなので、その次から本文になる。
|
|
18
|
+
*
|
|
19
|
+
* 位置を数える側が「先頭がフロントマターであること」を各所で知らずに済むよう、
|
|
20
|
+
* 導出をここ 1 か所に置く。
|
|
21
|
+
*/
|
|
22
|
+
export function bodyStart(doc) {
|
|
23
|
+
const first = doc.firstChild;
|
|
24
|
+
return first?.type === outlineSchema.nodes.front_matter ? first.nodeSize : 0;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* フロントマターの中身が始まる位置。領域が無ければ `null`。
|
|
28
|
+
*
|
|
29
|
+
* 中身は 1 つのテキストとして持つため、中身の中の文字数 `i` は文書上の
|
|
30
|
+
* `frontMatterContentStart(doc) + i` にそのまま対応する。`bodyStart` と同じ理由で
|
|
31
|
+
* ここに置く——位置を数える側が「先頭がフロントマターであること」を知らずに済む。
|
|
32
|
+
*/
|
|
33
|
+
export function frontMatterContentStart(doc) {
|
|
34
|
+
return doc.firstChild?.type === outlineSchema.nodes.front_matter ? 1 : null;
|
|
35
|
+
}
|
|
36
|
+
/** 本文の最初の子の添字。先頭がフロントマターなら 1 */
|
|
37
|
+
export function bodyIndex(doc) {
|
|
38
|
+
return doc.firstChild?.type === outlineSchema.nodes.front_matter ? 1 : 0;
|
|
39
|
+
}
|
|
40
|
+
/** 本文の子の数(フロントマターを数えない) */
|
|
41
|
+
export function bodyCount(doc) {
|
|
42
|
+
return doc.childCount - bodyIndex(doc);
|
|
43
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Node } from 'prosemirror-model';
|
|
2
|
+
/** 見出しの深さ。構造上の深さの写しであり、深さと独立した真実ではない */
|
|
3
|
+
export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
4
|
+
export declare const MIN_HEADING_LEVEL = 1;
|
|
5
|
+
export declare const MAX_HEADING_LEVEL = 6;
|
|
6
|
+
export declare function isHeadingLevel(value: unknown): value is HeadingLevel;
|
|
7
|
+
export interface HeadingAttrs {
|
|
8
|
+
readonly level: HeadingLevel;
|
|
9
|
+
}
|
|
10
|
+
/** 原文のまま保持する記法(HTML ブロックなど)を格納する */
|
|
11
|
+
export interface UnknownBlockAttrs {
|
|
12
|
+
readonly source: string;
|
|
13
|
+
}
|
|
14
|
+
/** 文書内で一意に定まるセクションの位置。深さ優先順のインデックス列 */
|
|
15
|
+
export type SectionPath = readonly number[];
|
|
16
|
+
export interface SectionRef {
|
|
17
|
+
readonly pos: number;
|
|
18
|
+
readonly node: Node;
|
|
19
|
+
/** 見出しを持たないセクションは `null`(アウトライン上のアドレスを持たない) */
|
|
20
|
+
readonly path: SectionPath | null;
|
|
21
|
+
/** 見出しを持たないセクションは `null` */
|
|
22
|
+
readonly level: HeadingLevel | null;
|
|
23
|
+
readonly hasChildren: boolean;
|
|
24
|
+
}
|
|
25
|
+
export type BlockKind = 'heading' | 'paragraph' | 'bullet_list' | 'ordered_list' | 'task_list' | 'blockquote' | 'code_block';
|
|
26
|
+
/** 表の列の配置指定。`schema.ts` の `cellAttributes.align` が取る値 */
|
|
27
|
+
export type CellAlign = 'left' | 'center' | 'right' | null;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Node } from 'prosemirror-model';
|
|
2
|
+
/**
|
|
3
|
+
* 畳んだときに隠れるものを持つか。先頭の子(見出し・項目の本文)は常に見えたままになる。
|
|
4
|
+
*
|
|
5
|
+
* **描画と折りたたみコマンドは、この 1 つの述語だけを使う**。
|
|
6
|
+
* 判定が分かれていると、ずれたときに「見えるのに押せない記号」か
|
|
7
|
+
* 「見えないのに反応する領域」が生まれる。どちらも原因を追いにくい。
|
|
8
|
+
*/
|
|
9
|
+
export declare function hasFoldableChildren(node: Node): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* 開閉状態を描画される要素へ出すための属性。畳めない対象には状態そのものを持たせない。
|
|
12
|
+
*
|
|
13
|
+
* 見出しと項目で同じ属性名にそろえる。一覧ライブラリは「畳めるか」しか出さず、
|
|
14
|
+
* 開いているか閉じているかを伝えないため、こちらで足す。
|
|
15
|
+
*/
|
|
16
|
+
export declare function foldStateAttrs(node: Node): {
|
|
17
|
+
'aria-expanded': string | undefined;
|
|
18
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 畳んだときに隠れるものを持つか。先頭の子(見出し・項目の本文)は常に見えたままになる。
|
|
3
|
+
*
|
|
4
|
+
* **描画と折りたたみコマンドは、この 1 つの述語だけを使う**。
|
|
5
|
+
* 判定が分かれていると、ずれたときに「見えるのに押せない記号」か
|
|
6
|
+
* 「見えないのに反応する領域」が生まれる。どちらも原因を追いにくい。
|
|
7
|
+
*/
|
|
8
|
+
export function hasFoldableChildren(node) {
|
|
9
|
+
return node.childCount > 1;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 開閉状態を描画される要素へ出すための属性。畳めない対象には状態そのものを持たせない。
|
|
13
|
+
*
|
|
14
|
+
* 見出しと項目で同じ属性名にそろえる。一覧ライブラリは「畳めるか」しか出さず、
|
|
15
|
+
* 開いているか閉じているかを伝えないため、こちらで足す。
|
|
16
|
+
*/
|
|
17
|
+
export function foldStateAttrs(node) {
|
|
18
|
+
return {
|
|
19
|
+
'aria-expanded': hasFoldableChildren(node) ? String(!node.attrs.collapsed) : undefined
|
|
20
|
+
};
|
|
21
|
+
}
|