diff --git a/apps/client/src/features/editor/extensions/clean-styles.ts b/apps/client/src/features/editor/extensions/clean-styles.ts new file mode 100644 index 000000000..f36e9f500 --- /dev/null +++ b/apps/client/src/features/editor/extensions/clean-styles.ts @@ -0,0 +1,20 @@ +import { Extension } from "@tiptap/core"; +import { Plugin, PluginKey } from "@tiptap/pm/state"; + +export const CleanStyles = Extension.create({ + name: "cleanStyles", + priority: 80, + + addProseMirrorPlugins() { + return [ + new Plugin({ + key: new PluginKey("cleanStyles"), + props: { + transformPastedHTML(html) { + return html.replace(/\s+style="[^"]*"/gi, ""); + }, + }, + }), + ]; + }, +}); diff --git a/apps/client/src/features/editor/extensions/extensions.ts b/apps/client/src/features/editor/extensions/extensions.ts index ef3127c65..f991b653c 100644 --- a/apps/client/src/features/editor/extensions/extensions.ts +++ b/apps/client/src/features/editor/extensions/extensions.ts @@ -112,6 +112,7 @@ import EmojiCommand from "./emoji-command"; import { countWords } from "alfaaz"; import AutoJoiner from "@/features/editor/extensions/autojoiner.ts"; import GlobalDragHandle from "@/features/editor/extensions/drag-handle.ts"; +import { CleanStyles } from "@/features/editor/extensions/clean-styles.ts"; const lowlight = createLowlight(common); lowlight.register("mermaid", plaintext); @@ -383,6 +384,7 @@ export const mainExtensions = [ MarkdownClipboard.configure({ transformPastedText: true, }), + CleanStyles, CharacterCount.configure({ wordCounter: (text) => countWords(text), }),