Skip to content

Commit

Permalink
feat: support reset all config
Browse files Browse the repository at this point in the history
  • Loading branch information
oeyoews committed Oct 6, 2024
1 parent 4bc7934 commit 8600678
Show file tree
Hide file tree
Showing 15 changed files with 94 additions and 36 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Changelog

* `2.7.0`: 添加恢复默全部设置按钮
* `2.6.0`: 添加恢复默设置按钮
* `2.5.0`: 支持ghost text
* `2.4.1`: 添加category css
* `2.4.0`: 添加searchPosition 配置
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.5.0",
"version": "2.7.0",
"packageManager": "[email protected]",
"scripts": {
"update:config": " pnpm ts-node scripts/generateConfig.ts",
Expand Down
19 changes: 18 additions & 1 deletion src/tiddlywiki-codemirror-6/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type ITiddlerConfig = {
| 'markdown'
| 'placeholder'
| 'completion'
| 'keymap'
| 'fold';
description?: {
zh: string;
Expand Down Expand Up @@ -77,7 +78,7 @@ export const tiddlers = defineConfig({
},
text: 1,
description: {
zh: '新建tiddler自动生成N行',
zh: '新建tiddler自动生成N行(最大不超过20行)',
en: 'Max Lines'
}
},
Expand Down Expand Up @@ -118,8 +119,24 @@ export const tiddlers = defineConfig({
en: 'Line Wrapping'
}
},
keymap: {
caption: {
zh: '键位绑定',
en: 'KeyMap'
},
icon: '🎮',
category: 'keymap',
text: 'standard',
'option-names': 'standard vim',
'option-values': 'standard vim',
description: {
zh: '选择编辑器的键位绑定',
en: 'select editor keymap'
}
},
// vim
vimmode: {
disable: true,
caption: {
zh: 'Vim 模式',
en: 'Vim Mode'
Expand Down
4 changes: 2 additions & 2 deletions src/tiddlywiki-codemirror-6/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class CodeMirrorEngine {
extensions: this.cme
});

// main: create a codemirror6 instance
// #region main: create a codemirror6 instance
this.editor = new EditorView({
parent: this.domNode,
state: this.state
Expand All @@ -88,7 +88,7 @@ class CodeMirrorEngine {
// },
});
// @see https://github.com/replit/codemirror-vim/issues/6
if (cm6.vimmode() && cm6.insertModeFirst() && !options.value) {
if (cm6.keymap() === 'vim' && cm6.insertModeFirst() && !options.value) {
let editor = getCM(this.editor);
Vim.exitInsertMode(editor);
Vim.handleKey(editor, 'i');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export function snippets(widget: IWidget) {

// break;
case 'toggleMode':
const nextValue = cm6.vimmode() ? 'no' : 'yes';
const nextValue = cm6.keymap() === 'vim' ? 'no' : 'yes';
$tw.wiki.setText(
configBaseTitle + 'vimmode',
'text',
Expand Down
2 changes: 1 addition & 1 deletion src/tiddlywiki-codemirror-6/modules/extensions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default function updateExtensions(cme: Extension[], widget: IWidget) {
);
}

if (conf.vimmode()) {
if (conf.keymap() === 'vim') {
setVimKeymap(widget);
cme.push(Prec.high(vim())); // NOTE: not support new Comparement usage
}
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.5.0",
"version": "2.7.0",
"core-version": ">=5.3.4",
"list": "readme usage"
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ foldByIndent/caption: 📝 Fold By Indent
foldByIndent/description: Fold By Indent
lineWrapping/caption: ↩️ Line Wrapping
lineWrapping/description: Line Wrapping
vimmode/caption: 🎮 Vim Mode
vimmode/description: Enable Vim mode for text editing.
keymap/caption: 🎮 KeyMap
keymap/description: select editor keymap
vimJK/caption: ⌨️ Vim keyboard mapping JK(You know what I'm saying.)
vimJK/description: Fast Exit Insert Mode
insertModeFirst/caption: 📝 Insert Mode Auto Firstly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ title: $:/language/codemirror6/zh/
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行
lines/description: 新建tiddler自动生成N行(最大不超过20行)
foldGutter/caption: 📂 折叠按钮图标
foldGutter/description: 在编辑器行号右侧显示折叠按钮图标
foldByIndent/caption: 📝 按缩进折叠
foldByIndent/description: 按缩进折叠
lineWrapping/caption: ↩️ 自动换行
lineWrapping/description: 自动换行, 建议开启
vimmode/caption: 🎮 Vim 模式
vimmode/description: 启用文本编辑的 Vim 模式。
keymap/caption: 🎮 键位绑定
keymap/description: 选择编辑器的键位绑定
vimJK/caption: ⌨️ Vim JK
vimJK/description: 快速退出插入模式
insertModeFirst/caption: 📝 VIM自动进入插入模式
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
title: $:/config/codemirror-6/keymap
caption: {{$:/language/codemirror6/keymap/caption}}
caption-zh: {{$:/language/codemirror6/zh/keymap/caption}}
description: {{$:/language/codemirror6/keymap/description}}
description-zh: {{$:/language/codemirror6/zh/keymap/description}}
settings-template: $:/plugins/oeyoews/tiddlywiki-codemirror-6/ui/templates/settings/select
id: 6
settings-group: keymap
option-names: standard vim
option-values: standard vim

standard

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ subtitle: {{||$:/esc}}
\end

<!-- TODO: toggle i18n -->
Your codemirror6 config tiddlers: <$count filter="[prefix[$:/config/codemirror-6]] "/>/<$count filter="[all[tiddlers+shadows]prefix[$:/config/codemirror-6]]"/> (<small><$text text= {{{ [[$:/plugins/oeyoews/tiddlywiki-codemirror-6]get[version]] }}} /></small>)

Language: <$select tiddler="$:/config/codemirror6/language" tooltip='change codemirror6 config language'>
Your codemirror6 config tiddlers: <$count filter="[prefix[$:/config/codemirror-6]] "/>/<$count filter="[all[tiddlers+shadows]prefix[$:/config/codemirror-6]]"/> (<small><$text text= {{{ [[$:/plugins/oeyoews/tiddlywiki-codemirror-6]get[version]] }}} /></small>) Language: <$select tiddler="$:/config/codemirror6/language" tooltip='change codemirror6 config language'>
<option value=en>En</option>
<option value=zh>中文</option>
</$select>
</$select> <% if [prefix[$:/config/codemirror-6]] %> <$button> <!-- <$action-deletetiddler $filter="[prefix[$:/config/codemirror-6]]"/> --> reset all config to default
<$action-setfield $tiddler="$:/temp/advancedsearch" text="[prefix[$:/config/codemirror-6]]"/>
<$action-setfield $tiddler="$:/temp/advancedsearch/input" text="[prefix[$:/config/codemirror-6]]"/>
<$action-setfield $tiddler="$:/temp/advancedsearch/refresh" text="yes"/>
<$action-setfield $tiddler="$:/state/tab--1498284803" text="$:/core/ui/AdvancedSearch/Filter"/>
<$action-navigate $to="$:/AdvancedSearch" $scroll="no"/>
</$button>
<% endif %>

<$edit-text tiddler="$:/state/codemirror-6/settings/search" class="btc-search-input" default="" tag="input" type="search" placeholder="search..." focus="yes"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,25 @@ title: $:/plugins/oeyoews/tiddlywiki-codemirror-6/ui/templates/settings/input-sw
<$reveal type="match" state="$:/config/codemirror6/language" text="en">
<$link tooltip={{!!description}}>{{!!caption}}</$link>
<div>
<small>
{{!!description}}
<small> {{!!description}}
<% if [<currentTiddler>is[tiddler]] %>
<$button> Reset
<$action-deletetiddler $tiddler=<<currentTiddler>>/>
</$button>
<% endif %>
</small>
</div>
</$reveal>

<$reveal type="match" state="$:/config/codemirror6/language" text="zh">
<$link tooltip={{!!description-zh}}>{{!!caption-zh}}</$link>
<div>
<small>
{{!!description-zh}}
<small> {{!!description-zh}}
<% if [<currentTiddler>is[tiddler]] %>
<$button> 恢复默认设置
<$action-deletetiddler $tiddler=<<currentTiddler>>/>
</$button>
<% endif %>
</small>
</div>
</$reveal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,25 @@ title: $:/plugins/oeyoews/tiddlywiki-codemirror-6/ui/templates/settings/input
<$reveal type="match" state="$:/config/codemirror6/language" text="en">
<$link tooltip={{!!description}}>{{!!caption}}</$link>
<div>
<small>
{{!!description}}
<small> {{!!description}}
<% if [<currentTiddler>is[tiddler]] %>
<$button> Reset
<$action-deletetiddler $tiddler=<<currentTiddler>>/>
</$button>
<% endif %>
</small>
</div>
</$reveal>

<$reveal type="match" state="$:/config/codemirror6/language" text="zh">
<$link tooltip={{!!description-zh}}>{{!!caption-zh}}</$link>
<div>
<small>
{{!!description-zh}}
<small> {{!!description-zh}}
<% if [<currentTiddler>is[tiddler]] %>
<$button> 恢复默认设置
<$action-deletetiddler $tiddler=<<currentTiddler>>/>
</$button>
<% endif %>
</small>
</div>
</$reveal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,28 @@ title: $:/plugins/oeyoews/tiddlywiki-codemirror-6/ui/templates/settings/select

<$reveal type="match" state="$:/config/codemirror6/language" text="en">
<$link tooltip={{!!description}}>{{!!caption}}</$link>
<div><small> {{!!description}}</small></div>
<div>
<small> {{!!description}}
<% if [<currentTiddler>is[tiddler]] %>
<$button> Reset
<$action-deletetiddler $tiddler=<<currentTiddler>>/>
</$button>
<% endif %>
</small>
</div>
</$reveal>

<$reveal type="match" state="$:/config/codemirror6/language" text="zh">
<$link tooltip={{!!description-zh}}>{{!!caption-zh}}</$link>
<div><small> {{!!description-zh}}</small></div>
<div>
<small> {{!!description-zh}}
<% if [<currentTiddler>is[tiddler]] %>
<$button> 恢复默认设置
<$action-deletetiddler $tiddler=<<currentTiddler>>/>
</$button>
<% endif %>
</small>
</div>
</$reveal>

</label>
Expand Down

0 comments on commit 8600678

Please sign in to comment.