oasis-editor 0.0.148 → 0.0.149

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 (35) hide show
  1. package/dist/{OasisEditorApp-B1b1iJOQ.js → OasisEditorApp-CmqlSXEk.js} +302 -45
  2. package/dist/app/controllers/useEditorSurfaceEvents.d.ts +1 -0
  3. package/dist/assets/importDocxWorker-CpQR2fwx.js +12 -0
  4. package/dist/core/commands/builtinCommands.d.ts +1 -1
  5. package/dist/core/commands/publicCommandTypes.d.ts +7 -1
  6. package/dist/core/commands/text.d.ts +1 -1
  7. package/dist/core/commands/textEditing.d.ts +3 -1
  8. package/dist/core/document/clone.d.ts +2 -1
  9. package/dist/core/math/linear.d.ts +5 -0
  10. package/dist/core/model/index.d.ts +3 -1
  11. package/dist/core/model/runKind.d.ts +3 -0
  12. package/dist/core/model/types/layout.d.ts +2 -0
  13. package/dist/core/model/types/math.d.ts +95 -0
  14. package/dist/core/model/types/nodes.d.ts +4 -0
  15. package/dist/export/docx/text/mathXml.d.ts +3 -0
  16. package/dist/i18n/locales/en.d.ts +5 -0
  17. package/dist/i18n/locales/pt-BR.d.ts +5 -0
  18. package/dist/import/docx/math.d.ts +5 -0
  19. package/dist/import/docx/runs/types.d.ts +2 -1
  20. package/dist/{index-CpZO1PF4.js → index-B7V7kbjr.js} +1860 -1285
  21. package/dist/index.d.ts +1 -0
  22. package/dist/oasis-editor.css +1 -1
  23. package/dist/oasis-editor.js +79 -79
  24. package/dist/oasis-editor.umd.cjs +4 -4
  25. package/dist/plugins/internal/essentialsCapabilities.d.ts +4 -1
  26. package/dist/ui/app/EditorDialogsLayer.d.ts +2 -0
  27. package/dist/ui/app/createEditorCommandRuntime.d.ts +5 -0
  28. package/dist/ui/app/createEditorInteractionRuntime.d.ts +1 -0
  29. package/dist/ui/app/essentials/types.d.ts +1 -0
  30. package/dist/ui/app/useEditorDialogs.d.ts +11 -0
  31. package/dist/ui/app/useEditorInteractionWiring.d.ts +1 -0
  32. package/dist/ui/components/Dialogs/EquationDialog.d.ts +10 -0
  33. package/dist/ui/math/mathPainter.d.ts +10 -0
  34. package/package.json +1 -1
  35. package/dist/assets/importDocxWorker-BLm3QMHu.js +0 -12
