@threadlabs/looma 0.28.8 → 0.28.9
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/components/ui-editor-code-language/ui-editor-code-language.html +17 -0
- package/components/ui-editor-code-language/ui-editor-code-language.js +14 -0
- package/dist/index.js +37 -36
- package/package.json +1 -1
- package/styles/ui-editor-code-language.css +1 -0
- package/vanilla/UiEditorCodeLanguage.d.ts +16 -0
- package/vanilla/UiEditorCodeLanguage.js +64 -0
- package/vanilla/index.js +1 -0
- package/vue/UiEditorCodeLanguage.d.ts +44 -0
- package/vue/UiEditorCodeLanguage.js +2 -0
- package/vue/UiEditorCodeLanguage.vue +156 -0
- package/vue/chunks/UiEditorCodeLanguage.js +163 -0
- package/vue/editor/index.js +11 -14
- package/vue/editor/primitives.d.ts +5 -1
- package/vue/index.d.ts +1 -0
- package/vue/index.js +2 -1
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/* Generated by HTML Next 1.0.0-alpha.51. Do not edit. */
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Generated by HTML Next 1.0.0-alpha.51 for Vanilla DOM. Do not edit.
|
|
2
|
+
export interface UiEditorCodeLanguageEventMap {
|
|
3
|
+
language: CustomEvent<{ readonly value: string }>;
|
|
4
|
+
}
|
|
5
|
+
export interface UiEditorCodeLanguageElement extends HTMLDivElement {
|
|
6
|
+
addEventListener<K extends keyof UiEditorCodeLanguageEventMap>(type: K, listener: (this: UiEditorCodeLanguageElement, event: UiEditorCodeLanguageEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void;
|
|
7
|
+
removeEventListener<K extends keyof UiEditorCodeLanguageEventMap>(type: K, listener: (this: UiEditorCodeLanguageElement, event: UiEditorCodeLanguageEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void;
|
|
8
|
+
}
|
|
9
|
+
export interface UiEditorCodeLanguageProps {
|
|
10
|
+
languages?: readonly ({ readonly value: string; readonly label: string })[] | null;
|
|
11
|
+
value?: string | null;
|
|
12
|
+
attributes?: Readonly<Record<string, string | number | boolean | null | undefined>>;
|
|
13
|
+
children?: readonly (string | Node)[];
|
|
14
|
+
slots?: Readonly<Record<string, readonly (string | Node)[]>>;
|
|
15
|
+
}
|
|
16
|
+
export declare function createUiEditorCodeLanguage(props?: UiEditorCodeLanguageProps): UiEditorCodeLanguageElement;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Generated by HTML Next 1.0.0-alpha.51 for Vanilla DOM. Do not edit.
|
|
2
|
+
import { attachGeneratedController, buildTemplate, KeyedList, readMember, toAttribute, toText, trackContainer, writeAttribute, dispatchDeclared, detailCheck, acceptProps, manageProps, checkList, checkObject, checkString } from "@nextwebwg/html-next/generated-runtime";
|
|
3
|
+
import * as controller from "../components/ui-editor-code-language/ui-editor-code-language.js";
|
|
4
|
+
import "../styles/ui-editor-code-language.css";
|
|
5
|
+
|
|
6
|
+
const T0 = ["",[],["ui-combobox",["label","Code language","label-visibility","sr-only","size","sm","filter","label"],2]];
|
|
7
|
+
const T1 = ["option",[],0];
|
|
8
|
+
let P0, P1;
|
|
9
|
+
const E = new Map();
|
|
10
|
+
const S = { n: [], t: [], f: import.meta.url, g: "ui-editor-code-language", d: { "language": [detailCheck(checkObject([["value", checkString, false]], false)), true, true, false] }, x: dispatchDeclared };
|
|
11
|
+
const D = { props: { "languages": { "required":false,"default":[], c: checkList(checkObject([["value", checkString, false], ["label", checkString, false]], false)), j: 1, m: ["l",["o",["value","s","label","s"]]] }, "value": { "required":false,"default":"auto", c: checkString, t: "string", j: 0, m: "s" } } };
|
|
12
|
+
const C = (host) => controller.default(host);
|
|
13
|
+
|
|
14
|
+
export function createUiEditorCodeLanguage(options = {}, html) {
|
|
15
|
+
const { attributes = {}, children = [], slots = {}, ...componentProps } = options;
|
|
16
|
+
const element = document.createElement("div");
|
|
17
|
+
for (const [name, value] of Object.entries(attributes)) {
|
|
18
|
+
if (value === null || value === undefined || value === false) continue;
|
|
19
|
+
element.setAttribute(name, value === true ? "" : String(value));
|
|
20
|
+
}
|
|
21
|
+
element.setAttribute("data-component", "ui-editor-code-language");
|
|
22
|
+
element.append((P0 ??= buildTemplate(T0)).cloneNode(true));
|
|
23
|
+
const v = [null, null];
|
|
24
|
+
const B = acceptProps(element, D, S.n, v, componentProps, [], html);
|
|
25
|
+
const m1 = (o, j, l) => {
|
|
26
|
+
const n = (P1 ??= buildTemplate(T1)).cloneNode(true);
|
|
27
|
+
const t0 = n.firstChild;
|
|
28
|
+
const r = { k: undefined, i: o, n, x: 0, y: 0, a1: t0, w: 0, v0: null, v1: "" };
|
|
29
|
+
p1(r, -1, E);
|
|
30
|
+
return r;
|
|
31
|
+
};
|
|
32
|
+
const p1 = (r, c, d) => {
|
|
33
|
+
const o = r.i;
|
|
34
|
+
if (c & 1073741824) {
|
|
35
|
+
r.w = 0;
|
|
36
|
+
const x0 = trackContainer(r, readMember(o, "value"));
|
|
37
|
+
const s0 = toAttribute(x0, "value");
|
|
38
|
+
if (s0 !== r.v0) writeAttribute(r.n, "value", r.v0 = s0);
|
|
39
|
+
const x1 = trackContainer(r, readMember(o, "label"));
|
|
40
|
+
const s1 = toText(x1);
|
|
41
|
+
if (s1 !== r.v1) r.a1.data = r.v1 = s1;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const p0 = (r, c, d) => {
|
|
45
|
+
if (c === -1) {
|
|
46
|
+
const x0 = true;
|
|
47
|
+
const s0 = toAttribute(x0, "disclosure");
|
|
48
|
+
if (s0 !== r.v0) writeAttribute(r.a0, "disclosure", r.v0 = s0);
|
|
49
|
+
}
|
|
50
|
+
if (c & 2) {
|
|
51
|
+
const x1 = v[1];
|
|
52
|
+
const s1 = toAttribute(x1, "value");
|
|
53
|
+
if (s1 !== r.v1) writeAttribute(r.a0, "value", r.v1 = s1);
|
|
54
|
+
}
|
|
55
|
+
if (c & 1073741825) r.L0.update(v[0], d, c);
|
|
56
|
+
};
|
|
57
|
+
const t0 = element.firstChild;
|
|
58
|
+
const t1 = t0.firstChild;
|
|
59
|
+
const R = { a0: t0, v0: null, v1: null, L0: new KeyedList(t1, t1.nextSibling, m1, p1, (o) => readMember(o, "value"), "language") };
|
|
60
|
+
const I = { B };
|
|
61
|
+
attachGeneratedController(element, S, v, ((c, d) => p0(R, c, d)), C, undefined, I);
|
|
62
|
+
manageProps(I);
|
|
63
|
+
return element;
|
|
64
|
+
}
|
package/vanilla/index.js
CHANGED
|
@@ -20,6 +20,7 @@ export * from "./UiDialog.js";
|
|
|
20
20
|
export * from "./UiDisclosure.js";
|
|
21
21
|
export * from "./UiEditable.js";
|
|
22
22
|
export * from "./UiEditorBlockActions.js";
|
|
23
|
+
export * from "./UiEditorCodeLanguage.js";
|
|
23
24
|
export * from "./UiEditorImageToolbar.js";
|
|
24
25
|
export * from "./UiEditorInsertTableGrid.js";
|
|
25
26
|
export * from "./UiEditorLinkCard.js";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { PropType } from 'vue';
|
|
2
|
+
declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
3
|
+
languages: {
|
|
4
|
+
type: PropType<readonly ({
|
|
5
|
+
readonly value: string;
|
|
6
|
+
readonly label: string;
|
|
7
|
+
})[] | null>;
|
|
8
|
+
default: () => never[];
|
|
9
|
+
};
|
|
10
|
+
value: {
|
|
11
|
+
type: PropType<string | null>;
|
|
12
|
+
default: string;
|
|
13
|
+
};
|
|
14
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
15
|
+
"update:value": (value: string) => any;
|
|
16
|
+
language: (event: CustomEvent<{
|
|
17
|
+
readonly value: string;
|
|
18
|
+
}>) => any;
|
|
19
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
20
|
+
languages: {
|
|
21
|
+
type: PropType<readonly ({
|
|
22
|
+
readonly value: string;
|
|
23
|
+
readonly label: string;
|
|
24
|
+
})[] | null>;
|
|
25
|
+
default: () => never[];
|
|
26
|
+
};
|
|
27
|
+
value: {
|
|
28
|
+
type: PropType<string | null>;
|
|
29
|
+
default: string;
|
|
30
|
+
};
|
|
31
|
+
}>> & Readonly<{
|
|
32
|
+
"onUpdate:value"?: ((value: string) => any) | undefined;
|
|
33
|
+
onLanguage?: ((event: CustomEvent<{
|
|
34
|
+
readonly value: string;
|
|
35
|
+
}>) => any) | undefined;
|
|
36
|
+
}>, {
|
|
37
|
+
value: string | null;
|
|
38
|
+
languages: readonly {
|
|
39
|
+
readonly value: string;
|
|
40
|
+
readonly label: string;
|
|
41
|
+
}[] | null;
|
|
42
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
43
|
+
declare const _default: typeof __VLS_export;
|
|
44
|
+
export default _default;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
<!-- Generated by HTML Next 1.0.0-alpha.51 for Vue 3.5. Do not edit. -->
|
|
2
|
+
<script setup lang="ts">
|
|
3
|
+
import { computed, getCurrentInstance, ref, watchSyncEffect } from 'vue'
|
|
4
|
+
import type { PropType } from 'vue'
|
|
5
|
+
import {
|
|
6
|
+
checkHydratedRoot,
|
|
7
|
+
createDispatch,
|
|
8
|
+
KeyedBoundary,
|
|
9
|
+
nativeAttrs,
|
|
10
|
+
uniqueKeys,
|
|
11
|
+
useComponentHost,
|
|
12
|
+
useReflectedProp,
|
|
13
|
+
} from './host'
|
|
14
|
+
import { checkedProp, propValidityState, vPropValidity } from './props'
|
|
15
|
+
import UiCombobox from './UiCombobox.vue'
|
|
16
|
+
|
|
17
|
+
defineOptions({ inheritAttrs: false })
|
|
18
|
+
|
|
19
|
+
const propValidityContract = {
|
|
20
|
+
props: {
|
|
21
|
+
languages: {
|
|
22
|
+
type: {
|
|
23
|
+
kind: 'list',
|
|
24
|
+
item: {
|
|
25
|
+
kind: 'object',
|
|
26
|
+
fields: [{ name: 'value', type: { kind: 'terminal', name: 'string' }, optional: false }, {
|
|
27
|
+
name: 'label',
|
|
28
|
+
type: { kind: 'terminal', name: 'string' },
|
|
29
|
+
optional: false,
|
|
30
|
+
}],
|
|
31
|
+
open: false,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
required: false,
|
|
35
|
+
target: { attribute: 'languages' },
|
|
36
|
+
description:
|
|
37
|
+
'The languages to offer, in order, each with its label; the editor lists Auto first and marks a saved language it cannot highlight.',
|
|
38
|
+
default: [],
|
|
39
|
+
},
|
|
40
|
+
value: {
|
|
41
|
+
type: { kind: 'terminal', name: 'string' },
|
|
42
|
+
required: false,
|
|
43
|
+
target: { attribute: 'value' },
|
|
44
|
+
description: 'The code block\'s language, or auto to detect it.',
|
|
45
|
+
default: 'auto',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
} as const
|
|
49
|
+
const props = defineProps({
|
|
50
|
+
languages: {
|
|
51
|
+
type: null as unknown as PropType<
|
|
52
|
+
readonly ({ readonly value: string; readonly label: string })[] | null
|
|
53
|
+
>,
|
|
54
|
+
default: () => [],
|
|
55
|
+
},
|
|
56
|
+
value: { type: null as unknown as PropType<string | null>, default: 'auto' },
|
|
57
|
+
})
|
|
58
|
+
const acceptedProps: Record<string, unknown> = { languages: () => [], value: 'auto' }
|
|
59
|
+
const checkedProps = computed(() => ({
|
|
60
|
+
languages: checkedProp<readonly ({ readonly value: string; readonly label: string })[]>(
|
|
61
|
+
props['languages'],
|
|
62
|
+
{
|
|
63
|
+
kind: 'list',
|
|
64
|
+
item: {
|
|
65
|
+
kind: 'object',
|
|
66
|
+
fields: [{ name: 'value', type: { kind: 'terminal', name: 'string' }, optional: false }, {
|
|
67
|
+
name: 'label',
|
|
68
|
+
type: { kind: 'terminal', name: 'string' },
|
|
69
|
+
optional: false,
|
|
70
|
+
}],
|
|
71
|
+
open: false,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
false,
|
|
75
|
+
'languages',
|
|
76
|
+
acceptedProps,
|
|
77
|
+
) as readonly ({ readonly value: string; readonly label: string })[],
|
|
78
|
+
value: checkedProp<string>(
|
|
79
|
+
props['value'],
|
|
80
|
+
{ kind: 'terminal', name: 'string' },
|
|
81
|
+
false,
|
|
82
|
+
'value',
|
|
83
|
+
acceptedProps,
|
|
84
|
+
) as string,
|
|
85
|
+
}))
|
|
86
|
+
void checkedProps.value
|
|
87
|
+
watchSyncEffect(() => {
|
|
88
|
+
void checkedProps.value
|
|
89
|
+
})
|
|
90
|
+
const reflectedProp = useReflectedProp()
|
|
91
|
+
const hydrationInstance = getCurrentInstance()
|
|
92
|
+
const emit = defineEmits<{
|
|
93
|
+
'update:value': [value: string]
|
|
94
|
+
language: [event: CustomEvent<{ readonly value: string }>]
|
|
95
|
+
}>()
|
|
96
|
+
|
|
97
|
+
const root = ref<HTMLElement | null>(null)
|
|
98
|
+
checkHydratedRoot('div', 'ui-editor-code-language')
|
|
99
|
+
|
|
100
|
+
const isLanguageDetail = (
|
|
101
|
+
detail: unknown,
|
|
102
|
+
): boolean => (detail !== null && typeof detail === 'object' && !Array.isArray(detail)
|
|
103
|
+
&& typeof (detail as Record<string, unknown>)['value'] === 'string'
|
|
104
|
+
&& Object.keys(detail as object).every((key) => ['value'].includes(key)))
|
|
105
|
+
const dispatch = createDispatch(root, emit as (name: string, detail: unknown) => void, {
|
|
106
|
+
checks: {
|
|
107
|
+
language: isLanguageDetail,
|
|
108
|
+
},
|
|
109
|
+
modeled: ['value'],
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
useComponentHost(() => import('../components/ui-editor-code-language/ui-editor-code-language.js'), {
|
|
113
|
+
root,
|
|
114
|
+
dispatch,
|
|
115
|
+
controllerSource: {
|
|
116
|
+
specifier: '../components/ui-editor-code-language/ui-editor-code-language.js',
|
|
117
|
+
definition: './components/ui-editor-code-language/ui-editor-code-language.html',
|
|
118
|
+
},
|
|
119
|
+
props: checkedProps,
|
|
120
|
+
propInputs: (name: string) => {
|
|
121
|
+
const incoming = hydrationInstance?.vnode.props
|
|
122
|
+
const kebab = name.replace(/[A-Z]/g, (letter) => '-' + letter.toLowerCase())
|
|
123
|
+
return incoming !== null && incoming !== undefined
|
|
124
|
+
? (incoming[name] ?? incoming[kebab] ?? null)
|
|
125
|
+
: null
|
|
126
|
+
},
|
|
127
|
+
propNames: ['languages', 'value'],
|
|
128
|
+
propValidity: (name: string) =>
|
|
129
|
+
propValidityState({ contract: propValidityContract, values: { ...props } }, name),
|
|
130
|
+
})
|
|
131
|
+
</script>
|
|
132
|
+
|
|
133
|
+
<template>
|
|
134
|
+
<div
|
|
135
|
+
v-bind="nativeAttrs($attrs)"
|
|
136
|
+
v-prop-validity="{ contract: propValidityContract, values: { ...props } }"
|
|
137
|
+
:data-languages="reflectedProp('languages', 'languages', checkedProps.languages, undefined, false)"
|
|
138
|
+
:data-value="reflectedProp('value', 'value', checkedProps.value, undefined, false)"
|
|
139
|
+
ref="root"
|
|
140
|
+
>
|
|
141
|
+
<UiCombobox
|
|
142
|
+
label="Code language"
|
|
143
|
+
label-visibility="sr-only"
|
|
144
|
+
size="sm"
|
|
145
|
+
filter="label"
|
|
146
|
+
:disclosure="true"
|
|
147
|
+
:value="checkedProps.value"
|
|
148
|
+
><KeyedBoundary><option
|
|
149
|
+
v-for="language in uniqueKeys(checkedProps.languages, (language, index, loop) => language.value)"
|
|
150
|
+
:key="language.value"
|
|
151
|
+
:value="language.value"
|
|
152
|
+
>
|
|
153
|
+
{{ language.label }}
|
|
154
|
+
</option></KeyedBoundary></UiCombobox>
|
|
155
|
+
</div>
|
|
156
|
+
</template>
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { _ as uniqueKeys, i as checkHydratedRoot, n as KeyedBoundary, o as createDispatch, p as nativeAttrs, v as useComponentHost, y as useReflectedProp } from "./_plugin-vue_export-helper.js";
|
|
2
|
+
import { a as vPropValidity, n as checkedProp, r as propValidityState } from "./props.js";
|
|
3
|
+
import { t as UiCombobox_default } from "./UiCombobox.js";
|
|
4
|
+
import { Fragment, computed, createElementBlock, createVNode, defineComponent, getCurrentInstance, mergeProps, openBlock, ref, renderList, toDisplayString, unref, watchSyncEffect, withCtx, withDirectives } from "vue";
|
|
5
|
+
//#region .build/vue/UiEditorCodeLanguage.vue?vue&type=script&setup=true&lang.ts
|
|
6
|
+
var _hoisted_1 = ["data-languages", "data-value"];
|
|
7
|
+
var _hoisted_2 = ["value"];
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region .build/vue/UiEditorCodeLanguage.vue
|
|
10
|
+
var UiEditorCodeLanguage_default = /* @__PURE__ */ defineComponent({
|
|
11
|
+
inheritAttrs: false,
|
|
12
|
+
__name: "UiEditorCodeLanguage",
|
|
13
|
+
props: {
|
|
14
|
+
languages: {
|
|
15
|
+
type: null,
|
|
16
|
+
default: () => []
|
|
17
|
+
},
|
|
18
|
+
value: {
|
|
19
|
+
type: null,
|
|
20
|
+
default: "auto"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
emits: ["update:value", "language"],
|
|
24
|
+
setup(__props, { emit: __emit }) {
|
|
25
|
+
const propValidityContract = { props: {
|
|
26
|
+
languages: {
|
|
27
|
+
type: {
|
|
28
|
+
kind: "list",
|
|
29
|
+
item: {
|
|
30
|
+
kind: "object",
|
|
31
|
+
fields: [{
|
|
32
|
+
name: "value",
|
|
33
|
+
type: {
|
|
34
|
+
kind: "terminal",
|
|
35
|
+
name: "string"
|
|
36
|
+
},
|
|
37
|
+
optional: false
|
|
38
|
+
}, {
|
|
39
|
+
name: "label",
|
|
40
|
+
type: {
|
|
41
|
+
kind: "terminal",
|
|
42
|
+
name: "string"
|
|
43
|
+
},
|
|
44
|
+
optional: false
|
|
45
|
+
}],
|
|
46
|
+
open: false
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
required: false,
|
|
50
|
+
target: { attribute: "languages" },
|
|
51
|
+
description: "The languages to offer, in order, each with its label; the editor lists Auto first and marks a saved language it cannot highlight.",
|
|
52
|
+
default: []
|
|
53
|
+
},
|
|
54
|
+
value: {
|
|
55
|
+
type: {
|
|
56
|
+
kind: "terminal",
|
|
57
|
+
name: "string"
|
|
58
|
+
},
|
|
59
|
+
required: false,
|
|
60
|
+
target: { attribute: "value" },
|
|
61
|
+
description: "The code block's language, or auto to detect it.",
|
|
62
|
+
default: "auto"
|
|
63
|
+
}
|
|
64
|
+
} };
|
|
65
|
+
const props = __props;
|
|
66
|
+
const acceptedProps = {
|
|
67
|
+
languages: () => [],
|
|
68
|
+
value: "auto"
|
|
69
|
+
};
|
|
70
|
+
const checkedProps = computed(() => ({
|
|
71
|
+
languages: checkedProp(props["languages"], {
|
|
72
|
+
kind: "list",
|
|
73
|
+
item: {
|
|
74
|
+
kind: "object",
|
|
75
|
+
fields: [{
|
|
76
|
+
name: "value",
|
|
77
|
+
type: {
|
|
78
|
+
kind: "terminal",
|
|
79
|
+
name: "string"
|
|
80
|
+
},
|
|
81
|
+
optional: false
|
|
82
|
+
}, {
|
|
83
|
+
name: "label",
|
|
84
|
+
type: {
|
|
85
|
+
kind: "terminal",
|
|
86
|
+
name: "string"
|
|
87
|
+
},
|
|
88
|
+
optional: false
|
|
89
|
+
}],
|
|
90
|
+
open: false
|
|
91
|
+
}
|
|
92
|
+
}, false, "languages", acceptedProps),
|
|
93
|
+
value: checkedProp(props["value"], {
|
|
94
|
+
kind: "terminal",
|
|
95
|
+
name: "string"
|
|
96
|
+
}, false, "value", acceptedProps)
|
|
97
|
+
}));
|
|
98
|
+
checkedProps.value;
|
|
99
|
+
watchSyncEffect(() => {
|
|
100
|
+
checkedProps.value;
|
|
101
|
+
});
|
|
102
|
+
const reflectedProp = useReflectedProp();
|
|
103
|
+
const hydrationInstance = getCurrentInstance();
|
|
104
|
+
const emit = __emit;
|
|
105
|
+
const root = ref(null);
|
|
106
|
+
checkHydratedRoot("div", "ui-editor-code-language");
|
|
107
|
+
const isLanguageDetail = (detail) => detail !== null && typeof detail === "object" && !Array.isArray(detail) && typeof detail["value"] === "string" && Object.keys(detail).every((key) => ["value"].includes(key));
|
|
108
|
+
const dispatch = createDispatch(root, emit, {
|
|
109
|
+
checks: { language: isLanguageDetail },
|
|
110
|
+
modeled: ["value"]
|
|
111
|
+
});
|
|
112
|
+
useComponentHost(() => import("@threadlabs/looma/components/ui-editor-code-language/ui-editor-code-language.js"), {
|
|
113
|
+
root,
|
|
114
|
+
dispatch,
|
|
115
|
+
controllerSource: {
|
|
116
|
+
specifier: "../components/ui-editor-code-language/ui-editor-code-language.js",
|
|
117
|
+
definition: "./components/ui-editor-code-language/ui-editor-code-language.html"
|
|
118
|
+
},
|
|
119
|
+
props: checkedProps,
|
|
120
|
+
propInputs: (name) => {
|
|
121
|
+
const incoming = hydrationInstance?.vnode.props;
|
|
122
|
+
const kebab = name.replace(/[A-Z]/g, (letter) => "-" + letter.toLowerCase());
|
|
123
|
+
return incoming !== null && incoming !== void 0 ? incoming[name] ?? incoming[kebab] ?? null : null;
|
|
124
|
+
},
|
|
125
|
+
propNames: ["languages", "value"],
|
|
126
|
+
propValidity: (name) => propValidityState({
|
|
127
|
+
contract: propValidityContract,
|
|
128
|
+
values: { ...props }
|
|
129
|
+
}, name)
|
|
130
|
+
});
|
|
131
|
+
return (_ctx, _cache) => {
|
|
132
|
+
return withDirectives((openBlock(), createElementBlock("div", mergeProps(unref(nativeAttrs)(_ctx.$attrs), {
|
|
133
|
+
"data-languages": unref(reflectedProp)("languages", "languages", checkedProps.value.languages, void 0, false),
|
|
134
|
+
"data-value": unref(reflectedProp)("value", "value", checkedProps.value.value, void 0, false),
|
|
135
|
+
ref_key: "root",
|
|
136
|
+
ref: root
|
|
137
|
+
}), [createVNode(UiCombobox_default, {
|
|
138
|
+
label: "Code language",
|
|
139
|
+
"label-visibility": "sr-only",
|
|
140
|
+
size: "sm",
|
|
141
|
+
filter: "label",
|
|
142
|
+
disclosure: true,
|
|
143
|
+
value: checkedProps.value.value
|
|
144
|
+
}, {
|
|
145
|
+
default: withCtx(() => [createVNode(unref(KeyedBoundary), null, {
|
|
146
|
+
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(unref(uniqueKeys)(checkedProps.value.languages, (language, index, loop) => language.value), (language) => {
|
|
147
|
+
return openBlock(), createElementBlock("option", {
|
|
148
|
+
key: language.value,
|
|
149
|
+
value: language.value
|
|
150
|
+
}, toDisplayString(language.label), 9, _hoisted_2);
|
|
151
|
+
}), 128))]),
|
|
152
|
+
_: 1
|
|
153
|
+
})]),
|
|
154
|
+
_: 1
|
|
155
|
+
}, 8, ["value"])], 16, _hoisted_1)), [[unref(vPropValidity), {
|
|
156
|
+
contract: propValidityContract,
|
|
157
|
+
values: { ...props }
|
|
158
|
+
}]]);
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
//#endregion
|
|
163
|
+
export { UiEditorCodeLanguage_default as t };
|
package/vue/editor/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { computed, createApp, defineComponent, h, nextTick, onBeforeUnmount, onMounted, reactive, ref, shallowRef, useId, watch } from "vue";
|
|
2
2
|
import { DEFAULT_MENTION_RESULT_LIMIT, LOOMA_CHIP_COLORS, LOOMA_ICONS, createLoomaMentionExtension, createLoomaSlashCommandExtension, getActiveTableUiState, getDefaultEditorExtensions, getDefaultSlashCommands, getTableOfContentsEntries, getVisualViewportRect, handleTableAction, handleTableOverlayAction, measureTableOverlayGeometry, normalizeActiveTableColumnWidths, normalizeLoomaChipColor, normalizeTableOfContentsConfig, resolveTableCellAt, siteRelativeHref } from "@threadlabs/looma/editor";
|
|
3
|
-
import { Button, Callout, Card, Checkbox, Cluster,
|
|
3
|
+
import { Button, Callout, Card, Checkbox, Cluster, Disclosure, EditorBlockActions, EditorCodeLanguage, EditorImageToolbar, EditorInsertTableGrid, EditorLinkCard, EditorLinkForm, EditorMentionMenu, EditorMentionMenuItem, EditorSlashMenu, EditorSlashMenuGroup, EditorSlashMenuItem, EditorSurface, EditorTableContextMenu, EditorTableOverlay, EditorTableToolbar, EditorToolbar, FormField, Icon, IconButton, Image, Input, List, Menu, MenuItem, Popover, Separator, Stack, Text, Tooltip } from "@threadlabs/looma/vue";
|
|
4
4
|
import { Editor, Extension, Node as Node$1, getText, getTextSerializersFromSchema, isNodeSelection, mergeAttributes, nodeInputRule, posToDOMRect } from "@tiptap/core";
|
|
5
5
|
import { Editor as Editor$1 } from "@tiptap/vue-3";
|
|
6
6
|
import { closeHistory } from "@tiptap/pm/history";
|
|
@@ -25,7 +25,8 @@ var EDITOR_ADAPTER_COMPONENT_TAG_MAP = {
|
|
|
25
25
|
EditorImageToolbar: "ui-editor-image-toolbar",
|
|
26
26
|
EditorLinkCard: "ui-editor-link-card",
|
|
27
27
|
EditorLinkForm: "ui-editor-link-form",
|
|
28
|
-
EditorBlockActions: "ui-editor-block-actions"
|
|
28
|
+
EditorBlockActions: "ui-editor-block-actions",
|
|
29
|
+
EditorCodeLanguage: "ui-editor-code-language"
|
|
29
30
|
};
|
|
30
31
|
//#endregion
|
|
31
32
|
//#region src/components/shared/overlay.js
|
|
@@ -3194,10 +3195,10 @@ var LoomaEditor = defineComponent({
|
|
|
3194
3195
|
}))
|
|
3195
3196
|
];
|
|
3196
3197
|
});
|
|
3197
|
-
const chooseCodeLanguage = (
|
|
3198
|
+
const chooseCodeLanguage = (value) => {
|
|
3198
3199
|
const instance = editor.value;
|
|
3199
|
-
if (!instance
|
|
3200
|
-
const language =
|
|
3200
|
+
if (!instance) return;
|
|
3201
|
+
const language = value === "auto" ? null : value;
|
|
3201
3202
|
if (language !== null && !codeLanguageNames.includes(language)) return;
|
|
3202
3203
|
const node = instance.state.doc.nodeAt(codeUi.pos);
|
|
3203
3204
|
if (node?.type.name !== "codeBlock") return;
|
|
@@ -4049,15 +4050,11 @@ var LoomaEditor = defineComponent({
|
|
|
4049
4050
|
class: "looma-editor__code-language",
|
|
4050
4051
|
style: codeUi.style,
|
|
4051
4052
|
onFocusout: () => updateCodeUi()
|
|
4052
|
-
}, [h(
|
|
4053
|
-
label: "Code language",
|
|
4054
|
-
labelVisibility: "sr-only",
|
|
4055
|
-
size: "sm",
|
|
4056
|
-
disclosure: true,
|
|
4057
|
-
filter: "label",
|
|
4053
|
+
}, [h(EditorCodeLanguage, {
|
|
4058
4054
|
value: codeUi.language,
|
|
4059
|
-
|
|
4060
|
-
|
|
4055
|
+
languages: codeLanguageOptions.value,
|
|
4056
|
+
onLanguage: (event) => chooseCodeLanguage(event.detail.value)
|
|
4057
|
+
})]) : null,
|
|
4061
4058
|
instance && (props.editable || props.selectionActions.length && !instance.state.selection.empty || activeRangeActions(instance).length > 0) && mobile.value && (editorFocused.value || linkOpen.value || !props.editable) ? h("div", {
|
|
4062
4059
|
key: "looma-mobile-toolbar-shell",
|
|
4063
4060
|
ref: mobileToolbarRef,
|
|
@@ -4310,4 +4307,4 @@ var LoomaEditor = defineComponent({
|
|
|
4310
4307
|
}
|
|
4311
4308
|
});
|
|
4312
4309
|
//#endregion
|
|
4313
|
-
export { EDITOR_ADAPTER_COMPONENT_TAG_MAP, EditorBlockActions, EditorImageToolbar, EditorInsertTableGrid, EditorLinkCard, EditorLinkForm, EditorMentionMenu, EditorMentionMenuItem, EditorSlashMenu, EditorSlashMenuGroup, EditorSlashMenuItem, EditorTableContextMenu, EditorTableOverlay, EditorTableToolbar, EditorToolbar, LoomaEditor };
|
|
4310
|
+
export { EDITOR_ADAPTER_COMPONENT_TAG_MAP, EditorBlockActions, EditorCodeLanguage, EditorImageToolbar, EditorInsertTableGrid, EditorLinkCard, EditorLinkForm, EditorMentionMenu, EditorMentionMenuItem, EditorSlashMenu, EditorSlashMenuGroup, EditorSlashMenuItem, EditorTableContextMenu, EditorTableOverlay, EditorTableToolbar, EditorToolbar, LoomaEditor };
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* `@threadlabs/looma/vue`, re-exported beside the editor that composes them.
|
|
4
4
|
*/
|
|
5
5
|
import type { InsertTableEventDetail, MentionMenuHighlightEventDetail, MentionMenuSelectEventDetail, SlashMenuHighlightEventDetail, SlashMenuSelectEventDetail, TableContextMenuActionEventDetail } from "@threadlabs/looma/editor";
|
|
6
|
-
export { EditorBlockActions, EditorImageToolbar, EditorInsertTableGrid, EditorLinkCard, EditorLinkForm, EditorMentionMenu, EditorMentionMenuItem, EditorSlashMenu, EditorSlashMenuGroup, EditorSlashMenuItem, EditorTableContextMenu, EditorTableOverlay, EditorTableToolbar, EditorToolbar, } from "@threadlabs/looma/vue";
|
|
6
|
+
export { EditorBlockActions, EditorCodeLanguage, EditorImageToolbar, EditorInsertTableGrid, EditorLinkCard, EditorLinkForm, EditorMentionMenu, EditorMentionMenuItem, EditorSlashMenu, EditorSlashMenuGroup, EditorSlashMenuItem, EditorTableContextMenu, EditorTableOverlay, EditorTableToolbar, EditorToolbar, } from "@threadlabs/looma/vue";
|
|
7
7
|
/** The editor components' event details, by event name. */
|
|
8
8
|
export interface VueEditorAdapterEventMap {
|
|
9
9
|
highlight: MentionMenuHighlightEventDetail | SlashMenuHighlightEventDetail;
|
|
@@ -36,6 +36,9 @@ export interface VueEditorAdapterEventMap {
|
|
|
36
36
|
clear: Record<string, never>;
|
|
37
37
|
save: Record<string, never>;
|
|
38
38
|
dismiss: Record<string, never>;
|
|
39
|
+
language: {
|
|
40
|
+
value: string;
|
|
41
|
+
};
|
|
39
42
|
"add-row-before": {
|
|
40
43
|
boundaryIndex: number;
|
|
41
44
|
};
|
|
@@ -103,4 +106,5 @@ export declare const EDITOR_ADAPTER_COMPONENT_TAG_MAP: {
|
|
|
103
106
|
readonly EditorLinkCard: "ui-editor-link-card";
|
|
104
107
|
readonly EditorLinkForm: "ui-editor-link-form";
|
|
105
108
|
readonly EditorBlockActions: "ui-editor-block-actions";
|
|
109
|
+
readonly EditorCodeLanguage: "ui-editor-code-language";
|
|
106
110
|
};
|
package/vue/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export { default as Dialog } from "./UiDialog.js";
|
|
|
20
20
|
export { default as Disclosure } from "./UiDisclosure.js";
|
|
21
21
|
export { default as Editable } from "./UiEditable.js";
|
|
22
22
|
export { default as EditorBlockActions } from "./UiEditorBlockActions.js";
|
|
23
|
+
export { default as EditorCodeLanguage } from "./UiEditorCodeLanguage.js";
|
|
23
24
|
export { default as EditorImageToolbar } from "./UiEditorImageToolbar.js";
|
|
24
25
|
export { default as EditorInsertTableGrid } from "./UiEditorInsertTableGrid.js";
|
|
25
26
|
export { default as EditorLinkCard } from "./UiEditorLinkCard.js";
|
package/vue/index.js
CHANGED
|
@@ -26,6 +26,7 @@ import { t as UiEditable_default } from "./chunks/UiEditable.js";
|
|
|
26
26
|
import { t as UiMenu_default } from "./chunks/UiMenu.js";
|
|
27
27
|
import { t as UiMenuItem_default } from "./chunks/UiMenuItem.js";
|
|
28
28
|
import { t as UiEditorBlockActions_default } from "./chunks/UiEditorBlockActions.js";
|
|
29
|
+
import { t as UiEditorCodeLanguage_default } from "./chunks/UiEditorCodeLanguage.js";
|
|
29
30
|
import { t as UiEditorToolbar_default } from "./chunks/UiEditorToolbar.js";
|
|
30
31
|
import { t as UiFormField_default } from "./chunks/UiFormField.js";
|
|
31
32
|
import { t as UiIconButton_default } from "./chunks/UiIconButton.js";
|
|
@@ -78,4 +79,4 @@ import { t as UiTopBar_default } from "./chunks/UiTopBar.js";
|
|
|
78
79
|
import { t as UiTree_default } from "./chunks/UiTree.js";
|
|
79
80
|
import { t as UiTreeItem_default } from "./chunks/UiTreeItem.js";
|
|
80
81
|
import { trackInputModality } from "@threadlabs/looma/components/shared/input-modality.js";
|
|
81
|
-
export { UiActionBar_default as ActionBar, UiAffordanceScope_default as AffordanceScope, UiAvatar_default as Avatar, UiAvatarGroup_default as AvatarGroup, UiBadge_default as Badge, UiBreadcrumbItem_default as BreadcrumbItem, UiBreadcrumbs_default as Breadcrumbs, UiButton_default as Button, UiCallout_default as Callout, UiCard_default as Card, UiCheckbox_default as Checkbox, UiCluster_default as Cluster, UiCombobox_default as Combobox, UiContainer_default as Container, UiContextMenu_default as ContextMenu, UiCover_default as Cover, UiDescriptionItem_default as DescriptionItem, UiDescriptionList_default as DescriptionList, UiDialog_default as Dialog, UiDisclosure_default as Disclosure, UiEditable_default as Editable, UiEditorBlockActions_default as EditorBlockActions, UiEditorImageToolbar_default as EditorImageToolbar, UiEditorInsertTableGrid_default as EditorInsertTableGrid, UiEditorLinkCard_default as EditorLinkCard, UiEditorLinkForm_default as EditorLinkForm, UiEditorMentionMenu_default as EditorMentionMenu, UiEditorMentionMenuItem_default as EditorMentionMenuItem, UiEditorSlashMenu_default as EditorSlashMenu, UiEditorSlashMenuGroup_default as EditorSlashMenuGroup, UiEditorSlashMenuItem_default as EditorSlashMenuItem, UiEditorSurface_default as EditorSurface, UiEditorTableContextMenu_default as EditorTableContextMenu, UiEditorTableOverlay_default as EditorTableOverlay, UiEditorTableToolbar_default as EditorTableToolbar, UiEditorToolbar_default as EditorToolbar, UiFloatingActionButton_default as FloatingActionButton, UiFormField_default as FormField, UiGrid_default as Grid, UiIcon_default as Icon, UiIconButton_default as IconButton, UiImage_default as Image, UiInput_default as Input, UiInputGroup_default as InputGroup, UiList_default as List, UiListItem_default as ListItem, UiListbox_default as Listbox, UiMenu_default as Menu, UiMenuGroup_default as MenuGroup, UiMenuItem_default as MenuItem, UiMeter_default as Meter, UiNavItem_default as NavItem, UiPageHeader_default as PageHeader, UiPopover_default as Popover, UiRadio_default as Radio, UiRadioGroup_default as RadioGroup, UiReel_default as Reel, UiScrollArea_default as ScrollArea, UiSearchResultRow_default as SearchResultRow, UiSearchShell_default as SearchShell, UiSection_default as Section, UiSelect_default as Select, UiSeparator_default as Separator, UiSidebar_default as Sidebar, UiSpinner_default as Spinner, UiStack_default as Stack, UiStatusMessage_default as StatusMessage, UiSwitch_default as Switch, UiSwitcher_default as Switcher, UiTable_default as Table, UiTabs_default as Tabs, UiText_default as Text, UiTextarea_default as Textarea, UiToast_default as Toast, UiToastRegion_default as ToastRegion, UiTooltip_default as Tooltip, UiTopBar_default as TopBar, UiTree_default as Tree, UiTreeItem_default as TreeItem, trackInputModality };
|
|
82
|
+
export { UiActionBar_default as ActionBar, UiAffordanceScope_default as AffordanceScope, UiAvatar_default as Avatar, UiAvatarGroup_default as AvatarGroup, UiBadge_default as Badge, UiBreadcrumbItem_default as BreadcrumbItem, UiBreadcrumbs_default as Breadcrumbs, UiButton_default as Button, UiCallout_default as Callout, UiCard_default as Card, UiCheckbox_default as Checkbox, UiCluster_default as Cluster, UiCombobox_default as Combobox, UiContainer_default as Container, UiContextMenu_default as ContextMenu, UiCover_default as Cover, UiDescriptionItem_default as DescriptionItem, UiDescriptionList_default as DescriptionList, UiDialog_default as Dialog, UiDisclosure_default as Disclosure, UiEditable_default as Editable, UiEditorBlockActions_default as EditorBlockActions, UiEditorCodeLanguage_default as EditorCodeLanguage, UiEditorImageToolbar_default as EditorImageToolbar, UiEditorInsertTableGrid_default as EditorInsertTableGrid, UiEditorLinkCard_default as EditorLinkCard, UiEditorLinkForm_default as EditorLinkForm, UiEditorMentionMenu_default as EditorMentionMenu, UiEditorMentionMenuItem_default as EditorMentionMenuItem, UiEditorSlashMenu_default as EditorSlashMenu, UiEditorSlashMenuGroup_default as EditorSlashMenuGroup, UiEditorSlashMenuItem_default as EditorSlashMenuItem, UiEditorSurface_default as EditorSurface, UiEditorTableContextMenu_default as EditorTableContextMenu, UiEditorTableOverlay_default as EditorTableOverlay, UiEditorTableToolbar_default as EditorTableToolbar, UiEditorToolbar_default as EditorToolbar, UiFloatingActionButton_default as FloatingActionButton, UiFormField_default as FormField, UiGrid_default as Grid, UiIcon_default as Icon, UiIconButton_default as IconButton, UiImage_default as Image, UiInput_default as Input, UiInputGroup_default as InputGroup, UiList_default as List, UiListItem_default as ListItem, UiListbox_default as Listbox, UiMenu_default as Menu, UiMenuGroup_default as MenuGroup, UiMenuItem_default as MenuItem, UiMeter_default as Meter, UiNavItem_default as NavItem, UiPageHeader_default as PageHeader, UiPopover_default as Popover, UiRadio_default as Radio, UiRadioGroup_default as RadioGroup, UiReel_default as Reel, UiScrollArea_default as ScrollArea, UiSearchResultRow_default as SearchResultRow, UiSearchShell_default as SearchShell, UiSection_default as Section, UiSelect_default as Select, UiSeparator_default as Separator, UiSidebar_default as Sidebar, UiSpinner_default as Spinner, UiStack_default as Stack, UiStatusMessage_default as StatusMessage, UiSwitch_default as Switch, UiSwitcher_default as Switcher, UiTable_default as Table, UiTabs_default as Tabs, UiText_default as Text, UiTextarea_default as Textarea, UiToast_default as Toast, UiToastRegion_default as ToastRegion, UiTooltip_default as Tooltip, UiTopBar_default as TopBar, UiTree_default as Tree, UiTreeItem_default as TreeItem, trackInputModality };
|