@bhsd/codemirror-mediawiki 2.28.0 → 2.29.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/i18n/en.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.28.0",
2
+ "version": "2.29.0",
3
3
  "lang": "en",
4
4
  "title": "CodeMirror Addons",
5
5
  "label": "Please select the addons you wish to load",
package/i18n/zh-hans.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.28.0",
2
+ "version": "2.29.0",
3
3
  "lang": "zh-hans",
4
4
  "title": "CodeMirror插件",
5
5
  "label": "请选择您希望加载的插件",
package/i18n/zh-hant.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.28.0",
2
+ "version": "2.29.0",
3
3
  "lang": "zh-hant",
4
4
  "title": "CodeMirror外掛程式",
5
5
  "label": "請選擇您希望載入的外掛程式",
package/mediawiki.css CHANGED
@@ -1,4 +1,4 @@
1
- .cm-editor{background-color:#fff}.cm-editor .cm-lineNumbers .cm-gutterElement{text-align:end}.cm-panel .cm-textfield,.cm-panel .cm-button,.cm-panels>.cm-search.cm-panel label,.cm-panels>.cm-gotoLine.cm-panel label{font-size:inherit}.cm-tooltip-fold{cursor:pointer;line-height:1.2;padding:0 1px;opacity:.6}.cm-tooltip-fold:hover{opacity:1}.cm-tooltip-ref,.cm-tooltip-hover{padding:2px 5px;width:max-content;max-width:60vw}.cm-tooltip-ref{cursor:pointer;white-space:pre-wrap}.cm-tooltip-hover *{margin-top:0!important;margin-bottom:0!important}.cm-tooltip-hover>div{font-size:90%;line-height:1.4}.cm-tooltip-hover code{background-color:#e0e6eb;padding:.1em .4em;border-radius:.4em}#cm-preference>.oo-ui-window-frame{height:100%!important}#cm-preference .oo-ui-panelLayout{overflow:visible}#cm-preference .cm-editor{border:1.5px solid #dedede;border-radius:.3em}#cm-preference .oo-ui-checkboxMultioptionWidget.oo-ui-widget-disabled{display:none}.wikiEditor-ui-toolbar{z-index:7}.codemirror-readonly .group-format,.codemirror-readonly .group-insert,.codemirror-readonly .tabs,.codemirror-readonly .sections,.codemirror-coding .group-format,.codemirror-coding .group-insert,.codemirror-coding .tabs,.codemirror-coding .sections{display:none}.wikiEditor-ui-toolbar:not(.codemirror-coding) .group-codemirror6-format{display:none!important}.cm-mw-section--1,.cm-mw-section--1~*{font-size:1.8em;line-height:1.2em}.cm-mw-section--2,.cm-mw-section--2~*{font-size:1.5em;line-height:1.2em}.cm-mw-section--3~*,.cm-mw-section--4~*,.cm-mw-section--5~*,.cm-mw-section--6~*{font-weight:700}.cm-mw-section-header{color:#0076dd;font-weight:400}.cm-mw-error{color:#d73333}.cm-mw-pagename,.cm-mw-link-tosection,.cm-mw-extlink-protocol,.cm-mw-extlink,.cm-mw-free-extlink-protocol,.cm-mw-free-extlink,.cm-mw-magic-link{text-decoration:underline}.cm-mw-skipformatting{background-color:#86ceff4d}.cm-mw-redirect,.cm-mw-list{color:#0076dd;font-weight:700}.cm-mw-double-underscore,.cm-mw-signature,.cm-mw-hr{color:#0076dd;font-weight:700;background-color:#00000012}.cm-mw-comment{color:#7b8c8f;font-weight:400}.cm-mw-apostrophes{color:#0076dd}.cm-mw-template{font-weight:400}.cm-mw-template-name,.cm-mw-template-delimiter,.cm-mw-template-bracket{color:#80c;font-weight:700}.cm-mw-template-argument-name{color:#b0c;font-weight:400}.cm-mw-templatevariable{color:#ad9300;font-weight:400}.cm-mw-templatevariable-name,.cm-mw-templatevariable-bracket,.cm-mw-templatevariable-delimiter{color:#ac6600;font-weight:700}.cm-mw-parserfunction{font-weight:400}.cm-mw-parserfunction-name,.cm-mw-parserfunction-bracket,.cm-mw-parserfunction-delimiter{color:#a11;font-weight:700}.cm-mw-link-pagename,.cm-mw-link-bracket,.cm-mw-link-delimiter,.cm-mw-file-delimiter,.cm-mw-extlink,.cm-mw-free-extlink,.cm-mw-magic-link{color:#000aaa;font-weight:400}.cm-mw-image-parameter,.cm-mw-link-tosection{color:#006fe6;font-weight:400}.cm-mw-extlink-protocol,.cm-mw-free-extlink-protocol,.cm-mw-extlink-bracket{color:#000aaa;font-weight:700}.cm-mw-strong{font-weight:700}.cm-mw-em{font-style:italic}.cm-mw-exttag-name,.cm-mw-htmltag-name{color:#14866d;font-weight:700}.cm-mw-exttag-bracket,.cm-mw-exttag-attribute,.cm-mw-htmltag-bracket,.cm-mw-htmltag-attribute{color:#14866d;font-weight:400}.cm-mw-exttag-attribute-value,.cm-mw-htmltag-attribute-value{color:#179b1c;font-weight:400}.cm-mw-table-bracket,.cm-mw-table-delimiter{color:#d08;font-weight:700}.cm-mw-table-delimiter2,.cm-mw-table-definition{color:#d08;font-weight:400}.cm-mw-table-definition-value{color:#f500d4;font-weight:400}.cm-mw-table-th,.cm-mw-table-caption{font-weight:700}.cm-mw-convert-bracket,.cm-mw-convert-delimiter{color:#b68;font-weight:700}.cm-mw-convert-flag,.cm-mw-convert-lang{color:#b68}.cm-mw-entity{color:#00a1a1}.cm-mw-template-ground{background-color:#aa11110a}.cm-mw-template2-ground{background-color:#aa111114}.cm-mw-template3-ground{background-color:#aa11111f}.cm-mw-template-ext-ground,.cm-mw-ext-ground,.cm-mw-exttag{background-color:#7700aa0a}.cm-mw-template-ext2-ground,.cm-mw-ext2-ground{background-color:#7700aa14}.cm-mw-template-ext3-ground,.cm-mw-ext3-ground{background-color:#7700aa1f}.cm-mw-template-link-ground,.cm-mw-ext-link-ground,.cm-mw-link-ground{background-color:#2211990a}.cm-mw-template-ext-link-ground,.cm-mw-ext2-link-ground{background-color:#4d09a214}.cm-mw-template-ext2-link-ground,.cm-mw-ext3-link-ground{background-color:#5b06a41f}.cm-mw-template-ext3-link-ground{background-color:#6204a629}.cm-mw-template2-ext-ground{background-color:#91095e14}.cm-mw-template2-ext2-ground{background-color:#8806771f}.cm-mw-template2-ext3-ground{background-color:#84048429}.cm-mw-template2-link-ground{background-color:#66115514}.cm-mw-template2-ext-link-ground{background-color:#6c0b711f}.cm-mw-template2-ext2-link-ground{background-color:#6f098029}.cm-mw-template2-ext3-link-ground{background-color:#70078833}.cm-mw-template3-ext-ground{background-color:#990b441f}.cm-mw-template3-ext2-ground{background-color:#91095e29}.cm-mw-template3-ext3-ground{background-color:#8b076d33}.cm-mw-template3-link-ground{background-color:#7d113e1f}.cm-mw-template3-ext-link-ground{background-color:#7b0d5929}.cm-mw-template3-ext2-link-ground{background-color:#7a0a6933}.cm-mw-template3-ext3-link-ground{background-color:#7a09743d}.cm-mw-tag-pre,.cm-mw-tag-nowiki{background-color:#0000000a}.cm-bidi-isolate,.cm-editor[dir=rtl] .cm-mw-template-name{unicode-bidi:isolate}.cm-bidi-ltr{direction:ltr;display:inline-block}.cm-focused .cm-matchingTag{background-color:#328c8252}.cm-focused .cm-nonmatchingTag{background-color:#bb555545}.cm-inlay-hint{color:#969696;font-style:italic;-webkit-user-select:none;user-select:none}.cm-panel-status{line-height:1.4}.cm-panel-status>div{padding:0 .3em;display:table-cell}.cm-status-worker{user-select:none}.cm-status-worker>*{display:table-cell;white-space:nowrap}.cm-status-error,.cm-status-warning{padding-right:8px}.cm-status-worker-enabled .cm-status-error,.cm-status-worker-enabled .cm-status-warning{cursor:pointer}.cm-status-worker>*>div{display:inline-block;vertical-align:middle}.cm-status-worker>*>div:first-child{margin-right:4px;width:1em;height:1em}.cm-status-fix-disabled,.cm-status-fix-enabled{mask-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><g><path d="M8 19a1 1 0 001 1h2a1 1 0 001-1v-1H8zm9-12a7 7 0 10-12 4.9S7 14 7 15v1a1 1 0 001 1h4a1 1 0 001-1v-1c0-1 2-3.1 2-3.1A7 7 0 0017 7"></path></g></svg>');mask-size:100%;mask-repeat:no-repeat;mask-position:center}.cm-status-fix-disabled{background-color:#dadde3}.cm-status-fix-enabled{background-color:#ffce31;cursor:pointer}.cm-status-fix-menu{display:none;position:absolute;z-index:301;background-color:#f5f5f5;border:1px solid #ddd;border-radius:2px;box-shadow:0 2px 2px #00000040;outline:none;white-space:nowrap}.cm-status-fix-menu>div{padding:1px 5px;cursor:pointer}.cm-status-fix-menu>div:hover{background-color:#e2f2ff}.cm-status-message{border-left:1px solid #c8ccd1;border-right:1px solid #c8ccd1;width:100%}.cm-status-message .cm-diagnosticAction{padding-top:0;padding-bottom:0}.cm-status-line{white-space:nowrap}span.mtku{text-decoration:none}.monaco-container{min-height:2em}
1
+ .cm-editor{background-color:#fff}.cm-editor .cm-lineNumbers .cm-gutterElement{text-align:end}.cm-panel .cm-textfield,.cm-panel .cm-button,.cm-panels>.cm-search.cm-panel label,.cm-panels>.cm-gotoLine.cm-panel label{font-size:inherit}.cm-tooltip-fold{cursor:pointer;line-height:1.2;padding:0 1px;opacity:.6}.cm-tooltip-fold:hover{opacity:1}.cm-tooltip-ref,.cm-tooltip-hover{padding:2px 5px;width:max-content;max-width:60vw}.cm-tooltip-ref{cursor:pointer;white-space:pre-wrap}.cm-tooltip-hover *{margin-top:0!important;margin-bottom:0!important}.cm-tooltip-hover>div{font-size:90%;line-height:1.4}.cm-tooltip-hover code{background-color:#e0e6eb;padding:.1em .4em;border-radius:.4em}#cm-preference>.oo-ui-window-frame{height:100%!important}#cm-preference .oo-ui-panelLayout{overflow:visible}#cm-preference .cm-editor{border:1.5px solid #dedede;border-radius:.3em}#cm-preference .oo-ui-checkboxMultioptionWidget.oo-ui-widget-disabled{display:none}.wikiEditor-ui-toolbar{z-index:7}.codemirror-readonly .group-format,.codemirror-readonly .group-insert,.codemirror-readonly .tabs,.codemirror-readonly .sections,.codemirror-coding .group-format,.codemirror-coding .group-insert,.codemirror-coding .tabs,.codemirror-coding .sections{display:none}.codemirror-wiki .group-codemirror6-format,.codemirror-wiki .group-codemirror6-search{display:none!important}.codeEditor-ui-toolbar .group-codemirror6{display:none}.cm-mw-section--1,.cm-mw-section--1~*{font-size:1.8em;line-height:1.2em}.cm-mw-section--2,.cm-mw-section--2~*{font-size:1.5em;line-height:1.2em}.cm-mw-section--3~*,.cm-mw-section--4~*,.cm-mw-section--5~*,.cm-mw-section--6~*{font-weight:700}.cm-mw-section-header{color:#0076dd;font-weight:400}.cm-mw-error{color:#d73333}.cm-mw-pagename,.cm-mw-link-tosection,.cm-mw-extlink-protocol,.cm-mw-extlink,.cm-mw-free-extlink-protocol,.cm-mw-free-extlink,.cm-mw-magic-link{text-decoration:underline}.cm-mw-skipformatting{background-color:#86ceff4d}.cm-mw-redirect,.cm-mw-list{color:#0076dd;font-weight:700}.cm-mw-double-underscore,.cm-mw-signature,.cm-mw-hr{color:#0076dd;font-weight:700;background-color:#00000012}.cm-mw-comment{color:#7b8c8f;font-weight:400}.cm-mw-apostrophes{color:#0076dd}.cm-mw-template{font-weight:400}.cm-mw-template-name,.cm-mw-template-delimiter,.cm-mw-template-bracket{color:#80c;font-weight:700}.cm-mw-template-argument-name{color:#b0c;font-weight:400}.cm-mw-templatevariable{color:#ad9300;font-weight:400}.cm-mw-templatevariable-name,.cm-mw-templatevariable-bracket,.cm-mw-templatevariable-delimiter{color:#ac6600;font-weight:700}.cm-mw-parserfunction{font-weight:400}.cm-mw-parserfunction-name,.cm-mw-parserfunction-bracket,.cm-mw-parserfunction-delimiter{color:#a11;font-weight:700}.cm-mw-link-pagename,.cm-mw-link-bracket,.cm-mw-link-delimiter,.cm-mw-file-delimiter,.cm-mw-extlink,.cm-mw-free-extlink,.cm-mw-magic-link{color:#000aaa;font-weight:400}.cm-mw-image-parameter,.cm-mw-link-tosection{color:#006fe6;font-weight:400}.cm-mw-extlink-protocol,.cm-mw-free-extlink-protocol,.cm-mw-extlink-bracket{color:#000aaa;font-weight:700}.cm-mw-strong{font-weight:700}.cm-mw-em{font-style:italic}.cm-mw-exttag-name,.cm-mw-htmltag-name{color:#14866d;font-weight:700}.cm-mw-exttag-bracket,.cm-mw-exttag-attribute,.cm-mw-htmltag-bracket,.cm-mw-htmltag-attribute{color:#14866d;font-weight:400}.cm-mw-exttag-attribute-value,.cm-mw-htmltag-attribute-value{color:#179b1c;font-weight:400}.cm-mw-table-bracket,.cm-mw-table-delimiter{color:#d08;font-weight:700}.cm-mw-table-delimiter2,.cm-mw-table-definition{color:#d08;font-weight:400}.cm-mw-table-definition-value{color:#f500d4;font-weight:400}.cm-mw-table-th,.cm-mw-table-caption{font-weight:700}.cm-mw-convert-bracket,.cm-mw-convert-delimiter{color:#b68;font-weight:700}.cm-mw-convert-flag,.cm-mw-convert-lang{color:#b68}.cm-mw-entity{color:#00a1a1}.cm-mw-template-ground{background-color:#aa11110a}.cm-mw-template2-ground{background-color:#aa111114}.cm-mw-template3-ground{background-color:#aa11111f}.cm-mw-template-ext-ground,.cm-mw-ext-ground,.cm-mw-exttag{background-color:#7700aa0a}.cm-mw-template-ext2-ground,.cm-mw-ext2-ground{background-color:#7700aa14}.cm-mw-template-ext3-ground,.cm-mw-ext3-ground{background-color:#7700aa1f}.cm-mw-template-link-ground,.cm-mw-ext-link-ground,.cm-mw-link-ground{background-color:#2211990a}.cm-mw-template-ext-link-ground,.cm-mw-ext2-link-ground{background-color:#4d09a214}.cm-mw-template-ext2-link-ground,.cm-mw-ext3-link-ground{background-color:#5b06a41f}.cm-mw-template-ext3-link-ground{background-color:#6204a629}.cm-mw-template2-ext-ground{background-color:#91095e14}.cm-mw-template2-ext2-ground{background-color:#8806771f}.cm-mw-template2-ext3-ground{background-color:#84048429}.cm-mw-template2-link-ground{background-color:#66115514}.cm-mw-template2-ext-link-ground{background-color:#6c0b711f}.cm-mw-template2-ext2-link-ground{background-color:#6f098029}.cm-mw-template2-ext3-link-ground{background-color:#70078833}.cm-mw-template3-ext-ground{background-color:#990b441f}.cm-mw-template3-ext2-ground{background-color:#91095e29}.cm-mw-template3-ext3-ground{background-color:#8b076d33}.cm-mw-template3-link-ground{background-color:#7d113e1f}.cm-mw-template3-ext-link-ground{background-color:#7b0d5929}.cm-mw-template3-ext2-link-ground{background-color:#7a0a6933}.cm-mw-template3-ext3-link-ground{background-color:#7a09743d}.cm-mw-tag-pre,.cm-mw-tag-nowiki{background-color:#0000000a}.cm-bidi-isolate,.cm-editor[dir=rtl] .cm-mw-template-name{unicode-bidi:isolate}.cm-bidi-ltr{direction:ltr;display:inline-block}.cm-focused .cm-matchingTag{background-color:#328c8252}.cm-focused .cm-nonmatchingTag{background-color:#bb555545}.cm-inlay-hint{color:#969696;font-style:italic;-webkit-user-select:none;user-select:none}.cm-panel-status{line-height:1.4}.cm-panel-status>div{padding:0 .3em;display:table-cell}.cm-status-worker{user-select:none}.cm-status-worker>*{display:table-cell;white-space:nowrap}.cm-status-error,.cm-status-warning{padding-right:8px}.cm-status-worker-enabled .cm-status-error,.cm-status-worker-enabled .cm-status-warning{cursor:pointer}.cm-status-worker>*>div{display:inline-block;vertical-align:middle}.cm-status-worker>*>div:first-child{margin-right:4px;width:1em;height:1em}.cm-status-fix-disabled,.cm-status-fix-enabled{mask-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><g><path d="M8 19a1 1 0 001 1h2a1 1 0 001-1v-1H8zm9-12a7 7 0 10-12 4.9S7 14 7 15v1a1 1 0 001 1h4a1 1 0 001-1v-1c0-1 2-3.1 2-3.1A7 7 0 0017 7"></path></g></svg>');mask-size:100%;mask-repeat:no-repeat;mask-position:center}.cm-status-fix-disabled{background-color:#dadde3}.cm-status-fix-enabled{background-color:#ffce31;cursor:pointer}.cm-status-fix-menu{display:none;position:absolute;z-index:301;background-color:#f5f5f5;border:1px solid #ddd;border-radius:2px;box-shadow:0 2px 2px #00000040;outline:none;white-space:nowrap}.cm-status-fix-menu>div{padding:1px 5px;cursor:pointer}.cm-status-fix-menu>div:hover{background-color:#e2f2ff}.cm-status-message{border-left:1px solid #c8ccd1;border-right:1px solid #c8ccd1;width:100%}.cm-status-message .cm-diagnosticAction{padding-top:0;padding-bottom:0}.cm-status-line{white-space:nowrap}span.mtku{text-decoration:none}.monaco-container{min-height:2em}
2
2
  /**
3
3
  * @author pastakhov and others
4
4
  * @license GPL-2.0-or-later
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bhsd/codemirror-mediawiki",
3
- "version": "2.28.0",
3
+ "version": "2.29.0",
4
4
  "description": "Modified CodeMirror mode based on wikimedia/mediawiki-extensions-CodeMirror",
5
5
  "keywords": [
6
6
  "mediawiki",
@@ -16,13 +16,12 @@
16
16
  "/i18n/",
17
17
  "/dist/*.js",
18
18
  "/dist/*.d.ts",
19
- "/dist/*.mjs",
20
- "/dist/*.d.mts",
21
19
  "/mediawiki.css"
22
20
  ],
23
21
  "browser": "dist/main.min.js",
24
- "main": "./dist/main.min.js",
22
+ "main": "./dist/codemirror.js",
25
23
  "types": "./dist/codemirror.d.ts",
24
+ "type": "module",
26
25
  "sideEffects": false,
27
26
  "repository": {
28
27
  "type": "git",
@@ -30,13 +29,15 @@
30
29
  },
31
30
  "scripts": {
32
31
  "prepublishOnly": "npm run build",
32
+ "bundle:core": "esbuild ./src/codemirror.ts --charset=utf8 --bundle --format=esm --outfile=build/main.js",
33
+ "bundle:wiki": "esbuild ./mw/index.ts --charset=utf8 --bundle --format=esm --outfile=build/wiki.js",
33
34
  "build:css": "esbuild ./css/index.css --bundle --minify --outfile=mediawiki.css",
34
- "build:core": "esbuild ./src/codemirror.ts --charset=utf8 --bundle --minify --target=es2019 --format=esm --sourcemap --outfile=dist/main.min.js && esbuild ./src/linter.ts ./src/keybindings.ts --charset=utf8 --target=es2019 --format=esm --outdir=dist --out-extension:.js=.mjs && tsc --emitDeclarationOnly && cp dist/linter.d.ts dist/linter.d.mts && cp dist/keybindings.d.ts dist/keybindings.d.mts && mv dist/mwConfig.d.ts dist/mwConfig.d.mts && rm dist/*-page.d.ts",
35
- "build:mw": "esbuild ./mw/index.ts --charset=utf8 --bundle --minify --target=es2019 --format=esm --outfile=dist/mw.min.js && esbuild ./mw/config.ts --charset=utf8 --bundle --target=es2019 --format=esm --outfile=dist/mwConfig.mjs",
36
- "build:wiki": "esbuild ./mw/index.ts --charset=utf8 --bundle --minify --target=es2019 --format=iife --sourcemap --outfile=dist/wiki.min.js",
35
+ "build:core": "npm run bundle:core && esbuild ./build/main.js --charset=utf8 --minify --target=es2019 --format=esm --sourcemap --outfile=dist/main.min.js && tsc && rm dist/*-page.{js,d.ts}",
36
+ "build:mw": "esbuild ./build/wiki.js --charset=utf8 --minify --target=es2019 --format=esm --outfile=dist/mw.min.js && esbuild ./mw/config.ts --charset=utf8 --bundle --target=es2019 --format=esm --outfile=dist/mwConfig.js",
37
+ "build:wiki": "npm run bundle:wiki && esbuild ./build/wiki.js --charset=utf8 --minify --target=es2019 --format=iife --sourcemap --outfile=dist/wiki.min.js",
37
38
  "build:gh-page": "bash build.sh",
38
39
  "build:test": "tsc --project test/tsconfig.json && npm test",
39
- "build": "npm run build:css && rm -rf dist/ && npm run build:core && npm run build:mw && npm run build:wiki && eslint --no-eslintrc -c .eslintrc.dist.cjs dist/*.js",
40
+ "build": "npm run build:css && rm -rf dist/ && npm run build:core && npm run build:wiki && npm run build:mw && eslint --no-eslintrc -c .eslintrc.dist.cjs dist/*.min.js",
40
41
  "lint:ts": "tsc --noEmit && tsc --project mw/tsconfig.json --noEmit && tsc --project test/tsconfig.json --noEmit && eslint --cache .",
41
42
  "lint:css": "stylelint **/*.css",
42
43
  "lint": "npm run lint:ts && npm run lint:css",
@@ -47,24 +48,24 @@
47
48
  "test:real": "node test/dist/test/real.js"
48
49
  },
49
50
  "dependencies": {
50
- "@bhsd/common": "^0.13.0",
51
- "@codemirror/lint": "^6.8.5",
52
- "@codemirror/state": "^6.5.2",
53
- "@codemirror/view": "^6.36.8",
54
- "@lezer/common": "^1.2.3",
55
- "wikiparser-node": "^1.21.2"
56
- },
57
- "devDependencies": {
58
51
  "@bhsd/codemirror-css-color-picker": "^6.3.0",
52
+ "@bhsd/common": "^0.13.1",
59
53
  "@codemirror/autocomplete": "^6.18.6",
60
54
  "@codemirror/commands": "^6.8.1",
55
+ "@codemirror/language": "^6.11.0",
61
56
  "@codemirror/lang-css": "^6.3.1",
62
57
  "@codemirror/lang-javascript": "^6.2.2",
63
58
  "@codemirror/lang-json": "^6.0.1",
64
- "@codemirror/language": "^6.11.0",
65
59
  "@codemirror/legacy-modes": "^6.4.2",
60
+ "@codemirror/lint": "^6.8.5",
66
61
  "@codemirror/search": "^6.5.11",
62
+ "@codemirror/state": "^6.5.2",
63
+ "@codemirror/view": "^6.36.8",
64
+ "@lezer/common": "^1.2.3",
67
65
  "@lezer/highlight": "^1.2.1",
66
+ "wikiparser-node": "^1.21.2"
67
+ },
68
+ "devDependencies": {
68
69
  "@stylistic/eslint-plugin": "^3.1.0",
69
70
  "@stylistic/stylelint-plugin": "^3.1.2",
70
71
  "@types/eslint": "^8.56.10",
@@ -85,7 +86,7 @@
85
86
  "eslint-plugin-regexp": "^2.7.0",
86
87
  "eslint-plugin-unicorn": "^56.0.1",
87
88
  "http-server": "^14.1.1",
88
- "luacheck-browserify": "^0.5.2",
89
+ "luacheck-browserify": "^0.7.0",
89
90
  "mocha": "^11.1.0",
90
91
  "monaco-editor": "^0.52.2",
91
92
  "stylelint": "^16.20.0",
@@ -1,15 +0,0 @@
1
- export interface KeymapConfig {
2
- key: string;
3
- desc: string;
4
- pre?: string;
5
- post?: string;
6
- splitlines?: boolean;
7
- }
8
- export declare const keybindings: KeymapConfig[];
9
- /**
10
- * 将文本各行包裹在指定的前后缀中
11
- * @param text 跨行文本
12
- * @param pre 前缀
13
- * @param post 后缀
14
- */
15
- export declare const encapsulateLines: (text: string, pre: string, post: string) => string;
@@ -1,34 +0,0 @@
1
- const keybindings = [
2
- { key: "Ctrl-8", pre: "<blockquote>", post: "</blockquote>", desc: "blockquote" },
3
- { key: "Mod-.", pre: "<sup>", post: "</sup>", desc: "sup" },
4
- { key: "Mod-,", pre: "<sub>", post: "</sub>", desc: "sub" },
5
- { key: "Mod-Shift-6", pre: "<code>", post: "</code>", desc: "code" },
6
- { key: "Ctrl-Shift-5", pre: "<s>", post: "</s>", desc: "s" },
7
- { key: "Mod-u", pre: "<u>", post: "</u>", desc: "u" },
8
- { key: "Mod-k", pre: "[[", post: "]]", desc: "link" },
9
- { key: "Mod-i", pre: "''", post: "''", desc: "italic" },
10
- { key: "Mod-b", pre: "'''", post: "'''", desc: "bold" },
11
- { key: "Mod-Shift-k", pre: "<ref>", post: "</ref>", desc: "ref" },
12
- { key: "Mod-/", pre: "<!-- ", post: " -->", desc: "comment" },
13
- { key: "Ctrl-0", splitlines: true, desc: "heading 0" },
14
- ...new Array(6).fill(0).map((_, i) => ({
15
- key: `Ctrl-${i + 1}`,
16
- pre: `${"=".repeat(i + 1)} `,
17
- post: ` ${"=".repeat(i + 1)}`,
18
- splitlines: true,
19
- desc: `heading ${i + 1}`
20
- })),
21
- { key: "Ctrl-7", pre: " ", splitlines: true, desc: "pre" }
22
- ];
23
- const encapsulateLines = (text, pre, post) => {
24
- const lines = text.split("\n");
25
- return lines.map((line) => {
26
- var _a, _b;
27
- const str = ((_b = (_a = /^(={1,6})(.+)\1\s*$/u.exec(line)) == null ? void 0 : _a[2]) != null ? _b : line).trim();
28
- return pre === " " || lines.length === 1 || line.trim() ? pre + str + post : str;
29
- }).join("\n");
30
- };
31
- export {
32
- encapsulateLines,
33
- keybindings
34
- };
package/dist/linter.d.mts DELETED
@@ -1,43 +0,0 @@
1
- import type { Diagnostic as DiagnosticBase, Range } from 'vscode-languageserver-types';
2
- import type { Linter } from 'eslint';
3
- import type { Warning } from 'stylelint';
4
- import type { Diagnostic } from 'luacheck-browserify';
5
- export type Option = Record<string, unknown> | null | undefined;
6
- export type LiveOption = (runtime?: true) => Option;
7
- declare type getLinter<T> = () => (text: string) => T;
8
- declare type asyncLinter<T, S = Record<string, unknown>> = ((text: string, config?: Option) => T) & {
9
- config?: S;
10
- fixer?: (code: string, rule?: string) => string | Promise<string>;
11
- };
12
- /**
13
- * @param opt 初始化选项
14
- * @param obj 仅用于wikiparse.LanguageService
15
- */
16
- declare type getAsyncLinter<T, S = never, R = never> = (opt?: S, obj?: R) => Promise<asyncLinter<T>>;
17
- declare interface MixedDiagnostic extends Omit<DiagnosticBase, 'range'> {
18
- range?: Range;
19
- from?: number;
20
- to?: number;
21
- }
22
- /**
23
- * 获取 Wikitext LSP
24
- * @param opt 选项
25
- * @param obj 对象
26
- */
27
- export declare const getWikiLinter: getAsyncLinter<Promise<MixedDiagnostic[]>, Option, object>;
28
- /** 获取 ESLint */
29
- export declare const getJsLinter: getAsyncLinter<Linter.LintMessage[]>;
30
- /** 获取 Stylelint */
31
- export declare const getCssLinter: getAsyncLinter<Promise<Warning[]>>;
32
- /** 获取 Luacheck */
33
- export declare const getLuaLinter: getAsyncLinter<Promise<Diagnostic[]>>;
34
- declare interface JsonError {
35
- message: string;
36
- severity: 'error';
37
- line: string | undefined;
38
- column: string | undefined;
39
- position: string | undefined;
40
- }
41
- /** JSON.parse */
42
- export declare const getJsonLinter: getLinter<JsonError[]>;
43
- export {};
package/dist/linter.mjs DELETED
@@ -1,132 +0,0 @@
1
- import { loadScript, getWikiparse, getLSP, sanitizeInlineStyle } from "@bhsd/common";
2
- import { styleLint } from "@bhsd/common/dist/stylelint";
3
- const offsetAt = (range, line, column) => {
4
- if (line === -2) {
5
- return range[0];
6
- }
7
- return line === 0 ? range[1] : range[0] + column;
8
- };
9
- const getWikiLinter = async (opt, obj) => {
10
- await getWikiparse(
11
- opt == null ? void 0 : opt["getConfig"],
12
- opt == null ? void 0 : opt["i18n"]
13
- );
14
- const lsp = getLSP(obj, opt == null ? void 0 : opt["include"]);
15
- return async (text, config) => {
16
- const diagnostics = (await lsp.provideDiagnostics(text)).filter(
17
- ({ code, severity }) => {
18
- var _a;
19
- return Number((_a = config == null ? void 0 : config[code]) != null ? _a : 2) > Number(severity === 2);
20
- }
21
- ), tokens = "findStyleTokens" in lsp && (config == null ? void 0 : config["invalid-css"]) !== "0" ? await lsp.findStyleTokens() : [];
22
- if (tokens.length === 0) {
23
- return diagnostics;
24
- }
25
- const cssLint = await getCssLinter();
26
- return [
27
- ...diagnostics,
28
- ...(await cssLint(
29
- tokens.map(({ childNodes, type, tag }, i) => `${type === "ext-attr" ? "div" : tag}#${i}{
30
- ${sanitizeInlineStyle(childNodes[1].childNodes[0].data).replace(/\n/gu, " ")}
31
- }`).join("\n")
32
- )).map(({ line, column, endLine, endColumn, rule, severity, text: message }) => {
33
- const i = Math.ceil(line / 3), { range } = tokens[i - 1].childNodes[1].childNodes[0], from = offsetAt(range, line - 3 * i, column - 1);
34
- return {
35
- from,
36
- to: endLine === void 0 ? from : offsetAt(range, endLine - 3 * i, endColumn - 1),
37
- severity: severity === "error" ? 1 : 2,
38
- source: "Stylelint",
39
- code: rule,
40
- message
41
- };
42
- })
43
- ];
44
- };
45
- };
46
- const getJsLinter = async () => {
47
- var _a;
48
- await loadScript("npm/@bhsd/eslint-browserify", "eslint");
49
- const esLinter = new eslint.Linter(), conf = {
50
- env: { browser: true, es2024: true },
51
- parserOptions: { ecmaVersion: 15, sourceType: "module" }
52
- }, recommended = {};
53
- for (const [name, { meta }] of esLinter.getRules()) {
54
- if ((_a = meta == null ? void 0 : meta.docs) == null ? void 0 : _a.recommended) {
55
- recommended[name] = 2;
56
- }
57
- }
58
- const linter = (text, opt) => {
59
- const config = { ...conf, ...opt };
60
- if (!("rules" in config) || config.extends === "eslint:recommended" || Array.isArray(config.extends) && config.extends.includes("eslint:recommended")) {
61
- config.rules = { ...recommended, ...config.rules };
62
- }
63
- delete config.extends;
64
- linter.config = config;
65
- return esLinter.verify(text, config);
66
- };
67
- linter.fixer = (code, rule) => {
68
- var _a2, _b;
69
- return esLinter.verifyAndFix(
70
- code,
71
- rule ? { ...linter.config, rules: { [rule]: (_b = (_a2 = linter.config.rules) == null ? void 0 : _a2[rule]) != null ? _b : 2 } } : linter.config
72
- ).output;
73
- };
74
- return linter;
75
- };
76
- const getCssLinter = async () => {
77
- await loadScript("npm/@bhsd/stylelint-browserify", "stylelint");
78
- const linter = async (code, opt) => {
79
- const warnings = await styleLint(stylelint, code, opt);
80
- if (opt && "rules" in opt) {
81
- linter.config = opt;
82
- }
83
- return warnings;
84
- };
85
- linter.fixer = (code, rule) => {
86
- var _a, _b;
87
- if (!linter.config) {
88
- throw new Error("Fixer unavailable!");
89
- }
90
- return styleLint(
91
- stylelint,
92
- code,
93
- rule ? { extends: [], rules: { [rule]: (_b = (_a = linter.config.rules) == null ? void 0 : _a[rule]) != null ? _b : true } } : linter.config,
94
- true
95
- );
96
- };
97
- return linter;
98
- };
99
- const getLuaLinter = async () => {
100
- await loadScript("npm/luacheck-browserify", "luacheck");
101
- const luachecker = await luacheck(void 0);
102
- return async (text) => (await luachecker.queue(text)).filter(({ severity }) => severity);
103
- };
104
- const getJsonLinter = () => (str) => {
105
- var _a, _b, _c;
106
- try {
107
- if (str.trim()) {
108
- JSON.parse(str);
109
- }
110
- } catch (e) {
111
- if (e instanceof SyntaxError) {
112
- const { message } = e, line = (_a = /\bline (\d+)/u.exec(message)) == null ? void 0 : _a[1], column = (_b = /\bcolumn (\d+)/u.exec(message)) == null ? void 0 : _b[1], position = (_c = /\bposition (\d+)/u.exec(message)) == null ? void 0 : _c[1];
113
- return [
114
- {
115
- message,
116
- severity: "error",
117
- line,
118
- column,
119
- position
120
- }
121
- ];
122
- }
123
- }
124
- return [];
125
- };
126
- export {
127
- getCssLinter,
128
- getJsLinter,
129
- getJsonLinter,
130
- getLuaLinter,
131
- getWikiLinter
132
- };
File without changes