@bhsd/codemirror-mediawiki 2.15.5 → 2.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ref.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ import { EditorView } from '@codemirror/view';
2
+ import type { AST } from 'wikiparser-node/base';
3
+ import type { editor } from 'monaco-editor';
4
+ declare type Ranges = [number, number][];
5
+ export declare const trees: WeakMap<EditorView | editor.ITextModel, Promise<AST> & {
6
+ docChanged?: boolean;
7
+ }>;
8
+ /**
9
+ * 异步查找注释的内容
10
+ * @param view
11
+ * @param target 目标名称
12
+ * @param all 是否查找所有
13
+ */
14
+ export declare const findRef: (view: EditorView | editor.ITextModel, target: string, all?: boolean) => Promise<Ranges>;
15
+ export declare const refHover: import("@codemirror/state").Extension[];
16
+ export {};
package/dist/token.d.ts CHANGED
@@ -4,72 +4,8 @@
4
4
  * @see https://gerrit.wikimedia.org/g/mediawiki/extensions/CodeMirror
5
5
  */
6
6
  import { Tag } from '@lezer/highlight';
7
+ import { tokens } from './config';
7
8
  import type { StreamParser, StringStream } from '@codemirror/language';
8
- declare const tokens: {
9
- apostrophes: string;
10
- comment: string;
11
- convertBracket: string;
12
- convertDelimiter: string;
13
- convertFlag: string;
14
- convertLang: string;
15
- doubleUnderscore: string;
16
- em: string;
17
- error: string;
18
- extLink: string;
19
- extLinkBracket: string;
20
- extLinkProtocol: string;
21
- extLinkText: string;
22
- extTag: string;
23
- extTagAttribute: string;
24
- extTagAttributeValue: string;
25
- extTagBracket: string;
26
- extTagName: string;
27
- fileText: string;
28
- freeExtLink: string;
29
- freeExtLinkProtocol: string;
30
- hr: string;
31
- htmlEntity: string;
32
- htmlTagAttribute: string;
33
- htmlTagAttributeValue: string;
34
- htmlTagBracket: string;
35
- htmlTagName: string;
36
- imageParameter: string;
37
- linkBracket: string;
38
- linkDelimiter: string;
39
- linkPageName: string;
40
- linkText: string;
41
- linkToSection: string;
42
- list: string;
43
- magicLink: string;
44
- pageName: string;
45
- parserFunction: string;
46
- parserFunctionBracket: string;
47
- parserFunctionDelimiter: string;
48
- parserFunctionName: string;
49
- redirect: string;
50
- section: string;
51
- sectionHeader: string;
52
- signature: string;
53
- skipFormatting: string;
54
- strong: string;
55
- tableBracket: string;
56
- tableCaption: string;
57
- tableDefinition: string;
58
- tableDefinitionValue: string;
59
- tableDelimiter: string;
60
- tableDelimiter2: string;
61
- tableTd: string;
62
- tableTh: string;
63
- template: string;
64
- templateArgumentName: string;
65
- templateBracket: string;
66
- templateDelimiter: string;
67
- templateName: string;
68
- templateVariable: string;
69
- templateVariableBracket: string;
70
- templateVariableDelimiter: string;
71
- templateVariableName: string;
72
- };
73
9
  declare type Style = string | [string];
