{"version":3,"sources":["../src/lib/slatejs-edits/add-autocompletions.ts"],"sourcesContent":["import { BasePoint, Transforms } from \"slate\";\nimport { CustomEditor } from \"../../types/base/custom-editor\";\n\nexport function addAutocompletionsToEditor(\n  editor: CustomEditor,\n  newSuggestion: string,\n  point: BasePoint,\n) {\n  const editorPosition = editor.selection;\n\n  Transforms.insertNodes(\n    editor,\n    [\n      {\n        type: \"suggestion\",\n        inline: true,\n        content: newSuggestion,\n        children: [{ text: \"\" }],\n      },\n    ],\n    {\n      at: point,\n    },\n  );\n\n  // restore cursor position\n  if (editorPosition) {\n    editor.selection = editorPosition;\n  }\n}\n"],"mappings":";AAAA,SAAoB,kBAAkB;AAG/B,SAAS,2BACd,QACA,eACA,OACA;AACA,QAAM,iBAAiB,OAAO;AAE9B,aAAW;AAAA,IACT;AAAA,IACA;AAAA,MACE;AAAA,QACE,MAAM;AAAA,QACN,QAAQ;AAAA,QACR,SAAS;AAAA,QACT,UAAU,CAAC,EAAE,MAAM,GAAG,CAAC;AAAA,MACzB;AAAA,IACF;AAAA,IACA;AAAA,MACE,IAAI;AAAA,IACN;AAAA,EACF;AAGA,MAAI,gBAAgB;AAClB,WAAO,YAAY;AAAA,EACrB;AACF;","names":[]}