@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,8 @@
|
|
|
1
|
+
export const SLUGS = ['basic', 'toh251'];
|
|
2
|
+
export type Slug = (typeof SLUGS)[number];
|
|
3
|
+
|
|
4
|
+
export const FORMATS = ['json', 'passages', 'html', 'text'] as const;
|
|
5
|
+
export type Format = (typeof FORMATS)[number];
|
|
6
|
+
|
|
7
|
+
export const EDITORS = ['translation', 'block'];
|
|
8
|
+
export type EditorType = (typeof EDITORS)[number];
|
package/src/index.ts
ADDED
package/src/lib/block.ts
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Alignment,
|
|
3
|
+
AnnotationType,
|
|
4
|
+
BodyItemType,
|
|
5
|
+
Passage,
|
|
6
|
+
TranslationEditorContentItem,
|
|
7
|
+
TranslationEditorContent,
|
|
8
|
+
} from '@eightyfourthousand/data-access';
|
|
9
|
+
import { annotateBlock } from './transformers/annotate';
|
|
10
|
+
|
|
11
|
+
const passageTemplate = (passage: Passage): TranslationEditorContentItem => {
|
|
12
|
+
const alignments: { [key: string]: Alignment } =
|
|
13
|
+
passage.alignments?.reduce(
|
|
14
|
+
(acc, alignment) => {
|
|
15
|
+
acc[alignment.toh] = alignment;
|
|
16
|
+
return acc;
|
|
17
|
+
},
|
|
18
|
+
{} as { [key: string]: Alignment },
|
|
19
|
+
) || {};
|
|
20
|
+
const block: TranslationEditorContentItem = {
|
|
21
|
+
type: 'passage',
|
|
22
|
+
attrs: {
|
|
23
|
+
uuid: passage.uuid,
|
|
24
|
+
sort: passage.sort,
|
|
25
|
+
type: passage.type,
|
|
26
|
+
label: passage.label,
|
|
27
|
+
toh: passage.toh,
|
|
28
|
+
alignments,
|
|
29
|
+
...(passage.references?.length ? { references: passage.references } : {}),
|
|
30
|
+
},
|
|
31
|
+
content: [],
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const template =
|
|
35
|
+
TEMPLATES_FOR_BLOCK_TYPE[passage.type] ||
|
|
36
|
+
TEMPLATES_FOR_BLOCK_TYPE['translation'];
|
|
37
|
+
block.content = [template(passage)];
|
|
38
|
+
|
|
39
|
+
return block;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const textTemplate = (text: string): TranslationEditorContentItem => ({
|
|
43
|
+
type: 'text',
|
|
44
|
+
text,
|
|
45
|
+
attrs: {
|
|
46
|
+
start: 0,
|
|
47
|
+
end: text.length,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const headingTemplate = (passage: Passage): TranslationEditorContentItem => {
|
|
52
|
+
const block: TranslationEditorContentItem = {
|
|
53
|
+
type: 'heading',
|
|
54
|
+
attrs: {
|
|
55
|
+
level: 1,
|
|
56
|
+
start: 0,
|
|
57
|
+
end: passage.content.length,
|
|
58
|
+
uuid: passage.uuid,
|
|
59
|
+
},
|
|
60
|
+
content: [],
|
|
61
|
+
};
|
|
62
|
+
block.content = [textTemplate(passage.content)];
|
|
63
|
+
return block;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const paragraphTemplate = (passage: Passage): TranslationEditorContentItem => {
|
|
67
|
+
const block: TranslationEditorContentItem = {
|
|
68
|
+
type: 'paragraph',
|
|
69
|
+
attrs: {
|
|
70
|
+
start: 0,
|
|
71
|
+
end: passage.content.length,
|
|
72
|
+
uuid: passage.uuid,
|
|
73
|
+
},
|
|
74
|
+
content: [],
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
block.content = [textTemplate(passage.content)];
|
|
78
|
+
return block;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const abbreviationTemplate = (
|
|
82
|
+
passage: Passage,
|
|
83
|
+
): TranslationEditorContentItem => {
|
|
84
|
+
const block: TranslationEditorContentItem = {
|
|
85
|
+
type: 'paragraph',
|
|
86
|
+
attrs: {
|
|
87
|
+
class: 'flex flex-row gap-2',
|
|
88
|
+
start: 0,
|
|
89
|
+
end: passage.content.length,
|
|
90
|
+
uuid: passage.uuid,
|
|
91
|
+
},
|
|
92
|
+
content: [],
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
block.content = [textTemplate(passage.content)];
|
|
96
|
+
return block;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const TEMPLATES_FOR_BLOCK_TYPE: {
|
|
100
|
+
[key in BodyItemType]: (passage: Passage) => TranslationEditorContentItem;
|
|
101
|
+
} = {
|
|
102
|
+
acknowledgment: paragraphTemplate,
|
|
103
|
+
acknowledgmentHeader: headingTemplate,
|
|
104
|
+
abbreviations: abbreviationTemplate,
|
|
105
|
+
abbreviationsHeader: headingTemplate,
|
|
106
|
+
appendix: paragraphTemplate,
|
|
107
|
+
appendixHeader: headingTemplate,
|
|
108
|
+
colophon: paragraphTemplate,
|
|
109
|
+
colophonHeader: headingTemplate,
|
|
110
|
+
endnotes: paragraphTemplate,
|
|
111
|
+
endnotesHeader: headingTemplate,
|
|
112
|
+
homage: paragraphTemplate,
|
|
113
|
+
homageHeader: headingTemplate,
|
|
114
|
+
introduction: paragraphTemplate,
|
|
115
|
+
introductionHeader: headingTemplate,
|
|
116
|
+
prelude: paragraphTemplate,
|
|
117
|
+
preludeHeader: headingTemplate,
|
|
118
|
+
prologue: paragraphTemplate,
|
|
119
|
+
prologueHeader: headingTemplate,
|
|
120
|
+
summary: paragraphTemplate,
|
|
121
|
+
summaryHeader: headingTemplate,
|
|
122
|
+
translation: paragraphTemplate,
|
|
123
|
+
translationHeader: headingTemplate,
|
|
124
|
+
unknown: paragraphTemplate,
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
enum BlockPriority {
|
|
128
|
+
OuterBlock = 0,
|
|
129
|
+
ParentBlock = 1,
|
|
130
|
+
Block = 2,
|
|
131
|
+
Attribute = 3,
|
|
132
|
+
Inline = 4,
|
|
133
|
+
Mark = 5,
|
|
134
|
+
Unknown = Number.MIN_SAFE_INTEGER,
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const PRIORITY_FOR_ANNOTAION_TYPE: { [key in AnnotationType]: BlockPriority } =
|
|
138
|
+
{
|
|
139
|
+
abbreviation: BlockPriority.Inline,
|
|
140
|
+
audio: BlockPriority.Inline,
|
|
141
|
+
blockquote: BlockPriority.OuterBlock,
|
|
142
|
+
code: BlockPriority.Inline,
|
|
143
|
+
deprecated: BlockPriority.Unknown,
|
|
144
|
+
endNoteLink: BlockPriority.Mark,
|
|
145
|
+
glossaryInstance: BlockPriority.Mark,
|
|
146
|
+
hasAbbreviation: BlockPriority.Inline,
|
|
147
|
+
heading: BlockPriority.OuterBlock,
|
|
148
|
+
indent: BlockPriority.Attribute,
|
|
149
|
+
image: BlockPriority.Inline,
|
|
150
|
+
inlineTitle: BlockPriority.Mark,
|
|
151
|
+
internalLink: BlockPriority.Mark,
|
|
152
|
+
leadingSpace: BlockPriority.Attribute,
|
|
153
|
+
line: BlockPriority.Block,
|
|
154
|
+
lineGroup: BlockPriority.ParentBlock,
|
|
155
|
+
link: BlockPriority.Mark,
|
|
156
|
+
list: BlockPriority.ParentBlock,
|
|
157
|
+
listItem: BlockPriority.Block,
|
|
158
|
+
mantra: BlockPriority.Mark,
|
|
159
|
+
mention: BlockPriority.Inline,
|
|
160
|
+
paragraph: BlockPriority.OuterBlock,
|
|
161
|
+
quote: BlockPriority.Inline,
|
|
162
|
+
quoted: BlockPriority.Unknown,
|
|
163
|
+
reference: BlockPriority.Unknown,
|
|
164
|
+
span: BlockPriority.Mark,
|
|
165
|
+
table: BlockPriority.OuterBlock,
|
|
166
|
+
tableBodyData: BlockPriority.Block,
|
|
167
|
+
tableBodyHeader: BlockPriority.ParentBlock,
|
|
168
|
+
tableBodyRow: BlockPriority.ParentBlock,
|
|
169
|
+
trailer: BlockPriority.OuterBlock,
|
|
170
|
+
unknown: BlockPriority.Unknown,
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
export const blocksFromTranslationBody = (
|
|
174
|
+
passages: Passage[],
|
|
175
|
+
): TranslationEditorContent => {
|
|
176
|
+
const blocks: TranslationEditorContent = [];
|
|
177
|
+
passages.forEach((passage) => {
|
|
178
|
+
if (!passage.content) {
|
|
179
|
+
console.warn('passage has no content');
|
|
180
|
+
console.warn(passage);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const block = blockFromPassage(passage);
|
|
185
|
+
|
|
186
|
+
if (!block) {
|
|
187
|
+
console.warn('unknown block type');
|
|
188
|
+
console.warn(passage);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
blocks.push(block);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
return blocks;
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
export const blockFromPassage = (
|
|
199
|
+
passage: Passage,
|
|
200
|
+
): TranslationEditorContentItem => {
|
|
201
|
+
const block = passageTemplate(passage);
|
|
202
|
+
|
|
203
|
+
// Sort annotations by start position, then by end position in descending
|
|
204
|
+
// order to ensure that the longest annotations are processed first. If two
|
|
205
|
+
// annotations have the same start and end positions, sort by processing
|
|
206
|
+
// priority.
|
|
207
|
+
passage.annotations?.sort((a, b) => {
|
|
208
|
+
if (a.start !== b.start) {
|
|
209
|
+
return a.start - b.start;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (a.end !== b.end) {
|
|
213
|
+
return b.end - a.end;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const aPriority =
|
|
217
|
+
PRIORITY_FOR_ANNOTAION_TYPE[a.type] || BlockPriority.Unknown;
|
|
218
|
+
const bPriority =
|
|
219
|
+
PRIORITY_FOR_ANNOTAION_TYPE[b.type] || BlockPriority.Unknown;
|
|
220
|
+
return aPriority - bPriority;
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
annotateBlock(block, passage.annotations);
|
|
224
|
+
|
|
225
|
+
return block;
|
|
226
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
EditorContent,
|
|
5
|
+
type Content,
|
|
6
|
+
type UseEditorOptions,
|
|
7
|
+
} from '@tiptap/react';
|
|
8
|
+
import { useBlockEditor, useDefaultExtensions } from './hooks';
|
|
9
|
+
import { MainBubbleMenu } from './menus/MainBubbleMenu';
|
|
10
|
+
|
|
11
|
+
export type BlockEditorContent = Content;
|
|
12
|
+
|
|
13
|
+
export const BlockEditor = ({
|
|
14
|
+
content,
|
|
15
|
+
isEditable = true,
|
|
16
|
+
onUpdate,
|
|
17
|
+
onCreate,
|
|
18
|
+
}: UseEditorOptions & {
|
|
19
|
+
content: BlockEditorContent;
|
|
20
|
+
isEditable?: boolean;
|
|
21
|
+
}) => {
|
|
22
|
+
const { extensions } = useDefaultExtensions();
|
|
23
|
+
const { editor } = useBlockEditor({
|
|
24
|
+
extensions,
|
|
25
|
+
content,
|
|
26
|
+
isEditable,
|
|
27
|
+
onCreate,
|
|
28
|
+
onUpdate,
|
|
29
|
+
});
|
|
30
|
+
return (
|
|
31
|
+
<div className="relative flex flex-col flex-1 h-full">
|
|
32
|
+
<EditorContent className="flex-1" editor={editor} />
|
|
33
|
+
<MainBubbleMenu editor={editor} />
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default BlockEditor;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
createGraphQLClient,
|
|
5
|
+
getTranslationBlocks,
|
|
6
|
+
getWorkGlossaryTerms,
|
|
7
|
+
getWorkBibliography,
|
|
8
|
+
type GlossaryTermsPage,
|
|
9
|
+
} from '@eightyfourthousand/client-graphql';
|
|
10
|
+
import type { BibliographyEntries } from '@eightyfourthousand/data-access';
|
|
11
|
+
import { BackMatterPanel } from '../shared/BackMatterPanel';
|
|
12
|
+
import { TranslationRenderer } from '../shared/types';
|
|
13
|
+
import { useEditorState } from './EditorProvider';
|
|
14
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
15
|
+
import { TranslationEditorContent } from '../editor';
|
|
16
|
+
import { TranslationSkeleton } from '../shared/TranslationSkeleton';
|
|
17
|
+
import { TranslationBuilder } from '../editor';
|
|
18
|
+
import { isStaticFeatureEnabled } from '@eightyfourthousand/lib-instr/static';
|
|
19
|
+
|
|
20
|
+
export const EditorBackMatterPage = () => {
|
|
21
|
+
const { work } = useEditorState();
|
|
22
|
+
const [endnotes, setEndnotes] = useState<TranslationEditorContent>();
|
|
23
|
+
const [abbreviations, setAbbreviations] =
|
|
24
|
+
useState<TranslationEditorContent>();
|
|
25
|
+
const [glossary, setGlossary] = useState<GlossaryTermsPage>();
|
|
26
|
+
const [bibliography, setBibliography] = useState<BibliographyEntries>();
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
(async () => {
|
|
30
|
+
const { uuid } = work;
|
|
31
|
+
const graphqlClient = createGraphQLClient();
|
|
32
|
+
const withAttestations = isStaticFeatureEnabled('glossary-attestations');
|
|
33
|
+
|
|
34
|
+
const [
|
|
35
|
+
{ blocks: endnoteBlocks },
|
|
36
|
+
{ blocks: abbreviationBlocks },
|
|
37
|
+
glossaryData,
|
|
38
|
+
bibliographyData,
|
|
39
|
+
] = await Promise.all([
|
|
40
|
+
getTranslationBlocks({
|
|
41
|
+
client: graphqlClient,
|
|
42
|
+
uuid,
|
|
43
|
+
type: 'endnotes',
|
|
44
|
+
}),
|
|
45
|
+
getTranslationBlocks({
|
|
46
|
+
client: graphqlClient,
|
|
47
|
+
uuid,
|
|
48
|
+
type: 'abbreviations',
|
|
49
|
+
}),
|
|
50
|
+
getWorkGlossaryTerms({
|
|
51
|
+
client: graphqlClient,
|
|
52
|
+
uuid,
|
|
53
|
+
withAttestations,
|
|
54
|
+
}),
|
|
55
|
+
getWorkBibliography({
|
|
56
|
+
client: graphqlClient,
|
|
57
|
+
uuid,
|
|
58
|
+
}),
|
|
59
|
+
]);
|
|
60
|
+
|
|
61
|
+
setEndnotes(endnoteBlocks);
|
|
62
|
+
setAbbreviations(abbreviationBlocks);
|
|
63
|
+
setGlossary(glossaryData);
|
|
64
|
+
setBibliography(bibliographyData);
|
|
65
|
+
})();
|
|
66
|
+
}, [work]);
|
|
67
|
+
|
|
68
|
+
const renderTranslation = useCallback(
|
|
69
|
+
({ content, name, className }: TranslationRenderer) => (
|
|
70
|
+
<TranslationBuilder
|
|
71
|
+
content={content}
|
|
72
|
+
name={name}
|
|
73
|
+
className={className}
|
|
74
|
+
filter={name}
|
|
75
|
+
panel="right"
|
|
76
|
+
/>
|
|
77
|
+
),
|
|
78
|
+
[],
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
if (!endnotes || !glossary || !bibliography || !abbreviations) {
|
|
82
|
+
return <TranslationSkeleton />;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<BackMatterPanel
|
|
87
|
+
workUuid={work.uuid}
|
|
88
|
+
endnotes={endnotes}
|
|
89
|
+
glossary={glossary}
|
|
90
|
+
bibliography={bibliography}
|
|
91
|
+
abbreviations={abbreviations}
|
|
92
|
+
renderTranslation={renderTranslation}
|
|
93
|
+
/>
|
|
94
|
+
);
|
|
95
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
createGraphQLClient,
|
|
5
|
+
BODY_MATTER_FILTER,
|
|
6
|
+
FRONT_MATTER_FILTER,
|
|
7
|
+
getTranslationBlocks,
|
|
8
|
+
getTranslationTitles,
|
|
9
|
+
} from '@eightyfourthousand/client-graphql';
|
|
10
|
+
import type { Title } from '@eightyfourthousand/data-access';
|
|
11
|
+
import { BodyPanel } from '../shared/BodyPanel';
|
|
12
|
+
import { TitlesRenderer, TranslationRenderer } from '../shared/types';
|
|
13
|
+
import { useEditorState } from './EditorProvider';
|
|
14
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
15
|
+
import { TranslationBuilder, TranslationEditorContent } from '.';
|
|
16
|
+
import { TranslationSkeleton } from '../shared/TranslationSkeleton';
|
|
17
|
+
import { TitlesBuilder } from './TitlesBuilder';
|
|
18
|
+
|
|
19
|
+
const INITIAL_PASSAGES = 100;
|
|
20
|
+
|
|
21
|
+
export const EditorBodyPage = () => {
|
|
22
|
+
const { work } = useEditorState();
|
|
23
|
+
const [body, setBody] = useState<TranslationEditorContent>();
|
|
24
|
+
const [frontMatter, setFrontMatter] = useState<TranslationEditorContent>();
|
|
25
|
+
const [titles, setTitles] = useState<Title[]>();
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
(async () => {
|
|
29
|
+
const client = createGraphQLClient();
|
|
30
|
+
|
|
31
|
+
const [{ blocks: frontBlocks }, { blocks: bodyBlocks }, titlesData] =
|
|
32
|
+
await Promise.all([
|
|
33
|
+
getTranslationBlocks({
|
|
34
|
+
client,
|
|
35
|
+
uuid: work.uuid,
|
|
36
|
+
type: FRONT_MATTER_FILTER,
|
|
37
|
+
maxPassages: INITIAL_PASSAGES,
|
|
38
|
+
}),
|
|
39
|
+
getTranslationBlocks({
|
|
40
|
+
client,
|
|
41
|
+
uuid: work.uuid,
|
|
42
|
+
type: BODY_MATTER_FILTER,
|
|
43
|
+
maxPassages: INITIAL_PASSAGES,
|
|
44
|
+
}),
|
|
45
|
+
getTranslationTitles({ client, uuid: work.uuid }),
|
|
46
|
+
]);
|
|
47
|
+
|
|
48
|
+
setTitles(titlesData);
|
|
49
|
+
setFrontMatter(frontBlocks);
|
|
50
|
+
setBody(bodyBlocks);
|
|
51
|
+
})();
|
|
52
|
+
}, [work.uuid]);
|
|
53
|
+
|
|
54
|
+
const renderTitles = useCallback(
|
|
55
|
+
({ titles, imprint }: TitlesRenderer) => (
|
|
56
|
+
<TitlesBuilder titles={titles} imprint={imprint} />
|
|
57
|
+
),
|
|
58
|
+
[],
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const renderTranslation = useCallback(
|
|
62
|
+
({ content, name, className }: TranslationRenderer) => (
|
|
63
|
+
<TranslationBuilder
|
|
64
|
+
content={content}
|
|
65
|
+
name={name}
|
|
66
|
+
className={className}
|
|
67
|
+
filter={name === 'front' ? FRONT_MATTER_FILTER : BODY_MATTER_FILTER}
|
|
68
|
+
panel="main"
|
|
69
|
+
/>
|
|
70
|
+
),
|
|
71
|
+
[],
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
if (!titles || !frontMatter || !body) {
|
|
75
|
+
return <TranslationSkeleton />;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<BodyPanel
|
|
80
|
+
titles={titles}
|
|
81
|
+
frontMatter={frontMatter}
|
|
82
|
+
body={body}
|
|
83
|
+
renderTitles={renderTitles}
|
|
84
|
+
renderTranslation={renderTranslation}
|
|
85
|
+
/>
|
|
86
|
+
);
|
|
87
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useSyncExternalStore } from 'react';
|
|
4
|
+
import { SaveButton } from '@eightyfourthousand/design-system';
|
|
5
|
+
import { useEditorState } from './EditorProvider';
|
|
6
|
+
|
|
7
|
+
export const EditorHeader = () => {
|
|
8
|
+
const { dirtyStore, save } = useEditorState();
|
|
9
|
+
|
|
10
|
+
// Subscribe to dirty state directly
|
|
11
|
+
const isDirty = useSyncExternalStore(
|
|
12
|
+
dirtyStore.subscribe.bind(dirtyStore),
|
|
13
|
+
dirtyStore.getSnapshot.bind(dirtyStore),
|
|
14
|
+
() => false,
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<div className="px-4 py-3 flex justify-end h-12 z-10 gap-2">
|
|
19
|
+
{isDirty && <SaveButton size="xs" onClick={save} />}
|
|
20
|
+
</div>
|
|
21
|
+
);
|
|
22
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { ReactNode, use, useEffect, useState } from 'react';
|
|
4
|
+
import { EditorContextProvider } from './EditorProvider';
|
|
5
|
+
import {
|
|
6
|
+
createGraphQLClient,
|
|
7
|
+
getTranslationMetadataByUuid,
|
|
8
|
+
Work,
|
|
9
|
+
} from '@eightyfourthousand/client-graphql';
|
|
10
|
+
import { ThreeColumnRenderer, TranslationSkeleton } from '../shared';
|
|
11
|
+
import {
|
|
12
|
+
LeftPanel,
|
|
13
|
+
MainPanel,
|
|
14
|
+
MainPanelHeader,
|
|
15
|
+
RightPanel,
|
|
16
|
+
} from '@eightyfourthousand/design-system';
|
|
17
|
+
import { EditorHeader } from './EditorHeader';
|
|
18
|
+
|
|
19
|
+
export const EditorLayout = ({
|
|
20
|
+
left,
|
|
21
|
+
main,
|
|
22
|
+
right,
|
|
23
|
+
params,
|
|
24
|
+
}: {
|
|
25
|
+
left: ReactNode;
|
|
26
|
+
main: ReactNode;
|
|
27
|
+
right: ReactNode;
|
|
28
|
+
params: Promise<{ slug: string }>;
|
|
29
|
+
}) => {
|
|
30
|
+
const { slug } = use(params);
|
|
31
|
+
const [work, setWork] = useState<Work>();
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
(async () => {
|
|
35
|
+
const client = createGraphQLClient();
|
|
36
|
+
const work = await getTranslationMetadataByUuid({
|
|
37
|
+
client,
|
|
38
|
+
uuid: slug,
|
|
39
|
+
});
|
|
40
|
+
if (work) {
|
|
41
|
+
setWork(work);
|
|
42
|
+
}
|
|
43
|
+
})();
|
|
44
|
+
}, [slug]);
|
|
45
|
+
|
|
46
|
+
if (!work) {
|
|
47
|
+
return <TranslationSkeleton />;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<EditorContextProvider work={work}>
|
|
52
|
+
<ThreeColumnRenderer withHeader={true}>
|
|
53
|
+
<LeftPanel>{left}</LeftPanel>
|
|
54
|
+
<MainPanelHeader>
|
|
55
|
+
<EditorHeader />
|
|
56
|
+
</MainPanelHeader>
|
|
57
|
+
<MainPanel>{main}</MainPanel>
|
|
58
|
+
<RightPanel>{right}</RightPanel>
|
|
59
|
+
</ThreeColumnRenderer>
|
|
60
|
+
</EditorContextProvider>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { createGraphQLClient, getTranslationToc } from '@eightyfourthousand/client-graphql';
|
|
4
|
+
import type { Toc } from '@eightyfourthousand/data-access';
|
|
5
|
+
import { LeftPanel } from '../shared/LeftPanel';
|
|
6
|
+
import { useEditorState } from './EditorProvider';
|
|
7
|
+
import { useEffect, useState } from 'react';
|
|
8
|
+
import { TranslationSkeleton } from '../shared/TranslationSkeleton';
|
|
9
|
+
|
|
10
|
+
export const EditorLeftPanelPage = () => {
|
|
11
|
+
const { work } = useEditorState();
|
|
12
|
+
const [toc, setToc] = useState<Toc>();
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
(async () => {
|
|
16
|
+
const client = createGraphQLClient();
|
|
17
|
+
const toc = await getTranslationToc({ client, uuid: work.uuid });
|
|
18
|
+
setToc(toc);
|
|
19
|
+
})();
|
|
20
|
+
}, [work.uuid]);
|
|
21
|
+
|
|
22
|
+
if (!toc) {
|
|
23
|
+
return <TranslationSkeleton />;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return <LeftPanel toc={toc} work={work} />;
|
|
27
|
+
};
|