Skip to content
Snippets Groups Projects
Commit 3356478e authored by chris's avatar chris
Browse files

rename tool

parent e2181699
No related branches found
No related tags found
1 merge request!466Chatgpt demo
......@@ -4,9 +4,9 @@ import { ToolGroup } from 'wax-prosemirror-core';
@injectable()
class Anystyle extends ToolGroup {
tools = [];
constructor(@inject('AnyStyleTool') anyStyleTool) {
constructor(@inject('ExternalAPIContentTool') ExternalAPIContentTool) {
super();
this.tools = [anyStyleTool];
this.tools = [ExternalAPIContentTool];
}
}
......
import { Service } from 'wax-prosemirror-core';
import AnyStyleTool from './AnyStyleTool';
import ExternalAPIContentTool from './ExternalAPIContentTool';
import AnyStyleToolGroupService from './AnyStyleToolGroupService/AnyStyleToolGroupService';
import ExternalAPIContentPlaceHolderPlugin from './plugins/ExternalAPIContentPlaceHolderPlugin';
import './anyStyle.css';
import './externalApiContent.css';
class ExternalAPIContentService extends Service {
name = 'ExternalAPIContentService';
......@@ -15,7 +15,7 @@ class ExternalAPIContentService extends Service {
}
register() {
this.container.bind('AnyStyleTool').to(AnyStyleTool);
this.container.bind('ExternalAPIContentTool').to(ExternalAPIContentTool);
}
dependencies = [new AnyStyleToolGroupService()];
......
......@@ -7,7 +7,7 @@ import ExternalApiButton from './components/ExternalApiButton';
import replaceText from './replaceText';
@injectable()
class AnyStyleTool extends Tools {
class ExternalAPIContentTool extends Tools {
title = 'ChatGPT';
name = 'ChatGPT';
label = 'ChatGPT';
......@@ -29,7 +29,7 @@ class AnyStyleTool extends Tools {
renderTool(view) {
if (isEmpty(view)) return null;
const context = useContext(WaxContext);
const anyStyle = replaceText(
const ExternalAPIContent = replaceText(
view,
this.config.get('config.ExternalAPIContentService')
.ExternalAPIContentTransformation,
......@@ -38,32 +38,13 @@ class AnyStyleTool extends Tools {
);
return this.isDisplayed() ? (
<ExternalApiButton
anyStyle={anyStyle}
ExternalAPIContent={ExternalAPIContent}
item={this.toJSON()}
key={uuidv4()}
view={view}
/>
) : null;
}
// renderTool(view) {
// if (isEmpty(view)) return null;
// const context = useContext(WaxContext);
// const upload = fileUpload(
// view,
// this.config.get('fileUpload'),
// this.pmplugins.get('imagePlaceHolder'),
// context,
// );
// return this.isDisplayed() ? (
// <ImageUpload
// fileUpload={upload}
// item={this.toJSON()}
// key={uuidv4()}
// view={view}
// />
// ) : null;
// }
}
export default AnyStyleTool;
export default ExternalAPIContentTool;
......@@ -3,7 +3,7 @@ import React, { useContext, useMemo, useEffect } from 'react';
import { WaxContext, DocumentHelpers, MenuButton } from 'wax-prosemirror-core';
import { TextSelection } from 'prosemirror-state';
const ExternalApiButton = ({ view = {}, item, anyStyle }) => {
const ExternalApiButton = ({ view = {}, item, ExternalAPIContent }) => {
const { active, icon, label, run, select, title } = item;
const {
......@@ -20,12 +20,11 @@ const ExternalApiButton = ({ view = {}, item, anyStyle }) => {
const {
selection: { $from, $to },
} = editorState;
/* this is the content that we have to get from the selection */
const textSelection = new TextSelection($from, $to);
const content = textSelection.content();
anyStyle(content.content.content[0].textContent);
ExternalAPIContent(content.content.content[0].textContent);
};
useEffect(() => {}, []);
......
placeholder-any-style:before {
placeholder-external-api:before {
position: relative;
top: 3px;
content: url("data:image/svg+xml; utf8, <svg xmlns='http://www.w3.org/2000/svg' height='24' width='24'><path d='M8 20h8v-3q0-1.65-1.175-2.825Q13.65 13 12 13q-1.65 0-2.825 1.175Q8 15.35 8 17Zm-4 2v-2h2v-3q0-1.525.713-2.863Q7.425 12.8 8.7 12q-1.275-.8-1.987-2.138Q6 8.525 6 7V4H4V2h16v2h-2v3q0 1.525-.712 2.862Q16.575 11.2 15.3 12q1.275.8 1.988 2.137Q18 15.475 18 17v3h2v2Z' /></svg>");
......
......@@ -15,7 +15,7 @@ export default key =>
// See if the transaction adds or removes any placeholders
const action = tr.getMeta(this);
if (action && action.add) {
const widget = document.createElement('placeholder-any-style');
const widget = document.createElement('placeholder-external-api');
const deco = Decoration.widget(action.add.pos, widget, {
id: action.add.id,
});
......
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