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