* WIP: Slate editor
* WIP
* Focus at start / end working
* ah ha
* Super basic floating toolbar
* Nested list editing
* Pulling more logic into plugins
* inline code markdown
* Backspace at end of code block should remove mark
* Ensure there is always an empty line at editor end
* Add keyboard shortcuts for bold, italic, underline
* Add strikethrough shortcode and toolbar
* Toolbar to declarative
Fixed paragraph styling
Removed unused stuffs
* Super basic link editing
* Split Toolbar, now possible to edit and remove links
* Add new link to selection from toolbar working
* Ensure toolbar doesn't extend off screen
* Fix minor js issues, disable formatting of document title
* Boom, icons
* Remove codemirror, fix MD parsing issues
* CMD+S now saves inplace
* Add --- shortcut for horizontal rule
* Improved styling for link editor
* Add header anchors in readOnly
* More readable core text color
* Restored image file uploading 🎉
* Add support for inline md syntax, ** __ etc
* Centered
* Flooooow
* Checklist support
* Upgrade edit list plugin
* Finally. Allow keydown within rich textarea
* Update Markdown serializer
* Cleanup, remove async editor loading
* Editor > MarkdownEditor
Fixed unsaved changes warning triggered when all changes are saved
* MOAR typing
* Combine edit and view
* Fixed checkboxes still editable in readOnly
* wip
* Breadcrumb
Restored scroll
* Move document scene actions to menu
* Added: Support for code blocks, syntax highlighting
* Cleanup
* > styled component
* Prevent CMD+Enter from adding linebreak
* Show image uploading in layout activity indicator
* Upgrade editor deps
* Improve link toolbar. Only one scenario where it's not working now
111 lines
2.2 KiB
JavaScript
111 lines
2.2 KiB
JavaScript
// @flow
|
|
import { List, Set, Map } from 'immutable';
|
|
|
|
export type NodeTransform = {
|
|
addMarkByKey: Function,
|
|
insertNodeByKey: Function,
|
|
insertTextByKey: Function,
|
|
moveNodeByKey: Function,
|
|
removeMarkByKey: Function,
|
|
removeNodeByKey: Function,
|
|
removeTextByKey: Function,
|
|
setMarkByKey: Function,
|
|
setNodeByKey: Function,
|
|
splitNodeByKey: Function,
|
|
unwrapInlineByKey: Function,
|
|
unwrapBlockByKey: Function,
|
|
unwrapNodeByKey: Function,
|
|
wrapBlockByKey: Function,
|
|
wrapInlineByKey: Function,
|
|
};
|
|
|
|
export type StateTransform = {
|
|
deleteBackward: Function,
|
|
deleteForward: Function,
|
|
delete: Function,
|
|
insertBlock: Function,
|
|
insertFragment: Function,
|
|
insertInline: Function,
|
|
insertText: Function,
|
|
addMark: Function,
|
|
setBlock: Function,
|
|
setInline: Function,
|
|
splitBlock: Function,
|
|
splitInline: Function,
|
|
removeMark: Function,
|
|
toggleMark: Function,
|
|
unwrapBlock: Function,
|
|
unwrapInline: Function,
|
|
wrapBlock: Function,
|
|
wrapInline: Function,
|
|
wrapText: Function,
|
|
};
|
|
|
|
export type Transform = NodeTransform & StateTransform;
|
|
|
|
export type Editor = {
|
|
props: Object,
|
|
className: string,
|
|
onChange: Function,
|
|
onDocumentChange: Function,
|
|
onSelectionChange: Function,
|
|
plugins: Array<Object>,
|
|
readOnly: boolean,
|
|
state: Object,
|
|
style: Object,
|
|
placeholder?: string,
|
|
placeholderClassName?: string,
|
|
placeholderStyle?: string,
|
|
blur: Function,
|
|
focus: Function,
|
|
getSchema: Function,
|
|
getState: Function,
|
|
};
|
|
|
|
export type Node = {
|
|
key: string,
|
|
kind: string,
|
|
length: number,
|
|
text: string,
|
|
data: Map<string, any>,
|
|
nodes: List<Node>,
|
|
getMarks: Function,
|
|
getBlocks: Function,
|
|
getParent: Function,
|
|
getInlines: Function,
|
|
getInlinesAtRange: Function,
|
|
setBlock: Function,
|
|
};
|
|
|
|
export type Block = Node & {
|
|
type: string,
|
|
};
|
|
|
|
export type Document = Node;
|
|
|
|
export type Props = {
|
|
node: Node,
|
|
parent?: Node,
|
|
attributes?: Object,
|
|
editor: Editor,
|
|
readOnly?: boolean,
|
|
children?: React$Element<any>,
|
|
};
|
|
|
|
export type State = {
|
|
document: Document,
|
|
selection: Selection,
|
|
startBlock: Block,
|
|
endBlock: Block,
|
|
startText: Node,
|
|
endText: Node,
|
|
marks: Set<*>,
|
|
blocks: List<Block>,
|
|
fragment: Document,
|
|
lines: List<Node>,
|
|
tests: List<Node>,
|
|
startBlock: Block,
|
|
transform: Function,
|
|
isBlurred: Function,
|
|
};
|