bookish-press 0.4.1 → 0.4.3
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/README.md +3 -1
- package/components/Auth.svelte +27 -24
- package/components/Auth.svelte.d.ts +4 -4
- package/components/Authentication.d.ts +2 -2
- package/components/BookPreview.svelte +75 -59
- package/components/BookPreview.svelte.d.ts +5 -5
- package/components/External.svelte +1 -1
- package/components/External.svelte.d.ts +3 -3
- package/components/Link.svelte +49 -3
- package/components/Link.svelte.d.ts +3 -4
- package/components/app/BookList.svelte +19 -0
- package/components/app/BookList.svelte.d.ts +18 -0
- package/components/app/Button.svelte +49 -0
- package/components/app/Button.svelte.d.ts +22 -0
- package/components/app/Feedback.svelte +47 -0
- package/components/app/Feedback.svelte.d.ts +18 -0
- package/components/app/Head.svelte +15 -0
- package/components/app/Head.svelte.d.ts +18 -0
- package/components/app/Large.svelte +8 -0
- package/components/app/Large.svelte.d.ts +27 -0
- package/components/app/Lead.svelte +12 -0
- package/components/app/Lead.svelte.d.ts +27 -0
- package/components/app/Link.svelte +24 -0
- package/components/app/Link.svelte.d.ts +20 -0
- package/components/app/Options.svelte +24 -0
- package/components/app/Options.svelte.d.ts +19 -0
- package/components/app/Paragraph.svelte +20 -0
- package/components/app/Paragraph.svelte.d.ts +18 -0
- package/components/app/Section.svelte +12 -0
- package/components/app/Section.svelte.d.ts +27 -0
- package/components/app/Table.svelte +32 -0
- package/components/app/Table.svelte.d.ts +27 -0
- package/components/app/TextInput.svelte +38 -0
- package/components/app/TextInput.svelte.d.ts +22 -0
- package/components/chapter/Atom.svelte +20 -6
- package/components/chapter/Atom.svelte.d.ts +3 -3
- package/components/chapter/Block.svelte +26 -21
- package/components/chapter/Block.svelte.d.ts +4 -4
- package/components/chapter/Callout.svelte +38 -7
- package/components/chapter/Callout.svelte.d.ts +4 -4
- package/components/chapter/CaptionedCode.svelte +67 -24
- package/components/chapter/CaptionedCode.svelte.d.ts +4 -4
- package/components/chapter/ChapterBody.svelte +62 -9
- package/components/chapter/ChapterBody.svelte.d.ts +5 -4
- package/components/chapter/Citations.svelte +86 -20
- package/components/chapter/Citations.svelte.d.ts +4 -4
- package/components/chapter/Code.svelte +152 -21
- package/components/chapter/Code.svelte.d.ts +3 -3
- package/components/chapter/Comment.svelte +39 -17
- package/components/chapter/Comment.svelte.d.ts +3 -3
- package/components/chapter/Definition.svelte +52 -18
- package/components/chapter/Definition.svelte.d.ts +5 -8
- package/components/chapter/Embed.svelte +155 -67
- package/components/chapter/Embed.svelte.d.ts +6 -4
- package/components/chapter/ErrorMessage.svelte +7 -2
- package/components/chapter/ErrorMessage.svelte.d.ts +4 -4
- package/components/chapter/ExtendedPrism.d.ts +2 -0
- package/components/chapter/ExtendedPrism.js +69 -0
- package/components/chapter/Figure.svelte +90 -0
- package/components/chapter/Figure.svelte.d.ts +24 -0
- package/components/chapter/Footnote.svelte +75 -12
- package/components/chapter/Footnote.svelte.d.ts +4 -4
- package/components/chapter/Format.svelte +63 -38
- package/components/chapter/Format.svelte.d.ts +5 -4
- package/components/chapter/InlineCode.svelte +16 -6
- package/components/chapter/InlineCode.svelte.d.ts +4 -4
- package/components/chapter/Label.svelte +38 -9
- package/components/chapter/Label.svelte.d.ts +4 -4
- package/components/chapter/Link.svelte +24 -19
- package/components/chapter/Link.svelte.d.ts +4 -4
- package/components/chapter/List.svelte +75 -8
- package/components/chapter/List.svelte.d.ts +4 -4
- package/components/chapter/Marginal.svelte +169 -27
- package/components/chapter/Marginal.svelte.d.ts +6 -3
- package/components/chapter/Paragraph.svelte +79 -6
- package/components/chapter/Paragraph.svelte.d.ts +4 -4
- package/components/chapter/Positioned.svelte +33 -0
- package/components/chapter/Positioned.svelte.d.ts +19 -0
- package/components/chapter/Problem.svelte +15 -0
- package/components/chapter/Problem.svelte.d.ts +27 -0
- package/components/chapter/Python.svelte +68 -21
- package/components/chapter/Python.svelte.d.ts +4 -4
- package/components/chapter/Quote.svelte +64 -11
- package/components/chapter/Quote.svelte.d.ts +4 -4
- package/components/chapter/Rule.svelte +12 -1
- package/components/chapter/Rule.svelte.d.ts +4 -4
- package/components/chapter/Table.svelte +36 -25
- package/components/chapter/Table.svelte.d.ts +4 -4
- package/components/chapter/Text.svelte +61 -36
- package/components/chapter/Text.svelte.d.ts +5 -4
- package/components/editor/BookishEditor.svelte +373 -244
- package/components/editor/BookishEditor.svelte.d.ts +9 -6
- package/components/editor/CalloutEditor.svelte +5 -5
- package/components/editor/CalloutEditor.svelte.d.ts +4 -4
- package/components/editor/CaptionedCodeEditor.svelte +16 -12
- package/components/editor/CaptionedCodeEditor.svelte.d.ts +4 -4
- package/components/editor/CaretContext.d.ts +48 -16
- package/components/editor/CaretState.d.ts +16 -44
- package/components/editor/CaretUtilities.d.ts +2 -2
- package/components/editor/CaretView.svelte +82 -0
- package/components/editor/CaretView.svelte.d.ts +25 -0
- package/components/editor/CitationsEditor.svelte +36 -25
- package/components/editor/CitationsEditor.svelte.d.ts +4 -4
- package/components/editor/Clipboard.d.ts +2 -2
- package/components/editor/Command.d.ts +13 -12
- package/components/editor/Commands.d.ts +1 -1
- package/components/editor/Commands.js +1114 -571
- package/components/editor/ConfirmButton.svelte +18 -12
- package/components/editor/ConfirmButton.svelte.d.ts +5 -4
- package/components/editor/DefinitionEditor.svelte +29 -21
- package/components/editor/DefinitionEditor.svelte.d.ts +4 -4
- package/components/editor/EmbedEditor.svelte +93 -43
- package/components/editor/EmbedEditor.svelte.d.ts +3 -3
- package/components/editor/Icon.svelte +17 -0
- package/components/editor/Icon.svelte.d.ts +16 -0
- package/components/editor/ImageChooser.svelte +53 -34
- package/components/editor/ImageChooser.svelte.d.ts +3 -3
- package/components/editor/InlineCodeEditor.svelte +7 -4
- package/components/editor/InlineCodeEditor.svelte.d.ts +4 -4
- package/components/editor/LabelEditor.svelte +20 -11
- package/components/editor/LabelEditor.svelte.d.ts +4 -4
- package/components/editor/LanguageEditor.svelte +10 -7
- package/components/editor/LanguageEditor.svelte.d.ts +3 -3
- package/components/editor/LinkEditor.svelte +64 -39
- package/components/editor/LinkEditor.svelte.d.ts +4 -4
- package/components/editor/Note.svelte +4 -3
- package/components/editor/Note.svelte.d.ts +6 -2
- package/components/editor/Permissions.svelte +95 -0
- package/components/editor/Permissions.svelte.d.ts +20 -0
- package/components/editor/PositionEditor.svelte +9 -6
- package/components/editor/PositionEditor.svelte.d.ts +4 -4
- package/components/editor/QuoteEditor.svelte +7 -2
- package/components/editor/QuoteEditor.svelte.d.ts +4 -4
- package/components/editor/Switch.svelte +55 -28
- package/components/editor/Switch.svelte.d.ts +4 -4
- package/components/editor/TableEditor.svelte +10 -0
- package/components/editor/TableEditor.svelte.d.ts +17 -0
- package/components/editor/TextEditor.svelte +83 -45
- package/components/editor/TextEditor.svelte.d.ts +5 -4
- package/components/editor/Toggle.svelte +11 -8
- package/components/editor/Toggle.svelte.d.ts +4 -4
- package/components/editor/Toolbar.svelte +191 -144
- package/components/editor/Toolbar.svelte.d.ts +5 -8
- package/components/editor/ToolbarGroup.svelte +17 -23
- package/components/editor/ToolbarGroup.svelte.d.ts +3 -4
- package/components/editor/ToolbarSpacer.svelte +8 -1
- package/components/editor/ToolbarSpacer.svelte.d.ts +6 -2
- package/components/editor/URLEditor.svelte +6 -8
- package/components/editor/URLEditor.svelte.d.ts +3 -3
- package/components/editor/UndoState.d.ts +3 -3
- package/components/editor/icons/annotate.svg +1 -0
- package/components/editor/icons/block.svg +1 -0
- package/components/editor/icons/bold.svg +1 -0
- package/components/editor/icons/bullets.svg +1 -0
- package/components/editor/icons/callout.svg +1 -0
- package/components/editor/icons/citation.svg +8 -0
- package/components/editor/icons/clear.svg +1 -0
- package/components/editor/icons/clipboard.svg +1 -0
- package/components/editor/icons/code.svg +1 -0
- package/components/editor/icons/columnafter.svg +1 -0
- package/components/editor/icons/columnbefore.svg +1 -0
- package/components/editor/icons/comment.svg +1 -0
- package/components/editor/icons/copy.svg +1 -0
- package/components/editor/icons/cut.svg +1 -0
- package/components/editor/icons/define.svg +7 -0
- package/components/editor/icons/deletecolumn.svg +1 -0
- package/components/editor/icons/deleterow.svg +1 -0
- package/components/editor/icons/footnote.svg +8 -0
- package/components/editor/icons/header1.svg +7 -0
- package/components/editor/icons/header2.svg +7 -0
- package/components/editor/icons/header3.svg +7 -0
- package/components/editor/icons/home.svg +1 -0
- package/components/editor/icons/indent.svg +1 -0
- package/components/editor/icons/italic.svg +1 -0
- package/components/editor/icons/label.svg +1 -0
- package/components/editor/icons/left.svg +1 -0
- package/components/editor/icons/level.svg +1 -0
- package/components/editor/icons/link.svg +1 -0
- package/components/editor/icons/list.svg +1 -0
- package/components/editor/icons/media.svg +1 -0
- package/components/editor/icons/middle.svg +1 -0
- package/components/editor/icons/numbers.svg +10 -0
- package/components/editor/icons/paragraph.svg +1 -0
- package/components/editor/icons/paste.svg +10 -0
- package/components/editor/icons/quote.svg +1 -0
- package/components/editor/icons/redo.svg +1 -0
- package/components/editor/icons/right.svg +1 -0
- package/components/editor/icons/rowabove.svg +1 -0
- package/components/editor/icons/rowbelow.svg +1 -0
- package/components/editor/icons/rule.svg +1 -0
- package/components/editor/icons/sub.svg +1 -0
- package/components/editor/icons/super.svg +1 -0
- package/components/editor/icons/table.svg +1 -0
- package/components/editor/icons/text.svg +1 -0
- package/components/editor/icons/time.svg +1 -0
- package/components/editor/icons/undo.svg +1 -0
- package/components/editor/icons/unindent.svg +1 -0
- package/components/editor/icons/unlink.svg +1 -0
- package/components/page/Acknowledgements.svelte +35 -24
- package/components/page/Acknowledgements.svelte.d.ts +4 -4
- package/components/page/Authors.svelte +34 -17
- package/components/page/Authors.svelte.d.ts +7 -6
- package/components/page/BookLoader.svelte +59 -0
- package/components/page/BookLoader.svelte.d.ts +16 -0
- package/components/page/BulkReferenceEditor.svelte +54 -23
- package/components/page/BulkReferenceEditor.svelte.d.ts +4 -4
- package/components/page/Chapter.svelte +234 -143
- package/components/page/Chapter.svelte.d.ts +3 -3
- package/components/page/ChapterContext.d.ts +4 -4
- package/components/page/ChapterNumber.svelte +9 -0
- package/components/page/ChapterNumber.svelte.d.ts +27 -0
- package/components/page/ChapterTitle.svelte +16 -0
- package/components/page/ChapterTitle.svelte.d.ts +18 -0
- package/components/page/Contexts.d.ts +42 -22
- package/components/page/Contexts.js +129 -17
- package/components/page/DefinitionView.svelte +129 -90
- package/components/page/DefinitionView.svelte.d.ts +3 -3
- package/components/page/Description.svelte +31 -19
- package/components/page/Description.svelte.d.ts +4 -4
- package/components/page/Edition.svelte +135 -81
- package/components/page/Edition.svelte.d.ts +5 -6
- package/components/page/EditionLoader.svelte +99 -0
- package/components/page/EditionLoader.svelte.d.ts +18 -0
- package/components/page/Editions.svelte +106 -0
- package/components/page/Editions.svelte.d.ts +14 -0
- package/components/page/Glossary.svelte +65 -49
- package/components/page/Glossary.svelte.d.ts +4 -4
- package/components/page/Header.svelte +143 -56
- package/components/page/Header.svelte.d.ts +8 -6
- package/components/page/Index.svelte +116 -80
- package/components/page/Index.svelte.d.ts +4 -4
- package/components/page/Instructions.svelte +18 -17
- package/components/page/Instructions.svelte.d.ts +6 -4
- package/components/page/License.svelte +39 -23
- package/components/page/License.svelte.d.ts +4 -4
- package/components/page/Loading.svelte +102 -12
- package/components/page/Loading.svelte.d.ts +6 -2
- package/components/page/Media.svelte +81 -53
- package/components/page/Media.svelte.d.ts +4 -4
- package/components/page/MediaPreview.svelte +26 -8
- package/components/page/MediaPreview.svelte.d.ts +3 -3
- package/components/page/Muted.svelte +10 -0
- package/components/page/Muted.svelte.d.ts +27 -0
- package/components/page/Outline.svelte +279 -59
- package/components/page/Outline.svelte.d.ts +3 -3
- package/components/page/Page.svelte +40 -9
- package/components/page/Page.svelte.d.ts +3 -3
- package/components/page/PageHeader.svelte +14 -0
- package/components/page/PageHeader.svelte.d.ts +18 -0
- package/components/page/PageParagraph.svelte +18 -0
- package/components/page/PageParagraph.svelte.d.ts +27 -0
- package/components/page/PossibleChapter.svelte +7 -7
- package/components/page/PossibleChapter.svelte.d.ts +4 -4
- package/components/page/PossibleReference.svelte +6 -11
- package/components/page/PossibleReference.svelte.d.ts +6 -7
- package/components/page/Print.svelte +27 -3
- package/components/page/Print.svelte.d.ts +4 -4
- package/components/page/Publish.svelte +134 -0
- package/components/page/Publish.svelte.d.ts +14 -0
- package/components/page/Reference.svelte +259 -117
- package/components/page/Reference.svelte.d.ts +5 -5
- package/components/page/References.svelte +45 -48
- package/components/page/References.svelte.d.ts +4 -4
- package/components/page/Rows.svelte +54 -0
- package/components/page/Rows.svelte.d.ts +27 -0
- package/components/page/Search.svelte +88 -63
- package/components/page/Search.svelte.d.ts +4 -4
- package/components/page/Status.svelte +46 -39
- package/components/page/Status.svelte.d.ts +4 -9
- package/components/page/SubdomainEditor.svelte +41 -27
- package/components/page/SubdomainEditor.svelte.d.ts +4 -4
- package/components/page/TableOfContents.svelte +264 -191
- package/components/page/TableOfContents.svelte.d.ts +4 -4
- package/components/page/TableOfContentsImage.svelte +8 -8
- package/components/page/TableOfContentsImage.svelte.d.ts +3 -3
- package/components/page/TableOfContentsRow.svelte +97 -34
- package/components/page/TableOfContentsRow.svelte.d.ts +4 -4
- package/components/page/ThemeEditor.svelte +177 -39
- package/components/page/ThemeEditor.svelte.d.ts +4 -4
- package/components/page/ThemeEditorPreview.svelte +35 -23
- package/components/page/ThemeEditorPreview.svelte.d.ts +5 -5
- package/components/page/ThemeSetEditor.svelte +15 -13
- package/components/page/ThemeSetEditor.svelte.d.ts +4 -4
- package/components/page/ThemeVariableEditor.svelte +24 -15
- package/components/page/ThemeVariableEditor.svelte.d.ts +3 -3
- package/components/page/Title.svelte +12 -0
- package/components/page/Title.svelte.d.ts +27 -0
- package/components/page/Unknown.svelte +28 -21
- package/components/page/Unknown.svelte.d.ts +4 -4
- package/components/page/margins.js +50 -33
- package/index.d.ts +13 -0
- package/index.js +14 -0
- package/models/CRUD.d.ts +27 -0
- package/models/CRUD.js +262 -0
- package/models/Firebase.d.ts +1 -0
- package/models/Firebase.js +26 -16
- package/models/book/Book.d.ts +40 -39
- package/models/book/Book.js +121 -121
- package/models/book/BookMedia.d.ts +3 -3
- package/models/book/BookMedia.js +22 -16
- package/models/book/BookSaveStatus.d.ts +7 -0
- package/models/book/BookSaveStatus.js +8 -0
- package/models/book/Chapter.d.ts +50 -39
- package/models/book/Chapter.js +189 -198
- package/models/book/ChapterID.js +7 -7
- package/models/book/Definition.d.ts +1 -1
- package/models/book/Edition.d.ts +87 -61
- package/models/book/Edition.js +460 -309
- package/models/book/Reference.d.ts +24 -0
- package/models/book/Reference.js +78 -0
- package/models/book/Schema.d.ts +168 -0
- package/models/book/Schema.js +115 -0
- package/models/book/Theme.d.ts +44 -37
- package/models/book/Theme.js +452 -52
- package/models/book/ThemeColors.d.ts +1 -1
- package/models/book/Words.d.ts +2 -0
- package/models/book/Words.js +110 -0
- package/models/chapter/AtomNode.d.ts +4 -4
- package/models/chapter/AtomNode.js +20 -13
- package/models/chapter/BlockNode.d.ts +9 -10
- package/models/chapter/BlockNode.js +32 -13
- package/models/chapter/BlocksNode.d.ts +10 -10
- package/models/chapter/BlocksNode.js +315 -120
- package/models/chapter/BlocksNode.test.js +494 -228
- package/models/chapter/Bookkeeping.d.ts +1 -1
- package/models/chapter/CalloutNode.d.ts +3 -3
- package/models/chapter/CalloutNode.js +34 -12
- package/models/chapter/Caret.d.ts +9 -7
- package/models/chapter/Caret.js +11 -6
- package/models/chapter/ChapterNode.d.ts +11 -11
- package/models/chapter/ChapterNode.js +70 -33
- package/models/chapter/CitationsNode.d.ts +3 -3
- package/models/chapter/CitationsNode.js +31 -12
- package/models/chapter/CodeNode.d.ts +11 -6
- package/models/chapter/CodeNode.js +143 -34
- package/models/chapter/CommentNode.d.ts +5 -5
- package/models/chapter/CommentNode.js +29 -13
- package/models/chapter/DefinitionNode.d.ts +2 -2
- package/models/chapter/DefinitionNode.js +15 -7
- package/models/chapter/Edit.d.ts +3 -3
- package/models/chapter/EmbedNode.d.ts +9 -5
- package/models/chapter/EmbedNode.js +108 -35
- package/models/chapter/ErrorNode.d.ts +2 -2
- package/models/chapter/ErrorNode.js +34 -12
- package/models/chapter/FootnoteNode.d.ts +5 -5
- package/models/chapter/FootnoteNode.js +34 -16
- package/models/chapter/FormatNode.d.ts +10 -10
- package/models/chapter/FormatNode.js +237 -106
- package/models/chapter/FormatNode.test.js +87 -45
- package/models/chapter/InlineCodeNode.d.ts +2 -2
- package/models/chapter/InlineCodeNode.js +22 -9
- package/models/chapter/LabelNode.d.ts +4 -4
- package/models/chapter/LabelNode.js +31 -13
- package/models/chapter/LinkNode.d.ts +2 -2
- package/models/chapter/LinkNode.js +21 -9
- package/models/chapter/ListNode.d.ts +8 -8
- package/models/chapter/ListNode.js +99 -38
- package/models/chapter/ListNode.test.js +29 -24
- package/models/chapter/MetadataNode.d.ts +3 -3
- package/models/chapter/MetadataNode.js +13 -5
- package/models/chapter/Node.d.ts +5 -3
- package/models/chapter/Node.js +76 -29
- package/models/chapter/Node.test.js +20 -18
- package/models/chapter/ParagraphNode.d.ts +6 -6
- package/models/chapter/ParagraphNode.js +84 -29
- package/models/chapter/ParagraphNode.test.js +22 -13
- package/models/chapter/Parser.d.ts +27 -27
- package/models/chapter/Parser.js +220 -206
- package/models/chapter/Parser.test.js +16 -16
- package/models/chapter/Position.d.ts +1 -1
- package/models/chapter/QuoteNode.d.ts +6 -6
- package/models/chapter/QuoteNode.js +61 -23
- package/models/chapter/RootNode.d.ts +4 -4
- package/models/chapter/RuleNode.d.ts +2 -2
- package/models/chapter/RuleNode.js +31 -11
- package/models/chapter/TableNode.d.ts +8 -6
- package/models/chapter/TableNode.js +89 -34
- package/models/chapter/TableNode.test.js +22 -24
- package/models/chapter/TextNode.d.ts +6 -6
- package/models/chapter/TextNode.js +72 -32
- package/models/chapter/TextNode.test.js +4 -4
- package/package.json +108 -26
- package/util/getSubdomain.js +8 -6
- package/util/isMobile.js +1 -1
- package/util/mineReference.d.ts +3 -2
- package/util/mineReference.js +67 -29
- package/util/scrollToEyeLevel.js +6 -1
- package/components/chapter/renderPosition.d.ts +0 -3
- package/components/chapter/renderPosition.js +0 -4
- package/components/editor/ToolbarIcon.svelte +0 -22
- package/components/editor/ToolbarIcon.svelte.d.ts +0 -16
- package/components/page/Alert.svelte +0 -11
- package/components/page/Alert.svelte.d.ts +0 -23
- package/components/page/Revisions.svelte +0 -124
- package/components/page/Revisions.svelte.d.ts +0 -14
- package/models/BookLoader.d.ts +0 -2
- package/models/BookLoader.js +0 -67
- package/models/Firestore.d.ts +0 -22
- package/models/Firestore.js +0 -194
- package/models/chapter/ReferenceNode.d.ts +0 -29
- package/models/chapter/ReferenceNode.js +0 -48
- package/models/loadEdition.d.ts +0 -5
- package/models/loadEdition.js +0 -16
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { test, expect } from 'vitest';
|
|
2
|
-
import Parser from
|
|
3
|
-
test(
|
|
4
|
-
expect(Parser.parseChapter(undefined,
|
|
2
|
+
import Parser from './Parser';
|
|
3
|
+
test('Empty chapter', () => {
|
|
4
|
+
expect(Parser.parseChapter(undefined, '').toBookdown()).toBe('');
|
|
5
5
|
});
|
|
6
|
-
test(
|
|
7
|
-
expect(Parser.parseChapter(undefined,
|
|
6
|
+
test('Single paragraph', () => {
|
|
7
|
+
expect(Parser.parseChapter(undefined, 'hello').toBookdown()).toBe('hello');
|
|
8
8
|
});
|
|
9
|
-
test(
|
|
10
|
-
const p = new Parser(undefined,
|
|
11
|
-
expect(p.peek()).toBe(
|
|
12
|
-
expect(p.read()).toBe(
|
|
13
|
-
expect(p.peek()).toBe(
|
|
9
|
+
test('Peek', () => {
|
|
10
|
+
const p = new Parser(undefined, '# hello');
|
|
11
|
+
expect(p.peek()).toBe('#');
|
|
12
|
+
expect(p.read()).toBe('#');
|
|
13
|
+
expect(p.peek()).toBe(' ');
|
|
14
14
|
});
|
|
15
|
-
test(
|
|
16
|
-
const p = new Parser(undefined,
|
|
15
|
+
test('More', () => {
|
|
16
|
+
const p = new Parser(undefined, '#');
|
|
17
17
|
expect(p.more()).toBe(true);
|
|
18
|
-
const p2 = new Parser(undefined,
|
|
18
|
+
const p2 = new Parser(undefined, '');
|
|
19
19
|
expect(p2.more()).toBe(false);
|
|
20
20
|
});
|
|
21
|
-
test(
|
|
22
|
-
const p = new Parser(undefined,
|
|
21
|
+
test('Whitespace', () => {
|
|
22
|
+
const p = new Parser(undefined, ' Hi');
|
|
23
23
|
p.readWhitespace();
|
|
24
|
-
expect(p.peek()).toBe(
|
|
24
|
+
expect(p.peek()).toBe('H');
|
|
25
25
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
type Position = '|' | '<' | '>';
|
|
2
2
|
export default Position;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type Node from
|
|
2
|
-
import BlockNode from
|
|
3
|
-
import type Position from
|
|
4
|
-
import FormatNode from
|
|
5
|
-
import BlocksNode from
|
|
6
|
-
import type { CaretRange } from
|
|
1
|
+
import type Node from './Node';
|
|
2
|
+
import BlockNode from './BlockNode';
|
|
3
|
+
import type Position from './Position';
|
|
4
|
+
import FormatNode from './FormatNode';
|
|
5
|
+
import BlocksNode from './BlocksNode';
|
|
6
|
+
import type { CaretRange } from './Caret';
|
|
7
7
|
export default class QuoteNode extends BlocksNode {
|
|
8
8
|
#private;
|
|
9
9
|
constructor(elements: BlockNode[], credit?: FormatNode, position?: Position);
|
|
@@ -1,27 +1,46 @@
|
|
|
1
|
-
import BlockNode from
|
|
2
|
-
import FormatNode from
|
|
3
|
-
import BlocksNode from
|
|
4
|
-
import TextNode from
|
|
1
|
+
import BlockNode from './BlockNode';
|
|
2
|
+
import FormatNode from './FormatNode';
|
|
3
|
+
import BlocksNode from './BlocksNode';
|
|
4
|
+
import TextNode from './TextNode';
|
|
5
5
|
export default class QuoteNode extends BlocksNode {
|
|
6
6
|
#credit;
|
|
7
7
|
#position;
|
|
8
|
-
constructor(elements, credit, position =
|
|
8
|
+
constructor(elements, credit, position = '|') {
|
|
9
9
|
super(elements);
|
|
10
10
|
this.#position = position;
|
|
11
|
-
this.#credit =
|
|
11
|
+
this.#credit =
|
|
12
|
+
credit === undefined
|
|
13
|
+
? new FormatNode('', [new TextNode()])
|
|
14
|
+
: credit.withTextIfEmpty();
|
|
15
|
+
}
|
|
16
|
+
getType() {
|
|
17
|
+
return 'quote';
|
|
18
|
+
}
|
|
19
|
+
getCredit() {
|
|
20
|
+
return this.#credit;
|
|
21
|
+
}
|
|
22
|
+
getPosition() {
|
|
23
|
+
return this.#position;
|
|
24
|
+
}
|
|
25
|
+
getFormats() {
|
|
26
|
+
return [this.#credit];
|
|
12
27
|
}
|
|
13
|
-
getType() { return "quote"; }
|
|
14
|
-
getCredit() { return this.#credit; }
|
|
15
|
-
getPosition() { return this.#position; }
|
|
16
|
-
getFormats() { return [this.#credit]; }
|
|
17
28
|
toText() {
|
|
18
|
-
return this.getBlocks()
|
|
29
|
+
return (this.getBlocks()
|
|
30
|
+
.map((element) => element.toText())
|
|
31
|
+
.join(' ') + (this.#credit ? ' ' + this.#credit.toText() : ''));
|
|
19
32
|
}
|
|
20
33
|
toBookdown() {
|
|
21
|
-
return `"\n${this.getBlocks()
|
|
34
|
+
return `"\n${this.getBlocks()
|
|
35
|
+
.map((element) => element.toBookdown())
|
|
36
|
+
.join('\n\n')}\n"${this.#position === '|' ? '' : this.#position}${this.#credit ? this.#credit.toBookdown() : ''}`;
|
|
37
|
+
}
|
|
38
|
+
toHTML() {
|
|
39
|
+
return `"${super.toHTML()}"<center>${this.#credit.toHTML()}</center>`;
|
|
40
|
+
}
|
|
41
|
+
getChildren() {
|
|
42
|
+
return [...this.getBlocks(), this.#credit];
|
|
22
43
|
}
|
|
23
|
-
toHTML() { return `"${super.toHTML()}"<center>${this.#credit.toHTML()}</center>`; }
|
|
24
|
-
getChildren() { return [...this.getBlocks(), this.#credit]; }
|
|
25
44
|
getParentOf(node) {
|
|
26
45
|
if (node === this.#credit)
|
|
27
46
|
return this;
|
|
@@ -30,11 +49,16 @@ export default class QuoteNode extends BlocksNode {
|
|
|
30
49
|
return creditParent;
|
|
31
50
|
return super.getParentOf(node);
|
|
32
51
|
}
|
|
33
|
-
copy() {
|
|
34
|
-
|
|
52
|
+
copy() {
|
|
53
|
+
return new QuoteNode(this.getBlocks().map((b) => b.copy()));
|
|
54
|
+
}
|
|
55
|
+
create(blocks) {
|
|
56
|
+
return new QuoteNode(blocks, this.#credit, this.#position);
|
|
57
|
+
}
|
|
35
58
|
withChildReplaced(node, replacement) {
|
|
36
59
|
// Replace the credit.
|
|
37
|
-
if (this.#credit === node &&
|
|
60
|
+
if (this.#credit === node &&
|
|
61
|
+
(replacement instanceof FormatNode || replacement === undefined))
|
|
38
62
|
return new QuoteNode(this.getBlocks(), replacement, this.#position);
|
|
39
63
|
// Replace a block.
|
|
40
64
|
if (replacement !== undefined && !(replacement instanceof BlockNode))
|
|
@@ -43,19 +67,33 @@ export default class QuoteNode extends BlocksNode {
|
|
|
43
67
|
if (index < 0)
|
|
44
68
|
return;
|
|
45
69
|
// Make a new blocks node, assigning and re-parenting the replacement.
|
|
46
|
-
const blocks = replacement === undefined
|
|
47
|
-
[
|
|
48
|
-
|
|
70
|
+
const blocks = replacement === undefined
|
|
71
|
+
? [
|
|
72
|
+
...this.getBlocks().slice(0, index),
|
|
73
|
+
...this.getBlocks().slice(index + 1),
|
|
74
|
+
]
|
|
75
|
+
: [
|
|
76
|
+
...this.getBlocks().slice(0, index),
|
|
77
|
+
replacement,
|
|
78
|
+
...this.getBlocks().slice(index + 1),
|
|
79
|
+
];
|
|
49
80
|
return new QuoteNode(blocks, this.#credit, this.#position);
|
|
50
81
|
}
|
|
51
|
-
withCredit(credit) {
|
|
52
|
-
|
|
82
|
+
withCredit(credit) {
|
|
83
|
+
return new QuoteNode(this.getBlocks(), credit, this.#position);
|
|
84
|
+
}
|
|
85
|
+
withPosition(position) {
|
|
86
|
+
return new QuoteNode(this.getBlocks(), this.#credit, position);
|
|
87
|
+
}
|
|
53
88
|
withContentInRange(range) {
|
|
54
89
|
// First get the blocks in range.
|
|
55
90
|
const newQuote = super.withContentInRange(range);
|
|
56
91
|
if (newQuote === undefined)
|
|
57
92
|
return;
|
|
58
|
-
const newCredit = this.getBlocks().find(b => b.contains(range.end.node)) !==
|
|
93
|
+
const newCredit = this.getBlocks().find((b) => b.contains(range.end.node)) !==
|
|
94
|
+
undefined
|
|
95
|
+
? new FormatNode('', [new TextNode()])
|
|
96
|
+
: this.#credit.withContentInRange(range);
|
|
59
97
|
return newQuote.withNodeReplaced(this.#credit, newCredit);
|
|
60
98
|
}
|
|
61
99
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type ChapterNode from
|
|
2
|
-
import type EmbedNode from
|
|
3
|
-
import type FormatNode from
|
|
4
|
-
|
|
1
|
+
import type ChapterNode from './ChapterNode';
|
|
2
|
+
import type EmbedNode from './EmbedNode';
|
|
3
|
+
import type FormatNode from './FormatNode';
|
|
4
|
+
type RootNode = ChapterNode | FormatNode | EmbedNode;
|
|
5
5
|
export default RootNode;
|
|
@@ -1,16 +1,36 @@
|
|
|
1
|
-
import BlockNode from
|
|
1
|
+
import BlockNode from './BlockNode';
|
|
2
2
|
export default class RuleNode extends BlockNode {
|
|
3
3
|
constructor() {
|
|
4
4
|
super();
|
|
5
5
|
}
|
|
6
|
-
getType() {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
getType() {
|
|
7
|
+
return 'rule';
|
|
8
|
+
}
|
|
9
|
+
toText() {
|
|
10
|
+
return '';
|
|
11
|
+
}
|
|
12
|
+
toBookdown() {
|
|
13
|
+
return '-';
|
|
14
|
+
}
|
|
15
|
+
toHTML() {
|
|
16
|
+
return `<hr/>`;
|
|
17
|
+
}
|
|
18
|
+
getParentOf() {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
getFormats() {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
getChildren() {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
copy() {
|
|
28
|
+
return new RuleNode();
|
|
29
|
+
}
|
|
30
|
+
withChildReplaced() {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
withContentInRange() {
|
|
34
|
+
return this.copy();
|
|
35
|
+
}
|
|
16
36
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type Node from
|
|
2
|
-
import type Position from
|
|
3
|
-
import FormatNode from
|
|
4
|
-
import BlockNode from
|
|
5
|
-
import type { CaretRange } from
|
|
6
|
-
|
|
1
|
+
import type Node from './Node';
|
|
2
|
+
import type Position from './Position';
|
|
3
|
+
import FormatNode from './FormatNode';
|
|
4
|
+
import BlockNode from './BlockNode';
|
|
5
|
+
import type { CaretRange } from './Caret';
|
|
6
|
+
type Location = {
|
|
7
7
|
row: number;
|
|
8
8
|
column: number;
|
|
9
9
|
};
|
|
@@ -17,6 +17,7 @@ export default class TableNode extends BlockNode {
|
|
|
17
17
|
getPosition(): Position;
|
|
18
18
|
getCaption(): FormatNode;
|
|
19
19
|
getFormats(): FormatNode[];
|
|
20
|
+
getNextCell(format: FormatNode, direction?: -1 | 1): FormatNode | undefined;
|
|
20
21
|
toText(): string;
|
|
21
22
|
toBookdown(): string;
|
|
22
23
|
toHTML(): string;
|
|
@@ -31,5 +32,6 @@ export default class TableNode extends BlockNode {
|
|
|
31
32
|
withoutColumn(index: number): TableNode | undefined;
|
|
32
33
|
withNewColumn(index: number): TableNode | undefined;
|
|
33
34
|
withContentInRange(range: CaretRange): this | undefined;
|
|
35
|
+
withPosition(position: Position): TableNode;
|
|
34
36
|
}
|
|
35
37
|
export {};
|
|
@@ -1,40 +1,83 @@
|
|
|
1
|
-
import FormatNode from
|
|
2
|
-
import TextNode from
|
|
3
|
-
import BlockNode from
|
|
1
|
+
import FormatNode from './FormatNode';
|
|
2
|
+
import TextNode from './TextNode';
|
|
3
|
+
import BlockNode from './BlockNode';
|
|
4
4
|
export default class TableNode extends BlockNode {
|
|
5
5
|
#rows;
|
|
6
6
|
#caption;
|
|
7
7
|
#position;
|
|
8
8
|
constructor(rows, position, caption) {
|
|
9
9
|
super();
|
|
10
|
-
this.#rows = rows.map(r => r.map(c => c.withTextIfEmpty()));
|
|
11
|
-
this.#position = position ? position :
|
|
12
|
-
this.#caption =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
this.#rows = rows.map((r) => r.map((c) => c.withTextIfEmpty()));
|
|
11
|
+
this.#position = position ? position : '|';
|
|
12
|
+
this.#caption =
|
|
13
|
+
caption === undefined
|
|
14
|
+
? new FormatNode('', [new TextNode()])
|
|
15
|
+
: caption.withTextIfEmpty();
|
|
16
|
+
}
|
|
17
|
+
getType() {
|
|
18
|
+
return 'table';
|
|
19
|
+
}
|
|
20
|
+
getRows() {
|
|
21
|
+
return this.#rows;
|
|
22
|
+
}
|
|
23
|
+
getRowCount() {
|
|
24
|
+
return this.#rows.length;
|
|
25
|
+
}
|
|
26
|
+
getColumnCount() {
|
|
27
|
+
return this.#rows.length === 0 ? 0 : this.#rows[0].length;
|
|
28
|
+
}
|
|
29
|
+
getPosition() {
|
|
30
|
+
return this.#position;
|
|
31
|
+
}
|
|
32
|
+
getCaption() {
|
|
33
|
+
return this.#caption;
|
|
34
|
+
}
|
|
20
35
|
getFormats() {
|
|
21
36
|
const formats = [];
|
|
22
|
-
this.#rows.forEach(row => row.forEach(cell => {
|
|
37
|
+
this.#rows.forEach((row) => row.forEach((cell) => {
|
|
38
|
+
formats.push(cell);
|
|
39
|
+
}));
|
|
23
40
|
return [...formats, this.#caption];
|
|
24
41
|
}
|
|
42
|
+
getNextCell(format, direction = 1) {
|
|
43
|
+
let previous = undefined;
|
|
44
|
+
let found = false;
|
|
45
|
+
for (const row of this.#rows) {
|
|
46
|
+
for (const cell of row) {
|
|
47
|
+
if (found)
|
|
48
|
+
return cell;
|
|
49
|
+
if (cell === format) {
|
|
50
|
+
if (direction > 0)
|
|
51
|
+
found = true;
|
|
52
|
+
else
|
|
53
|
+
return previous;
|
|
54
|
+
}
|
|
55
|
+
previous = cell;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
25
60
|
toText() {
|
|
26
|
-
return this.#rows
|
|
61
|
+
return this.#rows
|
|
62
|
+
.map((row) => row.map((cell) => cell.toText()).join(', '))
|
|
63
|
+
.join(', ');
|
|
27
64
|
}
|
|
28
65
|
toBookdown() {
|
|
29
|
-
return this.#rows
|
|
30
|
-
|
|
66
|
+
return (this.#rows
|
|
67
|
+
.map((row) => `,${row.map((cell) => cell.toBookdown()).join('|')}`)
|
|
68
|
+
.join('\n') +
|
|
69
|
+
`\n${this.#position === '|' ? '' : this.#position}${this.#caption ? '' + this.#caption.toBookdown() : ''}`);
|
|
31
70
|
}
|
|
32
71
|
toHTML() {
|
|
33
|
-
return `<table><tbody>${this.#rows
|
|
72
|
+
return `<table><tbody>${this.#rows
|
|
73
|
+
.map((row) => `<tr>${row
|
|
74
|
+
.map((cell) => `<td>${cell.toHTML()}</td>`)
|
|
75
|
+
.join('')}`)
|
|
76
|
+
.join('')}</tbody></table><center>${this.#caption.toHTML()}</center>`;
|
|
34
77
|
}
|
|
35
78
|
getChildren() {
|
|
36
79
|
const children = [];
|
|
37
|
-
this.#rows.forEach(row => row.forEach(cell => children.push(cell)));
|
|
80
|
+
this.#rows.forEach((row) => row.forEach((cell) => children.push(cell)));
|
|
38
81
|
children.push(this.#caption);
|
|
39
82
|
return children;
|
|
40
83
|
}
|
|
@@ -48,9 +91,13 @@ export default class TableNode extends BlockNode {
|
|
|
48
91
|
}
|
|
49
92
|
}
|
|
50
93
|
getCell(row, col) {
|
|
51
|
-
return row >= 0 &&
|
|
52
|
-
this.#rows
|
|
53
|
-
|
|
94
|
+
return row >= 0 &&
|
|
95
|
+
row < this.#rows.length &&
|
|
96
|
+
this.#rows.length > 0 &&
|
|
97
|
+
col >= 0 &&
|
|
98
|
+
col < this.#rows[0].length
|
|
99
|
+
? this.#rows[row][col]
|
|
100
|
+
: undefined;
|
|
54
101
|
}
|
|
55
102
|
getParentOf(node) {
|
|
56
103
|
for (let r = 0; r < this.#rows.length; r++) {
|
|
@@ -67,16 +114,17 @@ export default class TableNode extends BlockNode {
|
|
|
67
114
|
}
|
|
68
115
|
copy() {
|
|
69
116
|
const rows = [];
|
|
70
|
-
this.#rows.forEach(row => {
|
|
117
|
+
this.#rows.forEach((row) => {
|
|
71
118
|
const cells = [];
|
|
72
|
-
row.forEach(cell => cells.push(cell.copy()));
|
|
119
|
+
row.forEach((cell) => cells.push(cell.copy()));
|
|
73
120
|
rows.push(cells);
|
|
74
121
|
});
|
|
75
122
|
return new TableNode(rows, this.#position, this.#caption ? this.#caption.copy() : undefined);
|
|
76
123
|
}
|
|
77
124
|
withChildReplaced(node, replacement) {
|
|
78
125
|
// If it's just the caption, make a new node with the new credit.
|
|
79
|
-
if (node === this.#caption &&
|
|
126
|
+
if (node === this.#caption &&
|
|
127
|
+
(replacement instanceof FormatNode || replacement === undefined))
|
|
80
128
|
return new TableNode(this.#rows, this.#position, replacement);
|
|
81
129
|
// If it's a cell, update the cell.
|
|
82
130
|
if (node instanceof FormatNode && replacement instanceof FormatNode) {
|
|
@@ -90,7 +138,7 @@ export default class TableNode extends BlockNode {
|
|
|
90
138
|
}
|
|
91
139
|
// Make new rows with the updated cell.
|
|
92
140
|
if (updateRow < this.#rows.length && updateColumn >= 0) {
|
|
93
|
-
const newRows = this.#rows.map(row => [...row]);
|
|
141
|
+
const newRows = this.#rows.map((row) => [...row]);
|
|
94
142
|
newRows[updateRow][updateColumn] = replacement;
|
|
95
143
|
return new TableNode(newRows, this.#position, this.#caption);
|
|
96
144
|
}
|
|
@@ -104,7 +152,7 @@ export default class TableNode extends BlockNode {
|
|
|
104
152
|
const columnCount = this.#rows.length === 0 ? 0 : this.#rows[0].length;
|
|
105
153
|
const column = [];
|
|
106
154
|
for (let c = 0; c < columnCount; c++)
|
|
107
|
-
column.push(new FormatNode(
|
|
155
|
+
column.push(new FormatNode('', [new TextNode()]));
|
|
108
156
|
const newRows = this.#rows.slice();
|
|
109
157
|
newRows.splice(index, 0, column);
|
|
110
158
|
return new TableNode(newRows, this.#position, this.#caption);
|
|
@@ -125,13 +173,14 @@ export default class TableNode extends BlockNode {
|
|
|
125
173
|
return new TableNode(newRows, this.#position, this.#caption);
|
|
126
174
|
}
|
|
127
175
|
withNewColumn(index) {
|
|
128
|
-
if (this.#rows.length > 0 &&
|
|
176
|
+
if (this.#rows.length > 0 &&
|
|
177
|
+
(index < 0 || index > this.#rows[0].length))
|
|
129
178
|
return;
|
|
130
|
-
// Figure out how many rows the table has and add a column
|
|
179
|
+
// Figure out how many rows the table has and add a column
|
|
131
180
|
const newRows = this.#rows.slice();
|
|
132
181
|
for (let r = 0; r < this.#rows.length; r++) {
|
|
133
182
|
newRows[r] = newRows[r].slice();
|
|
134
|
-
newRows[r].splice(index, 0, new FormatNode(
|
|
183
|
+
newRows[r].splice(index, 0, new FormatNode('', [new TextNode()]));
|
|
135
184
|
}
|
|
136
185
|
return new TableNode(newRows, this.#position, this.#caption);
|
|
137
186
|
}
|
|
@@ -149,7 +198,9 @@ export default class TableNode extends BlockNode {
|
|
|
149
198
|
for (; r < this.#rows.length; r++, c = 0) {
|
|
150
199
|
const row = this.#rows[r];
|
|
151
200
|
// Skip this row if this table contains the start node and we haven't found it and the row doesn't contain it
|
|
152
|
-
if (containsStart &&
|
|
201
|
+
if (containsStart &&
|
|
202
|
+
!foundStart &&
|
|
203
|
+
row.find((r) => r.contains(range.start.node)) === undefined)
|
|
153
204
|
continue;
|
|
154
205
|
// Stop if we found the end row.
|
|
155
206
|
if (containsEnd && foundEnd)
|
|
@@ -161,9 +212,10 @@ export default class TableNode extends BlockNode {
|
|
|
161
212
|
const newCell = row[c].withContentInRange(range);
|
|
162
213
|
if (newCell === undefined)
|
|
163
214
|
return;
|
|
164
|
-
newRows[newRows.length - 1].push(((
|
|
165
|
-
|
|
166
|
-
|
|
215
|
+
newRows[newRows.length - 1].push(((containsStart && foundStart) || !containsStart) &&
|
|
216
|
+
((containsEnd && !foundEnd) || !containsEnd)
|
|
217
|
+
? newCell
|
|
218
|
+
: new FormatNode('', [new TextNode()]));
|
|
167
219
|
if (row[c].contains(range.end.node))
|
|
168
220
|
foundEnd = true;
|
|
169
221
|
}
|
|
@@ -173,4 +225,7 @@ export default class TableNode extends BlockNode {
|
|
|
173
225
|
return;
|
|
174
226
|
return new TableNode(newRows, this.#position, newCaption);
|
|
175
227
|
}
|
|
228
|
+
withPosition(position) {
|
|
229
|
+
return new TableNode(this.#rows, position, this.#caption);
|
|
230
|
+
}
|
|
176
231
|
}
|
|
@@ -1,31 +1,29 @@
|
|
|
1
1
|
import { test, expect } from 'vitest';
|
|
2
|
-
import FormatNode from
|
|
3
|
-
import TextNode from
|
|
4
|
-
import TableNode from
|
|
5
|
-
const tl = new FormatNode(
|
|
6
|
-
const tr = new FormatNode(
|
|
7
|
-
const bl = new FormatNode(
|
|
8
|
-
const br = new FormatNode(
|
|
9
|
-
const caption = new FormatNode(
|
|
2
|
+
import FormatNode from './FormatNode';
|
|
3
|
+
import TextNode from './TextNode';
|
|
4
|
+
import TableNode from './TableNode';
|
|
5
|
+
const tl = new FormatNode('', [new TextNode('tl')]);
|
|
6
|
+
const tr = new FormatNode('', [new TextNode('tr')]);
|
|
7
|
+
const bl = new FormatNode('', [new TextNode('bl')]);
|
|
8
|
+
const br = new FormatNode('', [new TextNode('br')]);
|
|
9
|
+
const caption = new FormatNode('', [new TextNode('hi')]);
|
|
10
10
|
const table = new TableNode([
|
|
11
11
|
[tl, tr],
|
|
12
12
|
[bl, br],
|
|
13
|
-
],
|
|
14
|
-
test(
|
|
15
|
-
expect(table
|
|
16
|
-
.
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
], '|', caption);
|
|
14
|
+
test('Replace', () => {
|
|
15
|
+
expect(table
|
|
16
|
+
.withChildReplaced(tl, new FormatNode('', [new TextNode('new')]))
|
|
17
|
+
?.toBookdown()).toBe(',new|tr\n,bl|br\nhi');
|
|
18
|
+
expect(table
|
|
19
|
+
.withChildReplaced(caption, new FormatNode('', [new TextNode('bye')]))
|
|
20
|
+
?.toBookdown()).toBe(',tl|tr\n,bl|br\nbye');
|
|
19
21
|
});
|
|
20
|
-
test(
|
|
21
|
-
expect(table.withNewRow(0)?.toBookdown())
|
|
22
|
-
|
|
23
|
-
expect(table.withNewColumn(0)?.toBookdown())
|
|
24
|
-
.toBe(",|tl|tr\n,|bl|br\nhi");
|
|
22
|
+
test('Insert', () => {
|
|
23
|
+
expect(table.withNewRow(0)?.toBookdown()).toBe(',|\n,tl|tr\n,bl|br\nhi');
|
|
24
|
+
expect(table.withNewColumn(0)?.toBookdown()).toBe(',|tl|tr\n,|bl|br\nhi');
|
|
25
25
|
});
|
|
26
|
-
test(
|
|
27
|
-
expect(table.withoutRow(0)?.toBookdown())
|
|
28
|
-
|
|
29
|
-
expect(table.withoutColumn(0)?.toBookdown())
|
|
30
|
-
.toBe(",tr\n,br\nhi");
|
|
26
|
+
test('Delete', () => {
|
|
27
|
+
expect(table.withoutRow(0)?.toBookdown()).toBe(',bl|br\nhi');
|
|
28
|
+
expect(table.withoutColumn(0)?.toBookdown()).toBe(',tr\n,br\nhi');
|
|
31
29
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type Caret from
|
|
2
|
-
import type { CaretRange } from
|
|
3
|
-
import FormatNode from
|
|
4
|
-
import Node from
|
|
5
|
-
import BlocksNode from
|
|
6
|
-
import type RootNode from
|
|
1
|
+
import type Caret from './Caret';
|
|
2
|
+
import type { CaretRange } from './Caret';
|
|
3
|
+
import FormatNode from './FormatNode';
|
|
4
|
+
import Node from './Node';
|
|
5
|
+
import BlocksNode from './BlocksNode';
|
|
6
|
+
import type RootNode from './RootNode';
|
|
7
7
|
export default class TextNode extends Node {
|
|
8
8
|
#private;
|
|
9
9
|
constructor(text?: string);
|