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

@convertkit/slate-react-placeholder

Package Overview
Dependencies
Maintainers
12
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@convertkit/slate-react-placeholder - npm Package Compare versions

Comparing version 0.3.1 to 0.4.0-1

src/index.js

159

lib/slate-react-placeholder.js

@@ -1,10 +0,3 @@

'use strict';
import React from 'react';
Object.defineProperty(exports, '__esModule', { value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var React = _interopDefault(require('react'));
var isProduction = "development" === 'production';
var prefix = 'Invariant failed';

@@ -16,5 +9,3 @@ var index = (function (condition, message) {

if (isProduction) {
throw new Error(prefix);
} else {
{
throw new Error(prefix + ": " + (message || ''));

@@ -24,60 +15,2 @@ }

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;
};
var toConsumableArray = function (arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
} else {
return Array.from(arr);
}
};
/*

@@ -87,4 +20,3 @@ * Instance counter to enable unique marks for multiple Placeholder instances.

var instanceCounter = 0;
let instanceCounter = 0;
/**

@@ -97,21 +29,17 @@ * A plugin that renders a React placeholder for a given Slate node.

function SlateReactPlaceholder() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var instanceId = instanceCounter++;
var placeholderMark = {
function SlateReactPlaceholder(options = {}) {
const instanceId = instanceCounter++;
const placeholderMark = {
type: 'placeholder',
data: { key: instanceId }
data: {
key: instanceId
}
};
var placeholder = options.placeholder,
when = options.when,
_options$style = options.style,
style = _options$style === undefined ? {} : _options$style;
const {
placeholder,
when,
style = {}
} = options;
index(placeholder, 'You must pass `SlateReactPlaceholder` an `options.placeholder` string.');
index(when, 'You must pass `SlateReactPlaceholder` an `options.when` query.');
/**

@@ -131,8 +59,12 @@ * Decorate a match node with a placeholder mark when it fits the query.

var others = next();
var document = editor.value.document;
var first = node.getFirstText();
var last = node.getLastText();
var decoration = {
anchor: { key: first.key, offset: 0, path: document.getPath(first.key) },
const others = next();
const document = editor.value.document;
const first = node.getFirstText();
const last = node.getLastText();
const decoration = {
anchor: {
key: first.key,
offset: 0,
path: document.getPath(first.key)
},
focus: {

@@ -145,6 +77,4 @@ key: last.key,

};
return [].concat(toConsumableArray(others), [decoration]);
return [...others, decoration];
}
/**

@@ -159,9 +89,11 @@ * Render an inline placeholder for the placeholder mark.

function renderMark(props, editor, next) {
var children = props.children,
mark = props.mark;
const {
children,
mark
} = props;
if (mark.type === 'placeholder' && mark.data.get('key') === instanceId) {
var placeHolderStyle = _extends({
const placeHolderStyle = {
pointerEvents: 'none',

@@ -172,15 +104,9 @@ display: 'inline-block',

whiteSpace: 'nowrap',
opacity: '0.333'
}, style);
return React.createElement(
'span',
null,
React.createElement(
'span',
{ contentEditable: false, style: placeHolderStyle },
placeholder
),
children
);
opacity: '0.333',
...style
};
return /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("span", {
contentEditable: false,
style: placeHolderStyle
}, placeholder), children);
}

@@ -190,3 +116,2 @@

}
/**

@@ -198,6 +123,10 @@ * Return the plugin.

return { decorateNode: decorateNode, renderMark: renderMark };
return {
decorateNode,
renderMark
};
}
exports.default = SlateReactPlaceholder;
export default SlateReactPlaceholder;
//# sourceMappingURL=slate-react-placeholder.js.map
{
"name": "@convertkit/slate-react-placeholder",
"description": "A Slate plugin to render a placeholder with React.",
"version": "0.3.1",
"version": "0.4.0-1",
"license": "MIT",
"repository": "git://github.com/ianstormtaylor/slate.git",
"main": "lib/slate-react-placeholder.js",
"module": "lib/slate-react-placeholder.es.js",
"umd": "dist/slate-react-placeholder.js",
"umdMin": "dist/slate-react-placeholder.min.js",
"main": "src/index.js",
"module": "lib/slate-react-placeholder.js",
"files": [
"dist/",
"lib/"

@@ -20,3 +17,3 @@ ],

"devDependencies": {
"@convertkit/slate": "^0.52.1",
"@convertkit/slate": "^0.53.0-1",
"mocha": "^2.5.3",

@@ -23,0 +20,0 @@ "tiny-invariant": "^1.0.1"

Sorry, the diff of this file is not supported yet

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