@14ch/svelte-md-outliner 0.0.8 → 0.0.9

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,21 @@ 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.9] - 2026-09-12
9
+
10
+ ### Changed
11
+
12
+ - The text cursor and the built-in context menu are limited to the content. The
13
+ editor fills the box you give it, so the empty space below the document, the
14
+ leftover width beside a narrowed column, and the gaps between blocks all used
15
+ to show an I-beam and open the built-in menu. They now show the ordinary
16
+ pointer and leave right-click to the environment's own menu. Clicking there
17
+ still puts the caret at the nearest position, as before. Quotes, tables and
18
+ code blocks count as content in full — their bars, rules and fills read as
19
+ part of the block, not as a gap.
20
+ - Headings now leave 0.75em below them, the same gap paragraphs leave (was
21
+ 0.5em).
22
+
8
23
  ## [0.0.8] - 2026-09-10
9
24
 
10
25
  ### Fixed
@@ -276,17 +276,58 @@
276
276
  background: var(--markdown-editor-background);
277
277
  outline: none;
278
278
  /**
279
- * 編集エリアの上では I ビームにする。
279
+ * 面そのものは**矢印**にする(合図は中身が出す → 次の規則)。
280
280
  *
281
- * 既定(`auto`)だと、文字の上では I ビームでも、内側の余白やブロックの間の空きでは
282
- * 矢印に戻る。そこも押せば文字を打ち始められる場所なので、サーフェス全体で一貫させる。
283
- * 押して別のことが起きるターゲット(折りたたみの記号・表の印・チェック)は、各所で上書きする。
281
+ * **`auto` では矢印にならない。** 編集できる要素の上では、実行環境が中身の有無に関わらず
282
+ * I ビームを出す(Chromium は `contenteditable` の箱なら内側の余白でも I ビームにする)。
283
+ * 指定を消すだけでは面の全体が I ビームのままなので、矢印は明示する。
284
284
  */
285
- cursor: text;
285
+ cursor: default;
286
286
  white-space: pre-wrap;
287
287
  word-wrap: break-word;
288
288
  }
289
289
 
290
+ /**
291
+ * 文字を打つ合図(I ビーム)は、**書かれているものの上だけに出す**。
292
+ *
293
+ * 面は置いた先が与えた箱いっぱいに広がる(→ `.markdown-editor`)。面の全体を I ビームに
294
+ * すると、文書の下に残った空きや、版面を狭めたときの左右の余りまで「ここは文字の場所だ」と
295
+ * 言うことになる。**置いた先の余白と見分けが付かない場所で、編集エリアだけが自己主張する。**
296
+ * 独自のコンテキストメニューも同じ範囲に揃える(→ `contextMenu.ts`)。
297
+ *
298
+ * **押せることは変わらない。** 余りを押せばいちばん近い位置へカーソルが入る
299
+ * (→ `.markdown-editor`)。変えたのは合図を出す範囲だけである。
300
+ *
301
+ * 押して別のことが起きるターゲット(折りたたみの記号・表の印・チェック・帯)は、各所で
302
+ * 上書きする。どれも `.markdown-editor__surface` から始まる規則なので、この規則より強い。
303
+ */
304
+ .markdown-editor__surface * {
305
+ cursor: text;
306
+ }
307
+
308
+ /**
309
+ * **構造の箱は、自分の隙間に合図を出さない。**
310
+ *
311
+ * セクションと箇条書きの項目は、ブロックを並べるだけで自分の見た目を持たない。並んだ
312
+ * ブロックのあいだ(マージン)は、その箱に当たる。そこは面の余りと同じく何も書かれていない
313
+ * 場所なので、中身と同じ合図を出さない(利用者の指摘、2026-09-12)。
314
+ *
315
+ * **見た目を持つ箱(引用・表・コードブロック)は、箱ごと中身として扱う。** 自分の余白に線や
316
+ * 地を持ち(縦棒・罫線・背景)、そこは隙間ではなく中身の一部として見える。並べてしまうと、
317
+ * 引用の縦棒や表の罫線の上で合図が切れる。
318
+ *
319
+ * **この並びは `contextMenu.ts` の `CONTAINERS` と対になる。** 構造の箱を足したら両方へ足す。
320
+ */
321
+ .markdown-editor__surface
322
+ :is(
323
+ .markdown-editor__section,
324
+ .markdown-editor__intro-section,
325
+ .prosemirror-flat-list,
326
+ .list-content
327
+ ) {
328
+ cursor: default;
329
+ }
330
+
290
331
  /**
291
332
  * 最大幅(→ `--markdown-editor-max-width`)。**面ではなく中身に掛ける。**
292
333
  *
@@ -371,7 +412,7 @@
371
412
  content: '';
372
413
  position: absolute;
373
414
  /**
374
- * 帯の上では**押せる合図**を出す。編集エリアはサーフェス全体が I ビームなので、そのままだと
415
+ * 帯の上では**押せる合図**を出す。中身の上は I ビームなので、そのままだと
375
416
  * 押して別のことが起きる場所だと分からない。指定は擬似要素だけに置く(ブロックへ
376
417
  * 置くと `cursor` は継承されるので、中身まで合図が変わる)。
377
418
  */
