Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/editable-text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@ import { Group, Text } from 'react-konva';

import { TextEditor } from './text-editor';
import Konva from 'konva';
import { TextConfig } from 'konva/lib/shapes/Text';

export const EditorSt = React.forwardRef(({ text, onChange, ...props }) => {
interface EditorStProps extends TextConfig {
onChange: () => void;
}

export const EditorSt = React.forwardRef((props: EditorStProps) => {
const { text, onChange, ...rest } = props
const [editorEnabled, setEditorEnabled] = React.useState(false);
const textRef = React.useRef<Konva.Text>();
const textRef = React.useRef<Konva.Text>(null);

return (
<Group draggable>
Expand All @@ -18,7 +24,7 @@ export const EditorSt = React.forwardRef(({ text, onChange, ...props }) => {
setEditorEnabled(true);
}}
visible={!editorEnabled}
{...props}
{...rest}
/>
{editorEnabled && (
<Group>
Expand Down
2 changes: 1 addition & 1 deletion src/html.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const Html = ({
root.render(children);
});

React.useEffect(() => {
React.useLayoutEffect(() => {
return () => {
root.unmount();
};
Expand Down
13 changes: 11 additions & 2 deletions src/portal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,19 @@ export const Portal = ({ selector, enabled, children }) => {
} else {
inner.current.moveTo(outer.current);
}

// manually redraw layers
outer.current.getLayer().batchDraw();
const outerLayer = outer.current.getLayer();

if (!outerLayer) return;

outerLayer.batchDraw();
if (newContainer) {
newContainer.getLayer().batchDraw();
const newContainerLayer = newContainer.getLayer()

if (!newContainerLayer) return

newContainerLayer.batchDraw();
}
}, [selector, shouldMove]);

Expand Down
1 change: 0 additions & 1 deletion src/text-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export const TextEditor = ({
value,
onBlur,
onChange,
cursorPosition,
}) => {
const [style, setStyle] = React.useState<React.CSSProperties>();
React.useLayoutEffect(() => {
Expand Down