@iyio/rtxt 0.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/esm/package.json +3 -0
- package/esm/src/index.d.ts +9 -0
- package/esm/src/index.js +10 -0
- package/esm/src/index.js.map +1 -0
- package/esm/src/lib/RTxtEditor.d.ts +47 -0
- package/esm/src/lib/RTxtEditor.js +635 -0
- package/esm/src/lib/RTxtEditor.js.map +1 -0
- package/esm/src/lib/RTxtRenderer.d.ts +32 -0
- package/esm/src/lib/RTxtRenderer.js +370 -0
- package/esm/src/lib/RTxtRenderer.js.map +1 -0
- package/esm/src/lib/rtxt-descriptors.d.ts +2 -0
- package/esm/src/lib/rtxt-descriptors.js +92 -0
- package/esm/src/lib/rtxt-descriptors.js.map +1 -0
- package/esm/src/lib/rtxt-icons.d.ts +11 -0
- package/esm/src/lib/rtxt-icons.js +29 -0
- package/esm/src/lib/rtxt-icons.js.map +1 -0
- package/esm/src/lib/rtxt-internal.d.ts +10 -0
- package/esm/src/lib/rtxt-internal.js +63 -0
- package/esm/src/lib/rtxt-internal.js.map +1 -0
- package/esm/src/lib/rtxt-lib.d.ts +22 -0
- package/esm/src/lib/rtxt-lib.js +336 -0
- package/esm/src/lib/rtxt-lib.js.map +1 -0
- package/esm/src/lib/rtxt-style-editor.d.ts +2 -0
- package/esm/src/lib/rtxt-style-editor.js +131 -0
- package/esm/src/lib/rtxt-style-editor.js.map +1 -0
- package/esm/src/lib/rtxt-style-renderer.d.ts +2 -0
- package/esm/src/lib/rtxt-style-renderer.js +98 -0
- package/esm/src/lib/rtxt-style-renderer.js.map +1 -0
- package/esm/src/lib/rtxt-tool-lib.d.ts +34 -0
- package/esm/src/lib/rtxt-tool-lib.js +151 -0
- package/esm/src/lib/rtxt-tool-lib.js.map +1 -0
- package/esm/src/lib/rtxt-tools.d.ts +3 -0
- package/esm/src/lib/rtxt-tools.js +200 -0
- package/esm/src/lib/rtxt-tools.js.map +1 -0
- package/esm/src/lib/rtxt-types.d.ts +203 -0
- package/esm/src/lib/rtxt-types.js +16 -0
- package/esm/src/lib/rtxt-types.js.map +1 -0
- package/package.json +17 -0
- package/src/index.d.ts +9 -0
- package/src/index.js +13 -0
- package/src/index.js.map +1 -0
- package/src/lib/RTxtEditor.d.ts +47 -0
- package/src/lib/RTxtEditor.js +639 -0
- package/src/lib/RTxtEditor.js.map +1 -0
- package/src/lib/RTxtRenderer.d.ts +32 -0
- package/src/lib/RTxtRenderer.js +374 -0
- package/src/lib/RTxtRenderer.js.map +1 -0
- package/src/lib/rtxt-descriptors.d.ts +2 -0
- package/src/lib/rtxt-descriptors.js +96 -0
- package/src/lib/rtxt-descriptors.js.map +1 -0
- package/src/lib/rtxt-icons.d.ts +11 -0
- package/src/lib/rtxt-icons.js +33 -0
- package/src/lib/rtxt-icons.js.map +1 -0
- package/src/lib/rtxt-internal.d.ts +10 -0
- package/src/lib/rtxt-internal.js +71 -0
- package/src/lib/rtxt-internal.js.map +1 -0
- package/src/lib/rtxt-lib.d.ts +22 -0
- package/src/lib/rtxt-lib.js +356 -0
- package/src/lib/rtxt-lib.js.map +1 -0
- package/src/lib/rtxt-style-editor.d.ts +2 -0
- package/src/lib/rtxt-style-editor.js +135 -0
- package/src/lib/rtxt-style-editor.js.map +1 -0
- package/src/lib/rtxt-style-renderer.d.ts +2 -0
- package/src/lib/rtxt-style-renderer.js +102 -0
- package/src/lib/rtxt-style-renderer.js.map +1 -0
- package/src/lib/rtxt-tool-lib.d.ts +34 -0
- package/src/lib/rtxt-tool-lib.js +158 -0
- package/src/lib/rtxt-tool-lib.js.map +1 -0
- package/src/lib/rtxt-tools.d.ts +3 -0
- package/src/lib/rtxt-tools.js +205 -0
- package/src/lib/rtxt-tools.js.map +1 -0
- package/src/lib/rtxt-types.d.ts +203 -0
- package/src/lib/rtxt-types.js +19 -0
- package/src/lib/rtxt-types.js.map +1 -0
- package/src/package.json +4 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import type { RTxtEditor } from "./RTxtEditor";
|
|
2
|
+
import type { RTxtRenderer } from "./RTxtRenderer";
|
|
3
|
+
export declare const defaultRTxtNodeType = "span";
|
|
4
|
+
export declare const defaultRTxtLineElem = "p";
|
|
5
|
+
export type RTxtRenderMode = 'class' | 'inline';
|
|
6
|
+
export declare const defaultRTxtRenderMode: RTxtRenderMode;
|
|
7
|
+
export declare const rTxtIndexLookupAtt = "data-rtxt-index";
|
|
8
|
+
export declare const rTxtLineIndexAtt = "data-rtxt-line";
|
|
9
|
+
export declare const rTxtLineAlignAtt = "data-rtxt-line-align";
|
|
10
|
+
export declare const rTxtTypeAtt = "data-rtxt-type";
|
|
11
|
+
export declare const rTxtAttPrefix = "data-rtxt-att-";
|
|
12
|
+
export declare const rTxtNodeAtt = "data-rtxt-node";
|
|
13
|
+
export declare const rTxtDocAtt = "rtxt-doc";
|
|
14
|
+
export declare const rTxtIgnoreAtt = "rtxt-ignore";
|
|
15
|
+
export declare const defaultRTxtClassNamePrefix = "rtxt-";
|
|
16
|
+
export declare const defaultRTxtDocClassName = "rtxt-doc";
|
|
17
|
+
export type RTxtAlignment = 'start' | 'center' | 'end';
|
|
18
|
+
export declare const defaultRTxtAlignment: RTxtAlignment;
|
|
19
|
+
export declare const defaultRTxtChangeDelayMs = 600;
|
|
20
|
+
export interface RTxtDoc {
|
|
21
|
+
lines: (RTxtLine | RTxtNode[])[];
|
|
22
|
+
}
|
|
23
|
+
export interface RTxtLine {
|
|
24
|
+
nodes: RTxtNode[];
|
|
25
|
+
align?: RTxtAlignment;
|
|
26
|
+
atts?: Record<string, string>;
|
|
27
|
+
}
|
|
28
|
+
export interface RTxtNode {
|
|
29
|
+
/**
|
|
30
|
+
* The node's type or types
|
|
31
|
+
* @default 'span'
|
|
32
|
+
*/
|
|
33
|
+
t?: string | string[];
|
|
34
|
+
/**
|
|
35
|
+
* The text value of the node
|
|
36
|
+
*/
|
|
37
|
+
v?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Attributes of the node
|
|
40
|
+
*/
|
|
41
|
+
atts?: Record<string, string>;
|
|
42
|
+
}
|
|
43
|
+
export interface RTxtDocAndLookup {
|
|
44
|
+
doc: RTxtDoc;
|
|
45
|
+
lookup: RTxtNode[];
|
|
46
|
+
}
|
|
47
|
+
export interface RTxtEditorOptions {
|
|
48
|
+
/**
|
|
49
|
+
* Css selector, viewer or HTML element to bind the editor to.
|
|
50
|
+
*/
|
|
51
|
+
renderer?: RTxtRenderer | RTxtRenderOptions;
|
|
52
|
+
/**
|
|
53
|
+
* If true the default editor style sheet will not be inserted.
|
|
54
|
+
*/
|
|
55
|
+
useCustomStyleSheet?: boolean;
|
|
56
|
+
style?: RTxtEditorStyle;
|
|
57
|
+
/**
|
|
58
|
+
* Tools that will populate the tool menu. If undefined the tools returned from
|
|
59
|
+
* getDefaultRTxtTools will be used.
|
|
60
|
+
*/
|
|
61
|
+
tools?: RTxtTool[];
|
|
62
|
+
/**
|
|
63
|
+
* A prefix that will be added to all rendered editor classNames
|
|
64
|
+
*/
|
|
65
|
+
classPrefix?: string;
|
|
66
|
+
}
|
|
67
|
+
export interface RTxtRenderOptions {
|
|
68
|
+
/**
|
|
69
|
+
* Css selector or HTML element to bind the viewer to.
|
|
70
|
+
*/
|
|
71
|
+
target?: string | HTMLElement;
|
|
72
|
+
/**
|
|
73
|
+
* Document to render
|
|
74
|
+
*/
|
|
75
|
+
doc?: RTxtDoc;
|
|
76
|
+
/**
|
|
77
|
+
* Controls how nodes are rendered.
|
|
78
|
+
* @default = 'class'
|
|
79
|
+
*/
|
|
80
|
+
renderMode?: RTxtRenderMode;
|
|
81
|
+
/**
|
|
82
|
+
* A prefix that will be added to all rendered classNames
|
|
83
|
+
*/
|
|
84
|
+
classPrefix?: string;
|
|
85
|
+
/**
|
|
86
|
+
* A class name that is added to the root document element
|
|
87
|
+
* @default 'rtxt-doc'
|
|
88
|
+
*/
|
|
89
|
+
docClassName?: string | null;
|
|
90
|
+
descriptors?: RTxtDescriptor[];
|
|
91
|
+
/**
|
|
92
|
+
* Defines the type of element that each line is wrapped in.
|
|
93
|
+
* @default = 'p'
|
|
94
|
+
*/
|
|
95
|
+
lineElem?: string;
|
|
96
|
+
/**
|
|
97
|
+
* If true line break "br" elements are added between lines
|
|
98
|
+
*/
|
|
99
|
+
lineBreaks?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* If true the default viewer style sheet will not be inserted.
|
|
102
|
+
*/
|
|
103
|
+
useCustomStyleSheet?: boolean;
|
|
104
|
+
fontFamilies?: RTxtFontFamily[];
|
|
105
|
+
/**
|
|
106
|
+
* If true not style sheet will be generated to support the supplied fontFamilies.
|
|
107
|
+
*/
|
|
108
|
+
disableFontFamilyCss?: boolean;
|
|
109
|
+
placeholder?: string;
|
|
110
|
+
/**
|
|
111
|
+
* Number of milliseconds the delayed change event is delayed by.
|
|
112
|
+
*/
|
|
113
|
+
changeDelayMs?: number;
|
|
114
|
+
}
|
|
115
|
+
export interface RTxtDescriptor {
|
|
116
|
+
/**
|
|
117
|
+
* Used to match the descriptors to nodes using the node's t property.
|
|
118
|
+
*/
|
|
119
|
+
type: string;
|
|
120
|
+
elem: string;
|
|
121
|
+
/**
|
|
122
|
+
* If true and the node's element type is used self closing html tags are disabled.
|
|
123
|
+
*/
|
|
124
|
+
noSelfClose?: boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Class name or class names used when the render mode is set to 'class'. The default className
|
|
127
|
+
* of the node is the viewers class name prefix followed by the nodes type
|
|
128
|
+
*/
|
|
129
|
+
className?: string | string[] | ((node: RTxtNode) => string | string[] | undefined);
|
|
130
|
+
/**
|
|
131
|
+
* The inline style used when the render mode is set to 'inline'.
|
|
132
|
+
*/
|
|
133
|
+
inlineStyle?: RTxtStyleProvider;
|
|
134
|
+
/**
|
|
135
|
+
* Inline style used regardless of render mode.
|
|
136
|
+
*/
|
|
137
|
+
style?: RTxtStyleProvider;
|
|
138
|
+
remove?: (node: RTxtNode) => void;
|
|
139
|
+
priority?: number;
|
|
140
|
+
/**
|
|
141
|
+
* A node can only have 1 type for a given group.
|
|
142
|
+
*/
|
|
143
|
+
group?: string;
|
|
144
|
+
}
|
|
145
|
+
export type RTxtStyleProvider = Record<string, string | null | undefined> | ((node: RTxtNode) => Record<string, string | null | undefined>);
|
|
146
|
+
export interface RTxtSelection {
|
|
147
|
+
nodes: RTxtNode[];
|
|
148
|
+
startNode: RTxtNode;
|
|
149
|
+
startIndex: number;
|
|
150
|
+
startOffset: number;
|
|
151
|
+
endNode: RTxtNode;
|
|
152
|
+
endIndex: number;
|
|
153
|
+
endOffset: number;
|
|
154
|
+
cursorIndex: number;
|
|
155
|
+
cursorNode?: RTxtNode;
|
|
156
|
+
}
|
|
157
|
+
export interface RTxtDomSelection {
|
|
158
|
+
anchorNode: Node | null;
|
|
159
|
+
anchorOffset: number;
|
|
160
|
+
focusNode: Node | null;
|
|
161
|
+
focusOffset: number;
|
|
162
|
+
}
|
|
163
|
+
export interface RTxtEditorStyle {
|
|
164
|
+
backgroundColor?: string;
|
|
165
|
+
borderColor?: string;
|
|
166
|
+
zIndex?: number;
|
|
167
|
+
selectedColor?: string;
|
|
168
|
+
foregroundColor?: string;
|
|
169
|
+
}
|
|
170
|
+
export interface RTxtTool {
|
|
171
|
+
/**
|
|
172
|
+
* descriptor types that the tool is used with
|
|
173
|
+
*/
|
|
174
|
+
types: string[];
|
|
175
|
+
render(editor: RTxtEditor): Element | null | Element[];
|
|
176
|
+
/**
|
|
177
|
+
* Called when the current selection changes
|
|
178
|
+
* @param selection The current doc selection
|
|
179
|
+
* @param selectedDescriptors Array of descriptors that match the types of the tool which describe
|
|
180
|
+
* any currently selected characters
|
|
181
|
+
*/
|
|
182
|
+
onSelectionChange?: (toolSelection: RTxtToolSelection) => void;
|
|
183
|
+
isSelected?: (toolSelection: RTxtToolSelection) => boolean;
|
|
184
|
+
}
|
|
185
|
+
export interface RTxtToolSelection {
|
|
186
|
+
editor: RTxtEditor;
|
|
187
|
+
selection: RTxtSelection | null;
|
|
188
|
+
nodes: RTxtNode[];
|
|
189
|
+
lines: RTxtLine[];
|
|
190
|
+
descriptors: RTxtDescriptor[];
|
|
191
|
+
toolElems: Element[];
|
|
192
|
+
toolElem?: Element;
|
|
193
|
+
styleAtCursor?: CSSStyleDeclaration;
|
|
194
|
+
elemAtCursor?: Element;
|
|
195
|
+
colorAtCursor?: string;
|
|
196
|
+
sizeAtCursor?: string;
|
|
197
|
+
nodeAtCursor?: RTxtNode;
|
|
198
|
+
}
|
|
199
|
+
export interface RTxtFontFamily {
|
|
200
|
+
label: string;
|
|
201
|
+
family?: string;
|
|
202
|
+
className?: string;
|
|
203
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultRTxtChangeDelayMs = exports.defaultRTxtAlignment = exports.defaultRTxtDocClassName = exports.defaultRTxtClassNamePrefix = exports.rTxtIgnoreAtt = exports.rTxtDocAtt = exports.rTxtNodeAtt = exports.rTxtAttPrefix = exports.rTxtTypeAtt = exports.rTxtLineAlignAtt = exports.rTxtLineIndexAtt = exports.rTxtIndexLookupAtt = exports.defaultRTxtRenderMode = exports.defaultRTxtLineElem = exports.defaultRTxtNodeType = void 0;
|
|
4
|
+
exports.defaultRTxtNodeType = 'span';
|
|
5
|
+
exports.defaultRTxtLineElem = 'p';
|
|
6
|
+
exports.defaultRTxtRenderMode = 'class';
|
|
7
|
+
exports.rTxtIndexLookupAtt = 'data-rtxt-index';
|
|
8
|
+
exports.rTxtLineIndexAtt = 'data-rtxt-line';
|
|
9
|
+
exports.rTxtLineAlignAtt = 'data-rtxt-line-align';
|
|
10
|
+
exports.rTxtTypeAtt = 'data-rtxt-type';
|
|
11
|
+
exports.rTxtAttPrefix = 'data-rtxt-att-';
|
|
12
|
+
exports.rTxtNodeAtt = 'data-rtxt-node';
|
|
13
|
+
exports.rTxtDocAtt = 'rtxt-doc';
|
|
14
|
+
exports.rTxtIgnoreAtt = 'rtxt-ignore';
|
|
15
|
+
exports.defaultRTxtClassNamePrefix = 'rtxt-';
|
|
16
|
+
exports.defaultRTxtDocClassName = 'rtxt-doc';
|
|
17
|
+
exports.defaultRTxtAlignment = 'start';
|
|
18
|
+
exports.defaultRTxtChangeDelayMs = 600;
|
|
19
|
+
//# sourceMappingURL=rtxt-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rtxt-types.js","sourceRoot":"","sources":["../../../../../packages/rtxt/src/lib/rtxt-types.ts"],"names":[],"mappings":";;;AAGa,QAAA,mBAAmB,GAAC,MAAM,CAAC;AAE3B,QAAA,mBAAmB,GAAC,GAAG,CAAC;AAGxB,QAAA,qBAAqB,GAAgB,OAAO,CAAC;AAE7C,QAAA,kBAAkB,GAAC,iBAAiB,CAAC;AAErC,QAAA,gBAAgB,GAAC,gBAAgB,CAAC;AAElC,QAAA,gBAAgB,GAAC,sBAAsB,CAAC;AAExC,QAAA,WAAW,GAAC,gBAAgB,CAAC;AAE7B,QAAA,aAAa,GAAC,gBAAgB,CAAC;AAE/B,QAAA,WAAW,GAAC,gBAAgB,CAAC;AAE7B,QAAA,UAAU,GAAC,UAAU,CAAC;AAEtB,QAAA,aAAa,GAAC,aAAa,CAAC;AAE5B,QAAA,0BAA0B,GAAC,OAAO,CAAC;AAEnC,QAAA,uBAAuB,GAAC,UAAU,CAAC;AAGnC,QAAA,oBAAoB,GAAe,OAAO,CAAC;AAE3C,QAAA,wBAAwB,GAAC,GAAG,CAAC"}
|
package/src/package.json
ADDED