Insert span correctly #6063
Answered
by
bdbch
AnsBdran
asked this question in
Questions & Help
Insert span correctly
#6063
-
I have created a button that inserts an HTML span like this |
Beta Was this translation helpful? Give feedback.
Answered by
bdbch
Jan 31, 2025
Replies: 1 comment 6 replies
-
<RichTextEditor.ControlsGroup>
<Menu>
<MenuTarget>
<Button size='compact-xs' variant='outline' color='gray'>
رموز مميزة
</Button>
</MenuTarget>
<MenuDropdown>
<ScrollAreaAutosize mah={400} offsetScrollbars>
{Object.keys(SPECIAL_SYMBOLS).map((symbol) => (
<MenuItem
ta='center'
ff={specialSymbolsFont.style.fontFamily}
key={symbol}
onClick={() => {
editor?.commands.insertContent(
`<span style="display: inline">${symbol}</span>`,
{
parseOptions: {
preserveWhitespace: false,
},
applyInputRules: false,
}
);
}}
>
{symbol}
</MenuItem>
))}
</ScrollAreaAutosize>
</MenuDropdown>
</Menu>
</RichTextEditor.ControlsGroup> |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@AnsBdran please don't mention people directly - Philipp is not maintaining Tiptap anymore and probably doesn't appreciate random mentions in his inbox.
The problem is propably that the span is inclusive.
https://tiptap.dev/docs/editor/core-concepts/schema#inclusive
One solution would be to insert a white space after your span (so the editor can place the cursor outside of the span) or extend the extension handling your span's and setting the
inclusive
prop tofalse
.