@youcan/celeste 0.6.30 → 0.6.32

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 (101) hide show
  1. package/dist/celeste.css +483 -264
  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 +1154 -0
  7. package/dist/cjs/config.js +136 -0
  8. package/dist/cjs/extra-settings.js +155 -0
  9. package/dist/cjs/index.js +75 -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 +1155 -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 +94 -19
  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/index.d.ts +1 -0
  84. package/dist/utils/index.d.ts +3 -0
  85. package/dist/utils/sonner.d.ts +19 -0
  86. package/package.json +15 -4
  87. package/src/components/index.ts +2 -0
  88. package/src/components/rich-editor/config.ts +150 -0
  89. package/src/components/rich-editor/extra-settings.vue +151 -0
  90. package/src/components/rich-editor/index.ts +2 -0
  91. package/src/components/rich-editor/link-bubble.vue +288 -0
  92. package/src/components/rich-editor/rich-editor.vue +428 -0
  93. package/src/components/rich-editor/stories/rich-editor.stories.ts +87 -0
  94. package/src/components/rich-editor/types.ts +21 -0
  95. package/src/components/sonner/index.ts +5 -0
  96. package/src/components/sonner/sonner-alert.vue +54 -0
  97. package/src/components/sonner/sonner.vue +13 -0
  98. package/src/components/sonner/stories/sonner.stories.ts +194 -0
  99. package/src/index.ts +1 -0
  100. package/src/utils/index.ts +3 -0
  101. package/src/utils/sonner.ts +72 -0
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, computed, openBlock, createBlock, unref, mergeProps, withCtx, createTextVNode, toDisplayString, createCommentVNode, renderSlot } from "vue";
2
2
  import { c as clsx } from "./chunks/clsx.js";
3
- import { D as qv, Y as Yv } from "./chunks/index.js";
3
+ import { T as qv, Y as Yv } 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: "combobox-group",
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, mergeModels, useModel, computed, openBlock, createBlock, unref, mergeProps, withCtx, createVNode, createElementVNode } from "vue";
2
2
  import { c as clsx } from "./chunks/clsx.js";
3
- import { E as Wv } from "./chunks/index.js";
3
+ import { U as Wv } from "./chunks/index.js";
4
4
  import TextInput from "./text-input.js";
5
5
  import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
6
6
  const _sfc_main = /* @__PURE__ */ defineComponent({
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, computed, openBlock, createBlock, unref, mergeProps, withCtx, createElementVNode, normalizeClass, createCommentVNode, createElementBlock, renderSlot, toDisplayString } from "vue";
2
2
  import { c as clsx } from "./chunks/clsx.js";
3
- import { x as xe, H as Qv } from "./chunks/index.js";
3
+ import { x as xe, X as Qv } from "./chunks/index.js";
4
4
  import { _ as _sfc_main$1 } from "./chunks/checkbox.vue_vue_type_style_index_0_lang.js";
5
5
  import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
6
6
  const _hoisted_1 = ["aria-disabled"];
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, computed, openBlock, createBlock, unref, withCtx, createVNode, mergeProps, renderSlot } from "vue";
2
2
  import { c as clsx } from "./chunks/clsx.js";
3
- import { x as xe, I as nm, X as Xv, J as Jv } from "./chunks/index.js";
3
+ import { x as xe, _ as nm, $ as Xv, a0 as Jv } 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: "combobox-list",
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, openBlock, createBlock, unref, mergeProps, withCtx, renderSlot } from "vue";
2
- import { x as xe, L as Hv } from "./chunks/index.js";
2
+ import { x as xe, a1 as Hv } 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: "combobox-root",
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, computed, openBlock, createBlock, unref, mergeProps, withCtx, renderSlot } from "vue";
2
2
  import { c as clsx } from "./chunks/clsx.js";
3
- import { P as tm } from "./chunks/index.js";
3
+ import { a2 as tm } 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: "combobox-separator",
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, computed, openBlock, createBlock, unref, mergeProps, withCtx, renderSlot } from "vue";
2
2
  import { c as clsx } from "./chunks/clsx.js";
