@14ch/svelte-md-outliner 0.0.21 → 0.0.23
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
CHANGED
|
@@ -5,6 +5,24 @@ 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.23] - 2026-10-23
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Pressing Backspace while composing with an IME no longer leaves the editor
|
|
13
|
+
unable to commit the conversion or move the cursor. Keys pressed during
|
|
14
|
+
composition, including Tab and Enter, are now left to the IME.
|
|
15
|
+
|
|
16
|
+
## [0.0.22] - 2026-10-23
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- IME composition no longer reports Backspace or Enter as handled without
|
|
21
|
+
applying the change, allowing DOM edits and subsequent cursor movement to proceed.
|
|
22
|
+
|
|
23
|
+
- Pasting Markdown containing headings and tables now preserves the heading
|
|
24
|
+
hierarchy when the clipboard also contains HTML.
|
|
25
|
+
|
|
8
26
|
## [0.0.21] - 2026-10-11
|
|
9
27
|
|
|
10
28
|
### Changed
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { baseKeymap, chainCommands } from 'prosemirror-commands';
|
|
2
2
|
import { closeHistory } from 'prosemirror-history';
|
|
3
3
|
import { InputRule, inputRules } from 'prosemirror-inputrules';
|
|
4
|
-
import { keydownHandler
|
|
4
|
+
import { keydownHandler } from 'prosemirror-keymap';
|
|
5
5
|
import { Plugin } from 'prosemirror-state';
|
|
6
6
|
import { autoformatRules } from '../autoformat.js';
|
|
7
7
|
import { linkPastePlugin } from '../plugins/linkPaste.js';
|
|
@@ -39,13 +39,25 @@ function createPlugins(extraActions) {
|
|
|
39
39
|
// 表示操作は編集可否の判定より前に配る(→ viewKeymap)
|
|
40
40
|
viewKeymap(withoutCoreKeys(viewBindings, coreBindings)),
|
|
41
41
|
// 塞ぐかどうかは各定義の「文書を変えるか」で決まる。基盤と拡張で扱いを分けない
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
compositionAwareKeymap(coreBindings),
|
|
43
|
+
compositionAwareKeymap(bindingsOf(extraActions.filter((action) => action.category !== 'view'))),
|
|
44
|
+
compositionAwareKeymap(baseKeymap),
|
|
45
45
|
inputRules({ rules: autoformatRules.map(ruleAsOwnUndoStep) }),
|
|
46
46
|
linkPastePlugin()
|
|
47
47
|
];
|
|
48
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* DOM の変更を取り込む際にも handleKeyDown は呼ばれる。
|
|
51
|
+
* 変換中は「処理済み」にせず、標準キーを含めて IME の変更の取り込みへ譲る。
|
|
52
|
+
*/
|
|
53
|
+
function compositionAwareKeymap(bindings) {
|
|
54
|
+
const handler = keydownHandler(bindings);
|
|
55
|
+
return new Plugin({
|
|
56
|
+
props: {
|
|
57
|
+
handleKeyDown: (view, event) => view.composing || event.isComposing || event.keyCode === 229 ? false : handler(view, event)
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
49
61
|
/**
|
|
50
62
|
* 表示操作のキーを、編集できるかどうかの判定より前に配る。
|
|
51
63
|
*
|
|
@@ -63,6 +75,8 @@ function viewKeymap(bindings) {
|
|
|
63
75
|
props: {
|
|
64
76
|
handleDOMEvents: {
|
|
65
77
|
keydown: (view, event) => {
|
|
78
|
+
if (view.composing || event.isComposing || event.keyCode === 229)
|
|
79
|
+
return false;
|
|
66
80
|
if (!handler(view, event))
|
|
67
81
|
return false;
|
|
68
82
|
event.preventDefault();
|
|
@@ -154,12 +168,12 @@ function ruleAsOwnUndoStep(rule) {
|
|
|
154
168
|
}
|
|
155
169
|
/**
|
|
156
170
|
* IME で変換が確定していない間は、ショートカット・階層操作・既定の Enter 処理を実行しない。
|
|
157
|
-
*
|
|
171
|
+
* 未処理を返す。処理済みにすると DOM からの削除の取り込みまで止めてしまう。
|
|
158
172
|
*/
|
|
159
173
|
function withoutComposition(command) {
|
|
160
174
|
return (state, dispatch, view) => {
|
|
161
175
|
if (view?.composing)
|
|
162
|
-
return
|
|
176
|
+
return false;
|
|
163
177
|
return command(state, dispatch, view);
|
|
164
178
|
};
|
|
165
179
|
}
|
|
@@ -60,21 +60,14 @@ export function markdownClipboardPlugin() {
|
|
|
60
60
|
return false;
|
|
61
61
|
if (isInTable(view.state))
|
|
62
62
|
return false;
|
|
63
|
-
/**
|
|
64
|
-
* **表が同時に届いているなら、文字ではなく表として貼られるべきである**
|
|
65
|
-
* (要件 1.2)。スプレッドシートはタブ区切りの文字と表の HTML を同時に
|
|
66
|
-
* 載せる。ここで文字を読むと、表が 1 行に潰れる。譲った先(編集基盤の
|
|
67
|
-
* 既定の貼り付け)が、HTML を表として取り込む。
|
|
68
|
-
*
|
|
69
|
-
* **置く位置が仕様である。** 読み取り専用・記法を解釈しない場所・表の中と
|
|
70
|
-
* いう 3 つの判断より後に置く。先に置くと、記法を解釈しない場所で表を
|
|
71
|
-
* 貼ったときに、譲った先が表を作ろうとする。
|
|
72
|
-
*/
|
|
73
|
-
if (hasPastedTable(event.clipboardData))
|
|
74
|
-
return false;
|
|
75
63
|
const parsed = parseMarkdown(text);
|
|
76
64
|
if (!parsed.ok)
|
|
77
65
|
return false;
|
|
66
|
+
// Markdown の表なら、見出しも含めて Markdown として読む。
|
|
67
|
+
// HTML に表があるだけで既定の取り込みへ譲ると、見出しの兄弟関係が失われる。
|
|
68
|
+
// TSV など、文字側に表の構造が無いときだけ HTML の表へ譲る。
|
|
69
|
+
if (hasPastedTable(event.clipboardData) && !containsTable(parsed.value))
|
|
70
|
+
return false;
|
|
78
71
|
// 文書全体への貼り付けは**差し替え**である。メタデータごと入れ替わる
|
|
79
72
|
if (view.state.selection instanceof AllSelection) {
|
|
80
73
|
const replaced = replaceDocument(view.state, parsed.value.content);
|
|
@@ -286,3 +279,13 @@ function toArray(content) {
|
|
|
286
279
|
content.forEach((child) => nodes.push(child));
|
|
287
280
|
return nodes;
|
|
288
281
|
}
|
|
282
|
+
/** Markdown として表の構造を読み取れたか(コード中の表記などは含めない)。 */
|
|
283
|
+
function containsTable(doc) {
|
|
284
|
+
let found = false;
|
|
285
|
+
doc.descendants((node) => {
|
|
286
|
+
if (node.type === n.table)
|
|
287
|
+
found = true;
|
|
288
|
+
return !found;
|
|
289
|
+
});
|
|
290
|
+
return found;
|
|
291
|
+
}
|
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.23",
|
|
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.",
|