@onereach/ui-components 2.70.0-beta.2114.0 → 2.70.0-beta.2124.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.
Files changed (24) hide show
  1. package/dist/bundled/v2/{OrRichTextEditor-5c3cfb5b.js → OrRichTextEditor-766f829b.js} +27 -30
  2. package/dist/bundled/v2/components/index.js +1 -1
  3. package/dist/bundled/v2/components/or-rich-text-editor-v3/OrRichTextEditor.vue.d.ts +4 -4
  4. package/dist/bundled/v2/components/or-rich-text-editor-v3/index.js +1 -1
  5. package/dist/bundled/v2/index.js +1 -1
  6. package/dist/bundled/v3/{OrRichTextEditor.vue_vue_type_script_lang-3404134a.js → OrRichTextEditor.vue_vue_type_script_lang-05013a39.js} +24 -27
  7. package/dist/bundled/v3/components/index.js +1 -1
  8. package/dist/bundled/v3/components/or-rich-text-editor-v3/OrRichTextEditor.vue.d.ts +4 -4
  9. package/dist/bundled/v3/components/or-rich-text-editor-v3/index.js +1 -1
  10. package/dist/bundled/v3/index.js +7 -8
  11. package/dist/esm/v2/{OrRichTextEditor-1f6186c0.js → OrRichTextEditor-4510aa40.js} +27 -30
  12. package/dist/esm/v2/components/index.js +1 -1
  13. package/dist/esm/v2/components/or-rich-text-editor-v3/OrRichTextEditor.vue.d.ts +4 -4
  14. package/dist/esm/v2/components/or-rich-text-editor-v3/index.js +1 -1
  15. package/dist/esm/v2/index.js +1 -1
  16. package/dist/esm/v3/{OrRichTextEditor-cdf75b40.js → OrRichTextEditor-eefc4567.js} +30 -34
  17. package/dist/esm/v3/components/index.js +1 -1
  18. package/dist/esm/v3/components/or-rich-text-editor-v3/OrRichTextEditor.vue.d.ts +4 -4
  19. package/dist/esm/v3/components/or-rich-text-editor-v3/index.js +1 -1
  20. package/dist/esm/v3/index.js +1 -1
  21. package/package.json +1 -1
  22. package/src/components/or-rich-text-editor-v3/OrRichTextEditor.docs.mdx +6 -15
  23. package/src/components/or-rich-text-editor-v3/OrRichTextEditor.stories3.ts +22 -10
  24. package/src/components/or-rich-text-editor-v3/OrRichTextEditor.vue +34 -31
