@cozeloop/prompt-components 0.0.1 → 0.0.2
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/edenx.config.d.ts +2 -0
- package/dist/{es/basic-editor/extensions/go-syntax.js → go-syntax-067c4f5d.mjs} +16 -9
- package/dist/go-syntax-4deb0289.js +8 -0
- package/dist/{es/basic-editor/extensions/go-theme.js → go-theme-062a6df6.mjs} +3 -4
- package/dist/go-theme-fbd8a4fa.js +1 -0
- package/dist/index.cjs +61 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2788 -0
- package/dist/{types → src}/basic-editor/custom-facet.d.ts +2 -1
- package/dist/src/basic-editor/diff.d.ts +16 -0
- package/dist/src/basic-editor/extensions/go-syntax.d.ts +71 -0
- package/dist/src/basic-editor/extensions/go-template.d.ts +1 -0
- package/dist/{types → src}/basic-editor/extensions/go-theme.d.ts +1 -1
- package/dist/src/basic-editor/extensions/jinja.d.ts +4 -0
- package/dist/{types → src}/basic-editor/extensions/keymap.d.ts +3 -2
- package/dist/src/basic-editor/extensions/language-support.d.ts +2 -0
- package/dist/src/basic-editor/extensions/markdown.d.ts +2 -0
- package/dist/src/basic-editor/extensions/search/dom/icon.d.ts +59 -0
- package/dist/src/basic-editor/extensions/search/dom/match-count.d.ts +14 -0
- package/dist/src/basic-editor/extensions/search/index.d.ts +1 -0
- package/dist/src/basic-editor/extensions/search/panel.d.ts +33 -0
- package/dist/src/basic-editor/extensions/search/theme.d.ts +1 -0
- package/dist/src/basic-editor/extensions/validation.d.ts +8 -0
- package/dist/src/basic-editor/extensions/variable.d.ts +11 -0
- package/dist/src/basic-editor/index.d.ts +29 -0
- package/dist/{types → src}/code-editor/index.d.ts +1 -1
- package/dist/src/code-editor/json-editor.d.ts +18 -0
- package/dist/src/code-editor/raw-text-editor.d.ts +11 -0
- package/dist/{types → src}/consts/index.d.ts +1 -1
- package/dist/src/dev-layout/index.d.ts +7 -0
- package/dist/{types → src}/index.d.ts +7 -7
- package/dist/src/mermaid-diagram/index.d.ts +12 -0
- package/dist/src/mermaid-diagram/use-svg-pan-zoom.d.ts +12 -0
- package/dist/{types → src}/mermaid-diagram/utils.d.ts +1 -1
- package/dist/src/model-config-editor/basic-type.d.ts +13 -0
- package/dist/src/model-config-editor/model-config-form.d.ts +13 -0
- package/dist/src/model-config-editor/popover-type.d.ts +19 -0
- package/dist/src/model-select/index.d.ts +27 -0
- package/dist/src/model-select/model-option/index.d.ts +25 -0
- package/dist/src/model-select/model-option-group/index.d.ts +16 -0
- package/dist/src/prompt-editor/index.d.ts +31 -0
- package/dist/src/prompt-editor/message-type-select.d.ts +11 -0
- package/dist/src/schema-editor/index.d.ts +11 -0
- package/dist/{types → src}/utils/base.d.ts +5 -4
- package/dist/src/utils/model-config.d.ts +5 -0
- package/dist/style.css +1 -0
- package/dist/test-build.d.ts +7 -0
- package/dist/vite.config.d.ts +2 -0
- package/package.json +15 -5
- package/dist/es/basic-editor/custom-facet.js +0 -9
- package/dist/es/basic-editor/diff.js +0 -138
- package/dist/es/basic-editor/extensions/go-template.js +0 -16
- package/dist/es/basic-editor/extensions/jinja.js +0 -80
- package/dist/es/basic-editor/extensions/keymap.js +0 -442
- package/dist/es/basic-editor/extensions/language-support.js +0 -12
- package/dist/es/basic-editor/extensions/markdown.js +0 -58
- package/dist/es/basic-editor/extensions/search/dom/icon.js +0 -250
- package/dist/es/basic-editor/extensions/search/dom/match-count.js +0 -33
- package/dist/es/basic-editor/extensions/search/index.js +0 -18
- package/dist/es/basic-editor/extensions/search/panel.js +0 -418
- package/dist/es/basic-editor/extensions/search/theme.js +0 -184
- package/dist/es/basic-editor/extensions/validation.js +0 -84
- package/dist/es/basic-editor/extensions/validation.module.js +0 -5
- package/dist/es/basic-editor/extensions/validation_module.css +0 -7
- package/dist/es/basic-editor/extensions/variable.js +0 -178
- package/dist/es/basic-editor/index.js +0 -171
- package/dist/es/code-editor/code-editor.js +0 -83
- package/dist/es/code-editor/index.js +0 -12
- package/dist/es/code-editor/json-editor.js +0 -157
- package/dist/es/code-editor/raw-text-editor.js +0 -46
- package/dist/es/code-editor/text-editor.js +0 -41
- package/dist/es/code-editor/themes/coze-dark.js +0 -112
- package/dist/es/code-editor/themes/coze-light.js +0 -118
- package/dist/es/consts/index.js +0 -12
- package/dist/es/dev-layout/index.js +0 -35
- package/dist/es/index.js +0 -66
- package/dist/es/mermaid-diagram/index.js +0 -148
- package/dist/es/mermaid-diagram/index.module.js +0 -5
- package/dist/es/mermaid-diagram/index_module.css +0 -4
- package/dist/es/mermaid-diagram/use-svg-pan-zoom.js +0 -49
- package/dist/es/mermaid-diagram/utils.js +0 -74
- package/dist/es/model-config-editor/basic-type.js +0 -73
- package/dist/es/model-config-editor/index.module.js +0 -5
- package/dist/es/model-config-editor/index_module.css +0 -8
- package/dist/es/model-config-editor/model-config-form.js +0 -130
- package/dist/es/model-config-editor/popover-type.js +0 -118
- package/dist/es/model-select/index.js +0 -136
- package/dist/es/model-select/index.module.js +0 -5
- package/dist/es/model-select/index_module.css +0 -14
- package/dist/es/model-select/model-option/index.js +0 -161
- package/dist/es/model-select/model-option/index.module.js +0 -5
- package/dist/es/model-select/model-option/index_module.css +0 -23
- package/dist/es/model-select/model-option-group/index.js +0 -44
- package/dist/es/prompt-editor/index.js +0 -188
- package/dist/es/prompt-editor/index.module.js +0 -5
- package/dist/es/prompt-editor/index_module.css +0 -71
- package/dist/es/prompt-editor/message-type-select.js +0 -74
- package/dist/es/schema-editor/index.js +0 -43
- package/dist/es/utils/base.js +0 -53
- package/dist/es/utils/model-config.js +0 -32
- package/dist/lib/basic-editor/custom-facet.js +0 -33
- package/dist/lib/basic-editor/diff.js +0 -167
- package/dist/lib/basic-editor/extensions/go-syntax.js +0 -146
- package/dist/lib/basic-editor/extensions/go-template.js +0 -50
- package/dist/lib/basic-editor/extensions/go-theme.js +0 -1091
- package/dist/lib/basic-editor/extensions/jinja.js +0 -100
- package/dist/lib/basic-editor/extensions/keymap.js +0 -465
- package/dist/lib/basic-editor/extensions/language-support.js +0 -32
- package/dist/lib/basic-editor/extensions/markdown.js +0 -78
- package/dist/lib/basic-editor/extensions/search/dom/icon.js +0 -291
- package/dist/lib/basic-editor/extensions/search/dom/match-count.js +0 -67
- package/dist/lib/basic-editor/extensions/search/index.js +0 -38
- package/dist/lib/basic-editor/extensions/search/panel.js +0 -429
- package/dist/lib/basic-editor/extensions/search/theme.js +0 -208
- package/dist/lib/basic-editor/extensions/validation.js +0 -118
- package/dist/lib/basic-editor/extensions/validation.module.js +0 -25
- package/dist/lib/basic-editor/extensions/validation_module.css +0 -7
- package/dist/lib/basic-editor/extensions/variable.js +0 -190
- package/dist/lib/basic-editor/index.js +0 -193
- package/dist/lib/code-editor/code-editor.js +0 -117
- package/dist/lib/code-editor/index.js +0 -40
- package/dist/lib/code-editor/json-editor.js +0 -184
- package/dist/lib/code-editor/raw-text-editor.js +0 -70
- package/dist/lib/code-editor/text-editor.js +0 -75
- package/dist/lib/code-editor/themes/coze-dark.js +0 -136
- package/dist/lib/code-editor/themes/coze-light.js +0 -142
- package/dist/lib/consts/index.js +0 -38
- package/dist/lib/dev-layout/index.js +0 -69
- package/dist/lib/index.js +0 -110
- package/dist/lib/mermaid-diagram/index.js +0 -174
- package/dist/lib/mermaid-diagram/index.module.js +0 -25
- package/dist/lib/mermaid-diagram/index_module.css +0 -4
- package/dist/lib/mermaid-diagram/use-svg-pan-zoom.js +0 -83
- package/dist/lib/mermaid-diagram/utils.js +0 -98
- package/dist/lib/model-config-editor/basic-type.js +0 -105
- package/dist/lib/model-config-editor/index.module.js +0 -25
- package/dist/lib/model-config-editor/index_module.css +0 -8
- package/dist/lib/model-config-editor/model-config-form.js +0 -149
- package/dist/lib/model-config-editor/popover-type.js +0 -145
- package/dist/lib/model-select/index.js +0 -170
- package/dist/lib/model-select/index.module.js +0 -25
- package/dist/lib/model-select/index_module.css +0 -14
- package/dist/lib/model-select/model-option/index.js +0 -188
- package/dist/lib/model-select/model-option/index.module.js +0 -25
- package/dist/lib/model-select/model-option/index_module.css +0 -23
- package/dist/lib/model-select/model-option-group/index.js +0 -75
- package/dist/lib/prompt-editor/index.js +0 -218
- package/dist/lib/prompt-editor/index.module.js +0 -25
- package/dist/lib/prompt-editor/index_module.css +0 -71
- package/dist/lib/prompt-editor/message-type-select.js +0 -108
- package/dist/lib/schema-editor/index.js +0 -77
- package/dist/lib/utils/base.js +0 -82
- package/dist/lib/utils/model-config.js +0 -57
- package/dist/types/basic-editor/diff.d.ts +0 -15
- package/dist/types/basic-editor/extensions/go-syntax.d.ts +0 -71
- package/dist/types/basic-editor/extensions/go-template.d.ts +0 -1
- package/dist/types/basic-editor/extensions/jinja.d.ts +0 -6
- package/dist/types/basic-editor/extensions/language-support.d.ts +0 -2
- package/dist/types/basic-editor/extensions/markdown.d.ts +0 -2
- package/dist/types/basic-editor/extensions/search/dom/icon.d.ts +0 -59
- package/dist/types/basic-editor/extensions/search/dom/match-count.d.ts +0 -14
- package/dist/types/basic-editor/extensions/search/index.d.ts +0 -1
- package/dist/types/basic-editor/extensions/search/panel.d.ts +0 -32
- package/dist/types/basic-editor/extensions/search/theme.d.ts +0 -1
- package/dist/types/basic-editor/extensions/validation.d.ts +0 -10
- package/dist/types/basic-editor/extensions/variable.d.ts +0 -14
- package/dist/types/basic-editor/index.d.ts +0 -28
- package/dist/types/code-editor/code-editor.d.ts +0 -23
- package/dist/types/code-editor/json-editor.d.ts +0 -17
- package/dist/types/code-editor/raw-text-editor.d.ts +0 -11
- package/dist/types/code-editor/text-editor.d.ts +0 -23
- package/dist/types/code-editor/themes/coze-dark.d.ts +0 -1
- package/dist/types/code-editor/themes/coze-light.d.ts +0 -1
- package/dist/types/dev-layout/index.d.ts +0 -13
- package/dist/types/mermaid-diagram/index.d.ts +0 -12
- package/dist/types/mermaid-diagram/use-svg-pan-zoom.d.ts +0 -17
- package/dist/types/model-config-editor/basic-type.d.ts +0 -19
- package/dist/types/model-config-editor/model-config-form.d.ts +0 -14
- package/dist/types/model-config-editor/popover-type.d.ts +0 -25
- package/dist/types/model-select/index.d.ts +0 -38
- package/dist/types/model-select/model-option/index.d.ts +0 -30
- package/dist/types/model-select/model-option-group/index.d.ts +0 -15
- package/dist/types/prompt-editor/index.d.ts +0 -30
- package/dist/types/prompt-editor/message-type-select.d.ts +0 -16
- package/dist/types/schema-editor/index.d.ts +0 -18
- package/dist/types/utils/model-config.d.ts +0 -4
|
@@ -1,429 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __defProps = Object.defineProperties;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
-
var __spreadValues = (a, b) => {
|
|
14
|
-
for (var prop in b || (b = {}))
|
|
15
|
-
if (__hasOwnProp.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
if (__getOwnPropSymbols)
|
|
18
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
-
if (__propIsEnum.call(b, prop))
|
|
20
|
-
__defNormalProp(a, prop, b[prop]);
|
|
21
|
-
}
|
|
22
|
-
return a;
|
|
23
|
-
};
|
|
24
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
-
var __export = (target, all) => {
|
|
26
|
-
for (var name in all)
|
|
27
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
28
|
-
};
|
|
29
|
-
var __copyProps = (to, from, except, desc) => {
|
|
30
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
31
|
-
for (let key of __getOwnPropNames(from))
|
|
32
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
33
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
34
|
-
}
|
|
35
|
-
return to;
|
|
36
|
-
};
|
|
37
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
38
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
39
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
40
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
41
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
42
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
43
|
-
mod
|
|
44
|
-
));
|
|
45
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
46
|
-
var panel_exports = {};
|
|
47
|
-
__export(panel_exports, {
|
|
48
|
-
SearchPanel: () => SearchPanel
|
|
49
|
-
});
|
|
50
|
-
module.exports = __toCommonJS(panel_exports);
|
|
51
|
-
var import_crelt = __toESM(require("crelt"));
|
|
52
|
-
var import_view = require("@codemirror/view");
|
|
53
|
-
var import_search = require("@codemirror/search");
|
|
54
|
-
var import_match_count = require("./dom/match-count");
|
|
55
|
-
var import_icon = require("./dom/icon");
|
|
56
|
-
class SearchPanel {
|
|
57
|
-
constructor(view) {
|
|
58
|
-
this.view = view;
|
|
59
|
-
this.commit = this.commit.bind(this);
|
|
60
|
-
this.query = (0, import_search.getSearchQuery)(view.state);
|
|
61
|
-
this.matchCount = new import_match_count.MatchCount();
|
|
62
|
-
const searchLine = this.initSearchLine(view);
|
|
63
|
-
const replaceLine = this.initReplaceLine(view);
|
|
64
|
-
const replaceLineStatus = () => {
|
|
65
|
-
var _a;
|
|
66
|
-
if (view.state.readOnly) {
|
|
67
|
-
replaceLine.style.display = "none";
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
if (!((_a = this.expand) == null ? void 0 : _a.checked)) {
|
|
71
|
-
replaceLine.style.display = "none";
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
replaceLine.style.display = "flex";
|
|
75
|
-
};
|
|
76
|
-
replaceLineStatus();
|
|
77
|
-
const expand = this.initExpandButton(view, () => replaceLineStatus());
|
|
78
|
-
const onMouseDown = useDragSearchPanel(this);
|
|
79
|
-
this.dom = (0, import_crelt.default)(
|
|
80
|
-
"div",
|
|
81
|
-
{
|
|
82
|
-
onkeydown: (e) => this.keydown(e),
|
|
83
|
-
class: "cm-custom-search"
|
|
84
|
-
},
|
|
85
|
-
[
|
|
86
|
-
(0, import_crelt.default)("div", {
|
|
87
|
-
class: "cm-custom-search-drag",
|
|
88
|
-
onmousedown: onMouseDown
|
|
89
|
-
}),
|
|
90
|
-
...expand,
|
|
91
|
-
(0, import_crelt.default)(
|
|
92
|
-
"div",
|
|
93
|
-
{
|
|
94
|
-
class: "cm-custom-search-panel-content"
|
|
95
|
-
},
|
|
96
|
-
[searchLine, replaceLine]
|
|
97
|
-
)
|
|
98
|
-
]
|
|
99
|
-
);
|
|
100
|
-
this.updateMatchCount(view.state, this.query);
|
|
101
|
-
}
|
|
102
|
-
initExpandButton(view, onExpandChange) {
|
|
103
|
-
this.expand = new import_icon.IconChevronRight({
|
|
104
|
-
name: "expand",
|
|
105
|
-
title: phrase(view, "展开"),
|
|
106
|
-
onchange: onExpandChange
|
|
107
|
-
});
|
|
108
|
-
return view.state.readOnly ? [] : [
|
|
109
|
-
(0, import_crelt.default)(
|
|
110
|
-
"div",
|
|
111
|
-
{
|
|
112
|
-
class: "cm-custom-search-panel-expand"
|
|
113
|
-
},
|
|
114
|
-
[this.expand.dom]
|
|
115
|
-
)
|
|
116
|
-
];
|
|
117
|
-
}
|
|
118
|
-
initSearchLine(view) {
|
|
119
|
-
const inputWrapperRef = {
|
|
120
|
-
current: null
|
|
121
|
-
};
|
|
122
|
-
const handleInputFocus = () => {
|
|
123
|
-
var _a;
|
|
124
|
-
(_a = inputWrapperRef.current) == null ? void 0 : _a.focus();
|
|
125
|
-
if (inputWrapperRef.current && !inputWrapperRef.current.classList.contains(
|
|
126
|
-
"cm-custom-search-panel-content-input-wrapper-focus"
|
|
127
|
-
)) {
|
|
128
|
-
inputWrapperRef.current.classList.add(
|
|
129
|
-
"cm-custom-search-panel-content-input-wrapper-focus"
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
const handleInputBlur = () => {
|
|
134
|
-
var _a;
|
|
135
|
-
(_a = inputWrapperRef.current) == null ? void 0 : _a.blur();
|
|
136
|
-
if (inputWrapperRef.current) {
|
|
137
|
-
inputWrapperRef.current.classList.remove(
|
|
138
|
-
"cm-custom-search-panel-content-input-wrapper-focus"
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
this.searchField = (0, import_crelt.default)("input", {
|
|
143
|
-
value: this.query.search,
|
|
144
|
-
placeholder: phrase(view, "查找"),
|
|
145
|
-
title: phrase(view, "查找"),
|
|
146
|
-
class: "cm-custom-text-field",
|
|
147
|
-
name: "search",
|
|
148
|
-
form: "",
|
|
149
|
-
"main-field": "true",
|
|
150
|
-
onchange: this.commit,
|
|
151
|
-
onkeyup: this.commit,
|
|
152
|
-
onfocus: handleInputFocus,
|
|
153
|
-
onblur: handleInputBlur
|
|
154
|
-
});
|
|
155
|
-
this.caseField = new import_icon.IconCaseSensitive({
|
|
156
|
-
checked: this.query.caseSensitive,
|
|
157
|
-
onchange: () => {
|
|
158
|
-
this.searchField.focus();
|
|
159
|
-
this.commit();
|
|
160
|
-
},
|
|
161
|
-
name: "case",
|
|
162
|
-
title: phrase(view, "区分大小写")
|
|
163
|
-
});
|
|
164
|
-
this.reField = new import_icon.IconRegExp({
|
|
165
|
-
name: "re",
|
|
166
|
-
checked: this.query.regexp,
|
|
167
|
-
onchange: () => {
|
|
168
|
-
this.searchField.focus();
|
|
169
|
-
this.commit();
|
|
170
|
-
},
|
|
171
|
-
title: phrase(view, "正则表达式")
|
|
172
|
-
});
|
|
173
|
-
this.wordField = new import_icon.IconWholeWord({
|
|
174
|
-
name: "word",
|
|
175
|
-
checked: this.query.wholeWord,
|
|
176
|
-
onchange: () => {
|
|
177
|
-
this.searchField.focus();
|
|
178
|
-
this.commit();
|
|
179
|
-
},
|
|
180
|
-
title: phrase(view, "全词匹配")
|
|
181
|
-
});
|
|
182
|
-
this.arrowUp = new import_icon.IconArrowUp({
|
|
183
|
-
name: "previous",
|
|
184
|
-
onclick: () => {
|
|
185
|
-
(0, import_search.findPrevious)(view);
|
|
186
|
-
this.updateMatchCount(view.state, this.query);
|
|
187
|
-
},
|
|
188
|
-
title: phrase(view, "上一个匹配")
|
|
189
|
-
});
|
|
190
|
-
this.arrowDown = new import_icon.IconArrowDown({
|
|
191
|
-
name: "next",
|
|
192
|
-
onclick: () => {
|
|
193
|
-
(0, import_search.findNext)(view);
|
|
194
|
-
this.updateMatchCount(view.state, this.query);
|
|
195
|
-
},
|
|
196
|
-
title: phrase(view, "下一个匹配")
|
|
197
|
-
});
|
|
198
|
-
inputWrapperRef.current = (0, import_crelt.default)(
|
|
199
|
-
"div",
|
|
200
|
-
{
|
|
201
|
-
class: "cm-custom-search-panel-content-input-wrapper"
|
|
202
|
-
},
|
|
203
|
-
[
|
|
204
|
-
this.searchField,
|
|
205
|
-
// enter.dom,
|
|
206
|
-
this.caseField.dom,
|
|
207
|
-
this.reField.dom,
|
|
208
|
-
this.wordField.dom
|
|
209
|
-
]
|
|
210
|
-
);
|
|
211
|
-
return (0, import_crelt.default)(
|
|
212
|
-
"div",
|
|
213
|
-
{
|
|
214
|
-
class: "cm-custom-search-panel-content-top"
|
|
215
|
-
},
|
|
216
|
-
[
|
|
217
|
-
inputWrapperRef.current,
|
|
218
|
-
this.matchCount.dom,
|
|
219
|
-
(0, import_crelt.default)(
|
|
220
|
-
"div",
|
|
221
|
-
{
|
|
222
|
-
class: "cm-custom-search-action-wrapper"
|
|
223
|
-
},
|
|
224
|
-
[
|
|
225
|
-
this.arrowUp.dom,
|
|
226
|
-
this.arrowDown.dom,
|
|
227
|
-
new import_icon.IconClose({
|
|
228
|
-
name: "close-icon",
|
|
229
|
-
onclick: () => (0, import_search.closeSearchPanel)(view),
|
|
230
|
-
title: phrase(view, "关闭")
|
|
231
|
-
}).dom
|
|
232
|
-
]
|
|
233
|
-
)
|
|
234
|
-
]
|
|
235
|
-
);
|
|
236
|
-
}
|
|
237
|
-
initReplaceLine(view) {
|
|
238
|
-
const inputWrapperRef = {
|
|
239
|
-
current: null
|
|
240
|
-
};
|
|
241
|
-
const handleInputFocus = () => {
|
|
242
|
-
var _a;
|
|
243
|
-
(_a = inputWrapperRef.current) == null ? void 0 : _a.focus();
|
|
244
|
-
if (inputWrapperRef.current && !inputWrapperRef.current.classList.contains(
|
|
245
|
-
"cm-custom-search-panel-content-input-wrapper-focus"
|
|
246
|
-
)) {
|
|
247
|
-
inputWrapperRef.current.classList.add(
|
|
248
|
-
"cm-custom-search-panel-content-input-wrapper-focus"
|
|
249
|
-
);
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
const handleInputBlur = () => {
|
|
253
|
-
var _a;
|
|
254
|
-
(_a = inputWrapperRef.current) == null ? void 0 : _a.blur();
|
|
255
|
-
if (inputWrapperRef.current) {
|
|
256
|
-
inputWrapperRef.current.classList.remove(
|
|
257
|
-
"cm-custom-search-panel-content-input-wrapper-focus"
|
|
258
|
-
);
|
|
259
|
-
}
|
|
260
|
-
};
|
|
261
|
-
this.replaceField = (0, import_crelt.default)("input", {
|
|
262
|
-
value: this.query.replace,
|
|
263
|
-
placeholder: phrase(view, "替换"),
|
|
264
|
-
title: phrase(view, "替换"),
|
|
265
|
-
class: "cm-custom-text-field",
|
|
266
|
-
name: "replace",
|
|
267
|
-
form: "",
|
|
268
|
-
onchange: this.commit,
|
|
269
|
-
onkeyup: this.commit,
|
|
270
|
-
onfocus: handleInputFocus,
|
|
271
|
-
onblur: handleInputBlur
|
|
272
|
-
});
|
|
273
|
-
this.replace = new import_icon.IconReplace({
|
|
274
|
-
name: "replace",
|
|
275
|
-
onclick: () => {
|
|
276
|
-
(0, import_search.replaceNext)(view);
|
|
277
|
-
this.updateMatchCount(view.state, this.query);
|
|
278
|
-
},
|
|
279
|
-
title: phrase(view, "替换")
|
|
280
|
-
});
|
|
281
|
-
this.replaceAll = new import_icon.IconReplaceAll({
|
|
282
|
-
name: "replaceAll",
|
|
283
|
-
onclick: () => {
|
|
284
|
-
(0, import_search.replaceAll)(view);
|
|
285
|
-
this.updateMatchCount(view.state, this.query);
|
|
286
|
-
},
|
|
287
|
-
title: phrase(view, "替换所有")
|
|
288
|
-
});
|
|
289
|
-
inputWrapperRef.current = (0, import_crelt.default)(
|
|
290
|
-
"div",
|
|
291
|
-
{
|
|
292
|
-
class: "cm-custom-search-panel-content-input-wrapper"
|
|
293
|
-
},
|
|
294
|
-
[this.replaceField]
|
|
295
|
-
);
|
|
296
|
-
return (0, import_crelt.default)(
|
|
297
|
-
"div",
|
|
298
|
-
{
|
|
299
|
-
class: "cm-custom-search-panel-content-bottom"
|
|
300
|
-
},
|
|
301
|
-
[inputWrapperRef.current, this.replace.dom, this.replaceAll.dom]
|
|
302
|
-
);
|
|
303
|
-
}
|
|
304
|
-
commit() {
|
|
305
|
-
const query = new import_search.SearchQuery({
|
|
306
|
-
search: this.searchField.value,
|
|
307
|
-
caseSensitive: this.caseField.checked,
|
|
308
|
-
regexp: this.reField.checked,
|
|
309
|
-
wholeWord: this.wordField.checked,
|
|
310
|
-
replace: this.replaceField.value
|
|
311
|
-
});
|
|
312
|
-
if (!query.eq(this.query)) {
|
|
313
|
-
this.query = query;
|
|
314
|
-
this.view.dispatch({ effects: import_search.setSearchQuery.of(query) });
|
|
315
|
-
}
|
|
316
|
-
this.updateMatchCount(this.view.state, this.query);
|
|
317
|
-
}
|
|
318
|
-
keydown(e) {
|
|
319
|
-
if ((0, import_view.runScopeHandlers)(this.view, e, "search-panel")) {
|
|
320
|
-
e.preventDefault();
|
|
321
|
-
} else if ((e.keyCode === 13 || e.key === "Enter") && e.target === this.searchField) {
|
|
322
|
-
e.preventDefault();
|
|
323
|
-
(e.shiftKey ? import_search.findPrevious : import_search.findNext)(this.view);
|
|
324
|
-
} else if ((e.keyCode === 13 || e.key === "Enter") && e.target === this.replaceField) {
|
|
325
|
-
e.preventDefault();
|
|
326
|
-
(0, import_search.replaceNext)(this.view);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
updateMatchCount(state, query) {
|
|
330
|
-
this.matchCount.data = __spreadProps(__spreadValues({}, findMatchIndex(state, query)), {
|
|
331
|
-
searching: !!query.search
|
|
332
|
-
});
|
|
333
|
-
if (this.matchCount.data.matchCount > 0) {
|
|
334
|
-
this.replace.disabled = false;
|
|
335
|
-
this.replaceAll.disabled = false;
|
|
336
|
-
this.arrowUp.disabled = false;
|
|
337
|
-
this.arrowDown.disabled = false;
|
|
338
|
-
} else {
|
|
339
|
-
this.replace.disabled = true;
|
|
340
|
-
this.replaceAll.disabled = true;
|
|
341
|
-
this.arrowUp.disabled = true;
|
|
342
|
-
this.arrowDown.disabled = true;
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
update(update) {
|
|
346
|
-
for (const tr of update.transactions) {
|
|
347
|
-
for (const effect of tr.effects) {
|
|
348
|
-
if (effect.is(import_search.setSearchQuery) && !effect.value.eq(this.query)) {
|
|
349
|
-
this.setQuery(effect.value);
|
|
350
|
-
this.updateMatchCount(update.state, effect.value);
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
setQuery(query) {
|
|
356
|
-
this.query = query;
|
|
357
|
-
this.searchField.value = query.search;
|
|
358
|
-
this.replaceField.value = query.replace;
|
|
359
|
-
this.caseField.checked = query.caseSensitive;
|
|
360
|
-
this.reField.checked = query.regexp;
|
|
361
|
-
this.wordField.checked = query.wholeWord;
|
|
362
|
-
}
|
|
363
|
-
mount() {
|
|
364
|
-
this.searchField.select();
|
|
365
|
-
}
|
|
366
|
-
get top() {
|
|
367
|
-
return true;
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
function phrase(view, p) {
|
|
371
|
-
return view.state.phrase(p);
|
|
372
|
-
}
|
|
373
|
-
function findMatchIndex(state, query) {
|
|
374
|
-
try {
|
|
375
|
-
const { from, to } = state.selection.main;
|
|
376
|
-
let index = 0;
|
|
377
|
-
let matchIndex = -1;
|
|
378
|
-
const cursor = query.getCursor(state);
|
|
379
|
-
let data = cursor.next();
|
|
380
|
-
while (!data.done) {
|
|
381
|
-
if (data.value.from === from && data.value.to === to) {
|
|
382
|
-
matchIndex = index;
|
|
383
|
-
}
|
|
384
|
-
data = cursor.next();
|
|
385
|
-
index++;
|
|
386
|
-
}
|
|
387
|
-
return { matchIndex, matchCount: index };
|
|
388
|
-
} catch (e) {
|
|
389
|
-
return { matchIndex: -1, matchCount: 0 };
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
function useDragSearchPanel(panel) {
|
|
393
|
-
let isResizing = false;
|
|
394
|
-
let startX = 0;
|
|
395
|
-
let startWidth = 0;
|
|
396
|
-
const onMouseMove = (e) => {
|
|
397
|
-
e.preventDefault();
|
|
398
|
-
e.stopPropagation();
|
|
399
|
-
if (!isResizing || !(panel == null ? void 0 : panel.dom)) {
|
|
400
|
-
return;
|
|
401
|
-
}
|
|
402
|
-
const newWidth = startX - e.clientX + startWidth;
|
|
403
|
-
panel.dom.style.width = `${newWidth}px`;
|
|
404
|
-
};
|
|
405
|
-
const onMouseUp = (e) => {
|
|
406
|
-
e.preventDefault();
|
|
407
|
-
e.stopPropagation();
|
|
408
|
-
isResizing = false;
|
|
409
|
-
startX = 0;
|
|
410
|
-
startWidth = 0;
|
|
411
|
-
document.removeEventListener("mousemove", onMouseMove);
|
|
412
|
-
document.removeEventListener("mouseup", onMouseUp);
|
|
413
|
-
};
|
|
414
|
-
const onMouseDown = (e) => {
|
|
415
|
-
var _a;
|
|
416
|
-
e.preventDefault();
|
|
417
|
-
e.stopPropagation();
|
|
418
|
-
isResizing = true;
|
|
419
|
-
startX = e.clientX;
|
|
420
|
-
startWidth = (_a = panel == null ? void 0 : panel.dom.clientWidth) != null ? _a : 0;
|
|
421
|
-
document.addEventListener("mousemove", onMouseMove);
|
|
422
|
-
document.addEventListener("mouseup", onMouseUp);
|
|
423
|
-
};
|
|
424
|
-
return onMouseDown;
|
|
425
|
-
}
|
|
426
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
427
|
-
0 && (module.exports = {
|
|
428
|
-
SearchPanel
|
|
429
|
-
});
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], 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
|
-
var theme_exports = {};
|
|
20
|
-
__export(theme_exports, {
|
|
21
|
-
theme: () => theme
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(theme_exports);
|
|
24
|
-
var import_view = require("@codemirror/view");
|
|
25
|
-
var import_state = require("@codemirror/state");
|
|
26
|
-
const theme = import_state.Prec.high(
|
|
27
|
-
import_view.EditorView.theme({
|
|
28
|
-
"& .cm-panels.cm-panels-top": {
|
|
29
|
-
borderBottom: "none",
|
|
30
|
-
backgroundColor: "transparent"
|
|
31
|
-
},
|
|
32
|
-
"& .cm-panels.cm-panels-bottom": {
|
|
33
|
-
borderTop: "none",
|
|
34
|
-
backgroundColor: "transparent",
|
|
35
|
-
border: "1px solid rgba(28, 31, 35, .08)"
|
|
36
|
-
},
|
|
37
|
-
"& .cm-searchMatch": {
|
|
38
|
-
outline: "none"
|
|
39
|
-
},
|
|
40
|
-
"& .cm-custom-search": {
|
|
41
|
-
position: "absolute",
|
|
42
|
-
top: 0,
|
|
43
|
-
right: "10px",
|
|
44
|
-
backgroundColor: "#f3f3f3",
|
|
45
|
-
display: "flex",
|
|
46
|
-
padding: "4px",
|
|
47
|
-
boxSizing: "border-box",
|
|
48
|
-
minWidth: "360px",
|
|
49
|
-
maxWidth: "calc(100% - 30px)",
|
|
50
|
-
borderRadius: "4px",
|
|
51
|
-
boxShadow: "0 2px 8px 2px rgba(0, 0, 0, 0.16)",
|
|
52
|
-
overflow: "hidden"
|
|
53
|
-
},
|
|
54
|
-
"& .cm-custom-search button": {
|
|
55
|
-
borderWidth: 0
|
|
56
|
-
},
|
|
57
|
-
"& .cm-custom-search input": {
|
|
58
|
-
outline: "none"
|
|
59
|
-
},
|
|
60
|
-
"& .cm-custom-search .cm-custom-search-drag": {
|
|
61
|
-
width: "3px",
|
|
62
|
-
height: "100%",
|
|
63
|
-
position: "absolute",
|
|
64
|
-
top: "0px",
|
|
65
|
-
left: "0px",
|
|
66
|
-
backgroundColor: "#c8c8c8"
|
|
67
|
-
},
|
|
68
|
-
"& .cm-custom-search .cm-custom-search-drag:hover": {
|
|
69
|
-
backgroundColor: "#0090f1",
|
|
70
|
-
cursor: "col-resize"
|
|
71
|
-
},
|
|
72
|
-
"& .cm-custom-text-field": {
|
|
73
|
-
backgroundColor: "inherit",
|
|
74
|
-
padding: 0,
|
|
75
|
-
border: "none",
|
|
76
|
-
color: "#444d56",
|
|
77
|
-
fontSize: "12px",
|
|
78
|
-
lineHeight: "16px",
|
|
79
|
-
verticalAlign: "middle",
|
|
80
|
-
width: "calc(100% - 58px)"
|
|
81
|
-
},
|
|
82
|
-
"& .cm-custom-search-panel-icon": {
|
|
83
|
-
display: "inline-flex",
|
|
84
|
-
"align-items": "center",
|
|
85
|
-
"justify-content": "center",
|
|
86
|
-
padding: "4px",
|
|
87
|
-
"border-radius": "2px",
|
|
88
|
-
"background-color": "transparent",
|
|
89
|
-
"box-sizing": "border-box",
|
|
90
|
-
width: "20px",
|
|
91
|
-
height: "20px",
|
|
92
|
-
cursor: "pointer"
|
|
93
|
-
},
|
|
94
|
-
"& .cm-custom-search-panel-icon:hover": {
|
|
95
|
-
color: "rgba(0, 100, 250, 1)",
|
|
96
|
-
backgroundColor: "rgba(46, 60, 56, .09)"
|
|
97
|
-
},
|
|
98
|
-
"& .cm-custom-search-panel-icon:active": {
|
|
99
|
-
backgroundColor: "rgba(46, 50, 56, .13)"
|
|
100
|
-
},
|
|
101
|
-
"& .cm-custom-search-panel-icon span": {
|
|
102
|
-
display: "inline-flex",
|
|
103
|
-
lineHeight: "12px",
|
|
104
|
-
fontSize: "12px"
|
|
105
|
-
},
|
|
106
|
-
"& .cm-custom-search-panel-icon-active": {
|
|
107
|
-
color: "rgba(0, 100, 250, 1)",
|
|
108
|
-
backgroundColor: "rgba(46, 50, 56, .05)"
|
|
109
|
-
},
|
|
110
|
-
"& .cm-custom-search-panel-icon-disabled": {
|
|
111
|
-
color: "rgba(28, 31, 35, .35)",
|
|
112
|
-
backgroundColor: "transparent"
|
|
113
|
-
},
|
|
114
|
-
"& .cm-custom-search-panel-icon-disabled:hover": {
|
|
115
|
-
color: "rgba(28, 31, 35, .35)",
|
|
116
|
-
backgroundColor: "transparent"
|
|
117
|
-
},
|
|
118
|
-
"& .cm-custom-search-panel-icon-disabled:active": {
|
|
119
|
-
color: "rgba(28, 31, 35, .35)",
|
|
120
|
-
backgroundColor: "transparent"
|
|
121
|
-
},
|
|
122
|
-
"& .cm-custom-search-panel-expand": {
|
|
123
|
-
display: "flex",
|
|
124
|
-
padding: "4px"
|
|
125
|
-
},
|
|
126
|
-
"& .cm-custom-search-panel-content": {
|
|
127
|
-
display: "flex",
|
|
128
|
-
flexDirection: "column",
|
|
129
|
-
flex: 1
|
|
130
|
-
},
|
|
131
|
-
"& .cm-custom-search-panel-content-top": {
|
|
132
|
-
display: "flex",
|
|
133
|
-
alignItems: "center"
|
|
134
|
-
},
|
|
135
|
-
"& .cm-custom-search-action-wrapper": {
|
|
136
|
-
display: "flex",
|
|
137
|
-
alignItems: "center",
|
|
138
|
-
justifyContent: "end"
|
|
139
|
-
},
|
|
140
|
-
"& .cm-custom-search-panel-content-input-wrapper": {
|
|
141
|
-
display: "flex",
|
|
142
|
-
alignItems: "center",
|
|
143
|
-
flex: 1,
|
|
144
|
-
position: "relative",
|
|
145
|
-
border: "1px solid #555",
|
|
146
|
-
padding: "4px",
|
|
147
|
-
minWidth: "170px",
|
|
148
|
-
marginLeft: "4px",
|
|
149
|
-
marginRight: "6px",
|
|
150
|
-
borderRadius: "2px"
|
|
151
|
-
},
|
|
152
|
-
"& .cm-custom-search-panel-content-input-wrapper-focus": {
|
|
153
|
-
borderColor: "rgba(0, 100, 250, 1)"
|
|
154
|
-
},
|
|
155
|
-
"& .cm-custom-search-panel-content-input-wrapper .cm-custom-search-panel-icon": {
|
|
156
|
-
position: "absolute",
|
|
157
|
-
top: "4px",
|
|
158
|
-
right: "4px",
|
|
159
|
-
padding: "2px",
|
|
160
|
-
width: "16px",
|
|
161
|
-
height: "16px !important"
|
|
162
|
-
},
|
|
163
|
-
"& .cm-panel.cm-custom-search [name=word]": {
|
|
164
|
-
right: "22px"
|
|
165
|
-
},
|
|
166
|
-
"& .cm-panel.cm-custom-search [name=case]": {
|
|
167
|
-
right: "40px"
|
|
168
|
-
},
|
|
169
|
-
"& .cm-panel.cm-custom-search [name=enter]": {
|
|
170
|
-
right: "58px"
|
|
171
|
-
},
|
|
172
|
-
"& .cm-panel.cm-custom-search [name=previous]": {
|
|
173
|
-
marginRight: "2px"
|
|
174
|
-
},
|
|
175
|
-
"& .cm-panel.cm-custom-search [name=next]": {
|
|
176
|
-
marginRight: "2px"
|
|
177
|
-
},
|
|
178
|
-
"& .cm-panel.cm-custom-search [name=close-icon]": {
|
|
179
|
-
marginRight: "2px"
|
|
180
|
-
},
|
|
181
|
-
"& .cm-panel.cm-custom-search [name=replace]": {
|
|
182
|
-
marginRight: "2px"
|
|
183
|
-
},
|
|
184
|
-
"& .cm-panel.cm-custom-search [name=expand]": {
|
|
185
|
-
transform: "rotate(0deg)"
|
|
186
|
-
},
|
|
187
|
-
"& .cm-panel.cm-custom-search [name=expand].cm-custom-search-panel-icon-active": {
|
|
188
|
-
transform: "rotate(90deg)"
|
|
189
|
-
},
|
|
190
|
-
"& .cm-custom-search-match-count": {
|
|
191
|
-
fontSize: "12px",
|
|
192
|
-
width: "80px",
|
|
193
|
-
overflow: "hidden"
|
|
194
|
-
},
|
|
195
|
-
"& .cm-custom-search-panel-content-bottom": {
|
|
196
|
-
marginRight: "104px",
|
|
197
|
-
display: "flex",
|
|
198
|
-
alignItems: "center"
|
|
199
|
-
},
|
|
200
|
-
"& .cm-custom-search-panel-content-bottom .cm-custom-search-panel-content-input-wrapper": {
|
|
201
|
-
marginTop: "6px"
|
|
202
|
-
}
|
|
203
|
-
})
|
|
204
|
-
);
|
|
205
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
206
|
-
0 && (module.exports = {
|
|
207
|
-
theme
|
|
208
|
-
});
|