@flozy/editor 4.5.4 → 4.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable no-unused-vars */
2
2
  import React, { useRef, useCallback, useEffect, useMemo, useState, forwardRef, useImperativeHandle } from "react";
3
3
  import PropTypes from "prop-types";
4
- import { createEditor, Transforms } from "slate";
4
+ import { createEditor, Range, Transforms } from "slate";
5
5
  import { Slate, Editable, ReactEditor } from "slate-react";
6
6
  import { useDebounce, useDebouncedCallback } from "use-debounce";
7
7
  import { getMarked, getBlock } from "./utils/SlateUtilityFunctions";
@@ -114,7 +114,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
114
114
  editorClass,
115
115
  fixedWidth = "60%",
116
116
  fullWidth = "80%",
117
- hideTools
117
+ hideTools = []
118
118
  } = otherProps || {};
119
119
  const editor = useMemo(() => {
120
120
  if (collaborativeEditor) return collaborativeEditor;
@@ -365,10 +365,24 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
365
365
  });
366
366
  } else if (event.key === "Enter") {
367
367
  enterEvent(event, editor, customProps?.isMobile);
368
- } else if (event.key === "ArrowUp" && otherProps?.tagName !== 'Pages') {
368
+ } else if (event.key === "ArrowUp" && otherProps?.tagName !== "Pages") {
369
369
  upDownArrowKeyEvents(event, editor);
370
- } else if (event.key === "ArrowDown" && otherProps?.tagName !== 'Pages') {
370
+ } else if (event.key === "ArrowDown" && otherProps?.tagName !== "Pages") {
371
371
  upDownArrowKeyEvents(event, editor);
372
+ } else if (event.key === "Backspace") {
373
+ const {
374
+ selection
375
+ } = editor;
376
+ event.preventDefault();
377
+ if (selection) {
378
+ if (!Range.isCollapsed(selection)) {
379
+ editor.deleteFragment();
380
+ } else {
381
+ editor.deleteBackward({
382
+ unit: "character"
383
+ });
384
+ }
385
+ }
372
386
  }
373
387
  }, [chars, target, mentions, setMentions, search, type, mentionsRef]);
374
388
  const Overlay = collaborativeEditor && !isReadOnly ? RemoteCursorOverlay : React.Fragment;
@@ -216,7 +216,7 @@ const EditorButton = props => {
216
216
  },
217
217
  "& svg": {
218
218
  "& path": {
219
- stroke: appTheme.palette.text.primary
219
+ stroke: appTheme?.palette?.text?.primary
220
220
  }
221
221
  },
222
222
  "& button": {
@@ -215,7 +215,7 @@ const editorStyles = ({
215
215
  },
216
216
  "& .content-editable.empty": {
217
217
  "&:after": {
218
- color: theme.palette.type === "dark" ? "#99A5B6" : placeHolderColor
218
+ color: theme?.palette?.type === "dark" ? "#99A5B6" : placeHolderColor
219
219
  }
220
220
  },
221
221
  "& .checkbox-edit": {
@@ -1,6 +1,6 @@
1
1
  import { Editor, Range, Text } from "slate";
2
- const highlightSelection = ([node, path], editor) => {
3
- if (Text.isText(node) && editor.selection) {
2
+ const highlightSelection = ([node, path], editor = {}) => {
3
+ if (Text.isText(node) && editor?.selection) {
4
4
  const intersection = Range.intersection(editor.selection, Editor.range(editor, path));
5
5
  if (intersection == null) {
6
6
  return [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "4.5.4",
3
+ "version": "4.5.7",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"