Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.7.4 #157

Merged
merged 6 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 0.7.4 - 2024-03-01

### ✨ Introduce new features

- Support multiple cursors for (shift +) home & end keys

### πŸ› Fix a bug

- Fix error when parsing TSV line with empty cell(s) at the end of the last row

## 0.7.3 - 2024-02-27

### πŸ› 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.7.3</Version>
<Version>0.7.4</Version>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down
2 changes: 1 addition & 1 deletion CodeMirror6/NodeLib/src/CmColumns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ function findMaxColumnWidths(data: string[][]): number[] {
}

function parseCSV(csvData: string, separator: string): string[][] {
return csvData.trim().split('\n').map((row) => extractAllRowCells(row, separator))
return csvData.split('\n').filter(row => row).map((row) => extractAllRowCells(row, separator))
}

export function csvToMarkdownTable(text: string, separator: string, withHeaders: boolean)
Expand Down
38 changes: 35 additions & 3 deletions CodeMirror6/NodeLib/src/CmKeymap.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { toggleMarkdownBold, toggleMarkdownItalic } from "./CmCommands"
import { KeyBinding, EditorView } from '@codemirror/view'
import { Extension, RangeSetBuilder, Transaction, EditorSelection, SelectionRange, Text } from "@codemirror/state"
import { EditorSelection, SelectionRange, Text } from "@codemirror/state"
import {
deleteCharBackward, deleteCharForward, deleteGroupBackward, deleteGroupForward,
cursorGroupLeft, cursorGroupRight, selectGroupLeft, selectGroupRight,
Expand All @@ -12,14 +12,14 @@ export const customMarkdownKeymap: KeyBinding[] = [
{ key: 'Mod-i', run: toggleMarkdownItalic }, // Cmd/Ctrl + I for italics
]

export const customDeleteKeymap = [
export const multipleCursorDeleteKeymap = [
{ key: "Delete", run: deleteCharForward },
{ key: "Backspace", run: deleteCharBackward },
{ key: "Mod-Delete", run: deleteGroupForward },
{ key: "Mod-Backspace", run: deleteGroupBackward },
]

export const customArrowKeymap: KeyBinding[] = [
export const multipleCursorNavigationKeymap: KeyBinding[] = [
{
key: "ArrowLeft",
run: (view) => moveCursorsByCharacter(view, true, false),
Expand All @@ -40,6 +40,16 @@ export const customArrowKeymap: KeyBinding[] = [
run: (view) => moveCursorsByWord(view, false, false),
shift: (view) => moveCursorsByWord(view, false, true),
},
{
key: "Home",
run: (view) => moveCursorsToLineBoundaries(view, true, false),
shift: (view) => moveCursorsToLineBoundaries(view, true, true),
},
{
key: "End",
run: (view) => moveCursorsToLineBoundaries(view, false, false),
shift: (view) => moveCursorsToLineBoundaries(view, false, true),
},
]

function moveCursorsByCharacter(view: EditorView, previous: boolean, headOnly: boolean) {
Expand Down Expand Up @@ -80,6 +90,28 @@ function moveCursorsByWord(view: EditorView, previous: boolean, headOnly: boolea
return true
}

function moveCursorsToLineBoundaries(view: EditorView, start: boolean, headOnly: boolean): boolean {
const { state } = view
const newSelectionRanges: SelectionRange[] = []
for (const range of state.selection.ranges) {
const currentPos = range.head
const startOfLine = state.doc.lineAt(currentPos).from
const endOfLine = state.doc.lineAt(currentPos).to
const lineBoundary = start ? startOfLine : endOfLine

const newAnchor = headOnly ? range.anchor : lineBoundary
const newHead = !headOnly ? newAnchor : lineBoundary

newSelectionRanges.push(EditorSelection.range(newAnchor, newHead))
}
view.dispatch(state.update({
selection: EditorSelection.create(newSelectionRanges),
scrollIntoView: true,
userEvent: 'input'
}))
return true
}

function findWordBoundary(doc: Text, pos: number, previous: boolean, firstRun: boolean): number {
if (previous && pos === 0) return 0
if (!previous && pos === doc.length) return doc.length
Expand Down
4 changes: 1 addition & 3 deletions CodeMirror6/NodeLib/src/CmMentionsCompletion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ function getMentionCompletions(firstCharacters: string | null): Completion[] {

export function setCachedCompletions(completions: Completion[]) {
if (cachedCompletions.length === 0) {
completions.forEach(completion => {
cachedCompletions.push(completion)
})
cachedCompletions.push(...completions)
}
}

Expand Down
6 changes: 3 additions & 3 deletions CodeMirror6/NodeLib/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ import { getColumnStylingKeymap, columnStylingPlugin, columnLintSource, getSepar
import { consoleLog } from "./CmLogging"
import { createEditorWithId } from "./CmId"
import { hyperLink } from './CmHyperlink'
import { customArrowKeymap, customDeleteKeymap } from "./CmKeymap"
import { multipleCursorNavigationKeymap, multipleCursorDeleteKeymap } from "./CmKeymap"

export { getCmInstance }

Expand Down Expand Up @@ -180,8 +180,8 @@ export async function initCodeMirror(
...foldKeymap,
...completionKeymap,
...lintKeymap,
...customDeleteKeymap,
...customArrowKeymap,
...multipleCursorDeleteKeymap,
...multipleCursorNavigationKeymap,
])
]

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.3</Version>
<Version>0.7.4</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.3</Version>
<Version>0.7.4</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.3</Version>
<Version>0.7.4</Version>
</PropertyGroup>
<ItemGroup>
<SupportedPlatform Include="browser-wasm" />
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.3</Version>
<Version>0.7.4</Version>
</PropertyGroup>
<ItemGroup>
<SupportedPlatform Include="browser" />
Expand Down
9 changes: 4 additions & 5 deletions NEW_CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
### πŸ› Fix a bug
### ✨ Introduce new features

- Fix possible null ref on startup
- Replace \r\n with \n when pasting, to prevent crash in windows (#153)
- Support multiple cursors for (shift +) home & end keys

### πŸ—‘οΈ Deprecate code that needs to be cleaned up
### πŸ› Fix a bug

- Remove useless exports (#144)
- Fix error when parsing TSV line with empty cell(s) at the end of the last row
Loading