@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,308 @@
|
|
|
1
|
+
import { parser } from '../../../../../@lezer_python@1.1.18/node_modules/@lezer/python/dist/index.js';
|
|
2
|
+
import { LanguageSupport, LRLanguage, indentNodeProp, delimitedIndent, foldNodeProp, foldInside, syntaxTree } from '../../../../../@codemirror_language@6.12.3/node_modules/@codemirror/language/dist/index.js';
|
|
3
|
+
import { NodeWeakMap, IterMode } from '../../../../../@lezer_common@1.5.1/node_modules/@lezer/common/dist/index.js';
|
|
4
|
+
import { ifNotIn, completeFromList, snippetCompletion } from '../../../../../@codemirror_autocomplete@6.20.1/node_modules/@codemirror/autocomplete/dist/index.js';
|
|
5
|
+
|
|
6
|
+
const cache = /*@__PURE__*/new NodeWeakMap();
|
|
7
|
+
const ScopeNodes = /*@__PURE__*/new Set([
|
|
8
|
+
"Script", "Body",
|
|
9
|
+
"FunctionDefinition", "ClassDefinition", "LambdaExpression",
|
|
10
|
+
"ForStatement", "MatchClause"
|
|
11
|
+
]);
|
|
12
|
+
function defID(type) {
|
|
13
|
+
return (node, def, outer) => {
|
|
14
|
+
if (outer)
|
|
15
|
+
return false;
|
|
16
|
+
let id = node.node.getChild("VariableName");
|
|
17
|
+
if (id)
|
|
18
|
+
def(id, type);
|
|
19
|
+
return true;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const gatherCompletions = {
|
|
23
|
+
FunctionDefinition: /*@__PURE__*/defID("function"),
|
|
24
|
+
ClassDefinition: /*@__PURE__*/defID("class"),
|
|
25
|
+
ForStatement(node, def, outer) {
|
|
26
|
+
if (outer)
|
|
27
|
+
for (let child = node.node.firstChild; child; child = child.nextSibling) {
|
|
28
|
+
if (child.name == "VariableName")
|
|
29
|
+
def(child, "variable");
|
|
30
|
+
else if (child.name == "in")
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
ImportStatement(_node, def) {
|
|
35
|
+
var _a, _b;
|
|
36
|
+
let { node } = _node;
|
|
37
|
+
let isFrom = ((_a = node.firstChild) === null || _a === void 0 ? void 0 : _a.name) == "from";
|
|
38
|
+
for (let ch = node.getChild("import"); ch; ch = ch.nextSibling) {
|
|
39
|
+
if (ch.name == "VariableName" && ((_b = ch.nextSibling) === null || _b === void 0 ? void 0 : _b.name) != "as")
|
|
40
|
+
def(ch, isFrom ? "variable" : "namespace");
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
AssignStatement(node, def) {
|
|
44
|
+
for (let child = node.node.firstChild; child; child = child.nextSibling) {
|
|
45
|
+
if (child.name == "VariableName")
|
|
46
|
+
def(child, "variable");
|
|
47
|
+
else if (child.name == ":" || child.name == "AssignOp")
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
ParamList(node, def) {
|
|
52
|
+
for (let prev = null, child = node.node.firstChild; child; child = child.nextSibling) {
|
|
53
|
+
if (child.name == "VariableName" && (!prev || !/\*|AssignOp/.test(prev.name)))
|
|
54
|
+
def(child, "variable");
|
|
55
|
+
prev = child;
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
CapturePattern: /*@__PURE__*/defID("variable"),
|
|
59
|
+
AsPattern: /*@__PURE__*/defID("variable"),
|
|
60
|
+
__proto__: null
|
|
61
|
+
};
|
|
62
|
+
function getScope(doc, node) {
|
|
63
|
+
let cached = cache.get(node);
|
|
64
|
+
if (cached)
|
|
65
|
+
return cached;
|
|
66
|
+
let completions = [], top = true;
|
|
67
|
+
function def(node, type) {
|
|
68
|
+
let name = doc.sliceString(node.from, node.to);
|
|
69
|
+
completions.push({ label: name, type });
|
|
70
|
+
}
|
|
71
|
+
node.cursor(IterMode.IncludeAnonymous).iterate(node => {
|
|
72
|
+
if (node.name) {
|
|
73
|
+
let gather = gatherCompletions[node.name];
|
|
74
|
+
if (gather && gather(node, def, top) || !top && ScopeNodes.has(node.name))
|
|
75
|
+
return false;
|
|
76
|
+
top = false;
|
|
77
|
+
}
|
|
78
|
+
else if (node.to - node.from > 8192) {
|
|
79
|
+
// Allow caching for bigger internal nodes
|
|
80
|
+
for (let c of getScope(doc, node.node))
|
|
81
|
+
completions.push(c);
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
cache.set(node, completions);
|
|
86
|
+
return completions;
|
|
87
|
+
}
|
|
88
|
+
const Identifier = /^[\w\xa1-\uffff][\w\d\xa1-\uffff]*$/;
|
|
89
|
+
const dontComplete = ["String", "FormatString", "Comment", "PropertyName"];
|
|
90
|
+
/**
|
|
91
|
+
Completion source that looks up locally defined names in
|
|
92
|
+
Python code.
|
|
93
|
+
*/
|
|
94
|
+
function localCompletionSource(context) {
|
|
95
|
+
let inner = syntaxTree(context.state).resolveInner(context.pos, -1);
|
|
96
|
+
if (dontComplete.indexOf(inner.name) > -1)
|
|
97
|
+
return null;
|
|
98
|
+
let isWord = inner.name == "VariableName" ||
|
|
99
|
+
inner.to - inner.from < 20 && Identifier.test(context.state.sliceDoc(inner.from, inner.to));
|
|
100
|
+
if (!isWord && !context.explicit)
|
|
101
|
+
return null;
|
|
102
|
+
let options = [];
|
|
103
|
+
for (let pos = inner; pos; pos = pos.parent) {
|
|
104
|
+
if (ScopeNodes.has(pos.name))
|
|
105
|
+
options = options.concat(getScope(context.state.doc, pos));
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
options,
|
|
109
|
+
from: isWord ? inner.from : context.pos,
|
|
110
|
+
validFor: Identifier
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
const globals = /*@__PURE__*/[
|
|
114
|
+
"__annotations__", "__builtins__", "__debug__", "__doc__", "__import__", "__name__",
|
|
115
|
+
"__loader__", "__package__", "__spec__",
|
|
116
|
+
"False", "None", "True"
|
|
117
|
+
].map(n => ({ label: n, type: "constant" })).concat(/*@__PURE__*/[
|
|
118
|
+
"ArithmeticError", "AssertionError", "AttributeError", "BaseException", "BlockingIOError",
|
|
119
|
+
"BrokenPipeError", "BufferError", "BytesWarning", "ChildProcessError", "ConnectionAbortedError",
|
|
120
|
+
"ConnectionError", "ConnectionRefusedError", "ConnectionResetError", "DeprecationWarning",
|
|
121
|
+
"EOFError", "Ellipsis", "EncodingWarning", "EnvironmentError", "Exception", "FileExistsError",
|
|
122
|
+
"FileNotFoundError", "FloatingPointError", "FutureWarning", "GeneratorExit", "IOError",
|
|
123
|
+
"ImportError", "ImportWarning", "IndentationError", "IndexError", "InterruptedError",
|
|
124
|
+
"IsADirectoryError", "KeyError", "KeyboardInterrupt", "LookupError", "MemoryError",
|
|
125
|
+
"ModuleNotFoundError", "NameError", "NotADirectoryError", "NotImplemented", "NotImplementedError",
|
|
126
|
+
"OSError", "OverflowError", "PendingDeprecationWarning", "PermissionError", "ProcessLookupError",
|
|
127
|
+
"RecursionError", "ReferenceError", "ResourceWarning", "RuntimeError", "RuntimeWarning",
|
|
128
|
+
"StopAsyncIteration", "StopIteration", "SyntaxError", "SyntaxWarning", "SystemError",
|
|
129
|
+
"SystemExit", "TabError", "TimeoutError", "TypeError", "UnboundLocalError", "UnicodeDecodeError",
|
|
130
|
+
"UnicodeEncodeError", "UnicodeError", "UnicodeTranslateError", "UnicodeWarning", "UserWarning",
|
|
131
|
+
"ValueError", "Warning", "ZeroDivisionError"
|
|
132
|
+
].map(n => ({ label: n, type: "type" }))).concat(/*@__PURE__*/[
|
|
133
|
+
"bool", "bytearray", "bytes", "classmethod", "complex", "float", "frozenset", "int", "list",
|
|
134
|
+
"map", "memoryview", "object", "range", "set", "staticmethod", "str", "super", "tuple", "type"
|
|
135
|
+
].map(n => ({ label: n, type: "class" }))).concat(/*@__PURE__*/[
|
|
136
|
+
"abs", "aiter", "all", "anext", "any", "ascii", "bin", "breakpoint", "callable", "chr",
|
|
137
|
+
"compile", "delattr", "dict", "dir", "divmod", "enumerate", "eval", "exec", "exit", "filter",
|
|
138
|
+
"format", "getattr", "globals", "hasattr", "hash", "help", "hex", "id", "input", "isinstance",
|
|
139
|
+
"issubclass", "iter", "len", "license", "locals", "max", "min", "next", "oct", "open",
|
|
140
|
+
"ord", "pow", "print", "property", "quit", "repr", "reversed", "round", "setattr", "slice",
|
|
141
|
+
"sorted", "sum", "vars", "zip"
|
|
142
|
+
].map(n => ({ label: n, type: "function" })));
|
|
143
|
+
const snippets = [
|
|
144
|
+
/*@__PURE__*/snippetCompletion("def ${name}(${params}):\n\t${}", {
|
|
145
|
+
label: "def",
|
|
146
|
+
detail: "function",
|
|
147
|
+
type: "keyword"
|
|
148
|
+
}),
|
|
149
|
+
/*@__PURE__*/snippetCompletion("for ${name} in ${collection}:\n\t${}", {
|
|
150
|
+
label: "for",
|
|
151
|
+
detail: "loop",
|
|
152
|
+
type: "keyword"
|
|
153
|
+
}),
|
|
154
|
+
/*@__PURE__*/snippetCompletion("while ${}:\n\t${}", {
|
|
155
|
+
label: "while",
|
|
156
|
+
detail: "loop",
|
|
157
|
+
type: "keyword"
|
|
158
|
+
}),
|
|
159
|
+
/*@__PURE__*/snippetCompletion("try:\n\t${}\nexcept ${error}:\n\t${}", {
|
|
160
|
+
label: "try",
|
|
161
|
+
detail: "/ except block",
|
|
162
|
+
type: "keyword"
|
|
163
|
+
}),
|
|
164
|
+
/*@__PURE__*/snippetCompletion("if ${}:\n\t\n", {
|
|
165
|
+
label: "if",
|
|
166
|
+
detail: "block",
|
|
167
|
+
type: "keyword"
|
|
168
|
+
}),
|
|
169
|
+
/*@__PURE__*/snippetCompletion("if ${}:\n\t${}\nelse:\n\t${}", {
|
|
170
|
+
label: "if",
|
|
171
|
+
detail: "/ else block",
|
|
172
|
+
type: "keyword"
|
|
173
|
+
}),
|
|
174
|
+
/*@__PURE__*/snippetCompletion("class ${name}:\n\tdef __init__(self, ${params}):\n\t\t\t${}", {
|
|
175
|
+
label: "class",
|
|
176
|
+
detail: "definition",
|
|
177
|
+
type: "keyword"
|
|
178
|
+
}),
|
|
179
|
+
/*@__PURE__*/snippetCompletion("import ${module}", {
|
|
180
|
+
label: "import",
|
|
181
|
+
detail: "statement",
|
|
182
|
+
type: "keyword"
|
|
183
|
+
}),
|
|
184
|
+
/*@__PURE__*/snippetCompletion("from ${module} import ${names}", {
|
|
185
|
+
label: "from",
|
|
186
|
+
detail: "import",
|
|
187
|
+
type: "keyword"
|
|
188
|
+
})
|
|
189
|
+
];
|
|
190
|
+
/**
|
|
191
|
+
Autocompletion for built-in Python globals and keywords.
|
|
192
|
+
*/
|
|
193
|
+
const globalCompletion = /*@__PURE__*/ifNotIn(dontComplete, /*@__PURE__*/completeFromList(/*@__PURE__*/globals.concat(snippets)));
|
|
194
|
+
|
|
195
|
+
function innerBody(context) {
|
|
196
|
+
let { node, pos } = context;
|
|
197
|
+
let lineIndent = context.lineIndent(pos, -1);
|
|
198
|
+
let found = null;
|
|
199
|
+
for (;;) {
|
|
200
|
+
let before = node.childBefore(pos);
|
|
201
|
+
if (!before) {
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
else if (before.name == "Comment") {
|
|
205
|
+
pos = before.from;
|
|
206
|
+
}
|
|
207
|
+
else if (before.name == "Body" || before.name == "MatchBody") {
|
|
208
|
+
if (context.baseIndentFor(before) + context.unit <= lineIndent)
|
|
209
|
+
found = before;
|
|
210
|
+
node = before;
|
|
211
|
+
}
|
|
212
|
+
else if (before.name == "MatchClause") {
|
|
213
|
+
node = before;
|
|
214
|
+
}
|
|
215
|
+
else if (before.type.is("Statement")) {
|
|
216
|
+
node = before;
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return found;
|
|
223
|
+
}
|
|
224
|
+
function indentBody(context, node) {
|
|
225
|
+
let base = context.baseIndentFor(node);
|
|
226
|
+
let line = context.lineAt(context.pos, -1), to = line.from + line.text.length;
|
|
227
|
+
// Don't consider blank, deindented lines at the end of the
|
|
228
|
+
// block part of the block
|
|
229
|
+
if (/^\s*($|#)/.test(line.text) &&
|
|
230
|
+
context.node.to < to + 100 &&
|
|
231
|
+
!/\S/.test(context.state.sliceDoc(to, context.node.to)) &&
|
|
232
|
+
context.lineIndent(context.pos, -1) <= base)
|
|
233
|
+
return null;
|
|
234
|
+
// A normally deindenting keyword that appears at a higher
|
|
235
|
+
// indentation than the block should probably be handled by the next
|
|
236
|
+
// level
|
|
237
|
+
if (/^\s*(else:|elif |except |finally:|case\s+[^=:]+:)/.test(context.textAfter) && context.lineIndent(context.pos, -1) > base)
|
|
238
|
+
return null;
|
|
239
|
+
return base + context.unit;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
A language provider based on the [Lezer Python
|
|
243
|
+
parser](https://github.com/lezer-parser/python), extended with
|
|
244
|
+
highlighting and indentation information.
|
|
245
|
+
*/
|
|
246
|
+
const pythonLanguage = /*@__PURE__*/LRLanguage.define({
|
|
247
|
+
name: "python",
|
|
248
|
+
parser: /*@__PURE__*/parser.configure({
|
|
249
|
+
props: [
|
|
250
|
+
/*@__PURE__*/indentNodeProp.add({
|
|
251
|
+
Body: context => {
|
|
252
|
+
var _a;
|
|
253
|
+
let body = /^\s*(#|$)/.test(context.textAfter) && innerBody(context) || context.node;
|
|
254
|
+
return (_a = indentBody(context, body)) !== null && _a !== void 0 ? _a : context.continue();
|
|
255
|
+
},
|
|
256
|
+
MatchBody: context => {
|
|
257
|
+
var _a;
|
|
258
|
+
let inner = innerBody(context);
|
|
259
|
+
return (_a = indentBody(context, inner || context.node)) !== null && _a !== void 0 ? _a : context.continue();
|
|
260
|
+
},
|
|
261
|
+
IfStatement: cx => /^\s*(else:|elif )/.test(cx.textAfter) ? cx.baseIndent : cx.continue(),
|
|
262
|
+
"ForStatement WhileStatement": cx => /^\s*else:/.test(cx.textAfter) ? cx.baseIndent : cx.continue(),
|
|
263
|
+
TryStatement: cx => /^\s*(except[ :]|finally:|else:)/.test(cx.textAfter) ? cx.baseIndent : cx.continue(),
|
|
264
|
+
MatchStatement: cx => {
|
|
265
|
+
if (/^\s*case /.test(cx.textAfter))
|
|
266
|
+
return cx.baseIndent + cx.unit;
|
|
267
|
+
return cx.continue();
|
|
268
|
+
},
|
|
269
|
+
"TupleExpression ComprehensionExpression ParamList ArgList ParenthesizedExpression": /*@__PURE__*/delimitedIndent({ closing: ")" }),
|
|
270
|
+
"DictionaryExpression DictionaryComprehensionExpression SetExpression SetComprehensionExpression": /*@__PURE__*/delimitedIndent({ closing: "}" }),
|
|
271
|
+
"ArrayExpression ArrayComprehensionExpression": /*@__PURE__*/delimitedIndent({ closing: "]" }),
|
|
272
|
+
MemberExpression: cx => cx.baseIndent + cx.unit,
|
|
273
|
+
"String FormatString": () => null,
|
|
274
|
+
Script: context => {
|
|
275
|
+
var _a;
|
|
276
|
+
let inner = innerBody(context);
|
|
277
|
+
return (_a = (inner && indentBody(context, inner))) !== null && _a !== void 0 ? _a : context.continue();
|
|
278
|
+
},
|
|
279
|
+
}),
|
|
280
|
+
/*@__PURE__*/foldNodeProp.add({
|
|
281
|
+
"ArrayExpression DictionaryExpression SetExpression TupleExpression": foldInside,
|
|
282
|
+
Body: (node, state) => ({ from: node.from + 1, to: node.to - (node.to == state.doc.length ? 0 : 1) }),
|
|
283
|
+
"String FormatString": (node, state) => ({ from: state.doc.lineAt(node.from).to, to: node.to })
|
|
284
|
+
})
|
|
285
|
+
],
|
|
286
|
+
}),
|
|
287
|
+
languageData: {
|
|
288
|
+
closeBrackets: {
|
|
289
|
+
brackets: ["(", "[", "{", "'", '"', "'''", '"""'],
|
|
290
|
+
stringPrefixes: ["f", "fr", "rf", "r", "u", "b", "br", "rb",
|
|
291
|
+
"F", "FR", "RF", "R", "U", "B", "BR", "RB"]
|
|
292
|
+
},
|
|
293
|
+
commentTokens: { line: "#" },
|
|
294
|
+
// Indent logic logic are triggered upon below input patterns
|
|
295
|
+
indentOnInput: /^\s*([\}\]\)]|else:|elif |except |finally:|case\s+[^:]*:?)$/,
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
/**
|
|
299
|
+
Python language support.
|
|
300
|
+
*/
|
|
301
|
+
function python() {
|
|
302
|
+
return new LanguageSupport(pythonLanguage, [
|
|
303
|
+
pythonLanguage.data.of({ autocomplete: localCompletionSource }),
|
|
304
|
+
pythonLanguage.data.of({ autocomplete: globalCompletion }),
|
|
305
|
+
]);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export { globalCompletion, localCompletionSource, python, pythonLanguage };
|