@lincyaw/workbench 0.2.0-rc.119 → 0.2.0-rc.120

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 (48) hide show
  1. package/README.md +1 -1
  2. package/package.json +4 -4
  3. package/src/StepProductionEditor.tsx +2 -2
  4. package/src/caption-timing-drafts.ts +2 -2
  5. package/src/caption-timing.ts +2 -2
  6. package/src/component-draft-actions.ts +1 -1
  7. package/src/component-properties.ts +3 -3
  8. package/src/component-property-drafts.ts +1 -1
  9. package/src/document-drafts.ts +2 -2
  10. package/src/document-editing.ts +7 -6
  11. package/src/document-editor/ComponentMaterials.tsx +2 -2
  12. package/src/document-editor/ComponentPropertiesDialog.tsx +2 -2
  13. package/src/document-editor/DocumentBlockFallback.tsx +4 -3
  14. package/src/document-editor/DocumentComments.tsx +2 -2
  15. package/src/document-editor/DocumentEditor.tsx +10 -7
  16. package/src/document-editor/DocumentStepNarration.tsx +4 -3
  17. package/src/document-editor/agent-targets.ts +2 -2
  18. package/src/document-editor/comment-drafts.ts +4 -4
  19. package/src/document-editor/comments.ts +7 -7
  20. package/src/document-editor/inline.ts +1 -0
  21. package/src/document-editor/messages.ts +2 -2
  22. package/src/document-editor/projection.ts +19 -17
  23. package/src/document-preview.ts +3 -2
  24. package/src/document-production.ts +7 -6
  25. package/src/document-return-point.ts +2 -2
  26. package/src/document-session.ts +19 -16
  27. package/src/document-timing-drafts.ts +4 -4
  28. package/src/effective-settings.ts +12 -0
  29. package/src/messages.ts +6 -0
  30. package/src/outline.ts +5 -5
  31. package/src/panels/DocumentVoiceDialog.tsx +4 -3
  32. package/src/panels/DocumentVoiceField.tsx +2 -1
  33. package/src/panels/HomePanel.tsx +1 -0
  34. package/src/panels/ProductionCaptionSize.tsx +2 -2
  35. package/src/panels/ProductionMediaClips.tsx +2 -2
  36. package/src/panels/ProductionPanel.tsx +3 -2
  37. package/src/panels/ProductionRecordingRange.tsx +3 -2
  38. package/src/panels/ProductionTranscription.tsx +4 -3
  39. package/src/panels/SourceDocumentPanel.tsx +5 -3
  40. package/src/panels/TranscriptionAdoption.tsx +2 -2
  41. package/src/panels/VoiceScopeField.tsx +2 -2
  42. package/src/panels/VoiceoverDialog.tsx +9 -8
  43. package/src/recording-adoption.ts +4 -4
  44. package/src/speech-settings-messages.ts +1 -1
  45. package/src/step-production.ts +4 -4
  46. package/src/use-recording-adoption.ts +3 -2
  47. package/src/workbench.ts +14 -6
  48. package/src/workspace-client.ts +3 -0
package/README.md CHANGED
@@ -8,7 +8,7 @@ Presmium's workbench panels in React, for teachers who know no code. The panels
8
8
 
9
9
  Under them, bound to no framework, are the client of the workspace service (`presmium serve`), the workbench's state, the mapping of an edit on the page back to the source, the preview protocol's workbench side, and the shared components of Presmium's design (`PmButton`, `PmDialog`, `PmMenu` and the others) in React. Experimental (0.x).
10
10
 
11
- Part of [Presmium](https://github.com/Lincyaw/presmium), which compiles canonical lecture.json teaching documents into web pages, slides, Jupyter notebooks and narrated playback.
11
+ Part of [Presmium](https://github.com/Lincyaw/presmium), which compiles canonical index.pmd teaching documents into web pages, slides, Jupyter notebooks and narrated playback.
12
12
 
13
13
  ## Usage
14
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lincyaw/workbench",
3
- "version": "0.2.0-rc.119",
3
+ "version": "0.2.0-rc.120",
4
4
  "description": "Presmium's workbench panels in React (the documents, a document edited on its rendered page with comments and version history) with the workspace service's client and the preview protocol's workbench side; @lincyaw/dsh places them in presmium studio (experimental)",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -55,8 +55,8 @@
55
55
  "@tiptap/pm": "3.32.0",
56
56
  "katex": "0.18.10",
57
57
  "react-resizable-panels": "4.14.5",
58
- "@lincyaw/design": "1.0.0-rc.118",
59
- "@lincyaw/kernel": "1.0.0-rc.118"
58
+ "@lincyaw/kernel": "1.0.0-rc.119",
59
+ "@lincyaw/design": "1.0.0-rc.119"
60
60
  },
61
61
  "peerDependencies": {
62
62
  "react": "^18.3.1",
@@ -67,6 +67,6 @@
67
67
  "@types/react-dom": "18.3.7",
68
68
  "react": "^18.3.1",
69
69
  "react-dom": "^18.3.1",
70
- "@lincyaw/compiler": "1.0.0-rc.118"
70
+ "@lincyaw/compiler": "1.0.0-rc.119"
71
71
  }
72
72
  }
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useRef, useState } from 'react'
2
- import type { TeachingDocument } from '@lincyaw/kernel'
2
+ import type { PresmiumDocument } from '@lincyaw/kernel'
3
3
  import { PmButton, PmField, PmInput, PmSegmented } from './components.tsx'
4
4
  import type { Locale } from './messages.ts'
5
5
  import { stepNarrationStarts, stepTimingValue } from './step-production.ts'
