@14ch/svelte-md-outliner 0.0.24 → 0.0.25
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 +13 -0
- package/README.ja.md +33 -17
- package/README.md +33 -17
- package/dist/assets/styles/editor.css +7 -0
- package/dist/components/MarkdownEditor.svelte +12 -1
- package/dist/components/MarkdownEditor.svelte.d.ts +9 -0
- package/dist/index.d.ts +5 -0
- package/dist/operations/plugins/linkClick.d.ts +24 -0
- package/dist/operations/plugins/linkClick.js +77 -0
- package/dist/states/editorSession.js +2 -0
- package/dist/states/editorSession.types.d.ts +3 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,19 @@ 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.25] - 2026-10-29
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Links open in a new tab: ⌘-click (Ctrl-click outside macOS) while editing,
|
|
13
|
+
a plain click while `readonly`. A plain click while editing still places the
|
|
14
|
+
cursor. The pointer turns into a hand over a link only when a click would
|
|
15
|
+
open it.
|
|
16
|
+
- `onLinkClick` prop: called with the `href` as written (relative links are not
|
|
17
|
+
resolved) before the link opens. Call `event.preventDefault()` to handle the
|
|
18
|
+
link yourself instead of opening a new tab — for example, links between
|
|
19
|
+
Markdown files. The `LinkClick` type is exported.
|
|
20
|
+
|
|
8
21
|
## [0.0.24] - 2026-10-28
|
|
9
22
|
|
|
10
23
|
### Changed
|
package/README.ja.md
CHANGED
|
@@ -51,23 +51,24 @@ import '@14ch/svelte-md-outliner/styles/editor.css';
|
|
|
51
51
|
<MarkdownEditor bind:value bind:viewState label="議事録" maxWidth="42rem" />
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
| | 型
|
|
55
|
-
| ------------------- |
|
|
56
|
-
| `value` | `string`
|
|
57
|
-
| `onChange` | `(markdown: string) => void`
|
|
58
|
-
| `viewState` | `ViewState`
|
|
59
|
-
| `onViewStateChange` | `(viewState: ViewState) => void`
|
|
60
|
-
| `label` | `string`
|
|
61
|
-
| `readonly` | `boolean`
|
|
62
|
-
| `autofocus` | `boolean`
|
|
63
|
-
| `class` | `string`
|
|
64
|
-
| `padding` | `string`
|
|
65
|
-
| `maxWidth` | `string`
|
|
66
|
-
| `lang` | `'en' \| 'ja'`
|
|
67
|
-
| `messages` | `EditorMessagesOverride`
|
|
68
|
-
| `shortcutHelp` | `boolean`
|
|
69
|
-
| `contextMenu` | `boolean`
|
|
70
|
-
| `uploadImage` | `(file: File) => Promise<string \| null>`
|
|
54
|
+
| | 型 | 既定 | |
|
|
55
|
+
| ------------------- | ------------------------------------------- | ---------- | ---------------------------------------------------------------- |
|
|
56
|
+
| `value` | `string` | `''` | 本文のマークダウン(`bind:` 可)。取り消せる置き換えとして当たる |
|
|
57
|
+
| `onChange` | `(markdown: string) => void` | — | `bind:value` を使うなら不要 |
|
|
58
|
+
| `viewState` | `ViewState` | — | どの見出しを畳んでいるか、どこをフォーカスしているか |
|
|
59
|
+
| `onViewStateChange` | `(viewState: ViewState) => void` | — | `bind:viewState` を使うなら不要 |
|
|
60
|
+
| `label` | `string` | 内蔵の文言 | 編集エリアのアクセシブルネーム |
|
|
61
|
+
| `readonly` | `boolean` | `false` | 入力・編集コマンド・貼り付けを受け付けない |
|
|
62
|
+
| `autofocus` | `boolean` | `false` | マウント時にフォーカスする |
|
|
63
|
+
| `class` | `string` | `''` | 追加のクラス名 |
|
|
64
|
+
| `padding` | `string` | トークン | CSS の `padding` と同じ書き方 |
|
|
65
|
+
| `maxWidth` | `string` | トークン | 行の長さ。**クリックできる範囲は元の幅のまま** |
|
|
66
|
+
| `lang` | `'en' \| 'ja'` | `'en'` | 同梱の言語 |
|
|
67
|
+
| `messages` | `EditorMessagesOverride` | — | 文字列の差し替え。同梱しない言語は一式を渡す |
|
|
68
|
+
| `shortcutHelp` | `boolean` | `true` | 組み込みのショートカット一覧(`Mod-Alt-/`) |
|
|
69
|
+
| `contextMenu` | `boolean` | `true` | 組み込みのコンテキストメニュー(右クリック / `Mod-/`) |
|
|
70
|
+
| `uploadImage` | `(file: File) => Promise<string \| null>` | — | 貼り付けられた画像を引き受け、表示に使う URL を返す |
|
|
71
|
+
| `onLinkClick` | `(href: string, event: MouseEvent) => void` | — | リンクが押されたときの通知。止めなければ新しいタブで開く |
|
|
71
72
|
|
|
72
73
|
`viewState` は**今どう見ているか**であって、文書の内容ではない。このモジュールは何も保存しないので、保存先は利用側が決める(保存しなくてもよい)。
|
|
73
74
|
|
|
@@ -88,6 +89,21 @@ const uploadImage = async (file: File) => {
|
|
|
88
89
|
|
|
89
90
|
**画像を描くと、その先へ取りに行く。** 外部の URL が書かれた文書は、表示のたびにその先へ取得が飛ぶ(記法を描く以上避けられない)。
|
|
90
91
|
|
|
92
|
+
### リンク
|
|
93
|
+
|
|
94
|
+
リンクを押すと、リンク先が新しいタブで開く。編集中は ⌘+クリック(Mac 以外は Ctrl+クリック)、読み取り専用では素のクリックで開く。編集中の素のクリックはカーソルを置く操作のままである。
|
|
95
|
+
|
|
96
|
+
開く前に `onLinkClick` が書かれたとおりの `href` を受け取る(相対のままでも解決しない)。`event.preventDefault()` を呼べば、新しいタブでは開かない。`./other.md` のように、ブラウザで開いても意味を持たない行き先を利用側で扱うときに使う。
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
const onLinkClick = (href: string, event: MouseEvent) => {
|
|
100
|
+
if (href.endsWith('.md')) {
|
|
101
|
+
event.preventDefault();
|
|
102
|
+
openDocument(href);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
```
|
|
106
|
+
|
|
91
107
|
同梱していない言語は、同梱の一式を土台にする。
|
|
92
108
|
|
|
93
109
|
```ts
|
package/README.md
CHANGED
|
@@ -51,23 +51,24 @@ import '@14ch/svelte-md-outliner/styles/editor.css';
|
|
|
51
51
|
<MarkdownEditor bind:value bind:viewState label="Meeting notes" maxWidth="42rem" />
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
| | Type
|
|
55
|
-
| ------------------- |
|
|
56
|
-
| `value` | `string`
|
|
57
|
-
| `onChange` | `(markdown: string) => void`
|
|
58
|
-
| `viewState` | `ViewState`
|
|
59
|
-
| `onViewStateChange` | `(viewState: ViewState) => void`
|
|
60
|
-
| `label` | `string`
|
|
61
|
-
| `readonly` | `boolean`
|
|
62
|
-
| `autofocus` | `boolean`
|
|
63
|
-
| `class` | `string`
|
|
64
|
-
| `padding` | `string`
|
|
65
|
-
| `maxWidth` | `string`
|
|
66
|
-
| `lang` | `'en' \| 'ja'`
|
|
67
|
-
| `messages` | `EditorMessagesOverride`
|
|
68
|
-
| `shortcutHelp` | `boolean`
|
|
69
|
-
| `contextMenu` | `boolean`
|
|
70
|
-
| `uploadImage` | `(file: File) => Promise<string \| null>`
|
|
54
|
+
| | Type | Default | |
|
|
55
|
+
| ------------------- | ------------------------------------------- | -------- | ------------------------------------------------------------------ |
|
|
56
|
+
| `value` | `string` | `''` | Markdown source (bindable). Applied as an undoable replacement |
|
|
57
|
+
| `onChange` | `(markdown: string) => void` | — | Not needed when you use `bind:value` |
|
|
58
|
+
| `viewState` | `ViewState` | — | Which headings are folded, which section is zoomed |
|
|
59
|
+
| `onViewStateChange` | `(viewState: ViewState) => void` | — | Not needed when you use `bind:viewState` |
|
|
60
|
+
| `label` | `string` | built-in | Accessible name for the editing surface |
|
|
61
|
+
| `readonly` | `boolean` | `false` | Rejects typing, commands and pastes |
|
|
62
|
+
| `autofocus` | `boolean` | `false` | Focus on mount |
|
|
63
|
+
| `class` | `string` | `''` | Extra class names |
|
|
64
|
+
| `padding` | `string` | token | Written exactly like CSS `padding` |
|
|
65
|
+
| `maxWidth` | `string` | token | Line length. **The clickable surface keeps the full width** |
|
|
66
|
+
| `lang` | `'en' \| 'ja'` | `'en'` | Bundled UI language |
|
|
67
|
+
| `messages` | `EditorMessagesOverride` | — | Replace individual strings, or supply a whole language |
|
|
68
|
+
| `shortcutHelp` | `boolean` | `true` | Built-in shortcut sheet (`Mod-Alt-/`) |
|
|
69
|
+
| `contextMenu` | `boolean` | `true` | Built-in context menu (right click / `Mod-/`) |
|
|
70
|
+
| `uploadImage` | `(file: File) => Promise<string \| null>` | — | Takes a pasted image, returns the URL to display |
|
|
71
|
+
| `onLinkClick` | `(href: string, event: MouseEvent) => void` | — | Called when a link is clicked; opens in a new tab unless prevented |
|
|
71
72
|
|
|
72
73
|
`viewState` is **how you are looking at the document**, not its content. This module stores nothing, so persist it wherever you like — or not at all.
|
|
73
74
|
|
|
@@ -88,6 +89,21 @@ While it waits, a marker is shown at the paste position and **the document is no
|
|
|
88
89
|
|
|
89
90
|
**Rendering an image fetches it.** A document that names an external URL will request it from that host every time it is shown — that is what drawing image notation means.
|
|
90
91
|
|
|
92
|
+
### Links
|
|
93
|
+
|
|
94
|
+
Clicking a link opens its target in a new tab: ⌘-click (Ctrl-click outside macOS) while editing, a plain click while `readonly`. A plain click while editing still just places the cursor.
|
|
95
|
+
|
|
96
|
+
Before opening, `onLinkClick` receives the `href` exactly as written (relative links are not resolved). Call `event.preventDefault()` to stop the new tab — useful for targets such as `./other.md` that mean nothing to the browser but something to your app.
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
const onLinkClick = (href: string, event: MouseEvent) => {
|
|
100
|
+
if (href.endsWith('.md')) {
|
|
101
|
+
event.preventDefault();
|
|
102
|
+
openDocument(href);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
```
|
|
106
|
+
|
|
91
107
|
For a language that is not bundled, start from a bundled set:
|
|
92
108
|
|
|
93
109
|
```ts
|
|
@@ -1242,6 +1242,13 @@
|
|
|
1242
1242
|
color: var(--markdown-editor-link);
|
|
1243
1243
|
}
|
|
1244
1244
|
|
|
1245
|
+
/* 押せば開くときだけ指の形にする。編集中の素のクリックはカーソルを置く操作である
|
|
1246
|
+
(修飾キーの状態は `linkClick` プラグインが `data-link-open` へ写す) */
|
|
1247
|
+
.markdown-editor__surface[aria-readonly] .markdown-editor__link,
|
|
1248
|
+
.markdown-editor__surface[data-link-open] .markdown-editor__link {
|
|
1249
|
+
cursor: pointer;
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1245
1252
|
/* --- 箇条書き ---
|
|
1246
1253
|
項目は 1 ノードで 1 項目にあたり、入れ子は項目の中に項目を置く形で表す。
|
|
1247
1254
|
クラス名と data 属性は編集基盤(prosemirror-flat-list)が付けるものに合わせる。
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import type { EditorLang, EditorMessagesOverride } from '../messages/messages.types';
|
|
3
3
|
import type { ImageUpload } from '../operations/plugins/imagePaste';
|
|
4
|
+
import type { LinkClick } from '../operations/plugins/linkClick';
|
|
4
5
|
import type {
|
|
5
6
|
FrontMatterFields,
|
|
6
7
|
FrontMatterWriteError,
|
|
@@ -89,6 +90,14 @@
|
|
|
89
90
|
* 読み取り専用のあいだは呼ばれない。
|
|
90
91
|
*/
|
|
91
92
|
uploadImage?: ImageUpload;
|
|
93
|
+
/**
|
|
94
|
+
* リンクが押されたときの通知。`href` は書かれたとおりの値で、相対のままでも解決しない。
|
|
95
|
+
*
|
|
96
|
+
* 編集中は ⌘+クリック(Mac 以外は Ctrl+クリック)、読み取り専用では素のクリックで呼ばれる。
|
|
97
|
+
* `event.preventDefault()` を呼べば、新しいタブで開く既定の動きを止められる。
|
|
98
|
+
* 呼ばなければ(または渡さなければ)新しいタブで開く。
|
|
99
|
+
*/
|
|
100
|
+
onLinkClick?: LinkClick;
|
|
92
101
|
}
|
|
93
102
|
|
|
94
103
|
/** `padding` を四辺へ展開したもの。CSS 側へは辺ごとに渡す(→ `expandPadding`) */
|
|
@@ -206,7 +215,8 @@
|
|
|
206
215
|
onViewStateChange,
|
|
207
216
|
shortcutHelp = true,
|
|
208
217
|
contextMenu = true,
|
|
209
|
-
uploadImage
|
|
218
|
+
uploadImage,
|
|
219
|
+
onLinkClick
|
|
210
220
|
}: MarkdownEditorProps = $props();
|
|
211
221
|
|
|
212
222
|
// --- 状態 ---
|
|
@@ -284,6 +294,7 @@
|
|
|
284
294
|
* 呼ぶ時点の値が使われ、表示の組み直し(`view.setProps`)も起きない。
|
|
285
295
|
*/
|
|
286
296
|
imageUpload: () => uploadImage,
|
|
297
|
+
linkClick: () => onLinkClick,
|
|
287
298
|
extensions: [controller.extension, menuController.extension]
|
|
288
299
|
};
|
|
289
300
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { EditorLang, EditorMessagesOverride } from '../messages/messages.types';
|
|
2
2
|
import type { ImageUpload } from '../operations/plugins/imagePaste';
|
|
3
|
+
import type { LinkClick } from '../operations/plugins/linkClick';
|
|
3
4
|
import type { FrontMatterFields, FrontMatterWriteError, FrontMatterWriteOutcome } from '../models/markdown/markdown.types';
|
|
4
5
|
import type { Result } from '../utils/result.types';
|
|
5
6
|
import type { ViewState } from '../models/viewState/viewState.types';
|
|
@@ -83,6 +84,14 @@ export interface MarkdownEditorProps {
|
|
|
83
84
|
* 読み取り専用のあいだは呼ばれない。
|
|
84
85
|
*/
|
|
85
86
|
uploadImage?: ImageUpload;
|
|
87
|
+
/**
|
|
88
|
+
* リンクが押されたときの通知。`href` は書かれたとおりの値で、相対のままでも解決しない。
|
|
89
|
+
*
|
|
90
|
+
* 編集中は ⌘+クリック(Mac 以外は Ctrl+クリック)、読み取り専用では素のクリックで呼ばれる。
|
|
91
|
+
* `event.preventDefault()` を呼べば、新しいタブで開く既定の動きを止められる。
|
|
92
|
+
* 呼ばなければ(または渡さなければ)新しいタブで開く。
|
|
93
|
+
*/
|
|
94
|
+
onLinkClick?: LinkClick;
|
|
86
95
|
}
|
|
87
96
|
/** `padding` を四辺へ展開したもの。CSS 側へは辺ごとに渡す(→ `expandPadding`) */
|
|
88
97
|
export interface EditorPadding {
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,11 @@ export type { EditorMessages, EditorMessagesOverride, EditorLang, EditorShortcut
|
|
|
13
13
|
* `File` を受け取り、表示に使う URL を返す。失敗は reject か `null` で表す。
|
|
14
14
|
*/
|
|
15
15
|
export type { ImageUpload } from './operations/plugins/imagePaste';
|
|
16
|
+
/**
|
|
17
|
+
* リンクが押されたときの通知の型(`MarkdownEditor` の `onLinkClick` に渡す)。
|
|
18
|
+
* `event.preventDefault()` を呼ぶと、新しいタブで開く既定の動きを止める。
|
|
19
|
+
*/
|
|
20
|
+
export type { LinkClick } from './operations/plugins/linkClick';
|
|
16
21
|
export type { ViewState, ViewSectionRef } from './models/viewState/viewState.types';
|
|
17
22
|
/**
|
|
18
23
|
* 外から本文を当てる命令(`replaceMarkdown` / `applyRemoteChange`)の戻り値に現れる型。
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Plugin } from 'prosemirror-state';
|
|
2
|
+
/**
|
|
3
|
+
* リンクが押されたことの通知。`href` は書かれたとおりの値(相対のままでも解決しない)。
|
|
4
|
+
* `event.preventDefault()` を呼ぶと、新しいタブで開く既定の動きを止める。
|
|
5
|
+
*/
|
|
6
|
+
export type LinkClick = (href: string, event: MouseEvent) => void;
|
|
7
|
+
/** 呼ぶ時点の受け手を返す。渡されていなければ `undefined` */
|
|
8
|
+
export type LinkClickSource = () => LinkClick | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* リンクを押して、リンク先を新しいタブで開く。
|
|
11
|
+
*
|
|
12
|
+
* 編集中は**修飾キー(Mac は ⌘、それ以外は Ctrl)を添えたときだけ**開く。
|
|
13
|
+
* 素のクリックはカーソルを置く操作であり、奪うとリンクの文字を直せなくなる。
|
|
14
|
+
* 読み取り専用では素のクリックで開く。
|
|
15
|
+
*
|
|
16
|
+
* 開く前に利用側へ知らせる。相対のリンク(`./other.md`)のように、ブラウザで開いても
|
|
17
|
+
* 意味を持たない行き先は、利用側が引き取って扱う。
|
|
18
|
+
*
|
|
19
|
+
* `handleDOMEvents` で受けるため、読み取り専用でも届く。
|
|
20
|
+
*
|
|
21
|
+
* 修飾キーを押しているあいだは、編集エリアに `data-link-open` を立てる。押せば開くことを
|
|
22
|
+
* ポインタの形で見せるためで、CSS からはキーの状態が読めない。
|
|
23
|
+
*/
|
|
24
|
+
export declare function linkClickPlugin(getLinkClick: LinkClickSource): Plugin;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Plugin } from 'prosemirror-state';
|
|
2
|
+
import { isMacPlatform } from '../keymap/shortcutKeys.js';
|
|
3
|
+
/**
|
|
4
|
+
* リンクを押して、リンク先を新しいタブで開く。
|
|
5
|
+
*
|
|
6
|
+
* 編集中は**修飾キー(Mac は ⌘、それ以外は Ctrl)を添えたときだけ**開く。
|
|
7
|
+
* 素のクリックはカーソルを置く操作であり、奪うとリンクの文字を直せなくなる。
|
|
8
|
+
* 読み取り専用では素のクリックで開く。
|
|
9
|
+
*
|
|
10
|
+
* 開く前に利用側へ知らせる。相対のリンク(`./other.md`)のように、ブラウザで開いても
|
|
11
|
+
* 意味を持たない行き先は、利用側が引き取って扱う。
|
|
12
|
+
*
|
|
13
|
+
* `handleDOMEvents` で受けるため、読み取り専用でも届く。
|
|
14
|
+
*
|
|
15
|
+
* 修飾キーを押しているあいだは、編集エリアに `data-link-open` を立てる。押せば開くことを
|
|
16
|
+
* ポインタの形で見せるためで、CSS からはキーの状態が読めない。
|
|
17
|
+
*/
|
|
18
|
+
export function linkClickPlugin(getLinkClick) {
|
|
19
|
+
return new Plugin({
|
|
20
|
+
view: (view) => trackModifier(view),
|
|
21
|
+
props: {
|
|
22
|
+
handleDOMEvents: {
|
|
23
|
+
click: (view, event) => handleClick(view, event, getLinkClick)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function handleClick(view, event, getLinkClick) {
|
|
29
|
+
if (event.button !== 0)
|
|
30
|
+
return false;
|
|
31
|
+
if (view.editable && !isModifierHeld(event))
|
|
32
|
+
return false;
|
|
33
|
+
const target = event.target;
|
|
34
|
+
if (!(target instanceof Element))
|
|
35
|
+
return false;
|
|
36
|
+
const link = target.closest('a.markdown-editor__link');
|
|
37
|
+
if (!(link instanceof HTMLAnchorElement) || !view.dom.contains(link))
|
|
38
|
+
return false;
|
|
39
|
+
const href = link.getAttribute('href');
|
|
40
|
+
if (!href)
|
|
41
|
+
return false;
|
|
42
|
+
getLinkClick()?.(href, event);
|
|
43
|
+
if (event.defaultPrevented)
|
|
44
|
+
return true;
|
|
45
|
+
event.preventDefault();
|
|
46
|
+
window.open(href, '_blank', 'noopener,noreferrer');
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
function isModifierHeld(event) {
|
|
50
|
+
return isMacPlatform() ? event.metaKey : event.ctrlKey;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* 修飾キーの状態を編集エリアの属性へ写す。
|
|
54
|
+
*
|
|
55
|
+
* キーは焦点がどこにあっても押されうるため、文書全体で見る。ポインタを動かしたときにも
|
|
56
|
+
* 写し直す(ページの外でキーを押したまま戻ってきた場合に、キーの出来事は届かない)。
|
|
57
|
+
*/
|
|
58
|
+
function trackModifier(view) {
|
|
59
|
+
const element = view.dom;
|
|
60
|
+
const ownerDocument = element.ownerDocument;
|
|
61
|
+
const ownerWindow = ownerDocument.defaultView;
|
|
62
|
+
const sync = (event) => element.toggleAttribute('data-link-open', isModifierHeld(event));
|
|
63
|
+
const release = () => element.removeAttribute('data-link-open');
|
|
64
|
+
ownerDocument.addEventListener('keydown', sync);
|
|
65
|
+
ownerDocument.addEventListener('keyup', sync);
|
|
66
|
+
element.addEventListener('mousemove', sync);
|
|
67
|
+
ownerWindow?.addEventListener('blur', release);
|
|
68
|
+
return {
|
|
69
|
+
destroy: () => {
|
|
70
|
+
ownerDocument.removeEventListener('keydown', sync);
|
|
71
|
+
ownerDocument.removeEventListener('keyup', sync);
|
|
72
|
+
element.removeEventListener('mousemove', sync);
|
|
73
|
+
ownerWindow?.removeEventListener('blur', release);
|
|
74
|
+
release();
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
@@ -12,6 +12,7 @@ import { sectionViewPlugin } from '../operations/plugins/sectionView.js';
|
|
|
12
12
|
import { mermaidViewPlugin } from '../operations/plugins/mermaidView.js';
|
|
13
13
|
import { imagePastePlugin } from '../operations/plugins/imagePaste.js';
|
|
14
14
|
import { imageViewPlugin } from '../operations/plugins/imageView.js';
|
|
15
|
+
import { linkClickPlugin } from '../operations/plugins/linkClick.js';
|
|
15
16
|
import { blockHandlePlugin } from '../operations/plugins/blockHandle.js';
|
|
16
17
|
import { frontMatterGuardPlugin } from '../operations/plugins/frontMatterGuard.js';
|
|
17
18
|
import { editorFocusPlugin } from '../operations/plugins/editorFocus.js';
|
|
@@ -107,6 +108,7 @@ export function createEditorSession(element, options) {
|
|
|
107
108
|
})),
|
|
108
109
|
mermaidViewPlugin(() => presentation.mermaidText ?? defaultMermaidText()),
|
|
109
110
|
imageViewPlugin(() => imageText()),
|
|
111
|
+
linkClickPlugin(options.linkClick ?? (() => undefined)),
|
|
110
112
|
...extensions.flatMap((extension) => extension.plugins)
|
|
111
113
|
];
|
|
112
114
|
const view = new EditorView(element, {
|
|
@@ -5,6 +5,7 @@ import type { Result } from '../utils/result.types';
|
|
|
5
5
|
import type { EditorAction } from '../operations/operations.types';
|
|
6
6
|
import type { ImagePasteText, ImageUploadSource } from '../operations/plugins/imagePaste';
|
|
7
7
|
import type { ImageViewText } from '../operations/plugins/imageView';
|
|
8
|
+
import type { LinkClickSource } from '../operations/plugins/linkClick';
|
|
8
9
|
import type { MermaidBlockText } from '../operations/plugins/mermaidView';
|
|
9
10
|
/**
|
|
10
11
|
* 画像が出す文言。**2 つのプラグイン(貼り付けと表示)が読む先を 1 つにまとめる。**
|
|
@@ -52,6 +53,8 @@ export interface EditorSessionOptions extends EditorPresentation {
|
|
|
52
53
|
* `view.setProps` が呼ばれて入力が取りこぼされる(→ `setPresentation` の注)。
|
|
53
54
|
*/
|
|
54
55
|
readonly imageUpload?: ImageUploadSource;
|
|
56
|
+
/** リンクが押されたときの受け手。`imageUpload` と同じ理由で「呼ぶ時点で読む形」で受け取る */
|
|
57
|
+
readonly linkClick?: LinkClickSource;
|
|
55
58
|
}
|
|
56
59
|
/**
|
|
57
60
|
* 適用の種類。利用者の操作として取り消せる置き換えか、他の書き手の変更の同期反映か。
|
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.25",
|
|
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.",
|