bookish-press 0.4.47 → 0.4.49
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/components/Auth.svelte +55 -0
- package/components/Auth.svelte.d.ts +16 -0
- package/{src/lib/components/Authentication.ts → components/Authentication.d.ts} +0 -2
- package/components/Authentication.js +1 -0
- package/{src/lib/components → components}/BookPreview.svelte +22 -27
- package/components/BookPreview.svelte.d.ts +18 -0
- package/{src/lib/components → components}/External.svelte +1 -2
- package/components/External.svelte.d.ts +18 -0
- package/components/Link.svelte +51 -0
- package/components/Link.svelte.d.ts +18 -0
- package/{src/lib/components → components}/app/BookList.svelte +3 -6
- package/components/app/BookList.svelte.d.ts +18 -0
- package/{src/lib/components → components}/app/Button.svelte +4 -5
- package/components/app/Button.svelte.d.ts +22 -0
- package/{src/lib/components → components}/app/Feedback.svelte +7 -11
- package/components/app/Feedback.svelte.d.ts +18 -0
- package/{src/lib/components → components}/app/Head.svelte +1 -2
- package/components/app/Head.svelte.d.ts +18 -0
- package/{src/lib/components → components}/app/Large.svelte +0 -0
- package/components/app/Large.svelte.d.ts +27 -0
- package/{src/lib/components → components}/app/Lead.svelte +0 -0
- package/components/app/Lead.svelte.d.ts +27 -0
- package/{src/lib/components → components}/app/Link.svelte +3 -4
- package/components/app/Link.svelte.d.ts +20 -0
- package/{src/lib/components → components}/app/Options.svelte +4 -5
- package/components/app/Options.svelte.d.ts +19 -0
- package/{src/lib/components → components}/app/Paragraph.svelte +1 -2
- package/components/app/Paragraph.svelte.d.ts +18 -0
- package/{src/lib/components → components}/app/Section.svelte +0 -0
- package/components/app/Section.svelte.d.ts +27 -0
- package/{src/lib/components → components}/app/Table.svelte +0 -0
- package/components/app/Table.svelte.d.ts +27 -0
- package/{src/lib/components → components}/app/TextInput.svelte +9 -12
- package/components/app/TextInput.svelte.d.ts +22 -0
- package/{src/lib/components → components}/chapter/Atom.svelte +12 -18
- package/components/chapter/Atom.svelte.d.ts +19 -0
- package/components/chapter/Block.svelte +37 -0
- package/components/chapter/Block.svelte.d.ts +17 -0
- package/{src/lib/components → components}/chapter/Callout.svelte +3 -6
- package/components/chapter/Callout.svelte.d.ts +17 -0
- package/{src/lib/components → components}/chapter/CaptionedCode.svelte +13 -21
- package/components/chapter/CaptionedCode.svelte.d.ts +17 -0
- package/{src/lib/components → components}/chapter/ChapterBody.svelte +9 -13
- package/components/chapter/ChapterBody.svelte.d.ts +19 -0
- package/{src/lib/components → components}/chapter/Citations.svelte +33 -34
- package/components/chapter/Citations.svelte.d.ts +17 -0
- package/{src/lib/components → components}/chapter/Code.svelte +60 -64
- package/components/chapter/Code.svelte.d.ts +22 -0
- package/{src/lib/components → components}/chapter/Comment.svelte +18 -30
- package/components/chapter/Comment.svelte.d.ts +17 -0
- package/{src/lib/components → components}/chapter/Definition.svelte +17 -23
- package/components/chapter/Definition.svelte.d.ts +17 -0
- package/{src/lib/components → components}/chapter/Embed.svelte +77 -97
- package/components/chapter/Embed.svelte.d.ts +20 -0
- package/components/chapter/ErrorMessage.svelte +9 -0
- package/components/chapter/ErrorMessage.svelte.d.ts +17 -0
- package/components/chapter/ExtendedPrism.d.ts +2 -0
- package/{src/lib/components → components}/chapter/ExtendedPrism.js +0 -0
- package/{src/lib/components → components}/chapter/Figure.svelte +26 -34
- package/components/chapter/Figure.svelte.d.ts +24 -0
- package/{src/lib/components → components}/chapter/Footnote.svelte +20 -32
- package/components/chapter/Footnote.svelte.d.ts +19 -0
- package/{src/lib/components → components}/chapter/Format.svelte +34 -39
- package/components/chapter/Format.svelte.d.ts +19 -0
- package/{src/lib/components → components}/chapter/InlineCode.svelte +5 -9
- package/components/chapter/InlineCode.svelte.d.ts +17 -0
- package/{src/lib/components → components}/chapter/Label.svelte +14 -23
- package/components/chapter/Label.svelte.d.ts +17 -0
- package/{src/lib/components → components}/chapter/Link.svelte +21 -27
- package/components/chapter/Link.svelte.d.ts +17 -0
- package/{src/lib/components → components}/chapter/List.svelte +3 -5
- package/components/chapter/List.svelte.d.ts +17 -0
- package/{src/lib/components → components}/chapter/Marginal.svelte +41 -54
- package/components/chapter/Marginal.svelte.d.ts +22 -0
- package/{src/lib/components → components}/chapter/Paragraph.svelte +20 -25
- package/components/chapter/Paragraph.svelte.d.ts +18 -0
- package/{src/lib/components → components}/chapter/Positioned.svelte +1 -4
- package/components/chapter/Positioned.svelte.d.ts +19 -0
- package/{src/lib/components → components}/chapter/Problem.svelte +0 -0
- package/components/chapter/Problem.svelte.d.ts +27 -0
- package/components/chapter/Python.svelte +128 -0
- package/components/chapter/Python.svelte.d.ts +18 -0
- package/{src/lib/components → components}/chapter/Quote.svelte +19 -13
- package/components/chapter/Quote.svelte.d.ts +17 -0
- package/{src/lib/components → components}/chapter/Rule.svelte +1 -4
- package/components/chapter/Rule.svelte.d.ts +17 -0
- package/{src/lib/components → components}/chapter/Table.svelte +7 -11
- package/components/chapter/Table.svelte.d.ts +17 -0
- package/components/chapter/Text.svelte +87 -0
- package/components/chapter/Text.svelte.d.ts +18 -0
- package/components/editor/BookishEditor.svelte +884 -0
- package/components/editor/BookishEditor.svelte.d.ts +25 -0
- package/components/editor/CalloutEditor.svelte +10 -0
- package/components/editor/CalloutEditor.svelte.d.ts +17 -0
- package/{src/lib/components → components}/editor/CaptionedCodeEditor.svelte +6 -10
- package/components/editor/CaptionedCodeEditor.svelte.d.ts +17 -0
- package/components/editor/CaretContext.d.ts +50 -0
- package/components/editor/CaretContext.js +1 -0
- package/{src/lib/components/editor/CaretState.ts → components/editor/CaretState.d.ts} +7 -6
- package/components/editor/CaretState.js +1 -0
- package/{src/lib/components/editor/CaretUtilities.ts → components/editor/CaretUtilities.d.ts} +0 -1
- package/components/editor/CaretUtilities.js +1 -0
- package/{src/lib/components → components}/editor/CaretView.svelte +20 -25
- package/components/editor/CaretView.svelte.d.ts +25 -0
- package/components/editor/CitationsEditor.svelte +53 -0
- package/components/editor/CitationsEditor.svelte.d.ts +17 -0
- package/{src/lib/components/editor/Clipboard.ts → components/editor/Clipboard.d.ts} +1 -2
- package/components/editor/Clipboard.js +1 -0
- package/{src/lib/components/editor/Command.ts → components/editor/Command.d.ts} +2 -8
- package/components/editor/Command.js +1 -0
- package/components/editor/Commands.d.ts +3 -0
- package/{src/lib/components/editor/Commands.ts → components/editor/Commands.js} +315 -730
- package/components/editor/ConfirmButton.svelte +49 -0
- package/components/editor/ConfirmButton.svelte.d.ts +19 -0
- package/components/editor/DefinitionEditor.svelte +36 -0
- package/components/editor/DefinitionEditor.svelte.d.ts +17 -0
- package/components/editor/EmbedEditor.svelte +137 -0
- package/components/editor/EmbedEditor.svelte.d.ts +17 -0
- package/{src/lib/components → components}/editor/Icon.svelte +1 -2
- package/components/editor/Icon.svelte.d.ts +16 -0
- package/{src/lib/components → components}/editor/ImageChooser.svelte +19 -24
- package/components/editor/ImageChooser.svelte.d.ts +18 -0
- package/components/editor/InlineCodeEditor.svelte +12 -0
- package/components/editor/InlineCodeEditor.svelte.d.ts +17 -0
- package/{src/lib/components → components}/editor/LabelEditor.svelte +9 -14
- package/components/editor/LabelEditor.svelte.d.ts +17 -0
- package/{src/lib/components → components}/editor/LanguageEditor.svelte +5 -8
- package/components/editor/LanguageEditor.svelte.d.ts +17 -0
- package/components/editor/LinkEditor.svelte +100 -0
- package/components/editor/LinkEditor.svelte.d.ts +17 -0
- package/{src/lib/components → components}/editor/Note.svelte +0 -0
- package/components/editor/Note.svelte.d.ts +27 -0
- package/{src/lib/components → components}/editor/Permissions.svelte +36 -43
- package/components/editor/Permissions.svelte.d.ts +20 -0
- package/components/editor/PositionEditor.svelte +17 -0
- package/components/editor/PositionEditor.svelte.d.ts +18 -0
- package/components/editor/QuoteEditor.svelte +10 -0
- package/components/editor/QuoteEditor.svelte.d.ts +17 -0
- package/{src/lib/components → components}/editor/Switch.svelte +11 -14
- package/components/editor/Switch.svelte.d.ts +20 -0
- package/components/editor/TableEditor.svelte +10 -0
- package/components/editor/TableEditor.svelte.d.ts +17 -0
- package/{src/lib/components → components}/editor/TextEditor.svelte +89 -101
- package/components/editor/TextEditor.svelte.d.ts +24 -0
- package/components/editor/Toggle.svelte +41 -0
- package/components/editor/Toggle.svelte.d.ts +19 -0
- package/components/editor/Toolbar.svelte +249 -0
- package/components/editor/Toolbar.svelte.d.ts +17 -0
- package/{src/lib/components → components}/editor/ToolbarGroup.svelte +3 -5
- package/components/editor/ToolbarGroup.svelte.d.ts +18 -0
- package/{src/lib/components → components}/editor/ToolbarSpacer.svelte +0 -0
- package/components/editor/ToolbarSpacer.svelte.d.ts +23 -0
- package/components/editor/URLEditor.svelte +13 -0
- package/components/editor/URLEditor.svelte.d.ts +18 -0
- package/{src/lib/components/editor/UndoState.ts → components/editor/UndoState.d.ts} +2 -3
- package/components/editor/UndoState.js +1 -0
- package/{src/lib/components → components}/editor/icons/annotate.svg +0 -0
- package/{src/lib/components → components}/editor/icons/block.svg +0 -0
- package/{src/lib/components → components}/editor/icons/bold.svg +0 -0
- package/{src/lib/components → components}/editor/icons/bullets.svg +0 -0
- package/{src/lib/components → components}/editor/icons/callout.svg +0 -0
- package/{src/lib/components → components}/editor/icons/citation.svg +0 -0
- package/{src/lib/components → components}/editor/icons/clear.svg +0 -0
- package/{src/lib/components → components}/editor/icons/clipboard.svg +0 -0
- package/{src/lib/components → components}/editor/icons/code.svg +0 -0
- package/{src/lib/components → components}/editor/icons/columnafter.svg +0 -0
- package/{src/lib/components → components}/editor/icons/columnbefore.svg +0 -0
- package/{src/lib/components → components}/editor/icons/comment.svg +0 -0
- package/{src/lib/components → components}/editor/icons/copy.svg +0 -0
- package/{src/lib/components → components}/editor/icons/cut.svg +0 -0
- package/{src/lib/components → components}/editor/icons/define.svg +0 -0
- package/{src/lib/components → components}/editor/icons/deletecolumn.svg +0 -0
- package/{src/lib/components → components}/editor/icons/deleterow.svg +0 -0
- package/{src/lib/components → components}/editor/icons/footnote.svg +0 -0
- package/{src/lib/components → components}/editor/icons/header1.svg +0 -0
- package/{src/lib/components → components}/editor/icons/header2.svg +0 -0
- package/{src/lib/components → components}/editor/icons/header3.svg +0 -0
- package/{src/lib/components → components}/editor/icons/home.svg +0 -0
- package/{src/lib/components → components}/editor/icons/indent.svg +0 -0
- package/{src/lib/components → components}/editor/icons/italic.svg +0 -0
- package/{src/lib/components → components}/editor/icons/label.svg +0 -0
- package/{src/lib/components → components}/editor/icons/left.svg +0 -0
- package/{src/lib/components → components}/editor/icons/level.svg +0 -0
- package/{src/lib/components → components}/editor/icons/link.svg +0 -0
- package/{src/lib/components → components}/editor/icons/list.svg +0 -0
- package/{src/lib/components → components}/editor/icons/media.svg +0 -0
- package/{src/lib/components → components}/editor/icons/middle.svg +0 -0
- package/{src/lib/components → components}/editor/icons/numbers.svg +0 -0
- package/{src/lib/components → components}/editor/icons/paragraph.svg +0 -0
- package/{src/lib/components → components}/editor/icons/paste.svg +0 -0
- package/{src/lib/components → components}/editor/icons/quote.svg +0 -0
- package/{src/lib/components → components}/editor/icons/redo.svg +0 -0
- package/{src/lib/components → components}/editor/icons/right.svg +0 -0
- package/{src/lib/components → components}/editor/icons/rowabove.svg +0 -0
- package/{src/lib/components → components}/editor/icons/rowbelow.svg +0 -0
- package/{src/lib/components → components}/editor/icons/rule.svg +0 -0
- package/{src/lib/components → components}/editor/icons/sub.svg +0 -0
- package/{src/lib/components → components}/editor/icons/super.svg +0 -0
- package/{src/lib/components → components}/editor/icons/table.svg +0 -0
- package/{src/lib/components → components}/editor/icons/text.svg +0 -0
- package/{src/lib/components → components}/editor/icons/time.svg +0 -0
- package/{src/lib/components → components}/editor/icons/undo.svg +0 -0
- package/{src/lib/components → components}/editor/icons/unindent.svg +0 -0
- package/{src/lib/components → components}/editor/icons/unlink.svg +0 -0
- package/{src/lib/components → components}/page/Acknowledgements.svelte +10 -19
- package/components/page/Acknowledgements.svelte.d.ts +14 -0
- package/components/page/Authors.svelte +85 -0
- package/components/page/Authors.svelte.d.ts +21 -0
- package/components/page/BookLoader.svelte +59 -0
- package/components/page/BookLoader.svelte.d.ts +16 -0
- package/components/page/BulkReferenceEditor.svelte +63 -0
- package/components/page/BulkReferenceEditor.svelte.d.ts +14 -0
- package/components/page/Chapter.svelte +393 -0
- package/components/page/Chapter.svelte.d.ts +18 -0
- package/components/page/ChapterContext.d.ts +10 -0
- package/components/page/ChapterContext.js +1 -0
- package/{src/lib/components → components}/page/ChapterNumber.svelte +0 -0
- package/components/page/ChapterNumber.svelte.d.ts +27 -0
- package/{src/lib/components → components}/page/ChapterTitle.svelte +2 -4
- package/components/page/ChapterTitle.svelte.d.ts +18 -0
- package/components/page/Contexts.d.ts +47 -0
- package/components/page/Contexts.js +133 -0
- package/{src/lib/components → components}/page/DefinitionView.svelte +38 -53
- package/components/page/DefinitionView.svelte.d.ts +18 -0
- package/{src/lib/components → components}/page/Description.svelte +7 -15
- package/components/page/Description.svelte.d.ts +14 -0
- package/components/page/Edition.svelte +161 -0
- package/components/page/Edition.svelte.d.ts +20 -0
- package/components/page/EditionLoader.svelte +99 -0
- package/components/page/EditionLoader.svelte.d.ts +18 -0
- package/{src/lib/components → components}/page/Editions.svelte +18 -22
- package/components/page/Editions.svelte.d.ts +14 -0
- package/{src/lib/components → components}/page/Glossary.svelte +28 -33
- package/components/page/Glossary.svelte.d.ts +14 -0
- package/{src/lib/components → components}/page/Header.svelte +52 -59
- package/components/page/Header.svelte.d.ts +29 -0
- package/{src/lib/components → components}/page/Index.svelte +47 -50
- package/components/page/Index.svelte.d.ts +14 -0
- package/{src/lib/components → components}/page/Instructions.svelte +1 -2
- package/components/page/Instructions.svelte.d.ts +18 -0
- package/{src/lib/components → components}/page/License.svelte +9 -17
- package/components/page/License.svelte.d.ts +14 -0
- package/{src/lib/components → components}/page/Loading.svelte +0 -0
- package/components/page/Loading.svelte.d.ts +23 -0
- package/{src/lib/components → components}/page/Media.svelte +27 -44
- package/components/page/Media.svelte.d.ts +14 -0
- package/{src/lib/components → components}/page/MediaPreview.svelte +2 -3
- package/components/page/MediaPreview.svelte.d.ts +19 -0
- package/{src/lib/components → components}/page/Muted.svelte +0 -0
- package/components/page/Muted.svelte.d.ts +27 -0
- package/{src/lib/components → components}/page/Outline.svelte +110 -140
- package/components/page/Outline.svelte.d.ts +19 -0
- package/components/page/Page.svelte +84 -0
- package/components/page/Page.svelte.d.ts +19 -0
- package/{src/lib/components → components}/page/PageHeader.svelte +1 -2
- package/components/page/PageHeader.svelte.d.ts +18 -0
- package/{src/lib/components → components}/page/PageParagraph.svelte +0 -0
- package/components/page/PageParagraph.svelte.d.ts +27 -0
- package/components/page/PossibleChapter.svelte +14 -0
- package/components/page/PossibleChapter.svelte.d.ts +14 -0
- package/components/page/PossibleReference.svelte +11 -0
- package/components/page/PossibleReference.svelte.d.ts +18 -0
- package/{src/lib/components → components}/page/Print.svelte +3 -5
- package/components/page/Print.svelte.d.ts +14 -0
- package/{src/lib/components → components}/page/Publish.svelte +52 -59
- package/components/page/Publish.svelte.d.ts +14 -0
- package/{src/lib/components → components}/page/Reference.svelte +30 -39
- package/components/page/Reference.svelte.d.ts +17 -0
- package/{src/lib/components → components}/page/References.svelte +14 -18
- package/components/page/References.svelte.d.ts +14 -0
- package/{src/lib/components → components}/page/Rows.svelte +0 -0
- package/components/page/Rows.svelte.d.ts +27 -0
- package/components/page/Search.svelte +133 -0
- package/components/page/Search.svelte.d.ts +14 -0
- package/{src/lib/components → components}/page/Status.svelte +3 -5
- package/components/page/Status.svelte.d.ts +14 -0
- package/{src/lib/components → components}/page/SubdomainEditor.svelte +13 -16
- package/components/page/SubdomainEditor.svelte.d.ts +14 -0
- package/{src/lib/components → components}/page/TableOfContents.svelte +68 -79
- package/components/page/TableOfContents.svelte.d.ts +14 -0
- package/components/page/TableOfContentsImage.svelte +18 -0
- package/components/page/TableOfContentsImage.svelte.d.ts +16 -0
- package/{src/lib/components → components}/page/TableOfContentsRow.svelte +24 -34
- package/components/page/TableOfContentsRow.svelte.d.ts +24 -0
- package/{src/lib/components → components}/page/ThemeEditor.svelte +33 -44
- package/components/page/ThemeEditor.svelte.d.ts +14 -0
- package/{src/lib/components → components}/page/ThemeEditorPreview.svelte +12 -21
- package/components/page/ThemeEditorPreview.svelte.d.ts +17 -0
- package/components/page/ThemeSetEditor.svelte +19 -0
- package/components/page/ThemeSetEditor.svelte.d.ts +18 -0
- package/{src/lib/components → components}/page/ThemeVariableEditor.svelte +14 -18
- package/components/page/ThemeVariableEditor.svelte.d.ts +18 -0
- package/{src/lib/components → components}/page/Title.svelte +0 -0
- package/components/page/Title.svelte.d.ts +27 -0
- package/{src/lib/components → components}/page/Unknown.svelte +8 -10
- package/components/page/Unknown.svelte.d.ts +16 -0
- package/components/page/margins.d.ts +2 -0
- package/{src/lib/components/page/margins.ts → components/page/margins.js} +46 -79
- package/index.d.ts +15 -0
- package/{src/lib/index.js → index.js} +0 -0
- package/models/CRUD.d.ts +27 -0
- package/models/CRUD.js +262 -0
- package/models/Firebase.d.ts +5 -0
- package/{src/lib/models/Firebase.ts → models/Firebase.js} +16 -26
- package/models/book/Book.d.ts +61 -0
- package/models/book/Book.js +135 -0
- package/models/book/BookMedia.d.ts +23 -0
- package/models/book/BookMedia.js +108 -0
- package/models/book/BookSaveStatus.d.ts +7 -0
- package/models/book/BookSaveStatus.js +8 -0
- package/models/book/Chapter.d.ts +81 -0
- package/models/book/Chapter.js +212 -0
- package/models/book/ChapterID.d.ts +10 -0
- package/{src/lib/models/book/ChapterID.ts → models/book/ChapterID.js} +0 -1
- package/models/book/Definition.d.ts +6 -0
- package/models/book/Definition.js +1 -0
- package/models/book/Edition.d.ts +139 -0
- package/models/book/Edition.js +620 -0
- package/models/book/Reference.d.ts +24 -0
- package/models/book/Reference.js +78 -0
- package/models/book/Schema.d.ts +174 -0
- package/{src/lib/models/book/Schema.ts → models/book/Schema.js} +0 -1
- package/models/book/Theme.d.ts +113 -0
- package/{src/lib/models/book/Theme.ts → models/book/Theme.js} +6 -110
- package/{src/lib/models/book/ThemeColors.ts → models/book/ThemeColors.d.ts} +0 -6
- package/models/book/ThemeColors.js +1 -0
- package/models/book/Words.d.ts +2 -0
- package/{src/lib/models/book/Words.ts → models/book/Words.js} +0 -1
- package/models/chapter/AtomNode.d.ts +18 -0
- package/{src/lib/models/chapter/AtomNode.ts → models/chapter/AtomNode.js} +10 -30
- package/models/chapter/BlockNode.d.ts +20 -0
- package/{src/lib/models/chapter/BlockNode.ts → models/chapter/BlockNode.js} +47 -80
- package/models/chapter/BlocksNode.d.ts +50 -0
- package/{src/lib/models/chapter/BlocksNode.ts → models/chapter/BlocksNode.js} +359 -571
- package/models/chapter/BlocksNode.test.d.ts +1 -0
- package/models/chapter/BlocksNode.test.js +568 -0
- package/{src/lib/models/chapter/Bookkeeping.ts → models/chapter/Bookkeeping.d.ts} +0 -0
- package/models/chapter/Bookkeeping.js +1 -0
- package/models/chapter/CalloutNode.d.ts +17 -0
- package/models/chapter/CalloutNode.js +58 -0
- package/models/chapter/Caret.d.ts +23 -0
- package/{src/lib/models/chapter/Caret.ts → models/chapter/Caret.js} +26 -50
- package/models/chapter/ChapterNode.d.ts +34 -0
- package/models/chapter/ChapterNode.js +117 -0
- package/models/chapter/CitationsNode.d.ts +16 -0
- package/{src/lib/models/chapter/CitationsNode.ts → models/chapter/CitationsNode.js} +10 -17
- package/models/chapter/CodeNode.d.ts +35 -0
- package/{src/lib/models/chapter/CodeNode.ts → models/chapter/CodeNode.js} +62 -125
- package/models/chapter/CommentNode.d.ts +18 -0
- package/models/chapter/CommentNode.js +48 -0
- package/models/chapter/DefinitionNode.d.ts +12 -0
- package/{src/lib/models/chapter/DefinitionNode.ts → models/chapter/DefinitionNode.js} +8 -14
- package/models/chapter/Edit.d.ts +7 -0
- package/models/chapter/Edit.js +1 -0
- package/models/chapter/EmbedNode.d.ts +45 -0
- package/models/chapter/EmbedNode.js +168 -0
- package/models/chapter/ErrorNode.d.ts +17 -0
- package/{src/lib/models/chapter/ErrorNode.ts → models/chapter/ErrorNode.js} +8 -15
- package/models/chapter/FootnoteNode.d.ts +18 -0
- package/models/chapter/FootnoteNode.js +47 -0
- package/models/chapter/FormatNode.d.ts +60 -0
- package/{src/lib/models/chapter/FormatNode.ts → models/chapter/FormatNode.js} +262 -443
- package/models/chapter/FormatNode.test.d.ts +1 -0
- package/models/chapter/FormatNode.test.js +96 -0
- package/models/chapter/InlineCodeNode.d.ts +12 -0
- package/{src/lib/models/chapter/InlineCodeNode.ts → models/chapter/InlineCodeNode.js} +9 -17
- package/models/chapter/LabelNode.d.ts +17 -0
- package/{src/lib/models/chapter/LabelNode.ts → models/chapter/LabelNode.js} +10 -26
- package/models/chapter/LinkNode.d.ts +12 -0
- package/{src/lib/models/chapter/LinkNode.ts → models/chapter/LinkNode.js} +7 -12
- package/models/chapter/ListNode.d.ts +51 -0
- package/{src/lib/models/chapter/ListNode.ts → models/chapter/ListNode.js} +200 -277
- package/models/chapter/ListNode.test.d.ts +1 -0
- package/{src/lib/models/chapter/ListNode.test.ts → models/chapter/ListNode.test.js} +20 -57
- package/models/chapter/MetadataNode.d.ts +17 -0
- package/models/chapter/MetadataNode.js +32 -0
- package/models/chapter/Node.d.ts +38 -0
- package/{src/lib/models/chapter/Node.ts → models/chapter/Node.js} +71 -155
- package/models/chapter/Node.test.d.ts +1 -0
- package/{src/lib/models → models}/chapter/Node.test.js +0 -0
- package/models/chapter/ParagraphNode.d.ts +33 -0
- package/{src/lib/models/chapter/ParagraphNode.ts → models/chapter/ParagraphNode.js} +58 -95
- package/models/chapter/ParagraphNode.test.d.ts +1 -0
- package/models/chapter/ParagraphNode.test.js +30 -0
- package/models/chapter/Parser.d.ts +75 -0
- package/{src/lib/models/chapter/Parser.ts → models/chapter/Parser.js} +184 -369
- package/models/chapter/Parser.test.d.ts +1 -0
- package/{src/lib/models/chapter/Parser.test.ts → models/chapter/Parser.test.js} +0 -7
- package/{src/lib/models/chapter/Position.ts → models/chapter/Position.d.ts} +0 -0
- package/models/chapter/Position.js +1 -0
- package/models/chapter/QuoteNode.d.ts +25 -0
- package/models/chapter/QuoteNode.js +99 -0
- package/{src/lib/models/chapter/RootNode.ts → models/chapter/RootNode.d.ts} +0 -2
- package/models/chapter/RootNode.js +1 -0
- package/models/chapter/RuleNode.d.ts +15 -0
- package/{src/lib/models/chapter/RuleNode.ts → models/chapter/RuleNode.js} +6 -9
- package/models/chapter/TableNode.d.ts +37 -0
- package/{src/lib/models/chapter/TableNode.ts → models/chapter/TableNode.js} +82 -141
- package/models/chapter/TableNode.test.d.ts +1 -0
- package/{src/lib/models/chapter/TableNode.test.ts → models/chapter/TableNode.test.js} +10 -27
- package/models/chapter/TextNode.d.ts +36 -0
- package/{src/lib/models/chapter/TextNode.ts → models/chapter/TextNode.js} +65 -117
- package/models/chapter/TextNode.test.d.ts +1 -0
- package/{src/lib/models/chapter/TextNode.test.ts → models/chapter/TextNode.test.js} +0 -2
- package/package.json +270 -53
- package/util/getSubdomain.d.ts +3 -0
- package/{src/lib/util/getSubdomain.ts → util/getSubdomain.js} +8 -14
- package/util/isMobile.d.ts +2 -0
- package/{src/lib/util/isMobile.ts → util/isMobile.js} +0 -1
- package/util/mineReference.d.ts +4 -0
- package/{src/lib/util/mineReference.ts → util/mineReference.js} +25 -45
- package/util/scrollToEyeLevel.d.ts +2 -0
- package/{src/lib/util/scrollToEyeLevel.ts → util/scrollToEyeLevel.js} +2 -4
- package/.env.example +0 -8
- package/.firebaserc +0 -8
- package/.prettierignore +0 -8
- package/.prettierrc.json +0 -5
- package/_update-notifier-last-checked +0 -0
- package/firebase.json +0 -46
- package/firestore.indexes.json +0 -4
- package/firestore.rules +0 -59
- package/functions/.eslintrc.js +0 -28
- package/functions/package-lock.json +0 -12595
- package/functions/package.json +0 -43
- package/functions/src/index.ts +0 -345
- package/functions/tsconfig.dev.json +0 -3
- package/functions/tsconfig.json +0 -15
- package/scripts/claims.cjs +0 -99
- package/src/app.d.ts +0 -9
- package/src/app.html +0 -24
- package/src/lib/components/Auth.svelte +0 -65
- package/src/lib/components/Link.svelte +0 -58
- package/src/lib/components/chapter/Block.svelte +0 -42
- package/src/lib/components/chapter/ErrorMessage.svelte +0 -12
- package/src/lib/components/chapter/Python.svelte +0 -144
- package/src/lib/components/chapter/Text.svelte +0 -109
- package/src/lib/components/editor/BookishEditor.svelte +0 -1101
- package/src/lib/components/editor/CalloutEditor.svelte +0 -14
- package/src/lib/components/editor/CaretContext.ts +0 -55
- package/src/lib/components/editor/CitationsEditor.svelte +0 -64
- package/src/lib/components/editor/ConfirmButton.svelte +0 -51
- package/src/lib/components/editor/DefinitionEditor.svelte +0 -44
- package/src/lib/components/editor/EmbedEditor.svelte +0 -152
- package/src/lib/components/editor/InlineCodeEditor.svelte +0 -16
- package/src/lib/components/editor/LinkEditor.svelte +0 -110
- package/src/lib/components/editor/PositionEditor.svelte +0 -21
- package/src/lib/components/editor/QuoteEditor.svelte +0 -14
- package/src/lib/components/editor/TableEditor.svelte +0 -14
- package/src/lib/components/editor/Toggle.svelte +0 -47
- package/src/lib/components/editor/Toolbar.svelte +0 -297
- package/src/lib/components/editor/URLEditor.svelte +0 -15
- package/src/lib/components/page/Authors.svelte +0 -92
- package/src/lib/components/page/BookLoader.svelte +0 -77
- package/src/lib/components/page/BulkReferenceEditor.svelte +0 -86
- package/src/lib/components/page/Chapter.svelte +0 -449
- package/src/lib/components/page/ChapterContext.ts +0 -13
- package/src/lib/components/page/Contexts.ts +0 -176
- package/src/lib/components/page/Edition.svelte +0 -189
- package/src/lib/components/page/EditionLoader.svelte +0 -123
- package/src/lib/components/page/Page.svelte +0 -94
- package/src/lib/components/page/PossibleChapter.svelte +0 -16
- package/src/lib/components/page/PossibleReference.svelte +0 -14
- package/src/lib/components/page/Search.svelte +0 -153
- package/src/lib/components/page/TableOfContentsImage.svelte +0 -22
- package/src/lib/components/page/ThemeSetEditor.svelte +0 -21
- package/src/lib/models/CRUD.ts +0 -469
- package/src/lib/models/book/Book.ts +0 -283
- package/src/lib/models/book/BookMedia.ts +0 -182
- package/src/lib/models/book/BookSaveStatus.ts +0 -8
- package/src/lib/models/book/Chapter.ts +0 -462
- package/src/lib/models/book/Definition.ts +0 -2
- package/src/lib/models/book/Edition.ts +0 -1216
- package/src/lib/models/book/Reference.ts +0 -171
- package/src/lib/models/chapter/BlocksNode.test.ts +0 -867
- package/src/lib/models/chapter/CalloutNode.ts +0 -79
- package/src/lib/models/chapter/ChapterNode.ts +0 -169
- package/src/lib/models/chapter/CommentNode.ts +0 -61
- package/src/lib/models/chapter/Edit.ts +0 -6
- package/src/lib/models/chapter/EmbedNode.ts +0 -257
- package/src/lib/models/chapter/FootnoteNode.ts +0 -59
- package/src/lib/models/chapter/FormatNode.test.ts +0 -137
- package/src/lib/models/chapter/MetadataNode.ts +0 -44
- package/src/lib/models/chapter/ParagraphNode.test.ts +0 -54
- package/src/lib/models/chapter/QuoteNode.ts +0 -135
- package/src/params/edition.ts +0 -3
- package/src/routes/+error.svelte +0 -12
- package/src/routes/+layout.svelte +0 -241
- package/src/routes/+page.svelte +0 -43
- package/src/routes/Footer.svelte +0 -0
- package/src/routes/Header.svelte +0 -112
- package/src/routes/[bookid]/+layout.svelte +0 -5
- package/src/routes/[bookid]/[[editionid=edition]]/+error.svelte +0 -14
- package/src/routes/[bookid]/[[editionid=edition]]/+layout.svelte +0 -7
- package/src/routes/[bookid]/[[editionid=edition]]/+page.svelte +0 -5
- package/src/routes/[bookid]/[[editionid=edition]]/[chapterid]/+page.svelte +0 -5
- package/src/routes/[bookid]/[[editionid=edition]]/glossary/+page.svelte +0 -5
- package/src/routes/[bookid]/[[editionid=edition]]/index/[[letter]]/+page.svelte +0 -5
- package/src/routes/[bookid]/[[editionid=edition]]/media/+page.svelte +0 -5
- package/src/routes/[bookid]/[[editionid=edition]]/print/+page.svelte +0 -5
- package/src/routes/[bookid]/[[editionid=edition]]/references/+page.svelte +0 -5
- package/src/routes/[bookid]/[[editionid=edition]]/search/+page.svelte +0 -5
- package/src/routes/[bookid]/editions/+page.svelte +0 -20
- package/src/routes/about/+page.svelte +0 -102
- package/src/routes/confirm/+page.svelte +0 -62
- package/src/routes/email/+page.svelte +0 -99
- package/src/routes/login/+page.svelte +0 -66
- package/src/routes/read/+page.svelte +0 -38
- package/src/routes/write/+error.svelte +0 -10
- package/src/routes/write/+layout.svelte +0 -11
- package/src/routes/write/+page.svelte +0 -114
- package/src/routes/write/[bookid]/+layout.svelte +0 -5
- package/src/routes/write/[bookid]/[[editionid=edition]]/+layout.svelte +0 -7
- package/src/routes/write/[bookid]/[[editionid=edition]]/+page.svelte +0 -5
- package/src/routes/write/[bookid]/[[editionid=edition]]/[chapterid]/+page.svelte +0 -5
- package/src/routes/write/[bookid]/[[editionid=edition]]/glossary/+page.svelte +0 -5
- package/src/routes/write/[bookid]/[[editionid=edition]]/index/[[letter]]/+page.svelte +0 -5
- package/src/routes/write/[bookid]/[[editionid=edition]]/media/+page.svelte +0 -5
- package/src/routes/write/[bookid]/[[editionid=edition]]/print/+page.svelte +0 -5
- package/src/routes/write/[bookid]/[[editionid=edition]]/references/+page.svelte +0 -5
- package/src/routes/write/[bookid]/[[editionid=edition]]/search/+page.svelte +0 -5
- package/src/routes/write/[bookid]/[[editionid=edition]]/theme/+page.svelte +0 -5
- package/src/routes/write/[bookid]/[[editionid=edition]]/unknown/+page.svelte +0 -5
- package/src/routes/write/[bookid]/editions/+page.svelte +0 -20
- package/src/vite-env.d.ts +0 -1
- package/static/icons/favicon.png +0 -0
- package/static/icons/icon.png +0 -0
- package/static/icons/ios-icon.png +0 -0
- package/storage.rules +0 -9
- package/svelte.config.js +0 -19
- package/tsconfig.json +0 -18
- package/tsconfig.node.json +0 -9
- package/vite.config.ts +0 -8
- package/vite.reader.config.ts +0 -32
|
@@ -1,30 +1,22 @@
|
|
|
1
|
-
import CalloutNode from '
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import BlocksNode from '$lib/models/chapter/BlocksNode';
|
|
21
|
-
|
|
22
|
-
import type RootNode from '$lib/models/chapter/RootNode';
|
|
23
|
-
import type Edit from '$lib/models/chapter/Edit';
|
|
24
|
-
import type Node from '$lib/models/chapter/Node';
|
|
25
|
-
import type CaretContext from './CaretContext';
|
|
26
|
-
import type Command from './Command';
|
|
27
|
-
|
|
1
|
+
import CalloutNode from '../../models/chapter/CalloutNode';
|
|
2
|
+
import CitationsNode from '../../models/chapter/CitationsNode';
|
|
3
|
+
import CodeNode from '../../models/chapter/CodeNode';
|
|
4
|
+
import CommentNode from '../../models/chapter/CommentNode';
|
|
5
|
+
import DefinitionNode from '../../models/chapter/DefinitionNode';
|
|
6
|
+
import EmbedNode from '../../models/chapter/EmbedNode';
|
|
7
|
+
import FootnoteNode from '../../models/chapter/FootnoteNode';
|
|
8
|
+
import FormatNode from '../../models/chapter/FormatNode';
|
|
9
|
+
import InlineCodeNode from '../../models/chapter/InlineCodeNode';
|
|
10
|
+
import LabelNode from '../../models/chapter/LabelNode';
|
|
11
|
+
import LinkNode from '../../models/chapter/LinkNode';
|
|
12
|
+
import ListNode from '../../models/chapter/ListNode';
|
|
13
|
+
import ParagraphNode from '../../models/chapter/ParagraphNode';
|
|
14
|
+
import QuoteNode from '../../models/chapter/QuoteNode';
|
|
15
|
+
import RuleNode from '../../models/chapter/RuleNode';
|
|
16
|
+
import TableNode from '../../models/chapter/TableNode';
|
|
17
|
+
import TextNode from '../../models/chapter/TextNode';
|
|
18
|
+
import AtomNode from '../../models/chapter/AtomNode';
|
|
19
|
+
import BlocksNode from '../../models/chapter/BlocksNode';
|
|
28
20
|
import BoldIcon from './icons/bold.svg?raw';
|
|
29
21
|
import BulletsIcon from './icons/bullets.svg?raw';
|
|
30
22
|
import CalloutIcon from './icons/callout.svg?raw';
|
|
@@ -61,7 +53,6 @@ import SuperscriptIcon from './icons/super.svg?raw';
|
|
|
61
53
|
import TableIcon from './icons/table.svg?raw';
|
|
62
54
|
import UndoIcon from './icons/undo.svg?raw';
|
|
63
55
|
import UnindentIcon from './icons/unindent.svg?raw';
|
|
64
|
-
import type { PasteContent } from './CaretContext';
|
|
65
56
|
/**
|
|
66
57
|
* Icons:
|
|
67
58
|
* From: https://www.streamlinehq.com/icons/streamline-mini-line
|
|
@@ -71,93 +62,53 @@ import type { PasteContent } from './CaretContext';
|
|
|
71
62
|
* 48 px
|
|
72
63
|
* stroke width 1
|
|
73
64
|
* */
|
|
74
|
-
|
|
75
|
-
function insertTableRowColumn(
|
|
76
|
-
context: CaretContext,
|
|
77
|
-
table: TableNode,
|
|
78
|
-
format: FormatNode,
|
|
79
|
-
row: boolean,
|
|
80
|
-
before: boolean
|
|
81
|
-
): Edit {
|
|
65
|
+
function insertTableRowColumn(context, table, format, row, before) {
|
|
82
66
|
const location = table.locate(format);
|
|
83
|
-
if (location === undefined)
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
table
|
|
87
|
-
row
|
|
88
|
-
? table.withNewRow(location.row + (before ? 0 : 1))
|
|
89
|
-
: table.withNewColumn(location.column + (before ? 0 : 1)),
|
|
90
|
-
(t) =>
|
|
91
|
-
(
|
|
92
|
-
(t as TableNode).getCell(
|
|
93
|
-
location.row + (row && !before ? 1 : 0),
|
|
94
|
-
location.column + (!row && !before ? 1 : 0)
|
|
95
|
-
) as FormatNode
|
|
96
|
-
).getFirstCaret()
|
|
97
|
-
);
|
|
67
|
+
if (location === undefined)
|
|
68
|
+
return;
|
|
69
|
+
return rootWithNode(context, table, row
|
|
70
|
+
? table.withNewRow(location.row + (before ? 0 : 1))
|
|
71
|
+
: table.withNewColumn(location.column + (before ? 0 : 1)), (t) => t.getCell(location.row + (row && !before ? 1 : 0), location.column + (!row && !before ? 1 : 0)).getFirstCaret());
|
|
98
72
|
}
|
|
99
|
-
|
|
100
|
-
function deleteTableRowColumn(
|
|
101
|
-
context: CaretContext,
|
|
102
|
-
table: TableNode,
|
|
103
|
-
format: FormatNode,
|
|
104
|
-
row: boolean
|
|
105
|
-
): Edit {
|
|
73
|
+
function deleteTableRowColumn(context, table, format, row) {
|
|
106
74
|
const location = table.locate(format);
|
|
107
|
-
if (location === undefined)
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
table
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
: location.row,
|
|
121
|
-
location.column
|
|
122
|
-
)
|
|
123
|
-
: (t as TableNode).getCell(
|
|
124
|
-
location.row,
|
|
125
|
-
location.column === table.getColumnCount()
|
|
126
|
-
? location.column - 1
|
|
127
|
-
: location.column
|
|
128
|
-
)
|
|
129
|
-
)?.getFirstCaret();
|
|
130
|
-
}
|
|
131
|
-
);
|
|
75
|
+
if (location === undefined)
|
|
76
|
+
return;
|
|
77
|
+
return rootWithNode(context, table, row
|
|
78
|
+
? table.withoutRow(location.row)
|
|
79
|
+
: table.withoutColumn(location.column), (t) => {
|
|
80
|
+
return (row
|
|
81
|
+
? t.getCell(location.row === table.getRowCount()
|
|
82
|
+
? location.row - 1
|
|
83
|
+
: location.row, location.column)
|
|
84
|
+
: t.getCell(location.row, location.column === table.getColumnCount()
|
|
85
|
+
? location.column - 1
|
|
86
|
+
: location.column))?.getFirstCaret();
|
|
87
|
+
});
|
|
132
88
|
}
|
|
133
|
-
|
|
134
89
|
// A helper function that encapsulates boilerplate for replacing a node in a root and updating a caret.
|
|
135
|
-
function rootWithNode
|
|
136
|
-
context: CaretContext,
|
|
137
|
-
original: NodeType | undefined,
|
|
138
|
-
replacement: NodeType | undefined,
|
|
139
|
-
caret?: (node: NodeType) => Caret | undefined
|
|
140
|
-
): Edit | undefined {
|
|
90
|
+
function rootWithNode(context, original, replacement, caret) {
|
|
141
91
|
// If there was no original or replacement, do nothing. Saves commands from having to check.
|
|
142
|
-
if (original === undefined || replacement === undefined)
|
|
92
|
+
if (original === undefined || replacement === undefined)
|
|
93
|
+
return;
|
|
143
94
|
// Make the new root. Bail on fail.
|
|
144
95
|
const newRoot = context.root.withNodeReplaced(original, replacement);
|
|
145
|
-
if (newRoot === undefined)
|
|
96
|
+
if (newRoot === undefined)
|
|
97
|
+
return;
|
|
146
98
|
// Generate a new caret based on the replacement, if there's a generator. Bail on fail.
|
|
147
99
|
const newCaret = caret?.call(undefined, replacement);
|
|
148
|
-
if (caret !== undefined && newCaret === undefined)
|
|
100
|
+
if (caret !== undefined && newCaret === undefined)
|
|
101
|
+
return;
|
|
149
102
|
// Return the edit
|
|
150
103
|
return {
|
|
151
104
|
root: newRoot,
|
|
152
|
-
range:
|
|
153
|
-
newCaret
|
|
154
|
-
|
|
155
|
-
: context.range,
|
|
105
|
+
range: newCaret !== undefined
|
|
106
|
+
? { start: newCaret, end: newCaret }
|
|
107
|
+
: context.range,
|
|
156
108
|
};
|
|
157
109
|
}
|
|
158
|
-
|
|
159
110
|
// An ordered list of command specifications for keyboard and mouse input.
|
|
160
|
-
const commands
|
|
111
|
+
const commands = [
|
|
161
112
|
{
|
|
162
113
|
icon: RowAboveIcon,
|
|
163
114
|
description: 'insert row above',
|
|
@@ -168,18 +119,10 @@ const commands: Command[] = [
|
|
|
168
119
|
shift: false,
|
|
169
120
|
key: 'ArrowUp',
|
|
170
121
|
visible: (context) => context.table !== undefined,
|
|
171
|
-
active: (context) =>
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
? insertTableRowColumn(
|
|
176
|
-
context,
|
|
177
|
-
context.table,
|
|
178
|
-
context.format,
|
|
179
|
-
true,
|
|
180
|
-
true
|
|
181
|
-
)
|
|
182
|
-
: undefined,
|
|
122
|
+
active: (context) => context.table !== undefined && context.format !== undefined,
|
|
123
|
+
handler: (context) => context.table !== undefined && context.format !== undefined
|
|
124
|
+
? insertTableRowColumn(context, context.table, context.format, true, true)
|
|
125
|
+
: undefined,
|
|
183
126
|
},
|
|
184
127
|
{
|
|
185
128
|
icon: RowBelowIcon,
|
|
@@ -191,18 +134,10 @@ const commands: Command[] = [
|
|
|
191
134
|
shift: false,
|
|
192
135
|
key: 'ArrowDown',
|
|
193
136
|
visible: (context) => context.table !== undefined,
|
|
194
|
-
active: (context) =>
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
? insertTableRowColumn(
|
|
199
|
-
context,
|
|
200
|
-
context.table,
|
|
201
|
-
context.format,
|
|
202
|
-
true,
|
|
203
|
-
false
|
|
204
|
-
)
|
|
205
|
-
: undefined,
|
|
137
|
+
active: (context) => context.table !== undefined && context.format !== undefined,
|
|
138
|
+
handler: (context) => context.table !== undefined && context.format !== undefined
|
|
139
|
+
? insertTableRowColumn(context, context.table, context.format, true, false)
|
|
140
|
+
: undefined,
|
|
206
141
|
},
|
|
207
142
|
{
|
|
208
143
|
icon: ColumnAfterIcon,
|
|
@@ -214,18 +149,10 @@ const commands: Command[] = [
|
|
|
214
149
|
shift: false,
|
|
215
150
|
key: 'ArrowRight',
|
|
216
151
|
visible: (context) => context.table !== undefined,
|
|
217
|
-
active: (context) =>
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
? insertTableRowColumn(
|
|
222
|
-
context,
|
|
223
|
-
context.table,
|
|
224
|
-
context.format,
|
|
225
|
-
false,
|
|
226
|
-
false
|
|
227
|
-
)
|
|
228
|
-
: undefined,
|
|
152
|
+
active: (context) => context.table !== undefined && context.format !== undefined,
|
|
153
|
+
handler: (context) => context.table !== undefined && context.format !== undefined
|
|
154
|
+
? insertTableRowColumn(context, context.table, context.format, false, false)
|
|
155
|
+
: undefined,
|
|
229
156
|
},
|
|
230
157
|
{
|
|
231
158
|
icon: ColumnBeforeIcon,
|
|
@@ -237,18 +164,10 @@ const commands: Command[] = [
|
|
|
237
164
|
shift: false,
|
|
238
165
|
key: 'ArrowLeft',
|
|
239
166
|
visible: (context) => context.table !== undefined,
|
|
240
|
-
active: (context) =>
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
? insertTableRowColumn(
|
|
245
|
-
context,
|
|
246
|
-
context.table,
|
|
247
|
-
context.format,
|
|
248
|
-
false,
|
|
249
|
-
true
|
|
250
|
-
)
|
|
251
|
-
: undefined,
|
|
167
|
+
active: (context) => context.table !== undefined && context.format !== undefined,
|
|
168
|
+
handler: (context) => context.table !== undefined && context.format !== undefined
|
|
169
|
+
? insertTableRowColumn(context, context.table, context.format, false, true)
|
|
170
|
+
: undefined,
|
|
252
171
|
},
|
|
253
172
|
{
|
|
254
173
|
icon: DeleteRowIcon,
|
|
@@ -260,19 +179,12 @@ const commands: Command[] = [
|
|
|
260
179
|
shift: false,
|
|
261
180
|
key: 'Backspace',
|
|
262
181
|
visible: (context) => context.table !== undefined,
|
|
263
|
-
active: (context) =>
|
|
264
|
-
context.format !== undefined &&
|
|
182
|
+
active: (context) => context.format !== undefined &&
|
|
265
183
|
context.table !== undefined &&
|
|
266
184
|
context.table.getRowCount() > 1,
|
|
267
|
-
handler: (context) =>
|
|
268
|
-
context
|
|
269
|
-
|
|
270
|
-
context,
|
|
271
|
-
context.table,
|
|
272
|
-
context.format,
|
|
273
|
-
true
|
|
274
|
-
)
|
|
275
|
-
: undefined,
|
|
185
|
+
handler: (context) => context.format !== undefined && context.table !== undefined
|
|
186
|
+
? deleteTableRowColumn(context, context.table, context.format, true)
|
|
187
|
+
: undefined,
|
|
276
188
|
},
|
|
277
189
|
{
|
|
278
190
|
icon: DeleteColumnIcon,
|
|
@@ -284,19 +196,12 @@ const commands: Command[] = [
|
|
|
284
196
|
shift: true,
|
|
285
197
|
key: 'Backspace',
|
|
286
198
|
visible: (context) => context.table !== undefined,
|
|
287
|
-
active: (context) =>
|
|
288
|
-
context.format !== undefined &&
|
|
199
|
+
active: (context) => context.format !== undefined &&
|
|
289
200
|
context.table !== undefined &&
|
|
290
201
|
context.table.getColumnCount() > 1,
|
|
291
|
-
handler: (context) =>
|
|
292
|
-
context
|
|
293
|
-
|
|
294
|
-
context,
|
|
295
|
-
context.table,
|
|
296
|
-
context.format,
|
|
297
|
-
false
|
|
298
|
-
)
|
|
299
|
-
: undefined,
|
|
202
|
+
handler: (context) => context.format !== undefined && context.table !== undefined
|
|
203
|
+
? deleteTableRowColumn(context, context.table, context.format, false)
|
|
204
|
+
: undefined,
|
|
300
205
|
},
|
|
301
206
|
{
|
|
302
207
|
icon: '➡️',
|
|
@@ -312,10 +217,7 @@ const commands: Command[] = [
|
|
|
312
217
|
handler: (context) => {
|
|
313
218
|
if (context.format) {
|
|
314
219
|
let caret = context.root
|
|
315
|
-
.getNodeAfter
|
|
316
|
-
context.format,
|
|
317
|
-
(node): node is FormatNode => node instanceof FormatNode
|
|
318
|
-
)
|
|
220
|
+
.getNodeAfter(context.format, (node) => node instanceof FormatNode)
|
|
319
221
|
?.getFirstCaret();
|
|
320
222
|
if (caret)
|
|
321
223
|
return {
|
|
@@ -340,10 +242,7 @@ const commands: Command[] = [
|
|
|
340
242
|
handler: (context) => {
|
|
341
243
|
if (context.format) {
|
|
342
244
|
let caret = context.root
|
|
343
|
-
.getNodeBefore
|
|
344
|
-
context.format,
|
|
345
|
-
(node): node is FormatNode => node instanceof FormatNode
|
|
346
|
-
)
|
|
245
|
+
.getNodeBefore(context.format, (node) => node instanceof FormatNode)
|
|
347
246
|
?.getFirstCaret();
|
|
348
247
|
if (caret)
|
|
349
248
|
return {
|
|
@@ -365,25 +264,19 @@ const commands: Command[] = [
|
|
|
365
264
|
visible: () => false,
|
|
366
265
|
active: (context) => context.endIsTextOrAtom,
|
|
367
266
|
handler: (context) => {
|
|
368
|
-
if (
|
|
369
|
-
context.end.node instanceof TextNode ||
|
|
267
|
+
if (context.end.node instanceof TextNode ||
|
|
370
268
|
context.end.node instanceof AtomNode ||
|
|
371
|
-
context.end.node instanceof EmbedNode
|
|
372
|
-
|
|
373
|
-
const nextCaret = context.root.getAdjacentCaret(
|
|
374
|
-
context.end,
|
|
375
|
-
false
|
|
376
|
-
);
|
|
269
|
+
context.end.node instanceof EmbedNode) {
|
|
270
|
+
const nextCaret = context.root.getAdjacentCaret(context.end, false);
|
|
377
271
|
const sortedRange = context.root.sortRange(context.range);
|
|
378
272
|
return {
|
|
379
273
|
root: context.root,
|
|
380
|
-
range:
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
: { start: nextCaret, end: nextCaret },
|
|
274
|
+
range: nextCaret === undefined
|
|
275
|
+
? {
|
|
276
|
+
start: sortedRange.start,
|
|
277
|
+
end: sortedRange.start,
|
|
278
|
+
}
|
|
279
|
+
: { start: nextCaret, end: nextCaret },
|
|
387
280
|
};
|
|
388
281
|
}
|
|
389
282
|
},
|
|
@@ -400,15 +293,10 @@ const commands: Command[] = [
|
|
|
400
293
|
visible: false,
|
|
401
294
|
active: (context) => context.endIsTextOrAtom,
|
|
402
295
|
handler: (context) => {
|
|
403
|
-
if (
|
|
404
|
-
context.end.node instanceof TextNode ||
|
|
296
|
+
if (context.end.node instanceof TextNode ||
|
|
405
297
|
context.end.node instanceof AtomNode ||
|
|
406
|
-
context.end.node instanceof EmbedNode
|
|
407
|
-
|
|
408
|
-
const previous = context.end.node.previousWord(
|
|
409
|
-
context.root,
|
|
410
|
-
context.end.index
|
|
411
|
-
);
|
|
298
|
+
context.end.node instanceof EmbedNode) {
|
|
299
|
+
const previous = context.end.node.previousWord(context.root, context.end.index);
|
|
412
300
|
return {
|
|
413
301
|
root: context.root,
|
|
414
302
|
range: { start: previous, end: previous },
|
|
@@ -452,16 +340,12 @@ const commands: Command[] = [
|
|
|
452
340
|
visible: false,
|
|
453
341
|
active: (context) => context.endIsTextOrAtom,
|
|
454
342
|
handler: (context) => {
|
|
455
|
-
if (
|
|
456
|
-
context.end.node instanceof TextNode ||
|
|
343
|
+
if (context.end.node instanceof TextNode ||
|
|
457
344
|
context.end.node instanceof AtomNode ||
|
|
458
|
-
context.end.node instanceof EmbedNode
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
false
|
|
463
|
-
);
|
|
464
|
-
if (previous === undefined) return;
|
|
345
|
+
context.end.node instanceof EmbedNode) {
|
|
346
|
+
const previous = context.root.getAdjacentCaret(context.end, false);
|
|
347
|
+
if (previous === undefined)
|
|
348
|
+
return;
|
|
465
349
|
return {
|
|
466
350
|
root: context.root,
|
|
467
351
|
range: { start: context.start, end: previous },
|
|
@@ -481,15 +365,10 @@ const commands: Command[] = [
|
|
|
481
365
|
visible: false,
|
|
482
366
|
active: (context) => context.endIsTextOrAtom,
|
|
483
367
|
handler: (context) => {
|
|
484
|
-
if (
|
|
485
|
-
context.end.node instanceof TextNode ||
|
|
368
|
+
if (context.end.node instanceof TextNode ||
|
|
486
369
|
context.end.node instanceof AtomNode ||
|
|
487
|
-
context.end.node instanceof EmbedNode
|
|
488
|
-
|
|
489
|
-
const previous = context.end.node.previousWord(
|
|
490
|
-
context.root,
|
|
491
|
-
context.end.index
|
|
492
|
-
);
|
|
370
|
+
context.end.node instanceof EmbedNode) {
|
|
371
|
+
const previous = context.end.node.previousWord(context.root, context.end.index);
|
|
493
372
|
return {
|
|
494
373
|
root: context.root,
|
|
495
374
|
range: { start: context.start, end: previous },
|
|
@@ -533,23 +412,17 @@ const commands: Command[] = [
|
|
|
533
412
|
visible: false,
|
|
534
413
|
active: (context) => context.endIsTextOrAtom,
|
|
535
414
|
handler: (context) => {
|
|
536
|
-
if (
|
|
537
|
-
context.end.node instanceof TextNode ||
|
|
415
|
+
if (context.end.node instanceof TextNode ||
|
|
538
416
|
context.end.node instanceof AtomNode ||
|
|
539
|
-
context.end.node instanceof EmbedNode
|
|
540
|
-
|
|
541
|
-
const nextCaret = context.root.getAdjacentCaret(
|
|
542
|
-
context.end,
|
|
543
|
-
true
|
|
544
|
-
);
|
|
417
|
+
context.end.node instanceof EmbedNode) {
|
|
418
|
+
const nextCaret = context.root.getAdjacentCaret(context.end, true);
|
|
545
419
|
const sortedRange = context.root.sortRange(context.range);
|
|
546
420
|
// If there is no next caret, move the caret to the largest of the current start and end.
|
|
547
421
|
return {
|
|
548
422
|
root: context.root,
|
|
549
|
-
range:
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
: { start: nextCaret, end: nextCaret },
|
|
423
|
+
range: nextCaret === undefined
|
|
424
|
+
? { start: sortedRange.end, end: sortedRange.end }
|
|
425
|
+
: { start: nextCaret, end: nextCaret },
|
|
553
426
|
};
|
|
554
427
|
}
|
|
555
428
|
},
|
|
@@ -566,15 +439,10 @@ const commands: Command[] = [
|
|
|
566
439
|
visible: false,
|
|
567
440
|
active: (context) => context.endIsTextOrAtom,
|
|
568
441
|
handler: (context) => {
|
|
569
|
-
if (
|
|
570
|
-
context.end.node instanceof TextNode ||
|
|
442
|
+
if (context.end.node instanceof TextNode ||
|
|
571
443
|
context.end.node instanceof AtomNode ||
|
|
572
|
-
context.end.node instanceof EmbedNode
|
|
573
|
-
|
|
574
|
-
const next = context.end.node.nextWord(
|
|
575
|
-
context.root,
|
|
576
|
-
context.end.index
|
|
577
|
-
);
|
|
444
|
+
context.end.node instanceof EmbedNode) {
|
|
445
|
+
const next = context.end.node.nextWord(context.root, context.end.index);
|
|
578
446
|
return {
|
|
579
447
|
root: context.root,
|
|
580
448
|
range: { start: next, end: next },
|
|
@@ -616,13 +484,12 @@ const commands: Command[] = [
|
|
|
616
484
|
visible: false,
|
|
617
485
|
active: (context) => context.endIsTextOrAtom,
|
|
618
486
|
handler: (context) => {
|
|
619
|
-
if (
|
|
620
|
-
context.end.node instanceof TextNode ||
|
|
487
|
+
if (context.end.node instanceof TextNode ||
|
|
621
488
|
context.end.node instanceof AtomNode ||
|
|
622
|
-
context.end.node instanceof EmbedNode
|
|
623
|
-
) {
|
|
489
|
+
context.end.node instanceof EmbedNode) {
|
|
624
490
|
const next = context.root.getAdjacentCaret(context.end, true);
|
|
625
|
-
if (next === undefined)
|
|
491
|
+
if (next === undefined)
|
|
492
|
+
return;
|
|
626
493
|
return {
|
|
627
494
|
root: context.root,
|
|
628
495
|
range: { start: context.start, end: next },
|
|
@@ -642,15 +509,10 @@ const commands: Command[] = [
|
|
|
642
509
|
visible: false,
|
|
643
510
|
active: (context) => context.endIsTextOrAtom,
|
|
644
511
|
handler: (context) => {
|
|
645
|
-
if (
|
|
646
|
-
context.end.node instanceof TextNode ||
|
|
512
|
+
if (context.end.node instanceof TextNode ||
|
|
647
513
|
context.end.node instanceof AtomNode ||
|
|
648
|
-
context.end.node instanceof EmbedNode
|
|
649
|
-
|
|
650
|
-
const previous = context.end.node.nextWord(
|
|
651
|
-
context.root,
|
|
652
|
-
context.end.index
|
|
653
|
-
);
|
|
514
|
+
context.end.node instanceof EmbedNode) {
|
|
515
|
+
const previous = context.end.node.nextWord(context.root, context.end.index);
|
|
654
516
|
return {
|
|
655
517
|
root: context.root,
|
|
656
518
|
range: { start: context.start, end: previous },
|
|
@@ -706,10 +568,8 @@ const commands: Command[] = [
|
|
|
706
568
|
};
|
|
707
569
|
}
|
|
708
570
|
// If in a code node, expand to the code.
|
|
709
|
-
else if (
|
|
710
|
-
context.
|
|
711
|
-
context.range.start.node === context.block.getCodeNode()
|
|
712
|
-
) {
|
|
571
|
+
else if (context.block instanceof CodeNode &&
|
|
572
|
+
context.range.start.node === context.block.getCodeNode()) {
|
|
713
573
|
const code = context.block.getCodeNode();
|
|
714
574
|
return {
|
|
715
575
|
root: context.root,
|
|
@@ -720,11 +580,9 @@ const commands: Command[] = [
|
|
|
720
580
|
};
|
|
721
581
|
}
|
|
722
582
|
// If in a non paragraph block, expand to the format of whatever format we're in.
|
|
723
|
-
else if (
|
|
724
|
-
context.paragraph === undefined &&
|
|
583
|
+
else if (context.paragraph === undefined &&
|
|
725
584
|
context.block &&
|
|
726
|
-
context.format
|
|
727
|
-
) {
|
|
585
|
+
context.format) {
|
|
728
586
|
return {
|
|
729
587
|
root: context.root,
|
|
730
588
|
range: {
|
|
@@ -732,7 +590,8 @@ const commands: Command[] = [
|
|
|
732
590
|
end: context.format.getLastCaret(),
|
|
733
591
|
},
|
|
734
592
|
};
|
|
735
|
-
}
|
|
593
|
+
}
|
|
594
|
+
else {
|
|
736
595
|
// Find the first and last caret of the entire chapter.
|
|
737
596
|
const text = context.root?.getTextNodes();
|
|
738
597
|
if (text && text.length > 0) {
|
|
@@ -832,31 +691,19 @@ const commands: Command[] = [
|
|
|
832
691
|
visible: false,
|
|
833
692
|
active: true,
|
|
834
693
|
handler: (context) => {
|
|
835
|
-
if (context.root === undefined)
|
|
694
|
+
if (context.root === undefined)
|
|
695
|
+
return;
|
|
836
696
|
if (context.isSelection) {
|
|
837
|
-
const edit = context.root.withRangeFormatted(
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
);
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
);
|
|
848
|
-
} else {
|
|
849
|
-
const edit = context.root.withoutAdjacentContent(
|
|
850
|
-
context.start,
|
|
851
|
-
false
|
|
852
|
-
);
|
|
853
|
-
if (edit === undefined) return;
|
|
854
|
-
return rootWithNode<RootNode>(
|
|
855
|
-
context,
|
|
856
|
-
context.root,
|
|
857
|
-
edit.root as RootNode,
|
|
858
|
-
() => edit.range.start
|
|
859
|
-
);
|
|
697
|
+
const edit = context.root.withRangeFormatted(context.range, undefined);
|
|
698
|
+
if (edit === undefined)
|
|
699
|
+
return;
|
|
700
|
+
return rootWithNode(context, context.root, edit.root, () => edit.range.start);
|
|
701
|
+
}
|
|
702
|
+
else {
|
|
703
|
+
const edit = context.root.withoutAdjacentContent(context.start, false);
|
|
704
|
+
if (edit === undefined)
|
|
705
|
+
return;
|
|
706
|
+
return rootWithNode(context, context.root, edit.root, () => edit.range.start);
|
|
860
707
|
}
|
|
861
708
|
},
|
|
862
709
|
},
|
|
@@ -872,31 +719,19 @@ const commands: Command[] = [
|
|
|
872
719
|
visible: false,
|
|
873
720
|
active: true,
|
|
874
721
|
handler: (context) => {
|
|
875
|
-
if (context.root === undefined)
|
|
722
|
+
if (context.root === undefined)
|
|
723
|
+
return;
|
|
876
724
|
if (context.isSelection) {
|
|
877
|
-
const edit = context.root.withRangeFormatted(
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
);
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
);
|
|
888
|
-
} else {
|
|
889
|
-
const edit = context.root.withoutAdjacentContent(
|
|
890
|
-
context.start,
|
|
891
|
-
true
|
|
892
|
-
);
|
|
893
|
-
if (edit === undefined) return;
|
|
894
|
-
return rootWithNode<RootNode>(
|
|
895
|
-
context,
|
|
896
|
-
context.root,
|
|
897
|
-
edit.root as RootNode,
|
|
898
|
-
() => edit.range.start
|
|
899
|
-
);
|
|
725
|
+
const edit = context.root.withRangeFormatted(context.range, undefined);
|
|
726
|
+
if (edit === undefined)
|
|
727
|
+
return;
|
|
728
|
+
return rootWithNode(context, context.root, edit.root, () => edit.range.start);
|
|
729
|
+
}
|
|
730
|
+
else {
|
|
731
|
+
const edit = context.root.withoutAdjacentContent(context.start, true);
|
|
732
|
+
if (edit === undefined)
|
|
733
|
+
return;
|
|
734
|
+
return rootWithNode(context, context.root, edit.root, () => edit.range.start);
|
|
900
735
|
}
|
|
901
736
|
},
|
|
902
737
|
},
|
|
@@ -912,20 +747,14 @@ const commands: Command[] = [
|
|
|
912
747
|
visible: false,
|
|
913
748
|
active: (context) => context.code !== undefined,
|
|
914
749
|
handler: (context) => {
|
|
915
|
-
if (context.code?.getCodeNode() !== context.start.node)
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
context.start.node,
|
|
924
|
-
newText,
|
|
925
|
-
(text) => {
|
|
926
|
-
return { node: text, index: context.start.index + 1 };
|
|
927
|
-
}
|
|
928
|
-
);
|
|
750
|
+
if (context.code?.getCodeNode() !== context.start.node)
|
|
751
|
+
return;
|
|
752
|
+
const newText = context.start.node.withCharacterAt('\n', context.start.index);
|
|
753
|
+
if (newText === undefined)
|
|
754
|
+
return;
|
|
755
|
+
return rootWithNode(context, context.start.node, newText, (text) => {
|
|
756
|
+
return { node: text, index: context.start.index + 1 };
|
|
757
|
+
});
|
|
929
758
|
},
|
|
930
759
|
},
|
|
931
760
|
{
|
|
@@ -940,69 +769,52 @@ const commands: Command[] = [
|
|
|
940
769
|
visible: false,
|
|
941
770
|
active: (context) => context.list !== undefined,
|
|
942
771
|
handler: (context) => {
|
|
943
|
-
if (context.list === undefined)
|
|
772
|
+
if (context.list === undefined)
|
|
773
|
+
return;
|
|
944
774
|
const lastItem = context.list.getLastItem();
|
|
945
775
|
const lastCaret = lastItem?.getLastCaret();
|
|
946
776
|
// If we're at the last item in the list and it's empty, then add a
|
|
947
|
-
if (
|
|
948
|
-
lastItem !== undefined &&
|
|
777
|
+
if (lastItem !== undefined &&
|
|
949
778
|
lastCaret !== undefined &&
|
|
950
779
|
lastCaret.node instanceof TextNode &&
|
|
951
780
|
lastCaret.node.getLength() === 0 &&
|
|
952
781
|
lastCaret.node === context.end.node &&
|
|
953
|
-
lastCaret.index === context.end.index
|
|
954
|
-
) {
|
|
782
|
+
lastCaret.index === context.end.index) {
|
|
955
783
|
const listParent = context.list.getParent(context.root);
|
|
956
784
|
if (listParent instanceof ListNode) {
|
|
957
785
|
const newSublist = context.list.withoutItem(lastItem);
|
|
958
|
-
if (newSublist === undefined)
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
if (newListWithoutSublistItem === undefined)
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
context,
|
|
970
|
-
listParent,
|
|
971
|
-
newListWithSublistItem,
|
|
972
|
-
() => lastCaret
|
|
973
|
-
);
|
|
974
|
-
} else if (listParent instanceof BlocksNode) {
|
|
786
|
+
if (newSublist === undefined)
|
|
787
|
+
return;
|
|
788
|
+
const newListWithoutSublistItem = listParent.withChildReplaced(context.list, newSublist);
|
|
789
|
+
if (newListWithoutSublistItem === undefined)
|
|
790
|
+
return;
|
|
791
|
+
const newListWithSublistItem = newListWithoutSublistItem.withItemAfter(lastItem, newSublist);
|
|
792
|
+
if (newListWithSublistItem === undefined)
|
|
793
|
+
return;
|
|
794
|
+
return rootWithNode(context, listParent, newListWithSublistItem, () => lastCaret);
|
|
795
|
+
}
|
|
796
|
+
else if (listParent instanceof BlocksNode) {
|
|
975
797
|
const listWithoutItem = context.list.withoutItem(lastItem);
|
|
976
|
-
if (listWithoutItem === undefined)
|
|
798
|
+
if (listWithoutItem === undefined)
|
|
799
|
+
return;
|
|
977
800
|
const newBlocks = listParent
|
|
978
801
|
.withChildReplaced(context.list, listWithoutItem)
|
|
979
|
-
?.withBlockInsertedAfter(
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
if (newBlocks === undefined) return;
|
|
984
|
-
return rootWithNode(
|
|
985
|
-
context,
|
|
986
|
-
listParent,
|
|
987
|
-
newBlocks,
|
|
988
|
-
() => lastCaret
|
|
989
|
-
);
|
|
802
|
+
?.withBlockInsertedAfter(listWithoutItem, new ParagraphNode(0, lastItem));
|
|
803
|
+
if (newBlocks === undefined)
|
|
804
|
+
return;
|
|
805
|
+
return rootWithNode(context, listParent, newBlocks, () => lastCaret);
|
|
990
806
|
}
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
context.list
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
if (item === undefined) return;
|
|
1003
|
-
return item.getFirstCaret();
|
|
1004
|
-
}
|
|
1005
|
-
);
|
|
807
|
+
}
|
|
808
|
+
else
|
|
809
|
+
return rootWithNode(context, context.list, context.list?.withItemSplit(context.range.start), (newList) => {
|
|
810
|
+
const index = context.list?.getItemContaining(context.range.start);
|
|
811
|
+
if (index === undefined)
|
|
812
|
+
return;
|
|
813
|
+
const item = newList.getItem(index + 1);
|
|
814
|
+
if (item === undefined)
|
|
815
|
+
return;
|
|
816
|
+
return item.getFirstCaret();
|
|
817
|
+
});
|
|
1006
818
|
},
|
|
1007
819
|
},
|
|
1008
820
|
{
|
|
@@ -1015,17 +827,12 @@ const commands: Command[] = [
|
|
|
1015
827
|
shift: false,
|
|
1016
828
|
key: 'Enter',
|
|
1017
829
|
visible: false,
|
|
1018
|
-
active: (context) =>
|
|
1019
|
-
context.atom === undefined && context.blocks !== undefined,
|
|
830
|
+
active: (context) => context.atom === undefined && context.blocks !== undefined,
|
|
1020
831
|
handler: (context) => {
|
|
1021
832
|
const edit = context.blocks?.withSelectionSplit(context.range);
|
|
1022
|
-
if (edit === undefined)
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
context.blocks,
|
|
1026
|
-
edit.root,
|
|
1027
|
-
() => edit.range.start
|
|
1028
|
-
);
|
|
833
|
+
if (edit === undefined)
|
|
834
|
+
return;
|
|
835
|
+
return rootWithNode(context, context.blocks, edit.root, () => edit.range.start);
|
|
1029
836
|
},
|
|
1030
837
|
},
|
|
1031
838
|
{
|
|
@@ -1039,12 +846,7 @@ const commands: Command[] = [
|
|
|
1039
846
|
key: 'Tab',
|
|
1040
847
|
visible: (context) => context.list !== undefined,
|
|
1041
848
|
active: (context) => context.list !== undefined,
|
|
1042
|
-
handler: (context) =>
|
|
1043
|
-
rootWithNode(
|
|
1044
|
-
context,
|
|
1045
|
-
context.blocks,
|
|
1046
|
-
context.blocks?.withListsIndented(context.range, true)
|
|
1047
|
-
),
|
|
849
|
+
handler: (context) => rootWithNode(context, context.blocks, context.blocks?.withListsIndented(context.range, true)),
|
|
1048
850
|
},
|
|
1049
851
|
{
|
|
1050
852
|
icon: UnindentIcon,
|
|
@@ -1056,15 +858,9 @@ const commands: Command[] = [
|
|
|
1056
858
|
shift: true,
|
|
1057
859
|
key: 'Tab',
|
|
1058
860
|
visible: (context) => context.list !== undefined,
|
|
1059
|
-
active: (context) =>
|
|
1060
|
-
context.list !== undefined &&
|
|
861
|
+
active: (context) => context.list !== undefined &&
|
|
1061
862
|
context.list.isInside(context.root, ListNode),
|
|
1062
|
-
handler: (context) =>
|
|
1063
|
-
rootWithNode(
|
|
1064
|
-
context,
|
|
1065
|
-
context.blocks,
|
|
1066
|
-
context.blocks?.withListsIndented(context.range, false)
|
|
1067
|
-
),
|
|
863
|
+
handler: (context) => rootWithNode(context, context.blocks, context.blocks?.withListsIndented(context.range, false)),
|
|
1068
864
|
},
|
|
1069
865
|
{
|
|
1070
866
|
icon: ClearIcon,
|
|
@@ -1077,8 +873,7 @@ const commands: Command[] = [
|
|
|
1077
873
|
key: '0',
|
|
1078
874
|
visible: true,
|
|
1079
875
|
active: (context) => context.startIsText || context.endIsText,
|
|
1080
|
-
handler: (context) =>
|
|
1081
|
-
context.root.withRangeFormatted(context.range, ''),
|
|
876
|
+
handler: (context) => context.root.withRangeFormatted(context.range, ''),
|
|
1082
877
|
},
|
|
1083
878
|
{
|
|
1084
879
|
icon: BoldIcon,
|
|
@@ -1091,8 +886,7 @@ const commands: Command[] = [
|
|
|
1091
886
|
key: 'b',
|
|
1092
887
|
visible: true,
|
|
1093
888
|
active: (context) => context.startIsText || context.endIsText,
|
|
1094
|
-
handler: (context) =>
|
|
1095
|
-
context.root.withRangeFormatted(context.range, '*'),
|
|
889
|
+
handler: (context) => context.root.withRangeFormatted(context.range, '*'),
|
|
1096
890
|
},
|
|
1097
891
|
{
|
|
1098
892
|
description: 'italic',
|
|
@@ -1105,8 +899,7 @@ const commands: Command[] = [
|
|
|
1105
899
|
key: 'i',
|
|
1106
900
|
visible: true,
|
|
1107
901
|
active: (context) => context.startIsText || context.endIsText,
|
|
1108
|
-
handler: (context) =>
|
|
1109
|
-
context.root.withRangeFormatted(context.range, '_'),
|
|
902
|
+
handler: (context) => context.root.withRangeFormatted(context.range, '_'),
|
|
1110
903
|
},
|
|
1111
904
|
{
|
|
1112
905
|
icon: SubscriptIcon,
|
|
@@ -1119,8 +912,7 @@ const commands: Command[] = [
|
|
|
1119
912
|
key: ',',
|
|
1120
913
|
visible: true,
|
|
1121
914
|
active: (context) => context.startIsText || context.endIsText,
|
|
1122
|
-
handler: (context) =>
|
|
1123
|
-
context.root.withRangeFormatted(context.range, 'v'),
|
|
915
|
+
handler: (context) => context.root.withRangeFormatted(context.range, 'v'),
|
|
1124
916
|
},
|
|
1125
917
|
{
|
|
1126
918
|
icon: SuperscriptIcon,
|
|
@@ -1133,8 +925,7 @@ const commands: Command[] = [
|
|
|
1133
925
|
key: '.',
|
|
1134
926
|
visible: true,
|
|
1135
927
|
active: (context) => context.startIsText || context.endIsText,
|
|
1136
|
-
handler: (context) =>
|
|
1137
|
-
context.root.withRangeFormatted(context.range, '^'),
|
|
928
|
+
handler: (context) => context.root.withRangeFormatted(context.range, '^'),
|
|
1138
929
|
},
|
|
1139
930
|
{
|
|
1140
931
|
icon: CodeIcon,
|
|
@@ -1147,20 +938,9 @@ const commands: Command[] = [
|
|
|
1147
938
|
key: 'e',
|
|
1148
939
|
visible: true,
|
|
1149
940
|
active: (context) => context.startIsText || context.endIsText,
|
|
1150
|
-
handler: (context) =>
|
|
1151
|
-
context.meta
|
|
1152
|
-
|
|
1153
|
-
context,
|
|
1154
|
-
context.format,
|
|
1155
|
-
context.format?.withSegmentReplaced(
|
|
1156
|
-
context.meta,
|
|
1157
|
-
context.meta.getText()
|
|
1158
|
-
)
|
|
1159
|
-
)
|
|
1160
|
-
: context.root.withSegmentAtSelection(
|
|
1161
|
-
context.range,
|
|
1162
|
-
(text) => new InlineCodeNode(new TextNode(text))
|
|
1163
|
-
),
|
|
941
|
+
handler: (context) => context.meta instanceof InlineCodeNode
|
|
942
|
+
? rootWithNode(context, context.format, context.format?.withSegmentReplaced(context.meta, context.meta.getText()))
|
|
943
|
+
: context.root.withSegmentAtSelection(context.range, (text) => new InlineCodeNode(new TextNode(text))),
|
|
1164
944
|
},
|
|
1165
945
|
{
|
|
1166
946
|
icon: LinkIcon,
|
|
@@ -1172,23 +952,11 @@ const commands: Command[] = [
|
|
|
1172
952
|
shift: false,
|
|
1173
953
|
key: 'k',
|
|
1174
954
|
visible: true,
|
|
1175
|
-
active: (context) =>
|
|
1176
|
-
(context.atom === undefined && context.meta === undefined) ||
|
|
955
|
+
active: (context) => (context.atom === undefined && context.meta === undefined) ||
|
|
1177
956
|
context.meta instanceof LinkNode,
|
|
1178
|
-
handler: (context) =>
|
|
1179
|
-
context.meta
|
|
1180
|
-
|
|
1181
|
-
context,
|
|
1182
|
-
context.format,
|
|
1183
|
-
context.format?.withSegmentReplaced(
|
|
1184
|
-
context.meta,
|
|
1185
|
-
context.meta.getText()
|
|
1186
|
-
)
|
|
1187
|
-
)
|
|
1188
|
-
: context.root.withSegmentAtSelection(
|
|
1189
|
-
context.range,
|
|
1190
|
-
(text) => new LinkNode(new TextNode(text))
|
|
1191
|
-
),
|
|
957
|
+
handler: (context) => context.meta instanceof LinkNode
|
|
958
|
+
? rootWithNode(context, context.format, context.format?.withSegmentReplaced(context.meta, context.meta.getText()))
|
|
959
|
+
: context.root.withSegmentAtSelection(context.range, (text) => new LinkNode(new TextNode(text))),
|
|
1192
960
|
},
|
|
1193
961
|
{
|
|
1194
962
|
icon: DefineIcon,
|
|
@@ -1199,28 +967,15 @@ const commands: Command[] = [
|
|
|
1199
967
|
alt: false,
|
|
1200
968
|
shift: false,
|
|
1201
969
|
key: 'd',
|
|
1202
|
-
visible: (context) =>
|
|
1203
|
-
context.chapter &&
|
|
970
|
+
visible: (context) => context.chapter &&
|
|
1204
971
|
context.atom === undefined &&
|
|
1205
972
|
context.meta === undefined,
|
|
1206
|
-
active: (context) =>
|
|
1207
|
-
context.chapter &&
|
|
973
|
+
active: (context) => context.chapter &&
|
|
1208
974
|
context.atom === undefined &&
|
|
1209
975
|
context.meta === undefined,
|
|
1210
|
-
handler: (context) =>
|
|
1211
|
-
context.meta
|
|
1212
|
-
|
|
1213
|
-
context,
|
|
1214
|
-
context.format,
|
|
1215
|
-
context.format?.withSegmentReplaced(
|
|
1216
|
-
context.meta,
|
|
1217
|
-
context.meta.getText()
|
|
1218
|
-
)
|
|
1219
|
-
)
|
|
1220
|
-
: context.root.withSegmentAtSelection(
|
|
1221
|
-
context.range,
|
|
1222
|
-
(text) => new DefinitionNode(new TextNode(text))
|
|
1223
|
-
),
|
|
976
|
+
handler: (context) => context.meta instanceof DefinitionNode
|
|
977
|
+
? rootWithNode(context, context.format, context.format?.withSegmentReplaced(context.meta, context.meta.getText()))
|
|
978
|
+
: context.root.withSegmentAtSelection(context.range, (text) => new DefinitionNode(new TextNode(text))),
|
|
1224
979
|
},
|
|
1225
980
|
{
|
|
1226
981
|
icon: FootnoteIcon,
|
|
@@ -1231,20 +986,13 @@ const commands: Command[] = [
|
|
|
1231
986
|
alt: false,
|
|
1232
987
|
shift: false,
|
|
1233
988
|
key: 'f',
|
|
1234
|
-
visible: (context) =>
|
|
1235
|
-
context.chapter &&
|
|
989
|
+
visible: (context) => context.chapter &&
|
|
1236
990
|
context.atom === undefined &&
|
|
1237
991
|
context.meta === undefined,
|
|
1238
|
-
active: (context) =>
|
|
1239
|
-
context.chapter &&
|
|
992
|
+
active: (context) => context.chapter &&
|
|
1240
993
|
context.atom === undefined &&
|
|
1241
994
|
context.meta === undefined,
|
|
1242
|
-
handler: (context) =>
|
|
1243
|
-
context.root.withSegmentAtSelection(
|
|
1244
|
-
context.range,
|
|
1245
|
-
(text) =>
|
|
1246
|
-
new FootnoteNode(new FormatNode('', [new TextNode(text)]))
|
|
1247
|
-
),
|
|
995
|
+
handler: (context) => context.root.withSegmentAtSelection(context.range, (text) => new FootnoteNode(new FormatNode('', [new TextNode(text)]))),
|
|
1248
996
|
},
|
|
1249
997
|
{
|
|
1250
998
|
icon: CitationIcon,
|
|
@@ -1255,19 +1003,13 @@ const commands: Command[] = [
|
|
|
1255
1003
|
alt: false,
|
|
1256
1004
|
shift: false,
|
|
1257
1005
|
key: 'o',
|
|
1258
|
-
visible: (context) =>
|
|
1259
|
-
context.chapter &&
|
|
1006
|
+
visible: (context) => context.chapter &&
|
|
1260
1007
|
context.atom === undefined &&
|
|
1261
1008
|
context.meta === undefined,
|
|
1262
|
-
active: (context) =>
|
|
1263
|
-
context.chapter &&
|
|
1009
|
+
active: (context) => context.chapter &&
|
|
1264
1010
|
context.atom === undefined &&
|
|
1265
1011
|
context.meta === undefined,
|
|
1266
|
-
handler: (context) =>
|
|
1267
|
-
context.root.withSegmentAtSelection(
|
|
1268
|
-
context.range,
|
|
1269
|
-
() => new CitationsNode([])
|
|
1270
|
-
),
|
|
1012
|
+
handler: (context) => context.root.withSegmentAtSelection(context.range, () => new CitationsNode([])),
|
|
1271
1013
|
},
|
|
1272
1014
|
{
|
|
1273
1015
|
icon: LabelIcon,
|
|
@@ -1278,19 +1020,13 @@ const commands: Command[] = [
|
|
|
1278
1020
|
alt: false,
|
|
1279
1021
|
shift: false,
|
|
1280
1022
|
key: 'l',
|
|
1281
|
-
visible: (context) =>
|
|
1282
|
-
context.chapter &&
|
|
1023
|
+
visible: (context) => context.chapter &&
|
|
1283
1024
|
context.atom === undefined &&
|
|
1284
1025
|
context.meta === undefined,
|
|
1285
|
-
active: (context) =>
|
|
1286
|
-
context.chapter &&
|
|
1026
|
+
active: (context) => context.chapter &&
|
|
1287
1027
|
context.atom === undefined &&
|
|
1288
1028
|
context.meta === undefined,
|
|
1289
|
-
handler: (context) =>
|
|
1290
|
-
context.root.withSegmentAtSelection(
|
|
1291
|
-
context.range,
|
|
1292
|
-
() => new LabelNode('')
|
|
1293
|
-
),
|
|
1029
|
+
handler: (context) => context.root.withSegmentAtSelection(context.range, () => new LabelNode('')),
|
|
1294
1030
|
},
|
|
1295
1031
|
{
|
|
1296
1032
|
icon: CommentIcon,
|
|
@@ -1301,20 +1037,13 @@ const commands: Command[] = [
|
|
|
1301
1037
|
alt: false,
|
|
1302
1038
|
shift: false,
|
|
1303
1039
|
key: "'",
|
|
1304
|
-
visible: (context) =>
|
|
1305
|
-
context.chapter &&
|
|
1040
|
+
visible: (context) => context.chapter &&
|
|
1306
1041
|
context.atom === undefined &&
|
|
1307
1042
|
context.meta === undefined,
|
|
1308
|
-
active: (context) =>
|
|
1309
|
-
context.chapter &&
|
|
1043
|
+
active: (context) => context.chapter &&
|
|
1310
1044
|
context.atom === undefined &&
|
|
1311
1045
|
context.meta === undefined,
|
|
1312
|
-
handler: (context) =>
|
|
1313
|
-
context.root.withSegmentAtSelection(
|
|
1314
|
-
context.range,
|
|
1315
|
-
(text) =>
|
|
1316
|
-
new CommentNode(new FormatNode('', [new TextNode(text)]))
|
|
1317
|
-
),
|
|
1046
|
+
handler: (context) => context.root.withSegmentAtSelection(context.range, (text) => new CommentNode(new FormatNode('', [new TextNode(text)]))),
|
|
1318
1047
|
},
|
|
1319
1048
|
{
|
|
1320
1049
|
icon: ParagraphIcon,
|
|
@@ -1325,19 +1054,14 @@ const commands: Command[] = [
|
|
|
1325
1054
|
alt: true,
|
|
1326
1055
|
shift: false,
|
|
1327
1056
|
code: 'Digit0',
|
|
1328
|
-
visible: (context) =>
|
|
1329
|
-
context.paragraph !== undefined &&
|
|
1057
|
+
visible: (context) => context.paragraph !== undefined &&
|
|
1330
1058
|
context.paragraph.getLevel() !== 0,
|
|
1331
|
-
active: (context) =>
|
|
1332
|
-
context.paragraph !== undefined &&
|
|
1059
|
+
active: (context) => context.paragraph !== undefined &&
|
|
1333
1060
|
context.paragraph.getLevel() !== 0,
|
|
1334
1061
|
handler: (context) => {
|
|
1335
|
-
if (context.paragraph === undefined)
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
context.paragraph,
|
|
1339
|
-
context.paragraph.withLevel(0)
|
|
1340
|
-
);
|
|
1062
|
+
if (context.paragraph === undefined)
|
|
1063
|
+
return;
|
|
1064
|
+
return rootWithNode(context, context.paragraph, context.paragraph.withLevel(0));
|
|
1341
1065
|
},
|
|
1342
1066
|
},
|
|
1343
1067
|
{
|
|
@@ -1350,15 +1074,9 @@ const commands: Command[] = [
|
|
|
1350
1074
|
shift: false,
|
|
1351
1075
|
code: 'Digit1',
|
|
1352
1076
|
visible: (context) => context.paragraph !== undefined,
|
|
1353
|
-
active: (context) =>
|
|
1354
|
-
context.paragraph !== undefined &&
|
|
1077
|
+
active: (context) => context.paragraph !== undefined &&
|
|
1355
1078
|
context.paragraph.getLevel() !== 1,
|
|
1356
|
-
handler: (context) =>
|
|
1357
|
-
rootWithNode(
|
|
1358
|
-
context,
|
|
1359
|
-
context.paragraph,
|
|
1360
|
-
context.paragraph?.withLevel(1)
|
|
1361
|
-
),
|
|
1079
|
+
handler: (context) => rootWithNode(context, context.paragraph, context.paragraph?.withLevel(1)),
|
|
1362
1080
|
},
|
|
1363
1081
|
{
|
|
1364
1082
|
icon: Header2Icon,
|
|
@@ -1370,15 +1088,9 @@ const commands: Command[] = [
|
|
|
1370
1088
|
shift: false,
|
|
1371
1089
|
code: 'Digit2',
|
|
1372
1090
|
visible: (context) => context.paragraph !== undefined,
|
|
1373
|
-
active: (context) =>
|
|
1374
|
-
context.paragraph !== undefined &&
|
|
1091
|
+
active: (context) => context.paragraph !== undefined &&
|
|
1375
1092
|
context.paragraph.getLevel() !== 2,
|
|
1376
|
-
handler: (context) =>
|
|
1377
|
-
rootWithNode(
|
|
1378
|
-
context,
|
|
1379
|
-
context.paragraph,
|
|
1380
|
-
context.paragraph?.withLevel(2)
|
|
1381
|
-
),
|
|
1093
|
+
handler: (context) => rootWithNode(context, context.paragraph, context.paragraph?.withLevel(2)),
|
|
1382
1094
|
},
|
|
1383
1095
|
{
|
|
1384
1096
|
icon: Header3Icon,
|
|
@@ -1390,15 +1102,9 @@ const commands: Command[] = [
|
|
|
1390
1102
|
shift: false,
|
|
1391
1103
|
code: 'Digit3',
|
|
1392
1104
|
visible: (context) => context.paragraph !== undefined,
|
|
1393
|
-
active: (context) =>
|
|
1394
|
-
context.paragraph !== undefined &&
|
|
1105
|
+
active: (context) => context.paragraph !== undefined &&
|
|
1395
1106
|
context.paragraph.getLevel() !== 3,
|
|
1396
|
-
handler: (context) =>
|
|
1397
|
-
rootWithNode(
|
|
1398
|
-
context,
|
|
1399
|
-
context.paragraph,
|
|
1400
|
-
context.paragraph?.withLevel(3)
|
|
1401
|
-
),
|
|
1107
|
+
handler: (context) => rootWithNode(context, context.paragraph, context.paragraph?.withLevel(3)),
|
|
1402
1108
|
},
|
|
1403
1109
|
{
|
|
1404
1110
|
icon: RuleIcon,
|
|
@@ -1410,19 +1116,10 @@ const commands: Command[] = [
|
|
|
1410
1116
|
shift: false,
|
|
1411
1117
|
key: 'u',
|
|
1412
1118
|
visible: (context) => context.paragraph !== undefined,
|
|
1413
|
-
active: (context) =>
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
? rootWithNode(
|
|
1418
|
-
context,
|
|
1419
|
-
context.blocks,
|
|
1420
|
-
context.blocks?.withBlockInsertedBefore(
|
|
1421
|
-
context.paragraph,
|
|
1422
|
-
new RuleNode()
|
|
1423
|
-
)
|
|
1424
|
-
)
|
|
1425
|
-
: undefined,
|
|
1119
|
+
active: (context) => context.paragraph !== undefined && context.atParagraphStart,
|
|
1120
|
+
handler: (context) => context.paragraph
|
|
1121
|
+
? rootWithNode(context, context.blocks, context.blocks?.withBlockInsertedBefore(context.paragraph, new RuleNode()))
|
|
1122
|
+
: undefined,
|
|
1426
1123
|
},
|
|
1427
1124
|
{
|
|
1428
1125
|
icon: CalloutIcon,
|
|
@@ -1434,22 +1131,13 @@ const commands: Command[] = [
|
|
|
1434
1131
|
shift: true,
|
|
1435
1132
|
key: '-',
|
|
1436
1133
|
visible: (context) => context.paragraph !== undefined,
|
|
1437
|
-
active: (context) =>
|
|
1438
|
-
context.paragraph !== undefined && context.atParagraphStart,
|
|
1134
|
+
active: (context) => context.paragraph !== undefined && context.atParagraphStart,
|
|
1439
1135
|
handler: (context) => {
|
|
1440
1136
|
// If the caret is in a paragraph in a blocks node, insert a callout before the current paragraph.
|
|
1441
1137
|
if (context.blocks && context.paragraph) {
|
|
1442
1138
|
// Make a new callout node with an empty paragraph, insert it before the paragraph the caret is in, and place the caret inside the empty paragraph.
|
|
1443
1139
|
const newParagraph = new ParagraphNode();
|
|
1444
|
-
return rootWithNode(
|
|
1445
|
-
context,
|
|
1446
|
-
context.blocks,
|
|
1447
|
-
context.blocks.withBlockInsertedBefore(
|
|
1448
|
-
context.paragraph,
|
|
1449
|
-
new CalloutNode([newParagraph])
|
|
1450
|
-
),
|
|
1451
|
-
() => newParagraph.getFirstCaret()
|
|
1452
|
-
);
|
|
1140
|
+
return rootWithNode(context, context.blocks, context.blocks.withBlockInsertedBefore(context.paragraph, new CalloutNode([newParagraph])), () => newParagraph.getFirstCaret());
|
|
1453
1141
|
}
|
|
1454
1142
|
},
|
|
1455
1143
|
},
|
|
@@ -1463,21 +1151,12 @@ const commands: Command[] = [
|
|
|
1463
1151
|
shift: true,
|
|
1464
1152
|
key: "'",
|
|
1465
1153
|
visible: (context) => context.paragraph !== undefined,
|
|
1466
|
-
active: (context) =>
|
|
1467
|
-
context.paragraph !== undefined && context.atParagraphStart,
|
|
1154
|
+
active: (context) => context.paragraph !== undefined && context.atParagraphStart,
|
|
1468
1155
|
handler: (context) => {
|
|
1469
1156
|
if (context.blocks && context.paragraph) {
|
|
1470
1157
|
// Make a new quote and place the caret inside the quote's first empty paragraph.
|
|
1471
1158
|
const newParagraph = new ParagraphNode();
|
|
1472
|
-
return rootWithNode(
|
|
1473
|
-
context,
|
|
1474
|
-
context.blocks,
|
|
1475
|
-
context.blocks.withBlockInsertedBefore(
|
|
1476
|
-
context.paragraph,
|
|
1477
|
-
new QuoteNode([newParagraph])
|
|
1478
|
-
),
|
|
1479
|
-
() => newParagraph.getFirstCaret()
|
|
1480
|
-
);
|
|
1159
|
+
return rootWithNode(context, context.blocks, context.blocks.withBlockInsertedBefore(context.paragraph, new QuoteNode([newParagraph])), () => newParagraph.getFirstCaret());
|
|
1481
1160
|
}
|
|
1482
1161
|
},
|
|
1483
1162
|
},
|
|
@@ -1491,22 +1170,13 @@ const commands: Command[] = [
|
|
|
1491
1170
|
shift: true,
|
|
1492
1171
|
key: 's',
|
|
1493
1172
|
visible: (context) => context.paragraph !== undefined,
|
|
1494
|
-
active: (context) =>
|
|
1495
|
-
context.paragraph !== undefined && context.atParagraphStart,
|
|
1173
|
+
active: (context) => context.paragraph !== undefined && context.atParagraphStart,
|
|
1496
1174
|
handler: (context) => {
|
|
1497
1175
|
if (context.blocks && context.paragraph) {
|
|
1498
1176
|
const newCode = new CodeNode(new TextNode(), 'plaintext', '|');
|
|
1499
|
-
return rootWithNode(
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
context.blocks.withBlockInsertedBefore(
|
|
1503
|
-
context.paragraph,
|
|
1504
|
-
newCode
|
|
1505
|
-
),
|
|
1506
|
-
() => {
|
|
1507
|
-
return { node: newCode.getCodeNode(), index: 0 };
|
|
1508
|
-
}
|
|
1509
|
-
);
|
|
1177
|
+
return rootWithNode(context, context.blocks, context.blocks.withBlockInsertedBefore(context.paragraph, newCode), () => {
|
|
1178
|
+
return { node: newCode.getCodeNode(), index: 0 };
|
|
1179
|
+
});
|
|
1510
1180
|
}
|
|
1511
1181
|
},
|
|
1512
1182
|
},
|
|
@@ -1520,21 +1190,12 @@ const commands: Command[] = [
|
|
|
1520
1190
|
shift: true,
|
|
1521
1191
|
key: 'i',
|
|
1522
1192
|
visible: (context) => context.paragraph !== undefined,
|
|
1523
|
-
active: (context) =>
|
|
1524
|
-
context.paragraph !== undefined && context.atParagraphStart,
|
|
1193
|
+
active: (context) => context.paragraph !== undefined && context.atParagraphStart,
|
|
1525
1194
|
handler: (context) => {
|
|
1526
1195
|
if (context.blocks && context.paragraph) {
|
|
1527
1196
|
// Place the caret inside the code's code node.
|
|
1528
1197
|
const newEmbed = new EmbedNode('', '');
|
|
1529
|
-
return rootWithNode(
|
|
1530
|
-
context,
|
|
1531
|
-
context.blocks,
|
|
1532
|
-
context.blocks.withBlockInsertedBefore(
|
|
1533
|
-
context.paragraph,
|
|
1534
|
-
newEmbed
|
|
1535
|
-
),
|
|
1536
|
-
() => newEmbed.getCaption().getFirstCaret()
|
|
1537
|
-
);
|
|
1198
|
+
return rootWithNode(context, context.blocks, context.blocks.withBlockInsertedBefore(context.paragraph, newEmbed), () => newEmbed.getCaption().getFirstCaret());
|
|
1538
1199
|
}
|
|
1539
1200
|
},
|
|
1540
1201
|
},
|
|
@@ -1548,36 +1209,23 @@ const commands: Command[] = [
|
|
|
1548
1209
|
shift: false,
|
|
1549
1210
|
key: '[',
|
|
1550
1211
|
visible: (context) => context.paragraph !== undefined,
|
|
1551
|
-
active: (context) =>
|
|
1552
|
-
context.paragraph !== undefined && context.atParagraphStart,
|
|
1212
|
+
active: (context) => context.paragraph !== undefined && context.atParagraphStart,
|
|
1553
1213
|
handler: (context) => {
|
|
1554
1214
|
if (context.blocks && context.paragraph) {
|
|
1555
1215
|
// Create a 3x3 of table rows and columns
|
|
1556
1216
|
// Return a caret corresponding to the first cell.
|
|
1557
|
-
const newRows
|
|
1217
|
+
const newRows = [[], [], []];
|
|
1558
1218
|
for (let r = 0; r < Math.max(1, 3); r++) {
|
|
1559
1219
|
for (let c = 0; c < Math.max(1, 3); c++)
|
|
1560
1220
|
newRows[r].push(new FormatNode('', [new TextNode()]));
|
|
1561
1221
|
}
|
|
1562
|
-
const newTable = new TableNode(
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
context.blocks,
|
|
1570
|
-
context.blocks.withBlockInsertedBefore(
|
|
1571
|
-
context.paragraph,
|
|
1572
|
-
newTable
|
|
1573
|
-
),
|
|
1574
|
-
() => {
|
|
1575
|
-
return {
|
|
1576
|
-
node: newTable.getRows()[0][0].getTextNodes()[0],
|
|
1577
|
-
index: 0,
|
|
1578
|
-
};
|
|
1579
|
-
}
|
|
1580
|
-
);
|
|
1222
|
+
const newTable = new TableNode(newRows, '|', new FormatNode('', [new TextNode()]));
|
|
1223
|
+
return rootWithNode(context, context.blocks, context.blocks.withBlockInsertedBefore(context.paragraph, newTable), () => {
|
|
1224
|
+
return {
|
|
1225
|
+
node: newTable.getRows()[0][0].getTextNodes()[0],
|
|
1226
|
+
index: 0,
|
|
1227
|
+
};
|
|
1228
|
+
});
|
|
1581
1229
|
}
|
|
1582
1230
|
},
|
|
1583
1231
|
},
|
|
@@ -1590,16 +1238,9 @@ const commands: Command[] = [
|
|
|
1590
1238
|
alt: false,
|
|
1591
1239
|
shift: true,
|
|
1592
1240
|
key: '7',
|
|
1593
|
-
visible: (context) =>
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
context.paragraph !== undefined && context.list === undefined,
|
|
1597
|
-
handler: (context) =>
|
|
1598
|
-
rootWithNode(
|
|
1599
|
-
context,
|
|
1600
|
-
context.blocks,
|
|
1601
|
-
context.blocks?.withParagraphsAsLists(context.range, false)
|
|
1602
|
-
),
|
|
1241
|
+
visible: (context) => context.paragraph !== undefined && context.list === undefined,
|
|
1242
|
+
active: (context) => context.paragraph !== undefined && context.list === undefined,
|
|
1243
|
+
handler: (context) => rootWithNode(context, context.blocks, context.blocks?.withParagraphsAsLists(context.range, false)),
|
|
1603
1244
|
},
|
|
1604
1245
|
{
|
|
1605
1246
|
icon: NumbersIcon,
|
|
@@ -1610,16 +1251,9 @@ const commands: Command[] = [
|
|
|
1610
1251
|
alt: false,
|
|
1611
1252
|
shift: true,
|
|
1612
1253
|
key: '8',
|
|
1613
|
-
visible: (context) =>
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
context.paragraph !== undefined && context.list === undefined,
|
|
1617
|
-
handler: (context) =>
|
|
1618
|
-
rootWithNode(
|
|
1619
|
-
context,
|
|
1620
|
-
context.blocks,
|
|
1621
|
-
context.blocks?.withParagraphsAsLists(context.range, true)
|
|
1622
|
-
),
|
|
1254
|
+
visible: (context) => context.paragraph !== undefined && context.list === undefined,
|
|
1255
|
+
active: (context) => context.paragraph !== undefined && context.list === undefined,
|
|
1256
|
+
handler: (context) => rootWithNode(context, context.blocks, context.blocks?.withParagraphsAsLists(context.range, true)),
|
|
1623
1257
|
},
|
|
1624
1258
|
{
|
|
1625
1259
|
icon: BulletsIcon,
|
|
@@ -1630,18 +1264,11 @@ const commands: Command[] = [
|
|
|
1630
1264
|
alt: false,
|
|
1631
1265
|
shift: true,
|
|
1632
1266
|
key: '7',
|
|
1633
|
-
visible: (context) =>
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
context.
|
|
1637
|
-
|
|
1638
|
-
context.list
|
|
1639
|
-
? rootWithNode(
|
|
1640
|
-
context,
|
|
1641
|
-
context.blocks,
|
|
1642
|
-
context.blocks?.withListAsStyle(context.list, false)
|
|
1643
|
-
)
|
|
1644
|
-
: undefined,
|
|
1267
|
+
visible: (context) => context.list !== undefined && context.list.isNumbered(),
|
|
1268
|
+
active: (context) => context.list !== undefined && context.list.isNumbered(),
|
|
1269
|
+
handler: (context) => context.list
|
|
1270
|
+
? rootWithNode(context, context.blocks, context.blocks?.withListAsStyle(context.list, false))
|
|
1271
|
+
: undefined,
|
|
1645
1272
|
},
|
|
1646
1273
|
{
|
|
1647
1274
|
icon: NumbersIcon,
|
|
@@ -1652,18 +1279,11 @@ const commands: Command[] = [
|
|
|
1652
1279
|
alt: false,
|
|
1653
1280
|
shift: true,
|
|
1654
1281
|
key: '8',
|
|
1655
|
-
visible: (context) =>
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
context.
|
|
1659
|
-
|
|
1660
|
-
context.list
|
|
1661
|
-
? rootWithNode(
|
|
1662
|
-
context,
|
|
1663
|
-
context.blocks,
|
|
1664
|
-
context.blocks?.withListAsStyle(context.list, true)
|
|
1665
|
-
)
|
|
1666
|
-
: undefined,
|
|
1282
|
+
visible: (context) => context.list !== undefined && !context.list.isNumbered(),
|
|
1283
|
+
active: (context) => context.list !== undefined && !context.list.isNumbered(),
|
|
1284
|
+
handler: (context) => context.list
|
|
1285
|
+
? rootWithNode(context, context.blocks, context.blocks?.withListAsStyle(context.list, true))
|
|
1286
|
+
: undefined,
|
|
1667
1287
|
},
|
|
1668
1288
|
{
|
|
1669
1289
|
icon: ParagraphIcon,
|
|
@@ -1676,12 +1296,7 @@ const commands: Command[] = [
|
|
|
1676
1296
|
key: ['7', '8'],
|
|
1677
1297
|
visible: (context) => context.list !== undefined,
|
|
1678
1298
|
active: (context) => context.list !== undefined,
|
|
1679
|
-
handler: (context) =>
|
|
1680
|
-
rootWithNode(
|
|
1681
|
-
context,
|
|
1682
|
-
context.blocks,
|
|
1683
|
-
context.blocks?.withListsAsParagraphs(context.range)
|
|
1684
|
-
),
|
|
1299
|
+
handler: (context) => rootWithNode(context, context.blocks, context.blocks?.withListsAsParagraphs(context.range)),
|
|
1685
1300
|
},
|
|
1686
1301
|
{
|
|
1687
1302
|
icon: UndoIcon,
|
|
@@ -1693,8 +1308,7 @@ const commands: Command[] = [
|
|
|
1693
1308
|
shift: false,
|
|
1694
1309
|
key: 'z',
|
|
1695
1310
|
visible: true,
|
|
1696
|
-
active: (context) =>
|
|
1697
|
-
context.undoStack.length > 0 &&
|
|
1311
|
+
active: (context) => context.undoStack.length > 0 &&
|
|
1698
1312
|
context.undoPosition < context.undoStack.length - 1,
|
|
1699
1313
|
handler: (context) => context.undo(),
|
|
1700
1314
|
},
|
|
@@ -1723,22 +1337,15 @@ const commands: Command[] = [
|
|
|
1723
1337
|
visible: true,
|
|
1724
1338
|
active: (context) => context.root !== undefined && context.isSelection,
|
|
1725
1339
|
handler: (context) => {
|
|
1726
|
-
if (context.root === undefined)
|
|
1340
|
+
if (context.root === undefined)
|
|
1341
|
+
return;
|
|
1727
1342
|
// Save the copied content to the clipboard
|
|
1728
1343
|
const copy = context.root.copyRange(context.range);
|
|
1729
|
-
const edit = context.root.withRangeFormatted(
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
);
|
|
1733
|
-
if (edit === undefined || copy === undefined) return;
|
|
1344
|
+
const edit = context.root.withRangeFormatted(context.range, undefined);
|
|
1345
|
+
if (edit === undefined || copy === undefined)
|
|
1346
|
+
return;
|
|
1734
1347
|
context.handleCopy(copy);
|
|
1735
|
-
|
|
1736
|
-
return rootWithNode<RootNode>(
|
|
1737
|
-
context,
|
|
1738
|
-
context.root,
|
|
1739
|
-
edit.root as RootNode,
|
|
1740
|
-
() => edit.range.start
|
|
1741
|
-
);
|
|
1348
|
+
return rootWithNode(context, context.root, edit.root, () => edit.range.start);
|
|
1742
1349
|
},
|
|
1743
1350
|
},
|
|
1744
1351
|
{
|
|
@@ -1753,10 +1360,12 @@ const commands: Command[] = [
|
|
|
1753
1360
|
visible: true,
|
|
1754
1361
|
active: (context) => context.isSelection,
|
|
1755
1362
|
handler: (context) => {
|
|
1756
|
-
if (context.root === undefined)
|
|
1363
|
+
if (context.root === undefined)
|
|
1364
|
+
return;
|
|
1757
1365
|
// Save the copied content to the clipboard
|
|
1758
1366
|
const copy = context.root.copyRange(context.range);
|
|
1759
|
-
if (copy !== undefined)
|
|
1367
|
+
if (copy !== undefined)
|
|
1368
|
+
context.handleCopy(copy);
|
|
1760
1369
|
return undefined;
|
|
1761
1370
|
},
|
|
1762
1371
|
},
|
|
@@ -1772,11 +1381,11 @@ const commands: Command[] = [
|
|
|
1772
1381
|
visible: true,
|
|
1773
1382
|
active: () => true,
|
|
1774
1383
|
handler: (context) => {
|
|
1775
|
-
if (context.root === undefined)
|
|
1776
|
-
|
|
1384
|
+
if (context.root === undefined)
|
|
1385
|
+
return undefined;
|
|
1777
1386
|
// See if there's something on the clipboard.
|
|
1778
1387
|
if (navigator.clipboard) {
|
|
1779
|
-
navigator.clipboard.read().then((items
|
|
1388
|
+
navigator.clipboard.read().then((items) => {
|
|
1780
1389
|
// If there's nothing, paste whatever is on the editor clipboard, if there is something.
|
|
1781
1390
|
if (items.length === 0 && context.clipboard !== undefined)
|
|
1782
1391
|
context.handlePaste(context, context.clipboard, true);
|
|
@@ -1787,37 +1396,27 @@ const commands: Command[] = [
|
|
|
1787
1396
|
if (item) {
|
|
1788
1397
|
async function gatherClipboard() {
|
|
1789
1398
|
// Eventually we should add HTML support.
|
|
1790
|
-
const contents
|
|
1399
|
+
const contents = {
|
|
1791
1400
|
plain: undefined,
|
|
1792
1401
|
};
|
|
1793
1402
|
try {
|
|
1794
1403
|
{
|
|
1795
|
-
const blob = await item.getType(
|
|
1796
|
-
'text/plain'
|
|
1797
|
-
);
|
|
1404
|
+
const blob = await item.getType('text/plain');
|
|
1798
1405
|
const text = await blob.text();
|
|
1799
1406
|
contents.plain = text;
|
|
1800
1407
|
}
|
|
1801
|
-
context.handlePaste(
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
true
|
|
1805
|
-
);
|
|
1806
|
-
} catch (err) {}
|
|
1408
|
+
context.handlePaste(context, contents, true);
|
|
1409
|
+
}
|
|
1410
|
+
catch (err) { }
|
|
1807
1411
|
}
|
|
1808
1412
|
gatherClipboard();
|
|
1809
1413
|
}
|
|
1810
1414
|
// Otherwise, try pasting what's on the app clipboard.
|
|
1811
1415
|
else if (context.clipboard !== undefined)
|
|
1812
|
-
return context.handlePaste(
|
|
1813
|
-
context,
|
|
1814
|
-
context.clipboard,
|
|
1815
|
-
false
|
|
1816
|
-
);
|
|
1416
|
+
return context.handlePaste(context, context.clipboard, false);
|
|
1817
1417
|
}
|
|
1818
1418
|
});
|
|
1819
1419
|
}
|
|
1820
|
-
|
|
1821
1420
|
// Return the current caret to avoid unhandled command feedback.
|
|
1822
1421
|
return { root: context.root, range: context.range };
|
|
1823
1422
|
},
|
|
@@ -1833,8 +1432,7 @@ const commands: Command[] = [
|
|
|
1833
1432
|
shift: undefined,
|
|
1834
1433
|
key: (key) => key.length === 1,
|
|
1835
1434
|
visible: false,
|
|
1836
|
-
active: (context, key) =>
|
|
1837
|
-
context && key !== undefined && key.length === 1,
|
|
1435
|
+
active: (context, key) => context && key !== undefined && key.length === 1,
|
|
1838
1436
|
handler: (context, utilities, key) => {
|
|
1839
1437
|
utilities;
|
|
1840
1438
|
const range = context.range;
|
|
@@ -1842,62 +1440,49 @@ const commands: Command[] = [
|
|
|
1842
1440
|
// Insert at the start.
|
|
1843
1441
|
let sortedRange = range.start.node.sortRange(range);
|
|
1844
1442
|
let insertionPoint = sortedRange.start;
|
|
1845
|
-
let newRoot
|
|
1846
|
-
|
|
1443
|
+
let newRoot = context.root;
|
|
1847
1444
|
// Not a text node? Fail.
|
|
1848
|
-
if (!(insertionPoint.node instanceof TextNode))
|
|
1849
|
-
|
|
1445
|
+
if (!(insertionPoint.node instanceof TextNode))
|
|
1446
|
+
return;
|
|
1850
1447
|
// If there's a selection, remove it before inserting, and insert at the caret returned.
|
|
1851
1448
|
if (context.isSelection) {
|
|
1852
1449
|
if (context.code) {
|
|
1853
|
-
if (
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
if (
|
|
1860
|
-
|
|
1861
|
-
insertionPoint.node,
|
|
1862
|
-
newText
|
|
1863
|
-
);
|
|
1864
|
-
if (edit === undefined) return;
|
|
1450
|
+
if (context.code.getCodeNode() ===
|
|
1451
|
+
sortedRange.start.node) {
|
|
1452
|
+
const newText = insertionPoint.node.withoutRange(sortedRange);
|
|
1453
|
+
if (newText === undefined)
|
|
1454
|
+
return;
|
|
1455
|
+
const edit = newRoot.withNodeReplaced(insertionPoint.node, newText);
|
|
1456
|
+
if (edit === undefined)
|
|
1457
|
+
return;
|
|
1865
1458
|
newRoot = edit;
|
|
1866
1459
|
insertionPoint = {
|
|
1867
1460
|
node: newText,
|
|
1868
1461
|
index: sortedRange.start.index,
|
|
1869
1462
|
};
|
|
1870
1463
|
}
|
|
1871
|
-
}
|
|
1464
|
+
}
|
|
1465
|
+
else {
|
|
1872
1466
|
// Try to remove the range.
|
|
1873
|
-
let edit = newRoot.withRangeFormatted(
|
|
1874
|
-
sortedRange,
|
|
1875
|
-
undefined
|
|
1876
|
-
);
|
|
1467
|
+
let edit = newRoot.withRangeFormatted(sortedRange, undefined);
|
|
1877
1468
|
// If we fail, fail to insert at the selection.
|
|
1878
|
-
if (edit === undefined)
|
|
1879
|
-
|
|
1469
|
+
if (edit === undefined)
|
|
1470
|
+
return;
|
|
1471
|
+
newRoot = edit.root;
|
|
1880
1472
|
insertionPoint = edit.range.start;
|
|
1881
1473
|
}
|
|
1882
1474
|
}
|
|
1883
|
-
|
|
1884
1475
|
// Not a text node? Fail.
|
|
1885
|
-
if (!(insertionPoint.node instanceof TextNode))
|
|
1886
|
-
|
|
1476
|
+
if (!(insertionPoint.node instanceof TextNode))
|
|
1477
|
+
return;
|
|
1887
1478
|
// Update the text node.
|
|
1888
|
-
const newText = insertionPoint.node.withCharacterAt(
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
);
|
|
1892
|
-
if (newText === undefined) return;
|
|
1893
|
-
|
|
1479
|
+
const newText = insertionPoint.node.withCharacterAt(key, insertionPoint.index);
|
|
1480
|
+
if (newText === undefined)
|
|
1481
|
+
return;
|
|
1894
1482
|
// Replace the text.
|
|
1895
|
-
newRoot = newRoot.withNodeReplaced(
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
);
|
|
1899
|
-
if (newRoot === undefined) return;
|
|
1900
|
-
|
|
1483
|
+
newRoot = newRoot.withNodeReplaced(insertionPoint.node, newText);
|
|
1484
|
+
if (newRoot === undefined)
|
|
1485
|
+
return;
|
|
1901
1486
|
// Update the chapter
|
|
1902
1487
|
return rootWithNode(context, context.root, newRoot, () => {
|
|
1903
1488
|
return { node: newText, index: insertionPoint.index + 1 };
|