@onereach/ui-components 10.4.4 → 10.4.5-beta.4371.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 (43) hide show
  1. package/dist/bundled/v2/components/OrRichTextEditorV3/OrRichTextEditor.js +372 -255
  2. package/dist/bundled/v2/components/OrRichTextEditorV3/OrRichTextEditor.vue.d.ts +21 -70
  3. package/dist/bundled/v2/components/OrRichTextEditorV3/styles.d.ts +0 -2
  4. package/dist/bundled/v2/components/OrRichTextEditorV3/styles.js +4 -14
  5. package/dist/bundled/v2/components/OrRichTextEditorV3/utils/codemirror/codemirrorNode.js +1 -1
  6. package/dist/bundled/v2/components/OrRichTextEditorV3/utils/codemirror/codemirrorView.js +1 -1
  7. package/dist/bundled/v2/components/OrRichTextEditorV3/utils/markdown.js +2 -2
  8. package/dist/bundled/v2/{index-02a897ac.js → index-0e9c2b43.js} +1 -1
  9. package/dist/bundled/v2/{index-7516cf60.js → index-f379c836.js} +258 -173
  10. package/dist/bundled/v2/index.js +1 -1
  11. package/dist/bundled/v2/{markdown-62ee11bf.js → markdown-ed7d6fe1.js} +90 -119
  12. package/dist/bundled/v3/components/OrRichTextEditorV3/OrRichTextEditor.js +1 -1
  13. package/dist/bundled/v3/components/OrRichTextEditorV3/OrRichTextEditor.vue.d.ts +14 -19
  14. package/dist/bundled/v3/components/OrRichTextEditorV3/index.js +1 -1
  15. package/dist/bundled/v3/components/OrRichTextEditorV3/props.js +1 -1
  16. package/dist/bundled/v3/components/OrRichTextEditorV3/styles.d.ts +0 -2
  17. package/dist/bundled/v3/components/OrRichTextEditorV3/styles.js +1 -1
  18. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/codemirrorNode.js +1 -1
  19. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/codemirrorView.js +1 -1
  20. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/index.js +1 -1
  21. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/theme.js +1 -1
  22. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/markdown.js +1 -1
  23. package/dist/bundled/v3/components/{OrRichTextEditorV3-00963af8.js → OrRichTextEditorV3-4359556d.js} +730 -591
  24. package/dist/bundled/v3/components/index.js +1 -1
  25. package/dist/bundled/v3/index.js +2 -2
  26. package/dist/esm/v2/{OrRichTextEditor-65eb8fb0.js → OrRichTextEditor-a471836c.js} +366 -262
  27. package/dist/esm/v2/components/index.js +1 -1
  28. package/dist/esm/v2/components/or-rich-text-editor-v3/OrRichTextEditor.vue.d.ts +21 -70
  29. package/dist/esm/v2/components/or-rich-text-editor-v3/index.js +10 -10
  30. package/dist/esm/v2/components/or-rich-text-editor-v3/partials/EditorToolbar.vue.d.ts +160 -0
  31. package/dist/esm/v2/components/or-rich-text-editor-v3/styles.d.ts +0 -2
  32. package/dist/esm/v2/index.js +1 -1
  33. package/dist/esm/v3/{OrRichTextEditor-e224b4ff.js → OrRichTextEditor-92587108.js} +381 -301
  34. package/dist/esm/v3/components/index.js +1 -1
  35. package/dist/esm/v3/components/or-rich-text-editor-v3/OrRichTextEditor.vue.d.ts +14 -19
  36. package/dist/esm/v3/components/or-rich-text-editor-v3/index.js +8 -8
  37. package/dist/esm/v3/components/or-rich-text-editor-v3/partials/EditorToolbar.vue.d.ts +89 -0
  38. package/dist/esm/v3/components/or-rich-text-editor-v3/styles.d.ts +0 -2
  39. package/dist/esm/v3/index.js +1 -1
  40. package/package.json +19 -21
  41. package/src/components/or-rich-text-editor-v3/OrRichTextEditor.vue +118 -276
  42. package/src/components/or-rich-text-editor-v3/partials/EditorToolbar.vue +240 -0
  43. package/src/components/or-rich-text-editor-v3/styles.ts +4 -40
@@ -1,26 +1,314 @@
1
1
  import { h as useResizeObserver, o as onClickOutside } from '../../index-fe85dfd9.js';
2
2
  import { u as useFocusTrap } from '../../useFocusTrap-5b440601.js';