@@ -1,2 +1,2 @@
1
- export declare const OASIS_BUILTIN_COMMANDS: readonly ["selectAll", "insertFootnote", "insertText", "insertTableOfContents", "updateTableOfContents", "pastePlainText", "bold", "italic", "underline", "strike", "superscript", "subscript", "link", "unlink", "alignLeft", "alignCenter", "alignRight", "alignJustify", "orderedList", "bulletList", "find", "replace", "toggleTrackChanges", "acceptRevisions", "rejectRevisions", "toggleShowMargins", "toggleShowParagraphMarks", "togglePreciseFonts", "undo", "redo", "pageBreak", "lineBreak", "splitBlock", "setFontFamily", "setFontSize", "increaseFontSize", "decreaseFontSize", "changeTextCase", "clearFormatting", "setColor", "setHighlight", "setTextShading", "setStyleId", "setCharacterStyleId", "setUnderlineStyle", "documentStyles", "print", "copy", "newDocument", "exportDocx", "exportPdf", "importDocument", "insertImage", "editImageAlt", "insertImageCaption", "imageContext", "imageWidthCm", "imageHeightCm", "imageCrop", "imageCropAspect", "imageBorder", "outdent", "indent", "togglePageBreakBefore", "toggleKeepWithNext", "setSpacingAfter", "setSpacingBefore", "setIndentLeft", "setIndentRight", "setIndentFirstLine", "setIndentHanging", "setSpecialIndent", "setParagraphShading", "applyParagraphBorders", "setLineHeight", "setListFormat", "setListStartAt", "toggleOrientation", "setOrientation", "sectionBreakNextPage", "sectionBreakContinuous", "setPageMargins", "tableContext", "tableMerge", "tableSplit", "tableInsertColumnBefore", "tableInsertColumnAfter", "tableDeleteColumn", "tableInsertRowBefore", "tableInsertRowAfter", "tableDeleteRow", "tableCellShading", "tableCellBorders", "tableCellNoBorders", "tableApplyBorderPreset", "toggleTableDrawBorders", "toggleTableGridlines", "tableWidth100", "tableAlignLeft", "tableAlignCenter", "tableAlignRight", "tableSetCellWidth", "tableToggleHeaderRow", "tableToggleTotalRow", "tableToggleBandedRows", "tableToggleFirstColumn", "tableToggleLastColumn", "tableToggleBandedColumns", "setTableStyle", "tableToggleAutoFit", "tableDistributeColumns", "tableDistributeRows", "insertTable", "insertShape", "openSymbolDialog"];
1
+ export declare const OASIS_BUILTIN_COMMANDS: readonly ["selectAll", "insertFootnote", "insertText", "insertEquation", "updateEquation", "insertTableOfContents", "updateTableOfContents", "pastePlainText", "bold", "italic", "underline", "strike", "superscript", "subscript", "link", "unlink", "alignLeft", "alignCenter", "alignRight", "alignJustify", "orderedList", "bulletList", "find", "replace", "toggleTrackChanges", "acceptRevisions", "rejectRevisions", "toggleShowMargins", "toggleShowParagraphMarks", "togglePreciseFonts", "undo", "redo", "pageBreak", "lineBreak", "splitBlock", "setFontFamily", "setFontSize", "increaseFontSize", "decreaseFontSize", "changeTextCase", "clearFormatting", "setColor", "setHighlight", "setTextShading", "setStyleId", "setCharacterStyleId", "setUnderlineStyle", "documentStyles", "print", "copy", "newDocument", "exportDocx", "exportPdf", "importDocument", "insertImage", "editImageAlt", "insertImageCaption", "imageContext", "imageWidthCm", "imageHeightCm", "imageCrop", "imageCropAspect", "imageBorder", "outdent", "indent", "togglePageBreakBefore", "toggleKeepWithNext", "setSpacingAfter", "setSpacingBefore", "setIndentLeft", "setIndentRight", "setIndentFirstLine", "setIndentHanging", "setSpecialIndent", "setParagraphShading", "applyParagraphBorders", "setLineHeight", "setListFormat", "setListStartAt", "toggleOrientation", "setOrientation", "sectionBreakNextPage", "sectionBreakContinuous", "setPageMargins", "tableContext", "tableMerge", "tableSplit", "tableInsertColumnBefore", "tableInsertColumnAfter", "tableDeleteColumn", "tableInsertRowBefore", "tableInsertRowAfter", "tableDeleteRow", "tableCellShading", "tableCellBorders", "tableCellNoBorders", "tableApplyBorderPreset", "toggleTableDrawBorders", "toggleTableGridlines", "tableWidth100", "tableAlignLeft", "tableAlignCenter", "tableAlignRight", "tableSetCellWidth", "tableToggleHeaderRow", "tableToggleTotalRow", "tableToggleBandedRows", "tableToggleFirstColumn", "tableToggleLastColumn", "tableToggleBandedColumns", "setTableStyle", "tableToggleAutoFit", "tableDistributeColumns", "tableDistributeRows", "insertTable", "insertShape", "openSymbolDialog", "openEquationDialog"];
2
2
  export type OasisBuiltinCommand = (typeof OASIS_BUILTIN_COMMANDS)[number];
@@ -1,5 +1,5 @@
1
1
  import { CommandRef } from './CommandRef.js';
2
- import { EditorPageMargins } from '../model.js';
2
+ import { EditorPageMargins, EditorMathExpression } from '../model.js';
3
3
  import { TextCaseMode } from './text.js';
4
4
  import { TableBorderPreset } from './table.js';
