Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { MarkerObject } from "@biblionexus-foundation/scripture-utilities";
import { SerializedEditorState } from "lexical";
import { typedMarkNodeName } from "shared/nodes/features/TypedMarkNode";
import { SerializedParaNode } from "shared/nodes/scripture/usj/ParaNode";
import { SerializedNoteNode } from "shared/nodes/scripture/usj/NoteNode";
import {
defaultNoteCallers,
immutableNoteCallerNodeName,
SerializedImmutableNoteCallerNode,
} from "shared-react/nodes/scripture/usj/ImmutableNoteCallerNode";
import { MarkNodeName } from "shared-react/nodes/scripture/usj/usj-node-options.model";
// Reaching inside only for tests.
// eslint-disable-next-line @nx/enforce-module-boundaries
import {
Expand Down Expand Up @@ -121,7 +121,7 @@ describe("USJ Editor Adaptor", () => {

it("should call `addMissingComments` if it's set", () => {
const mockAddMissingComments = jest.fn();
const nodeOptions = { [MarkNodeName]: { addMissingComments: mockAddMissingComments } };
const nodeOptions = { [typedMarkNodeName]: { addMissingComments: mockAddMissingComments } };
initialize(nodeOptions, console);

const serializedEditorState = serializeEditorState(usjMarks);
Expand Down
6 changes: 3 additions & 3 deletions packages/platform/src/editor/adaptors/usj-editor.adaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
COMMENT_MARK_TYPE,
SerializedTypedMarkNode,
TypedMarkNode,
typedMarkNodeName,
} from "shared/nodes/features/TypedMarkNode";
import {
SerializedUnknownNode,
Expand Down Expand Up @@ -117,7 +118,6 @@ import {
import { CallerData } from "shared-react/nodes/scripture/usj/node-react.utils";
import {
AddMissingComments,
MarkNodeName,
UsjNodeOptions,
} from "shared-react/nodes/scripture/usj/usj-node-options.model";
import { ViewOptions, getVerseNodeClass, getViewOptions } from "./view-options.utils";
Expand Down Expand Up @@ -211,8 +211,8 @@ function setNodeOptions(nodeOptions: UsjNodeOptions | undefined) {
if (nodeOptions) _nodeOptions = nodeOptions;

// Set the `addMissingComments` method.
if (nodeOptions?.[MarkNodeName]?.addMissingComments) {
addMissingComments = nodeOptions[MarkNodeName].addMissingComments;
if (nodeOptions?.[typedMarkNodeName]?.addMissingComments) {
addMissingComments = nodeOptions[typedMarkNodeName].addMissingComments;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect } from "react";
import { MarkNodeName } from "shared-react/nodes/scripture/usj/usj-node-options.model";
import { LoggerBasic } from "shared/adaptors/logger-basic.model";
import { typedMarkNodeName } from "shared/nodes/features/TypedMarkNode";
import { CommentStore, Comments } from "./commenting";
import { EditorProps } from "../../editor/Editor";

Expand Down Expand Up @@ -56,8 +56,9 @@ export default function useMissingCommentsProps<TLogger extends LoggerBasic>(
useEffect(() => {
if (!editorProps.options) editorProps.options = {};
if (!editorProps.options.nodes) editorProps.options.nodes = {};
if (!editorProps.options.nodes[MarkNodeName]) editorProps.options.nodes[MarkNodeName] = {};
editorProps.options.nodes[MarkNodeName].addMissingComments = (usjCommentIds: string[]) => {
if (!editorProps.options.nodes[typedMarkNodeName])
editorProps.options.nodes[typedMarkNodeName] = {};
editorProps.options.nodes[typedMarkNodeName].addMissingComments = (usjCommentIds: string[]) => {
addMissingComments(usjCommentIds, commentStoreRef);
};
}, [commentStoreRef, editorProps]);
Expand Down
6 changes: 3 additions & 3 deletions packages/scribe/src/adaptors/usj-editor.adaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
COMMENT_MARK_TYPE,
SerializedTypedMarkNode,
TypedMarkNode,
typedMarkNodeName,
} from "shared/nodes/features/TypedMarkNode";
import {
SerializedUnknownNode,
Expand Down Expand Up @@ -117,7 +118,6 @@ import {
import { CallerData } from "shared-react/nodes/scripture/usj/node-react.utils";
import {
AddMissingComments,
MarkNodeName,
UsjNodeOptions,
} from "shared-react/nodes/scripture/usj/usj-node-options.model";
import { ViewOptions, getVerseNodeClass, getViewOptions } from "./view-options.utils";
Expand Down Expand Up @@ -211,8 +211,8 @@ function setNodeOptions(nodeOptions: UsjNodeOptions | undefined) {
if (nodeOptions) _nodeOptions = nodeOptions;

// Set the `addMissingComments` method.
if (nodeOptions?.[MarkNodeName]?.addMissingComments) {
addMissingComments = nodeOptions[MarkNodeName].addMissingComments;
if (nodeOptions?.[typedMarkNodeName]?.addMissingComments) {
addMissingComments = nodeOptions[typedMarkNodeName].addMissingComments;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { NodeOptions } from "shared/adaptors/editor-adaptor.model";
import { typedMarkNodeName } from "shared/nodes/features/TypedMarkNode";
import { OnClick, immutableNoteCallerNodeName } from "./ImmutableNoteCallerNode";

export const MarkNodeName = "MarkNode";

export type AddMissingComments = (usjCommentIds: string[]) => void;

/** Options for each editor node. */
Expand All @@ -13,7 +12,7 @@ export interface UsjNodeOptions extends NodeOptions {
/** Click handler method. */
onClick?: OnClick;
};
[MarkNodeName]?: {
[typedMarkNodeName]?: {
/** Method to add missing comments. */
addMissingComments?: AddMissingComments;
};
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/nodes/features/TypedMarkNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export type SerializedTypedMarkNode = Spread<

/** Reserved type for CommentPlugin. */
export const COMMENT_MARK_TYPE = "comment";
export const typedMarkNodeName = "TypedMarkNode";

const reservedTypes = [COMMENT_MARK_TYPE];
const TYPED_MARK_VERSION = 1;

Expand Down