Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
chore(ckeditor5-math): integrate source code
Elian Doran5d42b942baaa
diff --git a/_regroup/ckeditor5-math/src/augmentation.ts b/_regroup/ckeditor5-math/src/augmentation.tsdeleted file mode 100644index cc32187ec9..0000000000--- a/_regroup/ckeditor5-math/src/augmentation.ts+++ /dev/null@@ -1,37 +0,0 @@-import Math from './math';-import MathCommand from './mathcommand';-import MathEditing from './mathediting';-import MathUI from './mathui';-import type { KatexOptions } from './typings-external';--declare module '@ckeditor/ckeditor5-core' {-- interface PluginsMap {- [ Math.pluginName ]: Math;- [ MathEditing.pluginName ]: MathEditing;- [ MathUI.pluginName ]: MathUI;- }-- interface CommandsMap {- math: MathCommand;- }-- interface EditorConfig {- math?: {- engine?:- | 'mathjax'- | 'katex'- | ( ( equation: string, element: HTMLElement, display: boolean ) => void )- | undefined;- lazyLoad?: undefined | ( () => Promise<void> );- outputType?: 'script' | 'span' | undefined;- className?: string | undefined;- forceOutputType?: boolean | undefined;- enablePreview?: boolean | undefined;- previewClassName?: Array<string> | undefined;- popupClassName?: Array<string> | undefined;- katexRenderOptions?: Partial<KatexOptions> | undefined;- };- }-}-diff --git a/_regroup/ckeditor5-math/src/index.ts b/_regroup/ckeditor5-math/src/index.tsdeleted file mode 100644index 39dc1a626e..0000000000--- a/_regroup/ckeditor5-math/src/index.ts+++ /dev/null@@ -1,8 +0,0 @@-/**- * @module math- */--export { default as Math } from './math';-export { default as AutoformatMath } from './autoformatmath';--import "./augmentation.js";diff --git a/_regroup/ckeditor5-math/src/math.ts b/_regroup/ckeditor5-math/src/math.tsdeleted file mode 100644index cfd390fb72..0000000000--- a/_regroup/ckeditor5-math/src/math.ts+++ /dev/null@@ -1,16 +0,0 @@-import { Plugin } from 'ckeditor5/src/core';-import { Widget } from 'ckeditor5/src/widget';--import MathUI from './mathui';-import MathEditing from './mathediting';-import AutoMath from './automath';--export default class Math extends Plugin {- public static get requires() {- return [ MathEditing, MathUI, AutoMath, Widget ] as const;- }-- public static get pluginName() {- return 'Math' as const;- }-}diff --git a/_regroup/ckeditor5-math/typings/svg.d.ts b/_regroup/ckeditor5-math/typings/svg.d.tsdeleted file mode 100644index 4657938300..0000000000--- a/_regroup/ckeditor5-math/typings/svg.d.ts+++ /dev/null@@ -1,4 +0,0 @@-declare module '*.svg' {- const src: string;- export default src;-}diff --git a/packages/ckeditor5-math/src/augmentation.ts b/packages/ckeditor5-math/src/augmentation.tsindex 17e30041ad..855e42133f 100644--- a/packages/ckeditor5-math/src/augmentation.ts+++ b/packages/ckeditor5-math/src/augmentation.ts@@ -1,7 +1,35 @@-import type { Math } from './index.js';+import type Math from './math.js';+import MathCommand from './mathcommand.js';+import MathEditing from './mathediting.js';+import MathUI from './mathui.js';+import { KatexOptions } from './typings-external.js';declare module 'ckeditor5' {interface PluginsMap {[ Math.pluginName ]: Math;+ [ MathEditing.pluginName ]: MathEditing;+ [ MathUI.pluginName ]: MathUI;+ }++ interface CommandsMap {+ math: MathCommand;+ }++ interface EditorConfig {+ math?: {+ engine?:+ | 'mathjax'+ | 'katex'+ | ( ( equation: string, element: HTMLElement, display: boolean ) => void )+ | undefined;+ lazyLoad?: undefined | ( () => Promise<void> );+ outputType?: 'script' | 'span' | undefined;+ className?: string | undefined;+ forceOutputType?: boolean | undefined;+ enablePreview?: boolean | undefined;+ previewClassName?: Array<string> | undefined;+ popupClassName?: Array<string> | undefined;+ katexRenderOptions?: Partial<KatexOptions> | undefined;+ };}}diff --git a/_regroup/ckeditor5-math/src/autoformatmath.ts b/packages/ckeditor5-math/src/autoformatmath.tssimilarity index 82%rename from _regroup/ckeditor5-math/src/autoformatmath.tsrename to packages/ckeditor5-math/src/autoformatmath.tsindex 3aa7697c43..7ae767928d 100644--- a/_regroup/ckeditor5-math/src/autoformatmath.ts+++ b/packages/ckeditor5-math/src/autoformatmath.ts@@ -1,10 +1,8 @@-import { Plugin } from 'ckeditor5/src/core';-import { global, logWarning } from 'ckeditor5/src/utils';+import { Plugin, logWarning, blockAutoformatEditing } from 'ckeditor5';// eslint-disable-next-line ckeditor5-rules/allow-imports-only-from-main-package-entry-point-import blockAutoformatEditing from '@ckeditor/ckeditor5-autoformat/src/blockautoformatediting';-import Math from './math';-import MathCommand from './mathcommand';-import MathUI from './mathui';+import Math from './math.js';+import MathCommand from './mathcommand.js';+import MathUI from './mathui.js';export default class AutoformatMath extends Plugin {public static get requires() {diff --git a/_regroup/ckeditor5-math/src/automath.ts b/packages/ckeditor5-math/src/automath.tssimilarity index 90%rename from _regroup/ckeditor5-math/src/automath.tsrename to packages/ckeditor5-math/src/automath.tsindex e8eb5e9c1e..bf16eacae8 100644--- a/_regroup/ckeditor5-math/src/automath.ts+++ b/packages/ckeditor5-math/src/automath.ts@@ -1,9 +1,5 @@-import { Clipboard } from 'ckeditor5/src/clipboard';-import { Plugin, type Editor } from 'ckeditor5/src/core';-import { LivePosition, LiveRange } from 'ckeditor5/src/engine';-import { Undo } from 'ckeditor5/src/undo';-import { global } from 'ckeditor5/src/utils';-import { extractDelimiters, hasDelimiters, delimitersCounts } from './utils';+import { Clipboard, Plugin, type Editor, LivePosition, LiveRange, Undo } from 'ckeditor5';+import { extractDelimiters, hasDelimiters, delimitersCounts } from './utils.js';export default class AutoMath extends Plugin {public static get requires() {@@ -73,7 +69,7 @@ export default class AutoMath extends Plugin {const editor = this.editor;// eslint-disable-next-line @typescript-eslint/no-non-null-assertion- const mathConfig = this.editor.config.get( 'math' )!;+ const mathConfig = this.editor.config.get( 'math' );const equationRange = new LiveRange( leftPosition, rightPosition );const walker = equationRange.getWalker( { ignoreElementEnd: true } );@@ -119,7 +115,7 @@ export default class AutoMath extends Plugin {editor.model.change( innerWriter => {const params = Object.assign( extractDelimiters( text ), {- type: mathConfig.outputType+ type: mathConfig?.outputType} );const mathElement = innerWriter.createElement( params.display ? 'mathtex-display' : 'mathtex-inline', params);diff --git a/packages/ckeditor5-math/src/index.ts b/packages/ckeditor5-math/src/index.tsindex 2ce8637975..788de3f8ad 100644--- a/packages/ckeditor5-math/src/index.ts+++ b/packages/ckeditor5-math/src/index.ts@@ -1,7 +1,9 @@import ckeditor from './../theme/icons/ckeditor.svg';import './augmentation.js';+import "../theme/mathform.css";export { default as Math } from './math.js';+export { default as AutoformatMath } from './autoformatmath.js';export const icons = {ckeditordiff --git a/packages/ckeditor5-math/src/math.ts b/packages/ckeditor5-math/src/math.tsindex 1be018aad7..fd9debb652 100644--- a/packages/ckeditor5-math/src/math.ts+++ b/packages/ckeditor5-math/src/math.ts@@ -1,39 +1,14 @@-import { Plugin, ButtonView } from 'ckeditor5';--import ckeditor5Icon from '../theme/icons/ckeditor.svg';+import { Plugin, Widget } from 'ckeditor5';+import MathEditing from './mathediting.js';+import MathUI from './mathui.js';+import AutoMath from './automath.js';export default class Math extends Plugin {- public static get pluginName() {- return 'Math' as const;+ public static get requires() {+ return [ MathEditing, MathUI, AutoMath, Widget ] as const;}- public init(): void {- const editor = this.editor;- const t = editor.t;- const model = editor.model;-- // Register the "math" button, so it can be displayed in the toolbar.- editor.ui.componentFactory.add( 'math', locale => {- const view = new ButtonView( locale );-- view.set( {- label: t( 'Math' ),- icon: ckeditor5Icon,- tooltip: true- } );-- // Insert a text into the editor after clicking the button.- this.listenTo( view, 'execute', () => {- model.change( writer => {- const textNode = writer.createText( 'Hello CKEditor 5!' );-- model.insertContent( textNode );- } );-- editor.editing.view.focus();- } );-- return view;- } );+ public static get pluginName() {+ return 'Math' as const;}}diff --git a/_regroup/ckeditor5-math/src/mathcommand.ts b/packages/ckeditor5-math/src/mathcommand.tssimilarity index 94%rename from _regroup/ckeditor5-math/src/mathcommand.tsrename to packages/ckeditor5-math/src/mathcommand.tsindex 5a8dbbe9f7..63671f4374 100644--- a/_regroup/ckeditor5-math/src/mathcommand.ts+++ b/packages/ckeditor5-math/src/mathcommand.ts@@ -1,5 +1,5 @@-import { Command } from 'ckeditor5/src/core';-import { getSelectedMathModelWidget } from './utils';+import { Command } from 'ckeditor5';+import { getSelectedMathModelWidget } from './utils.js';export default class MathCommand extends Command {public override value: string | null = null;diff --git a/_regroup/ckeditor5-math/src/mathediting.ts b/packages/ckeditor5-math/src/mathediting.tssimilarity index 95%rename from _regroup/ckeditor5-math/src/mathediting.tsrename to packages/ckeditor5-math/src/mathediting.tsindex 83a87e1ab7..bfd08ed372 100644--- a/_regroup/ckeditor5-math/src/mathediting.ts+++ b/packages/ckeditor5-math/src/mathediting.ts@@ -1,13 +1,6 @@-import MathCommand from './mathcommand';-import { type Editor, Plugin } from 'ckeditor5/src/core';-import {- toWidget,- Widget,- viewToModelPositionOutsideModelElement-} from 'ckeditor5/src/widget';-import { renderEquation, extractDelimiters } from './utils';-import type { DowncastWriter, Element } from 'ckeditor5/src/engine';-import { CKEditorError, uid } from 'ckeditor5/src/utils';+import MathCommand from './mathcommand.js';+import { type Editor, Plugin, toWidget, Widget, viewToModelPositionOutsideModelElement, type DowncastWriter, type Element, CKEditorError, uid } from 'ckeditor5';+import { renderEquation, extractDelimiters } from './utils.js';export default class MathEditing extends Plugin {public static get requires() {diff --git a/_regroup/ckeditor5-math/src/mathui.ts b/packages/ckeditor5-math/src/mathui.tssimilarity index 94%rename from _regroup/ckeditor5-math/src/mathui.tsrename to packages/ckeditor5-math/src/mathui.tsindex 7cc76f9907..f3c86af491 100644--- a/_regroup/ckeditor5-math/src/mathui.ts+++ b/packages/ckeditor5-math/src/mathui.ts@@ -1,16 +1,9 @@-import MathEditing from './mathediting';-import MainFormView from './ui/mainformview';+import MathEditing from './mathediting.js';+import MainFormView from './ui/mainformview.js';import mathIcon from '../theme/icons/math.svg';-import { Plugin } from 'ckeditor5/src/core';-import { ClickObserver } from 'ckeditor5/src/engine';-import {- ButtonView,- ContextualBalloon,- clickOutsideHandler-} from 'ckeditor5/src/ui';-import { CKEditorError, global, uid } from 'ckeditor5/src/utils';-import { getBalloonPositionData } from './utils';-import MathCommand from './mathcommand';+import { Plugin, ClickObserver, ButtonView, ContextualBalloon, clickOutsideHandler, CKEditorError, uid } from 'ckeditor5';+import { getBalloonPositionData } from './utils.js';+import MathCommand from './mathcommand.js';const mathKeystroke = 'Ctrl+M';diff --git a/_regroup/ckeditor5-math/src/typings-external.ts b/packages/ckeditor5-math/src/typings-external.tssimilarity index 100%rename from _regroup/ckeditor5-math/src/typings-external.tsrename to packages/ckeditor5-math/src/typings-external.tsdiff --git a/_regroup/ckeditor5-math/src/ui/mainformview.ts b/packages/ckeditor5-math/src/ui/mainformview.tssimilarity index 92%rename from _regroup/ckeditor5-math/src/ui/mainformview.tsrename to packages/ckeditor5-math/src/ui/mainformview.tsindex 0f302727fc..c9cd168c8c 100644--- a/_regroup/ckeditor5-math/src/ui/mainformview.ts+++ b/packages/ckeditor5-math/src/ui/mainformview.ts@@ -1,22 +1,8 @@-import { icons } from 'ckeditor5/src/core';-import {- ButtonView,- createLabeledInputText,- FocusCycler,- LabelView,- LabeledFieldView,- submitHandler,- SwitchButtonView,- View,- ViewCollection,- type InputTextView,- type FocusableView-} from 'ckeditor5/src/ui';-import { Locale, FocusTracker, KeystrokeHandler } from 'ckeditor5/src/utils';-import { extractDelimiters, hasDelimiters } from '../utils';-import MathView from './mathview';+import { icons, ButtonView, createLabeledInputText, FocusCycler, LabelView, LabeledFieldView, submitHandler, SwitchButtonView, View, ViewCollection, type InputTextView, type FocusableView, Locale, FocusTracker, KeystrokeHandler } from 'ckeditor5';+import { extractDelimiters, hasDelimiters } from '../utils.js';+import MathView from './mathview.js';import '../../theme/mathform.css';-import type { KatexOptions } from '../typings-external';+import type { KatexOptions } from '../typings-external.js';const { check: checkIcon, cancel: cancelIcon } = icons;diff --git a/_regroup/ckeditor5-math/src/ui/mathview.ts b/packages/ckeditor5-math/src/ui/mathview.tssimilarity index 88%rename from _regroup/ckeditor5-math/src/ui/mathview.tsrename to packages/ckeditor5-math/src/ui/mathview.tsindex ab36bea882..541227e43b 100644--- a/_regroup/ckeditor5-math/src/ui/mathview.ts+++ b/packages/ckeditor5-math/src/ui/mathview.ts@@ -1,7 +1,6 @@-import { View } from 'ckeditor5/src/ui';-import type { KatexOptions } from '../typings-external';-import { renderEquation } from '../utils';-import type { Locale } from 'ckeditor5/src/utils';+import { View, type Locale } from 'ckeditor5';+import type { KatexOptions } from '../typings-external.js';+import { renderEquation } from '../utils.js';export default class MathView extends View {public declare value: string;diff --git a/_regroup/ckeditor5-math/src/utils.ts b/packages/ckeditor5-math/src/utils.tssimilarity index 96%rename from _regroup/ckeditor5-math/src/utils.tsrename to packages/ckeditor5-math/src/utils.tsindex 79be614e38..3a29d3fc20 100644--- a/_regroup/ckeditor5-math/src/utils.ts+++ b/packages/ckeditor5-math/src/utils.ts@@ -1,11 +1,6 @@-import type { Editor } from 'ckeditor5/src/core';-import type {- Element as CKElement,- DocumentSelection-} from 'ckeditor5/src/engine';-import { BalloonPanelView } from 'ckeditor5/src/ui';-import { CKEditorError, type PositioningFunction } from 'ckeditor5/src/utils';-import type { KatexOptions, MathJax2, MathJax3 } from './typings-external';+import type { Editor, Element as CKElement, DocumentSelection, PositioningFunction } from 'ckeditor5';+import { BalloonPanelView, CKEditorError } from 'ckeditor5';+import type { KatexOptions, MathJax2, MathJax3 } from './typings-external.js';export function getSelectedMathModelWidget(selection: DocumentSelectiondiff --git a/packages/ckeditor5-math/theme/icons/ckeditor.svg b/packages/ckeditor5-math/theme/icons/ckeditor.svgdeleted file mode 100644index 25436f4b85..0000000000--- a/packages/ckeditor5-math/theme/icons/ckeditor.svg+++ /dev/null@@ -1 +0,0 @@-<svg width='68' height='64' viewBox='0 0 68 64' xmlns='http://www.w3.org/2000/svg'><g fill='none' fill-rule='evenodd'><path d='M43.71 11.025a11.508 11.508 0 0 0-1.213 5.159c0 6.42 5.244 11.625 11.713 11.625.083 0 .167 0 .25-.002v16.282a5.464 5.464 0 0 1-2.756 4.739L30.986 60.7a5.548 5.548 0 0 1-5.512 0L4.756 48.828A5.464 5.464 0 0 1 2 44.089V20.344c0-1.955 1.05-3.76 2.756-4.738L25.474 3.733a5.548 5.548 0 0 1 5.512 0l12.724 7.292z' fill='#FFF'/><path d='M45.684 8.79a12.604 12.604 0 0 0-1.329 5.65c0 7.032 5.744 12.733 12.829 12.733.091 0 .183-.001.274-.003v17.834a5.987 5.987 0 0 1-3.019 5.19L31.747 63.196a6.076 6.076 0 0 1-6.037 0L3.02 50.193A5.984 5.984 0 0 1 0 45.003V18.997c0-2.14 1.15-4.119 3.019-5.19L25.71.804a6.076 6.076 0 0 1 6.037 0L45.684 8.79zm-29.44 11.89c-.834 0-1.51.671-1.51 1.498v.715c0 .828.676 1.498 1.51 1.498h25.489c.833 0 1.51-.67 1.51-1.498v-.715c0-.827-.677-1.498-1.51-1.498h-25.49.001zm0 9.227c-.834 0-1.51.671-1.51 1.498v.715c0 .828.676 1.498 1.51 1.498h18.479c.833 0 1.509-.67 1.509-1.498v-.715c0-.827-.676-1.498-1.51-1.498H16.244zm0 9.227c-.834 0-1.51.671-1.51 1.498v.715c0 .828.676 1.498 1.51 1.498h25.489c.833 0 1.51-.67 1.51-1.498v-.715c0-.827-.677-1.498-1.51-1.498h-25.49.001zm41.191-14.459c-5.835 0-10.565-4.695-10.565-10.486 0-5.792 4.73-10.487 10.565-10.487C63.27 3.703 68 8.398 68 14.19c0 5.791-4.73 10.486-10.565 10.486v-.001z' fill='#1EBC61' fill-rule='nonzero'/><path d='M60.857 15.995c0-.467-.084-.875-.251-1.225a2.547 2.547 0 0 0-.686-.88 2.888 2.888 0 0 0-1.026-.531 4.418 4.418 0 0 0-1.259-.175c-.134 0-.283.006-.447.018-.15.01-.3.034-.446.07l.075-1.4h3.587v-1.8h-5.462l-.214 5.06c.319-.116.682-.21 1.089-.28.406-.071.77-.107 1.088-.107.218 0 .437.021.655.063.218.041.413.114.585.218s.313.244.422.419c.109.175.163.391.163.65 0 .424-.132.745-.396.961a1.434 1.434 0 0 1-.938.325c-.352 0-.656-.1-.912-.3-.256-.2-.43-.453-.523-.762l-1.925.588c.1.35.258.664.472.943.214.279.47.514.767.706.298.191.63.339.995.443.365.104.749.156 1.151.156.437 0 .86-.064 1.272-.193.41-.13.778-.323 1.1-.581a2.8 2.8 0 0 0 .775-.981c.193-.396.29-.864.29-1.405h-.001z' fill='#FFF' fill-rule='nonzero'/></g></svg>diff --git a/_regroup/ckeditor5-math/theme/icons/math.svg b/packages/ckeditor5-math/theme/icons/math.svgsimilarity index 100%rename from _regroup/ckeditor5-math/theme/icons/math.svgrename to packages/ckeditor5-math/theme/icons/math.svgdiff --git a/_regroup/ckeditor5-math/theme/mathform.css b/packages/ckeditor5-math/theme/mathform.csssimilarity index 100%rename from _regroup/ckeditor5-math/theme/mathform.cssrename to packages/ckeditor5-math/theme/mathform.css