Skip to content
This repository has been archived by the owner on Sep 24, 2021. It is now read-only.

Commit

Permalink
Some bug fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gk0Wk committed Aug 26, 2021
1 parent d030810 commit 7e195ec
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 41 deletions.
8 changes: 4 additions & 4 deletions build.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"meta": {
"version": "0.0.2",
"version": "0.0.3",
"type": "application/json",
"title": "$:/plugins/Gk0Wk/codemirror-mode-tiddlywiki5",
"plugin-type": "plugin",
"parent-plugin": "$:/plugins/tiddlywiki/codemirror",
"name": "CodeMirror Mode TiddlyWiki5",
"list": "readme-zh",
"list": "readme",
"description": "TiddlyWiki5 highlighting mode for CodeMirror",
"dependents": "$:/plugins/tiddlywiki/codemirror-mode-xml"
},
Expand Down Expand Up @@ -41,10 +41,10 @@
},
{
"type": "external",
"src": "./src/readme-zh.tw5",
"src": "./src/readme.tw5",
"meta": {
"type": "",
"title": "$:/plugins/Gk0Wk/codemirror-mode-tiddlywiki5/readme-zh",
"title": "$:/plugins/Gk0Wk/codemirror-mode-tiddlywiki5/readme",
"tags": ""
}
},
Expand Down
17 changes: 0 additions & 17 deletions src/readme-zh.tw5

This file was deleted.

5 changes: 5 additions & 0 deletions src/readme.tw5
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
View more on [[GitHub Repo|https://github.com/Gk0Wk/CodeMirror-Mode-TiddlyWiki5]].

Adds Syntax Highlighting for TiddlyWiki5 tiddlers (`text/vnd.tiddlywiki`) to the CodeMirror, along with some other useful editor addon (wikilink hint, macro hint, etc.). Now is under development.

为TiddlyWiki的CodeMirror编辑器添加TiddlyWiki5(`text/vnd.tiddlywiki`)语法高亮,同时还有其他有用的编辑器插件(如Wiki链接自动提示、宏提示等)。现在正在开发中。
2 changes: 1 addition & 1 deletion src/style.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.CodeMirror-hints {
/* 以免提示框被压在tiddler下面 */
z-index: 999999999999 !important;
z-index: 200 !important;
}

span.cm-underlined {
Expand Down
2 changes: 1 addition & 1 deletion src/style.min.css

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

26 changes: 13 additions & 13 deletions src/tw5-autohint.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
if (typeof exports === "object" && typeof module === "object") // CommonJS
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
else if (typeof define === "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
"use strict";

// 有新的editor实例创建,就Hook一下,达到实时提示的效果
CodeMirror.defineInitHook(editor => {
CodeMirror.defineInitHook(function (editor) {
// 如果补全建议中只有一个,不会自动补全,否则体验会非常糟糕
editor.options.hintOptions = {
completeSingle: false
};
// 当光标移动(输入、删除、光标移动)时进行补全
editor.on("cursorActivity", () => {
if (!editor.state.completeActive) {
editor.showHint();
editor.on("change", function (cm, event) {
if (!cm.state.completeActive && typeof cm.showHint === 'function') {
cm.showHint();
}
});
});
Expand All @@ -32,12 +32,12 @@

// wikilin匹配
// 向前找,找到[{|"为止,而如果找到]}.>或者到头,就不要继续找
var escapeChars = ['.', ']', '}', '>']
var stopChars = ['[', '{', '|', '"']
var escapeChars = ['.', ']', '}', '>'];
var stopChars = ['[', '{', '|', '"'];
while (pointer) {
var ch = curLine.charAt(pointer - 1)
var ch = curLine.charAt(pointer - 1);
if (end - pointer > max_length || escapeChars.includes(ch)) {
return null
return null;
}
if (!(stopChars.includes(ch))) {
pointer--;
Expand All @@ -52,13 +52,13 @@
list: $tw.wiki.filterTiddlers(`[all[tiddlers]search:title:literal[${curWord}]!prefix[$:/state]]`),
from: CodeMirror.Pos(cur.line, pointer),
to: CodeMirror.Pos(cur.line, end)
}
};
} else {
return {
list: $tw.wiki.filterTiddlers(`[all[tiddlers]!is[system]!is[shadow]search:title:literal[${curWord}]!prefix[$:/state]]`),
from: CodeMirror.Pos(cur.line, pointer),
to: CodeMirror.Pos(cur.line, end)
}
};
}
})
});
});
2 changes: 1 addition & 1 deletion src/tw5-autohint.min.js

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

6 changes: 3 additions & 3 deletions src/tw5-mode.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* Enhance from and specially thank to https://github.com/adithya-badidey/TW5-codemirror-plus */
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"), require("../xml/xml"));
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror", "../xml/xml"], mod);
define(["../../lib/codemirror"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
Expand Down Expand Up @@ -539,7 +539,7 @@
},
};
return mode;
}, "xml");
});

CodeMirror.defineMIME("text/vnd.tiddlywiki", "tiddlywiki5");
CodeMirror.defineMIME("", "tiddlywiki5");
Expand Down
Loading

0 comments on commit 7e195ec

Please sign in to comment.