@comet/cms-admin 9.0.0-beta.3 → 9.0.0-beta.4

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 (178) hide show
  1. package/lib/blocks/PixelImageBlock.d.ts.map +1 -1
  2. package/lib/blocks/PixelImageBlock.fragment.d.ts +2 -0
  3. package/lib/blocks/PixelImageBlock.fragment.d.ts.map +1 -0
  4. package/lib/blocks/PixelImageBlock.fragment.generated.d.ts +20 -0
  5. package/lib/blocks/PixelImageBlock.fragment.generated.d.ts.map +1 -0
  6. package/lib/blocks/PixelImageBlock.fragment.generated.js +5 -0
  7. package/lib/blocks/PixelImageBlock.fragment.js +4 -0
  8. package/lib/blocks/PixelImageBlock.js +3 -2
  9. package/lib/blocks/__stories__/RichTextBlock.stories.js +53 -0
  10. package/lib/blocks/createLinkBlock.d.ts.map +1 -1
  11. package/lib/blocks/createLinkBlock.js +50 -1
  12. package/lib/blocks/createRichTextBlock.d.ts.map +1 -1
  13. package/lib/blocks/createRichTextBlock.js +56 -20
  14. package/lib/blocks/createSeoBlock.d.ts.map +1 -1
  15. package/lib/blocks/createSeoBlock.js +6 -4
  16. package/lib/blocks/createTextLinkBlock.d.ts.map +1 -1
  17. package/lib/blocks/createTextLinkBlock.js +36 -1
  18. package/lib/blocks/factories/createBlocksBlock.d.ts.map +1 -1
  19. package/lib/blocks/factories/createBlocksBlock.js +70 -13
  20. package/lib/blocks/factories/createColumnsBlock.d.ts.map +1 -1
  21. package/lib/blocks/factories/createColumnsBlock.js +56 -6
  22. package/lib/blocks/factories/createListBlock.d.ts.map +1 -1
  23. package/lib/blocks/factories/createListBlock.js +56 -6
  24. package/lib/blocks/factories/createOneOfBlock.d.ts.map +1 -1
  25. package/lib/blocks/factories/createOneOfBlock.js +62 -5
  26. package/lib/blocks/factories/createOptionalBlock.d.ts.map +1 -1
  27. package/lib/blocks/factories/createOptionalBlock.js +38 -1
  28. package/lib/blocks/helpers/composeBlocks/composeBlocks.d.ts.map +1 -1
  29. package/lib/blocks/helpers/composeBlocks/composeBlocks.js +52 -16
  30. package/lib/blocks/helpers/composeBlocks/createCompositeBlockField.d.ts +2 -1
  31. package/lib/blocks/helpers/composeBlocks/createCompositeBlockField.d.ts.map +1 -1
  32. package/lib/blocks/helpers/composeBlocks/createCompositeBlockField.js +4 -2
  33. package/lib/blocks/helpers/composeBlocks/createSettingsBlock.d.ts +2 -1
  34. package/lib/blocks/helpers/composeBlocks/createSettingsBlock.d.ts.map +1 -1
  35. package/lib/blocks/helpers/composeBlocks/createSettingsBlock.js +5 -1
  36. package/lib/blocks/helpers/createBlockSkeleton.js +15 -1
  37. package/lib/blocks/helpers/createCompositeBlockTextField.d.ts +2 -1
  38. package/lib/blocks/helpers/createCompositeBlockTextField.d.ts.map +1 -1
  39. package/lib/blocks/helpers/createCompositeBlockTextField.js +20 -2
  40. package/lib/blocks/tipTap/BlockStyleContext.d.ts +3 -0
  41. package/lib/blocks/tipTap/BlockStyleContext.d.ts.map +1 -0
  42. package/lib/blocks/tipTap/BlockStyleContext.js +2 -0
  43. package/lib/blocks/tipTap/InlineStyleContext.d.ts +3 -0
  44. package/lib/blocks/tipTap/InlineStyleContext.d.ts.map +1 -0
  45. package/lib/blocks/tipTap/InlineStyleContext.js +2 -0
  46. package/lib/blocks/tipTap/TipTapLinkDialog.d.ts +10 -0
  47. package/lib/blocks/tipTap/TipTapLinkDialog.d.ts.map +1 -0
  48. package/lib/blocks/tipTap/TipTapLinkDialog.js +105 -0
  49. package/lib/blocks/tipTap/TipTapToolbar.d.ts +12 -0
  50. package/lib/blocks/tipTap/TipTapToolbar.d.ts.map +1 -0
  51. package/lib/blocks/tipTap/TipTapToolbar.js +611 -0
  52. package/lib/blocks/tipTap/__stories__/TipTapRichTextBlock.stories.js +1566 -0
  53. package/lib/blocks/tipTap/createTipTapRichTextBlock.d.ts +56 -0
  54. package/lib/blocks/tipTap/createTipTapRichTextBlock.d.ts.map +1 -0
  55. package/lib/blocks/tipTap/createTipTapRichTextBlock.js +418 -0
  56. package/lib/blocks/tipTap/extensions/BlockStyleHeading.d.ts +2 -0
  57. package/lib/blocks/tipTap/extensions/BlockStyleHeading.d.ts.map +1 -0
  58. package/lib/blocks/tipTap/extensions/BlockStyleHeading.js +57 -0
  59. package/lib/blocks/tipTap/extensions/BlockStyleParagraph.d.ts +2 -0
  60. package/lib/blocks/tipTap/extensions/BlockStyleParagraph.d.ts.map +1 -0
  61. package/lib/blocks/tipTap/extensions/BlockStyleParagraph.js +56 -0
  62. package/lib/blocks/tipTap/extensions/CmsLink.d.ts +13 -0
  63. package/lib/blocks/tipTap/extensions/CmsLink.d.ts.map +1 -0
  64. package/lib/blocks/tipTap/extensions/CmsLink.js +42 -0
  65. package/lib/blocks/tipTap/extensions/InlineStyleMark.d.ts +13 -0
  66. package/lib/blocks/tipTap/extensions/InlineStyleMark.d.ts.map +1 -0
  67. package/lib/blocks/tipTap/extensions/InlineStyleMark.js +71 -0
  68. package/lib/blocks/tipTap/extensions/NonBreakingSpace.d.ts +10 -0
  69. package/lib/blocks/tipTap/extensions/NonBreakingSpace.d.ts.map +1 -0
  70. package/lib/blocks/tipTap/extensions/NonBreakingSpace.js +57 -0
  71. package/lib/blocks/tipTap/extensions/SoftHyphen.d.ts +10 -0
  72. package/lib/blocks/tipTap/extensions/SoftHyphen.d.ts.map +1 -0
  73. package/lib/blocks/tipTap/extensions/SoftHyphen.js +51 -0
  74. package/lib/blocks/tipTap/listLevelMaxHelpers.d.ts +6 -0
  75. package/lib/blocks/tipTap/listLevelMaxHelpers.d.ts.map +1 -0
  76. package/lib/blocks/tipTap/listLevelMaxHelpers.js +108 -0
  77. package/lib/blocks/types.d.ts +7 -0
  78. package/lib/blocks/types.d.ts.map +1 -1
  79. package/lib/config/CometConfigContext.d.ts +2 -1
  80. package/lib/config/CometConfigContext.d.ts.map +1 -1
  81. package/lib/config/CometConfigContext.js +9 -5
  82. package/lib/contentScope/__stories__/ContentScopeProvider.stories.js +85 -0
  83. package/lib/contentScope/__stories__/ContentScopeSelect.stories.js +655 -0
  84. package/lib/contentScope/noContentScopeFallback/__stories__/NoContentScopeFallback.stories.js +7 -0
  85. package/lib/dam/DamTable.d.ts +5 -1
  86. package/lib/dam/DamTable.d.ts.map +1 -1
  87. package/lib/dam/DamTable.js +5 -1
  88. package/lib/dam/DataGrid/FolderDataGrid.d.ts +1 -1
  89. package/lib/dam/DataGrid/FolderDataGrid.d.ts.map +1 -1
  90. package/lib/dam/DataGrid/FolderDataGrid.js +52 -43
  91. package/lib/dam/DataGrid/selection/DamSelectionContext.d.ts +7 -4
  92. package/lib/dam/DataGrid/selection/DamSelectionContext.d.ts.map +1 -1
  93. package/lib/dam/DataGrid/selection/DamSelectionContext.js +11 -3
  94. package/lib/form/file/FileField.d.ts +15 -12
  95. package/lib/form/file/FileField.d.ts.map +1 -1
  96. package/lib/form/file/FileField.gql.d.ts +2 -0
  97. package/lib/form/file/FileField.gql.d.ts.map +1 -1
  98. package/lib/form/file/FileField.gql.generated.d.ts +40 -0
  99. package/lib/form/file/FileField.gql.generated.d.ts.map +1 -1
  100. package/lib/form/file/FileField.gql.generated.js +2 -1
  101. package/lib/form/file/FileField.gql.js +6 -3
  102. package/lib/form/file/FileField.js +170 -86
  103. package/lib/form/file/FileFieldMenu.d.ts +17 -0
  104. package/lib/form/file/FileFieldMenu.d.ts.map +1 -0
  105. package/lib/form/file/FileFieldMenu.js +91 -0
  106. package/lib/form/file/FileFieldRow.d.ts +12 -0
  107. package/lib/form/file/FileFieldRow.d.ts.map +1 -0
  108. package/lib/form/file/FileFieldRow.js +96 -0
  109. package/lib/form/file/chooseFile/BaseChooseDamFileDialog.d.ts +20 -0
  110. package/lib/form/file/chooseFile/BaseChooseDamFileDialog.d.ts.map +1 -0
  111. package/lib/form/file/chooseFile/BaseChooseDamFileDialog.js +106 -0
  112. package/lib/form/file/chooseFile/ChooseDamFileDialog.d.ts.map +1 -1
  113. package/lib/form/file/chooseFile/ChooseDamFileDialog.js +34 -89
  114. package/lib/form/file/chooseFile/ChooseDamFilesDialog.d.ts +9 -0
  115. package/lib/form/file/chooseFile/ChooseDamFilesDialog.d.ts.map +1 -0
  116. package/lib/form/file/chooseFile/ChooseDamFilesDialog.js +117 -0
  117. package/lib/graphql.generated.d.ts +12 -1
  118. package/lib/graphql.generated.d.ts.map +1 -1
  119. package/lib/index.d.ts +8 -1
  120. package/lib/index.d.ts.map +1 -1
  121. package/lib/index.js +5 -0
  122. package/lib/pages/createEditPageNode.d.ts.map +1 -1
  123. package/lib/pages/createEditPageNode.js +1 -12
  124. package/lib/pages/createUsePage.d.ts +1 -0
  125. package/lib/pages/createUsePage.d.ts.map +1 -1
  126. package/lib/pages/createUsePage.js +135 -6
  127. package/lib/pages/pageTree/PageActions.d.ts.map +1 -1
  128. package/lib/pages/pageTree/PageActions.js +21 -3
  129. package/lib/pages/pageTree/findAvailableSlug.d.ts +11 -0
  130. package/lib/pages/pageTree/findAvailableSlug.d.ts.map +1 -0
  131. package/lib/pages/pageTree/findAvailableSlug.generated.d.ts +16 -0
  132. package/lib/pages/pageTree/findAvailableSlug.generated.d.ts.map +1 -0
  133. package/lib/pages/pageTree/findAvailableSlug.generated.js +5 -0
  134. package/lib/pages/pageTree/findAvailableSlug.js +62 -0
  135. package/lib/pages/pageTree/transformToSlug.d.ts +2 -0
  136. package/lib/pages/pageTree/transformToSlug.d.ts.map +1 -0
  137. package/lib/pages/pageTree/transformToSlug.js +12 -0
  138. package/lib/pages/pageTree/useCopyPastePages/sendPages.d.ts.map +1 -1
  139. package/lib/pages/pageTree/useCopyPastePages/sendPages.generated.d.ts +0 -10
  140. package/lib/pages/pageTree/useCopyPastePages/sendPages.generated.d.ts.map +1 -1
  141. package/lib/pages/pageTree/useCopyPastePages/sendPages.generated.js +0 -1
  142. package/lib/pages/pageTree/useCopyPastePages/sendPages.js +19 -40
  143. package/lib/pages/pageTree/useCopyPastePages.d.ts.map +1 -1
  144. package/lib/pages/pageTree/useCopyPastePages.js +1 -1
  145. package/lib/pages/pageTree/{useCopyPastePages/ProgressDialog.d.ts → useProgressDialog.d.ts} +1 -1
  146. package/lib/pages/pageTree/useProgressDialog.d.ts.map +1 -0
  147. package/lib/pages/pageTree/useTranslatePagesAction.d.ts +16 -0
  148. package/lib/pages/pageTree/useTranslatePagesAction.d.ts.map +1 -0
  149. package/lib/pages/pageTree/useTranslatePagesAction.generated.d.ts +20 -0
  150. package/lib/pages/pageTree/useTranslatePagesAction.generated.d.ts.map +1 -0
  151. package/lib/pages/pageTree/useTranslatePagesAction.generated.js +5 -0
  152. package/lib/pages/pageTree/useTranslatePagesAction.js +339 -0
  153. package/lib/pages/pagesPage/PagesPageActionToolbar.d.ts.map +1 -1
  154. package/lib/pages/pagesPage/PagesPageActionToolbar.js +29 -2
  155. package/lib/pages/pagesPage/PagesPageActionToolbar.sc.d.ts +2 -2
  156. package/lib/translation/AzureAiTranslatorProvider.d.ts +1 -1
  157. package/lib/translation/AzureAiTranslatorProvider.d.ts.map +1 -1
  158. package/lib/translation/AzureAiTranslatorProvider.generated.d.ts +8 -0
  159. package/lib/translation/AzureAiTranslatorProvider.generated.d.ts.map +1 -1
  160. package/lib/translation/AzureAiTranslatorProvider.generated.js +2 -1
  161. package/lib/translation/AzureAiTranslatorProvider.js +31 -2
  162. package/lib/translation/TranslatableInterface.d.ts +4 -0
  163. package/lib/translation/TranslatableInterface.d.ts.map +1 -0
  164. package/lib/translation/TranslatableInterface.js +1 -0
  165. package/lib/translation/TranslateContentMenuItem.d.ts +7 -0
  166. package/lib/translation/TranslateContentMenuItem.d.ts.map +1 -0
  167. package/lib/translation/TranslateContentMenuItem.js +99 -0
  168. package/lib/translation/createDocumentTranslationMethods.d.ts +4 -0
  169. package/lib/translation/createDocumentTranslationMethods.d.ts.map +1 -0
  170. package/lib/translation/createDocumentTranslationMethods.js +62 -0
  171. package/lib/validation/validateJson.d.ts +2 -0
  172. package/lib/validation/validateJson.d.ts.map +1 -0
  173. package/lib/validation/validateJson.js +15 -0
  174. package/package.json +32 -23
  175. package/lib/dashboard/__stories__/DateTime.stories.d.ts +0 -7
  176. package/lib/dashboard/__stories__/DateTime.stories.d.ts.map +0 -1
  177. package/lib/pages/pageTree/useCopyPastePages/ProgressDialog.d.ts.map +0 -1
  178. /package/lib/pages/pageTree/{useCopyPastePages/ProgressDialog.js → useProgressDialog.js} +0 -0
