@onereach/ui-components 10.2.0 → 10.2.1-beta.4272.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 (42) hide show
  1. package/dist/bundled/v2/components/OrRichTextEditorV3/OrRichTextEditor.js +382 -252
  2. package/dist/bundled/v2/components/OrRichTextEditorV3/OrRichTextEditor.vue.d.ts +21 -68
  3. package/dist/bundled/v2/components/OrRichTextEditorV3/styles.d.ts +1 -0
  4. package/dist/bundled/v2/components/OrRichTextEditorV3/styles.js +5 -4
  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/{markdown-fe3bfb01.js → markdown-2d22cf16.js} +66 -113
  11. package/dist/bundled/v3/components/OrRichTextEditorV3/OrRichTextEditor.js +1 -1
  12. package/dist/bundled/v3/components/OrRichTextEditorV3/OrRichTextEditor.vue.d.ts +14 -18
  13. package/dist/bundled/v3/components/OrRichTextEditorV3/index.js +1 -1
  14. package/dist/bundled/v3/components/OrRichTextEditorV3/props.js +1 -1
  15. package/dist/bundled/v3/components/OrRichTextEditorV3/styles.d.ts +1 -0
  16. package/dist/bundled/v3/components/OrRichTextEditorV3/styles.js +1 -1
  17. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/codemirrorNode.js +1 -1
  18. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/codemirrorView.js +1 -1
  19. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/index.js +1 -1
  20. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/theme.js +1 -1
  21. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/markdown.js +1 -1
  22. package/dist/bundled/v3/components/{OrRichTextEditorV3-358d7df2.js → OrRichTextEditorV3-45e64a85.js} +673 -531
  23. package/dist/bundled/v3/components/index.js +1 -1
  24. package/dist/bundled/v3/index.js +1 -1
  25. package/dist/esm/v2/{OrRichTextEditor-734b8b27.js → OrRichTextEditor-fbcc33fd.js} +353 -244
  26. package/dist/esm/v2/components/index.js +1 -1
  27. package/dist/esm/v2/components/or-rich-text-editor-v3/OrRichTextEditor.vue.d.ts +21 -68
  28. package/dist/esm/v2/components/or-rich-text-editor-v3/index.js +7 -7
  29. package/dist/esm/v2/components/or-rich-text-editor-v3/partials/EditorToolbar.vue.d.ts +160 -0
  30. package/dist/esm/v2/components/or-rich-text-editor-v3/styles.d.ts +1 -0
  31. package/dist/esm/v2/index.js +1 -1
  32. package/dist/esm/v3/{OrRichTextEditor-b5684aab.js → OrRichTextEditor-cdd9e3e4.js} +325 -242
  33. package/dist/esm/v3/components/index.js +1 -1
  34. package/dist/esm/v3/components/or-rich-text-editor-v3/OrRichTextEditor.vue.d.ts +14 -18
  35. package/dist/esm/v3/components/or-rich-text-editor-v3/index.js +6 -6
  36. package/dist/esm/v3/components/or-rich-text-editor-v3/partials/EditorToolbar.vue.d.ts +89 -0
  37. package/dist/esm/v3/components/or-rich-text-editor-v3/styles.d.ts +1 -0
  38. package/dist/esm/v3/index.js +1 -1
  39. package/package.json +19 -20
  40. package/src/components/or-rich-text-editor-v3/OrRichTextEditor.vue +48 -203
  41. package/src/components/or-rich-text-editor-v3/partials/EditorToolbar.vue +238 -0
  42. package/src/components/or-rich-text-editor-v3/styles.ts +13 -10
@@ -1,6 +1,6 @@
1
1
  import { useResizeObserver, useDebounceFn, onClickOutside } from '@vueuse/core';
2
2
  import { useFocusTrap } from '@vueuse/integrations/useFocusTrap';
3
- import { defineComponent, ref, onMounted, onBeforeUnmount, computed, watch, nextTick } from 'vue-demi';
3
+ import { defineComponent, ref, computed, onMounted, onBeforeUnmount, watch, nextTick } from 'vue-demi';
4
4
  import { defaultMarkdownSerializer, MarkdownSerializer } from 'prosemirror-markdown';
5
5
  import { DOMParser as DOMParser$1 } from 'prosemirror-model';
6
6
  import Paragraph from '@tiptap/extension-paragraph';
@@ -16,17 +16,18 @@ import Blockquote from '@tiptap/extension-blockquote';
16
16
  import Link from '@tiptap/extension-link';
17
17
  import Highlight from '@tiptap/extension-highlight';
18
18
  import Underline from '@tiptap/extension-underline';
19
- import { s as script$7 } from './OrButton-c95aef65.js';
20
- import { s as script$1 } from './OrIconButton-6b3cc334.js';
21
- import { s as script$6 } from './OrInput-880cd853.js';
22
- import { s as script$2 } from './OrLabel-59d09591.js';
19
+ import { s as script$2 } from './OrIconButton-6b3cc334.js';
23
20
  import { s as script$3 } from './OrMenuItem-2c1cfee3.js';
24
21
  import { s as script$4 } from './OrMenu-87af0fa8.js';
25
- import { s as script$5 } from './OrModal-045e3f4c.js';
26
- import { s as script$8 } from './OrPopover-4fc2c5be.js';
22
+ import { s as script$5 } from './OrPopover-4fc2c5be.js';
27
23
  import './dom-53c9635b.js';
