Skip to content

Commit

Permalink
fix: add Mention extension to normalizers
Browse files Browse the repository at this point in the history
  • Loading branch information
robertu7 committed May 26, 2023
1 parent 62b5770 commit 8b78a95
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@matters/matters-editor",
"version": "0.2.0-alpha.47",
"version": "0.2.0-alpha.48",
"description": "Editor for matters.news",
"author": "https://github.com/thematters",
"homepage": "https://github.com/thematters/matters-editor",
Expand Down
5 changes: 3 additions & 2 deletions src/transformers/normalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { getSchema } from '@tiptap/core'
import { DOMParser, DOMSerializer, Node } from '@tiptap/pm/model'
import { createHTMLDocument, parseHTML, VHTMLDocument } from 'zeed-dom'
import {
Mention,
makeArticleEditorExtensions,
makeCommentEditorExtensions,
} from '../editors/extensions'
Expand All @@ -29,12 +30,12 @@ export const makeNormalizer = (extensions: Extensions) => {

export const normalizeArticleHTML = (html: string): string => {
const extensions = makeArticleEditorExtensions({})
const normalizer = makeNormalizer(extensions)
const normalizer = makeNormalizer([...extensions, Mention])
return normalizer(html)
}

export const normalizeCommentHTML = (html: string): string => {
const extensions = makeCommentEditorExtensions({})
const normalizer = makeNormalizer(extensions)
const normalizer = makeNormalizer([...extensions, Mention])
return normalizer(html)
}
2 changes: 1 addition & 1 deletion src/transformers/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const rehypeSanitizeOptions:
},
attributes: {
...defaultSchema.attributes,
a: ['href', 'ref', 'target'],
a: ['href', 'ref', 'target', 'className', 'data*'],
img: ['src', 'srcSet', 'data*'],
audio: ['controls', 'data*', ['preload', 'metadata']],
source: ['src', 'type', 'data*'],
Expand Down

0 comments on commit 8b78a95

Please sign in to comment.