@bhsd/codemirror-mediawiki 2.16.0 → 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.16.0",
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",
@@ -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.16.0",
2
+ "version": "2.17.0",
3
3
  "lang": "zh-hans",
4
4
  "i18n-failed": "获取 $1 的语言文件失败。",
5
5
  "title": "CodeMirror插件",
@@ -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扩展。",
@@ -53,5 +54,6 @@
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.16.0",
2
+ "version": "2.17.0",
3
3
  "lang": "zh-hant",
4
4
  "i18n-failed": "取得 $1 的語言檔案失敗。",
5
5
  "title": "CodeMirror外掛程式",
@@ -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擴展。",
@@ -53,5 +54,6 @@
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
@@ -15,6 +15,13 @@
15
15
  .cm-tooltip-fold:hover {
16
16
  opacity: 1;
17
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
+ }
18
25
  .cm-focused .cm-matchingTag {
19
26
  background-color: rgba(50, 140, 130, .32);
20
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bhsd/codemirror-mediawiki",
3
- "version": "2.16.0",
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
  },