@guardian/stand 0.0.2 → 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 +4 -0
- package/dist/types/playwright/byline.mock.d.ts +3 -0
- package/dist/types/playwright-ct.config.d.ts +5 -0
- package/package.json +8 -5
- package/.changeset/README.md +0 -8
- package/.changeset/config.json +0 -11
- package/.prettierrc +0 -1
- package/.storybook/main.ts +0 -12
- package/.storybook/preview.tsx +0 -83
- package/CHANGELOG.md +0 -7
- package/dist/types/src/mocks/prosemirror-view.d.ts +0 -10
- package/eslint.config.js +0 -14
- package/jest-setup-after-env.ts +0 -1
- package/jest.config.js +0 -12
- package/rollup.config.js +0 -49
- package/src/byline/Byline.stories.tsx +0 -186
- package/src/byline/Byline.test.tsx +0 -450
- package/src/byline/Byline.tsx +0 -524
- package/src/byline/Preview.tsx +0 -59
- package/src/byline/contributors-fixture.ts +0 -1006
- package/src/byline/lib.test.ts +0 -179
- package/src/byline/lib.ts +0 -426
- package/src/byline/placeholder.ts +0 -30
- package/src/byline/plugins.ts +0 -186
- package/src/byline/schema.ts +0 -62
- package/src/byline/styles.ts +0 -246
- package/src/byline/theme.ts +0 -45
- package/src/byline/util.ts +0 -5
- package/src/index.ts +0 -2
- package/src/mocks/prosemirror-view.ts +0 -19
- package/tsconfig.json +0 -19
- /package/dist/types/{src/byline/Byline.test.d.ts → playwright/byline.spec.d.ts} +0 -0
package/src/byline/plugins.ts
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { redo, undo } from 'prosemirror-history';
|
|
2
|
-
import { keymap } from 'prosemirror-keymap';
|
|
3
|
-
import type { Node as ProsemirrorNode } from 'prosemirror-model';
|
|
4
|
-
import { Slice } from 'prosemirror-model';
|
|
5
|
-
import { Plugin } from 'prosemirror-state';
|
|
6
|
-
import { NodeSelection } from 'prosemirror-state';
|
|
7
|
-
import type { Command } from 'prosemirror-state';
|
|
8
|
-
import { bylineEditorSchema } from './schema';
|
|
9
|
-
|
|
10
|
-
const serializeNode = (node: ProsemirrorNode, output: string[]): void => {
|
|
11
|
-
if (node.isText) {
|
|
12
|
-
output.push(node.text ?? '');
|
|
13
|
-
} else if (node.type.name === 'chip') {
|
|
14
|
-
output.push(node.attrs.label as string);
|
|
15
|
-
} else if (node.isInline) {
|
|
16
|
-
node.content.forEach((child) => serializeNode(child, output));
|
|
17
|
-
} else {
|
|
18
|
-
// fallback for other block/unknown content
|
|
19
|
-
node.content.forEach((child) => serializeNode(child, output));
|
|
20
|
-
output.push('\n');
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
// This runs after ProseMirror's default paste parsing, allowing us to work with
|
|
25
|
-
// the already-parsed document structure when pasting content.
|
|
26
|
-
const transformPastedNode = (
|
|
27
|
-
slice: Slice,
|
|
28
|
-
allowUntaggedContributors?: boolean,
|
|
29
|
-
contributorLimit?: number,
|
|
30
|
-
) => {
|
|
31
|
-
let contributorCount = 0;
|
|
32
|
-
const output: ProsemirrorNode[] = [];
|
|
33
|
-
|
|
34
|
-
const convertChipToPlaintext = (
|
|
35
|
-
node: ProsemirrorNode,
|
|
36
|
-
output: ProsemirrorNode[],
|
|
37
|
-
) => {
|
|
38
|
-
const label = node.attrs.label as string;
|
|
39
|
-
if (label) {
|
|
40
|
-
const textNode = bylineEditorSchema.text(label);
|
|
41
|
-
output.push(textNode);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
slice.content.forEach((node) => {
|
|
46
|
-
if (node.type.name === 'chip') {
|
|
47
|
-
const type = node.attrs.type as string;
|
|
48
|
-
|
|
49
|
-
// If there is a contributor limit and we've hit it, convert chips to plain text
|
|
50
|
-
if (
|
|
51
|
-
contributorLimit !== undefined &&
|
|
52
|
-
contributorCount >= contributorLimit
|
|
53
|
-
) {
|
|
54
|
-
convertChipToPlaintext(node, output);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// If untagged contributors are not allowed, convert untagged chips to plain text
|
|
59
|
-
if (type === 'untagged' && !allowUntaggedContributors) {
|
|
60
|
-
convertChipToPlaintext(node, output);
|
|
61
|
-
} else {
|
|
62
|
-
// Keep the chip as-is
|
|
63
|
-
output.push(node);
|
|
64
|
-
contributorCount++;
|
|
65
|
-
}
|
|
66
|
-
} else if (node.isText) {
|
|
67
|
-
// Keep text nodes as-is
|
|
68
|
-
output.push(node);
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
return output;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export const clipboardPlugin = (
|
|
76
|
-
allowUntaggedContributors?: boolean,
|
|
77
|
-
contributorLimit?: number,
|
|
78
|
-
): Plugin => {
|
|
79
|
-
return new Plugin({
|
|
80
|
-
props: {
|
|
81
|
-
// Custom serializer for copying content from the editor
|
|
82
|
-
clipboardTextSerializer: (slice) => {
|
|
83
|
-
const parts: string[] = [];
|
|
84
|
-
|
|
85
|
-
slice.content.forEach((node: ProsemirrorNode) => {
|
|
86
|
-
serializeNode(node, parts);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
return parts.join('');
|
|
90
|
-
},
|
|
91
|
-
// Transform pasted content after ProseMirror's default parsing
|
|
92
|
-
transformPasted: (slice) => {
|
|
93
|
-
const transformedNodes = transformPastedNode(
|
|
94
|
-
slice,
|
|
95
|
-
allowUntaggedContributors,
|
|
96
|
-
contributorLimit,
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
if (transformedNodes.length > 0) {
|
|
100
|
-
const newFragment = bylineEditorSchema.nodes.doc.create(
|
|
101
|
-
{},
|
|
102
|
-
transformedNodes,
|
|
103
|
-
).content;
|
|
104
|
-
return new Slice(
|
|
105
|
-
newFragment,
|
|
106
|
-
slice.openStart,
|
|
107
|
-
slice.openEnd,
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return slice;
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
});
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
const deleteSelectedChip: Command = (state, dispatch) => {
|
|
118
|
-
const { selection } = state;
|
|
119
|
-
// Check if we have a node selection and it's a chip
|
|
120
|
-
if (
|
|
121
|
-
selection instanceof NodeSelection &&
|
|
122
|
-
selection.node.type.name === 'chip'
|
|
123
|
-
) {
|
|
124
|
-
if (dispatch) {
|
|
125
|
-
const tr = state.tr.deleteSelection();
|
|
126
|
-
dispatch(tr);
|
|
127
|
-
}
|
|
128
|
-
return true;
|
|
129
|
-
}
|
|
130
|
-
return false;
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
export const keybindings = () =>
|
|
134
|
-
keymap({
|
|
135
|
-
'Mod-z': undo,
|
|
136
|
-
'Mod-y': redo,
|
|
137
|
-
'Mod-shift-z': redo,
|
|
138
|
-
Backspace: deleteSelectedChip,
|
|
139
|
-
Delete: deleteSelectedChip,
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
export const bylinePlugin = (): Plugin => {
|
|
143
|
-
return new Plugin({
|
|
144
|
-
props: {
|
|
145
|
-
nodeViews: {
|
|
146
|
-
chip: (node, view, getPos) => {
|
|
147
|
-
const dom = document.createElement('chip');
|
|
148
|
-
dom.setAttribute('data-label', node.attrs.label as string);
|
|
149
|
-
dom.setAttribute('data-type', node.attrs.type as string);
|
|
150
|
-
dom.setAttribute('data-tag-id', node.attrs.tagId as string);
|
|
151
|
-
dom.setAttribute('data-path', node.attrs.path as string);
|
|
152
|
-
if (node.attrs.meta) {
|
|
153
|
-
dom.setAttribute(
|
|
154
|
-
'data-meta',
|
|
155
|
-
JSON.stringify(node.attrs.meta),
|
|
156
|
-
);
|
|
157
|
-
}
|
|
158
|
-
dom.textContent = node.attrs.label as string;
|
|
159
|
-
|
|
160
|
-
const deleteHandle = document.createElement('span');
|
|
161
|
-
deleteHandle.innerHTML = '×';
|
|
162
|
-
deleteHandle.title = `Delete ${node.attrs.label}`;
|
|
163
|
-
|
|
164
|
-
deleteHandle.addEventListener('click', (event) => {
|
|
165
|
-
event.stopPropagation();
|
|
166
|
-
const pos = getPos();
|
|
167
|
-
|
|
168
|
-
if (pos === undefined) {
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
const tr = view.state.tr.deleteRange(
|
|
173
|
-
pos,
|
|
174
|
-
pos + node.nodeSize,
|
|
175
|
-
);
|
|
176
|
-
view.dispatch(tr);
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
dom.appendChild(deleteHandle);
|
|
180
|
-
|
|
181
|
-
return { dom };
|
|
182
|
-
},
|
|
183
|
-
},
|
|
184
|
-
},
|
|
185
|
-
});
|
|
186
|
-
};
|
package/src/byline/schema.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { Schema } from 'prosemirror-model';
|
|
2
|
-
|
|
3
|
-
export const bylineEditorSchema = new Schema({
|
|
4
|
-
nodes: {
|
|
5
|
-
doc: {
|
|
6
|
-
content: 'inline*',
|
|
7
|
-
},
|
|
8
|
-
chip: {
|
|
9
|
-
group: 'inline',
|
|
10
|
-
inline: true,
|
|
11
|
-
atom: false,
|
|
12
|
-
selectable: true, // allows selection for deletion/drag and drop
|
|
13
|
-
attrs: {
|
|
14
|
-
label: { default: '' },
|
|
15
|
-
type: { default: 'untagged' },
|
|
16
|
-
tagId: { default: '' }, // tagId is optional for untagged contributors
|
|
17
|
-
path: { default: '' }, // path is optional for untagged contributors
|
|
18
|
-
meta: { default: {} }, // meta is optional and can hold any additional data
|
|
19
|
-
},
|
|
20
|
-
parseDOM: [
|
|
21
|
-
{
|
|
22
|
-
tag: 'chip[data-label][data-type][data-tag-id][data-path][data-meta]',
|
|
23
|
-
getAttrs(dom: HTMLElement) {
|
|
24
|
-
return {
|
|
25
|
-
label: dom.getAttribute('data-label'),
|
|
26
|
-
type: dom.getAttribute('data-type'),
|
|
27
|
-
tagId: dom.getAttribute('data-tag-id') ?? '',
|
|
28
|
-
path: dom.getAttribute('data-path') ?? '',
|
|
29
|
-
meta: dom.getAttribute('data-meta')
|
|
30
|
-
? (JSON.parse(
|
|
31
|
-
dom.getAttribute('data-meta') as string,
|
|
32
|
-
) as unknown)
|
|
33
|
-
: {},
|
|
34
|
-
};
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
],
|
|
38
|
-
toDOM(node) {
|
|
39
|
-
return [
|
|
40
|
-
'chip',
|
|
41
|
-
{
|
|
42
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- label exists as string on chip node
|
|
43
|
-
'data-label': node.attrs.label,
|
|
44
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- type exists as string on chip node
|
|
45
|
-
'data-type': node.attrs.type,
|
|
46
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- tagId exists as string on chip node
|
|
47
|
-
'data-tag-id': node.attrs.tagId,
|
|
48
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- path exists as string on chip node
|
|
49
|
-
'data-path': node.attrs.path,
|
|
50
|
-
'data-meta': node.attrs.meta
|
|
51
|
-
? JSON.stringify(node.attrs.meta)
|
|
52
|
-
: {},
|
|
53
|
-
},
|
|
54
|
-
node.attrs.label,
|
|
55
|
-
];
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
text: {
|
|
59
|
-
group: 'inline',
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
});
|
package/src/byline/styles.ts
DELETED
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
import { css } from '@emotion/react';
|
|
2
|
-
import type { Node } from 'prosemirror-model';
|
|
3
|
-
import type { PartialBylineTheme } from './theme';
|
|
4
|
-
|
|
5
|
-
export const bylineContainerStyles = css`
|
|
6
|
-
position: relative;
|
|
7
|
-
width: 100%;
|
|
8
|
-
`;
|
|
9
|
-
|
|
10
|
-
export const bylineEditorStyles = (theme: PartialBylineTheme['editor']) => css`
|
|
11
|
-
border: ${theme?.border ?? '1px black solid'};
|
|
12
|
-
background-color: ${theme?.background ?? 'white'};
|
|
13
|
-
color: ${theme?.color ?? 'inherit'};
|
|
14
|
-
|
|
15
|
-
/* ProseMirror styles from prosemirror-view/styles/prosemirror.css */
|
|
16
|
-
.ProseMirror {
|
|
17
|
-
padding: 4px 4px;
|
|
18
|
-
word-wrap: break-word;
|
|
19
|
-
white-space: pre-wrap;
|
|
20
|
-
white-space: break-spaces;
|
|
21
|
-
-webkit-font-variant-ligatures: none;
|
|
22
|
-
font-variant-ligatures: none;
|
|
23
|
-
font-feature-settings: 'liga' 0; /* the above doesn't seem to work in Edge */
|
|
24
|
-
line-height: ${theme?.lineHeight ?? '1.8'};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.ProseMirror[contenteditable='false'] {
|
|
28
|
-
background: ${theme?.readOnlyBackground ?? '#dcdcdc'};
|
|
29
|
-
cursor: 'not-allowed';
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.ProseMirror pre {
|
|
33
|
-
white-space: pre-wrap;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.ProseMirror li {
|
|
37
|
-
position: relative;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.ProseMirror-hideselection *::selection {
|
|
41
|
-
background: transparent;
|
|
42
|
-
}
|
|
43
|
-
.ProseMirror-hideselection *::-moz-selection {
|
|
44
|
-
background: transparent;
|
|
45
|
-
}
|
|
46
|
-
.ProseMirror-hideselection {
|
|
47
|
-
caret-color: transparent;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/* See https://github.com/ProseMirror/prosemirror/issues/1421#issuecomment-1759320191 */
|
|
51
|
-
.ProseMirror [draggable][contenteditable='false'] {
|
|
52
|
-
user-select: text;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.ProseMirror-selectednode {
|
|
56
|
-
outline: ${theme?.chip?.selected?.border ?? '1px solid #b4d9ff'};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/* Make sure li selections wrap around markers */
|
|
60
|
-
|
|
61
|
-
li.ProseMirror-selectednode {
|
|
62
|
-
outline: none;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
li.ProseMirror-selectednode:after {
|
|
66
|
-
content: '';
|
|
67
|
-
position: absolute;
|
|
68
|
-
left: -32px;
|
|
69
|
-
right: -2px;
|
|
70
|
-
top: -2px;
|
|
71
|
-
bottom: -2px;
|
|
72
|
-
border: ${theme?.chip?.selected?.border ?? '1px solid #b4d9ff'};
|
|
73
|
-
pointer-events: none;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/* Protect against generic img rules */
|
|
77
|
-
|
|
78
|
-
img.ProseMirror-separator {
|
|
79
|
-
display: inline !important;
|
|
80
|
-
border: none !important;
|
|
81
|
-
margin: 0 !important;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
.ProseMirror:focus {
|
|
85
|
-
outline: none;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/* Invisible styles from @guardian/prosemirror-invisibles/dist/style.css */
|
|
89
|
-
|
|
90
|
-
.invisible {
|
|
91
|
-
/* Chrome in particular dislikes doing the right thing
|
|
92
|
-
* with carets and inline elements when contenteditable
|
|
93
|
-
* is 'false'. See e.g. https://github.com/ProseMirror/prosemirror/issues/1061
|
|
94
|
-
*/
|
|
95
|
-
display: inline;
|
|
96
|
-
position: relative;
|
|
97
|
-
pointer-events: none;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
.invisible:before {
|
|
101
|
-
position: relative;
|
|
102
|
-
caret-color: inherit;
|
|
103
|
-
color: ${theme?.invisibles?.color ?? 'gray'};
|
|
104
|
-
display: inline-block;
|
|
105
|
-
font-weight: 400;
|
|
106
|
-
font-style: normal;
|
|
107
|
-
line-height: initial;
|
|
108
|
-
width: 0;
|
|
109
|
-
top: 0;
|
|
110
|
-
left: 0;
|
|
111
|
-
z-index: 1;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
.invisible__selected-marker {
|
|
115
|
-
position: absolute;
|
|
116
|
-
caret-color: inherit;
|
|
117
|
-
background-color: #dcdcdc;
|
|
118
|
-
display: inline-block;
|
|
119
|
-
font-weight: 400;
|
|
120
|
-
font-style: normal;
|
|
121
|
-
line-height: initial;
|
|
122
|
-
top: 0;
|
|
123
|
-
left: 0;
|
|
124
|
-
width: 10px;
|
|
125
|
-
height: 100%;
|
|
126
|
-
z-index: 0;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
.ProseMirror-focused .invisible__selected-marker {
|
|
130
|
-
background-color: #b4d9ff;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
.ProseMirror-focused .invisible--is-selected::before {
|
|
134
|
-
background-color: #b4d8ff;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
.invisible--is-selected::before {
|
|
138
|
-
background-color: #dcdcdc;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
.invisible--space:before {
|
|
142
|
-
content: '·';
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
.invisible--nb-space {
|
|
146
|
-
vertical-align: text-bottom;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
.invisible--nb-space:before {
|
|
150
|
-
font-size: 15px;
|
|
151
|
-
content: '^';
|
|
152
|
-
position: absolute;
|
|
153
|
-
top: 9px;
|
|
154
|
-
left: -1px;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
chip {
|
|
158
|
-
border: ${theme?.chip?.border ?? '2px solid lightgrey'};
|
|
159
|
-
border-radius: ${theme?.chip?.borderRadius ?? '8px'};
|
|
160
|
-
padding: ${theme?.chip?.padding ?? '2px 4px'};
|
|
161
|
-
color: ${theme?.chip?.color ?? 'inherit'};
|
|
162
|
-
|
|
163
|
-
cursor: default;
|
|
164
|
-
|
|
165
|
-
&[data-type='tagged'] {
|
|
166
|
-
background-color: ${theme?.chip?.taggedBackground ?? 'lightgrey'};
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
&[data-type='untagged'] {
|
|
170
|
-
color: ${theme?.chip?.untagged?.color ?? 'inherit'};
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
::after {
|
|
174
|
-
content: '';
|
|
175
|
-
display: inline-block;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
span {
|
|
179
|
-
cursor: pointer;
|
|
180
|
-
margin-left: 5px;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/* Leave space between subsequent chips */
|
|
185
|
-
chip + chip {
|
|
186
|
-
margin-left: 3px;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
.placeholder {
|
|
190
|
-
display: inline-block;
|
|
191
|
-
height: 0;
|
|
192
|
-
width: 0;
|
|
193
|
-
white-space: nowrap;
|
|
194
|
-
color: ${theme?.placeholder?.color ?? '#777575'};
|
|
195
|
-
pointer-events: none;
|
|
196
|
-
cursor: text;
|
|
197
|
-
}
|
|
198
|
-
`;
|
|
199
|
-
|
|
200
|
-
export const dropdownContainerStyles = (
|
|
201
|
-
showDropdown: boolean,
|
|
202
|
-
theme?: PartialBylineTheme['dropdown'],
|
|
203
|
-
) => css`
|
|
204
|
-
position: absolute;
|
|
205
|
-
box-sizing: border-box;
|
|
206
|
-
width: 100%;
|
|
207
|
-
z-index: 1000;
|
|
208
|
-
border: ${theme?.border ?? '1px solid #ccc'};
|
|
209
|
-
background-color: ${theme?.background ?? 'rgba(255, 255, 255, 0.8)'};
|
|
210
|
-
display: ${showDropdown ? 'block' : 'none'};
|
|
211
|
-
max-height: ${theme?.maxHeight ?? '320px'};
|
|
212
|
-
overflow-y: auto;
|
|
213
|
-
`;
|
|
214
|
-
|
|
215
|
-
export const dropdownUlStyles = css`
|
|
216
|
-
margin: 0;
|
|
217
|
-
padding: 0;
|
|
218
|
-
list-style-type: none;
|
|
219
|
-
`;
|
|
220
|
-
|
|
221
|
-
export const dropdownLiStyles = (theme?: PartialBylineTheme) => css`
|
|
222
|
-
cursor: pointer;
|
|
223
|
-
padding: 5px;
|
|
224
|
-
border-bottom: ${theme?.dropdown?.li?.borderBottom ?? '1px solid #ccc'};
|
|
225
|
-
color: ${theme?.dropdown?.li?.color ?? 'inherit'};
|
|
226
|
-
`;
|
|
227
|
-
|
|
228
|
-
export const selectedDropdownLiStyles = (theme?: PartialBylineTheme) => css`
|
|
229
|
-
background-color: ${theme?.dropdown?.li?.selected?.background ??
|
|
230
|
-
'cadetblue'};
|
|
231
|
-
color: ${theme?.dropdown?.li?.selected?.color ?? 'white'};
|
|
232
|
-
`;
|
|
233
|
-
|
|
234
|
-
export const previewStyles = css`
|
|
235
|
-
margin-top: 5px;
|
|
236
|
-
white-space: pre-wrap;
|
|
237
|
-
`;
|
|
238
|
-
|
|
239
|
-
export const previewFreeTextStyles = css`
|
|
240
|
-
font-style: italic;
|
|
241
|
-
`;
|
|
242
|
-
|
|
243
|
-
export const previewContributorStyles = (node: Node) => css`
|
|
244
|
-
${node.attrs.type === 'tagged' ? 'text-decoration: underline;' : ''}
|
|
245
|
-
color: inherit;
|
|
246
|
-
`;
|
package/src/byline/theme.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import type { DeepPartial } from './util';
|
|
2
|
-
|
|
3
|
-
type BylineTheme = {
|
|
4
|
-
editor: {
|
|
5
|
-
invisibles: {
|
|
6
|
-
color: string;
|
|
7
|
-
};
|
|
8
|
-
color: string;
|
|
9
|
-
border: string;
|
|
10
|
-
background: string;
|
|
11
|
-
chip: {
|
|
12
|
-
color: string;
|
|
13
|
-
border: string;
|
|
14
|
-
padding: string;
|
|
15
|
-
borderRadius: string;
|
|
16
|
-
taggedBackground: string;
|
|
17
|
-
untagged: {
|
|
18
|
-
color: string;
|
|
19
|
-
};
|
|
20
|
-
selected: {
|
|
21
|
-
border: string;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
lineHeight: string;
|
|
25
|
-
placeholder: {
|
|
26
|
-
color: string;
|
|
27
|
-
};
|
|
28
|
-
readOnlyBackground: string;
|
|
29
|
-
};
|
|
30
|
-
dropdown: {
|
|
31
|
-
background: string;
|
|
32
|
-
border: string;
|
|
33
|
-
maxHeight: string;
|
|
34
|
-
li: {
|
|
35
|
-
color: string;
|
|
36
|
-
borderBottom: string;
|
|
37
|
-
selected: {
|
|
38
|
-
background: string;
|
|
39
|
-
color: string;
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export type PartialBylineTheme = DeepPartial<BylineTheme>;
|
package/src/byline/util.ts
DELETED
package/src/index.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// copied from flexible-frontend
|
|
2
|
-
// prosemirror's functions for finding what point in a document a user clicked on
|
|
3
|
-
// throw excepetions in the test enviroment, so need to be mocked out.
|
|
4
|
-
// Unclear if the exception is due to userEvent using mocked pointer events
|
|
5
|
-
// without co-ordinates, or JSdom not supporting the DOM methods used under the hood.
|
|
6
|
-
const mockEditorViewMethods = {
|
|
7
|
-
posAtCoords: () => {
|
|
8
|
-
return null;
|
|
9
|
-
},
|
|
10
|
-
coordsAtPos: () => {
|
|
11
|
-
return {
|
|
12
|
-
left: 0,
|
|
13
|
-
right: 0,
|
|
14
|
-
top: 0,
|
|
15
|
-
bottom: 0,
|
|
16
|
-
};
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
export { mockEditorViewMethods };
|
package/tsconfig.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "@guardian/tsconfig/tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "dist/types",
|
|
5
|
-
"declarationDir": "dist/types",
|
|
6
|
-
"emitDeclarationOnly": true,
|
|
7
|
-
"declaration": true,
|
|
8
|
-
"forceConsistentCasingInFileNames": true,
|
|
9
|
-
"importHelpers": true,
|
|
10
|
-
"isolatedModules": true,
|
|
11
|
-
"skipLibCheck": true,
|
|
12
|
-
"baseUrl": "./",
|
|
13
|
-
"jsx": "react-jsx",
|
|
14
|
-
"jsxImportSource": "@emotion/react",
|
|
15
|
-
"lib": ["dom", "es2022"]
|
|
16
|
-
},
|
|
17
|
-
"include": ["src/**/*", ".storybook/**/*", "jest-setup-after-env.ts"],
|
|
18
|
-
"exclude": ["node_modules", "dist"]
|
|
19
|
-
}
|
|
File without changes
|