diff --git a/src/renderer/App.tsx b/src/renderer/App.tsx index e89dbbe..515c358 100644 --- a/src/renderer/App.tsx +++ b/src/renderer/App.tsx @@ -1,9 +1,5 @@ -import { Component } from "react"; -import -{ Input } -from -"antd" -; +import { Component } from 'react'; +import { Input } from 'antd'; // import Taro from "@tarojs/taro"; // import { // View, @@ -14,9 +10,9 @@ from // Editor, // Textarea, // } from "@tarojs/components"; -import "./APP.scss"; +import './APP.scss'; // import { AtTabBar } from "taro-ui"; -import React, { useCallback, useEffect, useState } from "react"; +import React, { useCallback, useEffect, useState } from 'react'; // import { AtGrid } from "taro-ui"; // import { Swiper, SwiperItem } from "@tarojs/components"; // import { AtCard } from "taro-ui"; @@ -29,12 +25,12 @@ import React, { useCallback, useEffect, useState } from "react"; // import { AtModal, AtModalHeader, AtModalContent, AtModalAction } from "taro-ui"; // import { AtToast } from "taro-ui"; // import { AtIcon } from "taro-ui"; -import see from "../../images/see.png"; -import group from "../../images/group.png"; -import { marked } from "marked"; +import see from '../../images/see.png'; +import group from '../../images/group.png'; +import { marked } from 'marked'; // import _ from "lodash"; -import OriginMark from "./conpoments/OriginMark/index"; -import TextArea from "antd/es/input/TextArea"; +import OriginMark from './conpoments/OriginMark/index'; +import TextArea from 'antd/es/input/TextArea'; // marked.use(`marked-code-jsx-renderer`); // marked.use(`marked-extended-tables`); @@ -95,17 +91,15 @@ renderer.image = function (href, title, text) { return `${text}`; }; - // let listSinbal="▫️ " -let listSinbal="🔸" +let listSinbal = '🔸'; // 有序列表 renderer.list = function (body, ordered, start) { - // console.log("body,ordered, start", body, ordered, start); - const type = ordered ? "ol" : "ul"; + const type = ordered ? 'ol' : 'ul'; // console.log("type===>", type); - const startatt = ordered && start !== 1 ? ' start="' + start + '"' : ""; + const startatt = ordered && start !== 1 ? ' start="' + start + '"' : ''; // 正则取值 // const regex = /▫️\s*(.*?)/g; const regex = /([^<]*)/g; @@ -117,18 +111,18 @@ renderer.list = function (body, ordered, start) { // 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 numbers = ['1️⃣', '2️⃣', '3️⃣', '4️⃣', '5️⃣', '6️⃣', '7️⃣', '8️⃣', '9️⃣', '🔟']; const string = texts .map((value, index) => { // console.log("value, index==>", value, index); // ${ value.indexOf("▫️ ") === -1 ? '
111' : ""} return value.indexOf(listSinbal) !== -1 ? `
${ - type === "ol" ? numbers[newArray.indexOf(value)] : listSinbal - }${value.replace(listSinbal, "")}
` + type === 'ol' ? numbers[newArray.indexOf(value)] : listSinbal + }${value.replace(listSinbal, '')} ` : `
\t${value}
`; }) - .join(""); + .join(''); // return `1️⃣` // console.log("string===>", string); @@ -138,18 +132,16 @@ renderer.list = function (body, ordered, start) { // 无序列表 ▫️ renderer.listitem = function (text, task, checked) { // return `
  • ${text}
  • \n`; - return `${listSinbal}${text}
    ` + return `${listSinbal}${text}
    `; // return `➖${text}
    `; - ; - }; // 任务列表 renderer.checkbox = function (checked) { // ✅❌ - return !!checked ? "✅" : "❌"; + return !!checked ? '✅' : '❌'; return ( - "' + '' ); }; @@ -164,7 +156,7 @@ renderer.heading = function (text, level, raw) { // 分隔符 renderer.hr = function () { // return '
    \n'; - return "➖➖➖➖➖
    "; + return '➖➖➖➖➖
    '; }; // 内联样式,使用直角引号「」 @@ -176,11 +168,12 @@ renderer.codespan = function (text) { // 引用符号 renderer.blockquote = function (quote) { // console.log("quote", quote); + let content = null; var regex = /

    (.*?)<\/p>/; var str = quote; var match = regex.exec(str); if (match != null) { - let content = match[1]; // 获取第一个捕获组的内容 + content = match[1]; // 获取第一个捕获组的内容 // console.log(content); } //

    
    @@ -192,12 +185,12 @@ renderer.table = function (header, body) {
       if (body) body = `${body}`;
     
       return (
    -    "📊 表格 📊
    \n" + - "\n" + + '📊 表格 📊
    \n' + + '\n' + header + - "\n" + + '\n' + body + - "
    \n" + '\n' ); }; @@ -205,14 +198,13 @@ renderer.tablerow = function (content) { return `\n${content}\n`; }; - renderer.tablecell = function (content, flags) { - const type = flags.header ? "th" : "td"; + const type = flags.header ? 'th' : 'td'; const tag = flags.align ? `<${type} align="${flags.align}">` : `<${type}>`; return tag + `|${content}` + `\n`; }; -function cleanUrl(href:any) { +function cleanUrl(href: any) { try { href = encodeURI(href).replace(/%25/g, '%'); } catch (e) { @@ -231,7 +223,7 @@ renderer.link = function (href, title, text) { if (title) { out += ' title="' + title + '"'; } - out += ">" +`🌐`+ text + ""; + out += '>' + `🌐` + text + ''; // out += ">" +`🌐`+ text + ""+`(${href})`; return out; @@ -242,38 +234,38 @@ marked.use({ renderer }); // export default class Index extends Component { const Index = () => { + const [inputValue, setinputValue] = useState(''); const [markText, setmarkText] = useState(``); + const [oldmarkText, setoldmarkText] = useState(null); const [currentRender, setcurrentRender] = useState(null); const [markdownTable, setmarkdownTable] = useState(); const [tablecellArr, settablecellArr] = useState([]); - const onConfirm = (onConfirmtxt:any) => { - console.log("onConfirmtxt--->", onConfirmtxt.detail.value); + const onConfirm = (onConfirmtxt: any) => { + console.log('onConfirmtxt--->', onConfirmtxt.detail.value); }; - const onBlur = (onBlurtxt:any) => { - console.log("onBlurtxt--->", onBlurtxt.detail.value); + const onBlur = (onBlurtxt: any) => { + console.log('onBlurtxt--->', onBlurtxt.detail.value); if (onBlurtxt.detail.value) { setmarkText(onBlurtxt.detail.value); } }; - const onInput = (onInputtxt:any) => { - console.log("onInputtxt--->", onInputtxt); - let value=onInputtxt?.target?.innerText + const onInput = (onInputtxt: any) => { + console.log('onInputtxt--->', onInputtxt); + // console.log('inputValue',inputValue) + let value = onInputtxt?.target?.value; if (value) { setmarkText(value); } }; - - useEffect(() => {}, []); return (
    -
    -