Skip to content

Commit

Permalink
Merge pull request #163 from gaelj/release
Browse files Browse the repository at this point in the history
Release 0.8.0
  • Loading branch information
gaelj authored Mar 3, 2024
2 parents 1cc3763 + 05f7e41 commit f1a252e
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 21 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 0.8.0 - 2024-03-03

### ✨ Introduce new features

- Add a command to force linter update (#121)

## 0.7.5 - 2024-03-03

### 🎨 Improve structure / format of the code
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.7.5</Version>
<Version>0.8.0</Version>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down
4 changes: 4 additions & 0 deletions CodeMirror6/Models/CodeMirrorSimpleCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,8 @@ public enum CodeMirrorSimpleCommand
/// Delete the trailing whitespace
/// </summary>
DeleteTrailingWhitespace,
/// <summary>
/// Refresh the linter
/// </summary>
RequestLinterRefresh,
}
1 change: 1 addition & 0 deletions CodeMirror6/NodeLib/src/CmInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export class CmInstance
public view: EditorView
public setup: CmSetup
public config: CmConfiguration
public lintRefreshRequested: boolean = false
public languageCompartment: Compartment = new Compartment
public markdownStylingCompartment: Compartment = new Compartment
public tabSizeCompartment: Compartment = new Compartment
Expand Down
21 changes: 18 additions & 3 deletions CodeMirror6/NodeLib/src/CmLint.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { Diagnostic } from "@codemirror/lint"
import { ViewUpdate } from "@codemirror/view"
import { DotNet } from "@microsoft/dotnet-js-interop"
import { EditorView } from "codemirror"

import { consoleLog } from "./CmLogging"
import { CMInstances } from './CmInstance'

/**
* A function that fetches diagnostics from the Blazor component.
* Fetch diagnostics from the Blazor component
*/
export async function externalLintSource(id: string, view: EditorView, dotnetHelper: DotNet.DotNetObject): Promise<readonly Diagnostic[]> {
try {
Expand All @@ -19,10 +22,18 @@ export async function externalLintSource(id: string, view: EditorView, dotnetHel
}
}

/**
* Request a linter refresh. Linting is always re-done on document changes.
*/
export function requestLinterRefresh(id: string) {
consoleLog(id, `Linter refresh requested for Id ${id}`)
CMInstances[id].lintRefreshRequested = true
}

/**
* A function that fetches the linter configuration
*/
export function getExternalLinterConfig(): any {
export function getExternalLinterConfig(id: string): any {
return {
/**
Time to wait (in milliseconds) after a change before running
Expand All @@ -34,7 +45,11 @@ export function getExternalLinterConfig(): any {
need to be recomputed. Linting is always re-done on document
changes.
*/
needsRefresh: null,
needsRefresh: (update: ViewUpdate) => {
const lintRefreshRequested = CMInstances[id].lintRefreshRequested
CMInstances[id].lintRefreshRequested = false
return lintRefreshRequested
},
/**
Optional filter to determine which diagnostics produce markers
in the content.
Expand Down
7 changes: 5 additions & 2 deletions CodeMirror6/NodeLib/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import {
cut, copy, paste,
} from "./CmCommands"
import { dynamicImagesExtension } from "./CmImages"
import { externalLintSource, getExternalLinterConfig } from "./CmLint"
import { externalLintSource, getExternalLinterConfig, requestLinterRefresh } from "./CmLint"
import { CmSetup } from "./CmSetup"
import { replaceEmojiExtension, lastOperationWasUndo } from "./CmEmojiReplace"
import { blockquote } from "./CmBlockquote"
Expand All @@ -61,6 +61,7 @@ import { createEditorWithId } from "./CmId"
import { hyperLink } from './CmHyperlink'

export { getCmInstance }
export { requestLinterRefresh }

/**
* Initialize a new CodeMirror instance
Expand Down Expand Up @@ -167,7 +168,7 @@ export async function initCodeMirror(
if (setup.highlightSelectionMatches === true) extensions.push(highlightSelectionMatches())
if (setup.allowMultipleSelections === true) extensions.push(EditorState.allowMultipleSelections.of(true))
if (initialConfig.lintingEnabled === true || setup.bindValueMode == "OnDelayedInput") {
extensions.push(linter(async view => await externalLintSource(id, view, dotnetHelper), getExternalLinterConfig()))
extensions.push(linter(async view => await externalLintSource(id, view, dotnetHelper), getExternalLinterConfig(id)))
}
if (initialConfig.lintingEnabled === true)
extensions.push(lintGutter())
Expand Down Expand Up @@ -534,6 +535,8 @@ export function dispatchCommand(id: string, functionName: string, ...args: any[]
case 'ClearLocalStorage': clearLocalStorage(id); break;
case 'ScrollIntoView': view.dispatch({ scrollIntoView: true }); break;

case 'RequestLinterRefresh': requestLinterRefresh(id); break;

default: throw new Error(`Function ${functionName} does not exist.`);
}
view.focus()
Expand Down
2 changes: 1 addition & 1 deletion Examples.BlazorServer/Examples.BlazorServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>0.7.5</Version>
<Version>0.8.0</Version>
</PropertyGroup>
<ItemGroup>
<SupportedPlatform Include="browser" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
<Version>0.7.5</Version>
<Version>0.8.0</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Sentry.AspNetCore" Version="4.1.0" />
Expand Down
2 changes: 1 addition & 1 deletion Examples.BlazorWasm/Examples.BlazorWasm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
<Version>0.7.5</Version>
<Version>0.8.0</Version>
</PropertyGroup>
<ItemGroup>
<SupportedPlatform Include="browser-wasm" />
Expand Down
7 changes: 7 additions & 0 deletions Examples.Common/Example.razor
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@
})
>Scroll into view</button>

<button class="btn btn-primary"
@onclick=@(async () => {
if (codeMirror6WrapperRef.CommandDispatcher is not null)
await codeMirror6WrapperRef.CommandDispatcher.Dispatch(CodeMirrorSimpleCommand.RequestLinterRefresh);
})
>Refresh linter</button>

<CodeMirror6Wrapper
@ref=@codeMirror6WrapperRef
IsWASM=@IsWASM
Expand Down
2 changes: 1 addition & 1 deletion Examples.Common/Examples.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<Version>0.7.5</Version>
<Version>0.8.0</Version>
</PropertyGroup>
<ItemGroup>
<SupportedPlatform Include="browser" />
Expand Down
13 changes: 2 additions & 11 deletions NEW_CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
### 🎨 Improve structure / format of the code
### ✨ Introduce new features

- Minor cleanup
- Use integrated support for multiple cursors

### ⬆️ Upgrade dependencies

- Update js dependencies

### 🚨 Fix compiler / linter warnings

- Fix warning in example project Upload endpoint
- Add a command to force linter update (#121)

0 comments on commit f1a252e

Please sign in to comment.