diff --git a/main.js b/main.js index 9a87fd9..a518f7f 100644 --- a/main.js +++ b/main.js @@ -7,13 +7,16 @@ const {menuRebuild} = require('./src/comment/TopMenu.js') const { fileHelper } = require('./src/utils/File/fileHelper'); const iconName = path.join(__dirname, 'iconForDragAndDrop.png') -// electorn + const createWindow = () => { // Create the browser window. const win = new BrowserWindow({ width: 800, height: 600, webPreferences: { + nodeIntegration:true, + contextIsolation:false, + preload: path.join(__dirname, 'preload.js') } }) diff --git a/package.json b/package.json index b1e6494..29c2a23 100644 --- a/package.json +++ b/package.json @@ -53,9 +53,7 @@ "node-sass": "^7.0.3" }, "browser": { - "fs": false, - "os": false, - "path": false + "fs": false }, "browserslist": { "production": [ diff --git a/src/components/ActionPlug/index.jsx b/src/components/ActionPlug/index.jsx new file mode 100644 index 0000000..1db0d8a --- /dev/null +++ b/src/components/ActionPlug/index.jsx @@ -0,0 +1,25 @@ +import {Button} from "antd"; +import {importFile} from "../../utils/File"; +import {useLexicalComposerContext} from '@lexical/react/LexicalComposerContext'; +export default function actionPlug(){ + const [editor] = useLexicalComposerContext(); + return +} \ No newline at end of file diff --git a/src/pages/GateWay/index.jsx b/src/pages/GateWay/index.jsx index d934d95..a094360 100644 --- a/src/pages/GateWay/index.jsx +++ b/src/pages/GateWay/index.jsx @@ -20,17 +20,17 @@ const GateWay = () => { const colCount = 3; let colCode = ''; cols.push( - +
笔记
, ); cols.push( - +
TODO
, ); cols.push( - +
大乐透
, ); diff --git a/src/pages/Note/Hlexical/index.jsx b/src/pages/Note/Hlexical/index.jsx index e262c5a..f8c9ff1 100644 --- a/src/pages/Note/Hlexical/index.jsx +++ b/src/pages/Note/Hlexical/index.jsx @@ -7,6 +7,7 @@ import { AutoFocusPlugin } from "@lexical/react/LexicalAutoFocusPlugin"; import LexicalErrorBoundary from "@lexical/react/LexicalErrorBoundary"; import TreeViewPlugin from "./plugins/TreeViewPlugin"; import ToolbarPlugin from "./plugins/ToolbarPlugin"; +import {Button} from "antd"; import { HeadingNode, QuoteNode } from "@lexical/rich-text"; import { TableCellNode, TableNode, TableRowNode } from "@lexical/table"; import { ListItemNode, ListNode } from "@lexical/list"; @@ -23,6 +24,8 @@ import AutoLinkPlugin from "./plugins/AutoLinkPlugin"; import {useEffect,useState} from 'react'; import {useLexicalComposerContext} from '@lexical/react/LexicalComposerContext'; import {importFile} from "../../../utils/File" +import {CLEAR_HISTORY_COMMAND} from "lexical"; +import ActionPlugin from "../../../components/ActionPlug" function Placeholder() { return
Enter some rich text...
; } @@ -52,6 +55,7 @@ const editorConfig = { function OnChangePlugin({ onChange }) { const [editor] = useLexicalComposerContext(); + console.log('editor',editor) useEffect(() => { return editor.registerUpdateListener(({editorState}) => { onChange(editorState); @@ -68,6 +72,7 @@ export default function Hlexical() { // However, we still have a JavaScript object, so we need to convert it to an actual string with JSON.stringify setEditorState(JSON.stringify(editorStateJSON)); } + return (
@@ -82,7 +87,7 @@ export default function Hlexical() { {/*黑窗口动态记录当前操作*/} - {/**/} + {/**/} {/**/} {/**/} @@ -90,13 +95,7 @@ export default function Hlexical() { {/**/} - +
diff --git a/src/pages/Note/index.jsx b/src/pages/Note/index.jsx index e9b66a7..0248d80 100644 --- a/src/pages/Note/index.jsx +++ b/src/pages/Note/index.jsx @@ -91,58 +91,21 @@ const Note = () => { } />
-

上善若水

+

上善若水

- - - {/**/} - {/**/} - {/* : }*/} - {/* onClick={() => setCollapsed(!collapsed)}*/} - {/* style={{*/} - {/* fontSize: '16px',*/} - {/* width: 64,*/} - {/* height: 64,*/} - {/* }}*/} - {/* />*/} - {/**/} - {/**/} - {/*
*/} - {/* */} - {/*
*/} - - {/**/} - - - - {/*
*/} + + ); }; diff --git a/src/utils/File/fileHelper.js b/src/utils/File/fileHelper.js index d51e758..f057604 100644 --- a/src/utils/File/fileHelper.js +++ b/src/utils/File/fileHelper.js @@ -1,19 +1,24 @@ -const fs = require("fs") +// const fs = require("fs").promises -const fileHelper = { - readFile: (path) => { - return fs.readFile(path, { encoding: 'utf8'}) - }, - writeFile: (path, content) => { - return fs.writeFile(path, content, { encoding: 'utf8'}) - }, - renameFile: (path, newPath) => { - return fs.rename(path, newPath) - }, - deleteFile: (path) => { - return fs.unlink(path) - } -} +// const fileHelper =async (path) => { +// console.log("fileHelper-----------",fs) +// return await fs.readFile(path, {encoding: 'utf8'}) +// } -module.exports = fileHelper +// = { +// readFile: async (path) => { +// return await fs.readFile(path, {encoding: 'utf8'}) +// }, +// writeFile: (path, content) => { +// return fs.writeFile(path, content, { encoding: 'utf8'}) +// }, +// renameFile: (path, newPath) => { +// return fs.rename(path, newPath) +// }, +// deleteFile: (path) => { +// return fs.unlink(path) +// } +// } + +// module.exports = fileHelper diff --git a/src/utils/File/index.jsx b/src/utils/File/index.jsx index e4d494b..ae4375d 100644 --- a/src/utils/File/index.jsx +++ b/src/utils/File/index.jsx @@ -1,29 +1,8 @@ import {CLEAR_HISTORY_COMMAND} from 'lexical'; import {useLexicalComposerContext} from '@lexical/react/LexicalComposerContext'; -import {fileHelper} from './fileHelper' +// import fileHelper from './fileHelper' +const fs = window.require("fs").promises -export function importFile(pathName) { - readTextFileFromSystem(pathName,(text) => { - const [editor]=useLexicalComposerContext() - const json = JSON.parse(text); - const editorState = editor.parseEditorState( - JSON.stringify(json.editorState), - ); - editor.setEditorState(editorState); - editor.dispatchCommand(CLEAR_HISTORY_COMMAND, undefined); - }); -} - -async function readTextFileFromSystem(pathName, callback) { - console.log("fileHelper",fileHelper) - const files = fileHelper.readFile(pathName); - const reader = new FileReader(); - console.log('pathName',pathName) - reader.readAsText( files[0],'UTF-8'); - reader.onload = (readerEvent) => { - if (readerEvent.target) { - const content = readerEvent.target.result; - callback(content); - } - }; -} +export async function importFile(pathName) { + return await fs.readFile(pathName) +} \ No newline at end of file