rj-editor 1.1.5 → 1.1.7

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 (60) hide show
  1. package/README.md +93 -4
  2. package/dist/assets/icons/CodeSnippedIcon01.d.ts +2 -0
  3. package/dist/assets/icons/CodeSnippedIcon02.d.ts +2 -0
  4. package/dist/assets/icons/CopyIcon01.d.ts +2 -0
  5. package/dist/components/RJTextEditor.d.ts +1 -1
  6. package/dist/components/code-block/actions/CodeBlockActions.d.ts +1 -0
  7. package/dist/components/code-block/actions/code-block-action/CodeBlockAction.d.ts +8 -0
  8. package/dist/components/equation/visual/equation-visual-editor/EquationVisualEditor.d.ts +17 -0
  9. package/dist/components/equation/visual/equation-visual-editor/index.d.ts +1 -0
  10. package/dist/components/equation/visual/index.d.ts +1 -0
  11. package/dist/components/rj-text-editor/RJTextEditor.types.d.ts +2 -1
  12. package/dist/components/rj-text-editor/RJTextEditorContent.d.ts +3 -1
  13. package/dist/components/rj-text-editor/createInitialConfig.d.ts +36 -1
  14. package/dist/components/rj-text-editor/editorTheme.d.ts +34 -0
  15. package/dist/components/toolbar/equation/structures/EquationMathPreview.d.ts +7 -0
  16. package/dist/components/toolbar/equation/structures/EquationStructureGallery.d.ts +6 -0
  17. package/dist/components/toolbar/equation/symbols/EquationSymbolPalette.d.ts +6 -0
  18. package/dist/components/toolbar/equation/tools/EquationTools.d.ts +9 -0
  19. package/dist/components/toolbar/insert/code-block/CodeBlockControl.d.ts +1 -0
  20. package/dist/constants/equationStructureGroups.d.ts +15 -0
  21. package/dist/constants/equationSymbolGroups.d.ts +7 -0
  22. package/dist/constants/index.d.ts +3 -1
  23. package/dist/constants/insertCodeBlockCommand.d.ts +2 -0
  24. package/dist/index.d.ts +1 -1
  25. package/dist/plugins/CodeBlockPlugin.d.ts +1 -0
  26. package/dist/rj-editor.css +1 -1
  27. package/dist/rj-editor.js +2827 -1818
  28. package/dist/rj-editor.umd.cjs +2 -2
  29. package/dist/slice/toolbarSlice.d.ts +1 -1
  30. package/dist/theme/RJEditorThemeContext.d.ts +3 -0
  31. package/dist/theme/getAntdThemeConfig.d.ts +3 -0
  32. package/dist/theme/index.d.ts +4 -0
  33. package/dist/theme/useRJEditorTheme.d.ts +1 -0
  34. package/dist/theme/useResolvedRJEditorTheme.d.ts +2 -0
  35. package/dist/types/EquationModel.d.ts +73 -0
  36. package/dist/types/InsertCodeBlockPayload.d.ts +4 -0
  37. package/dist/types/RJEditorTheme.d.ts +1 -0
  38. package/dist/types/RJEditorTranslations.d.ts +9 -0
  39. package/dist/types/ResolvedRJEditorTheme.d.ts +2 -0
  40. package/dist/types/ToolbarState.d.ts +1 -0
  41. package/dist/types/index.d.ts +4 -0
  42. package/dist/utils/helpers/appendTextToEquationModelSlot.d.ts +12 -0
  43. package/dist/utils/helpers/copyTextToClipboard.d.ts +1 -0
  44. package/dist/utils/helpers/decodeEquationValue.d.ts +2 -0
  45. package/dist/utils/helpers/encodeEquationModel.d.ts +2 -0
  46. package/dist/utils/helpers/equationModelPrefix.d.ts +1 -0
  47. package/dist/utils/helpers/escapeHtml.d.ts +1 -0
  48. package/dist/utils/helpers/getEquationModelSlotValue.d.ts +2 -0
  49. package/dist/utils/helpers/getFirstEquationSlotId.d.ts +2 -0
  50. package/dist/utils/helpers/index.d.ts +14 -0
  51. package/dist/utils/helpers/insertEquationModelIntoSlot.d.ts +11 -0
  52. package/dist/utils/helpers/isVisualEquationValue.d.ts +1 -0
  53. package/dist/utils/helpers/normalizeEditorFontFamily.d.ts +1 -0
  54. package/dist/utils/helpers/normalizeEditorFontSize.d.ts +1 -0
  55. package/dist/utils/helpers/parseEquationRowInsertSlotId.d.ts +5 -0
  56. package/dist/utils/helpers/registerCodeBlockCopyHandler.d.ts +1 -0
  57. package/dist/utils/helpers/renderEquationModelToHtml.d.ts +2 -0
  58. package/dist/utils/helpers/updateEquationModelSlot.d.ts +2 -0
  59. package/package.json +2 -1
  60. package/dist/constants/equationStructures.d.ts +0 -33
