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

Convert to class #2

Merged
merged 6 commits into from
Oct 22, 2023
Merged
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"@codemirror/lint": "^6.4.2",
"@codemirror/search": "^6.5.4",
"@codemirror/state": "^6.3.1",
"@codemirror/theme-one-dark": "^6.1.2",
"@codemirror/view": "^6.21.3",
"@lezer/common": "^1.1.0",
"@lezer/highlight": "^1.1.6",
Expand Down
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 35 additions & 23 deletions src/tiddlywiki-codemirror-6/engine.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
// @ts-nocheck
import { completeAnyWord } from '@codemirror/autocomplete';
import { tags } from '@lezer/highlight';
import { Vim, vim } from '@replit/codemirror-vim';
import { html, htmlLanguage } from '@codemirror/lang-html';
import { json, jsonLanguage } from '@codemirror/lang-json';
import { css, cssLanguage } from '@codemirror/lang-css';
import {
markdown,
markdownLanguage,
markdownKeymap,
} from '@codemirror/lang-markdown';
import { javascript, javascriptLanguage } from '@codemirror/lang-javascript';
import { HighlightStyle, syntaxHighlighting } from '@codemirror/language';
// @language
import {
HighlightStyle,
indentUnit,
defaultHighlightStyle,
syntaxHighlighting,
Expand All @@ -21,16 +10,26 @@ import {
foldGutter,
foldKeymap,
} from '@codemirror/language';
import { html, htmlLanguage } from '@codemirror/lang-html';
import { json, jsonLanguage } from '@codemirror/lang-json';
import { css, cssLanguage } from '@codemirror/lang-css';
import {
markdown,
markdownLanguage,
markdownKeymap,
} from '@codemirror/lang-markdown';
import { javascript, javascriptLanguage } from '@codemirror/lang-javascript';

import { EditorState, EditorSelection, Prec } from '@codemirror/state';
import {
searchKeymap,
highlightSelectionMatches,
openSearchPanel,
closeSearchPanel,
} from '@codemirror/search';

import {
autocompletion,
completeAnyWord,
completionKeymap,
closeBrackets,
closeBracketsKeymap,
Expand Down Expand Up @@ -59,13 +58,10 @@ import {
placeholder,
tooltips,
} from '@codemirror/view';
import {
indentWithTab,
history,
historyKeymap,
undo,
redo,
} from '@codemirror/commands';
import { tags } from '@lezer/highlight';
import { Vim, vim } from '@replit/codemirror-vim';
// import { oneDarkTheme, oneDarkHighlightStyle, } from '@codemirror/theme-one-dark';

// import { tiddlywiki, tiddlywikiLanguage } from '@codemirror/lang-tiddlywiki';

class CodeMirrorEngine {
Expand All @@ -92,8 +88,22 @@ class CodeMirrorEngine {
this.openSearchPanel = openSearchPanel;
this.closeSearchPanel = closeSearchPanel;

this.solarizedLightTheme = EditorView.theme({}, { dark: false });
this.solarizedDarkTheme = EditorView.theme({}, { dark: true });
this.solarizedLightTheme = EditorView.theme(
{
'&.cm-focused': {
outline: 'none',
},
},
{ dark: false },
);
this.solarizedDarkTheme = EditorView.theme(
{
'&.cm-focused': {
outline: 'none',
},
},
{ dark: true },
);

this.solarizedLightHighlightStyle =
$tw.utils.codemirror.getSolarizedLightHighlightStyle(
Expand Down Expand Up @@ -324,10 +334,12 @@ class CodeMirrorEngine {
editorExtensions.push(keymap.of([indentWithTab]));
}

// vim
editorExtensions.push(vim());
Vim.map('jk', '<Esc>', 'insert'); // in insert mode
Vim.map('H', '0', 'normal');
Vim.map('L', '$', 'normal');
// editorExtensions.push(oneDarkTheme);

if (
this.widget.wiki.getTiddlerText(
Expand Down
146 changes: 0 additions & 146 deletions src/tiddlywiki-codemirror-6/files/lib/one-dark.js

This file was deleted.

8 changes: 0 additions & 8 deletions src/tiddlywiki-codemirror-6/files/tiddlywiki.files
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
{
"tiddlers": [
{
"file": "lib/one-dark.js",
"fields": {
"type": "application/javascript",
"title": "$:/plugins/BTC/tiddlywiki-codemirror-6/lib/one-dark.js",
"module-type": "library"
}
},
{
"file": "modules/startup/load-codemirror-modules.js",
"fields": {
Expand Down
10 changes: 9 additions & 1 deletion src/tiddlywiki-codemirror-6/readme.tid
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ If you like the plugin, feel free to leave me a star on [ext[GitHub|https://gith
!! TODO

* [x] 字体大小问题
* lsp: https://github.com/FurqanSoftware/codemirror-languageserver
* [ ] autocompletion better
* [ ] multi cursor
* [ ] toggle line wrap config option
* subplugin for different language
* lang-tiddlywiki
* refactor engine.js to es6 class
* 焦点残留问题
* 调色板问题
* theme: https://github.com/codemirror/theme-one-dark
* tab to completion
* min completion length
3 changes: 3 additions & 0 deletions wiki/tiddlers/22nd October 2023.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const demo = 1;

console.log(demo)
5 changes: 5 additions & 0 deletions wiki/tiddlers/22nd October 2023.js.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
created: 20231022083508728
modified: 20231022083643066
tags: Journal
title: 22nd October 2023
type: application/javascript