@progressive-development/pd-content 1.0.3 → 1.1.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/index.d.ts +2 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -4
- package/dist/node_modules/.pnpm/@codemirror_autocomplete@6.20.1/node_modules/@codemirror/autocomplete/dist/index.js +550 -0
- package/dist/node_modules/.pnpm/@codemirror_lang-css@6.3.1/node_modules/@codemirror/lang-css/dist/index.js +264 -0
- package/dist/node_modules/.pnpm/@codemirror_lang-html@6.4.11/node_modules/@codemirror/lang-html/dist/index.js +661 -0
- package/dist/node_modules/.pnpm/@codemirror_lang-java@6.0.2/node_modules/@codemirror/lang-java/dist/index.js +44 -0
- package/dist/node_modules/.pnpm/@codemirror_lang-javascript@6.2.5/node_modules/@codemirror/lang-javascript/dist/index.js +346 -0
- package/dist/node_modules/.pnpm/@codemirror_lang-json@6.0.2/node_modules/@codemirror/lang-json/dist/index.js +32 -0
- package/dist/node_modules/.pnpm/@codemirror_lang-markdown@6.5.0/node_modules/@codemirror/lang-markdown/dist/index.js +492 -0
- package/dist/node_modules/.pnpm/@codemirror_lang-python@6.2.1/node_modules/@codemirror/lang-python/dist/index.js +308 -0
- package/dist/node_modules/.pnpm/@codemirror_language@6.12.3/node_modules/@codemirror/language/dist/index.js +1572 -0
- package/dist/node_modules/.pnpm/@codemirror_state@6.6.0/node_modules/@codemirror/state/dist/index.js +3881 -0
- package/dist/node_modules/.pnpm/@codemirror_view@6.40.0/node_modules/@codemirror/view/dist/index.js +9657 -0
- package/dist/node_modules/.pnpm/@lezer_common@1.5.1/node_modules/@lezer/common/dist/index.js +2196 -0
- package/dist/node_modules/.pnpm/@lezer_css@1.3.3/node_modules/@lezer/css/dist/index.js +147 -0
- package/dist/node_modules/.pnpm/@lezer_highlight@1.2.3/node_modules/@lezer/highlight/dist/index.js +898 -0
- package/dist/node_modules/.pnpm/@lezer_html@1.3.13/node_modules/@lezer/html/dist/index.js +349 -0
- package/dist/node_modules/.pnpm/@lezer_java@1.1.3/node_modules/@lezer/java/dist/index.js +67 -0
- package/dist/node_modules/.pnpm/@lezer_javascript@1.5.4/node_modules/@lezer/javascript/dist/index.js +192 -0
- package/dist/node_modules/.pnpm/@lezer_json@1.0.3/node_modules/@lezer/json/dist/index.js +37 -0
- package/dist/node_modules/.pnpm/@lezer_lr@1.4.8/node_modules/@lezer/lr/dist/index.js +1884 -0
- package/dist/node_modules/.pnpm/@lezer_markdown@1.6.3/node_modules/@lezer/markdown/dist/index.js +2335 -0
- package/dist/node_modules/.pnpm/@lezer_python@1.1.18/node_modules/@lezer/python/dist/index.js +326 -0
- package/dist/node_modules/.pnpm/@marijn_find-cluster-break@1.0.2/node_modules/@marijn/find-cluster-break/src/index.js +82 -0
- package/dist/node_modules/.pnpm/style-mod@4.1.3/node_modules/style-mod/src/style-mod.js +174 -0
- package/dist/node_modules/.pnpm/w3c-keyname@2.2.8/node_modules/w3c-keyname/index.js +121 -0
- package/dist/pd-badge-order/PdBadgeItem.d.ts +11 -0
- package/dist/pd-badge-order/PdBadgeItem.d.ts.map +1 -1
- package/dist/pd-badge-order/PdBadgeItem.js +162 -10
- package/dist/pd-badge-order/PdBadgeOrder.d.ts +56 -17
- package/dist/pd-badge-order/PdBadgeOrder.d.ts.map +1 -1
- package/dist/pd-badge-order/PdBadgeOrder.js +308 -153
- package/dist/pd-badge-order/types.js +3 -1
- package/dist/pd-code-snippet/PdCodeSnippet.d.ts +29 -0
- package/dist/pd-code-snippet/PdCodeSnippet.d.ts.map +1 -1
- package/dist/pd-code-snippet/PdCodeSnippet.js +117 -67
- package/dist/pd-code-snippet/codemirror-setup.d.ts +10 -0
- package/dist/pd-code-snippet/codemirror-setup.d.ts.map +1 -0
- package/dist/pd-code-snippet/codemirror-setup.js +101 -0
- package/dist/pd-loading-state/PdLoadingState.d.ts +4 -1
- package/dist/pd-loading-state/PdLoadingState.d.ts.map +1 -1
- package/dist/pd-loading-state/pd-loading-state.d.ts +1 -1
- package/dist/pd-loading-state/pd-loading-state.d.ts.map +1 -1
- package/dist/pd-loading-state/pd-logo-loader.js +2 -2
- package/dist/pd-more-info/PdMoreInfo.d.ts +52 -4
- package/dist/pd-more-info/PdMoreInfo.d.ts.map +1 -1
- package/dist/pd-more-info/PdMoreInfo.js +146 -24
- package/dist/pd-notice-box/PdNoticeBox.d.ts +8 -1
- package/dist/pd-notice-box/PdNoticeBox.d.ts.map +1 -1
- package/dist/pd-notice-box/PdNoticeBox.js +41 -2
- package/dist/pd-panel-viewer/PdPanel.d.ts +3 -0
- package/dist/pd-panel-viewer/PdPanel.d.ts.map +1 -1
- package/dist/pd-panel-viewer/PdPanel.js +8 -1
- package/dist/pd-panel-viewer/PdPanelViewer.d.ts +3 -0
- package/dist/pd-panel-viewer/PdPanelViewer.d.ts.map +1 -1
- package/dist/pd-panel-viewer/PdPanelViewer.js +59 -26
- package/dist/pd-tab/PdTab.d.ts +8 -5
- package/dist/pd-tab/PdTab.d.ts.map +1 -1
- package/dist/pd-tab/PdTab.js +110 -56
- package/dist/pd-timeline/PdTimeline.d.ts +2 -0
- package/dist/pd-timeline/PdTimeline.d.ts.map +1 -1
- package/dist/pd-timeline/PdTimeline.js +50 -19
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +16 -8
- package/dist/pd-gallery/PdGallery.d.ts +0 -72
- package/dist/pd-gallery/PdGallery.d.ts.map +0 -1
- package/dist/pd-gallery/PdGallery.js +0 -660
- package/dist/pd-gallery/PdGalleryLightbox.d.ts +0 -53
- package/dist/pd-gallery/PdGalleryLightbox.d.ts.map +0 -1
- package/dist/pd-gallery/PdGalleryLightbox.js +0 -530
- package/dist/pd-gallery/index.d.ts +0 -4
- package/dist/pd-gallery/index.d.ts.map +0 -1
- package/dist/pd-gallery/pd-gallery-lightbox.d.ts +0 -3
- package/dist/pd-gallery/pd-gallery-lightbox.d.ts.map +0 -1
- package/dist/pd-gallery/pd-gallery.d.ts +0 -3
- package/dist/pd-gallery/pd-gallery.d.ts.map +0 -1
- package/dist/pd-gallery/types.d.ts +0 -23
- package/dist/pd-gallery/types.d.ts.map +0 -1
- package/dist/pd-gallery-lightbox.d.ts +0 -2
- package/dist/pd-gallery-lightbox.js +0 -8
- package/dist/pd-gallery.d.ts +0 -2
- package/dist/pd-gallery.js +0 -8
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { parser } from '../../../../../@lezer_java@1.1.3/node_modules/@lezer/java/dist/index.js';
|
|
2
|
+
import { LanguageSupport, LRLanguage, indentNodeProp, flatIndent, continuedIndent, delimitedIndent, foldNodeProp, foldInside } from '../../../../../@codemirror_language@6.12.3/node_modules/@codemirror/language/dist/index.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
A language provider based on the [Lezer Java
|
|
6
|
+
parser](https://github.com/lezer-parser/java), extended with
|
|
7
|
+
highlighting and indentation information.
|
|
8
|
+
*/
|
|
9
|
+
const javaLanguage = /*@__PURE__*/LRLanguage.define({
|
|
10
|
+
name: "java",
|
|
11
|
+
parser: /*@__PURE__*/parser.configure({
|
|
12
|
+
props: [
|
|
13
|
+
/*@__PURE__*/indentNodeProp.add({
|
|
14
|
+
IfStatement: /*@__PURE__*/continuedIndent({ except: /^\s*({|else\b)/ }),
|
|
15
|
+
TryStatement: /*@__PURE__*/continuedIndent({ except: /^\s*({|catch|finally)\b/ }),
|
|
16
|
+
LabeledStatement: flatIndent,
|
|
17
|
+
SwitchBlock: context => {
|
|
18
|
+
let after = context.textAfter, closed = /^\s*\}/.test(after), isCase = /^\s*(case|default)\b/.test(after);
|
|
19
|
+
return context.baseIndent + (closed ? 0 : isCase ? 1 : 2) * context.unit;
|
|
20
|
+
},
|
|
21
|
+
Block: /*@__PURE__*/delimitedIndent({ closing: "}" }),
|
|
22
|
+
BlockComment: () => null,
|
|
23
|
+
Statement: /*@__PURE__*/continuedIndent({ except: /^{/ })
|
|
24
|
+
}),
|
|
25
|
+
/*@__PURE__*/foldNodeProp.add({
|
|
26
|
+
["Block SwitchBlock ClassBody ElementValueArrayInitializer ModuleBody EnumBody " +
|
|
27
|
+
"ConstructorBody InterfaceBody ArrayInitializer"]: foldInside,
|
|
28
|
+
BlockComment(tree) { return { from: tree.from + 2, to: tree.to - 2 }; }
|
|
29
|
+
})
|
|
30
|
+
]
|
|
31
|
+
}),
|
|
32
|
+
languageData: {
|
|
33
|
+
commentTokens: { line: "//", block: { open: "/*", close: "*/" } },
|
|
34
|
+
indentOnInput: /^\s*(?:case |default:|\{|\})$/
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
Java language support.
|
|
39
|
+
*/
|
|
40
|
+
function java() {
|
|
41
|
+
return new LanguageSupport(javaLanguage);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { java, javaLanguage };
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
import { parser } from '../../../../../@lezer_javascript@1.5.4/node_modules/@lezer/javascript/dist/index.js';
|
|
2
|
+
import { LanguageSupport, sublanguageProp, LRLanguage, indentNodeProp, flatIndent, continuedIndent, delimitedIndent, foldNodeProp, foldInside, syntaxTree, defineLanguageFacet } from '../../../../../@codemirror_language@6.12.3/node_modules/@codemirror/language/dist/index.js';
|
|
3
|
+
import { EditorSelection } from '../../../../../@codemirror_state@6.6.0/node_modules/@codemirror/state/dist/index.js';
|
|
4
|
+
import { EditorView } from '../../../../../@codemirror_view@6.40.0/node_modules/@codemirror/view/dist/index.js';
|
|
5
|
+
import { ifNotIn, completeFromList, snippetCompletion } from '../../../../../@codemirror_autocomplete@6.20.1/node_modules/@codemirror/autocomplete/dist/index.js';
|
|
6
|
+
import { NodeWeakMap, IterMode } from '../../../../../@lezer_common@1.5.1/node_modules/@lezer/common/dist/index.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
A collection of JavaScript-related
|
|
10
|
+
[snippets](https://codemirror.net/6/docs/ref/#autocomplete.snippet).
|
|
11
|
+
*/
|
|
12
|
+
const snippets = [
|
|
13
|
+
/*@__PURE__*/snippetCompletion("function ${name}(${params}) {\n\t${}\n}", {
|
|
14
|
+
label: "function",
|
|
15
|
+
detail: "definition",
|
|
16
|
+
type: "keyword"
|
|
17
|
+
}),
|
|
18
|
+
/*@__PURE__*/snippetCompletion("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n\t${}\n}", {
|
|
19
|
+
label: "for",
|
|
20
|
+
detail: "loop",
|
|
21
|
+
type: "keyword"
|
|
22
|
+
}),
|
|
23
|
+
/*@__PURE__*/snippetCompletion("for (let ${name} of ${collection}) {\n\t${}\n}", {
|
|
24
|
+
label: "for",
|
|
25
|
+
detail: "of loop",
|
|
26
|
+
type: "keyword"
|
|
27
|
+
}),
|
|
28
|
+
/*@__PURE__*/snippetCompletion("do {\n\t${}\n} while (${})", {
|
|
29
|
+
label: "do",
|
|
30
|
+
detail: "loop",
|
|
31
|
+
type: "keyword"
|
|
32
|
+
}),
|
|
33
|
+
/*@__PURE__*/snippetCompletion("while (${}) {\n\t${}\n}", {
|
|
34
|
+
label: "while",
|
|
35
|
+
detail: "loop",
|
|
36
|
+
type: "keyword"
|
|
37
|
+
}),
|
|
38
|
+
/*@__PURE__*/snippetCompletion("try {\n\t${}\n} catch (${error}) {\n\t${}\n}", {
|
|
39
|
+
label: "try",
|
|
40
|
+
detail: "/ catch block",
|
|
41
|
+
type: "keyword"
|
|
42
|
+
}),
|
|
43
|
+
/*@__PURE__*/snippetCompletion("if (${}) {\n\t${}\n}", {
|
|
44
|
+
label: "if",
|
|
45
|
+
detail: "block",
|
|
46
|
+
type: "keyword"
|
|
47
|
+
}),
|
|
48
|
+
/*@__PURE__*/snippetCompletion("if (${}) {\n\t${}\n} else {\n\t${}\n}", {
|
|
49
|
+
label: "if",
|
|
50
|
+
detail: "/ else block",
|
|
51
|
+
type: "keyword"
|
|
52
|
+
}),
|
|
53
|
+
/*@__PURE__*/snippetCompletion("class ${name} {\n\tconstructor(${params}) {\n\t\t${}\n\t}\n}", {
|
|
54
|
+
label: "class",
|
|
55
|
+
detail: "definition",
|
|
56
|
+
type: "keyword"
|
|
57
|
+
}),
|
|
58
|
+
/*@__PURE__*/snippetCompletion("import {${names}} from \"${module}\"\n${}", {
|
|
59
|
+
label: "import",
|
|
60
|
+
detail: "named",
|
|
61
|
+
type: "keyword"
|
|
62
|
+
}),
|
|
63
|
+
/*@__PURE__*/snippetCompletion("import ${name} from \"${module}\"\n${}", {
|
|
64
|
+
label: "import",
|
|
65
|
+
detail: "default",
|
|
66
|
+
type: "keyword"
|
|
67
|
+
})
|
|
68
|
+
];
|
|
69
|
+
/**
|
|
70
|
+
A collection of snippet completions for TypeScript. Includes the
|
|
71
|
+
JavaScript [snippets](https://codemirror.net/6/docs/ref/#lang-javascript.snippets).
|
|
72
|
+
*/
|
|
73
|
+
const typescriptSnippets = /*@__PURE__*/snippets.concat([
|
|
74
|
+
/*@__PURE__*/snippetCompletion("interface ${name} {\n\t${}\n}", {
|
|
75
|
+
label: "interface",
|
|
76
|
+
detail: "definition",
|
|
77
|
+
type: "keyword"
|
|
78
|
+
}),
|
|
79
|
+
/*@__PURE__*/snippetCompletion("type ${name} = ${type}", {
|
|
80
|
+
label: "type",
|
|
81
|
+
detail: "definition",
|
|
82
|
+
type: "keyword"
|
|
83
|
+
}),
|
|
84
|
+
/*@__PURE__*/snippetCompletion("enum ${name} {\n\t${}\n}", {
|
|
85
|
+
label: "enum",
|
|
86
|
+
detail: "definition",
|
|
87
|
+
type: "keyword"
|
|
88
|
+
})
|
|
89
|
+
]);
|
|
90
|
+
|
|
91
|
+
const cache = /*@__PURE__*/new NodeWeakMap();
|
|
92
|
+
const ScopeNodes = /*@__PURE__*/new Set([
|
|
93
|
+
"Script", "Block",
|
|
94
|
+
"FunctionExpression", "FunctionDeclaration", "ArrowFunction", "MethodDeclaration",
|
|
95
|
+
"ForStatement"
|
|
96
|
+
]);
|
|
97
|
+
function defID(type) {
|
|
98
|
+
return (node, def) => {
|
|
99
|
+
let id = node.node.getChild("VariableDefinition");
|
|
100
|
+
if (id)
|
|
101
|
+
def(id, type);
|
|
102
|
+
return true;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
const functionContext = ["FunctionDeclaration"];
|
|
106
|
+
const gatherCompletions = {
|
|
107
|
+
FunctionDeclaration: /*@__PURE__*/defID("function"),
|
|
108
|
+
ClassDeclaration: /*@__PURE__*/defID("class"),
|
|
109
|
+
ClassExpression: () => true,
|
|
110
|
+
EnumDeclaration: /*@__PURE__*/defID("constant"),
|
|
111
|
+
TypeAliasDeclaration: /*@__PURE__*/defID("type"),
|
|
112
|
+
NamespaceDeclaration: /*@__PURE__*/defID("namespace"),
|
|
113
|
+
VariableDefinition(node, def) { if (!node.matchContext(functionContext))
|
|
114
|
+
def(node, "variable"); },
|
|
115
|
+
TypeDefinition(node, def) { def(node, "type"); },
|
|
116
|
+
__proto__: null
|
|
117
|
+
};
|
|
118
|
+
function getScope(doc, node) {
|
|
119
|
+
let cached = cache.get(node);
|
|
120
|
+
if (cached)
|
|
121
|
+
return cached;
|
|
122
|
+
let completions = [], top = true;
|
|
123
|
+
function def(node, type) {
|
|
124
|
+
let name = doc.sliceString(node.from, node.to);
|
|
125
|
+
completions.push({ label: name, type });
|
|
126
|
+
}
|
|
127
|
+
node.cursor(IterMode.IncludeAnonymous).iterate(node => {
|
|
128
|
+
if (top) {
|
|
129
|
+
top = false;
|
|
130
|
+
}
|
|
131
|
+
else if (node.name) {
|
|
132
|
+
let gather = gatherCompletions[node.name];
|
|
133
|
+
if (gather && gather(node, def) || ScopeNodes.has(node.name))
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
else if (node.to - node.from > 8192) {
|
|
137
|
+
// Allow caching for bigger internal nodes
|
|
138
|
+
for (let c of getScope(doc, node.node))
|
|
139
|
+
completions.push(c);
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
cache.set(node, completions);
|
|
144
|
+
return completions;
|
|
145
|
+
}
|
|
146
|
+
const Identifier = /^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/;
|
|
147
|
+
const dontComplete = [
|
|
148
|
+
"TemplateString", "String", "RegExp",
|
|
149
|
+
"LineComment", "BlockComment",
|
|
150
|
+
"VariableDefinition", "TypeDefinition", "Label",
|
|
151
|
+
"PropertyDefinition", "PropertyName",
|
|
152
|
+
"PrivatePropertyDefinition", "PrivatePropertyName",
|
|
153
|
+
"JSXText", "JSXAttributeValue", "JSXOpenTag", "JSXCloseTag", "JSXSelfClosingTag",
|
|
154
|
+
".", "?."
|
|
155
|
+
];
|
|
156
|
+
/**
|
|
157
|
+
Completion source that looks up locally defined names in
|
|
158
|
+
JavaScript code.
|
|
159
|
+
*/
|
|
160
|
+
function localCompletionSource(context) {
|
|
161
|
+
let inner = syntaxTree(context.state).resolveInner(context.pos, -1);
|
|
162
|
+
if (dontComplete.indexOf(inner.name) > -1)
|
|
163
|
+
return null;
|
|
164
|
+
let isWord = inner.name == "VariableName" ||
|
|
165
|
+
inner.to - inner.from < 20 && Identifier.test(context.state.sliceDoc(inner.from, inner.to));
|
|
166
|
+
if (!isWord && !context.explicit)
|
|
167
|
+
return null;
|
|
168
|
+
let options = [];
|
|
169
|
+
for (let pos = inner; pos; pos = pos.parent) {
|
|
170
|
+
if (ScopeNodes.has(pos.name))
|
|
171
|
+
options = options.concat(getScope(context.state.doc, pos));
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
options,
|
|
175
|
+
from: isWord ? inner.from : context.pos,
|
|
176
|
+
validFor: Identifier
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
A language provider based on the [Lezer JavaScript
|
|
182
|
+
parser](https://github.com/lezer-parser/javascript), extended with
|
|
183
|
+
highlighting and indentation information.
|
|
184
|
+
*/
|
|
185
|
+
const javascriptLanguage = /*@__PURE__*/LRLanguage.define({
|
|
186
|
+
name: "javascript",
|
|
187
|
+
parser: /*@__PURE__*/parser.configure({
|
|
188
|
+
props: [
|
|
189
|
+
/*@__PURE__*/indentNodeProp.add({
|
|
190
|
+
IfStatement: /*@__PURE__*/continuedIndent({ except: /^\s*({|else\b)/ }),
|
|
191
|
+
TryStatement: /*@__PURE__*/continuedIndent({ except: /^\s*({|catch\b|finally\b)/ }),
|
|
192
|
+
LabeledStatement: flatIndent,
|
|
193
|
+
SwitchBody: context => {
|
|
194
|
+
let after = context.textAfter, closed = /^\s*\}/.test(after), isCase = /^\s*(case|default)\b/.test(after);
|
|
195
|
+
return context.baseIndent + (closed ? 0 : isCase ? 1 : 2) * context.unit;
|
|
196
|
+
},
|
|
197
|
+
Block: /*@__PURE__*/delimitedIndent({ closing: "}" }),
|
|
198
|
+
ArrowFunction: cx => cx.baseIndent + cx.unit,
|
|
199
|
+
"TemplateString BlockComment": () => null,
|
|
200
|
+
"Statement Property": /*@__PURE__*/continuedIndent({ except: /^\s*{/ }),
|
|
201
|
+
JSXElement(context) {
|
|
202
|
+
let closed = /^\s*<\//.test(context.textAfter);
|
|
203
|
+
return context.lineIndent(context.node.from) + (closed ? 0 : context.unit);
|
|
204
|
+
},
|
|
205
|
+
JSXEscape(context) {
|
|
206
|
+
let closed = /\s*\}/.test(context.textAfter);
|
|
207
|
+
return context.lineIndent(context.node.from) + (closed ? 0 : context.unit);
|
|
208
|
+
},
|
|
209
|
+
"JSXOpenTag JSXSelfClosingTag"(context) {
|
|
210
|
+
return context.column(context.node.from) + context.unit;
|
|
211
|
+
}
|
|
212
|
+
}),
|
|
213
|
+
/*@__PURE__*/foldNodeProp.add({
|
|
214
|
+
"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType": foldInside,
|
|
215
|
+
BlockComment(tree) { return { from: tree.from + 2, to: tree.to - 2 }; },
|
|
216
|
+
JSXElement(tree) {
|
|
217
|
+
let open = tree.firstChild;
|
|
218
|
+
if (!open || open.name == "JSXSelfClosingTag")
|
|
219
|
+
return null;
|
|
220
|
+
let close = tree.lastChild;
|
|
221
|
+
return { from: open.to, to: close.type.isError ? tree.to : close.from };
|
|
222
|
+
},
|
|
223
|
+
"JSXSelfClosingTag JSXOpenTag"(tree) {
|
|
224
|
+
var _a;
|
|
225
|
+
let name = (_a = tree.firstChild) === null || _a === void 0 ? void 0 : _a.nextSibling, close = tree.lastChild;
|
|
226
|
+
if (!name || name.type.isError)
|
|
227
|
+
return null;
|
|
228
|
+
return { from: name.to, to: close.type.isError ? tree.to : close.from };
|
|
229
|
+
}
|
|
230
|
+
})
|
|
231
|
+
]
|
|
232
|
+
}),
|
|
233
|
+
languageData: {
|
|
234
|
+
closeBrackets: { brackets: ["(", "[", "{", "'", '"', "`"] },
|
|
235
|
+
commentTokens: { line: "//", block: { open: "/*", close: "*/" } },
|
|
236
|
+
indentOnInput: /^\s*(?:case |default:|\{|\}|<\/)$/,
|
|
237
|
+
wordChars: "$"
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
const jsxSublanguage = {
|
|
241
|
+
test: node => /^JSX/.test(node.name),
|
|
242
|
+
facet: /*@__PURE__*/defineLanguageFacet({ commentTokens: { block: { open: "{/*", close: "*/}" } } })
|
|
243
|
+
};
|
|
244
|
+
/**
|
|
245
|
+
A language provider for TypeScript.
|
|
246
|
+
*/
|
|
247
|
+
const typescriptLanguage = /*@__PURE__*/javascriptLanguage.configure({ dialect: "ts" }, "typescript");
|
|
248
|
+
/**
|
|
249
|
+
Language provider for JSX.
|
|
250
|
+
*/
|
|
251
|
+
const jsxLanguage = /*@__PURE__*/javascriptLanguage.configure({
|
|
252
|
+
dialect: "jsx",
|
|
253
|
+
props: [/*@__PURE__*/sublanguageProp.add(n => n.isTop ? [jsxSublanguage] : undefined)]
|
|
254
|
+
});
|
|
255
|
+
/**
|
|
256
|
+
Language provider for JSX + TypeScript.
|
|
257
|
+
*/
|
|
258
|
+
const tsxLanguage = /*@__PURE__*/javascriptLanguage.configure({
|
|
259
|
+
dialect: "jsx ts",
|
|
260
|
+
props: [/*@__PURE__*/sublanguageProp.add(n => n.isTop ? [jsxSublanguage] : undefined)]
|
|
261
|
+
}, "typescript");
|
|
262
|
+
let kwCompletion = (name) => ({ label: name, type: "keyword" });
|
|
263
|
+
const keywords = /*@__PURE__*/"break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(kwCompletion);
|
|
264
|
+
const typescriptKeywords = /*@__PURE__*/keywords.concat(/*@__PURE__*/["declare", "implements", "private", "protected", "public"].map(kwCompletion));
|
|
265
|
+
/**
|
|
266
|
+
JavaScript support. Includes [snippet](https://codemirror.net/6/docs/ref/#lang-javascript.snippets)
|
|
267
|
+
and local variable completion.
|
|
268
|
+
*/
|
|
269
|
+
function javascript(config = {}) {
|
|
270
|
+
let lang = config.jsx ? (config.typescript ? tsxLanguage : jsxLanguage)
|
|
271
|
+
: config.typescript ? typescriptLanguage : javascriptLanguage;
|
|
272
|
+
let completions = config.typescript ? typescriptSnippets.concat(typescriptKeywords) : snippets.concat(keywords);
|
|
273
|
+
return new LanguageSupport(lang, [
|
|
274
|
+
javascriptLanguage.data.of({
|
|
275
|
+
autocomplete: ifNotIn(dontComplete, completeFromList(completions))
|
|
276
|
+
}),
|
|
277
|
+
javascriptLanguage.data.of({
|
|
278
|
+
autocomplete: localCompletionSource
|
|
279
|
+
}),
|
|
280
|
+
config.jsx ? autoCloseTags : [],
|
|
281
|
+
]);
|
|
282
|
+
}
|
|
283
|
+
function findOpenTag(node) {
|
|
284
|
+
for (;;) {
|
|
285
|
+
if (node.name == "JSXOpenTag" || node.name == "JSXSelfClosingTag" || node.name == "JSXFragmentTag")
|
|
286
|
+
return node;
|
|
287
|
+
if (node.name == "JSXEscape" || !node.parent)
|
|
288
|
+
return null;
|
|
289
|
+
node = node.parent;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
function elementName(doc, tree, max = doc.length) {
|
|
293
|
+
for (let ch = tree === null || tree === void 0 ? void 0 : tree.firstChild; ch; ch = ch.nextSibling) {
|
|
294
|
+
if (ch.name == "JSXIdentifier" || ch.name == "JSXBuiltin" || ch.name == "JSXNamespacedName" ||
|
|
295
|
+
ch.name == "JSXMemberExpression")
|
|
296
|
+
return doc.sliceString(ch.from, Math.min(ch.to, max));
|
|
297
|
+
}
|
|
298
|
+
return "";
|
|
299
|
+
}
|
|
300
|
+
const android = typeof navigator == "object" && /*@__PURE__*//Android\b/.test(navigator.userAgent);
|
|
301
|
+
/**
|
|
302
|
+
Extension that will automatically insert JSX close tags when a `>` or
|
|
303
|
+
`/` is typed.
|
|
304
|
+
*/
|
|
305
|
+
const autoCloseTags = /*@__PURE__*/EditorView.inputHandler.of((view, from, to, text, defaultInsert) => {
|
|
306
|
+
if ((android ? view.composing : view.compositionStarted) || view.state.readOnly ||
|
|
307
|
+
from != to || (text != ">" && text != "/") ||
|
|
308
|
+
!javascriptLanguage.isActiveAt(view.state, from, -1))
|
|
309
|
+
return false;
|
|
310
|
+
let base = defaultInsert(), { state } = base;
|
|
311
|
+
let closeTags = state.changeByRange(range => {
|
|
312
|
+
var _a;
|
|
313
|
+
let { head } = range, around = syntaxTree(state).resolveInner(head - 1, -1), name;
|
|
314
|
+
if (around.name == "JSXStartTag")
|
|
315
|
+
around = around.parent;
|
|
316
|
+
if (state.doc.sliceString(head - 1, head) != text || around.name == "JSXAttributeValue" && around.to > head) ;
|
|
317
|
+
else if (text == ">" && around.name == "JSXFragmentTag") {
|
|
318
|
+
return { range, changes: { from: head, insert: `</>` } };
|
|
319
|
+
}
|
|
320
|
+
else if (text == "/" && around.name == "JSXStartCloseTag") {
|
|
321
|
+
let empty = around.parent, base = empty.parent;
|
|
322
|
+
if (base && empty.from == head - 2 &&
|
|
323
|
+
((name = elementName(state.doc, base.firstChild, head)) || ((_a = base.firstChild) === null || _a === void 0 ? void 0 : _a.name) == "JSXFragmentTag")) {
|
|
324
|
+
let insert = `${name}>`;
|
|
325
|
+
return { range: EditorSelection.cursor(head + insert.length, -1), changes: { from: head, insert } };
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
else if (text == ">") {
|
|
329
|
+
let openTag = findOpenTag(around);
|
|
330
|
+
if (openTag && openTag.name == "JSXOpenTag" &&
|
|
331
|
+
!/^\/?>|^<\//.test(state.doc.sliceString(head, head + 2)) &&
|
|
332
|
+
(name = elementName(state.doc, openTag, head)))
|
|
333
|
+
return { range, changes: { from: head, insert: `</${name}>` } };
|
|
334
|
+
}
|
|
335
|
+
return { range };
|
|
336
|
+
});
|
|
337
|
+
if (closeTags.changes.empty)
|
|
338
|
+
return false;
|
|
339
|
+
view.dispatch([
|
|
340
|
+
base,
|
|
341
|
+
state.update(closeTags, { userEvent: "input.complete", scrollIntoView: true })
|
|
342
|
+
]);
|
|
343
|
+
return true;
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
export { autoCloseTags, javascript, javascriptLanguage, jsxLanguage, localCompletionSource, snippets, tsxLanguage, typescriptLanguage, typescriptSnippets };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { parser } from '../../../../../@lezer_json@1.0.3/node_modules/@lezer/json/dist/index.js';
|
|
2
|
+
import { LanguageSupport, LRLanguage, indentNodeProp, continuedIndent, foldNodeProp, foldInside } from '../../../../../@codemirror_language@6.12.3/node_modules/@codemirror/language/dist/index.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
A language provider that provides JSON parsing.
|
|
6
|
+
*/
|
|
7
|
+
const jsonLanguage = /*@__PURE__*/LRLanguage.define({
|
|
8
|
+
name: "json",
|
|
9
|
+
parser: /*@__PURE__*/parser.configure({
|
|
10
|
+
props: [
|
|
11
|
+
/*@__PURE__*/indentNodeProp.add({
|
|
12
|
+
Object: /*@__PURE__*/continuedIndent({ except: /^\s*\}/ }),
|
|
13
|
+
Array: /*@__PURE__*/continuedIndent({ except: /^\s*\]/ })
|
|
14
|
+
}),
|
|
15
|
+
/*@__PURE__*/foldNodeProp.add({
|
|
16
|
+
"Object Array": foldInside
|
|
17
|
+
})
|
|
18
|
+
]
|
|
19
|
+
}),
|
|
20
|
+
languageData: {
|
|
21
|
+
closeBrackets: { brackets: ["[", "{", '"'] },
|
|
22
|
+
indentOnInput: /^\s*[\}\]]$/
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
JSON language support.
|
|
27
|
+
*/
|
|
28
|
+
function json() {
|
|
29
|
+
return new LanguageSupport(jsonLanguage);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { json, jsonLanguage };
|