From 8b78a95808c30987d98f470af8fba2ad91d5d3af Mon Sep 17 00:00:00 2001 From: robertu <4065233+robertu7@users.noreply.github.com> Date: Fri, 26 May 2023 13:24:53 +0800 Subject: [PATCH] fix: add Mention extension to normalizers --- package.json | 2 +- src/transformers/normalize.ts | 5 +++-- src/transformers/options.ts | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 1cef2ec3..d1e0fb2d 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/transformers/normalize.ts b/src/transformers/normalize.ts index 926d2b08..8f25aec6 100644 --- a/src/transformers/normalize.ts +++ b/src/transformers/normalize.ts @@ -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' @@ -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) } diff --git a/src/transformers/options.ts b/src/transformers/options.ts index 53f168aa..caca6164 100644 --- a/src/transformers/options.ts +++ b/src/transformers/options.ts @@ -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*'],