Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.

Commit 49f6c45

Browse files
authored
Merge pull request #76 from withspectrum/unsticky-inline-styles
Don't auto-insert spaces, unsticky inline styles
2 parents c7166e7 + a5eaeac commit 49f6c45

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "draft-js-markdown-plugin",
3-
"version": "2.0.0",
3+
"version": "2.0.1-0",
44
"description": "A DraftJS plugin for supporting Markdown syntax shortcuts, fork of draft-js-markdown-shortcuts-plugin",
55
"main": "lib/index.js",
66
"scripts": {

src/modifiers/__test__/handleInlineStyle-test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ describe("handleInlineStyle", () => {
6868
blocks: [
6969
{
7070
key: "item1",
71-
text: "hello inline style",
71+
text: "hello inline style",
7272
type: "unstyled",
7373
depth: 0,
7474
inlineStyleRanges: [
@@ -129,7 +129,7 @@ describe("handleInlineStyle", () => {
129129
blocks: [
130130
{
131131
key: "item1",
132-
text: "hello inline style",
132+
text: "hello inline style",
133133
type: "unstyled",
134134
depth: 0,
135135
inlineStyleRanges: [
@@ -174,7 +174,7 @@ describe("handleInlineStyle", () => {
174174
blocks: [
175175
{
176176
key: "item1",
177-
text: "hello TL;DR: style",
177+
text: "hello TL;DR: style",
178178
type: "unstyled",
179179
depth: 0,
180180
inlineStyleRanges: [
@@ -219,7 +219,7 @@ describe("handleInlineStyle", () => {
219219
blocks: [
220220
{
221221
key: "item1",
222-
text: "hello inline style",
222+
text: "hello inline style",
223223
type: "unstyled",
224224
depth: 0,
225225
inlineStyleRanges: [
@@ -270,7 +270,7 @@ describe("handleInlineStyle", () => {
270270
blocks: [
271271
{
272272
key: "item1",
273-
text: "hello inline style",
273+
text: "hello inline style",
274274
type: "unstyled",
275275
depth: 0,
276276
inlineStyleRanges: [
@@ -320,7 +320,7 @@ describe("handleInlineStyle", () => {
320320
blocks: [
321321
{
322322
key: "item1",
323-
text: "hello inline style",
323+
text: "hello inline style",
324324
type: "unstyled",
325325
depth: 0,
326326
inlineStyleRanges: [
@@ -365,7 +365,7 @@ describe("handleInlineStyle", () => {
365365
blocks: [
366366
{
367367
key: "item1",
368-
text: "hello inline style",
368+
text: "hello inline style",
369369
type: "unstyled",
370370
depth: 0,
371371
inlineStyleRanges: [
@@ -419,7 +419,7 @@ describe("handleInlineStyle", () => {
419419
blocks: [
420420
{
421421
key: "item1",
422-
text: "hello inline style",
422+
text: "hello inline style",
423423
type: "unstyled",
424424
depth: 0,
425425
inlineStyleRanges: [

src/modifiers/changeCurrentInlineStyle.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { OrderedSet } from "immutable";
12
import { EditorState, SelectionState, Modifier } from "draft-js";
23

34
const changeCurrentInlineStyle = (editorState, matchArr, style) => {
@@ -60,7 +61,10 @@ const changeCurrentInlineStyle = (editorState, matchArr, style) => {
6061
"change-inline-style"
6162
);
6263

63-
return EditorState.forceSelection(newEditorState, afterSelection);
64+
return EditorState.setInlineStyleOverride(
65+
EditorState.forceSelection(newEditorState, afterSelection),
66+
OrderedSet.of("")
67+
);
6468
};
6569

6670
export default changeCurrentInlineStyle;

src/modifiers/handleInlineStyle.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ const handleInlineStyle = (
5252

5353
if (character === "\n") {
5454
newContentState = Modifier.splitBlock(newContentState, selection);
55-
} else {
56-
newContentState = Modifier.insertText(newContentState, selection, " ");
5755
}
5856

5957
newEditorState = EditorState.push(

0 commit comments

Comments
 (0)