@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.
Files changed (153) hide show
  1. package/README.ja.md +190 -0
  2. package/README.md +190 -0
  3. package/dist/assets/styles/editor.css +1459 -0
  4. package/dist/assets/styles/theme.css +486 -0
  5. package/dist/components/ContextMenu.svelte +279 -0
  6. package/dist/components/ContextMenu.svelte.d.ts +9 -0
  7. package/dist/components/EditorSurface.svelte +99 -0
  8. package/dist/components/EditorSurface.svelte.d.ts +16 -0
  9. package/dist/components/FocusBreadcrumb.svelte +138 -0
  10. package/dist/components/FocusBreadcrumb.svelte.d.ts +16 -0
  11. package/dist/components/MarkdownEditor.svelte +393 -0
  12. package/dist/components/MarkdownEditor.svelte.d.ts +119 -0
  13. package/dist/components/ShortcutHelpDialog.svelte +155 -0
  14. package/dist/components/ShortcutHelpDialog.svelte.d.ts +12 -0
  15. package/dist/components/internal/Dialog.svelte +157 -0
  16. package/dist/components/internal/Dialog.svelte.d.ts +23 -0
  17. package/dist/components/internal/Modal.svelte +181 -0
  18. package/dist/components/internal/Modal.svelte.d.ts +18 -0
  19. package/dist/components/internal/Popup.svelte +248 -0
  20. package/dist/components/internal/Popup.svelte.d.ts +26 -0
  21. package/dist/index.d.ts +32 -0
  22. package/dist/index.js +28 -0
  23. package/dist/markdown.d.ts +13 -0
  24. package/dist/markdown.js +10 -0
  25. package/dist/messages/en.d.ts +2 -0
  26. package/dist/messages/en.js +107 -0
  27. package/dist/messages/index.d.ts +13 -0
  28. package/dist/messages/index.js +31 -0
  29. package/dist/messages/ja.d.ts +2 -0
  30. package/dist/messages/ja.js +112 -0
  31. package/dist/messages/messages.types.d.ts +59 -0
  32. package/dist/messages/messages.types.js +1 -0
  33. package/dist/models/document/bodySelection.d.ts +32 -0
  34. package/dist/models/document/bodySelection.js +43 -0
  35. package/dist/models/document/document.types.d.ts +27 -0
  36. package/dist/models/document/document.types.js +8 -0
  37. package/dist/models/document/foldable.d.ts +18 -0
  38. package/dist/models/document/foldable.js +21 -0
  39. package/dist/models/document/schema.d.ts +2 -0
  40. package/dist/models/document/schema.js +428 -0
  41. package/dist/models/document/sectionTree.d.ts +15 -0
  42. package/dist/models/document/sectionTree.js +123 -0
  43. package/dist/models/markdown/blockOutline.d.ts +9 -0
  44. package/dist/models/markdown/blockOutline.js +82 -0
  45. package/dist/models/markdown/frontMatter.d.ts +98 -0
  46. package/dist/models/markdown/frontMatter.js +300 -0
  47. package/dist/models/markdown/markdown.types.d.ts +60 -0
  48. package/dist/models/markdown/markdown.types.js +1 -0
  49. package/dist/models/markdown/markdownIt.d.ts +1 -0
  50. package/dist/models/markdown/markdownIt.js +92 -0
  51. package/dist/models/markdown/parser.d.ts +4 -0
  52. package/dist/models/markdown/parser.js +505 -0
  53. package/dist/models/markdown/plainText.d.ts +1 -0
  54. package/dist/models/markdown/plainText.js +25 -0
  55. package/dist/models/markdown/serializer.d.ts +17 -0
  56. package/dist/models/markdown/serializer.js +453 -0
  57. package/dist/models/viewState/viewState.types.d.ts +38 -0
  58. package/dist/models/viewState/viewState.types.js +17 -0
  59. package/dist/models/viewState/viewStateCodec.d.ts +31 -0
  60. package/dist/models/viewState/viewStateCodec.js +173 -0
  61. package/dist/operations/autoformat.d.ts +9 -0
  62. package/dist/operations/autoformat.js +86 -0
  63. package/dist/operations/commands/block.d.ts +24 -0
  64. package/dist/operations/commands/block.js +139 -0
  65. package/dist/operations/commands/codeBlock.d.ts +7 -0
  66. package/dist/operations/commands/codeBlock.js +26 -0
  67. package/dist/operations/commands/element.d.ts +67 -0
  68. package/dist/operations/commands/element.js +269 -0
  69. package/dist/operations/commands/frontMatter.d.ts +35 -0
  70. package/dist/operations/commands/frontMatter.js +120 -0
  71. package/dist/operations/commands/lineBreak.d.ts +9 -0
  72. package/dist/operations/commands/lineBreak.js +16 -0
  73. package/dist/operations/commands/link.d.ts +7 -0
  74. package/dist/operations/commands/link.js +21 -0
  75. package/dist/operations/commands/list.d.ts +126 -0
  76. package/dist/operations/commands/list.js +652 -0
  77. package/dist/operations/commands/mermaidBlock.d.ts +9 -0
  78. package/dist/operations/commands/mermaidBlock.js +28 -0
  79. package/dist/operations/commands/section.d.ts +217 -0
  80. package/dist/operations/commands/section.js +865 -0
  81. package/dist/operations/commands/sectionFold.d.ts +36 -0
  82. package/dist/operations/commands/sectionFold.js +219 -0
  83. package/dist/operations/commands/sectionJump.d.ts +8 -0
  84. package/dist/operations/commands/sectionJump.js +144 -0
  85. package/dist/operations/commands/selectedBlock.d.ts +37 -0
  86. package/dist/operations/commands/selectedBlock.js +170 -0
  87. package/dist/operations/commands/table.d.ts +64 -0
  88. package/dist/operations/commands/table.js +437 -0
  89. package/dist/operations/keymap/assemble.d.ts +22 -0
  90. package/dist/operations/keymap/assemble.js +165 -0
  91. package/dist/operations/keymap/coreActions.d.ts +2 -0
  92. package/dist/operations/keymap/coreActions.js +711 -0
  93. package/dist/operations/keymap/menuItems.d.ts +52 -0
  94. package/dist/operations/keymap/menuItems.js +114 -0
  95. package/dist/operations/keymap/shortcutKeys.d.ts +42 -0
  96. package/dist/operations/keymap/shortcutKeys.js +114 -0
  97. package/dist/operations/keymap/viewActions.d.ts +30 -0
  98. package/dist/operations/keymap/viewActions.js +182 -0
  99. package/dist/operations/operations.types.d.ts +121 -0
  100. package/dist/operations/operations.types.js +1 -0
  101. package/dist/operations/plugins/blockHandle.d.ts +25 -0
  102. package/dist/operations/plugins/blockHandle.js +112 -0
  103. package/dist/operations/plugins/contextMenu.d.ts +33 -0
  104. package/dist/operations/plugins/contextMenu.js +204 -0
  105. package/dist/operations/plugins/focus.d.ts +39 -0
  106. package/dist/operations/plugins/focus.js +350 -0
  107. package/dist/operations/plugins/foldClick.d.ts +11 -0
  108. package/dist/operations/plugins/foldClick.js +117 -0
  109. package/dist/operations/plugins/foldGuard.d.ts +15 -0
  110. package/dist/operations/plugins/foldGuard.js +31 -0
  111. package/dist/operations/plugins/frontMatterGuard.d.ts +21 -0
  112. package/dist/operations/plugins/frontMatterGuard.js +150 -0
  113. package/dist/operations/plugins/frontMatterView.d.ts +34 -0
  114. package/dist/operations/plugins/frontMatterView.js +137 -0
  115. package/dist/operations/plugins/linkPaste.d.ts +3 -0
  116. package/dist/operations/plugins/linkPaste.js +20 -0
  117. package/dist/operations/plugins/listStructure.d.ts +13 -0
  118. package/dist/operations/plugins/listStructure.js +18 -0
  119. package/dist/operations/plugins/markdownClipboard.d.ts +8 -0
  120. package/dist/operations/plugins/markdownClipboard.js +208 -0
  121. package/dist/operations/plugins/mermaidView.d.ts +20 -0
  122. package/dist/operations/plugins/mermaidView.js +206 -0
  123. package/dist/operations/plugins/requiredSelectionEntry.d.ts +10 -0
  124. package/dist/operations/plugins/requiredSelectionEntry.js +124 -0
  125. package/dist/operations/plugins/sectionView.d.ts +12 -0
  126. package/dist/operations/plugins/sectionView.js +44 -0
  127. package/dist/operations/plugins/tabEscape.d.ts +21 -0
  128. package/dist/operations/plugins/tabEscape.js +41 -0
  129. package/dist/operations/plugins/tableHandles.d.ts +24 -0
  130. package/dist/operations/plugins/tableHandles.js +89 -0
  131. package/dist/operations/transaction.d.ts +26 -0
  132. package/dist/operations/transaction.js +51 -0
  133. package/dist/operations/transactionOrigin.d.ts +17 -0
  134. package/dist/operations/transactionOrigin.js +9 -0
  135. package/dist/states/contextMenuController.svelte.d.ts +57 -0
  136. package/dist/states/contextMenuController.svelte.js +206 -0
  137. package/dist/states/editorSession.d.ts +12 -0
  138. package/dist/states/editorSession.js +268 -0
  139. package/dist/states/editorSession.types.d.ts +57 -0
  140. package/dist/states/editorSession.types.js +1 -0
  141. package/dist/states/outlineViewController.svelte.d.ts +52 -0
  142. package/dist/states/outlineViewController.svelte.js +134 -0
  143. package/dist/utils/dateText.d.ts +25 -0
  144. package/dist/utils/dateText.js +71 -0
  145. package/dist/utils/geometry.types.d.ts +13 -0
  146. package/dist/utils/geometry.types.js +1 -0
  147. package/dist/utils/json.types.d.ts +4 -0
  148. package/dist/utils/json.types.js +1 -0
  149. package/dist/utils/platform.d.ts +8 -0
  150. package/dist/utils/platform.js +10 -0
  151. package/dist/utils/result.types.d.ts +7 -0
  152. package/dist/utils/result.types.js +1 -0
  153. package/package.json +109 -0
