@bangle.dev/base-components
Advanced tools
Comparing version 0.28.1 to 0.28.3
@@ -6,3 +6,8 @@ /** | ||
/** @jsx psx */ | ||
import { psx, sendKeyToPm, setSelectionNear } from '@bangle.dev/test-helpers'; | ||
import { | ||
psx, | ||
sendKeyToPm, | ||
setSelectionNear, | ||
typeText, | ||
} from '@bangle.dev/test-helpers'; | ||
import { italic } from '../index'; | ||
@@ -64,1 +69,60 @@ import { defaultTestEditor } from './test-editor'; | ||
}); | ||
describe('markdown shortcuts', () => { | ||
const testEditor = defaultTestEditor(); | ||
test('_ shortcut', async () => { | ||
const { editorView } = testEditor( | ||
<doc> | ||
<para>first</para> | ||
<para>[]</para> | ||
</doc>, | ||
); | ||
typeText(editorView, '_magic_'); | ||
expect(editorView.state).toEqualDocAndSelection( | ||
<doc> | ||
<para>first</para> | ||
<para> | ||
<italic>magic</italic> | ||
</para> | ||
</doc>, | ||
); | ||
}); | ||
test('_ shortcut after a word', async () => { | ||
const { editorView } = testEditor( | ||
<doc> | ||
<para>first</para> | ||
<para>hey there []</para> | ||
</doc>, | ||
); | ||
typeText(editorView, '_sweety_'); | ||
expect(editorView.state).toEqualDocAndSelection( | ||
<doc> | ||
<para>first</para> | ||
<para> | ||
hey there <italic>sweety</italic> | ||
</para> | ||
</doc>, | ||
); | ||
}); | ||
test('_ shortcut while inside a word', async () => { | ||
const { editorView } = testEditor( | ||
<doc> | ||
<para>first</para> | ||
<para>hey there[]</para> | ||
</doc>, | ||
); | ||
typeText(editorView, '_omg_'); | ||
expect(editorView.state).toEqualDocAndSelection( | ||
<doc> | ||
<para>first</para> | ||
<para>hey there_omg_</para> | ||
</doc>, | ||
); | ||
}); | ||
}); |
@@ -76,5 +76,9 @@ import type { RawPlugins, RawSpecs } from '@bangle.dev/core'; | ||
markdownShortcut && | ||
markPasteRule(/(?:\*\*|__)([^*_]+)(?:\*\*|__)/g, type), | ||
markPasteRule(/(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))/g, type), | ||
markdownShortcut && | ||
markInputRule(/(?:\*\*|__)([^*_]+)(?:\*\*|__)$/, type), | ||
markPasteRule(/(?:^|\s)((?:__)((?:[^__]+))(?:__))/g, type), | ||
markdownShortcut && | ||
markInputRule(/(?:^|\s)((?:__)((?:[^__]+))(?:__))$/, type), | ||
markdownShortcut && | ||
markInputRule(/(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))$/, type), | ||
keybindings && | ||
@@ -81,0 +85,0 @@ keymap(createObject([[keybindings.toggleBold, toggleBold()]])), |
@@ -53,5 +53,9 @@ import { keymap, toggleMark, } from '@bangle.dev/pm'; | ||
markdownShortcut && | ||
markPasteRule(/(?:\*\*|__)([^*_]+)(?:\*\*|__)/g, type), | ||
markPasteRule(/(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))/g, type), | ||
markdownShortcut && | ||
markInputRule(/(?:\*\*|__)([^*_]+)(?:\*\*|__)$/, type), | ||
markPasteRule(/(?:^|\s)((?:__)((?:[^__]+))(?:__))/g, type), | ||
markdownShortcut && | ||
markInputRule(/(?:^|\s)((?:__)((?:[^__]+))(?:__))$/, type), | ||
markdownShortcut && | ||
markInputRule(/(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))$/, type), | ||
keybindings && | ||
@@ -58,0 +62,0 @@ keymap(createObject([[keybindings.toggleBold, toggleBold()]])), |
@@ -41,4 +41,4 @@ import { keymap, toggleMark, } from '@bangle.dev/pm'; | ||
markPasteRule(/\*([^*]+)\*/g, type), | ||
markInputRule(/(?:^|[^_])(_([^_]+)_)$/, type), | ||
markInputRule(/(?:^|[^*])(\*([^*]+)\*)$/, type), | ||
markInputRule(/(?:^|\s)((?:_)((?:[^_]+))(?:_))$/, type), | ||
markInputRule(/(?:^|\s)((?:\*)((?:[^*]+))(?:\*))$/, type), | ||
keybindings && | ||
@@ -45,0 +45,0 @@ keymap(createObject([[keybindings.toggleItalic, toggleMark(type)]])), |
@@ -53,4 +53,4 @@ import { keymap, toggleMark, } from '@bangle.dev/pm'; | ||
return [ | ||
markPasteRule(/~([^~]+)~/g, type), | ||
markInputRule(/~([^~]+)~$/, type), | ||
markPasteRule(/(?:^|\s)((?:~~)((?:[^~]+))(?:~~))/g, type), | ||
markInputRule(/(?:^|\s)((?:~~)((?:[^~]+))(?:~~))$/, type), | ||
keybindings && | ||
@@ -57,0 +57,0 @@ keymap(createObject([[keybindings.toggleStrike, toggleMark(type)]])), |
@@ -59,4 +59,4 @@ import type { RawPlugins, RawSpecs } from '@bangle.dev/core'; | ||
markPasteRule(/\*([^*]+)\*/g, type), | ||
markInputRule(/(?:^|[^_])(_([^_]+)_)$/, type), | ||
markInputRule(/(?:^|[^*])(\*([^*]+)\*)$/, type), | ||
markInputRule(/(?:^|\s)((?:_)((?:[^_]+))(?:_))$/, type), | ||
markInputRule(/(?:^|\s)((?:\*)((?:[^*]+))(?:\*))$/, type), | ||
keybindings && | ||
@@ -63,0 +63,0 @@ keymap(createObject([[keybindings.toggleItalic, toggleMark(type)]])), |
{ | ||
"name": "@bangle.dev/base-components", | ||
"version": "0.28.1", | ||
"version": "0.28.3", | ||
"homepage": "https://bangle.dev", | ||
@@ -35,9 +35,9 @@ "authors": [ | ||
"dependencies": { | ||
"@bangle.dev/pm-commands": "0.28.1", | ||
"@bangle.dev/utils": "0.28.1" | ||
"@bangle.dev/pm-commands": "0.28.3", | ||
"@bangle.dev/utils": "0.28.3" | ||
}, | ||
"devDependencies": { | ||
"@bangle.dev/core": "0.28.1", | ||
"@bangle.dev/pm": "0.28.1", | ||
"@bangle.dev/test-helpers": "0.28.1", | ||
"@bangle.dev/core": "0.28.3", | ||
"@bangle.dev/pm": "0.28.3", | ||
"@bangle.dev/test-helpers": "0.28.3", | ||
"@types/jest": "^26.0.23", | ||
@@ -44,0 +44,0 @@ "@types/markdown-it": "^12.0.3", |
@@ -72,4 +72,4 @@ import type { RawPlugins, RawSpecs } from '@bangle.dev/core'; | ||
return [ | ||
markPasteRule(/~([^~]+)~/g, type), | ||
markInputRule(/~([^~]+)~$/, type), | ||
markPasteRule(/(?:^|\s)((?:~~)((?:[^~]+))(?:~~))/g, type), | ||
markInputRule(/(?:^|\s)((?:~~)((?:[^~]+))(?:~~))$/, type), | ||
keybindings && | ||
@@ -76,0 +76,0 @@ keymap(createObject([[keybindings.toggleStrike, toggleMark(type)]])), |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
792204
19871
+ Added@bangle.dev/pm-commands@0.28.3(transitive)
+ Added@bangle.dev/utils@0.28.3(transitive)
- Removed@bangle.dev/pm-commands@0.28.1(transitive)
- Removed@bangle.dev/utils@0.28.1(transitive)
Updated@bangle.dev/utils@0.28.3