@youcan/celeste 0.6.30 → 0.6.31

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.
Files changed (99) hide show
  1. package/dist/celeste.css +293 -74
  2. package/dist/cjs/alert.js +2 -2
  3. package/dist/cjs/chunks/index.js +229 -2
  4. package/dist/cjs/chunks/index2.js +1457 -0
  5. package/dist/cjs/chunks/index3.js +16457 -0
  6. package/dist/cjs/chunks/sonner.js +1153 -0
  7. package/dist/cjs/config.js +136 -0
  8. package/dist/cjs/extra-settings.js +155 -0
  9. package/dist/cjs/index.js +9 -0
  10. package/dist/cjs/label.js +2 -2
  11. package/dist/cjs/link-bubble.js +228 -0
  12. package/dist/cjs/link-button.js +2 -2
  13. package/dist/cjs/rich-editor.js +4996 -0
  14. package/dist/cjs/select-icon.js +2 -2
  15. package/dist/cjs/sonner-alert.js +41 -0
  16. package/dist/cjs/sonner.js +3 -0
  17. package/dist/cjs/text-input-affix.js +2 -2
  18. package/dist/cjs/types.js +1 -0
  19. package/dist/components/index.d.ts +2 -0
  20. package/dist/components/rich-editor/config.d.ts +33 -0
  21. package/dist/components/rich-editor/extra-settings.d.ts +6 -0
  22. package/dist/components/rich-editor/index.d.ts +2 -0
  23. package/dist/components/rich-editor/link-bubble.d.ts +11 -0
  24. package/dist/components/rich-editor/rich-editor.d.ts +55 -0
  25. package/dist/components/rich-editor/types.d.ts +19 -0
  26. package/dist/components/sonner/index.d.ts +4 -0
  27. package/dist/components/sonner/sonner-alert.d.ts +13 -0
  28. package/dist/components/sonner/sonner.d.ts +5 -0
  29. package/dist/es/alert.js +2 -2
  30. package/dist/es/checkbox-label.js +1 -1
  31. package/dist/es/chunks/index.js +277 -50
  32. package/dist/es/chunks/index2.js +1457 -0
  33. package/dist/es/chunks/index3.js +16458 -0
  34. package/dist/es/chunks/sonner.js +1154 -0
  35. package/dist/es/combobox-group.js +1 -1
  36. package/dist/es/combobox-input.js +1 -1
  37. package/dist/es/combobox-item.js +1 -1
  38. package/dist/es/combobox-list.js +1 -1
  39. package/dist/es/combobox-root.js +1 -1
  40. package/dist/es/combobox-separator.js +1 -1
  41. package/dist/es/combobox-trigger.js +1 -1
  42. package/dist/es/command-group.js +1 -1
  43. package/dist/es/command-input.js +1 -1
  44. package/dist/es/command-item.js +1 -1
  45. package/dist/es/command-list.js +1 -1
  46. package/dist/es/command-root.js +1 -1
  47. package/dist/es/command-separator.js +1 -1
  48. package/dist/es/config.js +136 -0
  49. package/dist/es/dropdown-menu-group.js +1 -1
  50. package/dist/es/dropdown-menu-item.js +1 -1
  51. package/dist/es/dropdown-menu-label.js +1 -1
  52. package/dist/es/dropdown-menu-separator.js +1 -1
  53. package/dist/es/dropdown-menu-trigger.js +1 -1
  54. package/dist/es/dropdown-menu.js +1 -1
  55. package/dist/es/dropdown.js +1 -1
  56. package/dist/es/extra-settings.js +156 -0
  57. package/dist/es/index.js +27 -18
  58. package/dist/es/label.js +3 -3
  59. package/dist/es/link-bubble.js +229 -0
  60. package/dist/es/link-button.js +2 -2
  61. package/dist/es/modal-content.js +1 -1
  62. package/dist/es/modal-header.js +1 -1
  63. package/dist/es/popover-content.js +1 -1
  64. package/dist/es/popover-trigger.js +1 -1
  65. package/dist/es/rich-editor.js +4997 -0
  66. package/dist/es/scroll-bar.js +1 -1
  67. package/dist/es/segmented-control-item.js +1 -1
  68. package/dist/es/segmented-control.js +1 -1
  69. package/dist/es/select-content.js +1 -1
  70. package/dist/es/select-icon.js +2 -2
  71. package/dist/es/select-item.js +1 -1
  72. package/dist/es/select-trigger.js +1 -1
  73. package/dist/es/select-value.js +1 -1
  74. package/dist/es/sonner-alert.js +42 -0
  75. package/dist/es/sonner.js +4 -0
  76. package/dist/es/tab-menu-content.js +1 -1
  77. package/dist/es/tab-menu-item.js +1 -1
  78. package/dist/es/tab-menu-list.js +1 -1
  79. package/dist/es/tab-menu.js +1 -1
  80. package/dist/es/text-input-affix.js +2 -2
  81. package/dist/es/tooltip.js +1 -1
  82. package/dist/es/types.js +1 -0
  83. package/dist/utils/index.d.ts +3 -0
  84. package/dist/utils/sonner.d.ts +19 -0
  85. package/package.json +15 -4
  86. package/src/components/index.ts +2 -0
  87. package/src/components/rich-editor/config.ts +150 -0
  88. package/src/components/rich-editor/extra-settings.vue +151 -0
  89. package/src/components/rich-editor/index.ts +2 -0
  90. package/src/components/rich-editor/link-bubble.vue +288 -0
  91. package/src/components/rich-editor/rich-editor.vue +428 -0
  92. package/src/components/rich-editor/stories/rich-editor.stories.ts +87 -0
  93. package/src/components/rich-editor/types.ts +21 -0
  94. package/src/components/sonner/index.ts +5 -0
  95. package/src/components/sonner/sonner-alert.vue +54 -0
  96. package/src/components/sonner/sonner.vue +13 -0
  97. package/src/components/sonner/stories/sonner.stories.ts +194 -0
  98. package/src/utils/index.ts +3 -0
  99. package/src/utils/sonner.ts +72 -0
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, computed, openBlock, createBlock, unref, mergeProps, withCtx, createVNode } from "vue";
2
2
  import { c as clsx } from "./chunks/clsx.js";
