diff --git a/README.md b/README.md index f0cab570..093e555b 100644 --- a/README.md +++ b/README.md @@ -22,12 +22,18 @@ Supports light and dark color theme. and generate your Markdown files into onlin Freely drag to sort document elements ![](./docs/assets/drag.gif) -[//]: # (## Share) +## Share -[//]: # (bluestone provides an optional sharing function that can automatically extract Markdown files and share them to the network, or merge multiple Markdown documents into a book at the same time [more](https://pb.bluemd.me/official/book/docs/share)) +Bluestone provides non-intrusive optional sharing functions that can automatically extract Markdown files and share them to the network, +or merge multiple Markdown documents into a book at the same time. -[//]: # () -[//]: # (![](./docs/assets/share.gif)) +Due to the data interaction involved, +the network function part is not yet open source, +and the sharing function is currently only supported in the [mac store](https://apps.apple.com/us/app/bluestone-markdown/id6451391474) environment. +[more](https://pb.bluemd.me/official/book/docs/share) + + +![](./docs/assets/share.gif) ## Format @@ -47,3 +53,4 @@ currently, the editor supports the following preferences ![](./docs/assets/d5.png) + diff --git a/build/entitlements.mac.plist b/build/entitlements.mac.plist index 6bc22e91..ac19baf4 100644 --- a/build/entitlements.mac.plist +++ b/build/entitlements.mac.plist @@ -10,5 +10,9 @@ com.apple.security.cs.disable-library-validation + com.apple.security.files.user-selected.read-write + + com.apple.security.network.client + diff --git a/docs/assets/d1.png b/docs/assets/d1.png index 1bc4c350..1678820e 100644 Binary files a/docs/assets/d1.png and b/docs/assets/d1.png differ diff --git a/docs/assets/d2.png b/docs/assets/d2.png index 09fd0c0c..c362aed2 100644 Binary files a/docs/assets/d2.png and b/docs/assets/d2.png differ diff --git a/electron-builder.yml b/electron-builder.yml index c7c725df..09f8720d 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -42,7 +42,7 @@ mac: target: - target: dmg arch: - - x64 +# - x64 - arm64 linux: target: diff --git a/osx-cert.sh b/osx-cert.sh deleted file mode 100644 index 13cbbfc3..00000000 --- a/osx-cert.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env sh - -KEY_CHAIN=build.keychain -CERTIFICATE_P12=certificate.p12 -CERTIFICATE_INSTALL_P12=certificate_install.p12 -CERTIFICATE_DISTRIBUTION_P12=certificate_distribution.P12 - -# Recreate the certificate from the secure environment variable -echo $CERTIFICATE_OSX_APPLICATION | base64 --decode > $CERTIFICATE_P12 -#security import $CERTIFICATE_P12 -k /Library/Keychains/System.keychain -P $CERTIFICATE_PASSWORD -echo $CERTIFICATE_OSX_INSTALL | base64 --decode > $CERTIFICATE_INSTALL_P12 -echo $CERTIFICATE_DISTRIBUTION | base64 --decode > $CERTIFICATE_DISTRIBUTION_P12 - -#create a keychain -security create-keychain -p actions $KEY_CHAIN -# -## Make the keychain the default so identities are found -security default-keychain -s $KEY_CHAIN -# -## Unlock the keychain -security unlock-keychain -p actions $KEY_CHAIN - -security import $CERTIFICATE_P12 -k $KEY_CHAIN -P $CERTIFICATE_PASSWORD -T /usr/bin/codesign; -security import $CERTIFICATE_INSTALL_P12 -k $KEY_CHAIN -P $INSTALL_PASSWORD -T /usr/bin/codesign; -security import $CERTIFICATE_DISTRIBUTION_P12 -k $KEY_CHAIN -P $INSTALL_PASSWORD -T /usr/bin/codesign; - -security set-key-partition-list -S apple-tool:,apple: -s -k actions $KEY_CHAIN - -# mas -#echo $CERTIFICATE_OSX_INSTALL | base64 --decode > $CERTIFICATE_INSTALL_P12 -# -#security create-keychain -p actions $KEY_CHAIN -# -## Make the keychain the default so identities are found -#security default-keychain -s $KEY_CHAIN -# -## Unlock the keychain -#security unlock-keychain -p actions $KEY_CHAIN -# -#security import $CERTIFICATE_INSTALL_P12 -k $KEY_CHAIN -P $INSTALL_PASSWORD -T /usr/bin/codesign; -# -#security set-key-partition-list -S apple-tool:,apple: -s -k actions $KEY_CHAIN -# remove certs -rm -fr *.p12 diff --git a/package.json b/package.json index 1fc18520..7892c5a1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bluestone", - "version": "0.8.1", + "version": "0.8.2", "description": "", "main": "./out/main/index.js", "license": "AGPL-3.0", @@ -29,11 +29,9 @@ "electron-log": "^4.4.8", "electron-store": "^8.1.0", "electron-updater": "^5.3.0", - "form-data": "^4.0.0", "got": "^11.8.6", "mime-types": "^2.1.35", "mkdirp": "^3.0.0", - "node-fetch": "^2.6.13", "node-watch": "^0.7.4", "shiki": "^0.14.1", "upath": "^2.0.1" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bbd37fb0..cce6d159 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -23,9 +23,6 @@ dependencies: electron-updater: specifier: ^5.3.0 version: 5.3.0 - form-data: - specifier: ^4.0.0 - version: 4.0.0 got: specifier: ^11.8.6 version: 11.8.6 @@ -35,9 +32,6 @@ dependencies: mkdirp: specifier: ^3.0.0 version: 3.0.0 - node-fetch: - specifier: ^2.6.13 - version: 2.6.13 node-watch: specifier: ^0.7.4 version: 0.7.4 @@ -1650,6 +1644,7 @@ packages: /asynckit@0.4.0: resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==} + dev: true /at-least-node@1.0.0: resolution: {integrity: sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==} @@ -1928,6 +1923,7 @@ packages: engines: {node: '>= 0.8'} dependencies: delayed-stream: 1.0.0 + dev: true /commander@5.1.0: resolution: {integrity: sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==} @@ -2393,6 +2389,7 @@ packages: /delayed-stream@1.0.0: resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==} engines: {node: '>=0.4.0'} + dev: true /dequal@2.0.3: resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==} @@ -2978,6 +2975,7 @@ packages: asynckit: 0.4.0 combined-stream: 1.0.8 mime-types: 2.1.35 + dev: true /framer-motion@10.10.0(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-eCsyOcJimIRbx9KOzBTO3j9u1rF/H8/o/ybizYqdrzHkEeHx9L2NcEfGWfV0OHTc1JV17ECVzuZpomupEJ4+dw==} @@ -4208,18 +4206,6 @@ packages: dev: true optional: true - /node-fetch@2.6.13: - resolution: {integrity: sha512-StxNAxh15zr77QvvkmveSQ8uCQ4+v5FkvNTj0OESmiHu+VRi/gXArXtkWMElOsOUNLtUEvI4yS+rdtOHZTwlQA==} - engines: {node: 4.x || >=6.0.0} - peerDependencies: - encoding: ^0.1.0 - peerDependenciesMeta: - encoding: - optional: true - dependencies: - whatwg-url: 5.0.0 - dev: false - /node-releases@2.0.13: resolution: {integrity: sha512-uYr7J37ae/ORWdZeQ1xxMJe3NtdmqMC/JZK+geofDrkLUApKRHPd18/TxtBOJ4A0/+uUIliorNrfYV6s1b02eQ==} dev: true @@ -5746,10 +5732,6 @@ packages: resolution: {integrity: sha512-BiZS+C1OS8g/q2RRbJmy59xpyghNBqrr6k5L/uKBGRsTfxmu3ffiRnd8mlGPUVayg8pvfi5urfnu8TU7DVOkLQ==} dev: true - /tr46@0.0.3: - resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} - dev: false - /trough@2.1.0: resolution: {integrity: sha512-AqTiAOLcj85xS7vQ8QkAV41hPDIJ71XJB4RCUrzo/1GM2CQwhkJGaf9Hgr7BOugMRpgGUrqRg/DrBDl4H40+8g==} dev: true @@ -6011,17 +5993,6 @@ packages: resolution: {integrity: sha512-PgF341avzqyx60neE9DD+XS26MMNMoUQRz9NOZwW32nPQrF6p77f1htcnjBSEV8BGMKZ16choqUG4hyI0Hx7mA==} dev: true - /webidl-conversions@3.0.1: - resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} - dev: false - - /whatwg-url@5.0.0: - resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==} - dependencies: - tr46: 0.0.3 - webidl-conversions: 3.0.1 - dev: false - /which@2.0.2: resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} engines: {node: '>= 8'} diff --git a/src/main/api.ts b/src/main/api.ts index c0632423..8d5eb9bc 100644 --- a/src/main/api.ts +++ b/src/main/api.ts @@ -3,13 +3,12 @@ import {mkdirp} from 'mkdirp' import {is} from '@electron-toolkit/utils' import {join} from 'path' import {store} from './store' -import {createReadStream, writeFileSync} from 'fs' +import {writeFileSync} from 'fs' // import icon from '../../resources/icon.png?asset' -import FormData from "form-data" export const baseUrl = is.dev && process.env['ELECTRON_RENDERER_URL'] ? process.env['ELECTRON_RENDERER_URL'] : join(__dirname, '../renderer/index.html') const workerPath = join(__dirname, '../renderer/worker.html') import BrowserWindowConstructorOptions = Electron.BrowserWindowConstructorOptions -import fetch from 'node-fetch' +import {openAuth, listener} from './auth' export const windowOptions: BrowserWindowConstructorOptions = { show: false, @@ -40,6 +39,7 @@ export const isDark = (config?: any) => { return dark } export const registerApi = () => { + listener(store) ipcMain.on('to-worker', (e, ...args:any[]) => { const window = BrowserWindow.fromWebContents(e.sender)! window?.getBrowserView()?.webContents.send('task', ...args) @@ -50,6 +50,9 @@ export const registerApi = () => { ipcMain.handle('get-path', (e, type: Parameters[0]) => { return app.getPath(type) }) + ipcMain.on('open-auth', (e, type: 'github') => { + openAuth(type) + }) ipcMain.handle('get-env', () => { return { isPackaged: app.isPackaged, @@ -81,7 +84,6 @@ export const registerApi = () => { showCharactersCount: typeof config.showCharactersCount === 'boolean' ? config.showCharactersCount : true, mas: process.mas || false, headingMarkLine: typeof config.headingMarkLine === 'boolean' ? config.headingMarkLine : true, - token: config.token, dragToSort: typeof config.dragToSort === 'boolean' ? config.dragToSort : true } }) @@ -117,6 +119,12 @@ export const registerApi = () => { window?.webContents.send(task, ...args) }) + ipcMain.on('send-to-all', (e, task: string, ...args) => { + const windows = BrowserWindow.getAllWindows() + for (let w of windows) { + w.webContents?.send(task, ...args) + } + }) ipcMain.on('close-window', (e) => { BrowserWindow.fromWebContents(e.sender)?.close() }) @@ -144,27 +152,6 @@ export const registerApi = () => { return shell.trashItem(path) }) - ipcMain.handle('upload', (e, data: { - url: string - data: Record - }) => { - const config:any = store.get('config') || {} - const form = new FormData() - for (let [key, v] of Object.entries(data.data)) { - if (key === 'file') { - form.append('file', createReadStream(v)) - } else { - form.append(key, v) - } - } - return fetch(data.url, { - method: 'post', body: form, - headers: { - Authorization: `Bearer ${config.token}` - } - }).then(res => res.json()) - }) - ipcMain.on('print-pdf', async (e, filePath: string, rootPath?: string) => { const win = BrowserWindow.fromWebContents(e.sender) if (win) { diff --git a/src/preload/index.d.ts b/src/preload/index.d.ts index 194b1e86..dc161be1 100644 --- a/src/preload/index.d.ts +++ b/src/preload/index.d.ts @@ -13,9 +13,11 @@ declare global { electron: ElectronAPI api: { sdk: typeof Sdk, + dev: boolean toUnix: (path: string) => string md5: (str: string | Buffer) => string createHttp: (options: ExtendOptions) => Got + mimeType: (file: string) => string // checkedLatest: () => Promise copyToClipboard: (str: string) => string highlightCode(code: string, lang: string): IThemedToken[][] diff --git a/src/preload/index.ts b/src/preload/index.ts index dfea4f5b..977221b2 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -10,7 +10,7 @@ import {ExtendOptions} from 'got/dist/source/types' const langSet = new Set(BUNDLED_LANGUAGES.map(l => [l.id, ...(l.aliases || [])]).flat(2)) let highlighter:Highlighter | null = null import {toUnix} from 'upath' - +import mime from 'mime-types' let watchers = new Map() let ready:any = null const api = { @@ -27,6 +27,9 @@ const api = { toUnix(path: string) { return toUnix(path) }, + mimeType(file: string) { + return mime.lookup(file) || '' + }, fs, watch: async (path: string, cb: (event: 'add'| 'addDir' | 'change'| 'unlink'| 'unlinkDir', path: string) => void) => { if (watchers.get(path)) await watchers.get(path)!.close() diff --git a/src/renderer/src/api/main.ts b/src/renderer/src/api/main.ts index 26aeebf4..c45d3ece 100644 --- a/src/renderer/src/api/main.ts +++ b/src/renderer/src/api/main.ts @@ -45,6 +45,9 @@ export const MainApi = { sendToSelf(task: string, ...args: any[]) { ipcRenderer.send('send-to-self', task, ...args) }, + sendToAll(task: string, ...args: any[]) { + ipcRenderer.send('send-to-all', task, ...args) + }, createNewFile(options?: { defaultPath: string }) { diff --git a/src/renderer/src/components/AceCode.tsx b/src/renderer/src/components/AceCode.tsx index d8d0edf1..16a65ef0 100644 --- a/src/renderer/src/components/AceCode.tsx +++ b/src/renderer/src/components/AceCode.tsx @@ -1,5 +1,8 @@ import AceEditor from 'react-ace' - +import "ace-builds/src-noconflict/mode-json"; +import "ace-builds/src-noconflict/theme-cloud9_night"; +import "ace-builds/src-noconflict/theme-cloud9_day"; +import {configStore} from '../store/config' export function AceCode(props: { value?: string onChange?: (v: string) => void @@ -13,7 +16,7 @@ export function AceCode(props: { highlightActiveLine: false, useWorker: false }} - theme="cloud9_night" + theme={configStore.config.dark ? 'cloud9_night' : 'cloud9_day'} height={'400px'} width={'100%'} tabSize={2} diff --git a/src/renderer/src/components/Nav.tsx b/src/renderer/src/components/Nav.tsx index 164f868d..b0af7f01 100644 --- a/src/renderer/src/components/Nav.tsx +++ b/src/renderer/src/components/Nav.tsx @@ -66,7 +66,6 @@ export const Nav = observer(() => {
- {/**/}
{ className={'text-lg duration-200 dark:group-hover:text-gray-300 group-hover:text-gray-700'} />
- {/**/}
diff --git a/src/renderer/src/editor/elements/head.tsx b/src/renderer/src/editor/elements/head.tsx index 4a3952b4..98558a33 100644 --- a/src/renderer/src/editor/elements/head.tsx +++ b/src/renderer/src/editor/elements/head.tsx @@ -2,7 +2,6 @@ import {ElementProps, HeadNode} from '../../el' import {createElement, useMemo} from 'react' import {useEditorStore} from '../store' import {DragHandle} from '../tools/DragHandle' -import {configStore} from '../../store/config' const levelDragHandleTop = new Map([ [1, '.52em'], @@ -21,7 +20,7 @@ export function Head({element, attributes, children}: ElementProps) { onDragStart: store.dragStart }, ( <> - + {children} )) diff --git a/src/renderer/src/editor/elements/list.tsx b/src/renderer/src/editor/elements/list.tsx index ca7ad640..972ec3a5 100644 --- a/src/renderer/src/editor/elements/list.tsx +++ b/src/renderer/src/editor/elements/list.tsx @@ -20,9 +20,10 @@ export const List = observer(({element, attributes, children}: ElementProps {configStore.config.dragToSort && ({type: 'blockquote'}), @@ -166,11 +168,27 @@ export const htmlParser = (editor: Editor, html: string) => { const sel = editor.selection let fragment = processFragment(deserialize(parsed)) if (!fragment?.length) return + let [node] = Editor.nodes(editor, { + match: n => Element.isElement(n) + }) if (sel) { - const [node] = Editor.nodes(editor, { + if (!Range.isCollapsed(sel)) { + const back = new BackspaceKey(editor) + back.range() + const start = Range.start(sel) + Transforms.select(editor, Editor.start(editor, start.path)) + setTimeout(() => { + const node = Editor.node(editor, [0]) + if (editor.children.length > 1 && node[0].type === 'paragraph' && !Node.string(node[0])) { + Transforms.delete(editor, {at: [0]}) + } + }) + } + const [n] = Editor.nodes(editor, { match: n => Element.isElement(n) && ['code', 'table-cell', 'head', 'list-item'].includes(n.type), at: Range.isCollapsed(sel) ? sel.anchor.path : Range.start(sel).path }) + if (n) node = n if (node) { if (node[0].type === 'code') { let text = parserCodeText(parsed) @@ -206,7 +224,7 @@ export const htmlParser = (editor: Editor, html: string) => { } } } - if (inner && !parsed.querySelector('.m-list-item.task')) return false + if (inner && !['code', 'code-line', 'table-cell'].includes(node?.[0].type)) return false Transforms.insertFragment(editor, fragment) return true } diff --git a/src/renderer/src/editor/plugins/useKeyboard.ts b/src/renderer/src/editor/plugins/useKeyboard.ts index 13d2710d..ca31ba69 100644 --- a/src/renderer/src/editor/plugins/useKeyboard.ts +++ b/src/renderer/src/editor/plugins/useKeyboard.ts @@ -5,11 +5,8 @@ import {EnterKey} from './hotKeyCommands/enter' import {BackspaceKey} from './hotKeyCommands/backspace' import {MatchKey} from './hotKeyCommands/match' import {keyArrow} from './hotKeyCommands/arrow' -import {isMix} from '../output' import {EditorUtils} from '../utils/editorUtils' import isHotkey from 'is-hotkey' - -const textNodes = new Set(['table-row', 'code-line', 'paragraph', 'head']) export const useKeyboard = (editor: Editor) => { return useMemo(() => { const tab = new TabKey(editor) diff --git a/src/renderer/src/editor/tools/TableAttr.tsx b/src/renderer/src/editor/tools/TableAttr.tsx index 51641f6b..bddf7ba0 100644 --- a/src/renderer/src/editor/tools/TableAttr.tsx +++ b/src/renderer/src/editor/tools/TableAttr.tsx @@ -339,7 +339,7 @@ export const TableAttr = observer(() => { onMouseDown={e => { e.preventDefault() }} - className={`${state().visible ? '' : 'hidden'} dark:bg-zinc-900/80 bg-gray-200/70 + className={`${state().visible ? '' : 'hidden'} dark:bg-zinc-900/70 bg-white/70 border-t border-l border-r border-gray-100 dark:border-gray-100/10 text-sm absolute z-10 items-center flex justify-between dark:text-gray-300 text-gray-500 h-[24px] w-full px-2 rounded-tr rounded-tl select-none `} > @@ -385,32 +385,32 @@ export const TableAttr = observer(() => { )} trigger="click"> - +
- +
setAligns('left')} - className={`${state().align === 'left' ? 'bg-gray-600/50' : ''} t-handle`} + className={`${state().align === 'left' ? 'bg-gray-300/30 dark:bg-gray-300/10' : ''} t-handle`} >
- +
setAligns('center')} - className={`${state().align === 'center' ? 'bg-gray-600/50' : ''} t-handle`} + className={`${state().align === 'center' ? 'bg-gray-300/30 dark:bg-gray-300/10' : ''} t-handle`} >
- +
setAligns('right')} - className={`${state().align === 'right' ? 'bg-gray-600/50' : ''} t-handle`} + className={`${state().align === 'right' ? 'bg-gray-300/30 dark:bg-gray-300/10' : ''} t-handle`} >
diff --git a/src/renderer/src/editor/utils/editorUtils.ts b/src/renderer/src/editor/utils/editorUtils.ts index b2f1b12d..c94bb2a2 100644 --- a/src/renderer/src/editor/utils/editorUtils.ts +++ b/src/renderer/src/editor/utils/editorUtils.ts @@ -73,7 +73,7 @@ export class EditorUtils { mode: 'highest', reverse: true }) - if (!insertNodes) insertNodes = [{type: 'paragraph', children: [{text: ''}]}] + if (!insertNodes) insertNodes = [EditorUtils.p] for (let n of Array.from(nodes)) { Transforms.delete(editor, {at: n[1]}) } diff --git a/src/renderer/src/share b/src/renderer/src/share index 502de6af..167df658 160000 --- a/src/renderer/src/share +++ b/src/renderer/src/share @@ -1 +1 @@ -Subproject commit 502de6afa043d7d4977e441deab4c04b184fbb41 +Subproject commit 167df658e9ec5249909d63c5f0b29dc85474d988 diff --git a/src/renderer/src/store/config.ts b/src/renderer/src/store/config.ts index 452ebd9d..33d3d57b 100644 --- a/src/renderer/src/store/config.ts +++ b/src/renderer/src/store/config.ts @@ -2,9 +2,7 @@ import {action, makeAutoObservable, runInAction} from 'mobx' import {MainApi} from '../api/main' import {ipcRenderer} from 'electron' import mermaid from 'mermaid' -import {Subject} from 'rxjs' -export const login$ = new Subject() class ConfigStore { visible = false config = { @@ -20,8 +18,7 @@ class ConfigStore { locale: 'en' as 'en' | 'zh', showCharactersCount: true, mas: false, - dragToSort: true, - token: '' + dragToSort: true } locale = 'en' timer = 0 @@ -31,9 +28,6 @@ class ConfigStore { get mas() { return process.mas || false } - get isLogin() { - return !!this.config.token - } constructor() { makeAutoObservable(this, { timer: false, @@ -88,7 +82,6 @@ class ConfigStore { } setConfig(key: T, value: typeof this.config[T]) { this.config[key] = value - if (key === 'token' && value) login$.next(true) ipcRenderer.send('setStore', `config.${key}`, value) } initial() { @@ -100,7 +93,6 @@ class ConfigStore { ...this.config, ...res } - if (this.config.token) login$.next(true) localStorage.setItem('theme', this.config.dark ? 'dark' : 'light') if (this.config.dark) { mermaid.initialize({ diff --git a/src/renderer/src/store/tree.ts b/src/renderer/src/store/tree.ts index e49690b4..f69c67f9 100644 --- a/src/renderer/src/store/tree.ts +++ b/src/renderer/src/store/tree.ts @@ -34,6 +34,10 @@ export class TreeStore { fold = true watcher: Watcher externalChange$ = new Subject() + moveFile$ = new Subject<{ + from: string + to: string + }>() get files() { if (!this.root) return [] let files: IFileItem[] = [] @@ -369,6 +373,10 @@ export class TreeStore { if (this.dragNode === this.currentTab.current) { MainApi.setWin({openFile: this.dragNode.filePath}) } + this.moveFile$.next({ + from: fromPath, + to: join(toPath, basename(fromPath)) + }) } } @@ -408,6 +416,10 @@ export class TreeStore { let newPath = join(path, '..', file.filename) if (!file.folder && file.ext) newPath += `.${file.ext}` renameSync(path, newPath) + this.moveFile$.next({ + from: path, + to: newPath + }) file.mode = undefined } } diff --git a/src/renderer/src/styles/editor.scss b/src/renderer/src/styles/editor.scss index 3fd07c16..ff98303e 100644 --- a/src/renderer/src/styles/editor.scss +++ b/src/renderer/src/styles/editor.scss @@ -160,7 +160,7 @@ a { font-size: 0.9em; } .t-handle { - @apply w-5 h-5 cursor-default duration-300 hover:bg-gray-600/30 rounded-sm flex items-center justify-center; + @apply w-5 h-5 cursor-default duration-200 dark:hover:bg-gray-300/20 hover:bg-gray-300/40 rounded-sm flex items-center justify-center; } blockquote { @@ -189,25 +189,24 @@ blockquote { padding-left: 24px; padding-top: 5px; padding-bottom: 5px; + &::marker{ + @apply text-gray-500; + } li:not(.task){ - &::marker{ - @apply text-gray-500; - } >:first-child{ .drag-handle{ padding-left: 2px; padding-right: 18px; - left: -36px !important; + left: -44px !important; top: .35em !important; } } - } li.task >:nth-child(2) { .drag-handle{ padding-left: 2px; padding-right: 42px; - left: -60px !important; + left: -68px !important; top: .35em !important; } }