@teipublisher/pb-components 1.40.2 → 1.41.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/CHANGELOG.md +20 -0
- package/dist/demo/pb-code-editor.html +12 -9
- package/dist/{iron-form-f540b15b.js → iron-form-9e72ac45.js} +1 -1
- package/dist/jinn-codemirror-cc5827eb.js +1 -0
- package/dist/{paper-checkbox-f6a70487.js → paper-checkbox-102e3b43.js} +120 -120
- package/dist/pb-code-editor.js +22 -0
- package/dist/pb-components-bundle.js +234 -234
- package/dist/pb-edit-app.js +33 -33
- package/dist/pb-elements.json +61 -16
- package/dist/pb-i18n-6ad23bcf.js +1 -0
- package/dist/pb-message-0fb0b538.js +911 -0
- package/dist/pb-odd-editor.js +125 -82
- package/package.json +4 -5
- package/pb-elements.json +61 -16
- package/src/pb-code-editor.js +51 -663
- package/src/pb-components.js +0 -1
- package/src/pb-odd-model-editor.js +68 -23
- package/src/pb-odd-parameter-editor.js +17 -9
- package/src/pb-odd-rendition-editor.js +19 -9
- package/css/codemirror/3024-day.css +0 -41
- package/css/codemirror/3024-night.css +0 -39
- package/css/codemirror/abbott.css +0 -268
- package/css/codemirror/abcdef.css +0 -32
- package/css/codemirror/ambiance-mobile.css +0 -5
- package/css/codemirror/ambiance.css +0 -74
- package/css/codemirror/ayu-dark.css +0 -44
- package/css/codemirror/ayu-mirage.css +0 -45
- package/css/codemirror/base16-dark.css +0 -40
- package/css/codemirror/base16-light.css +0 -38
- package/css/codemirror/bespin.css +0 -34
- package/css/codemirror/blackboard.css +0 -32
- package/css/codemirror/cobalt.css +0 -25
- package/css/codemirror/colorforth.css +0 -33
- package/css/codemirror/darcula.css +0 -53
- package/css/codemirror/dracula.css +0 -40
- package/css/codemirror/duotone-dark.css +0 -35
- package/css/codemirror/duotone-light.css +0 -36
- package/css/codemirror/eclipse.css +0 -23
- package/css/codemirror/elegant.css +0 -13
- package/css/codemirror/erlang-dark.css +0 -34
- package/css/codemirror/gruvbox-dark.css +0 -39
- package/css/codemirror/hopscotch.css +0 -34
- package/css/codemirror/icecoder.css +0 -43
- package/css/codemirror/idea.css +0 -42
- package/css/codemirror/isotope.css +0 -34
- package/css/codemirror/juejin.css +0 -30
- package/css/codemirror/lesser-dark.css +0 -47
- package/css/codemirror/liquibyte.css +0 -95
- package/css/codemirror/lucario.css +0 -37
- package/css/codemirror/material-darker.css +0 -135
- package/css/codemirror/material-ocean.css +0 -141
- package/css/codemirror/material-palenight.css +0 -141
- package/css/codemirror/material.css +0 -141
- package/css/codemirror/mbo.css +0 -37
- package/css/codemirror/mdn-like.css +0 -46
- package/css/codemirror/midnight.css +0 -39
- package/css/codemirror/monokai.css +0 -41
- package/css/codemirror/moxer.css +0 -143
- package/css/codemirror/neat.css +0 -12
- package/css/codemirror/neo.css +0 -43
- package/css/codemirror/night.css +0 -27
- package/css/codemirror/nord.css +0 -42
- package/css/codemirror/oceanic-next.css +0 -46
- package/css/codemirror/panda-syntax.css +0 -85
- package/css/codemirror/paraiso-dark.css +0 -38
- package/css/codemirror/paraiso-light.css +0 -38
- package/css/codemirror/pastel-on-dark.css +0 -52
- package/css/codemirror/railscasts.css +0 -34
- package/css/codemirror/rubyblue.css +0 -25
- package/css/codemirror/seti.css +0 -44
- package/css/codemirror/shadowfox.css +0 -52
- package/css/codemirror/solarized.css +0 -168
- package/css/codemirror/ssms.css +0 -16
- package/css/codemirror/the-matrix.css +0 -30
- package/css/codemirror/tomorrow-night-bright.css +0 -35
- package/css/codemirror/tomorrow-night-eighties.css +0 -38
- package/css/codemirror/ttcn.css +0 -64
- package/css/codemirror/twilight.css +0 -32
- package/css/codemirror/vibrant-ink.css +0 -34
- package/css/codemirror/xq-dark.css +0 -53
- package/css/codemirror/xq-light.css +0 -43
- package/css/codemirror/yeti.css +0 -44
- package/css/codemirror/yonce.css +0 -59
- package/css/codemirror/zenburn.css +0 -37
- package/dist/pb-message-1a0c0c52.js +0 -1360
- package/lib/codemirror/addon/display/placeholder.js +0 -70
- package/lib/codemirror/addon/edit/matchbrackets.js +0 -152
- package/lib/codemirror/addon/lint/lint.js +0 -282
- package/lib/codemirror/mode/css/css.js +0 -855
- package/lib/codemirror/mode/stex/stex.js +0 -249
- package/lib/codemirror/mode/xml/xml.js +0 -404
- package/lib/codemirror/mode/xquery/xquery.js +0 -434
package/src/pb-code-editor.js
CHANGED
|
@@ -1,495 +1,21 @@
|
|
|
1
|
-
import { LitElement, html, css } from 'lit-element'
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { LitElement, html, css } from 'lit-element';
|
|
2
|
+
import "@jinntec/jinn-codemirror/dist/src/jinn-codemirror";
|
|
3
|
+
import { translate } from './pb-i18n.js';
|
|
4
|
+
import { pbMixin } from "./pb-mixin.js";
|
|
4
5
|
|
|
5
|
-
import modeXquery from "../lib/codemirror/mode/xquery/xquery.js";
|
|
6
|
-
import modeCss from "../lib/codemirror/mode/css/css.js";
|
|
7
|
-
import modeXml from "../lib/codemirror/mode/xml/xml.js";
|
|
8
|
-
import modeStex from "../lib/codemirror/mode/stex/stex.js";
|
|
9
|
-
import addonDisplayPlaceholder from "../lib/codemirror/addon/display/placeholder.js";
|
|
10
|
-
import addonEditMatchBracket from "../lib/codemirror/addon/edit/matchbrackets.js";
|
|
11
|
-
import addonLint from "../lib/codemirror/addon/lint/lint.js";
|
|
12
|
-
import { resolveURL, cmpVersion } from './utils.js';
|
|
13
|
-
import { get as i18n } from './pb-i18n.js';
|
|
14
|
-
|
|
15
|
-
modeXquery(CodeMirror);
|
|
16
|
-
modeCss(CodeMirror);
|
|
17
|
-
modeXml(CodeMirror);
|
|
18
|
-
modeStex(CodeMirror);
|
|
19
|
-
addonDisplayPlaceholder(CodeMirror);
|
|
20
|
-
addonEditMatchBracket(CodeMirror);
|
|
21
|
-
addonLint(CodeMirror);
|
|
22
|
-
|
|
23
|
-
async function loadTheme(theme) {
|
|
24
|
-
const resource = resolveURL('../css/codemirror/') + `${theme}.css`;
|
|
25
|
-
console.log('<pb-code-editor> loading theme %s from %s', theme, resource);
|
|
26
|
-
|
|
27
|
-
const fetchedStyles = await fetch(resource).then(async response => response.text()).catch(e => '');
|
|
28
|
-
|
|
29
|
-
return html`<style>${fetchedStyles}</style>`;
|
|
30
|
-
}
|
|
31
6
|
|
|
32
7
|
/**
|
|
33
|
-
* A
|
|
34
|
-
*
|
|
8
|
+
* A code editor based on codemirror 6. Provides a wrapper around
|
|
9
|
+
* [@jinntec/jinn-codemirror](https://github.com/JinnElements/jinn-codemirror),
|
|
10
|
+
* mainly for backwards compatibility.
|
|
35
11
|
*
|
|
36
|
-
* @customElement
|
|
37
12
|
* @demo demo/pb-code-editor.html
|
|
38
13
|
*/
|
|
39
|
-
export class PbCodeEditor extends LitElement {
|
|
40
|
-
|
|
41
|
-
static get styles() {
|
|
42
|
-
return css`
|
|
43
|
-
:host {
|
|
44
|
-
display: block;
|
|
45
|
-
width: 100%;
|
|
46
|
-
margin: 0;
|
|
47
|
-
position: relative;
|
|
48
|
-
color:inherit;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
#editorDiv, .CodeMirror {
|
|
52
|
-
width: 100%;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.label {
|
|
56
|
-
color: var(--paper-grey-500);
|
|
57
|
-
margin-bottom:5px;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/* BASICS */
|
|
61
|
-
|
|
62
|
-
.CodeMirror {
|
|
63
|
-
/* Set height, width, borders, and global font properties here */
|
|
64
|
-
font-family: monospace;
|
|
65
|
-
height: auto;
|
|
66
|
-
color: black;
|
|
67
|
-
direction: ltr;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/* PADDING */
|
|
71
|
-
|
|
72
|
-
.CodeMirror-lines {
|
|
73
|
-
padding: 4px 0; /* Vertical padding around content */
|
|
74
|
-
}
|
|
75
|
-
.CodeMirror pre.CodeMirror-line,
|
|
76
|
-
.CodeMirror pre.CodeMirror-line-like {
|
|
77
|
-
padding: 0 4px; /* Horizontal padding of content */
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
|
81
|
-
background-color: white; /* The little square between H and V scrollbars */
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/* GUTTER */
|
|
85
|
-
|
|
86
|
-
.CodeMirror-gutters {
|
|
87
|
-
border-right: 1px solid #ddd;
|
|
88
|
-
background-color: #f7f7f7;
|
|
89
|
-
white-space: nowrap;
|
|
90
|
-
}
|
|
91
|
-
.CodeMirror-linenumbers {}
|
|
92
|
-
.CodeMirror-linenumber {
|
|
93
|
-
padding: 0 3px 0 5px;
|
|
94
|
-
min-width: 20px;
|
|
95
|
-
text-align: right;
|
|
96
|
-
color: #999;
|
|
97
|
-
white-space: nowrap;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
.CodeMirror-guttermarker { color: black; }
|
|
101
|
-
.CodeMirror-guttermarker-subtle { color: #999; }
|
|
102
|
-
|
|
103
|
-
/* CURSOR */
|
|
104
|
-
|
|
105
|
-
.CodeMirror-cursor {
|
|
106
|
-
border-left: 1px solid black;
|
|
107
|
-
border-right: none;
|
|
108
|
-
width: 0;
|
|
109
|
-
}
|
|
110
|
-
/* Shown when moving in bi-directional text */
|
|
111
|
-
.CodeMirror div.CodeMirror-secondarycursor {
|
|
112
|
-
border-left: 1px solid silver;
|
|
113
|
-
}
|
|
114
|
-
.cm-fat-cursor .CodeMirror-cursor {
|
|
115
|
-
width: auto;
|
|
116
|
-
border: 0 !important;
|
|
117
|
-
background: #7e7;
|
|
118
|
-
}
|
|
119
|
-
.cm-fat-cursor div.CodeMirror-cursors {
|
|
120
|
-
z-index: 1;
|
|
121
|
-
}
|
|
122
|
-
.cm-fat-cursor-mark {
|
|
123
|
-
background-color: rgba(20, 255, 20, 0.5);
|
|
124
|
-
-webkit-animation: blink 1.06s steps(1) infinite;
|
|
125
|
-
-moz-animation: blink 1.06s steps(1) infinite;
|
|
126
|
-
animation: blink 1.06s steps(1) infinite;
|
|
127
|
-
}
|
|
128
|
-
.cm-animate-fat-cursor {
|
|
129
|
-
width: auto;
|
|
130
|
-
border: 0;
|
|
131
|
-
-webkit-animation: blink 1.06s steps(1) infinite;
|
|
132
|
-
-moz-animation: blink 1.06s steps(1) infinite;
|
|
133
|
-
animation: blink 1.06s steps(1) infinite;
|
|
134
|
-
background-color: #7e7;
|
|
135
|
-
}
|
|
136
|
-
@-moz-keyframes blink {
|
|
137
|
-
0% {}
|
|
138
|
-
50% { background-color: transparent; }
|
|
139
|
-
100% {}
|
|
140
|
-
}
|
|
141
|
-
@-webkit-keyframes blink {
|
|
142
|
-
0% {}
|
|
143
|
-
50% { background-color: transparent; }
|
|
144
|
-
100% {}
|
|
145
|
-
}
|
|
146
|
-
@keyframes blink {
|
|
147
|
-
0% {}
|
|
148
|
-
50% { background-color: transparent; }
|
|
149
|
-
100% {}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/* Can style cursor different in overwrite (non-insert) mode */
|
|
153
|
-
.CodeMirror-overwrite .CodeMirror-cursor {}
|
|
154
|
-
|
|
155
|
-
.cm-tab { display: inline-block; text-decoration: inherit; }
|
|
156
|
-
|
|
157
|
-
.CodeMirror-rulers {
|
|
158
|
-
position: absolute;
|
|
159
|
-
left: 0; right: 0; top: -50px; bottom: 0;
|
|
160
|
-
overflow: hidden;
|
|
161
|
-
}
|
|
162
|
-
.CodeMirror-ruler {
|
|
163
|
-
border-left: 1px solid #ccc;
|
|
164
|
-
top: 0; bottom: 0;
|
|
165
|
-
position: absolute;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/* DEFAULT THEME */
|
|
169
|
-
|
|
170
|
-
.cm-s-default .cm-header {color: blue;}
|
|
171
|
-
.cm-s-default .cm-quote {color: #090;}
|
|
172
|
-
.cm-negative {color: #d44;}
|
|
173
|
-
.cm-positive {color: #292;}
|
|
174
|
-
.cm-header, .cm-strong {font-weight: bold;}
|
|
175
|
-
.cm-em {font-style: italic;}
|
|
176
|
-
.cm-link {text-decoration: underline;}
|
|
177
|
-
.cm-strikethrough {text-decoration: line-through;}
|
|
178
|
-
|
|
179
|
-
.cm-s-default .cm-keyword {color: #708;}
|
|
180
|
-
.cm-s-default .cm-atom {color: #219;}
|
|
181
|
-
.cm-s-default .cm-number {color: #164;}
|
|
182
|
-
.cm-s-default .cm-def {color: #00f;}
|
|
183
|
-
.cm-s-default .cm-variable,
|
|
184
|
-
.cm-s-default .cm-punctuation,
|
|
185
|
-
.cm-s-default .cm-property,
|
|
186
|
-
.cm-s-default .cm-operator {}
|
|
187
|
-
.cm-s-default .cm-variable-2 {color: #05a;}
|
|
188
|
-
.cm-s-default .cm-variable-3, .cm-s-default .cm-type {color: #085;}
|
|
189
|
-
.cm-s-default .cm-comment {color: #a50;}
|
|
190
|
-
.cm-s-default .cm-string {color: #a11;}
|
|
191
|
-
.cm-s-default .cm-string-2 {color: #f50;}
|
|
192
|
-
.cm-s-default .cm-meta {color: #555;}
|
|
193
|
-
.cm-s-default .cm-qualifier {color: #555;}
|
|
194
|
-
.cm-s-default .cm-builtin {color: #30a;}
|
|
195
|
-
.cm-s-default .cm-bracket {color: #997;}
|
|
196
|
-
.cm-s-default .cm-tag {color: #170;}
|
|
197
|
-
.cm-s-default .cm-attribute {color: #00c;}
|
|
198
|
-
.cm-s-default .cm-hr {color: #999;}
|
|
199
|
-
.cm-s-default .cm-link {color: #00c;}
|
|
200
|
-
|
|
201
|
-
.cm-s-default .cm-error {color: #f00;}
|
|
202
|
-
.cm-invalidchar {color: #f00;}
|
|
203
|
-
|
|
204
|
-
.CodeMirror-composing { border-bottom: 2px solid; }
|
|
205
|
-
|
|
206
|
-
/* Default styles for common addons */
|
|
207
|
-
|
|
208
|
-
div.CodeMirror span.CodeMirror-matchingbracket {color: #0b0;}
|
|
209
|
-
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}
|
|
210
|
-
.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
|
|
211
|
-
.CodeMirror-activeline-background {background: #e8f2ff;}
|
|
212
|
-
|
|
213
|
-
/* STOP */
|
|
214
|
-
|
|
215
|
-
/* The rest of this file contains styles related to the mechanics of
|
|
216
|
-
the editor. You probably shouldn't touch them. */
|
|
217
|
-
|
|
218
|
-
.CodeMirror {
|
|
219
|
-
position: relative;
|
|
220
|
-
overflow: hidden;
|
|
221
|
-
background: white;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
.CodeMirror-scroll {
|
|
225
|
-
/* 50px is the magic margin used to hide the element's real scrollbars */
|
|
226
|
-
/* See overflow: hidden in .CodeMirror */
|
|
227
|
-
margin-bottom: -50px; margin-right: -50px;
|
|
228
|
-
padding-bottom: 50px;
|
|
229
|
-
max-height: 100%;
|
|
230
|
-
outline: none; /* Prevent dragging from highlighting the element */
|
|
231
|
-
position: relative;
|
|
232
|
-
}
|
|
233
|
-
.CodeMirror-sizer {
|
|
234
|
-
position: relative;
|
|
235
|
-
border-right: 50px solid transparent;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
/* The fake, visible scrollbars. Used to force redraw during scrolling
|
|
239
|
-
before actual scrolling happens, thus preventing shaking and
|
|
240
|
-
flickering artifacts. */
|
|
241
|
-
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
|
242
|
-
position: absolute;
|
|
243
|
-
z-index: 6;
|
|
244
|
-
display: none;
|
|
245
|
-
}
|
|
246
|
-
.CodeMirror-vscrollbar {
|
|
247
|
-
right: 0; top: 0;
|
|
248
|
-
overflow-x: hidden;
|
|
249
|
-
overflow-y: scroll;
|
|
250
|
-
}
|
|
251
|
-
.CodeMirror-hscrollbar {
|
|
252
|
-
bottom: 0; left: 0;
|
|
253
|
-
overflow-y: hidden;
|
|
254
|
-
overflow-x: scroll;
|
|
255
|
-
}
|
|
256
|
-
.CodeMirror-scrollbar-filler {
|
|
257
|
-
right: 0; bottom: 0;
|
|
258
|
-
}
|
|
259
|
-
.CodeMirror-gutter-filler {
|
|
260
|
-
left: 0; bottom: 0;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
.CodeMirror-gutters {
|
|
264
|
-
position: absolute; left: 0; top: 0;
|
|
265
|
-
min-height: 100%;
|
|
266
|
-
z-index: 3;
|
|
267
|
-
}
|
|
268
|
-
.CodeMirror-gutter {
|
|
269
|
-
white-space: normal;
|
|
270
|
-
height: 100%;
|
|
271
|
-
display: inline-block;
|
|
272
|
-
vertical-align: top;
|
|
273
|
-
margin-bottom: -50px;
|
|
274
|
-
}
|
|
275
|
-
.CodeMirror-gutter-wrapper {
|
|
276
|
-
position: absolute;
|
|
277
|
-
z-index: 4;
|
|
278
|
-
background: none !important;
|
|
279
|
-
border: none !important;
|
|
280
|
-
}
|
|
281
|
-
.CodeMirror-gutter-background {
|
|
282
|
-
position: absolute;
|
|
283
|
-
top: 0; bottom: 0;
|
|
284
|
-
z-index: 4;
|
|
285
|
-
}
|
|
286
|
-
.CodeMirror-gutter-elt {
|
|
287
|
-
position: absolute;
|
|
288
|
-
cursor: default;
|
|
289
|
-
z-index: 4;
|
|
290
|
-
}
|
|
291
|
-
.CodeMirror-gutter-wrapper ::selection { background-color: transparent }
|
|
292
|
-
.CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent }
|
|
293
|
-
|
|
294
|
-
.CodeMirror-lines {
|
|
295
|
-
cursor: text;
|
|
296
|
-
min-height: 1px; /* prevents collapsing before first draw */
|
|
297
|
-
}
|
|
298
|
-
.CodeMirror pre.CodeMirror-line,
|
|
299
|
-
.CodeMirror pre.CodeMirror-line-like {
|
|
300
|
-
/* Reset some styles that the rest of the page might have set */
|
|
301
|
-
-moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
|
|
302
|
-
border-width: 0;
|
|
303
|
-
background: transparent;
|
|
304
|
-
font-family: inherit;
|
|
305
|
-
font-size: inherit;
|
|
306
|
-
margin: 0;
|
|
307
|
-
white-space: pre;
|
|
308
|
-
word-wrap: normal;
|
|
309
|
-
line-height: inherit;
|
|
310
|
-
color: inherit;
|
|
311
|
-
z-index: 2;
|
|
312
|
-
position: relative;
|
|
313
|
-
overflow: visible;
|
|
314
|
-
-webkit-tap-highlight-color: transparent;
|
|
315
|
-
-webkit-font-variant-ligatures: contextual;
|
|
316
|
-
font-variant-ligatures: contextual;
|
|
317
|
-
}
|
|
318
|
-
.CodeMirror-wrap pre.CodeMirror-line,
|
|
319
|
-
.CodeMirror-wrap pre.CodeMirror-line-like {
|
|
320
|
-
word-wrap: break-word;
|
|
321
|
-
white-space: pre-wrap;
|
|
322
|
-
word-break: normal;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
.CodeMirror-linebackground {
|
|
326
|
-
position: absolute;
|
|
327
|
-
left: 0; right: 0; top: 0; bottom: 0;
|
|
328
|
-
z-index: 0;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
.CodeMirror-linewidget {
|
|
332
|
-
position: relative;
|
|
333
|
-
z-index: 2;
|
|
334
|
-
padding: 0.1px; /* Force widget margins to stay inside of the container */
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
.CodeMirror-widget {}
|
|
338
|
-
|
|
339
|
-
.CodeMirror-rtl pre { direction: rtl; }
|
|
340
|
-
|
|
341
|
-
.CodeMirror-code {
|
|
342
|
-
outline: none;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
/* Force content-box sizing for the elements where we expect it */
|
|
346
|
-
.CodeMirror-scroll,
|
|
347
|
-
.CodeMirror-sizer,
|
|
348
|
-
.CodeMirror-gutter,
|
|
349
|
-
.CodeMirror-gutters,
|
|
350
|
-
.CodeMirror-linenumber {
|
|
351
|
-
-moz-box-sizing: content-box;
|
|
352
|
-
box-sizing: content-box;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
.CodeMirror-measure {
|
|
356
|
-
position: absolute;
|
|
357
|
-
width: 100%;
|
|
358
|
-
height: 0;
|
|
359
|
-
overflow: hidden;
|
|
360
|
-
visibility: hidden;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
.CodeMirror-cursor {
|
|
364
|
-
position: absolute;
|
|
365
|
-
pointer-events: none;
|
|
366
|
-
}
|
|
367
|
-
.CodeMirror-measure pre { position: static; }
|
|
368
|
-
|
|
369
|
-
div.CodeMirror-cursors {
|
|
370
|
-
visibility: hidden;
|
|
371
|
-
position: relative;
|
|
372
|
-
z-index: 3;
|
|
373
|
-
}
|
|
374
|
-
div.CodeMirror-dragcursors {
|
|
375
|
-
visibility: visible;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
.CodeMirror-focused div.CodeMirror-cursors {
|
|
379
|
-
visibility: visible;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
.CodeMirror-selected { background: #d9d9d9; }
|
|
383
|
-
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
|
|
384
|
-
.CodeMirror-crosshair { cursor: crosshair; }
|
|
385
|
-
.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }
|
|
386
|
-
.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }
|
|
387
|
-
|
|
388
|
-
.cm-searching {
|
|
389
|
-
background-color: #ffa;
|
|
390
|
-
background-color: rgba(255, 255, 0, .4);
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
/* Used to force a border model for a node */
|
|
394
|
-
.cm-force-border { padding-right: .1px; }
|
|
395
|
-
|
|
396
|
-
@media print {
|
|
397
|
-
/* Hide the cursor when printing */
|
|
398
|
-
.CodeMirror div.CodeMirror-cursors {
|
|
399
|
-
visibility: hidden;
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
/* See issue #2901 */
|
|
404
|
-
.cm-tab-wrap-hack:after { content: ''; }
|
|
405
|
-
|
|
406
|
-
/* Help users use markselection to safely style text background */
|
|
407
|
-
span.CodeMirror-selectedtext { background: none; }
|
|
408
|
-
|
|
409
|
-
/* The lint marker gutter */
|
|
410
|
-
.CodeMirror-lint-markers {
|
|
411
|
-
width: 16px;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
.CodeMirror-lint-tooltip {
|
|
415
|
-
background-color: #ffd;
|
|
416
|
-
border: 1px solid black;
|
|
417
|
-
border-radius: 4px 4px 4px 4px;
|
|
418
|
-
color: black;
|
|
419
|
-
font-family: monospace;
|
|
420
|
-
font-size: 10pt;
|
|
421
|
-
overflow: hidden;
|
|
422
|
-
padding: 2px 5px;
|
|
423
|
-
position: fixed;
|
|
424
|
-
white-space: pre;
|
|
425
|
-
white-space: pre-wrap;
|
|
426
|
-
z-index: 100;
|
|
427
|
-
max-width: 600px;
|
|
428
|
-
opacity: 0;
|
|
429
|
-
transition: opacity .4s;
|
|
430
|
-
-moz-transition: opacity .4s;
|
|
431
|
-
-webkit-transition: opacity .4s;
|
|
432
|
-
-o-transition: opacity .4s;
|
|
433
|
-
-ms-transition: opacity .4s;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
.CodeMirror-lint-mark-error, .CodeMirror-lint-mark-warning {
|
|
437
|
-
background-position: left bottom;
|
|
438
|
-
background-repeat: repeat-x;
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
.CodeMirror-lint-mark-error {
|
|
442
|
-
background-image:
|
|
443
|
-
url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJDw4cOCW1/KIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAHElEQVQI12NggIL/DAz/GdA5/xkY/qPKMDAwAADLZwf5rvm+LQAAAABJRU5ErkJggg==")
|
|
444
|
-
;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
.CodeMirror-lint-mark-warning {
|
|
448
|
-
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJFhQXEbhTg7YAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAMklEQVQI12NkgIIvJ3QXMjAwdDN+OaEbysDA4MPAwNDNwMCwiOHLCd1zX07o6kBVGQEAKBANtobskNMAAAAASUVORK5CYII=");
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
.CodeMirror-lint-marker-error, .CodeMirror-lint-marker-warning {
|
|
452
|
-
background-position: center center;
|
|
453
|
-
background-repeat: no-repeat;
|
|
454
|
-
cursor: pointer;
|
|
455
|
-
display: inline-block;
|
|
456
|
-
height: 16px;
|
|
457
|
-
width: 16px;
|
|
458
|
-
vertical-align: middle;
|
|
459
|
-
position: relative;
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
.CodeMirror-lint-message-error, .CodeMirror-lint-message-warning {
|
|
463
|
-
padding-left: 18px;
|
|
464
|
-
background-position: top left;
|
|
465
|
-
background-repeat: no-repeat;
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
.CodeMirror-lint-marker-error, .CodeMirror-lint-message-error {
|
|
469
|
-
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAHlBMVEW7AAC7AACxAAC7AAC7AAAAAAC4AAC5AAD///+7AAAUdclpAAAABnRSTlMXnORSiwCK0ZKSAAAATUlEQVR42mWPOQ7AQAgDuQLx/z8csYRmPRIFIwRGnosRrpamvkKi0FTIiMASR3hhKW+hAN6/tIWhu9PDWiTGNEkTtIOucA5Oyr9ckPgAWm0GPBog6v4AAAAASUVORK5CYII=");
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
.CodeMirror-lint-marker-warning, .CodeMirror-lint-message-warning {
|
|
473
|
-
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAANlBMVEX/uwDvrwD/uwD/uwD/uwD/uwD/uwD/uwD/uwD6twD/uwAAAADurwD2tQD7uAD+ugAAAAD/uwDhmeTRAAAADHRSTlMJ8mN1EYcbmiixgACm7WbuAAAAVklEQVR42n3PUQqAIBBFUU1LLc3u/jdbOJoW1P08DA9Gba8+YWJ6gNJoNYIBzAA2chBth5kLmG9YUoG0NHAUwFXwO9LuBQL1giCQb8gC9Oro2vp5rncCIY8L8uEx5ZkAAAAASUVORK5CYII=");
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
.CodeMirror-lint-marker-multiple {
|
|
477
|
-
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAMAAADzjKfhAAAACVBMVEUAAAAAAAC/v7914kyHAAAAAXRSTlMAQObYZgAAACNJREFUeNo1ioEJAAAIwmz/H90iFFSGJgFMe3gaLZ0od+9/AQZ0ADosbYraAAAAAElFTkSuQmCC");
|
|
478
|
-
background-repeat: no-repeat;
|
|
479
|
-
background-position: right bottom;
|
|
480
|
-
width: 100%; height: 100%;
|
|
481
|
-
}
|
|
482
|
-
`;
|
|
483
|
-
}
|
|
14
|
+
export class PbCodeEditor extends pbMixin(LitElement) {
|
|
484
15
|
|
|
485
16
|
static get properties() {
|
|
486
17
|
return {
|
|
487
|
-
|
|
488
|
-
* reference to actual CodeMirror object
|
|
489
|
-
*/
|
|
490
|
-
_editor: {
|
|
491
|
-
type: Object
|
|
492
|
-
},
|
|
18
|
+
...super.properties,
|
|
493
19
|
/**
|
|
494
20
|
* the code as a string
|
|
495
21
|
*/
|
|
@@ -503,6 +29,12 @@ export class PbCodeEditor extends LitElement {
|
|
|
503
29
|
mode: {
|
|
504
30
|
type: String
|
|
505
31
|
},
|
|
32
|
+
/**
|
|
33
|
+
* label for the editor
|
|
34
|
+
*/
|
|
35
|
+
label: {
|
|
36
|
+
type: String
|
|
37
|
+
},
|
|
506
38
|
/**
|
|
507
39
|
* placeholder if code is empty
|
|
508
40
|
*/
|
|
@@ -515,222 +47,78 @@ export class PbCodeEditor extends LitElement {
|
|
|
515
47
|
tabSize: {
|
|
516
48
|
type: Number
|
|
517
49
|
},
|
|
518
|
-
/**
|
|
519
|
-
* label for the editor
|
|
520
|
-
*/
|
|
521
|
-
label: {
|
|
522
|
-
type: String
|
|
523
|
-
},
|
|
524
|
-
theme: {
|
|
525
|
-
type: String
|
|
526
|
-
},
|
|
527
|
-
_themeStyles: {
|
|
528
|
-
type: String
|
|
529
|
-
},
|
|
530
50
|
linter: {
|
|
531
51
|
attribute: true
|
|
532
|
-
},
|
|
533
|
-
apiVersion: {
|
|
534
|
-
type: String
|
|
535
52
|
}
|
|
536
53
|
};
|
|
537
54
|
}
|
|
538
55
|
|
|
539
56
|
constructor() {
|
|
540
57
|
super();
|
|
58
|
+
|
|
541
59
|
this.code = '';
|
|
542
|
-
this.mode = '
|
|
60
|
+
this.mode = 'xml';
|
|
543
61
|
this.placeholder = 'odd.editor.model.empty';
|
|
544
62
|
this.tabSize = 2;
|
|
545
63
|
this.label = '';
|
|
546
64
|
this.linter = '';
|
|
547
|
-
this.
|
|
548
|
-
this._themeStyles = null;
|
|
549
|
-
this.apiVersion = '0.9.0';
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
set theme(value) {
|
|
553
|
-
if (value) {
|
|
554
|
-
loadTheme(value).then((styles) => {
|
|
555
|
-
this._themeStyles = styles;
|
|
556
|
-
this._editor.setOption('theme', value);
|
|
557
|
-
});
|
|
558
|
-
}
|
|
559
|
-
this.requestUpdate('_themeStyles', value);
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
render() {
|
|
563
|
-
return html`
|
|
564
|
-
${this._themeStyles}
|
|
565
|
-
<iron-ajax id="lint" url="${this.linter}"
|
|
566
|
-
handle-as="json"
|
|
567
|
-
method="POST"
|
|
568
|
-
@error="${this._handleLintError}"></iron-ajax>
|
|
569
|
-
|
|
570
|
-
<div class="label">${this.label}</div>
|
|
571
|
-
<div id="editorDiv"></div>
|
|
572
|
-
`;
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
attributeChangedCallback(name, old, value) {
|
|
576
|
-
super.attributeChangedCallback(name, old, value);
|
|
577
|
-
if (name === 'code') {
|
|
578
|
-
this.setSource(value);
|
|
579
|
-
this.code = value;
|
|
580
|
-
this.requestUpdate();
|
|
581
|
-
}
|
|
65
|
+
this._editor = null;
|
|
582
66
|
}
|
|
583
67
|
|
|
584
68
|
connectedCallback() {
|
|
585
69
|
super.connectedCallback();
|
|
586
|
-
|
|
587
|
-
this.placeholder = i18n(this.placeholder);
|
|
588
|
-
|
|
589
|
-
document.addEventListener('pb-i18n-update', (ev) => {
|
|
590
|
-
this.placeholder = ev.detail.t(this.placeholder);
|
|
591
|
-
if (this._editor) {
|
|
592
|
-
this._editor.setOption('placeholder', this.placeholder);
|
|
593
|
-
}
|
|
594
|
-
});
|
|
595
70
|
}
|
|
596
71
|
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
this._initEditor();
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
_initEditor() {
|
|
603
|
-
const options = {
|
|
604
|
-
value: this.code || '',
|
|
605
|
-
mode: this.mode,
|
|
606
|
-
lineNumbers: true,
|
|
607
|
-
lineWrapping: true,
|
|
608
|
-
autofocus: false,
|
|
609
|
-
matchBrackets: true,
|
|
610
|
-
placeholder: this.placeholder,
|
|
611
|
-
gutters: ["CodeMirror-lint-markers"],
|
|
612
|
-
lint: true,
|
|
613
|
-
viewportMargin: Infinity
|
|
614
|
-
};
|
|
615
|
-
if (this.theme) {
|
|
616
|
-
options.theme = this.theme;
|
|
617
|
-
}
|
|
72
|
+
firstUpdated() {
|
|
73
|
+
super.firstUpdated();
|
|
618
74
|
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
this._editor = cm;
|
|
625
|
-
if (this.mode === 'xquery' && this.linter !== '') {
|
|
626
|
-
CodeMirror.registerHelper("lint", "xquery", this.lintXQuery.bind(this));
|
|
627
|
-
}
|
|
75
|
+
this._editor = this.shadowRoot.getElementById('editor');
|
|
76
|
+
// this._editor.addEventListener('update', () => {
|
|
77
|
+
// this._setCode(this._editor.content);
|
|
78
|
+
// })
|
|
628
79
|
}
|
|
629
80
|
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
*
|
|
636
|
-
* @param {String} text
|
|
637
|
-
* @returns {Array|Promise}
|
|
638
|
-
*/
|
|
639
|
-
lintXQuery(text) {
|
|
640
|
-
if (!text) {
|
|
641
|
-
return [];
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
const ajax = this.shadowRoot.getElementById('lint');
|
|
645
|
-
|
|
646
|
-
return new Promise((resolve) => {
|
|
647
|
-
if (cmpVersion(this.apiVersion, '1.0.0')) {
|
|
648
|
-
ajax.contentType="application/x-www-form-urlencoded";
|
|
649
|
-
ajax.params = null;
|
|
650
|
-
const params = {
|
|
651
|
-
action: "lint",
|
|
652
|
-
code: text
|
|
653
|
-
};
|
|
654
|
-
ajax.body = params;
|
|
655
|
-
} else {
|
|
656
|
-
ajax.contentType="text";
|
|
657
|
-
ajax.params = {
|
|
658
|
-
code: text
|
|
659
|
-
};
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
const request = ajax.generateRequest();
|
|
663
|
-
request.completes.then((req) => {
|
|
664
|
-
const data = req.response;
|
|
665
|
-
if (data.status === 'fail') {
|
|
666
|
-
resolve([{
|
|
667
|
-
message: data.message,
|
|
668
|
-
severity: "error",
|
|
669
|
-
from: CodeMirror.Pos(data.line - 1, data.column),
|
|
670
|
-
to: CodeMirror.Pos(data.line - 1, data.column + 3)
|
|
671
|
-
}]);
|
|
672
|
-
}
|
|
673
|
-
else {
|
|
674
|
-
resolve([]);
|
|
675
|
-
}
|
|
676
|
-
});
|
|
677
|
-
|
|
678
|
-
});
|
|
81
|
+
render() {
|
|
82
|
+
return html`
|
|
83
|
+
<div class="label">${this.label}</div>
|
|
84
|
+
<jinn-codemirror id="editor" mode="${this.mode}" code="${this.code}" placeholder="${translate(this.placeholder)}"></jinn-codemirror>
|
|
85
|
+
`;
|
|
679
86
|
}
|
|
680
87
|
|
|
681
|
-
|
|
682
|
-
/**
|
|
683
|
-
*
|
|
684
|
-
* @returns {String} the sourcecode
|
|
685
|
-
*/
|
|
686
88
|
getSource() {
|
|
687
89
|
if (!this._editor) {
|
|
688
90
|
return '';
|
|
689
91
|
}
|
|
690
|
-
return this._editor.
|
|
92
|
+
return this._editor.value;
|
|
691
93
|
}
|
|
692
94
|
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
*
|
|
696
|
-
* @param {String} newval
|
|
697
|
-
*/
|
|
698
|
-
setSource(newval) {
|
|
699
|
-
if (!this._editor || newval === this._editor.getValue()) {
|
|
700
|
-
return;
|
|
701
|
-
}
|
|
702
|
-
const val = newval || ''
|
|
703
|
-
this._editor.setValue(val);
|
|
704
|
-
this._editor.refresh();
|
|
95
|
+
_setCode() {
|
|
96
|
+
this.dispatchEvent(new CustomEvent('code-changed', { composed: true, bubbles: true, detail: { code: this.getSource() } }));
|
|
705
97
|
}
|
|
706
98
|
|
|
707
|
-
/**
|
|
708
|
-
* call refresh() to update the view after external changes have occured. Might be needed after dynamic
|
|
709
|
-
* changes of the UI.
|
|
710
|
-
*/
|
|
711
99
|
refresh() {
|
|
712
|
-
if (!this._editor) return;
|
|
713
|
-
this._editor.refresh();
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
setCode(value) {
|
|
717
|
-
this.code = value
|
|
718
|
-
this.dispatchEvent(new CustomEvent('code-changed', { composed: true, bubbles: true, detail: { code: this.code } }));
|
|
719
100
|
}
|
|
720
101
|
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
}
|
|
102
|
+
static get styles() {
|
|
103
|
+
return css`
|
|
104
|
+
:host {
|
|
105
|
+
display: block;
|
|
106
|
+
width: 100%;
|
|
107
|
+
margin: 0;
|
|
108
|
+
position: relative;
|
|
109
|
+
color:inherit;
|
|
110
|
+
}
|
|
731
111
|
|
|
112
|
+
#editor {
|
|
113
|
+
width: 100%;
|
|
114
|
+
height: auto;
|
|
115
|
+
}
|
|
732
116
|
|
|
117
|
+
.label {
|
|
118
|
+
color: var(--paper-grey-500);
|
|
119
|
+
margin-bottom:5px;
|
|
120
|
+
}
|
|
121
|
+
`;
|
|
733
122
|
}
|
|
734
123
|
}
|
|
735
|
-
|
|
736
|
-
customElements.define('pb-code-editor', PbCodeEditor);
|
|
124
|
+
customElements.define('pb-code-editor', PbCodeEditor);
|