@pie-lib/editable-html-tip-tap 2.1.2-next.3 → 2.1.2-next.30
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 +131 -0
- package/dist/components/EditableHtml.d.ts +11 -0
- package/dist/components/EditableHtml.js +291 -0
- package/dist/components/MenuBar.d.ts +11 -0
- package/dist/components/MenuBar.js +462 -0
- package/dist/components/TiptapContainer.d.ts +11 -0
- package/dist/components/TiptapContainer.js +154 -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 +91 -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 +32 -0
- package/dist/components/icons/TextAlign.d.ts +18 -0
- package/dist/components/icons/TextAlign.js +134 -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 +32 -0
- package/dist/components/image/InsertImageHandler.js +53 -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/media/MediaWrapper.d.ts +19 -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 +156 -0
- package/dist/components/respArea/ExplicitConstructedResponse.d.ts +20 -0
- package/dist/components/respArea/ExplicitConstructedResponse.js +83 -0
- package/dist/components/respArea/InlineDropdown.d.ts +18 -0
- package/dist/components/respArea/InlineDropdown.js +119 -0
- package/dist/components/respArea/MathTemplated.d.ts +19 -0
- package/dist/components/respArea/MathTemplated.js +97 -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 +115 -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 +220 -0
- package/dist/extensions/image.d.ts +10 -0
- package/dist/extensions/image.js +68 -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 +158 -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 +259 -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/styles/editorContainerStyles.d.ts +134 -0
- package/dist/theme.d.ts +9 -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/package.json +56 -40
- package/CHANGELOG.json +0 -32
- package/CHANGELOG.md +0 -2532
- package/LICENSE.md +0 -5
- package/lib/components/CharacterPicker.js +0 -195
- package/lib/components/CharacterPicker.js.map +0 -1
- package/lib/components/EditableHtml.js +0 -375
- package/lib/components/EditableHtml.js.map +0 -1
- package/lib/components/MenuBar.js +0 -693
- package/lib/components/MenuBar.js.map +0 -1
- package/lib/components/TiptapContainer.js +0 -234
- 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 -144
- 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 -250
- package/lib/components/respArea/DragInTheBlank/choice.js.map +0 -1
- package/lib/components/respArea/ExplicitConstructedResponse.js +0 -136
- package/lib/components/respArea/ExplicitConstructedResponse.js.map +0 -1
- package/lib/components/respArea/InlineDropdown.js +0 -165
- 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/constants.js +0 -11
- package/lib/constants.js.map +0 -1
- package/lib/extensions/css.js +0 -217
- 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 -348
- 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 -343
- 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 -446
- package/lib/extensions/responseArea.js.map +0 -1
- package/lib/index.js +0 -30
- 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/src/__tests__/EditableHtml.test.jsx +0 -474
- package/src/__tests__/constants.test.js +0 -19
- package/src/__tests__/div-to-paragraph-conversion.test.jsx +0 -125
- package/src/__tests__/extensions.test.js +0 -208
- package/src/__tests__/index.test.jsx +0 -154
- package/src/__tests__/size-utils.test.js +0 -64
- package/src/__tests__/theme.test.js +0 -17
- package/src/components/CharacterPicker.jsx +0 -200
- package/src/components/EditableHtml.jsx +0 -438
- package/src/components/MenuBar.jsx +0 -549
- package/src/components/TiptapContainer.jsx +0 -219
- package/src/components/__tests__/AltDialog.test.jsx +0 -147
- package/src/components/__tests__/CharacterPicker.test.jsx +0 -219
- package/src/components/__tests__/CssIcon.test.jsx +0 -46
- package/src/components/__tests__/DragInTheBlank.test.jsx +0 -255
- package/src/components/__tests__/ExplicitConstructedResponse.test.jsx +0 -204
- package/src/components/__tests__/ImageToolbar.test.jsx +0 -128
- package/src/components/__tests__/InlineDropdown.test.jsx +0 -380
- package/src/components/__tests__/InsertImageHandler.test.js +0 -161
- package/src/components/__tests__/MediaDialog.test.jsx +0 -293
- package/src/components/__tests__/MediaToolbar.test.jsx +0 -74
- package/src/components/__tests__/MediaWrapper.test.jsx +0 -81
- package/src/components/__tests__/MenuBar.test.jsx +0 -249
- package/src/components/__tests__/RespArea.test.jsx +0 -122
- package/src/components/__tests__/TableIcons.test.jsx +0 -149
- package/src/components/__tests__/TextAlign.test.jsx +0 -167
- package/src/components/__tests__/TiptapContainer.test.jsx +0 -138
- package/src/components/__tests__/characterUtils.test.js +0 -166
- package/src/components/__tests__/choice.test.jsx +0 -171
- package/src/components/__tests__/custom-popper.test.jsx +0 -82
- package/src/components/__tests__/done-button.test.jsx +0 -54
- package/src/components/__tests__/toolbar-buttons.test.jsx +0 -234
- 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 -122
- 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 -256
- package/src/components/respArea/ExplicitConstructedResponse.jsx +0 -135
- package/src/components/respArea/InlineDropdown.jsx +0 -167
- package/src/components/respArea/MathTemplated.jsx +0 -124
- package/src/components/respArea/ToolbarIcon.jsx +0 -66
- package/src/components/respArea/__tests__/MathTemplated.test.jsx +0 -210
- package/src/constants.js +0 -5
- package/src/extensions/__tests__/css.test.js +0 -196
- package/src/extensions/__tests__/custom-toolbar-wrapper.test.jsx +0 -180
- package/src/extensions/__tests__/divNode.test.js +0 -87
- package/src/extensions/__tests__/ensure-empty-root-div.test.js +0 -57
- package/src/extensions/__tests__/ensure-list-item-content-is-div.test.js +0 -44
- package/src/extensions/__tests__/extended-list-item.test.js +0 -13
- package/src/extensions/__tests__/extended-table-cell.test.js +0 -22
- package/src/extensions/__tests__/extended-table.test.js +0 -183
- package/src/extensions/__tests__/image-component.test.jsx +0 -345
- package/src/extensions/__tests__/image.test.js +0 -237
- package/src/extensions/__tests__/math.test.js +0 -459
- package/src/extensions/__tests__/media-node-view.test.jsx +0 -298
- package/src/extensions/__tests__/media.test.js +0 -271
- package/src/extensions/__tests__/responseArea.test.js +0 -601
- package/src/extensions/css.js +0 -220
- 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 -338
- package/src/extensions/image.js +0 -109
- package/src/extensions/index.js +0 -81
- package/src/extensions/math.js +0 -327
- package/src/extensions/media.js +0 -188
- package/src/extensions/responseArea.js +0 -401
- package/src/index.jsx +0 -5
- package/src/styles/editorContainerStyles.js +0 -145
- package/src/theme.js +0 -1
- package/src/utils/__tests__/helper.test.js +0 -126
- package/src/utils/helper.js +0 -69
- package/src/utils/size.js +0 -32
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"editorContainerStyles.js","names":["_renderUi","require","styles","theme","root","position","padding","border","borderRadius","cursor","wordBreak","overflow","maxHeight","marginTop","margin","marginBottom","lineHeight","textWrap","fontSize","backgroundColor","color","background","fontFamily","borderLeft","borderTop","tableLayout","width","borderCollapse","text","textAlign","children","editorHolder","overflowY","disabledScrollbar","display","scrollbarWidth","error","concat","palette","main","noBorder","noPadding","toolbarOnTop","_default","exports"],"sources":["../../src/styles/editorContainerStyles.js"],"sourcesContent":["import { color } from '@pie-lib/render-ui';\n\nconst styles = (theme) => ({\n root: {\n position: 'relative',\n padding: '0px',\n border: '1px solid #ccc',\n borderRadius: '4px',\n cursor: 'text',\n '& [data-slate-editor=\"true\"]': {\n wordBreak: 'break-word',\n overflow: 'visible',\n maxHeight: '500px',\n // needed in order to be able to put the focus before a void element when it is the first one in the editor\n padding: '5px',\n },\n\n '&:first-child': {\n marginTop: 0,\n },\n\n '& ul, & ol': {\n padding: '0 1rem',\n margin: '1.25rem 1rem 1.25rem 0.4rem',\n },\n\n '& ul li p, & ol li p': {\n marginTop: '0.25em',\n marginBottom: '0.25em',\n },\n\n '& h1, & h2, & h3, & h4, & h5, & h6': {\n lineHeight: 1.1,\n marginTop: '2.5rem',\n textWrap: 'pretty',\n },\n\n '& h1, & h2': {\n marginTop: '3.5rem',\n marginBottom: '1.5rem',\n },\n\n '& h1': {\n fontSize: '1.4rem',\n },\n\n '& h2': {\n fontSize: '1.2rem',\n },\n\n '& h3': {\n fontSize: '1.1rem',\n },\n\n '& h4, & h5, & h6': {\n fontSize: '1rem',\n },\n\n '& code': {\n backgroundColor: 'var(--purple-light)',\n borderRadius: '0.4rem',\n color: 'var(--black)',\n fontSize: '0.85rem',\n padding: '0.25em 0.3em',\n },\n\n '& pre': {\n background: 'var(--black)',\n borderRadius: '0.5rem',\n color: 'var(--white)',\n fontFamily: '\\'JetBrainsMono\\', monospace',\n margin: '1.5rem 0',\n padding: '0.75rem 1rem',\n\n '& code': {\n background: 'none',\n color: 'inherit',\n fontSize: '0.8rem',\n padding: 0,\n },\n },\n\n '& blockquote': {\n background: '#f9f9f9',\n borderLeft: '5px solid #ccc',\n margin: '1.5em 10px',\n padding: '.5em 10px',\n },\n\n '& hr': {\n border: 'none',\n borderTop: '1px solid var(--gray-2)',\n margin: '2rem 0',\n },\n\n '& table': {\n tableLayout: 'fixed',\n width: '100%',\n borderCollapse: 'collapse',\n color: color.text(),\n backgroundColor: color.background(),\n },\n '& table:not([border=\"1\"]) tr': {\n borderTop: '1px solid #dfe2e5',\n },\n '& td, th': {\n padding: '.6em 1em',\n textAlign: 'center',\n },\n '& table:not([border=\"1\"]) td, th': {\n border: '1px solid #dfe2e5',\n },\n },\n children: {\n padding: '10px 16px',\n },\n editorHolder: {\n position: 'relative',\n padding: '0px',\n overflowY: 'auto',\n color: color.text(),\n backgroundColor: color.background(),\n },\n disabledScrollbar: {\n '&::-webkit-scrollbar': {\n display: 'none',\n },\n scrollbarWidth: 'none',\n '-ms-overflow-style': 'none',\n },\n error: {\n border: `2px solid ${theme.palette.error.main} !important`,\n },\n noBorder: {\n border: 'none',\n },\n noPadding: {\n padding: 0,\n },\n toolbarOnTop: {\n marginTop: '45px',\n },\n});\n\nexport default styles;\n"],"mappings":"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","ignoreList":[]}
|
package/lib/theme.js
DELETED
package/lib/theme.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"theme.js","names":["primary","exports"],"sources":["../src/theme.js"],"sourcesContent":["export const primary = '#304ffe';\n"],"mappings":";;;;;;AAAO,IAAMA,OAAO,GAAAC,OAAA,CAAAD,OAAA,GAAG,SAAS","ignoreList":[]}
|
package/lib/utils/helper.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.normalizeInitialMarkup = void 0;
|
|
7
|
-
var escapeHtml = function escapeHtml(str) {
|
|
8
|
-
return String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Converts consecutive div elements into a single paragraph with line breaks.
|
|
13
|
-
* Example: "<div>A</div><div>B</div>" becomes "<p>A<br>B</p>"
|
|
14
|
-
*/
|
|
15
|
-
var convertConsecutiveDivsToParagraph = function convertConsecutiveDivsToParagraph(html) {
|
|
16
|
-
// Create a temporary element to parse the HTML
|
|
17
|
-
var temp = document.createElement('div');
|
|
18
|
-
temp.innerHTML = html;
|
|
19
|
-
|
|
20
|
-
// Get all top-level children
|
|
21
|
-
var children = Array.from(temp.children);
|
|
22
|
-
|
|
23
|
-
// Only convert if there are 2 or more divs
|
|
24
|
-
if (children.length < 2) {
|
|
25
|
-
return html;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Check if all children are divs with simple content (text or inline elements)
|
|
29
|
-
var allDivs = children.every(function (child) {
|
|
30
|
-
return child.tagName === 'DIV';
|
|
31
|
-
});
|
|
32
|
-
if (!allDivs) {
|
|
33
|
-
return html;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// Check if divs have no attributes (only convert plain divs)
|
|
37
|
-
var hasNoAttributes = children.every(function (div) {
|
|
38
|
-
return div.attributes.length === 0;
|
|
39
|
-
});
|
|
40
|
-
if (!hasNoAttributes) {
|
|
41
|
-
return html;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Check if divs contain only simple content (no nested block elements)
|
|
45
|
-
var hasOnlySimpleContent = children.every(function (div) {
|
|
46
|
-
return Array.from(div.children).every(function (child) {
|
|
47
|
-
var tag = child.tagName;
|
|
48
|
-
// Allow inline elements and br tags
|
|
49
|
-
return ['SPAN', 'B', 'I', 'EM', 'STRONG', 'U', 'SUB', 'SUP', 'A', 'CODE', 'BR'].includes(tag);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
if (!hasOnlySimpleContent) {
|
|
53
|
-
return html;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Convert to paragraph with br tags
|
|
57
|
-
var contents = children.map(function (div) {
|
|
58
|
-
return div.innerHTML;
|
|
59
|
-
});
|
|
60
|
-
return "<p>".concat(contents.join('<br>'), "</p>");
|
|
61
|
-
};
|
|
62
|
-
var normalizeInitialMarkup = exports.normalizeInitialMarkup = function normalizeInitialMarkup(markup) {
|
|
63
|
-
var trimmed = String(markup !== null && markup !== void 0 ? markup : '').trim();
|
|
64
|
-
if (!trimmed) return '<div></div>';
|
|
65
|
-
var looksLikeHtml = /<[^>]+>/.test(trimmed);
|
|
66
|
-
if (!looksLikeHtml) {
|
|
67
|
-
return "<div>".concat(escapeHtml(trimmed), "</div>");
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Apply the div-to-paragraph transformation
|
|
71
|
-
return convertConsecutiveDivsToParagraph(trimmed);
|
|
72
|
-
};
|
|
73
|
-
//# sourceMappingURL=helper.js.map
|
package/lib/utils/helper.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helper.js","names":["escapeHtml","str","String","replace","convertConsecutiveDivsToParagraph","html","temp","document","createElement","innerHTML","children","Array","from","length","allDivs","every","child","tagName","hasNoAttributes","div","attributes","hasOnlySimpleContent","tag","includes","contents","map","concat","join","normalizeInitialMarkup","exports","markup","trimmed","trim","looksLikeHtml","test"],"sources":["../../src/utils/helper.js"],"sourcesContent":["const escapeHtml = (str) =>\n String(str)\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"')\n .replace(/'/g, ''');\n\n/**\n * Converts consecutive div elements into a single paragraph with line breaks.\n * Example: \"<div>A</div><div>B</div>\" becomes \"<p>A<br>B</p>\"\n */\nconst convertConsecutiveDivsToParagraph = (html) => {\n // Create a temporary element to parse the HTML\n const temp = document.createElement('div');\n temp.innerHTML = html;\n\n // Get all top-level children\n const children = Array.from(temp.children);\n\n // Only convert if there are 2 or more divs\n if (children.length < 2) {\n return html;\n }\n\n // Check if all children are divs with simple content (text or inline elements)\n const allDivs = children.every((child) => child.tagName === 'DIV');\n\n if (!allDivs) {\n return html;\n }\n\n // Check if divs have no attributes (only convert plain divs)\n const hasNoAttributes = children.every((div) => div.attributes.length === 0);\n\n if (!hasNoAttributes) {\n return html;\n }\n\n // Check if divs contain only simple content (no nested block elements)\n const hasOnlySimpleContent = children.every((div) => {\n return Array.from(div.children).every((child) => {\n const tag = child.tagName;\n // Allow inline elements and br tags\n return ['SPAN', 'B', 'I', 'EM', 'STRONG', 'U', 'SUB', 'SUP', 'A', 'CODE', 'BR'].includes(tag);\n });\n });\n\n if (!hasOnlySimpleContent) {\n return html;\n }\n\n // Convert to paragraph with br tags\n const contents = children.map((div) => div.innerHTML);\n return `<p>${contents.join('<br>')}</p>`;\n};\n\nexport const normalizeInitialMarkup = (markup) => {\n const trimmed = String(markup ?? '').trim();\n if (!trimmed) return '<div></div>';\n\n const looksLikeHtml = /<[^>]+>/.test(trimmed);\n if (!looksLikeHtml) {\n return `<div>${escapeHtml(trimmed)}</div>`;\n }\n\n // Apply the div-to-paragraph transformation\n return convertConsecutiveDivsToParagraph(trimmed);\n};\n"],"mappings":";;;;;;AAAA,IAAMA,UAAU,GAAG,SAAbA,UAAUA,CAAIC,GAAG;EAAA,OACrBC,MAAM,CAACD,GAAG,CAAC,CACRE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CACtBA,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CACrBA,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CACrBA,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CACvBA,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;AAAA;;AAE3B;AACA;AACA;AACA;AACA,IAAMC,iCAAiC,GAAG,SAApCA,iCAAiCA,CAAIC,IAAI,EAAK;EAClD;EACA,IAAMC,IAAI,GAAGC,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;EAC1CF,IAAI,CAACG,SAAS,GAAGJ,IAAI;;EAErB;EACA,IAAMK,QAAQ,GAAGC,KAAK,CAACC,IAAI,CAACN,IAAI,CAACI,QAAQ,CAAC;;EAE1C;EACA,IAAIA,QAAQ,CAACG,MAAM,GAAG,CAAC,EAAE;IACvB,OAAOR,IAAI;EACb;;EAEA;EACA,IAAMS,OAAO,GAAGJ,QAAQ,CAACK,KAAK,CAAC,UAACC,KAAK;IAAA,OAAKA,KAAK,CAACC,OAAO,KAAK,KAAK;EAAA,EAAC;EAElE,IAAI,CAACH,OAAO,EAAE;IACZ,OAAOT,IAAI;EACb;;EAEA;EACA,IAAMa,eAAe,GAAGR,QAAQ,CAACK,KAAK,CAAC,UAACI,GAAG;IAAA,OAAKA,GAAG,CAACC,UAAU,CAACP,MAAM,KAAK,CAAC;EAAA,EAAC;EAE5E,IAAI,CAACK,eAAe,EAAE;IACpB,OAAOb,IAAI;EACb;;EAEA;EACA,IAAMgB,oBAAoB,GAAGX,QAAQ,CAACK,KAAK,CAAC,UAACI,GAAG,EAAK;IACnD,OAAOR,KAAK,CAACC,IAAI,CAACO,GAAG,CAACT,QAAQ,CAAC,CAACK,KAAK,CAAC,UAACC,KAAK,EAAK;MAC/C,IAAMM,GAAG,GAAGN,KAAK,CAACC,OAAO;MACzB;MACA,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,CAACM,QAAQ,CAACD,GAAG,CAAC;IAC/F,CAAC,CAAC;EACJ,CAAC,CAAC;EAEF,IAAI,CAACD,oBAAoB,EAAE;IACzB,OAAOhB,IAAI;EACb;;EAEA;EACA,IAAMmB,QAAQ,GAAGd,QAAQ,CAACe,GAAG,CAAC,UAACN,GAAG;IAAA,OAAKA,GAAG,CAACV,SAAS;EAAA,EAAC;EACrD,aAAAiB,MAAA,CAAaF,QAAQ,CAACG,IAAI,CAAC,MAAM,CAAC;AACpC,CAAC;AAEM,IAAMC,sBAAsB,GAAAC,OAAA,CAAAD,sBAAA,GAAG,SAAzBA,sBAAsBA,CAAIE,MAAM,EAAK;EAChD,IAAMC,OAAO,GAAG7B,MAAM,CAAC4B,MAAM,aAANA,MAAM,cAANA,MAAM,GAAI,EAAE,CAAC,CAACE,IAAI,CAAC,CAAC;EAC3C,IAAI,CAACD,OAAO,EAAE,OAAO,aAAa;EAElC,IAAME,aAAa,GAAG,SAAS,CAACC,IAAI,CAACH,OAAO,CAAC;EAC7C,IAAI,CAACE,aAAa,EAAE;IAClB,eAAAP,MAAA,CAAe1B,UAAU,CAAC+B,OAAO,CAAC;EACpC;;EAEA;EACA,OAAO3B,iCAAiC,CAAC2B,OAAO,CAAC;AACnD,CAAC","ignoreList":[]}
|
package/lib/utils/size.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.valueToSize = void 0;
|
|
7
|
-
var valueToSize = exports.valueToSize = function valueToSize(v) {
|
|
8
|
-
if (!v) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
var calcRegex = /^calc\((.*)\)$/;
|
|
12
|
-
if (typeof v === 'string') {
|
|
13
|
-
if (v.endsWith('%')) {
|
|
14
|
-
return undefined;
|
|
15
|
-
}
|
|
16
|
-
if (v.endsWith('px') || v.endsWith('vh') || v.endsWith('vw') || v.endsWith('ch') || v.endsWith('em') || v.match(calcRegex)) {
|
|
17
|
-
return v;
|
|
18
|
-
}
|
|
19
|
-
var value = parseInt(v, 10);
|
|
20
|
-
return Number.isNaN(value) ? value : "".concat(value, "px");
|
|
21
|
-
}
|
|
22
|
-
if (typeof v === 'number') {
|
|
23
|
-
return "".concat(v, "px");
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=size.js.map
|
package/lib/utils/size.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"size.js","names":["valueToSize","exports","v","calcRegex","endsWith","undefined","match","value","parseInt","Number","isNaN","concat"],"sources":["../../src/utils/size.js"],"sourcesContent":["export const valueToSize = (v) => {\n if (!v) {\n return;\n }\n\n const calcRegex = /^calc\\((.*)\\)$/;\n\n if (typeof v === 'string') {\n if (v.endsWith('%')) {\n return undefined;\n }\n\n if (\n v.endsWith('px') ||\n v.endsWith('vh') ||\n v.endsWith('vw') ||\n v.endsWith('ch') ||\n v.endsWith('em') ||\n v.match(calcRegex)\n ) {\n return v;\n }\n\n const value = parseInt(v, 10);\n\n return Number.isNaN(value) ? value : `${value}px`;\n }\n\n if (typeof v === 'number') {\n return `${v}px`;\n }\n};\n"],"mappings":";;;;;;AAAO,IAAMA,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG,SAAdA,WAAWA,CAAIE,CAAC,EAAK;EAChC,IAAI,CAACA,CAAC,EAAE;IACN;EACF;EAEA,IAAMC,SAAS,GAAG,gBAAgB;EAElC,IAAI,OAAOD,CAAC,KAAK,QAAQ,EAAE;IACzB,IAAIA,CAAC,CAACE,QAAQ,CAAC,GAAG,CAAC,EAAE;MACnB,OAAOC,SAAS;IAClB;IAEA,IACEH,CAAC,CAACE,QAAQ,CAAC,IAAI,CAAC,IAChBF,CAAC,CAACE,QAAQ,CAAC,IAAI,CAAC,IAChBF,CAAC,CAACE,QAAQ,CAAC,IAAI,CAAC,IAChBF,CAAC,CAACE,QAAQ,CAAC,IAAI,CAAC,IAChBF,CAAC,CAACE,QAAQ,CAAC,IAAI,CAAC,IAChBF,CAAC,CAACI,KAAK,CAACH,SAAS,CAAC,EAClB;MACA,OAAOD,CAAC;IACV;IAEA,IAAMK,KAAK,GAAGC,QAAQ,CAACN,CAAC,EAAE,EAAE,CAAC;IAE7B,OAAOO,MAAM,CAACC,KAAK,CAACH,KAAK,CAAC,GAAGA,KAAK,MAAAI,MAAA,CAAMJ,KAAK,OAAI;EACnD;EAEA,IAAI,OAAOL,CAAC,KAAK,QAAQ,EAAE;IACzB,UAAAS,MAAA,CAAUT,CAAC;EACb;AACF,CAAC","ignoreList":[]}
|
|
@@ -1,474 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, waitFor } from '@testing-library/react';
|
|
3
|
-
import { useEditor } from '@tiptap/react';
|
|
4
|
-
import { EditableHtml } from '../components/EditableHtml';
|
|
5
|
-
|
|
6
|
-
// Mock TipTap dependencies
|
|
7
|
-
jest.mock('@tiptap/react', () => ({
|
|
8
|
-
EditorContent: ({ editor, ...props }) => <div data-testid="editor-content" {...props} />,
|
|
9
|
-
useEditor: jest.fn((config) => {
|
|
10
|
-
const mockEditor = {
|
|
11
|
-
getHTML: jest.fn(() => '<p>test content</p>'),
|
|
12
|
-
setEditable: jest.fn(),
|
|
13
|
-
commands: {
|
|
14
|
-
setContent: jest.fn(),
|
|
15
|
-
},
|
|
16
|
-
isActive: jest.fn(() => false),
|
|
17
|
-
isFocused: false,
|
|
18
|
-
};
|
|
19
|
-
return mockEditor;
|
|
20
|
-
}),
|
|
21
|
-
useEditorState: jest.fn(() => ({
|
|
22
|
-
isFocused: false,
|
|
23
|
-
})),
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
|
-
jest.mock('@tiptap/starter-kit', () => ({
|
|
27
|
-
__esModule: true,
|
|
28
|
-
default: {
|
|
29
|
-
configure: jest.fn(() => ({})),
|
|
30
|
-
},
|
|
31
|
-
}));
|
|
32
|
-
|
|
33
|
-
jest.mock('@tiptap/extension-text-style', () => ({
|
|
34
|
-
TextStyleKit: {},
|
|
35
|
-
}));
|
|
36
|
-
|
|
37
|
-
jest.mock('@tiptap/extension-character-count', () => ({
|
|
38
|
-
CharacterCount: {
|
|
39
|
-
configure: jest.fn(() => ({})),
|
|
40
|
-
},
|
|
41
|
-
}));
|
|
42
|
-
|
|
43
|
-
jest.mock('@tiptap/extension-superscript', () => ({
|
|
44
|
-
__esModule: true,
|
|
45
|
-
default: {},
|
|
46
|
-
}));
|
|
47
|
-
|
|
48
|
-
jest.mock('@tiptap/extension-subscript', () => ({
|
|
49
|
-
__esModule: true,
|
|
50
|
-
default: {},
|
|
51
|
-
}));
|
|
52
|
-
|
|
53
|
-
jest.mock('@tiptap/extension-text-align', () => ({
|
|
54
|
-
__esModule: true,
|
|
55
|
-
default: {
|
|
56
|
-
configure: jest.fn(() => ({})),
|
|
57
|
-
},
|
|
58
|
-
}));
|
|
59
|
-
|
|
60
|
-
jest.mock('@tiptap/extension-image', () => ({
|
|
61
|
-
__esModule: true,
|
|
62
|
-
default: {},
|
|
63
|
-
}));
|
|
64
|
-
|
|
65
|
-
jest.mock('@tiptap/extension-table', () => ({
|
|
66
|
-
__esModule: true,
|
|
67
|
-
default: {},
|
|
68
|
-
}));
|
|
69
|
-
|
|
70
|
-
jest.mock('@tiptap/extension-table-row', () => ({
|
|
71
|
-
TableRow: {},
|
|
72
|
-
}));
|
|
73
|
-
|
|
74
|
-
jest.mock('../extensions/extended-table-cell', () => ({
|
|
75
|
-
ExtendedTableCell: {},
|
|
76
|
-
ExtendedTableHeader: {},
|
|
77
|
-
}));
|
|
78
|
-
|
|
79
|
-
jest.mock('../extensions/extended-table', () => ({
|
|
80
|
-
__esModule: true,
|
|
81
|
-
default: {},
|
|
82
|
-
}));
|
|
83
|
-
|
|
84
|
-
jest.mock('../extensions/ensure-empty-root-div', () => ({
|
|
85
|
-
EnsureEmptyRootIsDiv: {},
|
|
86
|
-
}));
|
|
87
|
-
|
|
88
|
-
jest.mock('../extensions/extended-list-item', () => ({
|
|
89
|
-
ExtendedListItem: {},
|
|
90
|
-
}));
|
|
91
|
-
|
|
92
|
-
jest.mock('../extensions/ensure-list-item-content-is-div', () => ({
|
|
93
|
-
EnsureListItemContentIsDiv: {},
|
|
94
|
-
}));
|
|
95
|
-
|
|
96
|
-
jest.mock('../extensions/responseArea', () => ({
|
|
97
|
-
ExplicitConstructedResponseNode: {
|
|
98
|
-
configure: jest.fn(() => ({})),
|
|
99
|
-
},
|
|
100
|
-
DragInTheBlankNode: {
|
|
101
|
-
configure: jest.fn(() => ({})),
|
|
102
|
-
},
|
|
103
|
-
InlineDropdownNode: {
|
|
104
|
-
configure: jest.fn(() => ({})),
|
|
105
|
-
},
|
|
106
|
-
MathTemplatedNode: {
|
|
107
|
-
configure: jest.fn(() => ({})),
|
|
108
|
-
},
|
|
109
|
-
ResponseAreaExtension: {
|
|
110
|
-
configure: jest.fn(() => ({})),
|
|
111
|
-
},
|
|
112
|
-
}));
|
|
113
|
-
|
|
114
|
-
jest.mock('../extensions/math', () => ({
|
|
115
|
-
MathNode: {
|
|
116
|
-
configure: jest.fn(() => ({})),
|
|
117
|
-
},
|
|
118
|
-
}));
|
|
119
|
-
|
|
120
|
-
jest.mock('../extensions/image', () => ({
|
|
121
|
-
ImageUploadNode: {
|
|
122
|
-
configure: jest.fn(() => ({})),
|
|
123
|
-
},
|
|
124
|
-
}));
|
|
125
|
-
|
|
126
|
-
jest.mock('../extensions/media', () => ({
|
|
127
|
-
Media: {
|
|
128
|
-
configure: jest.fn(() => ({})),
|
|
129
|
-
},
|
|
130
|
-
}));
|
|
131
|
-
|
|
132
|
-
jest.mock('../extensions/css', () => ({
|
|
133
|
-
CSSMark: {
|
|
134
|
-
configure: jest.fn(() => ({})),
|
|
135
|
-
},
|
|
136
|
-
}));
|
|
137
|
-
|
|
138
|
-
jest.mock('../components/TiptapContainer', () => ({
|
|
139
|
-
__esModule: true,
|
|
140
|
-
default: ({ children }) => <div data-testid="editor-container">{children}</div>,
|
|
141
|
-
}));
|
|
142
|
-
|
|
143
|
-
jest.mock('../extensions', () => ({
|
|
144
|
-
...jest.requireActual('../extensions'),
|
|
145
|
-
buildExtensions: jest.fn(() => []),
|
|
146
|
-
}));
|
|
147
|
-
|
|
148
|
-
describe('EditableHtml', () => {
|
|
149
|
-
const defaultProps = {
|
|
150
|
-
markup: '<p>Hello World</p>',
|
|
151
|
-
onChange: jest.fn(),
|
|
152
|
-
onDone: jest.fn(),
|
|
153
|
-
disabled: false,
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
beforeEach(() => {
|
|
157
|
-
jest.clearAllMocks();
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
it('renders without crashing', () => {
|
|
161
|
-
const { container } = render(<EditableHtml {...defaultProps} />);
|
|
162
|
-
expect(container).toBeInTheDocument();
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it('renders editor container', () => {
|
|
166
|
-
const { getByTestId } = render(<EditableHtml {...defaultProps} />);
|
|
167
|
-
expect(getByTestId('editor-container')).toBeInTheDocument();
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
it('renders editor content when editor is initialized', async () => {
|
|
171
|
-
const { getByTestId } = render(<EditableHtml {...defaultProps} />);
|
|
172
|
-
await waitFor(() => {
|
|
173
|
-
expect(getByTestId('editor-content')).toBeInTheDocument();
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it('accepts custom toolbar options', () => {
|
|
178
|
-
const toolbarOpts = {
|
|
179
|
-
position: 'top',
|
|
180
|
-
alignment: 'center',
|
|
181
|
-
alwaysVisible: true,
|
|
182
|
-
showDone: false,
|
|
183
|
-
doneOn: 'change',
|
|
184
|
-
};
|
|
185
|
-
const { container } = render(<EditableHtml {...defaultProps} toolbarOpts={toolbarOpts} />);
|
|
186
|
-
expect(container).toBeInTheDocument();
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
it('accepts custom active plugins', () => {
|
|
190
|
-
const activePlugins = ['bold', 'italic', 'underline'];
|
|
191
|
-
const { container } = render(<EditableHtml {...defaultProps} activePlugins={activePlugins} />);
|
|
192
|
-
expect(container).toBeInTheDocument();
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
it('accepts plugin props', () => {
|
|
196
|
-
const pluginProps = {
|
|
197
|
-
showParagraphs: { disabled: false },
|
|
198
|
-
separateParagraphs: { disabled: false },
|
|
199
|
-
};
|
|
200
|
-
const { container } = render(<EditableHtml {...defaultProps} pluginProps={pluginProps} />);
|
|
201
|
-
expect(container).toBeInTheDocument();
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
it('accepts response area props', () => {
|
|
205
|
-
const responseAreaProps = {
|
|
206
|
-
type: 'explicit-constructed-response',
|
|
207
|
-
options: {},
|
|
208
|
-
};
|
|
209
|
-
const { container } = render(<EditableHtml {...defaultProps} responseAreaProps={responseAreaProps} />);
|
|
210
|
-
expect(container).toBeInTheDocument();
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
it('accepts size props', () => {
|
|
214
|
-
const sizeProps = {
|
|
215
|
-
width: 500,
|
|
216
|
-
height: 300,
|
|
217
|
-
minHeight: 200,
|
|
218
|
-
maxHeight: 400,
|
|
219
|
-
minWidth: 300,
|
|
220
|
-
maxWidth: 600,
|
|
221
|
-
};
|
|
222
|
-
const { container } = render(<EditableHtml {...defaultProps} {...sizeProps} />);
|
|
223
|
-
expect(container).toBeInTheDocument();
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
it('accepts character limit', () => {
|
|
227
|
-
const { container } = render(<EditableHtml {...defaultProps} charactersLimit={500} />);
|
|
228
|
-
expect(container).toBeInTheDocument();
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
it('accepts image support props', () => {
|
|
232
|
-
const imageSupport = {
|
|
233
|
-
add: jest.fn(),
|
|
234
|
-
delete: jest.fn(),
|
|
235
|
-
};
|
|
236
|
-
const { container } = render(<EditableHtml {...defaultProps} imageSupport={imageSupport} />);
|
|
237
|
-
expect(container).toBeInTheDocument();
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
it('accepts max image dimensions', () => {
|
|
241
|
-
const { container } = render(<EditableHtml {...defaultProps} maxImageWidth={800} maxImageHeight={600} />);
|
|
242
|
-
expect(container).toBeInTheDocument();
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
it('accepts language characters props', () => {
|
|
246
|
-
const languageCharactersProps = [
|
|
247
|
-
{ label: 'Greek', value: 'greek' },
|
|
248
|
-
{ label: 'Cyrillic', value: 'cyrillic' },
|
|
249
|
-
];
|
|
250
|
-
const { container } = render(<EditableHtml {...defaultProps} languageCharactersProps={languageCharactersProps} />);
|
|
251
|
-
expect(container).toBeInTheDocument();
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
it('accepts extra CSS rules', () => {
|
|
255
|
-
const extraCSSRules = {
|
|
256
|
-
'.custom-class': { color: 'red' },
|
|
257
|
-
};
|
|
258
|
-
const { container } = render(<EditableHtml {...defaultProps} extraCSSRules={extraCSSRules} />);
|
|
259
|
-
expect(container).toBeInTheDocument();
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
it('accepts upload sound support', () => {
|
|
263
|
-
const uploadSoundSupport = {
|
|
264
|
-
add: jest.fn(),
|
|
265
|
-
delete: jest.fn(),
|
|
266
|
-
};
|
|
267
|
-
const { container } = render(<EditableHtml {...defaultProps} uploadSoundSupport={uploadSoundSupport} />);
|
|
268
|
-
expect(container).toBeInTheDocument();
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
it('accepts onKeyDown handler', () => {
|
|
272
|
-
const onKeyDown = jest.fn();
|
|
273
|
-
const { container } = render(<EditableHtml {...defaultProps} onKeyDown={onKeyDown} />);
|
|
274
|
-
expect(container).toBeInTheDocument();
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
it('accepts disableImageAlignmentButtons prop', () => {
|
|
278
|
-
const { container } = render(<EditableHtml {...defaultProps} disableImageAlignmentButtons={true} />);
|
|
279
|
-
expect(container).toBeInTheDocument();
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
it('calls editorRef callback when editor is initialized', async () => {
|
|
283
|
-
const editorRef = jest.fn();
|
|
284
|
-
render(<EditableHtml {...defaultProps} editorRef={editorRef} />);
|
|
285
|
-
|
|
286
|
-
await waitFor(() => {
|
|
287
|
-
expect(editorRef).toHaveBeenCalled();
|
|
288
|
-
});
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
it('calls editorRef with the editor instance', async () => {
|
|
292
|
-
const editorRef = jest.fn();
|
|
293
|
-
render(<EditableHtml {...defaultProps} editorRef={editorRef} />);
|
|
294
|
-
|
|
295
|
-
await waitFor(() => {
|
|
296
|
-
expect(editorRef).toHaveBeenCalled();
|
|
297
|
-
// Verify it was called with an object that has editor-like properties
|
|
298
|
-
const callArg = editorRef.mock.calls[0][0];
|
|
299
|
-
expect(callArg).toHaveProperty('getHTML');
|
|
300
|
-
expect(callArg).toHaveProperty('commands');
|
|
301
|
-
});
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
it('handles editorRef being undefined', () => {
|
|
305
|
-
const { container } = render(<EditableHtml {...defaultProps} editorRef={undefined} />);
|
|
306
|
-
expect(container).toBeInTheDocument();
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
it('applies flex display to StyledEditorContent', async () => {
|
|
310
|
-
const { getByTestId } = render(<EditableHtml {...defaultProps} />);
|
|
311
|
-
await waitFor(() => {
|
|
312
|
-
const editorContent = getByTestId('editor-content');
|
|
313
|
-
expect(editorContent).toBeInTheDocument();
|
|
314
|
-
});
|
|
315
|
-
});
|
|
316
|
-
|
|
317
|
-
it('does not run blur onChange/onDone while an image insert flow is active', async () => {
|
|
318
|
-
jest.useFakeTimers();
|
|
319
|
-
const onChange = jest.fn();
|
|
320
|
-
const onDone = jest.fn();
|
|
321
|
-
|
|
322
|
-
render(
|
|
323
|
-
<EditableHtml
|
|
324
|
-
{...defaultProps}
|
|
325
|
-
markup="<p>Hello World</p>"
|
|
326
|
-
onChange={onChange}
|
|
327
|
-
onDone={onDone}
|
|
328
|
-
toolbarOpts={{ ...defaultProps.toolbarOpts, doneOn: 'blur' }}
|
|
329
|
-
/>,
|
|
330
|
-
);
|
|
331
|
-
|
|
332
|
-
await waitFor(() => {
|
|
333
|
-
expect(useEditor).toHaveBeenCalled();
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
const editorConfig = useEditor.mock.calls[useEditor.mock.calls.length - 1][0];
|
|
337
|
-
const blurEditor = {
|
|
338
|
-
getHTML: jest.fn(() => '<p>changed</p>'),
|
|
339
|
-
_insertingImage: true,
|
|
340
|
-
_toolbarOpened: false,
|
|
341
|
-
isActive: jest.fn(() => false),
|
|
342
|
-
};
|
|
343
|
-
|
|
344
|
-
editorConfig.onBlur({ editor: blurEditor });
|
|
345
|
-
jest.advanceTimersByTime(200);
|
|
346
|
-
|
|
347
|
-
expect(onChange).not.toHaveBeenCalled();
|
|
348
|
-
expect(onDone).not.toHaveBeenCalled();
|
|
349
|
-
|
|
350
|
-
jest.useRealTimers();
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
describe('onUpdate callback', () => {
|
|
354
|
-
it('calls onChange when transaction.isDone is true', async () => {
|
|
355
|
-
const onChange = jest.fn();
|
|
356
|
-
const markup = '<p>Initial content</p>';
|
|
357
|
-
|
|
358
|
-
render(<EditableHtml {...defaultProps} markup={markup} onChange={onChange} />);
|
|
359
|
-
|
|
360
|
-
await waitFor(() => {
|
|
361
|
-
expect(useEditor).toHaveBeenCalled();
|
|
362
|
-
});
|
|
363
|
-
|
|
364
|
-
const editorConfig = useEditor.mock.calls[useEditor.mock.calls.length - 1][0];
|
|
365
|
-
const mockEditor = {
|
|
366
|
-
getHTML: jest.fn(() => '<p>Updated content</p>'),
|
|
367
|
-
};
|
|
368
|
-
|
|
369
|
-
const mockTransaction = {
|
|
370
|
-
isDone: true,
|
|
371
|
-
};
|
|
372
|
-
|
|
373
|
-
editorConfig.onUpdate({ editor: mockEditor, transaction: mockTransaction });
|
|
374
|
-
|
|
375
|
-
expect(onChange).toHaveBeenCalledWith('<p>Updated content</p>');
|
|
376
|
-
});
|
|
377
|
-
|
|
378
|
-
it('calls onChange when markup differs from editor HTML', async () => {
|
|
379
|
-
const onChange = jest.fn();
|
|
380
|
-
const markup = '<p>Initial content</p>';
|
|
381
|
-
|
|
382
|
-
render(<EditableHtml {...defaultProps} markup={markup} onChange={onChange} />);
|
|
383
|
-
|
|
384
|
-
await waitFor(() => {
|
|
385
|
-
expect(useEditor).toHaveBeenCalled();
|
|
386
|
-
});
|
|
387
|
-
|
|
388
|
-
const editorConfig = useEditor.mock.calls[useEditor.mock.calls.length - 1][0];
|
|
389
|
-
const mockEditor = {
|
|
390
|
-
getHTML: jest.fn(() => '<p>Different content</p>'),
|
|
391
|
-
};
|
|
392
|
-
|
|
393
|
-
const mockTransaction = {
|
|
394
|
-
isDone: false,
|
|
395
|
-
};
|
|
396
|
-
|
|
397
|
-
editorConfig.onUpdate({ editor: mockEditor, transaction: mockTransaction });
|
|
398
|
-
|
|
399
|
-
expect(onChange).toHaveBeenCalledWith('<p>Different content</p>');
|
|
400
|
-
});
|
|
401
|
-
|
|
402
|
-
it('does not call onChange when transaction.isDone is false and markup matches editor HTML', async () => {
|
|
403
|
-
const onChange = jest.fn();
|
|
404
|
-
const markup = '<p>Same content</p>';
|
|
405
|
-
|
|
406
|
-
render(<EditableHtml {...defaultProps} markup={markup} onChange={onChange} />);
|
|
407
|
-
|
|
408
|
-
await waitFor(() => {
|
|
409
|
-
expect(useEditor).toHaveBeenCalled();
|
|
410
|
-
});
|
|
411
|
-
|
|
412
|
-
const editorConfig = useEditor.mock.calls[useEditor.mock.calls.length - 1][0];
|
|
413
|
-
const mockEditor = {
|
|
414
|
-
getHTML: jest.fn(() => '<p>Same content</p>'),
|
|
415
|
-
};
|
|
416
|
-
|
|
417
|
-
const mockTransaction = {
|
|
418
|
-
isDone: false,
|
|
419
|
-
};
|
|
420
|
-
|
|
421
|
-
editorConfig.onUpdate({ editor: mockEditor, transaction: mockTransaction });
|
|
422
|
-
|
|
423
|
-
expect(onChange).not.toHaveBeenCalled();
|
|
424
|
-
});
|
|
425
|
-
|
|
426
|
-
it('calls onChange when transaction.isDone is true even if markup matches', async () => {
|
|
427
|
-
const onChange = jest.fn();
|
|
428
|
-
const markup = '<p>Same content</p>';
|
|
429
|
-
|
|
430
|
-
render(<EditableHtml {...defaultProps} markup={markup} onChange={onChange} />);
|
|
431
|
-
|
|
432
|
-
await waitFor(() => {
|
|
433
|
-
expect(useEditor).toHaveBeenCalled();
|
|
434
|
-
});
|
|
435
|
-
|
|
436
|
-
const editorConfig = useEditor.mock.calls[useEditor.mock.calls.length - 1][0];
|
|
437
|
-
const mockEditor = {
|
|
438
|
-
getHTML: jest.fn(() => '<p>Same content</p>'),
|
|
439
|
-
};
|
|
440
|
-
|
|
441
|
-
const mockTransaction = {
|
|
442
|
-
isDone: true,
|
|
443
|
-
};
|
|
444
|
-
|
|
445
|
-
editorConfig.onUpdate({ editor: mockEditor, transaction: mockTransaction });
|
|
446
|
-
|
|
447
|
-
expect(onChange).toHaveBeenCalledWith('<p>Same content</p>');
|
|
448
|
-
});
|
|
449
|
-
|
|
450
|
-
it('does not call onChange when onChange is not provided', async () => {
|
|
451
|
-
const markup = '<p>Content</p>';
|
|
452
|
-
|
|
453
|
-
render(<EditableHtml {...defaultProps} markup={markup} onChange={undefined} />);
|
|
454
|
-
|
|
455
|
-
await waitFor(() => {
|
|
456
|
-
expect(useEditor).toHaveBeenCalled();
|
|
457
|
-
});
|
|
458
|
-
|
|
459
|
-
const editorConfig = useEditor.mock.calls[useEditor.mock.calls.length - 1][0];
|
|
460
|
-
const mockEditor = {
|
|
461
|
-
getHTML: jest.fn(() => '<p>Updated content</p>'),
|
|
462
|
-
};
|
|
463
|
-
|
|
464
|
-
const mockTransaction = {
|
|
465
|
-
isDone: true,
|
|
466
|
-
};
|
|
467
|
-
|
|
468
|
-
// Should not throw error when onChange is undefined
|
|
469
|
-
expect(() => {
|
|
470
|
-
editorConfig.onUpdate({ editor: mockEditor, transaction: mockTransaction });
|
|
471
|
-
}).not.toThrow();
|
|
472
|
-
});
|
|
473
|
-
});
|
|
474
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import constants, { PIE_TOOLBAR__CLASS } from '../constants';
|
|
2
|
-
|
|
3
|
-
describe('Constants', () => {
|
|
4
|
-
describe('PIE_TOOLBAR__CLASS', () => {
|
|
5
|
-
it('is defined', () => {
|
|
6
|
-
expect(PIE_TOOLBAR__CLASS).toBeDefined();
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
it('has the correct value', () => {
|
|
10
|
-
expect(PIE_TOOLBAR__CLASS).toBe('pie-toolbar');
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
describe('default export', () => {
|
|
15
|
-
it('contains PIE_TOOLBAR__CLASS', () => {
|
|
16
|
-
expect(constants.PIE_TOOLBAR__CLASS).toBe('pie-toolbar');
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
});
|