smartrte-react 0.3.4 → 1.0.0-beta.1
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/CHANGELOG.md +19 -0
- package/README.md +23 -0
- package/dist/adapters/domChecklistCommandBridge.d.ts +6 -0
- package/dist/adapters/domChecklistCommandBridge.js +33 -0
- package/dist/adapters/domCommandBridge.d.ts +19 -0
- package/dist/adapters/domCommandBridge.js +33 -0
- package/dist/adapters/domInlineAtomCommandBridge.d.ts +15 -0
- package/dist/adapters/domInlineAtomCommandBridge.js +205 -0
- package/dist/adapters/domInlineImageCommandBridge.d.ts +14 -0
- package/dist/adapters/domInlineImageCommandBridge.js +6 -0
- package/dist/adapters/domMoveCommandBridge.d.ts +7 -0
- package/dist/adapters/domMoveCommandBridge.js +54 -0
- package/dist/adapters/domSelectionBridge.d.ts +5 -3
- package/dist/adapters/domSelectionBridge.js +96 -44
- package/dist/adapters/domSmartDocument.d.ts +4 -4
- package/dist/adapters/domSmartDocument.js +159 -17
- package/dist/adapters/domTableCommandBridge.d.ts +61 -0
- package/dist/adapters/domTableCommandBridge.js +231 -0
- package/dist/adapters/internalFlags.d.ts +0 -8
- package/dist/adapters/internalFlags.js +0 -24
- package/dist/adapters/legacyListShadowComparator.d.ts +26 -0
- package/dist/adapters/legacyListShadowComparator.js +316 -0
- package/dist/adapters/pdfPrint.d.ts +8 -0
- package/dist/adapters/pdfPrint.js +22 -0
- package/dist/adapters/shadowMode.d.ts +3 -3
- package/dist/adapters/shadowMode.js +1 -1
- package/dist/canonicalEditorRuntime.d.ts +129 -0
- package/dist/canonicalEditorRuntime.js +331 -0
- package/dist/capabilityPresets.d.ts +27 -0
- package/dist/capabilityPresets.js +21 -0
- package/dist/collabTransport.d.ts +66 -0
- package/dist/collabTransport.js +1 -0
- package/dist/commentProvider.d.ts +24 -0
- package/dist/commentProvider.js +1 -0
- package/dist/components/CanonicalAuthorityEditor.d.ts +59 -0
- package/dist/components/CanonicalAuthorityEditor.js +1492 -0
- package/dist/components/ClassicEditorAuthority.d.ts +109 -0
- package/dist/components/ClassicEditorAuthority.js +17 -0
- package/dist/components/ColorPickerPopover.d.ts +39 -0
- package/dist/components/ColorPickerPopover.js +285 -0
- package/dist/components/CommentMarkers.d.ts +25 -0
- package/dist/components/CommentMarkers.js +105 -0
- package/dist/components/CommentThreadPanel.d.ts +26 -0
- package/dist/components/CommentThreadPanel.js +47 -0
- package/dist/components/ContextMenu.d.ts +23 -0
- package/dist/components/ContextMenu.js +141 -0
- package/dist/components/FormulaLibraryPopover.d.ts +16 -0
- package/dist/components/FormulaLibraryPopover.js +107 -0
- package/dist/components/LinkEditorPopover.d.ts +3 -1
- package/dist/components/LinkEditorPopover.js +22 -6
- package/dist/components/MediaManager.d.ts +4 -20
- package/dist/components/MediaManager.js +35 -6
- package/dist/components/MediaOverlay.d.ts +36 -0
- package/dist/components/MediaOverlay.js +163 -0
- package/dist/components/MediaPicker.d.ts +10 -0
- package/dist/components/MediaPicker.js +16 -0
- package/dist/components/SpecialCharacterPopover.d.ts +18 -0
- package/dist/components/SpecialCharacterPopover.js +99 -0
- package/dist/components/StructuralSuggestionMarkers.d.ts +20 -0
- package/dist/components/StructuralSuggestionMarkers.js +56 -0
- package/dist/components/SuggestionPanel.d.ts +26 -0
- package/dist/components/SuggestionPanel.js +33 -0
- package/dist/components/TableBorderPopover.d.ts +59 -0
- package/dist/components/TableBorderPopover.js +147 -0
- package/dist/components/TableResizeHandles.d.ts +25 -0
- package/dist/components/TableResizeHandles.js +301 -0
- package/dist/components/TableSizePickerPopover.d.ts +16 -0
- package/dist/components/TableSizePickerPopover.js +126 -0
- package/dist/components/ToolbarPrimitives.d.ts +129 -0
- package/dist/components/ToolbarPrimitives.js +146 -0
- package/dist/components/VersionHistoryPanel.d.ts +9 -0
- package/dist/components/VersionHistoryPanel.js +157 -0
- package/dist/formulaLibrary.d.ts +31 -0
- package/dist/formulaLibrary.js +90 -0
- package/dist/index.d.ts +23 -1
- package/dist/index.js +14 -1
- package/dist/mediaManagerAdapter.d.ts +12 -0
- package/dist/mediaManagerAdapter.js +34 -0
- package/dist/mediaProvider.d.ts +59 -0
- package/dist/mediaProvider.js +1 -0
- package/dist/specialCharacters.d.ts +22 -0
- package/dist/specialCharacters.js +86 -0
- package/dist/standalone/classic-editor-embed.js +19 -12
- package/dist/suggestionProvider.d.ts +17 -0
- package/dist/suggestionProvider.js +1 -0
- package/dist/theme.d.ts +1 -1
- package/dist/theme.js +161 -1
- package/dist/versionProvider.d.ts +29 -0
- package/dist/versionProvider.js +1 -0
- package/package.json +28 -14
- package/dist/adapters/coreBold.d.ts +0 -5
- package/dist/adapters/coreBold.js +0 -3
- package/dist/adapters/inlineMarkCoreExecution.d.ts +0 -9
- package/dist/adapters/inlineMarkCoreExecution.js +0 -25
- package/dist/components/ClassicEditor.d.ts +0 -66
- package/dist/components/ClassicEditor.js +0 -6617
- package/dist/standalone/editor.js +0 -841
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smartrte-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-beta.1",
|
|
4
4
|
"description": "A powerful, feature-rich Rich Text Editor for React with support for tables, mathematical formulas (LaTeX/KaTeX), and media management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./standalone/classic-editor-embed": {
|
|
15
|
+
"types": "./dist/standalone/classic-editor-embed.d.ts",
|
|
16
|
+
"import": "./dist/standalone/classic-editor-embed.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
9
19
|
"files": [
|
|
10
20
|
"dist",
|
|
11
21
|
"!dist/**/*.test.js",
|
|
12
22
|
"!dist/**/*.test.d.ts",
|
|
23
|
+
"!dist/test-harness/**",
|
|
13
24
|
"README.md",
|
|
14
25
|
"CHANGELOG.md"
|
|
15
26
|
],
|
|
@@ -41,16 +52,6 @@
|
|
|
41
52
|
},
|
|
42
53
|
"author": "Smart RTE Contributors",
|
|
43
54
|
"license": "MIT",
|
|
44
|
-
"scripts": {
|
|
45
|
-
"build": "tsc -p tsconfig.json",
|
|
46
|
-
"prepublishOnly": "npm run build",
|
|
47
|
-
"dev": "pnpm build",
|
|
48
|
-
"lint": "tsc -p tsconfig.json --noEmit",
|
|
49
|
-
"test": "vitest run --passWithNoTests",
|
|
50
|
-
"storybook": "storybook dev -p 6006",
|
|
51
|
-
"build-storybook": "storybook build",
|
|
52
|
-
"e2e": "playwright test --pass-with-no-tests"
|
|
53
|
-
},
|
|
54
55
|
"publishConfig": {
|
|
55
56
|
"access": "public"
|
|
56
57
|
},
|
|
@@ -60,16 +61,18 @@
|
|
|
60
61
|
"react-dom": ">=18"
|
|
61
62
|
},
|
|
62
63
|
"devDependencies": {
|
|
64
|
+
"@axe-core/playwright": "^4.12.1",
|
|
63
65
|
"@playwright/test": "^1.48.2",
|
|
64
66
|
"@storybook/addon-essentials": "^8.6.14",
|
|
65
67
|
"@storybook/react": "^8.6.14",
|
|
66
68
|
"@storybook/react-vite": "^8.6.14",
|
|
69
|
+
"@types/node": "^22",
|
|
67
70
|
"@types/pdfjs-dist": "^2.10.377",
|
|
68
71
|
"@types/react": "^18.3.4",
|
|
69
72
|
"@types/react-dom": "^18.3.0",
|
|
73
|
+
"jsdom": "^25.0.1",
|
|
70
74
|
"react": "18.3.1",
|
|
71
75
|
"react-dom": "18.3.1",
|
|
72
|
-
"jsdom": "^25.0.1",
|
|
73
76
|
"storybook": "^8.6.14",
|
|
74
77
|
"typescript": "^5.6.2",
|
|
75
78
|
"vite": "^5.4.8",
|
|
@@ -77,8 +80,19 @@
|
|
|
77
80
|
},
|
|
78
81
|
"dependencies": {
|
|
79
82
|
"jszip": "^3.10.1",
|
|
83
|
+
"katex": "^0.18.4",
|
|
84
|
+
"lucide-react": "^1.35.0",
|
|
80
85
|
"mammoth": "^1.11.0",
|
|
81
86
|
"pdfjs-dist": "^5.4.530",
|
|
82
|
-
"smartrte-core": "^0.
|
|
87
|
+
"smartrte-core": "^1.0.0-beta.1"
|
|
88
|
+
},
|
|
89
|
+
"scripts": {
|
|
90
|
+
"build": "rm -rf dist && tsc -p tsconfig.json",
|
|
91
|
+
"dev": "pnpm build",
|
|
92
|
+
"lint": "tsc -p tsconfig.json --noEmit",
|
|
93
|
+
"test": "vitest run --passWithNoTests",
|
|
94
|
+
"storybook": "storybook dev -p 6006",
|
|
95
|
+
"build-storybook": "storybook build",
|
|
96
|
+
"e2e": "pnpm --filter smartrte-core build && pnpm build && playwright test --pass-with-no-tests"
|
|
83
97
|
}
|
|
84
|
-
}
|
|
98
|
+
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type CoreInlineMarkResult } from "./inlineMarkCoreExecution.js";
|
|
2
|
-
export declare const isCoreBoldEnabled: () => boolean;
|
|
3
|
-
/** Executes only the core bold command. Callers own DOM writes and legacy fallback. */
|
|
4
|
-
export type CoreBoldResult = CoreInlineMarkResult;
|
|
5
|
-
export declare const getCoreBoldResult: (root: HTMLElement) => CoreBoldResult | null;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type SmartSelection } from "smartrte-core";
|
|
2
|
-
export type CoreInlineMark = "bold" | "italic" | "underline" | "superscript" | "subscript";
|
|
3
|
-
export interface CoreInlineMarkResult {
|
|
4
|
-
html: string;
|
|
5
|
-
selectionBefore: SmartSelection;
|
|
6
|
-
selectionAfter: SmartSelection;
|
|
7
|
-
}
|
|
8
|
-
export declare const isCoreInlineMarkEnabled: (mark: CoreInlineMark) => boolean;
|
|
9
|
-
export declare const getCoreInlineMarkResult: (root: HTMLElement, mark: CoreInlineMark) => CoreInlineMarkResult | null;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { applyTransaction, toggleBold, toggleItalic, toggleSubscript, toggleSuperscript, toggleUnderline, } from "smartrte-core";
|
|
2
|
-
import { selectionFromDom } from "./domSelectionBridge.js";
|
|
3
|
-
import { serializeSmartDocument, smartDocumentFromEditorRoot } from "./domSmartDocument.js";
|
|
4
|
-
import { isCoreInlineMarkFlagEnabled } from "./internalFlags.js";
|
|
5
|
-
const commands = {
|
|
6
|
-
bold: toggleBold,
|
|
7
|
-
italic: toggleItalic,
|
|
8
|
-
underline: toggleUnderline,
|
|
9
|
-
superscript: toggleSuperscript,
|
|
10
|
-
subscript: toggleSubscript,
|
|
11
|
-
};
|
|
12
|
-
export const isCoreInlineMarkEnabled = (mark) => isCoreInlineMarkFlagEnabled(mark);
|
|
13
|
-
export const getCoreInlineMarkResult = (root, mark) => {
|
|
14
|
-
const selection = selectionFromDom(root, window.getSelection());
|
|
15
|
-
if (!selection)
|
|
16
|
-
return null;
|
|
17
|
-
const { document } = smartDocumentFromEditorRoot(root);
|
|
18
|
-
const state = { document, selection };
|
|
19
|
-
const command = commands[mark];
|
|
20
|
-
if (!command.isEnabled(state))
|
|
21
|
-
return null;
|
|
22
|
-
const transaction = command.execute(state);
|
|
23
|
-
const next = applyTransaction(state, transaction);
|
|
24
|
-
return { html: serializeSmartDocument(next.document), selectionBefore: transaction.selectionBefore, selectionAfter: transaction.selectionAfter };
|
|
25
|
-
};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { MediaManagerAdapter } from "./MediaManager.js";
|
|
2
|
-
import { SrteTheme } from '../theme.js';
|
|
3
|
-
type ClassicEditorProps = {
|
|
4
|
-
value?: string;
|
|
5
|
-
onChange?: (html: string) => void;
|
|
6
|
-
placeholder?: string;
|
|
7
|
-
minHeight?: number | string;
|
|
8
|
-
maxHeight?: number | string;
|
|
9
|
-
readOnly?: boolean;
|
|
10
|
-
table?: boolean;
|
|
11
|
-
media?: boolean;
|
|
12
|
-
formula?: boolean;
|
|
13
|
-
mediaManager?: MediaManagerAdapter;
|
|
14
|
-
/**
|
|
15
|
-
* Optional custom list of fonts to display in the toolbar.
|
|
16
|
-
* If not provided, a default set of web-safe fonts will be used.
|
|
17
|
-
* Example: [{ name: 'Robto', value: 'Roboto, sans-serif' }]
|
|
18
|
-
*/
|
|
19
|
-
fonts?: {
|
|
20
|
-
name: string;
|
|
21
|
-
value: string;
|
|
22
|
-
}[];
|
|
23
|
-
/**
|
|
24
|
-
* The default font family to apply to the editor content.
|
|
25
|
-
* This sets the font-family style of the editable area.
|
|
26
|
-
* Example: "Arial, sans-serif"
|
|
27
|
-
*/
|
|
28
|
-
defaultFont?: string;
|
|
29
|
-
/**
|
|
30
|
-
* Preserve font-family styles from pasted/imported content.
|
|
31
|
-
* Defaults to false so host applications can keep a single app font while
|
|
32
|
-
* still preserving bold, italic, headings, lists, tables, and colors.
|
|
33
|
-
*/
|
|
34
|
-
preserveFontFamily?: boolean;
|
|
35
|
-
/**
|
|
36
|
-
* Preserve foreground/background colors from pasted/imported content.
|
|
37
|
-
* Defaults to false so dark-mode editors remain readable when content is
|
|
38
|
-
* copied from sources such as Google Docs with hardcoded black-on-white styles.
|
|
39
|
-
*/
|
|
40
|
-
preserveColors?: boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Preserve visual styling from imported DOCX files except font-family.
|
|
43
|
-
* This keeps Word-authored colors, spacing, borders, and table fills while
|
|
44
|
-
* still allowing the host app to control the editor font.
|
|
45
|
-
*/
|
|
46
|
-
preserveDocxStyles?: boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Theme mode for the editor.
|
|
49
|
-
* - "light" (default): Uses the built-in light theme.
|
|
50
|
-
* - "dark": Uses the built-in dark theme.
|
|
51
|
-
*/
|
|
52
|
-
theme?: SrteTheme;
|
|
53
|
-
/**
|
|
54
|
-
* Show the inline font-size dropdown in the toolbar.
|
|
55
|
-
* Defaults to true. Heading block controls are independent of this option.
|
|
56
|
-
*/
|
|
57
|
-
showFontSize?: boolean;
|
|
58
|
-
/**
|
|
59
|
-
* Additional CSS class name(s) to apply to the editor's root element.
|
|
60
|
-
* Useful for custom theming by overriding CSS custom properties.
|
|
61
|
-
* Example: className="my-editor-theme"
|
|
62
|
-
*/
|
|
63
|
-
className?: string;
|
|
64
|
-
};
|
|
65
|
-
export declare function ClassicEditor({ value, onChange, placeholder, minHeight, maxHeight, readOnly, table, media, formula, mediaManager, fonts, defaultFont, preserveFontFamily, preserveColors, preserveDocxStyles, theme, showFontSize, className, }: ClassicEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
66
|
-
export {};
|