17 Commits

Author SHA1 Message Date
renovate[bot]
c5a6799e94 fix(deps): update react monorepo to ~18.3.0 2024-08-04 19:19:37 +00:00
jaywcjlove
8991adcd15 ci: update workflows config. 2024-08-05 00:58:24 +08:00
jaywcjlove
1b2e3b534d released v2.4.0 2024-08-05 00:56:10 +08:00
jaywcjlove
d85368cb4f type: fix type error. 2024-08-05 00:44:13 +08:00
jaywcjlove
8b4194f5ae ci: update workflows config. 2024-08-05 00:03:05 +08:00
renovate[bot]
ab3423a697 fix(deps): update dependency rehype-prism-plus to v2 (#47)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-05 00:02:54 +08:00
renovate[bot]
504259b862 fix(deps): update remark (#48)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-05 00:02:27 +08:00
renovate[bot]
b05d90e15b fix(deps): update dependency rehype-stringify to v10 (#31)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-05 00:00:33 +08:00
renovate[bot]
f6e71388f1 fix(deps): update dependency rehype-ignore to v2 (#46)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-05 00:00:14 +08:00
renovate[bot]
1c9a7a8668 fix(deps): update dependency rehype-raw to v7 (#30)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-04 23:59:33 +08:00
renovate[bot]
314f47f8af fix(deps): update dependency rehype-attr to v3 (#36)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-04 23:59:14 +08:00
renovate[bot]
be06f694a5 fix(deps): update dependency unified to v11 (#29)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-04 23:58:31 +08:00
renovate[bot]
c23ada95ff chore(deps): update dependency tsbb to ~4.4.0 (#45)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-04 23:37:41 +08:00
renovate[bot]
2632cb1938 fix(deps): update dependency @uiw/react-markdown-editor to v6 (#43)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-04 23:36:07 +08:00
jaywcjlove
77616468a4 fix: fix copy issue. #44 2024-08-04 23:34:33 +08:00
jaywcjlove
41eb86cd2b ci: update workflows config. 2024-06-29 22:20:31 +08:00
jaywcjlove
5fe5ddfa61 ci: update workflow config. 2024-04-03 16:34:12 +08:00
13 changed files with 101 additions and 84 deletions

3
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1,3 @@
ko_fi: jaywcjlove
buy_me_a_coffee: jaywcjlove
custom: ["https://www.paypal.me/kennyiseeyou", "https://jaywcjlove.github.io/#/sponsor"]

View File

@@ -8,16 +8,16 @@ jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: actions/setup-node@v3 - uses: actions/setup-node@v4
with: with:
node-version: 18 node-version: 20
registry-url: 'https://registry.npmjs.org' registry-url: 'https://registry.npmjs.org'
- run: npm install - run: npm install
- run: npm run build - run: npm run build
- run: npm run doc - run: npm run doc
- uses: actions/upload-artifact@v3 - uses: actions/upload-artifact@v4
with: with:
name: webiste name: webiste
path: | path: |
@@ -41,7 +41,7 @@ jobs:
uses: jaywcjlove/changelog-generator@main uses: jaywcjlove/changelog-generator@main
- name: Deploy - name: Deploy
uses: peaceiris/actions-gh-pages@v3 uses: peaceiris/actions-gh-pages@v4
with: with:
commit_message: ${{ github.event.head_commit.message }} ${{steps.tag_version.outputs.tag}} commit_message: ${{ github.event.head_commit.message }} ${{steps.tag_version.outputs.tag}}
github_token: ${{ secrets.GITHUB_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }}
@@ -67,8 +67,8 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [build] needs: [build]
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: actions/download-artifact@v3 - uses: actions/download-artifact@v4
with: with:
name: webiste name: webiste
path: website/build path: website/build
@@ -99,33 +99,33 @@ jobs:
docker tag wxmp ${{ secrets.DOCKER_USER }}/wxmp:${{needs.build.outputs.version}} docker tag wxmp ${{ secrets.DOCKER_USER }}/wxmp:${{needs.build.outputs.version}}
docker push ${{ secrets.DOCKER_USER }}/wxmp:${{needs.build.outputs.version}} docker push ${{ secrets.DOCKER_USER }}/wxmp:${{needs.build.outputs.version}}
# Create Docker Image in GitHub # # Create Docker Image in GitHub
- name: Login to GitHub registry # - name: Login to GitHub registry
run: echo ${{ github.token }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin # run: echo ${{ github.token }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build docker image # - name: Build docker image
working-directory: website # working-directory: website
run: docker build -t ghcr.io/jaywcjlove/wxmp:latest . # run: docker build -t ghcr.io/jaywcjlove/wxmp:latest .
- name: Publish to GitHub registry # - name: Publish to GitHub registry
run: docker push ghcr.io/jaywcjlove/wxmp:latest # run: docker push ghcr.io/jaywcjlove/wxmp:latest
- name: Tag docker image (beta) and publish to GitHub registry # - name: Tag docker image (beta) and publish to GitHub registry
if: needs.build.outputs.successful # if: needs.build.outputs.successful
run: | # run: |
echo "version: v${{ needs.build.outputs.version }}" # echo "version: v${{ needs.build.outputs.version }}"
docker tag ghcr.io/jaywcjlove/wxmp:latest ghcr.io/jaywcjlove/wxmp:${{needs.build.outputs.version}} # docker tag ghcr.io/jaywcjlove/wxmp:latest ghcr.io/jaywcjlove/wxmp:${{needs.build.outputs.version}}
docker push ghcr.io/jaywcjlove/wxmp:${{needs.build.outputs.version}} # docker push ghcr.io/jaywcjlove/wxmp:${{needs.build.outputs.version}}
build_windows: build_windows:
needs: [build] needs: [build]
runs-on: windows-latest runs-on: windows-latest
timeout-minutes: 30 timeout-minutes: 30
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: actions/setup-node@v3 - uses: actions/setup-node@v4
with: with:
node-version: 18 node-version: 20
- name: Install - name: Install
run: npm install --build-from-source run: npm install --build-from-source
@@ -134,7 +134,7 @@ jobs:
- run: npm run build - run: npm run build
# - run: npm run electron # - run: npm run electron
- uses: actions/download-artifact@v3 - uses: actions/download-artifact@v4
with: with:
name: webiste name: webiste
path: website/build path: website/build
@@ -147,7 +147,8 @@ jobs:
- working-directory: electron/app/dist - working-directory: electron/app/dist
run: ls -R run: ls -R
- uses: actions/upload-artifact@v3 - uses: actions/upload-artifact@v4
if: needs.build.outputs.successful == 'true'
with: with:
name: wxmp-windows name: wxmp-windows
path: | path: |
@@ -158,16 +159,16 @@ jobs:
runs-on: macos-latest runs-on: macos-latest
timeout-minutes: 30 timeout-minutes: 30
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: actions/setup-node@v3 - uses: actions/setup-node@v4
with: with:
node-version: 18 node-version: 20
- run: npm install - run: npm install
- run: npm run hoist - run: npm run hoist
- run: npm run build - run: npm run build
- uses: actions/download-artifact@v3 - uses: actions/download-artifact@v4
with: with:
name: webiste name: webiste
path: website/build path: website/build
@@ -180,7 +181,8 @@ jobs:
- working-directory: electron/app/dist - working-directory: electron/app/dist
run: ls -R run: ls -R
- uses: actions/upload-artifact@v3 - uses: actions/upload-artifact@v4
if: needs.build.outputs.successful == 'true'
with: with:
name: wxmp-macos name: wxmp-macos
path: | path: |
@@ -191,16 +193,16 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 45 timeout-minutes: 45
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: actions/setup-node@v3 - uses: actions/setup-node@v4
with: with:
node-version: 18 node-version: 20
- run: npm install - run: npm install
- run: npm run hoist - run: npm run hoist
- run: npm run build - run: npm run build
# - run: npm run electron # - run: npm run electron
- uses: actions/download-artifact@v3 - uses: actions/download-artifact@v4
with: with:
name: webiste name: webiste
path: website/build path: website/build
@@ -213,7 +215,8 @@ jobs:
- working-directory: electron/app/dist - working-directory: electron/app/dist
run: ls -R run: ls -R
- uses: actions/upload-artifact@v3 - uses: actions/upload-artifact@v4
if: needs.build.outputs.successful == 'true'
with: with:
name: wxmp-linux name: wxmp-linux
path: | path: |
@@ -223,26 +226,26 @@ jobs:
create_release: create_release:
needs: [build, build_windows, build_macos, build_linux] needs: [build, build_windows, build_macos, build_linux]
if: needs.build.outputs.successful if: needs.build.outputs.successful == 'true'
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 45 timeout-minutes: 45
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: actions/setup-node@v3 - uses: actions/setup-node@v4
with: with:
node-version: 18 node-version: 20
- uses: actions/download-artifact@v3 - uses: actions/download-artifact@v4
with: with:
name: wxmp-linux name: wxmp-linux
path: dist/linux path: dist/linux
- uses: actions/download-artifact@v3 - uses: actions/download-artifact@v4
with: with:
name: wxmp-macos name: wxmp-macos
path: dist/macos path: dist/macos
- uses: actions/download-artifact@v3 - uses: actions/download-artifact@v4
with: with:
name: wxmp-windows name: wxmp-windows
path: dist/windows path: dist/windows
@@ -261,8 +264,9 @@ jobs:
- name: Create Release - name: Create Release
uses: ncipollo/release-action@v1 uses: ncipollo/release-action@v1
if: needs.build.outputs.successful if: needs.build.outputs.successful == 'true'
with: with:
allowUpdates: true
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ steps.changelog.outputs.tag }} name: ${{ steps.changelog.outputs.tag }}
tag: ${{ steps.changelog.outputs.tag }} tag: ${{ steps.changelog.outputs.tag }}
@@ -295,17 +299,16 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 4 timeout-minutes: 4
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v4
with: with:
ref: ${{ github.head_ref }} ref: ${{ github.head_ref }}
- run: echo "outputs.version - ${{ needs.build.outputs.create_tag_version }}" - run: echo "outputs.version - ${{ needs.build.outputs.create_tag_version }}"
- uses: dev-drprasad/delete-tag-and-release@v0.2.0 - uses: dev-drprasad/delete-tag-and-release@v1.1
if: needs.build.outputs.successful if: needs.build.outputs.successful == 'true'
with: with:
delete_release: true delete_release: true
repo: jaywcjlove/wxmp repo: jaywcjlove/wxmp
tag_name: '${{ needs.build.outputs.create_tag_version }}' tag_name: '${{ needs.build.outputs.create_tag_version }}'
env: github_token: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -2,7 +2,7 @@
"name": "wxmp", "name": "wxmp",
"description": "微信公众号 Markdown 编辑器", "description": "微信公众号 Markdown 编辑器",
"homepage": "https://github.com/jaywcjlove/wxmp.git", "homepage": "https://github.com/jaywcjlove/wxmp.git",
"version": "2.3.3", "version": "2.4.0",
"main": "main.js", "main": "main.js",
"author": "Kenny Wong <398188662@qq.com>", "author": "Kenny Wong <398188662@qq.com>",
"private": true, "private": true,
@@ -18,13 +18,13 @@
"build": "npm run copy && cross-env NODE_ENV=production electron-builder build --publish=never --config config.json" "build": "npm run copy && cross-env NODE_ENV=production electron-builder build --publish=never --config config.json"
}, },
"dependencies": { "dependencies": {
"@wcj/wxmp-main": "2.3.3" "@wcj/wxmp-main": "2.4.0"
}, },
"devDependencies": { "devDependencies": {
"@wcj/wxmp-preload": "2.3.3", "@wcj/wxmp-preload": "2.4.0",
"cpy-cli": "^5.0.0", "cpy-cli": "^5.0.0",
"electron": "20.1.3", "electron": "20.1.3",
"electron-builder": "23.3.3", "electron-builder": "23.3.3",
"website": "2.3.3" "website": "2.4.0"
} }
} }

View File

@@ -1,6 +1,6 @@
{ {
"name": "@wcj/wxmp-main", "name": "@wcj/wxmp-main",
"version": "2.3.3", "version": "2.4.0",
"main": "./lib/index.js", "main": "./lib/index.js",
"private": true, "private": true,
"scripts": { "scripts": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "@wcj/wxmp-preload", "name": "@wcj/wxmp-preload",
"version": "2.3.3", "version": "2.4.0",
"main": "./lib/index.js", "main": "./lib/index.js",
"private": true, "private": true,
"scripts": { "scripts": {

View File

@@ -1,4 +1,4 @@
{ {
"version": "2.3.3", "version": "2.4.0",
"packages": ["website", "electron/*"] "packages": ["website", "electron/*"]
} }

View File

@@ -16,10 +16,12 @@
"devDependencies": { "devDependencies": {
"@lerna/legacy-package-management": "^8.0.0", "@lerna/legacy-package-management": "^8.0.0",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"husky": "^9.0.0", "husky": "^8.0.1",
"lerna": "^8.0.0", "lerna": "^8.0.0",
"prettier": "^3.0.2", "prettier": "^3.0.2",
"tsbb": "~4.2.0" "react": "~18.3.0",
"react-dom": "~18.3.0",
"tsbb": "~4.4.0"
}, },
"workspaces": { "workspaces": {
"packages": [ "packages": [

View File

@@ -20,6 +20,8 @@ export default (conf: Configuration, env: 'development' | 'production', options:
}), }),
); );
/** https://github.com/kktjs/kkt/issues/446 */
conf.ignoreWarnings = [{ module: /node_modules[\\/]parse5[\\/]/ }];
conf.module!.exprContextCritical = false; conf.module!.exprContextCritical = false;
if (env === 'production') { if (env === 'production') {
conf.output = { ...conf.output, publicPath: './' }; conf.output = { ...conf.output, publicPath: './' };

View File

@@ -1,6 +1,6 @@
{ {
"name": "website", "name": "website",
"version": "2.3.3", "version": "2.4.0",
"private": true, "private": true,
"scripts": { "scripts": {
"start": "kkt start", "start": "kkt start",
@@ -25,23 +25,23 @@
"@uiw/codemirror-theme-xcode": "^4.11.6", "@uiw/codemirror-theme-xcode": "^4.11.6",
"@uiw/react-back-to-top": "^1.2.0", "@uiw/react-back-to-top": "^1.2.0",
"@uiw/react-github-corners": "^1.5.15", "@uiw/react-github-corners": "^1.5.15",
"@uiw/react-markdown-editor": "^5.11.2", "@uiw/react-markdown-editor": "^6.0.0",
"@wcj/dark-mode": "^1.0.15", "@wcj/dark-mode": "^1.0.15",
"css-tree": "^2.2.1", "css-tree": "^2.2.1",
"react": "^18.2.0", "react": "~18.3.0",
"react-dom": "^18.2.0", "react-dom": "~18.3.0",
"react-hot-toast": "^2.3.0", "react-hot-toast": "^2.3.0",
"react-router-dom": "^6.3.0", "react-router-dom": "^6.3.0",
"rehype-attr": "^2.0.8", "rehype-attr": "^3.0.0",
"rehype-ignore": "^1.0.1", "rehype-ignore": "^2.0.0",
"rehype-prism-plus": "^1.5.0", "rehype-prism-plus": "^2.0.0",
"rehype-raw": "^6.1.1", "rehype-raw": "^7.0.0",
"rehype-stringify": "^9.0.3", "rehype-stringify": "^10.0.0",
"remark-gfm": "^3.0.1", "remark-gfm": "^4.0.0",
"remark-parse": "^10.0.1", "remark-parse": "^11.0.0",
"remark-rehype": "^10.1.0", "remark-rehype": "^11.0.0",
"styled-components": "~6.1.0", "styled-components": "~6.1.0",
"unified": "^10.1.2" "unified": "^11.0.0"
}, },
"devDependencies": { "devDependencies": {
"@kkt/less-modules": "^7.2.0", "@kkt/less-modules": "^7.2.0",

View File

@@ -13,16 +13,22 @@ const Button = styled.button`
const CopyView: React.FC<{ command: ICommand; editorProps: IMarkdownEditor & ToolBarProps }> = (props) => { const CopyView: React.FC<{ command: ICommand; editorProps: IMarkdownEditor & ToolBarProps }> = (props) => {
const { editorProps } = props; const { editorProps } = props;
const handleClick = () => { const handleClick = () => {
const dom = editorProps.preview.current; const dom: HTMLDivElement | null = editorProps.preview.current;
dom?.focus(); if (!dom) {
window.getSelection()?.removeAllRanges(); toast.error(<div>dom is null</div>);
let range = document.createRange(); return;
range.setStartBefore(dom?.firstChild!); }
range.setEndAfter(dom?.lastChild!); dom.focus();
window.getSelection()?.addRange(range); const htmlContent = dom.innerHTML;
document.execCommand(`copy`); navigator.clipboard
window.getSelection()?.removeAllRanges(); .writeText(htmlContent)
toast.success(<div></div>); .then(() => {
toast.success(<div></div>);
})
.catch((err) => {
toast.error(<div>{JSON.stringify(err)}</div>);
console.error('Failed to copy: ', err);
});
}; };
return ( return (
<Button type="button" onClick={handleClick}> <Button type="button" onClick={handleClick}>

View File

@@ -1,5 +1,6 @@
import MarkdownEditor, { getCommands } from '@uiw/react-markdown-editor'; import MarkdownEditor, { getCommands } from '@uiw/react-markdown-editor';
import { useContext } from 'react'; import { useContext } from 'react';
// @ts-ignore
import { EditorView } from '@codemirror/view'; import { EditorView } from '@codemirror/view';
import { Preview } from './Preview'; import { Preview } from './Preview';
import { copy } from '../../commands/copy'; import { copy } from '../../commands/copy';

View File

@@ -129,7 +129,7 @@ export const footnotesLabel = (node: Element) => {
]; ];
}; };
export const imagesStyle = (node: Element, parent: Root | Element | null) => { export const imagesStyle = (node: Element, parent: Root | Element | undefined) => {
if ( if (
parent?.type === 'element' && parent?.type === 'element' &&
/(p|a)/.test(parent.tagName) && /(p|a)/.test(parent.tagName) &&

View File

@@ -26,21 +26,21 @@ export function markdownToHTML(md: string, css: string, opts: MarkdownToHTMLOpti
parseCustomProperty: false, parseCustomProperty: false,
positions: false, positions: false,
}); });
// @ts-ignore // @ts-ignore
const data = cssdata(ast.children.head, {}, { color: opts.preColor, theme: opts.previewTheme }); const data = cssdata(ast.children.head, {}, { color: opts.preColor, theme: opts.previewTheme });
const processor = unified() const processor = unified()
.use(remarkParse) .use(remarkParse)
.use(remarkGfm) .use(remarkGfm)
.use(remarkRehype, { allowDangerousHtml: true }) .use(remarkRehype, { allowDangerousHtml: true })
.use(rehypeRaw)
.use(rehypePrism, { .use(rehypePrism, {
ignoreMissing: true, ignoreMissing: true,
}) })
.use(rehypeRaw)
.use(rehypeIgnore, {}) .use(rehypeIgnore, {})
.use(rehypeAttrs, { properties: 'attr' }) .use(rehypeAttrs, { properties: 'attr' })
.use(rehypeRewrite, { .use(rehypeRewrite, {
rewrite: (node, _index, parent) => { rewrite: (node, _index, parent) => {
// @ts-ignore
if ( if (
node?.type === 'element' && node?.type === 'element' &&
node?.tagName === 'code' && node?.tagName === 'code' &&