diff --git a/CHANGELOG.md b/CHANGELOG.md index 14397645..522b1744 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ ## Syntaxes +- Added support for `XAML` syntax, see #1590 and #1655 (@mohamed-abdelnour) + ## New themes diff --git a/assets/patches/XML.sublime-syntax.patch b/assets/patches/XML.sublime-syntax.patch new file mode 100644 index 00000000..ea68b956 --- /dev/null +++ b/assets/patches/XML.sublime-syntax.patch @@ -0,0 +1,12 @@ +diff --git syntaxes/01_Packages/XML/XML.sublime-syntax syntaxes/01_Packages/XML/XML.sublime-syntax +index ad7d9c87..af4a00f0 100644 +--- syntaxes/01_Packages/XML/XML.sublime-syntax ++++ syntaxes/01_Packages/XML/XML.sublime-syntax +@@ -12,6 +12,7 @@ file_extensions: + - rss + - opml + - svg ++ - xaml + first_line_match: |- + (?x: + ^(?: diff --git a/assets/syntaxes.bin b/assets/syntaxes.bin index cd87edd8..958b2dfb 100644 Binary files a/assets/syntaxes.bin and b/assets/syntaxes.bin differ diff --git a/tests/syntax-tests/highlighted/XAML/ItemPage.xaml b/tests/syntax-tests/highlighted/XAML/ItemPage.xaml new file mode 100644 index 00000000..ea33f0d4 --- /dev/null +++ b/tests/syntax-tests/highlighted/XAML/ItemPage.xaml @@ -0,0 +1,264 @@ + +<Page + x:Class="AppUIBasics.ItemPage" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:common="using:AppUIBasics.Common" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:data="using:AppUIBasics.Data" + xmlns:local="using:AppUIBasics" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + x:Name="pageRoot" + mc:Ignorable="d"> + +  + <Grid x:Name="rootPanel" d:DataContext="{Binding Groups[0].Items[0], Source={d:DesignData Source=/DataModel/ControlinfoData.json, Type=data:ControlInfoDataSource}}" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> + <VisualStateManager.VisualStateGroups> + <VisualStateGroup> + <VisualState> + <VisualState.StateTriggers> + <local:DeviceFamilyTrigger DeviceFamily="Windows.Xbox" /> +  + <VisualState.Setters> + <Setter Target="svPanel.Margin" Value="0,0,48,27" /> +  +  +  + <VisualStateGroup> + <VisualState x:Name="NormalFrameContent" /> + <VisualState x:Name="WideFrameContent"> + <VisualState.Setters> + <Setter Target="contentFrame.Width" Value="1028" /> + <Setter Target="contentFrame.HorizontalAlignment" Value="Left" /> +  +  +  + <VisualStateGroup x:Name="LayoutVisualStates"> + <VisualState x:Name="LargeLayout"> + <VisualState.StateTriggers> + <AdaptiveTrigger MinWindowWidth="1372" /> +  +  + <VisualState x:Name="WideLayout"> + <VisualState.StateTriggers> + <AdaptiveTrigger MinWindowWidth="{StaticResource Breakpoint640Plus}" /> +  + <VisualState.Setters> + <Setter Target="seeAlsoPanel.Width" Value="Auto" /> + <Setter Target="seeAlsoPanel.(Grid.Row)" Value="3" /> + <Setter Target="seeAlsoPanel.(Grid.Column)" Value="0" /> + <Setter Target="seeAlsoPanel.(Grid.ColumnSpan)" Value="3" /> + + <Setter Target="SourcePanel.(Grid.ColumnSpan)" Value="1" /> + + <Setter Target="DocumentationPanel.(Grid.ColumnSpan)" Value="1" /> + + <Setter Target="RelatedControlsPanel.(Grid.Row)" Value="0" /> + <Setter Target="RelatedControlsPanel.(Grid.Column)" Value="2" /> + <Setter Target="RelatedControlsPanel.(Grid.ColumnSpan)" Value="1" /> + + <Setter Target="FeedbackPanel.(Grid.Row)" Value="1" /> + <Setter Target="FeedbackPanel.(Grid.Column)" Value="2" /> + <Setter Target="FeedbackPanel.(Grid.ColumnSpan)" Value="1" /> +  +  + <VisualState x:Name="NarrowLayout"> + <VisualState.StateTriggers> + <AdaptiveTrigger MinWindowWidth="0" /> +  + <VisualState.Setters> + <Setter Target="seeAlsoPanel.Width" Value="Auto" /> + <Setter Target="seeAlsoPanel.(Grid.Row)" Value="3" /> + <Setter Target="seeAlsoPanel.(Grid.Column)" Value="0" /> + <Setter Target="seeAlsoPanel.(Grid.ColumnSpan)" Value="3" /> + + <Setter Target="SourcePanel.(Grid.ColumnSpan)" Value="1" /> + + <Setter Target="DocumentationPanel.(Grid.ColumnSpan)" Value="1" /> + + <Setter Target="RelatedControlsPanel.(Grid.Row)" Value="0" /> + <Setter Target="RelatedControlsPanel.(Grid.Column)" Value="2" /> + <Setter Target="RelatedControlsPanel.(Grid.ColumnSpan)" Value="1" /> + + <Setter Target="FeedbackPanel.(Grid.Row)" Value="1" /> + <Setter Target="FeedbackPanel.(Grid.Column)" Value="2" /> + <Setter Target="FeedbackPanel.(Grid.ColumnSpan)" Value="1" /> + + <Setter Target="rightMargin.Width" Value="0" /> + <Setter Target="contentRoot.Padding" Value="14,0" /> +  +  +  +  + +  + <ScrollViewer + x:Name="svPanel" + + VerticalScrollBarVisibility="Auto" + VerticalScrollMode="Auto"> + <Grid x:Name="contentRoot" Padding="24,0,0,0" SizeChanged="OnContentRootSizeChanged"> + <Grid.ColumnDefinitions> + <ColumnDefinition x:Name="contentColumn" /> + <ColumnDefinition x:Name="rightMargin" Width="20" /> + <ColumnDefinition x:Name="infoColumn" Width="Auto" /> +  + <Grid.RowDefinitions> + <RowDefinition Height="Auto" /> + <RowDefinition Height="*" /> + <RowDefinition Height="20" /> + <RowDefinition Height="Auto" /> +  + + <TextBlock + x:Name="descriptionText" + Style="{ThemeResource BodyTextBlockStyle}" + Grid.ColumnSpan="2" + Margin="0,5,24,0" + Text="{x:Bind Item.Description}" /> + + <Frame x:Name="contentFrame" Grid.Row="1" /> + + <Grid + x:Name="seeAlsoPanel" + Grid.Row="0" + Grid.RowSpan="2" + Grid.Column="2" + Width="280" + Margin="0,0,24,24"> + <Grid.RowDefinitions> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> +  + <Grid.ColumnDefinitions> + <ColumnDefinition /> + <ColumnDefinition Width="20" /> + <ColumnDefinition /> +  + + <StackPanel x:Name="SourcePanel" Grid.Row="0" Grid.ColumnSpan="3" Margin="0,0,0,40"> + <TextBlock + x:Name="SourceHeader" + x:Uid="SourceHeader" + Style="{ThemeResource SubtitleTextBlockStyle}" + Text="View page code on GitHub"/> + <HyperlinkButton + x:Name="PageMarkupGitHubLink" + ToolTipService.ToolTip="{x:Bind PageMarkupGitHubLink.NavigateUri, Mode=OneWay}"> + <TextBlock Text="XAML source code"/> +  + <HyperlinkButton + x:Name="PageCodeGitHubLink" + ToolTipService.ToolTip="{x:Bind PageCodeGitHubLink.NavigateUri, Mode=OneWay}" + Margin="0,12,0,0"> + <TextBlock Text="C# source code"/> +  +  + + <StackPanel x:Name="DocumentationPanel" Grid.Row="1" Grid.ColumnSpan="3" Margin="0,0,0,40"> + <TextBlock + x:Name="docHeader" + x:Uid="DocHeader" + Style="{StaticResource SubtitleTextBlockStyle}" /> + <ItemsControl + x:Name="DocsList" + Margin="0,12,0,0" + IsTabStop="False" + ItemsSource="{x:Bind Item.Docs}"> + <ItemsControl.ItemsPanel> + <ItemsPanelTemplate> + <StackPanel Orientation="Vertical" /> +  +  + <ItemsControl.ItemTemplate> + <DataTemplate x:DataType="data:ControlInfoDocLink"> + <HyperlinkButton NavigateUri="{Binding Uri}" ToolTipService.ToolTip="{Binding Uri}"> + <TextBlock Text="{x:Bind Title}" /> +  +  +  +  +  + + <StackPanel x:Name="RelatedControlsPanel" Grid.Row="2" Grid.ColumnSpan="3" Margin="0,0,0,40"> + <TextBlock + x:Name="relatedControlsHeader" + x:Uid="RelatedControlsHeader" + Style="{StaticResource SubtitleTextBlockStyle}" /> + + <ItemsControl + x:Name="relatedItemsControl" + Margin="0,12,0,0" + IsTabStop="False" + ItemsSource="{x:Bind Item.RelatedControls}"> + <ItemsControl.ItemsPanel> + <ItemsPanelTemplate> + <StackPanel Orientation="Vertical" /> +  +  + <ItemsControl.ItemTemplate> + <DataTemplate x:DataType="x:String"> +  + <HyperlinkButton AutomationProperties.Name="{x:Bind}" Click="OnRelatedControlClick"> + <RelativePanel> +  + <Image + AutomationProperties.AccessibilityView="Raw" + x:Name="iconImage" + Width="25" + Margin="0,0,15,0" + common:ImageLoader.Source="{Binding}" /> + <TextBlock + AutomationProperties.AccessibilityView="Raw" + Foreground="{ThemeResource HyperlinkButtonForeground}" + RelativePanel.RightOf="iconImage" + Text="{x:Bind}" + TextWrapping="Wrap" /> +  +  +  +  +  +  + + <StackPanel x:Name="FeedbackPanel" Grid.Row="3" Grid.ColumnSpan="3"> + <TextBlock + x:Name="feedbackHeader" + x:Uid="FeedbackHeader" + Style="{StaticResource SubtitleTextBlockStyle}" /> + <HyperlinkButton NavigateUri="https://github.com/microsoft/Xaml-Controls-Gallery/issues/new/choose"  + ToolTipService.ToolTip="https://github.com/microsoft/Xaml-Controls-Gallery/issues/new/choose"> + <TextBlock x:Uid="FeedbackLink" /> +  +  +  +  +  +  + diff --git a/tests/syntax-tests/source/XAML/ItemPage.xaml b/tests/syntax-tests/source/XAML/ItemPage.xaml new file mode 100644 index 00000000..365afcdf --- /dev/null +++ b/tests/syntax-tests/source/XAML/ItemPage.xaml @@ -0,0 +1,264 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/syntax-tests/source/XAML/LICENSE.md b/tests/syntax-tests/source/XAML/LICENSE.md new file mode 100644 index 00000000..3e60997c --- /dev/null +++ b/tests/syntax-tests/source/XAML/LICENSE.md @@ -0,0 +1,23 @@ +The `ItemPage.xaml` file has been added from https://github.com/microsoft/Xaml-Controls-Gallery under the following license: + + MIT License + + Copyright (c) Microsoft Corporation. All rights reserved. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE