@nuxt-atelier/editor 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ano Rebel
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,7 @@
1
- # Temporary Holding Version
1
+ # @nuxt-atelier/editor
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Visual editor for Nuxt Atelier
4
+
5
+ Part of [Nuxt Atelier](https://nuxt-atelier.anorebel.net), a visual CMS for Nuxt. See the [documentation](https://nuxt-atelier.anorebel.net) to get started, or try the [live demo](https://nuxt-atelier-demo.anorebel.net).
6
+
7
+ MIT License
@@ -0,0 +1,14 @@
1
+ import { NuxtModule } from '@nuxt/schema';
2
+
3
+ interface ViewportPreset {
4
+ label: string;
5
+ width: number;
6
+ }
7
+ interface ModuleOptions {
8
+ /** The preview's widths to switch between (a custom width is always offered). */
9
+ presets?: ViewportPreset[];
10
+ }
11
+ declare const module$1: NuxtModule<ModuleOptions>;
12
+
13
+ export { module$1 as default };
14
+ export type { ModuleOptions, ViewportPreset };
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "@nuxt-atelier/editor",
3
+ "configKey": "atelierEditor",
4
+ "compatibility": {
5
+ "nuxt": ">=4.6.0"
6
+ },
7
+ "version": "0.1.0",
8
+ "builder": {
9
+ "@nuxt/module-builder": "1.0.3",
10
+ "unbuild": "unknown"
11
+ }
12
+ }
@@ -0,0 +1,27 @@
1
+ import { defineNuxtModule, createResolver, hasNuxtModule, useLogger } from '@nuxt/kit';
2
+
3
+ const module$1 = defineNuxtModule({
4
+ meta: {
5
+ name: "@nuxt-atelier/editor",
6
+ configKey: "atelierEditor",
7
+ compatibility: {
8
+ nuxt: ">=4.6.0"
9
+ }
10
+ },
11
+ defaults: { presets: [{ label: "Desktop", width: 1280 }, { label: "Tablet", width: 768 }, { label: "Mobile", width: 375 }] },
12
+ setup(options, nuxt) {
13
+ const { resolve } = createResolver(import.meta.url);
14
+ nuxt.hook("modules:done", () => {
15
+ if (!hasNuxtModule("@nuxt-atelier/admin", nuxt))
16
+ useLogger("@nuxt-atelier/editor").warn("The visual editor is part of the admin: add @nuxt-atelier/admin to your modules.");
17
+ });
18
+ nuxt.options.alias["#atelier-editor"] = resolve("./runtime/commands");
19
+ nuxt.options.alias["#atelier-inline-rich"] = resolve("./runtime/inline-rich");
20
+ nuxt.options.runtimeConfig.public.atelierEditor = { presets: options.presets ?? [] };
21
+ nuxt.hook("atelier:admin:pages", (pages) => {
22
+ pages.push({ path: "edit", label: "Visual editor", icon: "layout-dashboard", hidden: true, component: resolve("./runtime/VisualEditor.vue") });
23
+ });
24
+ }
25
+ });
26
+
27
+ export { module$1 as default };
@@ -0,0 +1,17 @@
1
+ import type { EditorCommand } from './commands.js';
2
+ type __VLS_Props = {
3
+ commands: EditorCommand[];
4
+ };
5
+ type __VLS_ModelProps = {
6
+ 'open'?: boolean;
7
+ };
8
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
9
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
+ run: (command: EditorCommand) => any;
11
+ "update:open": (value: boolean) => any;
12
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
13
+ onRun?: ((command: EditorCommand) => any) | undefined;
14
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
15
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
16
+ declare const _default: typeof __VLS_export;
17
+ export default _default;
@@ -0,0 +1,98 @@
1
+ <script setup>
2
+ import { computed, nextTick, ref, watch } from "vue";
3
+ import { useAdminI18n } from "#imports";
4
+ import CnModal from "#atelier-admin-runtime/crystal-neuo/components/Modal.vue";
5
+ const props = defineProps({
6
+ commands: { type: Array, required: true }
7
+ });
8
+ const emit = defineEmits(["run"]);
9
+ const open = defineModel("open", { type: Boolean, ...{ default: false } });
10
+ const { t } = useAdminI18n();
11
+ const text = ref("");
12
+ const active = ref(0);
13
+ const input = ref(null);
14
+ const shown = computed(() => {
15
+ const words = text.value.toLowerCase().split(/\s+/).filter(Boolean);
16
+ return props.commands.filter((c) => words.every((w) => `${c.label} ${c.group ?? ""}`.toLowerCase().includes(w)));
17
+ });
18
+ watch(shown, () => active.value = 0);
19
+ watch(open, async (isOpen) => {
20
+ if (isOpen) {
21
+ text.value = "";
22
+ await nextTick();
23
+ input.value?.focus();
24
+ }
25
+ });
26
+ function run(command) {
27
+ if (!command)
28
+ return;
29
+ open.value = false;
30
+ emit("run", command);
31
+ }
32
+ function onKey(e) {
33
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
34
+ e.preventDefault();
35
+ const n = shown.value.length;
36
+ if (n)
37
+ active.value = (active.value + (e.key === "ArrowDown" ? 1 : n - 1)) % n;
38
+ } else if (e.key === "Enter") {
39
+ e.preventDefault();
40
+ run(shown.value[active.value]);
41
+ }
42
+ }
43
+ </script>
44
+
45
+ <template>
46
+ <CnModal
47
+ v-model:open="open"
48
+ :title="t('editor.commands')"
49
+ size="lg"
50
+ >
51
+ <div class="app-stack app-global-search">
52
+ <input
53
+ ref="input"
54
+ v-model="text"
55
+ class="cn-input"
56
+ type="search"
57
+ role="combobox"
58
+ aria-autocomplete="list"
59
+ aria-controls="atelier-editor-commands"
60
+ :aria-expanded="shown.length > 0"
61
+ :aria-activedescendant="shown[active] ? `atelier-cmd-${active}` : void 0"
62
+ :aria-label="t('editor.commandsLabel')"
63
+ :placeholder="t('editor.commandsLabel')"
64
+ @keydown="onKey"
65
+ >
66
+ <ul
67
+ id="atelier-editor-commands"
68
+ role="listbox"
69
+ class="app-list app-global-search__results"
70
+ :aria-label="t('editor.commands')"
71
+ >
72
+ <li
73
+ v-for="(command, i) in shown"
74
+ :id="`atelier-cmd-${i}`"
75
+ :key="command.id"
76
+ role="option"
77
+ :aria-selected="i === active"
78
+ class="app-global-search__option"
79
+ @mousemove="active = i"
80
+ @click="run(command)"
81
+ >
82
+ <span class="app-global-search__title">{{ command.label }}</span>
83
+ <span
84
+ v-if="command.group"
85
+ class="app-muted"
86
+ >{{ command.group }}</span>
87
+ </li>
88
+ </ul>
89
+ <p
90
+ v-if="!shown.length"
91
+ class="app-muted"
92
+ role="status"
93
+ >
94
+ {{ t("editor.noCommands") }}
95
+ </p>
96
+ </div>
97
+ </CnModal>
98
+ </template>
@@ -0,0 +1,17 @@
1
+ import type { EditorCommand } from './commands.js';
2
+ type __VLS_Props = {
3
+ commands: EditorCommand[];
4
+ };
5
+ type __VLS_ModelProps = {
6
+ 'open'?: boolean;
7
+ };
8
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
9
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
+ run: (command: EditorCommand) => any;
11
+ "update:open": (value: boolean) => any;
12
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
13
+ onRun?: ((command: EditorCommand) => any) | undefined;
14
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
15
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
16
+ declare const _default: typeof __VLS_export;
17
+ export default _default;
@@ -0,0 +1,21 @@
1
+ import type { BlockList } from './tree.js';
2
+ type __VLS_Props = {
3
+ list: BlockList;
4
+ selected: string | null;
5
+ hovered: string | null;
6
+ depth: number;
7
+ emptyLabel: string;
8
+ };
9
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
+ select: (id: string) => any;
11
+ hover: (id: string | null) => any;
12
+ move: (id: string, by: 1 | -1) => any;
13
+ remove: (id: string) => any;
14
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
15
+ onSelect?: ((id: string) => any) | undefined;
16
+ onHover?: ((id: string | null) => any) | undefined;
17
+ onMove?: ((id: string, by: 1 | -1) => any) | undefined;
18
+ onRemove?: ((id: string) => any) | undefined;
19
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
20
+ declare const _default: typeof __VLS_export;
21
+ export default _default;
@@ -0,0 +1,98 @@
1
+ <script setup>
2
+ import { inject } from "vue";
3
+ import { dndKey } from "./dnd";
4
+ import StructureList from "./StructureList.vue";
5
+ defineOptions({ name: "AtelierEditorStructureList" });
6
+ const props = defineProps({
7
+ list: { type: Object, required: true },
8
+ selected: { type: [String, null], required: true },
9
+ hovered: { type: [String, null], required: true },
10
+ depth: { type: Number, required: true },
11
+ emptyLabel: { type: String, required: true }
12
+ });
13
+ const emit = defineEmits(["select", "hover", "move", "remove"]);
14
+ const dnd = inject(dndKey);
15
+ function onKey(event, id) {
16
+ if (event.altKey && (event.key === "ArrowUp" || event.key === "ArrowDown")) {
17
+ event.preventDefault();
18
+ emit("move", id, event.key === "ArrowUp" ? -1 : 1);
19
+ } else if (event.key === "Delete") {
20
+ event.preventDefault();
21
+ emit("remove", id);
22
+ }
23
+ }
24
+ function overBlock(event, index) {
25
+ const rect = event.currentTarget.getBoundingClientRect();
26
+ dnd.over(event, { list: props.list.path, index: event.clientY < rect.top + rect.height / 2 ? index : index + 1 });
27
+ }
28
+ const lineAt = (index) => dnd.dropAt.value?.list === props.list.path && dnd.dropAt.value.index === index;
29
+ </script>
30
+
31
+ <template>
32
+ <ul
33
+ class="ate-tree"
34
+ :aria-label="list.label"
35
+ :data-list="list.path"
36
+ >
37
+ <li
38
+ v-for="(block, index) in list.blocks"
39
+ :key="block.id"
40
+ class="ate-tree__item"
41
+ :data-drop-before="lineAt(index) ? '' : void 0"
42
+ :data-drop-after="index === list.blocks.length - 1 && lineAt(index + 1) ? '' : void 0"
43
+ >
44
+ <button
45
+ type="button"
46
+ class="ate-tree__block"
47
+ draggable="true"
48
+ :aria-pressed="selected === block.id"
49
+ :data-tree-block="block.id"
50
+ :data-hovered="hovered === block.id ? '' : void 0"
51
+ :style="{ paddingInlineStart: `${0.5 + depth}rem` }"
52
+ @click="emit('select', block.id)"
53
+ @keydown="onKey($event, block.id)"
54
+ @pointerenter="emit('hover', block.id)"
55
+ @pointerleave="emit('hover', null)"
56
+ @dragstart="dnd.start($event, { kind: 'block', id: block.id })"
57
+ @dragend="dnd.end()"
58
+ @dragover.stop="overBlock($event, index)"
59
+ @drop.stop="dnd.drop($event)"
60
+ >
61
+ {{ block.label }}
62
+ </button>
63
+ <template
64
+ v-for="area in block.areas"
65
+ :key="area.path"
66
+ >
67
+ <p
68
+ class="ate-tree__area"
69
+ :style="{ paddingInlineStart: `${1 + depth}rem` }"
70
+ >
71
+ {{ area.label }}
72
+ </p>
73
+ <StructureList
74
+ :list="area"
75
+ :selected="selected"
76
+ :hovered="hovered"
77
+ :depth="depth + 1"
78
+ :empty-label="emptyLabel"
79
+ @select="emit('select', $event)"
80
+ @hover="emit('hover', $event)"
81
+ @move="(id, by) => emit('move', id, by)"
82
+ @remove="emit('remove', $event)"
83
+ />
84
+ </template>
85
+ </li>
86
+ <li
87
+ v-if="!list.blocks.length"
88
+ class="ate-tree__empty"
89
+ :style="{ paddingInlineStart: `${0.5 + depth}rem` }"
90
+ :data-drop-before="lineAt(0) ? '' : void 0"
91
+ data-drop-zone
92
+ @dragover.stop="dnd.over($event, { list: list.path, index: 0 })"
93
+ @drop.stop="dnd.drop($event)"
94
+ >
95
+ {{ emptyLabel }}
96
+ </li>
97
+ </ul>
98
+ </template>
@@ -0,0 +1,21 @@
1
+ import type { BlockList } from './tree.js';
2
+ type __VLS_Props = {
3
+ list: BlockList;
4
+ selected: string | null;
5
+ hovered: string | null;
6
+ depth: number;
7
+ emptyLabel: string;
8
+ };
9
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
+ select: (id: string) => any;
11
+ hover: (id: string | null) => any;
12
+ move: (id: string, by: 1 | -1) => any;
13
+ remove: (id: string) => any;
14
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
15
+ onSelect?: ((id: string) => any) | undefined;
16
+ onHover?: ((id: string | null) => any) | undefined;
17
+ onMove?: ((id: string, by: 1 | -1) => any) | undefined;
18
+ onRemove?: ((id: string) => any) | undefined;
19
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
20
+ declare const _default: typeof __VLS_export;
21
+ export default _default;
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;