Compare commits
1 Commits
greenbook
...
feature/em
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c9d4450a7c |
@@ -42,18 +42,12 @@ import TextArea from 'antd/es/input/TextArea';
|
||||
|
||||
const createDecoratedTitleHTML = (text: any) => {
|
||||
const padding = 2; // 内容左右两边的空格数
|
||||
|
||||
const lineChar = '─'; // 水平线字符
|
||||
const edgeChar = '─'; // 边框装饰字符
|
||||
// const edgeChar = '━'; // 边框装饰字符
|
||||
// const cornerTopLeft = '╔';
|
||||
// const cornerTopRight = '╗';
|
||||
// const cornerBottomLeft = '╚';
|
||||
// const cornerBottomRight = '╝';
|
||||
const cornerTopLeft = '╭'; // 顶部左角
|
||||
const cornerTopRight = '╮'; // 顶部右角
|
||||
const cornerBottomLeft = '╰'; // 底部左角
|
||||
const cornerBottomRight = '╯'; // 底部右角
|
||||
const edgeChar = '━'; // 边框装饰字符
|
||||
const cornerTopLeft = '╔';
|
||||
const cornerTopRight = '╗';
|
||||
const cornerBottomLeft = '╚';
|
||||
const cornerBottomRight = '╝';
|
||||
|
||||
// 计算标题长度
|
||||
const titleLength = text.length + padding * 2;
|
||||
@@ -64,11 +58,9 @@ const createDecoratedTitleHTML = (text: any) => {
|
||||
const topBorder = `${cornerTopLeft}${edgeLength}${cornerTopRight}`;
|
||||
const bottomBorder = `${cornerBottomLeft}${edgeLength}${cornerBottomRight}`;
|
||||
const middleLine = ` 📢 ${text}`;
|
||||
// const middleLine = ` ⚡ ${text}`;
|
||||
|
||||
|
||||
return `<div>${topBorder}<br/>${middleLine}<br/>${bottomBorder}</div>`;
|
||||
// return `<div>${topBorder}<br/>${middleLine}<br/>${bottomBorder}</div><br/>`;
|
||||
// return `<div>${topBorder}\n${middleLine}\n${bottomBorder}</div>\n`;
|
||||
return `<div>${topBorder}<br/>${middleLine}<br/>${bottomBorder}</div>\n`;
|
||||
};
|
||||
|
||||
marked.setOptions({
|
||||
@@ -108,74 +100,60 @@ renderer.image = function (href, title, text) {
|
||||
return `<img width="300px" src="${href}" alt="${text}"/>`;
|
||||
};
|
||||
|
||||
// let listSinbal="▫️ "
|
||||
let listSinbal = '🔸';
|
||||
|
||||
// 有序列表
|
||||
renderer.list = function (body, ordered, start) {
|
||||
// console.log("body,ordered, start", body, ordered, start);
|
||||
const type = ordered ? 'ol' : 'ul';
|
||||
// console.log("type===>", type);
|
||||
const startatt = ordered && start !== 1 ? ' start="' + start + '"' : '';
|
||||
|
||||
// 移除 `<div>` 和 `</div>` 标签
|
||||
const cleanedBody = body.replace(/<\/?div>/g, '');
|
||||
|
||||
// 正则表达式匹配每个以 <br/> 结尾的列表项
|
||||
const regex = /([^<]*)<br\/?>/g;
|
||||
const input = cleanedBody;
|
||||
|
||||
// 正则取值
|
||||
// // const regex = /▫️\s*(.*?)<br\/?>/g;
|
||||
// const regex = /▫️\s*(.*?)<br\/?>/g;
|
||||
// const regex = /([^<]*)<br\/?>/g;
|
||||
// const input = body;
|
||||
// console.log('input--', input);
|
||||
const regex = /([^\n]*)\n/g;
|
||||
|
||||
const input = body;
|
||||
const matches = [...input.matchAll(regex)];
|
||||
console.log('matches--', matches);
|
||||
const texts = matches.map((match) => match[1]);
|
||||
console.log('texts===>', texts); // 输出: ["测试111", "测试222", "if"]
|
||||
// 不含▫️的元素数量
|
||||
// const diffcCount=texts.length-texts.filter(item => item.includes('▫️')).length;
|
||||
// console.log("texts===>", texts); // 输出: ["测试111", "测试222", "if"]
|
||||
const newArray = texts.filter((item) => item.includes(listSinbal));
|
||||
// 0️⃣',
|
||||
const numbers = ['1️⃣', '2️⃣', '3️⃣', '4️⃣', '5️⃣', '6️⃣', '7️⃣', '8️⃣', '9️⃣', '🔟'];
|
||||
// ┊ │ ╏
|
||||
|
||||
const string = texts
|
||||
.map((value, index) => {
|
||||
console.log('value--', value);
|
||||
// 判断是否是任务
|
||||
let task = false;
|
||||
if (value.includes('🔸⬜') || value.includes('🔸✅')) {
|
||||
task = true;
|
||||
}
|
||||
// console.log("value, index==>", value, index);
|
||||
// ${ value.indexOf("▫️ ") === -1 ? '<br/><span>111</sapn>' : ""}
|
||||
return value.indexOf(listSinbal) !== -1
|
||||
? `<div>${
|
||||
type === 'ol'
|
||||
? numbers[newArray.indexOf(value)]
|
||||
: task
|
||||
? ''
|
||||
: listSinbal
|
||||
type === 'ol' ? numbers[newArray.indexOf(value)] : listSinbal
|
||||
}${value.replace(listSinbal, '')} </div>`
|
||||
: `<div style="white-space:pre;">         ┊ ${value}</div>`;
|
||||
: `<div style="white-space:pre;">\t${value}</div>`;
|
||||
})
|
||||
.join('');
|
||||
// return `1️⃣`
|
||||
// console.log("string===>", string);
|
||||
|
||||
return `${string}`;
|
||||
};
|
||||
|
||||
// 示例输入
|
||||
const input = `🔸11<br/>🔸22<br/><br/>🔸33`;
|
||||
console.log(renderer.list(input, false, 1));
|
||||
|
||||
// 无序列表 ▫️
|
||||
renderer.listitem = function (text, task, checked) {
|
||||
// return `<li>${text}</li>\n`;
|
||||
return `${listSinbal}${text}<br/>`;
|
||||
// return `${listSinbal}${text}<br/>`;
|
||||
return `${listSinbal}${text}\n`;
|
||||
|
||||
// return `${listSinbal}${text}\n`;
|
||||
|
||||
// return `➖${text}<br/>`;
|
||||
};
|
||||
|
||||
// 任务列表
|
||||
renderer.checkbox = function (checked) {
|
||||
// ✅❌⬜
|
||||
return !!checked ? '✅' : '⬜';
|
||||
// ✅❌
|
||||
return !!checked ? '✅' : '❌';
|
||||
return (
|
||||
'<input ' + (checked ? 'checked="" ' : '') + 'disabled="" type="checkbox">'
|
||||
);
|
||||
@@ -190,16 +168,13 @@ renderer.heading = function (text, level, raw) {
|
||||
if (level == 1) {
|
||||
return createDecoratedTitleHTML(text);
|
||||
} else if (level == 2) {
|
||||
return `<div>📝${text}</div>\n`;
|
||||
return `<div>🔥${text}</div>\n`;
|
||||
// return `<div>🔥${text}</div><br>`;
|
||||
} else {
|
||||
return `<div>📝${text}</div>\n`;
|
||||
return `<div>🔥${text}</div>\n`;
|
||||
// return `<div>🔥${text}</div><br>`;
|
||||
}
|
||||
|
||||
return `<div>╔═━──────━═╗<br/>
|
||||
🔥 ${text}<br/>
|
||||
╚═━──────━═╝
|
||||
</div>\n`;
|
||||
|
||||
// return `<div>* * * * * * * * * * *<br/>
|
||||
// * ${text} *<br/>
|
||||
// * * * * * * * * * * *
|
||||
@@ -251,8 +226,8 @@ renderer.blockquote = function (quote) {
|
||||
//
|
||||
// return `<span style="white-space:pre;" class="blockquote">\t 👉${content}</span><br/> `
|
||||
// return `<div style="white-space:pre;" class="blockquote">\t 📌${content}</div>\n`; //ok
|
||||
// ├─⚡
|
||||
return `<div style="white-space:pre;" class="blockquote">            └─⚡${content}</div>`;
|
||||
// ├─
|
||||
return `<div style="white-space:pre;" class="blockquote">            └─📌${content}</div>`;
|
||||
};
|
||||
|
||||
renderer.table = function (header, body) {
|
||||
@@ -293,22 +268,22 @@ renderer.link = function (href, title, text) {
|
||||
return text;
|
||||
}
|
||||
href = cleanHref;
|
||||
console.log('href-', href);
|
||||
let out = '<a href="' + href + '"';
|
||||
if (title) {
|
||||
out += ' title="' + title + '"';
|
||||
}
|
||||
out += '>' + `🔗` + text + '</a>';
|
||||
// out += ">" +`🔗`+ text + "</a>"+`(${href})`;
|
||||
// console.log('out-',out)
|
||||
out += '>' + `🌐` + text + '</a>';
|
||||
// out += ">" +`🌐`+ text + "</a>"+`(${href})`;
|
||||
|
||||
return out + `: ${href}`;
|
||||
return out;
|
||||
};
|
||||
|
||||
renderer.paragraph = function (text) {
|
||||
// return `<p>${text}</p>\n`;
|
||||
// return `<p>${text}</p>`;
|
||||
return `<div>${text}</div>`;
|
||||
// return `<div>${text}</div>`;
|
||||
// return `<div>${text}</div><br>`;
|
||||
return `<div>${text}</div>\n`;
|
||||
};
|
||||
renderer.br = function () {
|
||||
return '<br>';
|
||||
@@ -357,36 +332,34 @@ const Index = () => {
|
||||
// `
|
||||
// │ 💬 随时欢迎聊天
|
||||
|
||||
// let contactMe = `<br>╭────────────────╮
|
||||
// let contactMe = `<br>╭────────────────╮
|
||||
// │ 🟩【wΞ𝗫𝗜𝗡】➡️联系我【➕🅥】
|
||||
// │
|
||||
// │ 🆔 hackrobot
|
||||
// ╰────────────────╯<br>💬 随时欢迎聊天`;
|
||||
|
||||
// let contactMe = `<br>➖➖➖➖➖<br>💬 欢迎交流<br>后台私信发送『关键词』: 加群`;
|
||||
let contactMe = `<br>➖➖➖➖➖<br>©️ 本文使用🔗『mdemoji.com』 编辑 `;
|
||||
// setmarkText(value);
|
||||
// setmarkText(value + contactMe);
|
||||
// let contactMe = `<br>\n💬 后台发送关键词: 加群`;
|
||||
let contactMe = `\n💬 后台发送关键词: 加群`;
|
||||
|
||||
if (value?.length < 10) {
|
||||
setmarkText(value);
|
||||
} else {
|
||||
setmarkText(value + contactMe);
|
||||
}
|
||||
setmarkText(value + contactMe);
|
||||
// if (value?.length < 10) {
|
||||
// setmarkText(value);
|
||||
// } else {
|
||||
// setmarkText(value + contactMe);
|
||||
// }
|
||||
};
|
||||
|
||||
useEffect(() => {}, []);
|
||||
|
||||
const copyToClipboard = () => {
|
||||
if (divRef.current) {
|
||||
const htmlContentinnerHTML = divRef.current.innerHTML;
|
||||
console.log('htmlContentinnerHTML', htmlContentinnerHTML);
|
||||
const htmlContentouterHTML = divRef.current.outerHTML;
|
||||
console.log('htmlContentouterHTML', htmlContentouterHTML);
|
||||
|
||||
// const htmlContentinnerHTML = divRef.current.innerHTML;
|
||||
// console.log('htmlContentinnerHTML', htmlContentinnerHTML);
|
||||
// const htmlContentouterHTML = divRef.current.outerHTML;
|
||||
// console.log('htmlContentouterHTML', htmlContentouterHTML);
|
||||
const htmlContent = divRef.current.innerText;
|
||||
// const htmlContent = divRef.current.outerHTML;
|
||||
// const htmlContent = divRef.current.textContent;
|
||||
|
||||
navigator.clipboard
|
||||
.writeText(htmlContent)
|
||||
.then(() => {
|
||||
|
||||
Reference in New Issue
Block a user