From 8a73b6f5b3e252fedb41904366209ba8ae1c682d Mon Sep 17 00:00:00 2001 From: 1708-huayu <57060237+1708-huayu@users.noreply.github.com> Date: Sun, 29 Sep 2024 16:38:59 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E6=96=87=E4=BB=B6=E5=A4=B9?= =?UTF-8?q?=E4=B8=AD=E6=89=93=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.js | 8 +- src/pages/Note/Hlexical/index.jsx | 1 + src/pages/Note/Hlexical/index.less | 376 +---------------------------- src/pages/Note/Hlexical/theme.less | 371 ++++++++++++++++++++++++++++ src/utils/File/index.jsx | 4 +- 5 files changed, 384 insertions(+), 376 deletions(-) create mode 100644 src/pages/Note/Hlexical/theme.less diff --git a/main.js b/main.js index 84616d4..792d715 100644 --- a/main.js +++ b/main.js @@ -1,4 +1,4 @@ -const {app, Menu, BrowserWindow,ipcMain,dialog} = require('electron') +const {app, Menu, BrowserWindow,ipcMain,dialog,shell } = require('electron') const path = require('path') const {menuRebuild} = require('./elsrc/TopMenu.js') const UploadUtils = require("./elsrc/sync/tencent/UploadUtils") @@ -93,6 +93,12 @@ app.whenReady().then(() => { console.log("electronStoreDelete") return store.delete(args) }) + ipcMain.handle("showOpenDialog",(listen,args)=>{ + console.log("showOpenDialog:"+args) + // return dialog.showOpenDialog({defaultPath:args.filePath, + // properties: ['openFile']} ) + return shell.openPath(args) + }) console.log("配置文件地址",app.getPath('userData')+"/config.json") console.log("操作系统:"+process.platform) }) diff --git a/src/pages/Note/Hlexical/index.jsx b/src/pages/Note/Hlexical/index.jsx index 73b6b7b..f084b70 100644 --- a/src/pages/Note/Hlexical/index.jsx +++ b/src/pages/Note/Hlexical/index.jsx @@ -11,6 +11,7 @@ import { TRANSFORMERS, $convertFromMarkdownString, } from "@lexical/markdown"; import "@/pages/Note/Hlexical/index.less" +import "@/pages/Note/Hlexical/theme.less" import {importFile} from "@/utils/File" import {isEmpty} from "@/utils/ObjectUtils"; diff --git a/src/pages/Note/Hlexical/index.less b/src/pages/Note/Hlexical/index.less index 1a4ceb9..b8a75f5 100644 --- a/src/pages/Note/Hlexical/index.less +++ b/src/pages/Note/Hlexical/index.less @@ -64,7 +64,8 @@ h1 { .editor-inner { background: #fff; position: relative; - height: 95%; + margin:20px; + height: 90%; overflow: hidden auto; } @@ -93,38 +94,6 @@ h1 { pointer-events: none; } -.editor-text-bold { - font-weight: bold; -} - -.editor-text-italic { - font-style: italic; -} - -.editor-text-underline { - text-decoration: underline; -} - -.editor-text-strikethrough { - text-decoration: line-through; -} - -.editor-text-underlineStrikethrough { - text-decoration: underline line-through; -} - -.editor-text-code { - background-color: rgb(240, 242, 245); - padding: 1px 0.25rem; - font-family: Menlo, Consolas, Monaco, monospace; - font-size: 94%; -} - -.editor-link { - color: rgb(33, 111, 219); - text-decoration: none; -} - .tree-view-output { display: block; background: #222; @@ -141,177 +110,6 @@ h1 { line-height: 14px; } -.editor-code { - background-color: rgb(240, 242, 245); - font-family: Menlo, Consolas, Monaco, monospace; - display: block; - padding: 8px 8px 8px 52px; - line-height: 1.53; - font-size: 13px; - margin: 0; - margin-top: 8px; - margin-bottom: 8px; - tab-size: 2; - white-space: pre; - overflow: auto; - position: relative; -} - -.editor-code:before { - content: attr(data-gutter); - position: absolute; - background-color: #eee; - left: 0; - top: 0; - border-right: 1px solid #ccc; - padding: 8px; - color: #777; - white-space: pre-wrap; - text-align: right; - min-width: 25px; -} - -.editor-code:after { - content: attr(data-highlight-language); - top: 0; - right: 3px; - padding: 3px; - font-size: 10px; - text-transform: uppercase; - position: absolute; - color: rgba(0, 0, 0, 0.5); -} - -.editor-tokenComment { - color: slategray; -} - -.editor-tokenPunctuation { - color: #999; -} - -.editor-tokenProperty { - color: #905; -} - -.editor-tokenSelector { - color: #690; -} - -.editor-tokenOperator { - color: #9a6e3a; -} - -.editor-tokenAttr { - color: #07a; -} - -.editor-tokenVariable { - color: #e90; -} - -.editor-tokenFunction { - color: #dd4a68; -} - -.editor-paragraph { - margin: 0; - margin-bottom: 8px; - position: relative; -} - -.editor-paragraph:last-child { - margin-bottom: 0; -} - -.editor-heading-h1 { - font-size: 50px; - color: rgb(5, 5, 5); - font-weight: 400; - margin: 0; - margin-bottom: 25px; - padding: 0; -} - -.editor-heading-h2 { - font-size: 45px; - //color: rgb(101, 103, 107); - //font-weight: 400; - color: rgb(5, 5, 5); - font-weight: 400; - margin: 0; - margin-top: 25px; - padding: 0; - //text-transform: uppercase; -} -.editor-heading-h3 { - font-size: 40px; - color: rgb(5, 5, 5); - font-weight: 400; - margin: 0; - margin-top: 20px; - padding: 0; - //text-transform: uppercase; -} -.editor-heading-h4 { - font-size: 35px; - color: rgb(5, 5, 5); - font-weight: 400; - margin: 0; - margin-top: 20px; - padding: 0; - //text-transform: uppercase; -} -.editor-heading-h5 { - font-size: 30px; - color: rgb(5, 5, 5); - font-weight: 400; - margin: 0; - margin-top: 15px; - padding: 0; - //text-transform: uppercase; -} -.editor-heading-h6 { - font-size: 25px; - color: rgb(5, 5, 5); - font-weight: 400; - margin: 0; - margin-top: 15px; - padding: 0; - //text-transform: uppercase; -} - -.editor-quote { - margin: 0; - margin-left: 20px; - font-size: 15px; - color: rgb(101, 103, 107); - border-left-color: rgb(206, 208, 212); - border-left-width: 4px; - border-left-style: solid; - padding-left: 16px; -} - -.editor-list-ol { - padding: 0; - margin: 0; - margin-left: 16px; -} - -.editor-list-ul { - padding: 0; - margin: 0; - margin-left: 16px; -} - -.editor-listitem { - margin: 8px 32px 8px 32px; -} - -.editor-nested-listitem { - list-style-type: none; -} - pre::-webkit-scrollbar { background: transparent; width: 10px; @@ -814,143 +612,6 @@ i.justify-align { background-image: url(images/icons/justify.svg); } -.editor-table { - border-collapse: collapse; - border-spacing: 0; - overflow-y: scroll; - overflow-x: scroll; - table-layout: fixed; - width: max-content; - margin: 30px 0; -} - -.editor-tableSelection *::selection { - background-color: transparent; -} - -.editor-tableSelected { - outline: 2px solid rgb(60, 132, 244); -} - -.editor-tableCell { - border: 1px solid #bbb; - width: 75px; - min-width: 75px; - vertical-align: top; - text-align: start; - padding: 6px 8px; - position: relative; - outline: none; -} - -.editor-tableCellSortedIndicator { - display: block; - opacity: 0.5; - position: absolute; - bottom: 0; - left: 0; - width: 100%; - height: 4px; - background-color: #999; -} - -.editor-tableCellResizer { - position: absolute; - right: -4px; - height: 100%; - width: 8px; - cursor: ew-resize; - z-index: 10; - top: 0; -} - -.editor-tableCellHeader { - background-color: #f2f3f5; - text-align: start; -} - -.editor-tableCellSelected { - background-color: #c9dbf0; -} - -.editor-tableCellPrimarySelected { - border: 2px solid rgb(60, 132, 244); - display: block; - height: calc(100% - 2px); - position: absolute; - width: calc(100% - 2px); - left: -1px; - top: -1px; - z-index: 2; -} - -.editor-tableCellEditing { - box-shadow: 0 0 5px rgba(0, 0, 0, 0.4); - border-radius: 3px; -} - -.editor-tableAddColumns { - position: absolute; - top: 0; - width: 20px; - background-color: #eee; - height: 100%; - right: -25px; - animation: table-controls 0.2s ease; - border: 0; - cursor: pointer; -} - -.editor-tableAddColumns:after { - background-image: url(images/icons/plus.svg); - background-size: contain; - background-position: center; - background-repeat: no-repeat; - display: block; - content: ' '; - position: absolute; - top: 0; - left: 0; - width: 100%; - height: 100%; - opacity: 0.4; -} - -.editor-tableAddColumns:hover { - background-color: #c9dbf0; -} - -.editor-tableAddRows { - position: absolute; - bottom: -25px; - width: calc(100% - 25px); - background-color: #eee; - height: 20px; - left: 0; - animation: table-controls 0.2s ease; - border: 0; - cursor: pointer; -} - -.editor-tableAddRows:after { - background-image: url(images/icons/plus.svg); - background-size: contain; - background-position: center; - background-repeat: no-repeat; - display: block; - content: ' '; - position: absolute; - top: 0; - left: 0; - width: 100%; - height: 100%; - opacity: 0.4; -} - -.editor-tableAddRows:hover { - background-color: #c9dbf0; -} - @keyframes table-controls { 0% { opacity: 0; @@ -960,37 +621,4 @@ i.justify-align { } } -.editor-tableCellResizeRuler { - display: block; - position: absolute; - width: 1px; - background-color: rgb(60, 132, 244); - height: 100%; - top: 0; -} - -.editor-tableCellActionButtonContainer { - display: block; - right: 5px; - top: 6px; - position: absolute; - z-index: 4; - width: 20px; - height: 20px; -} - -.editor-tableCellActionButton { - background-color: #eee; - display: block; - border: 0; - border-radius: 20px; - width: 20px; - height: 20px; - color: #222; - cursor: pointer; -} - -.editor-tableCellActionButton:hover { - background-color: #ddd; -} diff --git a/src/pages/Note/Hlexical/theme.less b/src/pages/Note/Hlexical/theme.less new file mode 100644 index 0000000..99a6326 --- /dev/null +++ b/src/pages/Note/Hlexical/theme.less @@ -0,0 +1,371 @@ +.editor-text-bold { + font-weight: bold; +} + +.editor-text-italic { + font-style: italic; +} + +.editor-text-underline { + text-decoration: underline; +} + +.editor-text-strikethrough { + text-decoration: line-through; +} + +.editor-text-underlineStrikethrough { + text-decoration: underline line-through; +} + +.editor-text-code { + background-color: rgb(240, 242, 245); + padding: 1px 0.25rem; + font-family: Menlo, Consolas, Monaco, monospace; + font-size: 94%; +} + +.editor-link { + color: rgb(33, 111, 219); + text-decoration: none; +} + +.editor-code { + background-color: rgb(240, 242, 245); + font-family: Menlo, Consolas, Monaco, monospace; + display: block; + padding: 8px 8px 8px 52px; + line-height: 1.53; + font-size: 13px; + margin: 0; + margin-top: 8px; + margin-bottom: 8px; + tab-size: 2; + white-space: pre; + overflow: auto; + position: relative; +} + +.editor-code:before { + content: attr(data-gutter); + position: absolute; + background-color: #eee; + left: 0; + top: 0; + border-right: 1px solid #ccc; + padding: 8px; + color: #777; + white-space: pre-wrap; + text-align: right; + min-width: 25px; +} + +.editor-code:after { + content: attr(data-highlight-language); + top: 0; + right: 3px; + padding: 3px; + font-size: 10px; + text-transform: uppercase; + position: absolute; + color: rgba(0, 0, 0, 0.5); +} + +.editor-tokenComment { + color: slategray; +} + +.editor-tokenPunctuation { + color: #999; +} + +.editor-tokenProperty { + color: #905; +} + +.editor-tokenSelector { + color: #690; +} + +.editor-tokenOperator { + color: #9a6e3a; +} + +.editor-tokenAttr { + color: #07a; +} + +.editor-tokenVariable { + color: #e90; +} + +.editor-tokenFunction { + color: #dd4a68; +} + +.editor-paragraph { + margin: 0; + margin-bottom: 8px; + position: relative; +} + +.editor-paragraph:last-child { + margin-bottom: 0; +} + +.editor-heading-h1 { + //font-size: 50px; + //color: rgb(5, 5, 5); + //font-weight: 400; + //margin: 0; + //margin-bottom: 25px; + //padding: 0; +} + +.editor-heading-h2 { + //font-size: 45px; + //color: rgb(101, 103, 107); + //font-weight: 400; + //color: rgb(5, 5, 5); + //font-weight: 400; + //margin: 0; + //margin-top: 25px; + //padding: 0; + //text-transform: uppercase; +} +.editor-heading-h3 { + //font-size: 40px; + //color: rgb(5, 5, 5); + //font-weight: 400; + //margin: 0; + //margin-top: 20px; + //padding: 0; + //text-transform: uppercase; +} +.editor-heading-h4 { + //font-size: 35px; + //color: rgb(5, 5, 5); + //font-weight: 400; + //margin: 0; + //margin-top: 20px; + //padding: 0; + //text-transform: uppercase; +} +.editor-heading-h5 { + //font-size: 30px; + //color: rgb(5, 5, 5); + //font-weight: 400; + //margin: 0; + //margin-top: 15px; + //padding: 0; + //text-transform: uppercase; +} +.editor-heading-h6 { + //font-size: 25px; + //color: rgb(5, 5, 5); + //font-weight: 400; + //margin: 0; + //margin-top: 15px; + //padding: 0; + //text-transform: uppercase; +} + +.editor-quote { + margin: 0; + margin-left: 20px; + font-size: 15px; + color: rgb(101, 103, 107); + border-left-color: rgb(206, 208, 212); + border-left-width: 4px; + border-left-style: solid; + padding-left: 16px; +} + +.editor-list-ol { + padding: 0; + margin: 0; + margin-left: 16px; +} + +.editor-list-ul { + padding: 0; + margin: 0; + margin-left: 16px; +} + +.editor-listitem { + margin: 8px 32px 8px 32px; +} + +.editor-nested-listitem { + list-style-type: none; +} +.editor-table { + border-collapse: collapse; + border-spacing: 0; + overflow-y: scroll; + overflow-x: scroll; + table-layout: fixed; + width: max-content; + margin: 30px 0; +} + +.editor-tableSelection *::selection { + background-color: transparent; +} + +.editor-tableSelected { + outline: 2px solid rgb(60, 132, 244); +} + +.editor-tableCell { + border: 1px solid #bbb; + width: 75px; + min-width: 75px; + vertical-align: top; + text-align: start; + padding: 6px 8px; + position: relative; + outline: none; +} + +.editor-tableCellSortedIndicator { + display: block; + opacity: 0.5; + position: absolute; + bottom: 0; + left: 0; + width: 100%; + height: 4px; + background-color: #999; +} + +.editor-tableCellResizer { + position: absolute; + right: -4px; + height: 100%; + width: 8px; + cursor: ew-resize; + z-index: 10; + top: 0; +} + +.editor-tableCellHeader { + background-color: #f2f3f5; + text-align: start; +} + +.editor-tableCellSelected { + background-color: #c9dbf0; +} + +.editor-tableCellPrimarySelected { + border: 2px solid rgb(60, 132, 244); + display: block; + height: calc(100% - 2px); + position: absolute; + width: calc(100% - 2px); + left: -1px; + top: -1px; + z-index: 2; +} + +.editor-tableCellEditing { + box-shadow: 0 0 5px rgba(0, 0, 0, 0.4); + border-radius: 3px; +} + +.editor-tableAddColumns { + position: absolute; + top: 0; + width: 20px; + background-color: #eee; + height: 100%; + right: -25px; + animation: table-controls 0.2s ease; + border: 0; + cursor: pointer; +} + +.editor-tableAddColumns:after { + background-image: url(images/icons/plus.svg); + background-size: contain; + background-position: center; + background-repeat: no-repeat; + display: block; + content: ' '; + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + opacity: 0.4; +} + +.editor-tableAddColumns:hover { + background-color: #c9dbf0; +} + +.editor-tableAddRows { + position: absolute; + bottom: -25px; + width: calc(100% - 25px); + background-color: #eee; + height: 20px; + left: 0; + animation: table-controls 0.2s ease; + border: 0; + cursor: pointer; +} + +.editor-tableAddRows:after { + background-image: url(images/icons/plus.svg); + background-size: contain; + background-position: center; + background-repeat: no-repeat; + display: block; + content: ' '; + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + opacity: 0.4; +} + +.editor-tableAddRows:hover { + background-color: #c9dbf0; +} +.editor-tableCellResizeRuler { + display: block; + position: absolute; + width: 1px; + background-color: rgb(60, 132, 244); + height: 100%; + top: 0; +} + +.editor-tableCellActionButtonContainer { + display: block; + right: 5px; + top: 6px; + position: absolute; + z-index: 4; + width: 20px; + height: 20px; +} + +.editor-tableCellActionButton { + background-color: #eee; + display: block; + border: 0; + border-radius: 20px; + width: 20px; + height: 20px; + color: #222; + cursor: pointer; +} + +.editor-tableCellActionButton:hover { + background-color: #ddd; +} \ No newline at end of file diff --git a/src/utils/File/index.jsx b/src/utils/File/index.jsx index e29c885..55e0842 100644 --- a/src/utils/File/index.jsx +++ b/src/utils/File/index.jsx @@ -54,5 +54,7 @@ export async function saveFileWithName(){ } export async function openInDir(filePath){ - return dialog.showOpenDialog({defaultPath:"filePath",properties: ['openDirectory']} ) + // return dialog.showOpenDialog({defaultPath:filePath,properties: ['openDirectory']} ) + console.log("pathOp.dirname(filePath.filePath)"+pathOp.dirname(filePath.filePath)) + return ipcRenderer.invoke("showOpenDialog",pathOp.dirname(filePath.filePath)) } \ No newline at end of file