@@ -715,7 +756,7 @@
715
756
  /* 折りたたみの記号を 1 行目の中央へ合わせるため、行の高さを控えておく */
716
757
  --markdown-editor-heading-line-height: 1.3;
717
758
 
718
- margin: 2em 0 0.5em;
759
+ margin: 2em 0 0.75em;
719
760
  font-size: calc(1em * var(--markdown-editor-heading-scale));
720
761
  line-height: var(--markdown-editor-heading-line-height);
721
762
  font-weight: 600;
@@ -102,12 +102,14 @@ export function createContextMenuPlugin(options) {
102
102
  * | 順 | 押された場所 | 挙動 |
103
103
  * | -- | -------------------------------------- | ---------------------------------------- |
104
104
  * | 1 | 要選択ブロックの押せる帯の上 | そのブロックを指して開く |
105
- * | 2 | 空でない文字列選択の内側 | 受け止めない(実行環境の既定に委ねる) |
106
- * | 3 | セル選択・ブロックを指す状態の内側 | 選択を保って開く |
107
- * | 4 | それ以外 | その位置へカーソルを置いて開く |
105
+ * | 2 | 書かれているものの外(余り・隙間) | 受け止めない(実行環境の既定に委ねる) |
106
+ * | 3 | 空でない文字列選択の内側 | 受け止めない(実行環境の既定に委ねる) |
107
+ * | 4 | セル選択・ブロックを指す状態の内側 | 選択を保って開く |
108
+ * | 5 | それ以外 | その位置へカーソルを置いて開く |
108
109
  *
109
- * 2 は既定のメニューにしかできないこと(コピー・辞書引き・翻訳)へ譲るためである。
110
- * 3 はカーソルを移すと行・列の削除が消えるためである。
110
+ * 2 は面の余りとブロックどうしの隙間(→ `onContent`)。3 は既定のメニューにしかできない
111
+ * こと(コピー・辞書引き・翻訳)へ譲るためである。4 はカーソルを移すと行・列の削除が
112
+ * 消えるためである。
111
113
  *
112
114
  * **帯を最初に見る。** 帯はブロックの箱の外にあり、そこには文書の位置が無い
113
115
  * (`posAtCoords` が答えない)。選択の内側かどうかは位置が要るため、後段では判定できない。
@@ -119,6 +121,8 @@ function handleContextMenu(view, event, options, pressedSelection) {
119
121
  view.dispatch(view.state.tr.setSelection(NodeSelection.create(view.state.doc, band.pos)));
120
122
  }
121
123
  else {
124
+ if (!onContent(view, event))
125
+ return false;
122
126
  const pos = posAt(view, event);
123
127
  if (pos === undefined)
124
128
  return false;
@@ -143,6 +147,38 @@ function handleContextMenu(view, event, options, pressedSelection) {
143
147
  event.preventDefault();
144
148
  return true;
145
149
  }
150
+ /**
151
+ * 配下をブロックとして並べるだけの箱。**並びは `editor.css` の合図の規則と対になる。**
152
+ *
153
+ * 自分の見た目を持たないものだけを並べる。見た目を持つ箱(引用・表・コードブロック)は
154
+ * 箱ごと中身として扱う(→ `editor.css`)。構造の箱を足したら両方へ足す。
155
+ */
156
+ const CONTAINERS = [
157
+ '.markdown-editor__section',
158
+ '.markdown-editor__intro-section',
159
+ '.prosemirror-flat-list',
160
+ '.list-content'
161
+ ].join(', ');
162
+ /**
163
+ * 押された場所が**書かれているものの上**か。
164
+ *
165
+ * 何も書かれていない場所が 2 通りある。**面の余り**——面は置いた先が与えた箱いっぱいに
166
+ * 広がる(→ `editor.css` の `.markdown-editor`)ので、内側の余白・版面の左右の余り・文書の
167
+ * 下の空きも面の一部である。そして**ブロックどうしの隙間**——並んだブロックのマージンは、
168
+ * それを並べている箱に当たる。どちらも押しただけでこのモジュールのメニューが出ると、
169
+ * 置いた先の余白や行間まで持ち場のように振る舞うことになる(利用者の指摘、2026-09-12)。
170
+ * **合図(I ビーム)を出す範囲と揃える。**
171
+ *
172
+ * **当たった要素で見る。座標から位置を引かない。** `posAtCoords` は隙間の上でもいちばん近い
173
+ * 位置を答えるため、隙間かどうかを区別できない。当たり判定は寄せずに、その点を占めている
174
+ * 箱をそのまま返す(ブロックの箱の外にある帯も、擬似要素なので当たりはブロックになる)。
175
+ */
176
+ function onContent(view, event) {
177
+ const target = event.target;
178
+ if (!(target instanceof Element) || target === view.dom)
179
+ return false;
180
+ return !target.matches(CONTAINERS);
181
+ }
146
182
  /** 押された座標が指す文書の位置。ブロックの箱の外(帯の上)では答えが無い */
147
183
  function posAt(view, event) {
148
184
  return view.posAtCoords({ left: event.clientX, top: event.clientY })?.pos;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@14ch/svelte-md-outliner",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
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.",