74
10
  declare type Tokenizer<T = Style> = ((stream: StringStream, state: State) => T) & {
75
11
  args?: unknown[];
package/i18n/en.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.15.5",
2
+ "version": "2.17.0",
3
3
  "lang": "en",
4
4
  "i18n-failed": "Failed to fetch the translation file in $1.",
5
5
  "title": "CodeMirror Addons",
@@ -7,7 +7,7 @@
7
7
  "feedback": "Bug reports or suggestions are welcome at <a href=\"https://github.com/bhsd-harry/$1/issues\" target=\"_blank\">GitHub</a> .",
8
8
  "contentmodel": "Please indicate the content model:",
9
9
  "addon-allowMultipleSelections": "Allow multiple selections",
10
- "addon-autocompletion": "<span title=\"Ctrl-Space\">Autocompletion</span>",
10
+ "addon-autocompletion": "<span title=\"Shift-Enter\">Autocompletion</span>",
11
11
  "addon-bracketMatching": "Highlight matching/non-matching brackets",
12
12
  "addon-closeBrackets": "Auto-close brackets and quotes",
13
13
  "addon-codeFolding": "<span title=\"Ctrl-Shift-[ : fold\nCtrl-Shift-] : unfold\nCtrl-Alt-[ : fold all\nCtrl-Alt-] : unfold all\">Code folding</span>",
@@ -26,6 +26,7 @@
26
26
  "addon-save": "Save your preferences on a [[special:mypage/codemirror-mediawiki.json|user subpage]]",
27
27
  "addon-scrollPastEnd": "Scroll down past the end of the document",
28
28
  "addon-tagMatching": "Highlight matching/non-matching tags",
29
+ "addon-refHover": "Hover over a predefined reference to see its content (CodeMirror) or go to its difinition (Monaco)",
29
30
  "addon-useMonaco": "Use Monaco Editor for new editors",
30
31
  "addon-wikiEditor": "Load WikiEditor toolbar",
31
32
  "no-wikiEditor": "WikiEditor is not available.",
@@ -40,5 +41,6 @@
40
41
  "Stylelint-config": "Stylelint configuration as JSON:",
41
42
  "and": " and ",
42
43
  "json-error": "Invalid JSON: $1",
43
- "phrase-Fold-template-or-extension-tag": "Fold template, parser function or extension tag"
44
+ "phrase-Fold-template-or-extension-tag": "Fold template, parser function or extension tag",
45
+ "phrase-No-definition-found": "No definition found: "
44
46
  }
package/i18n/zh-hans.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.15.5",
2
+ "version": "2.17.0",
3
3
  "lang": "zh-hans",
4
4
  "i18n-failed": "获取 $1 的语言文件失败。",
5
5
  "title": "CodeMirror插件",
@@ -7,7 +7,7 @@
7
7
  "feedback": "欢迎将错误报告或是改进建议提交到 <a href=\"https://github.com/bhsd-harry/$1/issues\" target=\"_blank\">GitHub</a> !",
8
8
  "contentmodel": "请输入内容模型:",
9
9
  "addon-allowMultipleSelections": "允许选择多个片段",
10
- "addon-autocompletion": "<span title=\"Ctrl-Space\">自动填充</span>",
10
+ "addon-autocompletion": "<span title=\"Shift-Enter\">自动填充</span>",
11
11
  "addon-bracketMatching": "高亮显示匹配和未匹配的括号",
12
12
  "addon-closeBrackets": "自动闭合括号和引号",
13
13
  "addon-codeFolding": "<span title=\"Ctrl-Shift-[ : 折叠\nCtrl-Shift-] : 展开\nCtrl-Alt-[ : 折叠所有\nCtrl-Alt-] : 展开所有\">代码折叠</span>",
@@ -26,6 +26,7 @@
26
26
  "addon-save": "将设置保存至[[special:mypage/codemirror-mediawiki.json|用户子页面]]",
27
27
  "addon-scrollPastEnd": "允许向下滚动超过文档末尾",
28
28
  "addon-tagMatching": "高亮显示匹配和未匹配的标签",
29
+ "addon-refHover": "悬停在预定义的引用上可查看其内容(CodeMirror)或转到其定义(Monaco)",
29
30
  "addon-useMonaco": "新增的编辑区使用Monaco编辑器",
30
31
  "addon-wikiEditor": "加载WikiEditor工具栏",
31
32
  "no-wikiEditor": "未找到WikiEditor扩展。",
@@ -42,16 +43,17 @@
42
43
  "json-error": "JSON格式错误:$1",
43
44
  "phrase-Find": "查找",
44
45
  "phrase-next": "下一个",
