履歴: プログラミング/svelte/pukiwikiの記事を流し込む
各行は、その日時に書かれた内容です。追加・削除は、1 つ前の版との行数の差です (全 7 版)。「差分」は比較する版、「基準」は比べる相手の版を選びます
| 日時 | タイトル | 文字数 | 追加 | 削除 | 内容 | 差分 | 基準 |
|---|---|---|---|---|---|---|---|
| 2023/12/4 20:41:22 | プログラミング/svelte/pukiwikiの記事を流し込む 最新版 | 19,170 | +22 | -8 | 表示 | 差分 | — |
| 2023/12/4 4:15:58 | プログラミング/svelte/pukiwikiの記事を流し込む | 19,007 | +75 | -0 | 表示 | 差分 | 選択 |
| 2023/12/3 13:00:31 | プログラミング/svelte/pukiwikiの記事を流し込む | 17,146 | +36 | -10 | 表示 | 表示中 | 選択 |
| 2023/12/3 3:41:46 | プログラミング/svelte/pukiwikiの記事を流し込む | 16,229 | +100 | -0 | 表示 | 差分 | 基準 |
| 2023/12/2 13:31:57 | プログラミング/svelte/pukiwikiの記事を流し込む | 13,503 | +164 | -0 | 表示 | 差分 | 選択 |
| 2023/12/2 4:40:52 | プログラミング/svelte/pukiwikiの記事を流し込む | 9,430 | +293 | -3 | 表示 | 差分 | 選択 |
| 2023/12/2 1:26:17 | プログラミング/svelte/pukiwikiの記事を流し込む | 1,725 | — | — | 表示 | — | 選択 |
基準: プログラミング/svelte/pukiwikiの記事を流し込む (2023/12/3 3:41:46) → 比較: プログラミング/svelte/pukiwikiの記事を流し込む (2023/12/3 13:00:31)
@@ -507,6 +507,8 @@
* 編集時に syntax も変更できるようにする [#m1a9cb4d]
+新規作成時も選べる。
+
src/lib/components/Select.svelte
<script lang="ts">
import type { Writable } from 'svelte/store';
@@ -560,7 +562,7 @@
+ syntax: z.number().min(0).max(1),
});
-import Select from '$lib/components/Select.svelte';
+src/routes/articles/ArticleEditor.svelte
LANG: html
import Select from '$lib/components/Select.svelte';
...
@@ -592,18 +594,42 @@
+ bind:syntax={$form.syntax}
/>
- form.data.title = article.title;
- form.data.body = article.body;
- form.data.syntax = article.syntax;
+src/lib/index.ts
+ LANG: ts
+ export function contractTo<T extends object, S extends T>(larger: S, smaller: T) {
+ const result={} as T;
+ Object.getOwnPropertyNames(smaller).forEach(k=> {
+ if(Object.hasOwn(smaller, k)) {
+ result[k as keyof T] = larger[k as keyof T];
+ }
+ });
+ return result;
+ }
-とか
+src/routes/articles/[...titleOrId]/(login)/edit/+page.server.ts
+ ...
+
+ + import { contractTo } from '$lib';
+ ...
+
+ - form.data.title = article.title;
+ - form.data.body = article.body;
+ + form.data = contractTo(article, form.data);
+ ...
+
+ + if (form.data.title == article.title && form.data.body == article.body) {
+ - if (form.data == contractTo(article, form.data)) {
- if (
- form.data.title == article.title &&
- form.data.body == article.body &&
- form.data.syntax == article.syntax) {
-とかを typescript でうまく書く方法は無いのだろうか?
+ LANG: console
+ $ git commit -m "Syntax を編集できるようにした"
+ new file: src/lib/components/Select.svelte
+ modified: src/lib/index.ts
+ modified: src/routes/articles/(login)/new/+page.svelte
+ modified: src/routes/articles/ArticleEditor.svelte
+ modified: src/routes/articles/[...titleOrId]/(login)/edit/+page.server.ts
+ modified: src/routes/articles/[...titleOrId]/(login)/edit/+page.svelte
+ modified: src/routes/articles/zod-schema.ts
* pukiwiki から markdown への変換 [#r3517e0a]