Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:Support keymap for vim mode #73

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions examples/plugins.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
import { ink, plugin } from 'ink-mde'
import { buildBlockWidgetDecoration, buildWidget, nodeDecorator } from '/lib/codemirror-kit'
import {
buildBlockWidgetDecoration,
buildWidget,
nodeDecorator,
} from '/lib/codemirror-kit'
import { katex } from '/plugins/katex'

ink(document.querySelector('#app')!, {
doc: '# Start with some text\n\nThis is some \$inline math\$\n\n\$\$\nc = \\pm\\sqrt{a^2 + b^2}\n\$\$\n\n```\nhi\n```\n\n```\nhello\n```',
doc: '# Start with some text\n\nThis is some $inline math$\n\n$$\nc = \\pm\\sqrt{a^2 + b^2}\n$$\n\n```\nhi\n```\n\n```\nhello\n```',
katex: true,
placeholder: 'This is a really long block of text... This is a really long block of text... This is a really long block of text... This is a really long block of text... This is a really long block of text... This is a really long block of text...',
placeholder:
'This is a really long block of text... This is a really long block of text... This is a really long block of text... This is a really long block of text... This is a really long block of text... This is a really long block of text...',
plugins: [
plugin({
value: async () => {
return nodeDecorator({
nodes: ['FencedCode'],
onMatch: (state, node) => {
const text = state.sliceDoc(node.from, node.to).split('\n').slice(1, -1).join('\n')
const text = state
.sliceDoc(node.from, node.to)
.split('\n')
.slice(1, -1)
.join('\n')

if (text) {
return buildBlockWidgetDecoration({
Expand Down Expand Up @@ -44,4 +53,14 @@ ink(document.querySelector('#app')!, {
}),
katex(),
],
vim: {
map: [
{
before: 'jj',
after: '<Esc>',
mode: 'insert',
},
],
open: true,
},
})
Loading
Loading