Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please describe your changes
Fix issue 4327
How did you accomplish your changes
Used Tiptap method of getting text, which use renderText, instead of textContent which does not.
How have you tested your changes
Added a new example with associated spec.
How can we verify your changes
Run the test or view the example and see that there is no menu shown editor has focus.
Remarks
Note that the spec is currently not with the ui example due to cypress issue on windows. (Perhaps demos folder could go in tests ? )
If pr is approved then I will move the spec in to the demos folder.
Also the ui is in Examples - do you want in Experiments / a new Issues folder ?
Should I expose a helper - getText(node,schema,blockseparator) ?
As this change uses TipTap renderText and not ProseMirror leafText the result will differ if Node extension is provided that has added leafText with extendNodeSchema or changed the schema in onBeforeCreate.
I don't think that any public repos are doing this.
https://github.com/search?q=tiptap+leafText&type=code
Regardless, The getTextSerializersFromSchema method could be changed to invoke the spec leafText if it had been provided. This would also ensure that editor.getText, generateText and the clipboardTextSerializer can also work with leafText.
Similar issues to this one where renderText is not used ( and spec.leafText is )
Node.textContent is used in other places in Tiptap. Potentially issues there too.
Node.textBetween => Fragment.textBetween => invokes leafText and not renderText.
Should Tiptap usages of Node.textBetween be changed to use Tiptap getTextBetween ( and schema text serializers) ?
renderText and how to ensure it is used is not well documented in the docs. This is the only mention
https://tiptap.dev/api/schema
(This is not the case anymore for mention extension )
As such users expect renderText to be used when using the ProseMirror api - #4310
It is possible to add leafText to the spec so that it calls renderText although the signatures are different. ( Could use onBeforeCreate to get the editor and the doc for parent and index but impossible to get the pos argument. )
Checklist
Related issues
#4327