@fa-repo/shard-editor
v0.1.0
Published
@fa-repo
Readme
Install
npm install @fa-repo/shard-editorBasic usage
// The engine
import ShardEditor from "@fa-repo/shard-editor";
import "@fa-repo/shard-editor/dist/shard-editor.css";
// Import a bundled shard or create your own.
import MarkdownShard from "@fa-repo/shard-editor/dist/shards/markdown";
import "@fa-repo/shard-editor/dist/shards/markdown.css";
// An array of sourceObjects, each rendered by a shard with matching `type` value.
const source = [
{ type: id: 0, "markdown", markdown: "## Hello world\nLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." }
];
// An array of shards used to render / edit sourceObjects.
const shards = [
{ type: 'markdown', shard: MarkdownShard, builder: ({ id, type }) => ({ id, type, markdown: '' }) }
];
// A generated menu enabling users to add shards.
const inserters = [
{ type: "markdown", label: "Markdown" }
]
export default () => {
return (
<ShardEditor
source={source}
shards={shards}
inserters={inserters}
editable // Content is readOnly by default. Set `editable` to true to enable editing.
/>
)
}Results in:

License
mit © @fa-repo