24
+ import { resolveComponent, openBlock, createElementBlock, normalizeClass, Fragment, renderList, createBlock, createCommentVNode, withCtx, createElementVNode, createTextVNode, toDisplayString, createVNode, renderSlot, withDirectives, vShow, vModelText } from 'vue';
25
+ import { s as script$8 } from './OrButton-c95aef65.js';
26
+ import { s as script$7 } from './OrInput-880cd853.js';
27
+ import { s as script$6 } from './OrModal-045e3f4c.js';
28
28
  import { s as script$9 } from './OrHint-262c8217.js';
29
29
  import { s as script$a } from './OrError-331220bc.js';
30
+ import { s as script$b } from './OrLabel-59d09591.js';
30
31
  import { Node, Editor, mergeAttributes } from '@tiptap/core';
31
32
  import Heading from '@tiptap/extension-heading';
32
33
  import Placeholder from '@tiptap/extension-placeholder';
@@ -34,7 +35,6 @@ import StarterKit from '@tiptap/starter-kit';
34
35
  import { C as CodeMirrorView } from './codemirrorView-020fe885.js';
35
36
  import { minimalSetup } from 'codemirror';
36
37
  import { javascript } from '@codemirror/lang-javascript';
37
- import { resolveComponent, openBlock, createElementBlock, normalizeClass, createBlock, withCtx, renderSlot, createTextVNode, toDisplayString, createCommentVNode, createElementVNode, Fragment, renderList, withDirectives, vShow, vModelText, createVNode } from 'vue';
38
38
  import { s as styleInject } from './style-inject.es-4c6f2515.js';
39
39
 
40
40
  const serializerNodes = {
@@ -162,16 +162,17 @@ const OrRichTextEditor = [
162
162
  // Spacing
163
163
  'gap-xs',
164
164
  // Box
165
- 'max-h-full'];
165
+ 'max-h-full', 'w-full'];
166
166
  const EditorContainer = [
167
167
  // Layout
168
168
  'layout-column',
169
- // Theme (focus)
170
- 'focus-within:theme-background-primary-translucent-1', 'dark:focus-within:theme-background-primary-translucent-1-dark', 'focus-within:theme-border-1-primary', 'dark:focus-within:theme-border-1-primary-dark', 'focus-within:theme-outline-2-primary', 'dark:focus-within:theme-outline-2-primary-dark',
171
169
  // Theme (invalid)
172
170
  'invalid:theme-background-error-translucent-1', 'dark:invalid:theme-background-error-translucent-1-dark', 'invalid:theme-foreground-default', 'dark:invalid:theme-foreground-default-dark', 'invalid:theme-border-1-error', 'dark:invalid:theme-border-1-error-dark', 'invalid:theme-outline-2-transparent', 'dark:invalid:theme-outline-2-transparent',
173
171
  // Box
174
172
  'border-1', 'rounded-md', 'w-full', 'overflow-hidden', 'grow'];
