update
This commit is contained in:
@@ -82,12 +82,17 @@ marked.setOptions({
|
|||||||
// 🔥❓👉
|
// 🔥❓👉
|
||||||
// 0️⃣1️⃣2️⃣3️⃣4️⃣5️⃣6️⃣7️⃣8️⃣9️⃣🔟
|
// 0️⃣1️⃣2️⃣3️⃣4️⃣5️⃣6️⃣7️⃣8️⃣9️⃣🔟
|
||||||
// ©️⭐🔍〰️➖
|
// ©️⭐🔍〰️➖
|
||||||
|
|
||||||
|
// 修改 marked 的解析规则
|
||||||
|
const block = marked.Lexer.rules.block;
|
||||||
|
// block.gfm.hr = /^( *[-*_]){3,} *(?:\n+|$)/;
|
||||||
|
// 自定义水平线规则,确保它们在文档中被正确识别
|
||||||
|
block.gfm.hr =
|
||||||
|
/^ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
|
||||||
|
|
||||||
const renderer = new marked.Renderer();
|
const renderer = new marked.Renderer();
|
||||||
// const originRenderer = _.cloneDeep(renderer);
|
// const originRenderer = _.cloneDeep(renderer);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 图片调整300px
|
// 图片调整300px
|
||||||
renderer.image = function (href, title, text) {
|
renderer.image = function (href, title, text) {
|
||||||
// console.log("href, title, text", href, title, text);
|
// console.log("href, title, text", href, title, text);
|
||||||
@@ -166,19 +171,14 @@ renderer.text = function (text) {
|
|||||||
// 分隔符
|
// 分隔符
|
||||||
renderer.hr = function () {
|
renderer.hr = function () {
|
||||||
// return '<hr>\n';
|
// return '<hr>\n';
|
||||||
return '➖➖➖➖➖<br/>';
|
// return '➖➖➖➖➖<br/>';
|
||||||
|
return '➖➖➖➖➖';
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 自定义分隔线解析规则
|
// 自定义分隔线解析规则
|
||||||
// marked.Lexer.rules.block.gfm.hr = /^(\*{3,}|-{3,}|_{3,})(?:\s*)$/;
|
// marked.Lexer.rules.block.gfm.hr = /^(\*{3,}|-{3,}|_{3,})(?:\s*)$/;
|
||||||
|
// hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 内联样式,使用直角引号「」
|
// 内联样式,使用直角引号「」
|
||||||
renderer.codespan = function (text) {
|
renderer.codespan = function (text) {
|
||||||
@@ -250,19 +250,15 @@ renderer.link = function (href, title, text) {
|
|||||||
return out;
|
return out;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
renderer.paragraph = function (text) {
|
||||||
renderer.paragraph= function(text) {
|
|
||||||
return `<p>${text}</p>\n`;
|
return `<p>${text}</p>\n`;
|
||||||
}
|
};
|
||||||
renderer.br= function() {
|
renderer.br = function () {
|
||||||
return '<br>';
|
return '<br>';
|
||||||
}
|
};
|
||||||
renderer.html= function(html, block) {
|
renderer.html = function (html, block) {
|
||||||
return html;
|
return html;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 使用拓展
|
// 使用拓展
|
||||||
marked.use({ renderer });
|
marked.use({ renderer });
|
||||||
@@ -298,14 +294,11 @@ const Index = () => {
|
|||||||
|
|
||||||
useEffect(() => {}, []);
|
useEffect(() => {}, []);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="index">
|
<div className="index">
|
||||||
<div className="left">
|
<div className="left">
|
||||||
<TextArea
|
<TextArea
|
||||||
// styles="background:#fff;width:100%;min-height:80px;padding:0 30rpx;"
|
// styles="background:#fff;width:100%;min-height:80px;padding:0 30rpx;"
|
||||||
// autoHeight
|
|
||||||
className="TextArea"
|
className="TextArea"
|
||||||
autoFocus
|
autoFocus
|
||||||
allowClear
|
allowClear
|
||||||
@@ -313,15 +306,19 @@ const Index = () => {
|
|||||||
showCount
|
showCount
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{markText ? (
|
<div className="right">
|
||||||
|
<div className="rightHtml" dangerouslySetInnerHTML={{ __html: marked(markText) }}></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* {markText ? (
|
||||||
<div
|
<div
|
||||||
className="right"
|
className="right"
|
||||||
dangerouslySetInnerHTML={{ __html: marked(markText) }}
|
dangerouslySetInnerHTML={{ __html: marked(markText) }}
|
||||||
></div>
|
></div>
|
||||||
) : null}
|
) : null} */}
|
||||||
<div className="origin">
|
{/* <div className="origin">
|
||||||
<OriginMark markText={markText} />
|
<OriginMark markText={markText} />
|
||||||
</div>
|
</div> */}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
http-equiv="Content-Security-Policy"
|
http-equiv="Content-Security-Policy"
|
||||||
content="script-src 'self' 'unsafe-inline'"
|
content="script-src 'self' 'unsafe-inline'"
|
||||||
/>
|
/>
|
||||||
<title>Hello Electron React!</title>
|
<title>emoji编辑器</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
|
|||||||
Reference in New Issue
Block a user