rimelight-components 2.0.47 → 2.0.48

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 (59) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +4 -2
  3. package/dist/runtime/components/app/ScrollToTop.d.vue.ts +4 -1
  4. package/dist/runtime/components/app/ScrollToTop.vue.d.ts +4 -1
  5. package/dist/runtime/components/blocks/Block.d.vue.ts +4 -17
  6. package/dist/runtime/components/blocks/Block.vue +25 -46
  7. package/dist/runtime/components/blocks/Block.vue.d.ts +4 -17
  8. package/dist/runtime/components/blocks/BlockEditRenderer.vue +55 -0
  9. package/dist/runtime/components/blocks/BlockEditor.d.vue.ts +15 -0
  10. package/dist/runtime/components/blocks/BlockEditor.vue +110 -0
  11. package/dist/runtime/components/blocks/BlockEditor.vue.d.ts +15 -0
  12. package/dist/runtime/components/{renderers/BlockRenderer.vue → blocks/BlockViewRenderer.vue} +21 -18
  13. package/dist/runtime/components/blocks/editor/CalloutBlockEditor.vue +1 -1
  14. package/dist/runtime/components/blocks/editor/CardBlockEditor.vue +1 -1
  15. package/dist/runtime/components/blocks/editor/ParagraphBlockEditor.d.vue.ts +5 -2
  16. package/dist/runtime/components/blocks/editor/ParagraphBlockEditor.vue +53 -5
  17. package/dist/runtime/components/blocks/editor/ParagraphBlockEditor.vue.d.ts +5 -2
  18. package/dist/runtime/components/blocks/editor/SectionBlockEditor.d.vue.ts +5 -2
  19. package/dist/runtime/components/blocks/editor/SectionBlockEditor.vue +101 -45
  20. package/dist/runtime/components/blocks/editor/SectionBlockEditor.vue.d.ts +5 -2
  21. package/dist/runtime/components/blocks/editor/TestBlockEditor.d.vue.ts +7 -0
  22. package/dist/runtime/components/blocks/editor/TestBlockEditor.vue +44 -0
  23. package/dist/runtime/components/blocks/editor/TestBlockEditor.vue.d.ts +7 -0
  24. package/dist/runtime/components/blocks/renderer/CalloutBlockRenderer.vue +1 -1
  25. package/dist/runtime/components/blocks/renderer/CardBlockRenderer.vue +1 -1
  26. package/dist/runtime/components/blocks/renderer/ParagraphBlockRenderer.vue +1 -3
  27. package/dist/runtime/components/blocks/renderer/SectionBlockRenderer.vue +2 -1
  28. package/dist/runtime/components/blocks/renderer/TestBlockRenderer.d.vue.ts +4 -0
  29. package/dist/runtime/components/blocks/renderer/TestBlockRenderer.vue +9 -0
  30. package/dist/runtime/components/blocks/renderer/TestBlockRenderer.vue.d.ts +4 -0
  31. package/dist/runtime/components/cards/TeamCard.d.vue.ts +2 -2
  32. package/dist/runtime/components/cards/TeamCard.vue.d.ts +2 -2
  33. package/dist/runtime/components/content/Callout.d.vue.ts +2 -2
  34. package/dist/runtime/components/content/Callout.vue.d.ts +2 -2
  35. package/dist/runtime/components/content/Section.d.vue.ts +5 -5
  36. package/dist/runtime/components/content/Section.vue +13 -8
  37. package/dist/runtime/components/content/Section.vue.d.ts +5 -5
  38. package/dist/runtime/components/content/Test.d.vue.ts +16 -0
  39. package/dist/runtime/components/content/Test.vue +13 -0
  40. package/dist/runtime/components/content/Test.vue.d.ts +16 -0
  41. package/dist/runtime/composables/useBlockEditor.d.ts +27233 -0
  42. package/dist/runtime/composables/useBlockEditor.js +163 -0
  43. package/dist/runtime/types/blocks.d.ts +9 -2
  44. package/dist/runtime/utils/richTextHelpers.d.ts +16 -0
  45. package/dist/runtime/utils/richTextHelpers.js +17 -0
  46. package/package.json +19 -21
  47. package/dist/runtime/components/renderers/BlockEditor.vue +0 -63
  48. package/dist/runtime/composables/useBlockContentEditor.d.ts +0 -32
  49. package/dist/runtime/composables/useBlockContentEditor.js +0 -63
  50. /package/dist/runtime/components/{renderers/BlockEditor.d.vue.ts → blocks/BlockEditRenderer.d.vue.ts} +0 -0
  51. /package/dist/runtime/components/{renderers/BlockEditor.vue.d.ts → blocks/BlockEditRenderer.vue.d.ts} +0 -0
  52. /package/dist/runtime/components/{renderers/BlockRenderer.d.vue.ts → blocks/BlockViewRenderer.d.vue.ts} +0 -0
  53. /package/dist/runtime/components/{renderers/BlockRenderer.vue.d.ts → blocks/BlockViewRenderer.vue.d.ts} +0 -0
  54. /package/dist/runtime/components/{renderers → blocks}/TOC.d.vue.ts +0 -0
  55. /package/dist/runtime/components/{renderers → blocks}/TOC.vue +0 -0
  56. /package/dist/runtime/components/{renderers → blocks}/TOC.vue.d.ts +0 -0
  57. /package/dist/runtime/components/{renderers → blocks}/TextRenderer.d.vue.ts +0 -0
  58. /package/dist/runtime/components/{renderers → blocks}/TextRenderer.vue +0 -0
  59. /package/dist/runtime/components/{renderers → blocks}/TextRenderer.vue.d.ts +0 -0
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rimelight-components",
3
- "version": "2.0.47",
3
+ "version": "2.0.48",
4
4
  "docs": "https://rimelight.com/tools/rimelight-components",
