Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2021-11-30 14:03:38 +0300
committerMax <max@nextcloud.com>2022-02-09 11:42:41 +0300
commitedfbb70f1578dad76ff869b9f2ca0f3c027232d2 (patch)
treea4458fed13123910d3ab7a5024e08edc33993f0c /src/commands
parent3c9f8e7b2c1d7019e79e855014ade08f79e86f2d (diff)
upgrade: tiptap v2
Migrate the entire editor to tiptap v2. Some changes were introduces that go beyond just using the new tiptap API: *Collaboration* Port tiptap1 collaboration. We still want to use our session and sync mechanism. *Serialization* Add Markdown extension to handle serialization. Tiptap config extensions are not automatically added to the prosemirror schema anymore. The extension adds the `toMarkdown` config value to the prosemirror schema. With the new naming scheme tiptap nodes for a number of elements do not match the prosemirror names. Camelcase the marks and nodes from `defaultMarkdownSerializer` so they match the tiptap names. *Menubar* * Specify args for isActive function directly rather than setting a function. * Make use of the editor instance inside the MenuBar component. * Use the editor rather than slots for command, focused etc. * disable icons based on editor.can * Show menubar as long as submenus are open. When opening a submenu of the menubar keep track of the open menu even for the image and the remaining action menu. Also refocus the editor whenever a submenu is closed. *MenuBubble* Let tippy handle the positioning Tippy is really good at positioning the menu bubble. Remove all our workarounds and let it do its thing. In order for this to work the content of the MenuBubble actually needs to live inside the tippy-content. Tippy bases its calculations on the width of tippy-content. So if we have the content hanging in a separate div with absolute positioning tippy-content will be 0x0 px and not represent the actual width of the menu bubble. *Upgrade image node and ImageView.* Quite a bit of the syntax changed. We now need a wrapping `<node-view-wrapper>` element. Pretty good docs at https://tiptap.dev/guide/node-views/vue#render-a-vue-component We also need to handle the async action. It will run the action on it's own. So in `clickIcon()` we need to test if the action returned anything. Tiptap v1 had inline images. v2 keeps them outside of paragraphs by default. Configure Image node to use inline images as markdownit creates inline images right now. *Trailing Node* Tiptap v2 does not ship the trailing node extension anymore. Included the one from the demos and turned it from typescript into javascript. *Tests* In order to isolate some problems tests were added. The tests in Undeline.spec.js were green right from the beginning. They are not related to the fix and only helped isolate the problem. Also introduced a cypress test for Lists that tests the editor without rendering the page and logging in. It is very fast and fairly easy to write. *Refactorings* * Split marks into separate files. Signed-off-by: Max <max@nextcloud.com>
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/listInputRule.js27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/commands/listInputRule.js b/src/commands/listInputRule.js
index 6ccf5aec9..8de74e0a2 100644
--- a/src/commands/listInputRule.js
+++ b/src/commands/listInputRule.js
@@ -20,22 +20,23 @@
*
*/
-import { InputRule, wrappingInputRule } from 'prosemirror-inputrules'
+import { InputRule, wrappingInputRule } from '@tiptap/core'
/**
- * @param {RegExp} regexp Input rule regular expression
- * @param {object} nodeType Node Type object
- * @param {undefined} getAttrs Attributes for the node
+ * Wrapping input handler that will append the content of the last match
+ *
+ * @param {RegExp} find find param for the wrapping input rule
+ * @param {object} type Node Type object
+ * @param {*} getAttributes handler to get the attributes
*/
-export default function(regexp, nodeType, getAttrs) {
- return new InputRule(regexp, (state, match, start, end) => {
- const tr = wrappingInputRule(regexp, nodeType).handler(state, match, start, end)
-
- // Insert the first character after bullet
+export default function(find, type, getAttributes) {
+ const handler = ({ state, range, match }) => {
+ const wrap = wrappingInputRule({ find, type, getAttributes })
+ wrap.handler({ state, range, match })
+ // Insert the first character after bullet if there is one
if (match.length >= 3) {
- tr.insertText(match[2])
+ state.tr.insertText(match[2])
}
-
- return tr
- })
+ }
+ return new InputRule({ find, handler })
}