This commit is contained in:
57
node_modules/slate-plain-serializer/Changelog.md
generated
vendored
Normal file
57
node_modules/slate-plain-serializer/Changelog.md
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
# Changelog
|
||||
|
||||
This document maintains a list of changes to the `slate-plain-serializer` package with each new version. Until `1.0.0` is released, breaking changes will be added as minor version bumps, and smaller changes won't be accounted for since the library is moving quickly.
|
||||
|
||||
---
|
||||
|
||||
### `0.7.0` — May 1, 2019
|
||||
|
||||
###### BREAKING
|
||||
|
||||
**Updated to work with `slate@0.46`.** The plain serializer has been updated to work alongside the new text data model in the latest version of slate. For serializing it requires you pass in the new format for text nodes. And for deserializing it will return the new format.
|
||||
|
||||
---
|
||||
|
||||
### `0.6.0` — August 22, 2018
|
||||
|
||||
###### BREAKING
|
||||
|
||||
**Remove all previously deprecated code paths.** This helps to reduce some of the complexity in Slate by not having to handle these code paths anymore. And it helps to reduce file size. When upgrading, it's _highly_ recommended that you upgrade to the previous version first and ensure there are no deprecation warnings being logged, then upgrade to this version.
|
||||
|
||||
---
|
||||
|
||||
### `0.5.0` — January 4, 2018
|
||||
|
||||
###### BREAKING
|
||||
|
||||
**The `kind` property of Slate objects has been renamed to `object`.** This is to reduce the confusion over the difference between "kind" and "type" which are practically synonyms. The "object" name was chosen to match the Stripe API, since it seems like a sensible choice and reads much more nicely when looking through JSON.
|
||||
|
||||
---
|
||||
|
||||
### `0.4.0` — October 27, 2017
|
||||
|
||||
###### BREAKING
|
||||
|
||||
**Remove all previously deprecated code paths.** This helps to reduce some of the complexity in Slate by not having to handle these code paths anymore. And it helps to reduce file size. When upgrading, it's _highly_ recommended that you upgrade to the previous version first and ensure there are no deprecation warnings being logged, then upgrade to this version.
|
||||
|
||||
---
|
||||
|
||||
### `0.3.0` — October 27, 2017
|
||||
|
||||
###### BREAKING
|
||||
|
||||
**Updated to work with `slate@0.29.0`.** This is required because `slate-plain-serializer` needs access to the new `Value` model.
|
||||
|
||||
---
|
||||
|
||||
### `0.2.0` — October 14, 2017
|
||||
|
||||
###### BREAKING
|
||||
|
||||
**Updated work with `slate@0.27.0`.** The new version of Slate renames the old `Range` model to `Leaf`, and the old `Selection` model to `Range`.
|
||||
|
||||
---
|
||||
|
||||
### `0.1.0` — September 17, 2017
|
||||
|
||||
:tada:
|
||||
1
node_modules/slate-plain-serializer/Readme.md
generated
vendored
Normal file
1
node_modules/slate-plain-serializer/Readme.md
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
This package contains a plain-text serializer for Slate documents.
|
||||
122
node_modules/slate-plain-serializer/dist/slate-plain-serializer.js
generated
vendored
Normal file
122
node_modules/slate-plain-serializer/dist/slate-plain-serializer.js
generated
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('slate'), require('immutable')) :
|
||||
typeof define === 'function' && define.amd ? define(['exports', 'slate', 'immutable'], factory) :
|
||||
(factory((global.SlatePlainSerializer = {}),global.Slate,global.Immutable));
|
||||
}(this, (function (exports,slate,immutable) { 'use strict';
|
||||
|
||||
var _extends = Object.assign || function (target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i];
|
||||
|
||||
for (var key in source) {
|
||||
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
||||
target[key] = source[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
};
|
||||
|
||||
/**
|
||||
* Deserialize a plain text `string` to a Slate value.
|
||||
*
|
||||
* @param {String} string
|
||||
* @param {Object} options
|
||||
* @property {Boolean} toJSON
|
||||
* @property {String|Object|Block} defaultBlock
|
||||
* @property {Array|Set} defaultMarks
|
||||
* @return {Value}
|
||||
*/
|
||||
|
||||
function deserialize(string) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
var _options$defaultBlock = options.defaultBlock,
|
||||
defaultBlock = _options$defaultBlock === undefined ? 'line' : _options$defaultBlock,
|
||||
_options$defaultMarks = options.defaultMarks,
|
||||
defaultMarks = _options$defaultMarks === undefined ? [] : _options$defaultMarks,
|
||||
_options$delimiter = options.delimiter,
|
||||
delimiter = _options$delimiter === undefined ? '\n' : _options$delimiter,
|
||||
_options$toJSON = options.toJSON,
|
||||
toJSON = _options$toJSON === undefined ? false : _options$toJSON;
|
||||
|
||||
|
||||
if (immutable.Set.isSet(defaultMarks)) {
|
||||
defaultMarks = defaultMarks.toArray();
|
||||
}
|
||||
|
||||
defaultBlock = slate.Node.createProperties(defaultBlock);
|
||||
defaultMarks = defaultMarks.map(slate.Mark.createProperties);
|
||||
|
||||
var json = {
|
||||
object: 'value',
|
||||
document: {
|
||||
object: 'document',
|
||||
data: {},
|
||||
nodes: string.split(delimiter).map(function (line) {
|
||||
return _extends({}, defaultBlock, {
|
||||
object: 'block',
|
||||
data: {},
|
||||
nodes: [{
|
||||
object: 'text',
|
||||
text: line,
|
||||
marks: defaultMarks
|
||||
}]
|
||||
});
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
var ret = toJSON ? json : slate.Value.fromJSON(json);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize a Slate `value` to a plain text string.
|
||||
*
|
||||
* @param {Value} value
|
||||
* @return {String}
|
||||
*/
|
||||
|
||||
function serialize(value) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
|
||||
return serializeNode(value.document, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize a `node` to plain text.
|
||||
*
|
||||
* @param {Node} node
|
||||
* @return {String}
|
||||
*/
|
||||
|
||||
function serializeNode(node) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
var _options$delimiter2 = options.delimiter,
|
||||
delimiter = _options$delimiter2 === undefined ? '\n' : _options$delimiter2;
|
||||
|
||||
|
||||
if (node.object === 'document' || node.object === 'block' && slate.Block.isBlockList(node.nodes)) {
|
||||
return node.nodes.map(serializeNode).join(delimiter);
|
||||
} else {
|
||||
return node.text;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Export.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
|
||||
var index = {
|
||||
deserialize: deserialize,
|
||||
serialize: serialize
|
||||
};
|
||||
|
||||
exports.default = index;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
||||
1
node_modules/slate-plain-serializer/dist/slate-plain-serializer.min.js
generated
vendored
Normal file
1
node_modules/slate-plain-serializer/dist/slate-plain-serializer.min.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("slate"),require("immutable")):"function"==typeof define&&define.amd?define(["exports","slate","immutable"],t):t(e.SlatePlainSerializer={},e.Slate,e.Immutable)}(this,function(e,t,o){"use strict";var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e};function i(e){var o=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).delimiter,r=void 0===o?"\n":o;return"document"===e.object||"block"===e.object&&t.Block.isBlockList(e.nodes)?e.nodes.map(i).join(r):e.text}var n={deserialize:function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=i.defaultBlock,a=void 0===n?"line":n,d=i.defaultMarks,l=void 0===d?[]:d,u=i.delimiter,c=void 0===u?"\n":u,s=i.toJSON,f=void 0!==s&&s;o.Set.isSet(l)&&(l=l.toArray()),a=t.Node.createProperties(a),l=l.map(t.Mark.createProperties);var m={object:"value",document:{object:"document",data:{},nodes:e.split(c).map(function(e){return r({},a,{object:"block",data:{},nodes:[{object:"text",text:e,marks:l}]})})}};return f?m:t.Value.fromJSON(m)},serialize:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return i(e.document,t)}};e.default=n,Object.defineProperty(e,"__esModule",{value:!0})});
|
||||
116
node_modules/slate-plain-serializer/lib/slate-plain-serializer.es.js
generated
vendored
Normal file
116
node_modules/slate-plain-serializer/lib/slate-plain-serializer.es.js
generated
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
import { Block, Mark, Node, Value } from 'slate';
|
||||
import { Set } from 'immutable';
|
||||
|
||||
var _extends = Object.assign || function (target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i];
|
||||
|
||||
for (var key in source) {
|
||||
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
||||
target[key] = source[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
};
|
||||
|
||||
/**
|
||||
* Deserialize a plain text `string` to a Slate value.
|
||||
*
|
||||
* @param {String} string
|
||||
* @param {Object} options
|
||||
* @property {Boolean} toJSON
|
||||
* @property {String|Object|Block} defaultBlock
|
||||
* @property {Array|Set} defaultMarks
|
||||
* @return {Value}
|
||||
*/
|
||||
|
||||
function deserialize(string) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
var _options$defaultBlock = options.defaultBlock,
|
||||
defaultBlock = _options$defaultBlock === undefined ? 'line' : _options$defaultBlock,
|
||||
_options$defaultMarks = options.defaultMarks,
|
||||
defaultMarks = _options$defaultMarks === undefined ? [] : _options$defaultMarks,
|
||||
_options$delimiter = options.delimiter,
|
||||
delimiter = _options$delimiter === undefined ? '\n' : _options$delimiter,
|
||||
_options$toJSON = options.toJSON,
|
||||
toJSON = _options$toJSON === undefined ? false : _options$toJSON;
|
||||
|
||||
|
||||
if (Set.isSet(defaultMarks)) {
|
||||
defaultMarks = defaultMarks.toArray();
|
||||
}
|
||||
|
||||
defaultBlock = Node.createProperties(defaultBlock);
|
||||
defaultMarks = defaultMarks.map(Mark.createProperties);
|
||||
|
||||
var json = {
|
||||
object: 'value',
|
||||
document: {
|
||||
object: 'document',
|
||||
data: {},
|
||||
nodes: string.split(delimiter).map(function (line) {
|
||||
return _extends({}, defaultBlock, {
|
||||
object: 'block',
|
||||
data: {},
|
||||
nodes: [{
|
||||
object: 'text',
|
||||
text: line,
|
||||
marks: defaultMarks
|
||||
}]
|
||||
});
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
var ret = toJSON ? json : Value.fromJSON(json);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize a Slate `value` to a plain text string.
|
||||
*
|
||||
* @param {Value} value
|
||||
* @return {String}
|
||||
*/
|
||||
|
||||
function serialize(value) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
|
||||
return serializeNode(value.document, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize a `node` to plain text.
|
||||
*
|
||||
* @param {Node} node
|
||||
* @return {String}
|
||||
*/
|
||||
|
||||
function serializeNode(node) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
var _options$delimiter2 = options.delimiter,
|
||||
delimiter = _options$delimiter2 === undefined ? '\n' : _options$delimiter2;
|
||||
|
||||
|
||||
if (node.object === 'document' || node.object === 'block' && Block.isBlockList(node.nodes)) {
|
||||
return node.nodes.map(serializeNode).join(delimiter);
|
||||
} else {
|
||||
return node.text;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Export.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
|
||||
var index = {
|
||||
deserialize: deserialize,
|
||||
serialize: serialize
|
||||
};
|
||||
|
||||
export default index;
|
||||
//# sourceMappingURL=slate-plain-serializer.es.js.map
|
||||
1
node_modules/slate-plain-serializer/lib/slate-plain-serializer.es.js.map
generated
vendored
Normal file
1
node_modules/slate-plain-serializer/lib/slate-plain-serializer.es.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"slate-plain-serializer.es.js","sources":["../src/index.js"],"sourcesContent":["import { Block, Mark, Node, Value } from 'slate'\nimport { Set } from 'immutable'\n\n/**\n * Deserialize a plain text `string` to a Slate value.\n *\n * @param {String} string\n * @param {Object} options\n * @property {Boolean} toJSON\n * @property {String|Object|Block} defaultBlock\n * @property {Array|Set} defaultMarks\n * @return {Value}\n */\n\nfunction deserialize(string, options = {}) {\n let {\n defaultBlock = 'line',\n defaultMarks = [],\n delimiter = '\\n',\n toJSON = false,\n } = options\n\n if (Set.isSet(defaultMarks)) {\n defaultMarks = defaultMarks.toArray()\n }\n\n defaultBlock = Node.createProperties(defaultBlock)\n defaultMarks = defaultMarks.map(Mark.createProperties)\n\n const json = {\n object: 'value',\n document: {\n object: 'document',\n data: {},\n nodes: string.split(delimiter).map(line => {\n return {\n ...defaultBlock,\n object: 'block',\n data: {},\n nodes: [\n {\n object: 'text',\n text: line,\n marks: defaultMarks,\n },\n ],\n }\n }),\n },\n }\n\n const ret = toJSON ? json : Value.fromJSON(json)\n return ret\n}\n\n/**\n * Serialize a Slate `value` to a plain text string.\n *\n * @param {Value} value\n * @return {String}\n */\n\nfunction serialize(value, options = {}) {\n return serializeNode(value.document, options)\n}\n\n/**\n * Serialize a `node` to plain text.\n *\n * @param {Node} node\n * @return {String}\n */\n\nfunction serializeNode(node, options = {}) {\n const { delimiter = '\\n' } = options\n\n if (\n node.object === 'document' ||\n (node.object === 'block' && Block.isBlockList(node.nodes))\n ) {\n return node.nodes.map(serializeNode).join(delimiter)\n } else {\n return node.text\n }\n}\n\n/**\n * Export.\n *\n * @type {Object}\n */\n\nexport default {\n deserialize,\n serialize,\n}\n"],"names":["deserialize","string","options","defaultBlock","defaultMarks","delimiter","toJSON","Set","isSet","toArray","Node","createProperties","map","Mark","json","split","line","ret","Value","fromJSON","serialize","value","serializeNode","document","node","object","Block","isBlockList","nodes","join","text"],"mappings":";;;;;;;;;;;;;;;;;AAGA;;;;;;;;;;;AAWA,SAASA,WAAT,CAAqBC,MAArB,EAA2C;MAAdC,OAAc,uEAAJ,EAAI;8BAMrCA,OANqC,CAEvCC,YAFuC;MAEvCA,YAFuC,yCAExB,MAFwB;8BAMrCD,OANqC,C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_modules/slate-plain-serializer/lib/slate-plain-serializer.js
generated
vendored
Normal file
120
node_modules/slate-plain-serializer/lib/slate-plain-serializer.js
generated
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var slate = require('slate');
|
||||
var immutable = require('immutable');
|
||||
|
||||
var _extends = Object.assign || function (target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i];
|
||||
|
||||
for (var key in source) {
|
||||
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
||||
target[key] = source[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
};
|
||||
|
||||
/**
|
||||
* Deserialize a plain text `string` to a Slate value.
|
||||
*
|
||||
* @param {String} string
|
||||
* @param {Object} options
|
||||
* @property {Boolean} toJSON
|
||||
* @property {String|Object|Block} defaultBlock
|
||||
* @property {Array|Set} defaultMarks
|
||||
* @return {Value}
|
||||
*/
|
||||
|
||||
function deserialize(string) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
var _options$defaultBlock = options.defaultBlock,
|
||||
defaultBlock = _options$defaultBlock === undefined ? 'line' : _options$defaultBlock,
|
||||
_options$defaultMarks = options.defaultMarks,
|
||||
defaultMarks = _options$defaultMarks === undefined ? [] : _options$defaultMarks,
|
||||
_options$delimiter = options.delimiter,
|
||||
delimiter = _options$delimiter === undefined ? '\n' : _options$delimiter,
|
||||
_options$toJSON = options.toJSON,
|
||||
toJSON = _options$toJSON === undefined ? false : _options$toJSON;
|
||||
|
||||
|
||||
if (immutable.Set.isSet(defaultMarks)) {
|
||||
defaultMarks = defaultMarks.toArray();
|
||||
}
|
||||
|
||||
defaultBlock = slate.Node.createProperties(defaultBlock);
|
||||
defaultMarks = defaultMarks.map(slate.Mark.createProperties);
|
||||
|
||||
var json = {
|
||||
object: 'value',
|
||||
document: {
|
||||
object: 'document',
|
||||
data: {},
|
||||
nodes: string.split(delimiter).map(function (line) {
|
||||
return _extends({}, defaultBlock, {
|
||||
object: 'block',
|
||||
data: {},
|
||||
nodes: [{
|
||||
object: 'text',
|
||||
text: line,
|
||||
marks: defaultMarks
|
||||
}]
|
||||
});
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
var ret = toJSON ? json : slate.Value.fromJSON(json);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize a Slate `value` to a plain text string.
|
||||
*
|
||||
* @param {Value} value
|
||||
* @return {String}
|
||||
*/
|
||||
|
||||
function serialize(value) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
|
||||
return serializeNode(value.document, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize a `node` to plain text.
|
||||
*
|
||||
* @param {Node} node
|
||||
* @return {String}
|
||||
*/
|
||||
|
||||
function serializeNode(node) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
var _options$delimiter2 = options.delimiter,
|
||||
delimiter = _options$delimiter2 === undefined ? '\n' : _options$delimiter2;
|
||||
|
||||
|
||||
if (node.object === 'document' || node.object === 'block' && slate.Block.isBlockList(node.nodes)) {
|
||||
return node.nodes.map(serializeNode).join(delimiter);
|
||||
} else {
|
||||
return node.text;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Export.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
|
||||
var index = {
|
||||
deserialize: deserialize,
|
||||
serialize: serialize
|
||||
};
|
||||
|
||||
exports.default = index;
|
||||
//# sourceMappingURL=slate-plain-serializer.js.map
|
||||
1
node_modules/slate-plain-serializer/lib/slate-plain-serializer.js.map
generated
vendored
Normal file
1
node_modules/slate-plain-serializer/lib/slate-plain-serializer.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"slate-plain-serializer.js","sources":["../src/index.js"],"sourcesContent":["import { Block, Mark, Node, Value } from 'slate'\nimport { Set } from 'immutable'\n\n/**\n * Deserialize a plain text `string` to a Slate value.\n *\n * @param {String} string\n * @param {Object} options\n * @property {Boolean} toJSON\n * @property {String|Object|Block} defaultBlock\n * @property {Array|Set} defaultMarks\n * @return {Value}\n */\n\nfunction deserialize(string, options = {}) {\n let {\n defaultBlock = 'line',\n defaultMarks = [],\n delimiter = '\\n',\n toJSON = false,\n } = options\n\n if (Set.isSet(defaultMarks)) {\n defaultMarks = defaultMarks.toArray()\n }\n\n defaultBlock = Node.createProperties(defaultBlock)\n defaultMarks = defaultMarks.map(Mark.createProperties)\n\n const json = {\n object: 'value',\n document: {\n object: 'document',\n data: {},\n nodes: string.split(delimiter).map(line => {\n return {\n ...defaultBlock,\n object: 'block',\n data: {},\n nodes: [\n {\n object: 'text',\n text: line,\n marks: defaultMarks,\n },\n ],\n }\n }),\n },\n }\n\n const ret = toJSON ? json : Value.fromJSON(json)\n return ret\n}\n\n/**\n * Serialize a Slate `value` to a plain text string.\n *\n * @param {Value} value\n * @return {String}\n */\n\nfunction serialize(value, options = {}) {\n return serializeNode(value.document, options)\n}\n\n/**\n * Serialize a `node` to plain text.\n *\n * @param {Node} node\n * @return {String}\n */\n\nfunction serializeNode(node, options = {}) {\n const { delimiter = '\\n' } = options\n\n if (\n node.object === 'document' ||\n (node.object === 'block' && Block.isBlockList(node.nodes))\n ) {\n return node.nodes.map(serializeNode).join(delimiter)\n } else {\n return node.text\n }\n}\n\n/**\n * Export.\n *\n * @type {Object}\n */\n\nexport default {\n deserialize,\n serialize,\n}\n"],"names":["deserialize","string","options","defaultBlock","defaultMarks","delimiter","toJSON","Set","isSet","toArray","Node","createProperties","map","Mark","json","split","line","ret","Value","fromJSON","serialize","value","serializeNode","document","node","object","Block","isBlockList","nodes","join","text"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAGA;;;;;;;;;;;AAWA,SAASA,WAAT,CAAqBC,MAArB,EAA2C;MAAdC,OAAc,uEAAJ,EAAI;8BAMrCA,OANqC,C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AAZ;;;;;;;;;;AAUJ,YAAe;0BAAA;;CAAf;;;;"}
|
||||
43
node_modules/slate-plain-serializer/package.json
generated
vendored
Normal file
43
node_modules/slate-plain-serializer/package.json
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"name": "slate-plain-serializer",
|
||||
"description": "A plain text serializer for Slate editors.",
|
||||
"version": "0.7.13",
|
||||
"license": "MIT",
|
||||
"repository": "git://github.com/ianstormtaylor/slate.git",
|
||||
"main": "lib/slate-plain-serializer.js",
|
||||
"module": "lib/slate-plain-serializer.es.js",
|
||||
"umd": "dist/slate-plain-serializer.js",
|
||||
"umdMin": "dist/slate-plain-serializer.min.js",
|
||||
"files": [
|
||||
"dist/",
|
||||
"lib/"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"immutable": ">=3.8.1",
|
||||
"slate": ">=0.46.0 <0.50.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "^2.5.3",
|
||||
"slate": "^0.47.9 <0.50.0",
|
||||
"slate-hyperscript": "^0.13.9 <0.50.0"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "rimraf ./dist ./lib ./node_modules"
|
||||
},
|
||||
"umdGlobals": {
|
||||
"immutable": "Immutable",
|
||||
"slate": "Slate"
|
||||
},
|
||||
"keywords": [
|
||||
"deserialize",
|
||||
"editor",
|
||||
"plain",
|
||||
"plaintext",
|
||||
"serialize",
|
||||
"serializer",
|
||||
"slate",
|
||||
"string",
|
||||
"text",
|
||||
"xml"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user