コード例 #1
0
ファイル: Helpers.cs プロジェクト: GilShalit/XmlPlanter
        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);
            }
        }