@@ -1,3 +1,3 @@
1
1
  import type { ToolbarState } from '../types/index';
2
- export declare const setBlockFormats: import("@reduxjs/toolkit").ActionCreatorWithPayload<Pick<ToolbarState, "alignment" | "listType">, "toolbar/setBlockFormats">, setCanRedo: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, "toolbar/setCanRedo">, setCanUndo: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, "toolbar/setCanUndo">, setEquationFormats: import("@reduxjs/toolkit").ActionCreatorWithPayload<Pick<ToolbarState, "isEquationSelected" | "selectedEquation" | "selectedEquationDisplayMode" | "selectedEquationKey">, "toolbar/setEquationFormats">, setImageFormats: import("@reduxjs/toolkit").ActionCreatorWithPayload<Pick<ToolbarState, "isImageSelected" | "selectedImageAspectRatioLocked" | "selectedImageAlignment" | "selectedImageAltText" | "selectedImageBorderEnabled" | "selectedImageBorderRadius" | "selectedImageCaption" | "selectedImageHeight" | "selectedImageKey" | "selectedImageLinkUrl" | "selectedImageObjectFit" | "selectedImageRotation" | "selectedImageShadowEnabled" | "selectedImageTextWrap" | "selectedImageWidth">, "toolbar/setImageFormats">, setStyleFormats: import("@reduxjs/toolkit").ActionCreatorWithPayload<Pick<ToolbarState, "backgroundColor" | "fontFamily" | "fontSize" | "lineHeight" | "textColor">, "toolbar/setStyleFormats">, setTableFormats: import("@reduxjs/toolkit").ActionCreatorWithPayload<Pick<ToolbarState, "isInTable" | "selectedTableCellsCount" | "tableCellBackgroundColor" | "tableCellVerticalAlign" | "tableHasMergedCell">, "toolbar/setTableFormats">, setTextFormats: import("@reduxjs/toolkit").ActionCreatorWithPayload<Pick<ToolbarState, "isBold" | "isItalic" | "isStrikethrough" | "isSubscript" | "isSuperscript" | "isUnderline">, "toolbar/setTextFormats">;
2
+ export declare const setBlockFormats: import("@reduxjs/toolkit").ActionCreatorWithPayload<Pick<ToolbarState, "alignment" | "listType">, "toolbar/setBlockFormats">, setCanRedo: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, "toolbar/setCanRedo">, setCanUndo: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, "toolbar/setCanUndo">, setEquationFormats: import("@reduxjs/toolkit").ActionCreatorWithPayload<Pick<ToolbarState, "isEquationSelected" | "selectedEquation" | "selectedEquationDisplayMode" | "selectedEquationKey">, "toolbar/setEquationFormats">, setImageFormats: import("@reduxjs/toolkit").ActionCreatorWithPayload<Pick<ToolbarState, "isImageSelected" | "selectedImageAspectRatioLocked" | "selectedImageAlignment" | "selectedImageAltText" | "selectedImageBorderEnabled" | "selectedImageBorderRadius" | "selectedImageCaption" | "selectedImageHeight" | "selectedImageKey" | "selectedImageLinkUrl" | "selectedImageObjectFit" | "selectedImageRotation" | "selectedImageShadowEnabled" | "selectedImageTextWrap" | "selectedImageWidth">, "toolbar/setImageFormats">, setStyleFormats: import("@reduxjs/toolkit").ActionCreatorWithPayload<Pick<ToolbarState, "backgroundColor" | "fontFamily" | "fontSize" | "lineHeight" | "textColor">, "toolbar/setStyleFormats">, setTableFormats: import("@reduxjs/toolkit").ActionCreatorWithPayload<Pick<ToolbarState, "isInTable" | "selectedTableCellsCount" | "tableCellBackgroundColor" | "tableCellVerticalAlign" | "tableHasMergedCell">, "toolbar/setTableFormats">, setTextFormats: import("@reduxjs/toolkit").ActionCreatorWithPayload<Pick<ToolbarState, "isBold" | "isCode" | "isItalic" | "isStrikethrough" | "isSubscript" | "isSuperscript" | "isUnderline">, "toolbar/setTextFormats">;
3
3
  export declare const toolbarReducer: import("redux").Reducer<ToolbarState>;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import type { ResolvedRJEditorTheme } from '../types/index';
