diff --git a/components/Carbon.js b/components/Carbon.js
index 7f2cb5d..972836b 100644
--- a/components/Carbon.js
+++ b/components/Carbon.js
@@ -7,9 +7,6 @@ import { Controlled as CodeMirror } from 'react-codemirror2'
import SpinnerWrapper from './SpinnerWrapper'
import WindowControls from './WindowControls'
-import Popout from './Popout'
-import Button from './Button'
-import ColorPicker from './ColorPicker'
import {
COLORS,
@@ -21,108 +18,9 @@ import {
THEMES_HASH
} from '../lib/constants'
-function ModifierButton(props) {
- return (
-
- )
-}
-
-function SeletionEditor({ pos, onChange }) {
- const [open, setOpen] = React.useState(false)
-
- const [bold, setBold] = React.useState(false)
- const [italics, setItalics] = React.useState(false)
- const [underline, setUnderline] = React.useState(false)
-
- const [color, setColor] = React.useState(null)
-
- React.useEffect(() => {
- onChange({
- bold,
- italics,
- underline,
- color
- })
- }, [onChange, bold, color, italics, underline])
-
- return (
-
-
-
-
- B
-
-
- I
-
-
- U
-
-
- {open && (
-
- setColor(d.hex)}
- />
-
- )}
-
-
-
- )
-}
-
+const SelectionEditor = dynamic(() => import('./SelectionEditor'), {
+ loading: () => null
+})
const Watermark = dynamic(() => import('./svg/Watermark'), {
loading: () => null
})
@@ -207,23 +105,13 @@ class Carbon extends React.PureComponent {
className="container"
onMouseUp={() => {
if (this.currentSelection) {
- const startPos = this.props.editorRef.current.editor.charCoords(
- this.currentSelection.from,
- 'local'
- )
- const endPos = this.props.editorRef.current.editor.charCoords(
- this.currentSelection.to,
- 'local'
- )
-
- const startWindowPos = this.props.editorRef.current.editor.charCoords(
- this.currentSelection.from,
- 'window'
- )
- const endWindowPos = this.props.editorRef.current.editor.charCoords(
- this.currentSelection.to,
- 'window'
- )
+ const { editor } = this.props.editorRef.current
+
+ const startPos = editor.charCoords(this.currentSelection.from, 'local')
+ const endPos = editor.charCoords(this.currentSelection.to, 'local')
+
+ const startWindowPos = editor.charCoords(this.currentSelection.from, 'window')
+ const endWindowPos = editor.charCoords(this.currentSelection.to, 'window')
const top =
Math.max(startWindowPos.bottom, endWindowPos.bottom) -
@@ -402,7 +290,7 @@ class Carbon extends React.PureComponent {
{this.state.modifierOpenAt && (
- {
if (this.currentSelection) {
diff --git a/components/SelectionEditor.js b/components/SelectionEditor.js
new file mode 100644
index 0000000..31cf6fc
--- /dev/null
+++ b/components/SelectionEditor.js
@@ -0,0 +1,105 @@
+import React from 'react'
+import Popout from './Popout'
+import Button from './Button'
+import ColorPicker from './ColorPicker'
+import { COLORS } from '../lib/constants'
+
+function ModifierButton(props) {
+ return (
+
+ )
+}
+
+function SelectionEditor({ pos, onChange }) {
+ const [open, setOpen] = React.useState(false)
+ const [bold, setBold] = React.useState(false)
+ const [italics, setItalics] = React.useState(false)
+ const [underline, setUnderline] = React.useState(false)
+ const [color, setColor] = React.useState(null)
+ React.useEffect(() => {
+ onChange({
+ bold,
+ italics,
+ underline,
+ color
+ })
+ }, [onChange, bold, color, italics, underline])
+ return (
+
+
+
+
+ B
+
+
+ I
+
+
+ U
+
+
+ {open && (
+
+ setColor(d.hex)}
+ />
+
+ )}
+
+
+
+ )
+}
+
+export default SelectionEditor