45
- "phrase-previous": "前一个",
46
- "phrase-all": "所有",
46
+ "phrase-previous": "上一个",
47
+ "phrase-all": "全部",
47
48
  "phrase-match-case": "区分大小写",
48
49
  "phrase-regexp": "正则表达式",
49
- "phrase-by-word": "全字匹配",
50
+ "phrase-by-word": "逐字",
50
51
  "phrase-Replace": "替换",
51
52
  "phrase-replace": "替换",
52
- "phrase-replace-all": "替换所有",
53
+ "phrase-replace-all": "全部替换",
53
54
  "phrase-unfold": "展开",
54
55
  "phrase-Fold-line": "折叠行",
55
56
  "phrase-Unfold-line": "展开行",
56
- "phrase-Fold-template-or-extension-tag": "折叠模板、解析器函数或扩展标签"
57
+ "phrase-Fold-template-or-extension-tag": "折叠模板、解析器函数或扩展标签",
58
+ "phrase-No-definition-found": "未找到定义:"
57
59
  }
package/i18n/zh-hant.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.15.5",
2
+ "version": "2.17.0",
3
3
  "lang": "zh-hant",
4
4
  "i18n-failed": "取得 $1 的語言檔案失敗。",
5
5
  "title": "CodeMirror外掛程式",
@@ -7,7 +7,7 @@
7
7
  "feedback": "歡迎將錯誤報告或是改進建議提交到 <a href=\"https://github.com/bhsd-harry/$1/issues\" target=\"_blank\">GitHub</a> !",
8
8
  "contentmodel": "請輸入內容模型:",
9
9
  "addon-allowMultipleSelections": "允許選擇多個片段",
10
- "addon-autocompletion": "<span title=\"Ctrl-Space\">自動填入</span>",
10
+ "addon-autocompletion": "<span title=\"Shift-Enter\">自動填入</span>",
11
11
  "addon-bracketMatching": "突出顯示匹配和未匹配的括號",
12
12
  "addon-closeBrackets": "自動閉合括號和引號",
13
13
  "addon-codeFolding": "<span title=\"Ctrl-Shift-[ : 摺疊\nCtrl-Shift-] : 展開\nCtrl-Alt-[ : 摺疊全部\nCtrl-Alt-] : 展開全部\">程式碼折疊</span>",
@@ -26,6 +26,7 @@
26
26
  "addon-save": "將設定儲存至[[special:mypage/codemirror-mediawiki.json|使用者子頁面]]",
27
27
  "addon-scrollPastEnd": "允許向下滾動超過文件末尾",
28
28
  "addon-tagMatching": "突出顯示匹配和未匹配的標籤",
29
+ "addon-refHover": "懸停在預定義的參考上可查看其內容(CodeMirror)或轉到其定義(Monaco)",
29
30
  "addon-useMonaco": "新增的編輯區使用Monaco編輯器",
30
31
  "addon-wikiEditor": "載入WikiEditor工具列",
31
32
  "no-wikiEditor": "未找到WikiEditor擴展。",
@@ -40,18 +41,19 @@
40
41
  "Stylelint-config": "JSON格式的Stylelint設定:",
41
42
  "and": "和",
42
43
  "json-error": "JSON格式錯誤:$1",
43
- "phrase-Find": "搜尋",
44
- "phrase-next": "下一筆",
45
- "phrase-previous": "前一筆",
44
+ "phrase-Find": "尋找",
45
+ "phrase-next": "下一個",
46
+ "phrase-previous": "上一個",
46
47
  "phrase-all": "全部",
47
- "phrase-match-case": "大小寫須相符",
48
- "phrase-regexp": "正規表示法",
49
- "phrase-by-word": "符合整個字詞",
48
+ "phrase-match-case": "區分大小寫",
49
+ "phrase-regexp": "正規表示式",
50
+ "phrase-by-word": "逐字",
50
51
  "phrase-Replace": "取代",
51
52
  "phrase-replace": "取代",
52
53
  "phrase-replace-all": "全部取代",