3
- import { defineComponent, ref, onMounted, onBeforeUnmount, computed, watch, nextTick } from 'vue-demi';
4
- import { B as Blockquote, a as Bold, b as BulletList, C as CodeBlock, H as HardBreak, c as HorizontalRule, I as Italic, L as ListItem, O as OrderedList, P as Paragraph, S as Strike, s as serialize, d as deserialize, U as Underline, e as Link, f as Highlight } from '../../markdown-62ee11bf.js';
5
- import { OrRichTextEditor, EditorContainer, ToolbarContainer, Toolbar, ToolbarButtonFocused, ToolbarButton, EditorInput } from './styles.js';
6
- import { Formats } from './props.js';
7
- import { N as Node, m as mergeAttributes, t as textblockTypeInputRule, E as Extension, D as Decoration, a as DecorationSet, M as Mark, b as markInputRule, c as markPasteRule, k as keydownHandler, d as callOrReturn, g as getExtensionField, e as Editor } from '../../index-7516cf60.js';
8
- import { P as Plugin, a as PluginKey, d as dropPoint, S as Selection, N as NodeSelection, F as Fragment, b as Slice, T as TextSelection, M as Mapping } from '../../index-02a897ac.js';
9
- import codemirrorNode from './utils/codemirror/codemirrorNode.js';
10
- import __vue_component__$1 from '../OrIconButtonV3/OrIconButton.js';
11
- import __vue_component__$2 from '../OrLabelV3/OrLabel.js';
3
+ import { defineComponent, ref, computed, onMounted, onBeforeUnmount, watch, nextTick } from 'vue-demi';
4
+ import { B as Blockquote, a as Bold, b as BulletList, C as CodeBlock, H as HardBreak, c as HorizontalRule, I as Italic, L as ListItem, O as OrderedList, P as Paragraph, S as Strike, s as serialize, d as deserialize, U as Underline, e as Link, f as Highlight } from '../../markdown-ed7d6fe1.js';
5
+ import { ToolbarContainer, Toolbar, ToolbarButtonFocused, ToolbarButton, OrRichTextEditor } from './styles.js';
6
+ import __vue_component__$2 from '../OrIconButtonV3/OrIconButton.js';
12
7
  import __vue_component__$3 from '../OrMenuItemV3/OrMenuItem.js';
13
8
  import __vue_component__$4 from '../OrMenuV3/OrMenu.js';
14
- import __vue_component__$5 from '../OrModalV3/OrModal.js';
15
- import { _ as __vue_component__$6 } from '../../OrInput-8f24749f.js';
16
- import __vue_component__$7 from '../OrButtonV3/OrButton.js';
17
- import __vue_component__$8 from '../OrPopoverV3/OrPopover.js';
9
+ import __vue_component__$5 from '../OrPopoverV3/OrPopover.js';
10
+ import { isArray } from '../../utils/isArray.js';
11
+ import { n as normalizeComponent } from '../../normalize-component-6e8e3d80.js';
12
+ import { Formats } from './props.js';
13
+ import { N as Node, m as mergeAttributes, t as textblockTypeInputRule, E as Extension, D as Decoration, a as DecorationSet, M as Mark, b as markInputRule, c as markPasteRule, k as keydownHandler, d as callOrReturn, g as getExtensionField, e as Editor } from '../../index-f379c836.js';
14
+ import { P as Plugin, a as PluginKey, d as dropPoint, S as Selection, N as NodeSelection, F as Fragment, b as Slice, T as TextSelection, M as Mapping } from '../../index-0e9c2b43.js';
15
+ import codemirrorNode from './utils/codemirror/codemirrorNode.js';
16
+ import __vue_component__$6 from '../OrModalV3/OrModal.js';
17
+ import { _ as __vue_component__$7 } from '../../OrInput-8f24749f.js';
18
+ import __vue_component__$8 from '../OrButtonV3/OrButton.js';
18
19
  import __vue_component__$9 from '../OrHintV3/OrHint.js';
19
20
  import __vue_component__$a from '../OrErrorV3/OrError.js';
21
+ import __vue_component__$b from '../OrLabelV3/OrLabel.js';
22
+ import __vue_component__$c from '../OrInputBoxV3/OrInputBox.js';
20
23
  import { a as useDebounceFn } from '../../index-279e78b9.js';
21
- import { isArray } from '../../utils/isArray.js';
22
24
  import { s as styleInject } from '../../style-inject.es-4c6f2515.js';