3
- import { A as At, U as Uv } from "./chunks/index.js";
3
+ import { A as At, a3 as Uv } 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: "combobox-trigger",
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, computed, openBlock, createBlock, unref, mergeProps, withCtx, createTextVNode, toDisplayString, createCommentVNode, renderSlot } from "vue";
2
- import { D as qv, Y as Yv } from "./chunks/index.js";
2
+ import { T as qv, Y as Yv } 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: "command-group",
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, computed, openBlock, createElementBlock, createElementVNode, createVNode, unref, mergeProps } from "vue";
2
2
  import { c as clsx } from "./chunks/clsx.js";
3
- import { A as At, E as Wv } from "./chunks/index.js";
3
+ import { A as At, U as Wv } from "./chunks/index.js";
4
4
  import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
5
5
  const _hoisted_1 = {
6
6
  class: "celeste-command-input",
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, computed, openBlock, createBlock, unref, mergeProps, withCtx, renderSlot } from "vue";
2
- import { x as xe, H as Qv } from "./chunks/index.js";
2
+ import { x as xe, X as Qv } from "./chunks/index.js";
3
3
  const _sfc_main = /* @__PURE__ */ defineComponent({
4
4
  __name: "command-item",
5
5
  props: {
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, computed, openBlock, createBlock, unref, mergeProps, withCtx, createElementVNode, renderSlot } from "vue";
2
- import { x as xe, X as Xv } from "./chunks/index.js";
2
+ import { x as xe, $ as Xv } from "./chunks/index.js";
3
3
  const _hoisted_1 = { role: "presentation" };
4
4
  const _sfc_main = /* @__PURE__ */ defineComponent({
5
5
  __name: "command-list",
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, computed, openBlock, createBlock, unref, mergeProps, withCtx, renderSlot } from "vue";
2
- import { x as xe, L as Hv } from "./chunks/index.js";
2
+ import { x as xe, a1 as Hv } from "./chunks/index.js";
3
3
  const _sfc_main = /* @__PURE__ */ defineComponent({
4
4
  __name: "command-root",
5
5
  props: {
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, computed, openBlock, createBlock, unref, mergeProps, withCtx, renderSlot } from "vue";
2
2
  import { c as clsx } from "./chunks/clsx.js";
3
- import { P as tm } from "./chunks/index.js";
3
+ import { a2 as tm } 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: "command-separator",
@@ -0,0 +1,136 @@
1
+ import { ref } from "vue";
2
+ const fullToolbar = ref([
3
+ {
4
+ slug: "heading",
5
+ name: "Text styles",
6
+ children: [
7
+ { option: "p", name: "Normal text", active: "paragraph" },
8
+ { option: "1", name: "Heading 1", active: { level: 1 } },
9
+ { option: "2", name: "Heading 2", active: { level: 2 } },
10
+ { option: "3", name: "Heading 3", active: { level: 3 } },
11
+ { option: "4", name: "Heading 4", active: { level: 4 } },
12
+ { option: "5", name: "Heading 5", active: { level: 5 } },
13
+ { option: "6", name: "Heading 6", active: { level: 6 } }
14
+ ]
15
+ },
16
+ { type: "divider" },
17
+ {
18
+ slug: "fontSize",
19
+ name: "Font size",
20
+ children: [
21
+ { option: "8px", name: "8", active: { fontSize: "8px" } },
22
+ { option: "10px", name: "10", active: { fontSize: "10px" } },
23
+ { option: "12px", name: "12", active: { fontSize: "12px" } },
24
+ { option: "14px", name: "14", active: { fontSize: "14px" } },
25
+ { option: "16px", name: "16", active: { fontSize: "16px" } },
26
+ { option: "18px", name: "18", active: { fontSize: "18px" } },
27
+ { option: "24px", name: "24", active: { fontSize: "24px" } },
28
+ { option: "30px", name: "30", active: { fontSize: "30px" } },
29
+ { option: "36px", name: "36", active: { fontSize: "36px" } },
30
+ { option: "48px", name: "48", active: { fontSize: "48px" } },
31
+ { option: "60px", name: "60", active: { fontSize: "60px" } },
32
+ { option: "72px", name: "72", active: { fontSize: "72px" } },
33
+ { option: "96px", name: "96", active: { fontSize: "96px" } }
34
+ ]
35
+ },
36
+ { type: "divider" },
37
+ {
38
+ slug: "color",
39
+ name: "Text color",
40
+ children: [
41
+ { option: "#000000", name: "Black", icon: "i-celeste-circle-fill", active: { color: "#000000" } },
42
+ { option: "#7B7B7B", name: "Gray", icon: "i-celeste-circle-fill", active: { color: "#7B7B7B" } },
43
+ { option: "#335CFF", name: "Blue", icon: "i-celeste-circle-fill", active: { color: "#335CFF" } },
44
+ { option: "#FA7319", name: "Orange", icon: "i-celeste-circle-fill", active: { color: "#FA7319" } },
45
+ { option: "#7D52F4", name: "Purple", icon: "i-celeste-circle-fill", active: { color: "#7D52F4" } },
46
+ { option: "#47C2FF", name: "Sky", icon: "i-celeste-circle-fill", active: { color: "#47C2FF" } }
47
+ ]
48
+ },
49
+ { type: "divider" },
50
+ { slug: "bold", name: "Bold", icon: "i-celeste-bold", active: "bold" },
51
+ { slug: "italic", name: "Italic", icon: "i-celeste-italic", active: "italic" },
52
+ { slug: "underline", name: "Underline", icon: "i-celeste-underline", active: "underline" },
53
+ { slug: "strike", name: "Strike", icon: "i-celeste-strikethrough", active: "strike" },
54
+ { type: "divider" },
55
+ { slug: "bulletList", name: "Bulleted list", icon: "i-celeste-list-unordered", active: "bulletList" },
56
+ { slug: "orderedList", name: "Numbered list", icon: "i-celeste-list-ordered", active: "orderedList" },
57
+ { type: "divider" },
58
+ {
59
+ slug: "align",
60
+ name: "Text alignment",
61
+ children: [
62
+ { option: "left", name: "Left align", icon: "i-celeste-align-left", active: { textAlign: "left" } },
63
+ { option: "center", name: "Center align", icon: "i-celeste-align-center", active: { textAlign: "center" } },
64
+ { option: "right", name: "Right align", icon: "i-celeste-align-right", active: { textAlign: "right" } },
65
+ { option: "justify", name: "Justify", icon: "i-celeste-align-justify", active: { textAlign: "justify" } }
66
+ ]
67
+ },
68
+ { type: "divider" },
69
+ { slug: "link", name: "Insert Link", icon: "i-celeste-link", active: "link" },
70
+ { type: "divider" },
71
+ { slug: "undo", name: "Undo", icon: "i-celeste-arrow-go-back-line", active: "undo" },
72
+ { slug: "redo", name: "Redo", icon: "i-celeste-arrow-go-forward-line", active: "redo" },
73
+ { slug: "clear", name: "Clear style", icon: "i-celeste-format-clear", active: "clear" }
74
+ ]);
75
+ function onActionClick(editor, slug, option = null, showLinkBubble) {
76
+ var _a;
77
+ const chain = editor.chain().focus();
78
+ if (!chain) {
79
+ return;
80
+ }
81
+ const actionTriggers = {
82
+ heading: () => {
83
+ if (!option) {
84
+ return;
85
+ }
86
+ if (option === "p") {
87
+ chain.setParagraph().run();
88
+ } else {
89
+ const headingLevel = Number(option);
90
+ chain.toggleHeading({ level: headingLevel }).run();
91
+ }
92
+ },
93
+ fontSize: () => {
94
+ editor.chain().focus().setFontSize(option ?? "16px").run();
95
+ },
96
+ color: () => {
97
+ editor.chain().focus().setColor(option ?? "#000000").run();
98
+ },
99
+ bold: () => chain.toggleBold().run(),
100
+ italic: () => chain.toggleItalic().run(),
101
+ underline: () => chain.toggleUnderline().run(),
102
+ strike: () => chain.toggleStrike().run(),
103
+ bulletList: () => chain.toggleBulletList().run(),
104
+ orderedList: () => chain.toggleOrderedList().run(),
105
+ align: () => chain.setTextAlign(option ?? "left").run(),
106
+ link: () => {
107
+ if (showLinkBubble) {
108
+ showLinkBubble();
109
+ }
110
+ },
111
+ undo: () => chain.undo().run(),
112
+ redo: () => chain.redo().run(),
113
+ clear: () => chain.clearNodes().unsetAllMarks().run()
114
+ };
115
+ (_a = actionTriggers[slug]) == null ? void 0 : _a.call(actionTriggers);
116
+ }
117
+ function selectedOption(editor, children) {
118
+ if (!Array.isArray(children)) {
119
+ return "";
120
+ }
121
+ for (const child of children) {
122
+ if (Object.prototype.hasOwnProperty.call(child.active, "fontSize")) {
123
+ const currentFontSize = editor.getAttributes("textStyle").fontSize || "16px";
124
+ return currentFontSize;
125
+ }
126
+ if (editor.isActive(child.active)) {
127
+ return child.option;
128
+ }
129
+ }
130
+ return children[0].option;
131
+ }
132
+ export {
133
+ fullToolbar,
134
+ onActionClick,
135
+ selectedOption
136
+ };
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, openBlock, createBlock, unref, mergeProps, withCtx, renderSlot } from "vue";
2
- import { R as fh } from "./chunks/index.js";
2
+ import { a4 as fh } 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: "dropdown-menu-group",
@@ -1,7 +1,7 @@
1
1
  import { defineComponent, openBlock, createBlock, unref, mergeProps, withCtx, createElementVNode, renderSlot, toDisplayString, 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, S as ch } from "./chunks/index.js";
4
+ import { A as At, a5 as ch } from "./chunks/index.js";
5
5
  import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
6
6
  const _hoisted_1 = { class: "celeste-dropdown-menu-item-prefix" };
7
7
  const _hoisted_2 = { class: "celeste-dropdown-menu-item-body" };
@@ -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 { A as At, T as hh } from "./chunks/index.js";
4
+ import { A as At, a6 as hh } 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: "dropdown-menu-label",
@@ -1,7 +1,7 @@
1
1
  import { defineComponent, openBlock, createBlock, unref, mergeProps } from "vue";
2
2
  import { useDelegatedProps } from "./use-delegated-props.js";
3
3
  import { c as clsx } from "./chunks/clsx.js";
4
- import { _ as ph } from "./chunks/index.js";
4
+ import { a7 as ph } 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: "dropdown-menu-separator",
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, openBlock, createBlock, unref, mergeProps, withCtx, renderSlot } from "vue";
2
- import { A as At, $ as rh } from "./chunks/index.js";
2
+ import { A as At, a8 as rh } 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: "dropdown-menu-trigger",
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, ref, openBlock, createBlock, unref, mergeProps, withCtx, renderSlot } from "vue";
2
2
  import { useDelegatedProps } from "./use-delegated-props.js";
3
- import { a0 as sh } from "./chunks/index.js";
3
+ import { a9 as sh } 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: "dropdown-menu",
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, mergeModels, useModel, ref, computed, watch, openBlock, createElementBlock, withKeys, createVNode, unref, withCtx, normalizeClass, createElementVNode, createCommentVNode, renderSlot, normalizeProps, guardReactiveProps, toDisplayString, createBlock, createSlots, Fragment, renderList } from "vue";
2
2
  import { c as clsx } from "./chunks/clsx.js";
3
- import { L as Hv, j as jv, U as Uv, X as Xv, J as Jv, P as tm, Z as Zv, D as qv, H as Qv } from "./chunks/index.js";
3
+ import { a1 as Hv, j as jv, a3 as Uv, $ as Xv, a0 as Jv, a2 as tm, Z as Zv, T as qv, X as Qv } from "./chunks/index.js";
4
4
  import Badge from "./badge.js";
5
5
  import TextInput from "./text-input.js";
6
6
  import DropdownItem from "./dropdown-item.js";
@@ -0,0 +1,156 @@
1
+ import { defineComponent, ref, openBlock, createElementBlock, createVNode, withCtx, Fragment, renderList, createElementVNode, normalizeClass, toDisplayString } from "vue";
2
+ import CompactButton from "./compact-button.js";
3
+ import SelectContent from "./select-content.js";
4
+ import SelectIcon from "./select-icon.js";
5
+ import SelectItem from "./select-item.js";
6
+ import SelectTrigger from "./select-trigger.js";
7
+ import { _ as _sfc_main$1 } from "./chunks/select.js";
8
+ import Tooltip from "./tooltip.js";
9
+ import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
10
+ const _hoisted_1 = { class: "show-more-wrapper" };
11
+ const _sfc_main = /* @__PURE__ */ defineComponent({
12
+ __name: "extra-settings",
13
+ props: {
14
+ editor: {}
15
+ },
16
+ setup(__props) {
17
+ const props = __props;
18
+ const defaultValue = ref("");
19
+ const extraSettings = [
20
+ {
21
+ name: "Copy",
22
+ icon: "i-celeste-file-copy-line"
23
+ },
24
+ {
25
+ name: "Cut",
26
+ icon: "i-celeste-scissors-line"
27
+ },
28
+ {
29
+ name: "Delete",
30
+ icon: "i-celeste-delete-bin-4-line"
31
+ },
32
+ {
33
+ name: "Duplicate",
34
+ icon: "i-celeste-add-circle-line"
35
+ }
36
+ ];
37
+ function selectedText(editor) {
38
+ const { from, to } = editor.state.selection;
39
+ const text = editor.state.doc.textBetween(from, to, "\n");
40
+ return text || null;
41
+ }
42
+ async function copySelectionToClipboard(editor) {
43
+ const text = selectedText(editor);
44
+ if (!text) {
45
+ return;
46
+ }
47
+ try {
48
+ if (!window.isSecureContext) {
49
+ throw new Error("Clipboard API is not available in insecure contexts");
50
+ }
51
+ const copyText = await navigator.clipboard.writeText(text);
52
+ return copyText;
53
+ } catch (error) {
54
+ console.error(error);
55
+ }
56
+ }
57
+ async function cutSelection(editor) {
58
+ await copySelectionToClipboard(editor);
59
+ deleteSelection(editor);
60
+ }
61
+ function deleteSelection(editor) {
62
+ return editor.commands.deleteSelection();
63
+ }
64
+ function duplicateSelection(editor) {
65
+ const { to } = editor.state.selection;
66
+ const text = selectedText(editor);
67
+ if (!text) {
68
+ return;
69
+ }
70
+ return editor.commands.insertContentAt(to, text);
71
+ }
72
+ function clearSelectedValue() {
73
+ defaultValue.value = "";
74
+ }
75
+ function onActionClick(name, editor) {
76
+ switch (name) {
77
+ case "Copy":
78
+ copySelectionToClipboard(editor);
79
+ break;
80
+ case "Cut":
81
+ cutSelection(editor);
82
+ break;
83
+ case "Delete":
84
+ deleteSelection(editor);
85
+ break;
86
+ case "Duplicate":
87
+ duplicateSelection(editor);
88
+ break;
89
+ }
90
+ }
91
+ return (_ctx, _cache) => {
92
+ return openBlock(), createElementBlock("div", _hoisted_1, [
93
+ createVNode(_sfc_main$1, {
94
+ modelValue: defaultValue.value,
95
+ "onUpdate:modelValue": [
96
+ _cache[0] || (_cache[0] = ($event) => defaultValue.value = $event),
97
+ _cache[1] || (_cache[1] = ($event) => onActionClick($event, props.editor))
98
+ ],
99
+ "onUpdate:open": clearSelectedValue
100
+ }, {
101
+ default: withCtx(() => [
102
+ createVNode(SelectTrigger, { variant: "inline" }, {
103
+ default: withCtx(() => [
104
+ createVNode(Tooltip, {
105
+ title: "Extra settings",
106
+ variant: "dark"
107
+ }, {
108
+ default: withCtx(() => [
109
+ createVNode(CompactButton, {
110
+ icon: "i-celeste-more-2-line",
111
+ variant: "ghost"
112
+ })
113
+ ]),
114
+ _: 1
115
+ })
116
+ ]),
117
+ _: 1
118
+ }),
119
+ createVNode(SelectContent, {
120
+ align: "end",
121
+ width: "fit"
122
+ }, {
123
+ default: withCtx(() => [
124
+ (openBlock(), createElementBlock(Fragment, null, renderList(extraSettings, (item, index) => {
125
+ return createVNode(SelectItem, {
126
+ key: index,
127
+ value: item.name
128
+ }, {
129
+ default: withCtx(() => [
130
+ createVNode(SelectIcon, null, {
131
+ default: withCtx(() => [
132
+ createElementVNode("i", {
133
+ class: normalizeClass(item.icon)
134
+ }, null, 2)
135
+ ]),
136
+ _: 2
137
+ }, 1024),
138
+ createElementVNode("span", null, toDisplayString(item.name), 1)
139
+ ]),
140
+ _: 2
141
+ }, 1032, ["value"]);
142
+ }), 64))
143
+ ]),
144
+ _: 1
145
+ })
146
+ ]),
147
+ _: 1
148
+ }, 8, ["modelValue"])
149
+ ]);
150
+ };
151
+ }
152
+ });
153
+ const ExtraSettings = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-49d51443"]]);
154
+ export {
155
+ ExtraSettings as default
156
+ };