@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,173 @@
|
|
|
1
|
+
import {Dialog, addAlert} from "fwtoolkit"
|
|
2
|
+
import {NodeSelection} from "prosemirror-state"
|
|
3
|
+
import {contributorTemplate} from "./templates"
|
|
4
|
+
/*
|
|
5
|
+
Source for email regexp:
|
|
6
|
+
https://html.spec.whatwg.org/multipage/input.html#e-mail-state-(type%3Demail)
|
|
7
|
+
*/
|
|
8
|
+
const emailRegExp =
|
|
9
|
+
/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/
|
|
10
|
+
|
|
11
|
+
export class ContributorDialog {
|
|
12
|
+
/**
|
|
13
|
+
* @param {Object} node - The contributors_part node
|
|
14
|
+
* @param {Object} view - The ProseMirror editor view
|
|
15
|
+
* @param {Object|false} contributor - The contributor data if editing, false if adding
|
|
16
|
+
* @param {Array} idTypes - Array of ID type configs from template [{label, regex}]
|
|
17
|
+
*/
|
|
18
|
+
constructor(node, view, contributor = false, idTypes = []) {
|
|
19
|
+
this.node = node
|
|
20
|
+
this.view = view
|
|
21
|
+
this.contributor = contributor
|
|
22
|
+
console.log("ContirbutorDialog", {node, view, contributor, idTypes})
|
|
23
|
+
this.idTypes = idTypes
|
|
24
|
+
this.dialog = false
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
init() {
|
|
28
|
+
const buttons = []
|
|
29
|
+
// Add Update/Add button
|
|
30
|
+
buttons.push({
|
|
31
|
+
text: this.contributor ? gettext("Update") : gettext("Add"),
|
|
32
|
+
classes: "fw-dark",
|
|
33
|
+
click: () => {
|
|
34
|
+
// Get form values
|
|
35
|
+
let firstname = this.dialog.dialogEl.querySelector(
|
|
36
|
+
"input[name=firstname]"
|
|
37
|
+
).value,
|
|
38
|
+
lastname = this.dialog.dialogEl.querySelector(
|
|
39
|
+
"input[name=lastname]"
|
|
40
|
+
).value,
|
|
41
|
+
email =
|
|
42
|
+
this.dialog.dialogEl.querySelector(
|
|
43
|
+
"input[name=email]"
|
|
44
|
+
).value,
|
|
45
|
+
institution = this.dialog.dialogEl.querySelector(
|
|
46
|
+
"input[name=institution]"
|
|
47
|
+
).value,
|
|
48
|
+
id_type = false,
|
|
49
|
+
id_value = false
|
|
50
|
+
|
|
51
|
+
firstname = firstname.length ? firstname : false
|
|
52
|
+
lastname = lastname.length ? lastname : false
|
|
53
|
+
institution = institution.length ? institution : false
|
|
54
|
+
email = email.length ? email : false
|
|
55
|
+
|
|
56
|
+
// Get ID type/value if fields are shown
|
|
57
|
+
if (this.idTypes && this.idTypes.length > 0) {
|
|
58
|
+
const idTypeEl =
|
|
59
|
+
this.dialog.dialogEl.querySelector("[name=id_type]")
|
|
60
|
+
if (idTypeEl && idTypeEl.value) {
|
|
61
|
+
id_type = idTypeEl.value
|
|
62
|
+
const idValueInput = this.dialog.dialogEl.querySelector(
|
|
63
|
+
"input[name=id_value]"
|
|
64
|
+
)
|
|
65
|
+
if (idValueInput && idValueInput.value) {
|
|
66
|
+
id_value = idValueInput.value
|
|
67
|
+
// Validate id_value against selected id_type's regex
|
|
68
|
+
const selectedType = this.idTypes.find(
|
|
69
|
+
t => t.label === id_type
|
|
70
|
+
)
|
|
71
|
+
if (selectedType && selectedType.regex) {
|
|
72
|
+
const regex = new RegExp(selectedType.regex)
|
|
73
|
+
if (!regex.test(id_value)) {
|
|
74
|
+
addAlert(
|
|
75
|
+
"error",
|
|
76
|
+
gettext(
|
|
77
|
+
"ID Value format is incorrect for "
|
|
78
|
+
) + id_type
|
|
79
|
+
)
|
|
80
|
+
return
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Validate email format
|
|
88
|
+
if (email && !emailRegExp.test(email)) {
|
|
89
|
+
addAlert("error", gettext("Email is in incorrect format!"))
|
|
90
|
+
return
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
this.dialog.close()
|
|
94
|
+
|
|
95
|
+
// Don't create contributor if all fields are empty
|
|
96
|
+
if (!firstname && !lastname && !institution && !email) {
|
|
97
|
+
// No data, don't insert.
|
|
98
|
+
return
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const view = this.view,
|
|
102
|
+
newNode = view.state.schema.nodes.contributor.create({
|
|
103
|
+
firstname,
|
|
104
|
+
lastname,
|
|
105
|
+
email,
|
|
106
|
+
institution,
|
|
107
|
+
id_type,
|
|
108
|
+
id_value
|
|
109
|
+
})
|
|
110
|
+
let tr
|
|
111
|
+
|
|
112
|
+
// Check if we're editing an existing contributor based on current selection
|
|
113
|
+
// This works for collaborative editing because we use current selection, not saved positions
|
|
114
|
+
if (
|
|
115
|
+
this.contributor &&
|
|
116
|
+
view.state.selection.jsonID === "node" &&
|
|
117
|
+
view.state.selection.node.type.name === "contributor"
|
|
118
|
+
) {
|
|
119
|
+
// Editing: replace the selected contributor
|
|
120
|
+
tr = view.state.tr.replaceSelectionWith(newNode, false)
|
|
121
|
+
// Set selection to the updated contributor
|
|
122
|
+
tr.setSelection(
|
|
123
|
+
NodeSelection.create(tr.doc, view.state.selection.from)
|
|
124
|
+
)
|
|
125
|
+
} else {
|
|
126
|
+
// Adding: find the insertion point based on current document state
|
|
127
|
+
// Adding: find the insertion point based on current document state
|
|
128
|
+
let posFrom, posTo
|
|
129
|
+
view.state.doc.descendants((node, pos) => {
|
|
130
|
+
// Find the contributors_part node to determine insertion position
|
|
131
|
+
if (node.attrs.id === this.node.attrs.id) {
|
|
132
|
+
posFrom = posTo = pos + node.nodeSize - 1
|
|
133
|
+
// - 1 to go to end of node contributors container node
|
|
134
|
+
}
|
|
135
|
+
if ("id" in node.attrs) {
|
|
136
|
+
return false
|
|
137
|
+
}
|
|
138
|
+
})
|
|
139
|
+
tr = view.state.tr.replaceRangeWith(posFrom, posTo, newNode)
|
|
140
|
+
// Set selection to the newly created contributor
|
|
141
|
+
tr.setSelection(NodeSelection.create(tr.doc, posFrom))
|
|
142
|
+
}
|
|
143
|
+
// Dispatch the transaction (both replacement and selection)
|
|
144
|
+
view.dispatch(tr)
|
|
145
|
+
return
|
|
146
|
+
}
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
buttons.push({
|
|
150
|
+
type: "cancel"
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
// Create and open the dialog
|
|
154
|
+
|
|
155
|
+
this.dialog = new Dialog({
|
|
156
|
+
id: "edit-contributor",
|
|
157
|
+
title: `${this.contributor ? gettext("Update") : gettext("Add")} ${this.node.attrs.item_title.toLowerCase()}`,
|
|
158
|
+
body: contributorTemplate({
|
|
159
|
+
contributor: this.contributor ? this.contributor : {},
|
|
160
|
+
idTypes: this.idTypes
|
|
161
|
+
}),
|
|
162
|
+
width: 836,
|
|
163
|
+
height: 360,
|
|
164
|
+
buttons,
|
|
165
|
+
// Focus the editor view when dialog closes
|
|
166
|
+
onClose: () => this.view.focus(),
|
|
167
|
+
// Don't restore previous active element (dialog handles focus)
|
|
168
|
+
restoreActiveElement: false
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
this.dialog.open()
|
|
172
|
+
}
|
|
173
|
+
}
|
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
import deepEqual from "fast-deep-equal"
|
|
2
|
+
|
|
3
|
+
import {randomFigureId} from "@fiduswriter/document/schema/common/index"
|
|
4
|
+
import {ContentMenu, Dialog, addAlert, dropdownSelect} from "fwtoolkit"
|
|
5
|
+
import {ImageSelectionDialog} from "../../images/selection_dialog"
|
|
6
|
+
import {E2EEEncryptor} from "../e2ee/encryptor"
|
|
7
|
+
import {configureFigureTemplate} from "./templates"
|
|
8
|
+
|
|
9
|
+
export class FigureDialog {
|
|
10
|
+
constructor(editor) {
|
|
11
|
+
this.editor = editor
|
|
12
|
+
this.imageDB = this.editor.mod.db.imageDB
|
|
13
|
+
this.userImageDB = this.editor.app.imageDB
|
|
14
|
+
this.imgId = false
|
|
15
|
+
this.imgDb = false
|
|
16
|
+
this.copyright = false
|
|
17
|
+
this.insideFigure = false
|
|
18
|
+
this.figureNode = false
|
|
19
|
+
this.contentNode = false
|
|
20
|
+
this.caption = true
|
|
21
|
+
this.category = "none"
|
|
22
|
+
this.aligned = "center"
|
|
23
|
+
this.width = "50"
|
|
24
|
+
this.equation = ""
|
|
25
|
+
this.node = false
|
|
26
|
+
this.submitMessage = gettext("Insert")
|
|
27
|
+
this.dialog = false
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
layoutMathEditor() {
|
|
31
|
+
this.dialog.dialogEl.querySelector(".inner-figure-preview").innerHTML =
|
|
32
|
+
`<div><span class="math-field" type="text" name="math" ></span></div>
|
|
33
|
+
<p class="formula-or-figure">${gettext("or")}</p>
|
|
34
|
+
<p><button type="button" id="insert-figure-image" class="fw-button fw-light">
|
|
35
|
+
${gettext("Insert image")} <i class="fa-solid fa-image"></i>
|
|
36
|
+
</button></p>`
|
|
37
|
+
|
|
38
|
+
this.mathliveDOM = this.dialog.dialogEl.querySelector(".math-field")
|
|
39
|
+
this.nonMathElements = [
|
|
40
|
+
this.dialog.dialogEl.querySelector("#insert-figure-image"),
|
|
41
|
+
this.dialog.dialogEl.querySelector(".formula-or-figure")
|
|
42
|
+
]
|
|
43
|
+
import("@fiduswriter/document/mathlive").then(MathLive => {
|
|
44
|
+
MathLive.MathfieldElement.strings = {
|
|
45
|
+
int: {
|
|
46
|
+
"keyboard.tooltip.functions": gettext("Functions"),
|
|
47
|
+
"keyboard.tooltip.greek": gettext("Greek Letters"),
|
|
48
|
+
"keyboard.tooltip.command": gettext("LaTeX Command Mode"),
|
|
49
|
+
"keyboard.tooltip.numeric": gettext("Numeric"),
|
|
50
|
+
"keyboard.tooltip.roman": gettext(
|
|
51
|
+
"Symbols and Roman Letters"
|
|
52
|
+
),
|
|
53
|
+
"tooltip.copy to clipboard": gettext("Copy to Clipboard"),
|
|
54
|
+
"tooltip.redo": gettext("Redo"),
|
|
55
|
+
"tooltip.toggle virtual keyboard": gettext(
|
|
56
|
+
"Toggle Virtual Keyboard"
|
|
57
|
+
),
|
|
58
|
+
"tooltip.undo": gettext("Undo")
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
MathLive.MathfieldElement.locale = "int"
|
|
62
|
+
MathLive.MathfieldElement.plonkSound = null
|
|
63
|
+
MathLive.MathfieldElement.keypressSound = null
|
|
64
|
+
this.mathField = new MathLive.MathfieldElement({
|
|
65
|
+
mathVirtualKeyboardPolicy: "manual"
|
|
66
|
+
})
|
|
67
|
+
this.mathField.value = this.equation
|
|
68
|
+
this.mathliveDOM.appendChild(this.mathField)
|
|
69
|
+
|
|
70
|
+
this.mathField.addEventListener("focusout", () =>
|
|
71
|
+
this.showPlaceHolder()
|
|
72
|
+
)
|
|
73
|
+
this.mathField.addEventListener("focus", () =>
|
|
74
|
+
this.hidePlaceHolder()
|
|
75
|
+
)
|
|
76
|
+
this.mathField.addEventListener("input", () => {
|
|
77
|
+
this.equation = this.mathField.getValue()
|
|
78
|
+
this.showHideNonMathElements()
|
|
79
|
+
})
|
|
80
|
+
this.mathField.select()
|
|
81
|
+
this.mathField.value = this.equation
|
|
82
|
+
|
|
83
|
+
this.showHideNonMathElements()
|
|
84
|
+
this.dialog.dialogEl
|
|
85
|
+
.querySelector("#insert-figure-image")
|
|
86
|
+
.addEventListener("click", () => this.selectImage())
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
showPlaceHolder() {
|
|
91
|
+
if (
|
|
92
|
+
!this.mathField.getValue().length &&
|
|
93
|
+
!this.mathliveDOM.querySelector(".fw-placeholder")
|
|
94
|
+
) {
|
|
95
|
+
this.mathliveDOM.insertAdjacentHTML(
|
|
96
|
+
"beforeend",
|
|
97
|
+
`<span class="fw-placeholder" >${gettext("Type formula")}</span>`
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
hidePlaceHolder() {
|
|
103
|
+
const placeHolder = this.mathliveDOM.querySelector(".fw-placeholder")
|
|
104
|
+
if (placeHolder) {
|
|
105
|
+
this.mathliveDOM.removeChild(placeHolder)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
showHideNonMathElements() {
|
|
110
|
+
if (this.equation.length) {
|
|
111
|
+
this.nonMathElements.forEach(el => (el.style.display = "none"))
|
|
112
|
+
} else {
|
|
113
|
+
this.nonMathElements.forEach(el => (el.style.display = ""))
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
selectImage() {
|
|
118
|
+
const imageSelection = new ImageSelectionDialog(
|
|
119
|
+
this.imageDB,
|
|
120
|
+
this.userImageDB,
|
|
121
|
+
this.imgId,
|
|
122
|
+
this.editor
|
|
123
|
+
)
|
|
124
|
+
imageSelection.init().then(({id, db}) => {
|
|
125
|
+
if (id) {
|
|
126
|
+
this.imgId = id
|
|
127
|
+
this.imgDb = db
|
|
128
|
+
// We take a copy of the object in case of the image coming from the user db in order
|
|
129
|
+
// not to overwrite the copyright info from the user's image db.
|
|
130
|
+
this.copyright =
|
|
131
|
+
db === "document"
|
|
132
|
+
? this.imageDB.db[this.imgId].copyright
|
|
133
|
+
: JSON.parse(
|
|
134
|
+
JSON.stringify(
|
|
135
|
+
this.userImageDB.db[this.imgId].copyright
|
|
136
|
+
)
|
|
137
|
+
)
|
|
138
|
+
this.layoutImagePreview()
|
|
139
|
+
} else {
|
|
140
|
+
this.imgId = false
|
|
141
|
+
this.imgDb = false
|
|
142
|
+
this.layoutMathEditor()
|
|
143
|
+
}
|
|
144
|
+
})
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
async layoutImagePreview() {
|
|
148
|
+
if (this.imgId) {
|
|
149
|
+
if (this.mathField) {
|
|
150
|
+
this.mathField = false
|
|
151
|
+
}
|
|
152
|
+
const db =
|
|
153
|
+
this.imgDb === "document"
|
|
154
|
+
? this.imageDB.db
|
|
155
|
+
: this.userImageDB.db
|
|
156
|
+
|
|
157
|
+
const imageEntry = db[this.imgId]
|
|
158
|
+
let imgSrc = imageEntry?.image || ""
|
|
159
|
+
|
|
160
|
+
if (imageEntry?.file_type === "application/octet-stream") {
|
|
161
|
+
const key = this.editor.e2ee?.key
|
|
162
|
+
if (key) {
|
|
163
|
+
try {
|
|
164
|
+
imgSrc = await E2EEEncryptor.decryptImageToUrl(
|
|
165
|
+
imageEntry.image,
|
|
166
|
+
key,
|
|
167
|
+
imageEntry.original_file_type || "image/png"
|
|
168
|
+
)
|
|
169
|
+
} catch (_e) {
|
|
170
|
+
imgSrc = staticUrl("img/error.avif")
|
|
171
|
+
}
|
|
172
|
+
} else {
|
|
173
|
+
imgSrc = staticUrl("img/error.avif")
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
this.dialog.dialogEl.querySelector(
|
|
178
|
+
".inner-figure-preview"
|
|
179
|
+
).innerHTML = `<img src="${imgSrc}" style="max-width: 400px;max-height:220px">
|
|
180
|
+
<span class="dot-menu-icon"><i class="fa-solid fa-ellipsis-v"></i></span>`
|
|
181
|
+
|
|
182
|
+
this.dialog.dialogEl
|
|
183
|
+
.querySelector(".dot-menu-icon")
|
|
184
|
+
.addEventListener("click", event => {
|
|
185
|
+
const contentMenu = new ContentMenu({
|
|
186
|
+
menu: this.editor.menu.imageMenuModel,
|
|
187
|
+
page: this,
|
|
188
|
+
menuPos: {X: event.pageX, Y: event.pageY}
|
|
189
|
+
})
|
|
190
|
+
contentMenu.open()
|
|
191
|
+
})
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
async submitForm() {
|
|
196
|
+
if (new RegExp(/^\s*$/).test(this.equation) && !this.imgId) {
|
|
197
|
+
// The math input is empty. Delete a math node if it exist. Then close the dialog.
|
|
198
|
+
if (this.insideFigure) {
|
|
199
|
+
const tr = this.editor.currentView.state.tr.deleteSelection()
|
|
200
|
+
this.editor.currentView.dispatch(tr)
|
|
201
|
+
}
|
|
202
|
+
this.dialog.close()
|
|
203
|
+
return false
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (this.imgDb === "user") {
|
|
207
|
+
if (this.editor.e2ee?.encrypted) {
|
|
208
|
+
// For E2EE: encrypt the user image and upload it to the document
|
|
209
|
+
const userImage = this.userImageDB.db[this.imgId]
|
|
210
|
+
try {
|
|
211
|
+
const response = await fetch(userImage.image)
|
|
212
|
+
const blob = await response.blob()
|
|
213
|
+
const file = new File(
|
|
214
|
+
[blob],
|
|
215
|
+
userImage.image.split("/").pop(),
|
|
216
|
+
{type: blob.type}
|
|
217
|
+
)
|
|
218
|
+
const encryptedFile = await E2EEEncryptor.encryptImage(
|
|
219
|
+
file,
|
|
220
|
+
this.editor.e2ee.key
|
|
221
|
+
)
|
|
222
|
+
const encryptedCopyright =
|
|
223
|
+
await E2EEEncryptor.encryptObject(
|
|
224
|
+
this.copyright,
|
|
225
|
+
this.editor.e2ee.key
|
|
226
|
+
)
|
|
227
|
+
const newId = await this.imageDB.saveImage({
|
|
228
|
+
image: encryptedFile,
|
|
229
|
+
title: userImage.title,
|
|
230
|
+
copyright: encryptedCopyright,
|
|
231
|
+
checksum: userImage.checksum,
|
|
232
|
+
original_file_type: blob.type,
|
|
233
|
+
cats: []
|
|
234
|
+
})
|
|
235
|
+
this.imgId = newId
|
|
236
|
+
this.imgDb = "document"
|
|
237
|
+
} catch (error) {
|
|
238
|
+
console.error("E2EE: Failed to encrypt user image", error)
|
|
239
|
+
addAlert("error", gettext("Could not encrypt image"))
|
|
240
|
+
return false
|
|
241
|
+
}
|
|
242
|
+
} else {
|
|
243
|
+
// Add image to document db.
|
|
244
|
+
const imageEntry = JSON.parse(
|
|
245
|
+
JSON.stringify(this.userImageDB.db[this.imgId])
|
|
246
|
+
)
|
|
247
|
+
imageEntry.copyright = this.copyright
|
|
248
|
+
this.imageDB.setImage(this.imgId, imageEntry)
|
|
249
|
+
this.imgDb = "document"
|
|
250
|
+
}
|
|
251
|
+
} else if (
|
|
252
|
+
this.imgId &&
|
|
253
|
+
this.imageDB.db[this.imgId] &&
|
|
254
|
+
!deepEqual(this.copyright, this.imageDB.db[this.imgId].copyright)
|
|
255
|
+
) {
|
|
256
|
+
const imageEntry = JSON.parse(
|
|
257
|
+
JSON.stringify(this.imageDB.db[this.imgId])
|
|
258
|
+
)
|
|
259
|
+
imageEntry.copyright = this.copyright
|
|
260
|
+
this.imageDB.setImage(this.imgId, imageEntry)
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
if (
|
|
264
|
+
this.insideFigure &&
|
|
265
|
+
this.equation ===
|
|
266
|
+
(this.node.content.content.find(
|
|
267
|
+
node => node.type.name === "figure_equation"
|
|
268
|
+
)?.attrs.equation || "") &&
|
|
269
|
+
this.imgId ===
|
|
270
|
+
(this.node.content.content.find(
|
|
271
|
+
node => node.type.name === "image"
|
|
272
|
+
)?.attrs.image || false) &&
|
|
273
|
+
this.imgDb === "document" &&
|
|
274
|
+
this.caption === this.node.attrs.caption &&
|
|
275
|
+
this.category === this.node.attrs.category &&
|
|
276
|
+
this.aligned === this.node.attrs.aligned &&
|
|
277
|
+
this.width === this.node.attrs.width
|
|
278
|
+
) {
|
|
279
|
+
// The figure has not been changed, just close the dialog
|
|
280
|
+
this.dialog.close()
|
|
281
|
+
return false
|
|
282
|
+
}
|
|
283
|
+
const content = []
|
|
284
|
+
if (this.imgId) {
|
|
285
|
+
content.push(
|
|
286
|
+
this.editor.currentView.state.schema.nodes["image"].create({
|
|
287
|
+
image: this.imgId
|
|
288
|
+
})
|
|
289
|
+
)
|
|
290
|
+
} else {
|
|
291
|
+
content.push(
|
|
292
|
+
this.editor.currentView.state.schema.nodes[
|
|
293
|
+
"figure_equation"
|
|
294
|
+
].create({
|
|
295
|
+
equation: this.equation
|
|
296
|
+
})
|
|
297
|
+
)
|
|
298
|
+
}
|
|
299
|
+
const captionNode =
|
|
300
|
+
this.node.content?.content.find(
|
|
301
|
+
node => node.type.name === "figure_caption"
|
|
302
|
+
) ||
|
|
303
|
+
this.editor.currentView.state.schema.nodes[
|
|
304
|
+
"figure_caption"
|
|
305
|
+
].create()
|
|
306
|
+
if (this.category === "table") {
|
|
307
|
+
content.unshift(captionNode)
|
|
308
|
+
} else {
|
|
309
|
+
content.push(captionNode)
|
|
310
|
+
}
|
|
311
|
+
const tr = this.editor.currentView.state.tr.replaceSelectionWith(
|
|
312
|
+
this.editor.currentView.state.schema.nodes["figure"].createAndFill(
|
|
313
|
+
{
|
|
314
|
+
aligned: this.aligned,
|
|
315
|
+
width: this.width,
|
|
316
|
+
category: this.category,
|
|
317
|
+
caption: this.caption,
|
|
318
|
+
id: this.insideFigure
|
|
319
|
+
? this.node.attrs.id
|
|
320
|
+
: randomFigureId()
|
|
321
|
+
},
|
|
322
|
+
content
|
|
323
|
+
),
|
|
324
|
+
false
|
|
325
|
+
)
|
|
326
|
+
this.editor.currentView.dispatch(tr)
|
|
327
|
+
|
|
328
|
+
this.dialog.close()
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
findFigure(state) {
|
|
332
|
+
if (
|
|
333
|
+
state.selection.node &&
|
|
334
|
+
state.selection.node.type.name == "figure"
|
|
335
|
+
) {
|
|
336
|
+
return state.selection.node
|
|
337
|
+
}
|
|
338
|
+
const $head = state.selection.$head
|
|
339
|
+
for (let d = $head.depth; d > 0; d--) {
|
|
340
|
+
if ($head.node(d).type.name == "figure") {
|
|
341
|
+
return $head.node(d)
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return false
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
init() {
|
|
348
|
+
this.node = this.findFigure(this.editor.currentView.state)
|
|
349
|
+
|
|
350
|
+
if (this.node?.attrs?.track?.find(track => track.type === "deletion")) {
|
|
351
|
+
// The figure is marked as deleted so we don't allow editing it.
|
|
352
|
+
return true
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
const buttons = []
|
|
356
|
+
|
|
357
|
+
if (this.node?.type && this.node?.type.name === "figure") {
|
|
358
|
+
this.insideFigure = true
|
|
359
|
+
this.submitMessage = gettext("Update")
|
|
360
|
+
this.equation =
|
|
361
|
+
this.node.content.content.find(
|
|
362
|
+
node => node.type.name === "figure_equation"
|
|
363
|
+
)?.attrs.equation || ""
|
|
364
|
+
this.imgId =
|
|
365
|
+
this.node.content.content.find(
|
|
366
|
+
node => node.type.name === "image"
|
|
367
|
+
)?.attrs.image || false
|
|
368
|
+
this.imgDb = "document"
|
|
369
|
+
this.category = this.node.attrs.category
|
|
370
|
+
this.caption = this.node.attrs.caption
|
|
371
|
+
this.aligned = this.node.attrs.aligned
|
|
372
|
+
this.width = this.node.attrs.width
|
|
373
|
+
buttons.push({
|
|
374
|
+
text: gettext("Remove"),
|
|
375
|
+
classes: "fw-orange",
|
|
376
|
+
click: () => {
|
|
377
|
+
const tr =
|
|
378
|
+
this.editor.currentView.state.tr.deleteSelection()
|
|
379
|
+
this.editor.currentView.dispatch(tr)
|
|
380
|
+
this.dialog.close()
|
|
381
|
+
}
|
|
382
|
+
})
|
|
383
|
+
}
|
|
384
|
+
// Image positioning both at the time of updating and inserting for the first time
|
|
385
|
+
buttons.push({
|
|
386
|
+
// Update
|
|
387
|
+
text: this.submitMessage,
|
|
388
|
+
classes: "fw-dark",
|
|
389
|
+
click: () => this.submitForm()
|
|
390
|
+
})
|
|
391
|
+
|
|
392
|
+
buttons.push({
|
|
393
|
+
type: "cancel"
|
|
394
|
+
})
|
|
395
|
+
|
|
396
|
+
this.dialog = new Dialog({
|
|
397
|
+
id: "figure-dialog",
|
|
398
|
+
title: gettext("Enter latex math or insert an image"),
|
|
399
|
+
body: configureFigureTemplate({
|
|
400
|
+
language: this.editor.view.state.doc.attrs.language
|
|
401
|
+
}),
|
|
402
|
+
buttons,
|
|
403
|
+
beforeClose: () => {
|
|
404
|
+
if (this.mathField) {
|
|
405
|
+
this.mathField = false
|
|
406
|
+
}
|
|
407
|
+
if (window.mathVirtualKeyboard) {
|
|
408
|
+
window.mathVirtualKeyboard.hide()
|
|
409
|
+
}
|
|
410
|
+
},
|
|
411
|
+
onClose: () => this.editor.currentView.focus(),
|
|
412
|
+
restoreActiveElement: false
|
|
413
|
+
})
|
|
414
|
+
|
|
415
|
+
this.dialog.open()
|
|
416
|
+
|
|
417
|
+
const alignmentSelector = dropdownSelect(
|
|
418
|
+
this.dialog.dialogEl.querySelector(".figure-alignment"),
|
|
419
|
+
{
|
|
420
|
+
onChange: newValue => {
|
|
421
|
+
this.aligned = newValue
|
|
422
|
+
},
|
|
423
|
+
width: "80%",
|
|
424
|
+
value: this.aligned
|
|
425
|
+
}
|
|
426
|
+
)
|
|
427
|
+
|
|
428
|
+
if (this.width === "100") {
|
|
429
|
+
alignmentSelector.setValue("center")
|
|
430
|
+
alignmentSelector.disable()
|
|
431
|
+
this.aligned = "center"
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
const figureWidthDOM =
|
|
435
|
+
this.dialog.dialogEl.querySelector(".figure-width")
|
|
436
|
+
figureWidthDOM.style.width = "80%"
|
|
437
|
+
figureWidthDOM.firstElementChild.innerText = `${this.width} %`
|
|
438
|
+
figureWidthDOM.addEventListener("click", event => {
|
|
439
|
+
const contentMenu = new ContentMenu({
|
|
440
|
+
menu: this.editor.menu.figureWidthMenuModel,
|
|
441
|
+
page: this,
|
|
442
|
+
menuPos: {X: event.pageX, Y: event.pageY},
|
|
443
|
+
onClose: () => {
|
|
444
|
+
if (this.width == "100") {
|
|
445
|
+
alignmentSelector.setValue("center")
|
|
446
|
+
alignmentSelector.disable()
|
|
447
|
+
this.aligned = "center"
|
|
448
|
+
} else {
|
|
449
|
+
alignmentSelector.enable()
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
})
|
|
453
|
+
contentMenu.open()
|
|
454
|
+
})
|
|
455
|
+
|
|
456
|
+
dropdownSelect(this.dialog.dialogEl.querySelector(".figure-category"), {
|
|
457
|
+
onChange: newValue => {
|
|
458
|
+
this.category = newValue
|
|
459
|
+
},
|
|
460
|
+
width: "80%",
|
|
461
|
+
value: this.category
|
|
462
|
+
})
|
|
463
|
+
|
|
464
|
+
dropdownSelect(this.dialog.dialogEl.querySelector(".figure-caption"), {
|
|
465
|
+
onChange: newValue => {
|
|
466
|
+
this.caption = newValue === "true"
|
|
467
|
+
},
|
|
468
|
+
width: "80%",
|
|
469
|
+
value: String(this.caption)
|
|
470
|
+
})
|
|
471
|
+
|
|
472
|
+
if (this.imgId && this.imageDB.db[this.imgId]) {
|
|
473
|
+
this.copyright = this.imageDB.db[this.imgId].copyright
|
|
474
|
+
this.layoutImagePreview()
|
|
475
|
+
} else {
|
|
476
|
+
this.layoutMathEditor()
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export {ContributorDialog} from "./contributor"
|
|
2
|
+
export {CitationDialog} from "./citation"
|
|
3
|
+
export {FigureDialog} from "./figure"
|
|
4
|
+
export {MathDialog} from "./math"
|
|
5
|
+
export {LanguageDialog} from "./language"
|
|
6
|
+
export {LinkDialog} from "./link"
|
|
7
|
+
export {TableDialog, TableConfigurationDialog} from "./table"
|
|
8
|
+
export {RevisionDialog} from "./revision"
|
|
9
|
+
export {OrderedListStartDialog} from "./ordered_list"
|
|
10
|
+
export {CodeBlockDialog} from "./code_block"
|