koishi-plugin-codemirror 0.0.1

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/style.css ADDED
@@ -0,0 +1 @@
1
+ .select-all{-webkit-user-select:all;user-select:all}
package/lib/index.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { Context, Schema } from "koishi";
2
+ export declare const name = "codemirror";
3
+ export declare const inject: string[];
4
+ export declare const filter = false;
5
+ export interface Config {
6
+ }
7
+ export declare const Config: Schema<Config>;
8
+ export declare function apply(ctx: Context): void;
package/lib/index.js ADDED
@@ -0,0 +1,52 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name2 in all)
8
+ __defProp(target, name2, { get: all[name2], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ Config: () => Config,
24
+ apply: () => apply,
25
+ filter: () => filter,
26
+ inject: () => inject,
27
+ name: () => name
28
+ });
29
+ module.exports = __toCommonJS(src_exports);
30
+ var import_koishi = require("koishi");
31
+ var import_path = require("path");
32
+ var name = "codemirror";
33
+ var inject = ["console"];
34
+ var filter = false;
35
+ var Config = import_koishi.Schema.object({
36
+ //test: Schema.string().role("codemirror").description("测试"),
37
+ });
38
+ function apply(ctx) {
39
+ ctx.console.addEntry({
40
+ dev: (0, import_path.resolve)(__dirname, "../client/index.ts"),
41
+ prod: (0, import_path.resolve)(__dirname, "../dist")
42
+ });
43
+ }
44
+ __name(apply, "apply");
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ Config,
48
+ apply,
49
+ filter,
50
+ inject,
51
+ name
52
+ });
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "koishi-plugin-codemirror",
3
+ "description": "CodeMirror schema role for Koishi Web UI",
4
+ "version": "0.0.1",
5
+ "main": "lib/index.js",
6
+ "typings": "lib/index.d.ts",
7
+ "files": [
8
+ "lib",
9
+ "dist"
10
+ ],
11
+ "license": "MIT",
12
+ "homepage": "https://github.com/DGCK81LNN/koishi-plugin-miniplug/tree/main/plugins/codemirror",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/DGCK81LNN/koishi-plugin-miniplug.git"
16
+ },
17
+ "keywords": [
18
+ "koishi",
19
+ "plugin"
20
+ ],
21
+ "koishi": {
22
+ "description": {
23
+ "zh": "用于 Web UI 的 CodeMirror schema role",
24
+ "en": "CodeMirror schema role for the Web UI"
25
+ },
26
+ "browser": true
27
+ },
28
+ "devDependencies": {
29
+ "@codemirror/lang-javascript": "^6.2.2",
30
+ "@codemirror/lang-json": "^6.0.1",
31
+ "@codemirror/theme-one-dark": "^6.1.2",
32
+ "@koishijs/client": "^5.29.1",
33
+ "codemirror": "^6.0.1"
34
+ },
35
+ "peerDependencies": {
36
+ "@koishijs/plugin-console": "^5.29.1",
37
+ "koishi": "^4.17.8"
38
+ }
39
+ }
package/readme.md ADDED
@@ -0,0 +1,21 @@
1
+ # koishi-plugin-codemirror
2
+
3
+ [![npm](https://img.shields.io/npm/v/koishi-plugin-codemirror?style=flat-square)](https://www.npmjs.com/package/koishi-plugin-codemirror)
4
+
5
+ 启用此插件将为 Koishi 控制台的 `string` 类型配置构型提供一个 `codemirror` `role`,用于将字符串配置项变成一个代码编辑框。
6
+
7
+ ~~~typescript
8
+ export interface Config {
9
+ code: string
10
+ }
11
+
12
+ export const Config: Schema<Config> = Schema.object({
13
+ code: Schema.string().role("codemirror").default('console.log("Hello, World!")\n\n'),
14
+ })
15
+ ~~~
16
+
17
+ 即可在你的插件配置中添加一个 JavaScript 代码编辑框。
18
+
19
+ ![](images/screenshot.png)
20
+
21
+ `.role("codemirror")` 还接受第二参数 `extra`,目前,唯一有效的值为 `{ lang: "json" }`,可将编辑语言改为 JSON。