@convertkit/editor-html
Advanced tools
Comparing version 0.1.10 to 0.2.0
138
es/index.js
@@ -1,3 +0,18 @@ | ||
import React from 'react'; | ||
import React, { Component } from 'react'; | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function _extends() { | ||
@@ -21,2 +36,16 @@ _extends = Object.assign || function (target) { | ||
function _inheritsLoose(subClass, superClass) { | ||
subClass.prototype = Object.create(superClass.prototype); | ||
subClass.prototype.constructor = subClass; | ||
subClass.__proto__ = superClass; | ||
} | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
return self; | ||
} | ||
function _extends$1() { | ||
@@ -1446,41 +1475,76 @@ _extends$1 = Object.assign || function (target) { | ||
var HTMLNode = function HTMLNode(_ref) { | ||
var node = _ref.node, | ||
attributes = _ref.attributes, | ||
children = _ref.children, | ||
editor = _ref.editor; | ||
var startBlock = editor.value.startBlock; | ||
var editing = startBlock && node.hasDescendant(startBlock.key); | ||
var HTMLNode = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
_inheritsLoose(HTMLNode, _Component); | ||
var toggle = function toggle() { | ||
if (editing) { | ||
editor.deselect(); | ||
} else { | ||
editor.moveToStartOfNode(node); | ||
} | ||
function HTMLNode(props) { | ||
var _this; | ||
_this = _Component.call(this, props) || this; | ||
_defineProperty(_assertThisInitialized(_this), "handleClick", function (event) { | ||
var changing = !_this.state.editing; | ||
_this.setState({ | ||
editing: true | ||
}); | ||
if (changing) _this.props.editor.moveToStartOfNode(_this.props.node); | ||
}); | ||
_defineProperty(_assertThisInitialized(_this), "handleClickOutside", function () { | ||
_this.setState({ | ||
editing: false | ||
}); | ||
}); | ||
_defineProperty(_assertThisInitialized(_this), "toggle", function () { | ||
_this.setState(function (prevState) { | ||
return { | ||
editing: !prevState.editing | ||
}; | ||
}); | ||
}); | ||
_this.state = { | ||
editing: false | ||
}; | ||
return _this; | ||
} | ||
var _proto = HTMLNode.prototype; | ||
_proto.render = function render() { | ||
var _this$props = this.props, | ||
node = _this$props.node, | ||
attributes = _this$props.attributes, | ||
children = _this$props.children; | ||
var className = "editor-html"; | ||
if (this.state.editing) className += " editing"; | ||
var texts = node.getTexts().toArray(); | ||
var html = texts.map(function (t) { | ||
return t.text.trim(); | ||
}).join(""); | ||
return React.createElement("div", _extends({ | ||
contentEditable: this.state.editing, | ||
suppressContentEditableWarning: true, | ||
className: className | ||
}, attributes), React.createElement("div", { | ||
className: "editor-html-rendered", | ||
dangerouslySetInnerHTML: { | ||
__html: html | ||
} | ||
}), React.createElement("div", { | ||
className: "editor-html-source" | ||
}, children), React.createElement("button", { | ||
contentEditable: false, | ||
className: "editor-html-toggle", | ||
onClick: this.toggle, | ||
type: "button" | ||
}, this.state.editing ? "PREVIEW" : "EDIT")); | ||
}; | ||
var className = "editor-html"; | ||
if (editing) className += " editing"; | ||
var texts = node.getTexts().toArray(); | ||
var html = texts.map(function (t) { | ||
return t.text.trim(); | ||
}).join(""); | ||
return React.createElement("div", _extends({ | ||
className: className | ||
}, attributes), React.createElement("div", { | ||
contentEditable: false, | ||
className: "editor-html-rendered", | ||
dangerouslySetInnerHTML: { | ||
__html: html | ||
} | ||
}), React.createElement("div", { | ||
className: "editor-html-source" | ||
}, children), React.createElement("button", { | ||
contentEditable: false, | ||
className: "editor-html-toggle", | ||
onClick: toggle, | ||
type: "button" | ||
}, editing ? "PREVIEW" : "EDIT")); | ||
}; | ||
return HTMLNode; | ||
}(Component); | ||
@@ -1487,0 +1551,0 @@ var schema = { |
{ | ||
"name": "@convertkit/editor-html", | ||
"version": "0.1.10", | ||
"version": "0.2.0", | ||
"description": "A plugin for handling HTML in the ConvertKit Editor", | ||
"main": "index.js", | ||
"module": "es/index.js", | ||
"main": "dist/index.js", | ||
"module": "dist/index.esm.js", | ||
"scripts": { | ||
"test": "jest --config ../../jest.config.js", | ||
"test": "library test", | ||
"lint": "eslint . --max-warnings=0", | ||
"build": "rollup src/index.js --config ../../rollup.config.js" | ||
"build": "library build" | ||
}, | ||
@@ -29,5 +29,9 @@ "author": "", | ||
"dependencies": { | ||
"@convertkit/slate-code": "^0.0.2" | ||
"@convertkit/slate-code": "^0.0.12", | ||
"@convertkit/slate-keymap": "^0.1.8" | ||
}, | ||
"gitHead": "873b55f01cb40150ac7f12cae7d420effc9fad2d" | ||
"devDependencies": { | ||
"library-cli": "0.0.7" | ||
}, | ||
"gitHead": "731c5bab4b7031f8c04ac296d3ac8880b2d79ab4" | ||
} |
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
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
89186
7
2934
7
1
+ Added@convertkit/slate-code@0.0.12(transitive)
+ Added@convertkit/slate-keymap@0.1.10(transitive)
- Removed@convertkit/slate-code@0.0.2(transitive)
- Removed@convertkit/slate-keymap@0.0.3(transitive)