formula-composer 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +122 -2
  3. package/angular/esm2020/formula-composer-tinymce-angular.mjs +4 -0
  4. package/angular/esm2020/lib/formula-composer.directive.mjs +52 -0
  5. package/angular/esm2020/lib/formula-composer.module.mjs +21 -0
  6. package/angular/esm2020/lib/init.mjs +9 -0
  7. package/angular/esm2020/lib/provide.mjs +11 -0
  8. package/angular/esm2020/public-api.mjs +8 -0
  9. package/angular/fesm2015/formula-composer-tinymce-angular.mjs +99 -0
  10. package/angular/fesm2020/formula-composer-tinymce-angular.mjs +101 -0
  11. package/angular/formula-composer-tinymce-angular.d.ts +5 -0
  12. package/angular/lib/formula-composer.directive.d.ts +22 -0
  13. package/angular/lib/formula-composer.module.d.ts +15 -0
  14. package/angular/lib/init.d.ts +23 -0
  15. package/angular/lib/provide.d.ts +10 -0
  16. package/angular/package.json +10 -0
  17. package/angular/public-api.d.ts +5 -0
  18. package/dist/editor-ui/catalog-types.d.ts +30 -0
  19. package/dist/editor-ui/catalog.generated.d.ts +2 -0
  20. package/dist/editor-ui/commands.d.ts +44 -0
  21. package/dist/editor-ui/dom.d.ts +8 -0
  22. package/dist/editor-ui/editor.d.ts +86 -0
  23. package/dist/editor-ui/icons.d.ts +5 -0
  24. package/dist/editor-ui/index.d.ts +9 -0
  25. package/dist/editor-ui/index.js +119 -0
  26. package/dist/editor-ui/modal.d.ts +81 -0
  27. package/dist/editor-ui/periodic.d.ts +8 -0
  28. package/dist/editor-ui/pickers.d.ts +23 -0
  29. package/dist/editor-ui/popover.d.ts +24 -0
  30. package/dist/editor-ui/special-chars.generated.d.ts +10 -0
  31. package/dist/editor-ui/strings.d.ts +48 -0
  32. package/dist/editor-ui/styles.d.ts +3 -0
  33. package/dist/editor-ui/toolbar.d.ts +47 -0
  34. package/dist/integration/content.d.ts +52 -0
  35. package/dist/integration/controller.d.ts +76 -0
  36. package/dist/integration/index.d.ts +3 -0
  37. package/dist/integration/index.js +1 -0
  38. package/dist/integration/options.d.ts +46 -0
  39. package/dist/math-core/a11y.d.ts +3 -0
  40. package/dist/math-core/caret-speech.d.ts +3 -0
  41. package/dist/math-core/editor.d.ts +212 -0
  42. package/dist/math-core/functions.d.ts +8 -0
  43. package/dist/math-core/history.d.ts +16 -0
  44. package/dist/math-core/index.d.ts +17 -0
  45. package/dist/math-core/index.js +3 -0
  46. package/dist/math-core/latex/parse.d.ts +11 -0
  47. package/dist/math-core/latex/serialize.d.ts +4 -0
  48. package/dist/math-core/latex/symbols.d.ts +32 -0
  49. package/dist/math-core/mathml.d.ts +33 -0
  50. package/dist/math-core/model.d.ts +69 -0
  51. package/dist/math-core/safe-xml.d.ts +7 -0
  52. package/dist/math-core/sanitize.d.ts +6 -0
  53. package/dist/math-core/tree-index.d.ts +26 -0
  54. package/dist/math-core/xml.d.ts +21 -0
  55. package/dist/renderer/alphanumerics.d.ts +3 -0
  56. package/dist/renderer/attributes.d.ts +10 -0
  57. package/dist/renderer/core.d.ts +13 -0
  58. package/dist/renderer/image.d.ts +29 -0
  59. package/dist/renderer/index.d.ts +22 -0
  60. package/dist/renderer/index.js +9 -0
  61. package/dist/renderer/layout.d.ts +14 -0
  62. package/dist/renderer/styles.d.ts +9 -0
  63. package/dist/renderer/view.d.ts +30 -0
  64. package/dist/renderer/vnode.d.ts +25 -0
  65. package/dist/tinymce/browser/plugin.min.js +129 -0
  66. package/dist/tinymce/compat.d.ts +24 -0
  67. package/dist/tinymce/index.d.ts +5 -0
  68. package/dist/tinymce/index.js +1 -0
  69. package/dist/tinymce/init.d.ts +22 -0
  70. package/dist/tinymce/plugin.d.ts +30 -0
  71. package/dist/tinymce/tinymce-types.d.ts +127 -0
  72. package/dist/tinymce-react/editor.d.ts +19 -0
  73. package/dist/tinymce-react/index.d.ts +3 -0
  74. package/dist/tinymce-react/index.js +1 -0
  75. package/dist/tinymce-react/init.d.ts +23 -0
  76. package/editor-ui/package.json +6 -0
  77. package/images/edit-formula.png +0 -0
  78. package/images/editor-content.png +0 -0
  79. package/integration/package.json +6 -0
  80. package/math-core/package.json +6 -0
  81. package/package.json +101 -4
  82. package/react/package.json +6 -0
  83. package/renderer/package.json +6 -0
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Formula Composer Free Use License
2
+
3
+ Copyright (c) 2026 Formula Composer. All rights reserved.
4
+
5
+ 1. Grant. You may install and use this software, free of charge, in any
6
+ personal, educational or commercial project, and distribute it unmodified
7
+ as part of your own application.
8
+
9
+ 2. Restrictions. You may not:
10
+ a. sell, sublicense, rent or otherwise charge for this software on its own,
11
+ or repackage it as a separate product or library;
12
+ b. copy, modify, decompile, reverse-engineer or create derivative works of
13
+ the software itself, except as allowed by applicable law;
14
+ c. remove or change this license or any copyright notice.
15
+
16
+ 3. Future versions. The authors may release future versions under different
17
+ terms, including paid terms. Versions already published under this license
18
+ remain free to use under these terms.
19
+
20
+ 4. No warranty. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
+ EXPRESS OR IMPLIED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM,
22
+ DAMAGES OR OTHER LIABILITY ARISING FROM THE USE OF THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,123 @@
1
- # Temporary Holding Version
1
+ # Formula Composer
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A math and chemistry equation editor for TinyMCE, with ready-made React and Angular integrations.
4
+ Write fractions, roots, integrals, matrices, Greek letters and chemical equations in a visual editor
5
+ or in LaTeX. Formulas are saved as standard MathML. Everything runs in the browser, no server needed.
6
+
7
+ ![Formulas in a TinyMCE editor](https://unpkg.com/formula-composer@0.1.0/images/editor-content.png)
8
+
9
+ ![Editing a formula](https://unpkg.com/formula-composer@0.1.0/images/edit-formula.png)
10
+
11
+ ## Features
12
+
13
+ - Visual editor window with 10 toolbar tabs: general, symbols, arrows, Greek, matrices, scripts, decorations, big operators, calculus and more.
14
+ - LaTeX mode, and `$$latex$$` typed straight into the text.
15
+ - Saves as MathML, safe XML, or SVG images that keep their MathML.
16
+ - Accessible: generated `alt` text, screen-reader support, full keyboard navigation.
17
+ - 10 UI languages and right-to-left support.
18
+ - Several editors on one page.
19
+ - Works with TinyMCE 5.10, 6, 7 and 8; React 16.14+; Angular 13+.
20
+
21
+ ## Install
22
+
23
+ ```bash
24
+ npm install formula-composer tinymce
25
+ ```
26
+
27
+ Click the **√x** toolbar button to insert a formula. Double-click a formula to edit it.
28
+
29
+ ## React
30
+
31
+ ```bash
32
+ npm install formula-composer @tinymce/tinymce-react tinymce
33
+ ```
34
+
35
+ ```tsx
36
+ import { FormulaComposerEditor, FormulaComposerProvider } from 'formula-composer/react';
37
+
38
+ <FormulaComposerProvider config={{ saveMode: 'xml' }}>
39
+ <FormulaComposerEditor
40
+ tinymceScriptSrc="/tinymce/tinymce.min.js"
41
+ init={{ plugins: 'lists', toolbar: 'undo redo | bold italic' }}
42
+ value={html}
43
+ onEditorChange={setHtml}
44
+ />
45
+ </FormulaComposerProvider>
46
+ ```
47
+
48
+ `<FormulaComposerEditor>` takes the same props as `<Editor>` from `@tinymce/tinymce-react`.
49
+
50
+ ## Angular
51
+
52
+ ```bash
53
+ npm install formula-composer @tinymce/tinymce-angular tinymce
54
+ ```
55
+
56
+ Add `provideFormulaComposer(...)` to your providers (or `FormulaComposerModule.forRoot(...)` to an NgModule),
57
+ import `FormulaComposerModule`, then add the `formulaComposer` directive to the TinyMCE `<editor>`:
58
+
59
+ ```ts
60
+ import { FormulaComposerModule, provideFormulaComposer } from 'formula-composer/angular';
61
+ ```
62
+
63
+ ```html
64
+ <editor formulaComposer [init]="{ plugins: 'lists' }" [(ngModel)]="html" />
65
+ ```
66
+
67
+ ## TinyMCE in a bundled app
68
+
69
+ ```ts
70
+ import tinymce from 'tinymce';
71
+ import { registerFormulaComposer } from 'formula-composer';
72
+
73
+ registerFormulaComposer(tinymce);
74
+ tinymce.init({
75
+ selector: '#editor',
76
+ plugins: 'formulacomposer',
77
+ toolbar: 'undo redo | bold italic | formulaComposer',
78
+ formulaComposer: { saveMode: 'xml' },
79
+ });
80
+ ```
81
+
82
+ ## TinyMCE with a script tag
83
+
84
+ Serve `node_modules/formula-composer/dist/tinymce/browser/plugin.min.js` next to TinyMCE:
85
+
86
+ ```html
87
+ <script src="/tinymce/tinymce.min.js"></script>
88
+ <script src="/formulacomposer/plugin.min.js"></script>
89
+ <script>
90
+ tinymce.init({
91
+ selector: '#editor',
92
+ plugins: 'formulacomposer',
93
+ toolbar: 'undo redo | bold italic | formulaComposer',
94
+ });
95
+ </script>
96
+ ```
97
+
98
+ TinyMCE 7 and 8 also need `license_key: 'gpl'` (or `licenseKey="gpl"` in React and Angular) or a commercial key.
99
+
100
+ ## Options
101
+
102
+ Pass them as `formulaComposer: { ... }` in the TinyMCE init (or `config` / `forRoot` in React and Angular).
103
+
104
+ | Option | Default | Meaning |
105
+ | --- | --- | --- |
106
+ | `saveMode` | `'xml'` | Output format: `xml`, `safeXml`, `image`, `base64` |
107
+ | `parseLatex` | `true` | Keep `$$latex$$` while editing; save it as MathML |
108
+ | `accessibility` | `true` | Generate `alt` text |
109
+ | `openFullScreen` | `false` | Open the editor maximized |
110
+ | `language` | TinyMCE language | `en`, `es`, `fr`, `de`, `it`, `pt`, `pt_br`, `ca`, `ar`, `he` |
111
+ | `toolbar` | all tabs | Tab ids to show, in order |
112
+ | `imageFontSize` | `16` | Formula image font size, 6 to 96 px |
113
+ | `latexToggle` | `true` | Show the LaTeX button |
114
+
115
+ ## Showing saved content
116
+
117
+ Browsers render MathML natively. To also render older markup such as `mfenced` or `menclose`,
118
+ call `upgradeMathElements(element)` (exported from `formula-composer`) on trusted content.
119
+
120
+ ## License
121
+
122
+ Free to use in personal and commercial projects. Selling, repackaging or modifying the library
123
+ itself is not allowed. See [LICENSE](LICENSE).
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Generated bundle index. Do not edit.
3
+ */
4
+ export * from './public-api';
@@ -0,0 +1,52 @@
1
+ import { Directive, Host, Inject, Input, Optional } from '@angular/core';
2
+ import { appendToolbarButton, withFormulaComposer } from './init';
3
+ import { FORMULA_COMPOSER_CONFIG } from './provide';
4
+ import * as i0 from "@angular/core";
5
+ import * as i1 from "@tinymce/tinymce-angular";
6
+ /**
7
+ * Adds the Formula Composer math editor to a stock TinyMCE `<editor>`:
8
+ * `<editor formulaComposer [init]="init" />` or `<editor [formulaComposer]="{ saveMode: 'safeXml' }" />`.
9
+ * Options are merged as provider defaults < directive input < `init.formulaComposer`.
10
+ * The legacy `sylarWiris` attribute and input still work.
11
+ * Declared by `FormulaComposerModule`, which NgModules and standalone components import.
12
+ */
13
+ export class FormulaComposerDirective {
14
+ constructor(host, defaults) {
15
+ this.host = host;
16
+ this.defaults = defaults;
17
+ this.formulaComposer = '';
18
+ /** @deprecated Use `formulaComposer`. */
19
+ this.sylarWiris = '';
20
+ }
21
+ ngOnInit() {
22
+ const legacy = this.sylarWiris;
23
+ const local = this.formulaComposer;
24
+ this.host.init = withFormulaComposer(this.host.init, {
25
+ ...this.defaults,
26
+ ...(legacy === '' ? {} : legacy),
27
+ ...(local === '' ? {} : local),
28
+ });
29
+ const toolbar = this.host.toolbar;
30
+ if (typeof toolbar === 'string')
31
+ this.host.toolbar = appendToolbarButton(toolbar);
32
+ else if (Array.isArray(toolbar))
33
+ this.host.toolbar = appendToolbarButton(toolbar);
34
+ }
35
+ }
36
+ FormulaComposerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FormulaComposerDirective, deps: [{ token: i1.EditorComponent, host: true }, { token: FORMULA_COMPOSER_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
37
+ FormulaComposerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FormulaComposerDirective, selector: "editor[formulaComposer], editor[sylarWiris]", inputs: { formulaComposer: "formulaComposer", sylarWiris: "sylarWiris" }, ngImport: i0 });
38
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FormulaComposerDirective, decorators: [{
39
+ type: Directive,
40
+ args: [{ selector: 'editor[formulaComposer], editor[sylarWiris]' }]
41
+ }], ctorParameters: function () { return [{ type: i1.EditorComponent, decorators: [{
42
+ type: Host
43
+ }] }, { type: undefined, decorators: [{
44
+ type: Optional
45
+ }, {
46
+ type: Inject,
47
+ args: [FORMULA_COMPOSER_CONFIG]
48
+ }] }]; }, propDecorators: { formulaComposer: [{
49
+ type: Input
50
+ }], sylarWiris: [{
51
+ type: Input
52
+ }] } });
@@ -0,0 +1,21 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { FormulaComposerDirective } from './formula-composer.directive';
3
+ import { provideFormulaComposer } from './provide';
4
+ import * as i0 from "@angular/core";
5
+ /**
6
+ * Declares and exports {@link FormulaComposerDirective}. Import it in an NgModule or, from Angular 14, in a
7
+ * standalone component's `imports`.
8
+ */
9
+ export class FormulaComposerModule {
10
+ /** The module plus app-wide defaults; the NgModule alternative to {@link provideFormulaComposer}. */
11
+ static forRoot(config = {}) {
12
+ return { ngModule: FormulaComposerModule, providers: provideFormulaComposer(config) };
13
+ }
14
+ }
15
+ FormulaComposerModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FormulaComposerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
16
+ FormulaComposerModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FormulaComposerModule, declarations: [FormulaComposerDirective], exports: [FormulaComposerDirective] });
17
+ FormulaComposerModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FormulaComposerModule });
18
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FormulaComposerModule, decorators: [{
19
+ type: NgModule,
20
+ args: [{ declarations: [FormulaComposerDirective], exports: [FormulaComposerDirective] }]
21
+ }] });
@@ -0,0 +1,9 @@
1
+ import { appendFormulaButton, withFormulaComposer as addFormulaComposer } from '../../../dist/tinymce/index.js';
2
+ export function appendToolbarButton(toolbar) {
3
+ return appendFormulaButton(toolbar);
4
+ }
5
+ export function withFormulaComposer(init = {}, options = {}) {
6
+ return addFormulaComposer(init, options);
7
+ }
8
+ /** @deprecated Use {@link withFormulaComposer}. */
9
+ export const withSylarWiris = withFormulaComposer;
@@ -0,0 +1,11 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ /** App-wide defaults for every `<editor formulaComposer>`. */
3
+ export const FORMULA_COMPOSER_CONFIG = new InjectionToken('FORMULA_COMPOSER_CONFIG');
4
+ /** Providers for app-wide defaults: use them in `bootstrapApplication`, NgModule or component `providers`. */
5
+ export function provideFormulaComposer(config = {}) {
6
+ return [{ provide: FORMULA_COMPOSER_CONFIG, useValue: config }];
7
+ }
8
+ /** @deprecated Use {@link FORMULA_COMPOSER_CONFIG}. */
9
+ export const SYLAR_WIRIS_CONFIG = FORMULA_COMPOSER_CONFIG;
10
+ /** @deprecated Use {@link provideFormulaComposer}. */
11
+ export const provideSylarWiris = provideFormulaComposer;
@@ -0,0 +1,8 @@
1
+ /*
2
+ * Public API Surface of @formula-composer/tinymce-angular
3
+ */
4
+ export { appendToolbarButton, withFormulaComposer, withSylarWiris } from './lib/init';
5
+ export { FORMULA_COMPOSER_CONFIG, SYLAR_WIRIS_CONFIG, provideFormulaComposer, provideSylarWiris } from './lib/provide';
6
+ export { FormulaComposerDirective, FormulaComposerDirective as SylarWirisDirective } from './lib/formula-composer.directive';
7
+ export { FormulaComposerModule } from './lib/formula-composer.module';
8
+ export { upgradeMathElements } from '../../dist/tinymce/index.js';
@@ -0,0 +1,99 @@
1
+ import { appendFormulaButton, withFormulaComposer as withFormulaComposer$1 } from '../../dist/tinymce/index.js';
2
+ export { upgradeMathElements } from '../../dist/tinymce/index.js';
3
+ import * as i0 from '@angular/core';
4
+ import { InjectionToken, Directive, Host, Optional, Inject, Input, NgModule } from '@angular/core';
5
+ import * as i1 from '@tinymce/tinymce-angular';
6
+
7
+ function appendToolbarButton(toolbar) {
8
+ return appendFormulaButton(toolbar);
9
+ }
10
+ function withFormulaComposer(init = {}, options = {}) {
11
+ return withFormulaComposer$1(init, options);
12
+ }
13
+ /** @deprecated Use {@link withFormulaComposer}. */
14
+ const withSylarWiris = withFormulaComposer;
15
+
16
+ /** App-wide defaults for every `<editor formulaComposer>`. */
17
+ const FORMULA_COMPOSER_CONFIG = new InjectionToken('FORMULA_COMPOSER_CONFIG');
18
+ /** Providers for app-wide defaults: use them in `bootstrapApplication`, NgModule or component `providers`. */
19
+ function provideFormulaComposer(config = {}) {
20
+ return [{ provide: FORMULA_COMPOSER_CONFIG, useValue: config }];
21
+ }
22
+ /** @deprecated Use {@link FORMULA_COMPOSER_CONFIG}. */
23
+ const SYLAR_WIRIS_CONFIG = FORMULA_COMPOSER_CONFIG;
24
+ /** @deprecated Use {@link provideFormulaComposer}. */
25
+ const provideSylarWiris = provideFormulaComposer;
26
+
27
+ /**
28
+ * Adds the Formula Composer math editor to a stock TinyMCE `<editor>`:
29
+ * `<editor formulaComposer [init]="init" />` or `<editor [formulaComposer]="{ saveMode: 'safeXml' }" />`.
30
+ * Options are merged as provider defaults < directive input < `init.formulaComposer`.
31
+ * The legacy `sylarWiris` attribute and input still work.
32
+ * Declared by `FormulaComposerModule`, which NgModules and standalone components import.
33
+ */
34
+ class FormulaComposerDirective {
35
+ constructor(host, defaults) {
36
+ this.host = host;
37
+ this.defaults = defaults;
38
+ this.formulaComposer = '';
39
+ /** @deprecated Use `formulaComposer`. */
40
+ this.sylarWiris = '';
41
+ }
42
+ ngOnInit() {
43
+ const legacy = this.sylarWiris;
44
+ const local = this.formulaComposer;
45
+ this.host.init = withFormulaComposer(this.host.init, Object.assign(Object.assign(Object.assign({}, this.defaults), (legacy === '' ? {} : legacy)), (local === '' ? {} : local)));
46
+ const toolbar = this.host.toolbar;
47
+ if (typeof toolbar === 'string')
48
+ this.host.toolbar = appendToolbarButton(toolbar);
49
+ else if (Array.isArray(toolbar))
50
+ this.host.toolbar = appendToolbarButton(toolbar);
51
+ }
52
+ }
53
+ FormulaComposerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FormulaComposerDirective, deps: [{ token: i1.EditorComponent, host: true }, { token: FORMULA_COMPOSER_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
54
+ FormulaComposerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FormulaComposerDirective, selector: "editor[formulaComposer], editor[sylarWiris]", inputs: { formulaComposer: "formulaComposer", sylarWiris: "sylarWiris" }, ngImport: i0 });
55
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FormulaComposerDirective, decorators: [{
56
+ type: Directive,
57
+ args: [{ selector: 'editor[formulaComposer], editor[sylarWiris]' }]
58
+ }], ctorParameters: function () {
59
+ return [{ type: i1.EditorComponent, decorators: [{
60
+ type: Host
61
+ }] }, { type: undefined, decorators: [{
62
+ type: Optional
63
+ }, {
64
+ type: Inject,
65
+ args: [FORMULA_COMPOSER_CONFIG]
66
+ }] }];
67
+ }, propDecorators: { formulaComposer: [{
68
+ type: Input
69
+ }], sylarWiris: [{
70
+ type: Input
71
+ }] } });
72
+
73
+ /**
74
+ * Declares and exports {@link FormulaComposerDirective}. Import it in an NgModule or, from Angular 14, in a
75
+ * standalone component's `imports`.
76
+ */
77
+ class FormulaComposerModule {
78
+ /** The module plus app-wide defaults; the NgModule alternative to {@link provideFormulaComposer}. */
79
+ static forRoot(config = {}) {
80
+ return { ngModule: FormulaComposerModule, providers: provideFormulaComposer(config) };
81
+ }
82
+ }
83
+ FormulaComposerModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FormulaComposerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
84
+ FormulaComposerModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FormulaComposerModule, declarations: [FormulaComposerDirective], exports: [FormulaComposerDirective] });
85
+ FormulaComposerModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FormulaComposerModule });
86
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FormulaComposerModule, decorators: [{
87
+ type: NgModule,
88
+ args: [{ declarations: [FormulaComposerDirective], exports: [FormulaComposerDirective] }]
89
+ }] });
90
+
91
+ /*
92
+ * Public API Surface of @formula-composer/tinymce-angular
93
+ */
94
+
95
+ /**
96
+ * Generated bundle index. Do not edit.
97
+ */
98
+
99
+ export { FORMULA_COMPOSER_CONFIG, FormulaComposerDirective, FormulaComposerModule, SYLAR_WIRIS_CONFIG, FormulaComposerDirective as SylarWirisDirective, appendToolbarButton, provideFormulaComposer, provideSylarWiris, withFormulaComposer, withSylarWiris };
@@ -0,0 +1,101 @@
1
+ import { appendFormulaButton, withFormulaComposer as withFormulaComposer$1 } from '../../dist/tinymce/index.js';
2
+ export { upgradeMathElements } from '../../dist/tinymce/index.js';
3
+ import * as i0 from '@angular/core';
4
+ import { InjectionToken, Directive, Host, Optional, Inject, Input, NgModule } from '@angular/core';
5
+ import * as i1 from '@tinymce/tinymce-angular';
6
+
7
+ function appendToolbarButton(toolbar) {
8
+ return appendFormulaButton(toolbar);
9
+ }
10
+ function withFormulaComposer(init = {}, options = {}) {
11
+ return withFormulaComposer$1(init, options);
12
+ }
13
+ /** @deprecated Use {@link withFormulaComposer}. */
14
+ const withSylarWiris = withFormulaComposer;
15
+
16
+ /** App-wide defaults for every `<editor formulaComposer>`. */
17
+ const FORMULA_COMPOSER_CONFIG = new InjectionToken('FORMULA_COMPOSER_CONFIG');
18
+ /** Providers for app-wide defaults: use them in `bootstrapApplication`, NgModule or component `providers`. */
19
+ function provideFormulaComposer(config = {}) {
20
+ return [{ provide: FORMULA_COMPOSER_CONFIG, useValue: config }];
21
+ }
22
+ /** @deprecated Use {@link FORMULA_COMPOSER_CONFIG}. */
23
+ const SYLAR_WIRIS_CONFIG = FORMULA_COMPOSER_CONFIG;
24
+ /** @deprecated Use {@link provideFormulaComposer}. */
25
+ const provideSylarWiris = provideFormulaComposer;
26
+
27
+ /**
28
+ * Adds the Formula Composer math editor to a stock TinyMCE `<editor>`:
29
+ * `<editor formulaComposer [init]="init" />` or `<editor [formulaComposer]="{ saveMode: 'safeXml' }" />`.
30
+ * Options are merged as provider defaults < directive input < `init.formulaComposer`.
31
+ * The legacy `sylarWiris` attribute and input still work.
32
+ * Declared by `FormulaComposerModule`, which NgModules and standalone components import.
33
+ */
34
+ class FormulaComposerDirective {
35
+ constructor(host, defaults) {
36
+ this.host = host;
37
+ this.defaults = defaults;
38
+ this.formulaComposer = '';
39
+ /** @deprecated Use `formulaComposer`. */
40
+ this.sylarWiris = '';
41
+ }
42
+ ngOnInit() {
43
+ const legacy = this.sylarWiris;
44
+ const local = this.formulaComposer;
45
+ this.host.init = withFormulaComposer(this.host.init, {
46
+ ...this.defaults,
47
+ ...(legacy === '' ? {} : legacy),
48
+ ...(local === '' ? {} : local),
49
+ });
50
+ const toolbar = this.host.toolbar;
51
+ if (typeof toolbar === 'string')
52
+ this.host.toolbar = appendToolbarButton(toolbar);
53
+ else if (Array.isArray(toolbar))
54
+ this.host.toolbar = appendToolbarButton(toolbar);
55
+ }
56
+ }
57
+ FormulaComposerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FormulaComposerDirective, deps: [{ token: i1.EditorComponent, host: true }, { token: FORMULA_COMPOSER_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
58
+ FormulaComposerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.4.0", type: FormulaComposerDirective, selector: "editor[formulaComposer], editor[sylarWiris]", inputs: { formulaComposer: "formulaComposer", sylarWiris: "sylarWiris" }, ngImport: i0 });
59
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FormulaComposerDirective, decorators: [{
60
+ type: Directive,
61
+ args: [{ selector: 'editor[formulaComposer], editor[sylarWiris]' }]
62
+ }], ctorParameters: function () { return [{ type: i1.EditorComponent, decorators: [{
63
+ type: Host
64
+ }] }, { type: undefined, decorators: [{
65
+ type: Optional
66
+ }, {
67
+ type: Inject,
68
+ args: [FORMULA_COMPOSER_CONFIG]
69
+ }] }]; }, propDecorators: { formulaComposer: [{
70
+ type: Input
71
+ }], sylarWiris: [{
72
+ type: Input
73
+ }] } });
74
+
75
+ /**
76
+ * Declares and exports {@link FormulaComposerDirective}. Import it in an NgModule or, from Angular 14, in a
77
+ * standalone component's `imports`.
78
+ */
79
+ class FormulaComposerModule {
80
+ /** The module plus app-wide defaults; the NgModule alternative to {@link provideFormulaComposer}. */
81
+ static forRoot(config = {}) {
82
+ return { ngModule: FormulaComposerModule, providers: provideFormulaComposer(config) };
83
+ }
84
+ }
85
+ FormulaComposerModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FormulaComposerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
86
+ FormulaComposerModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FormulaComposerModule, declarations: [FormulaComposerDirective], exports: [FormulaComposerDirective] });
87
+ FormulaComposerModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FormulaComposerModule });
88
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FormulaComposerModule, decorators: [{
89
+ type: NgModule,
90
+ args: [{ declarations: [FormulaComposerDirective], exports: [FormulaComposerDirective] }]
91
+ }] });
92
+
93
+ /*
94
+ * Public API Surface of @formula-composer/tinymce-angular
95
+ */
96
+
97
+ /**
98
+ * Generated bundle index. Do not edit.
99
+ */
100
+
101
+ export { FORMULA_COMPOSER_CONFIG, FormulaComposerDirective, FormulaComposerModule, SYLAR_WIRIS_CONFIG, FormulaComposerDirective as SylarWirisDirective, appendToolbarButton, provideFormulaComposer, provideSylarWiris, withFormulaComposer, withSylarWiris };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Generated bundle index. Do not edit.
3
+ */
4
+ /// <amd-module name="@formula-composer/tinymce-angular" />
5
+ export * from './public-api';
@@ -0,0 +1,22 @@
1
+ import { type OnInit } from '@angular/core';
2
+ import { EditorComponent } from '@tinymce/tinymce-angular';
3
+ import type { FormulaComposerOptions } from '../../dist/tinymce/index';
4
+ import * as i0 from "@angular/core";
5
+ /**
6
+ * Adds the Formula Composer math editor to a stock TinyMCE `<editor>`:
7
+ * `<editor formulaComposer [init]="init" />` or `<editor [formulaComposer]="{ saveMode: 'safeXml' }" />`.
8
+ * Options are merged as provider defaults < directive input < `init.formulaComposer`.
9
+ * The legacy `sylarWiris` attribute and input still work.
10
+ * Declared by `FormulaComposerModule`, which NgModules and standalone components import.
11
+ */
12
+ export declare class FormulaComposerDirective implements OnInit {
13
+ private readonly host;
14
+ private readonly defaults;
15
+ formulaComposer: FormulaComposerOptions | '';
16
+ /** @deprecated Use `formulaComposer`. */
17
+ sylarWiris: FormulaComposerOptions | '';
18
+ constructor(host: EditorComponent, defaults: FormulaComposerOptions | null);
19
+ ngOnInit(): void;
20
+ static ɵfac: i0.ɵɵFactoryDeclaration<FormulaComposerDirective, [{ host: true; }, { optional: true; }]>;
21
+ static ɵdir: i0.ɵɵDirectiveDeclaration<FormulaComposerDirective, "editor[formulaComposer], editor[sylarWiris]", never, { "formulaComposer": "formulaComposer"; "sylarWiris": "sylarWiris"; }, {}, never>;
22
+ }
@@ -0,0 +1,15 @@
1
+ import { type ModuleWithProviders } from '@angular/core';
2
+ import type { FormulaComposerOptions } from '../../dist/tinymce/index';
3
+ import * as i0 from "@angular/core";
4
+ import * as i1 from "./formula-composer.directive";
5
+ /**
6
+ * Declares and exports {@link FormulaComposerDirective}. Import it in an NgModule or, from Angular 14, in a
7
+ * standalone component's `imports`.
8
+ */
9
+ export declare class FormulaComposerModule {
10
+ /** The module plus app-wide defaults; the NgModule alternative to {@link provideFormulaComposer}. */
11
+ static forRoot(config?: FormulaComposerOptions): ModuleWithProviders<FormulaComposerModule>;
12
+ static ɵfac: i0.ɵɵFactoryDeclaration<FormulaComposerModule, never>;
13
+ static ɵmod: i0.ɵɵNgModuleDeclaration<FormulaComposerModule, [typeof i1.FormulaComposerDirective], never, [typeof i1.FormulaComposerDirective]>;
14
+ static ɵinj: i0.ɵɵInjectorDeclaration<FormulaComposerModule>;
15
+ }
@@ -0,0 +1,23 @@
1
+ import type { EditorComponent } from '@tinymce/tinymce-angular';
2
+ import { type FormulaComposerOptions } from '../../dist/tinymce/index';
3
+ /** TinyMCE init options as accepted by `<editor [init]>` of the installed `@tinymce/tinymce-angular`. */
4
+ export declare type TinyMCEInit = NonNullable<EditorComponent['init']>;
5
+ export declare type TinyMCEToolbar = TinyMCEInit['toolbar'];
6
+ /**
7
+ * Appends the formula button to an explicit toolbar. `undefined`/`true` (TinyMCE default toolbar)
8
+ * and `false` are returned unchanged.
9
+ */
10
+ export declare function appendToolbarButton(toolbar: string): string;
11
+ export declare function appendToolbarButton(toolbar: string[]): string[];
12
+ export declare function appendToolbarButton(toolbar: TinyMCEToolbar): TinyMCEToolbar;
13
+ /**
14
+ * Adds Formula Composer to TinyMCE init options: registers the bundled plugin before TinyMCE loads plugins,
15
+ * enables it, adds the toolbar button and merges `options` under the `formulaComposer` key (init wins).
16
+ *
17
+ * Init objects typed for the installed `@tinymce-angular` get that type back. Any other init object (for
18
+ * example a shared config typed as a plain object, or with parts that depend on a condition) keeps its own type.
19
+ */
20
+ export declare function withFormulaComposer(init?: TinyMCEInit, options?: FormulaComposerOptions): TinyMCEInit;
21
+ export declare function withFormulaComposer<T extends object>(init: T, options?: FormulaComposerOptions): T;
22
+ /** @deprecated Use {@link withFormulaComposer}. */
23
+ export declare const withSylarWiris: typeof withFormulaComposer;
@@ -0,0 +1,10 @@
1
+ import { InjectionToken, type Provider } from '@angular/core';
2
+ import type { FormulaComposerOptions } from '../../dist/tinymce/index';
3
+ /** App-wide defaults for every `<editor formulaComposer>`. */
4
+ export declare const FORMULA_COMPOSER_CONFIG: InjectionToken<FormulaComposerOptions>;
5
+ /** Providers for app-wide defaults: use them in `bootstrapApplication`, NgModule or component `providers`. */
6
+ export declare function provideFormulaComposer(config?: FormulaComposerOptions): Provider[];
7
+ /** @deprecated Use {@link FORMULA_COMPOSER_CONFIG}. */
8
+ export declare const SYLAR_WIRIS_CONFIG: InjectionToken<FormulaComposerOptions>;
9
+ /** @deprecated Use {@link provideFormulaComposer}. */
10
+ export declare const provideSylarWiris: typeof provideFormulaComposer;
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "formula-composer/angular",
3
+ "sideEffects": false,
4
+ "module": "fesm2015/formula-composer-tinymce-angular.mjs",
5
+ "es2020": "fesm2020/formula-composer-tinymce-angular.mjs",
6
+ "esm2020": "esm2020/formula-composer-tinymce-angular.mjs",
7
+ "fesm2020": "fesm2020/formula-composer-tinymce-angular.mjs",
8
+ "fesm2015": "fesm2015/formula-composer-tinymce-angular.mjs",
9
+ "typings": "formula-composer-tinymce-angular.d.ts"
10
+ }
@@ -0,0 +1,5 @@
1
+ export { type TinyMCEInit, type TinyMCEToolbar, appendToolbarButton, withFormulaComposer, withSylarWiris } from './lib/init';
2
+ export { FORMULA_COMPOSER_CONFIG, SYLAR_WIRIS_CONFIG, provideFormulaComposer, provideSylarWiris } from './lib/provide';
3
+ export { FormulaComposerDirective, FormulaComposerDirective as SylarWirisDirective } from './lib/formula-composer.directive';
4
+ export { FormulaComposerModule } from './lib/formula-composer.module';
5
+ export { type FormulaComposerOptions, type SaveMode, type SylarWirisOptions, upgradeMathElements } from '../dist/tinymce/index';
@@ -0,0 +1,30 @@
1
+ export type ToolbarItemKind = 'symbol' | 'template' | 'action' | 'select';
2
+ export type TabId = 'GEN' | 'SYM' | 'ARR' | 'GRK' | 'MAT' | 'SCR' | 'DEC' | 'BIG' | 'CAL' | 'CTX';
3
+ export interface ToolbarItem {
4
+ /** REA feature id, e.g. `TB-GEN-001`. */
5
+ readonly id: string;
6
+ readonly title: string;
7
+ readonly kind: ToolbarItemKind;
8
+ /** MathML fragment inserted by symbols and templates. */
9
+ readonly mml?: string;
10
+ readonly options?: readonly string[];
11
+ /** MathML inferred (the reference output was not captured). */
12
+ readonly inferred?: boolean;
13
+ /** Zero-based `[row, column]` in the reference toolbar grid. */
14
+ readonly cell: readonly [number, number];
15
+ }
16
+ export interface ToolbarSection {
17
+ readonly id: string;
18
+ /** Grid rows in the reference toolbar (1, 2 or 3). */
19
+ readonly rows: number;
20
+ readonly items: readonly ToolbarItem[];
21
+ /** Items of the section's "More" popup. */
22
+ readonly more?: readonly ToolbarItem[];
23
+ /** Grid rows of the "More" popup. */
24
+ readonly moreRows?: number;
25
+ }
26
+ export interface ToolbarTab {
27
+ readonly id: TabId;
28
+ readonly title: string;
29
+ readonly sections: readonly ToolbarSection[];
30
+ }
@@ -0,0 +1,2 @@
1
+ import type { ToolbarTab } from './catalog-types.js';
2
+ export declare const TOOLBAR_CATALOG: readonly ToolbarTab[];
@@ -0,0 +1,44 @@
1
+ import type { MathEditorModel, MatrixKind } from '../math-core/index';
2
+ import type { EditorStrings } from './strings.js';
3
+ export type NumeralMode = 'western' | 'arabic-indic' | 'eastern-arabic-indic';
4
+ /** What toolbar commands need from the editor. */
5
+ export interface EditorHost {
6
+ readonly model: MathEditorModel;
7
+ readonly strings: EditorStrings;
8
+ readonly numerals: NumeralMode;
9
+ setNumerals(mode: NumeralMode): void;
10
+ insertMathML(fragment: string): void;
11
+ copy(): void;
12
+ cut(): void;
13
+ paste(): void;
14
+ openColorPicker(anchor: HTMLElement): void;
15
+ openSpecialCharacters(anchor: HTMLElement): void;
16
+ openMatrixPicker(anchor: HTMLElement, kind: MatrixKind): void;
17
+ openValuePrompt(anchor: HTMLElement, label: string, initial: string, apply: (value: string) => void): void;
18
+ }
19
+ export interface ActionSpec {
20
+ /** Short visible label; `icon` and then `mml` win when set. */
21
+ readonly label?: string;
22
+ readonly icon?: readonly string[];
23
+ /** MathML fragment drawn as the icon. */
24
+ readonly mml?: string;
25
+ readonly popup?: boolean;
26
+ run(host: EditorHost, anchor: HTMLElement): void;
27
+ enabled?(host: EditorHost): boolean;
28
+ pressed?(host: EditorHost): boolean;
29
+ /** Contextual visibility; hidden controls are not rendered. */
30
+ visible?(host: EditorHost): boolean;
31
+ }
32
+ export interface SelectSpec {
33
+ /** Option values in the same order as the catalog options; `null` clears. */
34
+ readonly values: ReadonlyArray<string | null>;
35
+ run(host: EditorHost, value: string | null): void;
36
+ current?(host: EditorHost): string | null;
37
+ visible?(host: EditorHost): boolean;
38
+ }
39
+ /** Toolbar actions by REA id. Ids absent from this map and from {@link SELECTS} are not rendered (see docs/gaps.md). */
40
+ export declare const ACTIONS: Readonly<Record<string, ActionSpec>>;
41
+ /** Selects by REA id. The catalog provides the option labels. */
42
+ export declare const SELECTS: Readonly<Record<string, SelectSpec>>;
43
+ /** REA ids intentionally not rendered, with the reason recorded in docs/gaps.md. */
44
+ export declare const UNSUPPORTED_ACTIONS: Readonly<Record<string, string>>;