@@ -0,0 +1,52 @@
1
+ import type { Result } from '../utils/result.types';
2
+ import { type FocusBreadcrumbItem } from '../operations/plugins/focus';
3
+ import type { SectionPath } from '../models/document/document.types';
4
+ import type { ViewState, ViewStateError } from '../models/viewState/viewState.types';
5
+ import type { EditorExtension, EditorSession } from './editorSession.types';
6
+ export interface OutlineViewControllerOptions {
7
+ /**
8
+ * 現在のセッション。**生き死にの管理はコンポーネントが持つ**ため、
9
+ * コントローラは都度たどるだけで、抱え込まない
10
+ */
11
+ readonly getSession: () => EditorSession | null;
12
+ /**
13
+ * 組み込みのショートカット一覧を使うか。使わないなら開閉のキーも受け止めない
14
+ * (受け止めて何も起きないと、キーが効かない理由が分からなくなる)
15
+ */
16
+ readonly isShortcutHelpEnabled?: () => boolean;
17
+ }
18
+ export interface OutlineViewController {
19
+ /** 基盤へ渡す拡張。セッション生成より前に取得する */
20
+ readonly extension: EditorExtension;
21
+ /**
22
+ * 現在のセッションから投影を読み直す。**更新のきっかけは外から与える。**
23
+ * コンポーネントが既に行っている購読の中から呼ぶ
24
+ */
25
+ sync(): void;
26
+ readonly breadcrumb: readonly FocusBreadcrumbItem[];
27
+ readonly isFocused: boolean;
28
+ /** 組み込みのショートカット一覧を開いているか */
29
+ readonly isShortcutHelpOpen: boolean;
30
+ closeShortcutHelp(): void;
31
+ clearFocus(): void;
32
+ /** パン屑から上位の階層を選んだとき、その階層へフォーカスを移す */
33
+ focusPath(path: SectionPath): void;
34
+ getViewState(): ViewState;
35
+ applyViewState(value: unknown): Result<void, ViewStateError>;
36
+ /**
37
+ * 本文の差し替えを挟んで、見出しの折りたたみを引き継ぐ。
38
+ * 差分適用は変更範囲のノードを作り直すため、そのままでは折りたたみが失われる。
39
+ * `resetDocument`(別の文書を開く)には用いない。
40
+ */
41
+ preserveFolds<T>(apply: () => T): T;
42
+ }
43
+ /**
44
+ * 表示状態のまとめ役。
45
+ *
46
+ * **エディタ 1 インスタンスにつき 1 つ生成する。** 状態を持つプラグインをここで作るため、
47
+ * 共有すると同じページの 2 つのエディタが表示状態を分け合ってしまう。
48
+ *
49
+ * **寿命を持たない。** 接続・切り離し・破棄の手続きも購読も持たず、更新のきっかけは
50
+ * 外から受け取る。管理する場所が 2 つになると、片方だけ更新されたときに表示が止まる。
51
+ */
52
+ export declare function createOutlineViewController(options: OutlineViewControllerOptions): OutlineViewController;
@@ -0,0 +1,134 @@
1
+ import { foldCommands } from '../operations/commands/sectionFold';
2
+ import { foldClickPlugin } from '../operations/plugins/foldClick';
3
+ import { foldGuardPlugin } from '../operations/plugins/foldGuard';
4
+ import { createFocusPlugin } from '../operations/plugins/focus';
5
+ import { createViewActions } from '../operations/keymap/viewActions';
6
+ import { EMPTY_VIEW_STATE, viewStateCodec } from '../models/viewState/viewStateCodec';
7
+ /**
8
+ * 表示状態のまとめ役。
9
+ *
10
+ * **エディタ 1 インスタンスにつき 1 つ生成する。** 状態を持つプラグインをここで作るため、
11
+ * 共有すると同じページの 2 つのエディタが表示状態を分け合ってしまう。
12
+ *
13
+ * **寿命を持たない。** 接続・切り離し・破棄の手続きも購読も持たず、更新のきっかけは
14
+ * 外から受け取る。管理する場所が 2 つになると、片方だけ更新されたときに表示が止まる。
15
+ */
16
+ export function createOutlineViewController(options) {
17
+ const focus = createFocusPlugin();
18
+ const extension = {
19
+ plugins: [focus.plugin, foldGuardPlugin(), foldClickPlugin()],
20
+ actions: createViewActions(focus, toggleShortcutHelp)
21
+ };
22
+ // 画面へ渡す投影。真実は文書とプラグインにあり、これはその控えである
23
+ let breadcrumb = $state([]);
24
+ let isFocused = $state(false);
25
+ let shortcutHelpOpen = $state(false);
26
+ /** 直近の取り出しの材料。同じ材料なら走査をやり直さない */
27
+ let encodedFrom = {
28
+ doc: null,
29
+ anchorPos: null,
30
+ viewState: EMPTY_VIEW_STATE
31
+ };
32
+ function viewOf() {
33
+ return options.getSession()?.getView() ?? null;
34
+ }
35
+ function sync() {
36
+ const view = viewOf();
37
+ if (!view) {
38
+ breadcrumb = [];
39
+ isFocused = false;
40
+ return;
41
+ }
42
+ const state = focus.getState(view.state);
43
+ breadcrumb = state.breadcrumb;
44
+ isFocused = state.anchorPos !== null;
45
+ }
46
+ /**
47
+ * 現在の表示状態を取り出す。
48
+ *
49
+ * **文書を変更しない操作では走らせない**。折りたたみは文書の属性、
50
+ * フォーカスは位置 1 つなので、この 2 つが前回と同じなら結果も同じである。
51
+ * 選択が動いただけの Transaction は文書の実体を作り直さないため、ここで打ち切れる。
52
+ */
53
+ function getViewState() {
54
+ const view = viewOf();
55
+ if (!view)
56
+ return EMPTY_VIEW_STATE;
57
+ const anchorPos = focus.getState(view.state).anchorPos;
58
+ if (view.state.doc === encodedFrom.doc && anchorPos === encodedFrom.anchorPos) {
59
+ return encodedFrom.viewState;
60
+ }
61
+ const viewState = viewStateCodec.encode(view.state, focus.getFocusedPath(view.state));
62
+ encodedFrom = { doc: view.state.doc, anchorPos, viewState };
63
+ return viewState;
64
+ }
65
+ function applyViewState(value) {
66
+ const view = viewOf();
67
+ // まだ編集の仕組みができていない。当てる先がないだけで、失敗ではない
68
+ if (!view)
69
+ return { ok: true, value: undefined };
70
+ const decoded = viewStateCodec.decode(value, view.state.doc);
71
+ if (!decoded.ok)
72
+ return decoded;
73
+ const dispatch = view.dispatch.bind(view);
74
+ foldCommands.applyFoldedPaths(decoded.value.foldedPaths)(view.state, dispatch, view);
75
+ focus.applyFocus(decoded.value.focusedPath)(view.state, dispatch, view);
76
+ sync();
77
+ return { ok: true, value: undefined };
78
+ }
79
+ function toggleShortcutHelp() {
80
+ if (options.isShortcutHelpEnabled?.() === false)
81
+ return false;
82
+ shortcutHelpOpen = !shortcutHelpOpen;
83
+ return true;
84
+ }
85
+ function clearFocus() {
86
+ const view = viewOf();
87
+ if (!view)
88
+ return;
89
+ focus.clearFocus(view.state, view.dispatch.bind(view), view);
90
+ sync();
91
+ }
92
+ function focusPath(path) {
93
+ const view = viewOf();
94
+ if (!view)
95
+ return;
96
+ focus.applyFocus(path)(view.state, view.dispatch.bind(view), view);
97
+ sync();
98
+ }
99
+ function preserveFolds(apply) {
100
+ const before = getViewState();
101
+ const result = apply();
102
+ const view = viewOf();
103
+ if (!view)
104
+ return result;
105
+ // 突合キーによる照合をそのまま使うため、本当に変わったセクションには当たらない
106
+ const decoded = viewStateCodec.decode(before, view.state.doc);
107
+ if (decoded.ok && decoded.value.foldedPaths.length > 0) {
108
+ foldCommands.applyFoldedPaths(decoded.value.foldedPaths)(view.state, view.dispatch.bind(view), view);
109
+ }
110
+ sync();
111
+ return result;
112
+ }
113
+ return {
114
+ extension,
115
+ sync,
116
+ get breadcrumb() {
117
+ return breadcrumb;
118
+ },
119
+ get isFocused() {
120
+ return isFocused;
121
+ },
122
+ get isShortcutHelpOpen() {
123
+ return shortcutHelpOpen;
124
+ },
125
+ closeShortcutHelp: () => {
126
+ shortcutHelpOpen = false;
127
+ },
128
+ clearFocus,
129
+ focusPath,
130
+ getViewState,
131
+ applyViewState,
132
+ preserveFolds
133
+ };
134
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * 文字列の中の**機械向けの日時表記**を、人が読む形へ書き換える道具。
3
+ * ドメインを知らない純粋関数として置く。
4
+ *
5
+ * 扱うのは ISO 8601 だけである。手で書かれた `2026/08/22 15:06` のような形まで拾うと、
6
+ * 日時でない値(版番号・識別子)を書き換える危険が出る。**迷ったら触らない**——
7
+ * 書いた文字がそのまま出ることのほうが、読みやすさより優先される。
8
+ */
9
+ /**
10
+ * 書き換える範囲と、書き換えた後の文字。
11
+ * 位置は渡した文字列の中の添字(`start` は含み、`end` は含まない)。
12
+ */
13
+ export interface DateTextMatch {
14
+ readonly start: number;
15
+ readonly end: number;
16
+ readonly text: string;
17
+ }
18
+ /**
19
+ * 文字列の中の日時・日付を探し、読みやすい形へ書き換える指示を返す。
20
+ *
21
+ * 探すのは**値の形**だけで、その左に何というキーが書かれているかは見ない。
22
+ * 特定の項目名を知らずに済ませるためであり、`timestamp` でも `updated` でも
23
+ * 書き手が付けた名前でも、同じ規則で扱われる。
24
+ */
25
+ export declare function findDateText(text: string, lang: string): readonly DateTextMatch[];
@@ -0,0 +1,71 @@
1
+ /**
2
+ * 文字列の中の**機械向けの日時表記**を、人が読む形へ書き換える道具。
3
+ * ドメインを知らない純粋関数として置く。
4
+ *
5
+ * 扱うのは ISO 8601 だけである。手で書かれた `2026/08/22 15:06` のような形まで拾うと、
6
+ * 日時でない値(版番号・識別子)を書き換える危険が出る。**迷ったら触らない**——
7
+ * 書いた文字がそのまま出ることのほうが、読みやすさより優先される。
8
+ */
9
+ /**
10
+ * ISO 8601 の日時と日付。
11
+ *
12
+ * **時刻帯(`Z` または `±hh:mm`)を持つ日時**と、**日付だけ**の 2 通りを拾う。
13
+ * 時刻帯を持たない日時(`2026-08-22T15:06:11`)は、どの瞬間を指すのか決められないので
14
+ * 拾わない——こちらの都合で時刻帯を補うと、書き手が書いていない情報を足すことになる。
15
+ *
16
+ * 前後は、語を作る文字と `-` `:` `.` で区切られていないことを条件にする。
17
+ * `abc-2026-08-22-x` のような識別子の一部を日付として拾わないため。
18
+ */
19
+ const ISO_8601 = /(?<![\w\-:.])(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?(Z|[+-]\d{2}:?\d{2}))?(?![\w\-:.])/g;
20
+ /**
21
+ * 文字列の中の日時・日付を探し、読みやすい形へ書き換える指示を返す。
22
+ *
23
+ * 探すのは**値の形**だけで、その左に何というキーが書かれているかは見ない。
24
+ * 特定の項目名を知らずに済ませるためであり、`timestamp` でも `updated` でも
25
+ * 書き手が付けた名前でも、同じ規則で扱われる。
26
+ */
27
+ export function findDateText(text, lang) {
28
+ const matches = [];
29
+ for (const found of text.matchAll(ISO_8601)) {
30
+ const readable = readableOf(found, lang);
31
+ if (readable === null)
32
+ continue;
33
+ matches.push({ start: found.index, end: found.index + found[0].length, text: readable });
34
+ }
35
+ return matches;
36
+ }
37
+ /**
38
+ * 1 つの一致を読みやすい形にする。読めない値(存在しない日付など)は `null`。
39
+ *
40
+ * **日付だけの値は、時刻帯を跨がせない。** その日の始まりとして解いて書き換えると、
41
+ * 西回りの地域では前日になる。日付は暦の上の 1 日を指しているのであって、
42
+ * ある瞬間を指してはいない。
43
+ */
44
+ function readableOf(found, lang) {
45
+ const [, year, month, day, hour, minute, second, zone] = found;
46
+ if (zone === undefined) {
47
+ const date = new Date(Number(year), Number(month) - 1, Number(day));
48
+ if (!isSameDate(date, year, month, day))
49
+ return null;
50
+ return format(date, lang, { dateStyle: 'medium' });
51
+ }
52
+ const at = new Date(`${year}-${month}-${day}T${hour}:${minute}:${second ?? '00'}${normalizeZone(zone)}`);
53
+ if (Number.isNaN(at.getTime()))
54
+ return null;
55
+ return format(at, lang, { dateStyle: 'medium', timeStyle: 'short' });
56
+ }
57
+ /** `Date` は範囲外の値を繰り上げる(`2026-02-30` が 3 月になる)ので、戻して確かめる */
58
+ function isSameDate(date, year, month, day) {
59
+ return (date.getFullYear() === Number(year) &&
60
+ date.getMonth() === Number(month) - 1 &&
61
+ date.getDate() === Number(day));
62
+ }
63
+ /** `+0900` の形も受け取れるよう、コロンを補う */
64
+ function normalizeZone(zone) {
65
+ if (zone === 'Z')
66
+ return 'Z';
67
+ return zone.includes(':') ? zone : `${zone.slice(0, 3)}:${zone.slice(3)}`;
68
+ }
69
+ function format(date, lang, options) {
70
+ return new Intl.DateTimeFormat(lang, options).format(date);
71
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * 画面上の矩形。**ドメインを知らない道具型。**
3
+ *
4
+ * `view.coordsAtPos()` の戻り値と `getBoundingClientRect()` の双方が構造的に適合する。
5
+ * ポインタの座標(幅も高さもない矩形)と要素の箱を同じ型で扱えるようにするための形であり、
6
+ * 「錨は要素である」という前提を持ち込まない。
7
+ */
8
+ export interface AnchorRect {
9
+ readonly top: number;
10
+ readonly bottom: number;
11
+ readonly left: number;
12
+ readonly right: number;
13
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ /** JSON で表せる値。ドメインを知らない道具型 */
2
+ export type JsonValue = string | number | boolean | null | readonly JsonValue[] | {
3
+ readonly [key: string]: JsonValue;
4
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 実行環境の名乗りが Apple 系かどうかを判定する。
3
+ *
4
+ * 表記は出どころによって揺れる。`navigator.platform` は `MacIntel`、
5
+ * 新しい `userAgentData.platform` は `macOS` と、頭文字の大小が違う。
6
+ * 大文字小文字を区別すると、新しい方を見ている環境で取りこぼす。
7
+ */
8
+ export declare function looksLikeMac(platform: string): boolean;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 実行環境の名乗りが Apple 系かどうかを判定する。
3
+ *
4
+ * 表記は出どころによって揺れる。`navigator.platform` は `MacIntel`、
5
+ * 新しい `userAgentData.platform` は `macOS` と、頭文字の大小が違う。
6
+ * 大文字小文字を区別すると、新しい方を見ている環境で取りこぼす。
7
+ */
8
+ export function looksLikeMac(platform) {
9
+ return /mac|iphone|ipad|ipod/i.test(platform);
10
+ }
@@ -0,0 +1,7 @@
1
+ export type Result<T, E> = {
2
+ readonly ok: true;
3
+ readonly value: T;
4
+ } | {
5
+ readonly ok: false;
6
+ readonly error: E;
7
+ };
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,109 @@
1
+ {
2
+ "name": "@14ch/svelte-md-outliner",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "license": "MIT",
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.",
7
+ "keywords": [
8
+ "svelte",
9
+ "svelte5",
10
+ "markdown",
11
+ "markdown-editor",
12
+ "editor",
13
+ "wysiwyg",
14
+ "outliner",
15
+ "outline",
16
+ "prosemirror",
17
+ "mermaid",
18
+ "front-matter"
19
+ ],
20
+ "author": "iyodatakashi",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/iyodatakashi/svelte-md-outliner.git"
24
+ },
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "files": [
29
+ "dist",
30
+ "README.ja.md",
31
+ "!dist/**/*.test.*",
32
+ "!dist/**/*.spec.*"
33
+ ],
34
+ "sideEffects": [
35
+ "**/*.css"
36
+ ],
37
+ "svelte": "./dist/index.js",
38
+ "types": "./dist/index.d.ts",
39
+ "exports": {
40
+ ".": {
41
+ "types": "./dist/index.d.ts",
42
+ "svelte": "./dist/index.js",
43
+ "default": "./dist/index.js"
44
+ },
45
+ "./markdown": {
46
+ "types": "./dist/markdown.d.ts",
47
+ "default": "./dist/markdown.js"
48
+ },
49
+ "./styles/editor.css": "./dist/assets/styles/editor.css",
50
+ "./styles/theme.css": "./dist/assets/styles/theme.css"
51
+ },
52
+ "scripts": {
53
+ "dev": "vite dev",
54
+ "build": "vite build",
55
+ "preview": "vite preview",
56
+ "prepare": "svelte-kit sync || echo ''",
57
+ "prepack": "svelte-kit sync && svelte-package --input src/lib --output dist",
58
+ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
59
+ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
60
+ "lint": "prettier --check . && eslint .",
61
+ "format": "prettier --write .",
62
+ "test:unit": "vitest",
63
+ "test": "npm run test:unit -- --run && npm run test:e2e",
64
+ "test:e2e": "playwright install && playwright test"
65
+ },
66
+ "peerDependencies": {
67
+ "svelte": "^5.0.0"
68
+ },
69
+ "dependencies": {
70
+ "markdown-it": "^15.0.0",
71
+ "mermaid": "^11.10.0",
72
+ "prosemirror-commands": "^1.7.1",
73
+ "prosemirror-flat-list": "0.7.1",
74
+ "prosemirror-gapcursor": "^1.4.0",
75
+ "prosemirror-history": "^1.5.0",
76
+ "prosemirror-inputrules": "^1.5.0",
77
+ "prosemirror-keymap": "^1.2.3",
78
+ "prosemirror-markdown": "^1.13.5",
79
+ "prosemirror-model": "^1.25.3",
80
+ "prosemirror-state": "^1.4.4",
81
+ "prosemirror-tables": "^1.8.5",
82
+ "prosemirror-transform": "^1.12.0",
83
+ "prosemirror-view": "^1.42.0"
84
+ },
85
+ "devDependencies": {
86
+ "@eslint/js": "^10.0.1",
87
+ "@playwright/test": "^1.60.0",
88
+ "@sveltejs/adapter-static": "^3.0.10",
89
+ "@sveltejs/kit": "^2.63.0",
90
+ "@sveltejs/package": "^2.5.8",
91
+ "@sveltejs/vite-plugin-svelte": "^7.1.2",
92
+ "@types/node": "^24",
93
+ "@vitest/browser-playwright": "^4.1.8",
94
+ "eslint": "^10.4.1",
95
+ "eslint-config-prettier": "^10.1.8",
96
+ "eslint-plugin-svelte": "^3.19.0",
97
+ "globals": "^17.6.0",
98
+ "playwright": "^1.60.0",
99
+ "prettier": "^3.8.3",
100
+ "prettier-plugin-svelte": "^4.1.0",
101
+ "svelte": "^5.56.1",
102
+ "svelte-check": "^4.6.0",
103
+ "typescript": "^6.0.3",
104
+ "typescript-eslint": "^8.60.1",
105
+ "vite": "^8.0.16",
106
+ "vitest": "^4.1.8",
107
+ "vitest-browser-svelte": "^2.1.1"
108
+ }
109
+ }