3
- import { M as My, V as Vy } from "./chunks/index.js";
3
+ import { R as My, V as Vy } from "./chunks/index.js";
4
4
  import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
5
5
  const _sfc_main = /* @__PURE__ */ defineComponent({
6
6
  __name: "scroll-bar",
@@ -1,7 +1,7 @@
1
1
  import { defineComponent, openBlock, createBlock, unref, mergeProps, withCtx, renderSlot } from "vue";
2
2
  import { useDelegatedProps } from "./use-delegated-props.js";
3
3
  import { c as clsx } from "./chunks/clsx.js";
4
- import { v as sv } from "./chunks/index.js";
4
+ import { P as sv } from "./chunks/index.js";
5
5
  import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
6
6
  const _sfc_main = /* @__PURE__ */ defineComponent({
7
7
  __name: "segmented-control-item",
@@ -1,7 +1,7 @@
1
1
  import { defineComponent, openBlock, createBlock, unref, mergeProps, withCtx, renderSlot } from "vue";
2
2
  import { useDelegatedProps } from "./use-delegated-props.js";
3
3
  import { c as clsx } from "./chunks/clsx.js";
4
- import { x as xe, s as lv } from "./chunks/index.js";
4
+ import { x as xe, M as lv } from "./chunks/index.js";
5
5
  import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
6
6
  const _sfc_main = /* @__PURE__ */ defineComponent({
7
7
  __name: "segmented-control",
@@ -1,7 +1,7 @@
1
1
  import { defineComponent, openBlock, createBlock, unref, withCtx, createVNode, mergeProps, renderSlot } from "vue";
2
2
  import { useDelegatedProps } from "./use-delegated-props.js";
3
3
  import { c as clsx } from "./chunks/clsx.js";
4
- import { x as xe, ab as zy, ac as Ky, ad as Xy } from "./chunks/index.js";
4
+ import { x as xe, ak as zy, al as Ky, am as Xy } from "./chunks/index.js";
5
5
  import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
6
6
  const _sfc_main = /* @__PURE__ */ defineComponent({
7
7
  __name: "select-content",
@@ -20,7 +20,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
20
20
  };
21
21
  }
22
22
  });
23
- const selectIcon = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-5c4a7fcf"]]);
23
+ const SelectIcon = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-5c4a7fcf"]]);
24
24
  export {
25
- selectIcon as default
25
+ SelectIcon as default
26
26
  };
@@ -1,7 +1,7 @@
1
1
  import { defineComponent, openBlock, createBlock, unref, mergeProps, withCtx, createVNode, renderSlot, createElementVNode } from "vue";
2
2
  import { useDelegatedProps } from "./use-delegated-props.js";
3
3
  import { c as clsx } from "./chunks/clsx.js";
4
- import { ae as jy, af as Yy, ag as Uy } from "./chunks/index.js";
4
+ import { an as jy, ao as Yy, ap as Uy } from "./chunks/index.js";
5
5
  import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
6
6
  const _sfc_main = /* @__PURE__ */ defineComponent({
7
7
  __name: "select-item",
@@ -1,7 +1,7 @@
1
1
  import { defineComponent, openBlock, createBlock, unref, mergeProps, withCtx, renderSlot, createVNode, createElementVNode } from "vue";
2
2
  import { useDelegatedProps } from "./use-delegated-props.js";
3
3
  import { c as clsx } from "./chunks/clsx.js";
4
- import { ah as Ly, ai as eg } from "./chunks/index.js";
4
+ import { aq as Ly, ar as eg } from "./chunks/index.js";
5
5
  import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
6
6
  const _sfc_main = /* @__PURE__ */ defineComponent({
7
7
  __name: "select-trigger",
@@ -1,7 +1,7 @@
1
1
  import { defineComponent, openBlock, createBlock, unref, mergeProps, withCtx, renderSlot } from "vue";
2
2
  import { useDelegatedProps } from "./use-delegated-props.js";
3
3
  import { c as clsx } from "./chunks/clsx.js";
4
- import { aj as Qy } from "./chunks/index.js";
4
+ import { as as Qy } from "./chunks/index.js";
5
5
  import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
6
6
  const _sfc_main = /* @__PURE__ */ defineComponent({
7
7
  __name: "select-value",
@@ -0,0 +1,42 @@
1
+ import { defineComponent, openBlock, createBlock, unref, mergeProps, createSlots, withCtx, createTextVNode, toDisplayString } from "vue";
2
+ import Alert from "./alert.js";
3
+ import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
4
+ const _sfc_main = /* @__PURE__ */ defineComponent({
5
+ __name: "sonner-alert",
6
+ props: {
7
+ title: {},
8
+ description: {},
9
+ onDismiss: {}
10
+ },
11
+ setup(__props) {
12
+ const props = __props;
13
+ function handleDismiss() {
14
+ if (props.onDismiss) {
15
+ props.onDismiss();
16
+ }
17
+ }
18
+ return (_ctx, _cache) => {
19
+ return openBlock(), createBlock(unref(Alert), mergeProps(props, {
20
+ class: "sonner-alert",
21
+ onDismiss: handleDismiss
22
+ }), createSlots({
23
+ title: withCtx(() => [
24
+ createTextVNode(toDisplayString(props.title), 1)
25
+ ]),
26
+ _: 2
27
+ }, [
28
+ props.description ? {
29
+ name: "description",
30
+ fn: withCtx(() => [
31
+ createTextVNode(toDisplayString(props.description), 1)
32
+ ]),
33
+ key: "0"
34
+ } : void 0
35
+ ]), 1040);
36
+ };
37
+ }
38
+ });
39
+ const sonnerAlert = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-c8bb23e0"]]);
40
+ export {
41
+ sonnerAlert as default
42
+ };
@@ -0,0 +1,4 @@
1
+ import { _ as _sfc_main } from "./chunks/sonner.js";
2
+ export {
3
+ _sfc_main as default
4
+ };
@@ -1,7 +1,7 @@
1
1
  import { defineComponent, openBlock, createBlock, unref, mergeProps, withCtx, renderSlot } from "vue";
2
2
  import { useDelegatedProps } from "./use-delegated-props.js";
3
3
  import { c as clsx } from "./chunks/clsx.js";
4
- import { r as bg } from "./chunks/index.js";
4
+ import { L as bg } from "./chunks/index.js";
5
5
  import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
6
6
  const _sfc_main = /* @__PURE__ */ defineComponent({
7
7
  __name: "tab-menu-content",
@@ -1,7 +1,7 @@
1
1
  import { defineComponent, openBlock, createBlock, unref, mergeProps, withCtx, renderSlot, createElementBlock, createCommentVNode } from "vue";
2
2
  import { useDelegatedProps } from "./use-delegated-props.js";
3
3
  import { c as clsx } from "./chunks/clsx.js";
4
- import { A as At, p as Cg } from "./chunks/index.js";
4
+ import { A as At, J as Cg } from "./chunks/index.js";
5
5
  import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
6
6
  const _hoisted_1 = {
7
7
  key: 0,
@@ -1,7 +1,7 @@
1
1
  import { defineComponent, openBlock, createBlock, unref, mergeProps, withCtx, renderSlot } from "vue";
2
2
  import { useDelegatedProps } from "./use-delegated-props.js";
3
3
  import { c as clsx } from "./chunks/clsx.js";
4
- import { l as gg } from "./chunks/index.js";
4
+ import { I as gg } from "./chunks/index.js";
5
5
  import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
6
6
  const _sfc_main = /* @__PURE__ */ defineComponent({
7
7
  __name: "tab-menu-list",
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, openBlock, createBlock, unref, mergeProps, withCtx, renderSlot } from "vue";
2
- import { x as xe, g as yg } from "./chunks/index.js";
2
+ import { x as xe, H as yg } from "./chunks/index.js";
3
3
  import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
4
4
  const _sfc_main = /* @__PURE__ */ defineComponent({
5
5
  __name: "tab-menu",
@@ -22,7 +22,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
22
22
  };
23
23
  }
24
24
  });
25
- const textInputAffix = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-2d8a1dbc"]]);
25
+ const TextInputAffix = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-2d8a1dbc"]]);
26
26
  export {
27
- textInputAffix as default
27
+ TextInputAffix as default
28
28
  };
@@ -1,7 +1,7 @@
1
1
  import { defineComponent, ref, openBlock, createBlock, unref, withCtx, createVNode, mergeProps, renderSlot, createElementBlock, normalizeClass, createCommentVNode, createElementVNode, toDisplayString } from "vue";
2
2
  import CompactButton from "./compact-button.js";
3
3
  import { c as clsx } from "./chunks/clsx.js";
4
- import { x as xe, ak as Lg, al as zg, am as Kg, an as jg, ao as Hg, ap as Wg } from "./chunks/index.js";
4
+ import { x as xe, at as Lg, au as zg, av as Kg, aw as jg, ax as Hg, ay as Wg } from "./chunks/index.js";
5
5
  import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
6
6
  const _hoisted_1 = { class: "celeste-tooltip-content-box" };
7
7
  const _hoisted_2 = {
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,3 @@
1
+ export * from './color';
2
+ export * from './crypto';
3
+ export * from './sonner';
@@ -0,0 +1,19 @@
1
+ import { SonnerAlertProps } from '../components/sonner/sonner-alert';
2
+ import { ExternalToast } from 'vue-sonner';
3
+ export interface ToastOptions extends ExternalToast {
4
+ state?: SonnerAlertProps['state'];
5
+ variant?: SonnerAlertProps['variant'];
6
+ size?: SonnerAlertProps['size'];
7
+ dismissable?: SonnerAlertProps['dismissable'];
8
+ }
9
+ declare function createToast(title: string, data?: ToastOptions): string | number;
10
+ export declare const toast: typeof createToast & {
11
+ success: (title: string, data?: Omit<ToastOptions, "state">) => string | number;
12
+ error: (title: string, data?: Omit<ToastOptions, "state">) => string | number;
13
+ warning: (title: string, data?: Omit<ToastOptions, "state">) => string | number;
14
+ info: (title: string, data?: Omit<ToastOptions, "state">) => string | number;
15
+ feature: (title: string, data?: Omit<ToastOptions, "state">) => string | number;
16
+ dismiss: (id?: string | number) => void;
17
+ loading: (title: string, data?: ExternalToast) => string | number;
18
+ };
19
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@youcan/celeste",
3
3
  "type": "module",
4
- "version": "0.6.30",
4
+ "version": "0.6.31",
5
5
  "author": "YouCan <tech@youcan.shop>",
6
6
  "keywords": [
7
7
  "youcan",
@@ -29,11 +29,22 @@
29
29
  "vue": "^3.5.13"
30
30
  },
31
31
  "dependencies": {
32
+ "@tiptap/core": "^3.0.7",
33
+ "@tiptap/extension-bubble-menu": "^3.0.7",
34
+ "@tiptap/extension-color": "^3.0.7",
35
+ "@tiptap/extension-link": "^3.0.7",
36
+ "@tiptap/extension-text-align": "^3.0.7",
37
+ "@tiptap/extension-text-style": "^3.0.7",
38
+ "@tiptap/extensions": "^3.0.7",
39
+ "@tiptap/pm": "^3.0.7",
40
+ "@tiptap/starter-kit": "^3.0.7",
41
+ "@tiptap/vue-3": "^3.0.7",
32
42
  "clsx": "^2.1.1",
33
43
  "radix-vue": "^1.9.12",
34
44
  "tinycolor2": "^1.6.0",
35
- "@youcan/celeste-icons": "0.6.30",
36
- "@youcan/celeste-tokens": "0.6.30"
45
+ "vue-sonner": "^2.0.2",
46
+ "@youcan/celeste-icons": "0.6.31",
47
+ "@youcan/celeste-tokens": "0.6.31"
37
48
  },
38
49
  "devDependencies": {
39
50
  "@chromatic-com/storybook": "^4.0.0",
@@ -59,7 +70,7 @@
59
70
  "rimraf": "^6.0.1",
60
71
  "sass": "^1.83.1",
61
72
  "storybook": "^9.0.17",
62
- "unocss": "^0.65.4",
73
+ "unocss": "^66.3.3",
63
74
  "vite": "^6.0.7",
64
75
  "vite-plugin-dts": "^4.4.0",
65
76
  "vitest": "^2.1.8",
@@ -10,10 +10,12 @@ export * from './hint-text';
10
10
  export * from './label';
11
11
  export * from './modal';
12
12
  export * from './popover';
13
+ export * from './rich-editor';
13
14
  export * from './scroll-area';
14
15
  export * from './segmented-control';
15
16
  export * from './select';
16
17
  export * from './slider';
18
+ export * from './sonner';
17
19
  export * from './switch';
18
20
  export * from './tab-menu';
19
21
  export * from './text-input';
@@ -0,0 +1,150 @@
1
+ import type { Editor } from '@tiptap/vue-3';
2
+ import type { ToolbarChildOption, ToolbarItem } from './types';
3
+ import { ref } from 'vue';
4
+ // @unocss-include
5
+
6
+ export const fullToolbar = ref<ToolbarItem[]>([
7
+ {
8
+ slug: 'heading',
9
+ name: 'Text styles',
10
+ children: [
11
+ { option: 'p', name: 'Normal text', active: 'paragraph' },
12
+ { option: '1', name: 'Heading 1', active: { level: 1 } },
13
+ { option: '2', name: 'Heading 2', active: { level: 2 } },
14
+ { option: '3', name: 'Heading 3', active: { level: 3 } },
15
+ { option: '4', name: 'Heading 4', active: { level: 4 } },
16
+ { option: '5', name: 'Heading 5', active: { level: 5 } },
17
+ { option: '6', name: 'Heading 6', active: { level: 6 } },
18
+ ],
19
+ },
20
+ { type: 'divider' },
21
+ {
22
+ slug: 'fontSize',
23
+ name: 'Font size',
24
+ children: [
25
+ { option: '8px', name: '8', active: { fontSize: '8px' } },
26
+ { option: '10px', name: '10', active: { fontSize: '10px' } },
27
+ { option: '12px', name: '12', active: { fontSize: '12px' } },
28
+ { option: '14px', name: '14', active: { fontSize: '14px' } },
29
+ { option: '16px', name: '16', active: { fontSize: '16px' } },
30
+ { option: '18px', name: '18', active: { fontSize: '18px' } },
31
+ { option: '24px', name: '24', active: { fontSize: '24px' } },
32
+ { option: '30px', name: '30', active: { fontSize: '30px' } },
33
+ { option: '36px', name: '36', active: { fontSize: '36px' } },
34
+ { option: '48px', name: '48', active: { fontSize: '48px' } },
35
+ { option: '60px', name: '60', active: { fontSize: '60px' } },
36
+ { option: '72px', name: '72', active: { fontSize: '72px' } },
37
+ { option: '96px', name: '96', active: { fontSize: '96px' } },
38
+ ],
39
+ },
40
+ { type: 'divider' },
41
+ {
42
+ slug: 'color',
43
+ name: 'Text color',
44
+ children: [
45
+ { option: '#000000', name: 'Black', icon: 'i-celeste-circle-fill', active: { color: '#000000' } },
46
+ { option: '#7B7B7B', name: 'Gray', icon: 'i-celeste-circle-fill', active: { color: '#7B7B7B' } },
47
+ { option: '#335CFF', name: 'Blue', icon: 'i-celeste-circle-fill', active: { color: '#335CFF' } },
48
+ { option: '#FA7319', name: 'Orange', icon: 'i-celeste-circle-fill', active: { color: '#FA7319' } },
49
+ { option: '#7D52F4', name: 'Purple', icon: 'i-celeste-circle-fill', active: { color: '#7D52F4' } },
50
+ { option: '#47C2FF', name: 'Sky', icon: 'i-celeste-circle-fill', active: { color: '#47C2FF' } },
51
+ ],
52
+ },
53
+ { type: 'divider' },
54
+ { slug: 'bold', name: 'Bold', icon: 'i-celeste-bold', active: 'bold' },
55
+ { slug: 'italic', name: 'Italic', icon: 'i-celeste-italic', active: 'italic' },
56
+ { slug: 'underline', name: 'Underline', icon: 'i-celeste-underline', active: 'underline' },
57
+ { slug: 'strike', name: 'Strike', icon: 'i-celeste-strikethrough', active: 'strike' },
58
+ { type: 'divider' },
59
+ { slug: 'bulletList', name: 'Bulleted list', icon: 'i-celeste-list-unordered', active: 'bulletList' },
60
+ { slug: 'orderedList', name: 'Numbered list', icon: 'i-celeste-list-ordered', active: 'orderedList' },
61
+ { type: 'divider' },
62
+ {
63
+ slug: 'align',
64
+ name: 'Text alignment',
65
+ children: [
66
+ { option: 'left', name: 'Left align', icon: 'i-celeste-align-left', active: { textAlign: 'left' } },
67
+ { option: 'center', name: 'Center align', icon: 'i-celeste-align-center', active: { textAlign: 'center' } },
68
+ { option: 'right', name: 'Right align', icon: 'i-celeste-align-right', active: { textAlign: 'right' } },
69
+ { option: 'justify', name: 'Justify', icon: 'i-celeste-align-justify', active: { textAlign: 'justify' } },
70
+ ],
71
+ },
72
+ { type: 'divider' },
73
+ { slug: 'link', name: 'Insert Link', icon: 'i-celeste-link', active: 'link' },
74
+ { type: 'divider' },
75
+ { slug: 'undo', name: 'Undo', icon: 'i-celeste-arrow-go-back-line', active: 'undo' },
76
+ { slug: 'redo', name: 'Redo', icon: 'i-celeste-arrow-go-forward-line', active: 'redo' },
77
+ { slug: 'clear', name: 'Clear style', icon: 'i-celeste-format-clear', active: 'clear' },
78
+ ]);
79
+
80
+ export function onActionClick(
81
+ editor: Editor,
82
+ slug: string,
83
+ option: string | null = null,
84
+ showLinkBubble?: () => void,
85
+ ): void {
86
+ const chain = editor.chain().focus();
87
+
88
+ if (!chain) {
89
+ return;
90
+ }
91
+
92
+ const actionTriggers: Record<string, () => void> = {
93
+ heading: () => {
94
+ if (!option) {
95
+ return;
96
+ }
97
+
98
+ if (option === 'p') {
99
+ chain.setParagraph().run();
100
+ }
101
+ else {
102
+ const headingLevel = Number(option);
103
+ chain.toggleHeading({ level: headingLevel as 1 | 2 | 3 | 4 | 5 | 6 }).run();
104
+ }
105
+ },
106
+ fontSize: () => {
107
+ editor.chain().focus().setFontSize(option ?? '16px').run();
108
+ },
109
+ color: () => {
110
+ editor.chain().focus().setColor(option ?? '#000000').run();
111
+ },
112
+ bold: () => chain.toggleBold().run(),
113
+ italic: () => chain.toggleItalic().run(),
114
+ underline: () => chain.toggleUnderline().run(),
115
+ strike: () => chain.toggleStrike().run(),
116
+ bulletList: () => chain.toggleBulletList().run(),
117
+ orderedList: () => chain.toggleOrderedList().run(),
118
+ align: () => chain.setTextAlign(option ?? 'left').run(),
119
+ link: () => {
120
+ if (showLinkBubble) {
121
+ showLinkBubble();
122
+ }
123
+ },
124
+ undo: () => chain.undo().run(),
125
+ redo: () => chain.redo().run(),
126
+ clear: () => chain.clearNodes().unsetAllMarks().run(),
127
+ };
128
+
129
+ actionTriggers[slug]?.();
130
+ }
131
+
132
+ export function selectedOption(editor: Editor, children: ToolbarChildOption[]): string {
133
+ if (!Array.isArray(children)) {
134
+ return '';
135
+ }
136
+
137
+ for (const child of children) {
138
+ if (Object.prototype.hasOwnProperty.call(child.active, 'fontSize')) {
139
+ const currentFontSize = editor.getAttributes('textStyle').fontSize || '16px';
140
+
141
+ return currentFontSize;
142
+ }
143
+
144
+ if (editor.isActive(child.active)) {
145
+ return child.option;
146
+ }
147
+ }
148
+
149
+ return children[0].option;
150
+ }
@@ -0,0 +1,151 @@
1
+ <script setup lang="ts">
2
+ import type { Editor } from '@tiptap/vue-3';
3
+ import CompactButton from '@/components/button/compact-button.vue';
4
+ import SelectContent from '@/components/select/select-content.vue';
5
+ import SelectIcon from '@/components/select/select-icon.vue';
6
+ import SelectItem from '@/components/select/select-item.vue';
7
+ import SelectTrigger from '@/components/select/select-trigger.vue';
8
+ import Select from '@/components/select/select.vue';
9
+ import Tooltip from '@/components/tooltip/tooltip.vue';
10
+ import { ref } from 'vue';
11
+
12
+ const props = defineProps<{
13
+ editor: Editor;
14
+ }>();
15
+
16
+ const defaultValue = ref('');
17
+ const extraSettings = [
18
+ {
19
+ name: 'Copy',
20
+ icon: 'i-celeste-file-copy-line',
21
+ },
22
+ {
23
+ name: 'Cut',
24
+ icon: 'i-celeste-scissors-line',
25
+ },
26
+ {
27
+ name: 'Delete',
28
+ icon: 'i-celeste-delete-bin-4-line',
29
+ },
30
+ {
31
+ name: 'Duplicate',
32
+ icon: 'i-celeste-add-circle-line',
33
+ },
34
+ ];
35
+
36
+ function selectedText(editor: Editor) {
37
+ const { from, to } = editor.state.selection;
38
+ const text = editor.state.doc.textBetween(from, to, '\n');
39
+
40
+ return text || null;
41
+ }
42
+
43
+ async function copySelectionToClipboard(editor: Editor) {
44
+ const text = selectedText(editor);
45
+
46
+ if (!text) {
47
+ return;
48
+ }
49
+
50
+ try {
51
+ if (!window.isSecureContext) {
52
+ throw new Error('Clipboard API is not available in insecure contexts');
53
+ }
54
+
55
+ const copyText = await navigator.clipboard.writeText(text);
56
+
57
+ return copyText;
58
+ }
59
+ catch (error) {
60
+ console.error(error);
61
+ }
62
+ }
63
+
64
+ async function cutSelection(editor: Editor) {
65
+ await copySelectionToClipboard(editor);
66
+ deleteSelection(editor);
67
+ }
68
+
69
+ function deleteSelection(editor: Editor) {
70
+ return editor.commands.deleteSelection();
71
+ }
72
+
73
+ function duplicateSelection(editor: Editor) {
74
+ const { to } = editor.state.selection;
75
+ const text = selectedText(editor);
76
+
77
+ if (!text) {
78
+ return;
79
+ }
80
+
81
+ return editor.commands.insertContentAt(to, text);
82
+ }
83
+
84
+ function clearSelectedValue() {
85
+ defaultValue.value = '';
86
+ }
87
+
88
+ function onActionClick(name: string, editor: Editor) {
89
+ switch (name) {
90
+ case 'Copy':
91
+ copySelectionToClipboard(editor);
92
+ break;
93
+ case 'Cut':
94
+ cutSelection(editor);
95
+ break;
96
+ case 'Delete':
97
+ deleteSelection(editor);
98
+ break;
99
+ case 'Duplicate':
100
+ duplicateSelection(editor);
101
+ break;
102
+ default:
103
+ break;
104
+ }
105
+ }
106
+ </script>
107
+
108
+ <template>
109
+ <div class="show-more-wrapper">
110
+ <Select
111
+ v-model="defaultValue"
112
+ @update:model-value="onActionClick($event, props.editor)"
113
+ @update:open="clearSelectedValue"
114
+ >
115
+ <SelectTrigger variant="inline">
116
+ <Tooltip title="Extra settings" variant="dark">
117
+ <CompactButton
118
+ icon="i-celeste-more-2-line"
119
+ variant="ghost"
120
+ />
121
+ </Tooltip>
122
+ </SelectTrigger>
123
+ <SelectContent align="end" width="fit">
124
+ <SelectItem
125
+ v-for="(item, index) in extraSettings"
126
+ :key="index"
127
+ :value="item.name"
128
+ >
129
+ <SelectIcon>
130
+ <i :class="item.icon" />
131
+ </SelectIcon>
132
+ <span>{{ item.name }}</span>
133
+ </SelectItem>
134
+ </SelectContent>
135
+ </Select>
136
+ </div>
137
+ </template>
138
+
139
+ <style scoped lang="scss">
140
+ .show-more-wrapper {
141
+ :deep(.i-celeste-arrow-down-s-line) {
142
+ display: none;
143
+ }
144
+ }
145
+
146
+ .celeste-select-item[data-state='checked'] {
147
+ &:deep(.i-celeste-check-line) {
148
+ display: none;
149
+ }
150
+ }
151
+ </style>
@@ -0,0 +1,2 @@
1
+ export * from './rich-editor.vue';
2
+ export { default as RichEditor } from './rich-editor.vue';