23
- import { n as normalizeComponent } from '../../normalize-component-6e8e3d80.js';
25
+
26
+ var script$1 = defineComponent({
27
+ components: {
28
+ OrIconButton: __vue_component__$2,
29
+ OrMenuItem: __vue_component__$3,
30
+ OrMenu: __vue_component__$4,
31
+ OrPopover: __vue_component__$5
32
+ },
33
+ props: {
34
+ toolbar: {
35
+ type: Array,
36
+ default: () => []
37
+ },
38
+ isFocused: {
39
+ type: Boolean,
40
+ default: false
41
+ },
42
+ countOfNotVisibleTools: {
43
+ type: Number,
44
+ default: 0
45
+ },
46
+ activeHeadingLevel: {
47
+ type: Number,
48
+ default: 0
49
+ },
50
+ isActive: {
51
+ type: Object,
52
+ default: () => ({})
53
+ },
54
+ headingLevels: {
55
+ type: Array,
56
+ default: () => [1, 2, 3, 4]
57
+ }
58
+ },
59
+ emits: ['click-tool'],
60
+ setup(props, _ref) {
61
+ let {
62
+ emit
63
+ } = _ref;
64
+ const toolbarRef = ref();
65
+ const moreButtonRef = ref();
66
+ const moreRef = ref();
67
+ const toolbarButtonRef = ref();
68
+ const menuRef = ref();
69
+ const iconsEnum = ref({
70
+ bold: 'format_bold',
71
+ italic: 'format_italic',
72
+ underline: 'format_underlined',
73
+ strike: 'format_strikethrough',
74
+ bulletList: 'format_list_bulleted',
75
+ orderedList: 'format_list_numbered',
76
+ link: 'link',
77
+ highlight: 'highlight',
78
+ redo: 'redo',
79
+ undo: 'undo',
80
+ codeBlock: 'code_blocks',
81
+ blockquote: 'format_quote',
82
+ file: 'attach_file',
83
+ source: 'source_notes'
84
+ });
85
+ const iconTooltipsEnum = ref({
86
+ bold: 'Bold',
87
+ italic: 'Italic',
88
+ underline: 'Underline',
89
+ strike: 'Strike',
90
+ bulletList: 'Bulleted List',
91
+ orderedList: 'Numbered List',
92
+ link: 'Link',
93
+ highlight: 'Highlight',
94
+ redo: 'Redo',
95
+ undo: 'Undo',
96
+ codeBlock: 'Code Block',
97
+ blockquote: 'Quote',
98
+ file: 'File',
99
+ source: 'Source',
100
+ heading: 'Heading'
101
+ });
102
+ const notVisibleTools = computed(() => {
103
+ const count = props.countOfNotVisibleTools;
104
+ const toolbar = props.toolbar.flat();
105
+ let notVisible = new Set(toolbar.slice(toolbar.length - count, toolbar.length));
106
+ props.toolbar.forEach(tools => {
107
+ if (tools.some(item => notVisible.has(item))) {
108
+ tools.forEach(item => notVisible.add(item));
109
+ }
110
+ });
111
+ return notVisible;
112
+ });
113
+ const toolbarContainerStyles = computed(() => [...ToolbarContainer]);
114
+ const toolbarStyles = computed(() => [...Toolbar, ...(props.isFocused ? ToolbarButtonFocused : ToolbarButton)]);
115
+ const getIndexOfHeading = computed(() => {
116
+ return props.toolbar.flat().indexOf('heading');
117
+ });
118
+ const headingIcon = computed(() => {
119
+ if (props.activeHeadingLevel && props.isActive.heading) {
120
+ return `format_h${props.activeHeadingLevel}`;
121
+ }
122
+ return 'format_paragraph';
123
+ });
124
+ const isVisible = value => {
125
+ if (isArray(value)) {
126
+ const isHaveNotVisibleTools = value.some(item => notVisibleTools.value.has(item));
127
+ return isHaveNotVisibleTools;
128
+ }
129
+ return !notVisibleTools.value.has(value);
130
+ };
131
+ const handleClick = (item, level) => {
132
+ emit('click-tool', {
133
+ item,
134
+ level
135
+ });
136
+ };
137
+ return {
138
+ toolbarRef,
139
+ moreButtonRef,
140
+ moreRef,
141
+ toolbarButtonRef,
142
+ menuRef,
143
+ toolbarContainerStyles,
144
+ toolbarStyles,
145
+ isVisible,
146
+ handleClick,
147
+ headingIcon,
148
+ getIndexOfHeading,
149
+ notVisibleTools,
150
+ iconsEnum,
151
+ iconTooltipsEnum
152
+ };
153
+ }
154
+ });
155
+
156
+ /* script */
157
+ const __vue_script__$1 = script$1;
158
+
159
+ /* template */
160
+ var __vue_render__$1 = function () {
161
+ var _vm = this;
162
+ var _h = _vm.$createElement;
163
+ var _c = _vm._self._c || _h;
164
+ return _c('div', {
165
+ ref: "toolbarRef",
166
+ class: _vm.toolbarContainerStyles
167
+ }, [_vm._l(_vm.toolbar, function (tools, index) {
168
+ return _c('div', {
169
+ key: index,
170
+ class: _vm.toolbarStyles.concat([{
171
+ 'hidden': _vm.isVisible(tools)
172
+ }])
173
+ }, _vm._l(tools, function (item) {
174
+ return _c('div', {
175
+ key: item,
176
+ class: ['flex gap-md', {
177
+ 'hidden': !_vm.isVisible(item)
178
+ }]
179
+ }, [item === 'heading' ? _c('or-icon-button', {
180
+ ref: "toolbarButtonRef",
181
+ refInFor: true,
182
+ attrs: {
183
+ "selected": _vm.isActive[item],
184
+ "disabled": !_vm.isFocused,
185
+ "tooltip": {
186
+ content: _vm.iconTooltipsEnum[item],
187
+ placement: 'top'
188
+ },
189
+ "icon": {
190
+ icon: _vm.headingIcon,
191
+ variant: 'inherit'
192
+ }
193
+ },
194
+ on: {
195
+ "click": function ($event) {
196
+ _vm.menuRef && _vm.menuRef.toggle();
197
+ }
198
+ }
199
+ }) : _vm.isVisible(item) ? _c('or-icon-button', {
200
+ attrs: {
201
+ "tooltip": {
202
+ content: _vm.iconTooltipsEnum[item],
203
+ placement: 'top'
204
+ },
205
+ "selected": _vm.isActive[item],
206
+ "disabled": !_vm.isFocused,
207
+ "icon": {
208
+ icon: _vm.iconsEnum[item],
209
+ variant: 'inherit'
210
+ }
211
+ },
212
+ on: {
213
+ "click": function ($event) {
214
+ return _vm.handleClick(item);
215
+ }
216
+ }
217
+ }) : _vm._e()], 1);
218
+ }), 0);
219
+ }), _vm._v(" "), _vm.countOfNotVisibleTools > 0 ? _c('or-icon-button', {
220
+ ref: "moreButtonRef",
221
+ staticClass: "px-sm",
222
+ attrs: {
223
+ "disabled": !_vm.isFocused,
224
+ "icon": {
225
+ icon: 'more_horiz',
226
+ variant: 'inherit'
227
+ }
228
+ },
229
+ on: {
230
+ "click": function ($event) {
231
+ _vm.moreRef && _vm.moreRef.open();
232
+ }
233
+ }
234
+ }) : _vm._e(), _vm._v(" "), _vm.moreButtonRef ? _c('or-popover', {
235
+ ref: "moreRef",
236
+ attrs: {
237
+ "trigger": _vm.moreButtonRef && _vm.moreButtonRef.root,
238
+ "placement": "top-end"
239
+ }
240
+ }, [_c('div', {
241
+ staticClass: "flex p-sm gap-md"
242
+ }, _vm._l(_vm.notVisibleTools, function (item) {
243
+ return _c('or-icon-button', {
244
+ key: item,
245
+ attrs: {
246
+ "tooltip": {
247
+ content: _vm.iconTooltipsEnum[item],
248
+ placement: 'top'
249
+ },
250
+ "selected": _vm.isActive[item],
251
+ "icon": {
252
+ icon: _vm.iconsEnum[item],
253
+ variant: 'inherit'
254
+ }
255
+ },
256
+ on: {
257
+ "click": function ($event) {
258
+ return _vm.handleClick(item);
259
+ }
260
+ }
261
+ });
262
+ }), 1)]) : _vm._e(), _vm._v(" "), _vm.toolbarButtonRef ? _c('or-menu', {
263
+ ref: "menuRef",
264
+ attrs: {
265
+ "trigger": _vm.toolbarButtonRef[_vm.getIndexOfHeading] && _vm.toolbarButtonRef[_vm.getIndexOfHeading].root,
266
+ "placement": "bottom-start"
267
+ }
268
+ }, [_vm._l(_vm.headingLevels, function (heading) {
269
+ return _c('or-menu-item', {
270
+ key: heading,
271
+ attrs: {
272
+ "selected": _vm.activeHeadingLevel === heading
273
+ },
274
+ on: {
275
+ "click": function ($event) {
276
+ return _vm.handleClick('heading', heading);
277
+ }
278
+ }
279
+ }, [_vm._v("\n Heading " + _vm._s(heading) + "\n ")]);
280
+ }), _vm._v(" "), _c('or-menu-item', {
281
+ attrs: {
282
+ "selected": !_vm.activeHeadingLevel
283
+ },
284
+ on: {
285
+ "click": function ($event) {
286
+ return _vm.handleClick('heading');
287
+ }
288
+ }
289
+ }, [_vm._v("\n None\n ")])], 2) : _vm._e()], 2);
290
+ };
291
+ var __vue_staticRenderFns__$1 = [];
292
+
293
+ /* style */
294
+ const __vue_inject_styles__$1 = undefined;
295
+ /* scoped */
296
+ const __vue_scope_id__$1 = undefined;
297
+ /* module identifier */
298
+ const __vue_module_identifier__$1 = undefined;
299
+ /* functional template */
300
+ const __vue_is_functional_template__$1 = false;
301
+ /* style inject */
302
+
303
+ /* style inject SSR */
304
+
305
+ /* style inject shadow dom */
306
+
307
+ const __vue_component__$1 = /*#__PURE__*/normalizeComponent({
308
+ render: __vue_render__$1,
309
+ staticRenderFns: __vue_staticRenderFns__$1
310
+ }, __vue_inject_styles__$1, __vue_script__$1, __vue_scope_id__$1, __vue_is_functional_template__$1, __vue_module_identifier__$1, false, undefined, undefined, undefined);
311
+ var EditorToolbar = __vue_component__$1;
24
312
 
