@flozy/editor 9.4.9 → 9.5.0

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.
@@ -352,7 +352,8 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
352
352
  ...mentions,
353
353
  CHARACTERS,
354
354
  hideTools: updatedHideTools || [],
355
- translation: translation || translationFn
355
+ translation: translation || translationFn,
356
+ editor
356
357
  }) : [];
357
358
  const handleEditorChange = newValue => {
358
359
  if (JSON.stringify(newValue) !== JSON.stringify(debouncedValue?.current)) {
@@ -14,6 +14,7 @@ import { SectionSettingIcon } from "../iconListV2";
14
14
  // const list_types = ["orderedList", "unorderedList"];
15
15
  import { jsx as _jsx } from "react/jsx-runtime";
16
16
  import { jsxs as _jsxs } from "react/jsx-runtime";
17
+ const SECTION_PROPS = ["sectionBgColor", "sectionBackgroundImage", "sectionBannerSpacing", "sectionBorderRadius", "sectionGridSize", "sectionAlignment"];
17
18
  const Toolbar = ({
18
19
  readOnly,
19
20
  showTool,
@@ -118,11 +119,26 @@ const Section = props => {
118
119
  ...data
119
120
  };
120
121
  delete updateData.children;
121
- Transforms.setNodes(editor, {
122
- ...updateData
123
- }, {
124
- at: path
125
- });
122
+ if (element.type !== "paragraph") {
123
+ // remove section properties
124
+ Transforms.unsetNodes(editor, SECTION_PROPS, {
125
+ at: path
126
+ });
127
+ // wrap with paragraph with section properties
128
+ Transforms.wrapNodes(editor, {
129
+ ...updateData,
130
+ type: "paragraph",
131
+ children: []
132
+ }, {
133
+ at: path
134
+ });
135
+ } else {
136
+ Transforms.setNodes(editor, {
137
+ ...updateData
138
+ }, {
139
+ at: path
140
+ });
141
+ }
126
142
  onClose();
127
143
  };
128
144
  const onClose = () => {
@@ -15,6 +15,7 @@ import { Transforms } from "slate";
15
15
  import { insertInfinityAI } from "../../utils/infinityAI";
16
16
  import { insertDataView } from "../../utils/dataView";
17
17
  import SearchButton from "../../Elements/Search/SearchButton";
18
+ import canOpen from "../../helper/canOpen";
18
19
  import { jsx as _jsx } from "react/jsx-runtime";
19
20
  const ELEMENTS_LIST = [{
20
21
  name: "Heading 1",
@@ -358,8 +359,10 @@ const elements = props => {
358
359
  const {
359
360
  search,
360
361
  hideTools,
361
- translation
362
+ translation,
363
+ editor
362
364
  } = props;
365
+ const nodeType = canOpen(editor);
363
366
  const translatedElements = ELEMENTS_LIST.map(element => ({
364
367
  ...element,
365
368
  name: translation(element.name),
@@ -370,7 +373,7 @@ const elements = props => {
370
373
  });
371
374
  } : undefined
372
375
  }));
373
- const filteredElements = translatedElements.filter(f => (hideTools || []).indexOf(f.type) === -1);
376
+ const filteredElements = translatedElements.filter(f => (hideTools || []).indexOf(f.type) === -1 && (!f?.hideFor || f?.hideFor?.indexOf(nodeType) === -1));
374
377
  return filteredElements.filter(c => c.name.toLowerCase().includes(search?.toLowerCase()));
375
378
  };
376
379
  export default elements;
@@ -62,7 +62,6 @@ export const toggleBlock = (editor, format, selection = true, attr = {}) => {
62
62
  const isList = list_types.includes(format);
63
63
  const isIndent = alignment.includes(format);
64
64
  const isAligned = alignment.some(alignmentType => isBlockActive(editor, alignmentType));
65
- console.log(isAligned, isIndent);
66
65
 
67
66
  /*If the node is already aligned and change in indent is called we should unwrap it first and split the node to prevent
68
67
  messy, nested DOM structure and bugs due to that.*/
@@ -75,29 +74,10 @@ export const toggleBlock = (editor, format, selection = true, attr = {}) => {
75
74
 
76
75
  /* Wraping the nodes for alignment, to allow it to co-exist with other block level operations*/
77
76
  if (isIndent) {
78
- const [nodeEntry] = Editor.nodes(editor, {
79
- at: editor.selection,
80
- match: n => Element.isElement(n) && NEWLINESAFTER.indexOf(n.type) > -1
77
+ Transforms.wrapNodes(editor, {
78
+ type: format,
79
+ children: []
81
80
  });
82
- // for heading background preserve while alignment change
83
- if (nodeEntry) {
84
- // for headings alone
85
- Transforms.wrapNodes(editor, {
86
- type: format,
87
- children: []
88
- }, {
89
- at: editor.selection,
90
- match: n => {
91
- return Text.isText(n);
92
- }
93
- });
94
- } else {
95
- // follow old logic
96
- Transforms.wrapNodes(editor, {
97
- type: format,
98
- children: []
99
- });
100
- }
101
81
  return;
102
82
  }
103
83
  Transforms.unwrapNodes(editor, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "9.4.9",
3
+ "version": "9.5.0",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"