55
66import 'proxy-polyfill'
77
8- import { Editor } from '@tiptap/core'
8+ import { Editor , Extension } from '@tiptap/core'
99import hljs from 'highlight.js/lib/core'
1010import { createLowlight } from 'lowlight'
1111
12+ import type { Node } from '@tiptap/pm/model'
13+ import type { Connection } from './composables/useConnection'
1214import { FocusTrap , PlainText , RichText } from './extensions/index.js'
1315import { logger } from './helpers/logger.ts'
1416
1517const lowlight = createLowlight ( )
1618
17- const loadSyntaxHighlight = async ( language ) => {
19+ const loadSyntaxHighlight = async ( language : string ) => {
1820 const list = hljs . listLanguages ( )
1921 logger . debug ( 'Supported languages' , { list } )
2022 if ( ! lowlight . listLanguages ( ) . includes ( language ) ) {
2123 try {
22- logger . debug ( 'Loading language' , language )
24+ logger . debug ( 'Loading language ' + language )
2325 // eslint-disable-next-line n/no-missing-import
2426 const syntax = await import (
2527 `../node_modules/highlight.js/lib/languages/${ language } .js`
@@ -42,6 +44,11 @@ const createRichEditor = ({
4244 connection,
4345 relativePath,
4446 isEmbedded = false ,
47+ } : {
48+ extensions ?: Extension [ ]
49+ connection ?: Connection
50+ relativePath ?: string
51+ isEmbedded ?: boolean
4552} = { } ) => {
4653 return new Editor ( {
4754 editorProps,
@@ -53,7 +60,10 @@ const createRichEditor = ({
5360 } )
5461}
5562
56- const createPlainEditor = ( { language = 'plaintext' , extensions = [ ] } = { } ) => {
63+ const createPlainEditor = ( {
64+ language = 'plaintext' ,
65+ extensions = [ ] ,
66+ } : { language ?: string ; extensions ?: Extension [ ] } = { } ) => {
5767 return new Editor ( {
5868 editorProps,
5969 extensions : [
@@ -68,7 +78,7 @@ const createPlainEditor = ({ language = 'plaintext', extensions = [] } = {}) =>
6878 } )
6979}
7080
71- const serializePlainText = ( doc ) => {
81+ const serializePlainText = ( doc : Node ) => {
7282 return doc . textContent
7383}
7484
0 commit comments