@mdxeditor/editor 3.55.0 → 4.0.0

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.
@@ -1,21 +1,22 @@
1
- const bold = "_bold_1tncs_10";
2
- const italic = "_italic_1tncs_14";
3
- const underline = "_underline_1tncs_18";
4
- const strikethrough = "_strikethrough_1tncs_34";
5
- const underlineStrikethrough = "_underlineStrikethrough_1tncs_38";
6
- const subscript = "_subscript_1tncs_42";
7
- const superscript = "_superscript_1tncs_47";
8
- const code = "_code_1tncs_52";
9
- const nestedListItem = "_nestedListItem_1tncs_59";
10
- const listitem = "_listitem_1tncs_69";
11
- const listItemChecked = "_listItemChecked_1tncs_73";
12
- const listItemUnchecked = "_listItemUnchecked_1tncs_74";
13
- const admonitionDanger = "_admonitionDanger_1tncs_151";
14
- const admonitionInfo = "_admonitionInfo_1tncs_152";
15
- const admonitionNote = "_admonitionNote_1tncs_153";
16
- const admonitionTip = "_admonitionTip_1tncs_154";
17
- const admonitionCaution = "_admonitionCaution_1tncs_155";
18
- const mdxExpression = "_mdxExpression_1tncs_188";
1
+ const bold = "_bold_6j9u9_10";
2
+ const italic = "_italic_6j9u9_14";
3
+ const underline = "_underline_6j9u9_18";
4
+ const strikethrough = "_strikethrough_6j9u9_34";
5
+ const underlineStrikethrough = "_underlineStrikethrough_6j9u9_38";
6
+ const subscript = "_subscript_6j9u9_42";
7
+ const superscript = "_superscript_6j9u9_47";
8
+ const code = "_code_6j9u9_52";
9
+ const quote = "_quote_6j9u9_59";
10
+ const nestedListItem = "_nestedListItem_6j9u9_66";
11
+ const listitem = "_listitem_6j9u9_76";
12
+ const listItemChecked = "_listItemChecked_6j9u9_80";
13
+ const listItemUnchecked = "_listItemUnchecked_6j9u9_81";
14
+ const admonitionDanger = "_admonitionDanger_6j9u9_158";
15
+ const admonitionInfo = "_admonitionInfo_6j9u9_159";
16
+ const admonitionNote = "_admonitionNote_6j9u9_160";
17
+ const admonitionTip = "_admonitionTip_6j9u9_161";
18
+ const admonitionCaution = "_admonitionCaution_6j9u9_162";
19
+ const mdxExpression = "_mdxExpression_6j9u9_195";
19
20
  const lexicalThemeStyles = {
20
21
  bold,
21
22
  italic,
@@ -25,6 +26,7 @@ const lexicalThemeStyles = {
25
26
  subscript,
26
27
  superscript,
27
28
  code,
29
+ quote,
28
30
  nestedListItem,
29
31
  listitem,
30
32
  listItemChecked,
@@ -51,6 +53,7 @@ export {
51
53
  listitem,
52
54
  mdxExpression,
53
55
  nestedListItem,
56
+ quote,
54
57
  strikethrough,
55
58
  subscript,
56
59
  superscript,
@@ -1,5 +1,6 @@
1
1
  import lexicalThemeStyles from "./lexical-theme.module.css.js";
2
2
  const lexicalTheme = {
3
+ quote: lexicalThemeStyles.quote,
3
4
  text: {
4
5
  bold: lexicalThemeStyles.bold,
5
6
  italic: lexicalThemeStyles.italic,
@@ -1,98 +1,97 @@
1
- const editorRoot = "_editorRoot_1e2ox_53";
2
- const editorWrapper = "_editorWrapper_1e2ox_155";
3
- const toolbarRoot = "_toolbarRoot_1e2ox_162";
4
- const readOnlyToolbarRoot = "_readOnlyToolbarRoot_1e2ox_189";
5
- const toolbarToggleItem = "_toolbarToggleItem_1e2ox_208";
6
- const toolbarGroupOfGroups = "_toolbarGroupOfGroups_1e2ox_219";
7
- const toolbarToggleSingleGroup = "_toolbarToggleSingleGroup_1e2ox_224";
8
- const toolbarButton = "_toolbarButton_1e2ox_239";
9
- const activeToolbarButton = "_activeToolbarButton_1e2ox_275";
10
- const toolbarButtonDropdownContainer = "_toolbarButtonDropdownContainer_1e2ox_286";
11
- const selectContainer = "_selectContainer_1e2ox_288";
12
- const selectItem = "_selectItem_1e2ox_301";
13
- const toolbarButtonSelectTrigger = "_toolbarButtonSelectTrigger_1e2ox_307";
14
- const selectTrigger = "_selectTrigger_1e2ox_308";
15
- const selectDropdownArrow = "_selectDropdownArrow_1e2ox_374";
16
- const contentEditable = "_contentEditable_1e2ox_380";
17
- const codeMirrorWrapper = "_codeMirrorWrapper_1e2ox_392";
18
- const sandPackWrapper = "_sandPackWrapper_1e2ox_401";
19
- const codeMirrorToolbar = "_codeMirrorToolbar_1e2ox_409";
20
- const propertyPanelTitle = "_propertyPanelTitle_1e2ox_431";
21
- const propertyEditorTable = "_propertyEditorTable_1e2ox_439";
22
- const iconButton = "_iconButton_1e2ox_457";
23
- const readOnlyColumnCell = "_readOnlyColumnCell_1e2ox_462";
24
- const buttonsFooter = "_buttonsFooter_1e2ox_475";
25
- const propertyEditorInput = "_propertyEditorInput_1e2ox_481";
26
- const primaryButton = "_primaryButton_1e2ox_507";
27
- const secondaryButton = "_secondaryButton_1e2ox_508";
28
- const smallButton = "_smallButton_1e2ox_523";
29
- const dialogForm = "_dialogForm_1e2ox_535";
30
- const linkDialogEditForm = "_linkDialogEditForm_1e2ox_541";
31
- const linkDialogInputContainer = "_linkDialogInputContainer_1e2ox_549";
32
- const linkDialogInputWrapper = "_linkDialogInputWrapper_1e2ox_555";
33
- const linkDialogInput = "_linkDialogInput_1e2ox_549";
34
- const linkDialogAnchor = "_linkDialogAnchor_1e2ox_587";
35
- const linkDialogPopoverContent = "_linkDialogPopoverContent_1e2ox_601";
36
- const tableColumnEditorPopoverContent = "_tableColumnEditorPopoverContent_1e2ox_602";
37
- const dialogContent = "_dialogContent_1e2ox_603";
38
- const largeDialogContent = "_largeDialogContent_1e2ox_615";
39
- const dialogTitle = "_dialogTitle_1e2ox_625";
40
- const dialogCloseButton = "_dialogCloseButton_1e2ox_631";
41
- const popoverContent = "_popoverContent_1e2ox_638";
42
- const popoverArrow = "_popoverArrow_1e2ox_650";
43
- const linkDialogPreviewAnchor = "_linkDialogPreviewAnchor_1e2ox_654";
44
- const tooltipTrigger = "_tooltipTrigger_1e2ox_677";
45
- const tooltipContent = "_tooltipContent_1e2ox_681";
46
- const actionButton = "_actionButton_1e2ox_695";
47
- const primaryActionButton = "_primaryActionButton_1e2ox_702";
48
- const tableEditor = "_tableEditor_1e2ox_714";
49
- const toolCell = "_toolCell_1e2ox_725";
50
- const tableColumnEditorTrigger = "_tableColumnEditorTrigger_1e2ox_744";
51
- const addRowButton = "_addRowButton_1e2ox_746";
52
- const addColumnButton = "_addColumnButton_1e2ox_747";
53
- const tableColumnEditorToolbar = "_tableColumnEditorToolbar_1e2ox_789";
54
- const toggleGroupRoot = "_toggleGroupRoot_1e2ox_802";
55
- const tableToolsColumn = "_tableToolsColumn_1e2ox_820";
56
- const leftAlignedCell = "_leftAlignedCell_1e2ox_829";
57
- const rightAlignedCell = "_rightAlignedCell_1e2ox_833";
58
- const centeredCell = "_centeredCell_1e2ox_837";
59
- const dialogOverlay = "_dialogOverlay_1e2ox_870";
60
- const focusedImage = "_focusedImage_1e2ox_916";
61
- const imageWrapper = "_imageWrapper_1e2ox_920";
62
- const editImageToolbar = "_editImageToolbar_1e2ox_933";
63
- const editImageButton = "_editImageButton_1e2ox_937";
64
- const inlineEditor = "_inlineEditor_1e2ox_943";
65
- const blockEditor = "_blockEditor_1e2ox_952";
66
- const nestedEditor = "_nestedEditor_1e2ox_961";
67
- const genericComponentName = "_genericComponentName_1e2ox_980";
68
- const diffSourceToggleWrapper = "_diffSourceToggleWrapper_1e2ox_986";
69
- const ggDiffSourceToggle = "_ggDiffSourceToggle_1e2ox_994";
70
- const diffSourceToggle = "_diffSourceToggle_1e2ox_986";
71
- const selectWithLabel = "_selectWithLabel_1e2ox_1012";
72
- const toolbarTitleMode = "_toolbarTitleMode_1e2ox_1027";
73
- const imageControlWrapperResizing = "_imageControlWrapperResizing_1e2ox_1032";
74
- const imageResizer = "_imageResizer_1e2ox_1036";
75
- const imageResizerN = "_imageResizerN_1e2ox_1045";
76
- const imageResizerNe = "_imageResizerNe_1e2ox_1051";
77
- const imageResizerE = "_imageResizerE_1e2ox_1057";
78
- const imageResizerSe = "_imageResizerSe_1e2ox_1063";
79
- const imageResizerS = "_imageResizerS_1e2ox_1063";
80
- const imageResizerSw = "_imageResizerSw_1e2ox_1075";
81
- const imageResizerW = "_imageResizerW_1e2ox_1081";
82
- const imageResizerNw = "_imageResizerNw_1e2ox_1087";
83
- const imagePlaceholder = "_imagePlaceholder_1e2ox_1093";
84
- const imageDimensionsContainer = "_imageDimensionsContainer_1e2ox_1101";
85
- const placeholder = "_placeholder_1e2ox_1106";
86
- const rootContentEditableWrapper = "_rootContentEditableWrapper_1e2ox_1119";
87
- const downshiftInputWrapper = "_downshiftInputWrapper_1e2ox_1129";
88
- const downshiftInput = "_downshiftInput_1e2ox_1129";
89
- const downshiftAutocompleteContainer = "_downshiftAutocompleteContainer_1e2ox_1160";
90
- const textInput = "_textInput_1e2ox_1206";
91
- const multiFieldForm = "_multiFieldForm_1e2ox_1214";
92
- const formField = "_formField_1e2ox_1220";
93
- const markdownParseError = "_markdownParseError_1e2ox_1231";
94
- const popupContainer = "_popupContainer_1e2ox_1240";
95
- const inputSizer = "_inputSizer_1e2ox_1245";
1
+ const editorRoot = "_editorRoot_f3hmk_53";
2
+ const editorWrapper = "_editorWrapper_f3hmk_155";
3
+ const toolbarRoot = "_toolbarRoot_f3hmk_162";
4
+ const readOnlyToolbarRoot = "_readOnlyToolbarRoot_f3hmk_189";
5
+ const toolbarToggleItem = "_toolbarToggleItem_f3hmk_208";
6
+ const toolbarGroupOfGroups = "_toolbarGroupOfGroups_f3hmk_219";
7
+ const toolbarToggleSingleGroup = "_toolbarToggleSingleGroup_f3hmk_224";
8
+ const toolbarButton = "_toolbarButton_f3hmk_239";
9
+ const activeToolbarButton = "_activeToolbarButton_f3hmk_275";
10
+ const toolbarButtonDropdownContainer = "_toolbarButtonDropdownContainer_f3hmk_286";
11
+ const selectContainer = "_selectContainer_f3hmk_288";
12
+ const selectItem = "_selectItem_f3hmk_301";
13
+ const toolbarButtonSelectTrigger = "_toolbarButtonSelectTrigger_f3hmk_307";
14
+ const selectTrigger = "_selectTrigger_f3hmk_308";
15
+ const selectDropdownArrow = "_selectDropdownArrow_f3hmk_373";
16
+ const contentEditable = "_contentEditable_f3hmk_379";
17
+ const codeMirrorWrapper = "_codeMirrorWrapper_f3hmk_391";
18
+ const codeMirrorToolbar = "_codeMirrorToolbar_f3hmk_408";
19
+ const propertyPanelTitle = "_propertyPanelTitle_f3hmk_430";
20
+ const propertyEditorTable = "_propertyEditorTable_f3hmk_438";
21
+ const iconButton = "_iconButton_f3hmk_456";
22
+ const readOnlyColumnCell = "_readOnlyColumnCell_f3hmk_461";
23
+ const buttonsFooter = "_buttonsFooter_f3hmk_474";
24
+ const propertyEditorInput = "_propertyEditorInput_f3hmk_480";
25
+ const primaryButton = "_primaryButton_f3hmk_506";
26
+ const secondaryButton = "_secondaryButton_f3hmk_507";
27
+ const smallButton = "_smallButton_f3hmk_522";
28
+ const dialogForm = "_dialogForm_f3hmk_534";
29
+ const linkDialogEditForm = "_linkDialogEditForm_f3hmk_540";
30
+ const linkDialogInputContainer = "_linkDialogInputContainer_f3hmk_548";
31
+ const linkDialogInputWrapper = "_linkDialogInputWrapper_f3hmk_554";
32
+ const linkDialogInput = "_linkDialogInput_f3hmk_548";
33
+ const linkDialogAnchor = "_linkDialogAnchor_f3hmk_586";
34
+ const linkDialogPopoverContent = "_linkDialogPopoverContent_f3hmk_600";
35
+ const tableColumnEditorPopoverContent = "_tableColumnEditorPopoverContent_f3hmk_601";
36
+ const dialogContent = "_dialogContent_f3hmk_602";
37
+ const largeDialogContent = "_largeDialogContent_f3hmk_614";
38
+ const dialogTitle = "_dialogTitle_f3hmk_624";
39
+ const dialogCloseButton = "_dialogCloseButton_f3hmk_630";
40
+ const popoverContent = "_popoverContent_f3hmk_637";
41
+ const popoverArrow = "_popoverArrow_f3hmk_649";
42
+ const linkDialogPreviewAnchor = "_linkDialogPreviewAnchor_f3hmk_653";
43
+ const tooltipTrigger = "_tooltipTrigger_f3hmk_676";
44
+ const tooltipContent = "_tooltipContent_f3hmk_680";
45
+ const actionButton = "_actionButton_f3hmk_694";
46
+ const primaryActionButton = "_primaryActionButton_f3hmk_701";
47
+ const tableEditor = "_tableEditor_f3hmk_713";
48
+ const toolCell = "_toolCell_f3hmk_724";
49
+ const tableColumnEditorTrigger = "_tableColumnEditorTrigger_f3hmk_743";
50
+ const addRowButton = "_addRowButton_f3hmk_745";
51
+ const addColumnButton = "_addColumnButton_f3hmk_746";
52
+ const tableColumnEditorToolbar = "_tableColumnEditorToolbar_f3hmk_788";
53
+ const toggleGroupRoot = "_toggleGroupRoot_f3hmk_801";
54
+ const tableToolsColumn = "_tableToolsColumn_f3hmk_819";
55
+ const leftAlignedCell = "_leftAlignedCell_f3hmk_828";
56
+ const rightAlignedCell = "_rightAlignedCell_f3hmk_832";
57
+ const centeredCell = "_centeredCell_f3hmk_836";
58
+ const dialogOverlay = "_dialogOverlay_f3hmk_869";
59
+ const focusedImage = "_focusedImage_f3hmk_915";
60
+ const imageWrapper = "_imageWrapper_f3hmk_919";
61
+ const editImageToolbar = "_editImageToolbar_f3hmk_932";
62
+ const editImageButton = "_editImageButton_f3hmk_936";
63
+ const inlineEditor = "_inlineEditor_f3hmk_942";
64
+ const blockEditor = "_blockEditor_f3hmk_951";
65
+ const nestedEditor = "_nestedEditor_f3hmk_960";
66
+ const genericComponentName = "_genericComponentName_f3hmk_979";
67
+ const diffSourceToggleWrapper = "_diffSourceToggleWrapper_f3hmk_985";
68
+ const ggDiffSourceToggle = "_ggDiffSourceToggle_f3hmk_993";
69
+ const diffSourceToggle = "_diffSourceToggle_f3hmk_985";
70
+ const selectWithLabel = "_selectWithLabel_f3hmk_1011";
71
+ const toolbarTitleMode = "_toolbarTitleMode_f3hmk_1026";
72
+ const imageControlWrapperResizing = "_imageControlWrapperResizing_f3hmk_1031";
73
+ const imageResizer = "_imageResizer_f3hmk_1035";
74
+ const imageResizerN = "_imageResizerN_f3hmk_1044";
75
+ const imageResizerNe = "_imageResizerNe_f3hmk_1050";
76
+ const imageResizerE = "_imageResizerE_f3hmk_1056";
77
+ const imageResizerSe = "_imageResizerSe_f3hmk_1062";
78
+ const imageResizerS = "_imageResizerS_f3hmk_1062";
79
+ const imageResizerSw = "_imageResizerSw_f3hmk_1074";
80
+ const imageResizerW = "_imageResizerW_f3hmk_1080";
81
+ const imageResizerNw = "_imageResizerNw_f3hmk_1086";
82
+ const imagePlaceholder = "_imagePlaceholder_f3hmk_1092";
83
+ const imageDimensionsContainer = "_imageDimensionsContainer_f3hmk_1100";
84
+ const placeholder = "_placeholder_f3hmk_1105";
85
+ const rootContentEditableWrapper = "_rootContentEditableWrapper_f3hmk_1118";
86
+ const downshiftInputWrapper = "_downshiftInputWrapper_f3hmk_1128";
87
+ const downshiftInput = "_downshiftInput_f3hmk_1128";
88
+ const downshiftAutocompleteContainer = "_downshiftAutocompleteContainer_f3hmk_1159";
89
+ const textInput = "_textInput_f3hmk_1205";
90
+ const multiFieldForm = "_multiFieldForm_f3hmk_1213";
91
+ const formField = "_formField_f3hmk_1219";
92
+ const markdownParseError = "_markdownParseError_f3hmk_1230";
93
+ const popupContainer = "_popupContainer_f3hmk_1239";
94
+ const inputSizer = "_inputSizer_f3hmk_1244";
96
95
  const styles = {
97
96
  editorRoot,
98
97
  editorWrapper,
@@ -111,7 +110,6 @@ const styles = {
111
110
  selectDropdownArrow,
112
111
  contentEditable,
113
112
  codeMirrorWrapper,
114
- sandPackWrapper,
115
113
  codeMirrorToolbar,
116
114
  propertyPanelTitle,
117
115
  propertyEditorTable,
@@ -261,7 +259,6 @@ export {
261
259
  readOnlyToolbarRoot,
262
260
  rightAlignedCell,
263
261
  rootContentEditableWrapper,
264
- sandPackWrapper,
265
262
  secondaryButton,
266
263
  selectContainer,
267
264
  selectDropdownArrow,
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "*.css"
12
12
  ],
13
13
  "type": "module",
14
- "version": "3.55.0",
14
+ "version": "4.0.0",
15
15
  "description": "React component for rich text markdown editing",
16
16
  "scripts": {
17
17
  "build": "vite build",
@@ -44,7 +44,6 @@
44
44
  "@codemirror/merge": "^6.4.0",
45
45
  "@codemirror/state": "^6.4.0",
46
46
  "@codemirror/view": "^6.23.0",
47
- "@codesandbox/sandpack-react": "^2.20.0",
48
47
  "@lexical/clipboard": "^0.35.0",
49
48
  "@lexical/link": "^0.35.0",
50
49
  "@lexical/list": "^0.35.0",
@@ -1,56 +0,0 @@
1
- import { SandpackProvider, SandpackLayout, SandpackCodeEditor, SandpackPreview, useSandpack } from "@codesandbox/sandpack-react";
2
- import { useCellValues } from "@mdxeditor/gurx";
3
- import React__default from "react";
4
- import styles from "../../styles/ui.module.css.js";
5
- import { useCodeBlockEditorContext } from "../codeblock/CodeBlockNode.js";
6
- import { readOnly$, iconComponentFor$, useTranslation } from "../core/index.js";
7
- import { useCodeMirrorRef } from "./useCodeMirrorRef.js";
8
- const CodeUpdateEmitter = ({ onChange, snippetFileName }) => {
9
- const { sandpack } = useSandpack();
10
- onChange(sandpack.files[snippetFileName].code);
11
- return null;
12
- };
13
- const SandpackEditor = ({ nodeKey, code, focusEmitter, preset }) => {
14
- const codeMirrorRef = useCodeMirrorRef(nodeKey, "sandpack", "jsx", focusEmitter);
15
- const [readOnly, iconComponentFor] = useCellValues(readOnly$, iconComponentFor$);
16
- const { setCode } = useCodeBlockEditorContext();
17
- const { parentEditor, lexicalNode } = useCodeBlockEditorContext();
18
- const t = useTranslation();
19
- return /* @__PURE__ */ React__default.createElement("div", { className: styles.sandPackWrapper }, /* @__PURE__ */ React__default.createElement("div", { className: styles.codeMirrorToolbar }, /* @__PURE__ */ React__default.createElement(
20
- "button",
21
- {
22
- className: styles.iconButton,
23
- type: "button",
24
- disabled: readOnly,
25
- title: t("codeblock.delete", "Delete code block"),
26
- onClick: (e) => {
27
- e.preventDefault();
28
- parentEditor.update(() => {
29
- lexicalNode.remove();
30
- });
31
- }
32
- },
33
- iconComponentFor("delete_small")
34
- )), /* @__PURE__ */ React__default.createElement(
35
- SandpackProvider,
36
- {
37
- template: preset.sandpackTemplate,
38
- theme: preset.sandpackTheme,
39
- files: {
40
- [preset.snippetFileName]: code,
41
- ...Object.entries(preset.files ?? {}).reduce(
42
- (acc, [filePath, fileContents]) => ({ ...acc, ...{ [filePath]: { code: fileContents, readOnly: true } } }),
43
- {}
44
- )
45
- },
46
- customSetup: {
47
- dependencies: preset.dependencies
48
- }
49
- },
50
- /* @__PURE__ */ React__default.createElement(SandpackLayout, null, /* @__PURE__ */ React__default.createElement(SandpackCodeEditor, { readOnly, showLineNumbers: true, showInlineErrors: true, ref: codeMirrorRef }), /* @__PURE__ */ React__default.createElement(SandpackPreview, null)),
51
- /* @__PURE__ */ React__default.createElement(CodeUpdateEmitter, { onChange: setCode, snippetFileName: preset.snippetFileName })
52
- ));
53
- };
54
- export {
55
- SandpackEditor
56
- };
@@ -1,83 +0,0 @@
1
- import React__default from "react";
2
- import { insertCodeBlock$, appendCodeBlockEditorDescriptor$ } from "../codeblock/index.js";
3
- import { SandpackEditor } from "./SandpackEditor.js";
4
- import { Cell, Signal, withLatestFrom, map, useCellValue } from "@mdxeditor/gurx";
5
- import { realmPlugin } from "../../RealmWithPlugins.js";
6
- const defaultSnippetContent = `
7
- export default function App() {
8
- return (
9
- <div className="App">
10
- <h1>Hello CodeSandbox</h1>
11
- <h2>Start editing to see some magic happen!</h2>
12
- </div>
13
- );
14
- }
15
- `;
16
- const defaultSandpackConfig = {
17
- defaultPreset: "react",
18
- presets: [
19
- {
20
- name: "react",
21
- meta: "live react",
22
- label: "React",
23
- sandpackTemplate: "react",
24
- sandpackTheme: "light",
25
- snippetFileName: "/App.js",
26
- snippetLanguage: "jsx",
27
- initialSnippetContent: defaultSnippetContent
28
- }
29
- ]
30
- };
31
- const sandpackConfig$ = Cell(defaultSandpackConfig);
32
- const insertSandpack$ = Signal((r) => {
33
- r.link(
34
- r.pipe(
35
- insertSandpack$,
36
- withLatestFrom(sandpackConfig$),
37
- map(([presetName, sandpackConfig]) => {
38
- const preset = presetName ? sandpackConfig.presets.find((preset2) => preset2.name === presetName) : sandpackConfig.presets.find((preset2) => preset2.name == sandpackConfig.defaultPreset);
39
- if (!preset) {
40
- throw new Error(`No sandpack preset found with name ${presetName}`);
41
- }
42
- return {
43
- code: preset.initialSnippetContent ?? "",
44
- language: preset.snippetLanguage ?? "jsx",
45
- meta: preset.meta
46
- };
47
- })
48
- ),
49
- insertCodeBlock$
50
- );
51
- });
52
- const sandpackPlugin = realmPlugin({
53
- init(realm, params) {
54
- realm.pubIn({
55
- [sandpackConfig$]: params == null ? void 0 : params.sandpackConfig,
56
- [appendCodeBlockEditorDescriptor$]: sandpackCodeBlockDescriptor()
57
- });
58
- },
59
- update(realm, params) {
60
- realm.pub(sandpackConfig$, params == null ? void 0 : params.sandpackConfig);
61
- }
62
- });
63
- function sandpackCodeBlockDescriptor() {
64
- return {
65
- match(_language, meta) {
66
- return Boolean(meta == null ? void 0 : meta.startsWith("live"));
67
- },
68
- Editor(props) {
69
- const config = useCellValue(sandpackConfig$);
70
- const preset = config.presets.find((preset2) => preset2.meta === props.meta);
71
- if (!preset) {
72
- throw new Error(`No sandpack preset found with ${props.meta}`);
73
- }
74
- return /* @__PURE__ */ React__default.createElement(SandpackEditor, { ...props, preset });
75
- },
76
- priority: 1
77
- };
78
- }
79
- export {
80
- insertSandpack$,
81
- sandpackConfig$,
82
- sandpackPlugin
83
- };
@@ -1,15 +0,0 @@
1
- import React__default from "react";
2
- import { ButtonOrDropdownButton } from "../primitives/toolbar.js";
3
- import { sandpackConfig$, insertSandpack$ } from "../../sandpack/index.js";
4
- import { useCellValues, usePublisher } from "@mdxeditor/gurx";
5
- import { iconComponentFor$, useTranslation } from "../../core/index.js";
6
- const InsertSandpack = () => {
7
- const [sandpackConfig, iconComponentFor] = useCellValues(sandpackConfig$, iconComponentFor$);
8
- const insertSandpack = usePublisher(insertSandpack$);
9
- const items = React__default.useMemo(() => sandpackConfig.presets.map((preset) => ({ value: preset.name, label: preset.label })), [sandpackConfig]);
10
- const t = useTranslation();
11
- return /* @__PURE__ */ React__default.createElement(ButtonOrDropdownButton, { title: t("toolbar.insertSandpack", "Insert Sandpack"), onChoose: insertSandpack, items }, iconComponentFor("sandpack"));
12
- };
13
- export {
14
- InsertSandpack
15
- };
@@ -1,41 +0,0 @@
1
- import React__default from "react";
2
- import styles from "../../../styles/ui.module.css.js";
3
- import { $isCodeBlockNode } from "../../codeblock/CodeBlockNode.js";
4
- import { editorInFocus$, activeEditor$, iconComponentFor$, useTranslation } from "../../core/index.js";
5
- import { sandpackConfig$ } from "../../sandpack/index.js";
6
- import { ButtonWithTooltip } from "../primitives/toolbar.js";
7
- import { useCellValues } from "@mdxeditor/gurx";
8
- const ShowSandpackInfo = () => {
9
- const [editorInFocus, theEditor, iconComponentFor, sandpackConfig] = useCellValues(
10
- editorInFocus$,
11
- activeEditor$,
12
- iconComponentFor$,
13
- sandpackConfig$
14
- );
15
- const t = useTranslation();
16
- const sandpackNode = $isCodeBlockNode(editorInFocus.rootNode) ? editorInFocus.rootNode : null;
17
- if (!sandpackNode) {
18
- return null;
19
- }
20
- const preset = sandpackConfig.presets.find((preset2) => preset2.meta === sandpackNode.getMeta());
21
- return /* @__PURE__ */ React__default.createElement("div", { className: styles.selectWithLabel }, /* @__PURE__ */ React__default.createElement(
22
- ButtonWithTooltip,
23
- {
24
- title: t("toolbar.deleteSandpack", "Delete this code block"),
25
- onClick: () => {
26
- theEditor == null ? void 0 : theEditor.update(() => {
27
- if (sandpackNode.getNextSibling()) {
28
- sandpackNode.selectNext();
29
- } else {
30
- sandpackNode.selectPrevious();
31
- }
32
- sandpackNode.remove();
33
- });
34
- }
35
- },
36
- iconComponentFor("delete_big")
37
- ), /* @__PURE__ */ React__default.createElement("label", null, "Sandpack preset: ", preset.name));
38
- };
39
- export {
40
- ShowSandpackInfo
41
- };