Skip to content

Commit

Permalink
refactor(config): 更新中文配置描述
Browse files Browse the repository at this point in the history
  • Loading branch information
oeyoews committed Sep 25, 2024
1 parent 2d950c0 commit 7b6a059
Show file tree
Hide file tree
Showing 20 changed files with 151 additions and 192 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Changelog

* `1.9.0`: 更新中文配置描述

* `1.8.7`: 优化tiddler 弹窗预览样式
* `1.8.6`: 修复tiddler 跳转弹窗问题
* `1.8.5`: 支持中文`【【` 触发
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"registry": "https://registry.npmjs.org"
},
"license": "MIT",
"version": "1.8.7",
"version": "1.9.0",
"packageManager": "pnpm@9.0.6",
"scripts": {
"update:config": " pnpm ts-node scripts/generateConfig.ts",
Expand Down
128 changes: 64 additions & 64 deletions src/tiddlywiki-codemirror-6/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ export const tiddlers = defineConfig({
},
text: 'no'
},
EditorHeight: {
caption: {
zh: '最大高度',
en: 'Max Height'
},
text: ''
},
// EditorHeight: {
// caption: {
// zh: '最大高度',
// en: 'Max Height'
// },
// text: ''
// },
lines: {
caption: {
zh: '行数',
Expand Down Expand Up @@ -139,13 +139,13 @@ export const tiddlers = defineConfig({
},
activateOnTyping: {
caption: {
zh: '打字激活',
zh: '开启自动补全',
en: 'Activate on Typing'
},
text: 'yes',
icon: '🚀',
description: {
zh: '启用打字激活弹出补全框,关闭后,可以 ctrl+space 手动触发',
zh: '关闭后,可以 `CTRL+SPACE` 手动触发',
en: 'Enable activation on typing for enhanced functionality.'
}
},
Expand Down Expand Up @@ -189,7 +189,7 @@ export const tiddlers = defineConfig({
},
icon: '🔗',
description: {
zh: '启用超链接的预览。',
zh: '启用超链接预览。',
en: 'Enable preview for hyperlinks.'
}
},
Expand All @@ -202,7 +202,7 @@ export const tiddlers = defineConfig({
text: '',
icon: '📂',
description: {
zh: '设置字体以提高可读性。',
zh: '设置编辑器字体',
en: 'Set the font family for better readability.'
}
},
Expand All @@ -214,7 +214,7 @@ export const tiddlers = defineConfig({
text: '16px',
icon: '📏',
description: {
zh: '设置字体大小以提高可读性。',
zh: '设置编辑器字体大小',
en: 'Set the font size for better readability.'
}
},
Expand Down Expand Up @@ -258,7 +258,7 @@ export const tiddlers = defineConfig({
},
icon: '🔄',
description: {
zh: '启用系统 Tiddlers 的自动完成。',
zh: '更多关于系统条目标题的补全提示',
en: 'Enable completion for system tiddlers.'
}
},
Expand All @@ -270,7 +270,7 @@ export const tiddlers = defineConfig({
text: 'yes',
icon: '🔒',
description: {
zh: '失焦时自动关闭。',
zh: '光标不在编辑区域时, 自动隐藏自动补全弹窗',
en: 'Automatically close on blur.'
}
},
Expand All @@ -285,25 +285,25 @@ export const tiddlers = defineConfig({
en: 'Enable folding gutter for code.'
}
},
translate: {
caption: {
zh: '翻译',
en: 'Translate'
},
icon: '🌐',
description: {
zh: '启用翻译',
en: 'Enable translation.'
}
},
// translate: {
// caption: {
// zh: '翻译',
// en: 'Translate'
// },
// icon: '🌐',
// description: {
// zh: '启用翻译',
// en: 'Enable translation.'
// }
// },
rtl: {
caption: {
zh: 'RTL',
en: 'RTL'
},
icon: '↔️',
description: {
zh: '启用从右到左的文本方向',
zh: '启用从右到左的文本方向(不建议开启)',
en: 'Enable Right-to-Left text direction.'
}
},
Expand Down Expand Up @@ -333,7 +333,7 @@ export const tiddlers = defineConfig({
},
'clickable-icon': {
caption: {
zh: '可点击图标',
zh: '点击图标',
en: 'Clickable Icon'
},
text: '🐟',
Expand All @@ -350,18 +350,18 @@ export const tiddlers = defineConfig({
},
icon: '🖱️',
description: {
zh: '启用可点击性。',
zh: '可以在编辑区域内看到一个可以点击的图标',
en: 'Enable clickability.'
}
},
customPlaceholder: {
enableCustomPlaceholder: {
caption: {
zh: '自定义占位符',
zh: '启用自定义占位符',
en: 'Custom Placeholder'
},
icon: '🖊️',
description: {
zh: '设置自定义占位符。',
zh: '启用设置自定义占位符。',
en: 'Set a custom placeholder.'
}
},
Expand All @@ -373,7 +373,7 @@ export const tiddlers = defineConfig({
text: '✨ Write something ✒️ ...',
icon: '✏️️',
description: {
zh: '设置默认的占位符文本。',
zh: '设置自定义的占位符',
en: 'Set the default placeholder text.'
}
},
Expand All @@ -391,13 +391,13 @@ export const tiddlers = defineConfig({
},
minLength: {
caption: {
zh: '最小长度',
zh: '最小自动补全检测长度',
en: 'Min Length'
},
text: 1,
icon: '📏',
description: {
zh: '设置自动补全最小长度。1 为立刻触发',
zh: '设置自动补全最小长度。1为立刻触发',
en: 'Set the minimum length for input.'
}
},
Expand All @@ -420,7 +420,7 @@ export const tiddlers = defineConfig({
},
icon: '🗺️',
description: {
zh: '启用导航的小地图。',
zh: '启用右侧小地图',
en: 'Enable a minimap for navigation.'
}
},
Expand Down Expand Up @@ -473,7 +473,7 @@ export const tiddlers = defineConfig({
},
maxRenderedOptions: {
caption: {
zh: '最大渲染选项',
zh: '自动补全每页数量',
en: 'Max Rendered Options'
},
text: 20,
Expand All @@ -483,28 +483,28 @@ export const tiddlers = defineConfig({
en: 'Set the maximum number of rendered options in autocomplete.'
}
},
spellcheck: {
caption: {
zh: '拼写检查',
en: 'Spellcheck'
},
icon: '📝',
description: {
zh: '启用拼写检查。',
en: 'Enable spellchecking.'
}
},
autocorrect: {
caption: {
zh: '自动纠正',
en: 'Autocorrect'
},
icon: '🔄',
description: {
zh: '启用自动纠正。',
en: 'Enable autocorrection.'
}
},
// spellcheck: {
// caption: {
// zh: '拼写检查',
// en: 'Spellcheck'
// },
// icon: '📝',
// description: {
// zh: '启用拼写检查。',
// en: 'Enable spellchecking.'
// }
// },
// autocorrect: {
// caption: {
// zh: '自动纠正',
// en: 'Autocorrect'
// },
// icon: '🔄',
// description: {
// zh: '启用自动纠正。',
// en: 'Enable autocorrection.'
// }
// },
indentWithTab: {
caption: {
zh: '制表符缩进',
Expand Down Expand Up @@ -542,12 +542,12 @@ export const tiddlers = defineConfig({
},
completeAnyWord: {
caption: {
zh: '完成任意单词',
zh: '单词补全',
en: 'Complete Any Word'
},
icon: '🔄',
description: {
zh: '启用对任意单词的完成。',
zh: '如果当前编辑区域有重复输入的单词,重复输入时会提示',
en: 'Enable completion for any word.'
}
},
Expand All @@ -559,19 +559,19 @@ export const tiddlers = defineConfig({
text: 'no',
icon: '🔢',
description: {
zh: '显示行号以便更好地导航代码。',
zh: '开启行号',
en: 'Show line numbers for better code navigation.'
}
},
highlightActiveLine: {
caption: {
zh: '高亮活动行',
zh: '高亮当前行',
en: 'Highlight Active Line'
},
text: 'no',
icon: '🔍',
description: {
zh: '高亮活动行以便更好地可见。',
zh: '高亮光标所在行',
en: 'Highlight the active line for better visibility.'
}
},
Expand All @@ -595,7 +595,7 @@ export const tiddlers = defineConfig({
text: 'yes',
icon: '',
description: {
zh: 'tw 语法高亮(实验性',
zh: 'tw 语法高亮(实验性)',
en: 'tw systax highlight (experimental)'
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/tiddlywiki-codemirror-6/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ class CodeMirrorEngine {
private editor: EditorView;
private state: EditorState;
private dragCancel: boolean = false;
private maxHeight: string = '';
// private maxHeight: string = '';

constructor(options = {} as IOptions) {
this.widget = options.widget;
this.parentNode = options.parentNode;
this.nextSibling = options.nextSibling;

this.domNode = this.widget.document.createElement('div');
this.maxHeight = $tw.wiki.getTiddlerText(
'$:/config/codemirror-6/EditorHeight'
)!;
// this.maxHeight = $tw.wiki.getTiddlerText(
// '$:/config/codemirror-6/EditorHeight'
// )!;

this.domNode.style.maxHeight = this.maxHeight;
// this.domNode.style.maxHeight = this.maxHeight;
this.domNode.style.overflow = 'auto';

this.parentNode.insertBefore(this.domNode, this.nextSibling);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,6 @@ const type = 'cm-codeblock';
const delimiter = '```';
const description = 'generate codeblock';

const getIcontype = (text: string) => {
let type: ICompletionIcons = 'keyword';
switch (text) {
case 'js':
type = 'cm-js';
break;
case 'mermaid':
type = 'cm-mermaid';
break;
case 'html':
type = 'cm-html';
break;
default:
break;
}
return type;
};

const getBoostArrayFromArray = (arr: string[]) => {
return arr
.map((item, index) => {
Expand All @@ -35,7 +17,7 @@ const getBoostArrayFromArray = (arr: string[]) => {
};

function snippets() {
const types = ['js', 'mermaid', 'html'];
const types = ['html', 'js', 'mermaid'];
const cblTypes = types.map((item) => ({
title: item
}));
Expand All @@ -45,7 +27,7 @@ function snippets() {
snip(delimiter + `${item.title}\n#{1}\n` + delimiter, {
label: delimiter + item.title,
displayLabel: item.title,
type: getIcontype(item.title),
type: `cm-${item.title}`,
section,
boost: getBoostArrayFromArray(types)[index]
}) as Completion
Expand Down
Loading

0 comments on commit 7b6a059

Please sign in to comment.