Skip to content

Commit

Permalink
feat: publish 0.8.2
Browse files Browse the repository at this point in the history
fix: html paste bug
fix: task list insert new line format bug
perf: Interface and interaction
  • Loading branch information
1943time committed Sep 8, 2023
1 parent 6974834 commit 52902ec
Show file tree
Hide file tree
Showing 26 changed files with 119 additions and 160 deletions.
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -47,3 +53,4 @@ currently, the editor supports the following preferences

![](./docs/assets/d5.png)


4 changes: 4 additions & 0 deletions build/entitlements.mac.plist
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
</dict>
</plist>
Binary file modified docs/assets/d1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/d2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion electron-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ mac:
target:
- target: dmg
arch:
- x64
# - x64
- arm64
linux:
target:
Expand Down
44 changes: 0 additions & 44 deletions osx-cert.sh

This file was deleted.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bluestone",
"version": "0.8.1",
"version": "0.8.2",
"description": "",
"main": "./out/main/index.js",
"license": "AGPL-3.0",
Expand Down Expand Up @@ -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"
Expand Down
37 changes: 4 additions & 33 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 12 additions & 25 deletions src/main/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand All @@ -50,6 +50,9 @@ export const registerApi = () => {
ipcMain.handle('get-path', (e, type: Parameters<typeof app.getPath>[0]) => {
return app.getPath(type)
})
ipcMain.on('open-auth', (e, type: 'github') => {
openAuth(type)
})
ipcMain.handle('get-env', () => {
return {
isPackaged: app.isPackaged,
Expand Down Expand Up @@ -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
}
})
Expand Down Expand Up @@ -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()
})
Expand Down Expand Up @@ -144,27 +152,6 @@ export const registerApi = () => {
return shell.trashItem(path)
})

ipcMain.handle('upload', (e, data: {
url: string
data: Record<string, string>
}) => {
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) {
Expand Down
2 changes: 2 additions & 0 deletions src/preload/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any>
copyToClipboard: (str: string) => string
highlightCode(code: string, lang: string): IThemedToken[][]
Expand Down
5 changes: 4 additions & 1 deletion src/preload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, Watcher>()
let ready:any = null
const api = {
Expand All @@ -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()
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/src/api/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}) {
Expand Down
7 changes: 5 additions & 2 deletions src/renderer/src/components/AceCode.tsx
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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}
Expand Down
2 changes: 0 additions & 2 deletions src/renderer/src/components/Nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export const Nav = observer(() => {
</div>
</div>
<div className={'flex items-center pr-3 dark:text-gray-400/70 space-x-1 text-gray-500'}>
{/*<Share/>*/}
<Update/>
<div
className={'flex items-center justify-center p-1 group'}
Expand All @@ -76,7 +75,6 @@ export const Nav = observer(() => {
className={'text-lg duration-200 dark:group-hover:text-gray-300 group-hover:text-gray-700'}
/>
</div>
{/*<User/>*/}
</div>
</div>
</div>
Expand Down
3 changes: 1 addition & 2 deletions src/renderer/src/editor/elements/head.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -21,7 +20,7 @@ export function Head({element, attributes, children}: ElementProps<HeadNode>) {
onDragStart: store.dragStart
}, (
<>
<DragHandle style={{top: levelDragHandleTop.get(element.level)}}/>
<DragHandle style={{top: levelDragHandleTop.get(element.level), left: -28, paddingRight: 10}}/>
{children}
</>
))
Expand Down
Loading

0 comments on commit 52902ec

Please sign in to comment.