5
5
 
@@ -33,6 +33,11 @@ export interface OasisCommandPayloads {
33
33
  selectAll: undefined;
34
34
  insertFootnote: undefined;
35
35
  insertText: string | InsertTextPayload;
36
+ insertEquation: EditorMathExpression;
37
+ updateEquation: {
38
+ runId: string;
39
+ expression: EditorMathExpression;
40
+ };
36
41
  pastePlainText: undefined;
37
42
  bold: undefined;
38
43
  italic: undefined;
@@ -141,6 +146,7 @@ export interface OasisCommandPayloads {
141
146
  tableDistributeRows: undefined;
142
147
  insertTable: InsertTablePayload;
143
148
  openSymbolDialog: undefined;
149
+ openEquationDialog: undefined;
144
150
  }
145
151
  /** Maps commands to their typed return values. Commands not listed return `unknown`. */
146
152
  export interface OasisCommandResults {
@@ -1,4 +1,4 @@
1
- export { moveOrCopySelectionToPosition, insertTextAtSelection, insertPlainTextAtSelection, } from './textEditing.js';
1
+ export { moveOrCopySelectionToPosition, insertTextAtSelection, insertPlainTextAtSelection, insertMathAtSelection, updateMathRun, } from './textEditing.js';
2
2
  export { deleteBackward, deleteForward } from './textDeletion.js';
3
3
  export { toggleTextStyle, clearSelectedTextFormatting, setTextStyleValue, } from './textFormatting.js';
4
4
  export { type TextCaseMode, transformSelectedText, changeSelectedTextCase, } from './textCase.js';
@@ -1,7 +1,9 @@
1
- import { EditorPosition, EditorState, EditorTextStyle } from '../model.js';
1
+ import { EditorPosition, EditorState, EditorTextStyle, EditorMathExpression } from '../model.js';
2
2
 
3
3
  export declare function moveOrCopySelectionToPosition(state: EditorState, targetPosition: EditorPosition, options?: {
4
4
  copy?: boolean;
5
5
  }): EditorState;
6
6
  export declare function insertTextAtSelection(state: EditorState, text: string, styleOverride?: EditorTextStyle): EditorState;
7
+ export declare function insertMathAtSelection(state: EditorState, expression: EditorMathExpression): EditorState;
8
+ export declare function updateMathRun(state: EditorState, runId: string, expression: EditorMathExpression): EditorState;
7
9
  export declare function insertPlainTextAtSelection(state: EditorState, text: string, styleOverride?: EditorTextStyle): EditorState;
@@ -1,6 +1,7 @@
1
- import { EditorBlockNode, EditorParagraphListStyle, EditorParagraphNode, EditorTextBoxData, EditorTextRun } from '../model.js';
1
+ import { EditorBlockNode, EditorParagraphListStyle, EditorParagraphNode, EditorTextBoxData, EditorTextRun, EditorMathExpression } from '../model.js';
2
2
 
3
3
  export declare function cloneTextBox(textBox: EditorTextBoxData): EditorTextBoxData;
4
+ export declare function cloneMathExpression(expression: EditorMathExpression): EditorMathExpression;
4
5
  export declare function cloneRun(run: EditorTextRun): EditorTextRun;
5
6
  export declare function cloneParagraph(paragraph: EditorParagraphNode): EditorParagraphNode;
6
7
  export declare function cloneParagraphList(list?: EditorParagraphListStyle): EditorParagraphListStyle | undefined;
@@ -0,0 +1,5 @@
1
+ import { EditorMathExpression, EditorMathNode } from '../model.js';
2
+
3
+ export declare function parseLinearMath(linear: string): EditorMathExpression;
4
+ export declare function serializeLinearMathNodes(nodes: EditorMathNode[]): string;
5
+ export declare function serializeLinearMath(expression: EditorMathExpression): string;
@@ -9,8 +9,10 @@
9
9
  export type { EditorUnderlineStyle, EditorLigatures, EditorNumberSpacing, EditorNumberForm, EditorTextLanguage, EditorBorderStyle, EditorEmphasisMark, EditorTabStop, EditorParagraphListStyle, EditorImageCrop, EditorImageFillMode, EditorLineDash, EditorImageBorder, EditorImageFloatingPosition, EditorImageFloatingLayout, EditorImageRunData, EditorWrapPolygonPoint, EditorFieldData, EditorFieldChar, EditorFootnoteReferenceData, EditorEndnoteReferenceData, EditorRevision, EditorRevisionMetadata, EditorStructuralRevision, EditorPropertyRevision, EditorAsset, EditorFootnoteNumberFormat, EditorFootnoteRestart, EditorDocxWidthValue, EditorTableLayout, EditorTableRowHeightRule, EditorGradientStop, EditorTextFill, EditorTextOutline, EditorTextShadow, EditorGlow, EditorReflection, } from './types/primitives.js';
10
10
  export type { EditorTextStyle, EditorParagraphStyle, EditorTableStyle, EditorTableFloatingLayout, EditorTableConditionalFormat, EditorConditionalRowStyle, EditorTableConditionalType, EditorTableConditionalFlags, EditorTableCellStyle, EditorNamedStyle, } from './types/styles.js';
11
11
  export type { EditorRunBase, EditorTextRun, EditorTextBoxShape, EditorTextBoxBody, EditorTextBoxData, EditorDropCap, EditorSdtBlockWrapper, EditorSdtPr, EditorSdtSubtype, EditorSdtListItem, EditorSdtDataBinding, EditorParagraphNode, EditorTableCellNode, EditorTableRowStyle, EditorTableRowNode, EditorTableNode, EditorBlockNode, } from './types/nodes.js';
12
+ export type { EditorMathNode, EditorMathText, EditorMathFraction, EditorMathRadical, EditorMathScript, EditorMathDelimiter, EditorMathAccent, EditorMathNary, EditorMathLimit, EditorMathMatrix, EditorMathBox, EditorMathGroup, EditorMathRaw, EditorMathStyle, EditorMathExpression, } from './types/math.js';
13
+ export { EMPTY_EDITOR_MATH_EXPRESSION, MATH_OBJECT_REPLACEMENT, } from './types/math.js';
12
14
  export type { RunKind, RunOfKind, RunVisitor } from './runKind.js';
13
- export { getRunKind, isInlineObjectRun, visitRun, getRunImage, getRunTextBox, getRunField, getRunFieldChar, getRunFieldInstruction, getRunFootnoteReference, getRunEndnoteReference, getRunSym, } from './runKind.js';
15
+ export { getRunKind, isInlineObjectRun, visitRun, getRunImage, getRunTextBox, getRunField, getRunFieldChar, getRunFieldInstruction, getRunFootnoteReference, getRunEndnoteReference, getRunSym, getRunMath, } from './runKind.js';
14
16
  export type { EditorFootnote } from './types/documentFootnotes.js';
15
17
  export type { EditorEndnote } from './types/documentEndnotes.js';
16
18
  export type { EditorBookmark, EditorBookmarkAnchor, EditorBookmarks, } from './types/documentBookmarks.js';
@@ -1,4 +1,5 @@
1
1
  import { EditorTextBoxData, EditorTextRun } from './types/nodes.js';
2
+ import { EditorMathExpression } from './types/math.js';
2
3
  import { EditorFieldChar, EditorFieldData, EditorImageRunData, EditorFootnoteReferenceData, EditorEndnoteReferenceData } from './types/primitives.js';
3
4
 
4
5
  /**
@@ -26,6 +27,7 @@ export declare function getRunSym(run: EditorTextRun): {
26
27
  font: string;
27
28
  char: string;
28
29
  } | undefined;
30
+ export declare function getRunMath(run: EditorTextRun): EditorMathExpression | undefined;
29
31
  export interface RunVisitor<R> {
30
32
  text(run: RunOfKind<"text">): R;
31
33
  image(run: RunOfKind<"image">): R;
@@ -36,6 +38,7 @@ export interface RunVisitor<R> {
36
38
  footnoteReference(run: RunOfKind<"footnoteReference">): R;
37
39
  endnoteReference(run: RunOfKind<"endnoteReference">): R;
38
40
  sym(run: RunOfKind<"sym">): R;
41
+ math?(run: RunOfKind<"math">): R;
39
42
  }
40
43
  /**
41
44
  * Exhaustive dispatch over a run's kind, narrowing the run to the matching union
@@ -1,4 +1,5 @@
1
1
  import { EditorBlockNode, EditorTextBoxData } from './nodes.js';
2
+ import { EditorMathExpression } from './math.js';
2
3
  import { EditorPageSettings } from './document.js';
3
4
  import { EditorRevision, EditorImageRunData } from './primitives.js';
4
5
  import { EditorTextStyle } from './styles.js';
@@ -24,6 +25,7 @@ export interface EditorLayoutFragment {
24
25
  styles?: EditorTextStyle;
25
26
  image?: EditorImageRunData;
26
27
  textBox?: EditorTextBoxData;
28
+ math?: EditorMathExpression;
27
29
  revision?: EditorRevision;
28
30
  chars: EditorLayoutFragmentChar[];
29
31
  }
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Structured Office Math Markup Language (OMML) data used by the editor.
3
+ *
4
+ * Math expressions are deliberately independent from the document tree. A
5
+ * paragraph stores one expression as an inline object; the expression itself
6
+ * is edited as this small, serialisable AST.
7
+ */
8
+ export type EditorMathNode = EditorMathText | EditorMathFraction | EditorMathRadical | EditorMathScript | EditorMathDelimiter | EditorMathAccent | EditorMathNary | EditorMathLimit | EditorMathMatrix | EditorMathBox | EditorMathGroup | EditorMathRaw;
9
+ export interface EditorMathText {
10
+ kind: "text";
11
+ value: string;
12
+ style?: EditorMathStyle;
13
+ }
14
+ export interface EditorMathFraction {
15
+ kind: "fraction";
16
+ numerator: EditorMathNode[];
17
+ denominator: EditorMathNode[];
18
+ bar?: boolean;
19
+ }
20
+ export interface EditorMathRadical {
21
+ kind: "radical";
22
+ radicand: EditorMathNode[];
23
+ degree?: EditorMathNode[];
24
+ }
25
+ export interface EditorMathScript {
26
+ kind: "script";
27
+ base: EditorMathNode[];
28
+ subscript?: EditorMathNode[];
29
+ superscript?: EditorMathNode[];
30
+ }
31
+ export interface EditorMathDelimiter {
32
+ kind: "delimiter";
33
+ children: EditorMathNode[][];
34
+ begin?: string;
35
+ end?: string;
36
+ separator?: string;
37
+ grow?: boolean;
38
+ }
39
+ export interface EditorMathAccent {
40
+ kind: "accent";
41
+ accent: string;
42
+ children: EditorMathNode[];
43
+ }
44
+ export interface EditorMathNary {
45
+ kind: "nary";
46
+ operator: string;
47
+ children: EditorMathNode[];
48
+ subscript?: EditorMathNode[];
49
+ superscript?: EditorMathNode[];
50
+ grow?: boolean;
51
+ }
52
+ export interface EditorMathLimit {
53
+ kind: "limit";
54
+ operator: "low" | "upper";
55
+ base: EditorMathNode[];
56
+ limit: EditorMathNode[];
57
+ }
58
+ export interface EditorMathMatrix {
59
+ kind: "matrix";
60
+ rows: EditorMathNode[][][];
61
+ rowGap?: number;
62
+ columnGap?: number;
63
+ }
64
+ export interface EditorMathBox {
65
+ kind: "box";
66
+ children: EditorMathNode[];
67
+ border?: boolean;
68
+ hidden?: boolean;
69
+ }
70
+ export interface EditorMathGroup {
71
+ kind: "group";
72
+ children: EditorMathNode[];
73
+ }
74
+ /** Unknown OMML is retained so importing and re-exporting remains lossless. */
75
+ export interface EditorMathRaw {
76
+ kind: "raw";
77
+ xml: string;
78
+ fallbackText?: string;
79
+ }
80
+ export interface EditorMathStyle {
81
+ fontFamily?: string;
82
+ bold?: boolean;
83
+ italic?: boolean;
84
+ normalText?: boolean;
85
+ script?: "roman" | "script" | "fraktur" | "double-struck";
86
+ }
87
+ export interface EditorMathExpression {
88
+ version: 1;
89
+ children: EditorMathNode[];
90
+ display?: boolean;
91
+ /** Original OMML for diagnostics and exact round-trip of untouched data. */
92
+ sourceXml?: string;
93
+ }
94
+ export declare const EMPTY_EDITOR_MATH_EXPRESSION: EditorMathExpression;
95
+ export declare const MATH_OBJECT_REPLACEMENT = "\uFFFC";
@@ -1,4 +1,5 @@
1
1
  import { EditorDocxWidthValue, EditorEndnoteReferenceData, EditorFieldChar, EditorFieldData, EditorFootnoteReferenceData, EditorImageFloatingLayout, EditorImageRunData, EditorParagraphListStyle, EditorRevision, EditorPropertyRevision, EditorStructuralRevision, EditorTableRowHeightRule } from './primitives.js';
2
+ import { EditorMathExpression } from './math.js';
2
3
  import { EditorParagraphStyle, EditorTableCellStyle, EditorTableStyle, EditorTableConditionalFlags, EditorTextStyle } from './styles.js';
3
4
 
4
5
  /**
@@ -127,6 +128,9 @@ export type EditorTextRun = (EditorRunBase & {
127
128
  font: string;
128
129
  char: string;
129
130
  };
131
+ }) | (EditorRunBase & {
132
+ kind: "math";
133
+ math: EditorMathExpression;
130
134
  });
131
135
  /**
132
136
  * A drop cap (Word's `w:framePr/@dropCap`): a large initial letter sunk into
@@ -0,0 +1,3 @@
1
+ import { EditorMathExpression } from '../../../core/model.js';
2
+
3
+ export declare function serializeMathExpression(expression: EditorMathExpression): string;
@@ -351,6 +351,11 @@ export declare const en: {
351
351
  "dialog.symbol.recent": string;
352
352
  "dialog.symbol.code": string;
353
353
  "dialog.symbol.doubleClickHelp": string;
354
+ "dialog.equation.title": string;
355
+ "dialog.equation.insert": string;
356
+ "dialog.equation.structures": string;
357
+ "dialog.equation.linear": string;
358
+ "dialog.equation.empty": string;
354
359
  "dialog.newDocument.title": string;
355
360
  "dialog.newDocument.message": string;
356
361
  "dialog.newDocument.discard": string;
@@ -351,6 +351,11 @@ export declare const ptBR: {
351
351
  "dialog.symbol.recent": string;
352
352
  "dialog.symbol.code": string;
353
353
  "dialog.symbol.doubleClickHelp": string;
354
+ "dialog.equation.title": string;
355
+ "dialog.equation.insert": string;
356
+ "dialog.equation.structures": string;
357
+ "dialog.equation.linear": string;
358
+ "dialog.equation.empty": string;
354
359
  "dialog.newDocument.title": string;
355
360
  "dialog.newDocument.message": string;
356
361
  "dialog.newDocument.discard": string;
@@ -0,0 +1,5 @@
1
+ import { Element as XmlElement } from '@xmldom/xmldom';
2
+ import { EditorMathExpression } from '../../core/model.js';
3
+
4
+ export declare const MATH_NS = "http://schemas.openxmlformats.org/officeDocument/2006/math";
5
+ export declare function parseMathExpression(element: XmlElement): EditorMathExpression;
@@ -1,5 +1,5 @@
1
1
  import { Element as XmlElement } from '@xmldom/xmldom';
2
- import { EditorBlockNode, EditorTextStyle, EditorImageRunData, EditorTextBoxData } from '../../../core/model.js';
2
+ import { EditorBlockNode, EditorTextStyle, EditorImageRunData, EditorTextBoxData, EditorMathExpression } from '../../../core/model.js';
3
3
 
4
4
  export type ParseNestedBlocks = (container: XmlElement) => Promise<EditorBlockNode[]>;
5
5
  /**
@@ -53,4 +53,5 @@ export interface ImportedRun {
53
53
  font: string;
54
54
  char: string;
55
55
  };
56
+ math?: EditorMathExpression;
56
57
  }