diff --git a/extensions/src/platform-scripture-editor/package.json b/extensions/src/platform-scripture-editor/package.json index 5da426e275..8ea828042b 100644 --- a/extensions/src/platform-scripture-editor/package.json +++ b/extensions/src/platform-scripture-editor/package.json @@ -23,7 +23,8 @@ "lint:scripts": "eslint --ext .cjs,.js,.jsx,.ts,.tsx --cache .", "lint:styles": "stylelint **/*.{css,scss}", "lint-fix": "npm run lint-fix:scripts && npm run lint:styles -- --fix", - "lint-fix:scripts": "prettier --write \"**/*.{ts,tsx,js,jsx,cjs}\" && npm run lint:scripts" + "lint-fix:scripts": "prettier --write \"**/*.{ts,tsx,js,jsx,cjs}\" && npm run lint:scripts", + "typecheck": "tsc -p ./tsconfig.json" }, "browserslist": [], "peerDependencies": { diff --git a/extensions/src/platform-scripture-editor/src/types/@biblionexus-foundation__platform-editor.d.ts b/extensions/src/platform-scripture-editor/src/types/@biblionexus-foundation__platform-editor.d.ts new file mode 100644 index 0000000000..1ddea9951b --- /dev/null +++ b/extensions/src/platform-scripture-editor/src/types/@biblionexus-foundation__platform-editor.d.ts @@ -0,0 +1,65 @@ +/** + * Work-around until the `@biblionexus-foundation/platform-editor` package fully includes its types. + * Note there is also a patch that should be removed when this is fixed. + */ + +declare module 'shared-react/annotation/selection.model' { + type UsjLocation = { + jsonPath: string; + offset: number; + }; + + export type SelectionRange = { + start: UsjLocation; + end?: UsjLocation; + }; + + export type AnnotationRange = { + start: UsjLocation; + end: UsjLocation; + }; +} + +declare module 'shared-react/nodes/scripture/usj/ImmutableNoteCallerNode' { + export const immutableNoteCallerNodeName = 'ImmutableNoteCallerNode'; +} + +declare module 'shared-react/plugins/logger-basic.model' { + export type LoggerBasic = { + error(message: string): void; + warn(message: string): void; + info(message: string): void; + }; +} + +declare module 'shared-react/plugins/text-direction.model' { + /** Left-to-right or Right-to-left or Automatically determined from the content. */ + export type TextDirection = 'ltr' | 'rtl' | 'auto'; +} + +declare module 'shared-react/nodes/scripture/usj/usj-node-options.model' { + import { SyntheticEvent } from 'react'; + + /** Option properties to use with each node. */ + type NodeOptions = { [nodeClassName: string]: { [prop: string]: unknown } | undefined }; + type OnClick = (event: SyntheticEvent) => void; + const immutableNoteCallerNodeName = 'ImmutableNoteCallerNode'; + + export const MarkNodeName = 'MarkNode'; + + export type AddMissingComments = (usjCommentIds: string[]) => void; + + /** Options for each editor node. */ + export interface UsjNodeOptions extends NodeOptions { + [immutableNoteCallerNodeName]?: { + /** Possible note callers to use when caller is '+'. */ + noteCallers?: string[]; + /** Click handler method. */ + onClick?: OnClick; + }; + [MarkNodeName]?: { + /** Method to add missing comments. */ + addMissingComments?: AddMissingComments; + }; + } +} diff --git a/patches/@biblionexus-foundation+platform-editor+0.5.3.patch b/patches/@biblionexus-foundation+platform-editor+0.5.3.patch new file mode 100644 index 0000000000..2b246d9af7 --- /dev/null +++ b/patches/@biblionexus-foundation+platform-editor+0.5.3.patch @@ -0,0 +1,13 @@ +diff --git a/node_modules/@biblionexus-foundation/platform-editor/dist/index.d.ts b/node_modules/@biblionexus-foundation/platform-editor/dist/index.d.ts +index 81f96c0..27838a0 100644 +--- a/node_modules/@biblionexus-foundation/platform-editor/dist/index.d.ts ++++ b/node_modules/@biblionexus-foundation/platform-editor/dist/index.d.ts +@@ -5,7 +5,7 @@ import { LoggerBasic } from 'shared-react/plugins/logger-basic.model'; + import { ScriptureReference } from 'platform-bible-utils'; + import { SelectionRange } from 'shared-react/annotation/selection.model'; + import { TextDirection } from 'shared-react/plugins/text-direction.model'; +-import { Usj } from '../../../utilities/src'; ++import { Usj } from '@biblionexus-foundation/scripture-utilities'; + import { UsjNodeOptions } from 'shared-react/nodes/scripture/usj/usj-node-options.model'; + + declare type Comment_2 = {