braft-utils
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -8,5 +8,7 @@ "use strict"; | ||
var UniqueIndex = exports.UniqueIndex = function UniqueIndex() { | ||
return braftUniqueIndex += 1; | ||
exports.default = { | ||
UniqueIndex: function UniqueIndex() { | ||
return braftUniqueIndex += 1; | ||
} | ||
}; | ||
//# sourceMappingURL=base.js.map |
@@ -11,7 +11,7 @@ 'use strict'; | ||
var _colors = require('./colors'); | ||
var _color = require('./color'); | ||
exports.default = { | ||
selectionCollapsed: function selectionCollapsed(selectionState) { | ||
return selectionState.isCollapsed(); | ||
selectionCollapsed: function selectionCollapsed(editorState) { | ||
return editorState.getSelection().isCollapsed(); | ||
}, | ||
@@ -142,3 +142,5 @@ selectBlock: function selectBlock(editorState, block) { | ||
toggleSelectionColor: function toggleSelectionColor(editorState, color) { | ||
return this.toggleSelectionInlineStyle(editorState, 'COLOR-' + color.replace('#', ''), this.colorList.map(function (item) { | ||
var colorList = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; | ||
return this.toggleSelectionInlineStyle(editorState, 'COLOR-' + color.replace('#', ''), colorList.map(function (item) { | ||
return 'COLOR-' + item.replace('#', '').toUpperCase(); | ||
@@ -148,3 +150,5 @@ })); | ||
toggleSelectionBackgroundColor: function toggleSelectionBackgroundColor(editorState, color) { | ||
return this.toggleSelectionInlineStyle(editorState, 'BGCOLOR-' + color.replace('#', ''), this.colorList.map(function (item) { | ||
var colorList = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; | ||
return this.toggleSelectionInlineStyle(editorState, 'BGCOLOR-' + color.replace('#', ''), colorList.map(function (item) { | ||
return 'BGCOLOR-' + item.replace('#', '').toUpperCase(); | ||
@@ -154,3 +158,5 @@ })); | ||
toggleSelectionFontSize: function toggleSelectionFontSize(editorState, fontSize) { | ||
return this.toggleSelectionInlineStyle(editorState, 'FONTSIZE-' + fontSize, this.fontSizeList.map(function (item) { | ||
var fontSizeList = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; | ||
return this.toggleSelectionInlineStyle(editorState, 'FONTSIZE-' + fontSize, fontSizeList.map(function (item) { | ||
return 'FONTSIZE-' + item; | ||
@@ -160,3 +166,5 @@ })); | ||
toggleSelectionLineHeight: function toggleSelectionLineHeight(editorState, lineHeight) { | ||
return this.toggleSelectionInlineStyle(editorState, 'LINEHEIGHT-' + lineHeight, this.lineHeightList.map(function (item) { | ||
var lineHeightList = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; | ||
return this.toggleSelectionInlineStyle(editorState, 'LINEHEIGHT-' + lineHeight, lineHeightList.map(function (item) { | ||
return 'LINEHEIGHT-' + item; | ||
@@ -166,8 +174,12 @@ })); | ||
toggleSelectionFontFamily: function toggleSelectionFontFamily(editorState, fontFamily) { | ||
return this.toggleSelectionInlineStyle(editorState, 'FONTFAMILY-' + fontFamily, this.fontFamilyList.map(function (item) { | ||
var fontFamilyList = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; | ||
return this.toggleSelectionInlineStyle(editorState, 'FONTFAMILY-' + fontFamily, fontFamilyList.map(function (item) { | ||
return 'FONTFAMILY-' + item.name.toUpperCase(); | ||
})); | ||
}, | ||
toggleSelectionLetterSpacing: function toggleSelectionLetterSpacing(editorState, letterSpacing) { | ||
return this.toggleSelectionInlineStyle(editorState, 'LETTERSPACING-' + letterSpacing, this.letterSpacingList.map(function (item) { | ||
toggleSelectionLetterSpacing: function toggleSelectionLetterSpacing(editorState) { | ||
var letterSpacingList = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; | ||
return this.toggleSelectionInlineStyle(editorState, 'LETTERSPACING-' + letterSpacing, letterSpacingList.map(function (item) { | ||
return 'LETTERSPACING-' + item; | ||
@@ -177,3 +189,5 @@ })); | ||
toggleSelectionIndent: function toggleSelectionIndent(editorState, indent) { | ||
return this.toggleSelectionInlineStyle(editorState, 'INDENT-' + indent, this.indentList.map(function (item) { | ||
var indentList = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; | ||
return this.toggleSelectionInlineStyle(editorState, 'INDENT-' + indent, indentList.map(function (item) { | ||
return 'INDENT-' + item; | ||
@@ -251,3 +265,3 @@ })); | ||
if (!selectionState.isCollapsed()) { | ||
return replace ? _draftJs.EditorState.push(editorState, _draftJs.Modifier.replaceText(contentState, selectionState, text), 'replace-text') : this; | ||
return replace ? _draftJs.EditorState.push(editorState, _draftJs.Modifier.replaceText(contentState, selectionState, text), 'replace-text') : editorState; | ||
} else { | ||
@@ -271,7 +285,4 @@ return _draftJs.EditorState.push(editorState, _draftJs.Modifier.insertText(contentState, selectionState, text), 'insert-text'); | ||
var tempColors = (0, _colors.detectColorsFromHTMLString)(htmlString); | ||
var tempColors = (0, _color.detectColorsFromHTMLString)(htmlString); | ||
// this.addTempColors(tempColors) | ||
// this.requestFocus() | ||
return _draftJs.EditorState.push(editorState, _draftJs.Modifier.replaceWithFragment(contentState, selectionState, blockMap), 'insert-fragment'); | ||
@@ -278,0 +289,0 @@ } catch (error) { |
@@ -6,2 +6,3 @@ 'use strict'; | ||
}); | ||
exports.ContentUtils = exports.ColorUtils = exports.BaseUtils = undefined; | ||
@@ -22,3 +23,7 @@ var _base = require('./base'); | ||
exports.default = { BaseUtils: _base2.default, ColorUtils: _color2.default, ContentUtils: _content2.default }; | ||
var BaseUtils = exports.BaseUtils = _base2.default; | ||
var ColorUtils = exports.ColorUtils = _color2.default; | ||
var ContentUtils = exports.ContentUtils = _content2.default; | ||
exports.default = { BaseUtils: BaseUtils, ColorUtils: ColorUtils, ContentUtils: ContentUtils }; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "braft-utils", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Utils for Braft Editor", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
105581
500