Skip to content

Commit

Permalink
feat: add searchposition config
Browse files Browse the repository at this point in the history
  • Loading branch information
oeyoews committed Oct 4, 2024
1 parent 511bb0d commit d6e7ad3
Show file tree
Hide file tree
Showing 48 changed files with 138 additions and 79 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Changelog

* `2.4.0`: 添加searchPosition 配置
* `2.3.0`: 优化配置分组
* `2.2.2`: 重新添加 delimiter config
* `2.2.1`: 补全支持声音触发
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": "2.3.2",
"version": "2.4.0",
"packageManager": "pnpm@9.0.6",
"scripts": {
"update:config": " pnpm ts-node scripts/generateConfig.ts",
Expand Down
19 changes: 15 additions & 4 deletions scripts/generateConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ interface IConfigFields {
icon: string;
caption: I18n;
description: I18n;
template: 'input-switch' | 'input';
template: 'input-switch' | 'input' | 'select';
text: string;
// ---
disable: boolean;
category: string;
'option-names'?: string;
'option-values'?: string;
}

const templatePrefix =
Expand Down Expand Up @@ -56,12 +58,16 @@ tiddlersInfo.forEach(([title, fields], index) => {
text = 'no',
category = 'general'
} = fields;
const optionNames = fields['option-names'];
const optionvalues = fields['option-values'];

const captionEn =
icon + ' ' + caption.en.replace(/^\w/, (match) => match.toUpperCase());
const captionZh = icon + ' ' + caption.zh;

if (text === 'no' || text == 'yes') {
if (optionNames) {
template = 'select';
} else if (text === 'no' || text == 'yes') {
template = 'input-switch';
} else {
template = 'input';
Expand All @@ -70,16 +76,21 @@ tiddlersInfo.forEach(([title, fields], index) => {
multidcontentEn += `${title}/caption: ${captionEn}\n${title}/description: ${description.en}\n`;
multidcontentZH += `${title}/caption: ${captionZh}\n${title}/description: ${description.zh}\n`;

const content = `title: ${configBaseTitle}${title}
let content = `title: ${configBaseTitle}${title}
caption: {{$:/language/codemirror6/${title}/caption}}
caption-zh: {{$:/language/codemirror6/zh/${title}/caption}}
description: {{$:/language/codemirror6/${title}/description}}
description-zh: {{$:/language/codemirror6/zh/${title}/description}}
settings-template: ${templatePrefix}${template}
id: ${index + 1}
settings-group: ${category}
`;

${text}`;
if (optionNames) {
content += `option-names: ${optionNames}\noption-values: ${optionvalues}\n\n${text}`;
} else {
content += `\n${text}`;
}

const filepath = path.join(dir, title + '.tid');
fs.writeFileSync(filepath, content);
Expand Down
21 changes: 20 additions & 1 deletion src/tiddlywiki-codemirror-6/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ type ITiddlerConfig = {
zh: string;
en: string;
};
'option-names'?: string;
'option-values'?: string;
text?: string | number;
icon?: string;
category?:
Expand Down Expand Up @@ -196,11 +198,12 @@ export const tiddlers = defineConfig({
}
},
inlineSuggestion: {
disable: true,
disable: false,
caption: {
zh: '内联建议(实验性)',
en: 'Inline Suggestion (Experimental)'
},
text: 'yes',
icon: '🔍',
description: {
zh: '内联建议的实验性功能。',
Expand Down Expand Up @@ -621,6 +624,21 @@ export const tiddlers = defineConfig({
en: 'Highlight the active line for better visibility.'
}
},
// search
searchPosition: {
caption: {
zh: '搜索面板位置',
en: 'Search Position'
},
'option-names': 'top bottom',
'option-values': 'top bottom',
text: 'top',
icon: '🔍',
description: {
zh: '搜索面板位置, 默认在顶部',
en: 'Search Position'
}
},
enableTWMode: {
caption: {
zh: 'wikitext 语法高亮(实验性)',
Expand All @@ -641,6 +659,7 @@ export const tiddlers = defineConfig({
}
},
checkbox: {
disable: true,
icon: '☑️',
caption: {
zh: '复选框(JS)',
Expand Down
3 changes: 2 additions & 1 deletion src/tiddlywiki-codemirror-6/modules/extensions/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
indentOnInput
} from '@codemirror/language';
import { EditorState, Extension } from '@codemirror/state';
import { highlightSelectionMatches } from '@codemirror/search';
import { search, highlightSelectionMatches } from '@codemirror/search';

import { history } from '@codemirror/commands';

Expand Down Expand Up @@ -40,6 +40,7 @@ export function cme(self: any): Extension[] {
tabSizePlugin(),
fontSizeExt(),
indentUnit.of(' '),
search({ top: cm6.searchPosition() === 'top' }),
// EditorState.readOnly.of(true), // NOTE: lastest vim-mode extension has fix that bug

Prec.high(
Expand Down
2 changes: 1 addition & 1 deletion src/tiddlywiki-codemirror-6/plugin.info
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title": "$:/plugins/oeyoews/tiddlywiki-codemirror-6",
"name": "CodeMirror6",
"description": "CodeMirror 6 editor",
"version": "2.3.2",
"version": "2.4.0",
"core-version": ">=5.3.4",
"list": "readme usage"
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ caption-zh: {{$:/language/codemirror6/zh/autocompleteIcons/caption}}
description: {{$:/language/codemirror6/autocompleteIcons/description}}
description-zh: {{$:/language/codemirror6/zh/autocompleteIcons/description}}
settings-template: $:/plugins/oeyoews/tiddlywiki-codemirror-6/ui/templates/settings/input-switch
id: 33
id: 34
settings-group: completion

yes
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ caption-zh: {{$:/language/codemirror6/zh/bracketMatching/caption}}
description: {{$:/language/codemirror6/bracketMatching/description}}
description-zh: {{$:/language/codemirror6/zh/bracketMatching/description}}
settings-template: $:/plugins/oeyoews/tiddlywiki-codemirror-6/ui/templates/settings/input-switch
id: 32
id: 33
settings-group: general

no

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ caption-zh: {{$:/language/codemirror6/zh/clickable-icon/caption}}
description: {{$:/language/codemirror6/clickable-icon/description}}
description-zh: {{$:/language/codemirror6/zh/clickable-icon/description}}
settings-template: $:/plugins/oeyoews/tiddlywiki-codemirror-6/ui/templates/settings/input
id: 20
id: 21
settings-group: general

🐟
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ caption-zh: {{$:/language/codemirror6/zh/clickable/caption}}
description: {{$:/language/codemirror6/clickable/description}}
description-zh: {{$:/language/codemirror6/zh/clickable/description}}
settings-template: $:/plugins/oeyoews/tiddlywiki-codemirror-6/ui/templates/settings/input-switch
id: 21
id: 22
settings-group: general

no
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ caption-zh: {{$:/language/codemirror6/zh/closeBrackets/caption}}
description: {{$:/language/codemirror6/closeBrackets/description}}
description-zh: {{$:/language/codemirror6/zh/closeBrackets/description}}
settings-template: $:/plugins/oeyoews/tiddlywiki-codemirror-6/ui/templates/settings/input-switch
id: 29
id: 30
settings-group: general

yes
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ caption-zh: {{$:/language/codemirror6/zh/closeOnBlur/caption}}
description: {{$:/language/codemirror6/closeOnBlur/description}}
description-zh: {{$:/language/codemirror6/zh/closeOnBlur/description}}
settings-template: $:/plugins/oeyoews/tiddlywiki-codemirror-6/ui/templates/settings/input-switch
id: 18
id: 19
settings-group: general

yes
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ caption-zh: {{$:/language/codemirror6/zh/completeAnyWord/caption}}
description: {{$:/language/codemirror6/completeAnyWord/description}}
description-zh: {{$:/language/codemirror6/zh/completeAnyWord/description}}
settings-template: $:/plugins/oeyoews/tiddlywiki-codemirror-6/ui/templates/settings/input-switch
id: 37
id: 38
settings-group: completion

no
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
title: $:/language/codemirror6/

useSound/caption: 📝 Use Sound
useSound/caption: 🔊 Use Sound
useSound/description: Use Sound
lines/caption: 📝 Lines
lines/description: Max Lines
foldGutter/caption: 📂 Fold Gutter
foldGutter/description: Enable folding gutter for code.
foldByIndent/caption: 📝 Fold By Indent
foldByIndent/description: Fold By Indent
lineWrapping/caption: 📝 Line Wrapping
lineWrapping/caption: ↩️ Line Wrapping
lineWrapping/description: Line Wrapping
vimmode/caption: 🎮 Vim Mode
vimmode/description: Enable Vim mode for text editing.
vimJK/caption: 📝 Vim keyboard mapping JK(You know what I'm saying.)
vimJK/caption: ⌨️ Vim keyboard mapping JK(You know what I'm saying.)
vimJK/description: Fast Exit Insert Mode
insertModeFirst/caption: 📝 Insert Mode Auto Firstly
insertModeFirst/description: Insert Mode Auto Firstly
activateOnTyping/caption: 🚀 Activate on Typing
activateOnTyping/description: Enable activation on typing for enhanced functionality.
inlineSuggestion/caption: 🔍 Inline Suggestion (Experimental)
inlineSuggestion/description: Experimental feature for inline suggestions.
tiddlerPreview/caption: 📑 Tiddler Preview
tiddlerPreview/description: Enable preview for tiddlers.
snippetPreview/caption: 📝 Snippet Preview
snippetPreview/description: Enable preview for code snippets.
linkPreview/caption: 🔗 Link Preview
linkPreview/description: Enable preview for hyperlinks.
fontFamily/caption: 📂 Font Family
fontFamily/caption: 🅰️ Font Family
fontFamily/description: Set the font family for better readability.
fontsize/caption: 📏 Font Size
fontsize/description: Set the font size for better readability.
Expand All @@ -42,7 +44,7 @@ clickable-icon/caption: 🖱️ Clickable Icon
clickable-icon/description: Set a clickable icon.
clickable/caption: 🖱️ Clickable
clickable/description: Enable clickability.
enableCustomPlaceholder/caption: 🖊️ Custom Placeholder
enableCustomPlaceholder/caption: ️ Custom Placeholder
enableCustomPlaceholder/description: Set a custom placeholder.
placeholder/caption: ✏️️ Placeholder
placeholder/description: Set the default placeholder text.
Expand All @@ -66,7 +68,7 @@ bracketMatching/caption: 🔄 Bracket Matching
bracketMatching/description: Enable matching of brackets.
autocompleteIcons/caption: 🎨 Autocomplete Icons
autocompleteIcons/description: Enable icons in autocomplete suggestions.
footer/caption: 📝 Footer
footer/caption: 📜 Footer
footer/description: Show snippets footer
minLength/caption: 📏 Min Length
minLength/description: Set the minimum length for input.
Expand All @@ -76,19 +78,19 @@ completeAnyWord/caption: 🔄 Complete Any Word
completeAnyWord/description: Enable completion for any word.
enableSystemTiddlersCompletion/caption: 🔄 Enable System Tiddlers Completion
enableSystemTiddlersCompletion/description: Enable completion for system tiddlers.
maxRenderedOptions/caption: 🔍 Max Rendered Options
maxRenderedOptions/caption: 🔢 Max Rendered Options
maxRenderedOptions/description: Set the maximum number of rendered options in autocomplete.
lineNumbers/caption: 🔢 Line Numbers
lineNumbers/description: Show line numbers for better code navigation.
highlightActiveLine/caption: 🔍 Highlight Active Line
highlightActiveLine/description: Highlight the active line for better visibility.
searchPosition/caption: 🔍 Search Position
searchPosition/description: Search Position
enableTWMode/caption: Wikitext systax highlight (experimental)
enableTWMode/description: wikitexttw systax highlight (experimental)
todobox/caption: 📝 Task checkbox
todobox/caption: ☑️ Task checkbox
todobox/description: Task checkbox
checkbox/caption: 📝 Checkbox
checkbox/description: Checkbox
rtl/caption: ↔️ RTL
rtl/description: Enable Right-to-Left text direction.
removeOutline/caption: 📝 Remove editor outline
removeOutline/caption: 🚫 Remove editor outline
removeOutline/description: remove editor outline
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
title: $:/language/codemirror6/zh/

useSound/caption: 📝 开启音效
useSound/caption: 🔊 开启音效
useSound/description: 由插件 [[oeyoews/neotw-play-sound|https://neotw.vercel.app/#%24%3A%2Fplugins%2Foeyoews%2Fneotw-play-sound]] 提供声音支持, 默认关闭
lines/caption: 📝 自动生成行数
lines/description: 新建tiddler自动生成N行
foldGutter/caption: 📂 折叠按钮图标
foldGutter/description: 在编辑器行号右侧显示折叠按钮图标
foldByIndent/caption: 📝 按缩进折叠
foldByIndent/description: 按缩进折叠
lineWrapping/caption: 📝 自动换行
lineWrapping/caption: ↩️ 自动换行
lineWrapping/description: 自动换行, 建议开启
vimmode/caption: 🎮 Vim 模式
vimmode/description: 启用文本编辑的 Vim 模式。
vimJK/caption: 📝 Vim JK
vimJK/caption: ⌨️ Vim JK
vimJK/description: 快速退出插入模式
insertModeFirst/caption: 📝 VIM自动进入插入模式
insertModeFirst/description: VIM模式下新建tiddler自动进入插入模式
activateOnTyping/caption: 🚀 开启自动补全
activateOnTyping/description: 关闭后,可以 <kbd>CTRL+SPACE</kbd> 手动触发
inlineSuggestion/caption: 🔍 内联建议(实验性)
inlineSuggestion/description: 内联建议的实验性功能。
tiddlerPreview/caption: 📑 Tiddler 预览
tiddlerPreview/description: 启用 tiddlers 的预览。
snippetPreview/caption: 📝 / 预览文本
snippetPreview/description: 启用 `/` 代码片段的预览。
linkPreview/caption: 🔗 链接预览
linkPreview/description: 启用超链接预览。
fontFamily/caption: 📂 字体
fontFamily/caption: 🅰️ 字体
fontFamily/description: 设置编辑器字体
fontsize/caption: 📏 字体大小
fontsize/description: 设置编辑器字体大小
Expand All @@ -42,7 +44,7 @@ clickable-icon/caption: 🖱️ 点击图标
clickable-icon/description: 设置一个可点击的图标。
clickable/caption: 🖱️ 可点击
clickable/description: 可以在编辑区域内看到一个可以点击的图标 <kbd>CTRL+click</kbd>
enableCustomPlaceholder/caption: 🖊️ 启用自定义占位符
enableCustomPlaceholder/caption: ️ 启用自定义占位符
enableCustomPlaceholder/description: 启用设置自定义占位符。
placeholder/caption: ✏️️ 占位符
placeholder/description: 设置自定义的占位符
Expand All @@ -66,7 +68,7 @@ bracketMatching/caption: 🔄 括号匹配
bracketMatching/description: 启用括号匹配。
autocompleteIcons/caption: 🎨 自动完成图标
autocompleteIcons/description: 在自动完成建议中启用图标。
footer/caption: 📝 页脚
footer/caption: 📜 页脚
footer/description: 显示代码片段来源
minLength/caption: 📏 最小自动补全检测长度
minLength/description: 设置自动补全最小长度。1为立刻触发, 一般不建议修改
Expand All @@ -76,19 +78,19 @@ completeAnyWord/caption: 🔄 单词补全
completeAnyWord/description: 如果当前编辑区域有重复输入的单词,重复输入时会提示
enableSystemTiddlersCompletion/caption: 🔄 启用系统 Tiddlers 完成
enableSystemTiddlersCompletion/description: 更多关于系统条目标题的补全提示
maxRenderedOptions/caption: 🔍 自动补全每页数量
maxRenderedOptions/caption: 🔢 自动补全每页数量
maxRenderedOptions/description: 设置自动完成中渲染的选项的最大数量。(样式高度待调整)
lineNumbers/caption: 🔢 行号
lineNumbers/description: 开启行号
highlightActiveLine/caption: 🔍 高亮当前行
highlightActiveLine/description: 高亮光标所在行
searchPosition/caption: 🔍 搜索面板位置
searchPosition/description: 搜索面板位置, 默认在顶部
enableTWMode/caption: wikitext 语法高亮(实验性)
enableTWMode/description: wikitext 语法高亮(实验性)
todobox/caption: 📝 代办事项复选框(MD)
todobox/caption: ☑️ 代办事项复选框(MD)
todobox/description: 代办事项复选框(MD)
checkbox/caption: 📝 复选框(JS)
checkbox/description: 适用于tiddler类型为javascript, 用于切换常量的布尔值, 普通用户建议关闭
rtl/caption: ↔️ RTL
rtl/description: 启用从右到左的文本方向(中文不建议开启)
removeOutline/caption: 📝 移除编辑器边框
removeOutline/caption: 🚫 移除编辑器边框
removeOutline/description: 移除编辑器边框(配置待修复, 更改配置无效, 默认是移除)
Loading

0 comments on commit d6e7ad3

Please sign in to comment.