Skip to content

Commit

Permalink
add platform-scripture-editor typecheck
Browse files Browse the repository at this point in the history
- remove the patch and the type overrides when the BNF types are fixed.
  • Loading branch information
irahopkinson committed Aug 29, 2024
1 parent db902ab commit 1a314b6
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 1 deletion.
3 changes: 2 additions & 1 deletion extensions/src/platform-scripture-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
};
}
}
13 changes: 13 additions & 0 deletions patches/@biblionexus-foundation+platform-editor+0.5.3.patch
Original file line number Diff line number Diff line change
@@ -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 = {

0 comments on commit 1a314b6

Please sign in to comment.