@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
package/src/extensions/css.js
DELETED
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import ReactDOM from 'react-dom';
|
|
3
|
-
import { Mark, mergeAttributes } from '@tiptap/core';
|
|
4
|
-
import List from '@mui/material/List';
|
|
5
|
-
import ListItem from '@mui/material/ListItem';
|
|
6
|
-
|
|
7
|
-
export const removeDialogs = () => {
|
|
8
|
-
const prevDialogs = document.querySelectorAll('.insert-css-dialog');
|
|
9
|
-
|
|
10
|
-
prevDialogs.forEach((s) => s.remove());
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const insertDialog = ({ editor, callback, opts, selectedText, parentNode }) => {
|
|
14
|
-
const editorDOM = editor.options.element;
|
|
15
|
-
const newEl = document.createElement('div');
|
|
16
|
-
const { selection } = editor.state;
|
|
17
|
-
|
|
18
|
-
removeDialogs();
|
|
19
|
-
|
|
20
|
-
newEl.className = 'insert-css-dialog';
|
|
21
|
-
|
|
22
|
-
let popoverEl;
|
|
23
|
-
|
|
24
|
-
const closePopOver = () => {
|
|
25
|
-
if (popoverEl) {
|
|
26
|
-
popoverEl.remove();
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
let firstCallMade = false;
|
|
31
|
-
|
|
32
|
-
const listener = (e) => {
|
|
33
|
-
// this will be triggered right after setting it because
|
|
34
|
-
// this toolbar is added on the mousedown event
|
|
35
|
-
// so right after mouseup, the click will be triggered
|
|
36
|
-
if (firstCallMade) {
|
|
37
|
-
const focusIsInModals = newEl.contains(e.target) || (popoverEl && popoverEl.contains(e.target));
|
|
38
|
-
const focusIsInEditor = editorDOM.contains(e.target);
|
|
39
|
-
|
|
40
|
-
if (!(focusIsInModals || focusIsInEditor)) {
|
|
41
|
-
handleClose();
|
|
42
|
-
}
|
|
43
|
-
} else {
|
|
44
|
-
firstCallMade = true;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const handleClose = () => {
|
|
49
|
-
callback(undefined, true);
|
|
50
|
-
newEl.remove();
|
|
51
|
-
closePopOver();
|
|
52
|
-
document.body.removeEventListener('click', listener);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const handleChange = (name) => {
|
|
56
|
-
callback(name, true);
|
|
57
|
-
newEl.remove();
|
|
58
|
-
closePopOver();
|
|
59
|
-
document.body.removeEventListener('click', listener);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const parentNodeClass = parentNode?.attrs.class;
|
|
63
|
-
const createHTML = (name) => {
|
|
64
|
-
let html = `<span class="${name}">${selectedText}</span>`;
|
|
65
|
-
|
|
66
|
-
if (parentNode) {
|
|
67
|
-
let tag = 'span';
|
|
68
|
-
|
|
69
|
-
if (parentNode?.object === 'inline') {
|
|
70
|
-
tag = 'span';
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (parentNode?.object === 'block') {
|
|
74
|
-
tag = 'div';
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
html = `<${tag} class="${parentNodeClass}">${parentNode.text.slice(
|
|
78
|
-
0,
|
|
79
|
-
selection.$anchor.textOffset,
|
|
80
|
-
)}${html}${parentNode.text.slice(selection.$head.textOffset)}</${tag}>`;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return html;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const el = (
|
|
87
|
-
<div
|
|
88
|
-
style={{ background: 'white', height: 500, padding: 20, overflow: 'hidden', display: 'flex', flexFlow: 'column' }}
|
|
89
|
-
>
|
|
90
|
-
<h2>Please choose a css class</h2>
|
|
91
|
-
{parentNodeClass && <div>The current parent has this class {parentNodeClass}</div>}
|
|
92
|
-
<List component="nav" style={{ overflow: 'scroll' }}>
|
|
93
|
-
{opts.names.map((name, i) => (
|
|
94
|
-
<ListItem key={`rule-${i}`} button onClick={() => handleChange(name)}>
|
|
95
|
-
<div style={{ marginRight: 20 }}>{name}</div>
|
|
96
|
-
<div
|
|
97
|
-
dangerouslySetInnerHTML={{
|
|
98
|
-
__html: createHTML(name),
|
|
99
|
-
}}
|
|
100
|
-
/>
|
|
101
|
-
</ListItem>
|
|
102
|
-
))}
|
|
103
|
-
</List>
|
|
104
|
-
</div>
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
ReactDOM.render(el, newEl, () => {
|
|
108
|
-
const cursorItem = editor.view.nodeDOM(editor.state.selection.from);
|
|
109
|
-
const cursorNode = cursorItem?.parentNode;
|
|
110
|
-
|
|
111
|
-
if (cursorNode) {
|
|
112
|
-
const bodyRect = editorDOM.parentElement.parentElement.parentElement.getBoundingClientRect();
|
|
113
|
-
const boundRect = cursorNode.getBoundingClientRect();
|
|
114
|
-
|
|
115
|
-
editorDOM.parentElement.parentElement.parentElement.appendChild(newEl);
|
|
116
|
-
|
|
117
|
-
newEl.style.maxWidth = '500px';
|
|
118
|
-
newEl.style.position = 'absolute';
|
|
119
|
-
newEl.style.top = 0;
|
|
120
|
-
newEl.style.zIndex = 99999;
|
|
121
|
-
|
|
122
|
-
const leftValue = `${boundRect.left + Math.abs(bodyRect.left) + cursorNode.offsetWidth + 10}px`;
|
|
123
|
-
|
|
124
|
-
const rightValue = `${boundRect.x}px`;
|
|
125
|
-
|
|
126
|
-
newEl.style.left = leftValue;
|
|
127
|
-
|
|
128
|
-
const leftAlignedWidth = newEl.offsetWidth;
|
|
129
|
-
|
|
130
|
-
newEl.style.left = 'unset';
|
|
131
|
-
newEl.style.right = rightValue;
|
|
132
|
-
|
|
133
|
-
const rightAlignedWidth = newEl.offsetWidth;
|
|
134
|
-
|
|
135
|
-
newEl.style.left = 'unset';
|
|
136
|
-
newEl.style.right = 'unset';
|
|
137
|
-
|
|
138
|
-
if (leftAlignedWidth >= rightAlignedWidth) {
|
|
139
|
-
newEl.style.left = leftValue;
|
|
140
|
-
} else {
|
|
141
|
-
newEl.style.right = rightValue;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
document.body.addEventListener('click', listener);
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
export const CSSMark = Mark.create({
|
|
150
|
-
name: 'cssmark',
|
|
151
|
-
|
|
152
|
-
addOptions() {
|
|
153
|
-
return {
|
|
154
|
-
classes: [],
|
|
155
|
-
};
|
|
156
|
-
},
|
|
157
|
-
|
|
158
|
-
addAttributes() {
|
|
159
|
-
return {
|
|
160
|
-
class: {
|
|
161
|
-
default: null,
|
|
162
|
-
parseHTML: (el) => el.getAttribute('class'),
|
|
163
|
-
renderHTML: (attributes) => {
|
|
164
|
-
if (!attributes.class) return {};
|
|
165
|
-
return { class: attributes.class };
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
};
|
|
169
|
-
},
|
|
170
|
-
|
|
171
|
-
parseHTML() {
|
|
172
|
-
// Any span with a class that matches one of allowed classes any span that carries a class attribute
|
|
173
|
-
// so that pre-existing spans are preserved when loading content
|
|
174
|
-
return [
|
|
175
|
-
{
|
|
176
|
-
tag: 'span[class]',
|
|
177
|
-
getAttrs: (el) => {
|
|
178
|
-
const cls = el.getAttribute('class') || '';
|
|
179
|
-
|
|
180
|
-
if (!cls) {
|
|
181
|
-
return false;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
const allowedClasses = (this.options && this.options.classes) || [];
|
|
185
|
-
|
|
186
|
-
if (allowedClasses.length > 0) {
|
|
187
|
-
const match = this.options.classes.find((name) => cls.includes(name));
|
|
188
|
-
|
|
189
|
-
return match ? { class: match } : false;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
return { class: cls };
|
|
193
|
-
},
|
|
194
|
-
},
|
|
195
|
-
];
|
|
196
|
-
},
|
|
197
|
-
|
|
198
|
-
renderHTML({ HTMLAttributes }) {
|
|
199
|
-
return ['span', mergeAttributes(HTMLAttributes), 0];
|
|
200
|
-
},
|
|
201
|
-
|
|
202
|
-
addCommands() {
|
|
203
|
-
return {
|
|
204
|
-
setCSSClass:
|
|
205
|
-
(className) =>
|
|
206
|
-
({ commands }) => {
|
|
207
|
-
return commands.setMark(this.name, { class: className });
|
|
208
|
-
},
|
|
209
|
-
|
|
210
|
-
unsetCSSClass:
|
|
211
|
-
() =>
|
|
212
|
-
({ commands }) => {
|
|
213
|
-
return commands.unsetMark(this.name);
|
|
214
|
-
},
|
|
215
|
-
|
|
216
|
-
openCSSClassDialog:
|
|
217
|
-
() =>
|
|
218
|
-
({ editor }) => {
|
|
219
|
-
insertDialog({
|
|
220
|
-
editor,
|
|
221
|
-
selectedText: editor.state.doc.textBetween(editor.state.selection.from, editor.state.selection.to),
|
|
222
|
-
parentNode: editor.state.selection.$from.nodeAfter,
|
|
223
|
-
opts: this.options.extraCSSRules,
|
|
224
|
-
callback: (className) => {
|
|
225
|
-
if (className) {
|
|
226
|
-
editor.chain().focus().setCSSClass(className).run();
|
|
227
|
-
}
|
|
228
|
-
},
|
|
229
|
-
});
|
|
230
|
-
},
|
|
231
|
-
};
|
|
232
|
-
},
|
|
233
|
-
});
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import IconButton from '@mui/material/IconButton';
|
|
3
|
-
import Delete from '@mui/icons-material/Delete';
|
|
4
|
-
import { PIE_TOOLBAR__CLASS } from '../constants';
|
|
5
|
-
import { styled } from '@mui/material/styles';
|
|
6
|
-
import { DoneButton } from '../components/common/done-button';
|
|
7
|
-
|
|
8
|
-
const StyledToolbar = styled('div', {
|
|
9
|
-
shouldForwardProp: (prop) => !['showDone', 'toolbarAlignment', 'isFocused', 'autoWidth', 'isHidden'].includes(prop),
|
|
10
|
-
})(({ showDone, toolbarAlignment, isFocused, autoWidth, isHidden }) => ({
|
|
11
|
-
position: 'absolute',
|
|
12
|
-
zIndex: 10,
|
|
13
|
-
cursor: 'pointer',
|
|
14
|
-
justifyContent: 'space-between',
|
|
15
|
-
background: 'var(--editable-html-toolbar-bg, #efefef)',
|
|
16
|
-
minWidth: showDone ? '280px' : '265px',
|
|
17
|
-
margin: '5px 0 0 0',
|
|
18
|
-
padding: '2px',
|
|
19
|
-
boxShadow:
|
|
20
|
-
'0px 1px 5px 0px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 3px 1px -2px rgba(0, 0, 0, 0.12)',
|
|
21
|
-
boxSizing: 'border-box',
|
|
22
|
-
display: 'flex',
|
|
23
|
-
opacity: 1,
|
|
24
|
-
...(toolbarAlignment === 'right' && {
|
|
25
|
-
right: 0,
|
|
26
|
-
}),
|
|
27
|
-
...(autoWidth
|
|
28
|
-
? {
|
|
29
|
-
width: 'auto',
|
|
30
|
-
}
|
|
31
|
-
: {
|
|
32
|
-
width: '100%',
|
|
33
|
-
}),
|
|
34
|
-
...(isHidden && {
|
|
35
|
-
visibility: 'hidden',
|
|
36
|
-
}),
|
|
37
|
-
}));
|
|
38
|
-
|
|
39
|
-
const StyledIconButton = styled(IconButton)({
|
|
40
|
-
width: '28px',
|
|
41
|
-
height: '28px',
|
|
42
|
-
padding: '4px',
|
|
43
|
-
verticalAlign: 'top',
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
const SharedContainer = styled('div')({
|
|
47
|
-
display: 'flex',
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
function CustomToolbarWrapper(props) {
|
|
51
|
-
const { children, deletable, toolbarOpts, autoWidth, isFocused, doneButtonRef, onDelete, showDone, onDone, style } = props;
|
|
52
|
-
const customStyles = toolbarOpts.minWidth !== undefined ? { minWidth: toolbarOpts.minWidth } : {};
|
|
53
|
-
|
|
54
|
-
return (
|
|
55
|
-
<StyledToolbar
|
|
56
|
-
className={PIE_TOOLBAR__CLASS}
|
|
57
|
-
showDone={showDone}
|
|
58
|
-
toolbarAlignment={toolbarOpts.alignment}
|
|
59
|
-
isFocused={toolbarOpts.alwaysVisible || isFocused}
|
|
60
|
-
autoWidth={autoWidth}
|
|
61
|
-
isHidden={toolbarOpts.isHidden === true}
|
|
62
|
-
style={{ ...customStyles, ...style }}
|
|
63
|
-
>
|
|
64
|
-
{children}
|
|
65
|
-
|
|
66
|
-
<SharedContainer>
|
|
67
|
-
{deletable && (
|
|
68
|
-
<StyledIconButton aria-label="Delete" onMouseDown={(e) => onDelete?.(e)}>
|
|
69
|
-
<Delete />
|
|
70
|
-
</StyledIconButton>
|
|
71
|
-
)}
|
|
72
|
-
{showDone && <DoneButton doneButtonRef={doneButtonRef} onClick={onDone} />}
|
|
73
|
-
</SharedContainer>
|
|
74
|
-
</StyledToolbar>
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export default CustomToolbarWrapper;
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
// DivNode.ts
|
|
2
|
-
import { Node } from '@tiptap/core';
|
|
3
|
-
|
|
4
|
-
export const DivNode = Node.create({
|
|
5
|
-
name: 'div',
|
|
6
|
-
group: 'block',
|
|
7
|
-
content: 'inline*',
|
|
8
|
-
|
|
9
|
-
parseHTML() {
|
|
10
|
-
return [{ tag: 'div' }];
|
|
11
|
-
},
|
|
12
|
-
|
|
13
|
-
renderHTML({ HTMLAttributes }) {
|
|
14
|
-
return ['div', HTMLAttributes, 0];
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
addKeyboardShortcuts() {
|
|
18
|
-
const isInsideListItem = ($from) => {
|
|
19
|
-
for (let depth = $from.depth; depth >= 0; depth -= 1) {
|
|
20
|
-
if ($from.node(depth).type.name === 'listItem') {
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return false;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
return {
|
|
28
|
-
Enter: () => {
|
|
29
|
-
const { state } = this.editor;
|
|
30
|
-
const { $from } = state.selection;
|
|
31
|
-
|
|
32
|
-
if ($from.parent.type.name !== 'div') {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
if (isInsideListItem($from)) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return this.editor
|
|
40
|
-
.chain()
|
|
41
|
-
.focus()
|
|
42
|
-
.setNode('paragraph') // current div becomes <p>
|
|
43
|
-
.splitBlock() // create another <p>
|
|
44
|
-
.run();
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
// When the cursor is in a div and the user presses Backspace,
|
|
48
|
-
// ProseMirror's default handler may try to join/delete the block node
|
|
49
|
-
// once it becomes empty. That triggers the Enter shortcut above
|
|
50
|
-
// (div → p conversion + split), making it look like a new line is
|
|
51
|
-
// inserted instead of deleting.
|
|
52
|
-
// We handle two cases explicitly:
|
|
53
|
-
// 1. The div already IS empty → swallow the event (nothing to delete).
|
|
54
|
-
// 2. The div has exactly ONE character left → delete just that character
|
|
55
|
-
// using a precise transaction, then stop. This prevents ProseMirror
|
|
56
|
-
// from following up with a block-join that triggers the Enter handler.
|
|
57
|
-
Backspace: () => {
|
|
58
|
-
const { state } = this.editor;
|
|
59
|
-
const { $from, empty: selectionEmpty } = state.selection;
|
|
60
|
-
|
|
61
|
-
if ($from.parent.type.name !== 'div') {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (!selectionEmpty) {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const parentText = $from.parent.textContent;
|
|
70
|
-
|
|
71
|
-
if (parentText.length === 0) {
|
|
72
|
-
return state.doc.childCount === 1 ? true : false;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (parentText.length === 1 && $from.parentOffset === 1) {
|
|
76
|
-
const { tr } = state;
|
|
77
|
-
tr.delete($from.pos - 1, $from.pos);
|
|
78
|
-
this.editor.view.dispatch(tr);
|
|
79
|
-
return true;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return false;
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
},
|
|
86
|
-
});
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { Extension } from '@tiptap/core';
|
|
2
|
-
import { Plugin, PluginKey } from '@tiptap/pm/state';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* After ProseMirror repairs an empty document, it often inserts a `paragraph`.
|
|
6
|
-
* We want a lone empty top-level block to be `div` (DivNode) so typing stays `<div>A</div>`.
|
|
7
|
-
*/
|
|
8
|
-
export const EnsureEmptyRootIsDiv = Extension.create({
|
|
9
|
-
name: 'ensureEmptyRootIsDiv',
|
|
10
|
-
|
|
11
|
-
addProseMirrorPlugins() {
|
|
12
|
-
const key = new PluginKey(this.name);
|
|
13
|
-
|
|
14
|
-
return [
|
|
15
|
-
new Plugin({
|
|
16
|
-
key,
|
|
17
|
-
appendTransaction(transactions, _oldState, newState) {
|
|
18
|
-
if (!transactions.some((tr) => tr.docChanged)) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const { doc } = newState;
|
|
23
|
-
if (doc.childCount !== 1) {
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const first = doc.firstChild;
|
|
28
|
-
if (first.type.name !== 'paragraph' || first.content.size > 0) {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const divType = newState.schema.nodes.div;
|
|
33
|
-
if (!divType) {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Top-level content positions are 0 .. doc.content.size. The first block spans
|
|
38
|
-
// [0, first.nodeSize). Using start=1 replaces the wrong slice and can leave the
|
|
39
|
-
// document inconsistent after a full delete (Cmd+A, Backspace).
|
|
40
|
-
const start = 0;
|
|
41
|
-
const end = first.nodeSize;
|
|
42
|
-
return newState.tr.replaceWith(start, end, divType.create());
|
|
43
|
-
},
|
|
44
|
-
}),
|
|
45
|
-
];
|
|
46
|
-
},
|
|
47
|
-
});
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { Extension } from '@tiptap/core';
|
|
2
|
-
import { Plugin, PluginKey } from '@tiptap/pm/state';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Some list operations preserve/create `paragraph` children in `listItem`.
|
|
6
|
-
* Normalize direct `listItem > paragraph` children into `div` so list content
|
|
7
|
-
* stays consistent with DivNode-based editing.
|
|
8
|
-
*/
|
|
9
|
-
export const EnsureListItemContentIsDiv = Extension.create({
|
|
10
|
-
name: 'ensureListItemContentIsDiv',
|
|
11
|
-
|
|
12
|
-
addProseMirrorPlugins() {
|
|
13
|
-
const key = new PluginKey(this.name);
|
|
14
|
-
|
|
15
|
-
return [
|
|
16
|
-
new Plugin({
|
|
17
|
-
key,
|
|
18
|
-
appendTransaction(transactions, _oldState, newState) {
|
|
19
|
-
if (!transactions.some((tr) => tr.docChanged)) {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const { doc, schema } = newState;
|
|
24
|
-
const divType = schema.nodes.div;
|
|
25
|
-
if (!divType) {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const positionsToConvert = [];
|
|
30
|
-
|
|
31
|
-
doc.descendants((node, pos) => {
|
|
32
|
-
if (node.type.name !== 'listItem') {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
let childOffset = 1;
|
|
37
|
-
node.forEach((child) => {
|
|
38
|
-
if (child.type.name === 'paragraph') {
|
|
39
|
-
positionsToConvert.push({
|
|
40
|
-
pos: pos + childOffset,
|
|
41
|
-
attrs: child.attrs,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
childOffset += child.nodeSize;
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
if (positionsToConvert.length === 0) {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const tr = newState.tr;
|
|
53
|
-
positionsToConvert
|
|
54
|
-
.sort((a, b) => b.pos - a.pos)
|
|
55
|
-
.forEach(({ pos, attrs }) => tr.setNodeMarkup(pos, divType, attrs));
|
|
56
|
-
|
|
57
|
-
return tr;
|
|
58
|
-
},
|
|
59
|
-
}),
|
|
60
|
-
];
|
|
61
|
-
},
|
|
62
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ListItem } from '@tiptap/extension-list-item';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Default list items use `paragraph block*`, so empty/new items become `<p>`.
|
|
5
|
-
* Prefer `div` first to keep consistency with DivNode at root and table cells.
|
|
6
|
-
*/
|
|
7
|
-
export const ExtendedListItem = ListItem.extend({
|
|
8
|
-
content:
|
|
9
|
-
'(div | paragraph | heading | bulletList | orderedList | blockquote | codeBlock | horizontalRule | image | imageUploadNode)+',
|
|
10
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { TableCell } from '@tiptap/extension-table-cell';
|
|
2
|
-
import { TableHeader } from '@tiptap/extension-table-header';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Default table cells use ProseMirror `createAndFill()`, which prefers the first
|
|
6
|
-
* block type allowed by the content expression. Stock cells use `block+`, so
|
|
7
|
-
* `paragraph` wins. Listing `div` first matches the editor default for plain text
|
|
8
|
-
* (see DivNode) while still allowing other blocks (lists, headings, images, …).
|
|
9
|
-
*/
|
|
10
|
-
const TABLE_CELL_BLOCK_CONTENT =
|
|
11
|
-
'(div | paragraph | heading | bulletList | orderedList | blockquote | codeBlock | horizontalRule | image | imageUploadNode)+';
|
|
12
|
-
|
|
13
|
-
export const ExtendedTableCell = TableCell.extend({
|
|
14
|
-
content: TABLE_CELL_BLOCK_CONTENT,
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
export const ExtendedTableHeader = TableHeader.extend({
|
|
18
|
-
content: TABLE_CELL_BLOCK_CONTENT,
|
|
19
|
-
});
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { Table, TableView } from '@tiptap/extension-table';
|
|
2
|
-
|
|
3
|
-
const applyPresentationToTableElement = (table, attrs) => {
|
|
4
|
-
const border = attrs?.border != null && attrs.border !== '' ? attrs.border : '1';
|
|
5
|
-
|
|
6
|
-
table.setAttribute('border', border);
|
|
7
|
-
table.style.setProperty('color', 'var(--pie-text, black)');
|
|
8
|
-
table.style.setProperty('background-color', 'var(--pie-background, rgba(255, 255, 255))');
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
class ExtendedTableView extends TableView {
|
|
12
|
-
constructor(node, cellMinWidth, view) {
|
|
13
|
-
super(node, cellMinWidth, view);
|
|
14
|
-
applyPresentationToTableElement(this.table, node.attrs);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
update(node) {
|
|
18
|
-
const ok = super.update(node);
|
|
19
|
-
|
|
20
|
-
if (ok) {
|
|
21
|
-
applyPresentationToTableElement(this.table, node.attrs);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return ok;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const ExtendedTable = Table.extend({
|
|
29
|
-
addOptions() {
|
|
30
|
-
return {
|
|
31
|
-
...this.parent?.(),
|
|
32
|
-
// ProseMirror's default table DOM does not prune extra <col> nodes when a column
|
|
33
|
-
// is removed; TableView (via column resizing) does.
|
|
34
|
-
resizable: true,
|
|
35
|
-
handleWidth: 0,
|
|
36
|
-
View: ExtendedTableView,
|
|
37
|
-
};
|
|
38
|
-
},
|
|
39
|
-
addAttributes() {
|
|
40
|
-
return {
|
|
41
|
-
border: { default: '1' },
|
|
42
|
-
};
|
|
43
|
-
},
|
|
44
|
-
renderHTML(props) {
|
|
45
|
-
const originalTable = this.parent(props);
|
|
46
|
-
const { border } = props.HTMLAttributes;
|
|
47
|
-
|
|
48
|
-
const previousStyle = `${originalTable[1].style}${originalTable[1].style.match(/.*; */) ? '' : ';'}`;
|
|
49
|
-
|
|
50
|
-
originalTable[1].style = `${previousStyle}
|
|
51
|
-
color: var(--pie-text, black);
|
|
52
|
-
background-color: var(--pie-background, rgba(255, 255, 255))`;
|
|
53
|
-
originalTable[1].border = border ? border : '1';
|
|
54
|
-
|
|
55
|
-
return originalTable;
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
export { applyPresentationToTableElement, ExtendedTableView };
|
|
60
|
-
export default ExtendedTable;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { Node, mergeAttributes } from '@tiptap/core';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* HeadingParagraph extension
|
|
5
|
-
*
|
|
6
|
-
* Renders as <p data-heading="heading1"> in the HTML output instead of <h3>.
|
|
7
|
-
* This provides semantic heading styling without using a native heading element,
|
|
8
|
-
* as required by PIE's accessibility conventions.
|
|
9
|
-
*/
|
|
10
|
-
export const HeadingParagraph = Node.create({
|
|
11
|
-
name: 'headingParagraph',
|
|
12
|
-
|
|
13
|
-
group: 'block',
|
|
14
|
-
|
|
15
|
-
content: 'inline*',
|
|
16
|
-
|
|
17
|
-
defining: true,
|
|
18
|
-
|
|
19
|
-
addAttributes() {
|
|
20
|
-
return {
|
|
21
|
-
'data-heading': {
|
|
22
|
-
default: 'heading1',
|
|
23
|
-
parseHTML: (element) => element.getAttribute('data-heading'),
|
|
24
|
-
renderHTML: (attributes) => ({
|
|
25
|
-
'data-heading': attributes['data-heading'],
|
|
26
|
-
}),
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
parseHTML() {
|
|
32
|
-
return [
|
|
33
|
-
{ tag: 'p[data-heading]' },
|
|
34
|
-
];
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
renderHTML({ HTMLAttributes }) {
|
|
38
|
-
return ['p', mergeAttributes(HTMLAttributes), 0];
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
addCommands() {
|
|
42
|
-
return {
|
|
43
|
-
toggleHeadingParagraph:
|
|
44
|
-
() =>
|
|
45
|
-
({ commands, editor }) => {
|
|
46
|
-
if (editor.isActive('headingParagraph')) {
|
|
47
|
-
return commands.setNode('paragraph');
|
|
48
|
-
}
|
|
49
|
-
return commands.setNode('headingParagraph', { 'data-heading': 'heading1' });
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
},
|
|
53
|
-
});
|