5
5
  "configKey": "rimelightComponents",
6
6
  "compatibility": {
package/dist/module.mjs CHANGED
@@ -1,10 +1,10 @@
1
- import { addTemplate, defineNuxtModule, createResolver, addComponentsDir, addImportsDir } from '@nuxt/kit';
1
+ import { addTemplate, defineNuxtModule, createResolver, installModule, addComponentsDir, addImportsDir } from '@nuxt/kit';
2
2
  import { defu } from 'defu';
3
3
  import { readdirSync } from 'node:fs';
4
4
  import { basename } from 'node:path';
5
5
 
6
6
  const name = "rimelight-components";
7
- const version = "2.0.47";
7
+ const version = "2.0.48";
8
8
  const homepage = "https://rimelight.com/tools/rimelight-components";
9
9
 
10
10
  const defaultOptions = {
@@ -197,6 +197,8 @@ const module$1 = defineNuxtModule().with({
197
197
  nuxt.options.appConfig.rimelightComponents || {},
198
198
  options
199
199
  );
200
+ nuxt.options.build.transpile.push("@nuxt/ui");
201
+ installModule("@nuxt/ui");
200
202
  addComponentsDir({
201
203
  path: resolve("./runtime/components/"),
202
204
  pathPrefix: false,
@@ -2,6 +2,9 @@ interface Props {
2
2
  circleStrokeWidth?: number;
3
3
  duration?: number;
4
4
  }
5
- declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
5
+ declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
6
+ circleStrokeWidth: number;
7
+ duration: number;
8
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
9
  declare const _default: typeof __VLS_export;
7
10
  export default _default;
@@ -2,6 +2,9 @@ interface Props {
2
2
  circleStrokeWidth?: number;
3
3
  duration?: number;
4
4
  }
5
- declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
5
+ declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
6
+ circleStrokeWidth: number;
7
+ duration: number;
8
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
9
  declare const _default: typeof __VLS_export;
7
10
  export default _default;
@@ -1,25 +1,12 @@
1
1
  type __VLS_Props = {
2
2
  id: string;
3
+ type: string;
3
4
  };
4
- declare var __VLS_13: {};
5
+ declare var __VLS_12: {};
5
6
  type __VLS_Slots = {} & {
6
- default?: (props: typeof __VLS_13) => any;
7
+ default?: (props: typeof __VLS_12) => any;
7
8
  };
8
- declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
9
- moveBlockUp: (id: string) => any;
10
- moveBlockDown: (id: string) => any;
11
- addBlockAbove: (id: string) => any;
12
- addBlockBelow: (id: string) => any;
13
- duplicateBlock: (id: string) => any;
14
- deleteBlock: (id: string) => any;
15
- }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
16
- onMoveBlockUp?: ((id: string) => any) | undefined;
17
- onMoveBlockDown?: ((id: string) => any) | undefined;
18
- onAddBlockAbove?: ((id: string) => any) | undefined;
19
- onAddBlockBelow?: ((id: string) => any) | undefined;
20
- onDuplicateBlock?: ((id: string) => any) | undefined;
21
- onDeleteBlock?: ((id: string) => any) | undefined;
22
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
23
10
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
24
11
  declare const _default: typeof __VLS_export;
25
12
  export default _default;
@@ -1,89 +1,68 @@
1
1
  <script setup>
2
- import { ref } from "vue";
3
- const {
4
- id
5
- } = defineProps({
6
- id: { type: String, required: true }
2
+ import { inject, computed, ref } from "vue";
3
+ const editorApi = inject("block-editor-api");
4
+ if (!editorApi) {
5
+ throw new Error("RCBlock must be used within a BlockEditor component");
6
+ }
7
+ const { id, type } = defineProps({
8
+ id: { type: String, required: true },
9
+ type: { type: String, required: true }
7
10
  });
8
- const emit = defineEmits(["moveBlockUp", "moveBlockDown", "addBlockAbove", "addBlockBelow", "duplicateBlock", "deleteBlock"]);
9
- const handleMoveBlockUp = () => {
10
- emit("moveBlockUp", id);
11
- console.log(`Emitting 'moveBlockUp' for ID: ${id}`);
12
- };
13
- const handleMoveBlockDown = () => {
14
- emit("moveBlockDown", id);
15
- console.log(`Emitting 'moveBlockDown' for ID: ${id}`);
16
- };
17
- const handleAddBlockAbove = () => {
18
- emit("addBlockAbove", id);
19
- console.log(`Emitting 'addBlockAbove' for ID: ${id}`);
20
- };
21
- const handleAddBlockBelow = () => {
22
- emit("addBlockBelow", id);
23
- console.log(`Emitting 'addBlockBelow' for ID: ${id}`);
24
- };
25
- const handleDuplicateBlock = () => {
26
- emit("duplicateBlock", id);
27
- console.log(`Emitting 'duplicateBlock' for ID: ${id}`);
28
- };
29
- const handleDeleteBlock = () => {
30
- emit("deleteBlock", id);
31
- console.log(`Emitting 'deleteBlock' for ID: ${id}`);
32
- };
11
+ const onDelete = () => editorApi.removeBlock(id);
12
+ const onDuplicate = () => editorApi.duplicateBlock(id);
13
+ const onMoveUp = () => editorApi.moveBlock(id, -1);
14
+ const onMoveDown = () => editorApi.moveBlock(id, 1);
33
15
  const items = ref([
34
16
  [
35
17
  {
36
18
  icon: "lucide:arrow-up",
37
19
  label: "Move Block Up",
38
- click: handleMoveBlockUp
20
+ click: onMoveUp
39
21
  },
40
22
  {
41
23
  icon: "lucide:arrow-down",
42
24
  label: "Move Block Down",
43
- click: handleMoveBlockDown
25
+ click: onMoveDown
44
26
  }
45
27
  ],
46
28
  [
47
29
  {
48
30
  icon: "lucide:corner-right-up",
49
- label: "Add Block Above",
50
- click: handleAddBlockAbove
31
+ label: "Add Block Above"
32
+ //click: handleAddBlockAbove
51
33
  },
52
34
  {
53
35
  icon: "lucide:corner-right-down",
54
- label: "Add Block Below",
55
- click: handleAddBlockBelow
36
+ label: "Add Block Below"
37
+ //click: handleAddBlockBelow
56
38
  }
57
39
  ],
58
40
  [
59
41
  {
60
42
  icon: "lucide:copy-plus",
61
43
  label: "Duplicate Block",
62
- click: handleDuplicateBlock
44
+ click: onDuplicate
63
45
  },
64
46
  {
65
47
  color: "error",
66
48
  icon: "lucide:trash-2",
67
49
  label: "Delete Block",
68
- click: handleDeleteBlock
50
+ click: onDelete
69
51
  }
70
52
  ]
71
53
  ]);
72
54
  </script>
73
55
 
74
56
  <template>
75
- <div class="relative group">
57
+ <div class="group relative">
76
58
  <div
77
- class=" absolute top-0 -ms-10 left-0
78
- z-10 opacity-0 group-hover:opacity-100 transition-opacity"
59
+ class="absolute top-0 left-0 z-10 -ms-10 opacity-0 transition-opacity group-hover:opacity-100"
79
60
  >
80
- <UDropdownMenu
81
- :items="items"
82
- >
83
- <UButton icon="lucide:grip-vertical" variant="ghost" color="neutral"/>
61
+ <UDropdownMenu :items="items">
62
+ <UButton icon="lucide:grip-vertical" variant="ghost" color="neutral" />
84
63
  </UDropdownMenu>
85
64
  </div>
86
65
 
87
- <slot/>
66
+ <slot />
88
67
  </div>
89
68
  </template>
@@ -1,25 +1,12 @@
1
1
  type __VLS_Props = {
2
2
  id: string;
3
+ type: string;
3
4
  };
4
- declare var __VLS_13: {};
5
+ declare var __VLS_12: {};
5
6
  type __VLS_Slots = {} & {
6
- default?: (props: typeof __VLS_13) => any;
7
+ default?: (props: typeof __VLS_12) => any;
7
8
  };
8
- declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
9
- moveBlockUp: (id: string) => any;
10
- moveBlockDown: (id: string) => any;
11
- addBlockAbove: (id: string) => any;
12
- addBlockBelow: (id: string) => any;
13
- duplicateBlock: (id: string) => any;
14
- deleteBlock: (id: string) => any;
15
- }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
16
- onMoveBlockUp?: ((id: string) => any) | undefined;
17
- onMoveBlockDown?: ((id: string) => any) | undefined;
18
- onAddBlockAbove?: ((id: string) => any) | undefined;
19
- onAddBlockBelow?: ((id: string) => any) | undefined;
20
- onDuplicateBlock?: ((id: string) => any) | undefined;
21
- onDeleteBlock?: ((id: string) => any) | undefined;
22
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
23
10
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
24
11
  declare const _default: typeof __VLS_export;
25
12
  export default _default;
@@ -0,0 +1,55 @@
1
+ <script setup>
2
+ import {} from "vue";
3
+ import { getBlockEditorComponent } from "../../utils/blockMapper";
4
+ const { blocks } = defineProps({
5
+ blocks: { type: Array, required: true }
6
+ });
7
+ const getComponent = (block) => {
8
+ if (!block || !block.type || block.type.length === 0) {
9
+ console.error("Block object is missing the critical 'type' field.");
10
+ return null;
11
+ }
12
+ const resolvedComponent = getBlockEditorComponent(block.type);
13
+ if (!resolvedComponent) {
14
+ console.error(`Component resolution failed for block type: ${block.type}`);
15
+ return null;
16
+ }
17
+ return resolvedComponent;
18
+ };
19
+ </script>
20
+
21
+ <template>
22
+ <div class="flex flex-col gap-lg w-full">
23
+ <UEmpty
24
+ v-if="!blocks || blocks.length === 0"
25
+ variant="naked"
26
+ icon="lucide:blocks"
27
+ title="No blocks found for this page."
28
+ description="It looks like there isn't any content added to this page yet."
29
+ />
30
+ <template v-else>
31
+ <template v-for="block in blocks" :key="block.id">
32
+ <template v-if="getComponent(block)">
33
+ <RCBlock :id="block.id" :type="block.type" class="w-full">
34
+ <component
35
+ :is="getComponent(block)"
36
+ :id="block.id"
37
+ v-bind="block.props"
38
+ :type="block.type"
39
+ class="w-full"
40
+ />
41
+ </RCBlock>
42
+ </template>
43
+ <template v-else>
44
+ <UAlert
45
+ color="error"
46
+ variant="subtle"
47
+ icon="lucide:octagon-alert"
48
+ title="Rendering Error"
49
+ :description="`Block component for type \'${block.type || 'UNKNOWN_OR_MISSING'}\' was not found. This block will be skipped or the type is invalid/empty.`"
50
+ />
51
+ </template>
52
+ </template>
53
+ </template>
54
+ </div>
55
+ </template>
@@ -0,0 +1,15 @@
1
+ import type { Block } from "../../types/blocks.js";
2
+ type __VLS_ModelProps = {
3
+ modelValue: Block[];
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
6
+ "update:modelValue": (value: Block[]) => any;
7
+ } & {
8
+ "update:modelValue": (value: Block[]) => any;
9
+ save: () => any;
10
+ }, string, import("vue").PublicProps, Readonly<__VLS_ModelProps> & Readonly<{
11
+ "onUpdate:modelValue"?: ((value: Block[]) => any) | undefined;
12
+ onSave?: (() => any) | undefined;
13
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
+ declare const _default: typeof __VLS_export;
15
+ export default _default;
@@ -0,0 +1,110 @@
1
+ <script setup>
2
+ import { provide, ref, computed } from "vue";
3
+ import { useBlockEditor } from "../../composables/useBlockEditor";
4
+ const blocks = defineModel({ type: Array, ...{ required: true } });
5
+ const emit = defineEmits(["update:modelValue", "save"]);
6
+ const {
7
+ removeBlock,
8
+ moveBlock,
9
+ duplicateBlock,
10
+ updateBlockProps,
11
+ insertBlock,
12
+ undo,
13
+ redo,
14
+ canUndo,
15
+ canRedo
16
+ } = useBlockEditor(blocks);
17
+ provide("block-editor-api", {
18
+ removeBlock,
19
+ moveBlock,
20
+ duplicateBlock,
21
+ updateBlockProps,
22
+ insertBlock,
23
+ canUndo,
24
+ canRedo,
25
+ undo,
26
+ redo
27
+ });
28
+ const handleSave = () => {
29
+ emit("save");
30
+ };
31
+ const showPreview = ref(false);
32
+ const gridClass = computed(() => ({
33
+ // The base grid: transitions enable smooth resizing
34
+ "grid transition-[grid-template-columns] duration-300 ease-out": true,
35
+ // When hidden, use a single column (Editor takes full width)
36
+ "grid-cols-1": !showPreview.value,
37
+ // When visible, use two equal columns (Editor + Preview)
38
+ "grid-cols-2 gap-xl": showPreview.value
39
+ }));
40
+ const editorPanelClass = computed(() => ({
41
+ // When preview is visible, both editor/preview share 1/2 span.
42
+ "col-span-1 w-full": showPreview.value,
43
+ // When preview is hidden, the editor uses the full grid space.
44
+ "col-span-2 w-full": !showPreview.value
45
+ }));
46
+ const togglePreview = () => {
47
+ showPreview.value = !showPreview.value;
48
+ };
49
+ const undoAction = () => {
50
+ if (canUndo.value) {
51
+ undo();
52
+ }
53
+ };
54
+ const redoAction = () => {
55
+ if (canRedo.value) {
56
+ redo();
57
+ }
58
+ };
59
+ </script>
60
+
61
+ <template>
62
+ <div class="mb-lg flex justify-between pr-8">
63
+
64
+ <div class="flex items-center gap-sm">
65
+ <UButton
66
+ icon="lucide:rotate-ccw"
67
+ label="Undo"
68
+ variant="outline"
69
+ color="neutral"
70
+ :disabled="!canUndo"
71
+ @click="undoAction"
72
+ />
73
+ <UButton
74
+ icon="lucide:rotate-cw"
75
+ label="Redo"
76
+ variant="outline"
77
+ color="neutral"
78
+ :disabled="!canRedo"
79
+ @click="redoAction"
80
+ />
81
+ </div>
82
+
83
+ <UButton
84
+ :icon="showPreview ? 'lucide:eye-off' : 'lucide:eye'"
85
+ :label="showPreview ? 'Hide Preview' : 'Show Preview'"
86
+ variant="outline"
87
+ color="neutral"
88
+ @click="togglePreview"
89
+ />
90
+ </div>
91
+
92
+ <div :class="gridClass">
93
+
94
+ <div :class="editorPanelClass">
95
+ <div class="pl-8">
96
+ <RCBlockEditRenderer :blocks="blocks" />
97
+ </div>
98
+ </div>
99
+
100
+ <div
101
+ v-if="showPreview"
102
+ class="col-span-1 w-full"
103
+ >
104
+ <RCBlockViewRenderer
105
+ :blocks="blocks"
106
+ class="transition duration-300 opacity-100"
107
+ />
108
+ </div>
109
+ </div>
110
+ </template>
@@ -0,0 +1,15 @@
1
+ import type { Block } from "../../types/blocks.js";
2
+ type __VLS_ModelProps = {
3
+ modelValue: Block[];
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
6
+ "update:modelValue": (value: Block[]) => any;
7
+ } & {
8
+ "update:modelValue": (value: Block[]) => any;
9
+ save: () => any;
10
+ }, string, import("vue").PublicProps, Readonly<__VLS_ModelProps> & Readonly<{
11
+ "onUpdate:modelValue"?: ((value: Block[]) => any) | undefined;
12
+ onSave?: (() => any) | undefined;
13
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
+ declare const _default: typeof __VLS_export;
15
+ export default _default;
@@ -27,24 +27,27 @@ const getComponent = (block) => {
27
27
  title="No blocks found for this page."
28
28
  description="It looks like there isn't any content added to this page yet."
29
29
  />
30
- <template v-else v-for="block in blocks" :key="block.id">
31
- <template v-if="getComponent(block)">
32
- <component
33
- :is="getComponent(block)"
34
- v-bind="block.props"
35
- :key="block.id"
36
- :type="block.type"
37
- class="block-container"
38
- />
39
- </template>
40
- <template v-else>
41
- <UAlert
42
- color="error"
43
- variant="subtle"
44
- icon="lucide:octagon-alert"
45
- title="Rendering Error"
46
- :description="`Block component for type \'${block.type || 'UNKNOWN_OR_MISSING'}\' was not found. This block will be skipped or the type is invalid/empty.`"
47
- />
30
+ <template v-else>
31
+ <template v-for="block in blocks" :key="block.id">
32
+ <template v-if="getComponent(block)">
33
+ <component
34
+ :is="getComponent(block)"
35
+ :id="block.id"
36
+ v-bind="block.props"
37
+ :key="block.id"
38
+ :type="block.type"
39
+ class="block-container"
40
+ />
41
+ </template>
42
+ <template v-else>
43
+ <UAlert
44
+ color="error"
45
+ variant="subtle"
46
+ icon="lucide:octagon-alert"
47
+ title="Rendering Error"
48
+ :description="`Block component for type \'${block.type || 'UNKNOWN_OR_MISSING'}\' was not found. This block will be skipped or the type is invalid/empty.`"
49
+ />
50
+ </template>
48
51
  </template>
49
52
  </template>
50
53
  </div>
@@ -9,6 +9,6 @@ const { variant, children, to, target } = defineProps({
9
9
 
10
10
  <template>
11
11
  <RCCallout :variant="variant" :to="to" :target="target">
12
- <RCBlockEditor :blocks="children" />
12
+ <RCBlockViewRenderer :blocks="children" />
13
13
  </RCCallout>
14
14
  </template>
@@ -12,7 +12,7 @@ const { title, to, target, children } = defineProps({
12
12
  <NuxtLink :to="to" :target="target">
13
13
  <UCard class="flex h-full flex-col">
14
14
  <h3>{{ title }}</h3>
15
- <RCBlockRenderer :blocks="children" />
15
+ <RCBlockEditRenderer :blocks="children" />
16
16
  </UCard>
17
17
  </NuxtLink>
18
18
  </template>
@@ -1,4 +1,7 @@
1
- import type { ParagraphBlockProps } from "~~/src/runtime/types/blocks";
2
- declare const __VLS_export: import("vue").DefineComponent<ParagraphBlockProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ParagraphBlockProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
1
+ import type { ParagraphBlockProps } from "../../../types/blocks.js";
2
+ type __VLS_Props = ParagraphBlockProps & {
3
+ id: string;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
3
6
  declare const _default: typeof __VLS_export;
4
7
  export default _default;
@@ -1,11 +1,59 @@
1
1
  <script setup>
2
- const { text } = defineProps({
3
- text: { type: Array, required: true }
2
+ import { inject, ref, watch, onMounted, nextTick } from "vue";
3
+ import { richTextToHtml, parseHtmlToRichText } from "../../../utils/richTextHelpers";
4
+ const editorApi = inject("block-editor-api");
5
+ const props = defineProps({
6
+ text: { type: Array, required: true },
7
+ id: { type: String, required: true }
8
+ });
9
+ const editorRef = ref(null);
10
+ const localHtml = ref(richTextToHtml(props.text));
11
+ const isContentChanging = ref(false);
12
+ const commitContentOnBlur = () => {
13
+ if (!editorRef.value || !editorApi) return;
14
+ const rawHtml = editorRef.value.innerText.trim();
15
+ const currentPropText = richTextToHtml(props.text);
16
+ if (rawHtml === currentPropText) {
17
+ return;
18
+ }
19
+ isContentChanging.value = true;
20
+ const newRichContent = parseHtmlToRichText(rawHtml);
21
+ editorApi.updateBlockProps(props.id, { text: newRichContent });
22
+ nextTick(() => {
23
+ isContentChanging.value = false;
24
+ });
25
+ };
26
+ watch(
27
+ () => props.text,
28
+ (newContent) => {
29
+ if (isContentChanging.value || !editorRef.value || document.activeElement === editorRef.value) {
30
+ return;
31
+ }
32
+ const newHtml = richTextToHtml(newContent);
33
+ if (editorRef.value.innerText !== newHtml) {
34
+ editorRef.value.innerHTML = newHtml;
35
+ localHtml.value = newHtml;
36
+ }
37
+ },
38
+ { deep: true, immediate: true }
39
+ );
40
+ onMounted(() => {
41
+ if (editorRef.value) {
42
+ editorRef.value.innerHTML = localHtml.value;
43
+ }
4
44
  });
5
45
  </script>
6
46
 
7
47
  <template>
8
- <p>
9
- <RCTextRenderer :content="text" />
10
- </p>
48
+ <div
49
+ ref="editorRef"
50
+ contenteditable="true"
51
+ @blur="commitContentOnBlur"
52
+ :class="[
53
+ 'p-2 outline-none min-h-6',
54
+ 'focus:ring-2 focus:ring-blue-500 rounded-md transition duration-150',
55
+ 'text-base'
56
+ ]"
57
+ >
58
+ </div>
11
59
  </template>
@@ -1,4 +1,7 @@
1
- import type { ParagraphBlockProps } from "~~/src/runtime/types/blocks";
2
- declare const __VLS_export: import("vue").DefineComponent<ParagraphBlockProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ParagraphBlockProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
1
+ import type { ParagraphBlockProps } from "../../../types/blocks.js";
2
+ type __VLS_Props = ParagraphBlockProps & {
3
+ id: string;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
3
6
  declare const _default: typeof __VLS_export;
4
7
  export default _default;
@@ -1,4 +1,7 @@
1
- import type { SectionBlockProps } from "~~/src/runtime/types/blocks";
2
- declare const __VLS_export: import("vue").DefineComponent<SectionBlockProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<SectionBlockProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
1
+ import type { SectionBlockProps } from "../../../types/blocks.js";
2
+ type __VLS_Props = SectionBlockProps & {
3
+ id: string;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
3
6
  declare const _default: typeof __VLS_export;
4
7
  export default _default;