@pie-lib/editable-html-tip-tap 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/lib/components/CharacterPicker.js +221 -0
  2. package/lib/components/EditableHtml.js +323 -0
  3. package/lib/components/MenuBar.js +693 -0
  4. package/lib/components/TiptapContainer.js +90 -0
  5. package/lib/components/buttons/done-button.js +53 -0
  6. package/lib/components/characters/characterUtils.js +112 -0
  7. package/lib/components/characters/custom-popper.js +73 -0
  8. package/lib/components/common/done-button.js +53 -0
  9. package/lib/components/icons/CssIcon.js +37 -0
  10. package/lib/components/icons/RespArea.js +95 -0
  11. package/lib/components/icons/TableIcons.js +69 -0
  12. package/lib/components/icons/TextAlign.js +194 -0
  13. package/lib/components/icons/index.js +194 -0
  14. package/lib/components/image/ImageToolbar.js +16 -0
  15. package/lib/components/image/InsertImageHandler.js +16 -0
  16. package/lib/components/media/MediaDialog.js +16 -0
  17. package/lib/components/media/MediaToolbar.js +16 -0
  18. package/lib/components/respArea/DragInTheBlank/DragInTheBlank.js +94 -0
  19. package/lib/components/respArea/DragInTheBlank/choice.js +289 -0
  20. package/lib/components/respArea/DragInTheBlank.js +94 -0
  21. package/lib/components/respArea/ExplicitConstructedResponse.js +120 -0
  22. package/lib/components/respArea/InlineDropdown.js +126 -0
  23. package/lib/components/respArea/ToolbarIcon.js +105 -0
  24. package/lib/components/respArea/choice.js +2 -0
  25. package/lib/extensions/component.js +5 -5
  26. package/lib/extensions/custom-toolbar-wrapper.js +2 -4
  27. package/lib/extensions/extended-table.js +30 -0
  28. package/lib/extensions/index.js +52 -0
  29. package/lib/extensions/media.js +5 -5
  30. package/lib/extensions/responseArea.js +7 -7
  31. package/lib/index.js +16 -1481
  32. package/lib/plugins/index.js +8 -80
  33. package/lib/styles/editorContainerStyles.js +200 -0
  34. package/lib/utils/size.js +34 -0
  35. package/package.json +1 -1
  36. package/src/components/CharacterPicker.jsx +185 -0
  37. package/src/components/EditableHtml.jsx +306 -0
  38. package/src/components/MenuBar.jsx +630 -0
  39. package/src/components/TiptapContainer.jsx +96 -0
  40. package/src/components/characters/characterUtils.js +127 -0
  41. package/src/components/image/ImageToolbar.jsx +1 -0
  42. package/src/components/image/InsertImageHandler.js +1 -0
  43. package/src/components/media/MediaDialog.js +1 -0
  44. package/src/components/media/MediaToolbar.jsx +1 -0
  45. package/src/{plugins/respArea/drag-in-the-blank → components/respArea/DragInTheBlank}/choice.jsx +1 -1
  46. package/src/{plugins/respArea/inline-dropdown/index.jsx → components/respArea/InlineDropdown.jsx} +1 -1
  47. package/src/components/respArea/ToolbarIcon.jsx +68 -0
  48. package/src/extensions/component.jsx +2 -2
  49. package/src/extensions/custom-toolbar-wrapper.jsx +6 -7
  50. package/src/extensions/extended-table.js +27 -0
  51. package/src/extensions/index.js +76 -0
  52. package/src/extensions/media.js +10 -4
  53. package/src/extensions/responseArea.js +7 -7
  54. package/src/index.jsx +3 -1440
  55. package/src/styles/editorContainerStyles.js +203 -0
  56. package/src/utils/size.js +32 -0
  57. package/src/__tests__/editor.test.jsx +0 -363
  58. package/src/__tests__/serialization.test.js +0 -291
  59. package/src/block-tags.js +0 -17
  60. package/src/editor.jsx +0 -1197
  61. package/src/extensions/characters.js +0 -46
  62. package/src/old-index.jsx +0 -162
  63. package/src/parse-html.js +0 -8
  64. package/src/plugins/README.md +0 -27
  65. package/src/plugins/characters/index.jsx +0 -284
  66. package/src/plugins/characters/utils.js +0 -447
  67. package/src/plugins/css/index.jsx +0 -340
  68. package/src/plugins/customPlugin/index.jsx +0 -85
  69. package/src/plugins/html/icons/index.jsx +0 -19
  70. package/src/plugins/html/index.jsx +0 -72
  71. package/src/plugins/image/__tests__/__snapshots__/component.test.jsx.snap +0 -51
  72. package/src/plugins/image/__tests__/__snapshots__/image-toolbar-logic.test.jsx.snap +0 -27
  73. package/src/plugins/image/__tests__/__snapshots__/image-toolbar.test.jsx.snap +0 -44
  74. package/src/plugins/image/__tests__/component.test.jsx +0 -41
  75. package/src/plugins/image/__tests__/image-toolbar-logic.test.jsx +0 -42
  76. package/src/plugins/image/__tests__/image-toolbar.test.jsx +0 -11
  77. package/src/plugins/image/__tests__/index.test.js +0 -95
  78. package/src/plugins/image/__tests__/insert-image-handler.test.js +0 -113
  79. package/src/plugins/image/__tests__/mock-change.js +0 -15
  80. package/src/plugins/image/alt-dialog.jsx +0 -82
  81. package/src/plugins/image/component.jsx +0 -343
  82. package/src/plugins/image/image-toolbar.jsx +0 -100
  83. package/src/plugins/image/index.jsx +0 -227
  84. package/src/plugins/image/insert-image-handler.js +0 -79
  85. package/src/plugins/index.jsx +0 -377
  86. package/src/plugins/list/__tests__/index.test.js +0 -54
  87. package/src/plugins/list/index.jsx +0 -305
  88. package/src/plugins/math/__tests__/__snapshots__/index.test.jsx.snap +0 -48
  89. package/src/plugins/math/__tests__/index.test.jsx +0 -245
  90. package/src/plugins/math/index.jsx +0 -379
  91. package/src/plugins/media/__tests__/index.test.js +0 -75
  92. package/src/plugins/media/index.jsx +0 -325
  93. package/src/plugins/media/media-dialog.js +0 -624
  94. package/src/plugins/media/media-toolbar.jsx +0 -56
  95. package/src/plugins/media/media-wrapper.jsx +0 -43
  96. package/src/plugins/rendering/index.js +0 -31
  97. package/src/plugins/respArea/index.jsx +0 -299
  98. package/src/plugins/respArea/math-templated/index.jsx +0 -104
  99. package/src/plugins/respArea/utils.jsx +0 -90
  100. package/src/plugins/table/CustomTablePlugin.js +0 -113
  101. package/src/plugins/table/__tests__/__snapshots__/table-toolbar.test.jsx.snap +0 -44
  102. package/src/plugins/table/__tests__/index.test.jsx +0 -401
  103. package/src/plugins/table/__tests__/table-toolbar.test.jsx +0 -42
  104. package/src/plugins/table/index.jsx +0 -427
  105. package/src/plugins/table/table-toolbar.jsx +0 -136
  106. package/src/plugins/textAlign/index.jsx +0 -23
  107. package/src/plugins/toolbar/__tests__/__snapshots__/default-toolbar.test.jsx.snap +0 -923
  108. package/src/plugins/toolbar/__tests__/__snapshots__/editor-and-toolbar.test.jsx.snap +0 -20
  109. package/src/plugins/toolbar/__tests__/__snapshots__/toolbar-buttons.test.jsx.snap +0 -36
  110. package/src/plugins/toolbar/__tests__/__snapshots__/toolbar.test.jsx.snap +0 -46
  111. package/src/plugins/toolbar/__tests__/default-toolbar.test.jsx +0 -94
  112. package/src/plugins/toolbar/__tests__/editor-and-toolbar.test.jsx +0 -37
  113. package/src/plugins/toolbar/__tests__/toolbar-buttons.test.jsx +0 -51
  114. package/src/plugins/toolbar/__tests__/toolbar.test.jsx +0 -106
  115. package/src/plugins/toolbar/default-toolbar.jsx +0 -206
  116. package/src/plugins/toolbar/editor-and-toolbar.jsx +0 -257
  117. package/src/plugins/toolbar/index.jsx +0 -23
  118. package/src/plugins/toolbar/toolbar-buttons.jsx +0 -138
  119. package/src/plugins/toolbar/toolbar.jsx +0 -338
  120. package/src/plugins/utils.js +0 -31
  121. package/src/serialization.jsx +0 -621
  122. /package/src/{plugins → components}/characters/custom-popper.js +0 -0
  123. /package/src/{plugins/toolbar → components/common}/done-button.jsx +0 -0
  124. /package/src/{plugins/css/icons/index.jsx → components/icons/CssIcon.jsx} +0 -0
  125. /package/src/{plugins/respArea/icons/index.jsx → components/icons/RespArea.jsx} +0 -0
  126. /package/src/{plugins/table/icons/index.jsx → components/icons/TableIcons.jsx} +0 -0
  127. /package/src/{plugins/textAlign/icons/index.jsx → components/icons/TextAlign.jsx} +0 -0
  128. /package/src/{plugins/respArea/drag-in-the-blank/index.jsx → components/respArea/DragInTheBlank/DragInTheBlank.jsx} +0 -0
  129. /package/src/{plugins/respArea/explicit-constructed-response/index.jsx → components/respArea/ExplicitConstructedResponse.jsx} +0 -0
