-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bunch of errors that are logged in console (#4281)
* Fix bunch of errors that are loged in console * Typings
- Loading branch information
1 parent
e71633a
commit c31dfef
Showing
8 changed files
with
109 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"saleor-dashboard": patch | ||
--- | ||
|
||
Remove attributes error, pill reference, editor js error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import EditorJS, { | ||
EditorConfig, | ||
OutputData, | ||
ToolConstructable, | ||
} from "@editorjs/editorjs"; | ||
import Paragraph from "@editorjs/paragraph"; | ||
import { | ||
EditorCore, | ||
Props as ReactEditorJSProps, | ||
ReactEditorJS as BaseReactEditorJS, | ||
} from "@react-editor-js/core"; | ||
import React from "react"; | ||
|
||
// Source of @react-editor-js | ||
class ClientEditorCore implements EditorCore { | ||
private readonly _editorJS: EditorJS; | ||
|
||
constructor({ tools, ...config }: EditorConfig) { | ||
const extendTools = { | ||
// default tools | ||
paragraph: { | ||
class: Paragraph, | ||
inlineToolbar: true, | ||
} as unknown as ToolConstructable, | ||
...tools, | ||
}; | ||
|
||
this._editorJS = new EditorJS({ | ||
tools: extendTools, | ||
...config, | ||
}); | ||
} | ||
|
||
public async clear() { | ||
await this._editorJS.clear(); | ||
} | ||
|
||
public async save() { | ||
return this._editorJS.save(); | ||
} | ||
|
||
public async destroy() { | ||
try { | ||
await this._editorJS.destroy(); | ||
} catch (e) { | ||
/* | ||
Dismiss that error. | ||
Sometimes instance is already unmounted while Editor wants to destroy it. | ||
Editorjs does this properly so this error does not break anything | ||
*/ | ||
} | ||
} | ||
|
||
public async render(data: OutputData) { | ||
await this._editorJS.render(data); | ||
} | ||
} | ||
|
||
export type Props = Omit<ReactEditorJSProps, "factory">; | ||
|
||
function ReactEditorJSClient(props: Props) { | ||
const factory = React.useCallback( | ||
(config: EditorConfig) => new ClientEditorCore(config), | ||
[], | ||
); | ||
|
||
return <BaseReactEditorJS factory={factory} {...props} />; | ||
} | ||
|
||
export const ReactEditorJS = ReactEditorJSClient; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,5 @@ declare interface Window { | |
IS_CLOUD_INSTANCE?: string; | ||
}; | ||
} | ||
|
||
declare module "@editorjs/paragraph" {} |