From 6ee2380dbe89f1dc1bb97f7fd7ca395e0b0f96c5 Mon Sep 17 00:00:00 2001 From: chris <kokosias@yahoo.gr> Date: Thu, 19 Jan 2023 12:53:55 +0200 Subject: [PATCH] fix image hook --- editors/demo/src/Editoria/config/config.js | 1 - .../src/Editoria/layout/EditoriaLayout.js | 8 ++++- .../src/ImageService/Image.js | 31 +++++++------------ 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/editors/demo/src/Editoria/config/config.js b/editors/demo/src/Editoria/config/config.js index fc3926bfd..332bad041 100644 --- a/editors/demo/src/Editoria/config/config.js +++ b/editors/demo/src/Editoria/config/config.js @@ -93,7 +93,6 @@ export default { 'CustomTagInline', 'Notes', 'Lists', - 'Images', 'SpecialCharacters', 'CodeBlock', 'Tables', diff --git a/editors/demo/src/Editoria/layout/EditoriaLayout.js b/editors/demo/src/Editoria/layout/EditoriaLayout.js index 1842efbce..68b7e97be 100644 --- a/editors/demo/src/Editoria/layout/EditoriaLayout.js +++ b/editors/demo/src/Editoria/layout/EditoriaLayout.js @@ -1,4 +1,10 @@ -import React, { useContext, useState, useCallback, useEffect } from 'react'; +import React, { + useContext, + useState, + useCallback, + useEffect, + useMemo, +} from 'react'; import styled, { css, ThemeProvider } from 'styled-components'; import PanelGroup from 'react-panelgroup'; import { diff --git a/wax-prosemirror-services/src/ImageService/Image.js b/wax-prosemirror-services/src/ImageService/Image.js index b81daf643..e76e68c38 100644 --- a/wax-prosemirror-services/src/ImageService/Image.js +++ b/wax-prosemirror-services/src/ImageService/Image.js @@ -1,10 +1,9 @@ -import React, { useContext } from 'react'; -import { v4 as uuidv4 } from 'uuid'; -import { isEmpty } from 'lodash'; +import React from 'react'; import { injectable } from 'inversify'; -import { WaxContext, Commands, Tools } from 'wax-prosemirror-core'; -import ImageUpload from './components/ImageUpload'; -import fileUpload from './fileUpload'; +import { Commands, Tools } from 'wax-prosemirror-core'; +import { v4 as uuidv4 } from 'uuid'; + +import ImageUploadComponent from './components/ImageUploadComponent'; @injectable() export default class Image extends Tools { @@ -33,21 +32,15 @@ export default class Image extends Tools { } renderTool(view) { - const context = useContext(WaxContext); - if (isEmpty(view)) return null; - const upload = fileUpload( - view, - this.config.get('fileUpload'), - this.pmplugins.get('imagePlaceHolder'), - context, - ); - return this.isDisplayed() ? ( - <ImageUpload - fileUpload={upload} - item={this.toJSON()} + return ( + <ImageUploadComponent + config={this.config} + displayed={this.isDisplayed()} + item={this} key={uuidv4()} + pmplugins={this.pmplugins} view={view} /> - ) : null; + ); } } -- GitLab