Skip to content

Commit

Permalink
feat: add depth for bullet-list
Browse files Browse the repository at this point in the history
  • Loading branch information
afeiship committed Feb 4, 2021
1 parent 5176ce7 commit c1faed8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions public/plugins/bulleted-list.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import React from 'react';
import { jsx } from 'slate-hyperscript';
import { Path } from 'slate';
import { useSelected, ReactEditor, useSlate } from 'slate-react';


/**
* @usage:
Expand Down Expand Up @@ -34,8 +37,9 @@ export default {
return `<ul>${children}</ul>`;
},
hooks: {
element: (_, { attributes, children, element }) => {
return <ul {...attributes}>{children}</ul>;
element: (inContext, { attributes, children, element }) => {
const path = ReactEditor.findPath(inContext.editor, element);
return <ul data-depth={path.length} {...attributes}>{children}</ul>;
}
}
};

0 comments on commit c1faed8

Please sign in to comment.