Merge pull request 'feat(#246): inline spoiler mark (blur + click-reveal, lossless Markdown)' (#259) from feat/246-spoiler into develop

Reviewed-on: #259
This commit was merged in pull request #259.
This commit is contained in:
2026-06-30 01:47:46 +03:00
19 changed files with 507 additions and 0 deletions
@@ -9,6 +9,7 @@ import {
IconStrikethrough,
IconUnderline,
IconMessage,
IconEyeOff,
} from "@tabler/icons-react";
import clsx from "clsx";
import classes from "./bubble-menu.module.css";
@@ -74,6 +75,7 @@ export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props) => {
isStrike: ctx.editor.isActive("strike"),
isCode: ctx.editor.isActive("code"),
isComment: ctx.editor.isActive("comment"),
isSpoiler: ctx.editor.isActive("spoiler"),
};
},
});
@@ -109,6 +111,12 @@ export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props) => {
command: () => props.editor.chain().focus().toggleCode().run(),
icon: IconCode,
},
{
name: "Spoiler",
isActive: () => editorState?.isSpoiler,
command: () => props.editor.chain().focus().toggleSpoiler().run(),
icon: IconEyeOff,
},
];
const commentItem: BubbleMenuItem = {
@@ -0,0 +1,20 @@
import { MarkViewContent, MarkViewProps } from "@tiptap/react";
import { useState } from "react";
// Click-to-reveal spoiler. The revealed state is UI-only and is never written to
// the document: toggling only adds/removes the `is-revealed` class (CSS removes
// the blur). renderHTML never emits `is-revealed`, so it can't leak into the
// doc/clipboard. Works the same in editor, read-only and public-share views.
export default function SpoilerView(_props: MarkViewProps) {
const [revealed, setRevealed] = useState(false);
return (
<span
className={revealed ? "spoiler is-revealed" : "spoiler"}
data-spoiler="true"
onClick={() => setRevealed((v) => !v)}
>
<MarkViewContent />
</span>
);
}