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

fix

parent 163eb881
No related branches found
No related tags found
No related merge requests found
...@@ -15,19 +15,15 @@ class AskAiContentService extends Service { ...@@ -15,19 +15,15 @@ class AskAiContentService extends Service {
); );
const createOverlay = this.container.get('CreateOverlay'); const createOverlay = this.container.get('CreateOverlay');
const { config } = this; const config = this.config;
// Create the overlay // Create the overlay
createOverlay( createOverlay(AskAIOverlay, config, {
AskAIOverlay, nodeType: '',
{ config }, markType: '',
{ followCursor: false,
nodeType: '', selection: true,
markType: '', });
followCursor: false,
selection: true,
},
);
} }
register() { register() {
......
...@@ -8,6 +8,7 @@ const elementFromString = string => { ...@@ -8,6 +8,7 @@ const elementFromString = string => {
}; };
const replaceSelectedText = (view, responseText, replace = false) => { const replaceSelectedText = (view, responseText, replace = false) => {
if (!view) return;
let { state } = view; let { state } = view;
let { tr } = state; let { tr } = state;
const { from, to } = tr.selection; const { from, to } = tr.selection;
......
...@@ -192,7 +192,7 @@ const AskAIOverlay = ({ setPosition, position, config }) => { ...@@ -192,7 +192,7 @@ const AskAIOverlay = ({ setPosition, position, config }) => {
} }
}; };
return options.AiOn ? ( return options?.AiOn ? (
<Wrapper id="ai-overlay"> <Wrapper id="ai-overlay">
<AskAIForm> <AskAIForm>
<AskAIFormInput <AskAIFormInput
......
...@@ -14,10 +14,14 @@ export default () => { ...@@ -14,10 +14,14 @@ export default () => {
let createDecoration; let createDecoration;
const askAiInput = document.getElementById('askAiInput'); const askAiInput = document.getElementById('askAiInput');
if (askAiInput) { if (askAiInput) {
// const selectionWhenBlured = tr.getMeta(key); const selectionWhenBlured = tr.getMeta(key);
const from = newState.selection.from; const from = selectionWhenBlured
const to = newState.selection.to; ? selectionWhenBlured.from
: newState.selection.from;
const to = selectionWhenBlured
? selectionWhenBlured.to
: newState.selection.to;
createDecoration = DecorationSet.create(newState.doc, [ createDecoration = DecorationSet.create(newState.doc, [
Decoration.inline(from, to, { Decoration.inline(from, to, {
...@@ -38,7 +42,8 @@ export default () => { ...@@ -38,7 +42,8 @@ export default () => {
}, },
handleDOMEvents: { handleDOMEvents: {
blur(view) { blur(view) {
view.dispatch(view.state.tr.setMeta(key, view.state.selection)); if (view)
view.dispatch(view.state.tr.setMeta(key, view.state.selection));
}, },
// focus(view) { // focus(view) {
// view.dispatch(view.state.tr.setMeta(key, true)); // view.dispatch(view.state.tr.setMeta(key, true));
......
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