slate-hyperscript
Advanced tools
Comparing version 0.2.8 to 0.3.0
@@ -10,2 +10,16 @@ | ||
### `0.3.0` — October 27, 2017 | ||
###### BREAKING | ||
- **Updated to work with `slate@0.29.0`.** This is required because `slate-hyperscript` needs access to the new `Value` model. | ||
###### DEPRECATED | ||
- **The `<state>` tag has been renamed to `<value>`.** This is to stay in line with the newest version of Slate where the `State` object was renamed to `Value`. | ||
--- | ||
### `0.2.0` — October 14, 2017 | ||
@@ -12,0 +26,0 @@ |
@@ -136,2 +136,185 @@ (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){ | ||
},{}],4:[function(require,module,exports){ | ||
// shim for using process in browser | ||
var process = module.exports = {}; | ||
// cached from whatever global is present so that test runners that stub it | ||
// don't break things. But we need to wrap it in a try catch in case it is | ||
// wrapped in strict mode code which doesn't define any globals. It's inside a | ||
// function because try/catches deoptimize in certain engines. | ||
var cachedSetTimeout; | ||
var cachedClearTimeout; | ||
function defaultSetTimout() { | ||
throw new Error('setTimeout has not been defined'); | ||
} | ||
function defaultClearTimeout () { | ||
throw new Error('clearTimeout has not been defined'); | ||
} | ||
(function () { | ||
try { | ||
if (typeof setTimeout === 'function') { | ||
cachedSetTimeout = setTimeout; | ||
} else { | ||
cachedSetTimeout = defaultSetTimout; | ||
} | ||
} catch (e) { | ||
cachedSetTimeout = defaultSetTimout; | ||
} | ||
try { | ||
if (typeof clearTimeout === 'function') { | ||
cachedClearTimeout = clearTimeout; | ||
} else { | ||
cachedClearTimeout = defaultClearTimeout; | ||
} | ||
} catch (e) { | ||
cachedClearTimeout = defaultClearTimeout; | ||
} | ||
} ()) | ||
function runTimeout(fun) { | ||
if (cachedSetTimeout === setTimeout) { | ||
//normal enviroments in sane situations | ||
return setTimeout(fun, 0); | ||
} | ||
// if setTimeout wasn't available but was latter defined | ||
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { | ||
cachedSetTimeout = setTimeout; | ||
return setTimeout(fun, 0); | ||
} | ||
try { | ||
// when when somebody has screwed with setTimeout but no I.E. maddness | ||
return cachedSetTimeout(fun, 0); | ||
} catch(e){ | ||
try { | ||
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally | ||
return cachedSetTimeout.call(null, fun, 0); | ||
} catch(e){ | ||
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error | ||
return cachedSetTimeout.call(this, fun, 0); | ||
} | ||
} | ||
} | ||
function runClearTimeout(marker) { | ||
if (cachedClearTimeout === clearTimeout) { | ||
//normal enviroments in sane situations | ||
return clearTimeout(marker); | ||
} | ||
// if clearTimeout wasn't available but was latter defined | ||
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { | ||
cachedClearTimeout = clearTimeout; | ||
return clearTimeout(marker); | ||
} | ||
try { | ||
// when when somebody has screwed with setTimeout but no I.E. maddness | ||
return cachedClearTimeout(marker); | ||
} catch (e){ | ||
try { | ||
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally | ||
return cachedClearTimeout.call(null, marker); | ||
} catch (e){ | ||
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. | ||
// Some versions of I.E. have different rules for clearTimeout vs setTimeout | ||
return cachedClearTimeout.call(this, marker); | ||
} | ||
} | ||
} | ||
var queue = []; | ||
var draining = false; | ||
var currentQueue; | ||
var queueIndex = -1; | ||
function cleanUpNextTick() { | ||
if (!draining || !currentQueue) { | ||
return; | ||
} | ||
draining = false; | ||
if (currentQueue.length) { | ||
queue = currentQueue.concat(queue); | ||
} else { | ||
queueIndex = -1; | ||
} | ||
if (queue.length) { | ||
drainQueue(); | ||
} | ||
} | ||
function drainQueue() { | ||
if (draining) { | ||
return; | ||
} | ||
var timeout = runTimeout(cleanUpNextTick); | ||
draining = true; | ||
var len = queue.length; | ||
while(len) { | ||
currentQueue = queue; | ||
queue = []; | ||
while (++queueIndex < len) { | ||
if (currentQueue) { | ||
currentQueue[queueIndex].run(); | ||
} | ||
} | ||
queueIndex = -1; | ||
len = queue.length; | ||
} | ||
currentQueue = null; | ||
draining = false; | ||
runClearTimeout(timeout); | ||
} | ||
process.nextTick = function (fun) { | ||
var args = new Array(arguments.length - 1); | ||
if (arguments.length > 1) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
args[i - 1] = arguments[i]; | ||
} | ||
} | ||
queue.push(new Item(fun, args)); | ||
if (queue.length === 1 && !draining) { | ||
runTimeout(drainQueue); | ||
} | ||
}; | ||
// v8 likes predictible objects | ||
function Item(fun, array) { | ||
this.fun = fun; | ||
this.array = array; | ||
} | ||
Item.prototype.run = function () { | ||
this.fun.apply(null, this.array); | ||
}; | ||
process.title = 'browser'; | ||
process.browser = true; | ||
process.env = {}; | ||
process.argv = []; | ||
process.version = ''; // empty string to avoid regexp issues | ||
process.versions = {}; | ||
function noop() {} | ||
process.on = noop; | ||
process.addListener = noop; | ||
process.once = noop; | ||
process.off = noop; | ||
process.removeListener = noop; | ||
process.removeAllListeners = noop; | ||
process.emit = noop; | ||
process.binding = function (name) { | ||
throw new Error('process.binding is not supported'); | ||
}; | ||
process.cwd = function () { return '/' }; | ||
process.chdir = function (dir) { | ||
throw new Error('process.chdir is not supported'); | ||
}; | ||
process.umask = function() { return 0; }; | ||
},{}],5:[function(require,module,exports){ | ||
(function (process){ | ||
'use strict'; | ||
@@ -142,2 +325,113 @@ | ||
}); | ||
/* eslint-disable no-console */ | ||
/** | ||
* Is in development? | ||
* | ||
* @type {Boolean} | ||
*/ | ||
var IS_DEV = typeof process !== 'undefined' && process.env && process.env.NODE_ENV !== 'production'; | ||
/** | ||
* Has console? | ||
* | ||
* @type {Boolean} | ||
*/ | ||
var HAS_CONSOLE = typeof console != 'undefined' && typeof console.log == 'function' && typeof console.warn == 'function' && typeof console.error == 'function'; | ||
/** | ||
* Log a `message` at `level`. | ||
* | ||
* @param {String} level | ||
* @param {String} message | ||
* @param {Any} ...args | ||
*/ | ||
function log(level, message) { | ||
if (!IS_DEV) { | ||
return; | ||
} | ||
if (HAS_CONSOLE) { | ||
var _console; | ||
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { | ||
args[_key - 2] = arguments[_key]; | ||
} | ||
(_console = console)[level].apply(_console, [message].concat(args)); | ||
} | ||
} | ||
/** | ||
* Log an error `message`. | ||
* | ||
* @param {String} message | ||
* @param {Any} ...args | ||
*/ | ||
function error(message) { | ||
if (HAS_CONSOLE) { | ||
var _console2; | ||
for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | ||
args[_key2 - 1] = arguments[_key2]; | ||
} | ||
(_console2 = console).error.apply(_console2, [message].concat(args)); | ||
} | ||
} | ||
/** | ||
* Log a warning `message` in development only. | ||
* | ||
* @param {String} message | ||
* @param {Any} ...args | ||
*/ | ||
function warn(message) { | ||
for (var _len3 = arguments.length, args = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { | ||
args[_key3 - 1] = arguments[_key3]; | ||
} | ||
log.apply(undefined, ['warn', 'Warning: ' + message].concat(args)); | ||
} | ||
/** | ||
* Log a deprecation warning `message`, with helpful `version` number in | ||
* development only. | ||
* | ||
* @param {String} version | ||
* @param {String} message | ||
* @param {Any} ...args | ||
*/ | ||
function deprecate(version, message) { | ||
for (var _len4 = arguments.length, args = Array(_len4 > 2 ? _len4 - 2 : 0), _key4 = 2; _key4 < _len4; _key4++) { | ||
args[_key4 - 2] = arguments[_key4]; | ||
} | ||
log.apply(undefined, ['warn', 'Deprecation (' + version + '): ' + message].concat(args)); | ||
} | ||
/** | ||
* Export. | ||
* | ||
* @type {Function} | ||
*/ | ||
exports.default = { | ||
deprecate: deprecate, | ||
error: error, | ||
warn: warn | ||
}; | ||
}).call(this,require('_process')) | ||
},{"_process":4}],6:[function(require,module,exports){ | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.createHyperscript = undefined; | ||
@@ -155,2 +449,6 @@ | ||
var _slateDevLogger = require('slate-dev-logger'); | ||
var _slateDevLogger2 = _interopRequireDefault(_slateDevLogger); | ||
var _slate = (window.Slate); | ||
@@ -211,3 +509,7 @@ | ||
}, | ||
state: function state(tagName, attributes, children) { | ||
state: function state() { | ||
_slateDevLogger2.default.deprecate('slate-hyperscript@0.3.0', 'The `<state>` tag has been renamed to `<value>`.'); | ||
return CREATORS.value.apply(CREATORS, arguments); | ||
}, | ||
value: function value(tagName, attributes, children) { | ||
var data = attributes.data; | ||
@@ -249,4 +551,4 @@ | ||
var state = _slate.State.create({ data: data, document: document, selection: selection }); | ||
return state; | ||
var value = _slate.Value.create({ data: data, document: document, selection: selection }); | ||
return value; | ||
}, | ||
@@ -499,3 +801,3 @@ text: function text(tagName, attributes, children) { | ||
},{"is-empty":1,"is-plain-object":2}]},{},[4])(4) | ||
},{"is-empty":1,"is-plain-object":2,"slate-dev-logger":5}]},{},[6])(6) | ||
}); |
@@ -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)},state: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.State.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){var process=module.exports={};var cachedSetTimeout;var cachedClearTimeout;function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}(function(){try{if(typeof setTimeout==="function"){cachedSetTimeout=setTimeout}else{cachedSetTimeout=defaultSetTimout}}catch(e){cachedSetTimeout=defaultSetTimout}try{if(typeof clearTimeout==="function"){cachedClearTimeout=clearTimeout}else{cachedClearTimeout=defaultClearTimeout}}catch(e){cachedClearTimeout=defaultClearTimeout}})();function runTimeout(fun){if(cachedSetTimeout===setTimeout){return setTimeout(fun,0)}if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout){cachedSetTimeout=setTimeout;return setTimeout(fun,0)}try{return cachedSetTimeout(fun,0)}catch(e){try{return cachedSetTimeout.call(null,fun,0)}catch(e){return cachedSetTimeout.call(this,fun,0)}}}function runClearTimeout(marker){if(cachedClearTimeout===clearTimeout){return clearTimeout(marker)}if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout){cachedClearTimeout=clearTimeout;return clearTimeout(marker)}try{return cachedClearTimeout(marker)}catch(e){try{return cachedClearTimeout.call(null,marker)}catch(e){return cachedClearTimeout.call(this,marker)}}}var queue=[];var draining=false;var currentQueue;var queueIndex=-1;function cleanUpNextTick(){if(!draining||!currentQueue){return}draining=false;if(currentQueue.length){queue=currentQueue.concat(queue)}else{queueIndex=-1}if(queue.length){drainQueue()}}function drainQueue(){if(draining){return}var timeout=runTimeout(cleanUpNextTick);draining=true;var len=queue.length;while(len){currentQueue=queue;queue=[];while(++queueIndex<len){if(currentQueue){currentQueue[queueIndex].run()}}queueIndex=-1;len=queue.length}currentQueue=null;draining=false;runClearTimeout(timeout)}process.nextTick=function(fun){var args=new Array(arguments.length-1);if(arguments.length>1){for(var i=1;i<arguments.length;i++){args[i-1]=arguments[i]}}queue.push(new Item(fun,args));if(queue.length===1&&!draining){runTimeout(drainQueue)}};function Item(fun,array){this.fun=fun;this.array=array}Item.prototype.run=function(){this.fun.apply(null,this.array)};process.title="browser";process.browser=true;process.env={};process.argv=[];process.version="";process.versions={};function noop(){}process.on=noop;process.addListener=noop;process.once=noop;process.off=noop;process.removeListener=noop;process.removeAllListeners=noop;process.emit=noop;process.binding=function(name){throw new Error("process.binding is not supported")};process.cwd=function(){return"/"};process.chdir=function(dir){throw new Error("process.chdir is not supported")};process.umask=function(){return 0}},{}],5:[function(require,module,exports){(function(process){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var IS_DEV=typeof process!=="undefined"&&process.env&&process.env.NODE_ENV!=="production";var HAS_CONSOLE=typeof console!="undefined"&&typeof console.log=="function"&&typeof console.warn=="function"&&typeof console.error=="function";function log(level,message){if(!IS_DEV){return}if(HAS_CONSOLE){var _console;for(var _len=arguments.length,args=Array(_len>2?_len-2:0),_key=2;_key<_len;_key++){args[_key-2]=arguments[_key]}(_console=console)[level].apply(_console,[message].concat(args))}}function error(message){if(HAS_CONSOLE){var _console2;for(var _len2=arguments.length,args=Array(_len2>1?_len2-1:0),_key2=1;_key2<_len2;_key2++){args[_key2-1]=arguments[_key2]}(_console2=console).error.apply(_console2,[message].concat(args))}}function warn(message){for(var _len3=arguments.length,args=Array(_len3>1?_len3-1:0),_key3=1;_key3<_len3;_key3++){args[_key3-1]=arguments[_key3]}log.apply(undefined,["warn","Warning: "+message].concat(args))}function deprecate(version,message){for(var _len4=arguments.length,args=Array(_len4>2?_len4-2:0),_key4=2;_key4<_len4;_key4++){args[_key4-2]=arguments[_key4]}log.apply(undefined,["warn","Deprecation ("+version+"): "+message].concat(args))}exports.default={deprecate:deprecate,error:error,warn:warn}}).call(this,require("_process"))},{_process:4}],6:[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 s=r[e];if(!s)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)},[]),s(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)}),s=r.key?r.key:a?a.key:void 0,i=_slate.Text.create({key:s});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,s=e.__focus,c=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(c,e.text,n)),c+=e.text.length}),null!=a&&(i.__anchor=a+o),null!=s&&(i.__focus=s+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,s=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(s).map(function(e){i[e]=normalizeMark(e,s[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,s=_objectWithoutProperties(n,["key"]),i=_extends({},t,{kind:r,key:a,data:_extends({},t.data||{},s)});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),_slateDevLogger=require("slate-dev-logger"),_slateDevLogger2=_interopRequireDefault(_slateDevLogger),_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)},state:function(){return _slateDevLogger2.default.deprecate("slate-hyperscript@0.3.0","The `<state>` tag has been renamed to `<value>`."),CREATORS.value.apply(CREATORS,arguments)},value:function(e,t,r){var n=t.data,o=r.find(_slate.Document.isDocument),a=r.find(_slate.Range.isRange)||_slate.Range.create(),s={};if(o&&o.getTexts().forEach(function(e){null!=e.__anchor&&(s.anchorKey=e.key,s.anchorOffset=e.__anchor,s.isFocused=!0),null!=e.__focus&&(s.focusKey=e.key,s.focusOffset=e.__focus,s.isFocused=!0)}),s.anchorKey&&!s.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(!s.anchorKey&&s.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)(s)||(a=a.merge(s).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,"slate-dev-logger":5}]},{},[6])(6)}); |
@@ -18,2 +18,6 @@ 'use strict'; | ||
var _slateDevLogger = require('slate-dev-logger'); | ||
var _slateDevLogger2 = _interopRequireDefault(_slateDevLogger); | ||
var _slate = require('slate'); | ||
@@ -74,3 +78,7 @@ | ||
}, | ||
state: function state(tagName, attributes, children) { | ||
state: function state() { | ||
_slateDevLogger2.default.deprecate('slate-hyperscript@0.3.0', 'The `<state>` tag has been renamed to `<value>`.'); | ||
return CREATORS.value.apply(CREATORS, arguments); | ||
}, | ||
value: function value(tagName, attributes, children) { | ||
var data = attributes.data; | ||
@@ -112,4 +120,4 @@ | ||
var state = _slate.State.create({ data: data, document: document, selection: selection }); | ||
return state; | ||
var value = _slate.Value.create({ data: data, document: document, selection: selection }); | ||
return value; | ||
}, | ||
@@ -116,0 +124,0 @@ text: function text(tagName, attributes, children) { |
{ | ||
"name": "slate-hyperscript", | ||
"description": "A hyperscript helper for creating Slate documents.", | ||
"version": "0.2.8", | ||
"version": "0.3.0", | ||
"license": "MIT", | ||
@@ -10,6 +10,7 @@ "repository": "git://github.com/ianstormtaylor/slate.git", | ||
"is-empty": "^1.0.0", | ||
"is-plain-object": "^2.0.4" | ||
"is-plain-object": "^2.0.4", | ||
"slate-dev-logger": "^0.1.24" | ||
}, | ||
"peerDependencies": { | ||
"slate": "^0.28.2" | ||
"slate": "^0.29.0" | ||
}, | ||
@@ -20,3 +21,3 @@ "devDependencies": { | ||
"mocha": "^2.5.3", | ||
"slate": "^0.28.2", | ||
"slate": "^0.29.0", | ||
"uglify-js": "^2.7.0" | ||
@@ -23,0 +24,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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances 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
46787
985
4
11
+ Addedslate-dev-logger@^0.1.24
+ Addedslate@0.29.1(transitive)
- Removedslate@0.28.2(transitive)