Skip to content

Commit

Permalink
Merge pull request #106 from gaelj/release
Browse files Browse the repository at this point in the history
Release 0.3.7
  • Loading branch information
gaelj authored Feb 8, 2024
2 parents 4b47469 + c645f2f commit 28d4ee6
Show file tree
Hide file tree
Showing 30 changed files with 182 additions and 127 deletions.
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
# Changelog

## 0.3.7 - 2024-02-08

### ✨ Introduce new features

- Implement optional persist / restore of document to local storage

### 🎨 Improve structure / format of the code

- Finish removing Id parameter

### 🐛 Fix a bug

- Automatically load inline component css
- Fix browser refresh script url in example

### 📝 Add or update documentation

- Cleanup comments

### 🔊 Add or update logs

- Make all js loggings optional

### 🥅 Catch errors

- Catch js disconnected exceptions

## 0.3.6 - 2024-02-08

### 🐛 Fix a bug
Expand Down
2 changes: 1 addition & 1 deletion CodeMirror6/CodeMirror6.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AssemblyName>GaelJ.BlazorCodeMirror6</AssemblyName>
<IsPackable>true</IsPackable>
<PackageId>GaelJ.BlazorCodeMirror6</PackageId>
<Version>0.3.6</Version>
<Version>0.3.7</Version>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down
1 change: 1 addition & 0 deletions CodeMirror6/CodeMirror6Wrapper.razor
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
HighlightWhitespace="@HighlightWhitespace"
HighlightTrailingWhitespace="@HighlightTrailingWhitespace"
Visible="@Visible"
LocalStorageKey="@LocalStorageKey"
/>
</ChildContent>
<ErrorContent Context="c">
Expand Down
38 changes: 4 additions & 34 deletions CodeMirror6/CodeMirror6Wrapper.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,76 +12,57 @@ namespace GaelJ.BlazorCodeMirror6;
/// </summary>
public partial class CodeMirror6Wrapper : ComponentBase
{
/// <summary>
/// /// Gets or sets the unique identifier for the CodeMirror6 editor.
/// Defaults to CodeMirror6_Editor_{NewGuid}.
/// </summary>
/// <value></value>
[Parameter] public string Id { get; set; } = $"CodeMirror6_Editor_{Guid.NewGuid()}";
/// <summary>
/// The size of the tab character to use for the editor
/// </summary>
/// <value></value>
[Parameter] public int TabSize { get; set; } = 2;
/// <summary>
/// The number of spaces to use for indentation
/// </summary>
/// <value></value>
[Parameter] public int IndentationUnit { get; set; } = 2;
/// <summary>
/// The document contents
/// </summary>
/// <value></value>
[Parameter] public string? Doc { get; set; }
/// <summary>
/// The document contents has changed
/// </summary>
/// <value></value>
[Parameter] public EventCallback<string?> DocChanged { get; set; }
/// <summary>
/// The placeholder text to display in an empty editor
/// </summary>
/// <value></value>
[Parameter] public string? Placeholder { get; set; }
/// <summary>
/// The document focus has changed
/// </summary>
/// <value></value>
[Parameter] public EventCallback<bool> FocusChanged { get; set; }
/// <summary>
/// Set the cursor position or selections
/// </summary>
/// <value></value>
[Parameter] public List<SelectionRange>? Selection { get; set; }
/// <summary>
/// The cursor position or selections have changed
/// </summary>
/// <value></value>
[Parameter] public EventCallback<List<SelectionRange>?> SelectionChanged { get; set; }
/// <summary>
/// The theme to use for the editor
/// </summary>
/// <value></value>
[Parameter] public ThemeMirrorTheme? Theme { get; set; }
/// <summary>
/// Determine whether editing functionality should apply.
/// </summary>
/// <value></value>
[Parameter] public bool ReadOnly { get; set; }
/// <summary>
/// Controls whether the editor content DOM is editable
/// </summary>
/// <value></value>
[Parameter] public bool Editable { get; set; } = true;
/// <summary>
/// Controls whether long lines should wrap
/// </summary>
/// <value></value>
[Parameter] public bool LineWrapping { get; set; } = true;
/// <summary>
/// The language to use in the editor
/// </summary>
/// <value></value>
[Parameter] public CodeMirrorLanguage? Language { get; set; } = CodeMirrorLanguage.Markdown;
/// <summary>
/// Define a file name or file extension to be used for automatic language detection / syntax highlighting
Expand All @@ -90,22 +71,18 @@ public partial class CodeMirror6Wrapper : ComponentBase
/// <summary>
/// Automatically format (resize) markdown headers
/// </summary>
/// <value></value>
[Parameter] public bool AutoFormatMarkdown { get; set; }
/// <summary>
/// Content to be rendered before the editor
/// </summary>
/// <value></value>
[Parameter] public RenderFragment<(CMCommandDispatcher Commands, CodeMirrorConfiguration Config, CodeMirrorState State)>? ContentBefore { get; set; }
/// <summary>
/// Content to be rendered after the editor
/// </summary>
/// <value></value>
[Parameter] public RenderFragment<(CMCommandDispatcher Commands, CodeMirrorConfiguration Config, CodeMirrorState State)>? ContentAfter { get; set; }
/// <summary>
/// The active markdown styles at the current selection(s)
/// </summary>
/// <value></value>
[Parameter] public EventCallback<ReadOnlyCollection<string>> MarkdownStylesAtSelectionsChanged { get; set; }
/// <summary>
/// Whether to allow vertical resizing similar to a textarea
Expand All @@ -114,32 +91,26 @@ public partial class CodeMirror6Wrapper : ComponentBase
/// <summary>
/// Whether to allow horizontal resizing similar to a textarea
/// </summary>
/// <value></value>
[Parameter] public bool AllowHorizontalResize { get; set; }
/// <summary>
/// Find any errors in the document
/// </summary>
/// <value></value>
[Parameter] public Func<string, CancellationToken, Task<List<CodeMirrorDiagnostic>>>? LintDocument { get; set; }
/// <summary>
/// The CodeMirror setup
/// </summary>
/// <value></value>
[Parameter] public CodeMirrorSetup Setup { get; set; } = new();
/// <summary>
/// Whether to replace :emoji_codes: with emoji
/// </summary>
/// <value></value>
[Parameter] public bool ReplaceEmojiCodes { get; set; } = false;
/// <summary>
/// Get all users available for &#64;user mention completions
/// </summary>
/// <value></value>
[Parameter] public Func<Task<List<CodeMirrorCompletion>>>? GetMentionCompletions { get; set; }
/// <summary>
/// Upload a file to a server and return the URL to the file
/// </summary>
/// <value></value>
[Parameter] public Func<IFormFile, Task<string>>? UploadFile { get; set; }
/// <summary>
/// Upload an IBrowserFile to a server and returns the URL to the file
Expand All @@ -152,27 +123,26 @@ public partial class CodeMirror6Wrapper : ComponentBase
/// <summary>
/// The unified merge view configuration
/// </summary>
/// <value></value>
[Parameter] public UnifiedMergeConfig? MergeViewConfiguration { get; set; }
/// <summary>
/// Whether to allow horizontal resizing similar to a textarea
/// </summary>
/// <value></value>
[Parameter] public bool HighlightTrailingWhitespace { get; set; }
/// <summary>
/// Whether to allow horizontal resizing similar to a textarea
/// </summary>
/// <value></value>
[Parameter] public bool HighlightWhitespace { get; set; }
/// <summary>
/// Whether the editor is visible
/// </summary>
/// <value></value>
[Parameter] public bool Visible { get; set; } = true;
/// <summary>
/// Optional local storage key to use for saving the document
/// </summary>
[Parameter] public string? LocalStorageKey { get; set; }
/// <summary>
/// Additional attributes to be applied to the container element
/// </summary>
/// <value></value>
[Parameter(CaptureUnmatchedValues = true)] public Dictionary<string, object>? AdditionalAttributes { get; set; }

/// <summary>
Expand Down
4 changes: 4 additions & 0 deletions CodeMirror6/CodeMirror6WrapperInternal.razor.JsInterop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ internal async Task ModuleInvokeVoidAsync(string method, params object?[] args)
args = args.Prepend(cm6WrapperComponent.Setup.Id).ToArray();
await module.InvokeVoidAsync(method, args);
}
catch (JSDisconnectedException) {}
catch (Exception ex)
{
#if NET8_0_OR_GREATER
Expand All @@ -64,6 +65,9 @@ internal async Task ModuleInvokeVoidAsync(string method, params object?[] args)
args = args.Prepend(cm6WrapperComponent.Setup.Id).ToArray();
return await module.InvokeAsync<T?>(method, args);
}
catch (JSDisconnectedException) {
return default;
}
catch (Exception ex)
{
#if NET8_0_OR_GREATER
Expand Down
Loading

0 comments on commit 28d4ee6

Please sign in to comment.