@bridge-ui/vue 0.15.0 → 0.17.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/ai/AGENTS.md +1 -1
- package/ai/README.md +1 -1
- package/ai/llms.txt +0 -1
- package/ai/skills/bridge-ui-components/SKILL.md +3 -1
- package/ai/skills/bridge-ui-setup/SKILL.md +8 -8
- package/dist/Actions/Snackbar/BridgeSnackbarItem.vue_vue_type_script_setup_true_lang.js +42 -44
- package/dist/Actions/actionHostRegistry.d.ts +2 -1
- package/dist/Actions/actionHostRegistry.js +11 -7
- package/dist/Adapters/index.d.ts +0 -1
- package/dist/Adapters/index.js +1 -2
- package/dist/Components/Accordion/composables/useAccordion.js +1 -1
- package/dist/Components/Autocomplete/composables/useAutocomplete.js +248 -258
- package/dist/Components/Chart/Chart.js +5 -0
- package/dist/Components/Chart/Chart.vue.d.ts +14 -0
- package/dist/Components/Chart/Chart.vue_vue_type_script_setup_true_lang.js +52 -0
- package/dist/Components/Chart/chart.types.d.ts +126 -0
- package/dist/Components/Chart/chartInjectionKey.d.ts +94 -0
- package/dist/Components/Chart/chartInjectionKey.js +10 -0
- package/dist/Components/Chart/composables/useChart.d.ts +40 -0
- package/dist/Components/Chart/composables/useChart.js +344 -0
- package/dist/Components/Chart/echartsChart.d.ts +14 -0
- package/dist/Components/Chart/echartsChart.js +199 -0
- package/dist/Components/Chart/index.d.ts +4 -0
- package/dist/Components/Chart/index.js +4 -0
- package/dist/Components/ChartAxis/ChartAxis.js +5 -0
- package/dist/Components/ChartAxis/ChartAxis.vue.d.ts +7 -0
- package/dist/Components/ChartAxis/ChartAxis.vue_vue_type_script_setup_true_lang.js +30 -0
- package/dist/Components/ChartAxis/chartAxis.types.d.ts +56 -0
- package/dist/Components/ChartAxis/composables/useChartAxis.d.ts +5 -0
- package/dist/Components/ChartAxis/composables/useChartAxis.js +28 -0
- package/dist/Components/ChartAxis/index.d.ts +3 -0
- package/dist/Components/ChartAxis/index.js +3 -0
- package/dist/Components/ChartLegend/ChartLegend.js +5 -0
- package/dist/Components/ChartLegend/ChartLegend.vue.d.ts +6 -0
- package/dist/Components/ChartLegend/ChartLegend.vue_vue_type_script_setup_true_lang.js +33 -0
- package/dist/Components/ChartLegend/chartLegend.types.d.ts +71 -0
- package/dist/Components/ChartLegend/composables/useChartLegend.d.ts +16 -0
- package/dist/Components/ChartLegend/composables/useChartLegend.js +98 -0
- package/dist/Components/ChartLegend/index.d.ts +3 -0
- package/dist/Components/ChartLegend/index.js +3 -0
- package/dist/Components/ChartSeries/ChartSeries.js +5 -0
- package/dist/Components/ChartSeries/ChartSeries.vue.d.ts +4 -0
- package/dist/Components/ChartSeries/ChartSeries.vue_vue_type_script_setup_true_lang.js +24 -0
- package/dist/Components/ChartSeries/chartSeries.types.d.ts +37 -0
- package/dist/Components/ChartSeries/composables/useChartSeries.d.ts +10 -0
- package/dist/Components/ChartSeries/composables/useChartSeries.js +29 -0
- package/dist/Components/ChartSeries/index.d.ts +3 -0
- package/dist/Components/ChartSeries/index.js +3 -0
- package/dist/Components/ChartTooltip/ChartTooltip.js +5 -0
- package/dist/Components/ChartTooltip/ChartTooltip.vue.d.ts +11 -0
- package/dist/Components/ChartTooltip/ChartTooltip.vue_vue_type_script_setup_true_lang.js +25 -0
- package/dist/Components/ChartTooltip/chartTooltip.types.d.ts +82 -0
- package/dist/Components/ChartTooltip/composables/useChartTooltip.d.ts +15 -0
- package/dist/Components/ChartTooltip/composables/useChartTooltip.js +110 -0
- package/dist/Components/ChartTooltip/index.d.ts +3 -0
- package/dist/Components/ChartTooltip/index.js +3 -0
- package/dist/Components/DataTable/DataTable.vue.d.ts +5 -3
- package/dist/Components/DataTable/DataTable.vue_vue_type_script_setup_true_lang.js +138 -117
- package/dist/Components/DataTable/DataTableCellContent.vue.d.ts +1 -5
- package/dist/Components/DataTable/DataTableCellContent.vue_vue_type_script_setup_true_lang.js +24 -25
- package/dist/Components/DataTable/composables/useDataTable.d.ts +5 -3
- package/dist/Components/DataTable/composables/useDataTable.js +294 -272
- package/dist/Components/DataTable/composables/useDataTablePagination.js +1 -1
- package/dist/Components/DataTable/dataTable.types.d.ts +35 -2
- package/dist/Components/Drawer/composables/useDrawer.js +68 -67
- package/dist/Components/Modal/composables/useModal.js +129 -119
- package/dist/Components/Pagination/Pagination.vue.d.ts +6 -0
- package/dist/Components/Pagination/Pagination.vue_vue_type_script_setup_true_lang.js +23 -11
- package/dist/Components/Pagination/composables/usePagination.d.ts +3 -3
- package/dist/Components/Pagination/composables/usePagination.js +95 -84
- package/dist/Components/Pagination/pagination.types.d.ts +30 -2
- package/dist/Components/Resizable/Resizable.js +5 -0
- package/dist/Components/Resizable/Resizable.vue.d.ts +17 -0
- package/dist/Components/Resizable/Resizable.vue_vue_type_script_setup_true_lang.js +30 -0
- package/dist/Components/Resizable/composables/useResizable.d.ts +18 -0
- package/dist/Components/Resizable/composables/useResizable.js +195 -0
- package/dist/Components/Resizable/index.d.ts +4 -0
- package/dist/Components/Resizable/index.js +4 -0
- package/dist/Components/Resizable/resizable.types.d.ts +53 -0
- package/dist/Components/Resizable/resizableInjectionKey.d.ts +111 -0
- package/dist/Components/Resizable/resizableInjectionKey.js +4 -0
- package/dist/Components/ResizableHandle/ResizableHandle.js +5 -0
- package/dist/Components/ResizableHandle/ResizableHandle.vue.d.ts +14 -0
- package/dist/Components/ResizableHandle/ResizableHandle.vue_vue_type_script_setup_true_lang.js +31 -0
- package/dist/Components/ResizableHandle/composables/useResizableHandle.d.ts +35 -0
- package/dist/Components/ResizableHandle/composables/useResizableHandle.js +85 -0
- package/dist/Components/ResizableHandle/index.d.ts +3 -0
- package/dist/Components/ResizableHandle/index.js +3 -0
- package/dist/Components/ResizableHandle/resizableHandle.types.d.ts +58 -0
- package/dist/Components/ResizablePanel/ResizablePanel.js +5 -0
- package/dist/Components/ResizablePanel/ResizablePanel.vue.d.ts +24 -0
- package/dist/Components/ResizablePanel/ResizablePanel.vue_vue_type_script_setup_true_lang.js +39 -0
- package/dist/Components/ResizablePanel/composables/useResizablePanel.d.ts +21 -0
- package/dist/Components/ResizablePanel/composables/useResizablePanel.js +87 -0
- package/dist/Components/ResizablePanel/index.d.ts +3 -0
- package/dist/Components/ResizablePanel/index.js +3 -0
- package/dist/Components/ResizablePanel/resizablePanel.types.d.ts +71 -0
- package/dist/Components/RichTextEditor/RichTextEditor.vue.d.ts +1 -1
- package/dist/Components/RichTextEditor/RichTextEditor.vue_vue_type_script_setup_true_lang.js +17 -17
- package/dist/Components/RichTextEditor/composables/useRichTextEditor.d.ts +2 -2
- package/dist/Components/RichTextEditor/composables/useRichTextEditor.js +67 -73
- package/dist/Components/RichTextEditor/richTextEditor.types.d.ts +1 -1
- package/dist/Components/RichTextEditor/tiptapEditor.d.ts +111 -0
- package/dist/Components/RichTextEditor/tiptapEditor.js +121 -0
- package/dist/Components/Select/composables/useSelect.js +147 -157
- package/dist/Components/Snackbar/Snackbar.vue.d.ts +1 -1
- package/dist/Components/Snackbar/Snackbar.vue_vue_type_script_setup_true_lang.js +6 -7
- package/dist/Components/Snackbar/composables/useSnackbar.js +140 -146
- package/dist/Components/Stepper/composables/useStepper.js +1 -1
- package/dist/Components/Table/composables/useTableCell.d.ts +1 -1
- package/dist/Components/Tabs/composables/useTabs.js +1 -1
- package/dist/Components/ToggleGroup/composables/useToggleGroup.js +3 -3
- package/dist/augments.d.ts +34 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.js +187 -183
- package/dist/theme.css +1 -1
- package/docs/README.md +4 -3
- package/docs/components/BridgeUIProvider.md +0 -17
- package/docs/components/Chart.md +252 -0
- package/docs/components/DataTable.md +19 -0
- package/docs/components/Pagination.md +17 -5
- package/docs/components/Resizable.md +224 -0
- package/docs/components/RichTextEditor.md +2 -23
- package/package.json +27 -6
- package/dist/Adapters/RichText/index.d.ts +0 -1
- package/dist/Adapters/RichText/index.js +0 -2
- package/dist/Adapters/RichText/mockRichTextAdapter.d.ts +0 -5
- package/dist/Adapters/RichText/useRichTextAdapter.d.ts +0 -12
- package/dist/Adapters/RichText/useRichTextAdapter.js +0 -13
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RichTextValue } from '@bridge-ui/core/
|
|
1
|
+
import { RichTextValue } from '@bridge-ui/core/Domain';
|
|
2
2
|
import { RichTextEditorOwnProps, RichTextEditorSlots } from './richTextEditor.types';
|
|
3
3
|
type __VLS_Slots = RichTextEditorSlots;
|
|
4
4
|
type __VLS_Props = RichTextEditorOwnProps;
|
package/dist/Components/RichTextEditor/RichTextEditor.vue_vue_type_script_setup_true_lang.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { hasNamedSlot as e, presentSlotNames as t } from "../../Utils/slotOrProp.js";
|
|
2
2
|
import { useOptionalModel as n } from "../../Utils/useOptionalModel.js";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { FORM_FIELD_CHROME_SLOT_NAMES as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import c from "
|
|
3
|
+
import r from "../Button/Button.js";
|
|
4
|
+
import i from "../ActionFooter/ActionFooter.js";
|
|
5
|
+
import { FORM_FIELD_CHROME_SLOT_NAMES as a } from "../FormField/formField.types.js";
|
|
6
|
+
import o from "../FormField/FormField.js";
|
|
7
|
+
import s from "../Menu/Menu.js";
|
|
8
|
+
import ee from "../TextField/TextField.js";
|
|
9
|
+
import { useRichTextEditor as c } from "./composables/useRichTextEditor.js";
|
|
10
10
|
import { Fragment as l, createBlock as u, createCommentVNode as d, createElementBlock as f, createElementVNode as p, createSlots as m, createVNode as h, defineComponent as g, guardReactiveProps as _, isRef as v, mergeModels as y, mergeProps as b, normalizeProps as x, openBlock as S, ref as C, renderList as w, renderSlot as T, unref as E, useModel as D, useTemplateRef as O, withCtx as k, withModifiers as A } from "vue";
|
|
11
11
|
//#region src/Components/RichTextEditor/RichTextEditor.vue?vue&type=script&setup=true&lang.ts
|
|
12
12
|
var j = { class: "flex min-h-0 min-w-0 flex-1 flex-col" }, M = { class: "flex w-64 flex-col" }, N = { class: "p-1.5" }, P = { class: "flex items-center justify-end gap-2 border-t border-dark-100 bg-dark-50 px-3 py-2 dark:border-dark-800 dark:bg-dark-950/40" }, F = /*@__PURE__*/ g({
|
|
@@ -51,24 +51,24 @@ var j = { class: "flex min-h-0 min-w-0 flex-1 flex-col" }, M = { class: "flex w-
|
|
|
51
51
|
}),
|
|
52
52
|
emits: /*@__PURE__*/ y(["update:modelValue"], ["update:modelValue"]),
|
|
53
53
|
setup(g, { emit: y }) {
|
|
54
|
-
let F = D(g, "modelValue"), I = y, L = g, R = O("content"), z = C(L.defaultValue), B = n(F, z), { color: V, slots: H, tools: U, linkHref: W, linkOpen: G, formField: K, linkAnchor: q, contentBind: J, confirmLink: Y, onToolClick: X, toolbarBind: Z, showToolbar: Q, linkUrlLabel: $, canConfirmLink: te, closeLinkEditor: ne, getToolbarButtonBind: re } =
|
|
55
|
-
return (n,
|
|
56
|
-
default: k(() => [p("div", j, [E(Q) ? (S(), f(l, { key: 0 }, [E(e)(E(H), "toolbar") ? T(n.$slots, "toolbar", { tools: E(U) }, void 0, void 0, 0) : (S(), f("div", x(b({ key: 1 }, E(Z))), [(S(!0), f(l, null, w(E(U), (e) => (S(), u(E(
|
|
54
|
+
let F = D(g, "modelValue"), I = y, L = g, R = O("content"), z = C(L.defaultValue), B = n(F, z), { color: V, slots: H, tools: U, linkHref: W, linkOpen: G, formField: K, linkAnchor: q, contentBind: J, confirmLink: Y, onToolClick: X, toolbarBind: Z, showToolbar: Q, linkUrlLabel: $, canConfirmLink: te, closeLinkEditor: ne, getToolbarButtonBind: re } = c(L, B, I, R);
|
|
55
|
+
return (n, c) => (S(), u(E(o), { field: E(K) }, m({
|
|
56
|
+
default: k(() => [p("div", j, [E(Q) ? (S(), f(l, { key: 0 }, [E(e)(E(H), "toolbar") ? T(n.$slots, "toolbar", { tools: E(U) }, void 0, void 0, 0) : (S(), f("div", x(b({ key: 1 }, E(Z))), [(S(!0), f(l, null, w(E(U), (e) => (S(), u(E(r), b({
|
|
57
57
|
key: e,
|
|
58
|
-
onMousedown:
|
|
59
|
-
}, { ref_for: !0 }, E(re)(e), { onClick: (t) => E(X)(e, t) }), null, 16, ["onClick"]))), 128))], 16))], 64)) : d("", !0), p("div", b({ ref: "content" }, E(J)), null, 16)]), h(E(
|
|
58
|
+
onMousedown: c[0] ||= A(() => {}, ["prevent"])
|
|
59
|
+
}, { ref_for: !0 }, E(re)(e), { onClick: (t) => E(X)(e, t) }), null, 16, ["onClick"]))), 128))], 16))], 64)) : d("", !0), p("div", b({ ref: "content" }, E(J)), null, 16)]), h(E(s), {
|
|
60
60
|
modelValue: E(G),
|
|
61
|
-
"onUpdate:modelValue":
|
|
61
|
+
"onUpdate:modelValue": c[2] ||= (e) => v(G) ? G.value = e : null,
|
|
62
62
|
"anchor-el": E(q),
|
|
63
63
|
placement: "bottom-start"
|
|
64
64
|
}, {
|
|
65
|
-
default: k(() => [p("div", M, [p("div", N, [h(E(
|
|
65
|
+
default: k(() => [p("div", M, [p("div", N, [h(E(ee), {
|
|
66
66
|
size: "sm",
|
|
67
67
|
type: "url",
|
|
68
68
|
class: "w-full",
|
|
69
69
|
color: E(V),
|
|
70
70
|
modelValue: E(W),
|
|
71
|
-
"onUpdate:modelValue":
|
|
71
|
+
"onUpdate:modelValue": c[1] ||= (e) => v(W) ? W.value = e : null,
|
|
72
72
|
autocomplete: "off",
|
|
73
73
|
"hide-error-message": "",
|
|
74
74
|
"aria-label": E($),
|
|
@@ -78,7 +78,7 @@ var j = { class: "flex min-h-0 min-w-0 flex-1 flex-col" }, M = { class: "flex w-
|
|
|
78
78
|
"modelValue",
|
|
79
79
|
"aria-label",
|
|
80
80
|
"placeholder"
|
|
81
|
-
])]), p("div", P, [h(E(
|
|
81
|
+
])]), p("div", P, [h(E(i), {
|
|
82
82
|
color: E(V),
|
|
83
83
|
onApply: E(Y),
|
|
84
84
|
onCancel: E(ne),
|
|
@@ -98,7 +98,7 @@ var j = { class: "flex min-h-0 min-w-0 flex-1 flex-col" }, M = { class: "flex w-
|
|
|
98
98
|
_: 1
|
|
99
99
|
}, 8, ["modelValue", "anchor-el"])]),
|
|
100
100
|
_: 2
|
|
101
|
-
}, [w(E(t)(E(
|
|
101
|
+
}, [w(E(t)(E(a), n.$slots), (e) => ({
|
|
102
102
|
name: e,
|
|
103
103
|
fn: k((t) => [T(n.$slots, e, x(_(t || {})))])
|
|
104
104
|
}))]), 1032, ["field"]));
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Ref, SetupContext } from 'vue';
|
|
2
|
-
import { RichTextFormat, RichTextTool, RichTextValue } from '@bridge-ui/core/
|
|
2
|
+
import { RichTextFormat, RichTextTool, RichTextValue } from '@bridge-ui/core/Domain';
|
|
3
3
|
import { ButtonOwnProps } from '../../Button/button.types';
|
|
4
4
|
import { FormFieldOwnProps } from '../../FormField/formField.types';
|
|
5
5
|
import { RichTextEditorEmits, RichTextEditorOwnProps } from '../richTextEditor.types';
|
|
6
6
|
/**
|
|
7
|
-
* Composes FormField chrome
|
|
7
|
+
* Composes FormField chrome and the TipTap surface for Vue.
|
|
8
8
|
*/
|
|
9
9
|
export declare function useRichTextEditor(props: RichTextEditorOwnProps, model: Ref<undefined | RichTextValue>, emit: SetupContext<RichTextEditorEmits>["emit"], contentRef: Ref<null | undefined | HTMLDivElement>): {
|
|
10
10
|
color: import('vue').ComputedRef<NonNullable<keyof import('@bridge-ui/core/Tokens').FormFieldColor | undefined>>;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { useResolveMessage as e } from "../../../Adapters/I18n/useI18nAdapter.js";
|
|
2
|
-
import {
|
|
3
|
-
import { mergePartBind as n, useBridgeUIComponent as r, useBridgeUIMergedRegistryClasses as ee } from "../../../Utils/index.js";
|
|
2
|
+
import { mergePartBind as t, useBridgeUIComponent as n, useBridgeUIMergedRegistryClasses as r } from "../../../Utils/index.js";
|
|
4
3
|
import { formFieldBridgeKeys as i, useFormField as a } from "../../FormField/composables/useFormField.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { get as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
4
|
+
import { mountTiptapEditor as ee } from "../tiptapEditor.js";
|
|
5
|
+
import { computed as o, onBeforeUnmount as s, ref as c, useAttrs as l, useSlots as te, watch as u } from "vue";
|
|
6
|
+
import { get as d, isNil as f, omit as ne } from "es-toolkit/compat";
|
|
7
|
+
import { DEFAULT_RICH_TEXT_TOOLS as p, RICH_TEXT_TOOL_ICONS as m, RICH_TEXT_TOOL_LABELS as h, richTextValuesEqual as g } from "@bridge-ui/core/Domain";
|
|
8
|
+
import { richTextEditorSizeProps as _ } from "@bridge-ui/core/Tokens";
|
|
9
|
+
import { cn as v, mergeBridgeUILayeredClasses as y, splitComponentProps as b } from "@bridge-ui/core/Utils";
|
|
10
10
|
//#region src/Components/RichTextEditor/composables/useRichTextEditor.ts
|
|
11
|
-
var
|
|
11
|
+
var re = [
|
|
12
12
|
"tools",
|
|
13
13
|
"format",
|
|
14
14
|
"classes",
|
|
@@ -17,16 +17,16 @@ var y = [
|
|
|
17
17
|
"placeholder",
|
|
18
18
|
"defaultValue"
|
|
19
19
|
];
|
|
20
|
-
function
|
|
21
|
-
let
|
|
22
|
-
bridgeKeys:
|
|
20
|
+
function x(x, S, ie, C) {
|
|
21
|
+
let w = l(), T = te(), E = e(), D = c(""), O = c(0), k = c(null), A = c(null), j = c(null), M = o(() => b({
|
|
22
|
+
bridgeKeys: re,
|
|
23
23
|
props: {
|
|
24
|
-
...
|
|
25
|
-
...
|
|
24
|
+
...x,
|
|
25
|
+
...w
|
|
26
26
|
}
|
|
27
|
-
})), N = o(() => M.value.componentProps), P = o(() =>
|
|
27
|
+
})), N = o(() => M.value.componentProps), P = o(() => b({
|
|
28
28
|
bridgeKeys: i,
|
|
29
|
-
props:
|
|
29
|
+
props: ne(M.value.inheritedAttrs, ["class", "onUpdate:modelValue"])
|
|
30
30
|
})), F = o(() => P.value.componentProps), I = o(() => P.value.inheritedAttrs), L = o(() => {
|
|
31
31
|
let { content: e, toolbar: t, toolbarButton: n, ...r } = N.value.customProps ?? {};
|
|
32
32
|
return r;
|
|
@@ -38,7 +38,7 @@ function b(b, x, ae, S) {
|
|
|
38
38
|
color: F.value.color,
|
|
39
39
|
rounded: F.value.rounded,
|
|
40
40
|
variant: F.value.variant
|
|
41
|
-
})), { merged: B, entry: V } =
|
|
41
|
+
})), { merged: B, entry: V } = n({
|
|
42
42
|
chrome: "FormField",
|
|
43
43
|
componentName: "RichTextEditor",
|
|
44
44
|
props: () => z.value,
|
|
@@ -49,12 +49,12 @@ function b(b, x, ae, S) {
|
|
|
49
49
|
color: "primary",
|
|
50
50
|
variant: "outline"
|
|
51
51
|
}
|
|
52
|
-
}), H =
|
|
52
|
+
}), H = r({
|
|
53
53
|
entry: V,
|
|
54
54
|
props: () => z.value
|
|
55
|
-
}), U = o(() => B.value.format ?? "html"), W = o(() => [...N.value.tools ?? B.value.tools ??
|
|
56
|
-
let e = _
|
|
57
|
-
return
|
|
55
|
+
}), U = o(() => B.value.format ?? "html"), W = o(() => [...N.value.tools ?? B.value.tools ?? p]), G = o(() => N.value.readOnly === !0 || F.value.readonly === !0), K = o(() => !(G.value || F.value.disabled === !0) && W.value.length > 0), q = o(() => {
|
|
56
|
+
let e = y(_, V.value?.tokens?.size);
|
|
57
|
+
return d(e, F.value.size ?? B.value.size ?? "md");
|
|
58
58
|
}), J = a(() => ({
|
|
59
59
|
...I.value,
|
|
60
60
|
...F.value,
|
|
@@ -70,8 +70,8 @@ function b(b, x, ae, S) {
|
|
|
70
70
|
}, {
|
|
71
71
|
control: () => "textarea",
|
|
72
72
|
componentName: "RichTextEditor"
|
|
73
|
-
}), Y = o(() => J.merged.value.color ?? "primary"),
|
|
74
|
-
function
|
|
73
|
+
}), Y = o(() => J.merged.value.color ?? "primary"), ae = o(() => J.invalidated.value ? "error" : Y.value);
|
|
74
|
+
function oe(e) {
|
|
75
75
|
return !!(J.isDisabled.value || G.value || !(j.value?.can(e) ?? !0));
|
|
76
76
|
}
|
|
77
77
|
function X() {
|
|
@@ -80,13 +80,13 @@ function b(b, x, ae, S) {
|
|
|
80
80
|
function Z() {
|
|
81
81
|
D.value = "", A.value = null;
|
|
82
82
|
}
|
|
83
|
-
function
|
|
83
|
+
function se() {
|
|
84
84
|
let e = D.value.trim();
|
|
85
85
|
e.length !== 0 && (j.value?.run("link", { href: e }), X(), Z());
|
|
86
86
|
}
|
|
87
|
-
function
|
|
87
|
+
function Q(e, t) {
|
|
88
88
|
let n = j.value;
|
|
89
|
-
if (!
|
|
89
|
+
if (!f(n)) {
|
|
90
90
|
if (e === "link") {
|
|
91
91
|
if (n.isActive("link")) {
|
|
92
92
|
n.run("link"), X(), Z();
|
|
@@ -99,32 +99,30 @@ function b(b, x, ae, S) {
|
|
|
99
99
|
n.run(e), X();
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
-
let
|
|
102
|
+
let ce = o({
|
|
103
103
|
get() {
|
|
104
|
-
return !
|
|
104
|
+
return !f(A.value);
|
|
105
105
|
},
|
|
106
106
|
set(e) {
|
|
107
107
|
e || Z();
|
|
108
108
|
}
|
|
109
|
-
}),
|
|
110
|
-
|
|
109
|
+
}), le = o(() => D.value.trim().length > 0), ue = o(() => E("URL"));
|
|
110
|
+
u(K, (e) => {
|
|
111
111
|
e || Z();
|
|
112
112
|
});
|
|
113
113
|
function $() {
|
|
114
114
|
j.value?.destroy(), j.value = null;
|
|
115
115
|
let e = k.value;
|
|
116
|
-
|
|
116
|
+
f(e) || (e.remove(), k.value = null);
|
|
117
117
|
}
|
|
118
|
-
function
|
|
118
|
+
function de() {
|
|
119
119
|
$();
|
|
120
|
-
let e =
|
|
121
|
-
if (
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
tools: W.value,
|
|
127
|
-
value: x.value,
|
|
120
|
+
let e = C.value;
|
|
121
|
+
if (f(e)) return;
|
|
122
|
+
let t = document.createElement("div");
|
|
123
|
+
t.className = "flex min-h-0 min-w-0 w-full flex-1 flex-col outline-none", e.appendChild(t), k.value = t, j.value = ee({
|
|
124
|
+
element: t,
|
|
125
|
+
value: S.value,
|
|
128
126
|
format: U.value,
|
|
129
127
|
readOnly: G.value,
|
|
130
128
|
id: J.controlId.value,
|
|
@@ -136,24 +134,20 @@ function b(b, x, ae, S) {
|
|
|
136
134
|
ariaInvalid: J.invalidated.value,
|
|
137
135
|
ariaDescribedBy: J.ariaDescribedBy.value,
|
|
138
136
|
onChange: (e) => {
|
|
139
|
-
|
|
137
|
+
S.value = e;
|
|
140
138
|
}
|
|
141
139
|
});
|
|
142
140
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
S
|
|
147
|
-
], () => {
|
|
148
|
-
fe();
|
|
149
|
-
}, { flush: "post" }), d(() => x.value, (e) => {
|
|
141
|
+
u([U, C], () => {
|
|
142
|
+
de();
|
|
143
|
+
}, { flush: "post" }), u(() => S.value, (e) => {
|
|
150
144
|
let t = j.value;
|
|
151
|
-
|
|
152
|
-
}),
|
|
145
|
+
f(t) || e === void 0 || g(t.getValue(), e) || t.setValue(e);
|
|
146
|
+
}), u(() => J.isDisabled.value, (e) => {
|
|
153
147
|
j.value?.setDisabled(e);
|
|
154
|
-
}),
|
|
148
|
+
}), u(G, (e) => {
|
|
155
149
|
j.value?.setReadOnly(e);
|
|
156
|
-
}),
|
|
150
|
+
}), u([
|
|
157
151
|
G,
|
|
158
152
|
() => N.value.placeholder,
|
|
159
153
|
() => J.controlId.value,
|
|
@@ -172,57 +166,57 @@ function b(b, x, ae, S) {
|
|
|
172
166
|
}), s(() => {
|
|
173
167
|
$();
|
|
174
168
|
});
|
|
175
|
-
let
|
|
169
|
+
let fe = o(() => t(N.value.customProps?.toolbar, {
|
|
176
170
|
role: "toolbar",
|
|
177
|
-
"aria-label":
|
|
178
|
-
},
|
|
171
|
+
"aria-label": E("Formatting")
|
|
172
|
+
}, v({
|
|
179
173
|
[q.value?.toolbar ?? ""]: !0,
|
|
180
174
|
[H.value.toolbar ?? ""]: !0
|
|
181
|
-
}))),
|
|
175
|
+
}))), pe = o(() => t(N.value.customProps?.content, {}, v({
|
|
182
176
|
"min-w-0 flex-1": !0,
|
|
183
177
|
[q.value?.content ?? ""]: !0,
|
|
184
178
|
[H.value.content ?? ""]: !0,
|
|
185
179
|
[H.value.input ?? ""]: !0
|
|
186
180
|
})));
|
|
187
|
-
function
|
|
181
|
+
function me(e) {
|
|
188
182
|
O.value;
|
|
189
|
-
let
|
|
190
|
-
return
|
|
183
|
+
let n = j.value, r = E(h[e]);
|
|
184
|
+
return t(R.value, {
|
|
191
185
|
type: "button",
|
|
192
186
|
density: "mini",
|
|
193
187
|
variant: "flat",
|
|
194
188
|
"aria-label": r,
|
|
195
|
-
color:
|
|
196
|
-
icon:
|
|
197
|
-
disabled:
|
|
189
|
+
color: ae.value,
|
|
190
|
+
icon: m[e],
|
|
191
|
+
disabled: oe(e),
|
|
198
192
|
size: J.merged.value.size ?? "md",
|
|
199
|
-
selected:
|
|
193
|
+
selected: n?.isActive(e) ?? !1,
|
|
200
194
|
rounded: J.merged.value.rounded ?? "md"
|
|
201
|
-
},
|
|
195
|
+
}, v({
|
|
202
196
|
[q.value?.toolbarButton ?? ""]: !0,
|
|
203
197
|
[H.value.toolbarButton ?? ""]: !0
|
|
204
198
|
}));
|
|
205
199
|
}
|
|
206
200
|
return {
|
|
207
201
|
color: Y,
|
|
208
|
-
slots:
|
|
202
|
+
slots: T,
|
|
209
203
|
tools: W,
|
|
210
204
|
format: U,
|
|
211
205
|
linkHref: D,
|
|
212
|
-
linkOpen:
|
|
206
|
+
linkOpen: ce,
|
|
213
207
|
formField: J,
|
|
214
208
|
linkAnchor: A,
|
|
215
209
|
isReadOnly: G,
|
|
216
|
-
contentBind:
|
|
217
|
-
confirmLink:
|
|
218
|
-
onToolClick:
|
|
219
|
-
toolbarBind:
|
|
210
|
+
contentBind: pe,
|
|
211
|
+
confirmLink: se,
|
|
212
|
+
onToolClick: Q,
|
|
213
|
+
toolbarBind: fe,
|
|
220
214
|
showToolbar: K,
|
|
221
|
-
linkUrlLabel:
|
|
222
|
-
canConfirmLink:
|
|
215
|
+
linkUrlLabel: ue,
|
|
216
|
+
canConfirmLink: le,
|
|
223
217
|
closeLinkEditor: Z,
|
|
224
|
-
getToolbarButtonBind:
|
|
218
|
+
getToolbarButtonBind: me
|
|
225
219
|
};
|
|
226
220
|
}
|
|
227
221
|
//#endregion
|
|
228
|
-
export {
|
|
222
|
+
export { x as useRichTextEditor };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HTMLAttributes, Slot } from 'vue';
|
|
2
|
-
import { RichTextFormat, RichTextTool, RichTextValue } from '@bridge-ui/core/
|
|
2
|
+
import { RichTextFormat, RichTextTool, RichTextValue } from '@bridge-ui/core/Domain';
|
|
3
3
|
import { MergeHtmlProps } from '@bridge-ui/core/Utils';
|
|
4
4
|
import { ButtonOwnProps } from '../Button/button.types';
|
|
5
5
|
import { FormFieldClasses, FormFieldCustomProps, FormFieldOwnProps, FormFieldSlots } from '../FormField/formField.types';
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { RichTextA11yOptions, RichTextFormat, RichTextTool, RichTextToolPayload, RichTextValue } from '@bridge-ui/core/Domain';
|
|
2
|
+
/**
|
|
3
|
+
* Options for {@link mountTiptapEditor}.
|
|
4
|
+
*/
|
|
5
|
+
export type TiptapMountOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* `aria-describedby` on the editable root.
|
|
8
|
+
*/
|
|
9
|
+
ariaDescribedBy?: string;
|
|
10
|
+
/**
|
|
11
|
+
* `aria-disabled` on the editable root.
|
|
12
|
+
*/
|
|
13
|
+
ariaDisabled?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* `aria-invalid` on the editable root.
|
|
16
|
+
*/
|
|
17
|
+
ariaInvalid?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* `aria-readonly` on the editable root.
|
|
20
|
+
*/
|
|
21
|
+
ariaReadonly?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Disable editing and command execution.
|
|
24
|
+
*/
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Host element the editor mounts into.
|
|
28
|
+
*/
|
|
29
|
+
element: HTMLElement;
|
|
30
|
+
/**
|
|
31
|
+
* Document format for `value` / `onChange` / handle get/set.
|
|
32
|
+
*/
|
|
33
|
+
format: RichTextFormat;
|
|
34
|
+
/**
|
|
35
|
+
* Optional `id` applied to the editable root (for FormField label association).
|
|
36
|
+
*/
|
|
37
|
+
id?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Called whenever the document changes.
|
|
40
|
+
*/
|
|
41
|
+
onChange: (value: RichTextValue) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Called when the selection changes (toolbar active state).
|
|
44
|
+
*/
|
|
45
|
+
onSelectionChange?: () => void;
|
|
46
|
+
/**
|
|
47
|
+
* Empty-state hint in the content area.
|
|
48
|
+
*/
|
|
49
|
+
placeholder?: string;
|
|
50
|
+
/**
|
|
51
|
+
* View-only surface; commands should no-op.
|
|
52
|
+
*/
|
|
53
|
+
readOnly?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Initial document for the mount `format`.
|
|
56
|
+
*/
|
|
57
|
+
value?: RichTextValue;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Per-editor handle returned by {@link mountTiptapEditor}.
|
|
61
|
+
*/
|
|
62
|
+
export type TiptapEditorHandle = {
|
|
63
|
+
/**
|
|
64
|
+
* Blurs the editable surface when supported.
|
|
65
|
+
*/
|
|
66
|
+
blur: () => void;
|
|
67
|
+
/**
|
|
68
|
+
* Whether `tool` can run in the current selection / state.
|
|
69
|
+
*/
|
|
70
|
+
can: (tool: RichTextTool) => boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Tears down the editor instance.
|
|
73
|
+
*/
|
|
74
|
+
destroy: () => void;
|
|
75
|
+
/**
|
|
76
|
+
* Focuses the editable surface.
|
|
77
|
+
*/
|
|
78
|
+
focus: () => void;
|
|
79
|
+
/**
|
|
80
|
+
* Returns the current document in the mount `format`.
|
|
81
|
+
*/
|
|
82
|
+
getValue: () => RichTextValue;
|
|
83
|
+
/**
|
|
84
|
+
* Whether `tool` is active in the current selection.
|
|
85
|
+
*/
|
|
86
|
+
isActive: (tool: RichTextTool) => boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Runs a toolbar command (toggle mark, set link, …).
|
|
89
|
+
*/
|
|
90
|
+
run: (tool: RichTextTool, payload?: RichTextToolPayload) => void;
|
|
91
|
+
/**
|
|
92
|
+
* Updates a11y attributes and the empty-state placeholder after mount.
|
|
93
|
+
*/
|
|
94
|
+
setA11y: (options: RichTextA11yOptions) => void;
|
|
95
|
+
/**
|
|
96
|
+
* Updates the disabled flag after mount.
|
|
97
|
+
*/
|
|
98
|
+
setDisabled: (disabled: boolean) => void;
|
|
99
|
+
/**
|
|
100
|
+
* Updates the read-only flag after mount.
|
|
101
|
+
*/
|
|
102
|
+
setReadOnly: (readOnly: boolean) => void;
|
|
103
|
+
/**
|
|
104
|
+
* Replaces the document. Must match the mount `format`.
|
|
105
|
+
*/
|
|
106
|
+
setValue: (value: RichTextValue) => void;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Mounts a TipTap editor into `options.element` and returns a handle.
|
|
110
|
+
*/
|
|
111
|
+
export declare function mountTiptapEditor(options: TiptapMountOptions): TiptapEditorHandle;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { get as e, isNil as t, isString as n } from "es-toolkit/compat";
|
|
2
|
+
import { applyRichTextEditableA11y as r } from "@bridge-ui/core/Domain";
|
|
3
|
+
import { Editor as i } from "@tiptap/core";
|
|
4
|
+
import a from "@tiptap/extension-placeholder";
|
|
5
|
+
import o from "@tiptap/starter-kit";
|
|
6
|
+
//#region src/Components/RichTextEditor/tiptapEditor.ts
|
|
7
|
+
var s = "bridge-rich-text-editable";
|
|
8
|
+
function c(e, t) {
|
|
9
|
+
return t === "json" ? e.getJSON() : e.getHTML();
|
|
10
|
+
}
|
|
11
|
+
function l(e, n) {
|
|
12
|
+
let r = e.extensionManager.extensions.find((e) => e.name === "placeholder");
|
|
13
|
+
t(r) || r.options.placeholder === n || (r.options.placeholder = n, e.view.dispatch(e.state.tr));
|
|
14
|
+
}
|
|
15
|
+
var u = {
|
|
16
|
+
bold: (e) => e.isActive("bold"),
|
|
17
|
+
link: (e) => e.isActive("link"),
|
|
18
|
+
italic: (e) => e.isActive("italic"),
|
|
19
|
+
strike: (e) => e.isActive("strike"),
|
|
20
|
+
codeBlock: (e) => e.isActive("codeBlock"),
|
|
21
|
+
underline: (e) => e.isActive("underline"),
|
|
22
|
+
blockquote: (e) => e.isActive("blockquote"),
|
|
23
|
+
bulletList: (e) => e.isActive("bulletList"),
|
|
24
|
+
orderedList: (e) => e.isActive("orderedList"),
|
|
25
|
+
heading1: (e) => e.isActive("heading", { level: 1 }),
|
|
26
|
+
heading2: (e) => e.isActive("heading", { level: 2 }),
|
|
27
|
+
heading3: (e) => e.isActive("heading", { level: 3 })
|
|
28
|
+
}, d = {
|
|
29
|
+
link: () => !0,
|
|
30
|
+
bold: (e) => e.can().toggleBold(),
|
|
31
|
+
italic: (e) => e.can().toggleItalic(),
|
|
32
|
+
strike: (e) => e.can().toggleStrike(),
|
|
33
|
+
codeBlock: (e) => e.can().toggleCodeBlock(),
|
|
34
|
+
underline: (e) => e.can().toggleUnderline(),
|
|
35
|
+
blockquote: (e) => e.can().toggleBlockquote(),
|
|
36
|
+
bulletList: (e) => e.can().toggleBulletList(),
|
|
37
|
+
orderedList: (e) => e.can().toggleOrderedList(),
|
|
38
|
+
heading1: (e) => e.can().toggleHeading({ level: 1 }),
|
|
39
|
+
heading2: (e) => e.can().toggleHeading({ level: 2 }),
|
|
40
|
+
heading3: (e) => e.can().toggleHeading({ level: 3 })
|
|
41
|
+
}, f = {
|
|
42
|
+
bold: (e) => e.chain().focus().toggleBold().run(),
|
|
43
|
+
italic: (e) => e.chain().focus().toggleItalic().run(),
|
|
44
|
+
strike: (e) => e.chain().focus().toggleStrike().run(),
|
|
45
|
+
codeBlock: (e) => e.chain().focus().toggleCodeBlock().run(),
|
|
46
|
+
underline: (e) => e.chain().focus().toggleUnderline().run(),
|
|
47
|
+
blockquote: (e) => e.chain().focus().toggleBlockquote().run(),
|
|
48
|
+
bulletList: (e) => e.chain().focus().toggleBulletList().run(),
|
|
49
|
+
orderedList: (e) => e.chain().focus().toggleOrderedList().run(),
|
|
50
|
+
heading1: (e) => e.chain().focus().toggleHeading({ level: 1 }).run(),
|
|
51
|
+
heading2: (e) => e.chain().focus().toggleHeading({ level: 2 }).run(),
|
|
52
|
+
heading3: (e) => e.chain().focus().toggleHeading({ level: 3 }).run(),
|
|
53
|
+
link: (e, n) => {
|
|
54
|
+
if (!t(n?.href) && n.href.length > 0) {
|
|
55
|
+
e.chain().focus().extendMarkRange("link").setLink({ href: n.href }).run();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
e.isActive("link") && e.chain().focus().unsetLink().run();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
function p(t, n) {
|
|
62
|
+
return e(u, n, () => !1)(t);
|
|
63
|
+
}
|
|
64
|
+
function m(t, n) {
|
|
65
|
+
return e(d, n, () => !1)(t);
|
|
66
|
+
}
|
|
67
|
+
function h(t, n, r) {
|
|
68
|
+
e(f, n, () => void 0)(t, r);
|
|
69
|
+
}
|
|
70
|
+
function g(e) {
|
|
71
|
+
let t = e.disabled === !0, u = e.readOnly === !0, d = !1, f = new i({
|
|
72
|
+
autofocus: !1,
|
|
73
|
+
element: e.element,
|
|
74
|
+
editable: !t && !u,
|
|
75
|
+
onSelectionUpdate: () => {
|
|
76
|
+
e.onSelectionChange?.();
|
|
77
|
+
},
|
|
78
|
+
editorProps: { attributes: { class: s } },
|
|
79
|
+
onUpdate: ({ editor: t }) => {
|
|
80
|
+
e.onChange(c(t, e.format));
|
|
81
|
+
},
|
|
82
|
+
content: e.value ?? (e.format === "json" ? {
|
|
83
|
+
type: "doc",
|
|
84
|
+
content: []
|
|
85
|
+
} : ""),
|
|
86
|
+
extensions: [o.configure({ link: { openOnClick: !1 } }), a.configure({ placeholder: e.placeholder ?? "" })]
|
|
87
|
+
});
|
|
88
|
+
return r(f.view.dom, e), {
|
|
89
|
+
getValue: () => c(f, e.format),
|
|
90
|
+
blur: () => {
|
|
91
|
+
d || f.commands.blur();
|
|
92
|
+
},
|
|
93
|
+
focus: () => {
|
|
94
|
+
d || f.commands.focus();
|
|
95
|
+
},
|
|
96
|
+
isActive: (e) => !d && p(f, e),
|
|
97
|
+
destroy: () => {
|
|
98
|
+
d || (d = !0, f.destroy());
|
|
99
|
+
},
|
|
100
|
+
can: (e) => d || t || u ? !1 : m(f, e),
|
|
101
|
+
setDisabled: (e) => {
|
|
102
|
+
d || (t = e, f.setEditable(!t && !u, !1));
|
|
103
|
+
},
|
|
104
|
+
setReadOnly: (e) => {
|
|
105
|
+
d || (u = e, f.setEditable(!t && !u, !1));
|
|
106
|
+
},
|
|
107
|
+
run: (e, n) => {
|
|
108
|
+
d || t || u || h(f, e, n);
|
|
109
|
+
},
|
|
110
|
+
setA11y: (e) => {
|
|
111
|
+
d || (r(f.view.dom, e), l(f, e.placeholder ?? ""));
|
|
112
|
+
},
|
|
113
|
+
setValue: (t) => {
|
|
114
|
+
if (d) return;
|
|
115
|
+
let r = e.format === "html" ? n(t) ? t : "" : t;
|
|
116
|
+
f.commands.setContent(r, { emitUpdate: !1 });
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
//#endregion
|
|
121
|
+
export { g as mountTiptapEditor };
|