@@ -0,0 +1,96 @@
1
+ import React, { useEffect, useMemo } from 'react';
2
+ import classNames from 'classnames';
3
+ import { withStyles } from '@material-ui/core/styles';
4
+
5
+ import styles from '../styles/editorContainerStyles';
6
+ import { valueToSize } from '../utils/size';
7
+
8
+ import StyledMenuBar from './MenuBar';
9
+
10
+ function TiptapContainer(props) {
11
+ const {
12
+ editor,
13
+ disabled,
14
+ classes,
15
+ children,
16
+ disableUnderline,
17
+ disableScrollbar,
18
+ activePlugins,
19
+ toolbarOpts,
20
+ responseAreaProps,
21
+ autoFocus,
22
+ minWidth,
23
+ width,
24
+ maxWidth,
25
+ minHeight,
26
+ height,
27
+ maxHeight,
28
+ } = props;
29
+
30
+ const holderNames = classNames(classes.editorHolder, {
31
+ [classes.readOnly]: disabled,
32
+ [classes.disabledUnderline]: disableUnderline,
33
+ [classes.disabledScrollbar]: disableScrollbar,
34
+ });
35
+
36
+ useEffect(() => {
37
+ if (editor && autoFocus) {
38
+ Promise.resolve().then(() => {
39
+ editor.commands.focus('end');
40
+ });
41
+ }
42
+ }, [editor, autoFocus]);
43
+
44
+ const sizeStyle = useMemo(
45
+ () => ({
46
+ width: valueToSize(width),
47
+ minWidth: valueToSize(minWidth),
48
+ maxWidth: valueToSize(maxWidth),
49
+ height: valueToSize(height),
50
+ minHeight: valueToSize(minHeight),
51
+ maxHeight: valueToSize(maxHeight),
52
+ }),
53
+ [minWidth, width, maxWidth, minHeight, height, maxHeight],
54
+ );
55
+
56
+ return (
57
+ <div
58
+ className={classNames(
59
+ {
60
+ [classes.noBorder]: toolbarOpts && toolbarOpts.noBorder,
61
+ [classes.error]: toolbarOpts && toolbarOpts.error,
62
+ },
63
+ classes.root,
64
+ props.className,
65
+ )}
66
+ style={{ width: sizeStyle.width, minWidth: sizeStyle.minWidth, maxWidth: sizeStyle.maxWidth }}
67
+ >
68
+ <div className={holderNames}>
69
+ <div
70
+ className={classNames(
71
+ {
72
+ [classes.noPadding]: toolbarOpts && toolbarOpts.noPadding,
73
+ },
74
+ classes.children,
75
+ )}
76
+ >
77
+ {children}
78
+ </div>
79
+ </div>
80
+
81
+ {editor && (
82
+ <StyledMenuBar
83
+ editor={editor}
84
+ responseAreaProps={responseAreaProps}
85
+ toolbarOpts={toolbarOpts}
86
+ activePlugins={activePlugins}
87
+ onChange={props.onChange}
88
+ />
89
+ )}
90
+ </div>
91
+ );
92
+ }
93
+
94
+ const EditorContainer = withStyles(styles)(TiptapContainer);
95
+
96
+ export default EditorContainer;
@@ -0,0 +1,127 @@
1
+ export const spanishConfig = {
2
+ characters: [
3
+ ['á', 'é', 'í', 'ó', 'ú'],
4
+ ['Á', 'É', 'Í', 'Ó', 'Ú'],
5
+ ['—', '«', '»', 'ñ', 'ü'],
6
+ ['-', '¿', '¡', 'Ñ', 'Ü'],
7
+ ],
8
+ };
9
+
10
+ export const specialConfig = {
11
+ hasPreview: true,
12
+ characters: [
13
+ [
14
+ {
15
+ unicode: 'U+00A2',
16
+ description: 'CENT SIGN',
17
+ write: '¢',
18
+ label: '¢',
19
+ },
20
+ {
21
+ unicode: 'U+00BF',
22
+ description: 'INVERTED QUESTION MARK',
23
+ write: '¿',
24
+ label: '¿',
25
+ },
26
+ {
27
+ unicode: 'U+00B4',
28
+ description: 'ACUTE ACCENT',
29
+ write: '´',
30
+ label: '´',
31
+ extraProps: { style: { gridRow: 'span 2' } },
32
+ },
33
+ {
34
+ unicode: 'U+00E1',
35
+ description: 'LATIN SMALL LETTER A WITH ACUTE',
36
+ write: 'á',
37
+ label: 'á',
38
+ },
39
+ {
40
+ unicode: 'U+00E9',
41
+ description: 'LATIN SMALL LETTER E WITH ACUTE',
42
+ write: 'é',
43
+ label: 'é',
44
+ },
45
+ {
46
+ unicode: 'U+00ED',
47
+ description: 'LATIN SMALL LETTER I WITH ACUTE',
48
+ write: 'í',
49
+ label: 'í',
50
+ },
51
+ {
52
+ unicode: 'U+00F3',
53
+ description: 'LATIN SMALL LETTER O WITH ACUTE',
54
+ write: 'ó',
55
+ label: 'ó',
56
+ },
57
+ {
58
+ unicode: 'U+00FA',
59
+ description: 'LATIN SMALL LETTER U WITH ACUTE',
60
+ write: 'ú',
61
+ label: 'ú',
62
+ },
63
+ {
64
+ unicode: 'U+00F1',
65
+ description: 'LATIN SMALL LETTER N WITH TILDE',
66
+ write: 'ñ',
67
+ label: 'ñ',
68
+ },
69
+ ],
70
+ [
71
+ {
72
+ unicode: 'U+20AC',
73
+ description: 'EURO SIGN',
74
+ write: '€',
75
+ label: '€',
76
+ },
77
+ {
78
+ unicode: 'U+00A1',
79
+ description: 'INVERTED EXCLAMATION MARK',
80
+ write: '¡',
81
+ label: '¡',
82
+ },
83
+ {
84
+ unicode: 'U+00C1',
85
+ description: 'LATIN CAPITAL LETTER A WITH ACUTE',
86
+ write: 'Á',
87
+ label: 'Á',
88
+ },
89
+ {
90
+ unicode: 'U+00C9',
91
+ description: 'LATIN CAPITAL LETTER E WITH ACUTE',
92
+ write: 'É',
93
+ label: 'É',
94
+ },
95
+ {
96
+ unicode: 'U+00CD',
97
+ description: 'LATIN CAPITAL LETTER I WITH ACUTE',
98
+ write: 'Í',
99
+ label: 'Í',
100
+ },
101
+ {
102
+ unicode: 'U+00D3',
103
+ description: 'LATIN CAPITAL LETTER O WITH ACUTE',
104
+ write: 'Ó',
105
+ label: 'Ó',
106
+ },
107
+ {
108
+ unicode: 'U+00DA',
109
+ description: 'LATIN CAPITAL LETTER U WITH ACUTE',
110
+ write: 'Ú',
111
+ label: 'Ú',
112
+ },
113
+ {
114
+ unicode: 'U+00D1',
115
+ description: 'LATIN CAPITAL LETTER N WITH TILDE',
116
+ write: 'Ñ',
117
+ label: 'Ñ',
118
+ },
119
+ ],
120
+ // remaining rows kept identical to original utils.js...
121
+ ],
122
+ };
123
+
124
+ export const characterIcons = {
125
+ spanish: 'ñ',
126
+ special: '€',
127
+ };
@@ -0,0 +1 @@
1
+ export { default } from '../../plugins/image/image-toolbar';
@@ -0,0 +1 @@
1
+ export { default } from '../../plugins/image/insert-image-handler';
@@ -0,0 +1 @@
1
+ export { default } from '../../plugins/media/media-dialog';
@@ -0,0 +1 @@
1
+ export { default } from '../../plugins/media/media-toolbar';
@@ -7,7 +7,7 @@ import { renderMath } from '@pie-lib/math-rendering';
7
7
  import { withStyles } from '@material-ui/core/styles';
