@@ -57,6 +57,7 @@ import {
5757 variableHighlighter ,
5858 variableAutocompletion ,
5959 missingVariableTooltip ,
60+ existingVariableTooltip ,
6061 createThemeExtension ,
6162 type VariableDetectionLabels ,
6263} from " ./codemirror-extensions" ;
@@ -132,6 +133,7 @@ let editorView: EditorView | null = null;
132133const autocompletionCompartment = new Compartment ();
133134const highlighterCompartment = new Compartment ();
134135const missingVariableTooltipCompartment = new Compartment ();
136+ const existingVariableTooltipCompartment = new Compartment ();
135137const placeholderCompartment = new Compartment ();
136138const themeCompartment = new Compartment ();
137139
@@ -503,6 +505,23 @@ onMounted(() => {
503505 },
504506 ),
505507 ),
508+ // 已存在变量提示
509+ existingVariableTooltipCompartment .of (
510+ existingVariableTooltip (
511+ variableDetectionLabels .value ,
512+ {
513+ backgroundColor: themeVars .value .cardColor ,
514+ borderColor: themeVars .value .borderColor ,
515+ borderRadius: themeVars .value .borderRadius ,
516+ textColor: themeVars .value .textColor2 ,
517+ shadow: themeVars .value .boxShadow2 ,
518+ sourceGlobalColor: themeVars .value .infoColor ,
519+ sourceTemporaryColor: themeVars .value .successColor ,
520+ sourcePredefinedColor: themeVars .value .warningColor ,
521+ surfaceOverlay: themeVars .value .popoverColor ,
522+ },
523+ ),
524+ ),
506525 // 主题适配
507526 themeCompartment .of (createThemeExtension (themeVars .value )),
508527 // 监听文档变化
@@ -586,6 +605,22 @@ watch(
586605 },
587606 ),
588607 ),
608+ existingVariableTooltipCompartment .reconfigure (
609+ existingVariableTooltip (
610+ variableDetectionLabels .value ,
611+ {
612+ backgroundColor: themeVars .value .cardColor ,
613+ borderColor: themeVars .value .borderColor ,
614+ borderRadius: themeVars .value .borderRadius ,
615+ textColor: themeVars .value .textColor2 ,
616+ shadow: themeVars .value .boxShadow2 ,
617+ sourceGlobalColor: themeVars .value .infoColor ,
618+ sourceTemporaryColor: themeVars .value .successColor ,
619+ sourcePredefinedColor: themeVars .value .warningColor ,
620+ surfaceOverlay: themeVars .value .popoverColor ,
621+ },
622+ ),
623+ ),
589624 ],
590625 });
591626 },
@@ -618,6 +653,36 @@ watch(
618653 editorView .dispatch ({
619654 effects: [
620655 themeCompartment .reconfigure (createThemeExtension (vars )),
656+ missingVariableTooltipCompartment .reconfigure (
657+ missingVariableTooltip (
658+ handleAddMissingVariable ,
659+ variableDetectionLabels .value ,
660+ {
661+ backgroundColor: vars .cardColor ,
662+ borderColor: vars .borderColor ,
663+ borderRadius: vars .borderRadius ,
664+ textColor: vars .textColor2 ,
665+ primaryColor: vars .primaryColor ,
666+ primaryColorHover: vars .primaryColorHover ,
667+ },
668+ ),
669+ ),
670+ existingVariableTooltipCompartment .reconfigure (
671+ existingVariableTooltip (
672+ variableDetectionLabels .value ,
673+ {
674+ backgroundColor: vars .cardColor ,
675+ borderColor: vars .borderColor ,
676+ borderRadius: vars .borderRadius ,
677+ textColor: vars .textColor2 ,
678+ shadow: vars .boxShadow2 ,
679+ sourceGlobalColor: vars .infoColor ,
680+ sourceTemporaryColor: vars .successColor ,
681+ sourcePredefinedColor: vars .warningColor ,
682+ surfaceOverlay: vars .popoverColor ,
683+ },
684+ ),
685+ ),
621686 ],
622687 });
623688 },
0 commit comments