@@ -85,7 +85,7 @@ function DurationField({ label, value, source, locale, readOnly, draft, onDraft,
85
85
  }
86
86
 
87
87
  export interface StepProductionEditorProps {
88
- document: TeachingDocument
88
+ document: PresmiumDocument
89
89
  stepId: string
90
90
  locale: Locale
91
91
  readOnly?: boolean
@@ -1,4 +1,4 @@
1
- import type { CaptionTimingSource, TeachingDocument } from '@lincyaw/kernel'
1
+ import type { CaptionTimingSource, PresmiumDocument } from '@lincyaw/kernel'
2
2
 
3
3
  export interface CaptionTimingRow { id: string, from: number, to: number, start: string, end: string }
4
4
  export interface CaptionTimingDraft { version: string, text: string, basis: CaptionTimingSource, rows: CaptionTimingRow[] }
@@ -60,7 +60,7 @@ export class CaptionTimingDrafts {
60
60
  return true
61
61
  } catch { entry.failed = true; return false }
62
62
  }
63
- steps(scope: Scope, document: TeachingDocument): string[] { return [...this.#entry(scope).values.keys()].filter(id => Object.hasOwn(document.steps, id)) }
63
+ steps(scope: Scope, document: PresmiumDocument): string[] { return [...this.#entry(scope).values.keys()].filter(id => Object.hasOwn(document.steps, id)) }
64
64
  failed(scope: Scope): boolean { return this.#entry(scope).failed }
65
65
  set(scope: Scope, stepId: string, value: CaptionTimingDraft | undefined): void {
66
66
  const entry = this.#entry(scope)
@@ -1,9 +1,9 @@
1
1
  import { applyDocumentCaptionTiming, captionSourceFingerprint } from '@lincyaw/kernel'
2
- import type { DocumentAnswer, DocumentCaptionTimingAction, TeachingDocument } from '@lincyaw/kernel'
2
+ import type { DocumentAnswer, DocumentCaptionTimingAction, PresmiumDocument } from '@lincyaw/kernel'
3
3
 
4
4
  const same = (a: unknown, b: unknown) => JSON.stringify(a) === JSON.stringify(b)
5
5
  /** The source actor adopts only this caption slot; later native body input remains owned by the editor. */
6
- export function reconcileCaptionTiming(action: DocumentCaptionTimingAction, before: TeachingDocument, answer: DocumentAnswer, current: TeachingDocument): TeachingDocument | undefined {
6
+ export function reconcileCaptionTiming(action: DocumentCaptionTimingAction, before: PresmiumDocument, answer: DocumentAnswer, current: PresmiumDocument): PresmiumDocument | undefined {
7
7
  try {
8
8
  if (before.id !== answer.content.id || before.id !== current.id || !same(applyDocumentCaptionTiming(before, action).content, answer.content)) return
9
9
  if (!current.steps[action.stepId]) return current
@@ -6,7 +6,7 @@ import type { ComponentPropertyDraft, ComponentPropertyDrafts } from './componen
6
6
  export const sameComponentDraftReference = (a: ClientComponentDraftReference | null, b: ClientComponentDraftReference | null): boolean => a === null || b === null ? a === b
7
7
  : a.id === b.id && a.revision === b.revision && a.token === b.token && a.blockId === b.blockId && a.stepId === b.stepId
8
8
 
9
- /** Explicit form actions reuse the human bank; they never apply parameters to lecture.json. */
9
+ /** Explicit form actions reuse the human bank; they never apply parameters to index.pmd. */
10
10
  export async function mutateComponentDrafts(bank: ComponentPropertyDrafts, context: { identity: string, memberId: string, source: CanonicalSource }, action: Extract<AuthoringClientAction, { type: 'component-drafts.restore' | 'component-drafts.discard' }>, signal: AbortSignal, owned: (draft?: ComponentPropertyDraft) => void, fits: (result: AuthoringClientActionResult) => boolean): Promise<AuthoringClientActionResult> {
11
11
  const read = await bank.readForAgent(context, signal, action.draft)
12
12
  owned()
@@ -1,5 +1,5 @@
1
1
  import { applyDocumentComponentAction, createDocumentParameterChanges, effectiveComponentParameters } from '@lincyaw/kernel'
2
- import type { CanonicalSource, DocumentAnswer, DocumentComponentAction, JsonObject, TeachingDocument } from '@lincyaw/kernel'
2
+ import type { CanonicalSource, DocumentAnswer, DocumentComponentAction, JsonObject, PresmiumDocument } from '@lincyaw/kernel'
3
3
  import type { ComponentPropertyDraft } from './component-property-drafts.ts'
4
4
 
5
5
  export const sameComponentSource = (a: CanonicalSource, b: CanonicalSource) => a.documentId === b.documentId && a.version === b.version && a.fingerprint === b.fingerprint
@@ -15,7 +15,7 @@ export function componentPropertyAction(draft: ComponentPropertyDraft): Document
15
15
  }
16
16
 
17
17
  /** A checked rebase borrows the same reducer as the service, preserving unrelated current data. */
18
- export function rebaseComponentPropertyDraft(document: TeachingDocument, draft: ComponentPropertyDraft): JsonObject {
18
+ export function rebaseComponentPropertyDraft(document: PresmiumDocument, draft: ComponentPropertyDraft): JsonObject {
19
19
  const block = document.blocks[draft.target.blockId]
20
20
  if (block?.type !== 'component' || block.definitionId !== draft.definitionId) throw new Error('component-definition-changed')
21
21
  const action = componentPropertyAction(draft)
@@ -24,7 +24,7 @@ export function rebaseComponentPropertyDraft(document: TeachingDocument, draft:
24
24
  }
25
25
 
26
26
  /** An external acknowledgement owns its parameter paths, never a later body tree or sibling form. */
27
- export function reconcileComponentAction(action: DocumentComponentAction, before: TeachingDocument, answer: DocumentAnswer, current: TeachingDocument): TeachingDocument | undefined {
27
+ export function reconcileComponentAction(action: DocumentComponentAction, before: PresmiumDocument, answer: DocumentAnswer, current: PresmiumDocument): PresmiumDocument | undefined {
28
28
  try {
29
29
  if (answer.content.id !== before.id || current.id !== before.id) return
30
30
  const expected = applyDocumentComponentAction(before, action).content
@@ -43,7 +43,7 @@ function valid(value: unknown, target: ComponentPropertyTarget): value is Compon
43
43
  && typeof value.reset === 'boolean' && typeof value.composing === 'boolean' && typeof value.updatedAt === 'string' && Number.isFinite(Date.parse(value.updatedAt))
44
44
  }
45
45
 
46
- /** Unapplied form input borrows the existing strict backup actor; only lecture.json is authoring content. */
46
+ /** Unapplied form input borrows the existing strict backup actor; only index.pmd is authoring content. */
47
47
  export class ComponentPropertyDrafts {
48
48
  readonly #entries = new Map<string, Entry>()
49
49
  readonly #listeners = new Set<() => void>()
@@ -1,12 +1,12 @@
1
1
  import { isRecord, randomUUID, validateDocument } from '@lincyaw/kernel'
2
- import type { TeachingDocument } from '@lincyaw/kernel'
2
+ import type { PresmiumDocument } from '@lincyaw/kernel'
3
3
  import { DocumentDraftStore } from './document-draft-store.ts'
4
4
  import { sha256 as tokenOf } from './sha256.ts'
5
5
  import type { DraftStoreCommit, DraftStoreOperation } from './document-draft-store.ts'
6
6
 
7
7
  export interface DocumentDraftReference { id: string, revision: number, token: string }
8
8
  export interface DocumentDraft {
9
- content: TeachingDocument
9
+ content: PresmiumDocument
10
10
  baseVersion: string
11
11
  baseHash: string
12
12
  input: number
@@ -1,5 +1,5 @@
1
1
  import { duplicateDocumentPage, errorMessage, moveDocumentPage, pageDeletion, randomUUID, removeDocumentPage, renameDocumentPage } from '@lincyaw/kernel'
2
- import type { PageDeletePlan, TeachingDocument } from '@lincyaw/kernel'
2
+ import type { PageDeletePlan, PresmiumDocument } from '@lincyaw/kernel'
3
3
  import { undoDepth, redoDepth } from '@tiptap/pm/history'
4
4
  import { TextSelection } from '@tiptap/pm/state'
5
5
  import { isAgentChanging } from './workbench-state.ts'
@@ -14,6 +14,7 @@ import { nativeBlockText, nativeTextPoint, nativeTextPosition } from './document
14
14
  import type { NativeTextPoint } from './document-editor/selection.ts'
15
15
  import type { DocumentFieldBookmark, DocumentFieldRegistration, DocumentHistoryEditor } from './document-editor/focus.ts'
16
16
  import { contentText, MESSAGES } from './messages.ts'
17
+ import { effectiveOf } from './effective-settings.ts'
17
18
 
18
19
  interface EditingOptions {
19
20
  store: WorkbenchStore
@@ -35,7 +36,7 @@ export class DocumentEditing {
35
36
  #documentViewport?: { element: HTMLElement, identity: string, returnScrollTop?: number, stop(): void }
36
37
  #stopDocumentReturnScroll?: () => void
37
38
  #openingDocument?: { directory: string, scope: number, generation: number, focus?: 'body', initial?: boolean, stop(): void,
38
- basis?: { identity: string, reset: number, version?: string, content: TeachingDocument }, point?: DocumentReturnPoint, fallback?: DocumentReturnPoint }
39
+ basis?: { identity: string, reset: number, version?: string, content: PresmiumDocument }, point?: DocumentReturnPoint, fallback?: DocumentReturnPoint }
39
40
  #stopDocumentLayoutScroll?: () => void
40
41
  #activeDocumentHistory?: DocumentHistoryEditor
41
42
  #unsubscribeDocumentHistory?: () => void
@@ -58,7 +59,7 @@ export class DocumentEditing {
58
59
  || pending.field.blockId !== undefined && !authoring.content?.blocks[pending.field.blockId]
59
60
  || !authoring.content?.steps[pending.field.stepId])) this.#pendingDocumentField = undefined
60
61
  }
61
- rememberComponent(content: TeachingDocument, identity: string): void {
62
+ rememberComponent(content: PresmiumDocument, identity: string): void {
62
63
  if (this.#documentEditorBinding?.identity === identity) this.#documentEditorCommands?.rememberComponentConfiguration(content)
63
64
  }
64
65
  beforePosition(): void { this.cancelOpening(); this.#stopDocumentReturnScroll?.() }
@@ -339,7 +340,7 @@ export class DocumentEditing {
339
340
  }
340
341
  }
341
342
 
342
- async #changeDocumentPage(change: (document: TeachingDocument) => void): Promise<boolean> {
343
+ async #changeDocumentPage(change: (document: PresmiumDocument) => void): Promise<boolean> {
343
344
  const source = this.#store.state.authoring, directory = this.#store.state.document
344
345
  if (!source?.content || directory === undefined || isAgentChanging(this.#store.state)) return false
345
346
  const scope = this.#options.scope(), identity = source.identity, documentId = source.content.id
@@ -384,7 +385,7 @@ export class DocumentEditing {
384
385
  if (scope !== this.#options.scope() || identity !== this.#store.state.authoring?.identity) throw new Error('page-context-changed')
385
386
  const page = document.sections[section]
386
387
  if (!page) throw new Error('page-boundary')
387
- const copy = duplicateDocumentPage(document, section, contentText(document.metadata.lang).copyTitle(page.title), () => randomUUID())
388
+ const copy = duplicateDocumentPage(document, section, contentText(effectiveOf(document, this.#store.state.authoring?.inherited).metadata.lang).copyTitle(page.title), () => randomUUID())
388
389
  copied = copy.section
389
390
  Object.assign(document, copy.document)
390
391
  if (generation === this.#generation) this.#pendingDocumentFocus = { documentId: document.id, nodeId: `page:${copied}`, generation, afterSave: true }
@@ -431,7 +432,7 @@ export class DocumentEditing {
431
432
  || this.#store.state.isHistoryBusy || this.#store.state.isHistoryPreparing) return false
432
433
  try {
433
434
  this.#store.set({ pageEditFailure: undefined })
434
- const created = commands.insertPage(after, contentText(source.content.metadata.lang).newPage)
435
+ const created = commands.insertPage(after, contentText(effectiveOf(source.content, source.inherited).metadata.lang).newPage)
435
436
  this.#pendingDocumentField = undefined; this.#pendingDocumentSelection = undefined; this.#pendingDocumentFocus = undefined
436
437
  this.#store.set({ position: { section: created.sectionId, step: 0, trail: [], view: 'document' }, documentNavigation: { section: created.sectionId, request: randomUUID() } })
437
438
  // The default title is selected: the author's first words name the page, and Enter goes on to its body.
@@ -1,6 +1,6 @@
1
1
  import { useMemo } from 'react'
2
2
  import { applyDocumentComponentAction } from '@lincyaw/kernel'
3
- import type { TeachingDocument } from '@lincyaw/kernel'
3
+ import type { PresmiumDocument } from '@lincyaw/kernel'
4
4
  import { PmButton, PmMenu, PmSearchList } from '../components.tsx'
5
5
  import type { ComponentPropertyMessages } from '../component-property-messages.ts'
6
6
  import { componentDefinitionLabel } from './component-label.ts'
@@ -9,7 +9,7 @@ export { componentDefinitionLabel } from './component-label.ts'
9
9
 
10
10
  /** Selection is a proposal; only the caller's source-bound Apply changes a binding. */
11
11
  export function ComponentMaterials({ document, blockId, selected, onSelect, onLocate, disabled, messages: t }: {
12
- document: TeachingDocument, blockId: string, selected: string, onSelect(id: string): void,
12
+ document: PresmiumDocument, blockId: string, selected: string, onSelect(id: string): void,
13
13
  onLocate(blockId: string): void, disabled: boolean, messages: ComponentPropertyMessages,
14
14
  }) {
15
15
  const current = document.blocks[blockId]
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react'
2
2
  import { applyDocumentComponentAction, effectiveComponentParameters, isRecord, randomUUID, validateDocumentParameters } from '@lincyaw/kernel'
3
- import type { CanonicalSource, DocumentComponentAction, DocumentParameterValidation, JsonObject, TeachingDocument } from '@lincyaw/kernel'
3
+ import type { CanonicalSource, DocumentComponentAction, DocumentParameterValidation, JsonObject, PresmiumDocument } from '@lincyaw/kernel'
4
4
  import { PmButton, PmDialog, PmNotice, PmSelect } from '../components.tsx'
5
5
  import { useWorkbench, useWorkbenchState } from '../context.tsx'
6
6
  import { isAgentChanging } from '../workbench-state.ts'
@@ -13,7 +13,7 @@ import { ComponentMaterials, componentDefinitionLabel } from './ComponentMateria
13
13
 
14
14
  const subscribeEmpty = () => () => {}, snapshotEmpty = () => 0
15
15
  const targetKey = (target: ComponentPropertyTarget) => JSON.stringify([target.identity, target.memberId, target.blockId, target.stepId ?? null])
16
- function fresh(document: TeachingDocument, source: CanonicalSource, target: ComponentPropertyTarget): ComponentPropertyDraft {
16
+ function fresh(document: PresmiumDocument, source: CanonicalSource, target: ComponentPropertyTarget): ComponentPropertyDraft {
17
17
  const block = document.blocks[target.blockId]
18
18
  if (block?.type !== 'component') throw new Error('component-block-missing')
19
19
  const value = effectiveComponentParameters(document, block.id, target.stepId).parameters
@@ -1,4 +1,4 @@
1
- import type { DocumentBlock, TeachingDocument } from '@lincyaw/kernel'
1
+ import type { DocumentBlock, PresmiumDocument } from '@lincyaw/kernel'
2
2
  import type { Locale } from '../messages.ts'
3
3
  import { DOCUMENT_EDITOR_MESSAGES } from './messages.ts'
4
4
  import { BLOCK_PREVIEW_MESSAGES } from './block-preview-messages.ts'
@@ -14,9 +14,10 @@ const authorText = (value: unknown) => typeof value === 'string' && value.trim()
14
14
  * A readable source fallback while the independent component snapshot is unavailable. It names the content only by what
15
15
  * the author wrote (a title) or by its kind, never by its code (the component, file or definition names).
16
16
  */
17
- export function DocumentBlockFallback({ block, document, locale }: { block: DocumentBlock, document: TeachingDocument, locale: Locale }) {
17
+ export function DocumentBlockFallback({ block, document, locale }: { block: DocumentBlock, document: PresmiumDocument, locale: Locale }) {
18
18
  const t = DOCUMENT_EDITOR_MESSAGES[locale], p = BLOCK_PREVIEW_MESSAGES[locale]
19
- if (isDiagram(block, document)) return <PmNotice>{t.diagram(block.type === 'code' && block.title || '')}</PmNotice>
19
+ if (isDiagram(block, document.metadata.plugins)) return <PmNotice>{t.diagram(block.type === 'code' && block.title || '')}</PmNotice>
20
+ if (block.type === 'embed') return <PmNotice>{t.syncedBlock(block.source.document)}</PmNotice>
20
21
  if (block.type === 'code') return <PmNotice>{t.codeReference(block.title ?? block.origin?.anchor ?? block.language)}</PmNotice>
21
22
  if (block.type !== 'component') return null
22
23
  const definition = document.definitions[block.definitionId]
@@ -1,7 +1,7 @@
1
1
  import { createContext, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react'
2
2
  import type { FocusEvent, ReactNode } from 'react'
3
3
  import { documentAnchorOrder, isDocumentPlaceAnchor, randomUUID } from '@lincyaw/kernel'
4
- import type { DocumentPlaceAnchor, TeachingDocument } from '@lincyaw/kernel'
4
+ import type { DocumentPlaceAnchor, PresmiumDocument } from '@lincyaw/kernel'
5
5
  import { CommentEditorSubmitExtension, CommentsExtension } from '@blocknote/core/comments'
6
6
  import { components } from '@blocknote/mantine'
7
7
  import { FloatingThreadController, getReferenceText, Thread, useBlockNoteEditor, useCreateBlockNote, useEditorState, useExtension, useExtensionState, useThreads } from '@blocknote/react'
@@ -115,7 +115,7 @@ export function DocumentFloatingThreadController() {
115
115
  }} />
116
116
  }
117
117
 
118
- export function placeReference(document: TeachingDocument | undefined, anchor: DocumentPlaceAnchor, t: typeof DOCUMENT_EDITOR_MESSAGES['zh-CN']): string {
118
+ export function placeReference(document: PresmiumDocument | undefined, anchor: DocumentPlaceAnchor, t: typeof DOCUMENT_EDITOR_MESSAGES['zh-CN']): string {
119
119
  if (!document) return ''
120
120
  const block = document.blocks[anchor.blockId]
121
121
  let label: string
@@ -4,7 +4,7 @@ import type { Transaction } from '@tiptap/pm/state'
4
4
  import { TextSelection } from '@tiptap/pm/state'
5
5
  import { closeHistory } from '@tiptap/pm/history'
6
6
  import { allocateDocumentPage, randomUUID } from '@lincyaw/kernel'
7
- import type { Member, TeachingDocument } from '@lincyaw/kernel'
7
+ import type { Member, PresmiumDocument } from '@lincyaw/kernel'
8
8
  import type { Locale } from '../messages.ts'
9
9
  import { BlockNoteSurface } from './BlockNoteSurface.tsx'
10
10
  import type { CommentDrafts } from './comment-drafts.ts'
@@ -18,6 +18,7 @@ import { nativeEditingCursor, nativeTextPoint, nativeTextPosition } from './sele
18
18
  import type { NativeDocumentSelection, NativeTextPoint } from './selection.ts'
19
19
  import { documentInsertionPlace } from './insertion-place.ts'
20
20
  import type { DocumentInsertionPlace } from './insertion-place.ts'
21
+ import { effectiveOf } from '../effective-settings.ts'
21
22
 
22
23
  export interface DocumentEditingPosition {
23
24
  nativeBlockId: string
@@ -31,14 +32,16 @@ export interface DocumentAnimationRequests {
31
32
  }
32
33
  export interface DocumentEditorCommands {
33
34
  insertPage(after: string | undefined, title: string): NativePageCreation
34
- rememberComponentConfiguration(document: TeachingDocument): void
35
+ rememberComponentConfiguration(document: PresmiumDocument): void
35
36
  handleAnimationRequests(requests: DocumentAnimationRequests | undefined): void
36
37
  }
37
38
 
38
39
  export interface DocumentEditorProps {
39
40
  agentActivities?: import('@lincyaw/kernel').AgentActivity[]
40
41
  identity: string
41
- document: TeachingDocument
42
+ document: PresmiumDocument
43
+ /** What the document inherits from its ancestors: its content language and plugins when it sets none. */
44
+ inherited?: import('@lincyaw/kernel').DocumentDefaults
42
45
  version?: string
43
46
  member?: Member
44
47
  commentDrafts?: CommentDrafts
@@ -48,7 +51,7 @@ export interface DocumentEditorProps {
48
51
  acknowledged?: boolean
49
52
  getDocumentAcknowledged?(): boolean
50
53
  /** Read sibling field edits before their React render has committed. */
51
- getDocument?(): TeachingDocument | undefined
54
+ getDocument?(): PresmiumDocument | undefined
52
55
  /** Ownership of a deferred native focus notification. */
53
56
  getPositionToken?(): string
54
57
  /** Display-only URL resolution; native block URLs keep their canonical source locations. */
@@ -58,7 +61,7 @@ export interface DocumentEditorProps {
58
61
  locale: Locale
59
62
  readOnly?: boolean
60
63
  nodeViews?: DocumentNodeViews
61
- onChange(document: TeachingDocument): void
64
+ onChange(document: PresmiumDocument): void
62
65
  onSelection?(selection: NativeDocumentSelection | undefined): void
63
66
  onEditingPosition?(position: DocumentEditingPosition, editor: NativeDocumentEditor): void
64
67
  onReady?(editor: NativeDocumentEditor | undefined, commands?: DocumentEditorCommands): void
@@ -72,7 +75,7 @@ export interface DocumentEditorProps {
72
75
 
73
76
  /** A source version reset replaces the editor; its own save receipts never replace it. */
74
77
  export function DocumentEditor(props: DocumentEditorProps) {
75
- const projection = useMemo(() => createDocumentProjection(props.document), [props.identity, props.reset])
78
+ const projection = useMemo(() => createDocumentProjection(props.document, effectiveOf(props.document, props.inherited).metadata.plugins), [props.identity, props.reset])
76
79
  useEffect(() => rememberComponentConfiguration(projection, props.document), [projection, props.version])
77
80
  const comments = useMemo(() => new DocumentThreadStore(props.document, props.member, props.version, props.identity, props.commentDrafts), [props.identity, props.reset])
78
81
  useEffect(() => {
@@ -153,7 +156,7 @@ export function DocumentEditor(props: DocumentEditorProps) {
153
156
  reportPosition()
154
157
  } catch (error) { current.current.onError?.(error instanceof Error ? error : new Error(String(error))) }
155
158
  }
156
- return <BlockNoteSurface identity={props.identity} reset={props.reset} initialContent={projection.content} locale={props.locale} contentLang={props.document.metadata.lang || 'zh-CN'} readOnly={props.readOnly}
159
+ return <BlockNoteSurface identity={props.identity} reset={props.reset} initialContent={projection.content} locale={props.locale} contentLang={effectiveOf(props.document, props.inherited).metadata.lang} readOnly={props.readOnly}
157
160
  resolveAssetURL={props.resolveAssetURL} uploadImage={props.uploadImage}
158
161
  comments={comments} commentsPortal={props.commentsPortal} onCommentDraftRestore={() => current.current.onCommentDraftRestore?.()} onOpenComments={() => current.current.onOpenComments?.()} nodeViews={props.nodeViews} onComposition={props.onComposition} onSelection={props.onSelection}
159
162
  animationRequest={{
@@ -1,5 +1,5 @@
1
1
  import { useRef, useState } from 'react'
2
- import type { Narration, NarrationNode, TeachingDocument } from '@lincyaw/kernel'
2
+ import type { Narration, NarrationNode, PresmiumDocument } from '@lincyaw/kernel'
3
3
  import { randomUUID } from '@lincyaw/kernel'
4
4
  import { PmIconButton } from '../components.tsx'
5
5
  import { useWorkbench, useWorkbenchState } from '../context.tsx'
@@ -10,9 +10,10 @@ import { DOCUMENT_EDITOR_MESSAGES } from './messages.ts'
10
10
  import { narrationFieldFocus, narrationsToNative, nativeToNarrations } from './narration.ts'
11
11
  import type { NativeNarrationEditor } from './narration-schema.tsx'
12
12
  import { StepProductionEditor } from '../StepProductionEditor.tsx'
13
+ import { effectiveOf } from '../effective-settings.ts'
13
14
 
14
15
  /** Content ownership determines the page, even when the author is reading another page. */
15
- export function documentBlockSection(document: TeachingDocument, blockId: string): string | undefined {
16
+ export function documentBlockSection(document: PresmiumDocument, blockId: string): string | undefined {
16
17
  const contains = (id: string): boolean => {
17
18
  if (id === blockId) return true
18
19
  const block = document.blocks[id]
@@ -89,7 +90,7 @@ export function DocumentStepNarration({ blockId, sectionId, stepId, expanded, ad
89
90
  <NarrationField key={`narration:${source.identity}:${source.reset}:${stepId}`}
90
91
  identity={source.identity!} reset={source.reset} blockId={blockId} stepId={stepId}
91
92
  content={ids.map(id => ({ id, content: document.narrations[id]!.content }))} readOnly={readOnly} advanced={advanced} onPause={onPause} />
92
- <StepProductionEditor key={`timing:${source.identity}:${source.reset}:${stepId}`} document={document} stepId={stepId} locale={locale} readOnly={readOnly} advanced={advanced}
93
+ <StepProductionEditor key={`timing:${source.identity}:${source.reset}:${stepId}`} document={effectiveOf(document, source.inherited)} stepId={stepId} locale={locale} readOnly={readOnly} advanced={advanced}
93
94
  onPause={onPause} onInteraction={() => workbench.editing.interact()}
94
95
  onChange={patch => workbench.production.setStepTiming(stepId, patch, source.identity)}
95
96
  drafts={{ minimumHoldMs: workbench.production.timingDraft(stepId, 'minimumHoldMs', source.identity, source.reset), trailingPauseMs: workbench.production.timingDraft(stepId, 'trailingPauseMs', source.identity, source.reset) }}
@@ -1,8 +1,8 @@
1
- import type { AgentActivity, TeachingDocument } from '@lincyaw/kernel'
1
+ import type { AgentActivity, PresmiumDocument } from '@lincyaw/kernel'
2
2
  import type { DocumentProjection } from './projection.ts'
3
3
 
4
4
  /** Decorative attributes only: canonical IDs resolve through the editor's existing projection. */
5
- export function markAgentTargets(root: HTMLElement, projection: DocumentProjection, document: TeachingDocument, activities: readonly AgentActivity[]): () => void {
5
+ export function markAgentTargets(root: HTMLElement, projection: DocumentProjection, document: PresmiumDocument, activities: readonly AgentActivity[]): () => void {
6
6
  const marked = new Set<HTMLElement>()
7
7
  const mark = (element: HTMLElement | null, state: AgentActivity['state']) => {
8
8
  if (!element || marked.has(element)) return
@@ -1,5 +1,5 @@
1
1
  import { documentAnchorKey, documentCommentTargets, isDocumentPlaceAnchor, isRecord, randomUUID, validateDocument, validateDocumentCommentAnchor } from '@lincyaw/kernel'
2
- import type { DocumentComment, DocumentThread, DocumentThreadAnchor, RichTextNode, TeachingDocument } from '@lincyaw/kernel'
2
+ import type { DocumentComment, DocumentThread, DocumentThreadAnchor, RichTextNode, PresmiumDocument } from '@lincyaw/kernel'
3
3
  import { DocumentDraftStore, waitForDraft } from '../document-draft-store.ts'
4
4
  import { sha256 as tokenOf } from '../sha256.ts'
5
5
  import type { DraftStoreResult } from '../document-draft-store.ts'
@@ -8,7 +8,7 @@ export interface CommentDraftTarget { threadId: string, commentId?: string, thre
8
8
  export interface NewCommentDraftTarget { kind: 'create', intentId: string, documentId: string, anchor?: DocumentThreadAnchor, signature?: string }
9
9
  export type CommentComposerTarget = CommentDraftTarget | NewCommentDraftTarget
10
10
  export const isNewCommentDraft = (target: CommentComposerTarget): target is NewCommentDraftTarget => 'kind' in target && target.kind === 'create'
11
- export function newCommentDraftSignature(document: TeachingDocument, anchor: DocumentThreadAnchor | undefined): string | undefined {
11
+ export function newCommentDraftSignature(document: PresmiumDocument, anchor: DocumentThreadAnchor | undefined): string | undefined {
12
12
  if (!anchor) return
13
13
  try {
14
14
  validateDocumentCommentAnchor(document, anchor)
@@ -90,7 +90,7 @@ export class CommentDrafts {
90
90
  #closed = false
91
91
  #started = false
92
92
  #read = 0
93
- #document?: TeachingDocument
93
+ #document?: PresmiumDocument
94
94
  #version?: string
95
95
  #acknowledged = false
96
96
  #revision = 0
@@ -276,7 +276,7 @@ export class CommentDrafts {
276
276
  return Boolean(thread && !thread.deletedAt && thread.createdAt === (created ? record.pending.threadCreatedAt : target.threadCreatedAt)
277
277
  && (!created || documentAnchorKey(thread.anchor) === documentAnchorKey(target.anchor)) && comment && !comment.deletedAt && committedValue(comment) === record.pending.value)
278
278
  }
279
- synchronize(document: TeachingDocument, version: string | undefined, acknowledged = false): void {
279
+ synchronize(document: PresmiumDocument, version: string | undefined, acknowledged = false): void {
280
280
  this.#document = document; this.#version = version; this.#acknowledged = acknowledged
281
281
  for (const value of this.#writing.values()) if (this.#isCommitted(value.record)) void this.clearOwn(value.record)
282
282
  if (this.#started) void this.refresh()
@@ -5,7 +5,7 @@ import type { CommentData, ThreadData } from '@blocknote/core/comments'
5
5
  import { AddMarkStep, RemoveMarkStep } from '@tiptap/pm/transform'
6
6
  import { Plugin } from '@tiptap/pm/state'
7
7
  import { applyDocumentCommentAction, degradeDocumentCommentAnchor, hasRole, isDocumentPlaceAnchor, isDocumentTextAnchor, LOCAL_AUTHOR, randomUUID, validateDocumentCommentAnchor } from '@lincyaw/kernel'
8
- import type { DocumentComment, DocumentCommentAction, DocumentPlaceAnchor, DocumentThread, DocumentThreadAnchor, Member, RichTextNode, TeachingDocument } from '@lincyaw/kernel'
8
+ import type { DocumentComment, DocumentCommentAction, DocumentPlaceAnchor, DocumentThread, DocumentThreadAnchor, Member, RichTextNode, PresmiumDocument } from '@lincyaw/kernel'
9
9
  import { createRichProjection, nativeRichTextToProduct, productRichTextToNative } from './rich-text.ts'
10
10
  import type { RichProjection } from './rich-text.ts'
11
11
  import type { Transaction } from '@tiptap/pm/state'
@@ -16,7 +16,7 @@ import type { CommentComposerTarget, CommentDraftTarget, NewCommentDraftTarget }
16
16
  import { nativeProductText, nativeTextPoint, nativeTextPosition, nativeTextPositionInDocument } from './selection.ts'
17
17
 
18
18
  type NewComment = { body: unknown, metadata?: unknown }
19
- type Threads = NonNullable<TeachingDocument['comments']>
19
+ type Threads = NonNullable<PresmiumDocument['comments']>
20
20
  const date = (value: string) => new Date(value)
21
21
  const jsonObject = (value: unknown) => value && typeof value === 'object' && !Array.isArray(value) ? structuredClone(value) as DocumentThread['metadata'] : undefined
22
22
  const same = (a: unknown, b: unknown) => JSON.stringify(a) === JSON.stringify(b)
@@ -70,7 +70,7 @@ export class DocumentThreadStore extends ThreadStore {
70
70
  #threads = new Map<string, ThreadData>()
71
71
  #canonical: Threads = {}
72
72
  #version?: string
73
- #document: TeachingDocument
73
+ #document: PresmiumDocument
74
74
  #synchronizing = false
75
75
  readonly #edits = new Map<string, CommentEditing>()
76
76
  #submitting?: CommentEditing
@@ -78,13 +78,13 @@ export class DocumentThreadStore extends ThreadStore {
78
78
  readonly #rich: RichProjection = createRichProjection()
79
79
  readonly #anchors = new Map<string, DocumentThread['anchor']>()
80
80
  readonly #initialBodies = new Map<string, { body: unknown, content: RichTextNode[] }>()
81
- constructor(document: TeachingDocument, member?: Member, version?: string, identity?: string, drafts?: CommentDrafts) {
81
+ constructor(document: PresmiumDocument, member?: Member, version?: string, identity?: string, drafts?: CommentDrafts) {
82
82
  super(new DocumentThreadAuth(member)); this.member = member; this.#version = version; this.#document = document; this.#replace(document.comments ?? {})
83
83
  this.#ownsDrafts = !drafts
84
84
  if (drafts || identity && member?.id) { this.drafts = drafts ?? new CommentDrafts(identity!, member!.id) }
85
85
  }
86
86
  get version(): string | undefined { return this.#version }
87
- get document(): TeachingDocument { return this.#document }
87
+ get document(): PresmiumDocument { return this.#document }
88
88
  threadSnapshot(threadId: string): DocumentThread | undefined { return this.#canonical[threadId] }
89
89
  anchorOf(threadId: string): DocumentThreadAnchor | undefined { const anchor = this.#anchors.get(threadId); return anchor ? structuredClone(anchor) : undefined }
90
90
  placeAnchorOf(threadId: string): DocumentPlaceAnchor | undefined { const anchor = this.#anchors.get(threadId); return anchor && isDocumentPlaceAnchor(anchor) ? structuredClone(anchor) : undefined }
@@ -277,7 +277,7 @@ export class DocumentThreadStore extends ThreadStore {
277
277
  }
278
278
 
279
279
  /** Source adoption is not another native edit; preserve selected thread and unchanged comment bodies. */
280
- synchronize(document: TeachingDocument, version: string | undefined, editor: NativeDocumentEditor, transaction?: Transaction, acknowledged = false): void {
280
+ synchronize(document: PresmiumDocument, version: string | undefined, editor: NativeDocumentEditor, transaction?: Transaction, acknowledged = false): void {
281
281
  if (this.#synchronizing) return
282
282
  this.#document = document
283
283
  this.drafts?.synchronize(document, version, acknowledged)
@@ -314,7 +314,7 @@ export class DocumentThreadStore extends ThreadStore {
314
314
  transaction.setMeta('addToHistory', false)
315
315
  })
316
316
  }
317
- snapshot(editor: NativeDocumentEditor, source: TeachingDocument = this.#document): Threads {
317
+ snapshot(editor: NativeDocumentEditor, source: PresmiumDocument = this.#document): Threads {
318
318
  const positions = editor.getExtension(CommentsExtension)!.store.state.threadPositions
319
319
  const result = Object.fromEntries([...this.#threads.values()].map(thread => {
320
320
  const stored = this.#anchors.get(thread.id)
@@ -43,6 +43,7 @@ function label(node: InlineNode): string {
43
43
  if (node.type === 'math') return node.value
44
44
  if (node.type === 'break') return '\n'
45
45
  if (node.type === 'extension') return node.fallback
46
+ if (node.type === 'reference') return node.label ?? node.fallback
46
47
  return node.children.map(label).join('') || node.href
47
48
  }
48
49
 
@@ -4,8 +4,8 @@ export const IMAGE_IMPORT_MESSAGES = {
4
4
  }
5
5
 
6
6
  export const DOCUMENT_EDITOR_MESSAGES = {
7
- 'zh-CN': { colors: '颜色', textColor: '文字颜色', backgroundColor: '背景颜色', colorDefault: '默认', backgroundDefault: '无底色', colorNames: { muted: '灰色 · 次要', accent: '青色 · 强调', ok: '绿色 · 通过', warn: '橙色 · 提醒', danger: '红色 · 警示' }, backgroundNames: { muted: '灰底', accent: '青底', ok: '绿底', warn: '橙底', danger: '红底' }, formula: '公式', formulaInline: '行内公式', formulaBlock: '公式块', formulaInlineHint: '在文字中插入 LaTeX 公式', formulaBlockHint: '单独一行显示的 LaTeX 公式', openLink: '打开链接', goToSection: (title: string) => `跳到“${title}”`, mathEmpty: '插入公式', mathInvalid: '公式无法识别', mathPlaceholder: '输入 LaTeX 公式', commentRecoveryChanged: '已取消恢复草稿,当前输入已保留。', commentNewDraft: '新建批注', commentsEmpty: '还没有批注。选中正文中的文字,或在动画、图表的工具栏里选“本步批注”。', commentTargetUnavailable: '原选区已改变或不可用,草稿仍可恢复。', commentSessionOnly: '仅本次会话', commentDrafts: '批注草稿', commentChooseDraft: '请选择草稿', commentEditDraft: '编辑稿', commentReplyDraft: '回复稿', commentRecover: '恢复草稿', commentDiscard: '放弃草稿', commentBackupFailed: '最新的批注草稿只在本次会话中保留,请发布后再关闭窗口。', stepNarration: '讲稿', stepCaptions: '字幕', previousStep: '上一步', nextStep: '下一步', narrationStep: (step: number, total: number, title: string) => `第 ${step} / ${total} 步${title ? ` · ${title}` : ''}`, previewFailure: '预览失败', previewLoading: '正在更新预览…', previewPrevious: '上次已保存的预览', previewSnapshot: '文稿内预览', previewRetry: '重试', previewRefresh: '刷新', previewTitle: '内容块只读预览', comment: '新建批注', stepComment: (step: number) => `在第 ${step} 步批注`, stepCommentHint: (step: number, count: number) => count ? `第 ${step} 步 · ${count} 条未解决批注` : `在第 ${step} 步批注`, stepCommentFailed: '无法保存这条批注,请重试。', stepCommentStep: '批注位置', stepCommentWhole: '整个内容块', stepCommentOption: (step: number, title: string) => title ? `第 ${step} 步 · ${title}` : `第 ${step} 步`, placeCommentReference: (label: string, step?: number) => step ? `“${label}” · 第 ${step} 步` : `“${label}”`, block: '内容块', commentChanged: '这条批注已在别处修改。请先复制草稿,再取消以查看已保存的内容。', commentUnavailable: '无法确认这条批注的版本。请先复制草稿,再关闭并重新打开。', author: '作者', page: '新页面', document: '文稿', untitledPage: '未命名页面', opaque: '组件', animation: (title: string) => `动画:${title}`, component: (title: string) => `组件:${title}`, codeReference: (title: string) => `引用代码:${title}`, diagram: (title: string) => title ? `图表:${title}` : '图表', adapterError: '无法保存这次编辑。请保持页面打开,并查看诊断。', conflict: '文稿已在别处修改。草稿已保留,请先核对当前文稿,再重试或放弃草稿。', saveFailure: '文稿尚未确认保存,草稿已保留。请保持页面打开后重试。', restored: '已恢复尚未保存的草稿,请检查后重新保存或放弃。', loading: '正在加载文稿…', unavailable: '暂时无法加载文稿,请重试。', diagnostics: (count: number) => `${count} 项诊断`, formulaBlockAliases: '公式|数学', formulaInlineAliases: '行内公式|公式', pageAliases: '页面|章节', animateWithAI: '用 AI 插入动画…', animateWithAIHint: '告诉 AI 这里的动画要演示什么', animateWithAIAliases: '动画|场景|演示' },
8
- en: { colors: 'Colors', textColor: 'Text color', backgroundColor: 'Highlight', colorDefault: 'Default', backgroundDefault: 'No highlight', colorNames: { muted: 'Gray · subtle', accent: 'Teal · accent', ok: 'Green · success', warn: 'Amber · caution', danger: 'Red · alert' }, backgroundNames: { muted: 'Gray', accent: 'Teal', ok: 'Green', warn: 'Amber', danger: 'Red' }, formula: 'Formula', formulaInline: 'Inline Formula', formulaBlock: 'Formula Block', formulaInlineHint: 'A LaTeX formula within the text', formulaBlockHint: 'A LaTeX formula on its own line', openLink: 'Open Link', goToSection: (title: string) => `Go to “${title}”`, mathEmpty: 'Insert Formula', mathInvalid: 'Formula not recognized', mathPlaceholder: 'Enter a LaTeX formula', commentRecoveryChanged: 'Draft recovery canceled. Your current input is kept.', commentNewDraft: 'New Comment', commentsEmpty: 'No comments yet. Select text in the document, or use Comment on step in an animation or chart toolbar.', commentTargetUnavailable: 'The original selection changed or is unavailable. You can still recover your draft.', commentSessionOnly: 'This session only', commentDrafts: 'Comment drafts', commentChooseDraft: 'Choose a draft', commentEditDraft: 'Comment edit', commentReplyDraft: 'Reply', commentRecover: 'Recover Draft', commentDiscard: 'Discard Draft', commentBackupFailed: 'The latest comment draft is kept in this session only. Post it before closing this window.', stepNarration: 'Script', stepCaptions: 'Captions', previousStep: 'Previous Step', nextStep: 'Next Step', narrationStep: (step: number, total: number, title: string) => `Step ${step} / ${total}${title ? ` · ${title}` : ''}`, previewFailure: 'Preview failed', previewLoading: 'Updating preview…', previewPrevious: 'Last saved preview', previewSnapshot: 'Document preview', previewRetry: 'Retry', previewRefresh: 'Refresh', previewTitle: 'Read-only block preview', comment: 'New Comment', stepComment: (step: number) => `Comment on step ${step}`, stepCommentHint: (step: number, count: number) => count ? `Step ${step} · ${count} unresolved` : `Comment on step ${step}`, stepCommentFailed: 'Couldn’t save this comment. Try again.', stepCommentStep: 'Comment on', stepCommentWhole: 'The whole content block', stepCommentOption: (step: number, title: string) => title ? `Step ${step} · ${title}` : `Step ${step}`, placeCommentReference: (label: string, step?: number) => step ? `“${label}” · Step ${step}` : `“${label}”`, block: 'Content block', commentChanged: 'This comment changed elsewhere. Copy your draft, then cancel to view the saved comment.', commentUnavailable: 'Couldn’t confirm this comment’s version. Copy your draft before closing and reopening it.', author: 'Author', page: 'New Page', document: 'Document', untitledPage: 'Untitled page', opaque: 'Component', animation: (title: string) => `Animation: ${title}`, component: (title: string) => `Component: ${title}`, codeReference: (title: string) => `Referenced code: ${title}`, diagram: (title: string) => title ? `Diagram: ${title}` : 'Diagram', adapterError: 'Couldn’t save this edit. Keep this page open and check the diagnostics.', conflict: 'The document changed elsewhere. Your draft is kept; review the current document, then try again or discard your draft.', saveFailure: 'Couldn’t confirm the save. Your draft is kept; keep this page open and try again.', restored: 'A draft that was not saved was recovered. Review it, then save it again or discard it.', loading: 'Loading document…', unavailable: 'Couldn’t load the document. Try again.', diagnostics: (count: number) => `${count} ${count === 1 ? 'diagnostic' : 'diagnostics'}`, formulaBlockAliases: 'formula|math|equation|latex|tex', formulaInlineAliases: 'inline formula|inline math|latex|tex', pageAliases: 'page|section', animateWithAI: 'Insert Animation with AI…', animateWithAIHint: 'Tell the AI what the animation here should show', animateWithAIAliases: 'animation|animate|scene|motion' },
7
+ 'zh-CN': { colors: '颜色', textColor: '文字颜色', backgroundColor: '背景颜色', colorDefault: '默认', backgroundDefault: '无底色', colorNames: { muted: '灰色 · 次要', accent: '青色 · 强调', ok: '绿色 · 通过', warn: '橙色 · 提醒', danger: '红色 · 警示' }, backgroundNames: { muted: '灰底', accent: '青底', ok: '绿底', warn: '橙底', danger: '红底' }, formula: '公式', formulaInline: '行内公式', formulaBlock: '公式块', formulaInlineHint: '在文字中插入 LaTeX 公式', formulaBlockHint: '单独一行显示的 LaTeX 公式', openLink: '打开链接', goToSection: (title: string) => `跳到“${title}”`, mathEmpty: '插入公式', mathInvalid: '公式无法识别', mathPlaceholder: '输入 LaTeX 公式', commentRecoveryChanged: '已取消恢复草稿,当前输入已保留。', commentNewDraft: '新建批注', commentsEmpty: '还没有批注。选中正文中的文字,或在动画、图表的工具栏里选“本步批注”。', commentTargetUnavailable: '原选区已改变或不可用,草稿仍可恢复。', commentSessionOnly: '仅本次会话', commentDrafts: '批注草稿', commentChooseDraft: '请选择草稿', commentEditDraft: '编辑稿', commentReplyDraft: '回复稿', commentRecover: '恢复草稿', commentDiscard: '放弃草稿', commentBackupFailed: '最新的批注草稿只在本次会话中保留,请发布后再关闭窗口。', stepNarration: '讲稿', stepCaptions: '字幕', previousStep: '上一步', nextStep: '下一步', narrationStep: (step: number, total: number, title: string) => `第 ${step} / ${total} 步${title ? ` · ${title}` : ''}`, previewFailure: '预览失败', previewLoading: '正在更新预览…', previewPrevious: '上次已保存的预览', previewSnapshot: '文稿内预览', previewRetry: '重试', previewRefresh: '刷新', previewTitle: '内容块只读预览', comment: '新建批注', stepComment: (step: number) => `在第 ${step} 步批注`, stepCommentHint: (step: number, count: number) => count ? `第 ${step} 步 · ${count} 条未解决批注` : `在第 ${step} 步批注`, stepCommentFailed: '无法保存这条批注,请重试。', stepCommentStep: '批注位置', stepCommentWhole: '整个内容块', stepCommentOption: (step: number, title: string) => title ? `第 ${step} 步 · ${title}` : `第 ${step} 步`, placeCommentReference: (label: string, step?: number) => step ? `“${label}” · 第 ${step} 步` : `“${label}”`, block: '内容块', commentChanged: '这条批注已在别处修改。请先复制草稿,再取消以查看已保存的内容。', commentUnavailable: '无法确认这条批注的版本。请先复制草稿,再关闭并重新打开。', author: '作者', page: '新页面', document: '文稿', untitledPage: '未命名页面', opaque: '组件', animation: (title: string) => `动画:${title}`, component: (title: string) => `组件:${title}`, codeReference: (title: string) => `引用代码:${title}`, syncedBlock: (source: string) => `同步块:来自 ${source},将在后续版本中显示`, diagram: (title: string) => title ? `图表:${title}` : '图表', adapterError: '无法保存这次编辑。请保持页面打开,并查看诊断。', conflict: '文稿已在别处修改。草稿已保留,请先核对当前文稿,再重试或放弃草稿。', saveFailure: '文稿尚未确认保存,草稿已保留。请保持页面打开后重试。', restored: '已恢复尚未保存的草稿,请检查后重新保存或放弃。', loading: '正在加载文稿…', unavailable: '暂时无法加载文稿,请重试。', diagnostics: (count: number) => `${count} 项诊断`, formulaBlockAliases: '公式|数学', formulaInlineAliases: '行内公式|公式', pageAliases: '页面|章节', animateWithAI: '用 AI 插入动画…', animateWithAIHint: '告诉 AI 这里的动画要演示什么', animateWithAIAliases: '动画|场景|演示' },
8
+ en: { colors: 'Colors', textColor: 'Text color', backgroundColor: 'Highlight', colorDefault: 'Default', backgroundDefault: 'No highlight', colorNames: { muted: 'Gray · subtle', accent: 'Teal · accent', ok: 'Green · success', warn: 'Amber · caution', danger: 'Red · alert' }, backgroundNames: { muted: 'Gray', accent: 'Teal', ok: 'Green', warn: 'Amber', danger: 'Red' }, formula: 'Formula', formulaInline: 'Inline Formula', formulaBlock: 'Formula Block', formulaInlineHint: 'A LaTeX formula within the text', formulaBlockHint: 'A LaTeX formula on its own line', openLink: 'Open Link', goToSection: (title: string) => `Go to “${title}”`, mathEmpty: 'Insert Formula', mathInvalid: 'Formula not recognized', mathPlaceholder: 'Enter a LaTeX formula', commentRecoveryChanged: 'Draft recovery canceled. Your current input is kept.', commentNewDraft: 'New Comment', commentsEmpty: 'No comments yet. Select text in the document, or use Comment on step in an animation or chart toolbar.', commentTargetUnavailable: 'The original selection changed or is unavailable. You can still recover your draft.', commentSessionOnly: 'This session only', commentDrafts: 'Comment drafts', commentChooseDraft: 'Choose a draft', commentEditDraft: 'Comment edit', commentReplyDraft: 'Reply', commentRecover: 'Recover Draft', commentDiscard: 'Discard Draft', commentBackupFailed: 'The latest comment draft is kept in this session only. Post it before closing this window.', stepNarration: 'Script', stepCaptions: 'Captions', previousStep: 'Previous Step', nextStep: 'Next Step', narrationStep: (step: number, total: number, title: string) => `Step ${step} / ${total}${title ? ` · ${title}` : ''}`, previewFailure: 'Preview failed', previewLoading: 'Updating preview…', previewPrevious: 'Last saved preview', previewSnapshot: 'Document preview', previewRetry: 'Retry', previewRefresh: 'Refresh', previewTitle: 'Read-only block preview', comment: 'New Comment', stepComment: (step: number) => `Comment on step ${step}`, stepCommentHint: (step: number, count: number) => count ? `Step ${step} · ${count} unresolved` : `Comment on step ${step}`, stepCommentFailed: 'Couldn’t save this comment. Try again.', stepCommentStep: 'Comment on', stepCommentWhole: 'The whole content block', stepCommentOption: (step: number, title: string) => title ? `Step ${step} · ${title}` : `Step ${step}`, placeCommentReference: (label: string, step?: number) => step ? `“${label}” · Step ${step}` : `“${label}”`, block: 'Content block', commentChanged: 'This comment changed elsewhere. Copy your draft, then cancel to view the saved comment.', commentUnavailable: 'Couldn’t confirm this comment’s version. Copy your draft before closing and reopening it.', author: 'Author', page: 'New Page', document: 'Document', untitledPage: 'Untitled page', opaque: 'Component', animation: (title: string) => `Animation: ${title}`, component: (title: string) => `Component: ${title}`, codeReference: (title: string) => `Referenced code: ${title}`, syncedBlock: (source: string) => `Synced block from ${source}. It will be shown in a later version.`, diagram: (title: string) => title ? `Diagram: ${title}` : 'Diagram', adapterError: 'Couldn’t save this edit. Keep this page open and check the diagnostics.', conflict: 'The document changed elsewhere. Your draft is kept; review the current document, then try again or discard your draft.', saveFailure: 'Couldn’t confirm the save. Your draft is kept; keep this page open and try again.', restored: 'A draft that was not saved was recovered. Review it, then save it again or discard it.', loading: 'Loading document…', unavailable: 'Couldn’t load the document. Try again.', diagnostics: (count: number) => `${count} ${count === 1 ? 'diagnostic' : 'diagnostics'}`, formulaBlockAliases: 'formula|math|equation|latex|tex', formulaInlineAliases: 'inline formula|inline math|latex|tex', pageAliases: 'page|section', animateWithAI: 'Insert Animation with AI…', animateWithAIHint: 'Tell the AI what the animation here should show', animateWithAIAliases: 'animation|animate|scene|motion' },
9
9
  }
10
10
 
11
11
  /** Slash-menu search words (`|`-separated): an author finds an item by its name in either language, whatever the interface's. */