{ console.debug("Click:", detail.key); }}
>
💡 This is our default settings.
diff --git a/src/types/index.d.ts b/src/types/index.d.ts
index 1891c1a..f224b3e 100644
--- a/src/types/index.d.ts
+++ b/src/types/index.d.ts
@@ -1,10 +1,13 @@
-/**
- * Copyright (c) 2023 frostime. All rights reserved.
+/*
+ * Copyright (c) 2024 by frostime. All Rights Reserved.
+ * @Author : frostime
+ * @Date : 2023-08-15 10:28:10
+ * @FilePath : /src/types/index.d.ts
+ * @LastEditTime : 2024-06-08 20:50:53
+ * @Description : Frequently used data structures in SiYuan
*/
-/**
- * Frequently used data structures in SiYuan
- */
+
type DocumentId = string;
type BlockId = string;
type NotebookId = string;
@@ -28,7 +31,25 @@ type NotebookConf = {
dailyNoteTemplatePath: string;
}
-type BlockType = "d" | "s" | "h" | "t" | "i" | "p" | "f" | "audio" | "video" | "other";
+type BlockType =
+ | 'd'
+ | 'p'
+ | 'query_embed'
+ | 'l'
+ | 'i'
+ | 'h'
+ | 'iframe'
+ | 'tb'
+ | 'b'
+ | 's'
+ | 'c'
+ | 'widget'
+ | 't'
+ | 'html'
+ | 'm'
+ | 'av'
+ | 'audio';
+
type BlockSubType = "d1" | "d2" | "s1" | "s2" | "s3" | "t1" | "t2" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "table" | "task" | "toggle" | "latex" | "quote" | "html" | "code" | "footnote" | "cite" | "collection" | "bookmark" | "attachment" | "comment" | "mindmap" | "spreadsheet" | "calendar" | "image" | "audio" | "video" | "other";
@@ -70,6 +91,7 @@ type doOperation = {
interface Window {
siyuan: {
+ config: any;
notebooks: any;
menus: any;
dialogs: any;
@@ -78,5 +100,7 @@ interface Window {
user: any;
ws: any;
languages: any;
+ emojis: any;
};
+ Lute: any;
}
diff --git a/svelte.config.js b/svelte.config.js
index 7c8df62..d62a343 100644
--- a/svelte.config.js
+++ b/svelte.config.js
@@ -1,7 +1,26 @@
+/*
+ * Copyright (c) 2024 by frostime. All Rights Reserved.
+ * @Author : frostime
+ * @Date : 2023-05-19 19:49:13
+ * @FilePath : /svelte.config.js
+ * @LastEditTime : 2024-04-19 19:01:55
+ * @Description :
+ */
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte"
+const NoWarns = new Set([
+ "a11y-click-events-have-key-events",
+ "a11y-no-static-element-interactions",
+ "a11y-no-noninteractive-element-interactions"
+]);
+
export default {
// Consult https://svelte.dev/docs#compile-time-svelte-preprocess
// for more information about preprocessors
preprocess: vitePreprocess(),
+ onwarn: (warning, handler) => {
+ // suppress warnings on `vite dev` and `vite build`; but even without this, things still work
+ if (NoWarns.has(warning.code)) return;
+ handler(warning);
+ }
}
diff --git a/vite.config.ts b/vite.config.ts
index 4da8c11..31fc585 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -7,10 +7,12 @@ import { svelte } from "@sveltejs/vite-plugin-svelte"
import zipPack from "vite-plugin-zip-pack";
import fg from 'fast-glob';
+import vitePluginYamlI18n from './yaml-plugin';
+
const args = minimist(process.argv.slice(2))
const isWatch = args.watch || args.w || false
-const devDistDir = "./dev"
-const distDir = isWatch ? devDistDir : "./dist"
+const devDistDir = "dev"
+const distDir = isWatch ? devDistDir : "dist"
console.log("isWatch=>", isWatch)
console.log("distDir=>", distDir)
@@ -25,6 +27,11 @@ export default defineConfig({
plugins: [
svelte(),
+ vitePluginYamlI18n({
+ inDir: 'public/i18n',
+ outDir: `${distDir}/i18n`
+ }),
+
viteStaticCopy({
targets: [
{
diff --git a/yaml-plugin.js b/yaml-plugin.js
new file mode 100644
index 0000000..01c85e2
--- /dev/null
+++ b/yaml-plugin.js
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2024 by frostime. All Rights Reserved.
+ * @Author : frostime
+ * @Date : 2024-04-05 21:27:55
+ * @FilePath : /yaml-plugin.js
+ * @LastEditTime : 2024-04-05 22:53:34
+ * @Description : 去妮玛的 json 格式,我就是要用 yaml 写 i18n
+ */
+// plugins/vite-plugin-parse-yaml.js
+import fs from 'fs';
+import yaml from 'js-yaml';
+import { resolve } from 'path';
+
+export default function vitePluginYamlI18n(options = {}) {
+ // Default options with a fallback
+ const DefaultOptions = {
+ inDir: 'src/i18n',
+ outDir: 'dist/i18n',
+ };
+
+ const finalOptions = { ...DefaultOptions, ...options };
+
+ return {
+ name: 'vite-plugin-yaml-i18n',
+ buildStart() {
+ console.log('🌈 Parse I18n: YAML to JSON..');
+ const inDir = finalOptions.inDir;
+ const outDir = finalOptions.outDir
+
+ if (!fs.existsSync(outDir)) {
+ fs.mkdirSync(outDir, { recursive: true });
+ }
+
+ //Parse yaml file, output to json
+ const files = fs.readdirSync(inDir);
+ for (const file of files) {
+ if (file.endsWith('.yaml') || file.endsWith('.yml')) {
+ console.log(`-- Parsing ${file}`)
+ //检查是否有同名的json文件
+ const jsonFile = file.replace(/\.(yaml|yml)$/, '.json');
+ if (files.includes(jsonFile)) {
+ console.log(`---- File ${jsonFile} already exists, skipping...`);
+ continue;
+ }
+ try {
+ const filePath = resolve(inDir, file);
+ const fileContents = fs.readFileSync(filePath, 'utf8');
+ const parsed = yaml.load(fileContents);
+ const jsonContent = JSON.stringify(parsed, null, 2);
+ const outputFilePath = resolve(outDir, file.replace(/\.(yaml|yml)$/, '.json'));
+ console.log(`---- Writing to ${outputFilePath}`);
+ fs.writeFileSync(outputFilePath, jsonContent);
+ } catch (error) {
+ this.error(`---- Error parsing YAML file ${file}: ${error.message}`);
+ }
+ }
+ }
+ },
+ };
+}