53
54
  "phrase-unfold": "展開",
54
55
  "phrase-Fold-line": "摺疊行",
55
56
  "phrase-Unfold-line": "展開行",
56
- "phrase-Fold-template-or-extension-tag": "摺疊模板、解析器函數或擴展標籤"
57
+ "phrase-Fold-template-or-extension-tag": "摺疊模板、解析器函數或擴展標籤",
58
+ "phrase-No-definition-found": "未找到定義:"
57
59
  }
package/mediawiki.css CHANGED
@@ -1,6 +1,11 @@
1
1
  .cm-editor {
2
2
  background-color: #fff;
3
3
  }
4
+ .cm-search .cm-textfield,
5
+ .cm-search .cm-button,
6
+ .cm-panels > .cm-search.cm-panel label {
7
+ font-size: inherit;
8
+ }
4
9
  .cm-tooltip-fold {
5
10
  cursor: pointer;
6
11
  line-height: 1.2;
@@ -10,6 +15,13 @@
10
15
  .cm-tooltip-fold:hover {
11
16
  opacity: 1;
12
17
  }
18
+ .cm-tooltip-ref {
19
+ cursor: pointer;
20
+ padding: 2px 5px;
21
+ white-space: pre-wrap;
22
+ width: max-content;
23
+ max-width: 60vw;
24
+ }
13
25
  .cm-focused .cm-matchingTag {
14
26
  background-color: rgba(50, 140, 130, .32);
15
27
  }
@@ -92,7 +104,7 @@
92
104
 
93
105
  /* miscellaneous */
94
106
  .cm-mw-skipformatting {
95
- background-color: #adf;
107
+ background-color: rgba(134, 206, 255, .3);
96
108
  }
97
109
  .cm-mw-redirect,
98
110
  .cm-mw-list {
@@ -104,7 +116,7 @@
104
116
  .cm-mw-hr {
105
117
  color: #0076dd;
106
118
  font-weight: bold;
107
- background-color: #eee;
119
+ background-color: rgba(0, 0, 0, .07);
108
120
  }
109
121
  .cm-mw-comment {
110
122
  color: #7b8c8f;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bhsd/codemirror-mediawiki",
3
- "version": "2.15.5",
3
+ "version": "2.17.0",
4
4
  "description": "Modified CodeMirror mode based on wikimedia/mediawiki-extensions-CodeMirror",
5
5
  "keywords": [
6
6
  "mediawiki",
@@ -29,6 +29,7 @@
29
29
  "scripts": {
30
30
  "build:core": "esbuild ./src/codemirror.ts --bundle --minify --target=es2018 --format=esm --sourcemap --outfile=dist/main.min.js && tsc --emitDeclarationOnly",
31
31
  "build:mw": "esbuild ./mw/base.ts --bundle --minify --target=es2018 --format=esm --sourcemap --outfile=dist/mw.min.js",
32
+ "build:wiki": "esbuild ./mw/base.ts --bundle --minify --target=es2018 --format=iife --sourcemap --outfile=dist/mw.min.js",
32
33
  "build:gh-page": "bash build.sh",
33
34
  "build:test": "tsc --project test/tsconfig.json && node test/dist/test/test.js",
34
35
  "build": "npm run build:core && npm run build:mw",
@@ -39,7 +40,7 @@
39
40
  "lint": "npm run lint:ts && npm run lint:css",
40
41
  "prof": "node --prof test/dist/test/prof.js && node --prof-process isolate-0x*-v8.log > test/prof.txt && gsed -i '0,/Bottom up/d' test/prof.txt && rm isolate-0x*-v8.log",
41
42
  "server": "npm run test:end; http-server .. -c-1 --cors &",
42
- "test": "npm run build:core && npm run build:gh-page && npm run server",
43
+ "test": "npm run build:core && npm run build:wiki && npm run build:gh-page && npm run server",
43
44
  "test:end": "pkill -x http-server",
44
45
  "test:real": "node test/dist/test/real.js"
45
46
  },