draftmirror
Advanced tools
Comparing version 0.6.0 to 0.6.1
var Immutable = require('immutable'); | ||
var normalizeNewline = require('normalize-newline'); | ||
var schema = require('prosemirror/dist/schema-basic').schema; | ||
@@ -198,3 +199,3 @@ var Node = require('prosemirror/dist/model/node').Node; | ||
/** | ||
* Create a raw editor state from a text | ||
* Create a raw editor state from a text, each line gets its own block. | ||
* @param {String} text | ||
@@ -208,15 +209,20 @@ * @return {EditorState} | ||
text = normalizeNewline(text); | ||
var lines = text.split(/\n/); | ||
var blocks = lines.map(function(line) { | ||
return { | ||
type: textType, | ||
'content': line? [ | ||
{ | ||
type: styleType, | ||
text: line | ||
} | ||
] : [] | ||
}; | ||
}); | ||
return EditorState.createFromJSON(schema, { | ||
'type': docType, | ||
'content': [ | ||
{ | ||
type: textType, | ||
'content': text? [ | ||
{ | ||
type: styleType, | ||
text: text | ||
} | ||
] : [] | ||
} | ||
] | ||
'content': blocks | ||
}); | ||
@@ -223,0 +229,0 @@ }; |
{ | ||
"name": "draftmirror", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"description": "React component for ProseMirror providing a Draft.js like API", | ||
@@ -33,2 +33,3 @@ "main": "./lib/index.js", | ||
"is": "^3.1.0", | ||
"normalize-newline": "^2.0.0", | ||
"prosemirror": "^0.8.1", | ||
@@ -35,0 +36,0 @@ "react": "^15.1.0", |
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
95084
2491
8
+ Addednormalize-newline@^2.0.0
+ Addednormalize-newline@2.1.0(transitive)