@open-document/core 0.9.1 → 0.10.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.
Files changed (83) hide show
  1. package/dist/{build-B0GJXy8I.js → build-DJMLK50m.js} +1 -1
  2. package/dist/{check-CuDIWsPT.js → check-CUKuufBm.js} +3 -3
  3. package/dist/cli/bin.js +10 -6
  4. package/dist/{config-CAZ7Z_va.js → config-CvzpyAUA.js} +558 -546
  5. package/dist/{context-PWAh9qbf.js → context-B4ip7SoI.js} +1 -1
  6. package/dist/{dev-CYqppXDI.js → dev-dnH7DTlD.js} +1 -1
  7. package/dist/{diagram-CCaUUnRe.js → diagram-BK4jTZr4.js} +146 -146
  8. package/dist/diff-QTo0A5Rx.js +44 -0
  9. package/dist/{export-1JtO2OMC.js → export-BrRFrexj.js} +3 -3
  10. package/dist/{import-CsrdBOZ8.js → import-C14Vn9ER.js} +2 -2
  11. package/dist/index.d.ts +53 -2
  12. package/dist/index.js +457 -18
  13. package/dist/ops/index.d.ts +72 -17
  14. package/dist/ops/index.js +3 -3
  15. package/dist/{ops-B2y9BMpk.js → ops-DKidjLXP.js} +642 -124
  16. package/dist/{preview-DW3PM-JV.js → preview-wKM4C6Uk.js} +1 -1
  17. package/dist/{sdk-BqU6mwD_.d.ts → sdk-CpDEGRIo.d.ts} +2 -0
  18. package/dist/vite/index.js +1 -1
  19. package/package.json +2 -2
  20. package/skills/doc-authoring/SKILL.md +9 -4
  21. package/skills/doc-authoring/references/pagination.md +1 -1
  22. package/skills/doc-authoring/references/tables-and-charts.md +18 -1
  23. package/src/app/components/browser/browser-ui.tsx +105 -0
  24. package/src/app/components/chart.tsx +239 -0
  25. package/src/app/components/command-palette.tsx +284 -0
  26. package/src/app/components/design-panel/design-panel.tsx +22 -20
  27. package/src/app/components/design-panel/design-provider.tsx +4 -2
  28. package/src/app/components/diagram.tsx +11 -1
  29. package/src/app/components/doc-assets.tsx +6 -5
  30. package/src/app/components/doc-search.tsx +12 -10
  31. package/src/app/components/doc-sidebar.tsx +24 -18
  32. package/src/app/components/flow-page.tsx +2 -0
  33. package/src/app/components/inspector/inspector.tsx +75 -48
  34. package/src/app/components/language-toggle.tsx +38 -0
  35. package/src/app/components/palette-items.ts +128 -0
  36. package/src/app/components/panel/edit-save-card.tsx +4 -2
  37. package/src/app/components/panel/fields.tsx +5 -2
  38. package/src/app/components/panel/save-card.tsx +18 -10
  39. package/src/app/components/sidebar/folder-item.tsx +10 -8
  40. package/src/app/components/sidebar/icon-picker.tsx +3 -1
  41. package/src/app/components/sidebar/sidebar.tsx +44 -13
  42. package/src/app/components/theme-toggle.tsx +5 -3
  43. package/src/app/components/ui/menu.tsx +5 -0
  44. package/src/app/lib/agent-bridge.ts +8 -2
  45. package/src/app/lib/chart.test.ts +108 -0
  46. package/src/app/lib/chart.ts +343 -0
  47. package/src/app/lib/doc-preview.tsx +0 -10
  48. package/src/app/lib/docs.ts +3 -0
  49. package/src/app/lib/docx/from-dom.ts +11 -11
  50. package/src/app/lib/docx/ooxml.test.ts +25 -9
  51. package/src/app/lib/docx/ooxml.ts +58 -37
  52. package/src/app/lib/export-docx.ts +13 -8
  53. package/src/app/lib/flow.ts +1 -1
  54. package/src/app/lib/i18n-ja/browser.ts +88 -0
  55. package/src/app/lib/i18n-ja/doc.ts +65 -0
  56. package/src/app/lib/i18n-ja/index.ts +5 -0
  57. package/src/app/lib/i18n-ja/panels.ts +104 -0
  58. package/src/app/lib/i18n-ko/browser.ts +87 -0
  59. package/src/app/lib/i18n-ko/doc.ts +65 -0
  60. package/src/app/lib/i18n-ko/index.ts +5 -0
  61. package/src/app/lib/i18n-ko/panels.ts +102 -0
  62. package/src/app/lib/i18n-zh-cn/browser.ts +84 -0
  63. package/src/app/lib/i18n-zh-cn/doc.ts +64 -0
  64. package/src/app/lib/i18n-zh-cn/index.ts +5 -0
  65. package/src/app/lib/i18n-zh-cn/panels.ts +98 -0
  66. package/src/app/lib/i18n-zh-tw/browser.ts +84 -0
  67. package/src/app/lib/i18n-zh-tw/doc.ts +64 -0
  68. package/src/app/lib/i18n-zh-tw/index.ts +5 -0
  69. package/src/app/lib/i18n-zh-tw/panels.ts +99 -0
  70. package/src/app/lib/i18n.test.ts +24 -0
  71. package/src/app/lib/i18n.tsx +109 -0
  72. package/src/app/lib/outline.ts +23 -0
  73. package/src/app/lib/page-range.test.ts +10 -1
  74. package/src/app/lib/page-range.ts +26 -0
  75. package/src/app/lib/sdk.ts +2 -0
  76. package/src/app/main.tsx +4 -1
  77. package/src/app/routes/assets.tsx +193 -132
  78. package/src/app/routes/doc.tsx +666 -310
  79. package/src/app/routes/home-shell.tsx +115 -88
  80. package/src/app/routes/home.tsx +200 -67
  81. package/src/app/routes/themes.tsx +42 -35
  82. package/src/app/styles.css +84 -5
  83. package/src/app/virtual.d.ts +1 -0
