@vericus/slate-kit-align
Advanced tools
Comparing version 0.2.21 to 0.2.22
@@ -32,3 +32,3 @@ function removeAlign(opts) { | ||
removeAlign: removeAlign(opts), | ||
setAlign: setAlign(opts) | ||
setAlign: setAlign(opts), | ||
}; | ||
@@ -35,0 +35,0 @@ } |
@@ -11,7 +11,7 @@ import * as tslib_1 from "tslib"; | ||
"heading-four", | ||
"blockquote" | ||
"blockquote", | ||
], | ||
alignments: ["left", "right", "center", "justify"], | ||
dataField: "textAlign", | ||
label: "align" | ||
label: "align", | ||
}; | ||
@@ -18,0 +18,0 @@ var Options = /** @class */ (function (_super) { |
@@ -11,3 +11,3 @@ import getAlignBlocks, { getAlignBlocksInBlock } from "./getAlignBlocks"; | ||
isAligned: function (editor, alignment) { return isAligned(opts, editor, alignment); }, | ||
isAlignable: function (editor) { return isAlignable(opts, editor); } | ||
isAlignable: function (editor) { return isAlignable(opts, editor); }, | ||
}; | ||
@@ -14,0 +14,0 @@ } |
@@ -20,3 +20,3 @@ import * as tslib_1 from "tslib"; | ||
editor.setNodeByKey(error.node.key, { | ||
data: error.node.data.delete(dataField) | ||
data: error.node.data.delete(dataField), | ||
}); | ||
@@ -26,7 +26,7 @@ } | ||
} | ||
} | ||
}, | ||
}, _a))); | ||
}, {}) | ||
}, {}), | ||
}; | ||
} | ||
//# sourceMappingURL=index.js.map |
@@ -68,3 +68,3 @@ exports.__esModule = true; | ||
if (i % 2) { | ||
ownKeys(source, true).forEach(function (key) { | ||
ownKeys(Object(source), true).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
@@ -75,3 +75,3 @@ }); | ||
} else { | ||
ownKeys(source).forEach(function (key) { | ||
ownKeys(Object(source)).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
@@ -116,2 +116,15 @@ }); | ||
function _isNativeReflectConstruct() { | ||
if (typeof Reflect === "undefined" || !Reflect.construct) return false; | ||
if (Reflect.construct.sham) return false; | ||
if (typeof Proxy === "function") return true; | ||
try { | ||
Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
function _assertThisInitialized(self) { | ||
@@ -133,20 +146,52 @@ if (self === void 0) { | ||
function _createSuper(Derived) { | ||
var hasNativeReflectConstruct = _isNativeReflectConstruct(); | ||
return function () { | ||
var Super = _getPrototypeOf(Derived), | ||
result; | ||
if (hasNativeReflectConstruct) { | ||
var NewTarget = _getPrototypeOf(this).constructor; | ||
result = Reflect.construct(Super, arguments, NewTarget); | ||
} else { | ||
result = Super.apply(this, arguments); | ||
} | ||
return _possibleConstructorReturn(this, result); | ||
}; | ||
} | ||
function _toConsumableArray(arr) { | ||
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); | ||
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); | ||
} | ||
function _arrayWithoutHoles(arr) { | ||
if (Array.isArray(arr)) { | ||
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
if (Array.isArray(arr)) return _arrayLikeToArray(arr); | ||
} | ||
function _iterableToArray(iter) { | ||
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); | ||
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); | ||
} | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _nonIterableSpread() { | ||
throw new TypeError("Invalid attempt to spread non-iterable instance"); | ||
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
@@ -162,11 +207,11 @@ | ||
var Options = | ||
/*#__PURE__*/ | ||
function (_Record) { | ||
var Options = /*#__PURE__*/function (_Record) { | ||
_inherits(Options, _Record); | ||
var _super = _createSuper(Options); | ||
function Options() { | ||
_classCallCheck(this, Options); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(Options).apply(this, arguments)); | ||
return _super.apply(this, arguments); | ||
} | ||
@@ -177,3 +222,3 @@ | ||
value: function create(option) { | ||
var options = _objectSpread2({}, defaultOption, {}, option, { | ||
var options = _objectSpread2(_objectSpread2(_objectSpread2({}, defaultOption), option), {}, { | ||
floatBlocks: [].concat(_toConsumableArray(defaultOption.floatBlocks), _toConsumableArray(option.floatBlocks ? option.floatBlocks : [])), | ||
@@ -304,3 +349,3 @@ alignments: [].concat(_toConsumableArray(defaultOption.alignments), _toConsumableArray(option.alignments ? option.alignments : [])), | ||
if (textBlocks.includes(props.node.type)) { | ||
style = _objectSpread2({}, style, { | ||
style = _objectSpread2(_objectSpread2({}, style), {}, { | ||
textAlign: alignment | ||
@@ -311,3 +356,3 @@ }); | ||
if (floatBlocks.includes(props.node.type)) { | ||
style = _objectSpread2({}, style, { | ||
style = _objectSpread2(_objectSpread2({}, style), {}, { | ||
"float": alignment | ||
@@ -317,4 +362,4 @@ }); | ||
return _objectSpread2({}, props, { | ||
attributes: _objectSpread2({}, props.attributes, { | ||
return _objectSpread2(_objectSpread2({}, props), {}, { | ||
attributes: _objectSpread2(_objectSpread2({}, props.attributes), {}, { | ||
style: style | ||
@@ -334,3 +379,3 @@ }) | ||
blocks: alignBlocks.reduce(function (acc, block) { | ||
return _objectSpread2({}, acc, _defineProperty({}, block, { | ||
return _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty({}, block, { | ||
data: _defineProperty({}, dataField, function (align) { | ||
@@ -337,0 +382,0 @@ return !align || align && alignments.includes(align); |
@@ -61,3 +61,3 @@ import Register from '@vericus/slate-kit-utils-register-helpers'; | ||
if (i % 2) { | ||
ownKeys(source, true).forEach(function (key) { | ||
ownKeys(Object(source), true).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
@@ -68,3 +68,3 @@ }); | ||
} else { | ||
ownKeys(source).forEach(function (key) { | ||
ownKeys(Object(source)).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
@@ -109,2 +109,15 @@ }); | ||
function _isNativeReflectConstruct() { | ||
if (typeof Reflect === "undefined" || !Reflect.construct) return false; | ||
if (Reflect.construct.sham) return false; | ||
if (typeof Proxy === "function") return true; | ||
try { | ||
Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
function _assertThisInitialized(self) { | ||
@@ -126,20 +139,52 @@ if (self === void 0) { | ||
function _createSuper(Derived) { | ||
var hasNativeReflectConstruct = _isNativeReflectConstruct(); | ||
return function () { | ||
var Super = _getPrototypeOf(Derived), | ||
result; | ||
if (hasNativeReflectConstruct) { | ||
var NewTarget = _getPrototypeOf(this).constructor; | ||
result = Reflect.construct(Super, arguments, NewTarget); | ||
} else { | ||
result = Super.apply(this, arguments); | ||
} | ||
return _possibleConstructorReturn(this, result); | ||
}; | ||
} | ||
function _toConsumableArray(arr) { | ||
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); | ||
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); | ||
} | ||
function _arrayWithoutHoles(arr) { | ||
if (Array.isArray(arr)) { | ||
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
if (Array.isArray(arr)) return _arrayLikeToArray(arr); | ||
} | ||
function _iterableToArray(iter) { | ||
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); | ||
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); | ||
} | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _nonIterableSpread() { | ||
throw new TypeError("Invalid attempt to spread non-iterable instance"); | ||
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
@@ -155,11 +200,11 @@ | ||
var Options = | ||
/*#__PURE__*/ | ||
function (_Record) { | ||
var Options = /*#__PURE__*/function (_Record) { | ||
_inherits(Options, _Record); | ||
var _super = _createSuper(Options); | ||
function Options() { | ||
_classCallCheck(this, Options); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(Options).apply(this, arguments)); | ||
return _super.apply(this, arguments); | ||
} | ||
@@ -170,3 +215,3 @@ | ||
value: function create(option) { | ||
var options = _objectSpread2({}, defaultOption, {}, option, { | ||
var options = _objectSpread2(_objectSpread2(_objectSpread2({}, defaultOption), option), {}, { | ||
floatBlocks: [].concat(_toConsumableArray(defaultOption.floatBlocks), _toConsumableArray(option.floatBlocks ? option.floatBlocks : [])), | ||
@@ -297,3 +342,3 @@ alignments: [].concat(_toConsumableArray(defaultOption.alignments), _toConsumableArray(option.alignments ? option.alignments : [])), | ||
if (textBlocks.includes(props.node.type)) { | ||
style = _objectSpread2({}, style, { | ||
style = _objectSpread2(_objectSpread2({}, style), {}, { | ||
textAlign: alignment | ||
@@ -304,3 +349,3 @@ }); | ||
if (floatBlocks.includes(props.node.type)) { | ||
style = _objectSpread2({}, style, { | ||
style = _objectSpread2(_objectSpread2({}, style), {}, { | ||
"float": alignment | ||
@@ -310,4 +355,4 @@ }); | ||
return _objectSpread2({}, props, { | ||
attributes: _objectSpread2({}, props.attributes, { | ||
return _objectSpread2(_objectSpread2({}, props), {}, { | ||
attributes: _objectSpread2(_objectSpread2({}, props.attributes), {}, { | ||
style: style | ||
@@ -327,3 +372,3 @@ }) | ||
blocks: alignBlocks.reduce(function (acc, block) { | ||
return _objectSpread2({}, acc, _defineProperty({}, block, { | ||
return _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty({}, block, { | ||
data: _defineProperty({}, dataField, function (align) { | ||
@@ -330,0 +375,0 @@ return !align || align && alignments.includes(align); |
@@ -13,3 +13,3 @@ (function (global, factory) { | ||
} | ||
})(this, function (_exports, _slateKitUtilsRegisterHelpers, _immutable, _slate) { | ||
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _slateKitUtilsRegisterHelpers, _immutable, _slate) { | ||
@@ -78,3 +78,3 @@ _exports.__esModule = true; | ||
if (i % 2) { | ||
ownKeys(source, true).forEach(function (key) { | ||
ownKeys(Object(source), true).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
@@ -85,3 +85,3 @@ }); | ||
} else { | ||
ownKeys(source).forEach(function (key) { | ||
ownKeys(Object(source)).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
@@ -126,2 +126,15 @@ }); | ||
function _isNativeReflectConstruct() { | ||
if (typeof Reflect === "undefined" || !Reflect.construct) return false; | ||
if (Reflect.construct.sham) return false; | ||
if (typeof Proxy === "function") return true; | ||
try { | ||
Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
function _assertThisInitialized(self) { | ||
@@ -143,20 +156,52 @@ if (self === void 0) { | ||
function _createSuper(Derived) { | ||
var hasNativeReflectConstruct = _isNativeReflectConstruct(); | ||
return function () { | ||
var Super = _getPrototypeOf(Derived), | ||
result; | ||
if (hasNativeReflectConstruct) { | ||
var NewTarget = _getPrototypeOf(this).constructor; | ||
result = Reflect.construct(Super, arguments, NewTarget); | ||
} else { | ||
result = Super.apply(this, arguments); | ||
} | ||
return _possibleConstructorReturn(this, result); | ||
}; | ||
} | ||
function _toConsumableArray(arr) { | ||
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); | ||
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); | ||
} | ||
function _arrayWithoutHoles(arr) { | ||
if (Array.isArray(arr)) { | ||
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
if (Array.isArray(arr)) return _arrayLikeToArray(arr); | ||
} | ||
function _iterableToArray(iter) { | ||
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); | ||
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); | ||
} | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _nonIterableSpread() { | ||
throw new TypeError("Invalid attempt to spread non-iterable instance"); | ||
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
@@ -172,11 +217,11 @@ | ||
var Options = | ||
/*#__PURE__*/ | ||
function (_Record) { | ||
var Options = /*#__PURE__*/function (_Record) { | ||
_inherits(Options, _Record); | ||
var _super = _createSuper(Options); | ||
function Options() { | ||
_classCallCheck(this, Options); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(Options).apply(this, arguments)); | ||
return _super.apply(this, arguments); | ||
} | ||
@@ -187,3 +232,3 @@ | ||
value: function create(option) { | ||
var options = _objectSpread2({}, defaultOption, {}, option, { | ||
var options = _objectSpread2(_objectSpread2(_objectSpread2({}, defaultOption), option), {}, { | ||
floatBlocks: [].concat(_toConsumableArray(defaultOption.floatBlocks), _toConsumableArray(option.floatBlocks ? option.floatBlocks : [])), | ||
@@ -314,3 +359,3 @@ alignments: [].concat(_toConsumableArray(defaultOption.alignments), _toConsumableArray(option.alignments ? option.alignments : [])), | ||
if (textBlocks.includes(props.node.type)) { | ||
style = _objectSpread2({}, style, { | ||
style = _objectSpread2(_objectSpread2({}, style), {}, { | ||
textAlign: alignment | ||
@@ -321,3 +366,3 @@ }); | ||
if (floatBlocks.includes(props.node.type)) { | ||
style = _objectSpread2({}, style, { | ||
style = _objectSpread2(_objectSpread2({}, style), {}, { | ||
"float": alignment | ||
@@ -327,4 +372,4 @@ }); | ||
return _objectSpread2({}, props, { | ||
attributes: _objectSpread2({}, props.attributes, { | ||
return _objectSpread2(_objectSpread2({}, props), {}, { | ||
attributes: _objectSpread2(_objectSpread2({}, props.attributes), {}, { | ||
style: style | ||
@@ -344,3 +389,3 @@ }) | ||
blocks: alignBlocks.reduce(function (acc, block) { | ||
return _objectSpread2({}, acc, _defineProperty({}, block, { | ||
return _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty({}, block, { | ||
data: _defineProperty({}, dataField, function (align) { | ||
@@ -347,0 +392,0 @@ return !align || align && alignments.includes(align); |
@@ -1,1 +0,1 @@ | ||
!function(t,e){if("function"==typeof define&&define.amd)define(["exports","@vericus/slate-kit-utils-register-helpers","immutable","slate"],e);else if("undefined"!=typeof exports)e(exports,require("@vericus/slate-kit-utils-register-helpers"),require("immutable"),require("slate"));else{var n={exports:{}};e(n.exports,t.slateKitUtilsRegisterHelpers,t.immutable,t.slate),t.unknown=n.exports}}(this,function(t,e,n,r){var o;function i(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function a(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function l(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function u(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?l(n,!0).forEach(function(e){a(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):l(n).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function c(t){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function f(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function d(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}t.__esModule=!0,t.default=void 0,e=(o=e)&&o.__esModule?o:{default:o};var g={floatBlocks:[],textBlocks:["paragraph","heading-one","heading-two","heading-three","heading-four","blockquote"],alignments:["left","right","center","justify"],dataField:"textAlign",label:"align"},p=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),f(this,c(e).apply(this,arguments))}var r,o,a;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}(e,(0,n.Record)(g)),r=e,a=[{key:"create",value:function(t){return new e(u({},g,{},t,{floatBlocks:[].concat(d(g.floatBlocks),d(t.floatBlocks?t.floatBlocks:[])),alignments:[].concat(d(g.alignments),d(t.alignments?t.alignments:[])),textBlocks:[].concat(d(g.textBlocks),d(t.textBlocks?t.textBlocks:[]))}))}}],(o=null)&&i(r.prototype,o),a&&i(r,a),e}();function y(t,e){if(!e||!r.Block.isBlock(e))return[];var n=t.textBlocks,o=t.floatBlocks;return e.isLeafBlock()?n.includes(e.type)||o.includes(e.type)?[e]:[]:e.nodes.reduce(function(e,n){return[].concat(d(e),d(y(t,n)))},[])}function b(t){return{getAlignBlocks:function(e){return function(t,e){var r=e.getHighestSelectedBlocks();return 0===r.size?[]:(0,n.List)(r).reduce(function(e,n){return[].concat(d(e),d(y(t,n)))},[])}(t,e)},getAlignBlocksInBlock:function(e,n){return y(t,n)},getAlignment:function(e,n){return function(t,e){var n=t.dataField;return e&&e.data.get(n)||"left"}(t,n)},isAligned:function(e,n){return function(t,e,n){var r=e.getAlignBlocks(t);return 0!==r.length&&r.every(function(t){return t&&e.getAlignment(t)===n})}(t,e,n)},isAlignable:function(t){return function(t,e){return 0!==e.getAlignBlocks().length}(0,t)}}}function h(t){var e=t.dataField;return function(t,n){var r=t.value;t.withoutNormalizing(function(){t.getAlignBlocks(r).filter(function(t){return n&&t.data&&t.data.get(e)===n}).forEach(function(n){return t.setNodeByKey(n.key,{data:n.data.delete(e)})})})}}function v(t){var e=t.dataField;return function(n,r){var o=n.value,i=t.alignments;i&&i.includes(r)&&n.withoutNormalizing(function(){n.getAlignBlocks(o).forEach(function(t){n.setNodeByKey(t.key,{data:t.data.set(e,r)})})})}}var k=[].concat(["div","p","h1","h2","h3","h4","h5","h6"],["div","p","h1","h2","h3","img"]),m=["left","center","right","justify"];function B(t){var e=t.dataField;return{getData:function(t,n){return function(t,e){if(!e||!t.tagName||!k.includes(t.tagName.toLowerCase()))return{};if(t.style&&"string"==typeof t.style.textAlign){var n=t.style.textAlign;if(n&&m.includes(n))return{data:a({},e,n)}}if(t.getAttribute("align")){var r=t.getAttribute("align");if(r&&m.includes(r))return{data:a({},e,r)}}if(t.style&&"string"==typeof t.style.cssFloat&&"clear"!==t.style.cssFloat){var o=t.style.cssFloat;if(o&&m.includes(o))return{data:a({},e,o)}}return{}}(n,e)}}}var O=function(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=p.create(n),i=b(o),l={removeAlign:h(t=o),setAlign:v(t)},c=function(t){var e=t.floatBlocks,n=t.textBlocks;return function(t){if(!t.node||"block"!==t.node.object||!n.includes(t.node.type)&&!e.includes(t.node.type))return t;var r=t.editor.getAlignment(t.node),o=t.attributes&&t.attributes.style||{};return n.includes(t.node.type)&&(o=u({},o,{textAlign:r})),e.includes(t.node.type)&&(o=u({},o,{float:r})),u({},t,{attributes:u({},t.attributes,{style:o})})}}(o),s=function(t){var e=t.floatBlocks,n=t.textBlocks,o=t.dataField,i=t.alignments;return{blocks:[].concat(d(e),d(n)).reduce(function(t,e){return u({},t,a({},e,{data:a({},o,function(t){return!t||t&&i.includes(t)}),normalize:function(t,e){"node_data_invalid"===e.code&&t.withoutNormalizing(function(){r.Text.isText(e.node)||t.setNodeByKey(e.node.key,{data:e.node.data.delete(o)})})}}))},{})}}(o),f=B(o).getData;return[(0,e.default)({props:c,getData:f,options:o}),{queries:i,commands:l,schema:s}]};t.default=O}); | ||
!function(t,e){if("function"==typeof define&&define.amd)define(["exports","@vericus/slate-kit-utils-register-helpers","immutable","slate"],e);else if("undefined"!=typeof exports)e(exports,require("@vericus/slate-kit-utils-register-helpers"),require("immutable"),require("slate"));else{var n={exports:{}};e(n.exports,t.slateKitUtilsRegisterHelpers,t.immutable,t.slate),t.unknown=n.exports}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(t,e,n,r){var o;function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function u(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function c(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function l(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?c(Object(n),!0).forEach((function(e){u(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function f(t){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function d(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function g(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=f(t);if(e){var o=f(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return d(this,n)}}function p(t){return function(t){if(Array.isArray(t))return y(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return y(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return y(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function y(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}t.__esModule=!0,t.default=void 0,e=(o=e)&&o.__esModule?o:{default:o};var b={floatBlocks:[],textBlocks:["paragraph","heading-one","heading-two","heading-three","heading-four","blockquote"],alignments:["left","right","center","justify"],dataField:"textAlign",label:"align"},h=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}(u,t);var e,n,r,o=g(u);function u(){return i(this,u),o.apply(this,arguments)}return e=u,r=[{key:"create",value:function(t){return new u(l(l(l({},b),t),{},{floatBlocks:[].concat(p(b.floatBlocks),p(t.floatBlocks?t.floatBlocks:[])),alignments:[].concat(p(b.alignments),p(t.alignments?t.alignments:[])),textBlocks:[].concat(p(b.textBlocks),p(t.textBlocks?t.textBlocks:[]))}))}}],(n=null)&&a(e.prototype,n),r&&a(e,r),u}((0,n.Record)(b));function v(t,e){if(!e||!r.Block.isBlock(e))return[];var n=t.textBlocks,o=t.floatBlocks;return e.isLeafBlock()?n.includes(e.type)||o.includes(e.type)?[e]:[]:e.nodes.reduce((function(e,n){return[].concat(p(e),p(v(t,n)))}),[])}function m(t){return{getAlignBlocks:function(e){return function(t,e){var r=e.getHighestSelectedBlocks();return 0===r.size?[]:(0,n.List)(r).reduce((function(e,n){return[].concat(p(e),p(v(t,n)))}),[])}(t,e)},getAlignBlocksInBlock:function(e,n){return v(t,n)},getAlignment:function(e,n){return function(t,e){var n=t.dataField;return e&&e.data.get(n)||"left"}(t,n)},isAligned:function(e,n){return function(t,e,n){var r=e.getAlignBlocks(t);return 0!==r.length&&r.every((function(t){return t&&e.getAlignment(t)===n}))}(t,e,n)},isAlignable:function(t){return function(t,e){return 0!==e.getAlignBlocks().length}(0,t)}}}function k(t){var e=t.dataField;return function(t,n){var r=t.value;t.withoutNormalizing((function(){t.getAlignBlocks(r).filter((function(t){return n&&t.data&&t.data.get(e)===n})).forEach((function(n){return t.setNodeByKey(n.key,{data:n.data.delete(e)})}))}))}}function O(t){var e=t.dataField;return function(n,r){var o=n.value,i=t.alignments;i&&i.includes(r)&&n.withoutNormalizing((function(){n.getAlignBlocks(o).forEach((function(t){n.setNodeByKey(t.key,{data:t.data.set(e,r)})}))}))}}function B(t){return{removeAlign:k(t),setAlign:O(t)}}function j(t){var e=t.floatBlocks,n=t.textBlocks;return function(t){if(!t.node||"block"!==t.node.object||!n.includes(t.node.type)&&!e.includes(t.node.type))return t;var r=t.editor.getAlignment(t.node),o=t.attributes&&t.attributes.style||{};return n.includes(t.node.type)&&(o=l(l({},o),{},{textAlign:r})),e.includes(t.node.type)&&(o=l(l({},o),{},{float:r})),l(l({},t),{},{attributes:l(l({},t.attributes),{},{style:o})})}}function A(t){var e=t.floatBlocks,n=t.textBlocks,o=t.dataField,i=t.alignments;return{blocks:[].concat(p(e),p(n)).reduce((function(t,e){return l(l({},t),{},u({},e,{data:u({},o,(function(t){return!t||t&&i.includes(t)})),normalize:function(t,e){"node_data_invalid"===e.code&&t.withoutNormalizing((function(){r.Text.isText(e.node)||t.setNodeByKey(e.node.key,{data:e.node.data.delete(o)})}))}}))}),{})}}var w=[].concat(["div","p","h1","h2","h3","h4","h5","h6"],["div","p","h1","h2","h3","img"]),x=["left","center","right","justify"];function P(t){var e=t.dataField;return{getData:function(t,n){return function(t,e){if(!e||!t.tagName||!w.includes(t.tagName.toLowerCase()))return{};if(t.style&&"string"==typeof t.style.textAlign){var n=t.style.textAlign;if(n&&x.includes(n))return{data:u({},e,n)}}if(t.getAttribute("align")){var r=t.getAttribute("align");if(r&&x.includes(r))return{data:u({},e,r)}}if(t.style&&"string"==typeof t.style.cssFloat&&"clear"!==t.style.cssFloat){var o=t.style.cssFloat;if(o&&x.includes(o))return{data:u({},e,o)}}return{}}(n,e)}}}var _=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=h.create(t),r=m(n),o=B(n),i=j(n),a=A(n),u=P(n),c=u.getData;return[(0,e.default)({props:i,getData:c,options:n}),{queries:r,commands:o,schema:a}]};t.default=_})); |
@@ -5,5 +5,5 @@ import getData from "./getData"; | ||
return { | ||
getData: function (_editor, el) { return getData(el, dataField); } | ||
getData: function (_editor, el) { return getData(el, dataField); }, | ||
}; | ||
} | ||
//# sourceMappingURL=index.js.map |
{ | ||
"version": "0.2.21", | ||
"version": "0.2.22", | ||
"name": "@vericus/slate-kit-align", | ||
@@ -36,3 +36,3 @@ "description": "Plugins to provide a way to align blocks on slate", | ||
"dependencies": { | ||
"@vericus/slate-kit-utils-register-helpers": "^0.1.13", | ||
"@vericus/slate-kit-utils-register-helpers": "^0.1.14", | ||
"debug": "^3.1.0", | ||
@@ -43,4 +43,4 @@ "immutable": ">=3.8.2", | ||
"devDependencies": { | ||
"@vericus/slate-kit-typescript-typings": "^1.1.13", | ||
"@vericus/slate-kit-utils-hyperscript": "^0.2.15", | ||
"@vericus/slate-kit-typescript-typings": "^1.1.14", | ||
"@vericus/slate-kit-utils-hyperscript": "^0.2.16", | ||
"expect": "^23.1.0", | ||
@@ -63,3 +63,3 @@ "slate": ">=0.44.0 <0.46.0", | ||
], | ||
"gitHead": "5fea945a2b95d8b7371c95924d42f7a8a7f0d5e7" | ||
"gitHead": "023a23a9a885aceeb16c8592489e4f058da925fe" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
138311
1497