@fiduswriter/editor 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +22 -0
- package/dist/bibliography/tools.js +53 -0
- package/dist/bibliography/tools.js.map +1 -0
- package/dist/citations/index.js +339 -0
- package/dist/citations/index.js.map +1 -0
- package/dist/citations/render.js +47 -0
- package/dist/citations/render.js.map +1 -0
- package/dist/clipboard/copy/index.js +2 -0
- package/dist/clipboard/copy/index.js.map +1 -0
- package/dist/clipboard/copy/schema.js +54 -0
- package/dist/clipboard/copy/schema.js.map +1 -0
- package/dist/clipboard/copy/serializers.js +132 -0
- package/dist/clipboard/copy/serializers.js.map +1 -0
- package/dist/clipboard/paste/fidus_writer.js +45 -0
- package/dist/clipboard/paste/fidus_writer.js.map +1 -0
- package/dist/clipboard/paste/general.js +76 -0
- package/dist/clipboard/paste/general.js.map +1 -0
- package/dist/clipboard/paste/google_docs.js +24 -0
- package/dist/clipboard/paste/google_docs.js.map +1 -0
- package/dist/clipboard/paste/html.js +68 -0
- package/dist/clipboard/paste/html.js.map +1 -0
- package/dist/clipboard/paste/index.js +3 -0
- package/dist/clipboard/paste/index.js.map +1 -0
- package/dist/clipboard/paste/libreoffice_writer.js +27 -0
- package/dist/clipboard/paste/libreoffice_writer.js.map +1 -0
- package/dist/clipboard/paste/microsoft_word.js +79 -0
- package/dist/clipboard/paste/microsoft_word.js.map +1 -0
- package/dist/clipboard/paste/text.js +41 -0
- package/dist/clipboard/paste/text.js.map +1 -0
- package/dist/collab/chat.js +154 -0
- package/dist/collab/chat.js.map +1 -0
- package/dist/collab/colors.js +62 -0
- package/dist/collab/colors.js.map +1 -0
- package/dist/collab/doc.js +1090 -0
- package/dist/collab/doc.js.map +1 -0
- package/dist/collab/index.js +75 -0
- package/dist/collab/index.js.map +1 -0
- package/dist/collab/merge/changeset.js +90 -0
- package/dist/collab/merge/changeset.js.map +1 -0
- package/dist/collab/merge/editor.js +708 -0
- package/dist/collab/merge/editor.js.map +1 -0
- package/dist/collab/merge/footnotes.js +149 -0
- package/dist/collab/merge/footnotes.js.map +1 -0
- package/dist/collab/merge/index.js +270 -0
- package/dist/collab/merge/index.js.map +1 -0
- package/dist/collab/merge/recreate_transform.js +259 -0
- package/dist/collab/merge/recreate_transform.js.map +1 -0
- package/dist/collab/merge/schema.js +117 -0
- package/dist/collab/merge/schema.js.map +1 -0
- package/dist/collab/merge/state_plugins/action.js +138 -0
- package/dist/collab/merge/state_plugins/action.js.map +1 -0
- package/dist/collab/merge/state_plugins/clipboard.js +32 -0
- package/dist/collab/merge/state_plugins/clipboard.js.map +1 -0
- package/dist/collab/merge/state_plugins/diff.js +541 -0
- package/dist/collab/merge/state_plugins/diff.js.map +1 -0
- package/dist/collab/merge/state_plugins/index.js +3 -0
- package/dist/collab/merge/state_plugins/index.js.map +1 -0
- package/dist/collab/merge/tools.js +175 -0
- package/dist/collab/merge/tools.js.map +1 -0
- package/dist/collab/templates.js +10 -0
- package/dist/collab/templates.js.map +1 -0
- package/dist/comments/comment.js +17 -0
- package/dist/comments/comment.js.map +1 -0
- package/dist/comments/editors/answer.js +43 -0
- package/dist/comments/editors/answer.js.map +1 -0
- package/dist/comments/editors/comment.js +278 -0
- package/dist/comments/editors/comment.js.map +1 -0
- package/dist/comments/editors/index.js +4 -0
- package/dist/comments/editors/index.js.map +1 -0
- package/dist/comments/editors/notify.js +13 -0
- package/dist/comments/editors/notify.js.map +1 -0
- package/dist/comments/editors/schema.js +60 -0
- package/dist/comments/editors/schema.js.map +1 -0
- package/dist/comments/index.js +11 -0
- package/dist/comments/index.js.map +1 -0
- package/dist/comments/interactions.js +379 -0
- package/dist/comments/interactions.js.map +1 -0
- package/dist/comments/store.js +438 -0
- package/dist/comments/store.js.map +1 -0
- package/dist/contacts/add_dialog.js +88 -0
- package/dist/contacts/add_dialog.js.map +1 -0
- package/dist/contacts/templates.js +23 -0
- package/dist/contacts/templates.js.map +1 -0
- package/dist/copyright_dialog/index.js +148 -0
- package/dist/copyright_dialog/index.js.map +1 -0
- package/dist/copyright_dialog/templates.js +48 -0
- package/dist/copyright_dialog/templates.js.map +1 -0
- package/dist/databases/bibliography.js +162 -0
- package/dist/databases/bibliography.js.map +1 -0
- package/dist/databases/images.js +260 -0
- package/dist/databases/images.js.map +1 -0
- package/dist/databases/index.js +55 -0
- package/dist/databases/index.js.map +1 -0
- package/dist/dialogs/citation.js +321 -0
- package/dist/dialogs/citation.js.map +1 -0
- package/dist/dialogs/code_block.js +192 -0
- package/dist/dialogs/code_block.js.map +1 -0
- package/dist/dialogs/contributor.js +132 -0
- package/dist/dialogs/contributor.js.map +1 -0
- package/dist/dialogs/figure.js +378 -0
- package/dist/dialogs/figure.js.map +1 -0
- package/dist/dialogs/index.js +11 -0
- package/dist/dialogs/index.js.map +1 -0
- package/dist/dialogs/language.js +47 -0
- package/dist/dialogs/language.js.map +1 -0
- package/dist/dialogs/link.js +243 -0
- package/dist/dialogs/link.js.map +1 -0
- package/dist/dialogs/math.js +121 -0
- package/dist/dialogs/math.js.map +1 -0
- package/dist/dialogs/ordered_list.js +67 -0
- package/dist/dialogs/ordered_list.js.map +1 -0
- package/dist/dialogs/revision.js +36 -0
- package/dist/dialogs/revision.js.map +1 -0
- package/dist/dialogs/subsup.js +109 -0
- package/dist/dialogs/subsup.js.map +1 -0
- package/dist/dialogs/table.js +217 -0
- package/dist/dialogs/table.js.map +1 -0
- package/dist/dialogs/templates.js +366 -0
- package/dist/dialogs/templates.js.map +1 -0
- package/dist/document_template/exporter.js +83 -0
- package/dist/document_template/exporter.js.map +1 -0
- package/dist/document_template/index.js +327 -0
- package/dist/document_template/index.js.map +1 -0
- package/dist/documents/access_rights/index.js +532 -0
- package/dist/documents/access_rights/index.js.map +1 -0
- package/dist/documents/access_rights/templates.js +150 -0
- package/dist/documents/access_rights/templates.js.map +1 -0
- package/dist/e2ee/encryptor.js +201 -0
- package/dist/e2ee/encryptor.js.map +1 -0
- package/dist/e2ee/key-manager.js +171 -0
- package/dist/e2ee/key-manager.js.map +1 -0
- package/dist/e2ee/passphrase-crypto.js +365 -0
- package/dist/e2ee/passphrase-crypto.js.map +1 -0
- package/dist/e2ee/passphrase-dialog.js +548 -0
- package/dist/e2ee/passphrase-dialog.js.map +1 -0
- package/dist/e2ee/passphrase-manager.js +350 -0
- package/dist/e2ee/passphrase-manager.js.map +1 -0
- package/dist/e2ee/password-dialog.js +552 -0
- package/dist/e2ee/password-dialog.js.map +1 -0
- package/dist/e2ee/snapshot-manager.js +238 -0
- package/dist/e2ee/snapshot-manager.js.map +1 -0
- package/dist/exporter/native/copy.js +29 -0
- package/dist/exporter/native/copy.js.map +1 -0
- package/dist/exporter/native/file.js +19 -0
- package/dist/exporter/native/file.js.map +1 -0
- package/dist/exporter/native/index.js +4 -0
- package/dist/exporter/native/index.js.map +1 -0
- package/dist/exporter/native/revision.js +54 -0
- package/dist/exporter/native/revision.js.map +1 -0
- package/dist/exporter/native/zip.js +2 -0
- package/dist/exporter/native/zip.js.map +1 -0
- package/dist/footnotes/editor.js +180 -0
- package/dist/footnotes/editor.js.map +1 -0
- package/dist/footnotes/index.js +15 -0
- package/dist/footnotes/index.js.map +1 -0
- package/dist/footnotes/layout.js +125 -0
- package/dist/footnotes/layout.js.map +1 -0
- package/dist/footnotes/state_plugins/access_rights.js +25 -0
- package/dist/footnotes/state_plugins/access_rights.js.map +1 -0
- package/dist/footnotes/state_plugins/index.js +2 -0
- package/dist/footnotes/state_plugins/index.js.map +1 -0
- package/dist/images/edit_dialog/edit_dialog/index.js +186 -0
- package/dist/images/edit_dialog/edit_dialog/index.js.map +1 -0
- package/dist/images/edit_dialog/edit_dialog/model.js +152 -0
- package/dist/images/edit_dialog/edit_dialog/model.js.map +1 -0
- package/dist/images/edit_dialog/edit_dialog/templates.js +33 -0
- package/dist/images/edit_dialog/edit_dialog/templates.js.map +1 -0
- package/dist/images/edit_dialog/model.js +6 -0
- package/dist/images/edit_dialog/model.js.map +1 -0
- package/dist/images/selection_dialog/index.js +149 -0
- package/dist/images/selection_dialog/index.js.map +1 -0
- package/dist/index.js +1002 -0
- package/dist/index.js.map +1 -0
- package/dist/keymap.js +73 -0
- package/dist/keymap.js.map +1 -0
- package/dist/marginboxes/index.js +674 -0
- package/dist/marginboxes/index.js.map +1 -0
- package/dist/marginboxes/templates.js +447 -0
- package/dist/marginboxes/templates.js.map +1 -0
- package/dist/menus/code_block/index.js +2 -0
- package/dist/menus/code_block/index.js.map +1 -0
- package/dist/menus/code_block/model.js +49 -0
- package/dist/menus/code_block/model.js.map +1 -0
- package/dist/menus/figure/index.js +3 -0
- package/dist/menus/figure/index.js.map +1 -0
- package/dist/menus/figure/model.js +80 -0
- package/dist/menus/figure/model.js.map +1 -0
- package/dist/menus/figure/utils.js +6 -0
- package/dist/menus/figure/utils.js.map +1 -0
- package/dist/menus/headerbar/index.js +3 -0
- package/dist/menus/headerbar/index.js.map +1 -0
- package/dist/menus/headerbar/model.js +743 -0
- package/dist/menus/headerbar/model.js.map +1 -0
- package/dist/menus/headerbar/view.js +579 -0
- package/dist/menus/headerbar/view.js.map +1 -0
- package/dist/menus/image/index.js +2 -0
- package/dist/menus/image/index.js.map +1 -0
- package/dist/menus/image/model.js +32 -0
- package/dist/menus/image/model.js.map +1 -0
- package/dist/menus/index.js +10 -0
- package/dist/menus/index.js.map +1 -0
- package/dist/menus/navigator/index.js +2 -0
- package/dist/menus/navigator/index.js.map +1 -0
- package/dist/menus/navigator/model.js +29 -0
- package/dist/menus/navigator/model.js.map +1 -0
- package/dist/menus/ordered_list/index.js +2 -0
- package/dist/menus/ordered_list/index.js.map +1 -0
- package/dist/menus/ordered_list/model.js +17 -0
- package/dist/menus/ordered_list/model.js.map +1 -0
- package/dist/menus/selection/index.js +3 -0
- package/dist/menus/selection/index.js.map +1 -0
- package/dist/menus/selection/model.js +108 -0
- package/dist/menus/selection/model.js.map +1 -0
- package/dist/menus/selection/view.js +125 -0
- package/dist/menus/selection/view.js.map +1 -0
- package/dist/menus/table/index.js +2 -0
- package/dist/menus/table/index.js.map +1 -0
- package/dist/menus/table/model.js +319 -0
- package/dist/menus/table/model.js.map +1 -0
- package/dist/menus/toolbar/index.js +3 -0
- package/dist/menus/toolbar/index.js.map +1 -0
- package/dist/menus/toolbar/model.js +747 -0
- package/dist/menus/toolbar/model.js.map +1 -0
- package/dist/menus/toolbar/view.js +314 -0
- package/dist/menus/toolbar/view.js.map +1 -0
- package/dist/navigator/index.js +435 -0
- package/dist/navigator/index.js.map +1 -0
- package/dist/no_collab_save/index.js +169 -0
- package/dist/no_collab_save/index.js.map +1 -0
- package/dist/plugins/citation_dialog/index.js +2 -0
- package/dist/plugins/citation_dialog/index.js.map +1 -0
- package/dist/plugins/editor/index.js +2 -0
- package/dist/plugins/editor/index.js.map +1 -0
- package/dist/state_plugins/access_rights.js +30 -0
- package/dist/state_plugins/access_rights.js.map +1 -0
- package/dist/state_plugins/citation_render.js +78 -0
- package/dist/state_plugins/citation_render.js.map +1 -0
- package/dist/state_plugins/clipboard.js +217 -0
- package/dist/state_plugins/clipboard.js.map +1 -0
- package/dist/state_plugins/code_block.js +165 -0
- package/dist/state_plugins/code_block.js.map +1 -0
- package/dist/state_plugins/collab_carets.js +115 -0
- package/dist/state_plugins/collab_carets.js.map +1 -0
- package/dist/state_plugins/comments.js +197 -0
- package/dist/state_plugins/comments.js.map +1 -0
- package/dist/state_plugins/contributor_input/add_button.js +101 -0
- package/dist/state_plugins/contributor_input/add_button.js.map +1 -0
- package/dist/state_plugins/contributor_input/dropup.js +273 -0
- package/dist/state_plugins/contributor_input/dropup.js.map +1 -0
- package/dist/state_plugins/contributor_input/helpers.js +23 -0
- package/dist/state_plugins/contributor_input/helpers.js.map +1 -0
- package/dist/state_plugins/contributor_input/index.js +3 -0
- package/dist/state_plugins/contributor_input/index.js.map +1 -0
- package/dist/state_plugins/contributor_input/node_view.js +76 -0
- package/dist/state_plugins/contributor_input/node_view.js.map +1 -0
- package/dist/state_plugins/contributor_input/plugin.js +236 -0
- package/dist/state_plugins/contributor_input/plugin.js.map +1 -0
- package/dist/state_plugins/document_template.js +213 -0
- package/dist/state_plugins/document_template.js.map +1 -0
- package/dist/state_plugins/figure.js +90 -0
- package/dist/state_plugins/figure.js.map +1 -0
- package/dist/state_plugins/footnote_markers.js +187 -0
- package/dist/state_plugins/footnote_markers.js.map +1 -0
- package/dist/state_plugins/headerbar.js +10 -0
- package/dist/state_plugins/headerbar.js.map +1 -0
- package/dist/state_plugins/index.js +27 -0
- package/dist/state_plugins/index.js.map +1 -0
- package/dist/state_plugins/inline_math.js +719 -0
- package/dist/state_plugins/inline_math.js.map +1 -0
- package/dist/state_plugins/inline_reference/dropup.js +182 -0
- package/dist/state_plugins/inline_reference/dropup.js.map +1 -0
- package/dist/state_plugins/inline_reference/index.js +2 -0
- package/dist/state_plugins/inline_reference/index.js.map +1 -0
- package/dist/state_plugins/inline_reference/plugin.js +1134 -0
- package/dist/state_plugins/inline_reference/plugin.js.map +1 -0
- package/dist/state_plugins/jump_hidden_nodes.js +47 -0
- package/dist/state_plugins/jump_hidden_nodes.js.map +1 -0
- package/dist/state_plugins/links.js +622 -0
- package/dist/state_plugins/links.js.map +1 -0
- package/dist/state_plugins/marginboxes.js +13 -0
- package/dist/state_plugins/marginboxes.js.map +1 -0
- package/dist/state_plugins/ordered_list_menu.js +72 -0
- package/dist/state_plugins/ordered_list_menu.js.map +1 -0
- package/dist/state_plugins/placeholders.js +98 -0
- package/dist/state_plugins/placeholders.js.map +1 -0
- package/dist/state_plugins/search.js +212 -0
- package/dist/state_plugins/search.js.map +1 -0
- package/dist/state_plugins/selection_menu.js +10 -0
- package/dist/state_plugins/selection_menu.js.map +1 -0
- package/dist/state_plugins/settings.js +191 -0
- package/dist/state_plugins/settings.js.map +1 -0
- package/dist/state_plugins/table.js +104 -0
- package/dist/state_plugins/table.js.map +1 -0
- package/dist/state_plugins/tag_input/helpers.js +55 -0
- package/dist/state_plugins/tag_input/helpers.js.map +1 -0
- package/dist/state_plugins/tag_input/index.js +3 -0
- package/dist/state_plugins/tag_input/index.js.map +1 -0
- package/dist/state_plugins/tag_input/node_view.js +77 -0
- package/dist/state_plugins/tag_input/node_view.js.map +1 -0
- package/dist/state_plugins/tag_input/plugin.js +199 -0
- package/dist/state_plugins/tag_input/plugin.js.map +1 -0
- package/dist/state_plugins/tag_input/tag_editor.js +159 -0
- package/dist/state_plugins/tag_input/tag_editor.js.map +1 -0
- package/dist/state_plugins/tag_input/tag_editor_plugins.js +61 -0
- package/dist/state_plugins/tag_input/tag_editor_plugins.js.map +1 -0
- package/dist/state_plugins/toc_render.js +142 -0
- package/dist/state_plugins/toc_render.js.map +1 -0
- package/dist/state_plugins/toolbar.js +10 -0
- package/dist/state_plugins/toolbar.js.map +1 -0
- package/dist/state_plugins/track/find_selected_changes.js +82 -0
- package/dist/state_plugins/track/find_selected_changes.js.map +1 -0
- package/dist/state_plugins/track/helpers.js +67 -0
- package/dist/state_plugins/track/helpers.js.map +1 -0
- package/dist/state_plugins/track/index.js +3 -0
- package/dist/state_plugins/track/index.js.map +1 -0
- package/dist/state_plugins/track/plugin.js +114 -0
- package/dist/state_plugins/track/plugin.js.map +1 -0
- package/dist/tools/index.js +4 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/key_bindings/index.js +20 -0
- package/dist/tools/key_bindings/index.js.map +1 -0
- package/dist/tools/key_bindings/templates.js +68 -0
- package/dist/tools/key_bindings/templates.js.map +1 -0
- package/dist/tools/search_replace/index.js +275 -0
- package/dist/tools/search_replace/index.js.map +1 -0
- package/dist/tools/search_replace/templates.js +18 -0
- package/dist/tools/search_replace/templates.js.map +1 -0
- package/dist/tools/word_count/index.js +40 -0
- package/dist/tools/word_count/index.js.map +1 -0
- package/dist/tools/word_count/templates.js +27 -0
- package/dist/tools/word_count/templates.js.map +1 -0
- package/dist/track/accept.js +66 -0
- package/dist/track/accept.js.map +1 -0
- package/dist/track/accept_all.js +51 -0
- package/dist/track/accept_all.js.map +1 -0
- package/dist/track/accept_all_no_insertions.js +63 -0
- package/dist/track/accept_all_no_insertions.js.map +1 -0
- package/dist/track/amend_transaction.js +390 -0
- package/dist/track/amend_transaction.js.map +1 -0
- package/dist/track/delete.js +62 -0
- package/dist/track/delete.js.map +1 -0
- package/dist/track/index.js +6 -0
- package/dist/track/index.js.map +1 -0
- package/dist/track/mod.js +86 -0
- package/dist/track/mod.js.map +1 -0
- package/dist/track/reject.js +67 -0
- package/dist/track/reject.js.map +1 -0
- package/dist/track/reject_all.js +56 -0
- package/dist/track/reject_all.js.map +1 -0
- package/package.json +80 -0
- package/src/bibliography/tools.js +58 -0
- package/src/citations/index.js +443 -0
- package/src/citations/render.js +68 -0
- package/src/clipboard/copy/index.js +1 -0
- package/src/clipboard/copy/schema.js +62 -0
- package/src/clipboard/copy/serializers.js +179 -0
- package/src/clipboard/paste/fidus_writer.js +55 -0
- package/src/clipboard/paste/general.js +80 -0
- package/src/clipboard/paste/google_docs.js +26 -0
- package/src/clipboard/paste/html.js +76 -0
- package/src/clipboard/paste/index.js +2 -0
- package/src/clipboard/paste/libreoffice_writer.js +32 -0
- package/src/clipboard/paste/microsoft_word.js +87 -0
- package/src/clipboard/paste/text.js +58 -0
- package/src/collab/chat.js +195 -0
- package/src/collab/colors.js +67 -0
- package/src/collab/doc.js +1436 -0
- package/src/collab/index.js +81 -0
- package/src/collab/merge/changeset.js +103 -0
- package/src/collab/merge/editor.js +1065 -0
- package/src/collab/merge/footnotes.js +175 -0
- package/src/collab/merge/index.js +401 -0
- package/src/collab/merge/recreate_transform.js +326 -0
- package/src/collab/merge/schema.js +135 -0
- package/src/collab/merge/state_plugins/action.js +171 -0
- package/src/collab/merge/state_plugins/clipboard.js +32 -0
- package/src/collab/merge/state_plugins/diff.js +780 -0
- package/src/collab/merge/state_plugins/index.js +2 -0
- package/src/collab/merge/tools.js +217 -0
- package/src/collab/templates.js +10 -0
- package/src/comments/comment.js +29 -0
- package/src/comments/editors/answer.js +55 -0
- package/src/comments/editors/comment.js +318 -0
- package/src/comments/editors/index.js +4 -0
- package/src/comments/editors/notify.js +13 -0
- package/src/comments/editors/schema.js +65 -0
- package/src/comments/index.js +11 -0
- package/src/comments/interactions.js +465 -0
- package/src/comments/store.js +513 -0
- package/src/contacts/add_dialog.js +110 -0
- package/src/contacts/templates.js +28 -0
- package/src/copyright_dialog/index.js +179 -0
- package/src/copyright_dialog/templates.js +56 -0
- package/src/databases/bibliography.js +179 -0
- package/src/databases/images.js +320 -0
- package/src/databases/index.js +69 -0
- package/src/dialogs/citation.js +428 -0
- package/src/dialogs/code_block.js +242 -0
- package/src/dialogs/contributor.js +173 -0
- package/src/dialogs/figure.js +479 -0
- package/src/dialogs/index.js +10 -0
- package/src/dialogs/language.js +58 -0
- package/src/dialogs/link.js +358 -0
- package/src/dialogs/math.js +148 -0
- package/src/dialogs/ordered_list.js +84 -0
- package/src/dialogs/revision.js +43 -0
- package/src/dialogs/subsup.js +116 -0
- package/src/dialogs/table.js +258 -0
- package/src/dialogs/templates.js +426 -0
- package/src/document_template/exporter.js +97 -0
- package/src/document_template/index.js +483 -0
- package/src/documents/access_rights/index.js +693 -0
- package/src/documents/access_rights/templates.js +178 -0
- package/src/e2ee/encryptor.js +228 -0
- package/src/e2ee/key-manager.js +202 -0
- package/src/e2ee/passphrase-crypto.js +606 -0
- package/src/e2ee/passphrase-dialog.js +655 -0
- package/src/e2ee/passphrase-manager.js +502 -0
- package/src/e2ee/password-dialog.js +652 -0
- package/src/e2ee/snapshot-manager.js +305 -0
- package/src/exporter/native/copy.js +54 -0
- package/src/exporter/native/file.js +37 -0
- package/src/exporter/native/index.js +3 -0
- package/src/exporter/native/revision.js +86 -0
- package/src/exporter/native/zip.js +1 -0
- package/src/footnotes/editor.js +227 -0
- package/src/footnotes/index.js +16 -0
- package/src/footnotes/layout.js +190 -0
- package/src/footnotes/state_plugins/access_rights.js +39 -0
- package/src/footnotes/state_plugins/index.js +1 -0
- package/src/images/edit_dialog/edit_dialog/index.js +222 -0
- package/src/images/edit_dialog/edit_dialog/model.js +183 -0
- package/src/images/edit_dialog/edit_dialog/templates.js +41 -0
- package/src/images/edit_dialog/model.js +5 -0
- package/src/images/selection_dialog/index.js +176 -0
- package/src/index.js +1252 -0
- package/src/keymap.js +102 -0
- package/src/marginboxes/index.js +946 -0
- package/src/marginboxes/templates.js +573 -0
- package/src/menus/code_block/index.js +1 -0
- package/src/menus/code_block/model.js +52 -0
- package/src/menus/figure/index.js +2 -0
- package/src/menus/figure/model.js +91 -0
- package/src/menus/figure/utils.js +5 -0
- package/src/menus/headerbar/index.js +2 -0
- package/src/menus/headerbar/model.js +1077 -0
- package/src/menus/headerbar/view.js +675 -0
- package/src/menus/image/index.js +1 -0
- package/src/menus/image/model.js +32 -0
- package/src/menus/index.js +9 -0
- package/src/menus/navigator/index.js +1 -0
- package/src/menus/navigator/model.js +28 -0
- package/src/menus/ordered_list/index.js +1 -0
- package/src/menus/ordered_list/model.js +19 -0
- package/src/menus/selection/index.js +2 -0
- package/src/menus/selection/model.js +134 -0
- package/src/menus/selection/view.js +154 -0
- package/src/menus/table/index.js +1 -0
- package/src/menus/table/model.js +414 -0
- package/src/menus/toolbar/index.js +2 -0
- package/src/menus/toolbar/model.js +920 -0
- package/src/menus/toolbar/view.js +354 -0
- package/src/navigator/index.js +515 -0
- package/src/no_collab_save/index.js +209 -0
- package/src/plugins/citation_dialog/index.js +1 -0
- package/src/plugins/editor/index.js +1 -0
- package/src/state_plugins/access_rights.js +47 -0
- package/src/state_plugins/citation_render.js +88 -0
- package/src/state_plugins/clipboard.js +289 -0
- package/src/state_plugins/code_block.js +201 -0
- package/src/state_plugins/collab_carets.js +152 -0
- package/src/state_plugins/comments.js +259 -0
- package/src/state_plugins/contributor_input/add_button.js +134 -0
- package/src/state_plugins/contributor_input/dropup.js +318 -0
- package/src/state_plugins/contributor_input/helpers.js +24 -0
- package/src/state_plugins/contributor_input/index.js +2 -0
- package/src/state_plugins/contributor_input/node_view.js +86 -0
- package/src/state_plugins/contributor_input/plugin.js +318 -0
- package/src/state_plugins/document_template.js +315 -0
- package/src/state_plugins/figure.js +108 -0
- package/src/state_plugins/footnote_markers.js +238 -0
- package/src/state_plugins/headerbar.js +12 -0
- package/src/state_plugins/index.js +73 -0
- package/src/state_plugins/inline_math.js +918 -0
- package/src/state_plugins/inline_reference/dropup.js +208 -0
- package/src/state_plugins/inline_reference/index.js +5 -0
- package/src/state_plugins/inline_reference/plugin.js +1429 -0
- package/src/state_plugins/jump_hidden_nodes.js +58 -0
- package/src/state_plugins/links.js +830 -0
- package/src/state_plugins/marginboxes.js +14 -0
- package/src/state_plugins/ordered_list_menu.js +84 -0
- package/src/state_plugins/placeholders.js +123 -0
- package/src/state_plugins/search.js +251 -0
- package/src/state_plugins/selection_menu.js +12 -0
- package/src/state_plugins/settings.js +223 -0
- package/src/state_plugins/table.js +127 -0
- package/src/state_plugins/tag_input/helpers.js +69 -0
- package/src/state_plugins/tag_input/index.js +2 -0
- package/src/state_plugins/tag_input/node_view.js +85 -0
- package/src/state_plugins/tag_input/plugin.js +278 -0
- package/src/state_plugins/tag_input/tag_editor.js +202 -0
- package/src/state_plugins/tag_input/tag_editor_plugins.js +74 -0
- package/src/state_plugins/toc_render.js +160 -0
- package/src/state_plugins/toolbar.js +12 -0
- package/src/state_plugins/track/find_selected_changes.js +107 -0
- package/src/state_plugins/track/helpers.js +108 -0
- package/src/state_plugins/track/index.js +6 -0
- package/src/state_plugins/track/plugin.js +140 -0
- package/src/tools/index.js +3 -0
- package/src/tools/key_bindings/index.js +21 -0
- package/src/tools/key_bindings/templates.js +68 -0
- package/src/tools/search_replace/index.js +421 -0
- package/src/tools/search_replace/templates.js +19 -0
- package/src/tools/word_count/index.js +59 -0
- package/src/tools/word_count/templates.js +34 -0
- package/src/track/accept.js +102 -0
- package/src/track/accept_all.js +103 -0
- package/src/track/accept_all_no_insertions.js +102 -0
- package/src/track/amend_transaction.js +562 -0
- package/src/track/delete.js +92 -0
- package/src/track/index.js +8 -0
- package/src/track/mod.js +116 -0
- package/src/track/reject.js +116 -0
- package/src/track/reject_all.js +121 -0
|
@@ -0,0 +1,719 @@
|
|
|
1
|
+
import { NodeSelection, Plugin, PluginKey, TextSelection } from "prosemirror-state";
|
|
2
|
+
import { Decoration, DecorationSet } from "prosemirror-view";
|
|
3
|
+
import { COMMENT_ONLY_ROLES, READ_ONLY_ROLES } from "..";
|
|
4
|
+
import { MathDialog } from "../dialogs";
|
|
5
|
+
import { elementDisabled } from "../menus/toolbar/model";
|
|
6
|
+
const key = new PluginKey("inlineMath");
|
|
7
|
+
/**
|
|
8
|
+
* Check if an inline equation can be activated at the current position.
|
|
9
|
+
* Mirrors the toolbar equation-button disabled check.
|
|
10
|
+
*/
|
|
11
|
+
function canActivateInlineMath(_state, _$pos, editor) {
|
|
12
|
+
if (editor && elementDisabled(editor, "equation")) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
/* ────────────────────────────────────────────────────────── */
|
|
18
|
+
/* Helpers shared by the inline-editor widget */
|
|
19
|
+
/* ────────────────────────────────────────────────────────── */
|
|
20
|
+
function getInputCursorPos(input) {
|
|
21
|
+
const sel = window.getSelection();
|
|
22
|
+
if (!sel || sel.rangeCount === 0) {
|
|
23
|
+
return (input.textContent || "").length;
|
|
24
|
+
}
|
|
25
|
+
return sel.getRangeAt(0).startOffset;
|
|
26
|
+
}
|
|
27
|
+
function setInputCursorPos(input, pos) {
|
|
28
|
+
const textNode = input.firstChild;
|
|
29
|
+
if (!textNode) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const range = document.createRange();
|
|
33
|
+
const safePos = Math.min(pos, (textNode.textContent || "").length);
|
|
34
|
+
range.setStart(textNode, safePos);
|
|
35
|
+
range.collapse(true);
|
|
36
|
+
const sel = window.getSelection();
|
|
37
|
+
if (sel) {
|
|
38
|
+
sel.removeAllRanges();
|
|
39
|
+
sel.addRange(range);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Build the contenteditable widget that lets the user type raw LaTeX.
|
|
44
|
+
* The query includes the leading "$", which is shown in the widget so the
|
|
45
|
+
* user always sees "$…latex…".
|
|
46
|
+
*/
|
|
47
|
+
function createInlineMathWidget(editor, pluginState, pluginKey) {
|
|
48
|
+
const view = editor.currentView || editor.view;
|
|
49
|
+
const container = document.createElement("span");
|
|
50
|
+
container.className = "inline-math-widget";
|
|
51
|
+
const input = document.createElement("span");
|
|
52
|
+
input.contentEditable = "plaintext-only";
|
|
53
|
+
input.spellcheck = false;
|
|
54
|
+
input.className = "inline-math-input";
|
|
55
|
+
input.textContent = pluginState.query;
|
|
56
|
+
input.addEventListener("input", event => {
|
|
57
|
+
event.stopPropagation();
|
|
58
|
+
const text = input.textContent || "";
|
|
59
|
+
if (!text) {
|
|
60
|
+
// Everything including `$` was deleted — remove the node.
|
|
61
|
+
view.dispatch(view.state.tr.setMeta(pluginKey, { action: "cancelDelete" }));
|
|
62
|
+
view.focus();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (!text.startsWith("$")) {
|
|
66
|
+
// `$` was removed but content remains — restore it.
|
|
67
|
+
const cursorPos = getInputCursorPos(input);
|
|
68
|
+
input.textContent = "$" + text;
|
|
69
|
+
setInputCursorPos(input, cursorPos + 1);
|
|
70
|
+
}
|
|
71
|
+
view.dispatch(view.state.tr.setMeta(pluginKey, {
|
|
72
|
+
action: "updateQuery",
|
|
73
|
+
query: input.textContent
|
|
74
|
+
}));
|
|
75
|
+
});
|
|
76
|
+
input.addEventListener("keypress", event => {
|
|
77
|
+
// Stop keypress from reaching ProseMirror
|
|
78
|
+
event.stopPropagation();
|
|
79
|
+
});
|
|
80
|
+
input.addEventListener("keydown", event => {
|
|
81
|
+
event.stopPropagation();
|
|
82
|
+
const currentState = pluginKey.getState(view.state);
|
|
83
|
+
if (!currentState?.active) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
switch (event.key) {
|
|
87
|
+
case "ArrowLeft":
|
|
88
|
+
if (getInputCursorPos(input) === 0) {
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
view.dispatch(view.state.tr.setMeta(pluginKey, { action: "cancelLeft" }));
|
|
91
|
+
view.focus();
|
|
92
|
+
}
|
|
93
|
+
break;
|
|
94
|
+
case "ArrowRight":
|
|
95
|
+
if (getInputCursorPos(input) ===
|
|
96
|
+
(input.textContent || "").length) {
|
|
97
|
+
event.preventDefault();
|
|
98
|
+
view.dispatch(view.state.tr.setMeta(pluginKey, {
|
|
99
|
+
action: "commitAndRight"
|
|
100
|
+
}));
|
|
101
|
+
view.focus();
|
|
102
|
+
}
|
|
103
|
+
break;
|
|
104
|
+
case "Enter":
|
|
105
|
+
case "Tab":
|
|
106
|
+
event.preventDefault();
|
|
107
|
+
view.dispatch(view.state.tr.setMeta(pluginKey, { action: "commit" }));
|
|
108
|
+
view.focus();
|
|
109
|
+
break;
|
|
110
|
+
case "Escape":
|
|
111
|
+
event.preventDefault();
|
|
112
|
+
view.dispatch(view.state.tr.setMeta(pluginKey, { action: "cancel" }));
|
|
113
|
+
view.focus();
|
|
114
|
+
break;
|
|
115
|
+
case "Backspace":
|
|
116
|
+
// When only `$` remains, delete the whole node.
|
|
117
|
+
if ((input.textContent || "").length <= 1) {
|
|
118
|
+
event.preventDefault();
|
|
119
|
+
view.dispatch(view.state.tr.setMeta(pluginKey, {
|
|
120
|
+
action: "cancelDelete"
|
|
121
|
+
}));
|
|
122
|
+
view.focus();
|
|
123
|
+
}
|
|
124
|
+
break;
|
|
125
|
+
case "Delete":
|
|
126
|
+
// Same as Backspace when only `$` is left.
|
|
127
|
+
if ((input.textContent || "").length <= 1) {
|
|
128
|
+
event.preventDefault();
|
|
129
|
+
view.dispatch(view.state.tr.setMeta(pluginKey, {
|
|
130
|
+
action: "cancelDelete"
|
|
131
|
+
}));
|
|
132
|
+
view.focus();
|
|
133
|
+
}
|
|
134
|
+
break;
|
|
135
|
+
default:
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
input.addEventListener("focusout", event => {
|
|
140
|
+
const related = event.relatedTarget;
|
|
141
|
+
if (container.contains(related)) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const myWidgetId = pluginState.widgetId;
|
|
145
|
+
// Use a tiny timeout so that a click on the container itself
|
|
146
|
+
// (e.g. scrollbar) does not accidentally commit.
|
|
147
|
+
setTimeout(() => {
|
|
148
|
+
const currentState = pluginKey.getState(view.state);
|
|
149
|
+
if (currentState?.active && currentState.widgetId === myWidgetId) {
|
|
150
|
+
view.dispatch(view.state.tr.setMeta(pluginKey, { action: "commit" }));
|
|
151
|
+
}
|
|
152
|
+
}, 1);
|
|
153
|
+
});
|
|
154
|
+
container.addEventListener("mousedown", event => {
|
|
155
|
+
event.stopPropagation();
|
|
156
|
+
});
|
|
157
|
+
container.appendChild(input);
|
|
158
|
+
// Focus the input and position the cursor after mounting.
|
|
159
|
+
setTimeout(() => {
|
|
160
|
+
input.focus();
|
|
161
|
+
if (pluginState.cursorAtStart === true) {
|
|
162
|
+
setInputCursorPos(input, 0);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
setInputCursorPos(input, (input.textContent || "").length);
|
|
166
|
+
}
|
|
167
|
+
}, 0);
|
|
168
|
+
return container;
|
|
169
|
+
}
|
|
170
|
+
/* ────────────────────────────────────────────────────────── */
|
|
171
|
+
/* Dropup plugin (inline_math preference OFF) */
|
|
172
|
+
/* ────────────────────────────────────────────────────────── */
|
|
173
|
+
function dropupPlugin(options) {
|
|
174
|
+
const editor = options.editor;
|
|
175
|
+
let currentDropUpActions = [];
|
|
176
|
+
const editAccess = ["write", "write-tracked", "review-tracked"].includes(editor.docInfo.access_rights);
|
|
177
|
+
function getEquationNode(state) {
|
|
178
|
+
return state.selection instanceof NodeSelection &&
|
|
179
|
+
state.selection.node.type.name === "equation"
|
|
180
|
+
? state.selection.node
|
|
181
|
+
: undefined;
|
|
182
|
+
}
|
|
183
|
+
function createEquationDropUp(equationNode, selectedIndex = -1) {
|
|
184
|
+
const dropUp = document.createElement("span");
|
|
185
|
+
dropUp.classList.add("drop-up-outer");
|
|
186
|
+
const _latex = equationNode.attrs.equation || "";
|
|
187
|
+
const requiredPx = editAccess ? 92 : 50;
|
|
188
|
+
dropUp.innerHTML = `
|
|
189
|
+
<div class="drop-up-inner" style="top: -${requiredPx}px;">
|
|
190
|
+
<div class="drop-up-head"${editAccess ? "" : ' style="border-radius:6px;"'}>
|
|
191
|
+
<div class="link-title">${gettext("Equation")}</div>
|
|
192
|
+
</div>
|
|
193
|
+
${editAccess
|
|
194
|
+
? `<ul class="drop-up-options">
|
|
195
|
+
<li class="edit-equation" title="${gettext("Edit equation")}">
|
|
196
|
+
${gettext("Edit")}
|
|
197
|
+
</li>
|
|
198
|
+
<li class="remove-equation" title="${gettext("Remove equation")}">
|
|
199
|
+
${gettext("Remove")}
|
|
200
|
+
</li>
|
|
201
|
+
</ul>`
|
|
202
|
+
: ""}
|
|
203
|
+
</div>`;
|
|
204
|
+
currentDropUpActions = [];
|
|
205
|
+
const setupAction = (selector, action) => {
|
|
206
|
+
const el = dropUp.querySelector(selector);
|
|
207
|
+
if (!el) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
currentDropUpActions.push(action);
|
|
211
|
+
el.addEventListener("mousedown", event => {
|
|
212
|
+
event.preventDefault();
|
|
213
|
+
event.stopImmediatePropagation();
|
|
214
|
+
action();
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
setupAction(".edit-equation", () => {
|
|
218
|
+
// MathDialog reads the NodeSelection from the view, so we rely on
|
|
219
|
+
// the equation node already being NodeSelected when the button is
|
|
220
|
+
// activated.
|
|
221
|
+
const dialog = new MathDialog(editor);
|
|
222
|
+
dialog.init();
|
|
223
|
+
});
|
|
224
|
+
setupAction(".remove-equation", () => {
|
|
225
|
+
const view = editor.currentView;
|
|
226
|
+
const state = view.state;
|
|
227
|
+
if (state.selection instanceof NodeSelection) {
|
|
228
|
+
view.dispatch(state.tr.deleteSelection());
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
if (selectedIndex >= 0 && selectedIndex < currentDropUpActions.length) {
|
|
232
|
+
const items = Array.from(dropUp.querySelectorAll(".drop-up-options li"));
|
|
233
|
+
if (items[selectedIndex]) {
|
|
234
|
+
items[selectedIndex].classList.add("fw-focused");
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return dropUp;
|
|
238
|
+
}
|
|
239
|
+
function getDecos(state, selectedIndex = -1) {
|
|
240
|
+
const equationNode = getEquationNode(state);
|
|
241
|
+
if (!equationNode) {
|
|
242
|
+
return DecorationSet.empty;
|
|
243
|
+
}
|
|
244
|
+
// Place the dropup widget just after the equation node.
|
|
245
|
+
const startPos = state.selection.from + equationNode.nodeSize;
|
|
246
|
+
const dom = createEquationDropUp(equationNode, selectedIndex);
|
|
247
|
+
return DecorationSet.create(state.doc, [
|
|
248
|
+
Decoration.widget(startPos, dom)
|
|
249
|
+
]);
|
|
250
|
+
}
|
|
251
|
+
return new Plugin({
|
|
252
|
+
key,
|
|
253
|
+
state: {
|
|
254
|
+
init() {
|
|
255
|
+
return {
|
|
256
|
+
equationNode: undefined,
|
|
257
|
+
decos: DecorationSet.empty,
|
|
258
|
+
selectedIndex: -1
|
|
259
|
+
};
|
|
260
|
+
},
|
|
261
|
+
apply(tr, prev, _oldState, state) {
|
|
262
|
+
const newEquationNode = getEquationNode(state);
|
|
263
|
+
const meta = tr.getMeta(key);
|
|
264
|
+
let { selectedIndex } = prev;
|
|
265
|
+
if (meta?.action === "navigate") {
|
|
266
|
+
selectedIndex = meta.index;
|
|
267
|
+
return {
|
|
268
|
+
equationNode: newEquationNode,
|
|
269
|
+
decos: getDecos(state, selectedIndex),
|
|
270
|
+
selectedIndex
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
if (newEquationNode === prev.equationNode) {
|
|
274
|
+
return {
|
|
275
|
+
equationNode: newEquationNode,
|
|
276
|
+
decos: prev.decos.map(tr.mapping, tr.doc),
|
|
277
|
+
selectedIndex
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
// Equation node changed (or deselected): reset selection index.
|
|
281
|
+
selectedIndex = -1;
|
|
282
|
+
return {
|
|
283
|
+
equationNode: newEquationNode,
|
|
284
|
+
decos: getDecos(state, selectedIndex),
|
|
285
|
+
selectedIndex
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
props: {
|
|
290
|
+
handleKeyDown(view, event) {
|
|
291
|
+
const pluginState = key.getState(view.state);
|
|
292
|
+
if (!pluginState?.equationNode) {
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
const totalItems = currentDropUpActions.length;
|
|
296
|
+
if (totalItems === 0) {
|
|
297
|
+
return false;
|
|
298
|
+
}
|
|
299
|
+
const { selectedIndex } = pluginState;
|
|
300
|
+
if (event.key === "ArrowDown") {
|
|
301
|
+
event.preventDefault();
|
|
302
|
+
const newIndex = selectedIndex < totalItems - 1 ? selectedIndex + 1 : 0;
|
|
303
|
+
view.dispatch(view.state.tr.setMeta(key, {
|
|
304
|
+
action: "navigate",
|
|
305
|
+
index: newIndex
|
|
306
|
+
}));
|
|
307
|
+
return true;
|
|
308
|
+
}
|
|
309
|
+
if (event.key === "ArrowUp") {
|
|
310
|
+
event.preventDefault();
|
|
311
|
+
const newIndex = selectedIndex <= 0 ? totalItems - 1 : selectedIndex - 1;
|
|
312
|
+
view.dispatch(view.state.tr.setMeta(key, {
|
|
313
|
+
action: "navigate",
|
|
314
|
+
index: newIndex
|
|
315
|
+
}));
|
|
316
|
+
return true;
|
|
317
|
+
}
|
|
318
|
+
if (event.key === "Enter" &&
|
|
319
|
+
selectedIndex >= 0 &&
|
|
320
|
+
selectedIndex < totalItems) {
|
|
321
|
+
event.preventDefault();
|
|
322
|
+
currentDropUpActions[selectedIndex]();
|
|
323
|
+
return true;
|
|
324
|
+
}
|
|
325
|
+
return false;
|
|
326
|
+
},
|
|
327
|
+
decorations(state) {
|
|
328
|
+
const pluginState = key.getState(state);
|
|
329
|
+
return pluginState?.decos || DecorationSet.empty;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
/* ────────────────────────────────────────────────────────── */
|
|
335
|
+
/* Inline editor plugin (inline_math preference ON) */
|
|
336
|
+
/* ────────────────────────────────────────────────────────── */
|
|
337
|
+
function inlineEditorPlugin(options) {
|
|
338
|
+
const editor = options.editor;
|
|
339
|
+
return new Plugin({
|
|
340
|
+
key,
|
|
341
|
+
state: {
|
|
342
|
+
init() {
|
|
343
|
+
return {
|
|
344
|
+
active: false,
|
|
345
|
+
from: 0,
|
|
346
|
+
query: "",
|
|
347
|
+
isEdit: false,
|
|
348
|
+
mathNodePos: 0,
|
|
349
|
+
widgetId: undefined,
|
|
350
|
+
cursorAtStart: undefined,
|
|
351
|
+
decos: DecorationSet.empty
|
|
352
|
+
};
|
|
353
|
+
},
|
|
354
|
+
apply(tr, prev, _oldState, _newState) {
|
|
355
|
+
let next = { ...prev };
|
|
356
|
+
const meta = tr.getMeta(key);
|
|
357
|
+
if (meta?.action === "activate") {
|
|
358
|
+
next = {
|
|
359
|
+
active: true,
|
|
360
|
+
from: meta.from,
|
|
361
|
+
query: meta.query || "$",
|
|
362
|
+
isEdit: meta.isEdit || false,
|
|
363
|
+
mathNodePos: meta.mathNodePos || 0,
|
|
364
|
+
widgetId: Math.random().toString(36).slice(2),
|
|
365
|
+
cursorAtStart: meta.cursorAtStart,
|
|
366
|
+
decos: DecorationSet.empty
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
else if (meta?.action === "deactivate") {
|
|
370
|
+
next = {
|
|
371
|
+
active: false,
|
|
372
|
+
from: 0,
|
|
373
|
+
query: "",
|
|
374
|
+
isEdit: false,
|
|
375
|
+
mathNodePos: 0,
|
|
376
|
+
widgetId: undefined,
|
|
377
|
+
cursorAtStart: undefined,
|
|
378
|
+
decos: DecorationSet.empty
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
else if (meta?.action === "updateQuery") {
|
|
382
|
+
next.query = meta.query;
|
|
383
|
+
}
|
|
384
|
+
if (next.active) {
|
|
385
|
+
if (!prev.active || prev.from !== next.from) {
|
|
386
|
+
// Position changed or freshly activated: build decorations.
|
|
387
|
+
const decoList = [
|
|
388
|
+
Decoration.widget(next.from, () => createInlineMathWidget(editor, next, key), { key: "inline-math-widget", side: -1 })
|
|
389
|
+
];
|
|
390
|
+
if (next.isEdit) {
|
|
391
|
+
// Hide the equation node while the inline editor is open.
|
|
392
|
+
decoList.push(Decoration.node(next.mathNodePos, next.mathNodePos + 1, { class: "hide" }));
|
|
393
|
+
}
|
|
394
|
+
next.decos = DecorationSet.create(_newState.doc, decoList);
|
|
395
|
+
}
|
|
396
|
+
else if (tr.docChanged) {
|
|
397
|
+
next.decos = prev.decos.map(tr.mapping, _newState.doc);
|
|
398
|
+
}
|
|
399
|
+
else {
|
|
400
|
+
next.decos = prev.decos;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
else {
|
|
404
|
+
next.decos = DecorationSet.empty;
|
|
405
|
+
}
|
|
406
|
+
return next;
|
|
407
|
+
}
|
|
408
|
+
},
|
|
409
|
+
appendTransaction: (trs, oldState, newState) => {
|
|
410
|
+
const oldPluginState = key.getState(oldState);
|
|
411
|
+
const meta = trs.find(tr => tr.getMeta(key))?.getMeta(key);
|
|
412
|
+
/* ── commit / commitAndRight ── */
|
|
413
|
+
if (meta?.action === "commit" ||
|
|
414
|
+
meta?.action === "commitAndRight") {
|
|
415
|
+
if (!oldPluginState.active) {
|
|
416
|
+
return null;
|
|
417
|
+
}
|
|
418
|
+
const query = oldPluginState.query;
|
|
419
|
+
const latex = query.startsWith("$") ? query.slice(1) : query;
|
|
420
|
+
if (!latex.trim()) {
|
|
421
|
+
// Empty LaTeX: delete the node (edit) or just cancel (new).
|
|
422
|
+
if (oldPluginState.isEdit) {
|
|
423
|
+
const existingNode = newState.doc.nodeAt(oldPluginState.mathNodePos);
|
|
424
|
+
const tr = newState.tr.delete(oldPluginState.mathNodePos, oldPluginState.mathNodePos +
|
|
425
|
+
(existingNode?.nodeSize || 1));
|
|
426
|
+
tr.setSelection(TextSelection.create(tr.doc, oldPluginState.mathNodePos));
|
|
427
|
+
return tr.setMeta(key, { action: "deactivate" });
|
|
428
|
+
}
|
|
429
|
+
else {
|
|
430
|
+
// Insert the literal "$" and move cursor past it.
|
|
431
|
+
const tr = newState.tr.insertText("$", oldPluginState.from);
|
|
432
|
+
tr.setSelection(TextSelection.create(tr.doc, oldPluginState.from + 1));
|
|
433
|
+
return tr.setMeta(key, { action: "deactivate" });
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
const equationNode = newState.schema.nodes.equation.create({
|
|
437
|
+
equation: latex
|
|
438
|
+
});
|
|
439
|
+
if (oldPluginState.isEdit) {
|
|
440
|
+
const existingNode = newState.doc.nodeAt(oldPluginState.mathNodePos);
|
|
441
|
+
const tr = newState.tr.replaceWith(oldPluginState.mathNodePos, oldPluginState.mathNodePos +
|
|
442
|
+
(existingNode?.nodeSize || 1), equationNode);
|
|
443
|
+
tr.setSelection(TextSelection.create(tr.doc, oldPluginState.mathNodePos + equationNode.nodeSize));
|
|
444
|
+
return tr.setMeta(key, { action: "deactivate" });
|
|
445
|
+
}
|
|
446
|
+
else {
|
|
447
|
+
const tr = newState.tr.insert(oldPluginState.from, equationNode);
|
|
448
|
+
tr.setSelection(TextSelection.create(tr.doc, oldPluginState.from + equationNode.nodeSize));
|
|
449
|
+
return tr.setMeta(key, { action: "deactivate" });
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
/* ── cancel ── */
|
|
453
|
+
if (meta?.action === "cancel") {
|
|
454
|
+
if (oldPluginState.isEdit) {
|
|
455
|
+
// Leave the equation node unchanged; move cursor after it.
|
|
456
|
+
const node = newState.doc.nodeAt(oldPluginState.mathNodePos);
|
|
457
|
+
const tr = newState.tr.setSelection(TextSelection.create(newState.doc, oldPluginState.mathNodePos + (node?.nodeSize || 1)));
|
|
458
|
+
return tr.setMeta(key, { action: "deactivate" });
|
|
459
|
+
}
|
|
460
|
+
else {
|
|
461
|
+
// Restore the literal "$" at the original position.
|
|
462
|
+
const tr = newState.tr.insertText("$", oldPluginState.from);
|
|
463
|
+
tr.setSelection(TextSelection.create(tr.doc, oldPluginState.from + 1));
|
|
464
|
+
return tr.setMeta(key, { action: "deactivate" });
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
/* ── cancelDelete ── */
|
|
468
|
+
if (meta?.action === "cancelDelete") {
|
|
469
|
+
if (oldPluginState.isEdit) {
|
|
470
|
+
// Delete the equation node entirely.
|
|
471
|
+
const existingNode = newState.doc.nodeAt(oldPluginState.mathNodePos);
|
|
472
|
+
const tr = newState.tr.delete(oldPluginState.mathNodePos, oldPluginState.mathNodePos +
|
|
473
|
+
(existingNode?.nodeSize || 1));
|
|
474
|
+
tr.setSelection(TextSelection.create(tr.doc, oldPluginState.mathNodePos));
|
|
475
|
+
return tr.setMeta(key, { action: "deactivate" });
|
|
476
|
+
}
|
|
477
|
+
else {
|
|
478
|
+
// New node: just deactivate — don't insert anything.
|
|
479
|
+
return newState.tr.setMeta(key, { action: "deactivate" });
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
/* ── cancelLeft ── */
|
|
483
|
+
if (meta?.action === "cancelLeft") {
|
|
484
|
+
if (oldPluginState.isEdit) {
|
|
485
|
+
const tr = newState.tr.setSelection(TextSelection.create(newState.doc, oldPluginState.mathNodePos));
|
|
486
|
+
return tr.setMeta(key, { action: "deactivate" });
|
|
487
|
+
}
|
|
488
|
+
else {
|
|
489
|
+
const tr = newState.tr.insertText("$", oldPluginState.from);
|
|
490
|
+
tr.setSelection(TextSelection.create(tr.doc, oldPluginState.from));
|
|
491
|
+
return tr.setMeta(key, { action: "deactivate" });
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
/* ── implicit commit when selection moves away ── */
|
|
495
|
+
if (oldPluginState.active) {
|
|
496
|
+
if (trs.some(tr => tr.selectionSet) &&
|
|
497
|
+
(newState.selection.from !== oldPluginState.from ||
|
|
498
|
+
newState.selection.to !== oldPluginState.from)) {
|
|
499
|
+
const query = oldPluginState.query;
|
|
500
|
+
const latex = query.startsWith("$") ? query.slice(1) : query;
|
|
501
|
+
if (latex.trim()) {
|
|
502
|
+
const equationNode = newState.schema.nodes.equation.create({
|
|
503
|
+
equation: latex
|
|
504
|
+
});
|
|
505
|
+
if (oldPluginState.isEdit) {
|
|
506
|
+
const existingNode = newState.doc.nodeAt(oldPluginState.mathNodePos);
|
|
507
|
+
return newState.tr
|
|
508
|
+
.replaceWith(oldPluginState.mathNodePos, oldPluginState.mathNodePos +
|
|
509
|
+
(existingNode?.nodeSize || 1), equationNode)
|
|
510
|
+
.setMeta(key, { action: "deactivate" });
|
|
511
|
+
}
|
|
512
|
+
else {
|
|
513
|
+
return newState.tr
|
|
514
|
+
.insert(oldPluginState.from, equationNode)
|
|
515
|
+
.setMeta(key, { action: "deactivate" });
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
else {
|
|
519
|
+
return newState.tr.setMeta(key, { action: "deactivate" });
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
else {
|
|
524
|
+
/* ── equation NodeSelection → open inline editor ── */
|
|
525
|
+
const selection = newState.selection;
|
|
526
|
+
if (selection instanceof NodeSelection &&
|
|
527
|
+
selection.node.type.name === "equation") {
|
|
528
|
+
const eqNode = selection.node;
|
|
529
|
+
const from = selection.from;
|
|
530
|
+
return newState.tr.setMeta(key, {
|
|
531
|
+
action: "activate",
|
|
532
|
+
from,
|
|
533
|
+
query: `$${eqNode.attrs.equation}`,
|
|
534
|
+
isEdit: true,
|
|
535
|
+
mathNodePos: from
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
/* ── "$" typed via paste/mobile (doc changed) ── */
|
|
539
|
+
const changedTr = trs.find(tr => tr.docChanged);
|
|
540
|
+
if (changedTr) {
|
|
541
|
+
const $pos = newState.selection.$head;
|
|
542
|
+
if (canActivateInlineMath(newState, $pos, editor)) {
|
|
543
|
+
const beforeText = newState.doc.textBetween(Math.max(0, $pos.pos - 3), $pos.pos, "");
|
|
544
|
+
if (beforeText.endsWith("$")) {
|
|
545
|
+
return newState.tr
|
|
546
|
+
.delete($pos.pos - 1, $pos.pos)
|
|
547
|
+
.setMeta(key, {
|
|
548
|
+
action: "activate",
|
|
549
|
+
from: $pos.pos - 1,
|
|
550
|
+
query: "$",
|
|
551
|
+
isEdit: false,
|
|
552
|
+
mathNodePos: 0
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
return null;
|
|
559
|
+
},
|
|
560
|
+
props: {
|
|
561
|
+
decorations(state) {
|
|
562
|
+
const pluginState = key.getState(state);
|
|
563
|
+
return pluginState?.decos || DecorationSet.empty;
|
|
564
|
+
},
|
|
565
|
+
handleClickOn(_view, _pos, node, nodePos, _event, _direct) {
|
|
566
|
+
if (node.type.name === "equation") {
|
|
567
|
+
const tr = _view.state.tr.setSelection(TextSelection.create(_view.state.doc, nodePos + node.nodeSize));
|
|
568
|
+
tr.setMeta(key, {
|
|
569
|
+
action: "activate",
|
|
570
|
+
from: nodePos,
|
|
571
|
+
query: `$${node.attrs.equation}`,
|
|
572
|
+
isEdit: true,
|
|
573
|
+
mathNodePos: nodePos
|
|
574
|
+
});
|
|
575
|
+
_view.dispatch(tr);
|
|
576
|
+
return true;
|
|
577
|
+
}
|
|
578
|
+
return false;
|
|
579
|
+
},
|
|
580
|
+
handleDOMEvents: {
|
|
581
|
+
mousedown(view, event) {
|
|
582
|
+
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
583
|
+
return false;
|
|
584
|
+
}
|
|
585
|
+
if (event.button !== 0) {
|
|
586
|
+
return false;
|
|
587
|
+
}
|
|
588
|
+
const target = event.target.closest(".equation");
|
|
589
|
+
if (!target) {
|
|
590
|
+
return false;
|
|
591
|
+
}
|
|
592
|
+
let pos = view.posAtDOM(target, 0);
|
|
593
|
+
let node = view.state.doc.nodeAt(pos);
|
|
594
|
+
if (!node || node.type.name !== "equation") {
|
|
595
|
+
return false;
|
|
596
|
+
}
|
|
597
|
+
const pluginState = key.getState(view.state);
|
|
598
|
+
if (pluginState?.active) {
|
|
599
|
+
// Commit the current widget before opening a new one.
|
|
600
|
+
const commitTr = view.state.tr.setMeta(key, {
|
|
601
|
+
action: "commit"
|
|
602
|
+
});
|
|
603
|
+
view.dispatch(commitTr);
|
|
604
|
+
pos = commitTr.mapping.map(pos);
|
|
605
|
+
node = view.state.doc.nodeAt(pos);
|
|
606
|
+
if (!node || node.type.name !== "equation") {
|
|
607
|
+
return false;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
const tr = view.state.tr.setSelection(TextSelection.create(view.state.doc, pos + node.nodeSize));
|
|
611
|
+
tr.setMeta(key, {
|
|
612
|
+
action: "activate",
|
|
613
|
+
from: pos,
|
|
614
|
+
query: `$${node.attrs.equation}`,
|
|
615
|
+
isEdit: true,
|
|
616
|
+
mathNodePos: pos
|
|
617
|
+
});
|
|
618
|
+
view.dispatch(tr);
|
|
619
|
+
event.stopPropagation();
|
|
620
|
+
event.preventDefault();
|
|
621
|
+
return true;
|
|
622
|
+
},
|
|
623
|
+
click(view, event) {
|
|
624
|
+
const pluginState = key.getState(view.state);
|
|
625
|
+
if (pluginState?.active) {
|
|
626
|
+
if (event.target.closest(".inline-math-widget")) {
|
|
627
|
+
// Click inside the widget: let the widget handle it.
|
|
628
|
+
return false;
|
|
629
|
+
}
|
|
630
|
+
// Widget is active and user clicked elsewhere: the
|
|
631
|
+
// focusout handler will commit asynchronously; prevent
|
|
632
|
+
// the click from doing anything unexpected.
|
|
633
|
+
event.preventDefault();
|
|
634
|
+
event.stopPropagation();
|
|
635
|
+
return true;
|
|
636
|
+
}
|
|
637
|
+
return false;
|
|
638
|
+
}
|
|
639
|
+
},
|
|
640
|
+
handleKeyDown(view, event) {
|
|
641
|
+
const pluginState = key.getState(view.state);
|
|
642
|
+
if (!pluginState?.active) {
|
|
643
|
+
/* ── "$" keypress → activate inline editor ── */
|
|
644
|
+
if (event.key === "$") {
|
|
645
|
+
const $pos = view.state.selection.$head;
|
|
646
|
+
if (canActivateInlineMath(view.state, $pos, editor)) {
|
|
647
|
+
event.preventDefault();
|
|
648
|
+
view.dispatch(view.state.tr.setMeta(key, {
|
|
649
|
+
action: "activate",
|
|
650
|
+
from: $pos.pos,
|
|
651
|
+
query: "$",
|
|
652
|
+
isEdit: false,
|
|
653
|
+
mathNodePos: 0
|
|
654
|
+
}));
|
|
655
|
+
return true;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
/* ── ArrowRight into an equation node ── */
|
|
659
|
+
if (event.key === "ArrowRight") {
|
|
660
|
+
const sel = view.state.selection;
|
|
661
|
+
if (sel.empty) {
|
|
662
|
+
const nodeAfter = sel.$head.nodeAfter;
|
|
663
|
+
if (nodeAfter &&
|
|
664
|
+
nodeAfter.type.name === "equation") {
|
|
665
|
+
event.preventDefault();
|
|
666
|
+
const from = sel.$head.pos;
|
|
667
|
+
view.dispatch(view.state.tr.setMeta(key, {
|
|
668
|
+
action: "activate",
|
|
669
|
+
from,
|
|
670
|
+
query: `$${nodeAfter.attrs.equation}`,
|
|
671
|
+
isEdit: true,
|
|
672
|
+
mathNodePos: from,
|
|
673
|
+
cursorAtStart: true
|
|
674
|
+
}));
|
|
675
|
+
return true;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
/* ── ArrowLeft into an equation node ── */
|
|
680
|
+
if (event.key === "ArrowLeft") {
|
|
681
|
+
const sel = view.state.selection;
|
|
682
|
+
if (sel.empty) {
|
|
683
|
+
const nodeBefore = sel.$head.nodeBefore;
|
|
684
|
+
if (nodeBefore &&
|
|
685
|
+
nodeBefore.type.name === "equation") {
|
|
686
|
+
event.preventDefault();
|
|
687
|
+
const from = sel.$head.pos - nodeBefore.nodeSize;
|
|
688
|
+
view.dispatch(view.state.tr.setMeta(key, {
|
|
689
|
+
action: "activate",
|
|
690
|
+
from,
|
|
691
|
+
query: `$${nodeBefore.attrs.equation}`,
|
|
692
|
+
isEdit: true,
|
|
693
|
+
mathNodePos: from,
|
|
694
|
+
cursorAtStart: false
|
|
695
|
+
}));
|
|
696
|
+
return true;
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
return false;
|
|
701
|
+
}
|
|
702
|
+
// When the widget is active it traps its own events; nothing
|
|
703
|
+
// extra needs to be handled here.
|
|
704
|
+
return false;
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
/* ────────────────────────────────────────────────────────── */
|
|
710
|
+
/* Public plugin factory */
|
|
711
|
+
/* ────────────────────────────────────────────────────────── */
|
|
712
|
+
export const inlineMathPlugin = options => {
|
|
713
|
+
const editor = options.editor;
|
|
714
|
+
const enabled = editor.app.config.user?.preferences?.inline_math === true &&
|
|
715
|
+
!READ_ONLY_ROLES.includes(editor.docInfo.access_rights) &&
|
|
716
|
+
!COMMENT_ONLY_ROLES.includes(editor.docInfo.access_rights);
|
|
717
|
+
return enabled ? inlineEditorPlugin(options) : dropupPlugin(options);
|
|
718
|
+
};
|
|
719
|
+
//# sourceMappingURL=inline_math.js.map
|