vuewrite 0.0.13 → 0.0.15

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.
@@ -251,6 +251,7 @@ type?: string;
251
251
  decorator?: Decorator | undefined;
252
252
  parser?: TextParser | undefined;
253
253
  styles?: Style[] | undefined;
254
+ preventMultiline?: boolean | undefined;
254
255
  }>, {}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_2<{
255
256
  modelValue: {
256
257
  text: string;
@@ -260,6 +261,7 @@ type?: string;
260
261
  decorator?: Decorator | undefined;
261
262
  parser?: TextParser | undefined;
262
263
  styles?: Style[] | undefined;
264
+ preventMultiline?: boolean | undefined;
263
265
  }>>>, {}, {}>;
264
266
 
265
267
  declare type TextParser = (text: string) => Style[];
package/dist/vuewrite.js CHANGED
@@ -4,7 +4,7 @@ var __publicField = (obj, key, value) => {
4
4
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
5
  return value;
6
6
  };
7
- import { getCurrentScope, onScopeDispose, unref, watch, nextTick, reactive, computed, ref, defineComponent, getCurrentInstance, openBlock, createBlock, resolveDynamicComponent, createElementBlock, normalizeProps, mergeProps, h, useSlots, isProxy, toRaw, onMounted, Fragment, renderList, renderSlot, createCommentVNode } from "vue";
7
+ import { getCurrentScope, onScopeDispose, unref, watch, nextTick, reactive, computed, ref, defineComponent, getCurrentInstance, h, useSlots, isProxy, toRaw, onMounted, openBlock, createElementBlock, Fragment, renderList, createBlock, renderSlot, createCommentVNode } from "vue";
8
8
  function tryOnScopeDispose(fn) {
9
9
  if (getCurrentScope()) {
10
10
  onScopeDispose(fn);
@@ -530,18 +530,10 @@ class TextEditorStore {
530
530
  }
531
531
  let uidCounter = 0;
532
532
  const uid = () => (uidCounter++).toString();
533
- const _sfc_main$2 = /* @__PURE__ */ defineComponent({
534
- __name: "TextEditorBlock",
535
- props: {
536
- block: {},
537
- slots: {},
538
- decorator: { type: Function },
539
- parser: {}
540
- },
533
+ const _sfc_main$2 = defineComponent({
534
+ props: ["block", "slots", "static", "decorator", "parser"],
541
535
  emits: ["postrender"],
542
- setup(__props, { emit: __emit }) {
543
- const props = __props;
544
- const emit = __emit;
536
+ setup(props, { emit }) {
545
537
  const slot = computed(() => {
546
538
  if (!props.block.type)
547
539
  return props.slots["default"] ?? null;
@@ -550,31 +542,6 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
550
542
  const blockProps = {
551
543
  "data-vw-block-id": props.block.id
552
544
  };
553
- const renderBlockPart = (text, styles) => {
554
- if (!props.decorator)
555
- return text;
556
- let elementTag = "span";
557
- const attrs = {};
558
- for (let style of styles) {
559
- const partProps = props.decorator(style);
560
- if (!partProps)
561
- continue;
562
- const { class: _class, style: _style, tag, ...otherProps } = partProps;
563
- Object.assign(attrs, otherProps);
564
- if (_class) {
565
- attrs.class = attrs.class ? attrs.class + " " + _class : _class;
566
- }
567
- if (_style) {
568
- attrs.style = attrs.style ? attrs.style + " " + _style : _style;
569
- }
570
- if (tag) {
571
- elementTag = tag;
572
- }
573
- }
574
- if (Object.keys(attrs).length === 0)
575
- return text;
576
- return h(elementTag, attrs, text);
577
- };
578
545
  const instance = getCurrentInstance();
579
546
  const getRef = () => {
580
547
  if (!instance)
@@ -590,6 +557,8 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
590
557
  const cacheNodes = [];
591
558
  let cacheEl = null;
592
559
  const cleanTree = (count) => {
560
+ if (props.static === true)
561
+ return;
593
562
  const el = getRef();
594
563
  if (!el)
595
564
  return;
@@ -671,15 +640,35 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
671
640
  cleanTree(blocks.length);
672
641
  return blocks;
673
642
  };
674
- return (_ctx, _cache) => {
675
- return slot.value ? (openBlock(), createBlock(resolveDynamicComponent(slot.value), {
676
- key: 0,
677
- content,
678
- props: blockProps,
679
- block: _ctx.block
680
- }, null, 8, ["block"])) : (openBlock(), createElementBlock("div", normalizeProps(mergeProps({ key: 1 }, blockProps)), [
681
- (openBlock(), createBlock(resolveDynamicComponent(content)))
682
- ], 16));
643
+ const renderBlockPart = (text, styles) => {
644
+ if (!props.decorator)
645
+ return text;
646
+ let elementTag = "span";
647
+ const attrs = {};
648
+ for (let style of styles) {
649
+ const partProps = props.decorator(style);
650
+ if (!partProps)
651
+ continue;
652
+ const { class: _class, style: _style, tag, ...otherProps } = partProps;
653
+ Object.assign(attrs, otherProps);
654
+ if (_class) {
655
+ attrs.class = attrs.class ? attrs.class + " " + _class : _class;
656
+ }
657
+ if (_style) {
658
+ attrs.style = attrs.style ? attrs.style + " " + _style : _style;
659
+ }
660
+ if (tag) {
661
+ elementTag = tag;
662
+ }
663
+ }
664
+ if (Object.keys(attrs).length === 0)
665
+ return text;
666
+ return h(elementTag, attrs, text);
667
+ };
668
+ return () => {
669
+ if (slot.value)
670
+ return h(slot.value, { content, props: blockProps, block: props.block });
671
+ return h("div", blockProps, [content()]);
683
672
  };
684
673
  }
685
674
  });
@@ -930,7 +919,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
930
919
  modelValue: {},
931
920
  decorator: { type: Function },
932
921
  parser: {},
933
- styles: {}
922
+ styles: {},
923
+ preventMultiline: { type: Boolean }
934
924
  },
935
925
  setup(__props) {
936
926
  const props = __props;
@@ -949,7 +939,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
949
939
  block,
950
940
  slots: unref(slots),
951
941
  decorator: props.decorator,
952
- parser: props.parser
942
+ parser: props.parser,
943
+ static: ""
953
944
  }, null, 8, ["block", "slots", "decorator", "parser"]);
954
945
  }), 128))
955
946
  ]);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "vuewrite",
3
3
  "description": "Rich Text Editor based on Vue3 reactivity",
4
4
  "private": false,
5
- "version": "0.0.13",
5
+ "version": "0.0.15",
6
6
  "type": "module",
7
7
  "license": "MIT",
8
8
  "author": "den59k",