UX: keep content on rich editor footnote inputrule (#32296)

Instead of using the matched string, this PR uses the actual sliced
content from the ProseMirror document range as the content when creating
the footnote node.
This commit is contained in:
Renato Atilio
2025-04-14 19:36:18 -03:00
committed by GitHub
parent 79c642a446
commit c78a79bbf5

View File

@ -235,10 +235,10 @@ const extension = {
{
match: /\^\[(.*?)]$/,
handler: (state, match, start, end) => {
const footnote = state.schema.nodes.footnote.create(
null,
state.schema.nodes.paragraph.create(null, state.schema.text(match[1]))
);
const content = state.doc.slice(start + 2, end).content;
const paragraph = state.schema.nodes.paragraph.create(null, content);
const footnote = state.schema.nodes.footnote.create(null, paragraph);
return state.tr.replaceWith(start, end, footnote);
},
},