8
8
  import classnames from 'classnames';
9
9
 
10
- import { GripIcon } from '../icons';
10
+ import { GripIcon } from '../../icons/RespArea';
11
11
 
12
12
  const useStyles = withStyles((theme) => ({
13
13
  content: {
@@ -1,7 +1,7 @@
1
1
  import React, { useEffect, useRef, useState } from "react";
2
2
  import PropTypes from 'prop-types';
3
3
  import { NodeViewWrapper } from '@tiptap/react';
4
- import { Chevron } from '../icons';
4
+ import { Chevron } from '../icons/RespArea';
5
5
 
6
6
  const InlineDropdown = (props) => {
7
7
  const { editor, node, getPos, options, selected } = props;
@@ -0,0 +1,68 @@
1
+ import React from 'react';
2
+ import { withStyles } from '@material-ui/core/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 styles = (theme) => ({
55
+ icon: {
56
+ fontFamily: 'Cerebri Sans !important',
57
+ fontSize: theme.typography.fontSize,
58
+ fontWeight: 'bold',
59
+ lineHeight: '14px',
60
+ position: 'relative',
61
+ top: '7px',
62
+ width: '110px',
63
+ height: '28px',
64
+ whiteSpace: 'nowrap',
65
+ },
66
+ });
67
+
68
+ export const ToolbarIcon = withStyles(styles)(({ classes }) => <div className={classes.icon}>+ Response Area</div>);
@@ -6,8 +6,8 @@ import debug from 'debug';
6
6
  import LinearProgress from '@material-ui/core/LinearProgress';
7
7
  import { withStyles } from '@material-ui/core/styles';
8
8
  import { NodeViewWrapper } from '@tiptap/react';
9
- import InsertImageHandler from '../plugins/image/insert-image-handler';
10
- import ImageToolbar from '../plugins/image/image-toolbar';
9
+ import InsertImageHandler from '../components/image/InsertImageHandler';
10
+ import ImageToolbar from '../components/image/ImageToolbar';
11
11
  import CustomToolbarWrapper from './custom-toolbar-wrapper';
12
12
 
13
13
  const log = debug('@pie-lib:editable-html:plugins:image:component');
@@ -1,11 +1,10 @@
1
1
  import React, { useCallback } from 'react';
2
- import IconButton from "@material-ui/core/IconButton";
3
- import Delete from "@material-ui/icons/Delete";
4
- import { DoneButton } from "../plugins/toolbar/done-button";
5
- import classNames from "classnames";
6
- import { PIE_TOOLBAR__CLASS } from "../constants";
7
- import { withStyles } from "@material-ui/core/styles";
8
- import { Toolbar } from "../plugins/toolbar/toolbar";
2
+ import IconButton from '@material-ui/core/IconButton';
3
+ import Delete from '@material-ui/icons/Delete';
4
+ import classNames from 'classnames';
5
+ import { PIE_TOOLBAR__CLASS } from '../constants';
6
+ import { withStyles } from '@material-ui/core/styles';
7
+ import { DoneButton } from '../components/common/done-button';
9
8
 
10
9
  function CustomToolbarWrapper(props) {
11
10
  const {
@@ -0,0 +1,27 @@
1
+ import { Table } from '@tiptap/extension-table';
2
+
3
+ const ExtendedTable = Table.extend({
4
+ addAttributes() {
5
+ return {
6
+ border: { default: '1' },
7
+ };
8
+ },
9
+ renderHTML(props) {
10
+ const originalTable = this.parent(props);
11
+ const { border } = props.HTMLAttributes;
12
+
13
+ const previousStyle = `${originalTable[1].style}${originalTable[1].style.match(/.*; */) ? '' : ';'}`;
14
+
15
+ originalTable[1].style = `${previousStyle}
16
+ width: 100%;
17
+ color: var(--pie-text, black);
18
+ table-layout: fixed;
19
+ border-collapse: collapse;
20
+ background-color: var(--pie-background, rgba(255, 255, 255))`;
21
+ originalTable[1].border = border ? border : '1';
22
+
23
+ return originalTable;
24
+ },
25
+ });
26
+
27
+ export default ExtendedTable;
@@ -0,0 +1,76 @@
1
+ import React from 'react';
2
+ import compact from 'lodash/compact';
3
+ import isEmpty from 'lodash/isEmpty';
4
+ import debug from 'debug';
5
+
6
+ const log = debug('@pie-lib:editable-html:plugins');
7
+ export const ALL_PLUGINS = [
8
+ 'bold',
9
+ // 'code',
10
+ 'html',
11
+ 'extraCSSRules',
12
+ 'italic',
13
+ 'underline',
14
+ 'strikethrough',
15
+ 'bulleted-list',
16
+ 'numbered-list',
17
+ 'image',
18
+ 'math',
19
+ 'languageCharacters',
20
+ 'text-align',
21
+ 'blockquote',
22
+ 'h3',
23
+ 'table',
24
+ 'video',
25
+ 'audio',
26
+ 'responseArea',
27
+ 'redo',
28
+ 'undo',
29
+ 'superscript',
30
+ 'subscript',
31
+ ];
32
+
33
+ export const DEFAULT_EXTENSIONS = ALL_PLUGINS.filter((plug) => !['responseArea', 'h3', 'blockquote'].includes(plug));
34
+
35
+ export const buildExtensions = (activeExtensions, customExtensions, opts) => {
36
+ log('[buildPlugins] opts: ', opts);
37
+
38
+ activeExtensions = activeExtensions || DEFAULT_EXTENSIONS;
39
+
40
+ const addIf = (key, shouldAdd = true) => activeExtensions.includes(key) && shouldAdd && key;
41
+
42
+ const imagePlugin = opts.image && opts.image.onDelete;
43
+ const mathPlugin = opts.math;
44
+ const respAreaPlugin = opts.responseArea && opts.responseArea.type;
45
+ const cssPlugin = !isEmpty(opts.extraCSSRules);
46
+
47
+ const languageCharactersPlugins = opts?.languageCharacters || [];
48
+
49
+ return compact([
50
+ addIf('table'),
51
+ addIf('bold'),
52
+ // addIf('code', MarkHotkey({ key: '`', type: 'code', icon: <Code /> })),
53
+ addIf('italic'),
54
+ addIf('strikethrough'),
55
+ addIf('underline'),
56
+ // icon should be modifies accordingly
57
+ addIf('superscript'),
58
+ // icon should be modifies accordingly
59
+ addIf('subscript'),
60
+ addIf('image', imagePlugin),
61
+ addIf('video'),
62
+ addIf('audio'),
63
+ addIf('math', mathPlugin),
64
+ ...languageCharactersPlugins.map((plugin) => addIf('languageCharacters', plugin)),
65
+ addIf('text-align'),
66
+ addIf('blockquote'),
67
+ addIf('h3'),
68
+ addIf('bulleted-list'),
69
+ addIf('numbered-list'),
70
+ addIf('undo'),
71
+ addIf('redo'),
72
+ addIf('responseArea', respAreaPlugin),
73
+ addIf('css', cssPlugin),
74
+ addIf('html', !!opts.html),
75
+ ]);
76
+ };
@@ -2,8 +2,8 @@ import React, { useEffect } from 'react';
2
2
  import ReactDOM from 'react-dom';
3
3
  import { mergeAttributes, Node } from '@tiptap/core';
4
4
  import { NodeViewWrapper, ReactNodeViewRenderer } from '@tiptap/react';
5
- import MediaDialog from '../plugins/media/media-dialog';
6
- import MediaToolbar from '../plugins/media/media-toolbar';
5
+ import MediaDialog from '../components/media/MediaDialog';
6
+ import MediaToolbar from '../components/media/MediaToolbar';
7
7
 
8
8
  export const Media = Node.create({
9
9
  name: 'media',
@@ -144,7 +144,10 @@ export default function MediaNodeView({ editor, node, updateAttributes, deleteNo
144
144
  deleteNode();
145
145
  }
146
146
 
147
- editor.chain().focus().run();
147
+ editor
148
+ .chain()
149
+ .focus()
150
+ .run();
148
151
  },
149
152
  });
150
153
  };
@@ -161,7 +164,10 @@ export default function MediaNodeView({ editor, node, updateAttributes, deleteNo
161
164
  deleteNode();
162
165
  }
163
166
 
164
- editor.chain().focus().run();
167
+ editor
168
+ .chain()
169
+ .focus()
170
+ .run();
165
171
  },
166
172
  });
167
173
  }, []);
