@pie-lib/editable-html-tip-tap 2.2.0-beta.9 → 3.0.0-next.20261002094057
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/components/CharacterPicker.d.ts +31 -0
- package/dist/components/CharacterPicker.js +141 -0
- package/dist/components/EditableHtml.d.ts +11 -0
- package/dist/components/EditableHtml.js +331 -0
- package/dist/components/MenuBar.d.ts +11 -0
- package/dist/components/MenuBar.js +531 -0
- package/dist/components/TiptapContainer.d.ts +11 -0
- package/dist/components/TiptapContainer.js +167 -0
- package/dist/components/characters/characterUtils.d.ts +35 -0
- package/dist/components/characters/characterUtils.js +465 -0
- package/dist/components/characters/custom-popper.d.ts +14 -0
- package/dist/components/characters/custom-popper.js +32 -0
- package/dist/components/common/done-button.d.ts +30 -0
- package/dist/components/common/done-button.js +26 -0
- package/dist/components/common/toolbar-buttons.d.ts +38 -0
- package/dist/components/common/toolbar-buttons.js +96 -0
- package/dist/components/icons/CssIcon.d.ts +11 -0
- package/dist/components/icons/CssIcon.js +14 -0
- package/dist/components/icons/RespArea.d.ts +26 -0
- package/dist/components/icons/RespArea.js +42 -0
- package/dist/components/icons/TableIcons.d.ts +14 -0
- package/dist/components/icons/TableIcons.js +34 -0
- package/dist/components/icons/TextAlign.d.ts +18 -0
- package/dist/components/icons/TextAlign.js +143 -0
- package/dist/components/image/AltDialog.d.ts +22 -0
- package/dist/components/image/AltDialog.js +61 -0
- package/dist/components/image/ImageToolbar.d.ts +24 -0
- package/dist/components/image/ImageToolbar.js +80 -0
- package/dist/components/image/InsertImageHandler.d.ts +33 -0
- package/dist/components/image/InsertImageHandler.js +65 -0
- package/dist/components/image/findImageNode.d.ts +3 -0
- package/dist/components/image/findImageNode.js +11 -0
- package/dist/components/media/MediaDialog.d.ts +43 -0
- package/dist/components/media/MediaDialog.js +389 -0
- package/dist/components/media/MediaToolbar.d.ts +19 -0
- package/dist/components/media/MediaToolbar.js +41 -0
- package/dist/components/respArea/DragInTheBlank/DragInTheBlank.d.ts +23 -0
- package/dist/components/respArea/DragInTheBlank/DragInTheBlank.js +58 -0
- package/dist/components/respArea/DragInTheBlank/choice.d.ts +56 -0
- package/dist/components/respArea/DragInTheBlank/choice.js +157 -0
- package/dist/components/respArea/ExplicitConstructedResponse.d.ts +20 -0
- package/dist/components/respArea/ExplicitConstructedResponse.js +84 -0
- package/dist/components/respArea/InlineDropdown.d.ts +18 -0
- package/dist/components/respArea/InlineDropdown.js +126 -0
- package/dist/components/respArea/MathTemplated.d.ts +19 -0
- package/dist/components/respArea/MathTemplated.js +98 -0
- package/dist/components/respArea/ToolbarIcon.d.ts +14 -0
- package/dist/components/respArea/ToolbarIcon.js +17 -0
- package/dist/components/respArea/inlineDropdownUtils.d.ts +15 -0
- package/dist/components/respArea/inlineDropdownUtils.js +15 -0
- package/dist/constants.d.ts +13 -0
- package/dist/constants.js +4 -0
- package/dist/extensions/css.d.ts +11 -0
- package/dist/extensions/css.js +120 -0
- package/dist/extensions/custom-toolbar-wrapper.d.ts +11 -0
- package/dist/extensions/custom-toolbar-wrapper.js +61 -0
- package/dist/extensions/div-node.d.ts +10 -0
- package/dist/extensions/div-node.js +42 -0
- package/dist/extensions/ensure-empty-root-div.d.ts +14 -0
- package/dist/extensions/ensure-empty-root-div.js +24 -0
- package/dist/extensions/ensure-list-item-content-is-div.d.ts +15 -0
- package/dist/extensions/ensure-list-item-content-is-div.js +31 -0
- package/dist/extensions/extended-list-item.d.ts +13 -0
- package/dist/extensions/extended-list-item.js +5 -0
- package/dist/extensions/extended-table-cell.d.ts +10 -0
- package/dist/extensions/extended-table-cell.js +6 -0
- package/dist/extensions/extended-table.d.ts +17 -0
- package/dist/extensions/extended-table.js +34 -0
- package/dist/extensions/heading-paragraph.d.ts +17 -0
- package/dist/extensions/heading-paragraph.js +30 -0
- package/dist/extensions/image-component.d.ts +22 -0
- package/dist/extensions/image-component.js +223 -0
- package/dist/extensions/image.d.ts +10 -0
- package/dist/extensions/image.js +77 -0
- package/dist/extensions/index.d.ts +16 -0
- package/dist/extensions/index.js +64 -0
- package/dist/extensions/math.d.ts +15 -0
- package/dist/extensions/math.js +214 -0
- package/dist/extensions/media.d.ts +19 -0
- package/dist/extensions/media.js +149 -0
- package/dist/extensions/responseArea.d.ts +27 -0
- package/dist/extensions/responseArea.js +255 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +7 -0
- package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +16 -0
- package/dist/utils/helper.d.ts +9 -0
- package/dist/utils/helper.js +27 -0
- package/dist/utils/size.d.ts +9 -0
- package/dist/utils/size.js +14 -0
- package/dist/utils/toolbar.d.ts +10 -0
- package/dist/utils/toolbar.js +7 -0
- package/package.json +59 -43
- package/CHANGELOG.json +0 -32
- package/CHANGELOG.md +0 -2532
- package/lib/components/CharacterPicker.js +0 -226
- package/lib/components/CharacterPicker.js.map +0 -1
- package/lib/components/EditableHtml.js +0 -388
- package/lib/components/EditableHtml.js.map +0 -1
- package/lib/components/MenuBar.js +0 -702
- package/lib/components/MenuBar.js.map +0 -1
- package/lib/components/TiptapContainer.js +0 -242
- package/lib/components/TiptapContainer.js.map +0 -1
- package/lib/components/characters/characterUtils.js +0 -378
- package/lib/components/characters/characterUtils.js.map +0 -1
- package/lib/components/characters/custom-popper.js +0 -44
- package/lib/components/characters/custom-popper.js.map +0 -1
- package/lib/components/common/done-button.js +0 -34
- package/lib/components/common/done-button.js.map +0 -1
- package/lib/components/common/toolbar-buttons.js +0 -149
- package/lib/components/common/toolbar-buttons.js.map +0 -1
- package/lib/components/icons/CssIcon.js +0 -25
- package/lib/components/icons/CssIcon.js.map +0 -1
- package/lib/components/icons/RespArea.js +0 -72
- package/lib/components/icons/RespArea.js.map +0 -1
- package/lib/components/icons/TableIcons.js +0 -53
- package/lib/components/icons/TableIcons.js.map +0 -1
- package/lib/components/icons/TextAlign.js +0 -157
- package/lib/components/icons/TextAlign.js.map +0 -1
- package/lib/components/image/AltDialog.js +0 -98
- package/lib/components/image/AltDialog.js.map +0 -1
- package/lib/components/image/ImageToolbar.js +0 -137
- package/lib/components/image/ImageToolbar.js.map +0 -1
- package/lib/components/image/InsertImageHandler.js +0 -135
- package/lib/components/image/InsertImageHandler.js.map +0 -1
- package/lib/components/media/MediaDialog.js +0 -594
- package/lib/components/media/MediaDialog.js.map +0 -1
- package/lib/components/media/MediaToolbar.js +0 -74
- package/lib/components/media/MediaToolbar.js.map +0 -1
- package/lib/components/media/MediaWrapper.js +0 -67
- package/lib/components/media/MediaWrapper.js.map +0 -1
- package/lib/components/respArea/DragInTheBlank/DragInTheBlank.js +0 -84
- package/lib/components/respArea/DragInTheBlank/DragInTheBlank.js.map +0 -1
- package/lib/components/respArea/DragInTheBlank/choice.js +0 -253
- package/lib/components/respArea/DragInTheBlank/choice.js.map +0 -1
- package/lib/components/respArea/ExplicitConstructedResponse.js +0 -137
- package/lib/components/respArea/ExplicitConstructedResponse.js.map +0 -1
- package/lib/components/respArea/InlineDropdown.js +0 -223
- package/lib/components/respArea/InlineDropdown.js.map +0 -1
- package/lib/components/respArea/MathTemplated.js +0 -130
- package/lib/components/respArea/MathTemplated.js.map +0 -1
- package/lib/components/respArea/ToolbarIcon.js +0 -81
- package/lib/components/respArea/ToolbarIcon.js.map +0 -1
- package/lib/components/respArea/inlineDropdownUtils.js +0 -67
- package/lib/components/respArea/inlineDropdownUtils.js.map +0 -1
- package/lib/constants.js +0 -11
- package/lib/constants.js.map +0 -1
- package/lib/extensions/css.js +0 -227
- package/lib/extensions/css.js.map +0 -1
- package/lib/extensions/custom-toolbar-wrapper.js +0 -92
- package/lib/extensions/custom-toolbar-wrapper.js.map +0 -1
- package/lib/extensions/div-node.js +0 -83
- package/lib/extensions/div-node.js.map +0 -1
- package/lib/extensions/ensure-empty-root-div.js +0 -48
- package/lib/extensions/ensure-empty-root-div.js.map +0 -1
- package/lib/extensions/ensure-list-item-content-is-div.js +0 -64
- package/lib/extensions/ensure-list-item-content-is-div.js.map +0 -1
- package/lib/extensions/extended-list-item.js +0 -15
- package/lib/extensions/extended-list-item.js.map +0 -1
- package/lib/extensions/extended-table-cell.js +0 -22
- package/lib/extensions/extended-table-cell.js.map +0 -1
- package/lib/extensions/extended-table.js +0 -75
- package/lib/extensions/extended-table.js.map +0 -1
- package/lib/extensions/heading-paragraph.js +0 -61
- package/lib/extensions/heading-paragraph.js.map +0 -1
- package/lib/extensions/image-component.js +0 -351
- package/lib/extensions/image-component.js.map +0 -1
- package/lib/extensions/image.js +0 -134
- package/lib/extensions/image.js.map +0 -1
- package/lib/extensions/index.js +0 -46
- package/lib/extensions/index.js.map +0 -1
- package/lib/extensions/math.js +0 -469
- package/lib/extensions/math.js.map +0 -1
- package/lib/extensions/media.js +0 -243
- package/lib/extensions/media.js.map +0 -1
- package/lib/extensions/responseArea.js +0 -452
- package/lib/extensions/responseArea.js.map +0 -1
- package/lib/index.js +0 -37
- package/lib/index.js.map +0 -1
- package/lib/styles/editorContainerStyles.js +0 -137
- package/lib/styles/editorContainerStyles.js.map +0 -1
- package/lib/theme.js +0 -8
- package/lib/theme.js.map +0 -1
- package/lib/utils/helper.js +0 -73
- package/lib/utils/helper.js.map +0 -1
- package/lib/utils/size.js +0 -26
- package/lib/utils/size.js.map +0 -1
- package/lib/utils/toolbar.js +0 -19
- package/lib/utils/toolbar.js.map +0 -1
- package/src/components/CharacterPicker.jsx +0 -237
- package/src/components/EditableHtml.jsx +0 -458
- package/src/components/MenuBar.jsx +0 -561
- package/src/components/TiptapContainer.jsx +0 -235
- package/src/components/characters/characterUtils.js +0 -447
- package/src/components/characters/custom-popper.js +0 -38
- package/src/components/common/done-button.jsx +0 -27
- package/src/components/common/toolbar-buttons.jsx +0 -127
- package/src/components/icons/CssIcon.jsx +0 -15
- package/src/components/icons/RespArea.jsx +0 -71
- package/src/components/icons/TableIcons.jsx +0 -52
- package/src/components/icons/TextAlign.jsx +0 -114
- package/src/components/image/AltDialog.jsx +0 -82
- package/src/components/image/ImageToolbar.jsx +0 -99
- package/src/components/image/InsertImageHandler.js +0 -107
- package/src/components/media/MediaDialog.jsx +0 -596
- package/src/components/media/MediaToolbar.jsx +0 -49
- package/src/components/media/MediaWrapper.jsx +0 -39
- package/src/components/respArea/DragInTheBlank/DragInTheBlank.jsx +0 -76
- package/src/components/respArea/DragInTheBlank/choice.jsx +0 -259
- package/src/components/respArea/ExplicitConstructedResponse.jsx +0 -136
- package/src/components/respArea/InlineDropdown.jsx +0 -240
- package/src/components/respArea/MathTemplated.jsx +0 -124
- package/src/components/respArea/ToolbarIcon.jsx +0 -66
- package/src/components/respArea/inlineDropdownUtils.js +0 -79
- package/src/constants.js +0 -5
- package/src/extensions/css.js +0 -233
- package/src/extensions/custom-toolbar-wrapper.jsx +0 -78
- package/src/extensions/div-node.js +0 -86
- package/src/extensions/ensure-empty-root-div.js +0 -47
- package/src/extensions/ensure-list-item-content-is-div.js +0 -62
- package/src/extensions/extended-list-item.js +0 -10
- package/src/extensions/extended-table-cell.js +0 -19
- package/src/extensions/extended-table.js +0 -60
- package/src/extensions/heading-paragraph.js +0 -53
- package/src/extensions/image-component.jsx +0 -340
- package/src/extensions/image.js +0 -109
- package/src/extensions/index.js +0 -81
- package/src/extensions/math.js +0 -454
- package/src/extensions/media.js +0 -188
- package/src/extensions/responseArea.js +0 -407
- package/src/index.jsx +0 -5
- package/src/styles/editorContainerStyles.js +0 -145
- package/src/theme.js +0 -1
- package/src/utils/helper.js +0 -69
- package/src/utils/size.js +0 -32
- package/src/utils/toolbar.js +0 -15
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { color } from '@pie-lib/render-ui';
|
|
2
|
-
|
|
3
|
-
const styles = (theme) => ({
|
|
4
|
-
root: {
|
|
5
|
-
position: 'relative',
|
|
6
|
-
padding: '0px',
|
|
7
|
-
border: '1px solid #ccc',
|
|
8
|
-
borderRadius: '4px',
|
|
9
|
-
cursor: 'text',
|
|
10
|
-
'& [data-slate-editor="true"]': {
|
|
11
|
-
wordBreak: 'break-word',
|
|
12
|
-
overflow: 'visible',
|
|
13
|
-
maxHeight: '500px',
|
|
14
|
-
// needed in order to be able to put the focus before a void element when it is the first one in the editor
|
|
15
|
-
padding: '5px',
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
'&:first-child': {
|
|
19
|
-
marginTop: 0,
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
'& ul, & ol': {
|
|
23
|
-
padding: '0 1rem',
|
|
24
|
-
margin: '1.25rem 1rem 1.25rem 0.4rem',
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
'& ul li p, & ol li p': {
|
|
28
|
-
marginTop: '0.25em',
|
|
29
|
-
marginBottom: '0.25em',
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
'& h1, & h2, & h3, & h4, & h5, & h6': {
|
|
33
|
-
lineHeight: 1.1,
|
|
34
|
-
marginTop: '2.5rem',
|
|
35
|
-
textWrap: 'pretty',
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
'& h1, & h2': {
|
|
39
|
-
marginTop: '3.5rem',
|
|
40
|
-
marginBottom: '1.5rem',
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
'& h1': {
|
|
44
|
-
fontSize: '1.4rem',
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
'& h2': {
|
|
48
|
-
fontSize: '1.2rem',
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
'& h3': {
|
|
52
|
-
fontSize: '1.1rem',
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
'& h4, & h5, & h6': {
|
|
56
|
-
fontSize: '1rem',
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
'& code': {
|
|
60
|
-
backgroundColor: 'var(--purple-light)',
|
|
61
|
-
borderRadius: '0.4rem',
|
|
62
|
-
color: 'var(--black)',
|
|
63
|
-
fontSize: '0.85rem',
|
|
64
|
-
padding: '0.25em 0.3em',
|
|
65
|
-
},
|
|
66
|
-
|
|
67
|
-
'& pre': {
|
|
68
|
-
background: 'var(--black)',
|
|
69
|
-
borderRadius: '0.5rem',
|
|
70
|
-
color: 'var(--white)',
|
|
71
|
-
fontFamily: '\'JetBrainsMono\', monospace',
|
|
72
|
-
margin: '1.5rem 0',
|
|
73
|
-
padding: '0.75rem 1rem',
|
|
74
|
-
|
|
75
|
-
'& code': {
|
|
76
|
-
background: 'none',
|
|
77
|
-
color: 'inherit',
|
|
78
|
-
fontSize: '0.8rem',
|
|
79
|
-
padding: 0,
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
'& blockquote': {
|
|
84
|
-
background: '#f9f9f9',
|
|
85
|
-
borderLeft: '5px solid #ccc',
|
|
86
|
-
margin: '1.5em 10px',
|
|
87
|
-
padding: '.5em 10px',
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
'& hr': {
|
|
91
|
-
border: 'none',
|
|
92
|
-
borderTop: '1px solid var(--gray-2)',
|
|
93
|
-
margin: '2rem 0',
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
'& table': {
|
|
97
|
-
tableLayout: 'fixed',
|
|
98
|
-
width: '100%',
|
|
99
|
-
borderCollapse: 'collapse',
|
|
100
|
-
color: color.text(),
|
|
101
|
-
backgroundColor: color.background(),
|
|
102
|
-
},
|
|
103
|
-
'& table:not([border="1"]) tr': {
|
|
104
|
-
borderTop: '1px solid #dfe2e5',
|
|
105
|
-
},
|
|
106
|
-
'& td, th': {
|
|
107
|
-
padding: '.6em 1em',
|
|
108
|
-
textAlign: 'center',
|
|
109
|
-
},
|
|
110
|
-
'& table:not([border="1"]) td, th': {
|
|
111
|
-
border: '1px solid #dfe2e5',
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
children: {
|
|
115
|
-
padding: '10px 16px',
|
|
116
|
-
},
|
|
117
|
-
editorHolder: {
|
|
118
|
-
position: 'relative',
|
|
119
|
-
padding: '0px',
|
|
120
|
-
overflowY: 'auto',
|
|
121
|
-
color: color.text(),
|
|
122
|
-
backgroundColor: color.background(),
|
|
123
|
-
},
|
|
124
|
-
disabledScrollbar: {
|
|
125
|
-
'&::-webkit-scrollbar': {
|
|
126
|
-
display: 'none',
|
|
127
|
-
},
|
|
128
|
-
scrollbarWidth: 'none',
|
|
129
|
-
'-ms-overflow-style': 'none',
|
|
130
|
-
},
|
|
131
|
-
error: {
|
|
132
|
-
border: `2px solid ${theme.palette.error.main} !important`,
|
|
133
|
-
},
|
|
134
|
-
noBorder: {
|
|
135
|
-
border: 'none',
|
|
136
|
-
},
|
|
137
|
-
noPadding: {
|
|
138
|
-
padding: 0,
|
|
139
|
-
},
|
|
140
|
-
toolbarOnTop: {
|
|
141
|
-
marginTop: '45px',
|
|
142
|
-
},
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
export default styles;
|
package/src/theme.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const primary = '#304ffe';
|
package/src/utils/helper.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
const escapeHtml = (str) =>
|
|
2
|
-
String(str)
|
|
3
|
-
.replace(/&/g, '&')
|
|
4
|
-
.replace(/</g, '<')
|
|
5
|
-
.replace(/>/g, '>')
|
|
6
|
-
.replace(/"/g, '"')
|
|
7
|
-
.replace(/'/g, ''');
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Converts consecutive div elements into a single paragraph with line breaks.
|
|
11
|
-
* Example: "<div>A</div><div>B</div>" becomes "<p>A<br>B</p>"
|
|
12
|
-
*/
|
|
13
|
-
const convertConsecutiveDivsToParagraph = (html) => {
|
|
14
|
-
// Create a temporary element to parse the HTML
|
|
15
|
-
const temp = document.createElement('div');
|
|
16
|
-
temp.innerHTML = html;
|
|
17
|
-
|
|
18
|
-
// Get all top-level children
|
|
19
|
-
const children = Array.from(temp.children);
|
|
20
|
-
|
|
21
|
-
// Only convert if there are 2 or more divs
|
|
22
|
-
if (children.length < 2) {
|
|
23
|
-
return html;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Check if all children are divs with simple content (text or inline elements)
|
|
27
|
-
const allDivs = children.every((child) => child.tagName === 'DIV');
|
|
28
|
-
|
|
29
|
-
if (!allDivs) {
|
|
30
|
-
return html;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Check if divs have no attributes (only convert plain divs)
|
|
34
|
-
const hasNoAttributes = children.every((div) => div.attributes.length === 0);
|
|
35
|
-
|
|
36
|
-
if (!hasNoAttributes) {
|
|
37
|
-
return html;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Check if divs contain only simple content (no nested block elements)
|
|
41
|
-
const hasOnlySimpleContent = children.every((div) => {
|
|
42
|
-
return Array.from(div.children).every((child) => {
|
|
43
|
-
const tag = child.tagName;
|
|
44
|
-
// Allow inline elements and br tags
|
|
45
|
-
return ['SPAN', 'B', 'I', 'EM', 'STRONG', 'U', 'SUB', 'SUP', 'A', 'CODE', 'BR'].includes(tag);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
if (!hasOnlySimpleContent) {
|
|
50
|
-
return html;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Convert to paragraph with br tags
|
|
54
|
-
const contents = children.map((div) => div.innerHTML);
|
|
55
|
-
return `<p>${contents.join('<br>')}</p>`;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export const normalizeInitialMarkup = (markup) => {
|
|
59
|
-
const trimmed = String(markup ?? '').trim();
|
|
60
|
-
if (!trimmed) return '<div></div>';
|
|
61
|
-
|
|
62
|
-
const looksLikeHtml = /<[^>]+>/.test(trimmed);
|
|
63
|
-
if (!looksLikeHtml) {
|
|
64
|
-
return `<div>${escapeHtml(trimmed)}</div>`;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Apply the div-to-paragraph transformation
|
|
68
|
-
return convertConsecutiveDivsToParagraph(trimmed);
|
|
69
|
-
};
|
package/src/utils/size.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export const valueToSize = (v) => {
|
|
2
|
-
if (!v) {
|
|
3
|
-
return;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
const calcRegex = /^calc\((.*)\)$/;
|
|
7
|
-
|
|
8
|
-
if (typeof v === 'string') {
|
|
9
|
-
if (v.endsWith('%')) {
|
|
10
|
-
return undefined;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (
|
|
14
|
-
v.endsWith('px') ||
|
|
15
|
-
v.endsWith('vh') ||
|
|
16
|
-
v.endsWith('vw') ||
|
|
17
|
-
v.endsWith('ch') ||
|
|
18
|
-
v.endsWith('em') ||
|
|
19
|
-
v.match(calcRegex)
|
|
20
|
-
) {
|
|
21
|
-
return v;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const value = parseInt(v, 10);
|
|
25
|
-
|
|
26
|
-
return Number.isNaN(value) ? value : `${value}px`;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (typeof v === 'number') {
|
|
30
|
-
return `${v}px`;
|
|
31
|
-
}
|
|
32
|
-
};
|
package/src/utils/toolbar.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export const TOOLBAR_OPENED_META_KEY = 'toolbarOpenedChanged';
|
|
2
|
-
|
|
3
|
-
export const setToolbarOpened = (editor, opened) => {
|
|
4
|
-
const next = !!opened;
|
|
5
|
-
|
|
6
|
-
if (editor._toolbarOpened === next) {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
editor._toolbarOpened = next;
|
|
11
|
-
|
|
12
|
-
if (editor?.view && editor?.state?.tr) {
|
|
13
|
-
editor.view.dispatch(editor.state.tr.setMeta(TOOLBAR_OPENED_META_KEY, true));
|
|
14
|
-
}
|
|
15
|
-
};
|