-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support chinese embed tiddler trigger brackets
- Loading branch information
Showing
6 changed files
with
51 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
`1.8.0`: 帮助菜单支持连续触发补全弹窗 | ||
`1.8.2`: 代码片段预览改成纯文本 | ||
`1.8.4`: 修复嵌入标题含有特殊引号的问题 | ||
`1.8.4`: 修复嵌入标题含有特殊引号的问题 | ||
`1.8.5`: 支持中文`【【` 触发 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
"registry": "https://registry.npmjs.org" | ||
}, | ||
"license": "MIT", | ||
"version": "1.8.4", | ||
"version": "1.8.5", | ||
"packageManager": "[email protected]", | ||
"scripts": { | ||
"update:config": " pnpm ts-node scripts/generateConfig.ts", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/tiddlywiki-codemirror-6/modules/completions/sources/tiddlers-cn.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { Completion } from '@codemirror/autocomplete'; | ||
import conf from '@/cm6/config'; | ||
import { renderTid } from '@/cm6/utils/renderTiddler'; | ||
import { EditorView } from '@codemirror/view'; | ||
|
||
const type = 'cm-tiddler'; | ||
const section = 'tiddlers'; | ||
const delimiter = '【【'; | ||
const description = 'Tiddler Embed in Chinese'; | ||
|
||
export function getAllTiddlers(delimiter: string) { | ||
const systemFilter = | ||
'[all[tiddlers+shadows]!has[draft.of]!prefix[$:/status]!preifx[$:/temp]!prefix[$:/state]!tag[$:/tags/TextEditor/Snippet]!prefix[$:/language]!prefix[$:/config/Server/]!prefix[Draft of]]'; | ||
const filter = conf.enableSystemTiddlersCompletion() | ||
? systemFilter | ||
: '[!is[system]!has[draft.of]]'; | ||
const allTiddlers = $tw.wiki.filterTiddlers(filter); | ||
|
||
return allTiddlers.map( | ||
(title) => | ||
({ | ||
label: delimiter + title, | ||
displayLabel: title.length > 35 ? title.slice(0, 35) + ' …' : title, | ||
type, | ||
section, | ||
boost: title.startsWith('$') ? 0 : 1, | ||
// NOTE: TypeError: Cannot set property parentNode of #<Node> which has only a getter, 部分 widget 使用到$tw 的 fakedom api, 会导致报错。 | ||
info: () => renderTid(title), | ||
apply: (view: EditorView, completion, from, to) => { | ||
view.dispatch({ | ||
changes: { from, to, insert: '[[' + title + ']]' } | ||
}); | ||
} | ||
}) as Completion | ||
); | ||
} | ||
|
||
export default { | ||
section, | ||
type, | ||
delimiter, | ||
description, | ||
snippets: () => getAllTiddlers(delimiter) | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters