Skip to content

Commit

Permalink
fix: remove auto-add drag connector (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
prevwong authored Jan 22, 2021
1 parent 4a8126d commit 60a600a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
23 changes: 20 additions & 3 deletions packages/slate/src/extend/editable/Element.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,26 @@ const RenderSlateElement = ({
attributes,
children,
renderElement,
drag,
}) => {
const { type } = useEditor((state) => ({
type: state.options.resolver[element.type],
}));

const render = React.createElement(type, { element, children, attributes });
const render = React.createElement(type, {
element,
children,
attributes,
drag,
});

if (renderElement) {
return React.createElement(renderElement, { render, element });
return React.createElement(renderElement, {
render,
element,
attributes,
drag,
});
}

return render;
Expand Down Expand Up @@ -61,7 +72,6 @@ export const Element = ({ attributes, children, element, renderElement }) => {
}

connect(dom, id);
drag(dom, id);

if (!enabled) {
dom.setAttribute('contenteditable', false);
Expand All @@ -79,6 +89,13 @@ export const Element = ({ attributes, children, element, renderElement }) => {
element={element}
attributes={attributes}
children={children}
drag={(dom) => {
if (!exists) {
return;
}

drag(dom, id);
}}
/>
}
/>
Expand Down
1 change: 0 additions & 1 deletion packages/slate/src/extend/editable/RenderEditable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export const RenderEditable = ({ as, children, attributes }) => {
}

connectors.connect(dom, slateNodeId);
connectors.drag(dom, slateNodeId);
});

return React.createElement(as || DefaultRenderEditable, {
Expand Down

0 comments on commit 60a600a

Please sign in to comment.