This commit is contained in:
Tom Moor
2017-12-05 22:29:07 -08:00
parent e3f664e8a4
commit e64ca3ca43
5 changed files with 19 additions and 30 deletions

View File

@ -9,11 +9,10 @@ const { changes } = EditList;
type Options = { type Options = {
type: string | Object, type: string | Object,
wrapper?: string | Object, wrapper?: string | Object,
append?: string | Object,
}; };
export function splitAndInsertBlock(change: Change, options: Options) { export function splitAndInsertBlock(change: Change, options: Options) {
const { type, wrapper, append } = options; const { type, wrapper } = options;
const parent = change.value.document.getParent(change.value.startBlock.key); const parent = change.value.document.getParent(change.value.startBlock.key);
// lists get some special treatment // lists get some special treatment
@ -28,8 +27,6 @@ export function splitAndInsertBlock(change: Change, options: Options) {
change.insertBlock(type); change.insertBlock(type);
if (wrapper) change.wrapBlock(wrapper); if (wrapper) change.wrapBlock(wrapper);
if (append) change.insertBlock(append);
return change; return change;
} }
@ -40,7 +37,6 @@ export async function insertImageFile(
onImageUploadStop: () => void onImageUploadStop: () => void
) { ) {
onImageUploadStart(); onImageUploadStart();
console.log(file);
try { try {
// load the file as a data URL // load the file as a data URL
const id = uuid.v4(); const id = uuid.v4();
@ -55,7 +51,6 @@ export async function insertImageFile(
isVoid: true, isVoid: true,
data: { src, id, alt, loading: true }, data: { src, id, alt, loading: true },
}); });
console.log('insertBlock', change);
}); });
reader.readAsDataURL(file); reader.readAsDataURL(file);
@ -69,7 +64,6 @@ export async function insertImageFile(
const placeholder = change.value.document.findDescendant( const placeholder = change.value.document.findDescendant(
node => node.data && node.data.get('id') === id node => node.data && node.data.get('id') === id
); );
console.log('placeholder', placeholder);
return change.setNodeByKey(placeholder.key, { return change.setNodeByKey(placeholder.key, {
data: { src, alt, loading: false }, data: { src, alt, loading: false },

View File

@ -10,7 +10,6 @@ export default function ListItem({
...props ...props
}: SlateNodeProps) { }: SlateNodeProps) {
const checked = node.data.get('checked'); const checked = node.data.get('checked');
console.log('ListItem.checked', checked);
if (checked !== undefined) { if (checked !== undefined) {
return ( return (

View File

@ -26,7 +26,6 @@ type Props = SlateNodeProps & {
type Options = { type Options = {
type: string | Object, type: string | Object,
wrapper?: string | Object, wrapper?: string | Object,
append?: string | Object,
}; };
class BlockToolbar extends Component { class BlockToolbar extends Component {

View File

@ -25,7 +25,7 @@ const createPlugins = ({ onImageUploadStart, onImageUploadStop }: Options) => {
}), }),
InsertImages({ InsertImages({
extensions: ['png', 'jpg', 'gif'], extensions: ['png', 'jpg', 'gif'],
insertImage(change, file) { insertImage: (change, file) => {
return change.call( return change.call(
insertImageFile, insertImageFile,
file, file,

View File

@ -2,26 +2,23 @@
import { Block, Change, Node, Mark } from 'slate'; import { Block, Change, Node, Mark } from 'slate';
const schema = { const schema = {
// blocks: { blocks: {
// heading1: { marks: [''] }, heading1: { marks: [''] },
// heading2: { marks: [''] }, heading2: { marks: [''] },
// heading3: { marks: [''] }, heading3: { marks: [''] },
// heading4: { marks: [''] }, heading4: { marks: [''] },
// heading5: { marks: [''] }, heading5: { marks: [''] },
// heading6: { marks: [''] }, heading6: { marks: [''] },
// table: { table: {
// nodes: [{ types: ['table-row', 'table-head', 'table-cell'] }], nodes: [{ types: ['table-row', 'table-head', 'table-cell'] }],
// }, },
// image: { 'horizontal-rule': {
// isVoid: true, isVoid: true,
// }, },
// 'horizontal-rule': { 'block-toolbar': {
// isVoid: true, isVoid: true,
// }, },
// 'block-toolbar': { },
// isVoid: true,
// },
// },
document: { document: {
nodes: [ nodes: [
{ types: ['heading1'], min: 1, max: 1 }, { types: ['heading1'], min: 1, max: 1 },