braft-utils
Advanced tools
Comparing version 0.0.13 to 0.0.14
@@ -200,17 +200,2 @@ 'use strict'; | ||
}, | ||
insertHorizontalLine: function insertHorizontalLine(editorState) { | ||
var selectionState = editorState.getSelection(); | ||
var contentState = editorState.getCurrentContent(); | ||
if (!selectionState.isCollapsed() || this.getSelectionBlockType(editorState) === 'atomic') { | ||
return editorState; | ||
} | ||
var contentStateWithEntity = contentState.createEntity('HR', 'IMMUTABLE', {}); | ||
var entityKey = contentStateWithEntity.getLastCreatedEntityKey(); | ||
var newEditorState = _draftJs.AtomicBlockUtils.insertAtomicBlock(editorState, entityKey, ' '); | ||
return newEditorState; | ||
}, | ||
toggleSelectionLink: function toggleSelectionLink(editorState, href, target) { | ||
@@ -295,2 +280,23 @@ | ||
}, | ||
insertAtomicBlock: function insertAtomicBlock(editorState, type) { | ||
var immutable = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; | ||
var data = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; | ||
var selectionState = editorState.getSelection(); | ||
var contentState = editorState.getCurrentContent(); | ||
if (!selectionState.isCollapsed() || this.getSelectionBlockType(editorState) === 'atomic') { | ||
return editorState; | ||
} | ||
var contentStateWithEntity = contentState.createEntity(type, immutable ? 'IMMUTABLE' : 'MUTABLE', data); | ||
var entityKey = contentStateWithEntity.getLastCreatedEntityKey(); | ||
var newEditorState = _draftJs.AtomicBlockUtils.insertAtomicBlock(editorState, entityKey, ' '); | ||
return newEditorState; | ||
}, | ||
insertHorizontalLine: function insertHorizontalLine(editorState) { | ||
return this.insertAtomicBlock(editorState, 'HR'); | ||
}, | ||
insertMedias: function insertMedias(editorState) { | ||
@@ -297,0 +303,0 @@ var medias = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; |
{ | ||
"name": "braft-utils", | ||
"version": "0.0.13", | ||
"version": "0.0.14", | ||
"description": "Utils for Braft Editor", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
111477
522