@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,318 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contributor input plugin for ProseMirror editor
|
|
3
|
+
*
|
|
4
|
+
* Manages contributor selection, drop-up menu, and editing dialog
|
|
5
|
+
* Features:
|
|
6
|
+
* - Auto-select contributor nodes when navigating in contributors_part
|
|
7
|
+
* - Show drop-up menu when contributor is selected
|
|
8
|
+
* - Support keyboard navigation for contributors and drop-up menu
|
|
9
|
+
* - Handle contributor addition/editing via dialog
|
|
10
|
+
*/
|
|
11
|
+
import {NodeSelection, Plugin, PluginKey} from "prosemirror-state"
|
|
12
|
+
import {Decoration, DecorationSet} from "prosemirror-view"
|
|
13
|
+
|
|
14
|
+
import {ContributorDialog} from "../../dialogs"
|
|
15
|
+
import {createDropUp} from "./dropup"
|
|
16
|
+
import {nextSelection} from "./helpers"
|
|
17
|
+
import {ContributorsPartView} from "./node_view"
|
|
18
|
+
|
|
19
|
+
const key = new PluginKey("contributorInput")
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Create the contributor input plugin
|
|
23
|
+
* @param {Object} options - Plugin options with editor reference
|
|
24
|
+
* @returns {Plugin} ProseMirror plugin instance
|
|
25
|
+
*/
|
|
26
|
+
export const contributorInputPlugin = options =>
|
|
27
|
+
new Plugin({
|
|
28
|
+
key,
|
|
29
|
+
state: {
|
|
30
|
+
/**
|
|
31
|
+
* Initialize plugin state
|
|
32
|
+
* @param {Object} _config - Plugin config (unused)
|
|
33
|
+
* @param {Object} state - Initial ProseMirror state
|
|
34
|
+
* @returns {Object} Initial plugin state
|
|
35
|
+
*/
|
|
36
|
+
init(_config, state) {
|
|
37
|
+
const decos = DecorationSet.empty
|
|
38
|
+
if (options.editor.docInfo.access_rights === "write") {
|
|
39
|
+
this.spec.props.nodeViews["contributors_part"] = (
|
|
40
|
+
node,
|
|
41
|
+
view,
|
|
42
|
+
getPos
|
|
43
|
+
) => new ContributorsPartView(node, view, getPos)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Find all contributors_part nodes in document to track their positions
|
|
47
|
+
const contributorsPartPositions = []
|
|
48
|
+
state.doc.descendants((node, pos) => {
|
|
49
|
+
if (node.type.name === "contributors_part") {
|
|
50
|
+
contributorsPartPositions.push({
|
|
51
|
+
start: pos,
|
|
52
|
+
end: pos + node.nodeSize
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
return {contributorsPartPositions, decos}
|
|
58
|
+
},
|
|
59
|
+
/**
|
|
60
|
+
* Apply a transaction to plugin state
|
|
61
|
+
* @param {Transaction} tr - Transaction being applied
|
|
62
|
+
* @param {Object} prev - Previous plugin state
|
|
63
|
+
* @param {Object} oldState - ProseMirror state before transaction
|
|
64
|
+
* @param {Object} state - ProseMirror state after transaction
|
|
65
|
+
* @returns {Object} New plugin state
|
|
66
|
+
*/
|
|
67
|
+
apply(tr, prev, _oldState, state) {
|
|
68
|
+
let {decos, contributorsPartPositions} = prev
|
|
69
|
+
// If document was modified, update all positions
|
|
70
|
+
if (tr.docChanged) {
|
|
71
|
+
contributorsPartPositions = contributorsPartPositions.map(
|
|
72
|
+
range => ({
|
|
73
|
+
start: tr.mapping.map(range.start),
|
|
74
|
+
end: tr.mapping.map(range.end)
|
|
75
|
+
})
|
|
76
|
+
)
|
|
77
|
+
decos = decos.map(tr.mapping, tr.doc)
|
|
78
|
+
}
|
|
79
|
+
if (options.editor.docInfo.access_rights !== "write") {
|
|
80
|
+
return {
|
|
81
|
+
contributorsPartPositions,
|
|
82
|
+
decos
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (tr.selectionSet) {
|
|
86
|
+
// Always remove any existing contributor drop-up before adding a new one
|
|
87
|
+
// This ensures only one drop-up is ever shown at any time
|
|
88
|
+
const oldDropUpDeco = decos.find(
|
|
89
|
+
null,
|
|
90
|
+
null,
|
|
91
|
+
spec => spec.id === "contributorDropUp"
|
|
92
|
+
)
|
|
93
|
+
if (oldDropUpDeco && oldDropUpDeco.length) {
|
|
94
|
+
decos = decos.remove(oldDropUpDeco)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (
|
|
98
|
+
state.selection.jsonID === "node" &&
|
|
99
|
+
state.selection.node.type.name === "contributor" &&
|
|
100
|
+
state.selection.$anchor.node(1).attrs.locking !==
|
|
101
|
+
"fixed"
|
|
102
|
+
) {
|
|
103
|
+
const dropUpDeco = Decoration.widget(
|
|
104
|
+
state.selection.from,
|
|
105
|
+
createDropUp(state.selection, options.editor.view),
|
|
106
|
+
{
|
|
107
|
+
side: -1,
|
|
108
|
+
stopEvent: event => {
|
|
109
|
+
// Get drop-up element to check if it exists in DOM
|
|
110
|
+
const dropUpEl =
|
|
111
|
+
document.querySelector(".drop-up-outer")
|
|
112
|
+
|
|
113
|
+
if (!dropUpEl) {
|
|
114
|
+
// Drop-up not in DOM, let events pass through
|
|
115
|
+
return false
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Stop mouse events targeting the drop-up
|
|
119
|
+
if (
|
|
120
|
+
event.type === "mousedown" ||
|
|
121
|
+
event.type === "click"
|
|
122
|
+
) {
|
|
123
|
+
return event.target.closest(
|
|
124
|
+
".drop-up-outer"
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Stop keyboard events that should be handled by the drop-up
|
|
129
|
+
if (event.type === "keydown") {
|
|
130
|
+
// Check if event target is within drop-up or if drop-up has focus
|
|
131
|
+
const isTargetInDropUp =
|
|
132
|
+
event.target.closest(
|
|
133
|
+
".drop-up-outer"
|
|
134
|
+
)
|
|
135
|
+
const dropUpHasFocus =
|
|
136
|
+
dropUpEl.contains(
|
|
137
|
+
document.activeElement
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
// Keys that should be handled by the drop-up
|
|
141
|
+
const keysHandled = [
|
|
142
|
+
"ArrowDown",
|
|
143
|
+
"ArrowUp",
|
|
144
|
+
"Enter",
|
|
145
|
+
" ",
|
|
146
|
+
"Escape",
|
|
147
|
+
"Home",
|
|
148
|
+
"End"
|
|
149
|
+
]
|
|
150
|
+
|
|
151
|
+
// Arrow-Right and Arrow-Left should always pass through for contributor navigation
|
|
152
|
+
if (
|
|
153
|
+
event.key === "ArrowRight" ||
|
|
154
|
+
event.key === "ArrowLeft"
|
|
155
|
+
) {
|
|
156
|
+
return false
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Only stop the event if it's a handled key and either:
|
|
160
|
+
// 1. The event target is within the drop-up, or
|
|
161
|
+
// 2. The drop-up has focus
|
|
162
|
+
if (
|
|
163
|
+
keysHandled.includes(event.key) &&
|
|
164
|
+
(isTargetInDropUp || dropUpHasFocus)
|
|
165
|
+
) {
|
|
166
|
+
return true
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return false
|
|
170
|
+
},
|
|
171
|
+
id: "contributorDropUp"
|
|
172
|
+
}
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
decos = decos.add(state.doc, [dropUpDeco])
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return {
|
|
180
|
+
contributorsPartPositions,
|
|
181
|
+
decos
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
props: {
|
|
186
|
+
nodeViews: {},
|
|
187
|
+
decorations(state) {
|
|
188
|
+
const {decos} = this.getState(state)
|
|
189
|
+
|
|
190
|
+
return decos
|
|
191
|
+
},
|
|
192
|
+
/**
|
|
193
|
+
* Handle keyboard events
|
|
194
|
+
* @param {EditorView} view - ProseMirror editor view
|
|
195
|
+
* @param {KeyboardEvent} event - Keyboard event
|
|
196
|
+
* @returns {boolean} True if event was handled
|
|
197
|
+
*/
|
|
198
|
+
handleKeyDown(view, event) {
|
|
199
|
+
const isContributorSelected =
|
|
200
|
+
view.state.selection.node?.type.name === "contributor"
|
|
201
|
+
const dropUpEl = document.querySelector(".drop-up-options")
|
|
202
|
+
const dropUpHasFocus =
|
|
203
|
+
dropUpEl && dropUpEl.contains(document.activeElement)
|
|
204
|
+
|
|
205
|
+
// If drop-up is focused, let it handle all keyboard events
|
|
206
|
+
if (dropUpHasFocus) {
|
|
207
|
+
return false
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Arrow-Up on a selected contributor should focus the drop-up menu
|
|
211
|
+
if (event.key === "ArrowUp" && isContributorSelected) {
|
|
212
|
+
event.preventDefault()
|
|
213
|
+
if (dropUpEl) {
|
|
214
|
+
dropUpEl.focus()
|
|
215
|
+
}
|
|
216
|
+
return true
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Space key on a selected contributor opens the dialog (when drop-up not focused)
|
|
220
|
+
if (event.key === " " && isContributorSelected) {
|
|
221
|
+
const idTypes =
|
|
222
|
+
view.editor.mod.documentTemplate?.currentTemplate
|
|
223
|
+
?.id_types || []
|
|
224
|
+
const dialog = new ContributorDialog(
|
|
225
|
+
view.state.selection.$anchor.parent,
|
|
226
|
+
view,
|
|
227
|
+
view.state.selection.node.attrs,
|
|
228
|
+
idTypes
|
|
229
|
+
)
|
|
230
|
+
dialog.init()
|
|
231
|
+
return true
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// For all other cases, let ProseMirror handle the key
|
|
235
|
+
return false
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
/**
|
|
239
|
+
* Append additional transactions based on selection changes
|
|
240
|
+
* Handles auto-selection of contributor nodes when navigating in contributors_part
|
|
241
|
+
* @param {Array<Transaction>} trs - Transactions being applied
|
|
242
|
+
* @param {Object} oldState - State before transactions
|
|
243
|
+
* @param {Object} newState - State after transactions
|
|
244
|
+
* @returns {Transaction|null} Additional transaction to apply
|
|
245
|
+
*/
|
|
246
|
+
appendTransaction: (trs, oldState, newState) => {
|
|
247
|
+
// If selection is not collapsed or not changed, don't do anything
|
|
248
|
+
if (
|
|
249
|
+
newState.selection.from !== newState.selection.to ||
|
|
250
|
+
!trs.some(tr => tr.selectionSet)
|
|
251
|
+
) {
|
|
252
|
+
return
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const selectionPos = newState.selection.from
|
|
256
|
+
const pluginState = key.getState(newState)
|
|
257
|
+
|
|
258
|
+
// Check if selection is within any contributors_part node to handle contributor navigation
|
|
259
|
+
const contributorsPartRange =
|
|
260
|
+
pluginState.contributorsPartPositions.find(
|
|
261
|
+
range =>
|
|
262
|
+
selectionPos > range.start && selectionPos < range.end
|
|
263
|
+
)
|
|
264
|
+
|
|
265
|
+
if (contributorsPartRange) {
|
|
266
|
+
const oldSelectionPos = oldState.selection.from
|
|
267
|
+
|
|
268
|
+
if (selectionPos + 1 === contributorsPartRange.end) {
|
|
269
|
+
// Selection is at end of contributors_part.
|
|
270
|
+
// Put caret onto contributor add button if write access is present.
|
|
271
|
+
// Otherwise, move caret beyond contributors_part.
|
|
272
|
+
if (options.editor.docInfo.access_rights === "write") {
|
|
273
|
+
// contributor add button will be activated by node view.
|
|
274
|
+
return
|
|
275
|
+
}
|
|
276
|
+
if (oldSelectionPos < selectionPos) {
|
|
277
|
+
const newSelection = nextSelection(
|
|
278
|
+
newState,
|
|
279
|
+
contributorsPartRange.end,
|
|
280
|
+
1
|
|
281
|
+
)
|
|
282
|
+
if (!newSelection) {
|
|
283
|
+
// Cannot find a location. Give up.
|
|
284
|
+
return
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
return newState.tr.setSelection(newSelection)
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
const selectedNodePos =
|
|
292
|
+
oldSelectionPos < selectionPos
|
|
293
|
+
? selectionPos
|
|
294
|
+
: selectionPos - 1
|
|
295
|
+
|
|
296
|
+
if (selectedNodePos === contributorsPartRange.start) {
|
|
297
|
+
// selection is at start of contributors node. Find previous possible selection location.
|
|
298
|
+
const newSelection = nextSelection(
|
|
299
|
+
newState,
|
|
300
|
+
selectedNodePos,
|
|
301
|
+
-1
|
|
302
|
+
)
|
|
303
|
+
if (!newSelection) {
|
|
304
|
+
// Cannot find a location. Give up.
|
|
305
|
+
return
|
|
306
|
+
}
|
|
307
|
+
return newState.tr.setSelection(newSelection)
|
|
308
|
+
} else {
|
|
309
|
+
// Select an entire contributor node
|
|
310
|
+
return newState.tr.setSelection(
|
|
311
|
+
NodeSelection.create(newState.doc, selectedNodePos)
|
|
312
|
+
)
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
return null
|
|
317
|
+
}
|
|
318
|
+
})
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import {Fragment} from "prosemirror-model"
|
|
2
|
+
import {Plugin, PluginKey} from "prosemirror-state"
|
|
3
|
+
|
|
4
|
+
const key = new PluginKey("documentTemplate")
|
|
5
|
+
|
|
6
|
+
export function addDeletedPartWidget(dom, view, getPos) {
|
|
7
|
+
dom.classList.add("doc-deleted")
|
|
8
|
+
dom.insertAdjacentHTML(
|
|
9
|
+
"beforeend",
|
|
10
|
+
'<div class="remove-doc-part"><i class="fa-solid fa-trash-alt"></i></div>'
|
|
11
|
+
)
|
|
12
|
+
const removeButton = dom.lastElementChild
|
|
13
|
+
removeButton.addEventListener("click", () => {
|
|
14
|
+
const from = getPos(),
|
|
15
|
+
to = from + view.state.doc.nodeAt(from).nodeSize,
|
|
16
|
+
tr = view.state.tr
|
|
17
|
+
tr.delete(from, to)
|
|
18
|
+
tr.setMeta("deleteUnusedSection", true)
|
|
19
|
+
view.dispatch(tr)
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
export function getProtectedRanges(state) {
|
|
23
|
+
return key.getState(state).protectedRanges
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function getAllowedElementsAndMarks(state) {
|
|
27
|
+
// Get the allowed elements and marks at the current selection position
|
|
28
|
+
const {$anchor} = state.selection
|
|
29
|
+
const docPart = $anchor.node(1) // Get the part node (richtext_part, heading_part, etc.)
|
|
30
|
+
|
|
31
|
+
if (!docPart) {
|
|
32
|
+
return {elements: false, marks: false}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const allowedElements = docPart.attrs.elements
|
|
36
|
+
? docPart.attrs.elements.concat(
|
|
37
|
+
"table_caption",
|
|
38
|
+
"table_body",
|
|
39
|
+
"table_row",
|
|
40
|
+
"table_cell",
|
|
41
|
+
"table_header",
|
|
42
|
+
"list_item",
|
|
43
|
+
"text"
|
|
44
|
+
)
|
|
45
|
+
: false
|
|
46
|
+
|
|
47
|
+
const allowedMarks = docPart.attrs.marks
|
|
48
|
+
? docPart.attrs.marks.concat(
|
|
49
|
+
"insertion",
|
|
50
|
+
"deletion",
|
|
51
|
+
"comment",
|
|
52
|
+
"anchor"
|
|
53
|
+
)
|
|
54
|
+
: false
|
|
55
|
+
|
|
56
|
+
return {elements: allowedElements, marks: allowedMarks}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function checkProtectedInSelection(state) {
|
|
60
|
+
// Checks whether there is a protected range
|
|
61
|
+
// within a selection
|
|
62
|
+
const anchorDocPart = state.selection.$anchor.node(1),
|
|
63
|
+
headDocPart = state.selection.$head.node(1)
|
|
64
|
+
|
|
65
|
+
// If the protection is of header/start check if selection falls within the
|
|
66
|
+
// protected range
|
|
67
|
+
if (
|
|
68
|
+
["start", "header"].includes(anchorDocPart.attrs.locking) ||
|
|
69
|
+
["start", "header"].includes(headDocPart.attrs.locking)
|
|
70
|
+
) {
|
|
71
|
+
const protectedRanges = key.getState(state).protectedRanges,
|
|
72
|
+
start = state.selection.from,
|
|
73
|
+
end = state.selection.to
|
|
74
|
+
if (
|
|
75
|
+
protectedRanges.find(
|
|
76
|
+
({from, to}) =>
|
|
77
|
+
!(
|
|
78
|
+
(start <= from && end <= from) ||
|
|
79
|
+
(start >= to && end >= to)
|
|
80
|
+
)
|
|
81
|
+
)
|
|
82
|
+
) {
|
|
83
|
+
return true
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return (
|
|
87
|
+
anchorDocPart.attrs.locking === "fixed" ||
|
|
88
|
+
headDocPart.attrs.locking === "fixed"
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export class PartView {
|
|
93
|
+
constructor(node, view, getPos) {
|
|
94
|
+
this.node = node
|
|
95
|
+
this.view = view
|
|
96
|
+
this.getPos = getPos
|
|
97
|
+
this.dom = document.createElement("div")
|
|
98
|
+
this.dom.classList.add("doc-part")
|
|
99
|
+
this.dom.classList.add(`doc-${this.node.type.name}`)
|
|
100
|
+
this.dom.classList.add(`doc-${this.node.attrs.id}`)
|
|
101
|
+
if (node.attrs.hidden) {
|
|
102
|
+
this.dom.dataset.hidden = true
|
|
103
|
+
}
|
|
104
|
+
if (node.attrs.deleted) {
|
|
105
|
+
this.contentDOM = this.dom.appendChild(
|
|
106
|
+
document.createElement("div")
|
|
107
|
+
)
|
|
108
|
+
addDeletedPartWidget(this.dom, view, getPos)
|
|
109
|
+
} else {
|
|
110
|
+
this.contentDOM = this.dom
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
stopEvent() {
|
|
115
|
+
return false
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export const documentTemplatePlugin = options =>
|
|
120
|
+
new Plugin({
|
|
121
|
+
key,
|
|
122
|
+
state: {
|
|
123
|
+
init(_config, state) {
|
|
124
|
+
if (options.editor.docInfo.access_rights === "write") {
|
|
125
|
+
this.spec.props.nodeViews["richtext_part"] = (
|
|
126
|
+
node,
|
|
127
|
+
view,
|
|
128
|
+
getPos
|
|
129
|
+
) => new PartView(node, view, getPos)
|
|
130
|
+
this.spec.props.nodeViews["heading_part"] = (
|
|
131
|
+
node,
|
|
132
|
+
view,
|
|
133
|
+
getPos
|
|
134
|
+
) => new PartView(node, view, getPos)
|
|
135
|
+
this.spec.props.nodeViews["table_part"] = (
|
|
136
|
+
node,
|
|
137
|
+
view,
|
|
138
|
+
getPos
|
|
139
|
+
) => new PartView(node, view, getPos)
|
|
140
|
+
// Tags and Contributors have node views defined in tag_input and contributor_input.
|
|
141
|
+
// TOCs have node views defined in toc_render.
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const protectedRanges = [
|
|
145
|
+
{from: 0, to: 1} // article node
|
|
146
|
+
]
|
|
147
|
+
state.doc.forEach((node, pos) => {
|
|
148
|
+
const from = pos
|
|
149
|
+
let to = from
|
|
150
|
+
if (node.attrs.locking === "fixed") {
|
|
151
|
+
to = from + node.nodeSize
|
|
152
|
+
} else if (node.attrs.locking === "header") {
|
|
153
|
+
// only relevant for tables
|
|
154
|
+
to =
|
|
155
|
+
from +
|
|
156
|
+
1 +
|
|
157
|
+
1 +
|
|
158
|
+
1 +
|
|
159
|
+
node.firstChild.firstChild.nodeSize // + 1 for the part node + 1 for the table + 1 for the first row
|
|
160
|
+
} else if (node.attrs.locking === "start") {
|
|
161
|
+
let initialFragment = Fragment.fromJSON(
|
|
162
|
+
options.editor.schema,
|
|
163
|
+
node.attrs.initial
|
|
164
|
+
)
|
|
165
|
+
let protectionSize = initialFragment.size
|
|
166
|
+
if (initialFragment.lastChild?.isTextblock) {
|
|
167
|
+
protectionSize -= 1 // We allow writing at the end of the last text block.
|
|
168
|
+
if (initialFragment.lastChild.nodeSize === 2) {
|
|
169
|
+
// The last text block is empty, so we remove all protection from it, even node type
|
|
170
|
+
protectionSize -= 1
|
|
171
|
+
}
|
|
172
|
+
initialFragment = initialFragment.cut(
|
|
173
|
+
0,
|
|
174
|
+
protectionSize
|
|
175
|
+
)
|
|
176
|
+
}
|
|
177
|
+
if (
|
|
178
|
+
node.content.size >= protectionSize &&
|
|
179
|
+
initialFragment.eq(
|
|
180
|
+
node.slice(0, protectionSize).content
|
|
181
|
+
)
|
|
182
|
+
) {
|
|
183
|
+
// We only add protection if the start of the current content corresponds to the
|
|
184
|
+
// initial content. This may not be the case if the template has been changed.
|
|
185
|
+
to = from + 1 + protectionSize // + 1 for inside the part node
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
protectedRanges.push({from, to})
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
return {
|
|
192
|
+
protectedRanges
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
apply(tr, _prev, oldState, _state) {
|
|
196
|
+
let {protectedRanges} = this.getState(oldState)
|
|
197
|
+
protectedRanges = protectedRanges.map(marker => ({
|
|
198
|
+
from: tr.mapping.map(marker.from, 1),
|
|
199
|
+
to: tr.mapping.map(marker.to, -1)
|
|
200
|
+
}))
|
|
201
|
+
return {
|
|
202
|
+
protectedRanges
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
props: {
|
|
207
|
+
nodeViews: {}
|
|
208
|
+
},
|
|
209
|
+
filterTransaction: (tr, state) => {
|
|
210
|
+
if (
|
|
211
|
+
!tr.docChanged ||
|
|
212
|
+
tr.getMeta("fixIds") ||
|
|
213
|
+
tr.getMeta("remote") ||
|
|
214
|
+
tr.getMeta("track") ||
|
|
215
|
+
tr.getMeta("fromFootnote") ||
|
|
216
|
+
tr.getMeta("deleteUnusedSection") ||
|
|
217
|
+
tr.getMeta("settings") ||
|
|
218
|
+
["historyUndo", "historyRedo"].includes(tr.getMeta("inputType"))
|
|
219
|
+
) {
|
|
220
|
+
return true
|
|
221
|
+
}
|
|
222
|
+
if (state.doc.childCount !== tr.doc.childCount) {
|
|
223
|
+
return false
|
|
224
|
+
}
|
|
225
|
+
const {protectedRanges} = key.getState(state)
|
|
226
|
+
let allowed = true
|
|
227
|
+
|
|
228
|
+
let changingRanges = []
|
|
229
|
+
|
|
230
|
+
// We map all changes back to the document before changes have been applied.
|
|
231
|
+
tr.steps
|
|
232
|
+
.slice()
|
|
233
|
+
.reverse()
|
|
234
|
+
.forEach(step => {
|
|
235
|
+
const map = step.getMap()
|
|
236
|
+
if (changingRanges.length) {
|
|
237
|
+
const mapInv = map.invert()
|
|
238
|
+
changingRanges = changingRanges.map(range => ({
|
|
239
|
+
start: mapInv.map(range.start, -1),
|
|
240
|
+
end: mapInv.map(range.end, 1)
|
|
241
|
+
}))
|
|
242
|
+
}
|
|
243
|
+
if (["removeMark", "addMark"].includes(step.jsonID)) {
|
|
244
|
+
changingRanges.push({start: step.from, end: step.to})
|
|
245
|
+
}
|
|
246
|
+
map.forEach((start, end) => {
|
|
247
|
+
changingRanges.push({start, end})
|
|
248
|
+
})
|
|
249
|
+
})
|
|
250
|
+
changingRanges.forEach(({start, end}) => {
|
|
251
|
+
if (
|
|
252
|
+
protectedRanges.find(
|
|
253
|
+
({from, to}) =>
|
|
254
|
+
!(
|
|
255
|
+
(start <= from && end <= from) ||
|
|
256
|
+
(start >= to && end >= to)
|
|
257
|
+
)
|
|
258
|
+
)
|
|
259
|
+
) {
|
|
260
|
+
allowed = false
|
|
261
|
+
}
|
|
262
|
+
})
|
|
263
|
+
|
|
264
|
+
let allowedElements = false,
|
|
265
|
+
allowedMarks = false
|
|
266
|
+
|
|
267
|
+
changingRanges.forEach(range =>
|
|
268
|
+
state.doc.nodesBetween(
|
|
269
|
+
range.from,
|
|
270
|
+
range.to,
|
|
271
|
+
(node, pos, parent, _index) => {
|
|
272
|
+
if (parent === tr.doc) {
|
|
273
|
+
allowedElements = node.attrs.elements
|
|
274
|
+
? node.attrs.elements.concat(
|
|
275
|
+
"table_caption",
|
|
276
|
+
"table_body",
|
|
277
|
+
"table_row",
|
|
278
|
+
"table_cell",
|
|
279
|
+
"table_header",
|
|
280
|
+
"list_item",
|
|
281
|
+
"text"
|
|
282
|
+
)
|
|
283
|
+
: false
|
|
284
|
+
allowedMarks = node.attrs.marks
|
|
285
|
+
? node.attrs.marks.concat(
|
|
286
|
+
"insertion",
|
|
287
|
+
"deletion",
|
|
288
|
+
"comment",
|
|
289
|
+
"anchor"
|
|
290
|
+
)
|
|
291
|
+
: false
|
|
292
|
+
return allowed
|
|
293
|
+
}
|
|
294
|
+
if (pos < range.from) {
|
|
295
|
+
return true
|
|
296
|
+
}
|
|
297
|
+
if (
|
|
298
|
+
allowedElements &&
|
|
299
|
+
!allowedElements.includes(node.type.name)
|
|
300
|
+
) {
|
|
301
|
+
allowed = false
|
|
302
|
+
} else if (allowedMarks) {
|
|
303
|
+
node.marks.forEach(mark => {
|
|
304
|
+
if (!allowedMarks.includes(mark.type.name)) {
|
|
305
|
+
allowed = false
|
|
306
|
+
}
|
|
307
|
+
})
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
)
|
|
311
|
+
)
|
|
312
|
+
|
|
313
|
+
return allowed
|
|
314
|
+
}
|
|
315
|
+
})
|