173
+ const EditorContainerFocus = [
174
+ // Theme (focus)
175
+ 'focus-within:theme-background-primary-translucent-1', 'dark:focus-within:theme-background-primary-translucent-1-dark', 'focus-within:theme-border-1-primary', 'dark:focus-within:theme-border-1-primary-dark', 'focus-within:theme-outline-2-primary', 'dark:focus-within:theme-outline-2-primary-dark'];
175
176
  const ToolbarContainer = [
176
177
  // Layout
177
178
  'layout-row',
@@ -202,6 +203,251 @@ const EditorInput = [
202
203
  // Typography
203
204
  'typography-body-2-regular'];
204
205
 
206
+ var script$1 = defineComponent({
207
+ components: {
208
+ OrIconButton: script$2,
209
+ OrMenuItem: script$3,
210
+ OrMenu: script$4,
211
+ OrPopover: script$5
212
+ },
213
+ props: {
214
+ toolbar: {
215
+ type: Array,
216
+ default: () => []
217
+ },
218
+ isFocused: {
219
+ type: Boolean,
220
+ default: false
221
+ },
222
+ countOfNotVisibleTools: {
223
+ type: Number,
224
+ default: 0
225
+ },
226
+ activeHeadingLevel: {
227
+ type: Number,
228
+ default: 0
229
+ },
230
+ isActive: {
231
+ type: Object,
232
+ default: () => ({})
233
+ },
234
+ headingLevels: {
235
+ type: Array,
236
+ default: () => [1, 2, 3, 4]
237
+ }
238
+ },
239
+ emits: ['click-tool'],
240
+ setup(props, _ref) {
241
+ let {
242
+ emit
243
+ } = _ref;
244
+ const toolbarRef = ref();
245
+ const moreButtonRef = ref();
246
+ const moreRef = ref();
247
+ const toolbarButtonRef = ref();
248
+ const menuRef = ref();
249
+ const iconsEnum = ref({
250
+ bold: 'format_bold',
251
+ italic: 'format_italic',
252
+ underline: 'format_underlined',
253
+ strike: 'format_strikethrough',
254
+ bulletList: 'format_list_bulleted',
255
+ orderedList: 'format_list_numbered',
256
+ link: 'link',
257
+ highlight: 'highlight',
258
+ redo: 'redo',
259
+ undo: 'undo',
260
+ codeBlock: 'code_blocks',
261
+ blockquote: 'format_quote',
262
+ file: 'attach_file',
263
+ source: 'source_notes'
264
+ });
265
+ const iconTooltipsEnum = ref({
266
+ bold: 'Bold',
267
+ italic: 'Italic',
268
+ underline: 'Underline',
269
+ strike: 'Strike',
270
+ bulletList: 'Bulleted List',
271
+ orderedList: 'Numbered List',
272
+ link: 'Link',
273
+ highlight: 'Highlight',
274
+ redo: 'Redo',
275
+ undo: 'Undo',
276
+ codeBlock: 'Code Block',
277
+ blockquote: 'Quote',
278
+ file: 'File',
279
+ source: 'Source'
280
+ });
281
+ const notVisibleTools = computed(() => {
282
+ const count = props.countOfNotVisibleTools;
283
+ const toolbar = props.toolbar.flat();
284
+ let notVisible = new Set(toolbar.slice(toolbar.length - count, toolbar.length));
285
+ props.toolbar.forEach(tools => {
286
+ if (tools.some(item => notVisible.has(item))) {
287
+ tools.forEach(item => notVisible.add(item));
288
+ }
289
+ });
290
+ return notVisible;
291
+ });
292
+ const toolbarContainerStyles = computed(() => [...ToolbarContainer]);
293
+ const toolbarStyles = computed(() => [...Toolbar, ...(props.isFocused ? ToolbarButtonFocused : ToolbarButton)]);
294
+ const getIndexOfHeading = computed(() => {
295
+ return props.toolbar.flat().indexOf('heading');
296
+ });
297
+ const headingIcon = computed(() => {
298
+ if (props.activeHeadingLevel && props.isActive.heading) {
299
+ return `format_h${props.activeHeadingLevel}`;
300
+ }
301
+ return 'format_paragraph';
302
+ });
303
+ const isVisible = value => {
304
+ if (Array.isArray(value)) {
305
+ const isHaveNotVisibleTools = value.some(item => notVisibleTools.value.has(item));
306
+ return isHaveNotVisibleTools;
307
+ }
308
+ return !notVisibleTools.value.has(value);
309
+ };
310
+ const handleClick = (item, level) => {
311
+ emit('click-tool', {
312
+ item,
313
+ level
314
+ });
315
+ };
316
+ return {
317
+ toolbarRef,
318
+ moreButtonRef,
319
+ moreRef,
320
+ toolbarButtonRef,
321
+ menuRef,
322
+ toolbarContainerStyles,
323
+ toolbarStyles,
324
+ isVisible,
325
+ handleClick,
326
+ headingIcon,
327
+ getIndexOfHeading,
328
+ notVisibleTools,
329
+ iconsEnum,
330
+ iconTooltipsEnum
331
+ };
332
+ }
333
+ });
334
+
335
+ const _hoisted_1$1 = {
336
+ class: "flex p-sm gap-md"
337
+ };
338
+ function render$1(_ctx, _cache, $props, $setup, $data, $options) {
339
+ const _component_or_icon_button = resolveComponent("or-icon-button");
340
+ const _component_or_popover = resolveComponent("or-popover");
341
+ const _component_or_menu_item = resolveComponent("or-menu-item");
342
+ const _component_or_menu = resolveComponent("or-menu");
343
+ return openBlock(), createElementBlock("div", {
344
+ ref: "toolbarRef",
345
+ class: normalizeClass(_ctx.toolbarContainerStyles)
346
+ }, [(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.toolbar, (tools, index) => {
347
+ return openBlock(), createElementBlock("div", {
348
+ key: index,
349
+ class: normalizeClass([..._ctx.toolbarStyles, {
350
+ 'hidden': _ctx.isVisible(tools)
351
+ }])
352
+ }, [(openBlock(true), createElementBlock(Fragment, null, renderList(tools, item => {
353
+ return openBlock(), createElementBlock("div", {
354
+ key: item,
355
+ class: normalizeClass(['flex gap-md', {
356
+ 'hidden': !_ctx.isVisible(item)
357
+ }])
358
+ }, [item === 'heading' ? (openBlock(), createBlock(_component_or_icon_button, {
359
+ key: 0,
360
+ ref_for: true,
361
+ ref: "toolbarButtonRef",
362
+ selected: _ctx.isActive[item],
363
+ disabled: !_ctx.isFocused,
364
+ tooltip: {
365
+ content: item,
366
+ placement: 'top'
367
+ },
368
+ icon: {
369
+ icon: _ctx.headingIcon,
370
+ variant: 'inherit'
371
+ },
372
+ onClick: _cache[0] || (_cache[0] = $event => _ctx.menuRef && _ctx.menuRef.toggle())
373
+ }, null, 8 /* PROPS */, ["selected", "disabled", "tooltip", "icon"])) : _ctx.isVisible(item) ? (openBlock(), createBlock(_component_or_icon_button, {
374
+ key: 1,
375
+ tooltip: {
376
+ content: _ctx.iconTooltipsEnum[item],
377
+ placement: 'top'
378
+ },
379
+ selected: _ctx.isActive[item],
380
+ disabled: !_ctx.isFocused,
381
+ icon: {
382
+ icon: _ctx.iconsEnum[item],
383
+ variant: 'inherit'
384
+ },
385
+ onClick: $event => _ctx.handleClick(item)
386
+ }, null, 8 /* PROPS */, ["tooltip", "selected", "disabled", "icon", "onClick"])) : createCommentVNode("v-if", true)], 2 /* CLASS */);
387
+ }), 128 /* KEYED_FRAGMENT */))], 2 /* CLASS */);
388
+ }), 128 /* KEYED_FRAGMENT */)), _ctx.countOfNotVisibleTools > 0 ? (openBlock(), createBlock(_component_or_icon_button, {
389
+ key: 0,
390
+ ref: "moreButtonRef",
391
+ disabled: !_ctx.isFocused,
392
+ icon: {
393
+ icon: 'more_horiz',
394
+ variant: 'inherit'
395
+ },
396
+ class: "px-sm",
397
+ onClick: _cache[1] || (_cache[1] = $event => _ctx.moreRef && _ctx.moreRef.open())
398
+ }, null, 8 /* PROPS */, ["disabled"])) : createCommentVNode("v-if", true), _ctx.moreButtonRef ? (openBlock(), createBlock(_component_or_popover, {
399
+ key: 1,
400
+ ref: "moreRef",
401
+ trigger: _ctx.moreButtonRef && _ctx.moreButtonRef.root,
402
+ placement: "top-end"
403
+ }, {
404
+ default: withCtx(() => [createElementVNode("div", _hoisted_1$1, [(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.notVisibleTools, item => {
405
+ return openBlock(), createBlock(_component_or_icon_button, {
406
+ key: item,
407
+ tooltip: {
408
+ content: _ctx.iconTooltipsEnum[item],
409
+ placement: 'top'
410
+ },
411
+ selected: _ctx.isActive[item],
412
+ icon: {
413
+ icon: _ctx.iconsEnum[item],
414
+ variant: 'inherit'
415
+ },
416
+ onClick: $event => _ctx.handleClick(item)
417
+ }, null, 8 /* PROPS */, ["tooltip", "selected", "icon", "onClick"]);
418
+ }), 128 /* KEYED_FRAGMENT */))])]),
419
+
420
+ _: 1 /* STABLE */
421
+ }, 8 /* PROPS */, ["trigger"])) : createCommentVNode("v-if", true), _ctx.toolbarButtonRef ? (openBlock(), createBlock(_component_or_menu, {
422
+ key: 2,
423
+ ref: "menuRef",
424
+ trigger: _ctx.toolbarButtonRef[_ctx.getIndexOfHeading] && _ctx.toolbarButtonRef[_ctx.getIndexOfHeading].root,
425
+ placement: "bottom-start"
426
+ }, {
427
+ default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.headingLevels, heading => {
428
+ return openBlock(), createBlock(_component_or_menu_item, {
429
+ key: heading,
430
+ selected: _ctx.activeHeadingLevel === heading,
431
+ onClick: $event => _ctx.handleClick('heading', heading)
432
+ }, {
433
+ default: withCtx(() => [createTextVNode(" Heading " + toDisplayString(heading), 1 /* TEXT */)]),
434
+
435
+ _: 2 /* DYNAMIC */
436
+ }, 1032 /* PROPS, DYNAMIC_SLOTS */, ["selected", "onClick"]);
437
+ }), 128 /* KEYED_FRAGMENT */)), createVNode(_component_or_menu_item, {
438
+ selected: !_ctx.activeHeadingLevel,
439
+ onClick: _cache[2] || (_cache[2] = $event => _ctx.handleClick('heading'))
440
+ }, {
441
+ default: withCtx(() => [createTextVNode(" None ")]),
442
+ _: 1 /* STABLE */
443
+ }, 8 /* PROPS */, ["selected"])]),
444
+ _: 1 /* STABLE */
445
+ }, 8 /* PROPS */, ["trigger"])) : createCommentVNode("v-if", true)], 2 /* CLASS */);
446
+ }
447
+
448
+ script$1.render = render$1;
449
+ script$1.__file = "src/components/or-rich-text-editor-v3/partials/EditorToolbar.vue";
450
+
205
451
  var Formats;
