1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-02 12:47:41 +02:00

Chore: Fixes #9001: Fix error logged to console when a partial link is partially selected in Beta Editor (#9002)

This commit is contained in:
Henry Heino 2023-10-05 02:55:24 -07:00 committed by GitHub
parent feb95451fd
commit 992807eb8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 1 deletions

View File

@ -505,6 +505,7 @@ packages/editor/CodeMirror/editorCommands/editorCommands.js
packages/editor/CodeMirror/editorCommands/supportsCommand.js
packages/editor/CodeMirror/editorCommands/swapLine.js
packages/editor/CodeMirror/getScrollFraction.js
packages/editor/CodeMirror/markdown/computeSelectionFormatting.test.js
packages/editor/CodeMirror/markdown/computeSelectionFormatting.js
packages/editor/CodeMirror/markdown/decoratorExtension.js
packages/editor/CodeMirror/markdown/markdownCommands.bulletedVsChecklist.test.js

1
.gitignore vendored
View File

@ -491,6 +491,7 @@ packages/editor/CodeMirror/editorCommands/editorCommands.js
packages/editor/CodeMirror/editorCommands/supportsCommand.js
packages/editor/CodeMirror/editorCommands/swapLine.js
packages/editor/CodeMirror/getScrollFraction.js
packages/editor/CodeMirror/markdown/computeSelectionFormatting.test.js
packages/editor/CodeMirror/markdown/computeSelectionFormatting.js
packages/editor/CodeMirror/markdown/decoratorExtension.js
packages/editor/CodeMirror/markdown/markdownCommands.bulletedVsChecklist.test.js

View File

@ -0,0 +1,21 @@
import { EditorSelection } from '@codemirror/state';
import createTestEditor from '../testUtil/createTestEditor';
import computeSelectionFormatting from './computeSelectionFormatting';
describe('computeSelectionFormatting', () => {
// The below tests rely on CodeMirror to correctly parse the document, which
// can be buggy (and fail very rarely).
jest.retryTimes(2);
it('should correctly compute formatting for partial links', async () => {
// Start with the selection midway through the link
const editor = await createTestEditor('A [partial link]', EditorSelection.cursor(4), ['Link']);
const formatting = computeSelectionFormatting(editor.state, false);
expect(formatting.linkData).toMatchObject({
linkText: null,
linkURL: null,
});
});
});

View File

@ -20,7 +20,10 @@ const computeSelectionFormatting = (state: EditorState, globalSpellcheck: boolea
};
}
return null;
return {
linkText: null,
linkURL: null,
};
};
// Find nodes that overlap/are within the selected region