@umbra.ui/core 0.4.0 → 0.4.1

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.
@@ -5,7 +5,6 @@ import StarterKit from "@tiptap/starter-kit";
5
5
  import { Markdown } from "@tiptap/markdown";
6
6
  import Highlight from "@tiptap/extension-highlight";
7
7
  import Placeholder from "@tiptap/extension-placeholder";
8
- import Underline from "@tiptap/extension-underline";
9
8
  import "./theme.css";
10
9
  import "./editor.css";
11
10
 
@@ -24,24 +23,24 @@ const props = withDefaults(defineProps<Props>(), {
24
23
  const isUpdatingFromProps = ref(false);
25
24
 
26
25
  type MarkdownEditor = {
27
- getJSON: () => unknown;
28
- storage?: {
29
- markdown?: {
30
- getMarkdown?: () => string;
31
- serialize?: (doc: unknown) => string;
32
- };
26
+ getMarkdown?: () => string;
27
+ markdown?: {
28
+ serialize?: (docOrContent: any) => string;
33
29
  };
30
+ getJSON?: () => unknown;
31
+ getText?: () => string;
34
32
  };
35
33
 
36
34
  const getMarkdownFromEditor = (activeEditor: MarkdownEditor) => {
37
- const storage = activeEditor.storage?.markdown;
38
- if (storage?.getMarkdown) {
39
- return storage.getMarkdown();
35
+ if (activeEditor.getMarkdown) {
36
+ return activeEditor.getMarkdown();
40
37
  }
41
- if (storage?.serialize) {
42
- return storage.serialize(activeEditor.getJSON());
38
+ const markdownManager = activeEditor.markdown;
39
+ if (markdownManager?.serialize && activeEditor.getJSON) {
40
+ return markdownManager.serialize(activeEditor.getJSON());
43
41
  }
44
- return "";
42
+ const textFallback = activeEditor.getText?.();
43
+ return textFallback ?? "";
45
44
  };
46
45
 
47
46
  const editor = useEditor({
@@ -51,7 +50,6 @@ const editor = useEditor({
51
50
  StarterKit,
52
51
  Markdown,
53
52
  Highlight,
54
- Underline,
55
53
  Placeholder.configure({
56
54
  placeholder: props.placeholder,
57
55
  }),
@@ -62,21 +60,21 @@ const editor = useEditor({
62
60
  spellcheck: "true",
63
61
  },
64
62
  },
65
- onUpdate: ({ editor: activeEditor }: { editor: MarkdownEditor }) => {
63
+ onUpdate: ({ editor: activeEditor }) => {
66
64
  if (isUpdatingFromProps.value) {
67
65
  return;
68
66
  }
69
67
  const markdown = getMarkdownFromEditor(activeEditor);
70
68
  emit("update:text", markdown);
71
69
  },
72
- onBlur: ({ editor: activeEditor }: { editor: MarkdownEditor }) => {
70
+ onBlur: ({ editor: activeEditor }) => {
73
71
  const markdown = getMarkdownFromEditor(activeEditor);
74
72
  emit("onBlur", markdown);
75
73
  },
76
74
  });
77
75
 
78
76
  const editorMarkdown = computed(() =>
79
- editor.value ? getMarkdownFromEditor(editor.value) : ""
77
+ editor.value ? getMarkdownFromEditor(editor.value) : "",
80
78
  );
81
79
 
82
80
  watch(
@@ -86,11 +84,9 @@ watch(
86
84
  return;
87
85
  }
88
86
  isUpdatingFromProps.value = true;
89
- editor.value.commands.setContent(newValue, false, {
90
- contentType: "markdown",
91
- });
87
+ editor.value.commands.setContent(newValue, { contentType: "markdown" });
92
88
  isUpdatingFromProps.value = false;
93
- }
89
+ },
94
90
  );
95
91
 
96
92
  onBeforeUnmount(() => {
@@ -50,7 +50,6 @@
50
50
  }
51
51
 
52
52
  .tiptap {
53
- min-height: 5.882rem;
54
53
  width: 100%;
55
54
  color: var(--autogrow-text-color);
56
55
  outline: none;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umbra.ui/core",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Core components for Umbra UI",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -32,7 +32,6 @@
32
32
  "@floating-ui/vue": "^1.1.7",
33
33
  "@tiptap/extension-highlight": "^3.19.0",
34
34
  "@tiptap/extension-placeholder": "^3.19.0",
35
- "@tiptap/extension-underline": "^3.19.0",
36
35
  "@tiptap/markdown": "^3.19.0",
37
36
  "@tiptap/starter-kit": "^3.19.0",
38
37
  "@tiptap/vue-3": "^3.19.0",
@@ -5,7 +5,6 @@ import StarterKit from "@tiptap/starter-kit";
5
5
  import { Markdown } from "@tiptap/markdown";
6
6
  import Highlight from "@tiptap/extension-highlight";
7
7
  import Placeholder from "@tiptap/extension-placeholder";
8
- import Underline from "@tiptap/extension-underline";
9
8
  import "./theme.css";
10
9
  import "./editor.css";
11
10
 
@@ -24,24 +23,24 @@ const props = withDefaults(defineProps<Props>(), {
24
23
  const isUpdatingFromProps = ref(false);
25
24
 
26
25
  type MarkdownEditor = {
27
- getJSON: () => unknown;
28
- storage?: {
29
- markdown?: {
30
- getMarkdown?: () => string;
31
- serialize?: (doc: unknown) => string;
32
- };
26
+ getMarkdown?: () => string;
27
+ markdown?: {
28
+ serialize?: (docOrContent: any) => string;
33
29
  };
30
+ getJSON?: () => unknown;
31
+ getText?: () => string;
34
32
  };
35
33
 
36
34
  const getMarkdownFromEditor = (activeEditor: MarkdownEditor) => {
37
- const storage = activeEditor.storage?.markdown;
38
- if (storage?.getMarkdown) {
39
- return storage.getMarkdown();
35
+ if (activeEditor.getMarkdown) {
36
+ return activeEditor.getMarkdown();
40
37
  }
41
- if (storage?.serialize) {
42
- return storage.serialize(activeEditor.getJSON());
38
+ const markdownManager = activeEditor.markdown;
39
+ if (markdownManager?.serialize && activeEditor.getJSON) {
40
+ return markdownManager.serialize(activeEditor.getJSON());
43
41
  }
44
- return "";
42
+ const textFallback = activeEditor.getText?.();
43
+ return textFallback ?? "";
45
44
  };
46
45
 
47
46
  const editor = useEditor({
@@ -51,7 +50,6 @@ const editor = useEditor({
51
50
  StarterKit,
52
51
  Markdown,
53
52
  Highlight,
54
- Underline,
55
53
  Placeholder.configure({
56
54
  placeholder: props.placeholder,
57
55
  }),
@@ -62,21 +60,21 @@ const editor = useEditor({
62
60
  spellcheck: "true",
63
61
  },
64
62
  },
65
- onUpdate: ({ editor: activeEditor }: { editor: MarkdownEditor }) => {
63
+ onUpdate: ({ editor: activeEditor }) => {
66
64
  if (isUpdatingFromProps.value) {
67
65
  return;
68
66
  }
69
67
  const markdown = getMarkdownFromEditor(activeEditor);
70
68
  emit("update:text", markdown);
71
69
  },
72
- onBlur: ({ editor: activeEditor }: { editor: MarkdownEditor }) => {
70
+ onBlur: ({ editor: activeEditor }) => {
73
71
  const markdown = getMarkdownFromEditor(activeEditor);
74
72
  emit("onBlur", markdown);
75
73
  },
76
74
  });
77
75
 
78
76
  const editorMarkdown = computed(() =>
79
- editor.value ? getMarkdownFromEditor(editor.value) : ""
77
+ editor.value ? getMarkdownFromEditor(editor.value) : "",
80
78
  );
81
79
 
82
80
  watch(
@@ -86,11 +84,9 @@ watch(
86
84
  return;
87
85
  }
88
86
  isUpdatingFromProps.value = true;
89
- editor.value.commands.setContent(newValue, false, {
90
- contentType: "markdown",
91
- });
87
+ editor.value.commands.setContent(newValue, { contentType: "markdown" });
92
88
  isUpdatingFromProps.value = false;
93
- }
89
+ },
94
90
  );
95
91
 
96
92
  onBeforeUnmount(() => {
@@ -50,7 +50,6 @@
50
50
  }
51
51
 
52
52
  .tiptap {
53
- min-height: 5.882rem;
54
53
  width: 100%;
55
54
  color: var(--autogrow-text-color);
56
55
  outline: none;