@@ -1,48 +1,35 @@
1
1
  import { ArrowLeft, Palette } from 'lucide-react';
2
2
  import { Link, useParams } from 'react-router-dom';
3
+ import {
4
+ CARD_GRID,
5
+ CardText,
6
+ EmptyState,
7
+ PageHeader,
8
+ useCardWidth,
9
+ } from '../components/browser/browser-ui';
3
10
  import { Markdown } from '../components/themes/markdown';
4
11
  import { ThemePreview } from '../components/themes/theme-preview';
5
12
  import { docsByTheme } from '../lib/docs';
13
+ import { useT } from '../lib/i18n';
14
+ import type { ThemeMeta } from '../lib/themes';
6
15
  import { findTheme, themes } from '../lib/themes';
7
16
 
8
- const GALLERY_WIDTH = 200;
9
17
  const DETAIL_WIDTH = 260;
10
18
 
11
19
  export function ThemesGalleryPage() {
20
+ const t = useT();
12
21
  return (
13
22
  <div>
14
- <header className="border-border border-b px-8 py-6">
15
- <h1 className="font-medium text-lg tracking-tight">Themes</h1>
16
- <p className="mt-1 text-muted-foreground text-sm">
17
- Every <code className="font-mono">.md</code> file under{' '}
18
- <code className="font-mono">themes/</code>. A theme is documentation — palette, type
19
- scale, and paste-ready components a document copies from.
20
- </p>
21
- </header>
23
+ <PageHeader title={t('Themes')} icon={Palette} count={themes.length} />
22
24
 
23
25
  {themes.length === 0 ? (
24
- <div className="px-8 py-16 text-center">
25
- <Palette className="mx-auto size-6 text-muted-foreground" />
26
- <p className="mt-3 font-medium text-sm">No themes yet</p>
27
- <p className="mt-1 text-muted-foreground text-xs">
28
- Ask your agent for the <code className="font-mono">create-theme</code> skill, or add{' '}
29
- <code className="font-mono">themes/&lt;id&gt;.md</code>.
30
- </p>
31
- </div>
26
+ <EmptyState icon={Palette} title={t('No themes yet')}>
27
+ {t('Ask your agent to create a theme from a document you like.')}
28
+ </EmptyState>
32
29
  ) : (
33
- <div className="grid gap-8 px-8 py-8 [grid-template-columns:repeat(auto-fill,minmax(200px,1fr))]">
30
+ <div className={CARD_GRID}>
34
31
  {themes.map((theme) => (
35
- <Link key={theme.id} to={`/themes/${theme.id}`} className="group flex flex-col gap-3">
36
- <div className="transition-shadow group-hover:shadow-lg">
37
- <ThemePreview theme={theme} width={GALLERY_WIDTH} />
38
- </div>
39
- <div className="min-w-0">
40
- <p className="truncate font-medium text-sm">{theme.name}</p>
41
- <p className="mt-0.5 line-clamp-2 text-muted-foreground text-xs">
42
- {theme.description || theme.id}
43
- </p>
44
- </div>
45
- </Link>
32
+ <ThemeCard key={theme.id} theme={theme} />
46
33
  ))}
47
34
  </div>
48
35
  )}
@@ -50,16 +37,36 @@ export function ThemesGalleryPage() {
50
37
  );
51
38
  }
52
39
 
40
+ function ThemeCard({ theme }: { theme: ThemeMeta }) {
41
+ const [ref, width] = useCardWidth<HTMLAnchorElement>();
42
+ return (
43
+ <Link
44
+ ref={ref}
45
+ to={`/themes/${theme.id}`}
46
+ className="group flex min-w-0 flex-col gap-2.5 rounded-md focus-visible:outline-2 focus-visible:outline-primary focus-visible:outline-offset-4"
47
+ >
48
+ <div className="w-fit rounded-md transition-shadow group-hover:shadow-lg">
49
+ <ThemePreview theme={theme} width={width} />
50
+ </div>
51
+ <CardText
52
+ title={<span className="group-hover:underline">{theme.name}</span>}
53
+ meta={theme.description || theme.id}
54
+ />
55
+ </Link>
56
+ );
57
+ }
58
+
53
59
  export function ThemeDetailPage() {
60
+ const t = useT();
54
61
  const { themeId } = useParams<{ themeId: string }>();
55
62
  const theme = findTheme(themeId);
56
63
 
57
64
  if (!theme) {
58
65
  return (
59
- <div className="px-8 py-16 text-center">
60
- <p className="font-medium text-sm">Theme “{themeId}” not found.</p>
66
+ <div className="py-16 text-center">
67
+ <p className="font-medium text-sm">{t('Theme “{id}” not found.', { id: themeId ?? '' })}</p>
61
68
  <Link to="/themes" className="mt-3 inline-block text-muted-foreground text-xs underline">
62
- Back to themes
69
+ {t('Back to themes')}
63
70
  </Link>
64
71
  </div>
65
72
  );
@@ -69,13 +76,13 @@ export function ThemeDetailPage() {
69
76
  const chips = [theme.pageSize, theme.mode].filter(Boolean);
70
77
 
71
78
  return (
72
- <div className="px-8 py-6">
79
+ <div>
73
80
  <Link
74
81
  to="/themes"
75
82
  className="inline-flex items-center gap-1.5 text-muted-foreground text-xs hover:text-foreground"
76
83
  >
77
84
  <ArrowLeft className="size-3" />
78
- Themes
85
+ {t('Themes')}
79
86
  </Link>
80
87
 
81
88
  <div className="mt-4 flex flex-wrap items-baseline gap-3">
@@ -100,7 +107,7 @@ export function ThemeDetailPage() {
100
107
 
101
108
  {usedBy.length > 0 && (
102
109
  <div className="mt-6 flex flex-wrap items-center gap-2">
103
- <span className="text-muted-foreground text-xs">Used by</span>
110
+ <span className="text-muted-foreground text-xs">{t('Used by')}</span>
104
111
  {usedBy.map((docId) => (
105
112
  <Link
106
113
  key={docId}
@@ -9,6 +9,7 @@
9
9
  --color-background: var(--background);
10
10
  --color-foreground: var(--foreground);
11
11
  --color-canvas: var(--canvas);
12
+ --color-paper: var(--paper);
12
13
  --color-muted: var(--muted);
13
14
  --color-muted-foreground: var(--muted-foreground);
14
15
  --color-accent: var(--accent);
@@ -24,6 +25,9 @@
24
25
  --background: oklch(0.99 0 0);
25
26
  --foreground: oklch(0.145 0 0);
26
27
  --canvas: oklch(0.93 0 0);
28
+ /* What prints on: white in both themes. An asset is previewed on it, since a
29
+ dark logo on the dark chrome would read as an empty tile. */
30
+ --paper: oklch(1 0 0);
27
31
  --muted: oklch(0.955 0 0);
28
32
  --muted-foreground: oklch(0.5 0 0);
29
33
  --accent: oklch(0.945 0 0);
@@ -37,6 +41,7 @@
37
41
  --background: oklch(0.16 0 0);
38
42
  --foreground: oklch(0.97 0 0);
39
43
  --canvas: oklch(0.12 0 0);
44
+ --paper: oklch(1 0 0);
40
45
  --muted: oklch(0.24 0 0);
41
46
  --muted-foreground: oklch(0.68 0 0);
42
47
  --accent: oklch(0.25 0 0);
@@ -68,6 +73,9 @@
68
73
  .od-panel-in {
69
74
  animation: od-panel-in 150ms ease-out;
70
75
  }
76
+ .od-fade-in {
77
+ animation: od-fade-in 100ms ease-out;
78
+ }
71
79
  /* The save card rises from the edge it sits on; `translate` rather than
72
80
  `transform`, which already centres it. */
73
81
  .od-card-in {
@@ -91,11 +99,65 @@
91
99
  background-color: rgb(59 130 246 / 0.3);
92
100
  color: inherit;
93
101
  }
94
- /* Preflight strips every list of its markers and indent, which suits the
95
- chrome and not the paper: a plain <ul> in a document should print as a
96
- list. Given back on the sheet and in the measuring host alike — a list
97
- measured without its indent wraps differently from the one printed — and
98
- only just outranking preflight, so a document's own list style still wins. */
102
+ /* The paper's own base.
103
+ *
104
+ * Preflight resets every element for the chrome — headings to body text,
105
+ * links to plain text, lists to bare lines, code to the viewer's own mono —
106
+ * and it reaches the sheet too, so a plain <h2> or <a> in a document printed
107
+ * as if it were a paragraph. The sheet gets a base of its own instead, drawn
108
+ * from the document's design variables (with the default design's values
109
+ * where a document sets none). It applies in the measuring host as well: a
110
+ * block measured with different margins than it prints with breaks the page
111
+ * in the wrong place. Each rule only just outranks preflight, so a
112
+ * document's inline style or its own stylesheet still wins.
113
+ */
114
+ :is([data-od-page], [data-od-measure]) {
115
+ font-family: var(
116
+ --od-font-body,
117
+ -apple-system,
118
+ BlinkMacSystemFont,
119
+ "Inter",
120
+ system-ui,
121
+ sans-serif
122
+ );
123
+ font-size: var(--od-size-body, 14px);
124
+ line-height: var(--od-leading, 1.55);
125
+ color: var(--od-text, #16181d);
126
+ }
127
+ :is([data-od-page], [data-od-measure]) :where(h1, h2, h3, h4, h5, h6) {
128
+ font-family: var(
129
+ --od-font-heading,
130
+ -apple-system,
131
+ BlinkMacSystemFont,
132
+ "Inter",
133
+ system-ui,
134
+ sans-serif
135
+ );
136
+ font-weight: 700;
137
+ line-height: 1.25;
138
+ margin: 0 0 0.5em;
139
+ }
140
+ :is([data-od-page], [data-od-measure]) :where(h1) {
141
+ font-size: var(--od-size-h1, 28px);
142
+ }
143
+ :is([data-od-page], [data-od-measure]) :where(h2) {
144
+ font-size: var(--od-size-h2, 20px);
145
+ }
146
+ :is([data-od-page], [data-od-measure]) :where(h3) {
147
+ font-size: var(--od-size-h3, 16px);
148
+ }
149
+ :is([data-od-page], [data-od-measure]) :where(h4) {
150
+ font-size: calc(var(--od-size-body, 14px) * 1.1);
151
+ }
152
+ :is([data-od-page], [data-od-measure]) :where(h5, h6) {
153
+ font-size: var(--od-size-body, 14px);
154
+ }
155
+ :is([data-od-page], [data-od-measure]) :where(p, blockquote, pre, ul, ol, dl, table) {
156
+ margin: 0 0 0.75em;
157
+ }
158
+ :is([data-od-page], [data-od-measure]) :where(li > ul, li > ol) {
159
+ margin-bottom: 0;
160
+ }
99
161
  :is([data-od-page], [data-od-measure]) :where(ul, ol) {
100
162
  padding-inline-start: 1.5em;
101
163
  }
@@ -111,6 +173,23 @@
111
173
  :is([data-od-page], [data-od-measure]) :where(ul ul ul, ol ul ul, ul ol ul) {
112
174
  list-style: square;
113
175
  }
176
+ :is([data-od-page], [data-od-measure]) :where(a) {
177
+ color: var(--od-accent, #2563eb);
178
+ text-decoration: underline;
179
+ text-underline-offset: 0.15em;
180
+ }
181
+ :is([data-od-page], [data-od-measure]) :where(blockquote) {
182
+ padding-inline-start: 1em;
183
+ border-inline-start: 3px solid var(--od-rule, #e5e7eb);
184
+ color: var(--od-muted, #6b7280);
185
+ }
186
+ :is([data-od-page], [data-od-measure]) :where(code, kbd, samp, pre) {
187
+ font-family: var(--od-font-mono, ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace);
188
+ }
189
+ :is([data-od-page], [data-od-measure]) :where(hr) {
190
+ border-top-color: var(--od-rule, #e5e7eb);
191
+ margin: 1em 0;
192
+ }
114
193
  /* A heading's space-above is what separates it from the section before it —
115
194
  but at the top of a page that space is just a dent. Strip it there so the
116
195
  first block of every flow page starts flush with the margin. */
@@ -4,6 +4,7 @@ declare module 'virtual:open-doc/docs' {
4
4
  export const docIds: string[];
5
5
  export const docCreatedAt: Record<string, number>;
6
6
  export const docThemes: Record<string, string>;
7
+ export const docTitles: Record<string, string>;
7
8
  export function loadDoc(id: string): Promise<DocModule>;
8
9
  }
9
10