Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

slate-hyperscript

Package Overview
Dependencies
Maintainers
1
Versions
393
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

slate-hyperscript - npm Package Compare versions

Comparing version 0.4.16 to 0.5.0

10

Changelog.md

@@ -10,2 +10,12 @@

### `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

@@ -12,0 +22,0 @@

12

dist/slate-hyperscript.js

@@ -420,11 +420,11 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.SlateHyperscript = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

/**
* Normalize a node creator with `key` and `value`, of `kind`.
* Normalize a node creator with `key` and `value`, of `object`.
*
* @param {String} key
* @param {Function|Object|String} value
* @param {String} kind
* @param {String} object
* @return {Function}
*/
function normalizeNode(key, value, kind) {
function normalizeNode(key, value, object) {
if (typeof value == 'function') {

@@ -444,3 +444,3 @@ return value;

var attrs = _extends({}, value, {
kind: kind,
object: object,
key: attrKey,

@@ -450,7 +450,7 @@ data: _extends({}, value.data || {}, rest)

return CREATORS[kind](tagName, attrs, children);
return CREATORS[object](tagName, attrs, children);
};
}
throw new Error('Slate hyperscript ' + kind + ' creators can be either functions, objects or strings, but you passed: ' + value);
throw new Error('Slate hyperscript ' + object + ' creators can be either functions, objects or strings, but you passed: ' + value);
}

@@ -457,0 +457,0 @@

@@ -1,1 +0,1 @@

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.SlateHyperscript=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){var has=Object.prototype.hasOwnProperty;var toString=Object.prototype.toString;function isEmpty(val){if(val==null)return true;if("boolean"==typeof val)return false;if("number"==typeof val)return val===0;if("string"==typeof val)return val.length===0;if("function"==typeof val)return val.length===0;if(Array.isArray(val))return val.length===0;if(val instanceof Error)return val.message==="";if(val.toString==toString){switch(val.toString()){case"[object File]":case"[object Map]":case"[object Set]":{return val.size===0}case"[object Object]":{for(var key in val){if(has.call(val,key))return false}return true}}}return false}module.exports=isEmpty},{}],2:[function(require,module,exports){"use strict";var isObject=require("isobject");function isObjectObject(o){return isObject(o)===true&&Object.prototype.toString.call(o)==="[object Object]"}module.exports=function isPlainObject(o){var ctor,prot;if(isObjectObject(o)===false)return false;ctor=o.constructor;if(typeof ctor!=="function")return false;prot=ctor.prototype;if(isObjectObject(prot)===false)return false;if(prot.hasOwnProperty("isPrototypeOf")===false){return false}return true}},{isobject:3}],3:[function(require,module,exports){"use strict";module.exports=function isObject(val){return val!=null&&typeof val==="object"&&Array.isArray(val)===false}},{}],4:[function(require,module,exports){"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _objectWithoutProperties(e,t){var r={};for(var n in e)t.indexOf(n)>=0||Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n]);return r}function createHyperscript(){function e(e,t){for(var n=arguments.length,o=Array(n>2?n-2:0),a=2;a<n;a++)o[a-2]=arguments[a];var i=r[e];if(!i)throw new Error('No hyperscript creator found for tag: "'+e+'"');return null==t&&(t={}),(0,_isPlainObject2.default)(t)||(o=[t].concat(o),t={}),o=o.filter(function(e){return Boolean(e)}).reduce(function(e,t){return e.concat(t)},[]),i(e,t,o)}var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=resolveCreators(t);return e}function createChildren(e){function t(e){var t=c,r=t.__anchor,n=t.__focus;null!=r&&(e.__anchor=r),null!=n&&(e.__focus=n),c=e}var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=[],o=0,a=e.find(function(e){return _slate.Text.isText(e)}),i=r.key?r.key:a?a.key:void 0,c=_slate.Text.create({key:i});return e.forEach(function(e){if(_slate.Node.isNode(e)&&!_slate.Text.isText(e)&&((c.text.length||null!=c.__anchor||null!=c.__focus)&&n.push(c),n.push(e),c=_slate.Text.create(),o=0),"string"==typeof e&&(t(c.insertText(c.text.length,e,r.marks)),o+=e.length),_slate.Text.isText(e)){var a=e.__anchor,i=e.__focus,s=c.text.length;r.key||0!=c.text.length||t(c.set("key",e.key)),e.getLeaves().forEach(function(e){var n=e.marks;r.marks&&(n=n.union(r.marks)),t(c.insertText(s,e.text,n)),s+=e.text.length}),null!=a&&(c.__anchor=a+o),null!=i&&(c.__focus=i+o),o+=e.text.length}e!=ANCHOR&&e!=CURSOR||(c.__anchor=o),e!=FOCUS&&e!=CURSOR||(c.__focus=o)}),n.push(c),n}function resolveCreators(e){var t=e.blocks,r=void 0===t?{}:t,n=e.inlines,o=void 0===n?{}:n,a=e.marks,i=void 0===a?{}:a,c=_extends({},CREATORS,e.creators||{});return Object.keys(r).map(function(e){c[e]=normalizeNode(e,r[e],"block")}),Object.keys(o).map(function(e){c[e]=normalizeNode(e,o[e],"inline")}),Object.keys(i).map(function(e){c[e]=normalizeMark(e,i[e])}),c}function normalizeNode(e,t,r){if("function"==typeof t)return t;if("string"==typeof t&&(t={type:t}),(0,_isPlainObject2.default)(t))return function(e,n,o){var a=n.key,i=_objectWithoutProperties(n,["key"]),c=_extends({},t,{kind:r,key:a,data:_extends({},t.data||{},i)});return CREATORS[r](e,c,o)};throw new Error("Slate hyperscript "+r+" creators can be either functions, objects or strings, but you passed: "+t)}function normalizeMark(e,t){if("function"==typeof t)return t;if("string"==typeof t&&(t={type:t}),(0,_isPlainObject2.default)(t))return function(e,r,n){var o=_extends({},t,{data:_extends({},t.data||{},r)});return CREATORS.mark(e,o,n)};throw new Error("Slate hyperscript mark creators can be either functions, objects or strings, but you passed: "+t)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.createHyperscript=void 0;var _extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},_isEmpty=require("is-empty"),_isEmpty2=_interopRequireDefault(_isEmpty),_isPlainObject=require("is-plain-object"),_isPlainObject2=_interopRequireDefault(_isPlainObject),_slate=window.Slate,ANCHOR={},CURSOR={},FOCUS={},CREATORS={anchor:function(e,t,r){return ANCHOR},block:function(e,t,r){return _slate.Block.create(_extends({},t,{nodes:createChildren(r)}))},cursor:function(e,t,r){return CURSOR},document:function(e,t,r){return _slate.Document.create(_extends({},t,{nodes:createChildren(r)}))},focus:function(e,t,r){return FOCUS},inline:function(e,t,r){return _slate.Inline.create(_extends({},t,{nodes:createChildren(r)}))},mark:function(e,t,r){return createChildren(r,{marks:_slate.Mark.createSet([t])})},selection:function(e,t,r){return _slate.Range.create(t)},value:function(e,t,r){var n=t.data,o=r.find(_slate.Document.isDocument),a=r.find(_slate.Range.isRange)||_slate.Range.create(),i={};if(o&&o.getTexts().forEach(function(e){null!=e.__anchor&&(i.anchorKey=e.key,i.anchorOffset=e.__anchor,i.isFocused=!0),null!=e.__focus&&(i.focusKey=e.key,i.focusOffset=e.__focus,i.isFocused=!0)}),i.anchorKey&&!i.focusKey)throw new Error("Slate hyperscript must have both `<anchor/>` and `<focus/>` defined if one is defined, but you only defined `<anchor/>`. For collapsed selections, use `<cursor/>`.");if(!i.anchorKey&&i.focusKey)throw new Error("Slate hyperscript must have both `<anchor/>` and `<focus/>` defined if one is defined, but you only defined `<focus/>`. For collapsed selections, use `<cursor/>`.");return(0,_isEmpty2.default)(i)||(a=a.merge(i).normalize(o)),_slate.Value.create({data:n,document:o,selection:a})},text:function(e,t,r){return createChildren(r,{key:t.key})}};exports.default=createHyperscript(),exports.createHyperscript=createHyperscript},{"is-empty":1,"is-plain-object":2}]},{},[4])(4)});
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.SlateHyperscript=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){var has=Object.prototype.hasOwnProperty;var toString=Object.prototype.toString;function isEmpty(val){if(val==null)return true;if("boolean"==typeof val)return false;if("number"==typeof val)return val===0;if("string"==typeof val)return val.length===0;if("function"==typeof val)return val.length===0;if(Array.isArray(val))return val.length===0;if(val instanceof Error)return val.message==="";if(val.toString==toString){switch(val.toString()){case"[object File]":case"[object Map]":case"[object Set]":{return val.size===0}case"[object Object]":{for(var key in val){if(has.call(val,key))return false}return true}}}return false}module.exports=isEmpty},{}],2:[function(require,module,exports){"use strict";var isObject=require("isobject");function isObjectObject(o){return isObject(o)===true&&Object.prototype.toString.call(o)==="[object Object]"}module.exports=function isPlainObject(o){var ctor,prot;if(isObjectObject(o)===false)return false;ctor=o.constructor;if(typeof ctor!=="function")return false;prot=ctor.prototype;if(isObjectObject(prot)===false)return false;if(prot.hasOwnProperty("isPrototypeOf")===false){return false}return true}},{isobject:3}],3:[function(require,module,exports){"use strict";module.exports=function isObject(val){return val!=null&&typeof val==="object"&&Array.isArray(val)===false}},{}],4:[function(require,module,exports){"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _objectWithoutProperties(e,t){var r={};for(var n in e)t.indexOf(n)>=0||Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n]);return r}function createHyperscript(){function e(e,t){for(var n=arguments.length,o=Array(n>2?n-2:0),a=2;a<n;a++)o[a-2]=arguments[a];var c=r[e];if(!c)throw new Error('No hyperscript creator found for tag: "'+e+'"');return null==t&&(t={}),(0,_isPlainObject2.default)(t)||(o=[t].concat(o),t={}),o=o.filter(function(e){return Boolean(e)}).reduce(function(e,t){return e.concat(t)},[]),c(e,t,o)}var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=resolveCreators(t);return e}function createChildren(e){function t(e){var t=i,r=t.__anchor,n=t.__focus;null!=r&&(e.__anchor=r),null!=n&&(e.__focus=n),i=e}var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=[],o=0,a=e.find(function(e){return _slate.Text.isText(e)}),c=r.key?r.key:a?a.key:void 0,i=_slate.Text.create({key:c});return e.forEach(function(e){if(_slate.Node.isNode(e)&&!_slate.Text.isText(e)&&((i.text.length||null!=i.__anchor||null!=i.__focus)&&n.push(i),n.push(e),i=_slate.Text.create(),o=0),"string"==typeof e&&(t(i.insertText(i.text.length,e,r.marks)),o+=e.length),_slate.Text.isText(e)){var a=e.__anchor,c=e.__focus,s=i.text.length;r.key||0!=i.text.length||t(i.set("key",e.key)),e.getLeaves().forEach(function(e){var n=e.marks;r.marks&&(n=n.union(r.marks)),t(i.insertText(s,e.text,n)),s+=e.text.length}),null!=a&&(i.__anchor=a+o),null!=c&&(i.__focus=c+o),o+=e.text.length}e!=ANCHOR&&e!=CURSOR||(i.__anchor=o),e!=FOCUS&&e!=CURSOR||(i.__focus=o)}),n.push(i),n}function resolveCreators(e){var t=e.blocks,r=void 0===t?{}:t,n=e.inlines,o=void 0===n?{}:n,a=e.marks,c=void 0===a?{}:a,i=_extends({},CREATORS,e.creators||{});return Object.keys(r).map(function(e){i[e]=normalizeNode(e,r[e],"block")}),Object.keys(o).map(function(e){i[e]=normalizeNode(e,o[e],"inline")}),Object.keys(c).map(function(e){i[e]=normalizeMark(e,c[e])}),i}function normalizeNode(e,t,r){if("function"==typeof t)return t;if("string"==typeof t&&(t={type:t}),(0,_isPlainObject2.default)(t))return function(e,n,o){var a=n.key,c=_objectWithoutProperties(n,["key"]),i=_extends({},t,{object:r,key:a,data:_extends({},t.data||{},c)});return CREATORS[r](e,i,o)};throw new Error("Slate hyperscript "+r+" creators can be either functions, objects or strings, but you passed: "+t)}function normalizeMark(e,t){if("function"==typeof t)return t;if("string"==typeof t&&(t={type:t}),(0,_isPlainObject2.default)(t))return function(e,r,n){var o=_extends({},t,{data:_extends({},t.data||{},r)});return CREATORS.mark(e,o,n)};throw new Error("Slate hyperscript mark creators can be either functions, objects or strings, but you passed: "+t)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.createHyperscript=void 0;var _extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},_isEmpty=require("is-empty"),_isEmpty2=_interopRequireDefault(_isEmpty),_isPlainObject=require("is-plain-object"),_isPlainObject2=_interopRequireDefault(_isPlainObject),_slate=window.Slate,ANCHOR={},CURSOR={},FOCUS={},CREATORS={anchor:function(e,t,r){return ANCHOR},block:function(e,t,r){return _slate.Block.create(_extends({},t,{nodes:createChildren(r)}))},cursor:function(e,t,r){return CURSOR},document:function(e,t,r){return _slate.Document.create(_extends({},t,{nodes:createChildren(r)}))},focus:function(e,t,r){return FOCUS},inline:function(e,t,r){return _slate.Inline.create(_extends({},t,{nodes:createChildren(r)}))},mark:function(e,t,r){return createChildren(r,{marks:_slate.Mark.createSet([t])})},selection:function(e,t,r){return _slate.Range.create(t)},value:function(e,t,r){var n=t.data,o=r.find(_slate.Document.isDocument),a=r.find(_slate.Range.isRange)||_slate.Range.create(),c={};if(o&&o.getTexts().forEach(function(e){null!=e.__anchor&&(c.anchorKey=e.key,c.anchorOffset=e.__anchor,c.isFocused=!0),null!=e.__focus&&(c.focusKey=e.key,c.focusOffset=e.__focus,c.isFocused=!0)}),c.anchorKey&&!c.focusKey)throw new Error("Slate hyperscript must have both `<anchor/>` and `<focus/>` defined if one is defined, but you only defined `<anchor/>`. For collapsed selections, use `<cursor/>`.");if(!c.anchorKey&&c.focusKey)throw new Error("Slate hyperscript must have both `<anchor/>` and `<focus/>` defined if one is defined, but you only defined `<focus/>`. For collapsed selections, use `<cursor/>`.");return(0,_isEmpty2.default)(c)||(a=a.merge(c).normalize(o)),_slate.Value.create({data:n,document:o,selection:a})},text:function(e,t,r){return createChildren(r,{key:t.key})}};exports.default=createHyperscript(),exports.createHyperscript=createHyperscript},{"is-empty":1,"is-plain-object":2}]},{},[4])(4)});

@@ -285,11 +285,11 @@ 'use strict';

/**
* Normalize a node creator with `key` and `value`, of `kind`.
* Normalize a node creator with `key` and `value`, of `object`.
*
* @param {String} key
* @param {Function|Object|String} value
* @param {String} kind
* @param {String} object
* @return {Function}
*/
function normalizeNode(key, value, kind) {
function normalizeNode(key, value, object) {
if (typeof value == 'function') {

@@ -309,3 +309,3 @@ return value;

var attrs = _extends({}, value, {
kind: kind,
object: object,
key: attrKey,

@@ -315,7 +315,7 @@ data: _extends({}, value.data || {}, rest)

return CREATORS[kind](tagName, attrs, children);
return CREATORS[object](tagName, attrs, children);
};
}
throw new Error('Slate hyperscript ' + kind + ' creators can be either functions, objects or strings, but you passed: ' + value);
throw new Error('Slate hyperscript ' + object + ' creators can be either functions, objects or strings, but you passed: ' + value);
}

@@ -322,0 +322,0 @@

{
"name": "slate-hyperscript",
"description": "A hyperscript helper for creating Slate documents.",
"version": "0.4.16",
"version": "0.5.0",
"license": "MIT",

@@ -14,3 +14,3 @@ "repository": "git://github.com/ianstormtaylor/slate.git",

"peerDependencies": {
"slate": "^0.31.8"
"slate": "^0.32.0"
},

@@ -21,3 +21,3 @@ "devDependencies": {

"mocha": "^2.5.3",
"slate": "^0.31.8",
"slate": "^0.32.0",
"uglify-js": "^2.7.0"

@@ -24,0 +24,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc