@maketribe/ms-app 3.1.1 → 3.1.3
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/cjs/assets/iconfonts/iconfont.js +38 -0
- package/dist/cjs/assets/iconfonts/iconfont.js.map +1 -0
- package/dist/cjs/components/basic/icon-select/icon-select.js +1 -1
- package/dist/cjs/components/basic/icon-select/icon-select.js.map +1 -1
- package/dist/cjs/components/basic/svg-icon/svg-icon.js.map +1 -1
- package/dist/cjs/components/business/verify-dialog/verify-dialog.js.map +1 -1
- package/dist/cjs/components/data-model/data-table/components/column-action/column-action-options.d.ts +3 -2
- package/dist/cjs/components/data-model/data-table/components/column-action/column-action-options.js +2 -1
- package/dist/cjs/components/data-model/data-table/components/column-action/column-action-options.js.map +1 -1
- package/dist/cjs/components/data-model/data-table/components/column-action/column-action.d.ts +7 -3
- package/dist/cjs/components/data-model/data-table/components/column-action/column-action.js +5 -1
- package/dist/cjs/components/data-model/data-table/components/column-action/column-action.js.map +1 -1
- package/dist/cjs/components/data-model/data-table/components/column-action/index.d.ts +7 -3
- package/dist/cjs/core/MSAppClient.js +2 -2
- package/dist/cjs/core/MSAppClient.js.map +1 -1
- package/dist/cjs/index.d.ts +2 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/modules/cms/dataviews/cms-articles/CmsArticlesForm.js +3 -3
- package/dist/cjs/modules/cms/dataviews/cms-articles/CmsArticlesForm.js.map +1 -1
- package/dist/cjs/modules/cms/dataviews/cms-parts/CmsPartForm.js +32 -6
- package/dist/cjs/modules/cms/dataviews/cms-parts/CmsPartForm.js.map +1 -1
- package/dist/cjs/modules/cms/dataviews/cms-parts/CmsPartTree.js.map +1 -1
- package/dist/cjs/modules/cms/index.js +5 -0
- package/dist/cjs/modules/cms/index.js.map +1 -1
- package/dist/cjs/modules/cms/pages/cms-resource/components/resource-item/index.vue.d.ts +12 -0
- package/dist/cjs/modules/cms/pages/cms-resource/components/resource-item/index.vue.js +9 -0
- package/dist/cjs/modules/cms/pages/cms-resource/components/resource-item/index.vue.js.map +1 -0
- package/dist/cjs/modules/cms/pages/cms-resource/components/resource-item/index.vue2.js +91 -0
- package/dist/cjs/modules/cms/pages/cms-resource/components/resource-item/index.vue2.js.map +1 -0
- package/dist/cjs/modules/cms/pages/cms-resource/core/ResourceManager.d.ts +23 -0
- package/dist/cjs/modules/cms/pages/cms-resource/core/ResourceManager.js +133 -0
- package/dist/cjs/modules/cms/pages/cms-resource/core/ResourceManager.js.map +1 -0
- package/dist/cjs/modules/cms/pages/cms-resource/index.vue.d.ts +2 -0
- package/dist/cjs/modules/cms/pages/cms-resource/index.vue.js +9 -0
- package/dist/cjs/modules/cms/pages/cms-resource/index.vue.js.map +1 -0
- package/dist/cjs/modules/cms/pages/cms-resource/index.vue2.js +217 -0
- package/dist/cjs/modules/cms/pages/cms-resource/index.vue2.js.map +1 -0
- package/dist/cjs/modules/ms/pages/local-log/index.vue2.js.map +1 -1
- package/dist/cjs/node_modules/.pnpm/@codemirror_autocomplete@6.15.0_@codemirror_language@6.10.1_@codemirror_state@6.4.1_@codemirr_djjyqdn7bhwopzrz2h2s2bwhzm/node_modules/@codemirror/autocomplete/dist/index.js +276 -0
- package/dist/cjs/node_modules/.pnpm/@codemirror_autocomplete@6.15.0_@codemirror_language@6.10.1_@codemirror_state@6.4.1_@codemirr_djjyqdn7bhwopzrz2h2s2bwhzm/node_modules/@codemirror/autocomplete/dist/index.js.map +1 -1
- package/dist/cjs/node_modules/.pnpm/@codemirror_lang-css@6.2.1_@codemirror_view@6.26.1/node_modules/@codemirror/lang-css/dist/index.js +263 -0
- package/dist/cjs/node_modules/.pnpm/@codemirror_lang-css@6.2.1_@codemirror_view@6.26.1/node_modules/@codemirror/lang-css/dist/index.js.map +1 -0
- package/dist/cjs/node_modules/.pnpm/@codemirror_lang-html@6.4.9/node_modules/@codemirror/lang-html/dist/index.js +667 -0
- package/dist/cjs/node_modules/.pnpm/@codemirror_lang-html@6.4.9/node_modules/@codemirror/lang-html/dist/index.js.map +1 -0
- package/dist/cjs/node_modules/.pnpm/@codemirror_lang-javascript@6.2.2/node_modules/@codemirror/lang-javascript/dist/index.js +342 -0
- package/dist/cjs/node_modules/.pnpm/@codemirror_lang-javascript@6.2.2/node_modules/@codemirror/lang-javascript/dist/index.js.map +1 -0
- package/dist/cjs/node_modules/.pnpm/@codemirror_language@6.10.1/node_modules/@codemirror/language/dist/index.js +21 -0
- package/dist/cjs/node_modules/.pnpm/@codemirror_language@6.10.1/node_modules/@codemirror/language/dist/index.js.map +1 -1
- package/dist/cjs/node_modules/.pnpm/@lezer_common@1.2.1/node_modules/@lezer/common/dist/index.js +510 -1
- package/dist/cjs/node_modules/.pnpm/@lezer_common@1.2.1/node_modules/@lezer/common/dist/index.js.map +1 -1
- package/dist/cjs/node_modules/.pnpm/@lezer_css@1.1.8/node_modules/@lezer/css/dist/index.js +127 -0
- package/dist/cjs/node_modules/.pnpm/@lezer_css@1.1.8/node_modules/@lezer/css/dist/index.js.map +1 -0
- package/dist/cjs/node_modules/.pnpm/@lezer_html@1.3.10/node_modules/@lezer/html/dist/index.js +360 -0
- package/dist/cjs/node_modules/.pnpm/@lezer_html@1.3.10/node_modules/@lezer/html/dist/index.js.map +1 -0
- package/dist/cjs/node_modules/.pnpm/@lezer_javascript@1.4.17/node_modules/@lezer/javascript/dist/index.js +189 -0
- package/dist/cjs/node_modules/.pnpm/@lezer_javascript@1.4.17/node_modules/@lezer/javascript/dist/index.js.map +1 -0
- package/dist/cjs/node_modules/.pnpm/@lezer_lr@1.4.0/node_modules/@lezer/lr/dist/index.js +1879 -0
- package/dist/cjs/node_modules/.pnpm/@lezer_lr@1.4.0/node_modules/@lezer/lr/dist/index.js.map +1 -0
- package/dist/cjs/page/signup/index.vue2.js +1 -1
- package/dist/cjs/page/signup/index.vue2.js.map +1 -1
- package/dist/cjs/router-middleware/auth.js +1 -1
- package/dist/cjs/router-middleware/auth.js.map +1 -1
- package/dist/esm/assets/iconfonts/iconfont.js +36 -0
- package/dist/esm/assets/iconfonts/iconfont.js.map +1 -0
- package/dist/esm/components/basic/icon-select/icon-select.js +1 -1
- package/dist/esm/components/basic/icon-select/icon-select.js.map +1 -1
- package/dist/esm/components/basic/svg-icon/svg-icon.js.map +1 -1
- package/dist/esm/components/business/verify-dialog/verify-dialog.js.map +1 -1
- package/dist/esm/components/data-model/data-table/components/column-action/column-action-options.d.ts +3 -2
- package/dist/esm/components/data-model/data-table/components/column-action/column-action-options.js +3 -2
- package/dist/esm/components/data-model/data-table/components/column-action/column-action-options.js.map +1 -1
- package/dist/esm/components/data-model/data-table/components/column-action/column-action.d.ts +7 -3
- package/dist/esm/components/data-model/data-table/components/column-action/column-action.js +5 -1
- package/dist/esm/components/data-model/data-table/components/column-action/column-action.js.map +1 -1
- package/dist/esm/components/data-model/data-table/components/column-action/index.d.ts +7 -3
- package/dist/esm/core/MSAppClient.js +2 -2
- package/dist/esm/core/MSAppClient.js.map +1 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/modules/cms/dataviews/cms-articles/CmsArticlesForm.js +3 -3
- package/dist/esm/modules/cms/dataviews/cms-articles/CmsArticlesForm.js.map +1 -1
- package/dist/esm/modules/cms/dataviews/cms-parts/CmsPartForm.js +32 -6
- package/dist/esm/modules/cms/dataviews/cms-parts/CmsPartForm.js.map +1 -1
- package/dist/esm/modules/cms/dataviews/cms-parts/CmsPartTree.js.map +1 -1
- package/dist/esm/modules/cms/index.js +5 -0
- package/dist/esm/modules/cms/index.js.map +1 -1
- package/dist/esm/modules/cms/pages/cms-resource/components/resource-item/index.vue.d.ts +12 -0
- package/dist/esm/modules/cms/pages/cms-resource/components/resource-item/index.vue.js +7 -0
- package/dist/esm/modules/cms/pages/cms-resource/components/resource-item/index.vue.js.map +1 -0
- package/dist/esm/modules/cms/pages/cms-resource/components/resource-item/index.vue2.js +89 -0
- package/dist/esm/modules/cms/pages/cms-resource/components/resource-item/index.vue2.js.map +1 -0
- package/dist/esm/modules/cms/pages/cms-resource/core/ResourceManager.d.ts +23 -0
- package/dist/esm/modules/cms/pages/cms-resource/core/ResourceManager.js +131 -0
- package/dist/esm/modules/cms/pages/cms-resource/core/ResourceManager.js.map +1 -0
- package/dist/esm/modules/cms/pages/cms-resource/index.vue.d.ts +2 -0
- package/dist/esm/modules/cms/pages/cms-resource/index.vue.js +7 -0
- package/dist/esm/modules/cms/pages/cms-resource/index.vue.js.map +1 -0
- package/dist/esm/modules/cms/pages/cms-resource/index.vue2.js +215 -0
- package/dist/esm/modules/cms/pages/cms-resource/index.vue2.js.map +1 -0
- package/dist/esm/modules/ms/pages/local-log/index.vue2.js.map +1 -1
- package/dist/esm/node_modules/.pnpm/@codemirror_autocomplete@6.15.0_@codemirror_language@6.10.1_@codemirror_state@6.4.1_@codemirr_djjyqdn7bhwopzrz2h2s2bwhzm/node_modules/@codemirror/autocomplete/dist/index.js +273 -4
- package/dist/esm/node_modules/.pnpm/@codemirror_autocomplete@6.15.0_@codemirror_language@6.10.1_@codemirror_state@6.4.1_@codemirr_djjyqdn7bhwopzrz2h2s2bwhzm/node_modules/@codemirror/autocomplete/dist/index.js.map +1 -1
- package/dist/esm/node_modules/.pnpm/@codemirror_lang-css@6.2.1_@codemirror_view@6.26.1/node_modules/@codemirror/lang-css/dist/index.js +258 -0
- package/dist/esm/node_modules/.pnpm/@codemirror_lang-css@6.2.1_@codemirror_view@6.26.1/node_modules/@codemirror/lang-css/dist/index.js.map +1 -0
- package/dist/esm/node_modules/.pnpm/@codemirror_lang-html@6.4.9/node_modules/@codemirror/lang-html/dist/index.js +661 -0
- package/dist/esm/node_modules/.pnpm/@codemirror_lang-html@6.4.9/node_modules/@codemirror/lang-html/dist/index.js.map +1 -0
- package/dist/esm/node_modules/.pnpm/@codemirror_lang-javascript@6.2.2/node_modules/@codemirror/lang-javascript/dist/index.js +332 -0
- package/dist/esm/node_modules/.pnpm/@codemirror_lang-javascript@6.2.2/node_modules/@codemirror/lang-javascript/dist/index.js.map +1 -0
- package/dist/esm/node_modules/.pnpm/@codemirror_language@6.10.1/node_modules/@codemirror/language/dist/index.js +20 -1
- package/dist/esm/node_modules/.pnpm/@codemirror_language@6.10.1/node_modules/@codemirror/language/dist/index.js.map +1 -1
- package/dist/esm/node_modules/.pnpm/@lezer_common@1.2.1/node_modules/@lezer/common/dist/index.js +508 -2
- package/dist/esm/node_modules/.pnpm/@lezer_common@1.2.1/node_modules/@lezer/common/dist/index.js.map +1 -1
- package/dist/esm/node_modules/.pnpm/@lezer_css@1.1.8/node_modules/@lezer/css/dist/index.js +125 -0
- package/dist/esm/node_modules/.pnpm/@lezer_css@1.1.8/node_modules/@lezer/css/dist/index.js.map +1 -0
- package/dist/esm/node_modules/.pnpm/@lezer_html@1.3.10/node_modules/@lezer/html/dist/index.js +357 -0
- package/dist/esm/node_modules/.pnpm/@lezer_html@1.3.10/node_modules/@lezer/html/dist/index.js.map +1 -0
- package/dist/esm/node_modules/.pnpm/@lezer_javascript@1.4.17/node_modules/@lezer/javascript/dist/index.js +187 -0
- package/dist/esm/node_modules/.pnpm/@lezer_javascript@1.4.17/node_modules/@lezer/javascript/dist/index.js.map +1 -0
- package/dist/esm/node_modules/.pnpm/@lezer_lr@1.4.0/node_modules/@lezer/lr/dist/index.js +1872 -0
- package/dist/esm/node_modules/.pnpm/@lezer_lr@1.4.0/node_modules/@lezer/lr/dist/index.js.map +1 -0
- package/dist/esm/page/signup/index.vue2.js +1 -1
- package/dist/esm/page/signup/index.vue2.js.map +1 -1
- package/dist/esm/router-middleware/auth.js +1 -1
- package/dist/esm/router-middleware/auth.js.map +1 -1
- package/dist/style/index.css +1 -1
- package/dist/style/modules/cms/index.css +1 -0
- package/dist/style/modules/cms/resource-manager.css +1 -0
- package/dist/style/src/index.scss +16 -15
- package/dist/style/src/modules/cms/index.scss +1 -0
- package/dist/style/src/modules/cms/resource-manager.scss +71 -0
- package/package.json +4 -6
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { codePointSize, codePointAt, EditorSelection, CharCategory, Prec, Facet, combineConfig, StateField, StateEffect, MapMode, RangeValue, RangeSet, fromCodePoint, Annotation } from '../../../../../@codemirror_state@6.4.1/node_modules/@codemirror/state/dist/index.js';
|
|
2
|
-
import { EditorView, keymap, showTooltip, getTooltip, ViewPlugin, logException, Direction } from '../../../../../@codemirror_view@6.26.1/node_modules/@codemirror/view/dist/index.js';
|
|
3
|
-
import { syntaxTree } from '../../../../../@codemirror_language@6.10.1/node_modules/@codemirror/language/dist/index.js';
|
|
1
|
+
import { codePointSize, codePointAt, EditorSelection, CharCategory, Prec, Facet, combineConfig, StateField, StateEffect, MapMode, RangeValue, RangeSet, fromCodePoint, Annotation, Text, Transaction } from '../../../../../@codemirror_state@6.4.1/node_modules/@codemirror/state/dist/index.js';
|
|
2
|
+
import { EditorView, keymap, showTooltip, getTooltip, ViewPlugin, logException, Direction, Decoration, WidgetType } from '../../../../../@codemirror_view@6.26.1/node_modules/@codemirror/view/dist/index.js';
|
|
3
|
+
import { syntaxTree, indentUnit } from '../../../../../@codemirror_language@6.10.1/node_modules/@codemirror/language/dist/index.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
An instance of this is passed to completion source functions.
|
|
@@ -102,6 +102,21 @@ function completeFromList(list) {
|
|
|
102
102
|
return token || context.explicit ? { from: token ? token.from : context.pos, options, validFor } : null;
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
Wrap the given completion source so that it will not fire when the
|
|
107
|
+
cursor is in a syntax node with one of the given names.
|
|
108
|
+
*/
|
|
109
|
+
function ifNotIn(nodes, source) {
|
|
110
|
+
return (context) => {
|
|
111
|
+
for (let pos = syntaxTree(context.state).resolveInner(context.pos, -1); pos; pos = pos.parent) {
|
|
112
|
+
if (nodes.indexOf(pos.name) > -1)
|
|
113
|
+
return null;
|
|
114
|
+
if (pos.type.isTop)
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
return source(context);
|
|
118
|
+
};
|
|
119
|
+
}
|
|
105
120
|
class Option {
|
|
106
121
|
constructor(completion, source, match, score) {
|
|
107
122
|
this.completion = completion;
|
|
@@ -1316,6 +1331,260 @@ const baseTheme = /*@__PURE__*/EditorView.baseTheme({
|
|
|
1316
1331
|
}
|
|
1317
1332
|
});
|
|
1318
1333
|
|
|
1334
|
+
class FieldPos {
|
|
1335
|
+
constructor(field, line, from, to) {
|
|
1336
|
+
this.field = field;
|
|
1337
|
+
this.line = line;
|
|
1338
|
+
this.from = from;
|
|
1339
|
+
this.to = to;
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
class FieldRange {
|
|
1343
|
+
constructor(field, from, to) {
|
|
1344
|
+
this.field = field;
|
|
1345
|
+
this.from = from;
|
|
1346
|
+
this.to = to;
|
|
1347
|
+
}
|
|
1348
|
+
map(changes) {
|
|
1349
|
+
let from = changes.mapPos(this.from, -1, MapMode.TrackDel);
|
|
1350
|
+
let to = changes.mapPos(this.to, 1, MapMode.TrackDel);
|
|
1351
|
+
return from == null || to == null ? null : new FieldRange(this.field, from, to);
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
class Snippet {
|
|
1355
|
+
constructor(lines, fieldPositions) {
|
|
1356
|
+
this.lines = lines;
|
|
1357
|
+
this.fieldPositions = fieldPositions;
|
|
1358
|
+
}
|
|
1359
|
+
instantiate(state, pos) {
|
|
1360
|
+
let text = [], lineStart = [pos];
|
|
1361
|
+
let lineObj = state.doc.lineAt(pos), baseIndent = /^\s*/.exec(lineObj.text)[0];
|
|
1362
|
+
for (let line of this.lines) {
|
|
1363
|
+
if (text.length) {
|
|
1364
|
+
let indent = baseIndent, tabs = /^\t*/.exec(line)[0].length;
|
|
1365
|
+
for (let i = 0; i < tabs; i++)
|
|
1366
|
+
indent += state.facet(indentUnit);
|
|
1367
|
+
lineStart.push(pos + indent.length - tabs);
|
|
1368
|
+
line = indent + line.slice(tabs);
|
|
1369
|
+
}
|
|
1370
|
+
text.push(line);
|
|
1371
|
+
pos += line.length + 1;
|
|
1372
|
+
}
|
|
1373
|
+
let ranges = this.fieldPositions.map(pos => new FieldRange(pos.field, lineStart[pos.line] + pos.from, lineStart[pos.line] + pos.to));
|
|
1374
|
+
return { text, ranges };
|
|
1375
|
+
}
|
|
1376
|
+
static parse(template) {
|
|
1377
|
+
let fields = [];
|
|
1378
|
+
let lines = [], positions = [], m;
|
|
1379
|
+
for (let line of template.split(/\r\n?|\n/)) {
|
|
1380
|
+
while (m = /[#$]\{(?:(\d+)(?::([^}]*))?|([^}]*))\}/.exec(line)) {
|
|
1381
|
+
let seq = m[1] ? +m[1] : null, name = m[2] || m[3] || "", found = -1;
|
|
1382
|
+
for (let i = 0; i < fields.length; i++) {
|
|
1383
|
+
if (seq != null ? fields[i].seq == seq : name ? fields[i].name == name : false)
|
|
1384
|
+
found = i;
|
|
1385
|
+
}
|
|
1386
|
+
if (found < 0) {
|
|
1387
|
+
let i = 0;
|
|
1388
|
+
while (i < fields.length && (seq == null || (fields[i].seq != null && fields[i].seq < seq)))
|
|
1389
|
+
i++;
|
|
1390
|
+
fields.splice(i, 0, { seq, name });
|
|
1391
|
+
found = i;
|
|
1392
|
+
for (let pos of positions)
|
|
1393
|
+
if (pos.field >= found)
|
|
1394
|
+
pos.field++;
|
|
1395
|
+
}
|
|
1396
|
+
positions.push(new FieldPos(found, lines.length, m.index, m.index + name.length));
|
|
1397
|
+
line = line.slice(0, m.index) + name + line.slice(m.index + m[0].length);
|
|
1398
|
+
}
|
|
1399
|
+
for (let esc; esc = /\\([{}])/.exec(line);) {
|
|
1400
|
+
line = line.slice(0, esc.index) + esc[1] + line.slice(esc.index + esc[0].length);
|
|
1401
|
+
for (let pos of positions)
|
|
1402
|
+
if (pos.line == lines.length && pos.from > esc.index) {
|
|
1403
|
+
pos.from--;
|
|
1404
|
+
pos.to--;
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
lines.push(line);
|
|
1408
|
+
}
|
|
1409
|
+
return new Snippet(lines, positions);
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
let fieldMarker = /*@__PURE__*/Decoration.widget({ widget: /*@__PURE__*/new class extends WidgetType {
|
|
1413
|
+
toDOM() {
|
|
1414
|
+
let span = document.createElement("span");
|
|
1415
|
+
span.className = "cm-snippetFieldPosition";
|
|
1416
|
+
return span;
|
|
1417
|
+
}
|
|
1418
|
+
ignoreEvent() { return false; }
|
|
1419
|
+
} });
|
|
1420
|
+
let fieldRange = /*@__PURE__*/Decoration.mark({ class: "cm-snippetField" });
|
|
1421
|
+
class ActiveSnippet {
|
|
1422
|
+
constructor(ranges, active) {
|
|
1423
|
+
this.ranges = ranges;
|
|
1424
|
+
this.active = active;
|
|
1425
|
+
this.deco = Decoration.set(ranges.map(r => (r.from == r.to ? fieldMarker : fieldRange).range(r.from, r.to)));
|
|
1426
|
+
}
|
|
1427
|
+
map(changes) {
|
|
1428
|
+
let ranges = [];
|
|
1429
|
+
for (let r of this.ranges) {
|
|
1430
|
+
let mapped = r.map(changes);
|
|
1431
|
+
if (!mapped)
|
|
1432
|
+
return null;
|
|
1433
|
+
ranges.push(mapped);
|
|
1434
|
+
}
|
|
1435
|
+
return new ActiveSnippet(ranges, this.active);
|
|
1436
|
+
}
|
|
1437
|
+
selectionInsideField(sel) {
|
|
1438
|
+
return sel.ranges.every(range => this.ranges.some(r => r.field == this.active && r.from <= range.from && r.to >= range.to));
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
const setActive = /*@__PURE__*/StateEffect.define({
|
|
1442
|
+
map(value, changes) { return value && value.map(changes); }
|
|
1443
|
+
});
|
|
1444
|
+
const moveToField = /*@__PURE__*/StateEffect.define();
|
|
1445
|
+
const snippetState = /*@__PURE__*/StateField.define({
|
|
1446
|
+
create() { return null; },
|
|
1447
|
+
update(value, tr) {
|
|
1448
|
+
for (let effect of tr.effects) {
|
|
1449
|
+
if (effect.is(setActive))
|
|
1450
|
+
return effect.value;
|
|
1451
|
+
if (effect.is(moveToField) && value)
|
|
1452
|
+
return new ActiveSnippet(value.ranges, effect.value);
|
|
1453
|
+
}
|
|
1454
|
+
if (value && tr.docChanged)
|
|
1455
|
+
value = value.map(tr.changes);
|
|
1456
|
+
if (value && tr.selection && !value.selectionInsideField(tr.selection))
|
|
1457
|
+
value = null;
|
|
1458
|
+
return value;
|
|
1459
|
+
},
|
|
1460
|
+
provide: f => EditorView.decorations.from(f, val => val ? val.deco : Decoration.none)
|
|
1461
|
+
});
|
|
1462
|
+
function fieldSelection(ranges, field) {
|
|
1463
|
+
return EditorSelection.create(ranges.filter(r => r.field == field).map(r => EditorSelection.range(r.from, r.to)));
|
|
1464
|
+
}
|
|
1465
|
+
/**
|
|
1466
|
+
Convert a snippet template to a function that can
|
|
1467
|
+
[apply](https://codemirror.net/6/docs/ref/#autocomplete.Completion.apply) it. Snippets are written
|
|
1468
|
+
using syntax like this:
|
|
1469
|
+
|
|
1470
|
+
"for (let ${index} = 0; ${index} < ${end}; ${index}++) {\n\t${}\n}"
|
|
1471
|
+
|
|
1472
|
+
Each `${}` placeholder (you may also use `#{}`) indicates a field
|
|
1473
|
+
that the user can fill in. Its name, if any, will be the default
|
|
1474
|
+
content for the field.
|
|
1475
|
+
|
|
1476
|
+
When the snippet is activated by calling the returned function,
|
|
1477
|
+
the code is inserted at the given position. Newlines in the
|
|
1478
|
+
template are indented by the indentation of the start line, plus
|
|
1479
|
+
one [indent unit](https://codemirror.net/6/docs/ref/#language.indentUnit) per tab character after
|
|
1480
|
+
the newline.
|
|
1481
|
+
|
|
1482
|
+
On activation, (all instances of) the first field are selected.
|
|
1483
|
+
The user can move between fields with Tab and Shift-Tab as long as
|
|
1484
|
+
the fields are active. Moving to the last field or moving the
|
|
1485
|
+
cursor out of the current field deactivates the fields.
|
|
1486
|
+
|
|
1487
|
+
The order of fields defaults to textual order, but you can add
|
|
1488
|
+
numbers to placeholders (`${1}` or `${1:defaultText}`) to provide
|
|
1489
|
+
a custom order.
|
|
1490
|
+
|
|
1491
|
+
To include a literal `{` or `}` in your template, put a backslash
|
|
1492
|
+
in front of it. This will be removed and the brace will not be
|
|
1493
|
+
interpreted as indicating a placeholder.
|
|
1494
|
+
*/
|
|
1495
|
+
function snippet(template) {
|
|
1496
|
+
let snippet = Snippet.parse(template);
|
|
1497
|
+
return (editor, completion, from, to) => {
|
|
1498
|
+
let { text, ranges } = snippet.instantiate(editor.state, from);
|
|
1499
|
+
let spec = {
|
|
1500
|
+
changes: { from, to, insert: Text.of(text) },
|
|
1501
|
+
scrollIntoView: true,
|
|
1502
|
+
annotations: completion ? [pickedCompletion.of(completion), Transaction.userEvent.of("input.complete")] : undefined
|
|
1503
|
+
};
|
|
1504
|
+
if (ranges.length)
|
|
1505
|
+
spec.selection = fieldSelection(ranges, 0);
|
|
1506
|
+
if (ranges.some(r => r.field > 0)) {
|
|
1507
|
+
let active = new ActiveSnippet(ranges, 0);
|
|
1508
|
+
let effects = spec.effects = [setActive.of(active)];
|
|
1509
|
+
if (editor.state.field(snippetState, false) === undefined)
|
|
1510
|
+
effects.push(StateEffect.appendConfig.of([snippetState, addSnippetKeymap, snippetPointerHandler, baseTheme]));
|
|
1511
|
+
}
|
|
1512
|
+
editor.dispatch(editor.state.update(spec));
|
|
1513
|
+
};
|
|
1514
|
+
}
|
|
1515
|
+
function moveField(dir) {
|
|
1516
|
+
return ({ state, dispatch }) => {
|
|
1517
|
+
let active = state.field(snippetState, false);
|
|
1518
|
+
if (!active || dir < 0 && active.active == 0)
|
|
1519
|
+
return false;
|
|
1520
|
+
let next = active.active + dir, last = dir > 0 && !active.ranges.some(r => r.field == next + dir);
|
|
1521
|
+
dispatch(state.update({
|
|
1522
|
+
selection: fieldSelection(active.ranges, next),
|
|
1523
|
+
effects: setActive.of(last ? null : new ActiveSnippet(active.ranges, next)),
|
|
1524
|
+
scrollIntoView: true
|
|
1525
|
+
}));
|
|
1526
|
+
return true;
|
|
1527
|
+
};
|
|
1528
|
+
}
|
|
1529
|
+
/**
|
|
1530
|
+
A command that clears the active snippet, if any.
|
|
1531
|
+
*/
|
|
1532
|
+
const clearSnippet = ({ state, dispatch }) => {
|
|
1533
|
+
let active = state.field(snippetState, false);
|
|
1534
|
+
if (!active)
|
|
1535
|
+
return false;
|
|
1536
|
+
dispatch(state.update({ effects: setActive.of(null) }));
|
|
1537
|
+
return true;
|
|
1538
|
+
};
|
|
1539
|
+
/**
|
|
1540
|
+
Move to the next snippet field, if available.
|
|
1541
|
+
*/
|
|
1542
|
+
const nextSnippetField = /*@__PURE__*/moveField(1);
|
|
1543
|
+
/**
|
|
1544
|
+
Move to the previous snippet field, if available.
|
|
1545
|
+
*/
|
|
1546
|
+
const prevSnippetField = /*@__PURE__*/moveField(-1);
|
|
1547
|
+
const defaultSnippetKeymap = [
|
|
1548
|
+
{ key: "Tab", run: nextSnippetField, shift: prevSnippetField },
|
|
1549
|
+
{ key: "Escape", run: clearSnippet }
|
|
1550
|
+
];
|
|
1551
|
+
/**
|
|
1552
|
+
A facet that can be used to configure the key bindings used by
|
|
1553
|
+
snippets. The default binds Tab to
|
|
1554
|
+
[`nextSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.nextSnippetField), Shift-Tab to
|
|
1555
|
+
[`prevSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.prevSnippetField), and Escape
|
|
1556
|
+
to [`clearSnippet`](https://codemirror.net/6/docs/ref/#autocomplete.clearSnippet).
|
|
1557
|
+
*/
|
|
1558
|
+
const snippetKeymap = /*@__PURE__*/Facet.define({
|
|
1559
|
+
combine(maps) { return maps.length ? maps[0] : defaultSnippetKeymap; }
|
|
1560
|
+
});
|
|
1561
|
+
const addSnippetKeymap = /*@__PURE__*/Prec.highest(/*@__PURE__*/keymap.compute([snippetKeymap], state => state.facet(snippetKeymap)));
|
|
1562
|
+
/**
|
|
1563
|
+
Create a completion from a snippet. Returns an object with the
|
|
1564
|
+
properties from `completion`, plus an `apply` function that
|
|
1565
|
+
applies the snippet.
|
|
1566
|
+
*/
|
|
1567
|
+
function snippetCompletion(template, completion) {
|
|
1568
|
+
return Object.assign(Object.assign({}, completion), { apply: snippet(template) });
|
|
1569
|
+
}
|
|
1570
|
+
const snippetPointerHandler = /*@__PURE__*/EditorView.domEventHandlers({
|
|
1571
|
+
mousedown(event, view) {
|
|
1572
|
+
let active = view.state.field(snippetState, false), pos;
|
|
1573
|
+
if (!active || (pos = view.posAtCoords({ x: event.clientX, y: event.clientY })) == null)
|
|
1574
|
+
return false;
|
|
1575
|
+
let match = active.ranges.find(r => r.from <= pos && r.to >= pos);
|
|
1576
|
+
if (!match || match.field == active.active)
|
|
1577
|
+
return false;
|
|
1578
|
+
view.dispatch({
|
|
1579
|
+
selection: fieldSelection(active.ranges, match.field),
|
|
1580
|
+
effects: setActive.of(active.ranges.some(r => r.field > match.field)
|
|
1581
|
+
? new ActiveSnippet(active.ranges, match.field) : null),
|
|
1582
|
+
scrollIntoView: true
|
|
1583
|
+
});
|
|
1584
|
+
return true;
|
|
1585
|
+
}
|
|
1586
|
+
});
|
|
1587
|
+
|
|
1319
1588
|
const defaults = {
|
|
1320
1589
|
brackets: ["(", "[", "{", "'", '"'],
|
|
1321
1590
|
before: ")]}:;>",
|
|
@@ -1596,5 +1865,5 @@ const completionKeymap = [
|
|
|
1596
1865
|
];
|
|
1597
1866
|
const completionKeymapExt = /*@__PURE__*/Prec.highest(/*@__PURE__*/keymap.computeN([completionConfig], state => state.facet(completionConfig).defaultKeymap ? [completionKeymap] : []));
|
|
1598
1867
|
|
|
1599
|
-
export { CompletionContext, acceptCompletion, autocompletion, closeBrackets, closeBracketsKeymap, closeCompletion, completeFromList, completionKeymap, deleteBracketPair, insertBracket, insertCompletionText, moveCompletionSelection, pickedCompletion, startCompletion };
|
|
1868
|
+
export { CompletionContext, acceptCompletion, autocompletion, clearSnippet, closeBrackets, closeBracketsKeymap, closeCompletion, completeFromList, completionKeymap, deleteBracketPair, ifNotIn, insertBracket, insertCompletionText, moveCompletionSelection, nextSnippetField, pickedCompletion, prevSnippetField, snippet, snippetCompletion, snippetKeymap, startCompletion };
|
|
1600
1869
|
//# sourceMappingURL=index.js.map
|