fix(editor): mention handling on post editing (#1223)

This commit is contained in:
Anthony Fu 2023-01-16 13:36:22 +01:00 committed by GitHub
parent 7389226c38
commit b049b40298
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 1 deletions

View file

@ -141,6 +141,12 @@ export function treeToText(input: Node): string {
if (['p', 'pre'].includes(input.name))
pre = '\n'
if (input.attributes?.['data-type'] === 'mention') {
const acct = input.attributes['data-id']
if (acct)
return acct.startsWith('@') ? acct : `@${acct}`
}
if (input.name === 'code') {
if (input.parent?.name === 'pre') {
const lang = input.attributes.class?.replace('language-', '')