@@ -1,12 +1,12 @@
1
1
  // InlineNodes.js
2
2
  import React from 'react';
3
- import { Node, ReactNodeViewRenderer, ReactRenderer } from "@tiptap/react";
4
- import ExplicitConstructedResponse from '../plugins/respArea/explicit-constructed-response';
5
- import DragInTheBlank from '../plugins/respArea/drag-in-the-blank';
6
- import InlineDropdown from '../plugins/respArea/inline-dropdown';
7
- import { Extension } from "@tiptap/core";
8
- import { MathToolbar } from "@pie-lib/math-toolbar";
9
- import tippy from "tippy.js";
3
+ import { Node, ReactNodeViewRenderer, ReactRenderer } from '@tiptap/react';
4
+ import ExplicitConstructedResponse from '../components/respArea/ExplicitConstructedResponse';
5
+ import DragInTheBlank from '../components/respArea/DragInTheBlank/DragInTheBlank';
6
+ import InlineDropdown from '../components/respArea/InlineDropdown';
7
+ import { Extension } from '@tiptap/core';
8
+ import { MathToolbar } from '@pie-lib/math-toolbar';
9
+ import tippy from 'tippy.js';
10
10
 
11
11
  export const ResponseAreaExtension = Extension.create({
12
12
  name: 'responseArea',