feat: better markdown'
This commit is contained in:
parent
69082319a0
commit
fc6e6f39e9
|
|
@ -7,7 +7,9 @@ export const HeadingComponent: FC<{
|
|||
currentValue: string;
|
||||
}> = ({ editor }) => {
|
||||
const setHeading = (level: number) => () => {
|
||||
editor?.commands?.toggleHeading({ level })
|
||||
editor?.commands?.unsetUnderline();
|
||||
editor?.commands?.unsetBold();
|
||||
editor?.commands?.toggleHeading({ level });
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import striptags from 'striptags';
|
||||
import TurndownService from 'turndown';
|
||||
const turndownService = new TurndownService();
|
||||
|
||||
const bold = {
|
||||
a: '𝗮',
|
||||
|
|
@ -137,7 +135,7 @@ export const stripHtmlValidation = (
|
|||
value: string,
|
||||
replaceBold = false,
|
||||
none = false,
|
||||
convertMentionFunction?: (idOrHandle: string, name: string) => string,
|
||||
convertMentionFunction?: (idOrHandle: string, name: string) => string
|
||||
): string => {
|
||||
if (type === 'html') {
|
||||
return striptags(value, [
|
||||
|
|
@ -154,7 +152,30 @@ export const stripHtmlValidation = (
|
|||
}
|
||||
|
||||
if (type === 'markdown') {
|
||||
return turndownService.turndown(value);
|
||||
return striptags(
|
||||
value
|
||||
.replace(/<h1>([.\s\S]*?)<\/h1>/g, (match, p1) => {
|
||||
return `<h1># ${p1}</h1>\n`;
|
||||
})
|
||||
.replace(/<h2>([.\s\S]*?)<\/h2>/g, (match, p1) => {
|
||||
return `<h2>## ${p1}</h2>\n`;
|
||||
})
|
||||
.replace(/<h3>([.\s\S]*?)<\/h3>/g, (match, p1) => {
|
||||
return `<h3>### ${p1}</h3>\n`;
|
||||
})
|
||||
.replace(/<u>([.\s\S]*?)<\/u>/g, (match, p1) => {
|
||||
return `<u>__${p1}__</u>`;
|
||||
})
|
||||
.replace(/<strong>([.\s\S]*?)<\/strong>/g, (match, p1) => {
|
||||
return `<strong>**${p1}**</strong>`;
|
||||
})
|
||||
.replace(/<li.*?>([.\s\S]*?)<\/li.*?>/gm, (match, p1) => {
|
||||
return `<li>- ${p1.replace(/\n/gm, '')}</li>`;
|
||||
})
|
||||
.replace(/<p>([.\s\S]*?)<\/p>/g, (match, p1) => {
|
||||
return `<p>${p1}</p>\n`;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
if (value.indexOf('<p>') === -1 && !none) {
|
||||
|
|
|
|||
|
|
@ -131,6 +131,7 @@ export class DiscordProvider extends SocialAbstract implements SocialProvider {
|
|||
postDetails: PostDetails[]
|
||||
): Promise<PostResponse[]> {
|
||||
let channel = postDetails[0].settings.channel;
|
||||
console.log(postDetails[0].message);
|
||||
if (postDetails.length > 1) {
|
||||
const { id: threadId } = await (
|
||||
await fetch(
|
||||
|
|
|
|||
|
|
@ -109,7 +109,6 @@
|
|||
"@types/sha256": "^0.2.2",
|
||||
"@types/stripe": "^8.0.417",
|
||||
"@types/striptags": "^0.0.5",
|
||||
"@types/turndown": "^5.0.5",
|
||||
"@types/yup": "^0.32.0",
|
||||
"@uidotdev/usehooks": "^2.4.1",
|
||||
"@uiw/react-md-editor": "^4.0.3",
|
||||
|
|
@ -213,7 +212,6 @@
|
|||
"tldts": "^6.1.47",
|
||||
"transloadit": "^3.0.2",
|
||||
"tslib": "^2.3.0",
|
||||
"turndown": "^7.2.0",
|
||||
"tweetnacl": "^1.0.3",
|
||||
"twitter-api-v2": "^1.24.0",
|
||||
"twitter-text": "^3.1.0",
|
||||
|
|
|
|||
|
|
@ -207,9 +207,6 @@ importers:
|
|||
'@types/striptags':
|
||||
specifier: ^0.0.5
|
||||
version: 0.0.5
|
||||
'@types/turndown':
|
||||
specifier: ^5.0.5
|
||||
version: 5.0.5
|
||||
'@types/yup':
|
||||
specifier: ^0.32.0
|
||||
version: 0.32.0
|
||||
|
|
@ -519,9 +516,6 @@ importers:
|
|||
tslib:
|
||||
specifier: ^2.3.0
|
||||
version: 2.8.1
|
||||
turndown:
|
||||
specifier: ^7.2.0
|
||||
version: 7.2.0
|
||||
tweetnacl:
|
||||
specifier: ^1.0.3
|
||||
version: 1.0.3
|
||||
|
|
@ -3001,9 +2995,6 @@ packages:
|
|||
'@microsoft/tsdoc@0.15.1':
|
||||
resolution: {integrity: sha512-4aErSrCR/On/e5G2hDP0wjooqDdauzEbIq8hIkIe5pXV0rtWJZvdCEKL0ykZxex+IxIwBp0eGeV48hQN07dXtw==}
|
||||
|
||||
'@mixmark-io/domino@2.2.0':
|
||||
resolution: {integrity: sha512-Y28PR25bHXUg88kCV7nivXrP2Nj2RueZ3/l/jdx6J9f8J4nsEGcgX0Qe6lt7Pa+J79+kPiJU3LguR6O/6zrLOw==}
|
||||
|
||||
'@modelcontextprotocol/sdk@1.15.0':
|
||||
resolution: {integrity: sha512-67hnl/ROKdb03Vuu0YOr+baKTvf1/5YBHBm9KnZdjdAh8hjt4FRCPD5ucwxGB237sBpzlqQsLy1PFu7z/ekZ9Q==}
|
||||
engines: {node: '>=18'}
|
||||
|
|
@ -6402,9 +6393,6 @@ packages:
|
|||
'@types/trusted-types@2.0.7':
|
||||
resolution: {integrity: sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==}
|
||||
|
||||
'@types/turndown@5.0.5':
|
||||
resolution: {integrity: sha512-TL2IgGgc7B5j78rIccBtlYAnkuv8nUQqhQc+DSYV5j9Be9XOcm/SKOVRuA47xAVI3680Tk9B1d8flK2GWT2+4w==}
|
||||
|
||||
'@types/unist@2.0.11':
|
||||
resolution: {integrity: sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA==}
|
||||
|
||||
|
|
@ -14527,9 +14515,6 @@ packages:
|
|||
tunnel-agent@0.6.0:
|
||||
resolution: {integrity: sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==}
|
||||
|
||||
turndown@7.2.0:
|
||||
resolution: {integrity: sha512-eCZGBN4nNNqM9Owkv9HAtWRYfLA4h909E/WGAWWBpmB275ehNhZyk87/Tpvjbp0jjNl9XwCsbe6bm6CqFsgD+A==}
|
||||
|
||||
tus-js-client@2.3.2:
|
||||
resolution: {integrity: sha512-5a2rm7gp+G7Z+ZB0AO4PzD/dwczB3n1fZeWO5W8AWLJ12RRk1rY4Aeb2VAYX9oKGE+/rGPrdxoFPA/vDSVKnpg==}
|
||||
|
||||
|
|
@ -18711,8 +18696,6 @@ snapshots:
|
|||
|
||||
'@microsoft/tsdoc@0.15.1': {}
|
||||
|
||||
'@mixmark-io/domino@2.2.0': {}
|
||||
|
||||
'@modelcontextprotocol/sdk@1.15.0':
|
||||
dependencies:
|
||||
ajv: 6.12.6
|
||||
|
|
@ -22973,8 +22956,6 @@ snapshots:
|
|||
|
||||
'@types/trusted-types@2.0.7': {}
|
||||
|
||||
'@types/turndown@5.0.5': {}
|
||||
|
||||
'@types/unist@2.0.11': {}
|
||||
|
||||
'@types/unist@3.0.3': {}
|
||||
|
|
@ -33677,10 +33658,6 @@ snapshots:
|
|||
dependencies:
|
||||
safe-buffer: 5.2.1
|
||||
|
||||
turndown@7.2.0:
|
||||
dependencies:
|
||||
'@mixmark-io/domino': 2.2.0
|
||||
|
||||
tus-js-client@2.3.2:
|
||||
dependencies:
|
||||
buffer-from: 1.1.2
|
||||
|
|
|
|||
Loading…
Reference in New Issue