@bitcobblers/wod-wiki-lang 0.60.2257 → 0.61.2259
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.cjs +277 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -2
- package/dist/index.d.ts +15 -2
- package/dist/index.mjs +277 -55
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -3567,59 +3567,59 @@ tagHighlighter([
|
|
|
3567
3567
|
{ tag: tags.punctuation, class: "tok-punctuation" }
|
|
3568
3568
|
]);
|
|
3569
3569
|
var whiteboardScriptSnippets = [
|
|
3570
|
-
{
|
|
3571
|
-
name: "circuit",
|
|
3572
|
-
label: "Circuit",
|
|
3573
|
-
detail: "Rounds over indented movements",
|
|
3574
|
-
template: "(${1:3})\n ${2:10 Air Squats}\n ${3:10 Push Ups}\n ${4:10 Ring Rows}\n${0}"
|
|
3575
|
-
},
|
|
3576
|
-
{
|
|
3577
|
-
name: "5x5",
|
|
3578
|
-
label: "5x5",
|
|
3579
|
-
detail: "Inline strength sets",
|
|
3580
|
-
template: "${1:5}x${2:5} ${3:Back Squat} @${4:100kg}\n${0}"
|
|
3581
|
-
},
|
|
3582
3570
|
{
|
|
3583
3571
|
name: "emom",
|
|
3584
3572
|
label: "EMOM",
|
|
3585
3573
|
detail: "Every minute on the minute",
|
|
3586
|
-
template: "(${1:10}) ${2::60 EMOM}\n + ${3:
|
|
3574
|
+
template: "(${1:10}) ${2::60 EMOM}\n + ${3:10 Kettlebell Swing} @${4:24kg} #emom\n${0}"
|
|
3587
3575
|
},
|
|
3588
3576
|
{
|
|
3589
3577
|
name: "amrap",
|
|
3590
3578
|
label: "AMRAP",
|
|
3591
|
-
detail: "As many rounds as possible",
|
|
3592
|
-
template: "${1:
|
|
3579
|
+
detail: "As many rounds as possible in time cap",
|
|
3580
|
+
template: "${1:12:00 AMRAP}\n ${2:10 Pull-up}\n ${3:15 Push-up}\n ${4:200m Run} #amrap\n${0}"
|
|
3593
3581
|
},
|
|
3594
3582
|
{
|
|
3595
3583
|
name: "tabata",
|
|
3596
3584
|
label: "Tabata",
|
|
3597
|
-
detail: "
|
|
3598
|
-
template: "(${1:8}) ${2::20 Work}\n * ${3::10
|
|
3585
|
+
detail: "8 intervals of 20s work / 10s rest",
|
|
3586
|
+
template: "(${1:8}) ${2::20 Work}\n * ${3::10} [:rest]\n ${4:10 Air Squat} #tabata\n${0}"
|
|
3587
|
+
},
|
|
3588
|
+
{
|
|
3589
|
+
name: "5x5",
|
|
3590
|
+
label: "5x5",
|
|
3591
|
+
detail: "Sets \xD7 reps barbell progression",
|
|
3592
|
+
template: "${1:5}x${2:5} ${3:Back Squat} @${4:100kg} *${5:2:00} #strength\n${0}"
|
|
3593
|
+
},
|
|
3594
|
+
{
|
|
3595
|
+
name: "circuit",
|
|
3596
|
+
label: "Circuit",
|
|
3597
|
+
detail: "Multi-station timed rounds",
|
|
3598
|
+
template: "(${1:3})\n ${2:400m Run}\n ${3:15 Wall Ball} @${4:9kg}\n *${5:1:00} [:rest]\n${0}"
|
|
3599
3599
|
},
|
|
3600
3600
|
{
|
|
3601
3601
|
name: "ladder",
|
|
3602
3602
|
label: "Ladder",
|
|
3603
|
-
detail: "
|
|
3604
|
-
template: "(${1:21-15-9})\n ${2:
|
|
3603
|
+
detail: "Descending rep scheme (21-15-9)",
|
|
3604
|
+
template: "(${1:21-15-9})\n ${2:Thruster} @${3:43kg}\n ${4:Pull-up} #for-time\n${0}"
|
|
3605
3605
|
},
|
|
3606
3606
|
{
|
|
3607
3607
|
name: "choice",
|
|
3608
3608
|
label: "Choice",
|
|
3609
|
-
detail: "
|
|
3610
|
-
template: "${1:
|
|
3609
|
+
detail: "Scaled or equipment alternative (A | B)",
|
|
3610
|
+
template: "(${1:5})\n ${2:15 Kettlebell Swing} ${3:24 | 16 kg}\n${0}"
|
|
3611
3611
|
},
|
|
3612
3612
|
{
|
|
3613
3613
|
name: "superset",
|
|
3614
3614
|
label: "Superset",
|
|
3615
3615
|
detail: "Compound set via + lap markers",
|
|
3616
|
-
template: "+ ${1:5 Pull
|
|
3616
|
+
template: "+ ${1:5 Pull-up}\n+ ${2:10 Push-up}\n${0}"
|
|
3617
3617
|
},
|
|
3618
3618
|
{
|
|
3619
3619
|
name: "collectible",
|
|
3620
3620
|
label: "Collectible",
|
|
3621
|
-
detail: "
|
|
3622
|
-
template: "${1::?
|
|
3621
|
+
detail: "Open clock measure-until-done (:?)",
|
|
3622
|
+
template: "${1::? 2000m Row} #for-time\n${0}"
|
|
3623
3623
|
}
|
|
3624
3624
|
];
|
|
3625
3625
|
function applyTemplateDefaults(template) {
|
|
@@ -3630,6 +3630,8 @@ function snippetCompletions() {
|
|
|
3630
3630
|
(snippet) => autocomplete.snippetCompletion(snippet.template, {
|
|
3631
3631
|
label: snippet.label,
|
|
3632
3632
|
detail: snippet.detail,
|
|
3633
|
+
info: applyTemplateDefaults(snippet.template).trim(),
|
|
3634
|
+
section: { name: "Templates", rank: 3 },
|
|
3633
3635
|
type: "text",
|
|
3634
3636
|
boost: 10
|
|
3635
3637
|
})
|
|
@@ -3637,17 +3639,66 @@ function snippetCompletions() {
|
|
|
3637
3639
|
}
|
|
3638
3640
|
|
|
3639
3641
|
// src/parser/completion.ts
|
|
3642
|
+
var COMPLETION_SECTIONS = {
|
|
3643
|
+
units: { name: "Units", rank: 1 },
|
|
3644
|
+
inNotebook: { name: "In this notebook", rank: 2 },
|
|
3645
|
+
templates: { name: "Templates", rank: 3 },
|
|
3646
|
+
actionCues: { name: "Action Cues", rank: 4 },
|
|
3647
|
+
structure: { name: "Structure", rank: 5 },
|
|
3648
|
+
movements: { name: "Movements", rank: 6 },
|
|
3649
|
+
tags: { name: "Tags", rank: 7 },
|
|
3650
|
+
equipment: { name: "Equipment", rank: 8 },
|
|
3651
|
+
sounds: { name: "Sounds", rank: 9 },
|
|
3652
|
+
dialect: { name: "Dialect", rank: 10 },
|
|
3653
|
+
blockProperties: { name: "Block Properties", rank: 20 },
|
|
3654
|
+
unitAliases: { name: "Unit Aliases", rank: 50 },
|
|
3655
|
+
create: { name: "Create", rank: 90 }
|
|
3656
|
+
};
|
|
3657
|
+
var SECTION_BY_NAME = Object.fromEntries(
|
|
3658
|
+
Object.values(COMPLETION_SECTIONS).map((section) => [section.name.toLowerCase(), section])
|
|
3659
|
+
);
|
|
3660
|
+
function resolveSection(section) {
|
|
3661
|
+
if (!section) return void 0;
|
|
3662
|
+
if (typeof section === "object") return section;
|
|
3663
|
+
return SECTION_BY_NAME[section.toLowerCase()] ?? { name: section, rank: 15 };
|
|
3664
|
+
}
|
|
3640
3665
|
var COMPLETION_PROPERTY_KEYS = ["effort", "equipment", ...Object.keys(PROPERTY_KEY_TO_METRIC_TYPE)];
|
|
3641
3666
|
var STRUCTURE_KEYWORD_LABELS = ["amrap", "emom", "tabata", "for time", "rest"];
|
|
3642
3667
|
var STRUCTURE_KEYWORD_DISPLAY = {
|
|
3643
3668
|
"for time": "FOR TIME",
|
|
3644
3669
|
rest: "Rest"
|
|
3645
3670
|
};
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3671
|
+
var PRIMARY_UNIT_BOOST = {
|
|
3672
|
+
kg: 30,
|
|
3673
|
+
lb: 29,
|
|
3674
|
+
m: 28,
|
|
3675
|
+
km: 27,
|
|
3676
|
+
cal: 26,
|
|
3677
|
+
mi: 25,
|
|
3678
|
+
ft: 24,
|
|
3679
|
+
kcal: 23
|
|
3680
|
+
};
|
|
3681
|
+
function unitCompletions(units, dimension, preferredSet) {
|
|
3682
|
+
return units.toArray().filter((def) => !dimension || def.dimension === dimension).flatMap((def) => {
|
|
3683
|
+
const canonicalLower = def.canonical.toLowerCase();
|
|
3684
|
+
const canonicalBoost = preferredSet?.has(canonicalLower) ? 40 : PRIMARY_UNIT_BOOST[canonicalLower] ?? 20;
|
|
3685
|
+
return [
|
|
3686
|
+
{
|
|
3687
|
+
label: def.canonical,
|
|
3688
|
+
detail: def.dimension,
|
|
3689
|
+
type: "unit",
|
|
3690
|
+
section: COMPLETION_SECTIONS.units,
|
|
3691
|
+
boost: canonicalBoost
|
|
3692
|
+
},
|
|
3693
|
+
...def.aliases.map((alias) => ({
|
|
3694
|
+
label: alias,
|
|
3695
|
+
detail: def.dimension,
|
|
3696
|
+
type: "unit",
|
|
3697
|
+
section: COMPLETION_SECTIONS.unitAliases,
|
|
3698
|
+
boost: preferredSet?.has(alias.toLowerCase()) ? 35 : 5
|
|
3699
|
+
}))
|
|
3700
|
+
];
|
|
3701
|
+
});
|
|
3651
3702
|
}
|
|
3652
3703
|
function titleCase(word) {
|
|
3653
3704
|
return word.toLowerCase().replace(/(^|[\s])([a-z])/g, (_, lead, ch) => lead + ch.toUpperCase());
|
|
@@ -3659,22 +3710,24 @@ var SPORT_VOCABULARY = {
|
|
|
3659
3710
|
cardio: () => unique(CARDIO_ACTIVITY_KEYWORDS.flatMap((activity) => activity.keywords)).map((word) => ({
|
|
3660
3711
|
label: titleCase(word),
|
|
3661
3712
|
detail: "cardio",
|
|
3662
|
-
type: "text"
|
|
3713
|
+
type: "text",
|
|
3714
|
+
section: COMPLETION_SECTIONS.dialect
|
|
3663
3715
|
})),
|
|
3664
3716
|
yoga: () => unique([
|
|
3665
3717
|
...YogaDialect.POSE_KEYWORDS,
|
|
3666
3718
|
...YogaDialect.FLOW_KEYWORDS,
|
|
3667
3719
|
...YogaDialect.BREATHING_KEYWORDS,
|
|
3668
3720
|
...YogaDialect.MEDITATION_KEYWORDS
|
|
3669
|
-
]).filter((word) => /^[A-Z ]+$/.test(word)).map((word) => ({ label: titleCase(word), detail: "yoga", type: "text" })),
|
|
3721
|
+
]).filter((word) => /^[A-Z ]+$/.test(word)).map((word) => ({ label: titleCase(word), detail: "yoga", type: "text", section: COMPLETION_SECTIONS.dialect })),
|
|
3670
3722
|
habits: () => unique([...HabitsDialect.HABIT_KEYWORDS, ...HabitsDialect.STREAK_KEYWORDS]).map((word) => ({
|
|
3671
3723
|
label: titleCase(word),
|
|
3672
3724
|
detail: "habits",
|
|
3673
|
-
type: "text"
|
|
3725
|
+
type: "text",
|
|
3726
|
+
section: COMPLETION_SECTIONS.dialect
|
|
3674
3727
|
})),
|
|
3675
3728
|
climb: () => [
|
|
3676
|
-
...unique(Object.values(SEND_ALIASES)).map((send) => ({ label: send, detail: "send", type: "text" })),
|
|
3677
|
-
...unique(Object.values(DISCIPLINE_KEYWORDS)).map((discipline) => ({ label: discipline, detail: "discipline", type: "text" }))
|
|
3729
|
+
...unique(Object.values(SEND_ALIASES)).map((send) => ({ label: send, detail: "send", type: "text", section: COMPLETION_SECTIONS.dialect })),
|
|
3730
|
+
...unique(Object.values(DISCIPLINE_KEYWORDS)).map((discipline) => ({ label: discipline, detail: "discipline", type: "text", section: COMPLETION_SECTIONS.dialect }))
|
|
3678
3731
|
]
|
|
3679
3732
|
};
|
|
3680
3733
|
function structureKeywords() {
|
|
@@ -3682,22 +3735,93 @@ function structureKeywords() {
|
|
|
3682
3735
|
label: STRUCTURE_KEYWORD_DISPLAY[word] ?? word.toUpperCase(),
|
|
3683
3736
|
detail: "structure",
|
|
3684
3737
|
type: "keyword",
|
|
3738
|
+
section: COMPLETION_SECTIONS.structure,
|
|
3685
3739
|
boost: 5,
|
|
3686
3740
|
apply: STRUCTURE_KEYWORD_DISPLAY[word] ?? word.toUpperCase()
|
|
3687
3741
|
}));
|
|
3688
3742
|
}
|
|
3743
|
+
var ACTION_CUE_COMPLETIONS = [
|
|
3744
|
+
{ label: "[:rest]", detail: "Rest cue", type: "keyword", section: COMPLETION_SECTIONS.actionCues, apply: "[:rest] ", boost: 20 },
|
|
3745
|
+
{ label: "[:next]", detail: "Advance segment", type: "keyword", section: COMPLETION_SECTIONS.actionCues, apply: "[:next] ", boost: 15 },
|
|
3746
|
+
{ label: "[:done]", detail: "Complete block", type: "keyword", section: COMPLETION_SECTIONS.actionCues, apply: "[:done] ", boost: 12 },
|
|
3747
|
+
{ label: "[:mark]", detail: "Split / lap marker", type: "keyword", section: COMPLETION_SECTIONS.actionCues, apply: "[:mark] ", boost: 10 }
|
|
3748
|
+
];
|
|
3749
|
+
var DEFAULT_SECTION_BY_KIND = {
|
|
3750
|
+
effort: COMPLETION_SECTIONS.movements,
|
|
3751
|
+
equipment: COMPLETION_SECTIONS.equipment,
|
|
3752
|
+
sound: COMPLETION_SECTIONS.sounds,
|
|
3753
|
+
tag: COMPLETION_SECTIONS.tags
|
|
3754
|
+
};
|
|
3755
|
+
var COMPLETION_TYPE_BY_KIND = {
|
|
3756
|
+
effort: "variable",
|
|
3757
|
+
equipment: "text",
|
|
3758
|
+
sound: "constant",
|
|
3759
|
+
tag: "constant"
|
|
3760
|
+
};
|
|
3761
|
+
var completionAliases = /* @__PURE__ */ new WeakMap();
|
|
3689
3762
|
function toCompletions(values, detail, quoteValues = false) {
|
|
3763
|
+
const defaultSection = DEFAULT_SECTION_BY_KIND[detail];
|
|
3764
|
+
const completionType = COMPLETION_TYPE_BY_KIND[detail] ?? "text";
|
|
3690
3765
|
return values.map((value) => {
|
|
3691
3766
|
const insertText = quoteValues ? !/^[A-Za-z][A-Za-z0-9]*$/.test(value.value) ? JSON.stringify(value.value) : value.value : value.label ?? value.value;
|
|
3692
|
-
|
|
3767
|
+
const resolvedSection = resolveSection(value.section) ?? defaultSection;
|
|
3768
|
+
const item = {
|
|
3693
3769
|
label: value.label ?? value.value,
|
|
3694
3770
|
apply: insertText,
|
|
3695
3771
|
detail: value.detail ?? (value.label && value.label !== value.value ? value.value : detail),
|
|
3696
|
-
type:
|
|
3697
|
-
info: value.info
|
|
3772
|
+
type: completionType,
|
|
3773
|
+
info: value.info,
|
|
3774
|
+
...value.boost !== void 0 ? { boost: value.boost } : {},
|
|
3775
|
+
...resolvedSection ? { section: resolvedSection } : {}
|
|
3698
3776
|
};
|
|
3777
|
+
if (value.aliases?.length) {
|
|
3778
|
+
completionAliases.set(item, value.aliases.map((a) => a.toLowerCase()));
|
|
3779
|
+
}
|
|
3780
|
+
return item;
|
|
3699
3781
|
});
|
|
3700
3782
|
}
|
|
3783
|
+
function appendCreateEffortOption(pool, typedPhrase, onCreateEffort) {
|
|
3784
|
+
if (!onCreateEffort) return pool;
|
|
3785
|
+
const trimmed = typedPhrase.trim();
|
|
3786
|
+
if (trimmed.length < 3 || !/^[A-Za-z][A-Za-z0-9 -]*$/.test(trimmed)) return pool;
|
|
3787
|
+
const lower = trimmed.toLowerCase();
|
|
3788
|
+
const hasMatch = pool.some((opt) => {
|
|
3789
|
+
const labelLower = opt.label.toLowerCase();
|
|
3790
|
+
const applyLower = typeof opt.apply === "string" ? opt.apply.toLowerCase().trim() : "";
|
|
3791
|
+
const aliases = completionAliases.get(opt);
|
|
3792
|
+
return labelLower === lower || applyLower === lower || Boolean(aliases?.includes(lower));
|
|
3793
|
+
});
|
|
3794
|
+
if (hasMatch) return pool;
|
|
3795
|
+
const createOption = {
|
|
3796
|
+
label: trimmed,
|
|
3797
|
+
displayLabel: `+ Create "${trimmed}"`,
|
|
3798
|
+
detail: "Add to Effort Library",
|
|
3799
|
+
type: "create",
|
|
3800
|
+
section: COMPLETION_SECTIONS.create,
|
|
3801
|
+
boost: -25,
|
|
3802
|
+
apply: (view, _completion, from, to) => {
|
|
3803
|
+
view.dispatch({
|
|
3804
|
+
changes: { from, to, insert: trimmed },
|
|
3805
|
+
selection: { anchor: from + trimmed.length },
|
|
3806
|
+
userEvent: "input.complete"
|
|
3807
|
+
});
|
|
3808
|
+
void onCreateEffort(trimmed);
|
|
3809
|
+
}
|
|
3810
|
+
};
|
|
3811
|
+
return [...pool, createOption];
|
|
3812
|
+
}
|
|
3813
|
+
function completionMatchesAliasOnly(option, typedLower) {
|
|
3814
|
+
const aliases = completionAliases.get(option);
|
|
3815
|
+
return aliases ? aliases.some((alias) => alias.includes(typedLower)) : false;
|
|
3816
|
+
}
|
|
3817
|
+
function completionMatchesWord(option, typedLower) {
|
|
3818
|
+
const inserted = (typeof option.apply === "string" ? option.apply : option.label).toLowerCase();
|
|
3819
|
+
const label = option.label.toLowerCase();
|
|
3820
|
+
if (inserted.startsWith(typedLower) || label.startsWith(typedLower)) return "prefix";
|
|
3821
|
+
if (inserted.includes(typedLower) || label.includes(typedLower)) return "word";
|
|
3822
|
+
if (completionMatchesAliasOnly(option, typedLower)) return "alias";
|
|
3823
|
+
return null;
|
|
3824
|
+
}
|
|
3701
3825
|
function dialectWords(sport) {
|
|
3702
3826
|
if (!sport) return [];
|
|
3703
3827
|
const vocabulary = SPORT_VOCABULARY[SPORT_ALIASES[sport] ?? sport];
|
|
@@ -3749,24 +3873,64 @@ function inNode(context, names) {
|
|
|
3749
3873
|
}
|
|
3750
3874
|
return false;
|
|
3751
3875
|
}
|
|
3752
|
-
var
|
|
3876
|
+
var ALWAYS_SUPPRESSED_NODES = /* @__PURE__ */ new Set(["Text", "textComment", "MetricObject"]);
|
|
3877
|
+
var HEADING_NODES = /* @__PURE__ */ new Set(["Heading", "heading"]);
|
|
3753
3878
|
function whiteboardScriptCompletionSource(options = {}) {
|
|
3754
3879
|
const sportWords = dialectWords(options.sport);
|
|
3755
3880
|
const keywords = structureKeywords();
|
|
3756
3881
|
const snippets = snippetCompletions();
|
|
3882
|
+
const snippetLabels = new Set(snippets.map((s) => s.label));
|
|
3883
|
+
const startKeywords = keywords.filter((k) => !snippetLabels.has(k.label));
|
|
3757
3884
|
const units = options.units ?? UnitRegistry.standard();
|
|
3758
|
-
const allUnitOptions = unitCompletions(units);
|
|
3759
|
-
const massUnitOptions = unitCompletions(units, "mass");
|
|
3760
3885
|
return async (context) => {
|
|
3761
|
-
if (inNode(context,
|
|
3886
|
+
if (inNode(context, ALWAYS_SUPPRESSED_NODES)) return null;
|
|
3762
3887
|
const pos = context.pos;
|
|
3763
3888
|
const line = context.state.doc.lineAt(pos);
|
|
3764
3889
|
const before = line.text.slice(0, pos - line.from);
|
|
3765
3890
|
const word = /([A-Za-z0-9-]*)$/.exec(before)[1];
|
|
3766
3891
|
const beforeWord = before.slice(0, before.length - word.length);
|
|
3767
|
-
|
|
3768
|
-
|
|
3892
|
+
const actionMatch = /(\[:[a-zA-Z0-9-]*)$/.exec(before);
|
|
3893
|
+
if (actionMatch) {
|
|
3894
|
+
return {
|
|
3895
|
+
from: pos - actionMatch[1].length,
|
|
3896
|
+
options: ACTION_CUE_COMPLETIONS,
|
|
3897
|
+
validFor: /^\[:[a-zA-Z0-9-]*\]?$/
|
|
3898
|
+
};
|
|
3769
3899
|
}
|
|
3900
|
+
if (/(?:^|[\s:])#$/.test(beforeWord) && (options.tags || options.onCreateTag)) {
|
|
3901
|
+
const rawTags = options.tags ? await options.tags() : [];
|
|
3902
|
+
const tagOptions = toCompletions(rawTags, "tag");
|
|
3903
|
+
if (options.onCreateTag && word.length >= 2) {
|
|
3904
|
+
const slug = word.toLowerCase();
|
|
3905
|
+
const exists = rawTags.some(
|
|
3906
|
+
(tag) => tag.value.toLowerCase() === slug || (tag.label ?? "").toLowerCase() === slug
|
|
3907
|
+
);
|
|
3908
|
+
if (!exists) {
|
|
3909
|
+
tagOptions.push({
|
|
3910
|
+
label: slug,
|
|
3911
|
+
displayLabel: `+ Create "#${slug}"`,
|
|
3912
|
+
detail: "New tag",
|
|
3913
|
+
type: "create",
|
|
3914
|
+
section: COMPLETION_SECTIONS.create,
|
|
3915
|
+
boost: -20,
|
|
3916
|
+
apply: (view, _completion, from, to) => {
|
|
3917
|
+
view.dispatch({
|
|
3918
|
+
changes: { from, to, insert: slug },
|
|
3919
|
+
selection: { anchor: from + slug.length },
|
|
3920
|
+
userEvent: "input.complete"
|
|
3921
|
+
});
|
|
3922
|
+
void options.onCreateTag?.(slug);
|
|
3923
|
+
}
|
|
3924
|
+
});
|
|
3925
|
+
}
|
|
3926
|
+
}
|
|
3927
|
+
return {
|
|
3928
|
+
from: pos - word.length,
|
|
3929
|
+
options: tagOptions,
|
|
3930
|
+
validFor: /^[A-Za-z0-9-]*$/
|
|
3931
|
+
};
|
|
3932
|
+
}
|
|
3933
|
+
if (inNode(context, HEADING_NODES)) return null;
|
|
3770
3934
|
const statement = currentStatement(context);
|
|
3771
3935
|
if (statement?.name === "Property") {
|
|
3772
3936
|
const keyNode = statement.firstChild;
|
|
@@ -3783,14 +3947,44 @@ function whiteboardScriptCompletionSource(options = {}) {
|
|
|
3783
3947
|
label: eq.label ?? eq.value,
|
|
3784
3948
|
apply: `${eq.label ?? eq.value} `,
|
|
3785
3949
|
detail: eq.detail ?? "equipment",
|
|
3786
|
-
type: "text"
|
|
3950
|
+
type: "text",
|
|
3951
|
+
section: resolveSection(eq.section) ?? COMPLETION_SECTIONS.equipment,
|
|
3952
|
+
...eq.boost !== void 0 ? { boost: eq.boost } : {}
|
|
3787
3953
|
})) : [];
|
|
3954
|
+
const postQuantityEffortOptions = [...efforts, ...equipmentPrefixes, ...sportWords];
|
|
3788
3955
|
const effortOptions = [...keywords, ...efforts, ...equipmentPrefixes, ...sportWords];
|
|
3789
3956
|
if (/^[ \t]*[A-Za-z][A-Za-z0-9]*$/.test(before)) {
|
|
3790
3957
|
const supplied = suppliedPropertyKeys(context);
|
|
3958
|
+
const propertyOptions = COMPLETION_PROPERTY_KEYS.filter((key) => !supplied.has(key)).map((key) => ({
|
|
3959
|
+
label: key,
|
|
3960
|
+
apply: `${key}: `,
|
|
3961
|
+
detail: "block property",
|
|
3962
|
+
type: "property",
|
|
3963
|
+
section: COMPLETION_SECTIONS.blockProperties,
|
|
3964
|
+
boost: -10
|
|
3965
|
+
}));
|
|
3966
|
+
const allStartOptions = [
|
|
3967
|
+
...snippets,
|
|
3968
|
+
...startKeywords,
|
|
3969
|
+
...efforts,
|
|
3970
|
+
...sportWords,
|
|
3971
|
+
...propertyOptions
|
|
3972
|
+
];
|
|
3973
|
+
const typedRaw = before.trimStart();
|
|
3974
|
+
const typedStart = typedRaw.toLowerCase();
|
|
3975
|
+
const hasAliasHit = typedStart.length >= 2 && effortOptions.some((opt) => completionMatchesWord(opt, typedStart) === "alias");
|
|
3976
|
+
if (hasAliasHit) {
|
|
3977
|
+
const matched = allStartOptions.filter((opt) => completionMatchesWord(opt, typedStart) !== null);
|
|
3978
|
+
return {
|
|
3979
|
+
from: pos - typedRaw.length,
|
|
3980
|
+
options: appendCreateEffortOption(matched, typedRaw, options.onCreateEffort),
|
|
3981
|
+
filter: false,
|
|
3982
|
+
validFor: /^[A-Za-z]*$/
|
|
3983
|
+
};
|
|
3984
|
+
}
|
|
3791
3985
|
return {
|
|
3792
|
-
from: pos -
|
|
3793
|
-
options:
|
|
3986
|
+
from: pos - typedRaw.length,
|
|
3987
|
+
options: appendCreateEffortOption(allStartOptions, typedRaw, options.onCreateEffort),
|
|
3794
3988
|
validFor: /^[A-Za-z]*$/
|
|
3795
3989
|
};
|
|
3796
3990
|
}
|
|
@@ -3805,14 +3999,38 @@ function whiteboardScriptCompletionSource(options = {}) {
|
|
|
3805
3999
|
(fragment) => fragment.firstChild?.name === "Action" && fragment.from < (quantity?.from ?? pos) && !context.state.doc.sliceString(fragment.from, fragment.to).includes(":")
|
|
3806
4000
|
);
|
|
3807
4001
|
if (quantity && !incompleteAction) {
|
|
4002
|
+
const preferredSet = new Set(
|
|
4003
|
+
(options.preferredUnits?.() ?? []).map((u) => u.toLowerCase())
|
|
4004
|
+
);
|
|
4005
|
+
const unitPool = unitCompletions(
|
|
4006
|
+
units,
|
|
4007
|
+
quantity.getChild("AtSign") ? "mass" : void 0,
|
|
4008
|
+
preferredSet.size > 0 ? preferredSet : void 0
|
|
4009
|
+
);
|
|
4010
|
+
const wordText = completingWord ? context.state.doc.sliceString(last.from, pos).toLowerCase() : "";
|
|
4011
|
+
const hasAliasHit = wordText.length >= 2 && postQuantityEffortOptions.some((opt) => completionMatchesWord(opt, wordText) === "alias");
|
|
4012
|
+
const pool = [...unitPool, ...postQuantityEffortOptions];
|
|
4013
|
+
if (hasAliasHit && completingWord) {
|
|
4014
|
+
const rawPhrase = context.state.doc.sliceString(last.from, pos);
|
|
4015
|
+
return {
|
|
4016
|
+
from: last.from,
|
|
4017
|
+
options: appendCreateEffortOption(
|
|
4018
|
+
pool.filter((opt) => completionMatchesWord(opt, wordText) !== null),
|
|
4019
|
+
rawPhrase,
|
|
4020
|
+
options.onCreateEffort
|
|
4021
|
+
),
|
|
4022
|
+
filter: false,
|
|
4023
|
+
validFor: /^[A-Za-z]*$/
|
|
4024
|
+
};
|
|
4025
|
+
}
|
|
3808
4026
|
return {
|
|
3809
4027
|
from: completingWord ? last.from : pos,
|
|
3810
|
-
options:
|
|
4028
|
+
options: completingWord ? appendCreateEffortOption(pool, context.state.doc.sliceString(last.from, pos), options.onCreateEffort) : pool,
|
|
3811
4029
|
validFor: /^[A-Za-z]*$/
|
|
3812
4030
|
};
|
|
3813
4031
|
}
|
|
3814
4032
|
if (before.trim() === "") {
|
|
3815
|
-
return { from: pos, options: [...snippets, ...
|
|
4033
|
+
return { from: pos, options: [...snippets, ...startKeywords, ...efforts, ...sportWords] };
|
|
3816
4034
|
}
|
|
3817
4035
|
if (word.length === 0 && /[ \t]$/.test(before)) {
|
|
3818
4036
|
const effortRun = trailingEffortRun(context, statement, units);
|
|
@@ -3825,12 +4043,16 @@ function whiteboardScriptCompletionSource(options = {}) {
|
|
|
3825
4043
|
const first = effortRun[0];
|
|
3826
4044
|
const last2 = effortRun[effortRun.length - 1];
|
|
3827
4045
|
if (!first || !last2 || last2.to < pos) return null;
|
|
3828
|
-
const
|
|
3829
|
-
const
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
4046
|
+
const rawPhrase = context.state.doc.sliceString(first.from, pos);
|
|
4047
|
+
const typed = rawPhrase.toLowerCase();
|
|
4048
|
+
const compatible = effortOptions.filter((option) => completionMatchesWord(option, typed) !== null);
|
|
4049
|
+
const usesAlias = compatible.some((option) => completionMatchesWord(option, typed) === "alias");
|
|
4050
|
+
return {
|
|
4051
|
+
from: first.from,
|
|
4052
|
+
options: appendCreateEffortOption(compatible, rawPhrase, options.onCreateEffort),
|
|
4053
|
+
...usesAlias ? { filter: false } : {},
|
|
4054
|
+
validFor: /^[A-Za-z ]*$/
|
|
4055
|
+
};
|
|
3834
4056
|
}
|
|
3835
4057
|
return null;
|
|
3836
4058
|
};
|
|
@@ -17128,6 +17350,7 @@ exports.BlockBuilder = BlockBuilder;
|
|
|
17128
17350
|
exports.BlockContext = BlockContext;
|
|
17129
17351
|
exports.ButtonBehavior = ButtonBehavior;
|
|
17130
17352
|
exports.COMPLETION_PROPERTY_KEYS = COMPLETION_PROPERTY_KEYS;
|
|
17353
|
+
exports.COMPLETION_SECTIONS = COMPLETION_SECTIONS;
|
|
17131
17354
|
exports.CONSUMED_HINTS = CONSUMED_HINTS;
|
|
17132
17355
|
exports.CONSUMED_HINT_KEYS = CONSUMED_HINT_KEYS;
|
|
17133
17356
|
exports.CONTEXT_ATOMS = CONTEXT_ATOMS;
|