@guardian/stand 0.0.0 → 0.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 +19 -0
- package/dist/byline/Byline.cjs +375 -0
- package/dist/byline/Byline.js +273 -0
- package/dist/byline/Preview.cjs +52 -0
- package/dist/byline/Preview.js +26 -0
- package/dist/byline/lib.cjs +240 -0
- package/dist/byline/lib.js +181 -0
- package/dist/byline/placeholder.cjs +29 -0
- package/dist/byline/placeholder.js +27 -0
- package/dist/byline/plugins.cjs +144 -0
- package/dist/byline/plugins.js +123 -0
- package/dist/byline/schema.cjs +66 -0
- package/dist/byline/schema.js +59 -0
- package/dist/byline/styles.cjs +244 -0
- package/dist/byline/styles.js +234 -0
- package/dist/index.cjs +4 -4
- package/dist/index.js +1 -5
- package/dist/types/.storybook/main.d.ts +3 -0
- package/dist/types/.storybook/preview.d.ts +3 -0
- package/dist/types/jest-setup-after-env.d.ts +1 -0
- package/dist/types/playwright/byline.mock.d.ts +3 -0
- package/dist/types/playwright/byline.spec.d.ts +1 -0
- package/dist/types/playwright-ct.config.d.ts +5 -0
- package/dist/types/src/byline/Byline.d.ts +17 -0
- package/dist/types/src/byline/Byline.stories.d.ts +206 -0
- package/dist/types/src/byline/Preview.d.ts +4 -0
- package/dist/types/src/byline/contributors-fixture.d.ts +1 -0
- package/dist/types/src/byline/lib.d.ts +48 -0
- package/dist/types/src/byline/lib.test.d.ts +1 -0
- package/dist/types/src/byline/placeholder.d.ts +2 -0
- package/dist/types/src/byline/plugins.d.ts +4 -0
- package/dist/types/src/byline/schema.d.ts +2 -0
- package/dist/types/src/byline/styles.d.ts +11 -0
- package/dist/types/src/byline/theme.d.ts +44 -0
- package/dist/types/src/byline/util.d.ts +3 -0
- package/dist/types/src/index.d.ts +2 -0
- package/package.json +60 -126
- package/LICENSE +0 -201
- package/dist/index.d.ts +0 -3
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
|
|
3
|
+
const bylineContainerStyles = css`
|
|
4
|
+
position: relative;
|
|
5
|
+
width: 100%;
|
|
6
|
+
`;
|
|
7
|
+
const bylineEditorStyles = (theme) => css`
|
|
8
|
+
border: ${theme?.border ?? "1px black solid"};
|
|
9
|
+
background-color: ${theme?.background ?? "white"};
|
|
10
|
+
color: ${theme?.color ?? "inherit"};
|
|
11
|
+
|
|
12
|
+
/* ProseMirror styles from prosemirror-view/styles/prosemirror.css */
|
|
13
|
+
.ProseMirror {
|
|
14
|
+
padding: 4px 4px;
|
|
15
|
+
word-wrap: break-word;
|
|
16
|
+
white-space: pre-wrap;
|
|
17
|
+
white-space: break-spaces;
|
|
18
|
+
-webkit-font-variant-ligatures: none;
|
|
19
|
+
font-variant-ligatures: none;
|
|
20
|
+
font-feature-settings: 'liga' 0; /* the above doesn't seem to work in Edge */
|
|
21
|
+
line-height: ${theme?.lineHeight ?? "1.8"};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.ProseMirror[contenteditable='false'] {
|
|
25
|
+
background: ${theme?.readOnlyBackground ?? "#dcdcdc"};
|
|
26
|
+
cursor: 'not-allowed';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.ProseMirror pre {
|
|
30
|
+
white-space: pre-wrap;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.ProseMirror li {
|
|
34
|
+
position: relative;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.ProseMirror-hideselection *::selection {
|
|
38
|
+
background: transparent;
|
|
39
|
+
}
|
|
40
|
+
.ProseMirror-hideselection *::-moz-selection {
|
|
41
|
+
background: transparent;
|
|
42
|
+
}
|
|
43
|
+
.ProseMirror-hideselection {
|
|
44
|
+
caret-color: transparent;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/* See https://github.com/ProseMirror/prosemirror/issues/1421#issuecomment-1759320191 */
|
|
48
|
+
.ProseMirror [draggable][contenteditable='false'] {
|
|
49
|
+
user-select: text;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.ProseMirror-selectednode {
|
|
53
|
+
outline: ${theme?.chip?.selected?.border ?? "1px solid #b4d9ff"};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/* Make sure li selections wrap around markers */
|
|
57
|
+
|
|
58
|
+
li.ProseMirror-selectednode {
|
|
59
|
+
outline: none;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
li.ProseMirror-selectednode:after {
|
|
63
|
+
content: '';
|
|
64
|
+
position: absolute;
|
|
65
|
+
left: -32px;
|
|
66
|
+
right: -2px;
|
|
67
|
+
top: -2px;
|
|
68
|
+
bottom: -2px;
|
|
69
|
+
border: ${theme?.chip?.selected?.border ?? "1px solid #b4d9ff"};
|
|
70
|
+
pointer-events: none;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* Protect against generic img rules */
|
|
74
|
+
|
|
75
|
+
img.ProseMirror-separator {
|
|
76
|
+
display: inline !important;
|
|
77
|
+
border: none !important;
|
|
78
|
+
margin: 0 !important;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.ProseMirror:focus {
|
|
82
|
+
outline: none;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* Invisible styles from @guardian/prosemirror-invisibles/dist/style.css */
|
|
86
|
+
|
|
87
|
+
.invisible {
|
|
88
|
+
/* Chrome in particular dislikes doing the right thing
|
|
89
|
+
* with carets and inline elements when contenteditable
|
|
90
|
+
* is 'false'. See e.g. https://github.com/ProseMirror/prosemirror/issues/1061
|
|
91
|
+
*/
|
|
92
|
+
display: inline;
|
|
93
|
+
position: relative;
|
|
94
|
+
pointer-events: none;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.invisible:before {
|
|
98
|
+
position: relative;
|
|
99
|
+
caret-color: inherit;
|
|
100
|
+
color: ${theme?.invisibles?.color ?? "gray"};
|
|
101
|
+
display: inline-block;
|
|
102
|
+
font-weight: 400;
|
|
103
|
+
font-style: normal;
|
|
104
|
+
line-height: initial;
|
|
105
|
+
width: 0;
|
|
106
|
+
top: 0;
|
|
107
|
+
left: 0;
|
|
108
|
+
z-index: 1;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.invisible__selected-marker {
|
|
112
|
+
position: absolute;
|
|
113
|
+
caret-color: inherit;
|
|
114
|
+
background-color: #dcdcdc;
|
|
115
|
+
display: inline-block;
|
|
116
|
+
font-weight: 400;
|
|
117
|
+
font-style: normal;
|
|
118
|
+
line-height: initial;
|
|
119
|
+
top: 0;
|
|
120
|
+
left: 0;
|
|
121
|
+
width: 10px;
|
|
122
|
+
height: 100%;
|
|
123
|
+
z-index: 0;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.ProseMirror-focused .invisible__selected-marker {
|
|
127
|
+
background-color: #b4d9ff;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.ProseMirror-focused .invisible--is-selected::before {
|
|
131
|
+
background-color: #b4d8ff;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.invisible--is-selected::before {
|
|
135
|
+
background-color: #dcdcdc;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.invisible--space:before {
|
|
139
|
+
content: '·';
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.invisible--nb-space {
|
|
143
|
+
vertical-align: text-bottom;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.invisible--nb-space:before {
|
|
147
|
+
font-size: 15px;
|
|
148
|
+
content: '^';
|
|
149
|
+
position: absolute;
|
|
150
|
+
top: 9px;
|
|
151
|
+
left: -1px;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
chip {
|
|
155
|
+
border: ${theme?.chip?.border ?? "2px solid lightgrey"};
|
|
156
|
+
border-radius: ${theme?.chip?.borderRadius ?? "8px"};
|
|
157
|
+
padding: ${theme?.chip?.padding ?? "2px 4px"};
|
|
158
|
+
color: ${theme?.chip?.color ?? "inherit"};
|
|
159
|
+
|
|
160
|
+
cursor: default;
|
|
161
|
+
|
|
162
|
+
&[data-type='tagged'] {
|
|
163
|
+
background-color: ${theme?.chip?.taggedBackground ?? "lightgrey"};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
&[data-type='untagged'] {
|
|
167
|
+
color: ${theme?.chip?.untagged?.color ?? "inherit"};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
::after {
|
|
171
|
+
content: '';
|
|
172
|
+
display: inline-block;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
span {
|
|
176
|
+
cursor: pointer;
|
|
177
|
+
margin-left: 5px;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/* Leave space between subsequent chips */
|
|
182
|
+
chip + chip {
|
|
183
|
+
margin-left: 3px;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.placeholder {
|
|
187
|
+
display: inline-block;
|
|
188
|
+
height: 0;
|
|
189
|
+
width: 0;
|
|
190
|
+
white-space: nowrap;
|
|
191
|
+
color: ${theme?.placeholder?.color ?? "#777575"};
|
|
192
|
+
pointer-events: none;
|
|
193
|
+
cursor: text;
|
|
194
|
+
}
|
|
195
|
+
`;
|
|
196
|
+
const dropdownContainerStyles = (showDropdown, theme) => css`
|
|
197
|
+
position: absolute;
|
|
198
|
+
box-sizing: border-box;
|
|
199
|
+
width: 100%;
|
|
200
|
+
z-index: 1000;
|
|
201
|
+
border: ${theme?.border ?? "1px solid #ccc"};
|
|
202
|
+
background-color: ${theme?.background ?? "rgba(255, 255, 255, 0.8)"};
|
|
203
|
+
display: ${showDropdown ? "block" : "none"};
|
|
204
|
+
max-height: ${theme?.maxHeight ?? "320px"};
|
|
205
|
+
overflow-y: auto;
|
|
206
|
+
`;
|
|
207
|
+
const dropdownUlStyles = css`
|
|
208
|
+
margin: 0;
|
|
209
|
+
padding: 0;
|
|
210
|
+
list-style-type: none;
|
|
211
|
+
`;
|
|
212
|
+
const dropdownLiStyles = (theme) => css`
|
|
213
|
+
cursor: pointer;
|
|
214
|
+
padding: 5px;
|
|
215
|
+
border-bottom: ${theme?.dropdown?.li?.borderBottom ?? "1px solid #ccc"};
|
|
216
|
+
color: ${theme?.dropdown?.li?.color ?? "inherit"};
|
|
217
|
+
`;
|
|
218
|
+
const selectedDropdownLiStyles = (theme) => css`
|
|
219
|
+
background-color: ${theme?.dropdown?.li?.selected?.background ?? "cadetblue"};
|
|
220
|
+
color: ${theme?.dropdown?.li?.selected?.color ?? "white"};
|
|
221
|
+
`;
|
|
222
|
+
const previewStyles = css`
|
|
223
|
+
margin-top: 5px;
|
|
224
|
+
white-space: pre-wrap;
|
|
225
|
+
`;
|
|
226
|
+
const previewFreeTextStyles = css`
|
|
227
|
+
font-style: italic;
|
|
228
|
+
`;
|
|
229
|
+
const previewContributorStyles = (node) => css`
|
|
230
|
+
${node.attrs.type === "tagged" ? "text-decoration: underline;" : ""}
|
|
231
|
+
color: inherit;
|
|
232
|
+
`;
|
|
233
|
+
|
|
234
|
+
export { bylineContainerStyles, bylineEditorStyles, dropdownContainerStyles, dropdownLiStyles, dropdownUlStyles, previewContributorStyles, previewFreeTextStyles, previewStyles, selectedDropdownLiStyles };
|
package/dist/index.cjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { FocusEventHandler } from 'react';
|
|
2
|
+
import type { BylineModel, TaggedContributor } from './lib';
|
|
3
|
+
import type { PartialBylineTheme } from './theme';
|
|
4
|
+
type BylineProps = {
|
|
5
|
+
theme?: PartialBylineTheme;
|
|
6
|
+
allowUntaggedContributors?: boolean;
|
|
7
|
+
contributorLimit?: number;
|
|
8
|
+
enablePreview?: boolean;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
initialValue?: BylineModel;
|
|
11
|
+
readOnly?: boolean;
|
|
12
|
+
handleSave: (newValue: BylineModel) => void;
|
|
13
|
+
searchContributors?: (selectedText: string) => Promise<TaggedContributor[]>;
|
|
14
|
+
onBlur?: FocusEventHandler<HTMLDivElement>;
|
|
15
|
+
};
|
|
16
|
+
export declare const Byline: ({ theme, allowUntaggedContributors, contributorLimit, enablePreview, placeholder, initialValue, readOnly, handleSave, searchContributors, onBlur, }: BylineProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { TaggedContributor } from './lib';
|
|
3
|
+
declare const meta: {
|
|
4
|
+
title: string;
|
|
5
|
+
component: ({ theme, allowUntaggedContributors, contributorLimit, enablePreview, placeholder, initialValue, readOnly, handleSave, searchContributors, onBlur, }: {
|
|
6
|
+
theme?: {
|
|
7
|
+
editor?: {
|
|
8
|
+
invisibles?: {
|
|
9
|
+
color?: string | undefined;
|
|
10
|
+
} | undefined;
|
|
11
|
+
color?: string | undefined;
|
|
12
|
+
border?: string | undefined;
|
|
13
|
+
background?: string | undefined;
|
|
14
|
+
chip?: {
|
|
15
|
+
color?: string | undefined;
|
|
16
|
+
border?: string | undefined;
|
|
17
|
+
padding?: string | undefined;
|
|
18
|
+
borderRadius?: string | undefined;
|
|
19
|
+
taggedBackground?: string | undefined;
|
|
20
|
+
untagged?: {
|
|
21
|
+
color?: string | undefined;
|
|
22
|
+
} | undefined;
|
|
23
|
+
selected?: {
|
|
24
|
+
border?: string | undefined;
|
|
25
|
+
} | undefined;
|
|
26
|
+
} | undefined;
|
|
27
|
+
lineHeight?: string | undefined;
|
|
28
|
+
placeholder?: {
|
|
29
|
+
color?: string | undefined;
|
|
30
|
+
} | undefined;
|
|
31
|
+
readOnlyBackground?: string | undefined;
|
|
32
|
+
} | undefined;
|
|
33
|
+
dropdown?: {
|
|
34
|
+
background?: string | undefined;
|
|
35
|
+
border?: string | undefined;
|
|
36
|
+
maxHeight?: string | undefined;
|
|
37
|
+
li?: {
|
|
38
|
+
color?: string | undefined;
|
|
39
|
+
borderBottom?: string | undefined;
|
|
40
|
+
selected?: {
|
|
41
|
+
background?: string | undefined;
|
|
42
|
+
color?: string | undefined;
|
|
43
|
+
} | undefined;
|
|
44
|
+
} | undefined;
|
|
45
|
+
} | undefined;
|
|
46
|
+
} | undefined;
|
|
47
|
+
allowUntaggedContributors?: boolean | undefined;
|
|
48
|
+
contributorLimit?: number | undefined;
|
|
49
|
+
enablePreview?: boolean | undefined;
|
|
50
|
+
placeholder?: string | undefined;
|
|
51
|
+
initialValue?: import("./lib").BylineModel | undefined;
|
|
52
|
+
readOnly?: boolean | undefined;
|
|
53
|
+
handleSave: (newValue: import("./lib").BylineModel) => void;
|
|
54
|
+
searchContributors?: ((selectedText: string) => Promise<TaggedContributor[]>) | undefined;
|
|
55
|
+
onBlur?: import("react").FocusEventHandler<HTMLDivElement> | undefined;
|
|
56
|
+
}) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
57
|
+
parameters: {};
|
|
58
|
+
args: {
|
|
59
|
+
handleSave: () => void;
|
|
60
|
+
initialValue: never[];
|
|
61
|
+
searchContributors: (selectedText: string) => Promise<TaggedContributor[]>;
|
|
62
|
+
enablePreview: true;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
export declare const Default: {};
|
|
66
|
+
export declare const WithTheme: {
|
|
67
|
+
args: {
|
|
68
|
+
allowUntaggedContributors: true;
|
|
69
|
+
searchContributors: (selectedText: string) => Promise<TaggedContributor[]>;
|
|
70
|
+
theme: {
|
|
71
|
+
editor: {
|
|
72
|
+
invisibles: {
|
|
73
|
+
color: string;
|
|
74
|
+
};
|
|
75
|
+
color: string;
|
|
76
|
+
background: string;
|
|
77
|
+
border: string;
|
|
78
|
+
chip: {
|
|
79
|
+
color: string;
|
|
80
|
+
taggedBackground: string;
|
|
81
|
+
border: string;
|
|
82
|
+
borderRadius: string;
|
|
83
|
+
padding: string;
|
|
84
|
+
untagged: {
|
|
85
|
+
color: string;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
dropdown: {
|
|
90
|
+
background: string;
|
|
91
|
+
li: {
|
|
92
|
+
color: string;
|
|
93
|
+
borderBottom: string;
|
|
94
|
+
selected: {
|
|
95
|
+
color: string;
|
|
96
|
+
background: string;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
export declare const WithUntaggedContributors: {
|
|
104
|
+
parameters: {
|
|
105
|
+
chromatic: {
|
|
106
|
+
disableSnapshot: boolean;
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
args: {
|
|
110
|
+
allowUntaggedContributors: true;
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
export declare const WithInitialValue: {
|
|
114
|
+
args: {
|
|
115
|
+
allowUntaggedContributors: true;
|
|
116
|
+
initialValue: ({
|
|
117
|
+
type: "contributor";
|
|
118
|
+
value: string;
|
|
119
|
+
tagId: string;
|
|
120
|
+
path: string;
|
|
121
|
+
} | {
|
|
122
|
+
type: "text";
|
|
123
|
+
value: string;
|
|
124
|
+
tagId?: undefined;
|
|
125
|
+
path?: undefined;
|
|
126
|
+
} | {
|
|
127
|
+
type: "contributor";
|
|
128
|
+
value: string;
|
|
129
|
+
tagId?: undefined;
|
|
130
|
+
path?: undefined;
|
|
131
|
+
})[];
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
export declare const WithNoSearch: {
|
|
135
|
+
parameters: {
|
|
136
|
+
chromatic: {
|
|
137
|
+
disableSnapshot: boolean;
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
args: {
|
|
141
|
+
allowUntaggedContributors: true;
|
|
142
|
+
searchContributors: undefined;
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
export declare const WithNoSearchAndNoUntagged: {
|
|
146
|
+
parameters: {
|
|
147
|
+
chromatic: {
|
|
148
|
+
disableSnapshot: boolean;
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
args: {
|
|
152
|
+
allowUntaggedContributors: false;
|
|
153
|
+
searchContributors: undefined;
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
export declare const WithCustomPlaceholder: {
|
|
157
|
+
args: {
|
|
158
|
+
allowUntaggedContributors: true;
|
|
159
|
+
placeholder: string;
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
export declare const WithContributorLimit: {
|
|
163
|
+
parameters: {
|
|
164
|
+
chromatic: {
|
|
165
|
+
disableSnapshot: boolean;
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
args: {
|
|
169
|
+
contributorLimit: number;
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
export declare const WithoutPreview: {
|
|
173
|
+
parameters: {
|
|
174
|
+
chromatic: {
|
|
175
|
+
disableSnapshot: boolean;
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
args: {
|
|
179
|
+
allowUntaggedContributors: true;
|
|
180
|
+
enablePreview: false;
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
export declare const ReadOnly: {
|
|
184
|
+
args: {
|
|
185
|
+
readOnly: true;
|
|
186
|
+
allowUntaggedContributors: true;
|
|
187
|
+
enablePreview: true;
|
|
188
|
+
initialValue: ({
|
|
189
|
+
type: "contributor";
|
|
190
|
+
value: string;
|
|
191
|
+
tagId: string;
|
|
192
|
+
path: string;
|
|
193
|
+
} | {
|
|
194
|
+
type: "text";
|
|
195
|
+
value: string;
|
|
196
|
+
tagId?: undefined;
|
|
197
|
+
path?: undefined;
|
|
198
|
+
} | {
|
|
199
|
+
type: "contributor";
|
|
200
|
+
value: string;
|
|
201
|
+
tagId?: undefined;
|
|
202
|
+
path?: undefined;
|
|
203
|
+
})[];
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
export default meta;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const contributors: string[];
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Node } from 'prosemirror-model';
|
|
2
|
+
import type { Command } from 'prosemirror-state';
|
|
3
|
+
import type { EditorView } from 'prosemirror-view';
|
|
4
|
+
export type TypingFromStartRange = {
|
|
5
|
+
start: number;
|
|
6
|
+
maxReached: number;
|
|
7
|
+
lastPosition: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const detectNameInText: (text: string, cursorOffset: number, isTypingFromStartRange?: TypingFromStartRange) => {
|
|
10
|
+
name: string;
|
|
11
|
+
startIndex: number;
|
|
12
|
+
endIndex: number;
|
|
13
|
+
} | undefined;
|
|
14
|
+
export declare function insertChip(text: string, from: number, to: number, type: 'tagged', tagId: string, path?: string, meta?: unknown): Command;
|
|
15
|
+
export declare function insertChip(text: string, from: number, to: number, type: 'untagged', tagId?: undefined, meta?: undefined): Command;
|
|
16
|
+
export declare const getCurrentText: (doc: Node, currentOffset: number, toOffset: number, isTypingFromStartRange?: TypingFromStartRange) => {
|
|
17
|
+
currentTextNode: Node | null;
|
|
18
|
+
startOffset: number;
|
|
19
|
+
endOffset: number;
|
|
20
|
+
selectedText: string;
|
|
21
|
+
hasSelection: boolean;
|
|
22
|
+
};
|
|
23
|
+
export declare const hasHitContributorLimit: (doc: Node, contributorLimit?: number) => boolean;
|
|
24
|
+
export type TaggedContributor = {
|
|
25
|
+
tagId: string;
|
|
26
|
+
label: string;
|
|
27
|
+
internalLabel?: string;
|
|
28
|
+
path?: string;
|
|
29
|
+
meta?: unknown;
|
|
30
|
+
};
|
|
31
|
+
export declare const addUntaggedContributor: (viewRef: React.MutableRefObject<EditorView | null>, setShowDropdown: React.Dispatch<React.SetStateAction<boolean>>, contributorLimit?: number, isTypingFromStartRange?: TypingFromStartRange) => boolean | undefined;
|
|
32
|
+
export declare const addTaggedContributor: (contributor: TaggedContributor, viewRef: React.MutableRefObject<EditorView | null>, setShowDropdown: React.Dispatch<React.SetStateAction<boolean>>, contributorLimit?: number, isTypingFromStartRange?: TypingFromStartRange) => boolean | undefined;
|
|
33
|
+
type BylineText = {
|
|
34
|
+
type: 'text';
|
|
35
|
+
value: string;
|
|
36
|
+
};
|
|
37
|
+
type BylineContributor = {
|
|
38
|
+
type: 'contributor';
|
|
39
|
+
value: string;
|
|
40
|
+
tagId?: string;
|
|
41
|
+
path?: string;
|
|
42
|
+
meta?: unknown;
|
|
43
|
+
};
|
|
44
|
+
type BylinePart = BylineText | BylineContributor;
|
|
45
|
+
export type BylineModel = BylinePart[];
|
|
46
|
+
export declare const convertBylineModelToNode: (value?: BylineModel) => Node;
|
|
47
|
+
export declare const convertNodeToBylineModel: (doc: Node) => BylineModel;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Node } from 'prosemirror-model';
|
|
2
|
+
import type { PartialBylineTheme } from './theme';
|
|
3
|
+
export declare const bylineContainerStyles: import("@emotion/react").SerializedStyles;
|
|
4
|
+
export declare const bylineEditorStyles: (theme: PartialBylineTheme['editor']) => import("@emotion/react").SerializedStyles;
|
|
5
|
+
export declare const dropdownContainerStyles: (showDropdown: boolean, theme?: PartialBylineTheme['dropdown']) => import("@emotion/react").SerializedStyles;
|
|
6
|
+
export declare const dropdownUlStyles: import("@emotion/react").SerializedStyles;
|
|
7
|
+
export declare const dropdownLiStyles: (theme?: PartialBylineTheme) => import("@emotion/react").SerializedStyles;
|
|
8
|
+
export declare const selectedDropdownLiStyles: (theme?: PartialBylineTheme) => import("@emotion/react").SerializedStyles;
|
|
9
|
+
export declare const previewStyles: import("@emotion/react").SerializedStyles;
|
|
10
|
+
export declare const previewFreeTextStyles: import("@emotion/react").SerializedStyles;
|
|
11
|
+
export declare const previewContributorStyles: (node: Node) => import("@emotion/react").SerializedStyles;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { DeepPartial } from './util';
|
|
2
|
+
type BylineTheme = {
|
|
3
|
+
editor: {
|
|
4
|
+
invisibles: {
|
|
5
|
+
color: string;
|
|
6
|
+
};
|
|
7
|
+
color: string;
|
|
8
|
+
border: string;
|
|
9
|
+
background: string;
|
|
10
|
+
chip: {
|
|
11
|
+
color: string;
|
|
12
|
+
border: string;
|
|
13
|
+
padding: string;
|
|
14
|
+
borderRadius: string;
|
|
15
|
+
taggedBackground: string;
|
|
16
|
+
untagged: {
|
|
17
|
+
color: string;
|
|
18
|
+
};
|
|
19
|
+
selected: {
|
|
20
|
+
border: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
lineHeight: string;
|
|
24
|
+
placeholder: {
|
|
25
|
+
color: string;
|
|
26
|
+
};
|
|
27
|
+
readOnlyBackground: string;
|
|
28
|
+
};
|
|
29
|
+
dropdown: {
|
|
30
|
+
background: string;
|
|
31
|
+
border: string;
|
|
32
|
+
maxHeight: string;
|
|
33
|
+
li: {
|
|
34
|
+
color: string;
|
|
35
|
+
borderBottom: string;
|
|
36
|
+
selected: {
|
|
37
|
+
background: string;
|
|
38
|
+
color: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export type PartialBylineTheme = DeepPartial<BylineTheme>;
|
|
44
|
+
export {};
|