Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/admin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@waline/admin",
"version": "0.35.0",
"version": "0.36.0",
"description": "management system for waline",
"keywords": [
"comment",
Expand Down
11 changes: 11 additions & 0 deletions packages/admin/src/style/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -1053,3 +1053,14 @@ button.operate-reply {

cursor: pointer;
}

.spoiler {
cursor: help;
background-color: currentColor;
border-radius: 0.2em;
transition: background 0.5s;
}

.spoiler:focus {
background-color: #0000;
}
11 changes: 11 additions & 0 deletions packages/admin/src/style/custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,14 @@ button.operate-reply {

cursor: pointer;
}

.spoiler {
cursor: help;
background-color: currentColor;
border-radius: 0.2em;
transition: background 0.5s;

&:focus {
background-color: #0000;
}
}
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@waline/client",
"version": "3.15.2",
"version": "3.16.0",
"description": "client for waline comment system",
"keywords": [
"blog",
Expand Down
11 changes: 11 additions & 0 deletions packages/client/src/styles/highlight.scss
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,15 @@
.token.inserted {
color: #008000;
}

.spoiler {
cursor: help;
background-color: currentColor;
border-radius: 0.2em;
transition: background 0.5s;

&:focus {
background-color: #0000;
}
}
}
16 changes: 16 additions & 0 deletions packages/server/__tests__/markdown.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,22 @@ describe('markdown parser', () => {
expect(supResult).toContain('<sup>2</sup>');
});

it('should render spoilers', () => {
const result = parser('!!spoiler!!');

expect(result).toContain('<span class="spoiler" tabindex="-1">spoiler</span>');
});

it('should allow disabling spoilers', async () => {
const parserWithoutSpoiler = await getMarkdownParser({
plugin: { spoiler: false },
});
const result = parserWithoutSpoiler('!!spoiler!!');

expect(result).not.toContain('class="spoiler"');
expect(result).toContain('!!spoiler!!');
});

it('should render lists', () => {
const result = parser('- item1\n- item2\n');

Expand Down
3 changes: 2 additions & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@waline/vercel",
"version": "1.41.6",
"version": "1.42.0",
"description": "vercel server for waline comment system",
"keywords": [
"blog",
Expand Down Expand Up @@ -28,6 +28,7 @@
"@mdit/plugin-emoji": "1.2.1",
"@mdit/plugin-katex": "1.1.1",
"@mdit/plugin-mathjax": "1.2.1",
"@mdit/plugin-spoiler": "2.1.2",
"@mdit/plugin-sub": "1.1.1",
"@mdit/plugin-sup": "1.1.1",
"akismet": "^2.0.7",
Expand Down
8 changes: 7 additions & 1 deletion packages/server/src/service/markdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const getMarkdownParser = async (markdown = {}) => {
html: true,
});

const { emoji, tex, mathjax, katex, sub, sup } = plugin;
const { emoji, tex, mathjax, katex, sub, sup, spoiler } = plugin;

// parse emoji
if (emoji !== false) {
Expand All @@ -45,6 +45,12 @@ const getMarkdownParser = async (markdown = {}) => {
markdownIt.use(sup);
}

// parse spoiler
if (spoiler !== false) {
const { spoiler: spoilerPlugin } = await import('@mdit/plugin-spoiler');
markdownIt.use(spoilerPlugin, typeof spoiler === 'object' ? spoiler : {});
}

// parse tex
if (tex === 'katex') {
const { katex: katexPlugin } = await import('@mdit/plugin-katex');
Expand Down
22 changes: 3 additions & 19 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading