From 8b7c6354eac4aacfc17684745822c22df872f87d Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sat, 16 Mar 2024 06:26:49 -0500 Subject: [PATCH] refactor: katex.d.ts -> typings-external.ts This way the .d.ts will not be deleted when filse are deleted through rimraf --- src/augmentation.ts | 2 +- src/{katex.d.ts => typings-external.ts} | 9 ++++++--- src/ui/mainformview.ts | 2 +- src/ui/mathview.ts | 2 +- src/utils.ts | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) rename src/{katex.d.ts => typings-external.ts} (96%) diff --git a/src/augmentation.ts b/src/augmentation.ts index 3f95f248e..065176368 100644 --- a/src/augmentation.ts +++ b/src/augmentation.ts @@ -1,4 +1,4 @@ -import type { KatexOptions } from './katex'; +import type { KatexOptions } from './typings-external'; declare module '@ckeditor/ckeditor5-core' { interface EditorConfig { diff --git a/src/katex.d.ts b/src/typings-external.ts similarity index 96% rename from src/katex.d.ts rename to src/typings-external.ts index 8a0dff93d..d0bcf8b10 100644 --- a/src/katex.d.ts +++ b/src/typings-external.ts @@ -1,14 +1,17 @@ -interface MathJax3 { +/** + * Basic typings for third party, external libraries (KaTeX, MathJax). + */ +export interface MathJax3 { version: string; tex2chtmlPromise?: ( input: string, options: { display: boolean } ) => Promise; tex2svgPromise?: ( input: string, options: { display: boolean } ) => Promise; } -interface MathJax2 { +export interface MathJax2 { Hub: { Queue: ( callback: [string, MathJax2['Hub'], string | HTMLElement] | ( () => void ) ) => void }; } -interface Katex { +export interface Katex { render( equation: string, el: HTMLElement, options: KatexOptions ): void; } diff --git a/src/ui/mainformview.ts b/src/ui/mainformview.ts index dc4897868..0f302727f 100644 --- a/src/ui/mainformview.ts +++ b/src/ui/mainformview.ts @@ -16,7 +16,7 @@ import { Locale, FocusTracker, KeystrokeHandler } from 'ckeditor5/src/utils'; import { extractDelimiters, hasDelimiters } from '../utils'; import MathView from './mathview'; import '../../theme/mathform.css'; -import type { KatexOptions } from '../katex'; +import type { KatexOptions } from '../typings-external'; const { check: checkIcon, cancel: cancelIcon } = icons; diff --git a/src/ui/mathview.ts b/src/ui/mathview.ts index 5ee587d16..98cb875ad 100644 --- a/src/ui/mathview.ts +++ b/src/ui/mathview.ts @@ -1,7 +1,7 @@ import { View } from 'ckeditor5/src/ui'; +import type { KatexOptions } from '../typings-external'; import { renderEquation } from '../utils'; import type { Locale } from 'ckeditor5/src/utils'; -import type { KatexOptions } from '../katex'; export default class MathView extends View { public value: string; diff --git a/src/utils.ts b/src/utils.ts index 31a68e91f..a5a86909f 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -5,7 +5,7 @@ import type { } from 'ckeditor5/src/engine'; import { BalloonPanelView } from 'ckeditor5/src/ui'; import { CKEditorError, type PositioningFunction } from 'ckeditor5/src/utils'; -import type { KatexOptions, MathJax2, MathJax3 } from './katex'; +import type { KatexOptions, MathJax2, MathJax3 } from './typings-external'; export function getSelectedMathModelWidget( selection: DocumentSelection