@convertkit/editor-core
Advanced tools
Comparing version 0.0.2 to 0.0.3
import React from 'react'; | ||
var index = (function () { | ||
var index = (function (options) { | ||
if (options === void 0) { | ||
options = {}; | ||
} | ||
var defaultBlock = options.defaultBlock || "paragraph"; | ||
return { | ||
renderNode: function renderNode(props) { | ||
commands: { | ||
resetBlock: function resetBlock(change) { | ||
change.splitBlock().setBlocks(defaultBlock); | ||
} | ||
}, | ||
onKeyDown: function onKeyDown(event, change, next) { | ||
if (event.key == "Enter") { | ||
var handled = next(); | ||
if (handled) return handled; | ||
return change.resetBlock(); | ||
} | ||
return next(); | ||
}, | ||
renderNode: function renderNode(props, next) { | ||
var attributes = props.attributes, | ||
@@ -11,2 +30,20 @@ children = props.children, | ||
switch (node.type) { | ||
case "heading-one": | ||
return React.createElement("h1", attributes, children); | ||
case "heading-two": | ||
return React.createElement("h2", attributes, children); | ||
case "heading-three": | ||
return React.createElement("h3", attributes, children); | ||
case "heading-four": | ||
return React.createElement("h4", attributes, children); | ||
case "heading-five": | ||
return React.createElement("h5", attributes, children); | ||
case "heading-six": | ||
return React.createElement("h6", attributes, children); | ||
case "paragraph": | ||
@@ -16,6 +53,6 @@ return React.createElement("p", attributes, children); | ||
default: | ||
throw new Error("Unhandled node type: " + node.type); | ||
return next(); | ||
} | ||
}, | ||
renderMark: function renderMark(props) { | ||
renderMark: function renderMark(props, next) { | ||
var children = props.children, | ||
@@ -36,3 +73,3 @@ mark = props.mark, | ||
default: | ||
throw new Error("unhandled node type"); | ||
return next(); | ||
} | ||
@@ -39,0 +76,0 @@ } |
{ | ||
"name": "@convertkit/editor-core", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Core plugin for ConvertKit Editor", | ||
@@ -28,3 +28,3 @@ "main": "index.js", | ||
], | ||
"gitHead": "2ade8f2004e7520e07a64d904c844df522710ba0" | ||
"gitHead": "19e605bb14ab36d7ea3dc133ae02eeac4c8ce0d8" | ||
} |
import React from "react"; | ||
export default () => { | ||
export default (options = {}) => { | ||
const defaultBlock = options.defaultBlock || "paragraph"; | ||
return { | ||
renderNode(props) { | ||
commands: { | ||
resetBlock(change) { | ||
change.splitBlock().setBlocks(defaultBlock); | ||
} | ||
}, | ||
onKeyDown(event, change, next) { | ||
if (event.key == "Enter") { | ||
const handled = next(); | ||
if (handled) return handled; | ||
return change.resetBlock(); | ||
} | ||
return next(); | ||
}, | ||
renderNode(props, next) { | ||
const { attributes, children, node } = props; | ||
switch (node.type) { | ||
case "heading-one": | ||
return <h1 {...attributes}>{children}</h1>; | ||
case "heading-two": | ||
return <h2 {...attributes}>{children}</h2>; | ||
case "heading-three": | ||
return <h3 {...attributes}>{children}</h3>; | ||
case "heading-four": | ||
return <h4 {...attributes}>{children}</h4>; | ||
case "heading-five": | ||
return <h5 {...attributes}>{children}</h5>; | ||
case "heading-six": | ||
return <h6 {...attributes}>{children}</h6>; | ||
case "paragraph": | ||
return <p {...attributes}>{children}</p>; | ||
default: | ||
throw new Error(`Unhandled node type: ${node.type}`); | ||
return next(); | ||
} | ||
}, | ||
renderMark(props) { | ||
renderMark(props, next) { | ||
const { children, mark, attributes } = props; | ||
@@ -24,3 +51,3 @@ switch (mark.type) { | ||
default: | ||
throw new Error("unhandled node type"); | ||
return next(); | ||
} | ||
@@ -27,0 +54,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
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
4322
4
115