@@ -36469,19 +36469,14 @@ var script = defineComponent({
36469
36469
  OrMenu
36470
36470
  },
36471
36471
  inheritAttrs: false,
36472
- model: {
36473
- prop: 'modelValue',
36474
- event: 'update:modelValue'
36475
- },
36476
36472
  props: {
36477
36473
  modelValue: {
36478
36474
  type: String,
36479
- default: '',
36480
- required: false
36475
+ default: ''
36481
36476
  },
36482
36477
  value: {
36483
36478
  type: String,
36484
- default: undefined
36479
+ default: ''
36485
36480
  },
36486
36481
  toolbar: {
36487
36482
  type: Array,
@@ -36509,10 +36504,10 @@ var script = defineComponent({
36509
36504
  }
36510
36505
  },
36511
36506
  emits: ['update:modelValue', 'input'],
36512
- setup(props, {
36513
- emit
36514
- }) {
36507
+ expose: ['root'],
36508
+ setup(props, context) {
36515
36509
  // Refs
36510
+ const root = ref();
36516
36511
  let editor = null;
36517
36512
  const editorRef = ref();
36518
36513
  const containerRef = ref();
@@ -36566,22 +36561,19 @@ var script = defineComponent({
36566
36561
  const text = editor.getText();
36567
36562
  if (props.markdownFormat) {
36568
36563
  markdownOutput.value = serialize(editor.schema, editor.getJSON());
36569
- emit('update:modelValue', markdownOutput.value);
36570
- emit('input', markdownOutput.value);
36564
+ proxyModelValue.value = markdownOutput.value;
36571
36565
  } else {
36572
- emit('update:modelValue', text === '' ? text : html);
36573
- emit('input', text === '' ? text : html);
36566
+ proxyModelValue.value = text === '' ? text : html;
36574
36567
  }
36575
36568
  },
36576
36569
  onCreate: ({
36577
36570
  editor
36578
36571
  }) => {
36579
- var _a, _b;
36580
36572
  if (props.markdownFormat) {
36581
- const deserialized = deserialize(editor.schema, (_a = props.modelValue) !== null && _a !== void 0 ? _a : props.value);
36573
+ const deserialized = deserialize(editor.schema, proxyModelValue.value);
36582
36574
  editor.commands.setContent(deserialized);
36583
36575
  } else {
36584
- editor.commands.setContent((_b = props.modelValue) !== null && _b !== void 0 ? _b : props.value);
36576
+ editor.commands.setContent(proxyModelValue.value);
36585
36577
  }
36586
36578
  },
36587
36579
  element: editorRef.value,
@@ -36626,6 +36618,17 @@ var script = defineComponent({
36626
36618
  });
36627
36619
  // trap.activate();
36628
36620
  // Computed
36621
+ const proxyModelValue = computed({
36622
+ get: () => {
36623
+ var _a;
36624
+ return (_a = props.modelValue) !== null && _a !== void 0 ? _a : props.value; // TODO: Remove Vue 2 fallback
36625
+ },
36626
+
36627
+ set: value => {
36628
+ context.emit('input', value);
36629
+ context.emit('update:modelValue', value);
36630
+ }
36631
+ });
36629
36632
  const getIndexOfHeading = computed(() => {
36630
36633
  return props.toolbar.flat().indexOf('heading');
36631
36634
  });
@@ -36635,7 +36638,7 @@ var script = defineComponent({
36635
36638
  }
36636
36639
  return 'format_paragraph';
36637
36640
  });
36638
- // Methods
36641
+ //Methods
36639
36642
  const handleEditorClick = () => {
36640
36643
  setActiveFormats();
36641
36644
  editor === null || editor === void 0 ? void 0 : editor.commands.focus();
@@ -36717,7 +36720,8 @@ var script = defineComponent({
36717
36720
  'gap-md', ...(isActive.value[item] ? ToolbarButtonActive : ToolbarButton)];
36718
36721
  };
36719
36722
  //Effects
36720
- watch(() => props.modelValue, value => {
36723
+ watch(proxyModelValue, value => {
36724
+ console.log('watch', value);
36721
36725
  if (value !== (editor === null || editor === void 0 ? void 0 : editor.getHTML()) && !props.markdownFormat) {
36722
36726
  editor === null || editor === void 0 ? void 0 : editor.commands.setContent(value);
36723
36727
  }
@@ -36725,14 +36729,6 @@ var script = defineComponent({
36725
36729
  editor === null || editor === void 0 ? void 0 : editor.commands.setContent(markdownOutput.value);
36726
36730
  }
36727
36731
  });
36728
- // watch(() => props.value, (value) => { //for vue2
36729
- // if (value !== editor?.getHTML() && !props.markdownFormat) {
36730
- // editor?.commands.setContent(value);
36731
- // }
36732
- // if (props.markdownFormat && value !== markdownOutput.value) {
36733
- // editor?.commands.setContent(markdownOutput.value);
36734
- // }
36735
- // });
36736
36732
  return {
36737
36733
  editor,
36738
36734
  editorRef,
@@ -36748,6 +36744,7 @@ var script = defineComponent({
36748
36744
  toolbarContainerStyles,
36749
36745
  toolbarStyles,
36750
36746
  rootStyles,
36747
+ root,
36751
36748
  toolbarButtonStyles,
36752
36749
  editorInputStyles,
36753
36750
  getIndexOfHeading,
@@ -36765,10 +36762,10 @@ var __vue_render__ = function () {
36765
36762
  var _vm = this;
36766
36763
  var _h = _vm.$createElement;
36767
36764
  var _c = _vm._self._c || _h;
36768
- return _c('div', _vm._b({
36765
+ return _c('div', {
36769
36766
  ref: "root",
36770
36767
  class: _vm.rootStyles
36771
- }, 'div', _vm.$attrs, false), [_c('or-label', [_vm._v("\n " + _vm._s(_vm.description) + "\n ")]), _vm._v(" "), _c('div', {
36768
+ }, [_c('or-label', [_vm._v("\n " + _vm._s(_vm.description) + "\n ")]), _vm._v(" "), _c('div', {
36772
36769
  ref: "containerRef",
36773
36770
  class: _vm.containerStyles,
36774
36771
  on: {
@@ -36856,7 +36853,7 @@ var __vue_staticRenderFns__ = [];
36856
36853
  /* style */
36857
36854
  const __vue_inject_styles__ = function (inject) {
36858
36855
  if (!inject) return;
36859
- inject("data-v-b67bfabc_0", {
36856
+ inject("data-v-b9a5ce74_0", {
36860
36857
  source: ".tiptap-editor ol{margin:0 24px;list-style:decimal}.tiptap-editor ul{margin:0 24px;list-style:initial}.tiptap-editor pre{background-color:rgba(186,209,236,.3);padding:4px 8px;margin:4px 0;width:100%;border-radius:4px}.tiptap-editor blockquote{margin:8px 24px;padding:0 24px;border-left:4px solid #bad1ec}.tiptap-editor .is-editor-empty::before{content:attr(data-placeholder);height:0;pointer-events:none;float:left}",
36861
36858
  map: undefined,
36862
36859
  media: undefined
@@ -95,7 +95,7 @@ export { p as PropsV3, a as useQueueV3, u as useToastV3 } from '../useToast-3a3d
95
95
  export { O as OrTooltip } from '../OrTooltip-dfea7af2.js';
96
96
  export { O as OrTooltipContent } from '../OrTooltipContent-f0fd5f75.js';
97
97
  export { O as OrTooltipV3 } from '../OrTooltip-fbfa05fd.js';
98
- export { _ as OrRichTextEditorV3 } from '../OrRichTextEditor-5c3cfb5b.js';
98
+ export { _ as OrRichTextEditorV3 } from '../OrRichTextEditor-766f829b.js';
99
99
  import '../index-fa6eb4ca.js';
100
100
  import 'vue';
101
101
  import '@vue/composition-api/dist/vue-composition-api.mjs';
@@ -29,6 +29,7 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
29
29
  toolbarContainerStyles: import("@vue/composition-api").ComputedRef<string[]>;
30
30
  toolbarStyles: import("@vue/composition-api").ComputedRef<string[]>;
31
31
  rootStyles: import("@vue/composition-api").ComputedRef<(string | undefined)[]>;
32
+ root: import("@vue/composition-api").Ref<HTMLElement | undefined>;
32
33
  toolbarButtonStyles: (item: string) => string[];
33
34
  editorInputStyles: import("@vue/composition-api").ComputedRef<string[]>;
34
35
  getIndexOfHeading: import("@vue/composition-api").ComputedRef<number>;
@@ -38,11 +39,10 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
38
39
  modelValue: {
39
40
  type: StringConstructor;
40
41
  default: string;
41
- required: false;
42
42
  };
43
43
  value: {
44
44
  type: StringConstructor;
45
- default: undefined;
45
+ default: string;
46
46
  };
47
47
  toolbar: {
48
48
  type: ArrayConstructor;
@@ -72,11 +72,10 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
72
72
  modelValue: {
73
73
  type: StringConstructor;
74
74
  default: string;
75
- required: false;
76
75
  };
77
76
  value: {
78
77
  type: StringConstructor;
79
- default: undefined;
78
+ default: string;
80
79
  };
81
80
  toolbar: {
82
81
  type: ArrayConstructor;
@@ -142,6 +141,7 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
142
141
  toolbarContainerStyles: import("@vue/composition-api").ComputedRef<string[]>;
143
142
  toolbarStyles: import("@vue/composition-api").ComputedRef<string[]>;
144
143
  rootStyles: import("@vue/composition-api").ComputedRef<(string | undefined)[]>;
144
+ root: import("@vue/composition-api").Ref<HTMLElement | undefined>;
145
145
  toolbarButtonStyles: (item: string) => string[];
146
146
  editorInputStyles: import("@vue/composition-api").ComputedRef<string[]>;
147
147
  getIndexOfHeading: import("@vue/composition-api").ComputedRef<number>;
@@ -1,4 +1,4 @@
1
- export { _ as OrRichTextEditorV3 } from '../../OrRichTextEditor-5c3cfb5b.js';
1
+ export { _ as OrRichTextEditorV3 } from '../../OrRichTextEditor-766f829b.js';
2
2
  import '../../index-fa6eb4ca.js';
3
3
  import 'vue';
4
4
  import '@vue/composition-api/dist/vue-composition-api.mjs';
@@ -98,7 +98,7 @@ export { _ as OrToastContainerV3, O as OrToastV3, t as TypesV3 } from './types-f
98
98
  export { O as OrTooltip } from './OrTooltip-dfea7af2.js';
99
99
  export { O as OrTooltipContent } from './OrTooltipContent-f0fd5f75.js';
100
100
  export { O as OrTooltipV3 } from './OrTooltip-fbfa05fd.js';
101
- export { _ as OrRichTextEditorV3 } from './OrRichTextEditor-5c3cfb5b.js';
101
+ export { _ as OrRichTextEditorV3 } from './OrRichTextEditor-766f829b.js';
102
102
  export { D as DropdownClose, a as DropdownOpen } from './dropdown-open-e2a93aaf.js';
103
103
  export { u as useClassAttribute } from './useClassAttribute-9bf33346.js';
104
104
  export { u as useElevation } from './useElevation-aac032f4.js';
@@ -36470,19 +36470,14 @@ var script = defineComponent({
36470
36470
  OrMenu: script$4
36471
36471
  },
36472
36472
  inheritAttrs: false,
36473
- model: {
36474
- prop: 'modelValue',
36475
- event: 'update:modelValue'
36476
- },
36477
36473
  props: {
36478
36474
  modelValue: {
36479
36475
  type: String,
36480
- default: '',
36481
- required: false
36476
+ default: ''
36482
36477
  },
36483
36478
  value: {
36484
36479
  type: String,
36485
- default: undefined
36480
+ default: ''
36486
36481
  },
36487
36482
  toolbar: {
36488
36483
  type: Array,
@@ -36510,10 +36505,10 @@ var script = defineComponent({
36510
36505
  }
36511
36506
  },
36512
36507
  emits: ['update:modelValue', 'input'],
36513
- setup(props, {
36514
- emit
36515
- }) {
36508
+ expose: ['root'],
36509
+ setup(props, context) {
36516
36510
  // Refs
36511
+ const root = ref();
36517
36512
  let editor = null;
36518
36513
  const editorRef = ref();
36519
36514
  const containerRef = ref();
@@ -36567,22 +36562,19 @@ var script = defineComponent({
36567
36562
  const text = editor.getText();
36568
36563
  if (props.markdownFormat) {
36569
36564
  markdownOutput.value = serialize(editor.schema, editor.getJSON());
36570
- emit('update:modelValue', markdownOutput.value);
36571
- emit('input', markdownOutput.value);
36565
+ proxyModelValue.value = markdownOutput.value;
36572
36566
  } else {
36573
- emit('update:modelValue', text === '' ? text : html);
36574
- emit('input', text === '' ? text : html);
36567
+ proxyModelValue.value = text === '' ? text : html;
36575
36568
  }
36576
36569
  },
36577
36570
  onCreate: ({
36578
36571
  editor
36579
36572
  }) => {
36580
- var _a, _b;
36581
36573
  if (props.markdownFormat) {
36582
- const deserialized = deserialize(editor.schema, (_a = props.modelValue) !== null && _a !== void 0 ? _a : props.value);
36574
+ const deserialized = deserialize(editor.schema, proxyModelValue.value);
36583
36575
  editor.commands.setContent(deserialized);
36584
36576
  } else {
36585
- editor.commands.setContent((_b = props.modelValue) !== null && _b !== void 0 ? _b : props.value);
36577
+ editor.commands.setContent(proxyModelValue.value);
36586
36578
  }
36587
36579
  },
36588
36580
  element: editorRef.value,
@@ -36627,6 +36619,17 @@ var script = defineComponent({
36627
36619
  });
36628
36620
  // trap.activate();
36629
36621
  // Computed
36622
+ const proxyModelValue = computed({
36623
+ get: () => {
36624
+ var _a;
36625
+ return (_a = props.modelValue) !== null && _a !== void 0 ? _a : props.value; // TODO: Remove Vue 2 fallback
36626
+ },
36627
+
36628
+ set: value => {
36629
+ context.emit('input', value);
36630
+ context.emit('update:modelValue', value);
36631
+ }
36632
+ });
36630
36633
  const getIndexOfHeading = computed(() => {
36631
36634
  return props.toolbar.flat().indexOf('heading');
36632
36635
  });
@@ -36636,7 +36639,7 @@ var script = defineComponent({
36636
36639
  }
36637
36640
  return 'format_paragraph';
36638
36641
  });
36639
- // Methods
36642
+ //Methods
36640
36643
  const handleEditorClick = () => {
36641
36644
  setActiveFormats();
36642
36645
  editor === null || editor === void 0 ? void 0 : editor.commands.focus();
@@ -36718,7 +36721,8 @@ var script = defineComponent({
36718
36721
  'gap-md', ...(isActive.value[item] ? ToolbarButtonActive : ToolbarButton)];
36719
36722
  };
36720
36723
  //Effects
36721
- watch(() => props.modelValue, value => {
36724
+ watch(proxyModelValue, value => {
36725
+ console.log('watch', value);
36722
36726
  if (value !== (editor === null || editor === void 0 ? void 0 : editor.getHTML()) && !props.markdownFormat) {
36723
36727
  editor === null || editor === void 0 ? void 0 : editor.commands.setContent(value);
36724
36728
  }
@@ -36726,14 +36730,6 @@ var script = defineComponent({
36726
36730
  editor === null || editor === void 0 ? void 0 : editor.commands.setContent(markdownOutput.value);
36727
36731
  }
36728
36732
  });
36729
- // watch(() => props.value, (value) => { //for vue2
36730
- // if (value !== editor?.getHTML() && !props.markdownFormat) {
36731
- // editor?.commands.setContent(value);
36732
- // }
36733
- // if (props.markdownFormat && value !== markdownOutput.value) {
36734
- // editor?.commands.setContent(markdownOutput.value);
36735
- // }
36736
- // });
36737
36733
  return {
36738
36734
  editor,
36739
36735
  editorRef,
@@ -36749,6 +36745,7 @@ var script = defineComponent({
36749
36745
  toolbarContainerStyles,
36750
36746
  toolbarStyles,
36751
36747
  rootStyles,
36748
+ root,
36752
36749
  toolbarButtonStyles,
36753
36750
  editorInputStyles,
36754
36751
  getIndexOfHeading,
@@ -95,7 +95,7 @@ export { p as PropsV3, a as useQueueV3, u as useToastV3 } from '../useToast-4d43
95
95
  export { s as OrTooltip } from '../OrTooltip.vue_vue_type_script_lang-fa52d391.js';
96
96
  export { s as OrTooltipContent } from '../OrTooltipContent-b0dcb862.js';
97
97
  export { s as OrTooltipV3 } from '../OrTooltip.vue_vue_type_script_lang-67cc86ed.js';
98
- export { s as OrRichTextEditorV3 } from '../OrRichTextEditor.vue_vue_type_script_lang-3404134a.js';
98
+ export { s as OrRichTextEditorV3 } from '../OrRichTextEditor.vue_vue_type_script_lang-05013a39.js';
99
99
  import 'vue';
100
100
  import 'lodash';
101
101
  import '../OrIcon-1cae8a64.js';
@@ -29,6 +29,7 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
29
29
  toolbarContainerStyles: import("@vue/composition-api").ComputedRef<string[]>;
30
30
  toolbarStyles: import("@vue/composition-api").ComputedRef<string[]>;
31
31
  rootStyles: import("@vue/composition-api").ComputedRef<(string | undefined)[]>;
32
+ root: import("@vue/composition-api").Ref<HTMLElement | undefined>;
32
33
  toolbarButtonStyles: (item: string) => string[];
33
34
  editorInputStyles: import("@vue/composition-api").ComputedRef<string[]>;
34
35
  getIndexOfHeading: import("@vue/composition-api").ComputedRef<number>;
@@ -38,11 +39,10 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
38
39
  modelValue: {
39
40
  type: StringConstructor;
40
41
  default: string;
41
- required: false;
42
42
  };
43
43
  value: {
44
44
  type: StringConstructor;
45
- default: undefined;
45
+ default: string;
46
46
  };
47
47
  toolbar: {
48
48
  type: ArrayConstructor;
@@ -72,11 +72,10 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
72
72
  modelValue: {
73
73
  type: StringConstructor;
74
74
  default: string;
75
- required: false;
76
75
  };
77
76
  value: {
78
77
  type: StringConstructor;
79
- default: undefined;
78
+ default: string;
80
79
  };
81
80
  toolbar: {
82
81
  type: ArrayConstructor;
@@ -142,6 +141,7 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
142
141
  toolbarContainerStyles: import("@vue/composition-api").ComputedRef<string[]>;
143
142
  toolbarStyles: import("@vue/composition-api").ComputedRef<string[]>;
144
143
  rootStyles: import("@vue/composition-api").ComputedRef<(string | undefined)[]>;
144
+ root: import("@vue/composition-api").Ref<HTMLElement | undefined>;
145
145
  toolbarButtonStyles: (item: string) => string[];
146
146
  editorInputStyles: import("@vue/composition-api").ComputedRef<string[]>;
147
147
  getIndexOfHeading: import("@vue/composition-api").ComputedRef<number>;
@@ -1,4 +1,4 @@
1
- export { s as OrRichTextEditorV3 } from '../../OrRichTextEditor.vue_vue_type_script_lang-3404134a.js';
1
+ export { s as OrRichTextEditorV3 } from '../../OrRichTextEditor.vue_vue_type_script_lang-05013a39.js';
2
2
  import 'vue';
3
3
  import 'node:punycode';
4
4
  import '../../index.es-3f39f316.js';
@@ -123,8 +123,8 @@ import './OrToastContainer-f5525225.js';
123
123
  export { p as PropsV3, a as useQueueV3, u as useToastV3 } from './useToast-4d4329cd.js';
124
124
  export { a as OrToastContainerV3, s as OrToastV3, t as TypesV3 } from './types-6c5eee23.js';
125
125
  import './OrToastContainer-afb51e5d.js';
126
- import { s as script$Q } from './OrRichTextEditor.vue_vue_type_script_lang-3404134a.js';
127
- export { s as OrRichTextEditorV3 } from './OrRichTextEditor.vue_vue_type_script_lang-3404134a.js';
126
+ import { s as script$Q } from './OrRichTextEditor.vue_vue_type_script_lang-05013a39.js';
127
+ export { s as OrRichTextEditorV3 } from './OrRichTextEditor.vue_vue_type_script_lang-05013a39.js';
128
128
  export { a as BUTTON_COLOR, c as BUTTON_LOADER_TYPE, b as BUTTON_SIZE, B as BUTTON_TYPE, I as ICON_BUTTON_TYPE } from './constants-c5d1139f.js';
129
129
  export { s as OrCardV3 } from './OrCard.vue_vue_type_script_lang-165de137.js';
130
130
  export { s as OrCollapse } from './OrCollapse.vue_vue_type_script_lang-65cbb754.js';
@@ -2908,11 +2908,10 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
2908
2908
  const _component_or_icon_button = resolveComponent("or-icon-button");
2909
2909
  const _component_or_menu_item = resolveComponent("or-menu-item");
2910
2910
  const _component_or_menu = resolveComponent("or-menu");
2911
- return openBlock(), createElementBlock("div", mergeProps({
2912
- ref: "root"
2913
- }, _ctx.$attrs, {
2914
- class: _ctx.rootStyles
2915
- }), [createVNode(_component_or_label, null, {
2911
+ return openBlock(), createElementBlock("div", {
2912
+ ref: "root",
2913
+ class: normalizeClass(_ctx.rootStyles)
2914
+ }, [createVNode(_component_or_label, null, {
2916
2915
  default: withCtx(() => [createTextVNode(toDisplayString(_ctx.description), 1 /* TEXT */)]),
2917
2916
 
2918
2917
  _: 1 /* STABLE */
@@ -2984,7 +2983,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
2984
2983
  })]),
2985
2984
 
2986
2985
  _: 1 /* STABLE */
2987
- }, 8 /* PROPS */, ["trigger"])) : createCommentVNode("v-if", true)], 16 /* FULL_PROPS */);
2986
+ }, 8 /* PROPS */, ["trigger"])) : createCommentVNode("v-if", true)], 2 /* CLASS */);
2988
2987
  }
2989
2988
 
2990
2989
  var css_248z = ".tiptap-editor ol {\n margin: 0 24px;\n list-style: decimal;\n}\n.tiptap-editor ul {\n margin: 0 24px;\n list-style: disc outside none;\n list-style: initial;\n}\n.tiptap-editor pre {\n background-color: rgba(186, 209, 236, 0.3);\n padding: 4px 8px;\n margin: 4px 0;\n width: 100%;\n border-radius: 4px;\n}\n.tiptap-editor blockquote {\n margin: 8px 24px;\n padding: 0 24px;\n border-left: 4px solid #bad1ec;\n}\n.tiptap-editor .is-editor-empty::before {\n content: attr(data-placeholder);\n height: 0;\n pointer-events: none;\n float: left;\n}";
@@ -144,19 +144,14 @@ var script = defineComponent({
144
144
  OrMenu: __vue_component__$4
145
145
  },
146
146
  inheritAttrs: false,
147
- model: {
148
- prop: 'modelValue',
149
- event: 'update:modelValue'
150
- },
151
147
  props: {
152
148
  modelValue: {
153
149
  type: String,
154
- default: '',
155
- required: false
150
+ default: ''
156
151
  },
157
152
  value: {
158
153
  type: String,
159
- default: undefined
154
+ default: ''
160
155
  },
161
156
  toolbar: {
162
157
  type: Array,
@@ -184,10 +179,10 @@ var script = defineComponent({
184
179
  }
185
180
  },
186
181
  emits: ['update:modelValue', 'input'],
187
- setup(props, {
188
- emit
189
- }) {
182
+ expose: ['root'],
183
+ setup(props, context) {
190
184
  // Refs
185
+ const root = ref();
191
186
  let editor = null;
192
187
  const editorRef = ref();
193
188
  const containerRef = ref();
@@ -241,22 +236,19 @@ var script = defineComponent({
241
236
  const text = editor.getText();
242
237
  if (props.markdownFormat) {
243
238
  markdownOutput.value = serialize(editor.schema, editor.getJSON());
244
- emit('update:modelValue', markdownOutput.value);
245
- emit('input', markdownOutput.value);
239
+ proxyModelValue.value = markdownOutput.value;
246
240
  } else {
247
- emit('update:modelValue', text === '' ? text : html);
248
- emit('input', text === '' ? text : html);
241
+ proxyModelValue.value = text === '' ? text : html;
249
242
  }
250
243
  },
251
244
  onCreate: ({
252
245
  editor
253
246
  }) => {
254
- var _a, _b;
255
247
  if (props.markdownFormat) {
256
- const deserialized = deserialize(editor.schema, (_a = props.modelValue) !== null && _a !== void 0 ? _a : props.value);
248
+ const deserialized = deserialize(editor.schema, proxyModelValue.value);
257
249
  editor.commands.setContent(deserialized);
258
250
  } else {
259
- editor.commands.setContent((_b = props.modelValue) !== null && _b !== void 0 ? _b : props.value);
251
+ editor.commands.setContent(proxyModelValue.value);
260
252
  }
261
253
  },
262
254
  element: editorRef.value,
@@ -301,6 +293,17 @@ var script = defineComponent({
301
293
  });
302
294
  // trap.activate();
303
295
  // Computed
296
+ const proxyModelValue = computed({
297
+ get: () => {
298
+ var _a;
299
+ return (_a = props.modelValue) !== null && _a !== void 0 ? _a : props.value; // TODO: Remove Vue 2 fallback
300
+ },
301
+
302
+ set: value => {
303
+ context.emit('input', value);
304
+ context.emit('update:modelValue', value);
305
+ }
306
+ });
304
307
  const getIndexOfHeading = computed(() => {
305
308
  return props.toolbar.flat().indexOf('heading');
306
309
  });
@@ -310,7 +313,7 @@ var script = defineComponent({
310
313
  }
311
314
  return 'format_paragraph';
312
315
  });
313
- // Methods
316
+ //Methods
314
317
  const handleEditorClick = () => {
315
318
  setActiveFormats();
316
319
  editor === null || editor === void 0 ? void 0 : editor.commands.focus();
@@ -392,7 +395,8 @@ var script = defineComponent({
392
395
  'gap-md', ...(isActive.value[item] ? ToolbarButtonActive : ToolbarButton)];
393
396
  };
394
397
  //Effects
395
- watch(() => props.modelValue, value => {
398
+ watch(proxyModelValue, value => {
399
+ console.log('watch', value);
396
400
  if (value !== (editor === null || editor === void 0 ? void 0 : editor.getHTML()) && !props.markdownFormat) {
397
401
  editor === null || editor === void 0 ? void 0 : editor.commands.setContent(value);
398
402
  }
@@ -400,14 +404,6 @@ var script = defineComponent({
400
404
  editor === null || editor === void 0 ? void 0 : editor.commands.setContent(markdownOutput.value);
401
405
  }
402
406
  });
403
- // watch(() => props.value, (value) => { //for vue2
404
- // if (value !== editor?.getHTML() && !props.markdownFormat) {
405
- // editor?.commands.setContent(value);
406
- // }
407
- // if (props.markdownFormat && value !== markdownOutput.value) {
408
- // editor?.commands.setContent(markdownOutput.value);
409
- // }
410
- // });
411
407
  return {
412
408
  editor,
413
409
  editorRef,
@@ -423,6 +419,7 @@ var script = defineComponent({
423
419
  toolbarContainerStyles,
424
420
  toolbarStyles,
425
421
  rootStyles,
422
+ root,
426
423
  toolbarButtonStyles,
427
424
  editorInputStyles,
428
425
  getIndexOfHeading,
@@ -440,10 +437,10 @@ var __vue_render__ = function () {
440
437
  var _vm = this;
441
438
  var _h = _vm.$createElement;
442
439
  var _c = _vm._self._c || _h;
443
- return _c('div', _vm._b({
440
+ return _c('div', {
444
441
  ref: "root",
445
442
  class: _vm.rootStyles
446
- }, 'div', _vm.$attrs, false), [_c('or-label', [_vm._v("\n " + _vm._s(_vm.description) + "\n ")]), _vm._v(" "), _c('div', {
443
+ }, [_c('or-label', [_vm._v("\n " + _vm._s(_vm.description) + "\n ")]), _vm._v(" "), _c('div', {
447
444
  ref: "containerRef",
448
445
  class: _vm.containerStyles,
449
446
  on: {
@@ -531,7 +528,7 @@ var __vue_staticRenderFns__ = [];
531
528
  /* style */
532
529
  const __vue_inject_styles__ = function (inject) {
533
530
  if (!inject) return;
534
- inject("data-v-b67bfabc_0", {
531
+ inject("data-v-b9a5ce74_0", {
535
532
  source: ".tiptap-editor ol{margin:0 24px;list-style:decimal}.tiptap-editor ul{margin:0 24px;list-style:initial}.tiptap-editor pre{background-color:rgba(186,209,236,.3);padding:4px 8px;margin:4px 0;width:100%;border-radius:4px}.tiptap-editor blockquote{margin:8px 24px;padding:0 24px;border-left:4px solid #bad1ec}.tiptap-editor .is-editor-empty::before{content:attr(data-placeholder);height:0;pointer-events:none;float:left}",
536
533
  map: undefined,
537
534
  media: undefined
@@ -95,7 +95,7 @@ export { p as PropsV3, a as useQueueV3, u as useToastV3 } from '../useToast-0665
95
95
  export { _ as OrTooltip } from '../OrTooltip-614b016d.js';
96
96
  export { _ as OrTooltipContent } from '../OrTooltip.vue_rollup-plugin-vue_script-63559536.js';
97
97
  export { _ as OrTooltipV3 } from '../OrTooltip-513bee30.js';
98
- export { _ as OrRichTextEditorV3 } from '../OrRichTextEditor-1f6186c0.js';
98
+ export { _ as OrRichTextEditorV3 } from '../OrRichTextEditor-4510aa40.js';
99
99
  import 'vue-demi';
100
100
  import 'lodash';
101
101
  import '../normalize-component-6e8e3d80.js';
@@ -29,6 +29,7 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
29
29
  toolbarContainerStyles: import("@vue/composition-api").ComputedRef<string[]>;
30
30
  toolbarStyles: import("@vue/composition-api").ComputedRef<string[]>;
31
31
  rootStyles: import("@vue/composition-api").ComputedRef<(string | undefined)[]>;
32
+ root: import("@vue/composition-api").Ref<HTMLElement | undefined>;
32
33
  toolbarButtonStyles: (item: string) => string[];
33
34
  editorInputStyles: import("@vue/composition-api").ComputedRef<string[]>;
34
35
  getIndexOfHeading: import("@vue/composition-api").ComputedRef<number>;
@@ -38,11 +39,10 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
38
39
  modelValue: {
39
40
  type: StringConstructor;
40
41
  default: string;
41
- required: false;
42
42
  };
43
43
  value: {
44
44
  type: StringConstructor;
45
- default: undefined;
45
+ default: string;
46
46
  };
47
47
  toolbar: {
48
48
  type: ArrayConstructor;
@@ -72,11 +72,10 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
72
72
  modelValue: {
73
73
  type: StringConstructor;
74
74
  default: string;
75
- required: false;
76
75
  };
77
76
  value: {
78
77
  type: StringConstructor;
79
- default: undefined;
78
+ default: string;
80
79
  };
81
80
  toolbar: {
82
81
  type: ArrayConstructor;
@@ -142,6 +141,7 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
142
141
  toolbarContainerStyles: import("@vue/composition-api").ComputedRef<string[]>;
143
142
  toolbarStyles: import("@vue/composition-api").ComputedRef<string[]>;
144
143
  rootStyles: import("@vue/composition-api").ComputedRef<(string | undefined)[]>;
144
+ root: import("@vue/composition-api").Ref<HTMLElement | undefined>;
145
145
  toolbarButtonStyles: (item: string) => string[];
146
146
  editorInputStyles: import("@vue/composition-api").ComputedRef<string[]>;
147
147
  getIndexOfHeading: import("@vue/composition-api").ComputedRef<number>;
@@ -1,4 +1,4 @@
1
- export { _ as OrRichTextEditorV3 } from '../../OrRichTextEditor-1f6186c0.js';
1
+ export { _ as OrRichTextEditorV3 } from '../../OrRichTextEditor-4510aa40.js';
2
2
  import 'vue-demi';
3
3
  import '../../useClassAttribute-47fdb016.js';
4
4
  import '@vueuse/core';
@@ -95,7 +95,7 @@ export { p as PropsV3, a as useQueueV3, u as useToastV3 } from './useToast-06654
95
95
  export { _ as OrTooltip } from './OrTooltip-614b016d.js';
96
96
  export { _ as OrTooltipContent } from './OrTooltip.vue_rollup-plugin-vue_script-63559536.js';
97
97
  export { _ as OrTooltipV3 } from './OrTooltip-513bee30.js';
98
- export { _ as OrRichTextEditorV3 } from './OrRichTextEditor-1f6186c0.js';
98
+ export { _ as OrRichTextEditorV3 } from './OrRichTextEditor-4510aa40.js';
99
99
  export { D as DropdownClose, a as DropdownOpen } from './dropdown-open-0d314aa4.js';
100
100
  export { u as useClassAttribute } from './useClassAttribute-47fdb016.js';
101
101
  export { u as useElevation } from './useElevation-31bfe1f6.js';
@@ -26,7 +26,7 @@ import StarterKit from '@tiptap/starter-kit';
26
26
  import Underline from '@tiptap/extension-underline';
27
27
  import Heading from '@tiptap/extension-heading';
28
28
  import Placeholder from '@tiptap/extension-placeholder';
29
- import { resolveComponent, openBlock, createElementBlock, mergeProps, createVNode, withCtx, createTextVNode, toDisplayString, createElementVNode, normalizeClass, Fragment, renderList, createBlock, createCommentVNode } from 'vue';
29
+ import { resolveComponent, openBlock, createElementBlock, normalizeClass, createVNode, withCtx, createTextVNode, toDisplayString, createElementVNode, Fragment, renderList, createBlock, createCommentVNode } from 'vue';
30
30
  import { s as styleInject } from './style-inject.es-4c6f2515.js';
31
31
 
32
32
  const serializerNodes = {
@@ -144,19 +144,14 @@ var script = defineComponent({
144
144
  OrMenu: script$4
145
145
  },
146
146
  inheritAttrs: false,
147
- model: {
148
- prop: 'modelValue',
149
- event: 'update:modelValue'
150
- },
151
147
  props: {
152
148
  modelValue: {
153
149
  type: String,
154
- default: '',
155
- required: false
150
+ default: ''
156
151
  },
157
152
  value: {
158
153
  type: String,
159
- default: undefined
154
+ default: ''
160
155
  },
161
156
  toolbar: {
162
157
  type: Array,
@@ -184,10 +179,10 @@ var script = defineComponent({
184
179
  }
185
180
  },
186
181
  emits: ['update:modelValue', 'input'],
187
- setup(props, {
188
- emit
189
- }) {
182
+ expose: ['root'],
183
+ setup(props, context) {
190
184
  // Refs
185
+ const root = ref();
191
186
  let editor = null;
192
187
  const editorRef = ref();
193
188
  const containerRef = ref();
@@ -241,22 +236,19 @@ var script = defineComponent({
241
236
  const text = editor.getText();
242
237
  if (props.markdownFormat) {
243
238
  markdownOutput.value = serialize(editor.schema, editor.getJSON());
244
- emit('update:modelValue', markdownOutput.value);
245
- emit('input', markdownOutput.value);
239
+ proxyModelValue.value = markdownOutput.value;
246
240
  } else {
247
- emit('update:modelValue', text === '' ? text : html);
248
- emit('input', text === '' ? text : html);
241
+ proxyModelValue.value = text === '' ? text : html;
249
242
  }
250
243
  },
251
244
  onCreate: ({
252
245
  editor
253
246
  }) => {
254
- var _a, _b;
255
247
  if (props.markdownFormat) {
256
- const deserialized = deserialize(editor.schema, (_a = props.modelValue) !== null && _a !== void 0 ? _a : props.value);
248
+ const deserialized = deserialize(editor.schema, proxyModelValue.value);
257
249
  editor.commands.setContent(deserialized);
258
250
  } else {
259
- editor.commands.setContent((_b = props.modelValue) !== null && _b !== void 0 ? _b : props.value);
251
+ editor.commands.setContent(proxyModelValue.value);
260
252
  }
261
253
  },
262
254
  element: editorRef.value,
@@ -301,6 +293,17 @@ var script = defineComponent({
301
293
  });
302
294
  // trap.activate();
303
295
  // Computed
296
+ const proxyModelValue = computed({
297
+ get: () => {
298
+ var _a;
299
+ return (_a = props.modelValue) !== null && _a !== void 0 ? _a : props.value; // TODO: Remove Vue 2 fallback
300
+ },
301
+
302
+ set: value => {
303
+ context.emit('input', value);
304
+ context.emit('update:modelValue', value);
305
+ }
306
+ });
304
307
  const getIndexOfHeading = computed(() => {
305
308
  return props.toolbar.flat().indexOf('heading');
306
309
  });
@@ -310,7 +313,7 @@ var script = defineComponent({
310
313
  }
311
314
  return 'format_paragraph';
312
315
  });
313
- // Methods
316
+ //Methods
314
317
  const handleEditorClick = () => {
315
318
  setActiveFormats();
316
319
  editor === null || editor === void 0 ? void 0 : editor.commands.focus();
@@ -392,7 +395,8 @@ var script = defineComponent({
392
395
  'gap-md', ...(isActive.value[item] ? ToolbarButtonActive : ToolbarButton)];
393
396
  };
394
397
  //Effects
395
- watch(() => props.modelValue, value => {
398
+ watch(proxyModelValue, value => {
399
+ console.log('watch', value);
396
400
  if (value !== (editor === null || editor === void 0 ? void 0 : editor.getHTML()) && !props.markdownFormat) {
397
401
  editor === null || editor === void 0 ? void 0 : editor.commands.setContent(value);
398
402
  }
@@ -400,14 +404,6 @@ var script = defineComponent({
400
404
  editor === null || editor === void 0 ? void 0 : editor.commands.setContent(markdownOutput.value);
401
405
  }
402
406
  });
403
- // watch(() => props.value, (value) => { //for vue2
404
- // if (value !== editor?.getHTML() && !props.markdownFormat) {
405
- // editor?.commands.setContent(value);
406
- // }
407
- // if (props.markdownFormat && value !== markdownOutput.value) {
408
- // editor?.commands.setContent(markdownOutput.value);
409
- // }
410
- // });
411
407
  return {
412
408
  editor,
413
409
  editorRef,
@@ -423,6 +419,7 @@ var script = defineComponent({
423
419
  toolbarContainerStyles,
424
420
  toolbarStyles,
425
421
  rootStyles,
422
+ root,
426
423
  toolbarButtonStyles,
427
424
  editorInputStyles,
428
425
  getIndexOfHeading,
@@ -437,11 +434,10 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
437
434
  const _component_or_icon_button = resolveComponent("or-icon-button");
438
435
  const _component_or_menu_item = resolveComponent("or-menu-item");
439
436
  const _component_or_menu = resolveComponent("or-menu");
440
- return openBlock(), createElementBlock("div", mergeProps({
441
- ref: "root"
442
- }, _ctx.$attrs, {
443
- class: _ctx.rootStyles
444
- }), [createVNode(_component_or_label, null, {
437
+ return openBlock(), createElementBlock("div", {
438
+ ref: "root",
439
+ class: normalizeClass(_ctx.rootStyles)
440
+ }, [createVNode(_component_or_label, null, {
445
441
  default: withCtx(() => [createTextVNode(toDisplayString(_ctx.description), 1 /* TEXT */)]),
446
442
 
447
443
  _: 1 /* STABLE */
@@ -513,7 +509,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
513
509
  })]),
514
510
 
515
511
  _: 1 /* STABLE */
516
- }, 8 /* PROPS */, ["trigger"])) : createCommentVNode("v-if", true)], 16 /* FULL_PROPS */);
512
+ }, 8 /* PROPS */, ["trigger"])) : createCommentVNode("v-if", true)], 2 /* CLASS */);
517
513
  }
518
514
 
519
515
  var css_248z = ".tiptap-editor ol {\n margin: 0 24px;\n list-style: decimal;\n}\n.tiptap-editor ul {\n margin: 0 24px;\n list-style: initial;\n}\n.tiptap-editor pre {\n background-color: rgba(186, 209, 236, 0.3);\n padding: 4px 8px;\n margin: 4px 0;\n width: 100%;\n border-radius: 4px;\n}\n.tiptap-editor blockquote {\n margin: 8px 24px;\n padding: 0 24px;\n border-left: 4px solid #bad1ec;\n}\n.tiptap-editor .is-editor-empty::before {\n content: attr(data-placeholder);\n height: 0;\n pointer-events: none;\n float: left;\n}";
@@ -89,7 +89,7 @@ export { a as OrToastContainerV3, s as OrToastV3, t as TypesV3 } from '../types-
89
89
  export { p as PropsV3, a as useQueueV3, u as useToastV3 } from '../useToast-0665462d.js';
90
90
  export { s as OrTooltip, a as OrTooltipContent } from '../OrTooltip-78cd7f6b.js';
91
91
  export { s as OrTooltipV3 } from '../OrTooltip-50d27b4f.js';
92
- export { s as OrRichTextEditorV3 } from '../OrRichTextEditor-cdf75b40.js';
92
+ export { s as OrRichTextEditorV3 } from '../OrRichTextEditor-eefc4567.js';
93
93
  import 'vue-demi';
94
94
  import 'lodash';
95
95
  import 'vue';
@@ -29,6 +29,7 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
29
29
  toolbarContainerStyles: import("@vue/composition-api").ComputedRef<string[]>;
30
30
  toolbarStyles: import("@vue/composition-api").ComputedRef<string[]>;
31
31
  rootStyles: import("@vue/composition-api").ComputedRef<(string | undefined)[]>;
32
+ root: import("@vue/composition-api").Ref<HTMLElement | undefined>;
32
33
  toolbarButtonStyles: (item: string) => string[];
33
34
  editorInputStyles: import("@vue/composition-api").ComputedRef<string[]>;
34
35
  getIndexOfHeading: import("@vue/composition-api").ComputedRef<number>;
@@ -38,11 +39,10 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
38
39
  modelValue: {
39
40
  type: StringConstructor;
40
41
  default: string;
41
- required: false;
42
42
  };
43
43
  value: {
44
44
  type: StringConstructor;
45
- default: undefined;
45
+ default: string;
46
46
  };
47
47
  toolbar: {
48
48
  type: ArrayConstructor;
@@ -72,11 +72,10 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
72
72
  modelValue: {
73
73
  type: StringConstructor;
74
74
  default: string;
75
- required: false;
76
75
  };
77
76
  value: {
78
77
  type: StringConstructor;
79
- default: undefined;
78
+ default: string;
80
79
  };
81
80
  toolbar: {
82
81
  type: ArrayConstructor;
@@ -142,6 +141,7 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
142
141
  toolbarContainerStyles: import("@vue/composition-api").ComputedRef<string[]>;
143
142
  toolbarStyles: import("@vue/composition-api").ComputedRef<string[]>;
144
143
  rootStyles: import("@vue/composition-api").ComputedRef<(string | undefined)[]>;
144
+ root: import("@vue/composition-api").Ref<HTMLElement | undefined>;
145
145
  toolbarButtonStyles: (item: string) => string[];
146
146
  editorInputStyles: import("@vue/composition-api").ComputedRef<string[]>;
147
147
  getIndexOfHeading: import("@vue/composition-api").ComputedRef<number>;
@@ -1,4 +1,4 @@
1
- export { s as OrRichTextEditorV3 } from '../../OrRichTextEditor-cdf75b40.js';
1
+ export { s as OrRichTextEditorV3 } from '../../OrRichTextEditor-eefc4567.js';
2
2
  import 'vue-demi';
3
3
  import '../../useClassAttribute-47fdb016.js';
4
4
  import '@vueuse/core';
@@ -89,7 +89,7 @@ export { a as OrToastContainerV3, s as OrToastV3, t as TypesV3 } from './types-8
89
89
  export { p as PropsV3, a as useQueueV3, u as useToastV3 } from './useToast-0665462d.js';
90
90
  export { s as OrTooltip, a as OrTooltipContent } from './OrTooltip-78cd7f6b.js';
91
91
  export { s as OrTooltipV3 } from './OrTooltip-50d27b4f.js';
92
- export { s as OrRichTextEditorV3 } from './OrRichTextEditor-cdf75b40.js';
92
+ export { s as OrRichTextEditorV3 } from './OrRichTextEditor-eefc4567.js';
93
93
  export { D as DropdownClose, a as DropdownOpen } from './dropdown-open-0d314aa4.js';
94
94
  export { u as useClassAttribute } from './useClassAttribute-47fdb016.js';
95
95
  export { u as useElevation } from './useElevation-31bfe1f6.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onereach/ui-components",
3
- "version": "2.70.0-beta.2114.0",
3
+ "version": "2.70.0-beta.2124.0",
4
4
  "description": "Vue components library for v2/3",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/auto/index.js",
@@ -1,16 +1,7 @@
1
- import {
2
- Title,
3
- Subtitle,
4
- Description,
5
- Primary,
6
- ArgsTable,
7
- Stories,
8
- PRIMARY_STORY
9
- } from '@storybook/addon-docs';
1
+ import { DocsPage } from '@storybook/addon-docs';
10
2
 
11
- <Title />
12
- <Subtitle />
13
- <Description />
14
- <Primary />
15
- <ArgsTable story={PRIMARY_STORY} />
16
- <Stories />
3
+ ```ts
4
+ import { OrRichTextEditorV3 as OrRichTextEditor } from '@onereach/ui-components';
5
+ ```
6
+
7
+ <DocsPage />
@@ -1,3 +1,4 @@
1
+ // import { action } from '@storybook/addon-actions';
1
2
  import { Meta, StoryFn } from '@storybook/vue3';
2
3
  import { ref } from 'vue-demi';
3
4
  import OrRichTextEditorDocs from './OrRichTextEditor.docs.mdx';
@@ -9,13 +10,17 @@ export default {
9
10
 
10
11
  argTypes: {
11
12
  // Props
12
- description: {
13
+ modelValue: {
13
14
  control: { type: 'text' },
14
15
  },
15
- placeholder: {
16
+
17
+ value: { // TODO: Remove Vue 2 fallback
18
+ table: { disable: true },
19
+ },
20
+ description: {
16
21
  control: { type: 'text' },
17
22
  },
18
- modelValue: {
23
+ placeholder: {
19
24
  control: { type: 'text' },
20
25
  },
21
26
  markdown: {
@@ -24,6 +29,14 @@ export default {
24
29
  fullHeight: {
25
30
  control: { type: 'boolean' },
26
31
  },
32
+ // Events
33
+ 'update:modelValue': {
34
+ table: { disable: true },
35
+ },
36
+
37
+ input: {
38
+ table: { disable: true },
39
+ },
27
40
  },
28
41
 
29
42
  parameters: {
@@ -45,21 +58,20 @@ const Template: StoryFn<typeof OrRichTextEditor> = (args) => ({
45
58
 
46
59
  setup() {
47
60
  // Refs
48
- const text = ref('');
61
+ const model = ref<string>();
49
62
 
50
63
  return {
51
64
  args,
52
- text,
65
+ model,
53
66
  };
54
67
  },
55
68
 
56
69
  template: `
57
- <div class="p-md h-screen w-full">
58
70
  <OrRichTextEditor
59
- v-bind="args"
60
- v-model="text"
61
- />
62
- </div>
71
+ v-model="model"
72
+ v-bind="args"
73
+ >
74
+ </OrRichTextEditor>
63
75
  `,
64
76
  });
65
77
 
@@ -1,7 +1,6 @@
1
1
  <template>
2
2
  <div
3
3
  ref="root"
4
- v-bind="$attrs"
5
4
  :class="rootStyles"
6
5
  >
7
6
  <or-label>
@@ -68,9 +67,9 @@
68
67
  </template>
69
68
 
70
69
  <script lang="ts">
71
- import { defineComponent, ref, onMounted, onBeforeUnmount, computed, watch } from 'vue-demi';
70
+ import { defineComponent, ref, computed, onBeforeUnmount, onMounted, watch } from 'vue-demi';
72
71
  import { useClassAttribute } from '../../hooks';
73
- // import { useFocusTrap, UseFocusTrapReturn } from '@vueuse/integrations/useFocusTrap';
72
+ // // import { useFocusTrap, UseFocusTrapReturn } from '@vueuse/integrations/useFocusTrap';
74
73
  import { serialize, deserialize } from './utils/markdown';
75
74
 
76
75
  import { OrIconButtonV3 as OrIconButton } from '../or-icon-button-v3';
@@ -107,20 +106,14 @@ export default defineComponent({
107
106
 
108
107
  inheritAttrs: false,
109
108
 
110
- model: {
111
- prop: 'modelValue',
112
- event: 'update:modelValue',
113
- },
114
-
115
109
  props: {
116
110
  modelValue: {
117
111
  type: String,
118
112
  default: '',
119
- required: false,
120
113
  },
121
114
  value: { // TODO: Remove Vue 2 fallback
122
115
  type: String,
123
- default: undefined,
116
+ default: '',
124
117
  },
125
118
  toolbar: {
126
119
  type: Array,
@@ -148,10 +141,19 @@ export default defineComponent({
148
141
  },
149
142
  },
150
143
 
151
- emits: ['update:modelValue', 'input'],
144
+ emits: [
145
+ 'update:modelValue',
146
+
147
+ 'input',
148
+ ],
149
+
150
+ expose: [
151
+ 'root',
152
+ ],
152
153
 
153
- setup(props, { emit }) {
154
+ setup(props, context) {
154
155
  // Refs
156
+ const root = ref<HTMLElement>();
155
157
  let editor = null as Editor | null;
156
158
  const editorRef = ref<HTMLDivElement>();
157
159
  const containerRef = ref<HTMLDivElement>();
@@ -196,7 +198,6 @@ export default defineComponent({
196
198
  blockquote: 'Quote',
197
199
  });
198
200
 
199
-
200
201
  onMounted(() => {
201
202
  editor = new Editor({
202
203
  onUpdate: ({ editor }) => {
@@ -205,19 +206,17 @@ export default defineComponent({
205
206
  const text = editor.getText();
206
207
  if (props.markdownFormat) {
207
208
  markdownOutput.value = serialize(editor.schema, editor.getJSON());
208
- emit('update:modelValue', markdownOutput.value);
209
- emit('input', markdownOutput.value);
209
+ proxyModelValue.value = markdownOutput.value;
210
210
  } else {
211
- emit('update:modelValue', text === '' ? text : html);
212
- emit('input', text === '' ? text : html);
211
+ proxyModelValue.value = text === '' ? text : html;
213
212
  }
214
213
  },
215
214
  onCreate: ({ editor }) => {
216
215
  if (props.markdownFormat) {
217
- const deserialized = deserialize(editor.schema, props.modelValue ?? props.value);
216
+ const deserialized = deserialize(editor.schema, proxyModelValue.value);
218
217
  editor.commands.setContent(deserialized);
219
218
  } else {
220
- editor.commands.setContent(props.modelValue ?? props.value);
219
+ editor.commands.setContent(proxyModelValue.value as string);
221
220
  }
222
221
  },
223
222
  element: editorRef.value,
@@ -272,6 +271,17 @@ export default defineComponent({
272
271
  // trap.activate();
273
272
 
274
273
  // Computed
274
+ const proxyModelValue = computed({
275
+ get: () => {
276
+ return props.modelValue ?? props.value; // TODO: Remove Vue 2 fallback
277
+ },
278
+
279
+ set: (value) => {
280
+ context.emit('input', value);
281
+ context.emit('update:modelValue', value);
282
+ },
283
+ });
284
+
275
285
  const getIndexOfHeading = computed(() => {
276
286
  return props.toolbar.flat().indexOf('heading');
277
287
  });
@@ -283,7 +293,7 @@ export default defineComponent({
283
293
  return 'format_paragraph';
284
294
  });
285
295
 
286
- // Methods
296
+ //Methods
287
297
  const handleEditorClick = () => {
288
298
  setActiveFormats();
289
299
  editor?.commands.focus();
@@ -400,24 +410,16 @@ export default defineComponent({
400
410
  };
401
411
 
402
412
  //Effects
403
- watch(() => props.modelValue, (value) => {
413
+ watch(proxyModelValue, (value) => {
414
+ console.log('watch', value);
404
415
  if (value !== editor?.getHTML() && !props.markdownFormat) {
405
- editor?.commands.setContent(value);
416
+ editor?.commands.setContent(value as string);
406
417
  }
407
418
  if (props.markdownFormat && value !== markdownOutput.value) {
408
419
  editor?.commands.setContent(markdownOutput.value);
409
420
  }
410
421
  });
411
422
 
412
- // watch(() => props.value, (value) => { //for vue2
413
- // if (value !== editor?.getHTML() && !props.markdownFormat) {
414
- // editor?.commands.setContent(value);
415
- // }
416
- // if (props.markdownFormat && value !== markdownOutput.value) {
417
- // editor?.commands.setContent(markdownOutput.value);
418
- // }
419
- // });
420
-
421
423
  return {
422
424
  editor,
423
425
  editorRef,
@@ -433,6 +435,7 @@ export default defineComponent({
433
435
  toolbarContainerStyles,
434
436
  toolbarStyles,
435
437
  rootStyles,
438
+ root,
436
439
  toolbarButtonStyles,
437
440
  editorInputStyles,
438
441
  getIndexOfHeading,