chore: update Slate dependencies (#1451)
This commit is contained in:
committed by
Shawn Erquhart
parent
cd8eddf8f6
commit
a1677b0e24
@ -30,12 +30,12 @@
|
||||
"remark-parse": "^3.0.1",
|
||||
"remark-rehype": "^2.0.0",
|
||||
"remark-stringify": "^3.0.1",
|
||||
"slate": "^0.30.0",
|
||||
"slate-edit-list": "^0.10.1",
|
||||
"slate-edit-table": "^0.12.0",
|
||||
"slate-plain-serializer": "^0.4.0",
|
||||
"slate-react": "0.10.11",
|
||||
"slate-soft-break": "^0.6.0",
|
||||
"slate": "^0.34.0",
|
||||
"slate-edit-list": "^0.11.3",
|
||||
"slate-edit-table": "^0.15.1",
|
||||
"slate-plain-serializer": "^0.5.15",
|
||||
"slate-react": "0.12.9",
|
||||
"slate-soft-break": "^0.6.1",
|
||||
"unified": "^6.1.4",
|
||||
"unist-builder": "^1.0.2",
|
||||
"unist-util-visit-parents": "^1.1.1"
|
||||
|
@ -21,7 +21,7 @@ const VisualEditorContainer = styled.div`
|
||||
|
||||
const createEmptyRawDoc = () => {
|
||||
const emptyText = Text.create('');
|
||||
const emptyBlock = Block.create({ kind: 'block', type: 'paragraph', nodes: [emptyText] });
|
||||
const emptyBlock = Block.create({ object: 'block', type: 'paragraph', nodes: [emptyText] });
|
||||
return { nodes: [emptyBlock] };
|
||||
};
|
||||
|
||||
@ -86,7 +86,7 @@ export default class Editor extends React.Component {
|
||||
// Handle everything except list buttons.
|
||||
if (!['bulleted-list', 'numbered-list'].includes(type)) {
|
||||
const isActive = this.selectionHasBlock(type);
|
||||
change = change.setBlock(isActive ? 'paragraph' : type);
|
||||
change = change.setBlocks(isActive ? 'paragraph' : type);
|
||||
}
|
||||
|
||||
// Handle the extra wrapping required for list buttons.
|
||||
@ -144,7 +144,7 @@ export default class Editor extends React.Component {
|
||||
const { value } = this.state;
|
||||
const nodes = [Text.create('')];
|
||||
const block = {
|
||||
kind: 'block',
|
||||
object: 'block',
|
||||
type: 'shortcode',
|
||||
data: {
|
||||
shortcode: pluginId,
|
||||
@ -157,7 +157,7 @@ export default class Editor extends React.Component {
|
||||
let change = value.change();
|
||||
const { focusBlock } = change.value;
|
||||
|
||||
if (focusBlock.text === '') {
|
||||
if (focusBlock.text === '' && focusBlock.type === 'paragraph') {
|
||||
change = change.setNodeByKey(focusBlock.key, block);
|
||||
} else {
|
||||
change = change.insertBlock(block);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -70,7 +70,7 @@ const BackspaceCloseBlock = (options = {}) => ({
|
||||
if (ignoreIn && ignoreIn.includes(type)) return;
|
||||
|
||||
if (startBlock.text === '') {
|
||||
return change.setBlock(defaultBlock).focus();
|
||||
return change.setBlocks(defaultBlock).focus();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
@ -8,7 +8,7 @@ export function validateNode(node) {
|
||||
/**
|
||||
* Validation of the document itself.
|
||||
*/
|
||||
if (node.kind === 'document') {
|
||||
if (node.object === 'document') {
|
||||
const doc = node;
|
||||
/**
|
||||
* If the editor is ever in an empty state, insert an empty
|
||||
|
@ -71,7 +71,7 @@ function createBlock(type, nodes, props = {}) {
|
||||
nodes = undefined;
|
||||
}
|
||||
|
||||
const node = { kind: 'block', type, ...props };
|
||||
const node = { object: 'block', type, ...props };
|
||||
return addNodes(node, nodes);
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ function createBlock(type, nodes, props = {}) {
|
||||
* Create a Slate Block node.
|
||||
*/
|
||||
function createInline(type, props = {}, nodes) {
|
||||
const node = { kind: 'inline', type, ...props };
|
||||
const node = { object: 'inline', type, ...props };
|
||||
return addNodes(node, nodes);
|
||||
}
|
||||
|
||||
@ -87,7 +87,7 @@ function createInline(type, props = {}, nodes) {
|
||||
* Create a Slate Raw text node.
|
||||
*/
|
||||
function createText(value, data) {
|
||||
const node = { kind: 'text', data };
|
||||
const node = { object: 'text', data };
|
||||
const leaves = isArray(value) ? value : [{ text: value }];
|
||||
return { ...node, leaves };
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ function transform(node) {
|
||||
/**
|
||||
* Run individual nodes through conversion factories.
|
||||
*/
|
||||
return ['text'].includes(node.kind)
|
||||
return ['text'].includes(node.object)
|
||||
? convertTextNode(node)
|
||||
: convertNode(node, children, shortcodePlugins);
|
||||
}
|
||||
@ -117,15 +117,15 @@ function combineTextAndInline(nodes) {
|
||||
* children, so we remove the child node here.
|
||||
*/
|
||||
if (node.type === 'break') {
|
||||
acc.push({ kind: 'inline', type: 'break' });
|
||||
acc.push({ object: 'inline', type: 'break' });
|
||||
return acc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert remaining inline nodes to standalone text nodes with leaves.
|
||||
*/
|
||||
if (node.kind === 'inline') {
|
||||
acc.push({ kind: 'text', leaves: [{ node, marks: data.marks }] });
|
||||
if (node.object === 'inline') {
|
||||
acc.push({ object: 'text', leaves: [{ node, marks: data.marks }] });
|
||||
return acc;
|
||||
}
|
||||
|
||||
@ -175,7 +175,7 @@ function processCodeMark(markTypes) {
|
||||
* For example, this Slate text node:
|
||||
*
|
||||
* {
|
||||
* kind: 'text',
|
||||
* object: 'text',
|
||||
* leaves: [
|
||||
* {
|
||||
* text: 'test',
|
||||
@ -221,7 +221,7 @@ function convertTextNode(node) {
|
||||
return condensedNodes.nodes;
|
||||
}
|
||||
|
||||
if (node.kind === 'inline') {
|
||||
if (node.object === 'inline') {
|
||||
return transform(node);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user