@@ -0,0 +1,1566 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
8
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
9
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
10
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
11
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
12
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
14
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
15
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
16
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
17
+ import { Box, Typography } from "@mui/material";
18
+ import { useState } from "react";
19
+ import { expect, waitFor, within } from "storybook/test";
20
+ import { createTipTapRichTextBlock } from "../createTipTapRichTextBlock";
21
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
22
+ function StatePreview(_ref) {
23
+ var state = _ref.state;
24
+ return /*#__PURE__*/_jsx(Box, {
25
+ component: "pre",
26
+ sx: {
27
+ mt: 2,
28
+ p: 2,
29
+ backgroundColor: "#f5f5f5",
30
+ fontSize: 12,
31
+ overflow: "auto",
32
+ borderRadius: 1
33
+ },
34
+ children: JSON.stringify(state, null, 2)
35
+ });
36
+ }
37
+ function StoryWrapper(_ref2) {
38
+ var children = _ref2.children,
39
+ state = _ref2.state;
40
+ return /*#__PURE__*/_jsxs(_Fragment, {
41
+ children: [children, /*#__PURE__*/_jsx(StatePreview, {
42
+ state: state
43
+ })]
44
+ });
45
+ }
46
+ var TipTapRichTextBlock = createTipTapRichTextBlock();
47
+ function TipTapRichTextBlockStory() {
48
+ var _useState = useState(TipTapRichTextBlock.defaultValues()),
49
+ _useState2 = _slicedToArray(_useState, 2),
50
+ state = _useState2[0],
51
+ setState = _useState2[1];
52
+ return /*#__PURE__*/_jsx(StoryWrapper, {
53
+ state: state,
54
+ children: /*#__PURE__*/_jsx(TipTapRichTextBlock.AdminComponent, {
55
+ state: state,
56
+ updateState: setState
57
+ })
58
+ });
59
+ }
60
+ var config = {
61
+ component: TipTapRichTextBlockStory,
62
+ title: "blocks/TipTapRichTextBlock"
63
+ };
64
+ export default config;
65
+ export var Default = {
66
+ play: function () {
67
+ var _play = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(_ref3) {
68
+ var canvas, step;
69
+ return _regenerator().w(function (_context3) {
70
+ while (1) switch (_context3.n) {
71
+ case 0:
72
+ canvas = _ref3.canvas, step = _ref3.step;
73
+ _context3.n = 1;
74
+ return step("Editor is ready with toolbar", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
75
+ var buttons;
76
+ return _regenerator().w(function (_context) {
77
+ while (1) switch (_context.n) {
78
+ case 0:
79
+ _context.n = 1;
80
+ return waitFor(function () {
81
+ expect(canvas.getByRole("textbox")).toBeInTheDocument();
82
+ }, {
83
+ timeout: 5000
84
+ });
85
+ case 1:
86
+ // Heading select shows "Default"
87
+ expect(canvas.getByRole("combobox")).toBeInTheDocument();
88
+ expect(canvas.getByText("Default")).toBeInTheDocument();
89
+
90
+ // Toolbar has buttons (undo, redo, bold, italic, strike, more, ol, ul, indent, dedent, nbsp, shy)
91
+ buttons = canvas.getAllByRole("button");
92
+ expect(buttons.length).toBeGreaterThanOrEqual(10);
93
+ case 2:
94
+ return _context.a(2);
95
+ }
96
+ }, _callee);
97
+ })));
98
+ case 1:
99
+ _context3.n = 2;
100
+ return step("Undo/redo are disabled initially", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
101
+ var buttons;
102
+ return _regenerator().w(function (_context2) {
103
+ while (1) switch (_context2.n) {
104
+ case 0:
105
+ buttons = canvas.getAllByRole("button"); // First two buttons are undo and redo
106
+ expect(buttons[0]).toBeDisabled();
107
+ expect(buttons[1]).toBeDisabled();
108
+ case 1:
109
+ return _context2.a(2);
110
+ }
111
+ }, _callee2);
112
+ })));
113
+ case 2:
114
+ return _context3.a(2);
115
+ }
116
+ }, _callee3);
117
+ }));
118
+ function play(_x) {
119
+ return _play.apply(this, arguments);
120
+ }
121
+ return play;
122
+ }()
123
+ };
124
+ var BoldOnlyBlock = createTipTapRichTextBlock({
125
+ supports: ["bold"]
126
+ });
127
+ function BoldOnlyStory() {
128
+ var _useState3 = useState(BoldOnlyBlock.defaultValues()),
129
+ _useState4 = _slicedToArray(_useState3, 2),
130
+ state = _useState4[0],
131
+ setState = _useState4[1];
132
+ return /*#__PURE__*/_jsx(StoryWrapper, {
133
+ state: state,
134
+ children: /*#__PURE__*/_jsx(BoldOnlyBlock.AdminComponent, {
135
+ state: state,
136
+ updateState: setState
137
+ })
138
+ });
139
+ }
140
+ export var BoldOnly = {
141
+ render: function render() {
142
+ return /*#__PURE__*/_jsx(BoldOnlyStory, {});
143
+ },
144
+ play: function () {
145
+ var _play2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(_ref6) {
146
+ var canvas, step;
147
+ return _regenerator().w(function (_context5) {
148
+ while (1) switch (_context5.n) {
149
+ case 0:
150
+ canvas = _ref6.canvas, step = _ref6.step;
151
+ _context5.n = 1;
152
+ return step("Editor is ready with minimal toolbar", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
153
+ var buttons;
154
+ return _regenerator().w(function (_context4) {
155
+ while (1) switch (_context4.n) {
156
+ case 0:
157
+ _context4.n = 1;
158
+ return waitFor(function () {
159
+ expect(canvas.getByRole("textbox")).toBeInTheDocument();
160
+ }, {
161
+ timeout: 5000
162
+ });
163
+ case 1:
164
+ // Only bold button, no heading select
165
+ expect(canvas.queryByRole("combobox")).not.toBeInTheDocument();
166
+ expect(canvas.queryByText("Default")).not.toBeInTheDocument();
167
+
168
+ // Exactly 1 button (bold only — no undo/redo, no lists, no special chars)
169
+ buttons = canvas.getAllByRole("button");
170
+ expect(buttons).toHaveLength(1);
171
+ case 2:
172
+ return _context4.a(2);
173
+ }
174
+ }, _callee4);
175
+ })));
176
+ case 1:
177
+ return _context5.a(2);
178
+ }
179
+ }, _callee5);
180
+ }));
181
+ function play(_x2) {
182
+ return _play2.apply(this, arguments);
183
+ }
184
+ return play;
185
+ }()
186
+ };
187
+ var BlockStylesBlock = createTipTapRichTextBlock({
188
+ blockStyles: [{
189
+ name: "large-heading",
190
+ label: "Large Heading",
191
+ appliesTo: ["heading-1", "heading-2"],
192
+ element: function element(p) {
193
+ return /*#__PURE__*/_jsx(Typography, _objectSpread({
194
+ sx: {
195
+ fontSize: 48,
196
+ lineHeight: 1.2
197
+ },
198
+ variant: "h1"
199
+ }, p));
200
+ }
201
+ }, {
202
+ name: "intro",
203
+ label: "Intro Text",
204
+ appliesTo: ["paragraph"],
205
+ element: function element(props) {
206
+ return /*#__PURE__*/_jsx("p", _objectSpread({
207
+ style: {
208
+ fontSize: 20,
209
+ fontStyle: "italic"
210
+ }
211
+ }, props));
212
+ }
213
+ }, {
214
+ name: "highlight",
215
+ label: "Highlight",
216
+ element: function element(props) {
217
+ return /*#__PURE__*/_jsx("div", _objectSpread({
218
+ style: {
219
+ backgroundColor: "#fff3cd",
220
+ padding: 8
221
+ }
222
+ }, props));
223
+ }
224
+ }]
225
+ });
226
+ function BlockStylesStory() {
227
+ var _useState5 = useState(BlockStylesBlock.defaultValues()),
228
+ _useState6 = _slicedToArray(_useState5, 2),
229
+ state = _useState6[0],
230
+ setState = _useState6[1];
231
+ return /*#__PURE__*/_jsx(StoryWrapper, {
232
+ state: state,
233
+ children: /*#__PURE__*/_jsx(BlockStylesBlock.AdminComponent, {
234
+ state: state,
235
+ updateState: setState
236
+ })
237
+ });
238
+ }
239
+ export var BlockStyles = {
240
+ render: function render() {
241
+ return /*#__PURE__*/_jsx(BlockStylesStory, {});
242
+ },
243
+ play: function () {
244
+ var _play3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(_ref8) {
245
+ var canvas, userEvent, step;
246
+ return _regenerator().w(function (_context9) {
247
+ while (1) switch (_context9.n) {
248
+ case 0:
249
+ canvas = _ref8.canvas, userEvent = _ref8.userEvent, step = _ref8.step;
250
+ _context9.n = 1;
251
+ return step("Editor is ready with block style dropdown", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
252
+ var defaults;
253
+ return _regenerator().w(function (_context6) {
254
+ while (1) switch (_context6.n) {
255
+ case 0:
256
+ _context6.n = 1;
257
+ return waitFor(function () {
258
+ var comboboxes = canvas.getAllByRole("combobox");
259
+ expect(comboboxes).toHaveLength(2);
260
+ }, {
261
+ timeout: 5000
262
+ });
263
+ case 1:
264
+ defaults = canvas.getAllByText("Default");
265
+ expect(defaults.length).toBeGreaterThanOrEqual(2);
266
+ case 2:
267
+ return _context6.a(2);
268
+ }
269
+ }, _callee6);
270
+ })));
271
+ case 1:
272
+ _context9.n = 2;
273
+ return step("Select block style 'Intro Text'", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7() {
274
+ var comboboxes;
275
+ return _regenerator().w(function (_context7) {
276
+ while (1) switch (_context7.n) {
277
+ case 0:
278
+ // Click the second combobox (block style select)
279
+ comboboxes = canvas.getAllByRole("combobox");
280
+ _context7.n = 1;
281
+ return userEvent.click(comboboxes[1]);
282
+ case 1:
283
+ _context7.n = 2;
284
+ return waitFor(function () {
285
+ expect(within(document.body).getByRole("option", {
286
+ name: "Intro Text"
287
+ })).toBeInTheDocument();
288
+ }, {
289
+ timeout: 3000
290
+ });
291
+ case 2:
292
+ _context7.n = 3;
293
+ return userEvent.click(within(document.body).getByRole("option", {
294
+ name: "Intro Text"
295
+ }));
296
+ case 3:
297
+ _context7.n = 4;
298
+ return waitFor(function () {
299
+ expect(canvas.getByText("Intro Text")).toBeInTheDocument();
300
+ }, {
301
+ timeout: 3000
302
+ });
303
+ case 4:
304
+ return _context7.a(2);
305
+ }
306
+ }, _callee7);
307
+ })));
308
+ case 2:
309
+ _context9.n = 3;
310
+ return step("Typing into a styled block preserves character order (cursor does not jump to start)", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
311
+ var editor;
312
+ return _regenerator().w(function (_context8) {
313
+ while (1) switch (_context8.n) {
314
+ case 0:
315
+ editor = canvas.getByRole("textbox");
316
+ _context8.n = 1;
317
+ return userEvent.click(editor);
318
+ case 1:
319
+ _context8.n = 2;
320
+ return userEvent.keyboard("hello");
321
+ case 2:
322
+ _context8.n = 3;
323
+ return waitFor(function () {
324
+ expect(editor).toHaveTextContent("hello");
325
+ }, {
326
+ timeout: 3000
327
+ });
328
+ case 3:
329
+ return _context8.a(2);
330
+ }
331
+ }, _callee8);
332
+ })));
333
+ case 3:
334
+ return _context9.a(2);
335
+ }
336
+ }, _callee9);
337
+ }));
338
+ function play(_x3) {
339
+ return _play3.apply(this, arguments);
340
+ }
341
+ return play;
342
+ }()
343
+ };
344
+ var BlockStyleInteractionsBlock = createTipTapRichTextBlock({
345
+ blockStyles: [{
346
+ name: "chapter-heading",
347
+ label: "Chapter Heading",
348
+ appliesTo: ["heading-1"],
349
+ element: function element(props) {
350
+ return /*#__PURE__*/_jsx("h1", _objectSpread({
351
+ style: {
352
+ textTransform: "uppercase",
353
+ letterSpacing: "0.1em"
354
+ }
355
+ }, props));
356
+ }
357
+ }, {
358
+ name: "large-heading",
359
+ label: "Large Heading",
360
+ appliesTo: ["heading-1", "heading-2"],
361
+ element: function element(p) {
362
+ return /*#__PURE__*/_jsx(Typography, _objectSpread({
363
+ sx: {
364
+ fontSize: 48,
365
+ lineHeight: 1.2
366
+ },
367
+ variant: "h1"
368
+ }, p));
369
+ }
370
+ }, {
371
+ name: "intro",
372
+ label: "Intro Text",
373
+ appliesTo: ["paragraph"],
374
+ element: function element(props) {
375
+ return /*#__PURE__*/_jsx("p", _objectSpread({
376
+ style: {
377
+ fontSize: 20,
378
+ fontStyle: "italic"
379
+ }
380
+ }, props));
381
+ }
382
+ }, {
383
+ name: "highlight",
384
+ label: "Highlight",
385
+ element: function element(props) {
386
+ return /*#__PURE__*/_jsx("div", _objectSpread({
387
+ style: {
388
+ backgroundColor: "#fff3cd",
389
+ padding: 8
390
+ }
391
+ }, props));
392
+ }
393
+ }]
394
+ });
395
+ function BlockStyleInteractionsStory() {
396
+ var _useState7 = useState(BlockStyleInteractionsBlock.defaultValues()),
397
+ _useState8 = _slicedToArray(_useState7, 2),
398
+ state = _useState8[0],
399
+ setState = _useState8[1];
400
+ return /*#__PURE__*/_jsx(StoryWrapper, {
401
+ state: state,
402
+ children: /*#__PURE__*/_jsx(BlockStyleInteractionsBlock.AdminComponent, {
403
+ state: state,
404
+ updateState: setState
405
+ })
406
+ });
407
+ }
408
+ export var BlockStyleInteractions = {
409
+ render: function render() {
410
+ return /*#__PURE__*/_jsx(BlockStyleInteractionsStory, {});
411
+ },
412
+ play: function () {
413
+ var _play4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(_ref10) {
414
+ var canvas, userEvent, step;
415
+ return _regenerator().w(function (_context16) {
416
+ while (1) switch (_context16.n) {
417
+ case 0:
418
+ canvas = _ref10.canvas, userEvent = _ref10.userEvent, step = _ref10.step;
419
+ _context16.n = 1;
420
+ return step("Editor is ready", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0() {
421
+ return _regenerator().w(function (_context0) {
422
+ while (1) switch (_context0.n) {
423
+ case 0:
424
+ _context0.n = 1;
425
+ return waitFor(function () {
426
+ expect(canvas.getByRole("textbox")).toBeInTheDocument();
427
+ }, {
428
+ timeout: 5000
429
+ });
430
+ case 1:
431
+ return _context0.a(2);
432
+ }
433
+ }, _callee0);
434
+ })));
435
+ case 1:
436
+ _context16.n = 2;
437
+ return step("Select Heading 1", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
438
+ var blockTypeSelect;
439
+ return _regenerator().w(function (_context1) {
440
+ while (1) switch (_context1.n) {
441
+ case 0:
442
+ blockTypeSelect = canvas.getAllByRole("combobox")[0];
443
+ _context1.n = 1;
444
+ return userEvent.click(blockTypeSelect);
445
+ case 1:
446
+ _context1.n = 2;
447
+ return waitFor(function () {
448
+ expect(within(document.body).getByText("Heading 1")).toBeInTheDocument();
449
+ }, {
450
+ timeout: 3000
451
+ });
452
+ case 2:
453
+ _context1.n = 3;
454
+ return userEvent.click(within(document.body).getByText("Heading 1"));
455
+ case 3:
456
+ _context1.n = 4;
457
+ return waitFor(function () {
458
+ expect(canvas.getAllByRole("combobox")[0]).toHaveTextContent("Heading 1");
459
+ }, {
460
+ timeout: 3000
461
+ });
462
+ case 4:
463
+ return _context1.a(2);
464
+ }
465
+ }, _callee1);
466
+ })));
467
+ case 2:
468
+ _context16.n = 3;
469
+ return step("Verify available styles for Heading 1: Chapter Heading, Large Heading, Highlight — but not Intro Text", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10() {
470
+ var blockStyleSelect;
471
+ return _regenerator().w(function (_context10) {
472
+ while (1) switch (_context10.n) {
473
+ case 0:
474
+ blockStyleSelect = canvas.getAllByRole("combobox")[1];
475
+ _context10.n = 1;
476
+ return userEvent.click(blockStyleSelect);
477
+ case 1:
478
+ _context10.n = 2;
479
+ return waitFor(function () {
480
+ var body = within(document.body);
481
+ expect(body.getByText("Chapter Heading")).toBeInTheDocument();
482
+ expect(body.getByText("Large Heading")).toBeInTheDocument();
483
+ expect(body.getByText("Highlight")).toBeInTheDocument();
484
+ expect(body.queryByText("Intro Text")).not.toBeInTheDocument();
485
+ }, {
486
+ timeout: 3000
487
+ });
488
+ case 2:
489
+ return _context10.a(2);
490
+ }
491
+ }, _callee10);
492
+ })));
493
+ case 3:
494
+ _context16.n = 4;
495
+ return step("Select 'Chapter Heading' style (heading-1 only)", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
496
+ return _regenerator().w(function (_context11) {
497
+ while (1) switch (_context11.n) {
498
+ case 0:
499
+ _context11.n = 1;
500
+ return userEvent.click(within(document.body).getByText("Chapter Heading"));
501
+ case 1:
502
+ _context11.n = 2;
503
+ return waitFor(function () {
504
+ expect(canvas.getAllByRole("combobox")[1]).toHaveTextContent("Chapter Heading");
505
+ }, {
506
+ timeout: 3000
507
+ });
508
+ case 2:
509
+ return _context11.a(2);
510
+ }
511
+ }, _callee11);
512
+ })));
513
+ case 4:
514
+ _context16.n = 5;
515
+ return step("Verify chapter heading styling is applied (uppercase)", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
516
+ return _regenerator().w(function (_context12) {
517
+ while (1) switch (_context12.n) {
518
+ case 0:
519
+ _context12.n = 1;
520
+ return waitFor(function () {
521
+ var styledEl = document.querySelector('[data-block-style="chapter-heading"]');
522
+ expect(styledEl).toBeTruthy();
523
+ expect(styledEl).toHaveStyle({
524
+ textTransform: "uppercase"
525
+ });
526
+ }, {
527
+ timeout: 3000
528
+ });
529
+ case 1:
530
+ return _context12.a(2);
531
+ }
532
+ }, _callee12);
533
+ })));
534
+ case 5:
535
+ _context16.n = 6;
536
+ return step("Switch to Heading 2", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
537
+ var blockTypeSelect;
538
+ return _regenerator().w(function (_context13) {
539
+ while (1) switch (_context13.n) {
540
+ case 0:
541
+ blockTypeSelect = canvas.getAllByRole("combobox")[0];
542
+ _context13.n = 1;
543
+ return userEvent.click(blockTypeSelect);
544
+ case 1:
545
+ _context13.n = 2;
546
+ return waitFor(function () {
547
+ expect(within(document.body).getByText("Heading 2")).toBeInTheDocument();
548
+ }, {
549
+ timeout: 3000
550
+ });
551
+ case 2:
552
+ _context13.n = 3;
553
+ return userEvent.click(within(document.body).getByText("Heading 2"));
554
+ case 3:
555
+ _context13.n = 4;
556
+ return waitFor(function () {
557
+ expect(canvas.getAllByRole("combobox")[0]).toHaveTextContent("Heading 2");
558
+ }, {
559
+ timeout: 3000
560
+ });
561
+ case 4:
562
+ return _context13.a(2);
563
+ }
564
+ }, _callee13);
565
+ })));
566
+ case 6:
567
+ _context16.n = 7;
568
+ return step("Block style auto-resets to Default (Chapter Heading doesn't apply to heading-2)", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
569
+ return _regenerator().w(function (_context14) {
570
+ while (1) switch (_context14.n) {
571
+ case 0:
572
+ _context14.n = 1;
573
+ return waitFor(function () {
574
+ expect(canvas.getAllByRole("combobox")[1]).toHaveTextContent("Default");
575
+ }, {
576
+ timeout: 3000
577
+ });
578
+ case 1:
579
+ return _context14.a(2);
580
+ }
581
+ }, _callee14);
582
+ })));
583
+ case 7:
584
+ _context16.n = 8;
585
+ return step("Verify chapter heading styling is removed", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
586
+ return _regenerator().w(function (_context15) {
587
+ while (1) switch (_context15.n) {
588
+ case 0:
589
+ _context15.n = 1;
590
+ return waitFor(function () {
591
+ expect(document.querySelector("[data-block-style]")).toBeNull();
592
+ }, {
593
+ timeout: 3000
594
+ });
595
+ case 1:
596
+ return _context15.a(2);
597
+ }
598
+ }, _callee15);
599
+ })));
600
+ case 8:
601
+ return _context16.a(2);
602
+ }
603
+ }, _callee16);
604
+ }));
605
+ function play(_x4) {
606
+ return _play4.apply(this, arguments);
607
+ }
608
+ return play;
609
+ }()
610
+ };
611
+ var ListBlockStylesBlock = createTipTapRichTextBlock({
612
+ supports: ["bold", "ordered-list", "unordered-list", "heading"],
613
+ blockStyles: [{
614
+ name: "intro",
615
+ label: "Intro Text",
616
+ appliesTo: ["paragraph"],
617
+ element: function element(props) {
618
+ return /*#__PURE__*/_jsx("p", _objectSpread({
619
+ style: {
620
+ fontSize: 20,
621
+ fontStyle: "italic"
622
+ }
623
+ }, props));
624
+ }
625
+ }, {
626
+ name: "list-large",
627
+ label: "List Large",
628
+ appliesTo: ["ordered-list", "unordered-list"],
629
+ element: function element(props) {
630
+ return /*#__PURE__*/_jsx("p", _objectSpread({
631
+ style: {
632
+ fontSize: 18,
633
+ lineHeight: "26px"
634
+ }
635
+ }, props));
636
+ }
637
+ }, {
638
+ name: "list-small",
639
+ label: "List Small",
640
+ appliesTo: ["ordered-list", "unordered-list"],
641
+ element: function element(props) {
642
+ return /*#__PURE__*/_jsx("p", _objectSpread({
643
+ style: {
644
+ fontSize: 14,
645
+ lineHeight: "20px"
646
+ }
647
+ }, props));
648
+ }
649
+ }, {
650
+ name: "ol-only",
651
+ label: "Numbered Style",
652
+ appliesTo: ["ordered-list"],
653
+ element: function element(props) {
654
+ return /*#__PURE__*/_jsx("p", _objectSpread({
655
+ style: {
656
+ fontSize: 16,
657
+ fontWeight: 600
658
+ }
659
+ }, props));
660
+ }
661
+ }, {
662
+ name: "universal",
663
+ label: "Universal",
664
+ element: function element(props) {
665
+ return /*#__PURE__*/_jsx("div", _objectSpread({
666
+ style: {
667
+ backgroundColor: "#e8f5e9",
668
+ padding: 4
669
+ }
670
+ }, props));
671
+ }
672
+ }]
673
+ });
674
+ function ListBlockStylesStory() {
675
+ var _useState9 = useState(ListBlockStylesBlock.defaultValues()),
676
+ _useState0 = _slicedToArray(_useState9, 2),
677
+ state = _useState0[0],
678
+ setState = _useState0[1];
679
+ return /*#__PURE__*/_jsx(StoryWrapper, {
680
+ state: state,
681
+ children: /*#__PURE__*/_jsx(ListBlockStylesBlock.AdminComponent, {
682
+ state: state,
683
+ updateState: setState
684
+ })
685
+ });
686
+ }
687
+ export var ListBlockStyles = {
688
+ render: function render() {
689
+ return /*#__PURE__*/_jsx(ListBlockStylesStory, {});
690
+ },
691
+ play: function () {
692
+ var _play5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee26(_ref19) {
693
+ var canvas, userEvent, step;
694
+ return _regenerator().w(function (_context26) {
695
+ while (1) switch (_context26.n) {
696
+ case 0:
697
+ canvas = _ref19.canvas, userEvent = _ref19.userEvent, step = _ref19.step;
698
+ _context26.n = 1;
699
+ return step("Editor is ready with two comboboxes", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17() {
700
+ return _regenerator().w(function (_context17) {
701
+ while (1) switch (_context17.n) {
702
+ case 0:
703
+ _context17.n = 1;
704
+ return waitFor(function () {
705
+ expect(canvas.getByRole("textbox")).toBeInTheDocument();
706
+ expect(canvas.getAllByRole("combobox")).toHaveLength(2);
707
+ }, {
708
+ timeout: 5000
709
+ });
710
+ case 1:
711
+ return _context17.a(2);
712
+ }
713
+ }, _callee17);
714
+ })));
715
+ case 1:
716
+ _context26.n = 2;
717
+ return step("Paragraph mode: block style dropdown shows paragraph-applicable styles only", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18() {
718
+ var blockStyleSelect;
719
+ return _regenerator().w(function (_context18) {
720
+ while (1) switch (_context18.n) {
721
+ case 0:
722
+ blockStyleSelect = canvas.getAllByRole("combobox")[1];
723
+ _context18.n = 1;
724
+ return userEvent.click(blockStyleSelect);
725
+ case 1:
726
+ _context18.n = 2;
727
+ return waitFor(function () {
728
+ var body = within(document.body);
729
+ expect(body.getByText("Intro Text")).toBeInTheDocument();
730
+ expect(body.getByText("Universal")).toBeInTheDocument();
731
+ expect(body.queryByText("List Large")).not.toBeInTheDocument();
732
+ expect(body.queryByText("List Small")).not.toBeInTheDocument();
733
+ expect(body.queryByText("Numbered Style")).not.toBeInTheDocument();
734
+ }, {
735
+ timeout: 3000
736
+ });
737
+ case 2:
738
+ _context18.n = 3;
739
+ return userEvent.keyboard("{Escape}");
740
+ case 3:
741
+ return _context18.a(2);
742
+ }
743
+ }, _callee18);
744
+ })));
745
+ case 2:
746
+ _context26.n = 3;
747
+ return step("Click the editor, then type text so list toggle works", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19() {
748
+ var editor;
749
+ return _regenerator().w(function (_context19) {
750
+ while (1) switch (_context19.n) {
751
+ case 0:
752
+ editor = canvas.getByRole("textbox");
753
+ _context19.n = 1;
754
+ return userEvent.click(editor);
755
+ case 1:
756
+ _context19.n = 2;
757
+ return userEvent.keyboard("List item text");
758
+ case 2:
759
+ return _context19.a(2);
760
+ }
761
+ }, _callee19);
762
+ })));
763
+ case 3:
764
+ _context26.n = 4;
765
+ return step("Toggle bullet list via keyboard shortcut", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20() {
766
+ var editor, mod;
767
+ return _regenerator().w(function (_context20) {
768
+ while (1) switch (_context20.n) {
769
+ case 0:
770
+ editor = canvas.getByRole("textbox");
771
+ _context20.n = 1;
772
+ return userEvent.click(editor);
773
+ case 1:
774
+ // TipTap binds list shortcuts to Mod-Shift-{7,8}: Meta on Mac, Control elsewhere
775
+ mod = /Mac/i.test(navigator.platform) ? "Meta" : "Control";
776
+ _context20.n = 2;
777
+ return userEvent.keyboard("{".concat(mod, ">}{Shift>}8{/Shift}{/").concat(mod, "}"));
778
+ case 2:
779
+ _context20.n = 3;
780
+ return waitFor(function () {
781
+ expect(editor.querySelector("ul")).toBeTruthy();
782
+ }, {
783
+ timeout: 3000
784
+ });
785
+ case 3:
786
+ return _context20.a(2);
787
+ }
788
+ }, _callee20);
789
+ })));
790
+ case 4:
791
+ _context26.n = 5;
792
+ return step("Unordered list mode: block style dropdown shows UL-applicable styles", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21() {
793
+ var blockStyleSelect;
794
+ return _regenerator().w(function (_context21) {
795
+ while (1) switch (_context21.n) {
796
+ case 0:
797
+ _context21.n = 1;
798
+ return waitFor(function () {
799
+ expect(canvas.getAllByRole("combobox").length).toBeGreaterThanOrEqual(2);
800
+ }, {
801
+ timeout: 3000
802
+ });
803
+ case 1:
804
+ blockStyleSelect = canvas.getAllByRole("combobox")[1];
805
+ _context21.n = 2;
806
+ return userEvent.click(blockStyleSelect);
807
+ case 2:
808
+ _context21.n = 3;
809
+ return waitFor(function () {
810
+ var body = within(document.body);
811
+ expect(body.getByText("List Large")).toBeInTheDocument();
812
+ expect(body.getByText("List Small")).toBeInTheDocument();
813
+ expect(body.getByText("Universal")).toBeInTheDocument();
814
+ expect(body.queryByText("Intro Text")).not.toBeInTheDocument();
815
+ expect(body.queryByText("Numbered Style")).not.toBeInTheDocument();
816
+ }, {
817
+ timeout: 3000
818
+ });
819
+ case 3:
820
+ _context21.n = 4;
821
+ return userEvent.keyboard("{Escape}");
822
+ case 4:
823
+ return _context21.a(2);
824
+ }
825
+ }, _callee21);
826
+ })));
827
+ case 5:
828
+ _context26.n = 6;
829
+ return step("Switch to ordered list via keyboard shortcut", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee22() {
830
+ var editor, mod;
831
+ return _regenerator().w(function (_context22) {
832
+ while (1) switch (_context22.n) {
833
+ case 0:
834
+ editor = canvas.getByRole("textbox");
835
+ _context22.n = 1;
836
+ return userEvent.click(editor);
837
+ case 1:
838
+ mod = /Mac/i.test(navigator.platform) ? "Meta" : "Control";
839
+ _context22.n = 2;
840
+ return userEvent.keyboard("{".concat(mod, ">}{Shift>}7{/Shift}{/").concat(mod, "}"));
841
+ case 2:
842
+ _context22.n = 3;
843
+ return waitFor(function () {
844
+ expect(editor.querySelector("ol")).toBeTruthy();
845
+ }, {
846
+ timeout: 3000
847
+ });
848
+ case 3:
849
+ return _context22.a(2);
850
+ }
851
+ }, _callee22);
852
+ })));
853
+ case 6:
854
+ _context26.n = 7;
855
+ return step("Ordered list mode: block style dropdown includes OL-only style", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee23() {
856
+ var blockStyleSelect;
857
+ return _regenerator().w(function (_context23) {
858
+ while (1) switch (_context23.n) {
859
+ case 0:
860
+ blockStyleSelect = canvas.getAllByRole("combobox")[1];
861
+ _context23.n = 1;
862
+ return userEvent.click(blockStyleSelect);
863
+ case 1:
864
+ _context23.n = 2;
865
+ return waitFor(function () {
866
+ var body = within(document.body);
867
+ expect(body.getByText("List Large")).toBeInTheDocument();
868
+ expect(body.getByText("List Small")).toBeInTheDocument();
869
+ expect(body.getByText("Universal")).toBeInTheDocument();
870
+ expect(body.getByText("Numbered Style")).toBeInTheDocument();
871
+ expect(body.queryByText("Intro Text")).not.toBeInTheDocument();
872
+ }, {
873
+ timeout: 3000
874
+ });
875
+ case 2:
876
+ _context23.n = 3;
877
+ return userEvent.keyboard("{Escape}");
878
+ case 3:
879
+ return _context23.a(2);
880
+ }
881
+ }, _callee23);
882
+ })));
883
+ case 7:
884
+ _context26.n = 8;
885
+ return step("Select 'List Large' style", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee24() {
886
+ var blockStyleSelect;
887
+ return _regenerator().w(function (_context24) {
888
+ while (1) switch (_context24.n) {
889
+ case 0:
890
+ blockStyleSelect = canvas.getAllByRole("combobox")[1];
891
+ _context24.n = 1;
892
+ return userEvent.click(blockStyleSelect);
893
+ case 1:
894
+ _context24.n = 2;
895
+ return waitFor(function () {
896
+ expect(within(document.body).getByText("List Large")).toBeInTheDocument();
897
+ }, {
898
+ timeout: 3000
899
+ });
900
+ case 2:
901
+ _context24.n = 3;
902
+ return userEvent.click(within(document.body).getByText("List Large"));
903
+ case 3:
904
+ _context24.n = 4;
905
+ return waitFor(function () {
906
+ expect(canvas.getAllByRole("combobox")[1]).toHaveTextContent("List Large");
907
+ }, {
908
+ timeout: 3000
909
+ });
910
+ case 4:
911
+ return _context24.a(2);
912
+ }
913
+ }, _callee24);
914
+ })));
915
+ case 8:
916
+ _context26.n = 9;
917
+ return step("Verify 'list-large' block style attribute is applied in the editor", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee25() {
918
+ return _regenerator().w(function (_context25) {
919
+ while (1) switch (_context25.n) {
920
+ case 0:
921
+ _context25.n = 1;
922
+ return waitFor(function () {
923
+ var styledEl = document.querySelector('[data-block-style="list-large"]');
924
+ expect(styledEl).toBeTruthy();
925
+ }, {
926
+ timeout: 3000
927
+ });
928
+ case 1:
929
+ return _context25.a(2);
930
+ }
931
+ }, _callee25);
932
+ })));
933
+ case 9:
934
+ return _context26.a(2);
935
+ }
936
+ }, _callee26);
937
+ }));
938
+ function play(_x5) {
939
+ return _play5.apply(this, arguments);
940
+ }
941
+ return play;
942
+ }()
943
+ };
944
+ var MaxBlocksBlock = createTipTapRichTextBlock({
945
+ maxBlocks: 2
946
+ });
947
+ function MaxBlocksStory() {
948
+ var _useState1 = useState(MaxBlocksBlock.defaultValues()),
949
+ _useState10 = _slicedToArray(_useState1, 2),
950
+ state = _useState10[0],
951
+ setState = _useState10[1];
952
+ return /*#__PURE__*/_jsx(StoryWrapper, {
953
+ state: state,
954
+ children: /*#__PURE__*/_jsx(MaxBlocksBlock.AdminComponent, {
955
+ state: state,
956
+ updateState: setState
957
+ })
958
+ });
959
+ }
960
+ export var MaxBlocks = {
961
+ render: function render() {
962
+ return /*#__PURE__*/_jsx(MaxBlocksStory, {});
963
+ },
964
+ play: function () {
965
+ var _play6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee30(_ref29) {
966
+ var canvas, userEvent, step;
967
+ return _regenerator().w(function (_context30) {
968
+ while (1) switch (_context30.n) {
969
+ case 0:
970
+ canvas = _ref29.canvas, userEvent = _ref29.userEvent, step = _ref29.step;
971
+ _context30.n = 1;
972
+ return step("Editor is ready", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee27() {
973
+ return _regenerator().w(function (_context27) {
974
+ while (1) switch (_context27.n) {
975
+ case 0:
976
+ _context27.n = 1;
977
+ return waitFor(function () {
978
+ expect(canvas.getByRole("textbox")).toBeInTheDocument();
979
+ }, {
980
+ timeout: 5000
981
+ });
982
+ case 1:
983
+ return _context27.a(2);
984
+ }
985
+ }, _callee27);
986
+ })));
987
+ case 1:
988
+ _context30.n = 2;
989
+ return step("Type text and press Enter to create blocks", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee28() {
990
+ var editor;
991
+ return _regenerator().w(function (_context28) {
992
+ while (1) switch (_context28.n) {
993
+ case 0:
994
+ editor = canvas.getByRole("textbox");
995
+ _context28.n = 1;
996
+ return userEvent.click(editor);
997
+ case 1:
998
+ _context28.n = 2;
999
+ return userEvent.keyboard("First block");
1000
+ case 2:
1001
+ _context28.n = 3;
1002
+ return userEvent.keyboard("{Enter}");
1003
+ case 3:
1004
+ _context28.n = 4;
1005
+ return userEvent.keyboard("Second block");
1006
+ case 4:
1007
+ _context28.n = 5;
1008
+ return waitFor(function () {
1009
+ expect(editor).toHaveTextContent("First block");
1010
+ expect(editor).toHaveTextContent("Second block");
1011
+ }, {
1012
+ timeout: 3000
1013
+ });
1014
+ case 5:
1015
+ return _context28.a(2);
1016
+ }
1017
+ }, _callee28);
1018
+ })));
1019
+ case 2:
1020
+ _context30.n = 3;
1021
+ return step("Third Enter does not create a new block (maxBlocks=2 enforced)", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee29() {
1022
+ var editor;
1023
+ return _regenerator().w(function (_context29) {
1024
+ while (1) switch (_context29.n) {
1025
+ case 0:
1026
+ editor = canvas.getByRole("textbox");
1027
+ _context29.n = 1;
1028
+ return userEvent.keyboard("{Enter}");
1029
+ case 1:
1030
+ _context29.n = 2;
1031
+ return userEvent.keyboard("Third block");
1032
+ case 2:
1033
+ _context29.n = 3;
1034
+ return waitFor(function () {
1035
+ // Should still only have 2 paragraphs in the output
1036
+ var paragraphs = editor.querySelectorAll("p");
1037
+ expect(paragraphs.length).toBeLessThanOrEqual(2);
1038
+ }, {
1039
+ timeout: 3000
1040
+ });
1041
+ case 3:
1042
+ return _context29.a(2);
1043
+ }
1044
+ }, _callee29);
1045
+ })));
1046
+ case 3:
1047
+ return _context30.a(2);
1048
+ }
1049
+ }, _callee30);
1050
+ }));
1051
+ function play(_x6) {
1052
+ return _play6.apply(this, arguments);
1053
+ }
1054
+ return play;
1055
+ }()
1056
+ };
1057
+ var InlineStylesBlock = createTipTapRichTextBlock({
1058
+ inlineStyles: [{
1059
+ name: "highlight",
1060
+ label: "Highlight",
1061
+ element: function element(props) {
1062
+ return /*#__PURE__*/_jsx("span", _objectSpread({
1063
+ style: {
1064
+ backgroundColor: "#fff3cd",
1065
+ padding: "0 2px"
1066
+ }
1067
+ }, props));
1068
+ }
1069
+ }, {
1070
+ name: "tag",
1071
+ label: "Tag",
1072
+ element: function element(props) {
1073
+ return /*#__PURE__*/_jsx("span", _objectSpread({
1074
+ style: {
1075
+ backgroundColor: "#e0f0ff",
1076
+ color: "#0066cc",
1077
+ padding: "0 4px",
1078
+ borderRadius: 4
1079
+ }
1080
+ }, props));
1081
+ }
1082
+ }]
1083
+ });
1084
+ function InlineStylesStory() {
1085
+ var _useState11 = useState(InlineStylesBlock.defaultValues()),
1086
+ _useState12 = _slicedToArray(_useState11, 2),
1087
+ state = _useState12[0],
1088
+ setState = _useState12[1];
1089
+ return /*#__PURE__*/_jsx(StoryWrapper, {
1090
+ state: state,
1091
+ children: /*#__PURE__*/_jsx(InlineStylesBlock.AdminComponent, {
1092
+ state: state,
1093
+ updateState: setState
1094
+ })
1095
+ });
1096
+ }
1097
+ export var InlineStyles = {
1098
+ render: function render() {
1099
+ return /*#__PURE__*/_jsx(InlineStylesStory, {});
1100
+ },
1101
+ play: function () {
1102
+ var _play7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee38(_ref33) {
1103
+ var canvas, userEvent, step;
1104
+ return _regenerator().w(function (_context38) {
1105
+ while (1) switch (_context38.n) {
1106
+ case 0:
1107
+ canvas = _ref33.canvas, userEvent = _ref33.userEvent, step = _ref33.step;
1108
+ _context38.n = 1;
1109
+ return step("Editor is ready", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee31() {
1110
+ var comboboxes;
1111
+ return _regenerator().w(function (_context31) {
1112
+ while (1) switch (_context31.n) {
1113
+ case 0:
1114
+ _context31.n = 1;
1115
+ return waitFor(function () {
1116
+ expect(canvas.getByRole("textbox")).toBeInTheDocument();
1117
+ }, {
1118
+ timeout: 5000
1119
+ });
1120
+ case 1:
1121
+ // Heading select + inline style select
1122
+ comboboxes = canvas.getAllByRole("combobox");
1123
+ expect(comboboxes).toHaveLength(2);
1124
+ case 2:
1125
+ return _context31.a(2);
1126
+ }
1127
+ }, _callee31);
1128
+ })));
1129
+ case 1:
1130
+ _context38.n = 2;
1131
+ return step("Type text and select it", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee32() {
1132
+ var editor, range, selection;
1133
+ return _regenerator().w(function (_context32) {
1134
+ while (1) switch (_context32.n) {
1135
+ case 0:
1136
+ editor = canvas.getByRole("textbox");
1137
+ _context32.n = 1;
1138
+ return userEvent.click(editor);
1139
+ case 1:
1140
+ _context32.n = 2;
1141
+ return userEvent.keyboard("hello");
1142
+ case 2:
1143
+ _context32.n = 3;
1144
+ return waitFor(function () {
1145
+ expect(editor).toHaveTextContent("hello");
1146
+ }, {
1147
+ timeout: 3000
1148
+ });
1149
+ case 3:
1150
+ // userEvent's Shift+Home isn't supported in contenteditable; use the native Selection API.
1151
+ range = document.createRange();
1152
+ range.selectNodeContents(editor);
1153
+ selection = window.getSelection();
1154
+ selection === null || selection === void 0 || selection.removeAllRanges();
1155
+ selection === null || selection === void 0 || selection.addRange(range);
1156
+
1157
+ // Wait for the inline-style dropdown to enable (TipTap picks up selection via the selectionchange event).
1158
+ _context32.n = 4;
1159
+ return waitFor(function () {
1160
+ expect(canvas.getAllByRole("combobox")[1]).not.toBeDisabled();
1161
+ }, {
1162
+ timeout: 3000
1163
+ });
1164
+ case 4:
1165
+ return _context32.a(2);
1166
+ }
1167
+ }, _callee32);
1168
+ })));
1169
+ case 2:
1170
+ _context38.n = 3;
1171
+ return step("Apply 'Highlight' inline style", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee33() {
1172
+ var inlineStyleSelect;
1173
+ return _regenerator().w(function (_context33) {
1174
+ while (1) switch (_context33.n) {
1175
+ case 0:
1176
+ inlineStyleSelect = canvas.getAllByRole("combobox")[1];
1177
+ _context33.n = 1;
1178
+ return userEvent.click(inlineStyleSelect);
1179
+ case 1:
1180
+ _context33.n = 2;
1181
+ return waitFor(function () {
1182
+ expect(within(document.body).getByRole("option", {
1183
+ name: "Highlight"
1184
+ })).toBeInTheDocument();
1185
+ }, {
1186
+ timeout: 3000
1187
+ });
1188
+ case 2:
1189
+ _context33.n = 3;
1190
+ return userEvent.click(within(document.body).getByRole("option", {
1191
+ name: "Highlight"
1192
+ }));
1193
+ case 3:
1194
+ _context33.n = 4;
1195
+ return waitFor(function () {
1196
+ expect(canvas.getAllByRole("combobox")[1]).toHaveTextContent("Highlight");
1197
+ }, {
1198
+ timeout: 3000
1199
+ });
1200
+ case 4:
1201
+ return _context33.a(2);
1202
+ }
1203
+ }, _callee33);
1204
+ })));
1205
+ case 3:
1206
+ _context38.n = 4;
1207
+ return step("Verify highlight element (from `element` prop) is rendered with its styling", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee34() {
1208
+ return _regenerator().w(function (_context34) {
1209
+ while (1) switch (_context34.n) {
1210
+ case 0:
1211
+ _context34.n = 1;
1212
+ return waitFor(function () {
1213
+ var styledEl = document.querySelector('[data-inline-style="highlight"]');
1214
+ expect(styledEl).toBeTruthy();
1215
+ expect(styledEl).toHaveTextContent("hello");
1216
+ expect(styledEl).toHaveStyle({
1217
+ backgroundColor: "rgb(255, 243, 205)"
1218
+ });
1219
+ }, {
1220
+ timeout: 3000
1221
+ });
1222
+ case 1:
1223
+ return _context34.a(2);
1224
+ }
1225
+ }, _callee34);
1226
+ })));
1227
+ case 4:
1228
+ _context38.n = 5;
1229
+ return step("Switch to 'Tag' inline style", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee35() {
1230
+ var inlineStyleSelect;
1231
+ return _regenerator().w(function (_context35) {
1232
+ while (1) switch (_context35.n) {
1233
+ case 0:
1234
+ inlineStyleSelect = canvas.getAllByRole("combobox")[1];
1235
+ _context35.n = 1;
1236
+ return userEvent.click(inlineStyleSelect);
1237
+ case 1:
1238
+ _context35.n = 2;
1239
+ return waitFor(function () {
1240
+ expect(within(document.body).getByRole("option", {
1241
+ name: "Tag"
1242
+ })).toBeInTheDocument();
1243
+ }, {
1244
+ timeout: 3000
1245
+ });
1246
+ case 2:
1247
+ _context35.n = 3;
1248
+ return userEvent.click(within(document.body).getByRole("option", {
1249
+ name: "Tag"
1250
+ }));
1251
+ case 3:
1252
+ return _context35.a(2);
1253
+ }
1254
+ }, _callee35);
1255
+ })));
1256
+ case 5:
1257
+ _context38.n = 6;
1258
+ return step("Verify tag element replaces the highlight element", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee36() {
1259
+ return _regenerator().w(function (_context36) {
1260
+ while (1) switch (_context36.n) {
1261
+ case 0:
1262
+ _context36.n = 1;
1263
+ return waitFor(function () {
1264
+ expect(document.querySelector('[data-inline-style="highlight"]')).toBeNull();
1265
+ var tagEl = document.querySelector('[data-inline-style="tag"]');
1266
+ expect(tagEl).toBeTruthy();
1267
+ expect(tagEl).toHaveTextContent("hello");
1268
+ expect(tagEl).toHaveStyle({
1269
+ backgroundColor: "rgb(224, 240, 255)",
1270
+ color: "rgb(0, 102, 204)"
1271
+ });
1272
+ }, {
1273
+ timeout: 3000
1274
+ });
1275
+ case 1:
1276
+ return _context36.a(2);
1277
+ }
1278
+ }, _callee36);
1279
+ })));
1280
+ case 6:
1281
+ _context38.n = 7;
1282
+ return step("Clear inline style resets to default rendering", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee37() {
1283
+ var inlineStyleSelect;
1284
+ return _regenerator().w(function (_context37) {
1285
+ while (1) switch (_context37.n) {
1286
+ case 0:
1287
+ inlineStyleSelect = canvas.getAllByRole("combobox")[1];
1288
+ _context37.n = 1;
1289
+ return userEvent.click(inlineStyleSelect);
1290
+ case 1:
1291
+ _context37.n = 2;
1292
+ return waitFor(function () {
1293
+ expect(within(document.body).getByRole("option", {
1294
+ name: "Default"
1295
+ })).toBeInTheDocument();
1296
+ }, {
1297
+ timeout: 3000
1298
+ });
1299
+ case 2:
1300
+ _context37.n = 3;
1301
+ return userEvent.click(within(document.body).getByRole("option", {
1302
+ name: "Default"
1303
+ }));
1304
+ case 3:
1305
+ _context37.n = 4;
1306
+ return waitFor(function () {
1307
+ expect(document.querySelector("[data-inline-style]")).toBeNull();
1308
+ }, {
1309
+ timeout: 3000
1310
+ });
1311
+ case 4:
1312
+ return _context37.a(2);
1313
+ }
1314
+ }, _callee37);
1315
+ })));
1316
+ case 7:
1317
+ return _context38.a(2);
1318
+ }
1319
+ }, _callee38);
1320
+ }));
1321
+ function play(_x7) {
1322
+ return _play7.apply(this, arguments);
1323
+ }
1324
+ return play;
1325
+ }()
1326
+ };
1327
+ var ListLevelMaxBlock = createTipTapRichTextBlock({
1328
+ listLevelMax: 2
1329
+ });
1330
+ function ListLevelMaxStory() {
1331
+ var _useState13 = useState(ListLevelMaxBlock.defaultValues()),
1332
+ _useState14 = _slicedToArray(_useState13, 2),
1333
+ state = _useState14[0],
1334
+ setState = _useState14[1];
1335
+ return /*#__PURE__*/_jsx(StoryWrapper, {
1336
+ state: state,
1337
+ children: /*#__PURE__*/_jsx(ListLevelMaxBlock.AdminComponent, {
1338
+ state: state,
1339
+ updateState: setState
1340
+ })
1341
+ });
1342
+ }
1343
+ export var ListLevelMax = {
1344
+ render: function render() {
1345
+ return /*#__PURE__*/_jsx(ListLevelMaxStory, {});
1346
+ },
1347
+ play: function () {
1348
+ var _play8 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee43(_ref41) {
1349
+ var canvas, userEvent, step;
1350
+ return _regenerator().w(function (_context43) {
1351
+ while (1) switch (_context43.n) {
1352
+ case 0:
1353
+ canvas = _ref41.canvas, userEvent = _ref41.userEvent, step = _ref41.step;
1354
+ _context43.n = 1;
1355
+ return step("Editor is ready", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee39() {
1356
+ return _regenerator().w(function (_context39) {
1357
+ while (1) switch (_context39.n) {
1358
+ case 0:
1359
+ _context39.n = 1;
1360
+ return waitFor(function () {
1361
+ expect(canvas.getByRole("textbox")).toBeInTheDocument();
1362
+ }, {
1363
+ timeout: 5000
1364
+ });
1365
+ case 1:
1366
+ return _context39.a(2);
1367
+ }
1368
+ }, _callee39);
1369
+ })));
1370
+ case 1:
1371
+ _context43.n = 2;
1372
+ return step("Create a bullet list", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee40() {
1373
+ var editor, mod;
1374
+ return _regenerator().w(function (_context40) {
1375
+ while (1) switch (_context40.n) {
1376
+ case 0:
1377
+ editor = canvas.getByRole("textbox");
1378
+ _context40.n = 1;
1379
+ return userEvent.click(editor);
1380
+ case 1:
1381
+ _context40.n = 2;
1382
+ return userEvent.keyboard("Item 1");
1383
+ case 2:
1384
+ // Toggle bullet list using keyboard shortcut
1385
+ mod = /Mac/i.test(navigator.platform) ? "Meta" : "Control";
1386
+ _context40.n = 3;
1387
+ return userEvent.keyboard("{".concat(mod, ">}{Shift>}8{/Shift}{/").concat(mod, "}"));
1388
+ case 3:
1389
+ _context40.n = 4;
1390
+ return waitFor(function () {
1391
+ expect(editor.querySelector("ul")).toBeTruthy();
1392
+ }, {
1393
+ timeout: 3000
1394
+ });
1395
+ case 4:
1396
+ return _context40.a(2);
1397
+ }
1398
+ }, _callee40);
1399
+ })));
1400
+ case 2:
1401
+ _context43.n = 3;
1402
+ return step("Create a second list item and indent it (allowed, depth 2)", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee41() {
1403
+ var editor;
1404
+ return _regenerator().w(function (_context41) {
1405
+ while (1) switch (_context41.n) {
1406
+ case 0:
1407
+ editor = canvas.getByRole("textbox");
1408
+ _context41.n = 1;
1409
+ return userEvent.keyboard("{Enter}");
1410
+ case 1:
1411
+ _context41.n = 2;
1412
+ return userEvent.keyboard("Item 2");
1413
+ case 2:
1414
+ _context41.n = 3;
1415
+ return userEvent.keyboard("{Tab}");
1416
+ case 3:
1417
+ _context41.n = 4;
1418
+ return waitFor(function () {
1419
+ // Should have nested ul (depth 2)
1420
+ var nestedUl = editor.querySelector("ul ul");
1421
+ expect(nestedUl).toBeTruthy();
1422
+ }, {
1423
+ timeout: 3000
1424
+ });
1425
+ case 4:
1426
+ return _context41.a(2);
1427
+ }
1428
+ }, _callee41);
1429
+ })));
1430
+ case 3:
1431
+ _context43.n = 4;
1432
+ return step("Try to indent further (should be blocked, depth would exceed 2)", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee42() {
1433
+ var editor;
1434
+ return _regenerator().w(function (_context42) {
1435
+ while (1) switch (_context42.n) {
1436
+ case 0:
1437
+ editor = canvas.getByRole("textbox");
1438
+ _context42.n = 1;
1439
+ return userEvent.keyboard("{Enter}");
1440
+ case 1:
1441
+ _context42.n = 2;
1442
+ return userEvent.keyboard("Item 3");
1443
+ case 2:
1444
+ _context42.n = 3;
1445
+ return userEvent.keyboard("{Tab}");
1446
+ case 3:
1447
+ _context42.n = 4;
1448
+ return waitFor(function () {
1449
+ // Should NOT have triple-nested ul (depth 3 not allowed)
1450
+ var tripleNestedUl = editor.querySelector("ul ul ul");
1451
+ expect(tripleNestedUl).toBeNull();
1452
+ }, {
1453
+ timeout: 3000
1454
+ });
1455
+ case 4:
1456
+ return _context42.a(2);
1457
+ }
1458
+ }, _callee42);
1459
+ })));
1460
+ case 4:
1461
+ return _context43.a(2);
1462
+ }
1463
+ }, _callee43);
1464
+ }));
1465
+ function play(_x8) {
1466
+ return _play8.apply(this, arguments);
1467
+ }
1468
+ return play;
1469
+ }()
1470
+ };
1471
+ var CombinedStylesBlock = createTipTapRichTextBlock({
1472
+ blockStyles: [{
1473
+ name: "intro",
1474
+ label: "Intro Text",
1475
+ appliesTo: ["paragraph"],
1476
+ element: function element(props) {
1477
+ return /*#__PURE__*/_jsx("p", _objectSpread({
1478
+ style: {
1479
+ fontSize: 20,
1480
+ fontStyle: "italic"
1481
+ }
1482
+ }, props));
1483
+ }
1484
+ }],
1485
+ inlineStyles: [{
1486
+ name: "highlight",
1487
+ label: "Highlight",
1488
+ element: function element(props) {
1489
+ return /*#__PURE__*/_jsx("span", _objectSpread({
1490
+ style: {
1491
+ backgroundColor: "#fff3cd",
1492
+ padding: "0 2px"
1493
+ }
1494
+ }, props));
1495
+ }
1496
+ }, {
1497
+ name: "tag",
1498
+ label: "Tag",
1499
+ element: function element(props) {
1500
+ return /*#__PURE__*/_jsx("span", _objectSpread({
1501
+ style: {
1502
+ backgroundColor: "#e0f0ff",
1503
+ color: "#0066cc",
1504
+ padding: "0 4px",
1505
+ borderRadius: 4
1506
+ }
1507
+ }, props));
1508
+ }
1509
+ }]
1510
+ });
1511
+ function CombinedStylesStory() {
1512
+ var _useState15 = useState(CombinedStylesBlock.defaultValues()),
1513
+ _useState16 = _slicedToArray(_useState15, 2),
1514
+ state = _useState16[0],
1515
+ setState = _useState16[1];
1516
+ return /*#__PURE__*/_jsx(StoryWrapper, {
1517
+ state: state,
1518
+ children: /*#__PURE__*/_jsx(CombinedStylesBlock.AdminComponent, {
1519
+ state: state,
1520
+ updateState: setState
1521
+ })
1522
+ });
1523
+ }
1524
+ export var CombinedBlockAndInlineStyles = {
1525
+ render: function render() {
1526
+ return /*#__PURE__*/_jsx(CombinedStylesStory, {});
1527
+ },
1528
+ play: function () {
1529
+ var _play9 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee45(_ref46) {
1530
+ var canvas, step;
1531
+ return _regenerator().w(function (_context45) {
1532
+ while (1) switch (_context45.n) {
1533
+ case 0:
1534
+ canvas = _ref46.canvas, step = _ref46.step;
1535
+ _context45.n = 1;
1536
+ return step("Editor is ready with both block style and inline style dropdowns", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee44() {
1537
+ var comboboxes;
1538
+ return _regenerator().w(function (_context44) {
1539
+ while (1) switch (_context44.n) {
1540
+ case 0:
1541
+ _context44.n = 1;
1542
+ return waitFor(function () {
1543
+ expect(canvas.getByRole("textbox")).toBeInTheDocument();
1544
+ }, {
1545
+ timeout: 5000
1546
+ });
1547
+ case 1:
1548
+ // Heading select + block style select + inline style select
1549
+ comboboxes = canvas.getAllByRole("combobox");
1550
+ expect(comboboxes.length).toBeGreaterThanOrEqual(3);
1551
+ case 2:
1552
+ return _context44.a(2);
1553
+ }
1554
+ }, _callee44);
1555
+ })));
1556
+ case 1:
1557
+ return _context45.a(2);
1558
+ }
1559
+ }, _callee45);
1560
+ }));
1561
+ function play(_x9) {
1562
+ return _play9.apply(this, arguments);
1563
+ }
1564
+ return play;
1565
+ }()
1566
+ };