-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): take atom content entirely (#5321)
- Loading branch information
1 parent
b47df57
commit 4cca382
Showing
3 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@tiptap/core": patch | ||
--- | ||
|
||
Make sure that atoms are used in-full without cutting the content. Node size for atoms is 1 which causes text to be cut unexpectedly. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
tests/cypress/integration/core/getTextContentFromNodes.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/// <reference types="cypress" /> | ||
|
||
import { | ||
getSchemaByResolvedExtensions, getTextContentFromNodes, | ||
} from '@tiptap/core' | ||
import Document from '@tiptap/extension-document' | ||
import Mention from '@tiptap/extension-mention' | ||
import Paragraph from '@tiptap/extension-paragraph' | ||
import Text from '@tiptap/extension-text' | ||
import { Node } from '@tiptap/pm/model' | ||
|
||
describe(getTextContentFromNodes.name, () => { | ||
it('gets text', () => { | ||
const schema = getSchemaByResolvedExtensions([ | ||
Document, | ||
Paragraph, | ||
Text, | ||
Mention.configure({ renderText: ({ node }) => `@${node.attrs.label ?? 'Unknown'}` }), | ||
]) | ||
|
||
const doc = Node.fromJSON(schema, { | ||
type: 'doc', | ||
content: [ | ||
{ | ||
type: 'paragraph', | ||
content: [ | ||
{ type: 'text', text: 'Start ' }, | ||
{ type: 'mention', attrs: { id: 1, label: 'Mention' } }, | ||
{ type: 'text', text: ' End' }, | ||
], | ||
}, | ||
], | ||
}) | ||
|
||
const pos = doc.resolve(12) | ||
|
||
const text = getTextContentFromNodes(pos) | ||
|
||
expect(text).to.eq('Start @Mention End') | ||
}) | ||
}) |