3
+ export declare const RJEditorThemeContext: React.Context<ResolvedRJEditorTheme>;
@@ -0,0 +1,3 @@
1
+ import { type ThemeConfig } from 'antd';
2
+ import type { ResolvedRJEditorTheme } from '../types/index';
3
+ export declare function getAntdThemeConfig(theme: ResolvedRJEditorTheme): ThemeConfig;
@@ -0,0 +1,4 @@
1
+ export { getAntdThemeConfig } from './getAntdThemeConfig';
2
+ export { RJEditorThemeContext } from './RJEditorThemeContext';
3
+ export { useRJEditorTheme } from './useRJEditorTheme';
4
+ export { useResolvedRJEditorTheme } from './useResolvedRJEditorTheme';
@@ -0,0 +1 @@
1
+ export declare function useRJEditorTheme(): import("../types").ResolvedRJEditorTheme;
@@ -0,0 +1,2 @@
1
+ import type { RJEditorTheme, ResolvedRJEditorTheme } from '../types/index';
2
+ export declare function useResolvedRJEditorTheme(theme: RJEditorTheme): ResolvedRJEditorTheme;
@@ -0,0 +1,73 @@
1
+ export type EquationTextModel = {
2
+ kind: 'text';
3
+ value: string;
4
+ };
5
+ export type EquationRowModel = {
6
+ items: EquationModel[];
7
+ kind: 'row';
8
+ };
9
+ export type EquationFractionModel = {
10
+ denominator: EquationSlotValue;
11
+ kind: 'fraction';
12
+ numerator: EquationSlotValue;
13
+ variant?: 'linear' | 'skewed' | 'stacked';
14
+ };
15
+ export type EquationScriptModel = {
16
+ base: EquationSlotValue;
17
+ kind: 'script';
18
+ position?: 'after' | 'before';
19
+ subscript?: EquationSlotValue;
20
+ superscript?: EquationSlotValue;
21
+ };
22
+ export type EquationRootModel = {
23
+ index?: EquationSlotValue;
24
+ kind: 'root';
25
+ value: EquationSlotValue;
26
+ };
27
+ export type EquationIntegralModel = {
28
+ body: EquationSlotValue;
29
+ kind: 'integral';
30
+ lower?: EquationSlotValue;
31
+ upper?: EquationSlotValue;
32
+ variable: EquationSlotValue;
33
+ variant?: 'contour' | 'double' | 'single' | 'triple';
34
+ };
35
+ export type EquationLargeOperatorModel = {
36
+ body: EquationSlotValue;
37
+ kind: 'largeOperator';
38
+ lower?: EquationSlotValue;
39
+ operator: 'intersection' | 'product' | 'summation' | 'union';
40
+ upper?: EquationSlotValue;
41
+ };
42
+ export type EquationLimitModel = {
43
+ body: EquationSlotValue;
44
+ kind: 'limit';
45
+ target: EquationSlotValue;
46
+ };
47
+ export type EquationBracketModel = {
48
+ bracket: 'absolute' | 'angle' | 'brace' | 'ceiling' | 'doubleAbsolute' | 'floor' | 'parenthesis' | 'square';
49
+ kind: 'bracket';
50
+ separator?: boolean;
51
+ value: EquationSlotValue;
52
+ };
53
+ export type EquationFunctionModel = {
54
+ argument: EquationSlotValue;
55
+ functionName: 'arccos' | 'arcsin' | 'arctan' | 'cos' | 'cosh' | 'cot' | 'coth' | 'csc' | 'ln' | 'log' | 'sec' | 'sin' | 'sinh' | 'tan' | 'tanh';
56
+ kind: 'function';
57
+ };
58
+ export type EquationAccentModel = {
59
+ accent: 'bar' | 'dot' | 'doubleDot' | 'hat' | 'vector';
60
+ kind: 'accent';
61
+ value: EquationSlotValue;
62
+ };
63
+ export type EquationMatrixModel = {
64
+ bracket: 'determinant' | 'none' | 'round' | 'square';
65
+ cells: EquationSlotValue[][];
66
+ kind: 'matrix';
67
+ };
68
+ export type EquationOperatorModel = {
69
+ kind: 'operator';
70
+ value: string;
71
+ };
72
+ export type EquationModel = EquationAccentModel | EquationBracketModel | EquationFractionModel | EquationFunctionModel | EquationIntegralModel | EquationLargeOperatorModel | EquationLimitModel | EquationMatrixModel | EquationOperatorModel | EquationRowModel | EquationRootModel | EquationScriptModel | EquationTextModel;
73
+ export type EquationSlotValue = EquationModel | string;
@@ -0,0 +1,4 @@
1
+ export type InsertCodeBlockPayload = {
2
+ code?: string;
3
+ language: string;
4
+ };
@@ -0,0 +1 @@
1
+ export type RJEditorTheme = 'auto' | 'dark' | 'light';
@@ -25,6 +25,13 @@ export type RJEditorTranslations = {
25
25
  left: string;
26
26
  right: string;
27
27
  };
