diff --git a/CHANGELOG.md b/CHANGELOG.md
index 54daa92..802f760 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,15 @@
# Changelog
+## 0.8.2 - 2024-03-04
+
+### ✨ Introduce new features
+
+- Add setup property FocusOnCreation
+
+### 🐛 Fix a bug
+
+- Force scroll to start of document if not scrolling to end, on creation
+
## 0.8.1 - 2024-03-04
### ⚡️ Improve performance
diff --git a/CodeMirror6/CodeMirror6.csproj b/CodeMirror6/CodeMirror6.csproj
index acfde7f..d88cc6d 100644
--- a/CodeMirror6/CodeMirror6.csproj
+++ b/CodeMirror6/CodeMirror6.csproj
@@ -9,7 +9,7 @@
GaelJ.BlazorCodeMirror6
true
GaelJ.BlazorCodeMirror6
- 0.8.1
+ 0.8.2
true
snupkg
true
diff --git a/CodeMirror6/Models/CodeMirrorSetup.cs b/CodeMirror6/Models/CodeMirrorSetup.cs
index 3babaf0..2e4a700 100644
--- a/CodeMirror6/Models/CodeMirrorSetup.cs
+++ b/CodeMirror6/Models/CodeMirrorSetup.cs
@@ -109,5 +109,10 @@ public CodeMirrorSetup()
///
/// Whether to show the debug logs
///
- [JsonPropertyName("debugLogs")] public bool DebugLogs { get; init; } = false;
+ [JsonPropertyName("debugLogs")] public bool DebugLogs { get; init; }
+
+ ///
+ /// Whether to focus on the editor when it is created
+ ///
+ [JsonPropertyName("focusOnCreation")] public bool FocusOnCreation { get; init; }
}
diff --git a/CodeMirror6/NodeLib/src/CmSetup.ts b/CodeMirror6/NodeLib/src/CmSetup.ts
index 63305fe..9349bc7 100644
--- a/CodeMirror6/NodeLib/src/CmSetup.ts
+++ b/CodeMirror6/NodeLib/src/CmSetup.ts
@@ -22,4 +22,5 @@ export class CmSetup
public bindValueMode: string
public krokiUrl: string
public debugLogs: boolean
+ public focusOnCreation: boolean
}
diff --git a/CodeMirror6/NodeLib/src/index.ts b/CodeMirror6/NodeLib/src/index.ts
index 8ebdc77..c72faa6 100644
--- a/CodeMirror6/NodeLib/src/index.ts
+++ b/CodeMirror6/NodeLib/src/index.ts
@@ -199,7 +199,13 @@ export async function initCodeMirror(
const textInLocalStorage = localStorage.getItem(initialConfig.localStorageKey)
const initialDoc = textInLocalStorage ? textInLocalStorage : initialConfig.doc
- const initialScrollEffect = EditorView.scrollIntoView((initialDoc && setup.scrollToEnd === true) ? initialDoc.length : 0, { y: setup.scrollToEnd === true ? 'end' : 'start' })
+ const initialScrollPosition = (initialDoc && setup.scrollToEnd === true)
+ ? initialDoc.length
+ : 0
+ const initialScrollEffect = EditorView.scrollIntoView(
+ initialScrollPosition,
+ { y: setup.scrollToEnd === true ? 'end' : 'start' }
+ )
const docLines = initialDoc?.split(/\r\n|\r|\n/) ?? [initialDoc]
const text = Text.of(docLines)
const textLength = text?.length ?? 0
@@ -215,10 +221,10 @@ export async function initCodeMirror(
CMInstances[id].view = new EditorView({
state: CMInstances[id].state,
parent: parentDiv,
- scrollTo: setup.scrollToEnd === true ? initialScrollEffect : null,
+ scrollTo: initialScrollEffect,
})
- if (setup.scrollToEnd === true) {
+ if (setup.focusOnCreation === true) {
CMInstances[id].view.focus()
}
diff --git a/Examples.BlazorServer/Examples.BlazorServer.csproj b/Examples.BlazorServer/Examples.BlazorServer.csproj
index 490d9ac..7105573 100644
--- a/Examples.BlazorServer/Examples.BlazorServer.csproj
+++ b/Examples.BlazorServer/Examples.BlazorServer.csproj
@@ -4,7 +4,7 @@
enable
false
enable
- 0.8.1
+ 0.8.2
diff --git a/Examples.BlazorServerInteractive/Examples.BlazorServerInteractive.csproj b/Examples.BlazorServerInteractive/Examples.BlazorServerInteractive.csproj
index 47a5e17..3a6603c 100644
--- a/Examples.BlazorServerInteractive/Examples.BlazorServerInteractive.csproj
+++ b/Examples.BlazorServerInteractive/Examples.BlazorServerInteractive.csproj
@@ -4,7 +4,7 @@
enable
enable
false
- 0.8.1
+ 0.8.2
diff --git a/Examples.BlazorWasm/Examples.BlazorWasm.csproj b/Examples.BlazorWasm/Examples.BlazorWasm.csproj
index fcf8257..9e742c8 100644
--- a/Examples.BlazorWasm/Examples.BlazorWasm.csproj
+++ b/Examples.BlazorWasm/Examples.BlazorWasm.csproj
@@ -4,7 +4,7 @@
enable
enable
false
- 0.8.1
+ 0.8.2
diff --git a/Examples.Common/Examples.Common.csproj b/Examples.Common/Examples.Common.csproj
index e968d27..5c8144f 100644
--- a/Examples.Common/Examples.Common.csproj
+++ b/Examples.Common/Examples.Common.csproj
@@ -5,7 +5,7 @@
enable
enable
false
- 0.8.1
+ 0.8.2
diff --git a/NEW_CHANGELOG.md b/NEW_CHANGELOG.md
index 359943f..63ced49 100644
--- a/NEW_CHANGELOG.md
+++ b/NEW_CHANGELOG.md
@@ -1,7 +1,7 @@
-### ⚡️ Improve performance
+### ✨ Introduce new features
-- Add a cancellation token to help remove errors in Blazor Server with pre-rendering
+- Add setup property FocusOnCreation
-### 🚚 Move or rename resources (e.g., files, paths)
+### 🐛 Fix a bug
-- Move code blocks for consistency
+- Force scroll to start of document if not scrolling to end, on creation