This is an automated email from the ASF dual-hosted git repository. linkinstar pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/incubator-answer-plugins.git
commit a7c8e0c56430280756202a95909837b53de637d4 Author: robin <[email protected]> AuthorDate: Wed Jun 5 18:08:08 2024 +0800 refactor(editor-formula): Update i18n files to use YAML format --- editor-formula/Formula.tsx | 3 ++- editor-formula/i18n/en_US.json | 11 ----------- editor-formula/i18n/en_US.yaml | 5 +++++ editor-formula/i18n/index.ts | 4 ++-- editor-formula/i18n/zh_CN.json | 11 ----------- editor-formula/i18n/zh_CN.yaml | 5 +++++ editor-formula/package.json | 1 + editor-formula/pnpm-lock.yaml | 43 ++++++++++++++++++++++++++++++++++++++++++ editor-formula/tsconfig.json | 5 ++++- editor-formula/vite.config.ts | 25 ++++++++++-------------- 10 files changed, 72 insertions(+), 41 deletions(-) diff --git a/editor-formula/Formula.tsx b/editor-formula/Formula.tsx index e8ac71c..188ff10 100644 --- a/editor-formula/Formula.tsx +++ b/editor-formula/Formula.tsx @@ -33,7 +33,7 @@ interface FormulaProps { const Formula: FC<FormulaProps> = ({ editor, previewElement }) => { useRenderFormula(previewElement) const { t } = useTranslation('plugin', { - keyPrefix: 'formula', + keyPrefix: 'formula_editor.frontend', }) const [isLocked, setLockState] = useState(false) @@ -84,6 +84,7 @@ const Formula: FC<FormulaProps> = ({ editor, previewElement }) => { type="button" as={Button} variant="link" + title={t('title')} className="p-0 b-0 btn-no-border toolbar text-body" > <i className="bi bi-123" /> diff --git a/editor-formula/i18n/en_US.json b/editor-formula/i18n/en_US.json deleted file mode 100644 index 3769289..0000000 --- a/editor-formula/i18n/en_US.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "plugin": { - "formula": { - "text": "Formula", - "options": { - "inline": "Inline formula", - "block": "Block formula" - } - } - } -} \ No newline at end of file diff --git a/editor-formula/i18n/en_US.yaml b/editor-formula/i18n/en_US.yaml index c323f38..4efd1a4 100644 --- a/editor-formula/i18n/en_US.yaml +++ b/editor-formula/i18n/en_US.yaml @@ -23,3 +23,8 @@ plugin: other: Formula Editor description: other: Render formula in editor + frontend: + title: Formula + options: + inline: Inline formula + block: Block formula diff --git a/editor-formula/i18n/index.ts b/editor-formula/i18n/index.ts index 6853e76..7f7b453 100644 --- a/editor-formula/i18n/index.ts +++ b/editor-formula/i18n/index.ts @@ -17,8 +17,8 @@ * under the License. */ -import en_US from './en_US.json'; -import zh_CN from './zh_CN.json'; +import en_US from './en_US.yaml'; +import zh_CN from './zh_CN.yaml'; export default { en_US, diff --git a/editor-formula/i18n/zh_CN.json b/editor-formula/i18n/zh_CN.json deleted file mode 100644 index 50c18a9..0000000 --- a/editor-formula/i18n/zh_CN.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "plugin": { - "formula": { - "text": "公式", - "options": { - "inline": "行内公式", - "block": "公式块" - } - } - } -} \ No newline at end of file diff --git a/editor-formula/i18n/zh_CN.yaml b/editor-formula/i18n/zh_CN.yaml index 8520ffa..1b0b272 100644 --- a/editor-formula/i18n/zh_CN.yaml +++ b/editor-formula/i18n/zh_CN.yaml @@ -23,3 +23,8 @@ plugin: other: 公式编辑器 description: other: 在编辑器中渲染公式 + frontend: + title: 公式 + options: + inline: 行内公式 + block: 块公式 diff --git a/editor-formula/package.json b/editor-formula/package.json index f33548f..996f924 100644 --- a/editor-formula/package.json +++ b/editor-formula/package.json @@ -28,6 +28,7 @@ "react-i18next": "^11.18.3" }, "devDependencies": { + "@modyfi/vite-plugin-yaml": "^1.1.0", "@typescript-eslint/eslint-plugin": "^6.0.0", "@typescript-eslint/parser": "^6.0.0", "@vitejs/plugin-react-swc": "^3.3.2", diff --git a/editor-formula/pnpm-lock.yaml b/editor-formula/pnpm-lock.yaml index 7c2b10e..3f938d9 100644 --- a/editor-formula/pnpm-lock.yaml +++ b/editor-formula/pnpm-lock.yaml @@ -22,6 +22,9 @@ dependencies: version: 11.18.6([email protected])([email protected])([email protected]) devDependencies: + '@modyfi/vite-plugin-yaml': + specifier: ^1.1.0 + version: 1.1.0([email protected]) '@typescript-eslint/eslint-plugin': specifier: ^6.0.0 version: 6.21.0(@typescript-eslint/[email protected])([email protected])([email protected]) @@ -314,6 +317,19 @@ packages: resolution: {integrity: sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==} dev: true + /@modyfi/[email protected]([email protected]): + resolution: {integrity: sha512-L26xfzkSo1yamODCAtk/ipVlL6OEw2bcJ92zunyHu8zxi7+meV0zefA9xscRMDCsMY8xL3C3wi3DhMiPxcbxbw==} + peerDependencies: + vite: ^3.2.7 || ^4.0.5 || ^5.0.5 + dependencies: + '@rollup/pluginutils': 5.1.0 + js-yaml: 4.1.0 + tosource: 2.0.0-alpha.3 + vite: 4.5.3 + transitivePeerDependencies: + - rollup + dev: true + /@nodelib/[email protected]: resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -377,6 +393,20 @@ packages: warning: 4.0.3 dev: false + /@rollup/[email protected]: + resolution: {integrity: sha512-XTIWOPPcpvyKI6L1NHo0lFlCyznUEyPmPY1mc3KpPVDYulHSTvyeLNVW00QTLIAFNhR3kYnJTQHeGqU4M3n09g==} + engines: {node: '>=14.0.0'} + peerDependencies: + rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0 + peerDependenciesMeta: + rollup: + optional: true + dependencies: + '@types/estree': 1.0.5 + estree-walker: 2.0.2 + picomatch: 2.3.1 + dev: true + /@swc/[email protected]: resolution: {integrity: sha512-bZLVHPTpH3h6yhwVl395k0Mtx8v6CGhq5r4KQdAoPbADU974Mauz1b6ViHAJ74O0IVE5vyy7tD3OpkQxL/vMDQ==} engines: {node: '>=10'} @@ -508,6 +538,10 @@ packages: '@swc/counter': 0.1.3 dev: true + /@types/[email protected]: + resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==} + dev: true + /@types/[email protected]: resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} dev: true @@ -989,6 +1023,10 @@ packages: engines: {node: '>=4.0'} dev: true + /[email protected]: + resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==} + dev: true + /[email protected]: resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==} engines: {node: '>=0.10.0'} @@ -1599,6 +1637,11 @@ packages: is-number: 7.0.0 dev: true + /[email protected]: + resolution: {integrity: sha512-KAB2lrSS48y91MzFPFuDg4hLbvDiyTjOVgaK7Erw+5AmZXNq4sFRVn8r6yxSLuNs15PaokrDRpS61ERY9uZOug==} + engines: {node: '>=10'} + dev: true + /[email protected]([email protected]): resolution: {integrity: sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==} engines: {node: '>=16'} diff --git a/editor-formula/tsconfig.json b/editor-formula/tsconfig.json index d3c8b52..f7ada60 100644 --- a/editor-formula/tsconfig.json +++ b/editor-formula/tsconfig.json @@ -20,6 +20,9 @@ "noUnusedLocals": true, "noUnusedParameters": true, "noFallthroughCasesInSwitch": true, + "types": [ + "@modyfi/vite-plugin-yaml/modules" + ] }, - "references": [{ "path": "./tsconfig.node.json" }] + "references": [{ "path": "./tsconfig.node.json" }], } diff --git a/editor-formula/vite.config.ts b/editor-formula/vite.config.ts index 44969fb..3a20cc0 100644 --- a/editor-formula/vite.config.ts +++ b/editor-formula/vite.config.ts @@ -17,14 +17,15 @@ * under the License. */ -import { defineConfig } from 'vite'; -import react from '@vitejs/plugin-react-swc'; -import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'; -import packageJson from './package.json'; +import { defineConfig } from 'vite' +import react from '@vitejs/plugin-react-swc' +import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js' +import ViteYaml from '@modyfi/vite-plugin-yaml' +import packageJson from './package.json' // https://vitejs.dev/config/ export default defineConfig({ - plugins: [react(), cssInjectedByJsPlugin()], + plugins: [react(), cssInjectedByJsPlugin(), ViteYaml()], build: { lib: { entry: 'index.ts', @@ -32,22 +33,16 @@ export default defineConfig({ fileName: (format) => `${packageJson.name}.${format}.js`, }, rollupOptions: { - external: [ - 'react', - 'react-dom', - 'react-i18next', - 'react-bootstrap', - 'katex', - ], + external: ['react', 'react-dom', 'react-i18next', 'react-bootstrap', 'katex'], output: { globals: { - react: 'React', + 'react': 'React', 'react-dom': 'ReactDOM', 'react-i18next': 'reactI18next', 'react-bootstrap': 'reactBootstrap', - katex: 'katex', + 'katex': 'katex', }, }, }, }, -}); +})
