draft-regex
Advanced tools
Comparing version 1.1.7 to 1.2.0
@@ -11,3 +11,2 @@ module.exports = { | ||
'flowtype', | ||
'flowtype-errors', | ||
'prettier', | ||
@@ -23,24 +22,8 @@ 'unicorn', | ||
'class-methods-use-this': 0, | ||
'flowtype-errors/show-errors': 2, | ||
'flowtype-errors/enforce-min-coverage': [2, 50], | ||
'unicorn/catch-error-name': ['error', { name: 'err' }], | ||
'unicorn/explicit-length-check': 'error', | ||
'unicorn/filename-case': 0, | ||
'unicorn/no-abusive-eslint-disable': 'error', | ||
'unicorn/no-process-exit': 'error', | ||
'unicorn/throw-new-error': 'error', | ||
'unicorn/number-literal-case': 'error', | ||
'unicorn/escape-case': 'error', | ||
'unicorn/no-array-instanceof': 'error', | ||
'unicorn/no-new-buffer': 'error', | ||
'unicorn/no-hex-escape': 'error', | ||
'unicorn/custom-error-definition': 'error', | ||
'unicorn/prefer-starts-ends-with': 'error', | ||
'unicorn/prefer-type-error': 'error', | ||
'unicorn/no-fn-reference-in-iterator': 'error', | ||
'unicorn/import-index': 'error', | ||
'unicorn/new-for-builtins': 'error', | ||
'unicorn/regex-shorthand': 0, | ||
'unicorn/prefer-spread': 0, | ||
}, | ||
globals: { | ||
describe: true, | ||
it: true, | ||
expect: true | ||
} | ||
}; |
@@ -13,25 +13,20 @@ 'use strict'; | ||
function clearPastedStyle(editorState, options) { | ||
var CS = editorState.getCurrentContent(); | ||
var SS = editorState.getSelection(); | ||
var contentState = editorState.getCurrentContent(); | ||
var selectionState = editorState.getSelection(); | ||
var _ref = options || {}, | ||
blockTypes = _ref.blockTypes, | ||
replaceHeader = _ref.replaceHeader, | ||
shiftHeader = _ref.shiftHeader, | ||
replaceList = _ref.replaceList, | ||
shiftList = _ref.shiftList; | ||
var blockMap = CS.getBlockMap().map(function (block) { | ||
if (blockTypes && blockTypes.indexOf(block.type) === -1) { | ||
return (0, _replaceTextRegex.createContentBlock)(block, { type: 'unstyled' }); | ||
} | ||
if (replaceHeader && block.type.slice(0, 6) === 'header') { | ||
var blockMap = contentState.getBlockMap().map(function (block) { | ||
if (shiftHeader && block.type.slice(0, 6) === 'header') { | ||
return (0, _replaceTextRegex.createContentBlock)(block, { type: shiftHeader }); | ||
} | ||
if (replaceList && block.type.slice(-4) === 'item') { | ||
if (shiftList && block.type.slice(-4) === 'item') { | ||
return (0, _replaceTextRegex.createContentBlock)(block, { type: shiftList }); | ||
} | ||
if (blockTypes && blockTypes.indexOf(block.type) === -1) { | ||
return (0, _replaceTextRegex.createContentBlock)(block, { type: 'unstyled' }); | ||
} | ||
if (!blockTypes) return (0, _replaceTextRegex.createContentBlock)(block, { type: 'unstyled' }); | ||
@@ -41,7 +36,7 @@ | ||
}); | ||
var newCS = new _draftJs.ContentState({ blockMap: blockMap }); | ||
var newEditorState = _draftJs.EditorState.createWithContent(newCS); | ||
var ES = _draftJs.EditorState.acceptSelection(newEditorState, SS); | ||
var newContentState = new _draftJs.ContentState({ blockMap: blockMap }); | ||
var newEditorState = _draftJs.EditorState.createWithContent(newContentState); | ||
var finalEditorState = _draftJs.EditorState.acceptSelection(newEditorState, selectionState); | ||
return ES; | ||
return finalEditorState; | ||
} |
@@ -13,5 +13,6 @@ 'use strict'; | ||
var typoRules = [{ reg: new RegExp(/"([^"]+)"/g), shift: '«$1»' }, // меняет кавычки на елочки | ||
{ reg: new RegExp(/\s+/g), shift: ' ' }, // удаляет лишние пробелы | ||
{ reg: new RegExp(/\[^!?:;,.…] +[A-ZА-Я]/g), shift: '$1 $2' }]; | ||
var typoRules = [{ reg: new RegExp(/"([^"]+)"/g), shift: '«$1»' }, // меняем кавычки на елочки | ||
{ reg: new RegExp(/\s+/g), shift: ' ' }, // удаляем лишние пробелы | ||
{ reg: new RegExp(/(^|[^!?:;,.…]) ([!?:;,.…])(?!\))/g), shift: '$1$2' }, // удаляем лишние пробелы перед пунктуацией | ||
{ reg: new RegExp(/([А-Я][,.!?;…–])+?([А-Я])/gi), shift: '$1 $2' }]; | ||
@@ -52,3 +53,4 @@ var optionRules = {}; | ||
return text.replace(reg, shift); | ||
if (text.match(reg)) return text.replace(reg, shift); | ||
return text; | ||
} | ||
@@ -58,3 +60,3 @@ | ||
var text = currentContentBlock.getText().slice(); | ||
for (var i = 0; i < rules.length; i += 1) { | ||
for (var i = 0; i < rules.length; i + 1) { | ||
text = replaceText(text, rules[i]); | ||
@@ -61,0 +63,0 @@ } |
{ | ||
"name": "draft-regex", | ||
"version": "1.1.7", | ||
"version": "1.2.0", | ||
"description": "Plugin for checking text with regular expressions", | ||
@@ -10,3 +10,4 @@ "main": "build/index.js", | ||
"prepublish": "npm run build", | ||
"lint": "./node_modules/.bin/eslint src/" | ||
"lint": "./node_modules/.bin/eslint src/", | ||
"test": "jest" | ||
}, | ||
@@ -28,3 +29,3 @@ "repository": { | ||
"dependencies": { | ||
"draft-js": "^0.10.4", | ||
"draft-js": "^0.10.5", | ||
"react": "^16.2.0", | ||
@@ -39,3 +40,6 @@ "react-dom": "^16.2.0" | ||
"babel-preset-react": "^6.24.1", | ||
"eslint": "^4.15.0", | ||
"enzyme": "^3.3.0", | ||
"enzyme-adapter-react-16": "^1.1.1", | ||
"enzyme-to-json": "^3.3.1", | ||
"eslint": "^4.16.0", | ||
"eslint-config-airbnb": "^16.1.0", | ||
@@ -45,3 +49,3 @@ "eslint-config-prettier": "^2.9.0", | ||
"eslint-plugin-array-func": "^3.0.0", | ||
"eslint-plugin-flowtype": "^2.41.0", | ||
"eslint-plugin-flowtype": "^2.42.0", | ||
"eslint-plugin-flowtype-errors": "^3.3.7", | ||
@@ -53,8 +57,9 @@ "eslint-plugin-immutable": "^1.0.0", | ||
"eslint-plugin-promise": "^3.6.0", | ||
"eslint-plugin-react": "^7.5.1", | ||
"eslint-plugin-react": "^7.6.1", | ||
"eslint-plugin-standard": "^3.0.1", | ||
"eslint-plugin-unicorn": "^3.0.1", | ||
"flow-bin": "^0.63.0", | ||
"parcel-bundler": "^1.4.1" | ||
"flow-bin": "^0.64.0", | ||
"jest": "^22.1.4", | ||
"raf": "^3.4.0" | ||
} | ||
} |
@@ -116,4 +116,6 @@ | ||
If you do not want to use all six kinds of headings, you can bring the headers to the same view using `replaceHeader` and `shiftHeader`. | ||
A list of all types can be found [here](https://draftjs.org/docs/api-reference-content-block.html#content). | ||
If you do not want to use all six kinds of headings, you can bring the headers to the same view using `shiftHeader`. | ||
The same applies to lists. | ||
@@ -127,5 +129,3 @@ | ||
blockTypes?: Array<string>, | ||
replaceHeader?: boolean, | ||
shiftHeader?: string, | ||
replaceList?: boolean, | ||
shiftList?: string, | ||
@@ -132,0 +132,0 @@ } |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
18
178707
26
346
1
Updateddraft-js@^0.10.5