Skip to content

Commit

Permalink
Merge pull request #148 from prezly/refactor/slate-lists
Browse files Browse the repository at this point in the history
Refactor - Slate Lists package
  • Loading branch information
e1himself authored Apr 21, 2022
2 parents b681c6d + 7e77235 commit 9c38f3c
Show file tree
Hide file tree
Showing 94 changed files with 3,860 additions and 3,934 deletions.
95 changes: 71 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions packages/slate-commons/src/EditableWithExtensions.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* eslint-disable react-hooks/exhaustive-deps */
import type { FunctionComponent } from 'react';
import React, { useCallback, useMemo } from 'react';
import { Editable, useSlateStatic } from 'slate-react';
import type { Editor } from 'slate';
import type { ReactEditor } from 'slate-react';
import { Editable } from 'slate-react';

import {
combineDecorate,
Expand All @@ -22,6 +24,7 @@ import type {

export interface Props {
decorate?: Decorate;
editor: Editor & ReactEditor;
/**
* Each extension fields will be combined by role.
*
Expand Down Expand Up @@ -67,6 +70,7 @@ export interface Props {

export const EditableWithExtensions: FunctionComponent<Props> = ({
decorate,
editor,
extensions = [],
onDOMBeforeInput: onDOMBeforeInputList = [],
onDOMBeforeInputDeps = [],
Expand All @@ -78,8 +82,6 @@ export const EditableWithExtensions: FunctionComponent<Props> = ({
renderLeafDeps = [],
...props
}) => {
const editor = useSlateStatic();

const combinedDecorate: Decorate = useMemo(
function () {
const decorateFns = createExtensionsDecorators(editor, extensions);
Expand Down
2 changes: 1 addition & 1 deletion packages/slate-commons/src/commands/focus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ReactEditor } from 'slate-react';

import { moveCursorToEndOfDocument } from './moveCursorToEndOfDocument';

export function focus(editor: Editor): void {
export function focus(editor: Editor & ReactEditor): void {
ReactEditor.focus(editor);
moveCursorToEndOfDocument(editor);
}
3 changes: 2 additions & 1 deletion packages/slate-commons/src/commands/getCurrentDomNode.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { Editor } from 'slate';
import type { ReactEditor } from 'slate-react';

import { getCurrentNodeEntry } from './getCurrentNodeEntry';
import { toDomNode } from './toDomNode';

export function getCurrentDomNode(editor: Editor): HTMLElement | null {
export function getCurrentDomNode(editor: Editor & ReactEditor): HTMLElement | null {
const [currentNode] = getCurrentNodeEntry(editor) || [];

if (!currentNode) {
Expand Down
Loading

0 comments on commit 9c38f3c

Please sign in to comment.