@open-spreadsheet/core 0.3.0 → 0.4.0

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/app/i18n-more.ts CHANGED
@@ -217,7 +217,7 @@ export const zhCN: Dict = {
217
217
  protectedOff: '已取消保护。',
218
218
  protectedRefused: '这个区域受保护。请先取消保护(右键 → 取消保护)。',
219
219
  assets: 'Assets',
220
- assetsHint: '这个工作簿的图片和笔记;笔记也是 agent 处理时的背景资料。',
220
+ assetsHint: '这个工作簿的图表图片与上传的图片;图表从“表格”的工具栏创建。',
221
221
  assetsThisBook: '这个工作簿',
222
222
  assetsShared: '共享',
223
223
  newChartImage: '图表图片',
@@ -226,13 +226,72 @@ export const zhCN: Dict = {
226
226
  noAssets: '还没有内容。',
227
227
  saveIn: '保存在',
228
228
  noteContextHint: 'Markdown 格式。Agent 处理这个工作簿前会先读这些笔记:数字的含义、来源、要遵守的规则。',
229
- deleteAssetTitle: (n: string) => `删除 ${n}?`,
229
+ deleteAssetTitle: (n: string) => `删除“${n}”?`,
230
230
  deleteAssetBody: '会移到 assets 的 .trash 文件夹。',
231
- chartSaved: (n: string) => `已保存到 Assets:${n}`,
232
- chartsMoved: (k: number) => `已把 ${k} 个图表移到 Assets`,
233
- chartsOnGrid: (k: number) => `这个工作簿的单元格上有 ${k} 个图表;图表现在改以图片放在 Assets。`,
234
- moveChartsToAssets: '移到 Assets',
231
+ chartSaved: (n: string) => `已保存到素材:${n}`,
232
+ chartsMoved: (k: number) => `已把 ${k} 个图表移到素材`,
233
+ chartsOnGrid: (k: number) => `单元格上有 ${k} 个图表`,
234
+ moveChartsToAssets: '移到素材',
235
235
  close: '关闭',
236
+ viewSheet: '表格',
237
+ viewAssets: '素材',
238
+ viewNotes: '笔记',
239
+ notesTitle: '这个工作簿的笔记',
240
+ noImagesYet: '还没有图片。在“表格”选好数据,点工具栏的图表按钮。',
241
+ noNotesYet: '还没有笔记',
242
+ newChart: '新建图表',
243
+ editChart: '编辑图表',
244
+ chartType: '类型',
245
+ sheetLabel: '工作表',
246
+ rangeLabel: '区域',
247
+ noAssetsYet: '还没有素材',
248
+ notePlaceholder: '开始写,输入 # 变标题、- 变列表…',
249
+ markdownSource: 'Markdown 源码',
250
+ chartBarH: '条形图',
251
+ chartStacked: '堆积柱形图',
252
+ chartArea: '面积图',
253
+ chartDoughnut: '圆环图',
254
+ chartScatter: '散点图',
255
+ chartCombo: '组合图',
256
+ notesRecent: '最近',
257
+ notesFavorites: '收藏',
258
+ notesAll: '全部',
259
+ searchNotes: '搜索笔记',
260
+ favorite: '加入收藏',
261
+ unfavorite: '取消收藏',
262
+ noFavorites: '还没有收藏的笔记',
263
+ noMatches: '找不到匹配的项目',
264
+ justNow: '刚刚',
265
+ minutesAgo: (n: number) => `${n} 分钟前`,
266
+ hoursAgo: (n: number) => `${n} 小时前`,
267
+ home: '首页',
268
+ searchAssets: '搜索素材',
269
+ chartStyles: '图表样式',
270
+ newStyle: '新建样式',
271
+ styleLabel: '样式',
272
+ defaultBadge: '默认',
273
+ makeDefault: '设为默认',
274
+ builtIn: '内置',
275
+ duplicateEdit: '复制后编辑',
276
+ styleColors: '系列颜色',
277
+ styleColorsMore: '其他颜色',
278
+ styleBackground: '背景',
279
+ styleText: '标题',
280
+ styleMuted: '标签',
281
+ styleGrid: '网格',
282
+ styleFont: '字体',
283
+ styleCorners: '柱形圆角',
284
+ styleGridLines: '显示网格线',
285
+ fontSans: '黑体',
286
+ fontSerif: '宋体',
287
+ fontMono: '等宽',
288
+ fontRounded: '圆体',
289
+ addColor: '添加颜色',
290
+ removeColor: '移除最后一个颜色',
291
+ noFavoriteAssets: '还没有收藏的素材',
292
+ followDefault: (n: string) => `跟随默认(${n})`,
293
+ builtinStyle: (id: string) => (({ default: '标准', ocean: '海洋', warm: '暖阳', pastel: '柔和', mono: '黑白', night: '夜间' }) as Record<string, string>)[id] ?? id,
294
+ insertAsset: '插入素材',
236
295
  fontSize: '字号',
237
296
  fontSizeOther: '其他字号…',
238
297
  customSort: '自定义排序…',
@@ -502,7 +561,7 @@ export const ja: Dict = {
502
561
  protectedOff: '保護を解除しました。',
503
562
  protectedRefused: 'この範囲は保護されています。先に保護を解除してください(右クリック → 範囲の保護を解除)。',
504
563
  assets: 'Assets',
505
- assetsHint: 'このブックの画像とメモ。メモはエージェントの作業時の前提情報にもなります。',
564
+ assetsHint: 'このブックのグラフ画像とアップロードした画像。グラフはシートのツールバーから作成します。',
506
565
  assetsThisBook: 'このブック',
507
566
  assetsShared: '共有',
508
567
  newChartImage: 'グラフ画像',
@@ -512,12 +571,71 @@ export const ja: Dict = {
512
571
  noAssets: 'まだありません。',
513
572
  saveIn: '保存先',
514
573
  noteContextHint: 'Markdown。エージェントはブックを扱う前にこれらのメモを読みます:数字の意味、出典、守るべきルール。',
515
- deleteAssetTitle: (n: string) => `${n} を削除しますか?`,
574
+ deleteAssetTitle: (n: string) => `「${n}」を削除しますか?`,
516
575
  deleteAssetBody: 'assets の .trash フォルダーに移動します。',
517
- chartSaved: (n: string) => `Assets に保存しました:${n}`,
518
- chartsMoved: (k: number) => `${k} 個のグラフを Assets に移動しました`,
519
- chartsOnGrid: (k: number) => `このブックのセル上に ${k} 個のグラフがあります。グラフは画像として Assets に置くようになりました。`,
520
- moveChartsToAssets: 'Assets へ移動',
576
+ chartSaved: (n: string) => `アセットに保存しました:${n}`,
577
+ chartsMoved: (k: number) => `${k} 個のグラフをアセットに移動しました`,
578
+ chartsOnGrid: (k: number) => `セル上に ${k} 個のグラフがあります`,
579
+ moveChartsToAssets: 'アセットへ移動',
580
+ viewSheet: 'シート',
581
+ viewAssets: 'アセット',
582
+ viewNotes: 'ノート',
583
+ notesTitle: 'このブックのノート',
584
+ noImagesYet: '画像はまだありません。シートでデータを選び、ツールバーのグラフボタンを押してください。',
585
+ noNotesYet: 'ノートはまだありません',
586
+ newChart: '新しいグラフ',
587
+ editChart: 'グラフを編集',
588
+ chartType: '種類',
589
+ sheetLabel: 'シート',
590
+ rangeLabel: '範囲',
591
+ noAssetsYet: 'アセットはまだありません',
592
+ notePlaceholder: '書き始めましょう。# で見出し、- でリスト…',
593
+ markdownSource: 'Markdown ソース',
594
+ chartBarH: '横棒グラフ',
595
+ chartStacked: '積み上げ縦棒',
596
+ chartArea: '面グラフ',
597
+ chartDoughnut: 'ドーナツ',
598
+ chartScatter: '散布図',
599
+ chartCombo: '複合グラフ',
600
+ notesRecent: '最近',
601
+ notesFavorites: 'お気に入り',
602
+ notesAll: 'すべて',
603
+ searchNotes: 'ノートを検索',
604
+ favorite: 'お気に入りに追加',
605
+ unfavorite: 'お気に入りから削除',
606
+ noFavorites: 'お気に入りのノートはまだありません',
607
+ noMatches: '一致する項目はありません',
608
+ justNow: 'たった今',
609
+ minutesAgo: (n: number) => `${n} 分前`,
610
+ hoursAgo: (n: number) => `${n} 時間前`,
611
+ home: 'ホーム',
612
+ searchAssets: '素材を検索',
613
+ chartStyles: 'グラフのスタイル',
614
+ newStyle: '新しいスタイル',
615
+ styleLabel: 'スタイル',
616
+ defaultBadge: '既定',
617
+ makeDefault: '既定にする',
618
+ builtIn: '組み込み',
619
+ duplicateEdit: '複製して編集',
620
+ styleColors: '系列の色',
621
+ styleColorsMore: 'その他の色',
622
+ styleBackground: '背景',
623
+ styleText: 'タイトル',
624
+ styleMuted: 'ラベル',
625
+ styleGrid: '目盛線',
626
+ styleFont: 'フォント',
627
+ styleCorners: '棒の角丸',
628
+ styleGridLines: '目盛線を表示',
629
+ fontSans: 'ゴシック',
630
+ fontSerif: '明朝',
631
+ fontMono: '等幅',
632
+ fontRounded: '丸ゴシック',
633
+ addColor: '色を追加',
634
+ removeColor: '最後の色を削除',
635
+ noFavoriteAssets: 'お気に入りの素材はまだありません',
636
+ followDefault: (n: string) => `既定に従う(${n})`,
637
+ builtinStyle: (id: string) => (({ default: '標準', ocean: 'オーシャン', warm: 'ウォーム', pastel: 'パステル', mono: 'モノクロ', night: 'ナイト' }) as Record<string, string>)[id] ?? id,
638
+ insertAsset: '素材を挿入',
521
639
  fontSize: 'フォント サイズ',
522
640
  fontSizeOther: 'その他のサイズ…',
523
641
  customSort: 'ユーザー設定の並べ替え…',
@@ -553,7 +671,7 @@ export const ja: Dict = {
553
671
  splitDone: (n) => `${n} 個のセルを分割しました`,
554
672
  pasteTranspose: '行列を入れ替えて貼り付け',
555
673
  insertChart: 'グラフを挿入',
556
- chartBar: '棒グラフ',
674
+ chartBar: '縦棒グラフ',
557
675
  chartLine: '折れ線グラフ',
558
676
  chartPie: '円グラフ',
559
677
  chartTitle: 'グラフタイトル…',
@@ -787,7 +905,7 @@ export const ko: Dict = {
787
905
  protectedOff: '보호를 해제했습니다.',
788
906
  protectedRefused: '이 범위는 보호되어 있습니다. 먼저 보호를 해제하세요(오른쪽 클릭 → 범위 보호 해제).',
789
907
  assets: 'Assets',
790
- assetsHint: '이 통합 문서의 이미지와 메모입니다. 메모는 에이전트 작업의 배경 정보가 됩니다.',
908
+ assetsHint: '이 통합 문서의 차트 이미지와 업로드한 이미지입니다. 차트는 시트의 도구 모음에서 만듭니다.',
791
909
  assetsThisBook: '이 통합 문서',
792
910
  assetsShared: '공유',
793
911
  newChartImage: '차트 이미지',
@@ -797,12 +915,71 @@ export const ko: Dict = {
797
915
  noAssets: '아직 없습니다.',
798
916
  saveIn: '저장 위치',
799
917
  noteContextHint: 'Markdown 형식입니다. 에이전트는 통합 문서를 다루기 전에 이 메모를 읽습니다: 숫자의 의미, 출처, 지킬 규칙.',
800
- deleteAssetTitle: (n: string) => `${n}을(를) 삭제할까요?`,
918
+ deleteAssetTitle: (n: string) => `“${n}”을(를) 삭제할까요?`,
801
919
  deleteAssetBody: 'assets의 .trash 폴더로 이동합니다.',
802
- chartSaved: (n: string) => `Assets에 저장했습니다: ${n}`,
803
- chartsMoved: (k: number) => `차트 ${k}개를 Assets로 옮겼습니다`,
804
- chartsOnGrid: (k: number) => `이 통합 문서의 셀 위에 차트가 ${k}개 있습니다. 차트는 이제 이미지로 Assets에 둡니다.`,
805
- moveChartsToAssets: 'Assets로 이동',
920
+ chartSaved: (n: string) => `에셋에 저장했습니다: ${n}`,
921
+ chartsMoved: (k: number) => `차트 ${k}개를 에셋으로 옮겼습니다`,
922
+ chartsOnGrid: (k: number) => `셀 위에 차트가 ${k}개 있습니다`,
923
+ moveChartsToAssets: '에셋으로 이동',
924
+ viewSheet: '시트',
925
+ viewAssets: '에셋',
926
+ viewNotes: '노트',
927
+ notesTitle: '이 통합 문서의 노트',
928
+ noImagesYet: '아직 이미지가 없습니다. 시트에서 데이터를 선택하고 도구 모음의 차트 버튼을 누르세요.',
929
+ noNotesYet: '아직 노트가 없습니다',
930
+ newChart: '새 차트',
931
+ editChart: '차트 편집',
932
+ chartType: '종류',
933
+ sheetLabel: '시트',
934
+ rangeLabel: '범위',
935
+ noAssetsYet: '아직 에셋이 없습니다',
936
+ notePlaceholder: '작성을 시작하세요. #은 제목, -는 목록…',
937
+ markdownSource: 'Markdown 원본',
938
+ chartBarH: '가로 막대형',
939
+ chartStacked: '누적 세로 막대형',
940
+ chartArea: '영역형',
941
+ chartDoughnut: '도넛형',
942
+ chartScatter: '분산형',
943
+ chartCombo: '콤보',
944
+ notesRecent: '최근',
945
+ notesFavorites: '즐겨찾기',
946
+ notesAll: '전체',
947
+ searchNotes: '노트 검색',
948
+ favorite: '즐겨찾기에 추가',
949
+ unfavorite: '즐겨찾기에서 제거',
950
+ noFavorites: '즐겨찾기한 노트가 없습니다',
951
+ noMatches: '일치하는 항목이 없습니다',
952
+ justNow: '방금',
953
+ minutesAgo: (n: number) => `${n}분 전`,
954
+ hoursAgo: (n: number) => `${n}시간 전`,
955
+ home: '홈',
956
+ searchAssets: '소재 검색',
957
+ chartStyles: '차트 스타일',
958
+ newStyle: '새 스타일',
959
+ styleLabel: '스타일',
960
+ defaultBadge: '기본값',
961
+ makeDefault: '기본값으로 설정',
962
+ builtIn: '기본 제공',
963
+ duplicateEdit: '복제해서 편집',
964
+ styleColors: '계열 색',
965
+ styleColorsMore: '기타 색',
966
+ styleBackground: '배경',
967
+ styleText: '제목',
968
+ styleMuted: '레이블',
969
+ styleGrid: '눈금선',
970
+ styleFont: '글꼴',
971
+ styleCorners: '막대 모서리',
972
+ styleGridLines: '눈금선 표시',
973
+ fontSans: '고딕',
974
+ fontSerif: '명조',
975
+ fontMono: '고정폭',
976
+ fontRounded: '둥근 고딕',
977
+ addColor: '색 추가',
978
+ removeColor: '마지막 색 제거',
979
+ noFavoriteAssets: '즐겨찾기한 소재가 없습니다',
980
+ followDefault: (n: string) => `기본값 따르기 (${n})`,
981
+ builtinStyle: (id: string) => (({ default: '표준', ocean: '오션', warm: '웜', pastel: '파스텔', mono: '모노', night: '나이트' }) as Record<string, string>)[id] ?? id,
982
+ insertAsset: '소재 삽입',
806
983
  fontSize: '글꼴 크기',
807
984
  fontSizeOther: '다른 크기…',
808
985
  customSort: '사용자 지정 정렬…',
@@ -838,7 +1015,7 @@ export const ko: Dict = {
838
1015
  splitDone: (n) => `셀 ${n}개를 나눴습니다`,
839
1016
  pasteTranspose: '행/열 바꿔 붙여넣기',
840
1017
  insertChart: '차트 삽입',
841
- chartBar: '막대형 차트',
1018
+ chartBar: '세로 막대형',
842
1019
  chartLine: '꺾은선형 차트',
843
1020
  chartPie: '원형 차트',
844
1021
  chartTitle: '차트 제목…',
package/app/i18n.ts CHANGED
@@ -217,7 +217,7 @@ export const en = {
217
217
  protectedOff: 'Protection removed.',
218
218
  protectedRefused: 'This range is protected. Unprotect it first (right-click → Unprotect range).',
219
219
  assets: 'Assets',
220
- assetsHint: "This workbook's images and notes. Notes are context for agents.",
220
+ assetsHint: "Chart images and pictures for this workbook. Make a chart from the sheet's toolbar.",
221
221
  assetsThisBook: 'This workbook',
222
222
  assetsShared: 'Shared',
223
223
  newChartImage: 'Chart image',
@@ -226,13 +226,72 @@ export const en = {
226
226
  noAssets: 'Nothing here yet.',
227
227
  saveIn: 'Save in',
228
228
  noteContextHint: 'Markdown. Agents read these notes before working on the workbook: what the numbers mean, where they come from, what to keep.',
229
- deleteAssetTitle: (n: string) => `Delete ${n}?`,
229
+ deleteAssetTitle: (n: string) => `Delete “${n}”?`,
230
230
  deleteAssetBody: 'It moves to the assets .trash folder.',
231
- chartSaved: (n: string) => `Saved ${n} in Assets`,
231
+ chartSaved: (n: string) => `Saved “${n}” to Assets`,
232
232
  chartsMoved: (k: number) => `Moved ${k} chart${k === 1 ? '' : 's'} to Assets`,
233
- chartsOnGrid: (k: number) => `This workbook has ${k} chart${k === 1 ? '' : 's'} on the grid. Charts now live in Assets as images.`,
233
+ chartsOnGrid: (k: number) => `${k} chart${k === 1 ? '' : 's'} on the grid`,
234
234
  moveChartsToAssets: 'Move to Assets',
235
235
  close: 'Close',
236
+ viewSheet: 'Sheet',
237
+ viewAssets: 'Assets',
238
+ viewNotes: 'Notes',
239
+ notesTitle: 'Notes for this workbook',
240
+ noImagesYet: 'No images yet. In the sheet, select the data and use the chart button in the toolbar.',
241
+ noNotesYet: 'No notes yet',
242
+ newChart: 'New chart',
243
+ editChart: 'Edit chart',
244
+ chartType: 'Type',
245
+ sheetLabel: 'Sheet',
246
+ rangeLabel: 'Range',
247
+ noAssetsYet: 'No assets yet',
248
+ notePlaceholder: 'Write, or type # for a heading, - for a list…',
249
+ markdownSource: 'Markdown source',
250
+ chartBarH: 'Bar (horizontal)',
251
+ chartStacked: 'Stacked column',
252
+ chartArea: 'Area',
253
+ chartDoughnut: 'Doughnut',
254
+ chartScatter: 'Scatter',
255
+ chartCombo: 'Combo',
256
+ notesRecent: 'Recent',
257
+ notesFavorites: 'Favorites',
258
+ notesAll: 'All',
259
+ searchNotes: 'Search notes',
260
+ favorite: 'Add to favorites',
261
+ unfavorite: 'Remove from favorites',
262
+ noFavorites: 'No favorites yet',
263
+ noMatches: 'No matches',
264
+ justNow: 'Just now',
265
+ minutesAgo: (n: number) => `${n} min ago`,
266
+ hoursAgo: (n: number) => `${n} h ago`,
267
+ home: 'Home',
268
+ searchAssets: 'Search assets',
269
+ chartStyles: 'Chart styles',
270
+ newStyle: 'New style',
271
+ styleLabel: 'Style',
272
+ defaultBadge: 'Default',
273
+ makeDefault: 'Use for new charts',
274
+ builtIn: 'Built-in',
275
+ duplicateEdit: 'Duplicate to edit',
276
+ styleColors: 'Series colours',
277
+ styleColorsMore: 'Other colours',
278
+ styleBackground: 'Background',
279
+ styleText: 'Title',
280
+ styleMuted: 'Labels',
281
+ styleGrid: 'Grid',
282
+ styleFont: 'Font',
283
+ styleCorners: 'Bar corners',
284
+ styleGridLines: 'Grid lines',
285
+ fontSans: 'Sans serif',
286
+ fontSerif: 'Serif',
287
+ fontMono: 'Monospace',
288
+ fontRounded: 'Rounded',
289
+ addColor: 'Add colour',
290
+ removeColor: 'Remove last colour',
291
+ noFavoriteAssets: 'No favourites yet',
292
+ followDefault: (n: string) => `Follow the default (${n})`,
293
+ builtinStyle: (id: string) => (({ default: 'Standard', ocean: 'Ocean', warm: 'Warm', pastel: 'Pastel', mono: 'Mono', night: 'Night' }) as Record<string, string>)[id] ?? id,
294
+ insertAsset: 'Insert asset',
236
295
  fontSize: 'Font size',
237
296
  fontSizeOther: 'Other size…',
238
297
  customSort: 'Custom sort…',
@@ -268,7 +327,7 @@ export const en = {
268
327
  splitDone: (n: number) => `Split ${n} cell${n === 1 ? '' : 's'}`,
269
328
  pasteTranspose: 'Paste transposed',
270
329
  insertChart: 'Insert chart',
271
- chartBar: 'Bar chart',
330
+ chartBar: 'Column',
272
331
  chartLine: 'Line chart',
273
332
  chartPie: 'Pie chart',
274
333
  chartTitle: 'Chart title…',
@@ -502,7 +561,7 @@ const zh: Dict = {
502
561
  protectedOff: '已取消保護。',
503
562
  protectedRefused: '這個範圍受保護。請先取消保護(右鍵 → 取消保護)。',
504
563
  assets: 'Assets',
505
- assetsHint: '這本活頁簿的圖片和筆記;筆記也是 agent 處理時的背景資料。',
564
+ assetsHint: '這本活頁簿的圖表圖片與上傳的圖片;圖表從「表格」的工具列建立。',
506
565
  assetsThisBook: '這本活頁簿',
507
566
  assetsShared: '共用',
508
567
  newChartImage: '圖表圖片',
@@ -512,12 +571,71 @@ const zh: Dict = {
512
571
  noAssets: '還沒有內容。',
513
572
  saveIn: '存放在',
514
573
  noteContextHint: 'Markdown 格式。Agent 處理這本活頁簿前會先讀這些筆記:數字的意思、來源、要遵守的規則。',
515
- deleteAssetTitle: (n: string) => `刪除 ${n}?`,
574
+ deleteAssetTitle: (n: string) => `刪除「${n}」?`,
516
575
  deleteAssetBody: '會移到 assets 的 .trash 資料夾。',
517
- chartSaved: (n: string) => `已存到 Assets:${n}`,
518
- chartsMoved: (k: number) => `已把 ${k} 個圖表移到 Assets`,
519
- chartsOnGrid: (k: number) => `這本活頁簿的格子上有 ${k} 個圖表;圖表現在改以圖片放在 Assets。`,
520
- moveChartsToAssets: '移到 Assets',
576
+ chartSaved: (n: string) => `已存到素材:${n}`,
577
+ chartsMoved: (k: number) => `已把 ${k} 個圖表移到素材`,
578
+ chartsOnGrid: (k: number) => `格子上有 ${k} 個圖表`,
579
+ moveChartsToAssets: '移到素材',
580
+ viewSheet: '表格',
581
+ viewAssets: '素材',
582
+ viewNotes: '筆記',
583
+ notesTitle: '這本活頁簿的筆記',
584
+ noImagesYet: '還沒有圖片。在「表格」選好資料,按工具列的圖表按鈕。',
585
+ noNotesYet: '還沒有筆記',
586
+ newChart: '新增圖表',
587
+ editChart: '編輯圖表',
588
+ chartType: '類型',
589
+ sheetLabel: '工作表',
590
+ rangeLabel: '範圍',
591
+ noAssetsYet: '還沒有素材',
592
+ notePlaceholder: '開始寫,輸入 # 變標題、- 變清單…',
593
+ markdownSource: 'Markdown 原始碼',
594
+ chartBarH: '橫條圖',
595
+ chartStacked: '堆疊直條圖',
596
+ chartArea: '區域圖',
597
+ chartDoughnut: '環圈圖',
598
+ chartScatter: '散佈圖',
599
+ chartCombo: '組合圖',
600
+ notesRecent: '最近',
601
+ notesFavorites: '最愛',
602
+ notesAll: '全部',
603
+ searchNotes: '搜尋筆記',
604
+ favorite: '加入最愛',
605
+ unfavorite: '移除最愛',
606
+ noFavorites: '還沒有最愛的筆記',
607
+ noMatches: '找不到符合的項目',
608
+ justNow: '剛剛',
609
+ minutesAgo: (n: number) => `${n} 分鐘前`,
610
+ hoursAgo: (n: number) => `${n} 小時前`,
611
+ home: '首頁',
612
+ searchAssets: '搜尋素材',
613
+ chartStyles: '圖表風格',
614
+ newStyle: '新增風格',
615
+ styleLabel: '風格',
616
+ defaultBadge: '預設',
617
+ makeDefault: '設為預設',
618
+ builtIn: '內建',
619
+ duplicateEdit: '複製來編輯',
620
+ styleColors: '數列色彩',
621
+ styleColorsMore: '其他色彩',
622
+ styleBackground: '背景',
623
+ styleText: '標題',
624
+ styleMuted: '標籤',
625
+ styleGrid: '格線',
626
+ styleFont: '字型',
627
+ styleCorners: '長條圓角',
628
+ styleGridLines: '顯示格線',
629
+ fontSans: '黑體',
630
+ fontSerif: '明體',
631
+ fontMono: '等寬',
632
+ fontRounded: '圓體',
633
+ addColor: '新增顏色',
634
+ removeColor: '移除最後一個顏色',
635
+ noFavoriteAssets: '還沒有最愛的素材',
636
+ followDefault: (n: string) => `跟隨預設(${n})`,
637
+ builtinStyle: (id: string) => (({ default: '標準', ocean: '海洋', warm: '暖陽', pastel: '柔和', mono: '黑白', night: '夜間' }) as Record<string, string>)[id] ?? id,
638
+ insertAsset: '插入素材',
521
639
  fontSize: '字型大小',
522
640
  fontSizeOther: '其他大小…',
523
641
  customSort: '自訂排序…',
@@ -553,7 +671,7 @@ const zh: Dict = {
553
671
  splitDone: (n) => `已拆開 ${n} 格`,
554
672
  pasteTranspose: '轉置貼上',
555
673
  insertChart: '插入圖表',
556
- chartBar: '長條圖',
674
+ chartBar: '直條圖',
557
675
  chartLine: '折線圖',
558
676
  chartPie: '圓餅圖',
559
677
  chartTitle: '圖表標題…',
package/app/icons.ts CHANGED
@@ -10,6 +10,11 @@ const P: Record<string, string> = {
10
10
  chevronDown: '<path d="m6 9 6 6 6-6"/>',
11
11
  arrowLeft: '<path d="M19 12H5M12 19l-7-7 7-7"/>',
12
12
  arrowRight: '<path d="M5 12h14M12 5l7 7-7 7"/>',
13
+ code: '<path d="m8 8-4 4 4 4M16 8l4 4-4 4"/>',
14
+ image: '<rect x="3" y="4" width="18" height="16" rx="2"/><circle cx="9" cy="10" r="1.6"/><path d="m21 16-5-5-9 9"/>',
15
+ home: '<path d="M3 10.5 12 3l9 7.5V20a1 1 0 0 1-1 1h-5v-6h-6v6H4a1 1 0 0 1-1-1z"/>',
16
+ star: '<path d="m12 3 2.7 5.6 6.1.9-4.4 4.3 1 6.1L12 17l-5.4 2.9 1-6.1-4.4-4.3 6.1-.9z"/>',
17
+ starFill: '<path d="m12 3 2.7 5.6 6.1.9-4.4 4.3 1 6.1L12 17l-5.4 2.9 1-6.1-4.4-4.3 6.1-.9z" fill="currentColor"/>',
13
18
  more: '<circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/>',
14
19
  sun: '<circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/>',
15
20
  moon: '<path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"/>',
@@ -0,0 +1,25 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { inline, mdToHtml } from './markdown.ts';
3
+
4
+ describe('note Markdown', () => {
5
+ it('renders the blocks people write in notes', () => {
6
+ expect(mdToHtml('# 業績\n\n第一行\n第二行\n\n- 甲\n- 乙\n\n1. 一\n2. 二\n\n> 引言\n\n---\n\n```\nx < 1\n```')).toBe(
7
+ '<h1>業績</h1><p>第一行<br>第二行</p><ul><li>甲</li><li>乙</li></ul><ol><li>一</li><li>二</li></ol><blockquote><p>引言</p></blockquote><hr><pre><code>x &lt; 1</code></pre>',
8
+ );
9
+ });
10
+
11
+ it('renders inline marks, keeps code literal, and never runs HTML or unsafe links', () => {
12
+ expect(inline('**粗** 與 *斜* 與 `**不是粗體**`')).toBe('<strong>粗</strong> 與 <em>斜</em> 與 <code>**不是粗體**</code>');
13
+ expect(inline('<img src=x onerror=alert(1)>')).toBe('&lt;img src=x onerror=alert(1)&gt;');
14
+ expect(inline('[ok](https://example.com) [bad](javascript:alert(1))')).toBe('<a href="https://example.com" target="_blank" rel="noopener noreferrer">ok</a> bad)');
15
+ });
16
+
17
+ it('shows an image only where the note resolves it, and nothing in it is read as Markdown', () => {
18
+ const at = (src: string) => (src.endsWith('.svg') ? `/f?n=${src}` : null);
19
+ expect(inline('![業績 *圖*](a.svg)', at)).toBe('<img class="md-img" src="/f?n=a.svg" alt="業績 *圖*" data-src="a.svg">');
20
+ expect(inline('![x](https://evil.example/x.png)', at)).toBe('x');
21
+ expect(inline('![x](a.svg)')).toBe('x');
22
+ expect(inline('[link](https://a.b) ![p](a.svg)', at)).toContain('<a href="https://a.b"');
23
+ expect(inline('![p" onerror="x](a.svg)', at)).not.toContain('" onerror');
24
+ });
25
+ });
@@ -0,0 +1,150 @@
1
+ // Markdown for notes, both ways: a small renderer (the subset people write in
2
+ // notes — headings, paragraphs, lists, quotes, code, rules, bold, italic, code,
3
+ // links, images) and a serializer back from the edited DOM. Text is always
4
+ // escaped and links are http(s) or mailto only: a note may come from an agent.
5
+ // An image shows only when the caller resolves its source (to an asset beside
6
+ // the note); anything else stays as its alt text.
7
+
8
+ /** Where an image's Markdown source points, as a URL to show; null to leave it out. */
9
+ export type ImageResolver = (src: string) => string | null;
10
+
11
+ const esc = (s: string) => s.replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;').replaceAll('"', '&quot;');
12
+
13
+ const safeHref = (url: string) => (/^(https?:|mailto:)/i.test(url.trim()) ? url.trim() : '');
14
+
15
+ /** Inline Markdown in one line of text: `code`, **bold**, *italic*, [text](url), ![alt](image). */
16
+ export function inline(text: string, image?: ImageResolver): string {
17
+ const parts: string[] = [];
18
+ // Code spans first, so nothing inside them is read as Markdown.
19
+ const re = /`([^`\n]+)`/g;
20
+ let last = 0;
21
+ for (let m = re.exec(text); m; m = re.exec(text)) {
22
+ parts.push(rest(text.slice(last, m.index)), `<code>${esc(m[1]!)}</code>`);
23
+ last = m.index + m[0].length;
24
+ }
25
+ parts.push(rest(text.slice(last)));
26
+ return parts.join('');
27
+
28
+ function rest(t: string): string {
29
+ // Images first, held out as tokens so nothing in their alt text or source is read as Markdown.
30
+ const held: string[] = [];
31
+ return esc(t)
32
+ .replace(/!\[([^\]\n]*)\]\(([^)\s]+)\)/g, (_, alt: string, src: string) => {
33
+ const raw = src.replaceAll('&amp;', '&');
34
+ const url = image?.(raw);
35
+ held.push(url ? `<img class="md-img" src="${esc(url)}" alt="${alt}" data-src="${esc(raw)}">` : alt);
36
+ return `\u0000${held.length - 1}\u0000`;
37
+ })
38
+ .replace(/\[([^\]\n]+)\]\(([^)\s]+)\)/g, (_, label: string, url: string) => {
39
+ const href = safeHref(url.replaceAll('&amp;', '&'));
40
+ return href ? `<a href="${esc(href)}" target="_blank" rel="noopener noreferrer">${label}</a>` : label;
41
+ })
42
+ .replace(/\*\*([^*\n]+)\*\*/g, '<strong>$1</strong>')
43
+ .replace(/(^|[^*])\*([^*\n]+)\*(?!\*)/g, '$1<em>$2</em>')
44
+ .replace(/\u0000(\d+)\u0000/g, (_, k: string) => held[Number(k)] ?? '');
45
+ }
46
+ }
47
+
48
+ const inlineWith = (t: string, image?: ImageResolver) => inline(t, image);
49
+
50
+ /** A note's Markdown as HTML blocks for the editor. */
51
+ export function mdToHtml(md: string, image?: ImageResolver): string {
52
+ const inline = (t: string) => inlineWith(t, image);
53
+ const lines = md.replaceAll('\r\n', '\n').split('\n');
54
+ const out: string[] = [];
55
+ let i = 0;
56
+ while (i < lines.length) {
57
+ const line = lines[i]!;
58
+ if (/^```/.test(line)) {
59
+ const body: string[] = [];
60
+ i++;
61
+ while (i < lines.length && !/^```/.test(lines[i]!)) body.push(lines[i++]!);
62
+ i++;
63
+ out.push(`<pre><code>${esc(body.join('\n'))}</code></pre>`);
64
+ continue;
65
+ }
66
+ const h = /^(#{1,3})\s+(.*)$/.exec(line);
67
+ if (h) {
68
+ out.push(`<h${h[1]!.length}>${inline(h[2]!)}</h${h[1]!.length}>`);
69
+ i++;
70
+ continue;
71
+ }
72
+ if (/^\s*(-{3,}|\*{3,})\s*$/.test(line)) {
73
+ out.push('<hr>');
74
+ i++;
75
+ continue;
76
+ }
77
+ if (/^\s*[-*]\s+/.test(line) || /^\s*\d+[.)]\s+/.test(line)) {
78
+ const ordered = /^\s*\d+[.)]\s+/.test(line);
79
+ const items: string[] = [];
80
+ while (i < lines.length && (ordered ? /^\s*\d+[.)]\s+/ : /^\s*[-*]\s+/).test(lines[i]!)) {
81
+ items.push(`<li>${inline(lines[i]!.replace(ordered ? /^\s*\d+[.)]\s+/ : /^\s*[-*]\s+/, ''))}</li>`);
82
+ i++;
83
+ }
84
+ out.push(ordered ? `<ol>${items.join('')}</ol>` : `<ul>${items.join('')}</ul>`);
85
+ continue;
86
+ }
87
+ if (/^>\s?/.test(line)) {
88
+ const body: string[] = [];
89
+ while (i < lines.length && /^>\s?/.test(lines[i]!)) body.push(inline(lines[i++]!.replace(/^>\s?/, '')));
90
+ out.push(`<blockquote><p>${body.join('<br>')}</p></blockquote>`);
91
+ continue;
92
+ }
93
+ if (!line.trim()) {
94
+ i++;
95
+ continue;
96
+ }
97
+ const para: string[] = [];
98
+ while (i < lines.length && lines[i]!.trim() && !/^(#{1,3}\s|```|>|\s*[-*]\s+|\s*\d+[.)]\s+|\s*(-{3,}|\*{3,})\s*$)/.test(lines[i]!)) para.push(inline(lines[i++]!));
99
+ out.push(`<p>${para.join('<br>')}</p>`);
100
+ }
101
+ return out.join('') || '<p><br></p>';
102
+ }
103
+
104
+ /** Inline content of an element back to Markdown. */
105
+ function inlineMd(node: Node): string {
106
+ let s = '';
107
+ for (const child of node.childNodes) {
108
+ if (child.nodeType === Node.TEXT_NODE) {
109
+ s += (child.textContent ?? '').replaceAll(' ', ' ');
110
+ continue;
111
+ }
112
+ if (!(child instanceof HTMLElement)) continue;
113
+ const tag = child.tagName;
114
+ const inner = inlineMd(child);
115
+ if (tag === 'BR') s += '\n';
116
+ else if (tag === 'STRONG' || tag === 'B') s += inner.trim() ? `**${inner}**` : inner;
117
+ else if (tag === 'EM' || tag === 'I') s += inner.trim() ? `*${inner}*` : inner;
118
+ else if (tag === 'CODE') s += `\`${child.textContent ?? ''}\``;
119
+ else if (tag === 'IMG') s += child.dataset.src ? `![${child.getAttribute('alt') ?? ''}](${child.dataset.src})` : '';
120
+ else if (tag === 'A') s += safeHref(child.getAttribute('href') ?? '') ? `[${inner}](${child.getAttribute('href')})` : inner;
121
+ else s += inner;
122
+ }
123
+ return s;
124
+ }
125
+
126
+ /** The edited document back to Markdown, one block per paragraph. */
127
+ export function htmlToMd(root: HTMLElement): string {
128
+ const blocks: string[] = [];
129
+ const text = (el: Element) => inlineMd(el).replace(/\n+$/, '');
130
+ for (const child of root.childNodes) {
131
+ if (child.nodeType === Node.TEXT_NODE) {
132
+ if ((child.textContent ?? '').trim()) blocks.push(child.textContent!.trim());
133
+ continue;
134
+ }
135
+ if (!(child instanceof HTMLElement)) continue;
136
+ const tag = child.tagName;
137
+ if (/^H[1-6]$/.test(tag)) blocks.push(`${'#'.repeat(Math.min(3, Number(tag[1])))} ${text(child).replaceAll('\n', ' ')}`);
138
+ else if (tag === 'UL' || tag === 'OL') {
139
+ const items = [...child.children].filter((li) => li.tagName === 'LI');
140
+ blocks.push(items.map((li, k) => `${tag === 'OL' ? `${k + 1}.` : '-'} ${text(li).replaceAll('\n', ' ')}`).join('\n'));
141
+ } else if (tag === 'BLOCKQUOTE') blocks.push(text(child).split('\n').map((l) => `> ${l}`).join('\n'));
142
+ else if (tag === 'PRE') blocks.push(`\`\`\`\n${(child.textContent ?? '').replace(/\n$/, '')}\n\`\`\``);
143
+ else if (tag === 'HR') blocks.push('---');
144
+ else {
145
+ const t = text(child);
146
+ if (t.trim()) blocks.push(t.trim());
147
+ }
148
+ }
149
+ return `${blocks.join('\n\n')}\n`;
150
+ }