206
452
  (function (Formats) {
207
453
  Formats["Markdown"] = "markdown";
@@ -247,16 +493,13 @@ var codemirrorNode = Node.create({
247
493
  var script = defineComponent({
248
494
  name: 'OrRichTextEditor',
249
495
  components: {
250
- OrIconButton: script$1,
251
- OrLabel: script$2,
252
- OrMenuItem: script$3,
253
- OrMenu: script$4,
254
- OrModal: script$5,
255
- OrInput: script$6,
256
- OrButton: script$7,
257
- OrPopover: script$8,
496
+ OrModal: script$6,
497
+ OrInput: script$7,
498
+ OrButton: script$8,
258
499
  OrHint: script$9,
259
- OrError: script$a
500
+ OrError: script$a,
501
+ OrLabel: script$b,
502
+ EditorToolbar: script$1
260
503
  },
261
504
  model: {
262
505
  prop: 'modelValue',
@@ -302,6 +545,10 @@ var script = defineComponent({
302
545
  error: {
303
546
  type: [String, Boolean],
304
547
  default: undefined
548
+ },
549
+ readonly: {
550
+ type: Boolean,
551
+ default: false
305
552
  }
306
553
  },
307
554
  emits: ['update:modelValue', 'input', 'file-upload'],
@@ -313,11 +560,7 @@ var script = defineComponent({
313
560
  const editorRef = ref();
314
561
  const textareaRef = ref();
315
562
  const containerRef = ref();
316
- const toolbarRef = ref();
317
- const moreButtonRef = ref();
318
- const moreRef = ref();
319
- const toolbarButtonRef = ref();
320
- const menuRef = ref();
563
+ const toolbarContainerRef = ref();
321
564
  // isActive should be set with default values for all toolbar buttons, otherwise it will not work in vue2
322
565
  const isActive = ref({
323
566
  bold: false,
@@ -335,7 +578,7 @@ var script = defineComponent({
335
578
  file: false,
336
579
  source: false
337
580
  });
338
- const isFocused = ref(props.autofocus);
581
+ const isFocused = ref(!props.readonly ? props.autofocus : false);
339
582
  const headingLevels = [1, 2, 3, 4];
340
583
  const activeHeadingLevel = ref(0);
341
584
  const markdownOutput = ref('');
@@ -350,49 +593,19 @@ var script = defineComponent({
350
593
  fallbackFocus: '.container',
351
594
  allowOutsideClick: true
352
595
  });
353
- const iconsEnum = ref({
354
- bold: 'format_bold',
355
- italic: 'format_italic',
356
- underline: 'format_underlined',
357
- strike: 'format_strikethrough',
358
- bulletList: 'format_list_bulleted',
359
- orderedList: 'format_list_numbered',
360
- link: 'link',
361
- highlight: 'highlight',
362
- redo: 'redo',
363
- undo: 'undo',
364
- codeBlock: 'code_blocks',
365
- blockquote: 'format_quote',
366
- file: 'attach_file',
367
- source: 'source_notes'
368
- });
369
- const iconTooltipsEnum = ref({
370
- bold: 'Bold',
371
- italic: 'Italic',
372
- underline: 'Underline',
373
- strike: 'Strike',
374
- bulletList: 'Bulleted List',
375
- orderedList: 'Numbered List',
376
- link: 'Link',
377
- highlight: 'Highlight',
378
- redo: 'Redo',
379
- undo: 'Undo',
380
- codeBlock: 'Code Block',
381
- blockquote: 'Quote',
382
- file: 'File',
383
- source: 'Source'
384
- });
385
596
  useResizeObserver(root, useDebounceFn(entries => {
386
597
  var _a, _b;
387
598
  const entry = entries[0];
388
599
  const {
389
600
  width
390
601
  } = entry.contentRect;
391
- if (containerRef.value && toolbarRef.value && toolbarLength.value) {
602
+ const toolbarLength = props.toolbar.flat().length;
603
+ if (containerRef.value && toolbarContainerRef.value && toolbarLength) {
392
604
  let lengthOfItem = 0;
393
- lengthOfItem = ((_b = (_a = toolbarRef.value.firstElementChild) === null || _a === void 0 ? void 0 : _a.firstElementChild) === null || _b === void 0 ? void 0 : _b.offsetWidth) + 16;
605
+ const toolbarRef = toolbarContainerRef.value.$refs.toolbarRef;
606
+ 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;
394
607
  const count = width / lengthOfItem - 2;
395
- countOfNotVisibleTools.value = Math.round(toolbarLength.value - count);
608
+ countOfNotVisibleTools.value = Math.round(toolbarLength - count);
396
609
  }
397
610
  }, 10));
398
611
  onMounted(() => {
@@ -424,7 +637,8 @@ var script = defineComponent({
424
637
  }
425
638
  },
426
639
  element: editorRef.value,
427
- autofocus: props.autofocus,
640
+ autofocus: !props.readonly ? props.autofocus : false,
641
+ editable: !props.readonly,
428
642
  enableInputRules: true,
429
643
  enablePasteRules: true,
430
644
  extensions: [codemirrorNode, StarterKit.configure({
@@ -505,43 +719,15 @@ var script = defineComponent({
505
719
  context.emit('update:modelValue', value);
506
720
  }
507
721
  });
508
- const getIndexOfHeading = computed(() => {
509
- return props.toolbar.flat().indexOf('heading');
510
- });
511
- const headingIcon = computed(() => {
512
- if (activeHeadingLevel.value && isActive.value.heading) {
513
- return `format_h${activeHeadingLevel.value}`;
514
- }
515
- return 'format_paragraph';
516
- });
517
- const toolbarLength = computed(() => {
518
- return props.toolbar.flat().length;
519
- });
520
- const notVisibleTools = computed(() => {
521
- const count = countOfNotVisibleTools.value;
522
- const toolbar = props.toolbar.flat();
523
- let notVisible = new Set(toolbar.slice(toolbar.length - count, toolbar.length));
524
- props.toolbar.forEach(tools => {
525
- if (tools.some(item => notVisible.has(item))) {
526
- tools.forEach(item => notVisible.add(item));
527
- }
528
- });
529
- return notVisible;
530
- });
531
722
  //Methods
532
723
  const handleEditorClick = () => {
533
724
  var _a;
534
725
  setActiveFormats();
535
- isFocused.value = true;
536
- editor === null || editor === void 0 ? void 0 : editor.commands.focus();
537
- activeHeadingLevel.value = ((_a = editor === null || editor === void 0 ? void 0 : editor.getAttributes('heading')) === null || _a === void 0 ? void 0 : _a.level) || 0;
538
- };
539
- const isVisible = value => {
540
- if (Array.isArray(value)) {
541
- const isHaveNotVisibleTools = value.some(item => notVisibleTools.value.has(item));
542
- return isHaveNotVisibleTools;
726
+ if (!props.readonly) {
727
+ isFocused.value = true;
728
+ editor === null || editor === void 0 ? void 0 : editor.commands.focus();
543
729
  }
544
- return !notVisibleTools.value.has(value);
730
+ activeHeadingLevel.value = ((_a = editor === null || editor === void 0 ? void 0 : editor.getAttributes('heading')) === null || _a === void 0 ? void 0 : _a.level) || 0;
545
731
  };
546
732
  const handleInput = event => {
547
733
  const target = event.target;
@@ -550,7 +736,11 @@ var script = defineComponent({
550
736
  markdownOutput.value = serialize(editor === null || editor === void 0 ? void 0 : editor.schema, editor === null || editor === void 0 ? void 0 : editor.getJSON());
551
737
  proxyModelValue.value = markdownOutput.value;
552
738
  };
553
- const handleToolbarClick = (item, level) => {
739
+ const handleToolbarClick = _ref4 => {
740
+ let {
741
+ item,
742
+ level
743
+ } = _ref4;
554
744
  var _a, _b, _c, _d;
555
745
  switch (item) {
556
746
  case 'source':
@@ -630,10 +820,10 @@ var script = defineComponent({
630
820
  editor === null || editor === void 0 ? void 0 : editor.chain().focus().setMark('link', {
631
821
  href: link.value,
632
822
  target: '__blank'
633
- }).command(_ref4 => {
823
+ }).command(_ref5 => {
634
824
  let {
635
825
  tr
636
- } = _ref4;
826
+ } = _ref5;
637
827
  const preparedValue = text.value[text.value.length - 1] === ' ' ? text.value : `${text.value} `;
638
828
  tr.insertText(preparedValue);
639
829
  return true;
@@ -669,11 +859,7 @@ var script = defineComponent({
669
859
  };
670
860
  // Styles
671
861
  const rootStyles = computed(() => ['or-rich-text-editor-v3', ...OrRichTextEditor]);
672
- const containerStyles = computed(() => [...EditorContainer]);
673
- const toolbarContainerStyles = computed(() => [...ToolbarContainer]);
674
- const toolbarStyles = computed(() => [...Toolbar,
675
- // 'overflow-x-hidden',
676
- ...(isFocused.value ? ToolbarButtonFocused : ToolbarButton)]);
862
+ const containerStyles = computed(() => [...EditorContainer, ...(isFocused.value ? EditorContainerFocus : [])]);
677
863
  const editorInputStyles = computed(() => ['tiptap-editor-v3', ...EditorInput]);
678
864
  //Effects
679
865
  watch(proxyModelValue, value => {
@@ -681,43 +867,38 @@ var script = defineComponent({
681
867
  editor === null || editor === void 0 ? void 0 : editor.commands.setContent(value);
682
868
  }
683
869
  if (props.format === 'markdown' && value !== markdownOutput.value) {
684
- //TODO: const deserialized = deserialize(editor?.schema, value);
685
- editor === null || editor === void 0 ? void 0 : editor.commands.setContent(value);
870
+ const deserialized = deserialize(editor === null || editor === void 0 ? void 0 : editor.schema, value);
871
+ editor === null || editor === void 0 ? void 0 : editor.commands.setContent(deserialized);
686
872
  }
687
873
  });
874
+ watch(props, _ref6 => {
875
+ let {
876
+ readonly
877
+ } = _ref6;
878
+ isFocused.value = !readonly;
879
+ editor === null || editor === void 0 ? void 0 : editor.setEditable(!readonly);
880
+ });
688
881
  return {
689
882
  editor,
690
883
  editorRef,
691
- toolbarRef,
884
+ toolbarContainerRef,
692
885
  containerRef,
693
- toolbarButtonRef,
694
- moreButtonRef,
695
886
  textareaRef,
696
- moreRef,
697
- menuRef,
698
- iconsEnum,
699
887
  handleToolbarClick,
700
888
  handleEditorClick,
701
889
  isActive,
702
- iconTooltipsEnum,
703
890
  containerStyles,
704
- toolbarContainerStyles,
705
- toolbarStyles,
706
891
  rootStyles,
707
892
  root,
708
893
  editorInputStyles,
709
- getIndexOfHeading,
710
894
  headingLevels,
711
- headingIcon,
712
895
  attachLink,
713
896
  discardLink,
714
897
  isOpenLinkModal,
715
898
  text,
716
899
  link,
717
900
  isFocused,
718
- isVisible,
719
901
  countOfNotVisibleTools,
720
- notVisibleTools,
721
902
  handleInput,
722
903
  proxyModelValue,
723
904
  disableMarkdown,
@@ -732,26 +913,20 @@ const _hoisted_2 = {
732
913
  class: /*#__PURE__*/normalizeClass(['p-sm', 'overflow-auto', 'min-h-[88px]'])
733
914
  };
734
915
  const _hoisted_3 = ["activated"];
735
- const _hoisted_4 = {
736
- class: "flex p-sm gap-md"
737
- };
738
- const _hoisted_5 = /*#__PURE__*/createElementVNode("p", {
916
+ const _hoisted_4 = /*#__PURE__*/createElementVNode("p", {
739
917
  class: "text-headline-2"
740
918
  }, " Add Link ", -1 /* HOISTED */);
741
- const _hoisted_6 = {
919
+ const _hoisted_5 = {
742
920
  class: "flex ml-auto gap-md"
743
921
  };
744
- const _hoisted_7 = /*#__PURE__*/createElementVNode("p", null, "Cancel", -1 /* HOISTED */);
745
- const _hoisted_8 = /*#__PURE__*/createElementVNode("p", null, "Save", -1 /* HOISTED */);
922
+ const _hoisted_6 = /*#__PURE__*/createElementVNode("p", null, "Cancel", -1 /* HOISTED */);
923
+ const _hoisted_7 = /*#__PURE__*/createElementVNode("p", null, "Save", -1 /* HOISTED */);
746
924
 
747
925
  function render(_ctx, _cache, $props, $setup, $data, $options) {
748
926
  const _component_OrLabel = resolveComponent("OrLabel");
749
- const _component_or_icon_button = resolveComponent("or-icon-button");
927
+ const _component_editor_toolbar = resolveComponent("editor-toolbar");
750
928
  const _component_OrHint = resolveComponent("OrHint");
751
929
  const _component_OrError = resolveComponent("OrError");
752
- const _component_or_popover = resolveComponent("or-popover");
753
- const _component_or_menu_item = resolveComponent("or-menu-item");
754
- const _component_or_menu = resolveComponent("or-menu");
755
930
  const _component_or_label = resolveComponent("or-label");
756
931
  const _component_or_input = resolveComponent("or-input");
757
932
  const _component_or_button = resolveComponent("or-button");
@@ -768,75 +943,30 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
768
943
 
769
944
  _: 3 /* FORWARDED */
770
945
  })) : createCommentVNode("v-if", true), createElementVNode("div", {
771
- ref: 'containerRef',
946
+ ref: "containerRef",
772
947
  class: normalizeClass(_ctx.containerStyles),
773
948
  invalid: !!_ctx.error,
774
- onClick: _cache[4] || (_cache[4] = $event => _ctx.handleEditorClick())
775
- }, [createElementVNode("div", {
776
- ref: 'toolbarRef',
777
- class: normalizeClass(_ctx.toolbarContainerStyles)
778
- }, [(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.toolbar, (tools, index) => {
779
- return openBlock(), createElementBlock("div", {
780
- key: index,
781
- class: normalizeClass([..._ctx.toolbarStyles, {
782
- 'hidden': _ctx.isVisible(tools)
783
- }])
784
- }, [(openBlock(true), createElementBlock(Fragment, null, renderList(tools, item => {
785
- return openBlock(), createElementBlock("div", {
786
- key: item,
787
- class: normalizeClass(['flex gap-md', {
788
- 'hidden': !_ctx.isVisible(item)
789
- }])
790
- }, [item === 'heading' ? (openBlock(), createBlock(_component_or_icon_button, {
791
- key: 0,
792
- ref_for: true,
793
- ref: 'toolbarButtonRef',
794
- selected: _ctx.isActive[item],
795
- disabled: !_ctx.isFocused,
796
- tooltip: {
797
- content: item,
798
- placement: 'top'
799
- },
800
- icon: {
801
- icon: _ctx.headingIcon,
802
- variant: 'inherit'
803
- },
804
- onClick: _cache[0] || (_cache[0] = $event => _ctx.menuRef && _ctx.menuRef.toggle())
805
- }, null, 8 /* PROPS */, ["selected", "disabled", "tooltip", "icon"])) : _ctx.isVisible(item) ? (openBlock(), createBlock(_component_or_icon_button, {
806
- key: 1,
807
- tooltip: {
808
- content: _ctx.iconTooltipsEnum[item],
809
- placement: 'top'
810
- },
811
- selected: _ctx.isActive[item],
812
- disabled: !_ctx.isFocused,
813
- icon: {
814
- icon: _ctx.iconsEnum[item],
815
- variant: 'inherit'
816
- },
817
- onClick: $event => _ctx.handleToolbarClick(item)
818
- }, null, 8 /* PROPS */, ["tooltip", "selected", "disabled", "icon", "onClick"])) : createCommentVNode("v-if", true)], 2 /* CLASS */);
819
- }), 128 /* KEYED_FRAGMENT */))], 2 /* CLASS */);
820
- }), 128 /* KEYED_FRAGMENT */)), _ctx.countOfNotVisibleTools > 0 ? (openBlock(), createBlock(_component_or_icon_button, {
949
+ onClick: _cache[2] || (_cache[2] = $event => _ctx.handleEditorClick())
950
+ }, [!_ctx.readonly ? (openBlock(), createBlock(_component_editor_toolbar, {
821
951
  key: 0,
822
- ref: 'moreButtonRef',
823
- disabled: !_ctx.isFocused,
824
- icon: {
825
- icon: 'more_horiz',
826
- variant: 'inherit'
827
- },
828
- class: "px-sm",
829
- onClick: _cache[1] || (_cache[1] = $event => _ctx.moreRef && _ctx.moreRef.open())
830
- }, null, 8 /* PROPS */, ["disabled"])) : createCommentVNode("v-if", true)], 2 /* CLASS */), createElementVNode("div", _hoisted_2, [withDirectives(createElementVNode("textarea", {
952
+ ref: "toolbarContainerRef",
953
+ "count-of-not-visible-tools": _ctx.countOfNotVisibleTools,
954
+ toolbar: _ctx.toolbar,
955
+ "is-focused": _ctx.isFocused,
956
+ "active-heading-level": _ctx.activeHeadingLevel,
957
+ "is-active": _ctx.isActive,
958
+ "heading-levels": _ctx.headingLevels,
959
+ onClickTool: _ctx.handleToolbarClick
960
+ }, null, 8 /* PROPS */, ["count-of-not-visible-tools", "toolbar", "is-focused", "active-heading-level", "is-active", "heading-levels", "onClickTool"])) : createCommentVNode("v-if", true), createElementVNode("div", _hoisted_2, [withDirectives(createElementVNode("textarea", {
831
961
  ref: 'textareaRef',
832
- "onUpdate:modelValue": _cache[2] || (_cache[2] = $event => _ctx.sourceValue = $event),
962
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = $event => _ctx.sourceValue = $event),
833
963
  activated: _ctx.disableMarkdown,
834
964
  class: "block w-full h-full resize-none border-none outline-none bg-transparent typography-body-2-regular",
835
- onInput: _cache[3] || (_cache[3] = function () {
965
+ onInput: _cache[1] || (_cache[1] = function () {
836
966
  return _ctx.handleInput && _ctx.handleInput(...arguments);
837
967
  })
838
968
  }, null, 40 /* PROPS, HYDRATE_EVENTS */, _hoisted_3), [[vShow, _ctx.disableMarkdown], [vModelText, _ctx.sourceValue]]), withDirectives(createElementVNode("div", {
839
- ref: 'editorRef',
969
+ ref: "editorRef",
840
970
  class: normalizeClass(_ctx.editorInputStyles)
841
971
  }, null, 2 /* CLASS */), [[vShow, !_ctx.disableMarkdown]]), renderSlot(_ctx.$slots, "files")])], 10 /* CLASS, PROPS */, _hoisted_1), !_ctx.error ? (openBlock(), createElementBlock(Fragment, {
842
972
  key: 1
@@ -854,68 +984,21 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
854
984
  default: withCtx(() => [createTextVNode(toDisplayString(_ctx.error), 1 /* TEXT */)]),
855
985
 
856
986
  _: 1 /* STABLE */
857
- }, 8 /* PROPS */, ["disabled"])) : createCommentVNode("v-if", true), _ctx.moreButtonRef ? (openBlock(), createBlock(_component_or_popover, {
858
- key: 3,
859
- ref: 'moreRef',
860
- trigger: _ctx.moreButtonRef && _ctx.moreButtonRef.root,
861
- placement: "top-end"
862
- }, {
863
- default: withCtx(() => [createElementVNode("div", _hoisted_4, [(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.notVisibleTools, item => {
864
- return openBlock(), createBlock(_component_or_icon_button, {
865
- key: item,
866
- tooltip: {
867
- content: _ctx.iconTooltipsEnum[item],
868
- placement: 'top'
869
- },
870
- selected: _ctx.isActive[item],
871
- icon: {
872
- icon: _ctx.iconsEnum[item],
873
- variant: 'inherit'
874
- },
875
- onClick: $event => _ctx.handleToolbarClick(item)
876
- }, null, 8 /* PROPS */, ["tooltip", "selected", "icon", "onClick"]);
877
- }), 128 /* KEYED_FRAGMENT */))])]),
878
-
879
- _: 1 /* STABLE */
880
- }, 8 /* PROPS */, ["trigger"])) : createCommentVNode("v-if", true), _ctx.toolbarButtonRef ? (openBlock(), createBlock(_component_or_menu, {
881
- key: 4,
882
- ref: 'menuRef',
883
- trigger: _ctx.toolbarButtonRef[_ctx.getIndexOfHeading] && _ctx.toolbarButtonRef[_ctx.getIndexOfHeading].root,
884
- placement: "bottom-start"
885
- }, {
886
- default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.headingLevels, heading => {
887
- return openBlock(), createBlock(_component_or_menu_item, {
888
- key: heading,
889
- selected: _ctx.activeHeadingLevel === heading,
890
- onClick: $event => _ctx.handleToolbarClick('heading', heading)
891
- }, {
892
- default: withCtx(() => [createTextVNode(" Heading " + toDisplayString(heading), 1 /* TEXT */)]),
893
-
894
- _: 2 /* DYNAMIC */
895
- }, 1032 /* PROPS, DYNAMIC_SLOTS */, ["selected", "onClick"]);
896
- }), 128 /* KEYED_FRAGMENT */)), createVNode(_component_or_menu_item, {
897
- selected: !_ctx.activeHeadingLevel,
898
- onClick: _cache[5] || (_cache[5] = $event => _ctx.handleToolbarClick('heading'))
899
- }, {
900
- default: withCtx(() => [createTextVNode(" None ")]),
901
- _: 1 /* STABLE */
902
- }, 8 /* PROPS */, ["selected"])]),
903
- _: 1 /* STABLE */
904
- }, 8 /* PROPS */, ["trigger"])) : createCommentVNode("v-if", true), createVNode(_component_or_modal, {
987
+ }, 8 /* PROPS */, ["disabled"])) : createCommentVNode("v-if", true), createVNode(_component_or_modal, {
905
988
  "is-open": _ctx.isOpenLinkModal,
906
989
  size: "s"
907
990
  }, {
908
- header: withCtx(() => [_hoisted_5]),
909
- footer: withCtx(() => [createElementVNode("div", _hoisted_6, [createVNode(_component_or_button, {
991
+ header: withCtx(() => [_hoisted_4]),
992
+ footer: withCtx(() => [createElementVNode("div", _hoisted_5, [createVNode(_component_or_button, {
910
993
  variant: "outlined",
911
994
  onClick: _ctx.discardLink
912
995
  }, {
913
- default: withCtx(() => [_hoisted_7]),
996
+ default: withCtx(() => [_hoisted_6]),
914
997
  _: 1 /* STABLE */
915
998
  }, 8 /* PROPS */, ["onClick"]), createVNode(_component_or_button, {
916
999
  onClick: _ctx.attachLink
917
1000
  }, {
918
- default: withCtx(() => [_hoisted_8]),
1001
+ default: withCtx(() => [_hoisted_7]),
919
1002
  _: 1 /* STABLE */
920
1003
  }, 8 /* PROPS */, ["onClick"])])]),
921
1004
  default: withCtx(() => [createElementVNode("div", null, [createVNode(_component_or_label, null, {
@@ -923,7 +1006,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
923
1006
  _: 1 /* STABLE */
924
1007
  }), createVNode(_component_or_input, {
925
1008
  modelValue: _ctx.text,
926
- "onUpdate:modelValue": _cache[6] || (_cache[6] = $event => _ctx.text = $event),
1009
+ "onUpdate:modelValue": _cache[3] || (_cache[3] = $event => _ctx.text = $event),
927
1010
  placeholder: "Placeholder",
928
1011
  class: "pb-md"
929
1012
  }, null, 8 /* PROPS */, ["modelValue"]), createVNode(_component_or_label, null, {
@@ -931,7 +1014,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
931
1014
  _: 1 /* STABLE */
932
1015
  }), createVNode(_component_or_input, {
933
1016
  modelValue: _ctx.link,
934
- "onUpdate:modelValue": _cache[7] || (_cache[7] = $event => _ctx.link = $event),
1017
+ "onUpdate:modelValue": _cache[4] || (_cache[4] = $event => _ctx.link = $event),
935
1018
  placeholder: "Placeholder"
936
1019
  }, null, 8 /* PROPS */, ["modelValue"])])]),
937
1020
  _: 1 /* STABLE */