@eightyfourthousand/lib-editing 2026.3.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.
- package/.babelrc +12 -0
- package/.eslintrc.json +18 -0
- package/README.md +7 -0
- package/jest.config.ts +10 -0
- package/package.json +35 -0
- package/postcss.config.mjs +9 -0
- package/project.json +29 -0
- package/src/fixtures/basic/json.ts +396 -0
- package/src/fixtures/toh251/json.ts +4913 -0
- package/src/fixtures/toh251/passages.ts +2814 -0
- package/src/fixtures/types.ts +8 -0
- package/src/index.ts +4 -0
- package/src/lib/block.ts +226 -0
- package/src/lib/components/editor/BlockEditor.tsx +38 -0
- package/src/lib/components/editor/EditorBackMatterPage.tsx +95 -0
- package/src/lib/components/editor/EditorBodyPage.tsx +87 -0
- package/src/lib/components/editor/EditorHeader.tsx +22 -0
- package/src/lib/components/editor/EditorLayout.tsx +62 -0
- package/src/lib/components/editor/EditorLeftPanelPage.tsx +27 -0
- package/src/lib/components/editor/EditorProvider.tsx +399 -0
- package/src/lib/components/editor/PaginationProvider.tsx +472 -0
- package/src/lib/components/editor/TitlesBuilder.tsx +40 -0
- package/src/lib/components/editor/TranslationBuilder.tsx +171 -0
- package/src/lib/components/editor/TranslationEditor.tsx +32 -0
- package/src/lib/components/editor/extensions/Abbreviation/Abbreviation.ts +133 -0
- package/src/lib/components/editor/extensions/Audio/Audio.ts +69 -0
- package/src/lib/components/editor/extensions/Bold.ts +43 -0
- package/src/lib/components/editor/extensions/Document.ts +8 -0
- package/src/lib/components/editor/extensions/DragHandle/DragHandle.ts +429 -0
- package/src/lib/components/editor/extensions/EndNoteLink/EndNoteLink.tsx +39 -0
- package/src/lib/components/editor/extensions/EndNoteLink/EndNoteLinkHoverContent.tsx +139 -0
- package/src/lib/components/editor/extensions/EndNoteLink/EndNoteLinkMark.ts +236 -0
- package/src/lib/components/editor/extensions/EndNoteLink/endnote-utils.ts +412 -0
- package/src/lib/components/editor/extensions/GlobalConfig.ts +52 -0
- package/src/lib/components/editor/extensions/GlossaryInstance/GlossaryInput.tsx +54 -0
- package/src/lib/components/editor/extensions/GlossaryInstance/GlossaryInstance.tsx +129 -0
- package/src/lib/components/editor/extensions/GlossaryInstance/GlossaryInstanceNode.ts +148 -0
- package/src/lib/components/editor/extensions/Heading/Heading.ts +71 -0
- package/src/lib/components/editor/extensions/HoverInputField.tsx +54 -0
- package/src/lib/components/editor/extensions/Image.ts +18 -0
- package/src/lib/components/editor/extensions/Indent.ts +103 -0
- package/src/lib/components/editor/extensions/InternalLink/InternalLink.ts +173 -0
- package/src/lib/components/editor/extensions/InternalLink/InternalLinkHoverContent.tsx +137 -0
- package/src/lib/components/editor/extensions/InternalLink/InternalLinkInput.tsx +71 -0
- package/src/lib/components/editor/extensions/InternalLink/index.ts +1 -0
- package/src/lib/components/editor/extensions/Italic.ts +50 -0
- package/src/lib/components/editor/extensions/LeadingSpace.ts +106 -0
- package/src/lib/components/editor/extensions/Line/LineNode.ts +41 -0
- package/src/lib/components/editor/extensions/LineGroup/LineGroupNode.ts +124 -0
- package/src/lib/components/editor/extensions/Link/Link.ts +65 -0
- package/src/lib/components/editor/extensions/Link/LinkHoverContent.tsx +124 -0
- package/src/lib/components/editor/extensions/Link/index.ts +1 -0
- package/src/lib/components/editor/extensions/List.ts +74 -0
- package/src/lib/components/editor/extensions/Mantra/Mantra.ts +88 -0
- package/src/lib/components/editor/extensions/Mention/Mention.ts +184 -0
- package/src/lib/components/editor/extensions/Mention/MentionHoverContent.tsx +158 -0
- package/src/lib/components/editor/extensions/NodeWrapper.tsx +57 -0
- package/src/lib/components/editor/extensions/Paragraph/Paragraph.ts +25 -0
- package/src/lib/components/editor/extensions/ParagraphIndent.ts +87 -0
- package/src/lib/components/editor/extensions/Passage/EditLabel.tsx +57 -0
- package/src/lib/components/editor/extensions/Passage/EditorOptions.tsx +29 -0
- package/src/lib/components/editor/extensions/Passage/Passage.tsx +238 -0
- package/src/lib/components/editor/extensions/Passage/PassageNode.ts +223 -0
- package/src/lib/components/editor/extensions/Passage/ReaderOptions.tsx +55 -0
- package/src/lib/components/editor/extensions/Passage/ShowAnnotations.tsx +92 -0
- package/src/lib/components/editor/extensions/Passage/index.ts +1 -0
- package/src/lib/components/editor/extensions/Passage/label.spec.ts +118 -0
- package/src/lib/components/editor/extensions/Passage/label.ts +39 -0
- package/src/lib/components/editor/extensions/Placeholder.ts +9 -0
- package/src/lib/components/editor/extensions/SlashCommand/SlashCommand.ts +65 -0
- package/src/lib/components/editor/extensions/SlashCommand/SuggestionList.tsx +109 -0
- package/src/lib/components/editor/extensions/SlashCommand/Suggestions.ts +185 -0
- package/src/lib/components/editor/extensions/SmallCaps.ts +110 -0
- package/src/lib/components/editor/extensions/StarterKit.ts +36 -0
- package/src/lib/components/editor/extensions/Subscript.ts +43 -0
- package/src/lib/components/editor/extensions/Superscript.ts +43 -0
- package/src/lib/components/editor/extensions/Table.ts +32 -0
- package/src/lib/components/editor/extensions/TextAlign.ts +5 -0
- package/src/lib/components/editor/extensions/TitleMetadata.ts +40 -0
- package/src/lib/components/editor/extensions/TitleNode.ts +133 -0
- package/src/lib/components/editor/extensions/TitlesNode.ts +102 -0
- package/src/lib/components/editor/extensions/Trailer.ts +57 -0
- package/src/lib/components/editor/extensions/TranslationDocument.ts +7 -0
- package/src/lib/components/editor/extensions/TranslationMetadata.ts +58 -0
- package/src/lib/components/editor/extensions/Underline.ts +43 -0
- package/src/lib/components/editor/hooks/index.ts +4 -0
- package/src/lib/components/editor/hooks/useBlockEditor.ts +53 -0
- package/src/lib/components/editor/hooks/useDefaultExtensions.ts +39 -0
- package/src/lib/components/editor/hooks/useDirtyStore.ts +33 -0
- package/src/lib/components/editor/hooks/useTranslationExtensions.ts +148 -0
- package/src/lib/components/editor/index.ts +10 -0
- package/src/lib/components/editor/menus/EmptyBubbleMenu.tsx +42 -0
- package/src/lib/components/editor/menus/MainBubbleMenu.tsx +51 -0
- package/src/lib/components/editor/menus/TranslationBubbleMenu.tsx +57 -0
- package/src/lib/components/editor/menus/index.ts +3 -0
- package/src/lib/components/editor/menus/selectors/EndNoteSelector.tsx +388 -0
- package/src/lib/components/editor/menus/selectors/GlossarySelector.tsx +63 -0
- package/src/lib/components/editor/menus/selectors/LinkSelector.tsx +68 -0
- package/src/lib/components/editor/menus/selectors/MantraSelector.tsx +119 -0
- package/src/lib/components/editor/menus/selectors/NodeSelector.tsx +144 -0
- package/src/lib/components/editor/menus/selectors/ParagraphButtons.tsx +68 -0
- package/src/lib/components/editor/menus/selectors/SelectorInputField.tsx +68 -0
- package/src/lib/components/editor/menus/selectors/TextAlignSelector.tsx +89 -0
- package/src/lib/components/editor/menus/selectors/TextButtons.tsx +89 -0
- package/src/lib/components/editor/menus/selectors/TranslationNodeSelector.tsx +143 -0
- package/src/lib/components/editor/menus/selectors/TranslationTextButtons.tsx +125 -0
- package/src/lib/components/editor/menus/selectors/index.ts +5 -0
- package/src/lib/components/editor/save-filter.spec.ts +94 -0
- package/src/lib/components/editor/save-filter.ts +27 -0
- package/src/lib/components/editor/util.ts +304 -0
- package/src/lib/components/index.ts +3 -0
- package/src/lib/components/reader/ReaderBackMatterPage.tsx +62 -0
- package/src/lib/components/reader/ReaderBackMatterPanel.tsx +53 -0
- package/src/lib/components/reader/ReaderBodyPage.tsx +46 -0
- package/src/lib/components/reader/ReaderBodyPanel.tsx +68 -0
- package/src/lib/components/reader/ReaderLayout.tsx +39 -0
- package/src/lib/components/reader/ReaderLeftPanel.tsx +8 -0
- package/src/lib/components/reader/ReaderLeftPanelPage.tsx +31 -0
- package/src/lib/components/reader/TranslationReader.tsx +28 -0
- package/src/lib/components/reader/index.ts +2 -0
- package/src/lib/components/reader/ssr.ts +3 -0
- package/src/lib/components/shared/AiSummarizerPage.tsx +12 -0
- package/src/lib/components/shared/BackMatterPanel.tsx +143 -0
- package/src/lib/components/shared/BodyPanel.tsx +214 -0
- package/src/lib/components/shared/HoverCardProvider.tsx +407 -0
- package/src/lib/components/shared/Imprint.tsx +24 -0
- package/src/lib/components/shared/LabeledElement.tsx +133 -0
- package/src/lib/components/shared/LeftPanel.tsx +65 -0
- package/src/lib/components/shared/NavigationContext.ts +64 -0
- package/src/lib/components/shared/NavigationProvider.tsx +368 -0
- package/src/lib/components/shared/OpenGraphImage.tsx +75 -0
- package/src/lib/components/shared/PassageSkeleton.tsx +10 -0
- package/src/lib/components/shared/RestrictionWarning.tsx +177 -0
- package/src/lib/components/shared/SourceReader.tsx +83 -0
- package/src/lib/components/shared/SuggestRevisionForm.tsx +99 -0
- package/src/lib/components/shared/TableOfContents.tsx +280 -0
- package/src/lib/components/shared/ThreeColumnRenderer.tsx +54 -0
- package/src/lib/components/shared/TranslationHeader.tsx +86 -0
- package/src/lib/components/shared/TranslationHoverCard.tsx +84 -0
- package/src/lib/components/shared/TranslationSkeleton.tsx +16 -0
- package/src/lib/components/shared/TranslationTable.tsx +155 -0
- package/src/lib/components/shared/bibliography/BibliographyBody.tsx +28 -0
- package/src/lib/components/shared/bibliography/BibliographyList.tsx +63 -0
- package/src/lib/components/shared/bibliography/index.ts +1 -0
- package/src/lib/components/shared/generate-metadata.ts +44 -0
- package/src/lib/components/shared/glossary/GlossaryInstanceBody.tsx +144 -0
- package/src/lib/components/shared/glossary/GlossaryPaginationProvider.tsx +317 -0
- package/src/lib/components/shared/glossary/GlossarySkeleton.tsx +19 -0
- package/src/lib/components/shared/glossary/GlossaryTermList.tsx +58 -0
- package/src/lib/components/shared/glossary/index.ts +3 -0
- package/src/lib/components/shared/hooks/useGlossaryInstanceListener.tsx +42 -0
- package/src/lib/components/shared/hooks/useScrollInTab.tsx +43 -0
- package/src/lib/components/shared/hooks/useScrollPositionRestore.ts +274 -0
- package/src/lib/components/shared/hooks/useTohToggle.tsx +52 -0
- package/src/lib/components/shared/index.ts +11 -0
- package/src/lib/components/shared/ssr.ts +2 -0
- package/src/lib/components/shared/titles/FramedCard.tsx +132 -0
- package/src/lib/components/shared/titles/LongTitle.tsx +20 -0
- package/src/lib/components/shared/titles/LongTitles.tsx +28 -0
- package/src/lib/components/shared/titles/Title.tsx +54 -0
- package/src/lib/components/shared/titles/TitleDetails.tsx +47 -0
- package/src/lib/components/shared/titles/TitleForm.tsx +37 -0
- package/src/lib/components/shared/titles/Titles.tsx +114 -0
- package/src/lib/components/shared/titles/TitlesCard.tsx +113 -0
- package/src/lib/components/shared/titles/index.ts +8 -0
- package/src/lib/components/shared/types.ts +79 -0
- package/src/lib/components/ssr.ts +2 -0
- package/src/lib/exporters/abbreviation.spec.ts +31 -0
- package/src/lib/exporters/abbreviation.ts +22 -0
- package/src/lib/exporters/annotation.ts +193 -0
- package/src/lib/exporters/audio.spec.ts +77 -0
- package/src/lib/exporters/audio.ts +27 -0
- package/src/lib/exporters/blockquote.spec.ts +48 -0
- package/src/lib/exporters/blockquote.ts +24 -0
- package/src/lib/exporters/code.spec.ts +93 -0
- package/src/lib/exporters/code.ts +26 -0
- package/src/lib/exporters/end-note-link.spec.ts +104 -0
- package/src/lib/exporters/end-note-link.ts +35 -0
- package/src/lib/exporters/export.ts +12 -0
- package/src/lib/exporters/glossary-instance.spec.ts +85 -0
- package/src/lib/exporters/glossary-instance.ts +31 -0
- package/src/lib/exporters/has-abbreviation.spec.ts +31 -0
- package/src/lib/exporters/has-abbreviation.ts +21 -0
- package/src/lib/exporters/heading.spec.ts +80 -0
- package/src/lib/exporters/heading.ts +28 -0
- package/src/lib/exporters/image.spec.ts +48 -0
- package/src/lib/exporters/image.ts +25 -0
- package/src/lib/exporters/indent.spec.ts +58 -0
- package/src/lib/exporters/indent.ts +18 -0
- package/src/lib/exporters/index.ts +1 -0
- package/src/lib/exporters/internal-link.spec.ts +90 -0
- package/src/lib/exporters/internal-link.ts +35 -0
- package/src/lib/exporters/italic.spec.ts +84 -0
- package/src/lib/exporters/italic.ts +55 -0
- package/src/lib/exporters/leading-space.spec.ts +28 -0
- package/src/lib/exporters/leading-space.ts +16 -0
- package/src/lib/exporters/line-group.spec.ts +48 -0
- package/src/lib/exporters/line-group.ts +24 -0
- package/src/lib/exporters/line.spec.ts +48 -0
- package/src/lib/exporters/line.ts +24 -0
- package/src/lib/exporters/link.spec.ts +123 -0
- package/src/lib/exporters/link.ts +67 -0
- package/src/lib/exporters/list-item.spec.ts +48 -0
- package/src/lib/exporters/list-item.ts +24 -0
- package/src/lib/exporters/list.spec.ts +82 -0
- package/src/lib/exporters/list.ts +31 -0
- package/src/lib/exporters/mantra.spec.ts +51 -0
- package/src/lib/exporters/mantra.ts +25 -0
- package/src/lib/exporters/mention.ts +41 -0
- package/src/lib/exporters/paragraph.spec.ts +173 -0
- package/src/lib/exporters/paragraph.ts +32 -0
- package/src/lib/exporters/quote.spec.ts +56 -0
- package/src/lib/exporters/quote.ts +25 -0
- package/src/lib/exporters/span.spec.ts +118 -0
- package/src/lib/exporters/span.ts +44 -0
- package/src/lib/exporters/table-body-data.spec.ts +48 -0
- package/src/lib/exporters/table-body-data.ts +24 -0
- package/src/lib/exporters/table-body-header.spec.ts +48 -0
- package/src/lib/exporters/table-body-header.ts +24 -0
- package/src/lib/exporters/table-body-row.spec.ts +48 -0
- package/src/lib/exporters/table-body-row.ts +24 -0
- package/src/lib/exporters/table.spec.ts +48 -0
- package/src/lib/exporters/table.ts +24 -0
- package/src/lib/exporters/trailer.spec.ts +48 -0
- package/src/lib/exporters/trailer.ts +24 -0
- package/src/lib/exporters/util.ts +62 -0
- package/src/lib/passage.ts +182 -0
- package/src/lib/titles.ts +80 -0
- package/src/lib/transformers/abbreviation.spec.ts +87 -0
- package/src/lib/transformers/abbreviation.ts +30 -0
- package/src/lib/transformers/annotate.ts +146 -0
- package/src/lib/transformers/audio.spec.ts +55 -0
- package/src/lib/transformers/audio.ts +29 -0
- package/src/lib/transformers/blockquote.spec.ts +48 -0
- package/src/lib/transformers/blockquote.ts +41 -0
- package/src/lib/transformers/code.spec.ts +52 -0
- package/src/lib/transformers/code.ts +22 -0
- package/src/lib/transformers/deprecated.ts +7 -0
- package/src/lib/transformers/end-note-link.spec.ts +56 -0
- package/src/lib/transformers/end-note-link.ts +76 -0
- package/src/lib/transformers/glossary-instance.spec.ts +55 -0
- package/src/lib/transformers/glossary-instance.ts +40 -0
- package/src/lib/transformers/has-abbreviation.spec.ts +50 -0
- package/src/lib/transformers/has-abbreviation.ts +30 -0
- package/src/lib/transformers/heading.spec.ts +62 -0
- package/src/lib/transformers/heading.ts +30 -0
- package/src/lib/transformers/image.spec.ts +51 -0
- package/src/lib/transformers/image.ts +28 -0
- package/src/lib/transformers/indent.spec.ts +53 -0
- package/src/lib/transformers/indent.ts +17 -0
- package/src/lib/transformers/index.ts +33 -0
- package/src/lib/transformers/inline-title.spec.ts +59 -0
- package/src/lib/transformers/inline-title.ts +34 -0
- package/src/lib/transformers/internal-link.spec.ts +67 -0
- package/src/lib/transformers/internal-link.ts +65 -0
- package/src/lib/transformers/italic.ts +22 -0
- package/src/lib/transformers/leading-space.spec.ts +55 -0
- package/src/lib/transformers/leading-space.ts +17 -0
- package/src/lib/transformers/line-group.spec.ts +48 -0
- package/src/lib/transformers/line-group.ts +37 -0
- package/src/lib/transformers/line.spec.ts +54 -0
- package/src/lib/transformers/line.ts +27 -0
- package/src/lib/transformers/link.spec.ts +61 -0
- package/src/lib/transformers/link.ts +27 -0
- package/src/lib/transformers/list-item.spec.ts +48 -0
- package/src/lib/transformers/list-item.ts +37 -0
- package/src/lib/transformers/list.spec.ts +58 -0
- package/src/lib/transformers/list.ts +42 -0
- package/src/lib/transformers/mantra.spec.ts +58 -0
- package/src/lib/transformers/mantra.ts +28 -0
- package/src/lib/transformers/mention.ts +70 -0
- package/src/lib/transformers/paragraph.spec.ts +46 -0
- package/src/lib/transformers/paragraph.ts +26 -0
- package/src/lib/transformers/quote.spec.ts +42 -0
- package/src/lib/transformers/quote.ts +3 -0
- package/src/lib/transformers/quoted.ts +3 -0
- package/src/lib/transformers/recurse.ts +76 -0
- package/src/lib/transformers/reference.ts +3 -0
- package/src/lib/transformers/span.spec.ts +68 -0
- package/src/lib/transformers/span.ts +78 -0
- package/src/lib/transformers/split-at.ts +58 -0
- package/src/lib/transformers/split-block.ts +110 -0
- package/src/lib/transformers/split-content.ts +67 -0
- package/src/lib/transformers/split-insert.ts +76 -0
- package/src/lib/transformers/split-marks.ts +42 -0
- package/src/lib/transformers/split-node.ts +138 -0
- package/src/lib/transformers/table-body-data.spec.ts +44 -0
- package/src/lib/transformers/table-body-data.ts +29 -0
- package/src/lib/transformers/table-body-header.spec.ts +44 -0
- package/src/lib/transformers/table-body-header.ts +29 -0
- package/src/lib/transformers/table-body-row.spec.ts +44 -0
- package/src/lib/transformers/table-body-row.ts +29 -0
- package/src/lib/transformers/table.spec.ts +47 -0
- package/src/lib/transformers/table.ts +29 -0
- package/src/lib/transformers/trailer.spec.ts +43 -0
- package/src/lib/transformers/trailer.ts +26 -0
- package/src/lib/transformers/transformer.ts +25 -0
- package/src/lib/transformers/unknown.ts +8 -0
- package/src/lib/transformers/util.ts +20 -0
- package/src/lib/types.ts +10 -0
- package/src/ssr.ts +1 -0
- package/tsconfig.json +20 -0
- package/tsconfig.lib.json +29 -0
- package/tsconfig.spec.json +22 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Node } from '@tiptap/pm/model';
|
|
2
|
+
import { indent } from './indent';
|
|
3
|
+
|
|
4
|
+
describe('indent exporter', () => {
|
|
5
|
+
it('should export indent annotation correctly', () => {
|
|
6
|
+
const node = {
|
|
7
|
+
attrs: {
|
|
8
|
+
indentUuid: 'indent-uuid-1234',
|
|
9
|
+
},
|
|
10
|
+
textContent: 'Indented text',
|
|
11
|
+
} as unknown as Node;
|
|
12
|
+
|
|
13
|
+
const result = indent({
|
|
14
|
+
node,
|
|
15
|
+
parent: node,
|
|
16
|
+
root: node,
|
|
17
|
+
start: 0,
|
|
18
|
+
passageUuid: 'passage-uuid-1234',
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
expect(result).toEqual({
|
|
22
|
+
uuid: 'indent-uuid-1234',
|
|
23
|
+
passageUuid: 'passage-uuid-1234',
|
|
24
|
+
type: 'indent',
|
|
25
|
+
start: 0,
|
|
26
|
+
end: 13,
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('should use parent textContent when node textContent is missing', () => {
|
|
31
|
+
const parent = {
|
|
32
|
+
textContent: 'Parent text',
|
|
33
|
+
} as unknown as Node;
|
|
34
|
+
|
|
35
|
+
const node = {
|
|
36
|
+
attrs: {
|
|
37
|
+
indentUuid: 'indent-uuid-5678',
|
|
38
|
+
},
|
|
39
|
+
textContent: '',
|
|
40
|
+
} as unknown as Node;
|
|
41
|
+
|
|
42
|
+
const result = indent({
|
|
43
|
+
node,
|
|
44
|
+
parent,
|
|
45
|
+
root: parent,
|
|
46
|
+
start: 5,
|
|
47
|
+
passageUuid: 'passage-uuid-1234',
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
expect(result).toEqual({
|
|
51
|
+
uuid: 'indent-uuid-5678',
|
|
52
|
+
passageUuid: 'passage-uuid-1234',
|
|
53
|
+
type: 'indent',
|
|
54
|
+
start: 5,
|
|
55
|
+
end: 16,
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IndentAnnotation } from '@eightyfourthousand/data-access';
|
|
2
|
+
import { Exporter } from './export';
|
|
3
|
+
|
|
4
|
+
export const indent: Exporter<IndentAnnotation> = ({
|
|
5
|
+
node,
|
|
6
|
+
parent,
|
|
7
|
+
start,
|
|
8
|
+
passageUuid,
|
|
9
|
+
}): IndentAnnotation => {
|
|
10
|
+
const textContent = node.textContent || parent.textContent || '';
|
|
11
|
+
return {
|
|
12
|
+
uuid: node.attrs.indentUuid,
|
|
13
|
+
type: 'indent',
|
|
14
|
+
passageUuid,
|
|
15
|
+
start,
|
|
16
|
+
end: start + textContent.length,
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './annotation';
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { Node, Mark } from '@tiptap/pm/model';
|
|
2
|
+
import { internalLink } from './internal-link';
|
|
3
|
+
|
|
4
|
+
describe('internalLink exporter', () => {
|
|
5
|
+
it('should export internalLink annotation correctly', () => {
|
|
6
|
+
const node = {
|
|
7
|
+
textContent: 'internal link',
|
|
8
|
+
} as unknown as Node;
|
|
9
|
+
|
|
10
|
+
const mark = {
|
|
11
|
+
attrs: {
|
|
12
|
+
uuid: 'internal-link-uuid-1234',
|
|
13
|
+
type: 'passage',
|
|
14
|
+
entity: 'entity-uuid-5678',
|
|
15
|
+
href: '/passage/entity-uuid-5678',
|
|
16
|
+
isPending: false,
|
|
17
|
+
},
|
|
18
|
+
} as unknown as Mark;
|
|
19
|
+
|
|
20
|
+
const result = internalLink({
|
|
21
|
+
node,
|
|
22
|
+
mark,
|
|
23
|
+
parent: node,
|
|
24
|
+
root: node,
|
|
25
|
+
start: 0,
|
|
26
|
+
passageUuid: 'passage-uuid-1234',
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
expect(result).toEqual({
|
|
30
|
+
uuid: 'internal-link-uuid-1234',
|
|
31
|
+
passageUuid: 'passage-uuid-1234',
|
|
32
|
+
type: 'internalLink',
|
|
33
|
+
linkType: 'passage',
|
|
34
|
+
entity: 'entity-uuid-5678',
|
|
35
|
+
href: '/passage/entity-uuid-5678',
|
|
36
|
+
isPending: false,
|
|
37
|
+
start: 0,
|
|
38
|
+
end: 13,
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('should return undefined when textContent is missing', () => {
|
|
43
|
+
const node = {
|
|
44
|
+
textContent: '',
|
|
45
|
+
} as unknown as Node;
|
|
46
|
+
|
|
47
|
+
const mark = {
|
|
48
|
+
attrs: {
|
|
49
|
+
uuid: 'internal-link-uuid-empty',
|
|
50
|
+
type: 'passage',
|
|
51
|
+
entity: 'entity-uuid-5678',
|
|
52
|
+
},
|
|
53
|
+
} as unknown as Mark;
|
|
54
|
+
|
|
55
|
+
const result = internalLink({
|
|
56
|
+
node,
|
|
57
|
+
mark,
|
|
58
|
+
parent: node,
|
|
59
|
+
root: node,
|
|
60
|
+
start: 0,
|
|
61
|
+
passageUuid: 'passage-uuid-1234',
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
expect(result).toBeUndefined();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('should return undefined when entity is missing', () => {
|
|
68
|
+
const node = {
|
|
69
|
+
textContent: 'internal link',
|
|
70
|
+
} as unknown as Node;
|
|
71
|
+
|
|
72
|
+
const mark = {
|
|
73
|
+
attrs: {
|
|
74
|
+
uuid: 'internal-link-uuid-noentity',
|
|
75
|
+
type: 'passage',
|
|
76
|
+
},
|
|
77
|
+
} as unknown as Mark;
|
|
78
|
+
|
|
79
|
+
const result = internalLink({
|
|
80
|
+
node,
|
|
81
|
+
mark,
|
|
82
|
+
parent: node,
|
|
83
|
+
root: node,
|
|
84
|
+
start: 0,
|
|
85
|
+
passageUuid: 'passage-uuid-1234',
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
expect(result).toBeUndefined();
|
|
89
|
+
});
|
|
90
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { InternalLinkAnnotation } from '@eightyfourthousand/data-access';
|
|
2
|
+
import { Exporter } from './export';
|
|
3
|
+
|
|
4
|
+
export const internalLink: Exporter<InternalLinkAnnotation> = ({
|
|
5
|
+
mark,
|
|
6
|
+
node,
|
|
7
|
+
start,
|
|
8
|
+
passageUuid,
|
|
9
|
+
}): InternalLinkAnnotation | undefined => {
|
|
10
|
+
const textContent = node.textContent;
|
|
11
|
+
const linkType = mark?.attrs.type;
|
|
12
|
+
const entity = mark?.attrs.entity;
|
|
13
|
+
const uuid = mark?.attrs.uuid;
|
|
14
|
+
const href = mark?.attrs.href;
|
|
15
|
+
const isPending = mark?.attrs.isPending;
|
|
16
|
+
|
|
17
|
+
if (!textContent || !entity || !linkType || !uuid) {
|
|
18
|
+
console.warn(
|
|
19
|
+
`Internal link ${uuid} on pasage ${passageUuid} is incomplete`,
|
|
20
|
+
);
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
uuid,
|
|
26
|
+
type: 'internalLink',
|
|
27
|
+
passageUuid,
|
|
28
|
+
linkType,
|
|
29
|
+
entity,
|
|
30
|
+
href,
|
|
31
|
+
isPending,
|
|
32
|
+
start,
|
|
33
|
+
end: start + textContent.length,
|
|
34
|
+
};
|
|
35
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { Node, Mark } from '@tiptap/pm/model';
|
|
2
|
+
import { italic } from './italic';
|
|
3
|
+
|
|
4
|
+
describe('italic exporter', () => {
|
|
5
|
+
it('should export inlineTitle annotation correctly', () => {
|
|
6
|
+
const node = {
|
|
7
|
+
textContent: 'Inline Title',
|
|
8
|
+
} as unknown as Node;
|
|
9
|
+
|
|
10
|
+
const mark = {
|
|
11
|
+
attrs: {
|
|
12
|
+
uuid: 'italic-uuid-1234',
|
|
13
|
+
type: 'inlineTitle',
|
|
14
|
+
lang: 'en',
|
|
15
|
+
},
|
|
16
|
+
} as unknown as Mark;
|
|
17
|
+
|
|
18
|
+
const result = italic({
|
|
19
|
+
node,
|
|
20
|
+
mark,
|
|
21
|
+
parent: node,
|
|
22
|
+
root: node,
|
|
23
|
+
start: 0,
|
|
24
|
+
passageUuid: 'passage-uuid-1234',
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
expect(result).toEqual({
|
|
28
|
+
uuid: 'italic-uuid-1234',
|
|
29
|
+
passageUuid: 'passage-uuid-1234',
|
|
30
|
+
type: 'inlineTitle',
|
|
31
|
+
start: 0,
|
|
32
|
+
end: 12,
|
|
33
|
+
lang: 'en',
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should export span annotation with emphasis by default', () => {
|
|
38
|
+
const node = {
|
|
39
|
+
textContent: 'emphasized text',
|
|
40
|
+
} as unknown as Node;
|
|
41
|
+
|
|
42
|
+
const mark = {
|
|
43
|
+
attrs: {
|
|
44
|
+
uuid: 'italic-uuid-5678',
|
|
45
|
+
type: 'span',
|
|
46
|
+
},
|
|
47
|
+
} as unknown as Mark;
|
|
48
|
+
|
|
49
|
+
const result = italic({
|
|
50
|
+
node,
|
|
51
|
+
mark,
|
|
52
|
+
parent: node,
|
|
53
|
+
root: node,
|
|
54
|
+
start: 5,
|
|
55
|
+
passageUuid: 'passage-uuid-1234',
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
expect(result).toEqual({
|
|
59
|
+
uuid: 'italic-uuid-5678',
|
|
60
|
+
passageUuid: 'passage-uuid-1234',
|
|
61
|
+
type: 'span',
|
|
62
|
+
start: 5,
|
|
63
|
+
end: 20,
|
|
64
|
+
textStyle: 'emphasis',
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('should return undefined when mark is missing', () => {
|
|
69
|
+
const node = {
|
|
70
|
+
textContent: 'text',
|
|
71
|
+
} as unknown as Node;
|
|
72
|
+
|
|
73
|
+
const result = italic({
|
|
74
|
+
node,
|
|
75
|
+
mark: undefined,
|
|
76
|
+
parent: node,
|
|
77
|
+
root: node,
|
|
78
|
+
start: 0,
|
|
79
|
+
passageUuid: 'passage-uuid-1234',
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
expect(result).toBeUndefined();
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Exporter, ExporterContext } from './export';
|
|
2
|
+
import {
|
|
3
|
+
AnnotationType,
|
|
4
|
+
ExtendedTranslationLanguage,
|
|
5
|
+
InlineTitleAnnotation,
|
|
6
|
+
MantraAnnotation,
|
|
7
|
+
SpanAnnotation,
|
|
8
|
+
} from '@eightyfourthousand/data-access';
|
|
9
|
+
|
|
10
|
+
export const italic: Exporter<
|
|
11
|
+
InlineTitleAnnotation | MantraAnnotation | SpanAnnotation
|
|
12
|
+
> = ({
|
|
13
|
+
mark,
|
|
14
|
+
node,
|
|
15
|
+
parent,
|
|
16
|
+
start,
|
|
17
|
+
passageUuid,
|
|
18
|
+
}: ExporterContext):
|
|
19
|
+
| InlineTitleAnnotation
|
|
20
|
+
| MantraAnnotation
|
|
21
|
+
| SpanAnnotation
|
|
22
|
+
| undefined => {
|
|
23
|
+
if (!mark) {
|
|
24
|
+
console.warn('Italic exporter called without mark');
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const uuid = mark?.attrs.uuid;
|
|
29
|
+
const type = mark?.attrs.type as AnnotationType;
|
|
30
|
+
const textContent = node.textContent || parent.textContent || '';
|
|
31
|
+
const textStyle = (mark?.attrs.textStyle as string) || 'emphasis';
|
|
32
|
+
const lang = mark?.attrs.lang as ExtendedTranslationLanguage;
|
|
33
|
+
const end = start + textContent.length;
|
|
34
|
+
|
|
35
|
+
switch (type) {
|
|
36
|
+
case 'inlineTitle':
|
|
37
|
+
return {
|
|
38
|
+
uuid,
|
|
39
|
+
type: 'inlineTitle',
|
|
40
|
+
passageUuid,
|
|
41
|
+
start,
|
|
42
|
+
end,
|
|
43
|
+
lang,
|
|
44
|
+
} as InlineTitleAnnotation;
|
|
45
|
+
default:
|
|
46
|
+
return {
|
|
47
|
+
uuid,
|
|
48
|
+
type: 'span',
|
|
49
|
+
passageUuid,
|
|
50
|
+
start,
|
|
51
|
+
end,
|
|
52
|
+
textStyle,
|
|
53
|
+
} as SpanAnnotation;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Node } from '@tiptap/pm/model';
|
|
2
|
+
import { leadingSpace } from './leading-space';
|
|
3
|
+
|
|
4
|
+
describe('leadingSpace exporter', () => {
|
|
5
|
+
it('should export leadingSpace annotation correctly', () => {
|
|
6
|
+
const node = {
|
|
7
|
+
attrs: {
|
|
8
|
+
leadingSpaceUuid: 'leading-space-uuid-1234',
|
|
9
|
+
},
|
|
10
|
+
} as unknown as Node;
|
|
11
|
+
|
|
12
|
+
const result = leadingSpace({
|
|
13
|
+
node,
|
|
14
|
+
parent: node,
|
|
15
|
+
root: node,
|
|
16
|
+
start: 10,
|
|
17
|
+
passageUuid: 'passage-uuid-1234',
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
expect(result).toEqual({
|
|
21
|
+
uuid: 'leading-space-uuid-1234',
|
|
22
|
+
passageUuid: 'passage-uuid-1234',
|
|
23
|
+
type: 'leadingSpace',
|
|
24
|
+
start: 10,
|
|
25
|
+
end: 10,
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { LeadingSpaceAnnotation } from '@eightyfourthousand/data-access';
|
|
2
|
+
import { Exporter } from './export';
|
|
3
|
+
|
|
4
|
+
export const leadingSpace: Exporter<LeadingSpaceAnnotation> = ({
|
|
5
|
+
node,
|
|
6
|
+
start,
|
|
7
|
+
passageUuid,
|
|
8
|
+
}): LeadingSpaceAnnotation => {
|
|
9
|
+
return {
|
|
10
|
+
uuid: node.attrs.leadingSpaceUuid,
|
|
11
|
+
type: 'leadingSpace',
|
|
12
|
+
passageUuid,
|
|
13
|
+
start,
|
|
14
|
+
end: start,
|
|
15
|
+
};
|
|
16
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Node } from '@tiptap/pm/model';
|
|
2
|
+
import { lineGroup } from './line-group';
|
|
3
|
+
|
|
4
|
+
describe('lineGroup exporter', () => {
|
|
5
|
+
it('should export lineGroup annotation correctly', () => {
|
|
6
|
+
const node = {
|
|
7
|
+
attrs: {
|
|
8
|
+
uuid: 'linegroup-uuid-1234',
|
|
9
|
+
},
|
|
10
|
+
textContent: 'First line\nSecond line\nThird line',
|
|
11
|
+
} as unknown as Node;
|
|
12
|
+
|
|
13
|
+
const result = lineGroup({
|
|
14
|
+
node,
|
|
15
|
+
parent: node,
|
|
16
|
+
root: node,
|
|
17
|
+
start: 0,
|
|
18
|
+
passageUuid: 'passage-uuid-1234',
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
expect(result).toEqual({
|
|
22
|
+
uuid: 'linegroup-uuid-1234',
|
|
23
|
+
passageUuid: 'passage-uuid-1234',
|
|
24
|
+
type: 'lineGroup',
|
|
25
|
+
start: 0,
|
|
26
|
+
end: 33,
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('should return undefined when textContent is empty', () => {
|
|
31
|
+
const node = {
|
|
32
|
+
attrs: {
|
|
33
|
+
uuid: 'linegroup-uuid-empty',
|
|
34
|
+
},
|
|
35
|
+
textContent: '',
|
|
36
|
+
} as unknown as Node;
|
|
37
|
+
|
|
38
|
+
const result = lineGroup({
|
|
39
|
+
node,
|
|
40
|
+
parent: node,
|
|
41
|
+
root: node,
|
|
42
|
+
start: 0,
|
|
43
|
+
passageUuid: 'passage-uuid-1234',
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
expect(result).toBeUndefined();
|
|
47
|
+
});
|
|
48
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { LineGroupAnnotation } from '@eightyfourthousand/data-access';
|
|
2
|
+
import { Exporter } from './export';
|
|
3
|
+
|
|
4
|
+
export const lineGroup: Exporter<LineGroupAnnotation> = ({
|
|
5
|
+
node,
|
|
6
|
+
start,
|
|
7
|
+
passageUuid,
|
|
8
|
+
}): LineGroupAnnotation | undefined => {
|
|
9
|
+
const textContent = node.textContent || '';
|
|
10
|
+
const uuid = node.attrs.uuid;
|
|
11
|
+
|
|
12
|
+
if (!textContent) {
|
|
13
|
+
console.warn(`Line group ${uuid} is empty`);
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
uuid,
|
|
19
|
+
type: 'lineGroup',
|
|
20
|
+
passageUuid,
|
|
21
|
+
start,
|
|
22
|
+
end: start + textContent.length,
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Node } from '@tiptap/pm/model';
|
|
2
|
+
import { line } from './line';
|
|
3
|
+
|
|
4
|
+
describe('line exporter', () => {
|
|
5
|
+
it('should export line annotation correctly', () => {
|
|
6
|
+
const node = {
|
|
7
|
+
attrs: {
|
|
8
|
+
uuid: 'line-uuid-1234',
|
|
9
|
+
},
|
|
10
|
+
textContent: 'This is a line of verse.',
|
|
11
|
+
} as unknown as Node;
|
|
12
|
+
|
|
13
|
+
const result = line({
|
|
14
|
+
node,
|
|
15
|
+
parent: node,
|
|
16
|
+
root: node,
|
|
17
|
+
start: 0,
|
|
18
|
+
passageUuid: 'passage-uuid-1234',
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
expect(result).toEqual({
|
|
22
|
+
uuid: 'line-uuid-1234',
|
|
23
|
+
passageUuid: 'passage-uuid-1234',
|
|
24
|
+
type: 'line',
|
|
25
|
+
start: 0,
|
|
26
|
+
end: 24,
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('should return undefined when textContent is empty', () => {
|
|
31
|
+
const node = {
|
|
32
|
+
attrs: {
|
|
33
|
+
uuid: 'line-uuid-empty',
|
|
34
|
+
},
|
|
35
|
+
textContent: '',
|
|
36
|
+
} as unknown as Node;
|
|
37
|
+
|
|
38
|
+
const result = line({
|
|
39
|
+
node,
|
|
40
|
+
parent: node,
|
|
41
|
+
root: node,
|
|
42
|
+
start: 0,
|
|
43
|
+
passageUuid: 'passage-uuid-1234',
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
expect(result).toBeUndefined();
|
|
47
|
+
});
|
|
48
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { LineAnnotation } from '@eightyfourthousand/data-access';
|
|
2
|
+
import { Exporter } from './export';
|
|
3
|
+
|
|
4
|
+
export const line: Exporter<LineAnnotation> = ({
|
|
5
|
+
node,
|
|
6
|
+
start,
|
|
7
|
+
passageUuid,
|
|
8
|
+
}): LineAnnotation | undefined => {
|
|
9
|
+
const textContent = node.textContent || '';
|
|
10
|
+
const uuid = node.attrs.uuid;
|
|
11
|
+
|
|
12
|
+
if (!textContent) {
|
|
13
|
+
console.warn(`Line ${uuid} is empty`);
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
uuid,
|
|
19
|
+
type: 'line',
|
|
20
|
+
passageUuid,
|
|
21
|
+
start,
|
|
22
|
+
end: start + textContent.length,
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import type { Node, Mark } from '@tiptap/pm/model';
|
|
2
|
+
import { link } from './link';
|
|
3
|
+
|
|
4
|
+
describe('link exporter', () => {
|
|
5
|
+
it('should export link annotation correctly', () => {
|
|
6
|
+
const node = {
|
|
7
|
+
textContent: 'link text',
|
|
8
|
+
} as unknown as Node;
|
|
9
|
+
|
|
10
|
+
const mark = {
|
|
11
|
+
attrs: {
|
|
12
|
+
uuid: 'link-uuid-1234',
|
|
13
|
+
type: 'link',
|
|
14
|
+
href: 'https://example.com',
|
|
15
|
+
text: 'Example Link',
|
|
16
|
+
},
|
|
17
|
+
type: { name: 'link' },
|
|
18
|
+
} as unknown as Mark;
|
|
19
|
+
|
|
20
|
+
const result = link({
|
|
21
|
+
node,
|
|
22
|
+
mark,
|
|
23
|
+
parent: node,
|
|
24
|
+
root: node,
|
|
25
|
+
start: 0,
|
|
26
|
+
passageUuid: 'passage-uuid-1234',
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
expect(result).toEqual({
|
|
30
|
+
uuid: 'link-uuid-1234',
|
|
31
|
+
passageUuid: 'passage-uuid-1234',
|
|
32
|
+
type: 'link',
|
|
33
|
+
start: 0,
|
|
34
|
+
end: 9,
|
|
35
|
+
href: 'https://example.com',
|
|
36
|
+
text: 'Example Link',
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('should export reference annotation correctly', () => {
|
|
41
|
+
const node = {
|
|
42
|
+
textContent: 'reference text',
|
|
43
|
+
} as unknown as Node;
|
|
44
|
+
|
|
45
|
+
const mark = {
|
|
46
|
+
attrs: {
|
|
47
|
+
uuid: 'ref-uuid-5678',
|
|
48
|
+
type: 'reference',
|
|
49
|
+
href: '/passage/123',
|
|
50
|
+
},
|
|
51
|
+
type: { name: 'reference' },
|
|
52
|
+
} as unknown as Mark;
|
|
53
|
+
|
|
54
|
+
const result = link({
|
|
55
|
+
node,
|
|
56
|
+
mark,
|
|
57
|
+
parent: node,
|
|
58
|
+
root: node,
|
|
59
|
+
start: 5,
|
|
60
|
+
passageUuid: 'passage-uuid-1234',
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
expect(result).toEqual({
|
|
64
|
+
uuid: 'ref-uuid-5678',
|
|
65
|
+
passageUuid: 'passage-uuid-1234',
|
|
66
|
+
type: 'reference',
|
|
67
|
+
start: 5,
|
|
68
|
+
end: 19,
|
|
69
|
+
href: '/passage/123',
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('should return undefined when href is missing', () => {
|
|
74
|
+
const node = {
|
|
75
|
+
textContent: 'link text',
|
|
76
|
+
} as unknown as Node;
|
|
77
|
+
|
|
78
|
+
const mark = {
|
|
79
|
+
attrs: {
|
|
80
|
+
uuid: 'link-uuid-nohref',
|
|
81
|
+
type: 'link',
|
|
82
|
+
},
|
|
83
|
+
type: { name: 'link' },
|
|
84
|
+
} as unknown as Mark;
|
|
85
|
+
|
|
86
|
+
const result = link({
|
|
87
|
+
node,
|
|
88
|
+
mark,
|
|
89
|
+
parent: node,
|
|
90
|
+
root: node,
|
|
91
|
+
start: 0,
|
|
92
|
+
passageUuid: 'passage-uuid-1234',
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
expect(result).toBeUndefined();
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('should return undefined when type is invalid', () => {
|
|
99
|
+
const node = {
|
|
100
|
+
textContent: 'link text',
|
|
101
|
+
} as unknown as Node;
|
|
102
|
+
|
|
103
|
+
const mark = {
|
|
104
|
+
attrs: {
|
|
105
|
+
uuid: 'link-uuid-invalid',
|
|
106
|
+
type: 'invalidType',
|
|
107
|
+
href: 'https://example.com',
|
|
108
|
+
},
|
|
109
|
+
type: { name: 'invalidType' },
|
|
110
|
+
} as unknown as Mark;
|
|
111
|
+
|
|
112
|
+
const result = link({
|
|
113
|
+
node,
|
|
114
|
+
mark,
|
|
115
|
+
parent: node,
|
|
116
|
+
root: node,
|
|
117
|
+
start: 0,
|
|
118
|
+
passageUuid: 'passage-uuid-1234',
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
expect(result).toBeUndefined();
|
|
122
|
+
});
|
|
123
|
+
});
|