25
313
  const Heading = Node.create({
26
314
  name: 'heading',
@@ -1283,8 +1571,11 @@ const History = Extension.create({
1283
1571
  addKeyboardShortcuts() {
1284
1572
  return {
1285
1573
  'Mod-z': () => this.editor.commands.undo(),
1574
+ 'Mod-Z': () => this.editor.commands.undo(),
1286
1575
  'Mod-y': () => this.editor.commands.redo(),
1576
+ 'Mod-Y': () => this.editor.commands.redo(),
1287
1577
  'Shift-Mod-z': () => this.editor.commands.redo(),
1578
+ 'Shift-Mod-Z': () => this.editor.commands.redo(),
1288
1579
  // Russian keyboard layouts
1289
1580
  'Mod-я': () => this.editor.commands.undo(),
1290
1581
  'Shift-Mod-я': () => this.editor.commands.redo()
@@ -1363,16 +1654,14 @@ const StarterKit = Extension.create({
1363
1654
  var script = defineComponent({
1364
1655
  name: 'OrRichTextEditor',
1365
1656
  components: {
1366
- OrIconButton: __vue_component__$1,
1367
- OrLabel: __vue_component__$2,
1368
- OrMenuItem: __vue_component__$3,
1369
- OrMenu: __vue_component__$4,
1370
- OrModal: __vue_component__$5,
1371
- OrInput: __vue_component__$6,
1372
- OrButton: __vue_component__$7,
1373
- OrPopover: __vue_component__$8,
1657
+ OrModal: __vue_component__$6,
1658
+ OrInput: __vue_component__$7,
1659
+ OrButton: __vue_component__$8,
1374
1660
  OrHint: __vue_component__$9,
1375
- OrError: __vue_component__$a
1661
+ OrError: __vue_component__$a,
1662
+ OrLabel: __vue_component__$b,
1663
+ EditorToolbar,
1664
+ OrInputBox: __vue_component__$c
1376
1665
  },
1377
1666
  model: {
1378
1667
  prop: 'modelValue',
@@ -1418,6 +1707,10 @@ var script = defineComponent({
1418
1707
  error: {
1419
1708
  type: [String, Boolean],
1420
1709
  default: undefined
1710
+ },
1711
+ readonly: {
1712
+ type: Boolean,
1713
+ default: false
1421
1714
  }
1422
1715
  },
1423
1716
  emits: ['update:modelValue', 'input', 'file-upload'],
@@ -1429,11 +1722,7 @@ var script = defineComponent({
1429
1722
  const editorRef = ref();
1430
1723
  const textareaRef = ref();
1431
1724
  const containerRef = ref();
1432
- const toolbarRef = ref();
1433
- const moreButtonRef = ref();
1434
- const moreRef = ref();
1435
- const toolbarButtonRef = ref();
1436
- const menuRef = ref();
1725
+ const toolbarContainerRef = ref();
1437
1726
  // isActive should be set with default values for all toolbar buttons, otherwise it will not work in vue2
1438
1727
  const isActive = ref({
1439
1728
  bold: false,
@@ -1451,7 +1740,7 @@ var script = defineComponent({
1451
1740
  file: false,
1452
1741
  source: false
1453
1742
  });
1454
- const isFocused = ref(props.autofocus);
1743
+ const isFocused = ref(!props.readonly ? props.autofocus : false);
1455
1744
  const headingLevels = [1, 2, 3, 4];
1456
1745
  const activeHeadingLevel = ref(0);
1457
1746
  const markdownOutput = ref('');
@@ -1466,49 +1755,19 @@ var script = defineComponent({
1466
1755
  fallbackFocus: '.container',
1467
1756
  allowOutsideClick: true
1468
1757
  });
1469
- const iconsEnum = ref({
1470
- bold: 'format_bold',
1471
- italic: 'format_italic',
1472
- underline: 'format_underlined',
1473
- strike: 'format_strikethrough',
1474
- bulletList: 'format_list_bulleted',
1475
- orderedList: 'format_list_numbered',
1476
- link: 'link',
1477
- highlight: 'highlight',
1478
- redo: 'redo',
1479
- undo: 'undo',
1480
- codeBlock: 'code_blocks',
1481
- blockquote: 'format_quote',
1482
- file: 'attach_file',
1483
- source: 'source_notes'
1484
- });
1485
- const iconTooltipsEnum = ref({
1486
- bold: 'Bold',
1487
- italic: 'Italic',
1488
- underline: 'Underline',
1489
- strike: 'Strike',
1490
- bulletList: 'Bulleted List',
1491
- orderedList: 'Numbered List',
1492
- link: 'Link',
1493
- highlight: 'Highlight',
1494
- redo: 'Redo',
1495
- undo: 'Undo',
1496
- codeBlock: 'Code Block',
1497
- blockquote: 'Quote',
1498
- file: 'File',
1499
- source: 'Source'
1500
- });
1501
1758
  useResizeObserver(root, useDebounceFn(entries => {
1502
1759
  var _a, _b;
1503
1760
  const entry = entries[0];
1504
1761
  const {
1505
1762
  width
1506
1763
  } = entry.contentRect;
1507
- if (containerRef.value && toolbarRef.value && toolbarLength.value) {
1764
+ const toolbarLength = props.toolbar.flat().length;
1765
+ if (containerRef.value && toolbarContainerRef.value && toolbarLength) {
1508
1766
  let lengthOfItem = 0;
1509
- lengthOfItem = ((_b = (_a = toolbarRef.value.firstElementChild) === null || _a === void 0 ? void 0 : _a.firstElementChild) === null || _b === void 0 ? void 0 : _b.offsetWidth) + 16;
1767
+ const toolbarRef = toolbarContainerRef.value.$refs.toolbarRef;
1768
+ lengthOfItem = ((_b = (_a = toolbarRef === null || toolbarRef === void 0 ? void 0 : toolbarRef.firstElementChild) === null || _a === void 0 ? void 0 : _a.firstElementChild) === null || _b === void 0 ? void 0 : _b.offsetWidth) + 16;
1510
1769
  const count = width / lengthOfItem - 2;
1511
- countOfNotVisibleTools.value = Math.round(toolbarLength.value - count);
1770
+ countOfNotVisibleTools.value = Math.round(toolbarLength - count);
1512
1771
  }
1513
1772
  }, 10));
1514
1773
  onMounted(() => {
@@ -1540,7 +1799,8 @@ var script = defineComponent({
1540
1799
  }
1541
1800
  },
1542
1801
  element: editorRef.value,
1543
- autofocus: props.autofocus,
1802
+ autofocus: !props.readonly ? props.autofocus : false,
1803
+ editable: !props.readonly,
1544
1804
  enableInputRules: true,
1545
1805
  enablePasteRules: true,
1546
1806
  extensions: [codemirrorNode, StarterKit.configure({
@@ -1621,43 +1881,15 @@ var script = defineComponent({
1621
1881
  context.emit('update:modelValue', value);
1622
1882
  }
1623
1883
  });
1624
- const getIndexOfHeading = computed(() => {
1625
- return props.toolbar.flat().indexOf('heading');
1626
- });
1627
- const headingIcon = computed(() => {
1628
- if (activeHeadingLevel.value && isActive.value.heading) {
1629
- return `format_h${activeHeadingLevel.value}`;
1630
- }
1631
- return 'format_paragraph';
1632
- });
1633
- const toolbarLength = computed(() => {
1634
- return props.toolbar.flat().length;
1635
- });
1636
- const notVisibleTools = computed(() => {
1637
- const count = countOfNotVisibleTools.value;
1638
- const toolbar = props.toolbar.flat();
1639
- let notVisible = new Set(toolbar.slice(toolbar.length - count, toolbar.length));
1640
- props.toolbar.forEach(tools => {
1641
- if (tools.some(item => notVisible.has(item))) {
1642
- tools.forEach(item => notVisible.add(item));
1643
- }
1644
- });
1645
- return notVisible;
1646
- });
1647
1884
  //Methods
1648
1885
  const handleEditorClick = () => {
1649
1886
  var _a;
1650
1887
  setActiveFormats();
1651
- isFocused.value = true;
1652
- editor === null || editor === void 0 ? void 0 : editor.commands.focus();
1653
- activeHeadingLevel.value = ((_a = editor === null || editor === void 0 ? void 0 : editor.getAttributes('heading')) === null || _a === void 0 ? void 0 : _a.level) || 0;
1654
- };
1655
- const isVisible = value => {
1656
- if (isArray(value)) {
1657
- const isHaveNotVisibleTools = value.some(item => notVisibleTools.value.has(item));
1658
- return isHaveNotVisibleTools;
1888
+ if (!props.readonly) {
1889
+ isFocused.value = true;
1890
+ editor === null || editor === void 0 ? void 0 : editor.commands.focus();
1659
1891
  }
1660
- return !notVisibleTools.value.has(value);
1892
+ activeHeadingLevel.value = ((_a = editor === null || editor === void 0 ? void 0 : editor.getAttributes('heading')) === null || _a === void 0 ? void 0 : _a.level) || 0;
1661
1893
  };
1662
1894
  const handleInput = event => {
1663
1895
  const target = event.target;
@@ -1666,7 +1898,11 @@ var script = defineComponent({
1666
1898
  markdownOutput.value = serialize(editor === null || editor === void 0 ? void 0 : editor.schema, editor === null || editor === void 0 ? void 0 : editor.getJSON());
1667
1899
  proxyModelValue.value = markdownOutput.value;
1668
1900
  };
1669
- const handleToolbarClick = (item, level) => {
1901
+ const handleToolbarClick = _ref4 => {
1902
+ let {
1903
+ item,
1904
+ level
1905
+ } = _ref4;
1670
1906
  var _a, _b, _c, _d;
1671
1907
  switch (item) {
1672
1908
  case 'source':
@@ -1746,10 +1982,10 @@ var script = defineComponent({
1746
1982
  editor === null || editor === void 0 ? void 0 : editor.chain().focus().setMark('link', {
1747
1983
  href: link.value,
1748
1984
  target: '__blank'
1749
- }).command(_ref4 => {
1985
+ }).command(_ref5 => {
1750
1986
  let {
1751
1987
  tr
1752
- } = _ref4;
1988
+ } = _ref5;
1753
1989
  const preparedValue = text.value[text.value.length - 1] === ' ' ? text.value : `${text.value} `;
1754
1990
  tr.insertText(preparedValue);
1755
1991
  return true;
@@ -1785,12 +2021,7 @@ var script = defineComponent({
1785
2021
  };
1786
2022
  // Styles
1787
2023
  const rootStyles = computed(() => ['or-rich-text-editor-v3', ...OrRichTextEditor]);
1788
- const containerStyles = computed(() => [...EditorContainer]);
1789
- const toolbarContainerStyles = computed(() => [...ToolbarContainer]);
1790
- const toolbarStyles = computed(() => [...Toolbar,
1791
- // 'overflow-x-hidden',
1792
- ...(isFocused.value ? ToolbarButtonFocused : ToolbarButton)]);
1793
- const editorInputStyles = computed(() => ['tiptap-editor-v3', ...EditorInput]);
2024
+ const editorInputStyles = computed(() => ['tiptap-editor-v3']);
1794
2025
  //Effects
1795
2026
  watch(proxyModelValue, value => {
1796
2027
  if (value !== (editor === null || editor === void 0 ? void 0 : editor.getHTML()) && props.format !== 'markdown') {
@@ -1801,39 +2032,33 @@ var script = defineComponent({
1801
2032
  editor === null || editor === void 0 ? void 0 : editor.commands.setContent(deserialized);
1802
2033
  }
1803
2034
  });
2035
+ watch(props, _ref6 => {
2036
+ let {
2037
+ readonly
2038
+ } = _ref6;
2039
+ isFocused.value = !readonly;
2040
+ editor === null || editor === void 0 ? void 0 : editor.setEditable(!readonly);
2041
+ });
1804
2042
  return {
1805
2043
  editor,
1806
2044
  editorRef,
1807
- toolbarRef,
2045
+ toolbarContainerRef,
1808
2046
  containerRef,
1809
- toolbarButtonRef,
1810
- moreButtonRef,
1811
2047
  textareaRef,
1812
- moreRef,
1813
- menuRef,
1814
- iconsEnum,
1815
2048
  handleToolbarClick,
1816
2049
  handleEditorClick,
1817
2050
  isActive,
1818
- iconTooltipsEnum,
1819
- containerStyles,
1820
- toolbarContainerStyles,
1821
- toolbarStyles,
1822
2051
  rootStyles,
1823
2052
  root,
1824
2053
  editorInputStyles,
1825
- getIndexOfHeading,
1826
2054
  headingLevels,
1827
- headingIcon,
1828
2055
  attachLink,
1829
2056
  discardLink,
1830
2057
  isOpenLinkModal,
1831
2058
  text,
1832
2059
  link,
1833
2060
  isFocused,
1834
- isVisible,
1835
2061
  countOfNotVisibleTools,
1836
- notVisibleTools,
1837
2062
  handleInput,
1838
2063
  proxyModelValue,
1839
2064
  disableMarkdown,
@@ -1869,89 +2094,35 @@ var __vue_render__ = function () {
1869
2094
  }], null, true)
1870
2095
  }, [_vm._t("label", function () {
1871
2096
  return [_vm._v("\n " + _vm._s(_vm.label) + "\n ")];
1872
- })], 2)] : _vm._e(), _vm._v(" "), _c('div', {
1873
- ref: 'containerRef',
1874
- class: _vm.containerStyles,
2097
+ })], 2)] : _vm._e(), _vm._v(" "), _c('OrInputBox', {
2098
+ staticClass: "first:children:ml-none last:children:mr-none overflow-hidden flex flex-col",
1875
2099
  attrs: {
1876
- "invalid": !!_vm.error
2100
+ "invalid": !!_vm.error,
2101
+ "readonly": _vm.readonly
1877
2102
  },
1878
2103
  on: {
1879
2104
  "click": function ($event) {
1880
2105
  return _vm.handleEditorClick();
1881
2106
  }
1882
2107
  }
1883
- }, [_c('div', {
1884
- ref: 'toolbarRef',
1885
- class: _vm.toolbarContainerStyles
1886
- }, [_vm._l(_vm.toolbar, function (tools, index) {
1887
- return _c('div', {
1888
- key: index,
1889
- class: _vm.toolbarStyles.concat([{
1890
- 'hidden': _vm.isVisible(tools)
1891
- }])
1892
- }, _vm._l(tools, function (item) {
1893
- return _c('div', {
1894
- key: item,
1895
- class: ['flex gap-md', {
1896
- 'hidden': !_vm.isVisible(item)
1897
- }]
1898
- }, [item === 'heading' ? _c('or-icon-button', {
1899
- ref: 'toolbarButtonRef',
1900
- refInFor: true,
1901
- attrs: {
1902
- "selected": _vm.isActive[item],
1903
- "disabled": !_vm.isFocused,
1904
- "tooltip": {
1905
- content: item,
1906
- placement: 'top'
1907
- },
1908
- "icon": {
1909
- icon: _vm.headingIcon,
1910
- variant: 'inherit'
1911
- }
1912
- },
1913
- on: {
1914
- "click": function ($event) {
1915
- _vm.menuRef && _vm.menuRef.toggle();
1916
- }
1917
- }
1918
- }) : _vm.isVisible(item) ? _c('or-icon-button', {
1919
- attrs: {
1920
- "tooltip": {
1921
- content: _vm.iconTooltipsEnum[item],
1922
- placement: 'top'
1923
- },
1924
- "selected": _vm.isActive[item],
1925
- "disabled": !_vm.isFocused,
1926
- "icon": {
1927
- icon: _vm.iconsEnum[item],
1928
- variant: 'inherit'
1929
- }
1930
- },
1931
- on: {
1932
- "click": function ($event) {
1933
- return _vm.handleToolbarClick(item);
1934
- }
1935
- }
1936
- }) : _vm._e()], 1);
1937
- }), 0);
1938
- }), _vm._v(" "), _vm.countOfNotVisibleTools > 0 ? _c('or-icon-button', {
1939
- ref: 'moreButtonRef',
1940
- staticClass: "px-sm",
2108
+ }, [!_vm.readonly ? _c('editor-toolbar', {
2109
+ ref: "toolbarContainerRef",
1941
2110
  attrs: {
1942
- "disabled": !_vm.isFocused,
1943
- "icon": {
1944
- icon: 'more_horiz',
1945
- variant: 'inherit'
1946
- }
2111
+ "count-of-not-visible-tools": _vm.countOfNotVisibleTools,
2112
+ "toolbar": _vm.toolbar,
2113
+ "is-focused": _vm.isFocused,
2114
+ "active-heading-level": _vm.activeHeadingLevel,
2115
+ "is-active": _vm.isActive,
2116
+ "heading-levels": _vm.headingLevels
1947
2117
  },
1948
2118
  on: {
1949
- "click": function ($event) {
1950
- _vm.moreRef && _vm.moreRef.open();
1951
- }
2119
+ "click-tool": _vm.handleToolbarClick
1952
2120
  }
1953
- }) : _vm._e()], 2), _vm._v(" "), _c('div', {
1954
- class: ['p-sm', 'overflow-auto', 'min-h-[88px]']
2121
+ }) : _vm._e(), _vm._v(" "), _c('div', {
2122
+ ref: "containerRef",
2123
+ staticClass: "m-none w-full h-full p-sm overflow-hidden"
2124
+ }, [_c('div', {
2125
+ staticClass: "w-full h-full min-h-[88px]"
1955
2126
  }, [_c('textarea', {
1956
2127
  directives: [{
1957
2128
  name: "show",
@@ -1987,74 +2158,20 @@ var __vue_render__ = function () {
1987
2158
  value: !_vm.disableMarkdown,
1988
2159
  expression: "!disableMarkdown"
1989
2160
  }],
1990
- ref: 'editorRef',
2161
+ ref: "editorRef",
2162
+ staticClass: "overflow-auto w-full h-full",
1991
2163
  class: _vm.editorInputStyles
1992
2164
  }), _vm._v(" "), _vm._t("files")], 2)]), _vm._v(" "), !_vm.error ? [_vm.$slots.hint || _vm.hint ? [_c('OrHint', {
1993
2165
  attrs: {
1994
2166
  "disabled": _vm.disabled
1995
2167
  }
1996
2168
  }, [_vm._t("hint", function () {
1997
- return [_vm._v("\n " + _vm._s(_vm.hint) + "\n ")];
2169
+ return [_vm._v("\n " + _vm._s(_vm.hint) + "\n ")];
1998
2170
  })], 2)] : _vm._e()] : _vm._e(), _vm._v(" "), typeof _vm.error === 'string' ? [_c('OrError', {
1999
2171
  attrs: {
2000
2172
  "disabled": _vm.disabled
2001
2173
  }
2002
- }, [_vm._v("\n " + _vm._s(_vm.error) + "\n ")])] : _vm._e(), _vm._v(" "), _vm.moreButtonRef ? _c('or-popover', {
2003
- ref: 'moreRef',
2004
- attrs: {
2005
- "trigger": _vm.moreButtonRef && _vm.moreButtonRef.root,
2006
- "placement": "top-end"
2007
- }
2008
- }, [_c('div', {
2009
- staticClass: "flex p-sm gap-md"
2010
- }, _vm._l(_vm.notVisibleTools, function (item) {
2011
- return _c('or-icon-button', {
2012
- key: item,
2013
- attrs: {
2014
- "tooltip": {
2015
- content: _vm.iconTooltipsEnum[item],
2016
- placement: 'top'
2017
- },
2018
- "selected": _vm.isActive[item],
2019
- "icon": {
2020
- icon: _vm.iconsEnum[item],
2021
- variant: 'inherit'
2022
- }
2023
- },
2024
- on: {
2025
- "click": function ($event) {
2026
- return _vm.handleToolbarClick(item);
2027
- }
2028
- }
2029
- });
2030
- }), 1)]) : _vm._e(), _vm._v(" "), _vm.toolbarButtonRef ? _c('or-menu', {
2031
- ref: 'menuRef',
2032
- attrs: {
2033
- "trigger": _vm.toolbarButtonRef[_vm.getIndexOfHeading] && _vm.toolbarButtonRef[_vm.getIndexOfHeading].root,
2034
- "placement": "bottom-start"
2035
- }
2036
- }, [_vm._l(_vm.headingLevels, function (heading) {
2037
- return _c('or-menu-item', {
2038
- key: heading,
2039
- attrs: {
2040
- "selected": _vm.activeHeadingLevel === heading
2041
- },
2042
- on: {
2043
- "click": function ($event) {
2044
- return _vm.handleToolbarClick('heading', heading);
2045
- }
2046
- }
2047
- }, [_vm._v("\n Heading " + _vm._s(heading) + "\n ")]);
2048
- }), _vm._v(" "), _c('or-menu-item', {
2049
- attrs: {
2050
- "selected": !_vm.activeHeadingLevel
2051
- },
2052
- on: {
2053
- "click": function ($event) {
2054
- return _vm.handleToolbarClick('heading');
2055
- }
2056
- }
2057
- }, [_vm._v("\n None\n ")])], 2) : _vm._e(), _vm._v(" "), _c('or-modal', {
2174
+ }, [_vm._v("\n " + _vm._s(_vm.error) + "\n ")])] : _vm._e(), _vm._v(" "), _c('or-modal', {
2058
2175
  attrs: {
2059
2176
  "is-open": _vm.isOpenLinkModal,
2060
2177
  "size": "s"
@@ -2064,7 +2181,7 @@ var __vue_render__ = function () {
2064
2181
  fn: function () {
2065
2182
  return [_c('p', {
2066
2183
  staticClass: "text-headline-2"
2067
- }, [_vm._v("\n Add Link\n ")])];
2184
+ }, [_vm._v("\n Add Link\n ")])];
2068
2185
  },
2069
2186
  proxy: true
2070
2187
  }, {
@@ -2087,7 +2204,7 @@ var __vue_render__ = function () {
2087
2204
  },
2088
2205
  proxy: true
2089
2206
  }])
2090
- }, [_vm._v(" "), _c('div', [_c('or-label', [_vm._v("\n Text\n ")]), _vm._v(" "), _c('or-input', {
2207
+ }, [_vm._v(" "), _c('div', [_c('or-label', [_vm._v("\n Text\n ")]), _vm._v(" "), _c('or-input', {
2091
2208
  staticClass: "pb-md",
2092
2209
  attrs: {
2093
2210
  "placeholder": "Enter text"
@@ -2099,7 +2216,7 @@ var __vue_render__ = function () {
2099
2216
  },
2100
2217
  expression: "text"
2101
2218
  }
2102
- }), _vm._v(" "), _c('or-label', [_vm._v("\n Link\n ")]), _vm._v(" "), _c('or-input', {
2219
+ }), _vm._v(" "), _c('or-label', [_vm._v("\n Link\n ")]), _vm._v(" "), _c('or-input', {
2103
2220
  attrs: {
2104
2221
  "placeholder": "Enter link"
2105
2222
  },
@@ -2110,7 +2227,7 @@ var __vue_render__ = function () {
2110
2227
  },
2111
2228
  expression: "link"
2112
2229
  }
2113
- })], 1)])], 2);
2230
+ })], 1)])], 2)], 2);
2114
2231
  };
2115
2232
  var __vue_staticRenderFns__ = [];
2116
2233