diff --git a/package.json b/package.json index 4c8f145..468d026 100644 --- a/package.json +++ b/package.json @@ -91,6 +91,7 @@ "fork-ts-checker-webpack-plugin": "^6.0.8", "gh-pages": "^3.1.0", "husky": "^4.3.0", + "is-hotkey": "^0.2.0", "jest": "^26.6.1", "jsdom": "^16.3.0", "jspolyfill-array.prototype.findIndex": "^0.1.0", @@ -105,6 +106,8 @@ "rollup-plugin-peer-deps-external": "^2.2.4", "rollup-plugin-postcss": "^4.0.0", "rollup-plugin-typescript2": "^0.29.0", + "slate": "^0.59.0", + "slate-react": "^0.59.0", "styled-components": "^5.2.0", "ts-loader": "^8.0.7", "typescript": "^4.0.5" diff --git a/src/stories/button.tsx b/src/stories/button.tsx index 9a0bb6b..d073e97 100644 --- a/src/stories/button.tsx +++ b/src/stories/button.tsx @@ -14,6 +14,10 @@ const Button = styled.button` margin: 0.5rem; padding: 0 0.75em; + &:active { + background-color: #d5c2e7; + } + &:focus { color: white; background-color: rebeccapurple; diff --git a/src/stories/text-editor.stories.tsx b/src/stories/text-editor.stories.tsx new file mode 100644 index 0000000..3b7a424 --- /dev/null +++ b/src/stories/text-editor.stories.tsx @@ -0,0 +1,173 @@ +import "jspolyfill-array.prototype.findIndex"; +import isHotkey from "is-hotkey"; +import React, { FC, useCallback, useMemo, useRef, useState } from "react"; +import { Editable, withReact, useSlate, Slate } from "slate-react"; +import { Editor, createEditor, Node } from "slate"; +import { Meta } from "@storybook/react/types-6-0"; +import { RovingTabIndexProvider, useRovingTabIndex, useFocusEffect } from ".."; +import { Button } from "./button"; +import { Toolbar } from "./toolbar"; + +// The code in this file largely comes from the rich text editor example in the Slate docs: +// https://github.com/ianstormtaylor/slate/blob/master/site/examples/richtext.tsx + +const initialValue = [ + { + type: "paragraph", + children: [ + { text: "This is editable " }, + { text: "rich", bold: true }, + { text: " text, " }, + { text: "much", italic: true }, + { text: " better than a " }, + { text: "