vue-editify 0.0.28 → 0.0.29

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.
package/lib/editify.es.js CHANGED
@@ -2969,9 +2969,11 @@ const emptyDefaultBehaviorInblock = function(element2) {
2969
2969
  }
2970
2970
  };
2971
2971
  const setRangeInVisible = function() {
2972
- const fn = async (root2) => {
2973
- const scrollHeight = obj$1.element.getScrollHeight(root2);
2974
- if (root2.clientHeight < scrollHeight) {
2972
+ var _a;
2973
+ const fn = async (root) => {
2974
+ const scrollHeight = obj$1.element.getScrollHeight(root);
2975
+ const scrollWidth = obj$1.element.getScrollWidth(root);
2976
+ if (root.clientHeight < scrollHeight || root.clientWidth < scrollWidth) {
2975
2977
  const selection = window.getSelection();
2976
2978
  if (selection.rangeCount == 0) {
2977
2979
  return;
@@ -2983,36 +2985,65 @@ const setRangeInVisible = function() {
2983
2985
  target = this.range.focus.element.elm;
2984
2986
  }
2985
2987
  const childRect = target.getBoundingClientRect();
2986
- const parentRect = root2.getBoundingClientRect();
2987
- if (childRect.top < parentRect.top) {
2988
- await obj$1.element.setScrollTop({
2989
- el: root2,
2990
- number: 0
2991
- });
2992
- const tempChildRect = target.getBoundingClientRect();
2993
- const tempParentRect = root2.getBoundingClientRect();
2994
- obj$1.element.setScrollTop({
2995
- el: root2,
2996
- number: tempChildRect.top - tempParentRect.top - tempChildRect.height * 2
2997
- });
2998
- } else if (childRect.bottom > parentRect.bottom) {
2999
- await obj$1.element.setScrollTop({
3000
- el: root2,
3001
- number: 0
3002
- });
3003
- const tempChildRect = target.getBoundingClientRect();
3004
- const tempParentRect = root2.getBoundingClientRect();
3005
- obj$1.element.setScrollTop({
3006
- el: root2,
3007
- number: tempChildRect.bottom - tempParentRect.bottom + tempChildRect.height * 2
3008
- });
2988
+ const parentRect = root.getBoundingClientRect();
2989
+ if (root.clientHeight < scrollHeight) {
2990
+ if (childRect.top < parentRect.top) {
2991
+ await obj$1.element.setScrollTop({
2992
+ el: root,
2993
+ number: 0
2994
+ });
2995
+ const tempChildRect = target.getBoundingClientRect();
2996
+ const tempParentRect = root.getBoundingClientRect();
2997
+ obj$1.element.setScrollTop({
2998
+ el: root,
2999
+ number: tempChildRect.top - tempParentRect.top - tempChildRect.height * 2
3000
+ });
3001
+ } else if (childRect.bottom > parentRect.bottom) {
3002
+ await obj$1.element.setScrollTop({
3003
+ el: root,
3004
+ number: 0
3005
+ });
3006
+ const tempChildRect = target.getBoundingClientRect();
3007
+ const tempParentRect = root.getBoundingClientRect();
3008
+ obj$1.element.setScrollTop({
3009
+ el: root,
3010
+ number: tempChildRect.bottom - tempParentRect.bottom + tempChildRect.height * 2
3011
+ });
3012
+ }
3013
+ }
3014
+ if (root.clientWidth < scrollWidth) {
3015
+ if (childRect.left < parentRect.left) {
3016
+ await obj$1.element.setScrollLeft({
3017
+ el: root,
3018
+ number: 0
3019
+ });
3020
+ const tempChildRect = target.getBoundingClientRect();
3021
+ const tempParentRect = root.getBoundingClientRect();
3022
+ obj$1.element.setScrollLeft({
3023
+ el: root,
3024
+ number: tempChildRect.left - tempParentRect.left - tempChildRect.width * 2 - (tempChildRect.width * 2 > 20 ? 0 : 20)
3025
+ });
3026
+ } else if (childRect.right > parentRect.right) {
3027
+ await obj$1.element.setScrollLeft({
3028
+ el: root,
3029
+ number: 0
3030
+ });
3031
+ const tempChildRect = target.getBoundingClientRect();
3032
+ const tempParentRect = root.getBoundingClientRect();
3033
+ obj$1.element.setScrollLeft({
3034
+ el: root,
3035
+ number: tempChildRect.right - tempParentRect.right + tempChildRect.width * 2 + (tempChildRect.width * 2 > 20 ? 0 : 20)
3036
+ });
3037
+ }
3009
3038
  }
3010
3039
  }
3011
3040
  };
3012
- let root = this.$el;
3013
- while (obj$1.element.isElement(root) && root != document.documentElement) {
3014
- fn(root);
3015
- root = root.parentNode;
3041
+ if ((_a = this.range) == null ? void 0 : _a.focus.element.elm) {
3042
+ let root = this.range.focus.element.elm;
3043
+ while (obj$1.element.isElement(root) && root != document.documentElement) {
3044
+ fn(root);
3045
+ root = root.parentNode;
3046
+ }
3016
3047
  }
3017
3048
  };
3018
3049
  const handleStackEmpty = function() {
@@ -3089,6 +3120,7 @@ const handleSelectionChange = function() {
3089
3120
  } else {
3090
3121
  this.range = new AlexRange(anchor, focus);
3091
3122
  }
3123
+ this.history.updateCurrentRange(this.range);
3092
3124
  this.emit("rangeUpdate", this.range);
3093
3125
  }
3094
3126
  }
@@ -4124,6 +4156,7 @@ class AlexEditor {
4124
4156
  setTimeout(() => {
4125
4157
  setRangeInVisible.apply(this);
4126
4158
  this.__innerSelectionChange = false;
4159
+ this.history.updateCurrentRange(this.range);
4127
4160
  this.emit("rangeUpdate", this.range);
4128
4161
  }, 0);
4129
4162
  }
@@ -22929,7 +22962,7 @@ const i18n = (locale) => {
22929
22962
  return translations[locale][key];
22930
22963
  };
22931
22964
  };
22932
- const version = "0.0.28";
22965
+ const version = "0.0.29";
22933
22966
  const install = (app, props) => {
22934
22967
  const locale = (props ? props.locale : "zh_CN") || "zh_CN";
22935
22968
  app.provide("$editTrans", i18n(locale));