Skip to content

FIX: uses text selection when using hide details #33049

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 3, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
handle rich nodes
  • Loading branch information
jjaffeux committed Jun 3, 2025
commit 34697fdfceb9a7ad9d600e2d2ac779c6e65a98ea
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,22 @@ export default class ProsemirrorTextManipulation {
return;
}

const text =
head +
(sel.value?.length ? sel.value : i18n(`composer.${exampleKey}`)) +
tail;
const doc = this.convertFromMarkdown(text);
const { state } = this.view; // your EditorView instance
const { from, to, empty } = state.selection;

let text;
if (empty) {
text = i18n(`composer.${exampleKey}`);
} else {
const selectedFragment = state.doc.slice(from, to).content;
const temporaryDoc = state.schema.nodes.doc.create(
null,
selectedFragment
);
text = this.convertToMarkdown(temporaryDoc);
}

const doc = this.convertFromMarkdown(head + text + tail);

this.view.dispatch(
this.view.state.tr.replaceWith(sel.start, sel.end, doc.content.firstChild)
Expand Down
Loading