From bf994bb0fb9a3a8c7641f5f0dc11d20f7019d713 Mon Sep 17 00:00:00 2001 From: luojiyin Date: Sun, 30 Jun 2024 23:50:30 +0800 Subject: [PATCH 01/19] install edkit --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 08eff4d..57ccc8a 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "primereact": "^10.6.6", "react": "^18.3.1", "react-bootstrap": "^2.10.2", + "react-bootstrap-editor": "^2.0.4", "react-dom": "^18.3.1", "remark-frontmatter": "^5.0.0", "remark-gfm": "^4.0.0", From caa4bbd1572111ae13848ff89ffa78151dcc0c23 Mon Sep 17 00:00:00 2001 From: luojiyin Date: Mon, 1 Jul 2024 00:09:20 +0800 Subject: [PATCH 02/19] update pnpm-lock --- pnpm-lock.yaml | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c87d4ab..fe010f9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -92,6 +92,9 @@ importers: react-bootstrap: specifier: ^2.10.2 version: 2.10.2(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + react-bootstrap-editor: + specifier: ^2.0.4 + version: 2.0.4(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(typescript@5.4.5) react-dom: specifier: ^18.3.1 version: 18.3.1(react@18.3.1) @@ -1827,6 +1830,9 @@ packages: resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==} engines: {node: '>=8'} + browser-fs-access@0.35.0: + resolution: {integrity: sha512-sLoadumpRfsjprP8XzVjpQc0jK8yqHBx0PtUTGYj2fftT+P/t+uyDAQdMgGAPKD011in/O+YYGh7fIs0oG/viw==} + browserslist@4.23.0: resolution: {integrity: sha512-QW8HiM1shhT2GuzkvklfjcKDiWFXHOeFCIA/huJPwHsslwcydgk7X+z2zXpEijP98UCY7HbubZt5J2Zgvf0CaQ==} engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} @@ -2090,6 +2096,9 @@ packages: editorjs-html@3.4.3: resolution: {integrity: sha512-HMqQ3BCE98uhSpJsbfH0c3CoMctUMCHlap2Eq/7/VjaHas+g3IJqyf+ERtMByoQCzvcW22ISYaZEeE7rGkd8Xg==} + edkit@1.2.1: + resolution: {integrity: sha512-Mqixc9JdCC7oFFeQ+Vn8GmK3jaGkI7jEGighQQt3PZmKKXmlMovwRoMXFV2glev7pyiA48GP89sBXapZcQhgXQ==} + ejs@3.1.10: resolution: {integrity: sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==} engines: {node: '>=0.10.0'} @@ -3106,6 +3115,11 @@ packages: engines: {node: '>= 18'} hasBin: true + marked@13.0.1: + resolution: {integrity: sha512-7kBohS6GrZKvCsNXZyVVXSW7/hGBHe49ng99YPkDCckSUrrG7MSFLCexsRxptzOmyW2eT5dySh4Md1V6my52fA==} + engines: {node: '>= 18'} + hasBin: true + marked@4.3.0: resolution: {integrity: sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==} engines: {node: '>= 12'} @@ -3756,6 +3770,12 @@ packages: randombytes@2.1.0: resolution: {integrity: sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==} + react-bootstrap-editor@2.0.4: + resolution: {integrity: sha512-hKJMhCriJ1/V4QWq+FWccxYCtq6IYYIr79wBsyWlXSmwHypms79CQGNGL78F19MWQQn613AvltBMWaxwi7DEmw==} + peerDependencies: + react: '>=16' + react-dom: '>=16' + react-bootstrap@2.10.2: resolution: {integrity: sha512-UvB7mRqQjivdZNxJNEA2yOQRB7L9N43nBnKc33K47+cH90/ujmnMwatTCwQLu83gLhrzAl8fsa6Lqig/KLghaA==} peerDependencies: @@ -6645,6 +6665,8 @@ snapshots: dependencies: fill-range: 7.1.1 + browser-fs-access@0.35.0: {} + browserslist@4.23.0: dependencies: caniuse-lite: 1.0.30001625 @@ -6909,6 +6931,19 @@ snapshots: editorjs-html@3.4.3: {} + edkit@1.2.1(typescript@5.4.5): + dependencies: + '@swc/helpers': 0.5.11 + '@types/turndown': 5.0.4 + browser-fs-access: 0.35.0 + marked: 13.0.1 + regenerator-runtime: 0.14.1 + turndown: 7.2.0 + turndown-plugin-gfm: 1.0.2 + web-utility: 4.4.0(typescript@5.4.5) + transitivePeerDependencies: + - typescript + ejs@3.1.10: dependencies: jake: 10.9.1 @@ -8174,6 +8209,8 @@ snapshots: marked@12.0.2: {} + marked@13.0.1: {} + marked@4.3.0: {} mdast-util-find-and-replace@3.0.1: @@ -9094,6 +9131,19 @@ snapshots: dependencies: safe-buffer: 5.2.1 + react-bootstrap-editor@2.0.4(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(typescript@5.4.5): + dependencies: + '@swc/helpers': 0.5.11 + edkit: 1.2.1(typescript@5.4.5) + mobx: 6.12.3 + mobx-react: 9.1.1(mobx@6.12.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + react: 18.3.1 + react-dom: 18.3.1(react@18.3.1) + web-utility: 4.4.0(typescript@5.4.5) + transitivePeerDependencies: + - react-native + - typescript + react-bootstrap@2.10.2(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1): dependencies: '@babel/runtime': 7.24.6 From cede61be0aafbd990be4aed54b79de795bef3b9f Mon Sep 17 00:00:00 2001 From: luojiyin Date: Tue, 2 Jul 2024 23:36:44 +0800 Subject: [PATCH 03/19] add HTMLEditor compents --- components/Form/HTMLEditor/index.tsx | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 components/Form/HTMLEditor/index.tsx diff --git a/components/Form/HTMLEditor/index.tsx b/components/Form/HTMLEditor/index.tsx new file mode 100644 index 0000000..b7a481b --- /dev/null +++ b/components/Form/HTMLEditor/index.tsx @@ -0,0 +1,27 @@ +import { FC } from 'react'; +import { + AudioTool, + Editor, + EditorProps, + IFrameTool, + ImageTool, + OriginalTools, + VideoTool, +} from 'react-bootstrap-editor'; +import { insertToCursor, parseDOM } from 'web-utility'; + +import fileStore from '../models/Base/File'; + +ImageTool.prototype.save = blob => + fileStore.upload(new File([blob], uniqueID())); + +const ExcludeTools = [IFrameTool, AudioTool, VideoTool]; + +const CustomTools = OriginalTools.filter( + Tool => !ExcludeTools.includes(Tool as Constructor), +); + +const HTMLEditor: FC = props => ( + +); +export default HTMLEditor; From c2fd39f5032c2a0c4cb82595b9707087c4cf98ea Mon Sep 17 00:00:00 2001 From: luojiyin Date: Tue, 2 Jul 2024 23:38:18 +0800 Subject: [PATCH 04/19] add HTMLEditor compents --- components/Form/HTMLEditor/index.tsx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/components/Form/HTMLEditor/index.tsx b/components/Form/HTMLEditor/index.tsx index b7a481b..cacdec6 100644 --- a/components/Form/HTMLEditor/index.tsx +++ b/components/Form/HTMLEditor/index.tsx @@ -10,11 +10,6 @@ import { } from 'react-bootstrap-editor'; import { insertToCursor, parseDOM } from 'web-utility'; -import fileStore from '../models/Base/File'; - -ImageTool.prototype.save = blob => - fileStore.upload(new File([blob], uniqueID())); - const ExcludeTools = [IFrameTool, AudioTool, VideoTool]; const CustomTools = OriginalTools.filter( From e8dbdfa10b895d81e42146abf4c07c723bdb5e60 Mon Sep 17 00:00:00 2001 From: luojiyin Date: Tue, 2 Jul 2024 23:40:36 +0800 Subject: [PATCH 05/19] add HTMLEditor compents --- components/Form/HTMLEditor/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/Form/HTMLEditor/index.tsx b/components/Form/HTMLEditor/index.tsx index cacdec6..c720965 100644 --- a/components/Form/HTMLEditor/index.tsx +++ b/components/Form/HTMLEditor/index.tsx @@ -8,7 +8,7 @@ import { OriginalTools, VideoTool, } from 'react-bootstrap-editor'; -import { insertToCursor, parseDOM } from 'web-utility'; +import { Constructor } from 'web-utility'; const ExcludeTools = [IFrameTool, AudioTool, VideoTool]; From a180883167ccfbbf32791945c24dbd0b8e4e06e4 Mon Sep 17 00:00:00 2001 From: luojiyin Date: Thu, 4 Jul 2024 11:20:06 +0800 Subject: [PATCH 06/19] trt --- components/Git/ArticleEditor.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/Git/ArticleEditor.tsx b/components/Git/ArticleEditor.tsx index 235f83c..0e594e5 100644 --- a/components/Git/ArticleEditor.tsx +++ b/components/Git/ArticleEditor.tsx @@ -16,6 +16,7 @@ import { blobOf, formatDate, uniqueID } from 'web-utility'; import YAML from 'yaml'; import { GitRepositoryModel, userStore } from '../../models/Repository'; +import HTMLEditor from '../Form/HTMLEditor'; import { ListField } from '../Form/JSONEditor'; import { MarkdownEditor } from '../Form/MarkdownEditor'; import { PathSelect } from './PathSelect'; @@ -59,7 +60,7 @@ export class ArticleEditor extends Component { path = ''; URL = ''; - private Core = createRef(); + private Core = createRef(); get core() { return this.Core.current; @@ -313,7 +314,7 @@ export class ArticleEditor extends Component { {copied ? '√' : ''} Copy MarkDown - + ); From a23128f6547c23437332c5b6e30f9148a2747850 Mon Sep 17 00:00:00 2001 From: luojiyin Date: Sun, 7 Jul 2024 15:45:53 +0800 Subject: [PATCH 07/19] get err: document is not defined --- components/Git/ArticleEditor.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/Git/ArticleEditor.tsx b/components/Git/ArticleEditor.tsx index 0e594e5..e020fc0 100644 --- a/components/Git/ArticleEditor.tsx +++ b/components/Git/ArticleEditor.tsx @@ -314,7 +314,7 @@ export class ArticleEditor extends Component { {copied ? '√' : ''} Copy MarkDown - + ); From f6e0dff219eb6d51bd2da0f14a61c308344eabe1 Mon Sep 17 00:00:00 2001 From: luojiyin Date: Sun, 7 Jul 2024 22:08:25 +0800 Subject: [PATCH 08/19] fix from review --- components/Git/ArticleEditor.tsx | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/components/Git/ArticleEditor.tsx b/components/Git/ArticleEditor.tsx index e020fc0..9e94bf0 100644 --- a/components/Git/ArticleEditor.tsx +++ b/components/Git/ArticleEditor.tsx @@ -4,6 +4,7 @@ import { computed, observable } from 'mobx'; import { GitContent } from 'mobx-github'; import { observer } from 'mobx-react'; import { DataObject } from 'mobx-restful'; +import dynamic from 'next/dynamic'; import { ChangeEvent, Component, @@ -16,12 +17,13 @@ import { blobOf, formatDate, uniqueID } from 'web-utility'; import YAML from 'yaml'; import { GitRepositoryModel, userStore } from '../../models/Repository'; -import HTMLEditor from '../Form/HTMLEditor'; import { ListField } from '../Form/JSONEditor'; import { MarkdownEditor } from '../Form/MarkdownEditor'; import { PathSelect } from './PathSelect'; import { RepositorySelect } from './RepositorySelect'; +const HTMLEditor = dynamic(() => import('../Form/HTMLEditor'), { ssr: false }); + export const fileType = { MarkDown: ['md', 'markdown'], JSON: ['json'], @@ -60,12 +62,6 @@ export class ArticleEditor extends Component { path = ''; URL = ''; - private Core = createRef(); - - get core() { - return this.Core.current; - } - @observable accessor meta: PostMeta | null = null; @@ -314,7 +310,7 @@ export class ArticleEditor extends Component { {copied ? '√' : ''} Copy MarkDown - + ); From e03a0c64f95fc3cc53ca549a40e18218b86fb75e Mon Sep 17 00:00:00 2001 From: luojiyin Date: Tue, 9 Jul 2024 17:53:02 +0800 Subject: [PATCH 09/19] unknow --- components/Git/ArticleEditor.tsx | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/components/Git/ArticleEditor.tsx b/components/Git/ArticleEditor.tsx index 9e94bf0..149f7a9 100644 --- a/components/Git/ArticleEditor.tsx +++ b/components/Git/ArticleEditor.tsx @@ -5,20 +5,13 @@ import { GitContent } from 'mobx-github'; import { observer } from 'mobx-react'; import { DataObject } from 'mobx-restful'; import dynamic from 'next/dynamic'; -import { - ChangeEvent, - Component, - createRef, - FormEvent, - MouseEvent, -} from 'react'; +import { ChangeEvent, Component, FormEvent, MouseEvent } from 'react'; import { Button, Col, Form } from 'react-bootstrap'; import { blobOf, formatDate, uniqueID } from 'web-utility'; import YAML from 'yaml'; import { GitRepositoryModel, userStore } from '../../models/Repository'; import { ListField } from '../Form/JSONEditor'; -import { MarkdownEditor } from '../Form/MarkdownEditor'; import { PathSelect } from './PathSelect'; import { RepositorySelect } from './RepositorySelect'; @@ -42,6 +35,7 @@ export type HyperLink = HTMLAnchorElement | HTMLImageElement; export class ArticleEditor extends Component { @observable accessor repository = ''; + accessor core = {}; @computed get currentRepository() { From 2a9d0174c252fb9d1f30fb78714a68eb946acc75 Mon Sep 17 00:00:00 2001 From: luojiyin Date: Wed, 10 Jul 2024 23:10:41 +0800 Subject: [PATCH 10/19] unknow --- components/Git/ArticleEditor.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/Git/ArticleEditor.tsx b/components/Git/ArticleEditor.tsx index 149f7a9..82ccc00 100644 --- a/components/Git/ArticleEditor.tsx +++ b/components/Git/ArticleEditor.tsx @@ -35,7 +35,7 @@ export type HyperLink = HTMLAnchorElement | HTMLImageElement; export class ArticleEditor extends Component { @observable accessor repository = ''; - accessor core = {}; + accessor editorContent = ''; @computed get currentRepository() { @@ -114,13 +114,13 @@ export class ArticleEditor extends Component { if (meta[1]) this.setPostMeta(meta[1]); } - if (this.core) this.core.raw = content; + if (this.editorContent) this.editorContent = content; }; reset = () => { this.meta = null; - if (this.core) this.core.raw = ''; + if (this.editorContent) this.editorContent = ''; }; onPathClear = ({ target: { value } }: ChangeEvent) => { @@ -128,7 +128,7 @@ export class ArticleEditor extends Component { this.meta = null; - if (this.core) this.core.raw = ''; + if (this.editorContent) this.editorContent = ''; }; fixURL = debounce(() => { From e9f59160fbe3d7ba0523c458f1e7922e36ac151d Mon Sep 17 00:00:00 2001 From: luojiyin Date: Wed, 10 Jul 2024 23:15:20 +0800 Subject: [PATCH 11/19] unknow --- components/Git/ArticleEditor.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/components/Git/ArticleEditor.tsx b/components/Git/ArticleEditor.tsx index 82ccc00..5e4302a 100644 --- a/components/Git/ArticleEditor.tsx +++ b/components/Git/ArticleEditor.tsx @@ -157,14 +157,14 @@ export class ArticleEditor extends Component { getContent() { const type = this.URL.split('.').slice(-1)[0], - { meta, core } = this; + { meta, editorContent } = this; if (fileType.JSON.includes(type)) return JSON.stringify(meta); if (fileType.YAML.includes(type)) return YAML.stringify(meta); - if (fileType.MarkDown.includes(type) && core) { - if (!meta) return core.raw; + if (fileType.MarkDown.includes(type) && editorContent) { + if (!meta) return editorContent; // @ts-ignore meta.updated = formatDate(); @@ -172,18 +172,18 @@ export class ArticleEditor extends Component { ${YAML.stringify(meta)} --- - ${core.raw}`; + ${editorContent}`; } } submit = async (event: FormEvent) => { event.preventDefault(); - const { currentRepository, repositoryStore, core } = this, + const { currentRepository, repositoryStore, editorContent } = this, // @ts-ignore { message } = event.currentTarget.elements; - if (!core?.root) return; + if (!editorContent) return; const media: HTMLMediaElement[] = [].filter.call( core.root.querySelectorAll('img[src], audio[src], video[src]'), @@ -218,8 +218,8 @@ export class ArticleEditor extends Component { copyMarkdown = async (event: MouseEvent) => { event.preventDefault(); - if (this.core) { - await navigator.clipboard.writeText(this.core.raw); + if (this.editorContent) { + await navigator.clipboard.writeText(this.editorContent); this.copied = true; } @@ -304,7 +304,7 @@ export class ArticleEditor extends Component { {copied ? '√' : ''} Copy MarkDown - + ); From fb0a29c2cad3940c10781775dfeba4acfc6b66f0 Mon Sep 17 00:00:00 2001 From: luojiyin Date: Thu, 11 Jul 2024 10:23:31 +0800 Subject: [PATCH 12/19] fix from review --- components/Git/ArticleEditor.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/components/Git/ArticleEditor.tsx b/components/Git/ArticleEditor.tsx index 5e4302a..35d471d 100644 --- a/components/Git/ArticleEditor.tsx +++ b/components/Git/ArticleEditor.tsx @@ -35,7 +35,7 @@ export type HyperLink = HTMLAnchorElement | HTMLImageElement; export class ArticleEditor extends Component { @observable accessor repository = ''; - accessor editorContent = ''; + editorContent = ''; @computed get currentRepository() { @@ -114,7 +114,7 @@ export class ArticleEditor extends Component { if (meta[1]) this.setPostMeta(meta[1]); } - if (this.editorContent) this.editorContent = content; + this.editorContent = content; }; reset = () => { @@ -304,7 +304,10 @@ export class ArticleEditor extends Component { {copied ? '√' : ''} Copy MarkDown - + (this.editorContent = value)} + /> ); From fdf6d9fe4eec2bf46b277739c8153b9b3de02297 Mon Sep 17 00:00:00 2001 From: luojiyin Date: Thu, 11 Jul 2024 21:58:57 +0800 Subject: [PATCH 13/19] fix from review --- components/Git/ArticleEditor.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/components/Git/ArticleEditor.tsx b/components/Git/ArticleEditor.tsx index 35d471d..b17ed39 100644 --- a/components/Git/ArticleEditor.tsx +++ b/components/Git/ArticleEditor.tsx @@ -120,7 +120,7 @@ export class ArticleEditor extends Component { reset = () => { this.meta = null; - if (this.editorContent) this.editorContent = ''; + this.editorContent = ''; }; onPathClear = ({ target: { value } }: ChangeEvent) => { @@ -128,17 +128,16 @@ export class ArticleEditor extends Component { this.meta = null; - if (this.editorContent) this.editorContent = ''; + this.editorContent = ''; }; fixURL = debounce(() => { const { repository } = this, - pageURL = window.location.href.split('?')[0]; + pageURL = window.location.href.split('?')[0], + root = document.querySelector('div[contenteditable]'); - if (this.core && this.core.root) - for (let element of this.core.root.querySelectorAll( - '[href], [src]', - )) { + if (root) + for (let element of root.querySelectorAll('[href], [src]')) { let URI = element instanceof HTMLAnchorElement ? element.href : element.src; @@ -185,8 +184,9 @@ export class ArticleEditor extends Component { if (!editorContent) return; + const root = document.querySelector('div[contenteditable]'); const media: HTMLMediaElement[] = [].filter.call( - core.root.querySelectorAll('img[src], audio[src], video[src]'), + root!.querySelectorAll('img[src], audio[src], video[src]'), ({ src }) => new URL(src).protocol === 'blob:', ); From 7373ae1b144b28a157d117cdd78200d216f133a6 Mon Sep 17 00:00:00 2001 From: luojiyin Date: Thu, 11 Jul 2024 22:20:55 +0800 Subject: [PATCH 14/19] code clear --- components/Git/ArticleEditor.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/components/Git/ArticleEditor.tsx b/components/Git/ArticleEditor.tsx index b17ed39..2bc44da 100644 --- a/components/Git/ArticleEditor.tsx +++ b/components/Git/ArticleEditor.tsx @@ -126,9 +126,7 @@ export class ArticleEditor extends Component { onPathClear = ({ target: { value } }: ChangeEvent) => { if (value.trim()) return; - this.meta = null; - - this.editorContent = ''; + this.reset(); }; fixURL = debounce(() => { From cf5fa4f9117d950c5e62654f82d8f657b4adddef Mon Sep 17 00:00:00 2001 From: luojiyin Date: Thu, 11 Jul 2024 23:04:23 +0800 Subject: [PATCH 15/19] git page i18n --- components/Git/ArticleEditor.tsx | 21 ++++++++++++--------- translation/en-US.ts | 10 ++++++++++ translation/zh-CN.ts | 10 ++++++++++ translation/zh-TW.ts | 10 ++++++++++ 4 files changed, 42 insertions(+), 9 deletions(-) diff --git a/components/Git/ArticleEditor.tsx b/components/Git/ArticleEditor.tsx index 2bc44da..8a62238 100644 --- a/components/Git/ArticleEditor.tsx +++ b/components/Git/ArticleEditor.tsx @@ -11,10 +11,12 @@ import { blobOf, formatDate, uniqueID } from 'web-utility'; import YAML from 'yaml'; import { GitRepositoryModel, userStore } from '../../models/Repository'; +import { i18n } from '../../models/Translation'; import { ListField } from '../Form/JSONEditor'; import { PathSelect } from './PathSelect'; import { RepositorySelect } from './RepositorySelect'; +const { t } = i18n; const HTMLEditor = dynamic(() => import('../Form/HTMLEditor'), { ssr: false }); export const fileType = { @@ -119,7 +121,6 @@ export class ArticleEditor extends Component { reset = () => { this.meta = null; - this.editorContent = ''; }; @@ -249,7 +250,7 @@ export class ArticleEditor extends Component { onSubmit={this.submit} > - + (this.repository = `${owner}/${name}`) @@ -257,14 +258,16 @@ export class ArticleEditor extends Component { /> - + {repository && ( )} - + @@ -272,16 +275,16 @@ export class ArticleEditor extends Component { sm={3} className="d-flex flex-wrap gap-2 justify-content-around align-items-center" > - + {meta && ( - + @@ -292,14 +295,14 @@ export class ArticleEditor extends Component { )}
- +
Date: Fri, 12 Jul 2024 08:12:08 +0800 Subject: [PATCH 16/19] fix from review --- components/Git/ArticleEditor.tsx | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/components/Git/ArticleEditor.tsx b/components/Git/ArticleEditor.tsx index 8a62238..dbaf931 100644 --- a/components/Git/ArticleEditor.tsx +++ b/components/Git/ArticleEditor.tsx @@ -61,9 +61,6 @@ export class ArticleEditor extends Component { @observable accessor meta: PostMeta | null = null; - @observable - accessor copied = false; - static contentFilter({ type, name }: GitContent) { return ( type === 'dir' || @@ -125,9 +122,7 @@ export class ArticleEditor extends Component { }; onPathClear = ({ target: { value } }: ChangeEvent) => { - if (value.trim()) return; - - this.reset(); + if (!value.trim()) this.reset(); }; fixURL = debounce(() => { @@ -214,16 +209,6 @@ export class ArticleEditor extends Component { window.alert('Submitted'); }; - copyMarkdown = async (event: MouseEvent) => { - event.preventDefault(); - - if (this.editorContent) { - await navigator.clipboard.writeText(this.editorContent); - - this.copied = true; - } - }; - loadFile = async (path: string) => { const type = path.split('.').at(-1)?.toLowerCase(); @@ -241,7 +226,7 @@ export class ArticleEditor extends Component { }; render() { - const { repository, meta, copied } = this; + const { repository, meta } = this; return (
-
Date: Fri, 12 Jul 2024 08:15:07 +0800 Subject: [PATCH 17/19] fix from review --- components/Git/ArticleEditor.tsx | 4 ++-- translation/en-US.ts | 6 +++--- translation/zh-CN.ts | 6 +++--- translation/zh-TW.ts | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/components/Git/ArticleEditor.tsx b/components/Git/ArticleEditor.tsx index dbaf931..08680ef 100644 --- a/components/Git/ArticleEditor.tsx +++ b/components/Git/ArticleEditor.tsx @@ -243,7 +243,7 @@ export class ArticleEditor extends Component { /> - + {repository && ( @@ -251,7 +251,7 @@ export class ArticleEditor extends Component { diff --git a/translation/en-US.ts b/translation/en-US.ts index 18e202a..614a841 100644 --- a/translation/en-US.ts +++ b/translation/en-US.ts @@ -111,11 +111,11 @@ export default { // git pager repository: 'repository', - filePath: 'filePath', - commitMessage: 'commit Message', + file_path: 'filePath', + commit_message: 'commit Message', commit: 'commit', clear: 'clear', meta: 'meta', content: 'content', - copyMarkDown: 'copy Markdown', + copy_MarkDown: 'copy Markdown', } as const; diff --git a/translation/zh-CN.ts b/translation/zh-CN.ts index 0772622..aa30616 100644 --- a/translation/zh-CN.ts +++ b/translation/zh-CN.ts @@ -108,11 +108,11 @@ export default { // git pager repository: '代码仓库', - filePath: '文件路径', - commitMessage: '提交信息', + file_path: '文件路径', + commit_message: '提交信息', commit: '提交', clear: '清空', meta: '元数据', content: '内容', - copyMarkDown: '复制 Markdown', + copy_MarkDown: '复制 Markdown', } as const; diff --git a/translation/zh-TW.ts b/translation/zh-TW.ts index 9160f33..69cca31 100644 --- a/translation/zh-TW.ts +++ b/translation/zh-TW.ts @@ -108,11 +108,11 @@ export default { // git pager repository: '程式碼倉庫', - filePath: '檔案路徑', - commitMessage: '提交訊息', + file_path: '檔案路徑', + commit_message: '提交訊息', commit: '提交', clear: '清空', meta: '詮釋資料', content: '内容', - copyMarkDown: '複製 Markdown', + copy_MarkDown: '複製 Markdown', } as const; From 325fa0e5f641c349618f4bac62562e77ee11920b Mon Sep 17 00:00:00 2001 From: luojiyin Date: Fri, 12 Jul 2024 08:16:35 +0800 Subject: [PATCH 18/19] fix from review --- translation/en-US.ts | 2 +- translation/zh-CN.ts | 2 +- translation/zh-TW.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/translation/en-US.ts b/translation/en-US.ts index 614a841..8cab551 100644 --- a/translation/en-US.ts +++ b/translation/en-US.ts @@ -109,7 +109,7 @@ export default { range_module: 'module', last_step: 'back', - // git pager + // Git pager repository: 'repository', file_path: 'filePath', commit_message: 'commit Message', diff --git a/translation/zh-CN.ts b/translation/zh-CN.ts index aa30616..0d74a43 100644 --- a/translation/zh-CN.ts +++ b/translation/zh-CN.ts @@ -106,7 +106,7 @@ export default { range_module: '模块', last_step: '上一步', - // git pager + // Git pager repository: '代码仓库', file_path: '文件路径', commit_message: '提交信息', diff --git a/translation/zh-TW.ts b/translation/zh-TW.ts index 69cca31..d6d7ff7 100644 --- a/translation/zh-TW.ts +++ b/translation/zh-TW.ts @@ -106,7 +106,7 @@ export default { range_module: '模組', last_step: '上一步', - // git pager + // Git pager repository: '程式碼倉庫', file_path: '檔案路徑', commit_message: '提交訊息', From 52ca13788ed25f6538e842fc7b301398f1330307 Mon Sep 17 00:00:00 2001 From: luojiyin Date: Fri, 12 Jul 2024 19:46:29 +0800 Subject: [PATCH 19/19] fix from review --- translation/en-US.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/translation/en-US.ts b/translation/en-US.ts index 8cab551..3f8575f 100644 --- a/translation/en-US.ts +++ b/translation/en-US.ts @@ -111,8 +111,8 @@ export default { // Git pager repository: 'repository', - file_path: 'filePath', - commit_message: 'commit Message', + file_path: 'file path', + commit_message: 'commit message', commit: 'commit', clear: 'clear', meta: 'meta',