@firecms/editor 3.0.0 → 3.1.0-canary.1df3b2c

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/editor.d.ts CHANGED
@@ -2,6 +2,20 @@ import React from "react";
2
2
  import { type JSONContent } from "./components";
3
3
  import { EditorAIController } from "./types";
4
4
  export type FireCMSEditorTextSize = "sm" | "base" | "lg";
5
+ /**
6
+ * Configuration options for the markdown editor.
7
+ */
8
+ export interface MarkdownEditorConfig {
9
+ /**
10
+ * Allow HTML input/output. When set to false, HTML tags in pasted content
11
+ * will be stripped. Defaults to true.
12
+ */
13
+ html?: boolean;
14
+ /**
15
+ * Convert pasted text to markdown format. Defaults to false.
16
+ */
17
+ transformPastedText?: boolean;
18
+ }
5
19
  export type FireCMSEditorProps = {
6
20
  content?: JSONContent | string;
7
21
  onMarkdownContentChange?: (content: string) => void;
@@ -17,9 +31,14 @@ export type FireCMSEditorProps = {
17
31
  aiController?: EditorAIController;
18
32
  customComponents?: CustomEditorComponent[];
19
33
  disabled?: boolean;
34
+ /**
35
+ * Configuration for markdown parsing and serialization.
36
+ * Controls how HTML is handled during paste operations.
37
+ */
38
+ markdownConfig?: MarkdownEditorConfig;
20
39
  };
21
40
  export type CustomEditorComponent = {
22
41
  name: string;
23
42
  component: React.FC;
24
43
  };
25
- export declare const FireCMSEditor: ({ content, onJsonContentChange, onHtmlContentChange, onMarkdownContentChange, version, textSize, highlight, handleImageUpload, aiController, disabled }: FireCMSEditorProps) => import("react/jsx-runtime").JSX.Element;
44
+ export declare const FireCMSEditor: ({ content, onJsonContentChange, onHtmlContentChange, onMarkdownContentChange, version, textSize, highlight, handleImageUpload, aiController, disabled, markdownConfig }: FireCMSEditorProps) => import("react/jsx-runtime").JSX.Element;
package/dist/index.es.js CHANGED
@@ -280,7 +280,7 @@ const NodeSelector = (t0) => {
280
280
  t2 = $[3];
281
281
  }
282
282
  let t3;
283
- if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
283
+ if ($[4] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
284
284
  t3 = /* @__PURE__ */ jsx(KeyboardArrowDownIcon, { size: "small" });
285
285
  $[4] = t3;
286
286
  } else {
@@ -359,7 +359,7 @@ const LinkSelector = (t0) => {
359
359
  editor
360
360
  } = useCurrentEditor();
361
361
  let t1;
362
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
362
+ if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
363
363
  t1 = () => {
364
364
  inputRef.current && inputRef.current?.focus();
365
365
  };
@@ -414,7 +414,7 @@ const LinkSelector = (t0) => {
414
414
  t5 = $[8];
415
415
  }
416
416
  let t6;
417
- if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
417
+ if ($[9] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
418
418
  t6 = cls("text-surface-900 dark:text-white flex-grow bg-transparent p-1 text-sm outline-none", focusedDisabled);
419
419
  $[9] = t6;
420
420
  } else {
@@ -1613,7 +1613,7 @@ const CommandList = forwardRef((props, ref) => {
1613
1613
  }
1614
1614
  const enterHandler = t3;
1615
1615
  let t4;
1616
- if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
1616
+ if ($[15] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1617
1617
  t4 = () => setSelectedIndex(0);
1618
1618
  $[15] = t4;
1619
1619
  } else {
@@ -1659,7 +1659,7 @@ const CommandList = forwardRef((props, ref) => {
1659
1659
  }
1660
1660
  useImperativeHandle(ref, t6);
1661
1661
  let t7;
1662
- if ($[22] === Symbol.for("react.memo_cache_sentinel")) {
1662
+ if ($[22] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1663
1663
  t7 = [];
1664
1664
  $[22] = t7;
1665
1665
  } else {
@@ -1686,7 +1686,7 @@ const CommandList = forwardRef((props, ref) => {
1686
1686
  }
1687
1687
  useEffect(t8, t9);
1688
1688
  let t10;
1689
- if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
1689
+ if ($[26] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1690
1690
  t10 = cls("text-surface-900 dark:text-white z-50 max-h-[280px] h-auto w-72 overflow-y-auto rounded-md border bg-white dark:bg-surface-900 px-1 py-2 shadow transition-all", defaultBorderMixin);
1691
1691
  $[26] = t10;
1692
1692
  } else {
@@ -1921,7 +1921,8 @@ const FireCMSEditor = ({
1921
1921
  highlight,
1922
1922
  handleImageUpload,
1923
1923
  aiController,
1924
- disabled
1924
+ disabled,
1925
+ markdownConfig
1925
1926
  }) => {
1926
1927
  const ref = React.useRef(null);
1927
1928
  const editorRef = React.useRef(null);
@@ -1974,7 +1975,8 @@ const FireCMSEditor = ({
1974
1975
  const extensions = useMemo(() => [starterKit, Document.extend({}), HighlightDecorationExtension(highlight), TextLoadingDecorationExtension, Underline, Bold, TextStyleKit, Italic, Strike, Color, Highlight.configure({
1975
1976
  multicolor: true
1976
1977
  }), Heading, CustomKeymap, DragAndDrop, placeholder, tiptapLink, imageExtension, taskList, taskItem, Markdown.configure({
1977
- html: true
1978
+ html: markdownConfig?.html ?? true,
1979
+ transformPastedText: markdownConfig?.transformPastedText ?? false
1978
1980
  }), horizontalRule, bulletList, orderedList, listItem, blockquote, codeBlock, code, SlashCommand.configure({
1979
1981
  HTMLAttributes: {
1980
1982
  class: "mention"
@@ -1983,7 +1985,7 @@ const FireCMSEditor = ({
1983
1985
  upload: handleImageUpload,
1984
1986
  aiController
1985
1987
  })
1986
- })], []);
1988
+ })], [markdownConfig?.html, markdownConfig?.transformPastedText]);
1987
1989
  return /* @__PURE__ */ jsx("div", { ref, className: "relative min-h-[300px] w-full", children: /* @__PURE__ */ jsx(EditorProvider, { content: content ?? "", extensions, immediatelyRender: canUseDOM, editorProps: {
1988
1990
  editable: () => !disabled,
1989
1991
  attributes: {