28
+ codeBlock: {
29
+ code: string;
30
+ codePlaceholder: string;
31
+ copied: string;
32
+ copy: string;
33
+ language: string;
34
+ };
28
35
  fullscreen: {
29
36
  close: string;
30
37
  open: string;
@@ -62,6 +69,7 @@ export type RJEditorTranslations = {
62
69
  width: string;
63
70
  };
64
71
  insert: {
72
+ codeBlock: string;
65
73
  equation: string;
66
74
  horizontalLine: string;
67
75
  image: string;
@@ -156,6 +164,7 @@ export type RJEditorTranslations = {
156
164
  };
157
165
  textFormat: {
158
166
  bold: string;
167
+ code: string;
159
168
  italic: string;
160
169
  strikethrough: string;
161
170
  subscript: string;
@@ -0,0 +1,2 @@
1
+ import type { RJEditorTheme } from './RJEditorTheme';
2
+ export type ResolvedRJEditorTheme = Exclude<RJEditorTheme, 'auto'>;
@@ -13,6 +13,7 @@ export type ToolbarState = {
13
13
  fontSize?: string;
14
14
  isEquationSelected: boolean;
15
15
  isBold: boolean;
16
+ isCode: boolean;
16
17
  isImageSelected: boolean;
17
18
  isItalic: boolean;
18
19
  isStrikethrough: boolean;
@@ -1,15 +1,19 @@
1
1
  export type { AppDispatch } from './AppDispatch';
2
2
  export type { DeepPartial } from './DeepPartial';
3
3
  export type { EquationDisplayMode } from './EquationDisplayMode';
4
+ export type { EquationModel, EquationSlotValue } from './EquationModel';
4
5
  export type { ImageAlignment } from './ImageAlignment';
5
6
  export type { ImageObjectFit } from './ImageObjectFit';
6
7
  export type { ImageTextWrap } from './ImageTextWrap';
8
+ export type { InsertCodeBlockPayload } from './InsertCodeBlockPayload';
7
9
  export type { InsertImagePayload } from './InsertImagePayload';
8
10
  export type { InsertEquationPayload } from './InsertEquationPayload';
9
11
  export type { InsertYouTubePayload } from './InsertYouTubePayload';
10
12
  export type { RJEditorLocaleCode } from './RJEditorLocaleCode';
13
+ export type { RJEditorTheme } from './RJEditorTheme';
11
14
  export type { RJEditorTranslations } from './RJEditorTranslations';
12
15
  export type { RJTextEditorValue } from './RJTextEditorValue';
16
+ export type { ResolvedRJEditorTheme } from './ResolvedRJEditorTheme';
13
17
  export type { RootState } from './RootState';
14
18
  export type { SerializedEquationNode } from './SerializedEquationNode';
15
19
  export type { SerializedImageNode } from './SerializedImageNode';
@@ -0,0 +1,12 @@
1
+ import type { EquationModel } from '../../types/index';
2
+ type EquationTextSelection = {
3
+ end: number;
4
+ start: number;
5
+ };
6
+ type AppendTextToEquationModelSlotResult = {
7
+ activeSlotId: string;
8
+ model: EquationModel;
9
+ selection: EquationTextSelection;
10
+ };
11
+ export declare function appendTextToEquationModelSlot(model: EquationModel, slotId: string, text: string, selection?: EquationTextSelection): AppendTextToEquationModelSlotResult;
12
+ export {};
@@ -0,0 +1 @@
1
+ export declare function copyTextToClipboard(text: string): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import type { EquationModel } from '../../types/index';
2
+ export declare function decodeEquationValue(value: string): EquationModel | null;
@@ -0,0 +1,2 @@
1
+ import type { EquationModel } from '../../types/index';
2
+ export declare function encodeEquationModel(model: EquationModel): string;
@@ -0,0 +1 @@
1
+ export declare const EQUATION_MODEL_PREFIX = "rj-equation-model:";
@@ -0,0 +1 @@
1
+ export declare function escapeHtml(value: string): string;
@@ -0,0 +1,2 @@
1
+ import type { EquationModel, EquationSlotValue } from '../../types/index';
2
+ export declare function getEquationModelSlotValue(model: EquationModel, slotId: string): EquationSlotValue;
@@ -0,0 +1,2 @@
1
+ import type { EquationModel } from '../../types/index';
2
+ export declare function getFirstEquationSlotId(model: EquationModel): string;
@@ -1,13 +1,27 @@
1
+ export { appendTextToEquationModelSlot } from './appendTextToEquationModelSlot';
1
2
  export { clampValue } from './clampValue';
3
+ export { copyTextToClipboard } from './copyTextToClipboard';
4
+ export { decodeEquationValue } from './decodeEquationValue';
5
+ export { encodeEquationModel } from './encodeEquationModel';
6
+ export { escapeHtml } from './escapeHtml';
2
7
  export { formatNumberText } from './formatNumberText';
3
8
  export { formatShortcutTitle } from './formatShortcutTitle';
9
+ export { getEquationModelSlotValue } from './getEquationModelSlotValue';
10
+ export { getFirstEquationSlotId } from './getFirstEquationSlotId';
4
11
  export { getYouTubeVideoId } from './getYouTubeVideoId';
12
+ export { insertEquationModelIntoSlot } from './insertEquationModelIntoSlot';
5
13
  export { isApplePlatform } from './isApplePlatform';
14
+ export { isVisualEquationValue } from './isVisualEquationValue';
6
15
  export { normalizeNumberText } from './normalizeNumberText';
16
+ export { normalizeEditorFontFamily } from './normalizeEditorFontFamily';
17
+ export { normalizeEditorFontSize } from './normalizeEditorFontSize';
7
18
  export { normalizeRJEditorHtml } from './normalizeRJEditorHtml';
8
19
  export { numberToInputText } from './numberToInputText';
9
20
  export { openFilePicker } from './openFilePicker';
10
21
  export { pxToRem } from './pxToRem';
11
22
  export { readFileAsDataUrl } from './readFileAsDataUrl';
23
+ export { registerCodeBlockCopyHandler } from './registerCodeBlockCopyHandler';
24
+ export { renderEquationModelToHtml } from './renderEquationModelToHtml';
12
25
  export { renderEquationToHtml } from './renderEquationToHtml';
13
26
  export { setEditorHtml } from './setEditorHtml';
27
+ export { updateEquationModelSlot } from './updateEquationModelSlot';
@@ -0,0 +1,11 @@
1
+ import type { EquationModel } from '../../types/index';
2
+ type EquationTextSelection = {
3
+ end: number;
4
+ start: number;
5
+ };
6
+ type InsertEquationModelIntoSlotResult = {
7
+ activeSlotId: string;
8
+ model: EquationModel;
9
+ };
10
+ export declare function insertEquationModelIntoSlot(model: EquationModel, slotId: string, insertedModel: EquationModel, selection?: EquationTextSelection): InsertEquationModelIntoSlotResult;
11
+ export {};
@@ -0,0 +1 @@
1
+ export declare function isVisualEquationValue(value: string): boolean;
@@ -0,0 +1 @@
1
+ export declare function normalizeEditorFontFamily(fontFamily?: string): string | undefined;
@@ -0,0 +1 @@
1
+ export declare function normalizeEditorFontSize(fontSize?: string): string | undefined;
@@ -0,0 +1,5 @@
1
+ export type EquationRowInsertSlotId = {
2
+ insertIndex: number;
3
+ rowSlotId: string;
4
+ };
5
+ export declare function parseEquationRowInsertSlotId(slotId: string): EquationRowInsertSlotId | null;
@@ -0,0 +1 @@
1
+ export declare function registerCodeBlockCopyHandler(): void;
@@ -0,0 +1,2 @@
1
+ import type { EquationModel } from '../../types/index';
2
+ export declare function renderEquationModelToHtml(model: EquationModel): string;
@@ -0,0 +1,2 @@
1
+ import type { EquationModel, EquationSlotValue } from '../../types/index';
2
+ export declare function updateEquationModelSlot(model: EquationModel, slotId: string, value: EquationSlotValue): EquationModel;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rj-editor",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "description": "React rich text editor: toolbar tabs, table, image, link, YouTube, i18n, theme va Ant Design Form integratsiyasi.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -55,6 +55,7 @@
55
55
  "preview": "vite preview"
56
56
  },
57
57
  "dependencies": {
58
+ "@lexical/code": "^0.44.0",
58
59
  "@lexical/history": "^0.44.0",
59
60
  "@lexical/html": "^0.44.0",
60
61
  "@lexical/link": "^0.44.0",
@@ -1,33 +0,0 @@
1
- export declare const EQUATION_STRUCTURES: readonly [{
2
- readonly label: "Fraction";
3
- readonly snippet: "rj-equation:fraction";
4
- readonly value: string;
5
- }, {
6
- readonly label: "Script";
7
- readonly snippet: string;
8
- readonly value: string;
9
- }, {
10
- readonly label: "Radical";
11
- readonly snippet: string;
12
- readonly value: string;
13
- }, {
14
- readonly label: "Integral";
15
- readonly snippet: string;
16
- readonly value: string;
17
- }, {
18
- readonly label: "Large operator";
19
- readonly snippet: string;
20
- readonly value: string;
21
- }, {
22
- readonly label: "Bracket";
23
- readonly snippet: string;
24
- readonly value: string;
25
- }, {
26
- readonly label: "Matrix";
27
- readonly snippet: string;
28
- readonly value: string;
29
- }, {
30
- readonly label: "Chemistry";
31
- readonly snippet: string;
32
- readonly value: string;
33
- }];