@14ch/svelte-md-outliner 0.0.13 → 0.0.14

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,18 @@ 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.14] - 2026-09-19
9
+
10
+ ### Changed
11
+
12
+ - Pasting Markdown that carries front matter now replaces the document's front
13
+ matter with it. The pasted front matter used to land in the body as a `yaml`
14
+ code block, leaving the document's own metadata untouched — so copying a whole
15
+ document into a new one meant deleting that block and moving its lines into the
16
+ metadata by hand every time. Content pasted without front matter (or with an
17
+ empty one) leaves the document's metadata alone, and the result now matches
18
+ what you get when pasting over a full selection.
19
+
8
20
  ## [0.0.13] - 2026-09-19
9
21
 
10
22
  ### Fixed
@@ -81,11 +81,17 @@ export function markdownClipboardPlugin() {
81
81
  view.dispatch(replaced.setMeta('paste', true).scrollIntoView());
82
82
  return true;
83
83
  }
84
+ const source = parsed.value.content;
85
+ const pasted = source.firstChild?.type === n.front_matter ? source.firstChild : null;
86
+ const body = pasted ? source.cut(pasted.nodeSize) : source;
87
+ const meta = pasted && pasted.content.size > 0 ? pasted : null;
84
88
  const baseDepth = pasteDepth(view.state.doc, view.state.selection.from);
85
- const content = relevel(frontMatterAsCodeBlock(parsed.value.content), baseDepth);
86
- if (content.childCount === 0)
89
+ const content = relevel(body, baseDepth);
90
+ if (content.childCount === 0 && !meta)
87
91
  return false;
88
92
  const transaction = intoEmptyItem(view.state, content) ?? intoSelection(view.state, content);
93
+ if (meta)
94
+ transaction.replaceWith(0, view.state.doc.child(0).nodeSize, meta);
89
95
  // 空行の後始末(`appendTransaction`)が見る印
90
96
  view.dispatch(transaction.setMeta('paste', true).scrollIntoView());
91
97
  return true;
@@ -120,25 +126,6 @@ function replaceDocument(state, content) {
120
126
  // 打ち間違いとして本文へ移される
121
127
  return markDocumentReplacement(tr);
122
128
  }
123
- /**
124
- * 貼った内容の先頭にあるフロントマターを、`yaml` のコードブロックへ置き換える。中身が無ければ
125
- * 取り除く。
126
- *
127
- * 貼り先のフロントマターは触らない。挿入で貼り先のメタデータが
128
- * 書き換わってはならず、かといって貼った側の文字を捨てることもできないため、
129
- * **文字を失わないコンテナ**へ移す。区切りの行を中身に含めるのは、
130
- * 切り取ってメタデータ欄へ貼り直せるようにするためである。
131
- */
132
- function frontMatterAsCodeBlock(content) {
133
- const first = content.firstChild;
134
- if (first?.type !== n.front_matter)
135
- return content;
136
- const rest = content.cut(first.nodeSize);
137
- if (first.content.size === 0)
138
- return rest;
139
- const source = outlineSchema.text(`---\n${first.textContent}\n---`);
140
- return Fragment.from(n.code_block.createChecked({ language: 'yaml' }, source)).append(rest);
141
- }
142
129
  /**
143
130
  * 空の項目への貼り付け。**貼り付ける内容がその項目に成り代わる。** 対象でなければ null。
144
131
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@14ch/svelte-md-outliner",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
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.",