Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@
"postcss-loader": "^1.1.1",
"prettier": "^1.7.0",
"prismjs": "^1.6.0",
"react": "^15.4.1",
"react": "16.2.x",
"react-addons-pure-render-mixin": "^15.4.1",
"react-addons-test-utils": "^15.4.1",
"react-dom": "^15.4.1",
"react-dom": "16.2.0",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to keep these as caret versions?

"react-github-corner": "^2.0.0",
"react-github-fork-ribbon": "^0.4.4",
"react-test-renderer": "^16.2.0",
Expand Down
13 changes: 12 additions & 1 deletion src/modifiers/changeCurrentBlockType.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,27 @@ const changeCurrentBlockType = (
blockMetadata = {}
) => {
const currentContent = editorState.getCurrentContent();
const selection = editorState.getSelection();
let selection = editorState.getSelection();
const key = selection.getStartKey();
const blockMap = currentContent.getBlockMap();
const block = blockMap.get(key);
const data = block.getData().merge(blockMetadata);
const newBlock = block.merge({ type, data, text: text });

const lastOffset = text.length;

if (selection.getFocusOffset() > lastOffset) {
selection = selection.merge({
anchorOffset: lastOffset,
focusOffset: lastOffset,
});
}

const newContentState = currentContent.merge({
blockMap: blockMap.set(key, newBlock),
selectionAfter: selection,
});

return EditorState.push(editorState, newContentState, "change-block-type");
};

Expand Down
25 changes: 12 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5273,14 +5273,14 @@ react-deep-force-update@^1.0.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/react-deep-force-update/-/react-deep-force-update-1.1.1.tgz#bcd31478027b64b3339f108921ab520b4313dc2c"

react-dom@^15.4.1:
version "15.6.1"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-15.6.1.tgz#2cb0ed4191038e53c209eb3a79a23e2a4cf99470"
react-dom@16.2.0:
version "16.2.0"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.2.0.tgz#69003178601c0ca19b709b33a83369fe6124c044"
dependencies:
fbjs "^0.8.9"
fbjs "^0.8.16"
loose-envify "^1.1.0"
object-assign "^4.1.0"
prop-types "^15.5.10"
object-assign "^4.1.1"
prop-types "^15.6.0"

react-github-corner@^2.0.0:
version "2.0.0"
Expand Down Expand Up @@ -5326,15 +5326,14 @@ react@*:
object-assign "^4.1.0"
prop-types "^15.5.10"

react@^15.4.1:
version "15.6.2"
resolved "https://registry.yarnpkg.com/react/-/react-15.6.2.tgz#dba0434ab439cfe82f108f0f511663908179aa72"
react@16.2.x:
version "16.2.0"
resolved "https://registry.yarnpkg.com/react/-/react-16.2.0.tgz#a31bd2dab89bff65d42134fa187f24d054c273ba"
dependencies:
create-react-class "^15.6.0"
fbjs "^0.8.9"
fbjs "^0.8.16"
loose-envify "^1.1.0"
object-assign "^4.1.0"
prop-types "^15.5.10"
object-assign "^4.1.1"
prop-types "^15.6.0"

read-pkg-up@^1.0.1:
version "1.0.1"
Expand Down