diff --git a/wax-prosemirror-services/src/ExternalAPIContentService/AnyStyleToolGroupService/AnyStyle.js b/wax-prosemirror-services/src/ExternalAPIContentService/AnyStyleToolGroupService/AnyStyle.js index 57217fd6791e37ede78b30d4b9dbd810b7ac6db3..de84b006c50e1f14c23e9d0a77b5ed3ac7dac1e0 100644 --- a/wax-prosemirror-services/src/ExternalAPIContentService/AnyStyleToolGroupService/AnyStyle.js +++ b/wax-prosemirror-services/src/ExternalAPIContentService/AnyStyleToolGroupService/AnyStyle.js @@ -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]; } } diff --git a/wax-prosemirror-services/src/ExternalAPIContentService/ExternalAPIContentService.js b/wax-prosemirror-services/src/ExternalAPIContentService/ExternalAPIContentService.js index 22f36b1e92808ff12915e94db2a16c5b7278d75e..7c621ce564dc7975ab165cc2e453059745f07ebd 100644 --- a/wax-prosemirror-services/src/ExternalAPIContentService/ExternalAPIContentService.js +++ b/wax-prosemirror-services/src/ExternalAPIContentService/ExternalAPIContentService.js @@ -1,8 +1,8 @@ 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()]; diff --git a/wax-prosemirror-services/src/ExternalAPIContentService/AnyStyleTool.js b/wax-prosemirror-services/src/ExternalAPIContentService/ExternalAPIContentTool.js similarity index 61% rename from wax-prosemirror-services/src/ExternalAPIContentService/AnyStyleTool.js rename to wax-prosemirror-services/src/ExternalAPIContentService/ExternalAPIContentTool.js index 267a65981c17e4f5f26364523f5fa350d6749052..cd6fb8c52d247a8c638058f99d4abedf04cbce51 100644 --- a/wax-prosemirror-services/src/ExternalAPIContentService/AnyStyleTool.js +++ b/wax-prosemirror-services/src/ExternalAPIContentService/ExternalAPIContentTool.js @@ -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; diff --git a/wax-prosemirror-services/src/ExternalAPIContentService/components/ExternalApiButton.js b/wax-prosemirror-services/src/ExternalAPIContentService/components/ExternalApiButton.js index 2ac05fa1008807c1c6361364834db2af708e7084..d9ab3a46c2a50f5a68e101ece8f001df95fd9d22 100644 --- a/wax-prosemirror-services/src/ExternalAPIContentService/components/ExternalApiButton.js +++ b/wax-prosemirror-services/src/ExternalAPIContentService/components/ExternalApiButton.js @@ -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(() => {}, []); diff --git a/wax-prosemirror-services/src/ExternalAPIContentService/anyStyle.css b/wax-prosemirror-services/src/ExternalAPIContentService/externalApiContent.css similarity index 92% rename from wax-prosemirror-services/src/ExternalAPIContentService/anyStyle.css rename to wax-prosemirror-services/src/ExternalAPIContentService/externalApiContent.css index ef4885cbd069a2368e985ffe1f2bd90f26447d26..73355c35a0cfba97154b001ee61bbb99580024b4 100644 --- a/wax-prosemirror-services/src/ExternalAPIContentService/anyStyle.css +++ b/wax-prosemirror-services/src/ExternalAPIContentService/externalApiContent.css @@ -1,4 +1,4 @@ -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>"); diff --git a/wax-prosemirror-services/src/ExternalAPIContentService/plugins/ExternalAPIContentPlaceHolderPlugin.js b/wax-prosemirror-services/src/ExternalAPIContentService/plugins/ExternalAPIContentPlaceHolderPlugin.js index 990b75ee2173d6255fc6091b2210595b30a33f45..63915e6996851ba51f72fcef7b4d19405e9de178 100644 --- a/wax-prosemirror-services/src/ExternalAPIContentService/plugins/ExternalAPIContentPlaceHolderPlugin.js +++ b/wax-prosemirror-services/src/ExternalAPIContentService/plugins/ExternalAPIContentPlaceHolderPlugin.js @@ -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, });