@drghaliasri/butex 8.0.1 → 8.0.3
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.
- package/README.md +2 -0
- package/dist/document-cli.js +123 -16
- package/dist/document-cli.js.map +1 -1
- package/dist/document.d.mts +5 -5
- package/dist/document.d.ts +5 -5
- package/dist/document.js +65 -22
- package/dist/document.js.map +1 -1
- package/dist/document.mjs +65 -22
- package/dist/document.mjs.map +1 -1
- package/dist/index.d.mts +11 -4
- package/dist/index.d.ts +11 -4
- package/dist/index.global.js +54 -9
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +54 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +54 -9
- package/dist/index.mjs.map +1 -1
- package/dist/react-document-preview.js +44 -15
- package/dist/react-document-preview.js.map +1 -1
- package/dist/react-document-preview.mjs +44 -15
- package/dist/react-document-preview.mjs.map +1 -1
- package/dist/react-document.d.mts +3 -3
- package/dist/react-document.d.ts +3 -3
- package/dist/react-document.js +136 -46
- package/dist/react-document.js.map +1 -1
- package/dist/react-document.mjs +136 -46
- package/dist/react-document.mjs.map +1 -1
- package/dist/react.d.mts +4 -3
- package/dist/react.d.ts +4 -3
- package/dist/react.js +123 -37
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +123 -37
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -101,7 +101,7 @@ declare function injectBuTeXEditorStyles(doc?: Document): void;
|
|
|
101
101
|
type EditorSide = 'english' | 'arabic';
|
|
102
102
|
type EditorNodeKind = 'char' | 'number' | 'operator' | 'delimiter' | 'boxed' | 'frac' | 'sqrt' | 'overset' | 'underset' | 'accent' | 'env' | 'atomicCommand' | 'atomicOperatorCommand' | 'standardCommand';
|
|
103
103
|
type MatrixEnvStyle = 'matrix' | 'pmatrix' | 'bmatrix' | 'Bmatrix' | 'vmatrix' | 'Vmatrix';
|
|
104
|
-
type GridEnvName = MatrixEnvStyle | 'array' | 'aligned';
|
|
104
|
+
type GridEnvName = MatrixEnvStyle | 'array' | 'aligned' | 'cases';
|
|
105
105
|
type EnvColumnAlignment = 'l' | 'c' | 'r';
|
|
106
106
|
type CharacterFontId = 'default' | 'takween' | 'diwani' | 'diwaniOutline' | 'maghribi';
|
|
107
107
|
type DigitFormId = 'western' | 'arabicIndic' | 'persianIndic';
|
|
@@ -117,10 +117,10 @@ type EditorNode = {
|
|
|
117
117
|
kind: EditorNodeKind;
|
|
118
118
|
expr: string;
|
|
119
119
|
characterFont?: CharacterFontId;
|
|
120
|
-
/**
|
|
120
|
+
/** Canonical source identity; atomic Arabic-label edits preserve it, canonical-side edits invalidate it. */
|
|
121
121
|
sourceLatex?: string;
|
|
122
122
|
/** Existing editor node reused for wrapper commands that need editable content. */
|
|
123
|
-
wrapperCommand?: '\\unit' | '\\mathtt' | '\\mathbf' | '\\boldarabic';
|
|
123
|
+
wrapperCommand?: '\\unit' | '\\mathtt' | '\\operatorname' | '\\text' | '\\mathbf' | '\\boldarabic';
|
|
124
124
|
superscript: EditorChain | null;
|
|
125
125
|
subscript: EditorChain | null;
|
|
126
126
|
leftDelimExpr: string;
|
|
@@ -1405,11 +1405,14 @@ declare function sessionHasStandardCommands(session: EditorSession): boolean;
|
|
|
1405
1405
|
|
|
1406
1406
|
type RenderOptions = {
|
|
1407
1407
|
digitForm?: DigitFormId;
|
|
1408
|
+
casesPresentation?: boolean;
|
|
1408
1409
|
};
|
|
1409
1410
|
declare function renderChainEnglish(chain: EditorChain, options?: RenderOptions): string;
|
|
1410
1411
|
declare function renderChainArabic(chain: EditorChain, options?: RenderOptions): string;
|
|
1411
1412
|
declare function renderEnglishLatexFromSession(session: EditorSession): string;
|
|
1412
1413
|
declare function renderArabicLatexFromSession(session: EditorSession): string;
|
|
1414
|
+
/** Render-only RTL cases; never use this for source or stored MathObjects. */
|
|
1415
|
+
declare function renderArabicPreviewLatexFromSession(session: EditorSession): string;
|
|
1413
1416
|
|
|
1414
1417
|
type CharacterFontSpec = {
|
|
1415
1418
|
id: CharacterFontId;
|
|
@@ -1584,6 +1587,7 @@ declare function insertAccent(session: EditorSession, accentId: AccentCommandId)
|
|
|
1584
1587
|
declare function insertMatrixEnv(session: EditorSession, style: MatrixEnvStyle, rows: number, columns: number): EditorSession;
|
|
1585
1588
|
declare function insertArrayEnv(session: EditorSession, rows: number, columns: number, columnAlignments?: EnvColumnAlignment[]): EditorSession;
|
|
1586
1589
|
declare function insertAlignedEnv(session: EditorSession, rows: number, columns: number): EditorSession;
|
|
1590
|
+
declare function insertCasesEnv(session: EditorSession, rows: number): EditorSession;
|
|
1587
1591
|
declare function setMatrixEnvStyle(session: EditorSession, style: MatrixEnvStyle): EditorSession;
|
|
1588
1592
|
declare function setArrayColumnAlignment(session: EditorSession, columnIndex: number, alignment: EnvColumnAlignment): EditorSession;
|
|
1589
1593
|
declare function addMatrixRow(session: EditorSession): EditorSession;
|
|
@@ -1698,6 +1702,7 @@ type EditorRuntimeApi = {
|
|
|
1698
1702
|
insertMatrixEnv: (style: MatrixEnvStyle, rows: number, columns: number) => void;
|
|
1699
1703
|
insertArrayEnv: (rows: number, columns: number) => void;
|
|
1700
1704
|
insertAlignedEnv: (rows: number, columns: number) => void;
|
|
1705
|
+
insertCasesEnv: (rows: number) => void;
|
|
1701
1706
|
insertSqrt: () => void;
|
|
1702
1707
|
insertOverset: () => void;
|
|
1703
1708
|
insertUnderset: () => void;
|
|
@@ -1838,6 +1843,7 @@ declare const index_insertAlignedEnv: typeof insertAlignedEnv;
|
|
|
1838
1843
|
declare const index_insertArrayEnv: typeof insertArrayEnv;
|
|
1839
1844
|
declare const index_insertAtomicCommand: typeof insertAtomicCommand;
|
|
1840
1845
|
declare const index_insertAtomicOperatorCommand: typeof insertAtomicOperatorCommand;
|
|
1846
|
+
declare const index_insertCasesEnv: typeof insertCasesEnv;
|
|
1841
1847
|
declare const index_insertChar: typeof insertChar;
|
|
1842
1848
|
declare const index_insertDelimiterPair: typeof insertDelimiterPair;
|
|
1843
1849
|
declare const index_insertDivideOperator: typeof insertDivideOperator;
|
|
@@ -1870,6 +1876,7 @@ declare const index_removeMatrixRow: typeof removeMatrixRow;
|
|
|
1870
1876
|
declare const index_removeSub: typeof removeSub;
|
|
1871
1877
|
declare const index_removeSup: typeof removeSup;
|
|
1872
1878
|
declare const index_renderArabicLatexFromSession: typeof renderArabicLatexFromSession;
|
|
1879
|
+
declare const index_renderArabicPreviewLatexFromSession: typeof renderArabicPreviewLatexFromSession;
|
|
1873
1880
|
declare const index_renderChainArabic: typeof renderChainArabic;
|
|
1874
1881
|
declare const index_renderChainEnglish: typeof renderChainEnglish;
|
|
1875
1882
|
declare const index_renderEnglishLatexFromSession: typeof renderEnglishLatexFromSession;
|
|
@@ -1899,7 +1906,7 @@ declare const index_toggleTakweenCharacterFont: typeof toggleTakweenCharacterFon
|
|
|
1899
1906
|
declare const index_undoRedoCanRedo: typeof undoRedoCanRedo;
|
|
1900
1907
|
declare const index_undoRedoCanUndo: typeof undoRedoCanUndo;
|
|
1901
1908
|
declare namespace index {
|
|
1902
|
-
export { index_ACCENT_COMMANDS as ACCENT_COMMANDS, index_ACCENT_CSS as ACCENT_CSS, index_ATOMIC_COMMANDS as ATOMIC_COMMANDS, index_ATOMIC_COMMAND_CSS as ATOMIC_COMMAND_CSS, index_ATOMIC_OPERATOR_COMMANDS as ATOMIC_OPERATOR_COMMANDS, index_ATOMIC_OPERATOR_COMMAND_CSS as ATOMIC_OPERATOR_COMMAND_CSS, type index_AccentCommandId as AccentCommandId, type index_AccentCommandSpec as AccentCommandSpec, type index_AccentPlacement as AccentPlacement, type index_AtomicCommandCategory as AtomicCommandCategory, type index_AtomicCommandId as AtomicCommandId, type index_AtomicCommandSpec as AtomicCommandSpec, type index_AtomicOperatorCommandCategory as AtomicOperatorCommandCategory, type index_AtomicOperatorCommandId as AtomicOperatorCommandId, type index_AtomicOperatorCommandSpec as AtomicOperatorCommandSpec, index_BOXED_CSS as BOXED_CSS, index_BUTEX_EDITOR_CSS as BUTEX_EDITOR_CSS, index_BUTEX_FRAGMENT_MIME as BUTEX_FRAGMENT_MIME, index_CHARACTER_FONT_OPTIONS as CHARACTER_FONT_OPTIONS, index_CHARACTER_FONT_SPECS as CHARACTER_FONT_SPECS, type index_CharacterFontId as CharacterFontId, type index_CharacterFontSpec as CharacterFontSpec, index_DEFAULT_UNDO_HISTORY_MAX_DEPTH as DEFAULT_UNDO_HISTORY_MAX_DEPTH, index_DELIMITER_CSS as DELIMITER_CSS, type index_DigitFormId as DigitFormId, type index_EditorCaret as EditorCaret, type index_EditorChain as EditorChain, type index_EditorDebugEntry as EditorDebugEntry, type index_EditorFragment as EditorFragment, type index_EditorNode as EditorNode, type index_EditorNodeKind as EditorNodeKind, type index_EditorRuntimeApi as EditorRuntimeApi, type index_EditorRuntimeOptions as EditorRuntimeOptions, type index_EditorSelectionRange as EditorSelectionRange, type index_EditorSession as EditorSession, type index_EditorSide as EditorSide, type index_EditorSyncMap as EditorSyncMap, type index_EditorSyncState as EditorSyncState, type index_EnvColumnAlignment as EnvColumnAlignment, index_FRAC_CSS as FRAC_CSS, type index_GridEnvName as GridEnvName, index_MATRIX_ENV_CSS as MATRIX_ENV_CSS, type index_MatrixEnvStyle as MatrixEnvStyle, index_NON_DEFAULT_CHARACTER_FONT_SPECS as NON_DEFAULT_CHARACTER_FONT_SPECS, index_OVERSET_CSS as OVERSET_CSS, index_SQRT_CSS as SQRT_CSS, index_STANDARD_COMMANDS as STANDARD_COMMANDS, index_STANDARD_COMMAND_CSS as STANDARD_COMMAND_CSS, type index_SpacingCommandSpec as SpacingCommandSpec, type index_SpacingDirection as SpacingDirection, type index_StandardCommandSpec as StandardCommandSpec, type index_StandardCommandTex as StandardCommandTex, index_UNDERSET_CSS as UNDERSET_CSS, type index_UndoRedoStacks as UndoRedoStacks, index_accentCommandIdFromTex as accentCommandIdFromTex, index_accentCommandSpec as accentCommandSpec, index_accentCommandsList as accentCommandsList, index_activeSideLabel as activeSideLabel, index_activeTreeKey as activeTreeKey, index_addMatrixColumn as addMatrixColumn, index_addMatrixRow as addMatrixRow, index_addSub as addSub, index_addSup as addSup, index_atomicCommandSpec as atomicCommandSpec, index_atomicCommandsByCategory as atomicCommandsByCategory, index_atomicOperatorCommandSpec as atomicOperatorCommandSpec, index_atomicOperatorCommandsByCategory as atomicOperatorCommandsByCategory, index_breakLeafTyping as breakLeafTyping, index_buildInitialSyncMap as buildInitialSyncMap, index_buildNodeBody as buildNodeBody, index_buildNodeScripts as buildNodeScripts, index_caretStep as caretStep, index_characterFontSpec as characterFontSpec, index_characterFontSpecByMacro as characterFontSpecByMacro, index_clearSelection as clearSelection, index_cloneEditorSession as cloneEditorSession, index_collectCaretPositions as collectCaretPositions, index_copySelection as copySelection, index_coveredNodeIds as coveredNodeIds, index_createAccentNode as createAccentNode, index_createAtomicCommandNode as createAtomicCommandNode, index_createAtomicOperatorCommandNode as createAtomicOperatorCommandNode, index_createBoxedNode as createBoxedNode, index_createDelimiterNode as createDelimiterNode, index_createEditorChain as createEditorChain, index_createEditorNode as createEditorNode, index_createEditorRuntime as createEditorRuntime, index_createEditorSession as createEditorSession, index_createFracNode as createFracNode, index_createGridEnvNode as createGridEnvNode, index_createMatrixEnvNode as createMatrixEnvNode, index_createOversetNode as createOversetNode, index_createSqrtNode as createSqrtNode, index_createStarterSession as createStarterSession, index_createUndersetNode as createUndersetNode, index_createUndoRedoStacks as createUndoRedoStacks, index_cutSelection as cutSelection, index_deleteBackward as deleteBackward, index_deleteForward as deleteForward, index_deleteStructure as deleteStructure, index_deserializeFragment as deserializeFragment, index_extendSelectionByStep as extendSelectionByStep, index_findChainById as findChainById, index_findNodeById as findNodeById, index_formatDigits as formatDigits, index_fragmentToPlainText as fragmentToPlainText, index_horizontalCaretDelta as horizontalCaretDelta, index_injectBuTeXEditorStyles as injectBuTeXEditorStyles, index_insertAccent as insertAccent, index_insertAccentPair as insertAccentPair, index_insertAlignedEnv as insertAlignedEnv, index_insertArrayEnv as insertArrayEnv, index_insertAtomicCommand as insertAtomicCommand, index_insertAtomicOperatorCommand as insertAtomicOperatorCommand, index_insertChar as insertChar, index_insertDelimiterPair as insertDelimiterPair, index_insertDivideOperator as insertDivideOperator, index_insertFirstDerivative as insertFirstDerivative, index_insertFraction as insertFraction, index_insertLimitsSeriesTemplate as insertLimitsSeriesTemplate, index_insertMatrixEnv as insertMatrixEnv, index_insertNumber as insertNumber, index_insertOperator as insertOperator, index_insertOverset as insertOverset, index_insertSecondDerivative as insertSecondDerivative, index_insertSqrt as insertSqrt, index_insertUnderset as insertUnderset, index_isSelectionActive as isSelectionActive, index_isSpacingCommandSpec as isSpacingCommandSpec, index_isStandardCommandTex as isStandardCommandTex, index_mirrorBuTeXOperatorsInTex as mirrorBuTeXOperatorsInTex, index_moveCaret as moveCaret, index_moveCaretHorizontal as moveCaretHorizontal, index_moveCaretVertical as moveCaretVertical, index_nodeChildChains as nodeChildChains, index_normalizeSelection as normalizeSelection, index_passiveTreeKey as passiveTreeKey, index_pasteFragment as pasteFragment, index_pasteText as pasteText, index_pushUndoRedoSnapshot as pushUndoRedoSnapshot, index_regenerateFragmentIds as regenerateFragmentIds, index_removeMatrixColumn as removeMatrixColumn, index_removeMatrixRow as removeMatrixRow, index_removeSub as removeSub, index_removeSup as removeSup, index_renderArabicLatexFromSession as renderArabicLatexFromSession, index_renderChainArabic as renderChainArabic, index_renderChainEnglish as renderChainEnglish, index_renderEnglishLatexFromSession as renderEnglishLatexFromSession, index_restoreRedo as restoreRedo, index_restoreUndo as restoreUndo, index_runtimeStatusText as runtimeStatusText, index_selectNode as selectNode, index_serializeSelection as serializeSelection, index_sessionHasStandardCommands as sessionHasStandardCommands, index_setArabicReverseNumberTyping as setArabicReverseNumberTyping, index_setArrayColumnAlignment as setArrayColumnAlignment, index_setCaret as setCaret, index_setCurrentBoldCharacterStyle as setCurrentBoldCharacterStyle, index_setCurrentCharacterFont as setCurrentCharacterFont, index_setCurrentDigitForm as setCurrentDigitForm, index_setExpr as setExpr, index_setMatrixEnvStyle as setMatrixEnvStyle, index_setRenderError as setRenderError, index_setSelectionFromMouse as setSelectionFromMouse, index_setSplitLeafTyping as setSplitLeafTyping, index_shouldMirrorOperatorDisplay as shouldMirrorOperatorDisplay, index_standardCommandSpec as standardCommandSpec, index_switchSide as switchSide, index_syncSelectionToCaret as syncSelectionToCaret, index_syncStateSummary as syncStateSummary, index_toggleTakweenCharacterFont as toggleTakweenCharacterFont, index_undoRedoCanRedo as undoRedoCanRedo, index_undoRedoCanUndo as undoRedoCanUndo };
|
|
1909
|
+
export { index_ACCENT_COMMANDS as ACCENT_COMMANDS, index_ACCENT_CSS as ACCENT_CSS, index_ATOMIC_COMMANDS as ATOMIC_COMMANDS, index_ATOMIC_COMMAND_CSS as ATOMIC_COMMAND_CSS, index_ATOMIC_OPERATOR_COMMANDS as ATOMIC_OPERATOR_COMMANDS, index_ATOMIC_OPERATOR_COMMAND_CSS as ATOMIC_OPERATOR_COMMAND_CSS, type index_AccentCommandId as AccentCommandId, type index_AccentCommandSpec as AccentCommandSpec, type index_AccentPlacement as AccentPlacement, type index_AtomicCommandCategory as AtomicCommandCategory, type index_AtomicCommandId as AtomicCommandId, type index_AtomicCommandSpec as AtomicCommandSpec, type index_AtomicOperatorCommandCategory as AtomicOperatorCommandCategory, type index_AtomicOperatorCommandId as AtomicOperatorCommandId, type index_AtomicOperatorCommandSpec as AtomicOperatorCommandSpec, index_BOXED_CSS as BOXED_CSS, index_BUTEX_EDITOR_CSS as BUTEX_EDITOR_CSS, index_BUTEX_FRAGMENT_MIME as BUTEX_FRAGMENT_MIME, index_CHARACTER_FONT_OPTIONS as CHARACTER_FONT_OPTIONS, index_CHARACTER_FONT_SPECS as CHARACTER_FONT_SPECS, type index_CharacterFontId as CharacterFontId, type index_CharacterFontSpec as CharacterFontSpec, index_DEFAULT_UNDO_HISTORY_MAX_DEPTH as DEFAULT_UNDO_HISTORY_MAX_DEPTH, index_DELIMITER_CSS as DELIMITER_CSS, type index_DigitFormId as DigitFormId, type index_EditorCaret as EditorCaret, type index_EditorChain as EditorChain, type index_EditorDebugEntry as EditorDebugEntry, type index_EditorFragment as EditorFragment, type index_EditorNode as EditorNode, type index_EditorNodeKind as EditorNodeKind, type index_EditorRuntimeApi as EditorRuntimeApi, type index_EditorRuntimeOptions as EditorRuntimeOptions, type index_EditorSelectionRange as EditorSelectionRange, type index_EditorSession as EditorSession, type index_EditorSide as EditorSide, type index_EditorSyncMap as EditorSyncMap, type index_EditorSyncState as EditorSyncState, type index_EnvColumnAlignment as EnvColumnAlignment, index_FRAC_CSS as FRAC_CSS, type index_GridEnvName as GridEnvName, index_MATRIX_ENV_CSS as MATRIX_ENV_CSS, type index_MatrixEnvStyle as MatrixEnvStyle, index_NON_DEFAULT_CHARACTER_FONT_SPECS as NON_DEFAULT_CHARACTER_FONT_SPECS, index_OVERSET_CSS as OVERSET_CSS, index_SQRT_CSS as SQRT_CSS, index_STANDARD_COMMANDS as STANDARD_COMMANDS, index_STANDARD_COMMAND_CSS as STANDARD_COMMAND_CSS, type index_SpacingCommandSpec as SpacingCommandSpec, type index_SpacingDirection as SpacingDirection, type index_StandardCommandSpec as StandardCommandSpec, type index_StandardCommandTex as StandardCommandTex, index_UNDERSET_CSS as UNDERSET_CSS, type index_UndoRedoStacks as UndoRedoStacks, index_accentCommandIdFromTex as accentCommandIdFromTex, index_accentCommandSpec as accentCommandSpec, index_accentCommandsList as accentCommandsList, index_activeSideLabel as activeSideLabel, index_activeTreeKey as activeTreeKey, index_addMatrixColumn as addMatrixColumn, index_addMatrixRow as addMatrixRow, index_addSub as addSub, index_addSup as addSup, index_atomicCommandSpec as atomicCommandSpec, index_atomicCommandsByCategory as atomicCommandsByCategory, index_atomicOperatorCommandSpec as atomicOperatorCommandSpec, index_atomicOperatorCommandsByCategory as atomicOperatorCommandsByCategory, index_breakLeafTyping as breakLeafTyping, index_buildInitialSyncMap as buildInitialSyncMap, index_buildNodeBody as buildNodeBody, index_buildNodeScripts as buildNodeScripts, index_caretStep as caretStep, index_characterFontSpec as characterFontSpec, index_characterFontSpecByMacro as characterFontSpecByMacro, index_clearSelection as clearSelection, index_cloneEditorSession as cloneEditorSession, index_collectCaretPositions as collectCaretPositions, index_copySelection as copySelection, index_coveredNodeIds as coveredNodeIds, index_createAccentNode as createAccentNode, index_createAtomicCommandNode as createAtomicCommandNode, index_createAtomicOperatorCommandNode as createAtomicOperatorCommandNode, index_createBoxedNode as createBoxedNode, index_createDelimiterNode as createDelimiterNode, index_createEditorChain as createEditorChain, index_createEditorNode as createEditorNode, index_createEditorRuntime as createEditorRuntime, index_createEditorSession as createEditorSession, index_createFracNode as createFracNode, index_createGridEnvNode as createGridEnvNode, index_createMatrixEnvNode as createMatrixEnvNode, index_createOversetNode as createOversetNode, index_createSqrtNode as createSqrtNode, index_createStarterSession as createStarterSession, index_createUndersetNode as createUndersetNode, index_createUndoRedoStacks as createUndoRedoStacks, index_cutSelection as cutSelection, index_deleteBackward as deleteBackward, index_deleteForward as deleteForward, index_deleteStructure as deleteStructure, index_deserializeFragment as deserializeFragment, index_extendSelectionByStep as extendSelectionByStep, index_findChainById as findChainById, index_findNodeById as findNodeById, index_formatDigits as formatDigits, index_fragmentToPlainText as fragmentToPlainText, index_horizontalCaretDelta as horizontalCaretDelta, index_injectBuTeXEditorStyles as injectBuTeXEditorStyles, index_insertAccent as insertAccent, index_insertAccentPair as insertAccentPair, index_insertAlignedEnv as insertAlignedEnv, index_insertArrayEnv as insertArrayEnv, index_insertAtomicCommand as insertAtomicCommand, index_insertAtomicOperatorCommand as insertAtomicOperatorCommand, index_insertCasesEnv as insertCasesEnv, index_insertChar as insertChar, index_insertDelimiterPair as insertDelimiterPair, index_insertDivideOperator as insertDivideOperator, index_insertFirstDerivative as insertFirstDerivative, index_insertFraction as insertFraction, index_insertLimitsSeriesTemplate as insertLimitsSeriesTemplate, index_insertMatrixEnv as insertMatrixEnv, index_insertNumber as insertNumber, index_insertOperator as insertOperator, index_insertOverset as insertOverset, index_insertSecondDerivative as insertSecondDerivative, index_insertSqrt as insertSqrt, index_insertUnderset as insertUnderset, index_isSelectionActive as isSelectionActive, index_isSpacingCommandSpec as isSpacingCommandSpec, index_isStandardCommandTex as isStandardCommandTex, index_mirrorBuTeXOperatorsInTex as mirrorBuTeXOperatorsInTex, index_moveCaret as moveCaret, index_moveCaretHorizontal as moveCaretHorizontal, index_moveCaretVertical as moveCaretVertical, index_nodeChildChains as nodeChildChains, index_normalizeSelection as normalizeSelection, index_passiveTreeKey as passiveTreeKey, index_pasteFragment as pasteFragment, index_pasteText as pasteText, index_pushUndoRedoSnapshot as pushUndoRedoSnapshot, index_regenerateFragmentIds as regenerateFragmentIds, index_removeMatrixColumn as removeMatrixColumn, index_removeMatrixRow as removeMatrixRow, index_removeSub as removeSub, index_removeSup as removeSup, index_renderArabicLatexFromSession as renderArabicLatexFromSession, index_renderArabicPreviewLatexFromSession as renderArabicPreviewLatexFromSession, index_renderChainArabic as renderChainArabic, index_renderChainEnglish as renderChainEnglish, index_renderEnglishLatexFromSession as renderEnglishLatexFromSession, index_restoreRedo as restoreRedo, index_restoreUndo as restoreUndo, index_runtimeStatusText as runtimeStatusText, index_selectNode as selectNode, index_serializeSelection as serializeSelection, index_sessionHasStandardCommands as sessionHasStandardCommands, index_setArabicReverseNumberTyping as setArabicReverseNumberTyping, index_setArrayColumnAlignment as setArrayColumnAlignment, index_setCaret as setCaret, index_setCurrentBoldCharacterStyle as setCurrentBoldCharacterStyle, index_setCurrentCharacterFont as setCurrentCharacterFont, index_setCurrentDigitForm as setCurrentDigitForm, index_setExpr as setExpr, index_setMatrixEnvStyle as setMatrixEnvStyle, index_setRenderError as setRenderError, index_setSelectionFromMouse as setSelectionFromMouse, index_setSplitLeafTyping as setSplitLeafTyping, index_shouldMirrorOperatorDisplay as shouldMirrorOperatorDisplay, index_standardCommandSpec as standardCommandSpec, index_switchSide as switchSide, index_syncSelectionToCaret as syncSelectionToCaret, index_syncStateSummary as syncStateSummary, index_toggleTakweenCharacterFont as toggleTakweenCharacterFont, index_undoRedoCanRedo as undoRedoCanRedo, index_undoRedoCanUndo as undoRedoCanUndo };
|
|
1903
1910
|
}
|
|
1904
1911
|
|
|
1905
1912
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -101,7 +101,7 @@ declare function injectBuTeXEditorStyles(doc?: Document): void;
|
|
|
101
101
|
type EditorSide = 'english' | 'arabic';
|
|
102
102
|
type EditorNodeKind = 'char' | 'number' | 'operator' | 'delimiter' | 'boxed' | 'frac' | 'sqrt' | 'overset' | 'underset' | 'accent' | 'env' | 'atomicCommand' | 'atomicOperatorCommand' | 'standardCommand';
|
|
103
103
|
type MatrixEnvStyle = 'matrix' | 'pmatrix' | 'bmatrix' | 'Bmatrix' | 'vmatrix' | 'Vmatrix';
|
|
104
|
-
type GridEnvName = MatrixEnvStyle | 'array' | 'aligned';
|
|
104
|
+
type GridEnvName = MatrixEnvStyle | 'array' | 'aligned' | 'cases';
|
|
105
105
|
type EnvColumnAlignment = 'l' | 'c' | 'r';
|
|
106
106
|
type CharacterFontId = 'default' | 'takween' | 'diwani' | 'diwaniOutline' | 'maghribi';
|
|
107
107
|
type DigitFormId = 'western' | 'arabicIndic' | 'persianIndic';
|
|
@@ -117,10 +117,10 @@ type EditorNode = {
|
|
|
117
117
|
kind: EditorNodeKind;
|
|
118
118
|
expr: string;
|
|
119
119
|
characterFont?: CharacterFontId;
|
|
120
|
-
/**
|
|
120
|
+
/** Canonical source identity; atomic Arabic-label edits preserve it, canonical-side edits invalidate it. */
|
|
121
121
|
sourceLatex?: string;
|
|
122
122
|
/** Existing editor node reused for wrapper commands that need editable content. */
|
|
123
|
-
wrapperCommand?: '\\unit' | '\\mathtt' | '\\mathbf' | '\\boldarabic';
|
|
123
|
+
wrapperCommand?: '\\unit' | '\\mathtt' | '\\operatorname' | '\\text' | '\\mathbf' | '\\boldarabic';
|
|
124
124
|
superscript: EditorChain | null;
|
|
125
125
|
subscript: EditorChain | null;
|
|
126
126
|
leftDelimExpr: string;
|
|
@@ -1405,11 +1405,14 @@ declare function sessionHasStandardCommands(session: EditorSession): boolean;
|
|
|
1405
1405
|
|
|
1406
1406
|
type RenderOptions = {
|
|
1407
1407
|
digitForm?: DigitFormId;
|
|
1408
|
+
casesPresentation?: boolean;
|
|
1408
1409
|
};
|
|
1409
1410
|
declare function renderChainEnglish(chain: EditorChain, options?: RenderOptions): string;
|
|
1410
1411
|
declare function renderChainArabic(chain: EditorChain, options?: RenderOptions): string;
|
|
1411
1412
|
declare function renderEnglishLatexFromSession(session: EditorSession): string;
|
|
1412
1413
|
declare function renderArabicLatexFromSession(session: EditorSession): string;
|
|
1414
|
+
/** Render-only RTL cases; never use this for source or stored MathObjects. */
|
|
1415
|
+
declare function renderArabicPreviewLatexFromSession(session: EditorSession): string;
|
|
1413
1416
|
|
|
1414
1417
|
type CharacterFontSpec = {
|
|
1415
1418
|
id: CharacterFontId;
|
|
@@ -1584,6 +1587,7 @@ declare function insertAccent(session: EditorSession, accentId: AccentCommandId)
|
|
|
1584
1587
|
declare function insertMatrixEnv(session: EditorSession, style: MatrixEnvStyle, rows: number, columns: number): EditorSession;
|
|
1585
1588
|
declare function insertArrayEnv(session: EditorSession, rows: number, columns: number, columnAlignments?: EnvColumnAlignment[]): EditorSession;
|
|
1586
1589
|
declare function insertAlignedEnv(session: EditorSession, rows: number, columns: number): EditorSession;
|
|
1590
|
+
declare function insertCasesEnv(session: EditorSession, rows: number): EditorSession;
|
|
1587
1591
|
declare function setMatrixEnvStyle(session: EditorSession, style: MatrixEnvStyle): EditorSession;
|
|
1588
1592
|
declare function setArrayColumnAlignment(session: EditorSession, columnIndex: number, alignment: EnvColumnAlignment): EditorSession;
|
|
1589
1593
|
declare function addMatrixRow(session: EditorSession): EditorSession;
|
|
@@ -1698,6 +1702,7 @@ type EditorRuntimeApi = {
|
|
|
1698
1702
|
insertMatrixEnv: (style: MatrixEnvStyle, rows: number, columns: number) => void;
|
|
1699
1703
|
insertArrayEnv: (rows: number, columns: number) => void;
|
|
1700
1704
|
insertAlignedEnv: (rows: number, columns: number) => void;
|
|
1705
|
+
insertCasesEnv: (rows: number) => void;
|
|
1701
1706
|
insertSqrt: () => void;
|
|
1702
1707
|
insertOverset: () => void;
|
|
1703
1708
|
insertUnderset: () => void;
|
|
@@ -1838,6 +1843,7 @@ declare const index_insertAlignedEnv: typeof insertAlignedEnv;
|
|
|
1838
1843
|
declare const index_insertArrayEnv: typeof insertArrayEnv;
|
|
1839
1844
|
declare const index_insertAtomicCommand: typeof insertAtomicCommand;
|
|
1840
1845
|
declare const index_insertAtomicOperatorCommand: typeof insertAtomicOperatorCommand;
|
|
1846
|
+
declare const index_insertCasesEnv: typeof insertCasesEnv;
|
|
1841
1847
|
declare const index_insertChar: typeof insertChar;
|
|
1842
1848
|
declare const index_insertDelimiterPair: typeof insertDelimiterPair;
|
|
1843
1849
|
declare const index_insertDivideOperator: typeof insertDivideOperator;
|
|
@@ -1870,6 +1876,7 @@ declare const index_removeMatrixRow: typeof removeMatrixRow;
|
|
|
1870
1876
|
declare const index_removeSub: typeof removeSub;
|
|
1871
1877
|
declare const index_removeSup: typeof removeSup;
|
|
1872
1878
|
declare const index_renderArabicLatexFromSession: typeof renderArabicLatexFromSession;
|
|
1879
|
+
declare const index_renderArabicPreviewLatexFromSession: typeof renderArabicPreviewLatexFromSession;
|
|
1873
1880
|
declare const index_renderChainArabic: typeof renderChainArabic;
|
|
1874
1881
|
declare const index_renderChainEnglish: typeof renderChainEnglish;
|
|
1875
1882
|
declare const index_renderEnglishLatexFromSession: typeof renderEnglishLatexFromSession;
|
|
@@ -1899,7 +1906,7 @@ declare const index_toggleTakweenCharacterFont: typeof toggleTakweenCharacterFon
|
|
|
1899
1906
|
declare const index_undoRedoCanRedo: typeof undoRedoCanRedo;
|
|
1900
1907
|
declare const index_undoRedoCanUndo: typeof undoRedoCanUndo;
|
|
1901
1908
|
declare namespace index {
|
|
1902
|
-
export { index_ACCENT_COMMANDS as ACCENT_COMMANDS, index_ACCENT_CSS as ACCENT_CSS, index_ATOMIC_COMMANDS as ATOMIC_COMMANDS, index_ATOMIC_COMMAND_CSS as ATOMIC_COMMAND_CSS, index_ATOMIC_OPERATOR_COMMANDS as ATOMIC_OPERATOR_COMMANDS, index_ATOMIC_OPERATOR_COMMAND_CSS as ATOMIC_OPERATOR_COMMAND_CSS, type index_AccentCommandId as AccentCommandId, type index_AccentCommandSpec as AccentCommandSpec, type index_AccentPlacement as AccentPlacement, type index_AtomicCommandCategory as AtomicCommandCategory, type index_AtomicCommandId as AtomicCommandId, type index_AtomicCommandSpec as AtomicCommandSpec, type index_AtomicOperatorCommandCategory as AtomicOperatorCommandCategory, type index_AtomicOperatorCommandId as AtomicOperatorCommandId, type index_AtomicOperatorCommandSpec as AtomicOperatorCommandSpec, index_BOXED_CSS as BOXED_CSS, index_BUTEX_EDITOR_CSS as BUTEX_EDITOR_CSS, index_BUTEX_FRAGMENT_MIME as BUTEX_FRAGMENT_MIME, index_CHARACTER_FONT_OPTIONS as CHARACTER_FONT_OPTIONS, index_CHARACTER_FONT_SPECS as CHARACTER_FONT_SPECS, type index_CharacterFontId as CharacterFontId, type index_CharacterFontSpec as CharacterFontSpec, index_DEFAULT_UNDO_HISTORY_MAX_DEPTH as DEFAULT_UNDO_HISTORY_MAX_DEPTH, index_DELIMITER_CSS as DELIMITER_CSS, type index_DigitFormId as DigitFormId, type index_EditorCaret as EditorCaret, type index_EditorChain as EditorChain, type index_EditorDebugEntry as EditorDebugEntry, type index_EditorFragment as EditorFragment, type index_EditorNode as EditorNode, type index_EditorNodeKind as EditorNodeKind, type index_EditorRuntimeApi as EditorRuntimeApi, type index_EditorRuntimeOptions as EditorRuntimeOptions, type index_EditorSelectionRange as EditorSelectionRange, type index_EditorSession as EditorSession, type index_EditorSide as EditorSide, type index_EditorSyncMap as EditorSyncMap, type index_EditorSyncState as EditorSyncState, type index_EnvColumnAlignment as EnvColumnAlignment, index_FRAC_CSS as FRAC_CSS, type index_GridEnvName as GridEnvName, index_MATRIX_ENV_CSS as MATRIX_ENV_CSS, type index_MatrixEnvStyle as MatrixEnvStyle, index_NON_DEFAULT_CHARACTER_FONT_SPECS as NON_DEFAULT_CHARACTER_FONT_SPECS, index_OVERSET_CSS as OVERSET_CSS, index_SQRT_CSS as SQRT_CSS, index_STANDARD_COMMANDS as STANDARD_COMMANDS, index_STANDARD_COMMAND_CSS as STANDARD_COMMAND_CSS, type index_SpacingCommandSpec as SpacingCommandSpec, type index_SpacingDirection as SpacingDirection, type index_StandardCommandSpec as StandardCommandSpec, type index_StandardCommandTex as StandardCommandTex, index_UNDERSET_CSS as UNDERSET_CSS, type index_UndoRedoStacks as UndoRedoStacks, index_accentCommandIdFromTex as accentCommandIdFromTex, index_accentCommandSpec as accentCommandSpec, index_accentCommandsList as accentCommandsList, index_activeSideLabel as activeSideLabel, index_activeTreeKey as activeTreeKey, index_addMatrixColumn as addMatrixColumn, index_addMatrixRow as addMatrixRow, index_addSub as addSub, index_addSup as addSup, index_atomicCommandSpec as atomicCommandSpec, index_atomicCommandsByCategory as atomicCommandsByCategory, index_atomicOperatorCommandSpec as atomicOperatorCommandSpec, index_atomicOperatorCommandsByCategory as atomicOperatorCommandsByCategory, index_breakLeafTyping as breakLeafTyping, index_buildInitialSyncMap as buildInitialSyncMap, index_buildNodeBody as buildNodeBody, index_buildNodeScripts as buildNodeScripts, index_caretStep as caretStep, index_characterFontSpec as characterFontSpec, index_characterFontSpecByMacro as characterFontSpecByMacro, index_clearSelection as clearSelection, index_cloneEditorSession as cloneEditorSession, index_collectCaretPositions as collectCaretPositions, index_copySelection as copySelection, index_coveredNodeIds as coveredNodeIds, index_createAccentNode as createAccentNode, index_createAtomicCommandNode as createAtomicCommandNode, index_createAtomicOperatorCommandNode as createAtomicOperatorCommandNode, index_createBoxedNode as createBoxedNode, index_createDelimiterNode as createDelimiterNode, index_createEditorChain as createEditorChain, index_createEditorNode as createEditorNode, index_createEditorRuntime as createEditorRuntime, index_createEditorSession as createEditorSession, index_createFracNode as createFracNode, index_createGridEnvNode as createGridEnvNode, index_createMatrixEnvNode as createMatrixEnvNode, index_createOversetNode as createOversetNode, index_createSqrtNode as createSqrtNode, index_createStarterSession as createStarterSession, index_createUndersetNode as createUndersetNode, index_createUndoRedoStacks as createUndoRedoStacks, index_cutSelection as cutSelection, index_deleteBackward as deleteBackward, index_deleteForward as deleteForward, index_deleteStructure as deleteStructure, index_deserializeFragment as deserializeFragment, index_extendSelectionByStep as extendSelectionByStep, index_findChainById as findChainById, index_findNodeById as findNodeById, index_formatDigits as formatDigits, index_fragmentToPlainText as fragmentToPlainText, index_horizontalCaretDelta as horizontalCaretDelta, index_injectBuTeXEditorStyles as injectBuTeXEditorStyles, index_insertAccent as insertAccent, index_insertAccentPair as insertAccentPair, index_insertAlignedEnv as insertAlignedEnv, index_insertArrayEnv as insertArrayEnv, index_insertAtomicCommand as insertAtomicCommand, index_insertAtomicOperatorCommand as insertAtomicOperatorCommand, index_insertChar as insertChar, index_insertDelimiterPair as insertDelimiterPair, index_insertDivideOperator as insertDivideOperator, index_insertFirstDerivative as insertFirstDerivative, index_insertFraction as insertFraction, index_insertLimitsSeriesTemplate as insertLimitsSeriesTemplate, index_insertMatrixEnv as insertMatrixEnv, index_insertNumber as insertNumber, index_insertOperator as insertOperator, index_insertOverset as insertOverset, index_insertSecondDerivative as insertSecondDerivative, index_insertSqrt as insertSqrt, index_insertUnderset as insertUnderset, index_isSelectionActive as isSelectionActive, index_isSpacingCommandSpec as isSpacingCommandSpec, index_isStandardCommandTex as isStandardCommandTex, index_mirrorBuTeXOperatorsInTex as mirrorBuTeXOperatorsInTex, index_moveCaret as moveCaret, index_moveCaretHorizontal as moveCaretHorizontal, index_moveCaretVertical as moveCaretVertical, index_nodeChildChains as nodeChildChains, index_normalizeSelection as normalizeSelection, index_passiveTreeKey as passiveTreeKey, index_pasteFragment as pasteFragment, index_pasteText as pasteText, index_pushUndoRedoSnapshot as pushUndoRedoSnapshot, index_regenerateFragmentIds as regenerateFragmentIds, index_removeMatrixColumn as removeMatrixColumn, index_removeMatrixRow as removeMatrixRow, index_removeSub as removeSub, index_removeSup as removeSup, index_renderArabicLatexFromSession as renderArabicLatexFromSession, index_renderChainArabic as renderChainArabic, index_renderChainEnglish as renderChainEnglish, index_renderEnglishLatexFromSession as renderEnglishLatexFromSession, index_restoreRedo as restoreRedo, index_restoreUndo as restoreUndo, index_runtimeStatusText as runtimeStatusText, index_selectNode as selectNode, index_serializeSelection as serializeSelection, index_sessionHasStandardCommands as sessionHasStandardCommands, index_setArabicReverseNumberTyping as setArabicReverseNumberTyping, index_setArrayColumnAlignment as setArrayColumnAlignment, index_setCaret as setCaret, index_setCurrentBoldCharacterStyle as setCurrentBoldCharacterStyle, index_setCurrentCharacterFont as setCurrentCharacterFont, index_setCurrentDigitForm as setCurrentDigitForm, index_setExpr as setExpr, index_setMatrixEnvStyle as setMatrixEnvStyle, index_setRenderError as setRenderError, index_setSelectionFromMouse as setSelectionFromMouse, index_setSplitLeafTyping as setSplitLeafTyping, index_shouldMirrorOperatorDisplay as shouldMirrorOperatorDisplay, index_standardCommandSpec as standardCommandSpec, index_switchSide as switchSide, index_syncSelectionToCaret as syncSelectionToCaret, index_syncStateSummary as syncStateSummary, index_toggleTakweenCharacterFont as toggleTakweenCharacterFont, index_undoRedoCanRedo as undoRedoCanRedo, index_undoRedoCanUndo as undoRedoCanUndo };
|
|
1909
|
+
export { index_ACCENT_COMMANDS as ACCENT_COMMANDS, index_ACCENT_CSS as ACCENT_CSS, index_ATOMIC_COMMANDS as ATOMIC_COMMANDS, index_ATOMIC_COMMAND_CSS as ATOMIC_COMMAND_CSS, index_ATOMIC_OPERATOR_COMMANDS as ATOMIC_OPERATOR_COMMANDS, index_ATOMIC_OPERATOR_COMMAND_CSS as ATOMIC_OPERATOR_COMMAND_CSS, type index_AccentCommandId as AccentCommandId, type index_AccentCommandSpec as AccentCommandSpec, type index_AccentPlacement as AccentPlacement, type index_AtomicCommandCategory as AtomicCommandCategory, type index_AtomicCommandId as AtomicCommandId, type index_AtomicCommandSpec as AtomicCommandSpec, type index_AtomicOperatorCommandCategory as AtomicOperatorCommandCategory, type index_AtomicOperatorCommandId as AtomicOperatorCommandId, type index_AtomicOperatorCommandSpec as AtomicOperatorCommandSpec, index_BOXED_CSS as BOXED_CSS, index_BUTEX_EDITOR_CSS as BUTEX_EDITOR_CSS, index_BUTEX_FRAGMENT_MIME as BUTEX_FRAGMENT_MIME, index_CHARACTER_FONT_OPTIONS as CHARACTER_FONT_OPTIONS, index_CHARACTER_FONT_SPECS as CHARACTER_FONT_SPECS, type index_CharacterFontId as CharacterFontId, type index_CharacterFontSpec as CharacterFontSpec, index_DEFAULT_UNDO_HISTORY_MAX_DEPTH as DEFAULT_UNDO_HISTORY_MAX_DEPTH, index_DELIMITER_CSS as DELIMITER_CSS, type index_DigitFormId as DigitFormId, type index_EditorCaret as EditorCaret, type index_EditorChain as EditorChain, type index_EditorDebugEntry as EditorDebugEntry, type index_EditorFragment as EditorFragment, type index_EditorNode as EditorNode, type index_EditorNodeKind as EditorNodeKind, type index_EditorRuntimeApi as EditorRuntimeApi, type index_EditorRuntimeOptions as EditorRuntimeOptions, type index_EditorSelectionRange as EditorSelectionRange, type index_EditorSession as EditorSession, type index_EditorSide as EditorSide, type index_EditorSyncMap as EditorSyncMap, type index_EditorSyncState as EditorSyncState, type index_EnvColumnAlignment as EnvColumnAlignment, index_FRAC_CSS as FRAC_CSS, type index_GridEnvName as GridEnvName, index_MATRIX_ENV_CSS as MATRIX_ENV_CSS, type index_MatrixEnvStyle as MatrixEnvStyle, index_NON_DEFAULT_CHARACTER_FONT_SPECS as NON_DEFAULT_CHARACTER_FONT_SPECS, index_OVERSET_CSS as OVERSET_CSS, index_SQRT_CSS as SQRT_CSS, index_STANDARD_COMMANDS as STANDARD_COMMANDS, index_STANDARD_COMMAND_CSS as STANDARD_COMMAND_CSS, type index_SpacingCommandSpec as SpacingCommandSpec, type index_SpacingDirection as SpacingDirection, type index_StandardCommandSpec as StandardCommandSpec, type index_StandardCommandTex as StandardCommandTex, index_UNDERSET_CSS as UNDERSET_CSS, type index_UndoRedoStacks as UndoRedoStacks, index_accentCommandIdFromTex as accentCommandIdFromTex, index_accentCommandSpec as accentCommandSpec, index_accentCommandsList as accentCommandsList, index_activeSideLabel as activeSideLabel, index_activeTreeKey as activeTreeKey, index_addMatrixColumn as addMatrixColumn, index_addMatrixRow as addMatrixRow, index_addSub as addSub, index_addSup as addSup, index_atomicCommandSpec as atomicCommandSpec, index_atomicCommandsByCategory as atomicCommandsByCategory, index_atomicOperatorCommandSpec as atomicOperatorCommandSpec, index_atomicOperatorCommandsByCategory as atomicOperatorCommandsByCategory, index_breakLeafTyping as breakLeafTyping, index_buildInitialSyncMap as buildInitialSyncMap, index_buildNodeBody as buildNodeBody, index_buildNodeScripts as buildNodeScripts, index_caretStep as caretStep, index_characterFontSpec as characterFontSpec, index_characterFontSpecByMacro as characterFontSpecByMacro, index_clearSelection as clearSelection, index_cloneEditorSession as cloneEditorSession, index_collectCaretPositions as collectCaretPositions, index_copySelection as copySelection, index_coveredNodeIds as coveredNodeIds, index_createAccentNode as createAccentNode, index_createAtomicCommandNode as createAtomicCommandNode, index_createAtomicOperatorCommandNode as createAtomicOperatorCommandNode, index_createBoxedNode as createBoxedNode, index_createDelimiterNode as createDelimiterNode, index_createEditorChain as createEditorChain, index_createEditorNode as createEditorNode, index_createEditorRuntime as createEditorRuntime, index_createEditorSession as createEditorSession, index_createFracNode as createFracNode, index_createGridEnvNode as createGridEnvNode, index_createMatrixEnvNode as createMatrixEnvNode, index_createOversetNode as createOversetNode, index_createSqrtNode as createSqrtNode, index_createStarterSession as createStarterSession, index_createUndersetNode as createUndersetNode, index_createUndoRedoStacks as createUndoRedoStacks, index_cutSelection as cutSelection, index_deleteBackward as deleteBackward, index_deleteForward as deleteForward, index_deleteStructure as deleteStructure, index_deserializeFragment as deserializeFragment, index_extendSelectionByStep as extendSelectionByStep, index_findChainById as findChainById, index_findNodeById as findNodeById, index_formatDigits as formatDigits, index_fragmentToPlainText as fragmentToPlainText, index_horizontalCaretDelta as horizontalCaretDelta, index_injectBuTeXEditorStyles as injectBuTeXEditorStyles, index_insertAccent as insertAccent, index_insertAccentPair as insertAccentPair, index_insertAlignedEnv as insertAlignedEnv, index_insertArrayEnv as insertArrayEnv, index_insertAtomicCommand as insertAtomicCommand, index_insertAtomicOperatorCommand as insertAtomicOperatorCommand, index_insertCasesEnv as insertCasesEnv, index_insertChar as insertChar, index_insertDelimiterPair as insertDelimiterPair, index_insertDivideOperator as insertDivideOperator, index_insertFirstDerivative as insertFirstDerivative, index_insertFraction as insertFraction, index_insertLimitsSeriesTemplate as insertLimitsSeriesTemplate, index_insertMatrixEnv as insertMatrixEnv, index_insertNumber as insertNumber, index_insertOperator as insertOperator, index_insertOverset as insertOverset, index_insertSecondDerivative as insertSecondDerivative, index_insertSqrt as insertSqrt, index_insertUnderset as insertUnderset, index_isSelectionActive as isSelectionActive, index_isSpacingCommandSpec as isSpacingCommandSpec, index_isStandardCommandTex as isStandardCommandTex, index_mirrorBuTeXOperatorsInTex as mirrorBuTeXOperatorsInTex, index_moveCaret as moveCaret, index_moveCaretHorizontal as moveCaretHorizontal, index_moveCaretVertical as moveCaretVertical, index_nodeChildChains as nodeChildChains, index_normalizeSelection as normalizeSelection, index_passiveTreeKey as passiveTreeKey, index_pasteFragment as pasteFragment, index_pasteText as pasteText, index_pushUndoRedoSnapshot as pushUndoRedoSnapshot, index_regenerateFragmentIds as regenerateFragmentIds, index_removeMatrixColumn as removeMatrixColumn, index_removeMatrixRow as removeMatrixRow, index_removeSub as removeSub, index_removeSup as removeSup, index_renderArabicLatexFromSession as renderArabicLatexFromSession, index_renderArabicPreviewLatexFromSession as renderArabicPreviewLatexFromSession, index_renderChainArabic as renderChainArabic, index_renderChainEnglish as renderChainEnglish, index_renderEnglishLatexFromSession as renderEnglishLatexFromSession, index_restoreRedo as restoreRedo, index_restoreUndo as restoreUndo, index_runtimeStatusText as runtimeStatusText, index_selectNode as selectNode, index_serializeSelection as serializeSelection, index_sessionHasStandardCommands as sessionHasStandardCommands, index_setArabicReverseNumberTyping as setArabicReverseNumberTyping, index_setArrayColumnAlignment as setArrayColumnAlignment, index_setCaret as setCaret, index_setCurrentBoldCharacterStyle as setCurrentBoldCharacterStyle, index_setCurrentCharacterFont as setCurrentCharacterFont, index_setCurrentDigitForm as setCurrentDigitForm, index_setExpr as setExpr, index_setMatrixEnvStyle as setMatrixEnvStyle, index_setRenderError as setRenderError, index_setSelectionFromMouse as setSelectionFromMouse, index_setSplitLeafTyping as setSplitLeafTyping, index_shouldMirrorOperatorDisplay as shouldMirrorOperatorDisplay, index_standardCommandSpec as standardCommandSpec, index_switchSide as switchSide, index_syncSelectionToCaret as syncSelectionToCaret, index_syncStateSummary as syncStateSummary, index_toggleTakweenCharacterFont as toggleTakweenCharacterFont, index_undoRedoCanRedo as undoRedoCanRedo, index_undoRedoCanUndo as undoRedoCanUndo };
|
|
1903
1910
|
}
|
|
1904
1911
|
|
|
1905
1912
|
/**
|
package/dist/index.global.js
CHANGED
|
@@ -1651,6 +1651,11 @@ mjx-container[jax="CHTML"] .butex-preview-mirror {
|
|
|
1651
1651
|
transform-origin: center;
|
|
1652
1652
|
}
|
|
1653
1653
|
|
|
1654
|
+
.matrix-env--cases .matrix-env__wrapper:empty {
|
|
1655
|
+
min-width: 0;
|
|
1656
|
+
padding: 0;
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1654
1659
|
.matrix-env__grid {
|
|
1655
1660
|
display: inline-grid;
|
|
1656
1661
|
direction: ltr;
|
|
@@ -1695,9 +1700,10 @@ mjx-container[jax="CHTML"] .butex-preview-mirror {
|
|
|
1695
1700
|
}
|
|
1696
1701
|
function buildMatrixEnvNodeBody(node, buildChain, side) {
|
|
1697
1702
|
const wrap = document.createElement("span");
|
|
1698
|
-
wrap.className = `matrix-env matrix-env--${side}`;
|
|
1703
|
+
wrap.className = `matrix-env matrix-env--${side}${node.envName === "cases" ? " matrix-env--cases" : ""}`;
|
|
1704
|
+
if (node.envName === "cases") wrap.dir = "ltr";
|
|
1699
1705
|
const style = node.envName ?? node.matrixStyle ?? "matrix";
|
|
1700
|
-
const glyphs = style === "array" || style === "aligned" ? void 0 : WRAPPERS[style];
|
|
1706
|
+
const glyphs = style === "cases" ? side === "arabic" ? { left: "", right: "}" } : { left: "{", right: "" } : style === "array" || style === "aligned" ? void 0 : WRAPPERS[style];
|
|
1701
1707
|
const left = document.createElement("span");
|
|
1702
1708
|
left.className = "matrix-env__wrapper matrix-env__wrapper--left";
|
|
1703
1709
|
left.textContent = glyphs?.left ?? "";
|
|
@@ -1854,6 +1860,7 @@ mjx-container[jax="CHTML"] .butex-preview-mirror {
|
|
|
1854
1860
|
matrix: "\u0645\u0635\u0641\u0648\u0641\u0629",
|
|
1855
1861
|
array: "\u062C\u062F\u0648\u0644",
|
|
1856
1862
|
aligned: "\u0645\u062D\u0627\u0630\u0627\u0629",
|
|
1863
|
+
piecewise: "\u062F\u0627\u0644\u0629 \u0645\u062A\u0639\u062F\u062F\u0629 \u0627\u0644\u062A\u0639\u0631\u064A\u0641",
|
|
1857
1864
|
matrixType: "\u0646\u0648\u0639 \u0627\u0644\u0645\u0635\u0641\u0648\u0641\u0629",
|
|
1858
1865
|
chooseEnvironmentSize: "\u0627\u062E\u062A\u064A\u0627\u0631 \u062D\u062C\u0645 \u0627\u0644\u0628\u064A\u0626\u0629",
|
|
1859
1866
|
rows: "\u0635\u0641\u0648\u0641",
|
|
@@ -1981,6 +1988,7 @@ mjx-container[jax="CHTML"] .butex-preview-mirror {
|
|
|
1981
1988
|
matrix: "Matrix",
|
|
1982
1989
|
array: "Array",
|
|
1983
1990
|
aligned: "Aligned",
|
|
1991
|
+
piecewise: "Piecewise (cases)",
|
|
1984
1992
|
matrixType: "Matrix type",
|
|
1985
1993
|
chooseEnvironmentSize: "Choose environment size",
|
|
1986
1994
|
rows: "Rows",
|
|
@@ -3301,6 +3309,7 @@ ${STANDARD_COMMAND_CSS}
|
|
|
3301
3309
|
insertArrayEnv: () => insertArrayEnv,
|
|
3302
3310
|
insertAtomicCommand: () => insertAtomicCommand,
|
|
3303
3311
|
insertAtomicOperatorCommand: () => insertAtomicOperatorCommand,
|
|
3312
|
+
insertCasesEnv: () => insertCasesEnv,
|
|
3304
3313
|
insertChar: () => insertChar,
|
|
3305
3314
|
insertDelimiterPair: () => insertDelimiterPair,
|
|
3306
3315
|
insertDivideOperator: () => insertDivideOperator,
|
|
@@ -3333,6 +3342,7 @@ ${STANDARD_COMMAND_CSS}
|
|
|
3333
3342
|
removeSub: () => removeSub,
|
|
3334
3343
|
removeSup: () => removeSup,
|
|
3335
3344
|
renderArabicLatexFromSession: () => renderArabicLatexFromSession,
|
|
3345
|
+
renderArabicPreviewLatexFromSession: () => renderArabicPreviewLatexFromSession,
|
|
3336
3346
|
renderChainArabic: () => renderChainArabic,
|
|
3337
3347
|
renderChainEnglish: () => renderChainEnglish,
|
|
3338
3348
|
renderEnglishLatexFromSession: () => renderEnglishLatexFromSession,
|
|
@@ -3453,7 +3463,7 @@ ${STANDARD_COMMAND_CSS}
|
|
|
3453
3463
|
}
|
|
3454
3464
|
function createGridEnvNode(envName, rows, columns, columnAlignments) {
|
|
3455
3465
|
const safeRows = Math.max(1, Math.min(12, Math.trunc(rows)));
|
|
3456
|
-
const safeColumns = Math.max(1, Math.min(12, Math.trunc(columns)));
|
|
3466
|
+
const safeColumns = envName === "cases" ? 2 : Math.max(1, Math.min(12, Math.trunc(columns)));
|
|
3457
3467
|
const matrixStyles = /* @__PURE__ */ new Set(["matrix", "pmatrix", "bmatrix", "Bmatrix", "vmatrix", "Vmatrix"]);
|
|
3458
3468
|
const isMatrix = matrixStyles.has(envName) && envName !== "array" && envName !== "aligned";
|
|
3459
3469
|
return {
|
|
@@ -3738,6 +3748,9 @@ ${STANDARD_COMMAND_CSS}
|
|
|
3738
3748
|
const spec = (node.columnAlignments ?? []).slice(0, node.matrixRows[0]?.length ?? 0).reverse().map(reverseAlignmentForArabic).join("");
|
|
3739
3749
|
return `\\begin{array}{${spec || "c"}}${rows.join(" \\\\\n")}\\end{array}`;
|
|
3740
3750
|
}
|
|
3751
|
+
if (envName === "cases" && options?.casesPresentation) {
|
|
3752
|
+
return `\\left.\\begin{array}{rl}${rows.join(" \\\\\n")}\\end{array}\\right\\}`;
|
|
3753
|
+
}
|
|
3741
3754
|
return `\\begin{${envName}}${rows.join(" \\\\\n")}\\end{${envName}}`;
|
|
3742
3755
|
}
|
|
3743
3756
|
function renderAccentEnglish(command, accent, base, options) {
|
|
@@ -3759,6 +3772,10 @@ ${STANDARD_COMMAND_CSS}
|
|
|
3759
3772
|
function escapeText(s) {
|
|
3760
3773
|
return s.replace(/\\/g, "\\textbackslash{}").replace(/[{}]/g, "\\$&");
|
|
3761
3774
|
}
|
|
3775
|
+
function escapeAtomicLiteral(text) {
|
|
3776
|
+
const unescaped = text.replace(/\\([%_&#{}$])/g, "$1");
|
|
3777
|
+
return escapeText(unescaped).replace(/[%_&#$]/g, "\\$&");
|
|
3778
|
+
}
|
|
3762
3779
|
function renderCharContent(node, options) {
|
|
3763
3780
|
const expr = formatDigits(node.expr, selectedDigitForm(options));
|
|
3764
3781
|
const font = node.characterFont ?? "default";
|
|
@@ -3805,7 +3822,7 @@ ${STANDARD_COMMAND_CSS}
|
|
|
3805
3822
|
return `${body}${latinScripts(node, options)}`;
|
|
3806
3823
|
}
|
|
3807
3824
|
if (node.kind === "atomicOperatorCommand") {
|
|
3808
|
-
const body = atomicOperatorCommandSpec(node.expr)?.Tex ?? node.expr;
|
|
3825
|
+
const body = node.sourceLatex === "\\le" || node.sourceLatex === "\\ge" ? node.sourceLatex : atomicOperatorCommandSpec(node.expr)?.Tex ?? node.expr;
|
|
3809
3826
|
return `${body}${latinScripts(node, options)}`;
|
|
3810
3827
|
}
|
|
3811
3828
|
if (node.kind === "standardCommand") {
|
|
@@ -3822,7 +3839,8 @@ ${STANDARD_COMMAND_CSS}
|
|
|
3822
3839
|
if (node.wrapperCommand) {
|
|
3823
3840
|
const expr = formatDigits(node.expr, selectedDigitForm(options));
|
|
3824
3841
|
const wrapper = node.wrapperCommand === "\\boldarabic" ? "\\mathbf" : node.wrapperCommand;
|
|
3825
|
-
|
|
3842
|
+
const escaped = wrapper === "\\operatorname" || wrapper === "\\text" ? escapeAtomicLiteral(expr) : escapeText(expr);
|
|
3843
|
+
return `${wrapper}{${escaped}}${latinScripts(node, options)}`;
|
|
3826
3844
|
}
|
|
3827
3845
|
return `${renderCharContent(node, options)}${latinScripts(node, options)}`;
|
|
3828
3846
|
}
|
|
@@ -3883,7 +3901,8 @@ ${STANDARD_COMMAND_CSS}
|
|
|
3883
3901
|
const content = renderCharContent(node, options);
|
|
3884
3902
|
if (node.wrapperCommand) {
|
|
3885
3903
|
const wrapper = node.wrapperCommand === "\\mathbf" ? "\\boldarabic" : node.wrapperCommand;
|
|
3886
|
-
|
|
3904
|
+
const literal = wrapper === "\\operatorname" || wrapper === "\\text" ? escapeAtomicLiteral(expr) : content;
|
|
3905
|
+
return arabicScripts(node, `${wrapper}{${literal}}`, options);
|
|
3887
3906
|
}
|
|
3888
3907
|
return arabicScripts(node, (node.characterFont ?? "default") === "default" ? `\\text{${escapeText(expr)}}` : content, options);
|
|
3889
3908
|
}
|
|
@@ -3912,6 +3931,9 @@ ${STANDARD_COMMAND_CSS}
|
|
|
3912
3931
|
function renderArabicLatexFromSession(session) {
|
|
3913
3932
|
return renderChainArabic(session.arabicTree, { digitForm: session.currentDigitForm ?? "western" });
|
|
3914
3933
|
}
|
|
3934
|
+
function renderArabicPreviewLatexFromSession(session) {
|
|
3935
|
+
return renderChainArabic(session.arabicTree, { digitForm: session.currentDigitForm ?? "western", casesPresentation: true });
|
|
3936
|
+
}
|
|
3915
3937
|
|
|
3916
3938
|
// src/editor/caretOrder.ts
|
|
3917
3939
|
function collectCaretPositions(chain) {
|
|
@@ -4742,6 +4764,9 @@ ${STANDARD_COMMAND_CSS}
|
|
|
4742
4764
|
function clearSourceIdentity(session, nodeId) {
|
|
4743
4765
|
const english = findNodeById(session.englishTree, nodeId);
|
|
4744
4766
|
const arabic = findNodeById(session.arabicTree, nodeId);
|
|
4767
|
+
if (session.activeSide === "arabic" && english?.node.kind === "char" && ["\\mathtt", "\\operatorname", "\\text"].includes(english.node.wrapperCommand ?? "") && english.node.sourceLatex) {
|
|
4768
|
+
return;
|
|
4769
|
+
}
|
|
4745
4770
|
if (english) {
|
|
4746
4771
|
delete english.node.sourceLatex;
|
|
4747
4772
|
}
|
|
@@ -5742,6 +5767,9 @@ ${STANDARD_COMMAND_CSS}
|
|
|
5742
5767
|
function insertAlignedEnv(session, rows, columns) {
|
|
5743
5768
|
return insertGridEnv(session, "aligned", rows, columns);
|
|
5744
5769
|
}
|
|
5770
|
+
function insertCasesEnv(session, rows) {
|
|
5771
|
+
return insertGridEnv(session, "cases", rows, 2);
|
|
5772
|
+
}
|
|
5745
5773
|
function insertGridEnv(session, envName, rows, columns, columnAlignments) {
|
|
5746
5774
|
const base = replaceSelectionFirst(session);
|
|
5747
5775
|
const next = cloneEditorSession(base);
|
|
@@ -5762,7 +5790,7 @@ ${STANDARD_COMMAND_CSS}
|
|
|
5762
5790
|
function setMatrixEnvStyle(session, style) {
|
|
5763
5791
|
const next = cloneEditorSession(session);
|
|
5764
5792
|
const pair = findSelectedMatrixPair(next);
|
|
5765
|
-
if (!pair) {
|
|
5793
|
+
if (!pair || pair.english.envName === "cases") {
|
|
5766
5794
|
return session;
|
|
5767
5795
|
}
|
|
5768
5796
|
pair.english.envName = style;
|
|
@@ -5826,7 +5854,7 @@ ${STANDARD_COMMAND_CSS}
|
|
|
5826
5854
|
function addMatrixColumn(session) {
|
|
5827
5855
|
const next = cloneEditorSession(session);
|
|
5828
5856
|
const pair = findSelectedMatrixPair(next);
|
|
5829
|
-
if (!pair || !pair.english.matrixRows || !pair.arabic.matrixRows) {
|
|
5857
|
+
if (!pair || !pair.english.matrixRows || !pair.arabic.matrixRows || pair.english.envName === "cases") {
|
|
5830
5858
|
return session;
|
|
5831
5859
|
}
|
|
5832
5860
|
const columnCount = pair.english.matrixRows[0]?.length ?? 0;
|
|
@@ -5848,7 +5876,7 @@ ${STANDARD_COMMAND_CSS}
|
|
|
5848
5876
|
function removeMatrixColumn(session) {
|
|
5849
5877
|
const next = cloneEditorSession(session);
|
|
5850
5878
|
const pair = findSelectedMatrixPair(next);
|
|
5851
|
-
if (!pair || !pair.english.matrixRows || !pair.arabic.matrixRows) {
|
|
5879
|
+
if (!pair || !pair.english.matrixRows || !pair.arabic.matrixRows || pair.english.envName === "cases") {
|
|
5852
5880
|
return session;
|
|
5853
5881
|
}
|
|
5854
5882
|
const columnCount = pair.english.matrixRows[0]?.length ?? 0;
|
|
@@ -6075,6 +6103,9 @@ ${STANDARD_COMMAND_CSS}
|
|
|
6075
6103
|
return session;
|
|
6076
6104
|
}
|
|
6077
6105
|
activeNode.node.expr = expr;
|
|
6106
|
+
if (["\\mathtt", "\\operatorname", "\\text"].includes(activeNode.node.wrapperCommand ?? "")) {
|
|
6107
|
+
passiveNode.node.expr = expr;
|
|
6108
|
+
}
|
|
6078
6109
|
clearSourceIdentity(next, nodeId);
|
|
6079
6110
|
markExprSync(next, nodeId);
|
|
6080
6111
|
appendDebug(next, "setExpr", nodeId);
|
|
@@ -6175,6 +6206,14 @@ ${STANDARD_COMMAND_CSS}
|
|
|
6175
6206
|
if (!text) {
|
|
6176
6207
|
return session;
|
|
6177
6208
|
}
|
|
6209
|
+
const selection = session.selection;
|
|
6210
|
+
if (selection && Math.abs(selection.anchorIndex - selection.focusIndex) === 1) {
|
|
6211
|
+
const selectedChain = findChainById(session[activeTreeKey(session.activeSide)], selection.chainId);
|
|
6212
|
+
const selected = selectedChain?.chain.nodes[Math.min(selection.anchorIndex, selection.focusIndex)];
|
|
6213
|
+
if (selected?.kind === "char" && ["\\mathtt", "\\operatorname", "\\text"].includes(selected.wrapperCommand ?? "")) {
|
|
6214
|
+
return setExpr(session, selected.id, text);
|
|
6215
|
+
}
|
|
6216
|
+
}
|
|
6178
6217
|
let s = session;
|
|
6179
6218
|
let i = 0;
|
|
6180
6219
|
while (i < text.length) {
|
|
@@ -6234,6 +6273,8 @@ ${STANDARD_COMMAND_CSS}
|
|
|
6234
6273
|
if (node.wrapperCommand === "\\boldarabic" || node.wrapperCommand === "\\mathbf") {
|
|
6235
6274
|
value.classList.add("node-value--bold");
|
|
6236
6275
|
}
|
|
6276
|
+
if (node.wrapperCommand === "\\text") value.dir = "auto";
|
|
6277
|
+
if (node.wrapperCommand === "\\operatorname") value.classList.add("node-value--operator-name");
|
|
6237
6278
|
if (node.wrapperCommand === "\\unit") {
|
|
6238
6279
|
value.classList.add("node-value--unit");
|
|
6239
6280
|
value.title = "\u0648\u062D\u062F\u0629 (unit)";
|
|
@@ -7162,6 +7203,10 @@ ${STANDARD_COMMAND_CSS}
|
|
|
7162
7203
|
applyStructural((prev) => insertAlignedEnv(prev, rows, columns));
|
|
7163
7204
|
focusInput();
|
|
7164
7205
|
},
|
|
7206
|
+
insertCasesEnv: (rows) => {
|
|
7207
|
+
applyStructural((prev) => insertCasesEnv(prev, rows));
|
|
7208
|
+
focusInput();
|
|
7209
|
+
},
|
|
7165
7210
|
insertSqrt: () => {
|
|
7166
7211
|
applyStructural((prev) => insertSqrt(prev));
|
|
7167
7212
|
focusInput();
|