syntaxic-react-editor 1.0.1 → 1.0.2
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/dist/src/components/WordEditor/WordEditor.d.ts +4 -0
- package/dist/src/components/WordEditor/index.d.ts +3 -0
- package/dist/src/components/WordEditor/ribbon/components/ColorPicker.d.ts +12 -0
- package/dist/src/components/WordEditor/ribbon/components/ToolbarButton.d.ts +9 -0
- package/dist/src/components/WordEditor/ribbon/tabs/FileTab.d.ts +19 -0
- package/dist/src/components/WordEditor/ribbon/tabs/HelpTab.d.ts +1 -0
- package/dist/src/components/WordEditor/ribbon/tabs/HomeTab.d.ts +28 -0
- package/dist/src/components/WordEditor/ribbon/tabs/InsertTab.d.ts +28 -0
- package/dist/src/components/WordEditor/ribbon/tabs/LayoutTab.d.ts +17 -0
- package/dist/src/components/WordEditor/ribbon/tabs/PictureFormatTab.d.ts +9 -0
- package/dist/src/components/WordEditor/ribbon/tabs/TableLayoutTab.d.ts +8 -0
- package/dist/src/components/WordEditor/types.d.ts +127 -0
- package/dist/src/components/WordEditor/utils/tableActions.d.ts +6 -0
- package/dist/src/index.d.ts +3 -0
- package/package.json +3 -3
- package/dist/index.d.ts +0 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
interface ColorPickerProps {
|
|
3
|
+
label: string;
|
|
4
|
+
icon: React.ReactNode;
|
|
5
|
+
onSelect: (color: string | null) => void;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
onOpen?: () => void;
|
|
8
|
+
variant?: 'big' | 'compact';
|
|
9
|
+
activeColor?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const ColorPicker: React.FC<ColorPickerProps>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { default as React, HTMLAttributes } from 'react';
|
|
2
|
+
export interface ToolbarButtonProps extends HTMLAttributes<HTMLButtonElement> {
|
|
3
|
+
icon: React.ReactNode;
|
|
4
|
+
title: string;
|
|
5
|
+
isActive?: boolean;
|
|
6
|
+
label?: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const ToolbarButton: React.FC<ToolbarButtonProps>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ActiveStyles, WordEditorPlugin, CommandExec } from '../../types';
|
|
3
|
+
export interface FileTabProps {
|
|
4
|
+
onSave: () => void;
|
|
5
|
+
onSaveAsDocs: () => void;
|
|
6
|
+
onPrint: () => void;
|
|
7
|
+
toggleHtmlView: () => void;
|
|
8
|
+
activeStyles: ActiveStyles;
|
|
9
|
+
showHtml: boolean;
|
|
10
|
+
execCommand: CommandExec;
|
|
11
|
+
onImportWord?: () => void;
|
|
12
|
+
pluginContributions?: WordEditorPlugin['ribbonContributions'];
|
|
13
|
+
fonts: string[];
|
|
14
|
+
sizes: {
|
|
15
|
+
label: string;
|
|
16
|
+
value: string;
|
|
17
|
+
}[];
|
|
18
|
+
}
|
|
19
|
+
export declare const FileTab: React.FC<FileTabProps>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function HelpTab(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { WordEditorPlugin, ActiveStyles, ParagraphOptions, FontOptions, ClipboardOptions, EditingOptions, CommandExec } from '../../types';
|
|
3
|
+
export interface HomeTabProps {
|
|
4
|
+
showHtml: boolean;
|
|
5
|
+
execCommand: CommandExec;
|
|
6
|
+
activeStyles: ActiveStyles;
|
|
7
|
+
fontConf: FontOptions | false;
|
|
8
|
+
paragraphConf: ParagraphOptions | false;
|
|
9
|
+
changeLineSpacing: (spacing: string) => void;
|
|
10
|
+
changeListStyleType: (type: string) => void;
|
|
11
|
+
clipboardConf: ClipboardOptions | false;
|
|
12
|
+
handlePaste: () => void;
|
|
13
|
+
toggleHtmlView: () => void;
|
|
14
|
+
saveSelection: () => void;
|
|
15
|
+
onOpenFind?: () => void;
|
|
16
|
+
onOpenReplace?: () => void;
|
|
17
|
+
editingConf: EditingOptions | false;
|
|
18
|
+
pluginContributions?: WordEditorPlugin['ribbonContributions'];
|
|
19
|
+
toggleSelectionLock?: () => void;
|
|
20
|
+
fonts: string[];
|
|
21
|
+
sizes: {
|
|
22
|
+
label: string;
|
|
23
|
+
value: string;
|
|
24
|
+
}[];
|
|
25
|
+
openTextColorPicker?: () => void;
|
|
26
|
+
openHighlightColorPicker?: () => void;
|
|
27
|
+
}
|
|
28
|
+
export declare const HomeTab: React.FC<HomeTabProps>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { default as React, Dispatch, SetStateAction } from 'react';
|
|
2
|
+
export interface InsertTabProps {
|
|
3
|
+
showHtml: boolean;
|
|
4
|
+
tableConf: boolean;
|
|
5
|
+
tableMenuRef: React.RefObject<HTMLDivElement | null>;
|
|
6
|
+
isTableMenuOpen: boolean;
|
|
7
|
+
setIsTableMenuOpen: Dispatch<SetStateAction<boolean>>;
|
|
8
|
+
tableGridSize: {
|
|
9
|
+
r: number;
|
|
10
|
+
c: number;
|
|
11
|
+
};
|
|
12
|
+
setTableGridSize: Dispatch<SetStateAction<{
|
|
13
|
+
r: number;
|
|
14
|
+
c: number;
|
|
15
|
+
}>>;
|
|
16
|
+
handleInsertTable: (r: number, c: number) => void;
|
|
17
|
+
mediaConf: boolean;
|
|
18
|
+
imageInputRef: React.RefObject<HTMLInputElement | null>;
|
|
19
|
+
linkConf: boolean;
|
|
20
|
+
execCommand: (cmd: string, val?: string) => void;
|
|
21
|
+
savedRangeRef: React.MutableRefObject<Range | null>;
|
|
22
|
+
saveSelection: () => void;
|
|
23
|
+
isLinkMenuOpen: boolean;
|
|
24
|
+
setIsLinkMenuOpen: Dispatch<SetStateAction<boolean>>;
|
|
25
|
+
linkUrl: string;
|
|
26
|
+
setLinkUrl: Dispatch<SetStateAction<string>>;
|
|
27
|
+
}
|
|
28
|
+
export declare const InsertTab: React.FC<InsertTabProps>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export interface LayoutTabProps {
|
|
3
|
+
showHtml: boolean;
|
|
4
|
+
inputIndentLeft: string;
|
|
5
|
+
setInputIndentLeft: (val: string) => void;
|
|
6
|
+
inputIndentRight: string;
|
|
7
|
+
setInputIndentRight: (val: string) => void;
|
|
8
|
+
applyIndent: (side: 'left' | 'right', val: number) => void;
|
|
9
|
+
inputSpacingBefore: string;
|
|
10
|
+
setInputSpacingBefore: (val: string) => void;
|
|
11
|
+
inputSpacingAfter: string;
|
|
12
|
+
setInputSpacingAfter: (val: string) => void;
|
|
13
|
+
applySpacing: (side: 'before' | 'after', val: number) => void;
|
|
14
|
+
insertPageBreak: () => void;
|
|
15
|
+
pagesConf: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare const LayoutTab: React.FC<LayoutTabProps>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export interface PictureFormatTabProps {
|
|
3
|
+
showHtml: boolean;
|
|
4
|
+
activeImage: HTMLElement | null;
|
|
5
|
+
imageWidth: number;
|
|
6
|
+
handleImageWidthChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
7
|
+
handleImageAction: (action: string) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const PictureFormatTab: React.FC<PictureFormatTabProps>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export interface TableLayoutTabProps {
|
|
3
|
+
showHtml: boolean;
|
|
4
|
+
activeTableCell: HTMLElement | null;
|
|
5
|
+
handleTableAction: (action: string, value?: string | number) => void;
|
|
6
|
+
saveSelection: () => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const TableLayoutTab: React.FC<TableLayoutTabProps>;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Konfigurasi Detail untuk setiap Grup Toolbar
|
|
3
|
+
*/
|
|
4
|
+
export interface ClipboardOptions {
|
|
5
|
+
[key: string]: boolean | undefined;
|
|
6
|
+
paste?: boolean;
|
|
7
|
+
cut?: boolean;
|
|
8
|
+
copy?: boolean;
|
|
9
|
+
undo?: boolean;
|
|
10
|
+
redo?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface FontOptions {
|
|
13
|
+
[key: string]: boolean | undefined;
|
|
14
|
+
family?: boolean;
|
|
15
|
+
size?: boolean;
|
|
16
|
+
bold?: boolean;
|
|
17
|
+
italic?: boolean;
|
|
18
|
+
underline?: boolean;
|
|
19
|
+
strikeThrough?: boolean;
|
|
20
|
+
subscript?: boolean;
|
|
21
|
+
superscript?: boolean;
|
|
22
|
+
highlight?: boolean;
|
|
23
|
+
color?: boolean;
|
|
24
|
+
clear?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface ParagraphOptions {
|
|
27
|
+
[key: string]: boolean | undefined;
|
|
28
|
+
bullets?: boolean;
|
|
29
|
+
numbering?: boolean;
|
|
30
|
+
outdent?: boolean;
|
|
31
|
+
indent?: boolean;
|
|
32
|
+
alignLeft?: boolean;
|
|
33
|
+
alignCenter?: boolean;
|
|
34
|
+
alignRight?: boolean;
|
|
35
|
+
alignJustify?: boolean;
|
|
36
|
+
lineSpacing?: boolean;
|
|
37
|
+
blockquote?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface EditingOptions {
|
|
40
|
+
[key: string]: boolean | undefined;
|
|
41
|
+
find?: boolean;
|
|
42
|
+
replace?: boolean;
|
|
43
|
+
lock?: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface ToolbarOptions {
|
|
46
|
+
clipboard?: boolean | ClipboardOptions;
|
|
47
|
+
font?: boolean | FontOptions;
|
|
48
|
+
paragraph?: boolean | ParagraphOptions;
|
|
49
|
+
editing?: boolean | EditingOptions;
|
|
50
|
+
table?: boolean;
|
|
51
|
+
link?: boolean;
|
|
52
|
+
media?: boolean;
|
|
53
|
+
pages?: boolean;
|
|
54
|
+
code?: boolean;
|
|
55
|
+
}
|
|
56
|
+
export interface ActiveStyles {
|
|
57
|
+
bold: boolean;
|
|
58
|
+
italic: boolean;
|
|
59
|
+
underline: boolean;
|
|
60
|
+
strikeThrough: boolean;
|
|
61
|
+
insertUnorderedList: boolean;
|
|
62
|
+
insertOrderedList: boolean;
|
|
63
|
+
justifyLeft: boolean;
|
|
64
|
+
justifyCenter: boolean;
|
|
65
|
+
justifyRight: boolean;
|
|
66
|
+
justifyFull: boolean;
|
|
67
|
+
fontSize: string;
|
|
68
|
+
fontName: string;
|
|
69
|
+
subscript: boolean;
|
|
70
|
+
superscript: boolean;
|
|
71
|
+
[key: string]: boolean | string;
|
|
72
|
+
}
|
|
73
|
+
export type CommandExec = (command: string, value?: string | null) => void;
|
|
74
|
+
export interface WordEditorPlugin {
|
|
75
|
+
id: string;
|
|
76
|
+
name: string;
|
|
77
|
+
ribbonContributions?: {
|
|
78
|
+
tabId: 'Home' | 'Insert' | 'Layout' | 'TableLayout' | 'PictureFormat' | 'File' | 'Help';
|
|
79
|
+
groupId?: 'clipboard' | 'font' | 'paragraph' | 'insert' | 'editing' | 'custom';
|
|
80
|
+
component: React.ComponentType<{
|
|
81
|
+
execCommand: CommandExec;
|
|
82
|
+
activeStyles: ActiveStyles;
|
|
83
|
+
showHtml: boolean;
|
|
84
|
+
toggleHtmlView?: () => void;
|
|
85
|
+
onOpenFind?: () => void;
|
|
86
|
+
onOpenReplace?: () => void;
|
|
87
|
+
onImportWord?: () => void;
|
|
88
|
+
toggleSelectionLock?: () => void;
|
|
89
|
+
fonts?: string[];
|
|
90
|
+
sizes?: {
|
|
91
|
+
label: string;
|
|
92
|
+
value: string;
|
|
93
|
+
}[];
|
|
94
|
+
saveSelection?: () => void;
|
|
95
|
+
openTextColorPicker?: () => void;
|
|
96
|
+
openHighlightColorPicker?: () => void;
|
|
97
|
+
fontConf?: FontOptions | false;
|
|
98
|
+
paragraphConf?: ParagraphOptions | false;
|
|
99
|
+
clipboardConf?: ClipboardOptions | false;
|
|
100
|
+
editingConf?: EditingOptions | false;
|
|
101
|
+
}>;
|
|
102
|
+
}[];
|
|
103
|
+
}
|
|
104
|
+
export interface WordEditorProps {
|
|
105
|
+
initialHTML?: string;
|
|
106
|
+
onChange?: (html: string) => void;
|
|
107
|
+
onSave?: (html: string) => void;
|
|
108
|
+
toolbarOptions?: ToolbarOptions;
|
|
109
|
+
height?: string;
|
|
110
|
+
className?: string;
|
|
111
|
+
initialPaddingLeft?: number;
|
|
112
|
+
initialPaddingRight?: number;
|
|
113
|
+
initialIndentLeft?: number;
|
|
114
|
+
initialIndentRight?: number;
|
|
115
|
+
initialLineSpacing?: string;
|
|
116
|
+
initialSpacingBefore?: number;
|
|
117
|
+
initialSpacingAfter?: number;
|
|
118
|
+
plugins?: WordEditorPlugin[];
|
|
119
|
+
}
|
|
120
|
+
export interface SearchResult {
|
|
121
|
+
text: string;
|
|
122
|
+
context: string;
|
|
123
|
+
node: Node;
|
|
124
|
+
start: number;
|
|
125
|
+
end: number;
|
|
126
|
+
fullContent?: string;
|
|
127
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type TableAction = 'insertRowAbove' | 'insertRowBelow' | 'insertColLeft' | 'insertColRight' | 'deleteRow' | 'deleteCol' | 'deleteTable' | 'mergeRight' | 'mergeDown' | 'splitCell' | 'mergeCells' | 'alignTop' | 'alignMiddle' | 'alignBottom' | 'justifyLeft' | 'justifyCenter' | 'justifyRight' | 'justifyFull' | 'cellColor' | 'cellBorder' | 'cellPadding' | 'borderTop' | 'borderBottom' | 'borderLeft' | 'borderRight' | 'borderAll' | 'borderNone' | 'paddingTopPlus' | 'paddingTopMinus' | 'paddingTopSet' | 'paddingBottomPlus' | 'paddingBottomMinus' | 'paddingBottomSet' | 'paddingLeftPlus' | 'paddingLeftMinus' | 'paddingLeftSet' | 'paddingRightPlus' | 'paddingRightMinus' | 'paddingRightSet';
|
|
2
|
+
export declare function executeTableAction(action: TableAction | string, activeTableCell: HTMLElement | null, value?: string | number, callbacks?: {
|
|
3
|
+
onTableDeleted?: () => void;
|
|
4
|
+
onContentChanged?: () => void;
|
|
5
|
+
onFocusRequested?: () => void;
|
|
6
|
+
}): void;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { default } from './components/WordEditor/WordEditor';
|
|
2
|
+
export { ColorPicker } from './components/WordEditor/ribbon/components/ColorPicker';
|
|
3
|
+
export type { WordEditorProps, ToolbarOptions, ClipboardOptions, FontOptions, ParagraphOptions, EditingOptions, WordEditorPlugin, ActiveStyles } from './components/WordEditor/types';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "syntaxic-react-editor",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "A powerful and customizable Microsoft Word-like editor for React.",
|
|
5
5
|
"author": "Syntaxic Labs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
],
|
|
22
22
|
"main": "./dist/index.umd.cjs",
|
|
23
23
|
"module": "./dist/index.js",
|
|
24
|
-
"types": "./dist/index.d.ts",
|
|
24
|
+
"types": "./dist/src/index.d.ts",
|
|
25
25
|
"exports": {
|
|
26
26
|
".": {
|
|
27
27
|
"import": "./dist/index.js",
|
|
28
28
|
"require": "./dist/index.umd.cjs",
|
|
29
|
-
"types": "./dist/index.d.ts"
|
|
29
|
+
"types": "./dist/src/index.d.ts"
|
|
30
30
|
},
|
|
31
31
|
"./style.css": "./dist/style.css"
|
|
32
32
|
},
|
package/dist/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { }
|