@crystallize/design-system 1.6.1 → 1.7.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @crystallize/design-system
2
2
 
3
+ ## 1.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 6739bf9: Added "Copy JSON" action menu option. This will copy the JSON AST to the clipboard.
8
+
3
9
  ## 1.6.1
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -8464,7 +8464,15 @@ init_TablePlugin();
8464
8464
  var import_lexical24 = require("lexical");
8465
8465
  var import_LexicalComposerContext16 = require("@lexical/react/LexicalComposerContext");
8466
8466
  var import_jsx_runtime91 = require("react/jsx-runtime");
8467
- async function exportFile(editor) {
8467
+ async function copyJson(editor) {
8468
+ const json = lexicalToCrystallizeRichText({ editorState: editor.getEditorState() });
8469
+ try {
8470
+ await navigator.clipboard.writeText(JSON.stringify(json, null, 1));
8471
+ } catch (error) {
8472
+ console.warn("Copy failed", error);
8473
+ }
8474
+ }
8475
+ async function exportJson(editor) {
8468
8476
  const json = lexicalToCrystallizeRichText({ editorState: editor.getEditorState() });
8469
8477
  const blob = new Blob([JSON.stringify(json, null, 1)], {
8470
8478
  type: "application/json"
@@ -8495,8 +8503,12 @@ function ActionsPlugin({
8495
8503
  children: actionItem.title
8496
8504
  }, actionItem.title)),
8497
8505
  /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ActionMenu.Item, {
8498
- onSelect: () => exportFile(editor),
8499
- children: "Export to JSON"
8506
+ onSelect: () => copyJson(editor),
8507
+ children: "Copy JSON"
8508
+ }),
8509
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ActionMenu.Item, {
8510
+ onSelect: () => exportJson(editor),
8511
+ children: "Export JSON"
8500
8512
  }),
8501
8513
  /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ActionMenu.Item, {
8502
8514
  className: "danger",
package/dist/index.mjs CHANGED
@@ -6355,7 +6355,15 @@ import {
6355
6355
  import { CLEAR_EDITOR_COMMAND } from "lexical";
6356
6356
  import { useLexicalComposerContext as useLexicalComposerContext14 } from "@lexical/react/LexicalComposerContext";
6357
6357
  import { jsx as jsx82, jsxs as jsxs63 } from "react/jsx-runtime";
6358
- async function exportFile(editor) {
6358
+ async function copyJson(editor) {
6359
+ const json = lexicalToCrystallizeRichText({ editorState: editor.getEditorState() });
6360
+ try {
6361
+ await navigator.clipboard.writeText(JSON.stringify(json, null, 1));
6362
+ } catch (error) {
6363
+ console.warn("Copy failed", error);
6364
+ }
6365
+ }
6366
+ async function exportJson(editor) {
6359
6367
  const json = lexicalToCrystallizeRichText({ editorState: editor.getEditorState() });
6360
6368
  const blob = new Blob([JSON.stringify(json, null, 1)], {
6361
6369
  type: "application/json"
@@ -6386,8 +6394,12 @@ function ActionsPlugin({
6386
6394
  children: actionItem.title
6387
6395
  }, actionItem.title)),
6388
6396
  /* @__PURE__ */ jsx82(ActionMenu.Item, {
6389
- onSelect: () => exportFile(editor),
6390
- children: "Export to JSON"
6397
+ onSelect: () => copyJson(editor),
6398
+ children: "Copy JSON"
6399
+ }),
6400
+ /* @__PURE__ */ jsx82(ActionMenu.Item, {
6401
+ onSelect: () => exportJson(editor),
6402
+ children: "Export JSON"
6391
6403
  }),
6392
6404
  /* @__PURE__ */ jsx82(ActionMenu.Item, {
6393
6405
  className: "danger",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crystallize/design-system",
3
- "version": "1.6.1",
3
+ "version": "1.7.0",
4
4
  "types": "./dist/index.d.ts",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -14,7 +14,17 @@ import { ActionMenu } from '../../../action-menu';
14
14
  import { lexicalToCrystallizeRichText } from '../../model/lexical-to-crystallize';
15
15
  import type { CrystallizeRichTextActionMenuItem } from '../../types/types';
16
16
 
17
- async function exportFile(editor: LexicalEditor) {
17
+ async function copyJson(editor: LexicalEditor) {
18
+ const json = lexicalToCrystallizeRichText({ editorState: editor.getEditorState() });
19
+
20
+ try {
21
+ await navigator.clipboard.writeText(JSON.stringify(json, null, 1));
22
+ } catch (error) {
23
+ console.warn('Copy failed', error);
24
+ }
25
+ }
26
+
27
+ async function exportJson(editor: LexicalEditor) {
18
28
  const json = lexicalToCrystallizeRichText({ editorState: editor.getEditorState() });
19
29
 
20
30
  const blob = new Blob([JSON.stringify(json, null, 1)], {
@@ -56,7 +66,8 @@ export default function ActionsPlugin({
56
66
  {actionItem.title}
57
67
  </ActionMenu.Item>
58
68
  ))}
59
- <ActionMenu.Item onSelect={() => exportFile(editor)}>Export to JSON</ActionMenu.Item>
69
+ <ActionMenu.Item onSelect={() => copyJson(editor)}>Copy JSON</ActionMenu.Item>
70
+ <ActionMenu.Item onSelect={() => exportJson(editor)}>Export JSON</ActionMenu.Item>
60
71
  <ActionMenu.Item
61
72
  className="danger"
62
73
  onSelect={() => {