mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-05 15:00:30 +03:00
Add support for sending spoiler markdown (#267)
* Basic spoiler markdown plugin * Remove console.log statement
This commit is contained in:
parent
5f7fa0557f
commit
0e8219b200
4 changed files with 173 additions and 17 deletions
|
|
@ -3,6 +3,7 @@ import { micromark } from 'micromark';
|
|||
import { gfm, gfmHtml } from 'micromark-extension-gfm';
|
||||
import encrypt from 'browser-encrypt-attachment';
|
||||
import { getShortcodeToEmoji } from '../../app/organisms/emoji-board/custom-emoji';
|
||||
import { spoilerExtension, spoilerExtensionHtml } from '../../util/markdown';
|
||||
import cons from './cons';
|
||||
import settings from './settings';
|
||||
|
||||
|
|
@ -84,8 +85,8 @@ function getVideoThumbnail(video, width, height, mimeType) {
|
|||
|
||||
function getFormattedBody(markdown) {
|
||||
const result = micromark(markdown, {
|
||||
extensions: [gfm()],
|
||||
htmlExtensions: [gfmHtml],
|
||||
extensions: [gfm(), spoilerExtension()],
|
||||
htmlExtensions: [gfmHtml, spoilerExtensionHtml],
|
||||
});
|
||||
const bodyParts = result.match(/^(<p>)(.*)(<\/p>)$/);
|
||||
if (bodyParts === null) return result;
|
||||
|
|
@ -406,7 +407,7 @@ class RoomsInput extends EventEmitter {
|
|||
// Apply formatting if relevant
|
||||
const formattedBody = formatAndEmojifyText(
|
||||
this.matrixClient.getRoom(roomId),
|
||||
editedBody
|
||||
editedBody,
|
||||
);
|
||||
if (formattedBody !== editedBody) {
|
||||
content.formatted_body = ` * ${formattedBody}`;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue