@wistia/vhs 4.0.0-beta.144ba507.317e0d6 → 4.0.0-beta.297d7ed5.4ab52c0

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/index.d.mts CHANGED
@@ -5,11 +5,12 @@ import * as react from 'react';
5
5
  import { JSX, ReactNode, ComponentPropsWithoutRef, Dispatch, SetStateAction, RefObject, MutableRefObject, MouseEvent, ComponentPropsWithRef, ChangeEvent, ElementType, Ref, ComponentClass, ComponentProps, FocusEvent, HTMLInputTypeAttribute, KeyboardEvent as KeyboardEvent$1, ReactElement, ComponentType, PropsWithChildren } from 'react';
6
6
  import { FormikProps, FormikHelpers, FormikErrors, Field } from 'formik';
7
7
  export { useFormikContext } from 'formik';
8
+ import { BaseEditor, Descendant } from 'slate';
9
+ import { ReactEditor } from 'slate-react';
10
+ import { HistoryEditor } from 'slate-history';
8
11
  import { DropdownMenuProps, DropdownMenuContentProps, DropdownMenuItemProps, DropdownMenuCheckboxItemProps, DropdownMenuRadioItemProps } from '@radix-ui/react-dropdown-menu';
9
12
  export { DropdownMenuRadioGroup as MenuRadioGroup } from '@radix-ui/react-dropdown-menu';
10
13
  import * as styled_components_dist_types from 'styled-components/dist/types';
11
- import { Descendant } from 'slate';
12
- import { ReactEditor } from 'slate-react';
13
14
 
14
15
  interface VHSTheme {
15
16
  readonly breakpoint: {
@@ -1868,6 +1869,35 @@ type CustomComponentClass = {
1868
1869
  };
1869
1870
  };
1870
1871
 
1872
+ type NodeElementObject = {
1873
+ attributes?: Record<string, string>;
1874
+ children?: NodeLeafObject[];
1875
+ type?: string;
1876
+ url?: string;
1877
+ };
1878
+ type NodeObject = NodeElementObject | NodeLeafObject;
1879
+ type NodeLeafObject = {
1880
+ attributes?: Record<string, string>;
1881
+ bold?: boolean;
1882
+ code?: boolean;
1883
+ italic?: boolean;
1884
+ parent?: NodeObject;
1885
+ children?: NodeLeafObject[];
1886
+ strikethrough?: boolean;
1887
+ text?: string;
1888
+ type?: string;
1889
+ url?: string;
1890
+ underline?: boolean;
1891
+ };
1892
+ type CustomEditor = BaseEditor & HistoryEditor & ReactEditor;
1893
+ declare module 'slate' {
1894
+ interface CustomTypes {
1895
+ Editor: CustomEditor;
1896
+ Element: NodeElementObject;
1897
+ Text: NodeLeafObject;
1898
+ }
1899
+ }
1900
+
1871
1901
  declare const rteFormatTypes: Readonly<{
1872
1902
  BOLD: "BOLD";
1873
1903
  ITALIC: "ITALIC";
@@ -2837,34 +2867,6 @@ declare const RangeSelector: {
2837
2867
  displayName: string;
2838
2868
  };
2839
2869
 
2840
- type NodeElementObject = {
2841
- attributes?: Record<string, string>;
2842
- children?: NodeLeafObject[];
2843
- type?: string;
2844
- url?: string;
2845
- };
2846
- type NodeObject = NodeElementObject | NodeLeafObject;
2847
- type NodeLeafObject = {
2848
- attributes?: Record<string, string>;
2849
- bold?: boolean;
2850
- code?: boolean;
2851
- italic?: boolean;
2852
- parent?: NodeObject;
2853
- children?: NodeLeafObject[];
2854
- strikethrough?: boolean;
2855
- text?: string;
2856
- type?: string;
2857
- url?: string;
2858
- underline?: boolean;
2859
- };
2860
- declare module 'slate' {
2861
- interface CustomTypes {
2862
- Editor: ReactEditor;
2863
- Element: NodeElementObject;
2864
- Text: NodeLeafObject;
2865
- }
2866
- }
2867
-
2868
2870
  type RichTextEditorProps = {
2869
2871
  /**
2870
2872
  * Optional id to set aria-labelledby
package/dist/index.d.ts CHANGED
@@ -5,11 +5,12 @@ import * as react from 'react';
5
5
  import { JSX, ReactNode, ComponentPropsWithoutRef, Dispatch, SetStateAction, RefObject, MutableRefObject, MouseEvent, ComponentPropsWithRef, ChangeEvent, ElementType, Ref, ComponentClass, ComponentProps, FocusEvent, HTMLInputTypeAttribute, KeyboardEvent as KeyboardEvent$1, ReactElement, ComponentType, PropsWithChildren } from 'react';
6
6
  import { FormikProps, FormikHelpers, FormikErrors, Field } from 'formik';
7
7
  export { useFormikContext } from 'formik';
8
+ import { BaseEditor, Descendant } from 'slate';
9
+ import { ReactEditor } from 'slate-react';
10
+ import { HistoryEditor } from 'slate-history';
8
11
  import { DropdownMenuProps, DropdownMenuContentProps, DropdownMenuItemProps, DropdownMenuCheckboxItemProps, DropdownMenuRadioItemProps } from '@radix-ui/react-dropdown-menu';
9
12
  export { DropdownMenuRadioGroup as MenuRadioGroup } from '@radix-ui/react-dropdown-menu';
10
13
  import * as styled_components_dist_types from 'styled-components/dist/types';
11
- import { Descendant } from 'slate';
12
- import { ReactEditor } from 'slate-react';
13
14
 
14
15
  interface VHSTheme {
15
16
  readonly breakpoint: {
@@ -1868,6 +1869,35 @@ type CustomComponentClass = {
1868
1869
  };
1869
1870
  };
1870
1871
 
1872
+ type NodeElementObject = {
1873
+ attributes?: Record<string, string>;
1874
+ children?: NodeLeafObject[];
1875
+ type?: string;
1876
+ url?: string;
1877
+ };
1878
+ type NodeObject = NodeElementObject | NodeLeafObject;
1879
+ type NodeLeafObject = {
1880
+ attributes?: Record<string, string>;
1881
+ bold?: boolean;
1882
+ code?: boolean;
1883
+ italic?: boolean;
1884
+ parent?: NodeObject;
1885
+ children?: NodeLeafObject[];
1886
+ strikethrough?: boolean;
1887
+ text?: string;
1888
+ type?: string;
1889
+ url?: string;
1890
+ underline?: boolean;
1891
+ };
1892
+ type CustomEditor = BaseEditor & HistoryEditor & ReactEditor;
1893
+ declare module 'slate' {
1894
+ interface CustomTypes {
1895
+ Editor: CustomEditor;
1896
+ Element: NodeElementObject;
1897
+ Text: NodeLeafObject;
1898
+ }
1899
+ }
1900
+
1871
1901
  declare const rteFormatTypes: Readonly<{
1872
1902
  BOLD: "BOLD";
1873
1903
  ITALIC: "ITALIC";
@@ -2837,34 +2867,6 @@ declare const RangeSelector: {
2837
2867
  displayName: string;
2838
2868
  };
2839
2869
 
2840
- type NodeElementObject = {
2841
- attributes?: Record<string, string>;
2842
- children?: NodeLeafObject[];
2843
- type?: string;
2844
- url?: string;
2845
- };
2846
- type NodeObject = NodeElementObject | NodeLeafObject;
2847
- type NodeLeafObject = {
2848
- attributes?: Record<string, string>;
2849
- bold?: boolean;
2850
- code?: boolean;
2851
- italic?: boolean;
2852
- parent?: NodeObject;
2853
- children?: NodeLeafObject[];
2854
- strikethrough?: boolean;
2855
- text?: string;
2856
- type?: string;
2857
- url?: string;
2858
- underline?: boolean;
2859
- };
2860
- declare module 'slate' {
2861
- interface CustomTypes {
2862
- Editor: ReactEditor;
2863
- Element: NodeElementObject;
2864
- Text: NodeLeafObject;
2865
- }
2866
- }
2867
-
2868
2870
  type RichTextEditorProps = {
2869
2871
  /**
2870
2872
  * Optional id to set aria-labelledby
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  /*
3
- * @license @wistia/vhs v4.0.0-beta.144ba507.317e0d6
3
+ * @license @wistia/vhs v4.0.0-beta.297d7ed5.4ab52c0
4
4
  *
5
5
  * Copyright (c) 2021-2025, Wistia, Inc. and its affiliates.
6
6
  *
@@ -7932,7 +7932,7 @@ FormConnectorCheckboxGroup.displayName = "FormConnectorCheckboxGroup";
7932
7932
  import { isNotUndefined as isNotUndefined6 } from "@wistia/type-guards";
7933
7933
  import { jsx as jsx158 } from "react/jsx-runtime";
7934
7934
  var FormConnectorCustomField = ({
7935
- customComponent: Element7,
7935
+ customComponent: Element8,
7936
7936
  field,
7937
7937
  form,
7938
7938
  label = "",
@@ -7951,7 +7951,7 @@ var FormConnectorCustomField = ({
7951
7951
  labelProps,
7952
7952
  name,
7953
7953
  children: /* @__PURE__ */ jsx158(
7954
- Element7,
7954
+ Element8,
7955
7955
  {
7956
7956
  field,
7957
7957
  form,
@@ -8921,9 +8921,9 @@ import { isNotUndefined as isNotUndefined11 } from "@wistia/type-guards";
8921
8921
  import { useCallback as useCallback12, useMemo as useMemo7, useEffect as useEffect18 } from "react";
8922
8922
  import { styled as styled41 } from "styled-components";
8923
8923
  import { Editable, withReact, Slate, ReactEditor } from "slate-react";
8924
- import { createEditor, Transforms as Transforms5, Element as Element6, Text as Text4 } from "slate";
8924
+ import { createEditor, Transforms as Transforms5, Element as Element7, Text as Text4 } from "slate";
8925
8925
  import { withHistory } from "slate-history";
8926
- import isHotkey from "is-hotkey";
8926
+ import { isHotkey } from "is-hotkey";
8927
8927
  import { isNil as isNil14, isNotNil as isNotNil26, isNonEmptyString as isNonEmptyString11 } from "@wistia/type-guards";
8928
8928
  import isEqual2 from "react-fast-compare";
8929
8929
 
@@ -9172,7 +9172,10 @@ var deserializeHTMLNode = (el) => {
9172
9172
  return null;
9173
9173
  }
9174
9174
  const children = getNodeChildren(el, deserializeHTMLNode);
9175
- const safeChildren = children.length > 0 && children[0] != null ? children : [emptyTextNode];
9175
+ const filteredChildren = children.filter(
9176
+ (child) => child === null || typeof child === "string" || typeof child === "object" && ("text" in child || "type" in child)
9177
+ );
9178
+ const safeChildren = filteredChildren.length > 0 && filteredChildren[0] != null ? filteredChildren : [emptyTextNode];
9176
9179
  if (el.nodeName === "BODY") {
9177
9180
  return jsx168("fragment", {}, safeChildren);
9178
9181
  }
@@ -9359,10 +9362,10 @@ import { Transforms as Transforms2, Element as Element4, Text as Text3 } from "s
9359
9362
  import { isNotUndefined as isNotUndefined10, isNotNil as isNotNil25 } from "@wistia/type-guards";
9360
9363
 
9361
9364
  // src/components/RichTextEditor/utilities/toggle.ts
9362
- import { Element as Element3, Editor, Transforms } from "slate";
9365
+ import { Element as Element3, Transforms, Editor as SlateEditor } from "slate";
9363
9366
  import { isNotNil as isNotNil24, isNonEmptyString as isNonEmptyString8 } from "@wistia/type-guards";
9364
9367
  var isBlockActive = (editor, format) => {
9365
- const [match] = Editor.nodes(editor, {
9368
+ const [match] = SlateEditor.nodes(editor, {
9366
9369
  match: (node) => Element3.isElement(node) && node.type === format
9367
9370
  });
9368
9371
  return Boolean(match);
@@ -9385,15 +9388,15 @@ var toggleBlck = (editor, format) => {
9385
9388
  }
9386
9389
  };
9387
9390
  var isMarkActive = (editor, format) => {
9388
- const valueMarks = Editor.marks(editor);
9391
+ const valueMarks = SlateEditor.marks(editor);
9389
9392
  return isNonEmptyString8(valueMarks && Object.keys(valueMarks).find((mark) => mark === format));
9390
9393
  };
9391
9394
  var toggleMark = (editor, format) => {
9392
9395
  const isActive = isMarkActive(editor, format);
9393
9396
  if (isActive) {
9394
- Editor.removeMark(editor, format);
9397
+ SlateEditor.removeMark(editor, format);
9395
9398
  } else {
9396
- Editor.addMark(editor, format, true);
9399
+ SlateEditor.addMark(editor, format, true);
9397
9400
  }
9398
9401
  };
9399
9402
 
@@ -9450,14 +9453,14 @@ var withImages = (editor) => {
9450
9453
  };
9451
9454
 
9452
9455
  // src/components/RichTextEditor/utilities/withLinksPlugin.ts
9453
- import { Transforms as Transforms3, Element as Element5, Node, Editor as Editor2, Range, Path } from "slate";
9456
+ import { Transforms as Transforms3, Element as Element5, Node, Editor, Range, Path } from "slate";
9454
9457
  import { isNonEmptyString as isNonEmptyString9 } from "@wistia/type-guards";
9455
9458
  var isHashUrl = (urlString) => {
9456
9459
  const urlPattern = /^#.+$/i;
9457
9460
  return Boolean(urlPattern.test(urlString));
9458
9461
  };
9459
9462
  var isLinkActive = (editor) => {
9460
- const [link] = Editor2.nodes(editor, {
9463
+ const [link] = Editor.nodes(editor, {
9461
9464
  match: (node) => Element5.isElement(node) && node.type === "link"
9462
9465
  });
9463
9466
  return Boolean(link);
@@ -9486,7 +9489,8 @@ var wrapLink = (editor, url) => {
9486
9489
  }
9487
9490
  };
9488
9491
  var withLinks = (editor) => {
9489
- const { insertData, insertText, isInline, normalizeNode } = editor;
9492
+ const { insertText, isInline, normalizeNode } = editor;
9493
+ const { insertData } = editor;
9490
9494
  editor.isInline = (element) => element.type === "link" ? true : isInline(element);
9491
9495
  editor.insertText = (text) => {
9492
9496
  if (text && isUrl(text)) {
@@ -9541,10 +9545,10 @@ var insertLink = (editor) => {
9541
9545
  };
9542
9546
 
9543
9547
  // src/components/RichTextEditor/utilities/handleListEscape.ts
9544
- import { Transforms as Transforms4, Range as Range2, Editor as Editor3 } from "slate";
9548
+ import { Transforms as Transforms4, Range as Range2, Editor as Editor2, Element as Element6 } from "slate";
9545
9549
  var OverriddenEditor = {
9546
- ...Editor3,
9547
- isBlck: Editor3.isBlock
9550
+ ...Editor2,
9551
+ isBlck: Editor2.isBlock
9548
9552
  };
9549
9553
  var newLine = {
9550
9554
  type: "paragraph",
@@ -9568,7 +9572,7 @@ var handleListEscape = (editor) => {
9568
9572
  const selectedElement = editor.children[selection.anchor.path[0]];
9569
9573
  const isList = selectedElement.type === "bulleted-list" || selectedElement.type === "numbered-list";
9570
9574
  const blockAbove = OverriddenEditor.above(editor, {
9571
- match: (node) => OverriddenEditor.isBlck(editor, node)
9575
+ match: (node) => Element6.isElement(node) && OverriddenEditor.isBlck(editor, node)
9572
9576
  });
9573
9577
  if ((textIsNotSelected ?? false) && isList && isLastChildBlankText(blockAbove[0].children)) {
9574
9578
  Transforms4.removeNodes(editor, { hanging: true });
@@ -10056,17 +10060,19 @@ var RichTextEditor = ({
10056
10060
  return;
10057
10061
  }
10058
10062
  const selectedElement = editor.children[selection.anchor.path[0]];
10059
- if (Element6.isElement(selectedElement) && selectedElement.type === "image") {
10063
+ if (Element7.isElement(selectedElement) && selectedElement.type === "image") {
10060
10064
  toggleBlck(editor, "image");
10061
10065
  Transforms5.removeNodes(editor, { at: selection });
10062
10066
  Transforms5.move(editor, { reverse: true });
10063
- const spanElement = editor.children.filter((child) => child.type === "span")[0];
10064
- if (Element6.isElement(spanElement) && spanElement.type === "span" && isNotNil26(spanElement.children) && isNotNil26(spanElement.children[0]) && isNotNil26(spanElement.children[0].text) && spanElement.children[0].text.trim() !== "") {
10067
+ const spanElement = editor.children.filter(
10068
+ (child) => Element7.isElement(child) && child.type === "span"
10069
+ )[0];
10070
+ if (Element7.isElement(spanElement) && spanElement.type === "span" && isNotNil26(spanElement.children) && isNotNil26(spanElement.children[0]) && isNotNil26(spanElement.children[0].text) && spanElement.children[0].text.trim() !== "") {
10065
10071
  Transforms5.setNodes(
10066
10072
  editor,
10067
10073
  { type: "paragraph" },
10068
10074
  {
10069
- match: (node) => node.type === "span" && isNotNil26(node.children) && Text4.isText(node.children[0]) && isNotNil26(node.children[0].text) && node.children[0].text.trim() !== "",
10075
+ match: (node) => Element7.isElement(node) && node.type === "span" && isNotNil26(node.children) && Text4.isText(node.children[0]) && isNotNil26(node.children[0].text) && node.children[0].text.trim() !== "",
10070
10076
  split: true,
10071
10077
  mode: "highest"
10072
10078
  }
@@ -10082,7 +10088,9 @@ var RichTextEditor = ({
10082
10088
  "data-testid": dataTestId,
10083
10089
  disabled,
10084
10090
  height,
10085
- onClick: () => ReactEditor.focus(editor),
10091
+ onClick: () => {
10092
+ ReactEditor.focus(editor);
10093
+ },
10086
10094
  children: /* @__PURE__ */ jsxs30(
10087
10095
  Slate,
10088
10096
  {