@pie-lib/editable-html-tip-tap 2.2.0-beta.7 → 3.0.0-next.35
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 +330 -0
- package/dist/components/MenuBar.d.ts +11 -0
- package/dist/components/MenuBar.js +528 -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 +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 +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 +225 -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 +213 -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/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/dist/utils/toolbar.d.ts +10 -0
- package/dist/utils/toolbar.js +7 -0
- package/package.json +43 -29
- package/CHANGELOG.json +0 -32
- package/CHANGELOG.md +0 -2532
- package/lib/__tests__/EditableHtml.test.js +0 -831
- package/lib/__tests__/EditableHtml.test.js.map +0 -1
- package/lib/__tests__/constants.test.js +0 -21
- package/lib/__tests__/constants.test.js.map +0 -1
- package/lib/__tests__/div-to-paragraph-conversion.test.js +0 -213
- package/lib/__tests__/div-to-paragraph-conversion.test.js.map +0 -1
- package/lib/__tests__/extensions.test.js +0 -209
- package/lib/__tests__/extensions.test.js.map +0 -1
- package/lib/__tests__/index.test.js +0 -250
- package/lib/__tests__/index.test.js.map +0 -1
- package/lib/__tests__/size-utils.test.js +0 -57
- package/lib/__tests__/size-utils.test.js.map +0 -1
- package/lib/__tests__/theme.test.js +0 -17
- package/lib/__tests__/theme.test.js.map +0 -1
- 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/__tests__/AltDialog.test.js +0 -201
- package/lib/components/__tests__/AltDialog.test.js.map +0 -1
- package/lib/components/__tests__/CharacterPicker.test.js +0 -455
- package/lib/components/__tests__/CharacterPicker.test.js.map +0 -1
- package/lib/components/__tests__/CssIcon.test.js +0 -58
- package/lib/components/__tests__/CssIcon.test.js.map +0 -1
- package/lib/components/__tests__/DragInTheBlank.test.js +0 -295
- package/lib/components/__tests__/DragInTheBlank.test.js.map +0 -1
- package/lib/components/__tests__/ExplicitConstructedResponse.test.js +0 -345
- package/lib/components/__tests__/ExplicitConstructedResponse.test.js.map +0 -1
- package/lib/components/__tests__/ImageToolbar.test.js +0 -185
- package/lib/components/__tests__/ImageToolbar.test.js.map +0 -1
- package/lib/components/__tests__/InlineDropdown.test.js +0 -839
- package/lib/components/__tests__/InlineDropdown.test.js.map +0 -1
- package/lib/components/__tests__/InsertImageHandler.test.js +0 -171
- package/lib/components/__tests__/InsertImageHandler.test.js.map +0 -1
- package/lib/components/__tests__/MediaDialog.test.js +0 -433
- package/lib/components/__tests__/MediaDialog.test.js.map +0 -1
- package/lib/components/__tests__/MediaToolbar.test.js +0 -126
- package/lib/components/__tests__/MediaToolbar.test.js.map +0 -1
- package/lib/components/__tests__/MediaWrapper.test.js +0 -96
- package/lib/components/__tests__/MediaWrapper.test.js.map +0 -1
- package/lib/components/__tests__/MenuBar.test.js +0 -502
- package/lib/components/__tests__/MenuBar.test.js.map +0 -1
- package/lib/components/__tests__/RespArea.test.js +0 -171
- package/lib/components/__tests__/RespArea.test.js.map +0 -1
- package/lib/components/__tests__/TableIcons.test.js +0 -153
- package/lib/components/__tests__/TableIcons.test.js.map +0 -1
- package/lib/components/__tests__/TextAlign.test.js +0 -209
- package/lib/components/__tests__/TextAlign.test.js.map +0 -1
- package/lib/components/__tests__/TiptapContainer.test.js +0 -196
- package/lib/components/__tests__/TiptapContainer.test.js.map +0 -1
- package/lib/components/__tests__/characterUtils.test.js +0 -178
- package/lib/components/__tests__/characterUtils.test.js.map +0 -1
- package/lib/components/__tests__/choice.test.js +0 -213
- package/lib/components/__tests__/choice.test.js.map +0 -1
- package/lib/components/__tests__/custom-popper.test.js +0 -108
- package/lib/components/__tests__/custom-popper.test.js.map +0 -1
- package/lib/components/__tests__/done-button.test.js +0 -72
- package/lib/components/__tests__/done-button.test.js.map +0 -1
- package/lib/components/__tests__/toolbar-buttons.test.js +0 -277
- package/lib/components/__tests__/toolbar-buttons.test.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/__tests__/choice.test.js +0 -90
- package/lib/components/respArea/DragInTheBlank/__tests__/choice.test.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/__tests__/MathTemplated.test.js +0 -217
- package/lib/components/respArea/__tests__/MathTemplated.test.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/__tests__/css.test.js +0 -214
- package/lib/extensions/__tests__/css.test.js.map +0 -1
- package/lib/extensions/__tests__/custom-toolbar-wrapper.test.js +0 -175
- package/lib/extensions/__tests__/custom-toolbar-wrapper.test.js.map +0 -1
- package/lib/extensions/__tests__/divNode.test.js +0 -108
- package/lib/extensions/__tests__/divNode.test.js.map +0 -1
- package/lib/extensions/__tests__/ensure-empty-root-div.test.js +0 -50
- package/lib/extensions/__tests__/ensure-empty-root-div.test.js.map +0 -1
- package/lib/extensions/__tests__/ensure-list-item-content-is-div.test.js +0 -60
- package/lib/extensions/__tests__/ensure-list-item-content-is-div.test.js.map +0 -1
- package/lib/extensions/__tests__/extended-list-item.test.js +0 -13
- package/lib/extensions/__tests__/extended-list-item.test.js.map +0 -1
- package/lib/extensions/__tests__/extended-table-cell.test.js +0 -15
- package/lib/extensions/__tests__/extended-table-cell.test.js.map +0 -1
- package/lib/extensions/__tests__/extended-table.test.js +0 -200
- package/lib/extensions/__tests__/extended-table.test.js.map +0 -1
- package/lib/extensions/__tests__/image-component.test.js +0 -432
- package/lib/extensions/__tests__/image-component.test.js.map +0 -1
- package/lib/extensions/__tests__/image.test.js +0 -313
- package/lib/extensions/__tests__/image.test.js.map +0 -1
- package/lib/extensions/__tests__/math.test.js +0 -1411
- package/lib/extensions/__tests__/math.test.js.map +0 -1
- package/lib/extensions/__tests__/media-node-view.test.js +0 -307
- package/lib/extensions/__tests__/media-node-view.test.js.map +0 -1
- package/lib/extensions/__tests__/media.test.js +0 -292
- package/lib/extensions/__tests__/media.test.js.map +0 -1
- package/lib/extensions/__tests__/responseArea.test.js +0 -736
- package/lib/extensions/__tests__/responseArea.test.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/__tests__/helper.test.js +0 -107
- package/lib/utils/__tests__/helper.test.js.map +0 -1
- package/lib/utils/__tests__/toolbar.test.js +0 -38
- package/lib/utils/__tests__/toolbar.test.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/__tests__/EditableHtml.test.jsx +0 -588
- 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 -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/__tests__/AltDialog.test.jsx +0 -147
- package/src/components/__tests__/CharacterPicker.test.jsx +0 -270
- 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 -209
- package/src/components/__tests__/ImageToolbar.test.jsx +0 -128
- package/src/components/__tests__/InlineDropdown.test.jsx +0 -557
- 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 -250
- 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 -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/__tests__/choice.test.jsx +0 -72
- 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/__tests__/MathTemplated.test.jsx +0 -210
- package/src/components/respArea/inlineDropdownUtils.js +0 -79
- 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 -346
- package/src/extensions/__tests__/image.test.js +0 -237
- package/src/extensions/__tests__/math.test.js +0 -900
- 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 -655
- 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/__tests__/helper.test.js +0 -126
- package/src/utils/__tests__/toolbar.test.js +0 -43
- package/src/utils/helper.js +0 -69
- package/src/utils/size.js +0 -32
- package/src/utils/toolbar.js +0 -15
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import ReactDOM from 'react-dom';
|
|
3
|
-
import { renderMath } from '@pie-lib/math-rendering';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
|
-
import { NodeViewWrapper } from '@tiptap/react';
|
|
6
|
-
import { NodeSelection } from 'prosemirror-state';
|
|
7
|
-
import { Chevron } from '../icons/RespArea';
|
|
8
|
-
import CustomToolbarWrapper from '../../extensions/custom-toolbar-wrapper';
|
|
9
|
-
import { setToolbarOpened } from '../../utils/toolbar';
|
|
10
|
-
|
|
11
|
-
const InlineDropdown = (props) => {
|
|
12
|
-
const { editor, node, getPos, options, selected } = props;
|
|
13
|
-
const { attrs: attributes } = node;
|
|
14
|
-
const { value, error } = attributes;
|
|
15
|
-
const html = value || '<div> </div>';
|
|
16
|
-
const pos = getPos();
|
|
17
|
-
const toolbarRef = useRef(null);
|
|
18
|
-
const toolbarEditor = useRef(null);
|
|
19
|
-
const pendingCloseRequest = useRef(false);
|
|
20
|
-
const elementRef = useRef(null);
|
|
21
|
-
|
|
22
|
-
const isHeld = () =>
|
|
23
|
-
editor._holdInlineDropdownToolbarIndex != null &&
|
|
24
|
-
String(editor._holdInlineDropdownToolbarIndex) === String(node.attrs.index);
|
|
25
|
-
|
|
26
|
-
const [showToolbar, setShowToolbar] = useState(false);
|
|
27
|
-
const [position, setPosition] = useState({ top: 0, left: 0 });
|
|
28
|
-
|
|
29
|
-
const closeToolbar = () => {
|
|
30
|
-
if (isHeld()) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
setShowToolbar(false);
|
|
35
|
-
options.onInlineDropdownToolbarClose?.(editor);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const InlineDropdownToolbar = options.respAreaToolbar([node, pos], editor, closeToolbar);
|
|
39
|
-
|
|
40
|
-
const reselectNode = () => {
|
|
41
|
-
const { tr } = editor.state;
|
|
42
|
-
const nodeAtPos = tr.doc.nodeAt(pos);
|
|
43
|
-
|
|
44
|
-
if (!nodeAtPos) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const { selection } = tr;
|
|
49
|
-
|
|
50
|
-
if (selection.from === pos && selection.to === pos + nodeAtPos.nodeSize) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
tr.setSelection(NodeSelection.create(tr.doc, pos));
|
|
55
|
-
editor.view.dispatch(tr);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const requestClose = () => {
|
|
59
|
-
if (pendingCloseRequest.current) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (options.onToolbarCloseRequest) {
|
|
64
|
-
pendingCloseRequest.current = true;
|
|
65
|
-
|
|
66
|
-
options.onToolbarCloseRequest(
|
|
67
|
-
[node, pos],
|
|
68
|
-
editor,
|
|
69
|
-
() => {
|
|
70
|
-
pendingCloseRequest.current = false;
|
|
71
|
-
delete editor._holdInlineDropdownToolbarIndex;
|
|
72
|
-
closeToolbar();
|
|
73
|
-
},
|
|
74
|
-
() => {
|
|
75
|
-
pendingCloseRequest.current = false;
|
|
76
|
-
delete editor._holdInlineDropdownToolbarIndex;
|
|
77
|
-
setShowToolbar(true);
|
|
78
|
-
setTimeout(reselectNode, 0);
|
|
79
|
-
},
|
|
80
|
-
);
|
|
81
|
-
} else {
|
|
82
|
-
closeToolbar();
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
useEffect(() => {
|
|
87
|
-
const { selection } = editor.state;
|
|
88
|
-
const onlyThisNodeSelected = selection.from + node.nodeSize === selection.to;
|
|
89
|
-
|
|
90
|
-
if (selected) {
|
|
91
|
-
if (onlyThisNodeSelected) {
|
|
92
|
-
setShowToolbar(true);
|
|
93
|
-
}
|
|
94
|
-
} else if (showToolbar) {
|
|
95
|
-
requestClose();
|
|
96
|
-
}
|
|
97
|
-
}, [editor, node, selected]);
|
|
98
|
-
|
|
99
|
-
const isScrollbarClicked = (event) =>
|
|
100
|
-
event.clientX > document.documentElement.clientWidth ||
|
|
101
|
-
event.clientY > document.documentElement.clientHeight ||
|
|
102
|
-
event.target === document.documentElement;
|
|
103
|
-
|
|
104
|
-
useEffect(() => {
|
|
105
|
-
if (elementRef.current && typeof renderMath === 'function') {
|
|
106
|
-
renderMath(elementRef.current);
|
|
107
|
-
}
|
|
108
|
-
}, [value]);
|
|
109
|
-
|
|
110
|
-
useEffect(() => {
|
|
111
|
-
// Calculate position relative to selection
|
|
112
|
-
const bodyRect = document.body.getBoundingClientRect();
|
|
113
|
-
const { from } = editor.state.selection;
|
|
114
|
-
const start = editor.view.coordsAtPos(from);
|
|
115
|
-
|
|
116
|
-
setPosition({
|
|
117
|
-
top: start.top + Math.abs(bodyRect.top) + 40, // shift above
|
|
118
|
-
left: start.left,
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
const handleClickOutside = (event) => {
|
|
122
|
-
if (isScrollbarClicked(event)) {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const insideSomeEditor = event.target.closest('[data-toolbar-for]');
|
|
127
|
-
|
|
128
|
-
if (
|
|
129
|
-
!event.target.closest('[data-inline-dropdown-toolbar]') &&
|
|
130
|
-
(!insideSomeEditor || insideSomeEditor.dataset.toolbarFor !== toolbarEditor.current?.instanceId) &&
|
|
131
|
-
!editor._toolbarOpened &&
|
|
132
|
-
toolbarRef.current &&
|
|
133
|
-
!toolbarRef.current.contains(event.target) &&
|
|
134
|
-
!event.target.closest('[data-inline-node]')
|
|
135
|
-
) {
|
|
136
|
-
requestClose();
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
if (showToolbar) {
|
|
141
|
-
document.addEventListener('mousedown', handleClickOutside);
|
|
142
|
-
} else {
|
|
143
|
-
document.removeEventListener('mousedown', handleClickOutside);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return () => document.removeEventListener('mousedown', handleClickOutside);
|
|
147
|
-
}, [showToolbar, node]);
|
|
148
|
-
|
|
149
|
-
return (
|
|
150
|
-
<NodeViewWrapper
|
|
151
|
-
className="inline-dropdown"
|
|
152
|
-
data-selected={selected}
|
|
153
|
-
style={{
|
|
154
|
-
display: 'inline-flex',
|
|
155
|
-
height: '50px',
|
|
156
|
-
cursor: 'pointer',
|
|
157
|
-
}}
|
|
158
|
-
>
|
|
159
|
-
<div
|
|
160
|
-
ref={elementRef}
|
|
161
|
-
style={{
|
|
162
|
-
display: 'inline-flex',
|
|
163
|
-
minWidth: '178px',
|
|
164
|
-
height: '36px',
|
|
165
|
-
background: '#FFF',
|
|
166
|
-
border: '1px solid #C0C3CF',
|
|
167
|
-
boxSizing: 'border-box',
|
|
168
|
-
borderRadius: '3px',
|
|
169
|
-
margin: '0 2px',
|
|
170
|
-
position: 'relative',
|
|
171
|
-
alignItems: 'center',
|
|
172
|
-
}}
|
|
173
|
-
onClick={() => setShowToolbar(true)}
|
|
174
|
-
>
|
|
175
|
-
<div
|
|
176
|
-
style={{
|
|
177
|
-
flex: 1,
|
|
178
|
-
overflow: 'hidden',
|
|
179
|
-
padding: '0 25px 0 8px',
|
|
180
|
-
whiteSpace: 'nowrap',
|
|
181
|
-
textOverflow: 'ellipsis',
|
|
182
|
-
}}
|
|
183
|
-
>
|
|
184
|
-
<span
|
|
185
|
-
style={{
|
|
186
|
-
display: 'inline-block',
|
|
187
|
-
verticalAlign: 'middle',
|
|
188
|
-
}}
|
|
189
|
-
dangerouslySetInnerHTML={{ __html: html }}
|
|
190
|
-
/>
|
|
191
|
-
</div>
|
|
192
|
-
<Chevron direction="down" style={{ position: 'absolute', top: '5px', right: '5px' }} />
|
|
193
|
-
</div>
|
|
194
|
-
{showToolbar && (
|
|
195
|
-
<React.Fragment>
|
|
196
|
-
{ReactDOM.createPortal(
|
|
197
|
-
<div ref={toolbarRef}>
|
|
198
|
-
<InlineDropdownToolbar
|
|
199
|
-
editorCallback={(instance) => {
|
|
200
|
-
toolbarEditor.current = instance;
|
|
201
|
-
}}
|
|
202
|
-
/>
|
|
203
|
-
</div>,
|
|
204
|
-
editor?._tiptapContainerEl || document.body,
|
|
205
|
-
)}
|
|
206
|
-
|
|
207
|
-
{editor._tiptapContainerEl &&
|
|
208
|
-
ReactDOM.createPortal(
|
|
209
|
-
<CustomToolbarWrapper
|
|
210
|
-
deletable
|
|
211
|
-
toolbarOpts={{ minWidth: 'auto' }}
|
|
212
|
-
autoWidth
|
|
213
|
-
style={{ top: -40, left: 0, right: 0 }}
|
|
214
|
-
onDelete={() => {
|
|
215
|
-
const { tr } = editor.state;
|
|
216
|
-
tr.delete(pos, pos + node.nodeSize);
|
|
217
|
-
// Prevent the debounced onBlur/onDone from firing into the
|
|
218
|
-
// now-deleted node's stale position
|
|
219
|
-
setToolbarOpened(editor, false);
|
|
220
|
-
delete editor._holdInlineDropdownToolbarIndex;
|
|
221
|
-
editor.view.dispatch(tr);
|
|
222
|
-
setShowToolbar(false);
|
|
223
|
-
editor.commands.focus();
|
|
224
|
-
}}
|
|
225
|
-
showDone={false}
|
|
226
|
-
/>,
|
|
227
|
-
editor._tiptapContainerEl,
|
|
228
|
-
)}
|
|
229
|
-
</React.Fragment>
|
|
230
|
-
)}
|
|
231
|
-
</NodeViewWrapper>
|
|
232
|
-
);
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
InlineDropdown.propTypes = {
|
|
236
|
-
attributes: PropTypes.object,
|
|
237
|
-
selectedItem: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
export default InlineDropdown;
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { NodeViewWrapper } from '@tiptap/react';
|
|
4
|
-
import { mq } from '@pie-lib/math-input-mathlive';
|
|
5
|
-
import { styled } from '@mui/material/styles';
|
|
6
|
-
|
|
7
|
-
const StyledSpanContainer = styled('span')(() => ({
|
|
8
|
-
display: 'inline-flex',
|
|
9
|
-
border: '1px solid #C0C3CF',
|
|
10
|
-
margin: '1px 5px',
|
|
11
|
-
cursor: 'pointer',
|
|
12
|
-
alignItems: 'center',
|
|
13
|
-
justifyContent: 'center',
|
|
14
|
-
minWidth: '50px',
|
|
15
|
-
minHeight: '36px',
|
|
16
|
-
height: 'fit-content',
|
|
17
|
-
}));
|
|
18
|
-
|
|
19
|
-
const StyledResponseBox = styled('div')(({ theme }) => ({
|
|
20
|
-
background: theme.palette.grey['A100'],
|
|
21
|
-
color: theme.palette.grey['A700'],
|
|
22
|
-
display: 'inline-flex',
|
|
23
|
-
borderRight: '2px solid #C0C3CF',
|
|
24
|
-
boxSizing: 'border-box',
|
|
25
|
-
overflow: 'hidden',
|
|
26
|
-
fontSize: '12px',
|
|
27
|
-
minHeight: '36px',
|
|
28
|
-
height: '100%',
|
|
29
|
-
alignItems: 'center',
|
|
30
|
-
fontFamily: 'Symbola, Times New Roman, serif',
|
|
31
|
-
padding: '0 2px',
|
|
32
|
-
}));
|
|
33
|
-
|
|
34
|
-
const StyledMathBlock = styled('div')(() => ({
|
|
35
|
-
flex: 8,
|
|
36
|
-
color: 'var(--pie-text, black)',
|
|
37
|
-
padding: '4px !important',
|
|
38
|
-
display: 'flex',
|
|
39
|
-
alignItems: 'center',
|
|
40
|
-
justifyContent: 'center',
|
|
41
|
-
backgroundColor: 'var(--pie-background, rgba(255, 255, 255, 0))',
|
|
42
|
-
'& > .mq-math-mode sup.mq-nthroot': {
|
|
43
|
-
fontSize: '70% !important',
|
|
44
|
-
verticalAlign: '1em !important',
|
|
45
|
-
},
|
|
46
|
-
'& > .mq-math-mode .mq-sqrt-stem': {
|
|
47
|
-
borderTop: '0.07em solid',
|
|
48
|
-
marginLeft: '-1.5px',
|
|
49
|
-
marginTop: '-2px !important',
|
|
50
|
-
paddingTop: '5px !important',
|
|
51
|
-
},
|
|
52
|
-
'& .mq-overarrow-inner': {
|
|
53
|
-
paddingTop: '0 !important',
|
|
54
|
-
border: 'none !important',
|
|
55
|
-
},
|
|
56
|
-
'& .mq-overarrow.mq-arrow-both': {
|
|
57
|
-
marginTop: '0px',
|
|
58
|
-
minWidth: '1.23em',
|
|
59
|
-
'& *': {
|
|
60
|
-
lineHeight: '1 !important',
|
|
61
|
-
},
|
|
62
|
-
'&:before': {
|
|
63
|
-
top: '-0.4em',
|
|
64
|
-
left: '-1px',
|
|
65
|
-
},
|
|
66
|
-
'&:after': {
|
|
67
|
-
top: '0px !important',
|
|
68
|
-
position: 'absolute !important',
|
|
69
|
-
right: '-2px',
|
|
70
|
-
},
|
|
71
|
-
'&.mq-empty:after': {
|
|
72
|
-
top: '-0.45em',
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
'& .mq-overarrow.mq-arrow-right': {
|
|
76
|
-
'&:before': {
|
|
77
|
-
top: '-0.4em',
|
|
78
|
-
right: '-1px',
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
'& .mq-overarrow-inner-right': {
|
|
82
|
-
display: 'none !important',
|
|
83
|
-
},
|
|
84
|
-
'& .mq-overarrow-inner-left': {
|
|
85
|
-
display: 'none !important',
|
|
86
|
-
},
|
|
87
|
-
}));
|
|
88
|
-
const MathTemplated = (props) => {
|
|
89
|
-
const { node, options, selected } = props;
|
|
90
|
-
const { attrs: attributes } = node;
|
|
91
|
-
const { value, index } = attributes;
|
|
92
|
-
|
|
93
|
-
// add 1 to index to display R 1 instead of R 0
|
|
94
|
-
const keyToDisplay = `R ${parseInt(index) + 1}`;
|
|
95
|
-
|
|
96
|
-
// console.log({nodeProps.children})
|
|
97
|
-
return (
|
|
98
|
-
<NodeViewWrapper
|
|
99
|
-
className="math-templated"
|
|
100
|
-
data-selected={selected}
|
|
101
|
-
style={{
|
|
102
|
-
display: 'inline-flex',
|
|
103
|
-
minHeight: '36px',
|
|
104
|
-
minWidth: '50px',
|
|
105
|
-
cursor: 'pointer',
|
|
106
|
-
}}
|
|
107
|
-
>
|
|
108
|
-
<StyledSpanContainer {...attributes}>
|
|
109
|
-
<StyledResponseBox>{keyToDisplay}</StyledResponseBox>
|
|
110
|
-
<StyledMathBlock>
|
|
111
|
-
<mq.Static latex={value} />
|
|
112
|
-
</StyledMathBlock>
|
|
113
|
-
</StyledSpanContainer>
|
|
114
|
-
</NodeViewWrapper>
|
|
115
|
-
);
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
MathTemplated.propTypes = {
|
|
119
|
-
attributes: PropTypes.object,
|
|
120
|
-
value: PropTypes.string,
|
|
121
|
-
keyToDisplay: PropTypes.string,
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
export default MathTemplated;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { styled } from '@mui/material/styles';
|
|
3
|
-
|
|
4
|
-
export const Chevron = (props) => {
|
|
5
|
-
const { direction, style } = props;
|
|
6
|
-
const rotate = (() => {
|
|
7
|
-
switch (direction) {
|
|
8
|
-
case 'down':
|
|
9
|
-
return 90;
|
|
10
|
-
case 'up':
|
|
11
|
-
return -90;
|
|
12
|
-
case 'left':
|
|
13
|
-
return 180;
|
|
14
|
-
default:
|
|
15
|
-
return 0;
|
|
16
|
-
}
|
|
17
|
-
})();
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<svg
|
|
21
|
-
style={{
|
|
22
|
-
transform: `rotate(${rotate}deg)`,
|
|
23
|
-
...style,
|
|
24
|
-
}}
|
|
25
|
-
width="24"
|
|
26
|
-
height="24"
|
|
27
|
-
viewBox="0 0 24 24"
|
|
28
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
29
|
-
>
|
|
30
|
-
<path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z" fill="currentColor" />
|
|
31
|
-
</svg>
|
|
32
|
-
);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export const GripIcon = ({ style }) => (
|
|
36
|
-
<span style={style}>
|
|
37
|
-
<svg
|
|
38
|
-
style={{
|
|
39
|
-
margin: '0 -16px',
|
|
40
|
-
}}
|
|
41
|
-
width="24"
|
|
42
|
-
height="24"
|
|
43
|
-
viewBox="0 0 24 24"
|
|
44
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
45
|
-
>
|
|
46
|
-
<path d="M9 3H7v2h2V3zm0 4H7v2h2V7zm0 4H7v2h2v-2zm0 4H7v2h2v-2zm0 4H7v2h2v-2zm4-16h-2v2h2V3zm0 4h-2v2h2V7zm0 4h-2v2h2v-2zm0 4h-2v2h2v-2zm0 4h-2v2h2v-2z" />
|
|
47
|
-
</svg>
|
|
48
|
-
<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
49
|
-
<path d="M9 3H7v2h2V3zm0 4H7v2h2V7zm0 4H7v2h2v-2zm0 4H7v2h2v-2zm0 4H7v2h2v-2zm4-16h-2v2h2V3zm0 4h-2v2h2V7zm0 4h-2v2h2v-2zm0 4h-2v2h2v-2zm0 4h-2v2h2v-2z" />
|
|
50
|
-
</svg>
|
|
51
|
-
</span>
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
const StyledToolbarIcon = styled('div')(({ theme }) => ({
|
|
55
|
-
fontFamily: 'Cerebri Sans !important',
|
|
56
|
-
fontSize: theme.typography.fontSize,
|
|
57
|
-
fontWeight: 'bold',
|
|
58
|
-
lineHeight: '14px',
|
|
59
|
-
position: 'relative',
|
|
60
|
-
top: '7px',
|
|
61
|
-
width: '110px',
|
|
62
|
-
height: '28px',
|
|
63
|
-
whiteSpace: 'nowrap',
|
|
64
|
-
}));
|
|
65
|
-
|
|
66
|
-
export const ToolbarIcon = () => <StyledToolbarIcon>+ Response Area</StyledToolbarIcon>;
|
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
3
|
-
import MathTemplated from '../MathTemplated';
|
|
4
|
-
|
|
5
|
-
// Mock the dependencies
|
|
6
|
-
jest.mock('@tiptap/react', () => ({
|
|
7
|
-
NodeViewWrapper: ({ children, ...props }) => (
|
|
8
|
-
<div data-testid="node-view-wrapper" {...props}>
|
|
9
|
-
{children}
|
|
10
|
-
</div>
|
|
11
|
-
),
|
|
12
|
-
}));
|
|
13
|
-
|
|
14
|
-
jest.mock('@pie-lib/math-input-mathlive', () => ({
|
|
15
|
-
mq: {
|
|
16
|
-
Static: ({ latex }) => (
|
|
17
|
-
<div data-testid="mq-static" data-latex={latex}>
|
|
18
|
-
{latex}
|
|
19
|
-
</div>
|
|
20
|
-
),
|
|
21
|
-
},
|
|
22
|
-
}));
|
|
23
|
-
|
|
24
|
-
describe('MathTemplated', () => {
|
|
25
|
-
const defaultProps = {
|
|
26
|
-
node: {
|
|
27
|
-
attrs: {
|
|
28
|
-
value: 'x^2 + y^2 = r^2',
|
|
29
|
-
index: 0,
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
options: {},
|
|
33
|
-
selected: false,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
it('renders without crashing', () => {
|
|
37
|
-
const { container } = render(<MathTemplated {...defaultProps} />);
|
|
38
|
-
expect(container).toBeInTheDocument();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('renders NodeViewWrapper with correct className', () => {
|
|
42
|
-
const { getByTestId } = render(<MathTemplated {...defaultProps} />);
|
|
43
|
-
const wrapper = getByTestId('node-view-wrapper');
|
|
44
|
-
expect(wrapper).toHaveClass('math-templated');
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('displays correct response key for index 0', () => {
|
|
48
|
-
const { getByText } = render(<MathTemplated {...defaultProps} />);
|
|
49
|
-
expect(getByText('R 1')).toBeInTheDocument();
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('displays correct response key for index 1', () => {
|
|
53
|
-
const props = {
|
|
54
|
-
...defaultProps,
|
|
55
|
-
node: {
|
|
56
|
-
attrs: {
|
|
57
|
-
value: 'a + b',
|
|
58
|
-
index: 1,
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
const { getByText } = render(<MathTemplated {...props} />);
|
|
63
|
-
expect(getByText('R 2')).toBeInTheDocument();
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('displays correct response key for index 5', () => {
|
|
67
|
-
const props = {
|
|
68
|
-
...defaultProps,
|
|
69
|
-
node: {
|
|
70
|
-
attrs: {
|
|
71
|
-
value: 'c = d',
|
|
72
|
-
index: 5,
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
const { getByText } = render(<MathTemplated {...props} />);
|
|
77
|
-
expect(getByText('R 6')).toBeInTheDocument();
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('renders LaTeX value correctly', () => {
|
|
81
|
-
const { getByTestId } = render(<MathTemplated {...defaultProps} />);
|
|
82
|
-
const mqStatic = getByTestId('mq-static');
|
|
83
|
-
expect(mqStatic).toHaveAttribute('data-latex', 'x^2 + y^2 = r^2');
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('renders different LaTeX value', () => {
|
|
87
|
-
const props = {
|
|
88
|
-
...defaultProps,
|
|
89
|
-
node: {
|
|
90
|
-
attrs: {
|
|
91
|
-
value: '\\frac{a}{b}',
|
|
92
|
-
index: 2,
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
};
|
|
96
|
-
const { getByTestId } = render(<MathTemplated {...props} />);
|
|
97
|
-
const mqStatic = getByTestId('mq-static');
|
|
98
|
-
expect(mqStatic).toHaveAttribute('data-latex', '\\frac{a}{b}');
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it('passes selected prop to NodeViewWrapper', () => {
|
|
102
|
-
const props = {
|
|
103
|
-
...defaultProps,
|
|
104
|
-
selected: true,
|
|
105
|
-
};
|
|
106
|
-
const { getByTestId } = render(<MathTemplated {...props} />);
|
|
107
|
-
const wrapper = getByTestId('node-view-wrapper');
|
|
108
|
-
expect(wrapper).toHaveAttribute('data-selected', 'true');
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('passes false selected prop to NodeViewWrapper', () => {
|
|
112
|
-
const { getByTestId } = render(<MathTemplated {...defaultProps} />);
|
|
113
|
-
const wrapper = getByTestId('node-view-wrapper');
|
|
114
|
-
expect(wrapper).toHaveAttribute('data-selected', 'false');
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it('applies correct inline styles to NodeViewWrapper', () => {
|
|
118
|
-
const { getByTestId } = render(<MathTemplated {...defaultProps} />);
|
|
119
|
-
const wrapper = getByTestId('node-view-wrapper');
|
|
120
|
-
expect(wrapper).toHaveStyle({
|
|
121
|
-
display: 'inline-flex',
|
|
122
|
-
minHeight: '36px',
|
|
123
|
-
minWidth: '50px',
|
|
124
|
-
cursor: 'pointer',
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it('handles string index correctly', () => {
|
|
129
|
-
const props = {
|
|
130
|
-
...defaultProps,
|
|
131
|
-
node: {
|
|
132
|
-
attrs: {
|
|
133
|
-
value: 'test',
|
|
134
|
-
index: '3',
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
};
|
|
138
|
-
const { getByText } = render(<MathTemplated {...props} />);
|
|
139
|
-
expect(getByText('R 4')).toBeInTheDocument();
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it('handles empty value', () => {
|
|
143
|
-
const props = {
|
|
144
|
-
...defaultProps,
|
|
145
|
-
node: {
|
|
146
|
-
attrs: {
|
|
147
|
-
value: '',
|
|
148
|
-
index: 0,
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
};
|
|
152
|
-
const { getByTestId } = render(<MathTemplated {...props} />);
|
|
153
|
-
const mqStatic = getByTestId('mq-static');
|
|
154
|
-
expect(mqStatic).toHaveAttribute('data-latex', '');
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
it('renders all styled components', () => {
|
|
158
|
-
const { container, getByText } = render(<MathTemplated {...defaultProps} />);
|
|
159
|
-
|
|
160
|
-
// Check for response box
|
|
161
|
-
expect(getByText('R 1')).toBeInTheDocument();
|
|
162
|
-
|
|
163
|
-
// Check for math block with LaTeX
|
|
164
|
-
const mqStatic = container.querySelector('[data-testid="mq-static"]');
|
|
165
|
-
expect(mqStatic).toBeInTheDocument();
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it('handles zero index', () => {
|
|
169
|
-
const props = {
|
|
170
|
-
...defaultProps,
|
|
171
|
-
node: {
|
|
172
|
-
attrs: {
|
|
173
|
-
value: 'x = 0',
|
|
174
|
-
index: 0,
|
|
175
|
-
},
|
|
176
|
-
},
|
|
177
|
-
};
|
|
178
|
-
const { getByText } = render(<MathTemplated {...props} />);
|
|
179
|
-
expect(getByText('R 1')).toBeInTheDocument();
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it('handles large index values', () => {
|
|
183
|
-
const props = {
|
|
184
|
-
...defaultProps,
|
|
185
|
-
node: {
|
|
186
|
-
attrs: {
|
|
187
|
-
value: 'x = 100',
|
|
188
|
-
index: 99,
|
|
189
|
-
},
|
|
190
|
-
},
|
|
191
|
-
};
|
|
192
|
-
const { getByText } = render(<MathTemplated {...props} />);
|
|
193
|
-
expect(getByText('R 100')).toBeInTheDocument();
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
it('renders with complex LaTeX expression', () => {
|
|
197
|
-
const props = {
|
|
198
|
-
...defaultProps,
|
|
199
|
-
node: {
|
|
200
|
-
attrs: {
|
|
201
|
-
value: '\\sqrt{x^2 + y^2}',
|
|
202
|
-
index: 0,
|
|
203
|
-
},
|
|
204
|
-
},
|
|
205
|
-
};
|
|
206
|
-
const { getByTestId } = render(<MathTemplated {...props} />);
|
|
207
|
-
const mqStatic = getByTestId('mq-static');
|
|
208
|
-
expect(mqStatic).toHaveAttribute('data-latex', '\\sqrt{x^2 + y^2}');
|
|
209
|
-
});
|
|
210
|
-
});
|