예제 #1
0
 public async Task ResetDeltaDecorations()
 {
     DeltaDecorationIds = null;
     if (MonacoEditor == null)
     {
         throw new NullReferenceException("MonacoEditor has not been set");
     }
     await MonacoEditor.ResetDeltaDecorations();
 }
        public static async Task <string[]> ResetDeltaDecorations(MonacoEditor monacoEditor)
        {
            if (monacoEditor == null)
            {
                throw new NullReferenceException("MonacoEditor has not been set");
            }
            await monacoEditor.ResetDeltaDecorations();

            return(null);
        }
예제 #3
0
        public static async Task markTags(MonacoEditor editor, string tag,
                                          Dictionary <string, BlazorMonaco.Range> sourceDecorations)
        {
            sourceDecorations.Clear();
            TextModel sourceModel = await editor.GetModel();

            List <FindMatch> sourceMatches;
            await editor.ResetDeltaDecorations();

            List <ModelDeltaDecoration> lstDecorations = new List <ModelDeltaDecoration>();

            sourceMatches = await sourceModel.FindMatches($"<{tag}", false, false, false, null, true, 10000);

            if (sourceMatches.Count > 0)
            {
                foreach (FindMatch m in sourceMatches)
                {
                    m.Range = await Helpers.ExpandTagRange(m.Range, sourceModel);

                    lstDecorations.Add(new ModelDeltaDecoration
                    {
                        Range   = m.Range,
                        Options = new ModelDecorationOptions
                        {
                            IsWholeLine          = false,
                            ClassName            = "decorationContent",
                            GlyphMarginClassName = "decorationGlyphMargin",
                            Minimap = new ModelDecorationMinimapOptions()
                            {
                                Position = MinimapPosition.Inline, Color = "#FFFF00"
                            }                                                                                                     //#90EE90 #FFFFFE
                        }
                    });
                }
                string[] decorations = await editor.DeltaDecorations(null, lstDecorations.ToArray());

                for (int i = 0; i < sourceMatches.Count; i++)
                {
                    sourceDecorations.Add(decorations[i], sourceMatches[i].Range);
                }
                await editor.RevealRangeInCenter(sourceMatches[0].Range);
            }
        }