Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 33 additions & 11 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@radix-ui/react-radio-group": "^1.2.3",
"@reach/auto-id": "^0.16.0",
"@saleor/macaw-ui": "npm:@saleor/macaw-ui@0.7.4",
"@saleor/macaw-ui-next": "npm:@saleor/macaw-ui@1.1.19",
"@saleor/macaw-ui-next": "npm:@saleor/macaw-ui@1.3.5",
"@saleor/sdk": "0.6.0",
"@sentry/react": "^8.21.0",
"@sentry/vite-plugin": "^2.21.1",
Expand Down
1 change: 1 addition & 0 deletions src/components/FilterPresetsSelect/FilterPresetItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const FilterPresetItem = ({
>
<RemoveIcon
data-test-id="preset-delete-button"
// @ts-expect-error - check why style is not accepted in types, but can be used
color={{
default: "default2",
hover: "default1",
Expand Down
14 changes: 13 additions & 1 deletion src/components/RichTextEditor/ReactEditorJS.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {
} from "@react-editor-js/core";
import React from "react";

import { convertEditorJSListBlocks } from "./utils";

// Source of @react-editor-js
class ClientEditorCore implements EditorCore {
private readonly _editorJS: EditorJS;
Expand All @@ -27,14 +29,24 @@ class ClientEditorCore implements EditorCore {
});
}

/**
* This property is required by the EditorCore interface to optionally expose
* the underlying Editor.js instance for advanced use cases. In this implementation,
* we intentionally do not expose the low-level instance to maintain encapsulation
* and prevent unsafe direct access. Therefore, this always returns null.
*/
get dangerouslyLowLevelInstance(): any | null {
return null;
}

public async clear() {
await this._editorJS.clear();
}

public async save() {
await this._editorJS.isReady;

return this._editorJS.save();
return convertEditorJSListBlocks(await this._editorJS.save());
}

public async destroy() {
Expand Down
3 changes: 1 addition & 2 deletions src/components/RichTextEditor/RichTextEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { tools } from "./consts";
import { useHasRendered, useUpdateOnRerender } from "./hooks";
import { ReactEditorJS } from "./ReactEditorJS";
import useStyles from "./styles";
import { convertEditorJSListBlocks } from "./utils";

export type EditorJsProps = Omit<ReactEditorJSProps, "factory">;

Expand Down Expand Up @@ -106,7 +105,7 @@ const RichTextEditor: React.FC<RichTextEditorProps> = ({

setHasValue(editorJsValue.blocks.length > 0);

return onChange?.(convertEditorJSListBlocks(editorJsValue));
return onChange?.(editorJsValue);
}}
{...props}
>
Expand Down
5 changes: 1 addition & 4 deletions src/utils/richText/useRichText.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { convertEditorJSListBlocks } from "@dashboard/components/RichTextEditor/utils";
import { OutputData } from "@editorjs/editorjs";
import { EditorCore } from "@react-editor-js/core";
import { MutableRefObject, useMemo, useRef, useState } from "react";
Expand Down Expand Up @@ -34,9 +33,7 @@ export function useRichText({
if (editorRef.current) {
setIsDirty(false);

const convertedOutputData = convertEditorJSListBlocks(await editorRef.current.save());

return convertedOutputData;
return editorRef.current.save();
} else {
throw new Error("Editor instance is not available");
}
Expand Down
Loading