update
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { Component } from 'react';
|
import { Component, useRef } from 'react';
|
||||||
import { Input } from 'antd';
|
import { Input } from 'antd';
|
||||||
|
import { Button, Flex } from 'antd'
|
||||||
// import Taro from "@tarojs/taro";
|
// import Taro from "@tarojs/taro";
|
||||||
// import {
|
// import {
|
||||||
// View,
|
// View,
|
||||||
@@ -37,32 +38,6 @@ import TextArea from 'antd/es/input/TextArea';
|
|||||||
|
|
||||||
// 
|
// 
|
||||||
|
|
||||||
const markTextStr = `
|
|
||||||
## 标题
|
|
||||||
> 测试引用桔子的样子
|
|
||||||
随便测试普通的文本,要不要来个\`内敛\`的字符串
|
|
||||||
---
|
|
||||||
- 无序列表1
|
|
||||||
个人有看看
|
|
||||||
- 无序列表2
|
|
||||||
- [ ] 任务列表
|
|
||||||
- [x] 完成任务
|
|
||||||
1. 测试111
|
|
||||||
恶魔女哪里的请
|
|
||||||
2. 你好啊
|
|
||||||
3. iefw4t43t43t
|
|
||||||
永远不要相信一个
|
|
||||||
---
|
|
||||||
相信我
|
|
||||||
`;
|
|
||||||
|
|
||||||
let tablecellArr = [];
|
|
||||||
let tableRowArr = [];
|
|
||||||
let maxLengthCell = null;
|
|
||||||
let bodydata = null;
|
|
||||||
let headerdata = null;
|
|
||||||
let maxWidths = null;
|
|
||||||
|
|
||||||
marked.setOptions({
|
marked.setOptions({
|
||||||
breaks: true, // 是否回车换行
|
breaks: true, // 是否回车换行
|
||||||
gfm: true, //使用经批准的 GitHub Flavored Markdown (GFM) 规范
|
gfm: true, //使用经批准的 GitHub Flavored Markdown (GFM) 规范
|
||||||
@@ -121,6 +96,7 @@ renderer.list = function (body, ordered, start) {
|
|||||||
const newArray = texts.filter((item) => item.includes(listSinbal));
|
const newArray = texts.filter((item) => item.includes(listSinbal));
|
||||||
// 0️⃣',
|
// 0️⃣',
|
||||||
const numbers = ['1️⃣', '2️⃣', '3️⃣', '4️⃣', '5️⃣', '6️⃣', '7️⃣', '8️⃣', '9️⃣', '🔟'];
|
const numbers = ['1️⃣', '2️⃣', '3️⃣', '4️⃣', '5️⃣', '6️⃣', '7️⃣', '8️⃣', '9️⃣', '🔟'];
|
||||||
|
|
||||||
const string = texts
|
const string = texts
|
||||||
.map((value, index) => {
|
.map((value, index) => {
|
||||||
// console.log("value, index==>", value, index);
|
// console.log("value, index==>", value, index);
|
||||||
@@ -173,7 +149,6 @@ renderer.hr = function () {
|
|||||||
// return '<hr>\n';
|
// return '<hr>\n';
|
||||||
// return '➖➖➖➖➖<br/>';
|
// return '➖➖➖➖➖<br/>';
|
||||||
return '➖➖➖➖➖';
|
return '➖➖➖➖➖';
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 自定义分隔线解析规则
|
// 自定义分隔线解析规则
|
||||||
@@ -253,7 +228,6 @@ renderer.link = function (href, title, text) {
|
|||||||
renderer.paragraph = function (text) {
|
renderer.paragraph = function (text) {
|
||||||
return `<p>${text}</p>\n`;
|
return `<p>${text}</p>\n`;
|
||||||
// return `<p>${text}</p>`;
|
// return `<p>${text}</p>`;
|
||||||
|
|
||||||
};
|
};
|
||||||
renderer.br = function () {
|
renderer.br = function () {
|
||||||
return '<br>';
|
return '<br>';
|
||||||
@@ -267,6 +241,7 @@ marked.use({ renderer });
|
|||||||
|
|
||||||
// export default class Index extends Component {
|
// export default class Index extends Component {
|
||||||
const Index = () => {
|
const Index = () => {
|
||||||
|
const divRef = useRef(null);
|
||||||
const [inputValue, setinputValue] = useState('');
|
const [inputValue, setinputValue] = useState('');
|
||||||
const [markText, setmarkText] = useState(``);
|
const [markText, setmarkText] = useState(``);
|
||||||
|
|
||||||
@@ -296,31 +271,58 @@ const Index = () => {
|
|||||||
|
|
||||||
useEffect(() => {}, []);
|
useEffect(() => {}, []);
|
||||||
|
|
||||||
|
const copyToClipboard = () => {
|
||||||
|
if (divRef.current) {
|
||||||
|
// const htmlContent = divRef.current.innerHTML;
|
||||||
|
// const htmlContent = divRef.current.outerHTML;
|
||||||
|
const htmlContent = divRef.current.innerText;
|
||||||
|
|
||||||
|
navigator.clipboard
|
||||||
|
.writeText(htmlContent)
|
||||||
|
.then(() => {
|
||||||
|
// alert('Content copied to clipboard!');
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error('Error copying text: ', err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="index">
|
<div className="index">
|
||||||
<div className="left">
|
<div className="up">
|
||||||
<TextArea
|
<div className="upLeft">
|
||||||
// styles="background:#fff;width:100%;min-height:80px;padding:0 30rpx;"
|
{/* <button onClick={copyToClipboard}>Copy to Clipboardl</button> */}
|
||||||
className="TextArea"
|
</div>
|
||||||
autoFocus
|
<div className="upRight">
|
||||||
allowClear
|
{/* <button onClick={copyToClipboard}>Copy to Clipboarrd</button> */}
|
||||||
onChange={onInput}
|
{/* <Button type="primary" onClick={copyToClipboard}>复制</Button> */}
|
||||||
showCount
|
<Button onClick={copyToClipboard}>复制</Button>
|
||||||
/>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="right">
|
<div className="down">
|
||||||
<div className="rightHtml" dangerouslySetInnerHTML={{ __html: marked(markText) }}></div>
|
{' '}
|
||||||
</div>
|
<div className="left">
|
||||||
|
<TextArea
|
||||||
{/* {markText ? (
|
// styles="background:#fff;width:100%;min-height:80px;padding:0 30rpx;"
|
||||||
<div
|
className="TextArea"
|
||||||
className="right"
|
autoFocus
|
||||||
dangerouslySetInnerHTML={{ __html: marked(markText) }}
|
allowClear
|
||||||
></div>
|
onChange={onInput}
|
||||||
) : null} */}
|
showCount
|
||||||
{/* <div className="origin">
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="right">
|
||||||
|
<div
|
||||||
|
className="rightHtml"
|
||||||
|
ref={divRef}
|
||||||
|
dangerouslySetInnerHTML={{ __html: marked(markText) }}
|
||||||
|
></div>
|
||||||
|
</div>
|
||||||
|
{/* <div className="origin">
|
||||||
<OriginMark markText={markText} />
|
<OriginMark markText={markText} />
|
||||||
</div> */}
|
</div> */}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user