@sujen/blocks-editor
v0.1.28
Published
A block with all inline styles formatting that spans one line.
Downloads
2
Readme
Blocks Editor
A block with all inline styles formatting that spans one line.
Tutorial
- Default
<BlockProvider>
<BlockEditor />
</BlockProvider>
- Custom Inline Style
const customInlineStyleMap = {
bold: { fontWeight: "bold" },
italic: { color: "#382838" },
// underline ...
// code ...
// strikethrough ...
}
<BlockProvider customInlineStyleMap={customInlineStyleMap}>
<BlockEditor />
</BlockProvider>
- Custom Block Style
const customBlockStyle = {
color: "#383838",
backgroundColor: "#ffffff"
}
<BlockProvider customBlockStyle={customBlockStyle}>
<BlockEditor />
</BlockProvider>
- Custom Key Binding
const customKeyBindingFn: (e: React.KeyboardEvent) => StyleType = (
e: React.KeyboardEvent
) => {
if (!e.metaKey) {
return;
}
switch (e.key) {
case "a":
return "bold";
case "s":
return "underline";
case "d":
return "italic";
case "f":
return "code";
case "e":
return "strikethrough";
}
};
<BlockProvider customKeyBindingFn={customKeyBindingFn}>
<BlockEditor />
</BlockProvider>;
Block Editor
Optional Arguments
- block: preset input text and styles
- onChange: called with every update of the block
- focus: if the block should be focused