Skip to content
Snippets Groups Projects
Commit 43b7f974 authored by chris's avatar chris
Browse files

ímage upload position

parent 34472d73
No related branches found
No related tags found
1 merge request!359new node structure
/* eslint react/prop-types: 0 */
import React, { useContext, useRef, useMemo } from 'react';
import { WaxContext } from 'wax-prosemirror-core';
import { TextSelection } from 'prosemirror-state';
import styled from 'styled-components';
import MenuButton from '../../ui/buttons/MenuButton';
import insertImage from './Upload';
......@@ -12,17 +13,32 @@ const Wrapper = styled.div`
`;
const ImageUpload = ({ item, fileUpload, view }) => {
const context = useContext(WaxContext);
const {
app,
activeView,
activeViewId,
view: { main },
} = useContext(WaxContext);
} = context;
const inputRef = useRef(null);
const placeholderPlugin = app.PmPlugins.get('imagePlaceHolder');
const imageServiceConfig = app.config.get('config.ImageService');
const handleMouseDown = () => {
if (activeViewId !== 'main') {
context.view.main.dispatch(
context.view.main.state.tr
.setMeta('outsideView', activeViewId)
.setSelection(
new TextSelection(
context.view.main.state.tr.doc.resolve(
4 + context.view[activeViewId].state.selection.to,
),
),
),
);
}
if (imageServiceConfig && imageServiceConfig.handleAssetManager) {
insertThroughFileMAnager();
} else {
......@@ -51,7 +67,10 @@ const ImageUpload = ({ item, fileUpload, view }) => {
active={false}
disabled={isDisabled}
iconName={item.icon}
onMouseDown={handleMouseDown}
onMouseDown={e => {
e.preventDefault();
handleMouseDown();
}}
title="Upload Image"
/>
......
/* eslint-disable no-underscore-dangle */
import React, { useContext, useRef, useEffect } from 'react';
import { WaxContext } from 'wax-prosemirror-core';
import React from 'react';
import { v4 as uuidv4 } from 'uuid';
import { isEmpty } from 'lodash';
import { injectable } from 'inversify';
......@@ -39,8 +37,6 @@ class Image extends Tools {
renderTool(view) {
if (isEmpty(view)) return null;
const context = useContext(WaxContext);
console.log(context.activeViewId);
const upload = fileUpload(
view,
this.config.get('fileUpload'),
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment