@mnykj/wangeditoroptimize-basic-modules 1.0.0 → 1.0.1

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/dist/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
- import { i18nAddResources, DomEditor, t, genModalInputElems, genModalButtonElems, canRemoveEmptyLineAboveBlock, resolveElemPath, insertEmptyLineAboveAtPath, removeEmptyLineAboveTopLevelBlock, setBlockToParagraph, replaceBlockWithEmptyLine, pinEditorScrollDuring, getEditorNodeAtPath as getEditorNodeAtPath$1, isBlankParagraphNode } from '@mnykj/wangeditoroptimize-core';
1
+ import { i18nAddResources, DomEditor, t, genModalInputElems, genModalButtonElems, genEmptyParagraph, pinEditorScrollDuring, canRemoveEmptyLineAboveBlock, removeEmptyLineAboveTopLevelBlock, resolveElemPath, insertEmptyLineAboveAtPath, setBlockToParagraph, replaceBlockWithEmptyLine, getEditorNodeAtPath as getEditorNodeAtPath$1, isBlankParagraphNode } from '@mnykj/wangeditoroptimize-core';
2
2
  import { jsx, h } from 'snabbdom';
3
- import { Text, Editor, Element as Element$1, Node, Transforms, Range, Point } from 'slate';
3
+ import { Text, Editor, Element as Element$1, Node, Transforms, Range, Path, Point } from 'slate';
4
4
  import $, { css, append, prepend, addClass, removeClass, hasClass, on, off, focus, attr, removeAttr, hide, show, parents, dataset, val, text, html as html$2, children, remove, find, width, height, filter, empty as empty$2 } from 'dom7';
5
5
  import { nanoid } from 'nanoid';
6
6
  import throttle from 'lodash.throttle';
@@ -9,7 +9,9 @@ var enResources = {
9
9
  common: {
10
10
  ok: 'OK',
11
11
  delete: 'Delete',
12
- enter: 'Enter'
12
+ enter: 'Enter',
13
+ enterAbove: 'Enter (blank line above)',
14
+ cancelEnter: 'Cancel enter'
13
15
  },
14
16
  blockQuote: {
15
17
  title: 'Quote'
@@ -98,7 +100,9 @@ var zhResources = {
98
100
  common: {
99
101
  ok: '确定',
100
102
  delete: '删除',
101
- enter: '回车'
103
+ enter: '回车',
104
+ enterAbove: '回车(上方空行)',
105
+ cancelEnter: '取消回车'
102
106
  },
103
107
  blockQuote: {
104
108
  title: '引用'
@@ -2650,6 +2654,7 @@ var SUP_SVG = '<svg viewBox="0 0 1024 1024"><path d="M768 206.016v50.016h128v64h
2650
2654
  var SUB_SVG = '<svg viewBox="0 0 1024 1024"><path d="M768 910.016v50.016h128v64h-192v-146.016l128-60V768h-128v-64h192v146.016zM676 256h-136L352 444 164 256H28l256 256-256 256h136L352 580 540 768h136l-256-256z"></path></svg>';
2651
2655
  var CHECK_BOX_SVG = '<svg viewBox="0 0 1024 1024"><path d="M278.755556 403.911111l-79.644445 79.644445L455.111111 739.555556l568.888889-568.888889-79.644444-79.644445L455.111111 580.266667l-176.355555-176.355556zM910.222222 910.222222H113.777778V113.777778h568.888889V0H113.777778C51.2 0 0 51.2 0 113.777778v796.444444c0 62.577778 51.2 113.777778 113.777778 113.777778h796.444444c62.577778 0 113.777778-51.2 113.777778-113.777778V455.111111h-113.777778v455.111111z"></path></svg>';
2652
2656
  var ENTER_SVG = '<svg viewBox="0 0 1255 1024"><path d="M1095.111111 731.477333h-625.777778V1024L0 658.318222 469.333333 292.408889v292.636444h625.777778V0h156.444445v731.477333z"></path></svg>';
2657
+ var CANCEL_ENTER_SVG = '<svg viewBox="0 0 1024 1024"><path d="M436 680H124v-56h312l-124-124 42-42 220 220-220 220-42-42 124-124z"></path><path d="M198 128l64-64 628 628-64 64z"></path></svg>';
2653
2658
 
2654
2659
  var BoldMenu =
2655
2660
  function (_super) {
@@ -3035,43 +3040,53 @@ function () {
3035
3040
  HeaderSelectMenu.prototype.getOptions = function (editor) {
3036
3041
  var options = [
3037
3042
  {
3043
+ value: 'paragraph',
3044
+ text: t('header.text'),
3045
+ styleForRenderMenuList: {
3046
+ 'font-size': '14px',
3047
+ 'font-weight': 'normal',
3048
+ 'line-height': '1.25'
3049
+ }
3050
+ }, {
3038
3051
  value: 'header1',
3039
3052
  text: 'H1',
3040
3053
  styleForRenderMenuList: {
3041
3054
  'font-size': '32px',
3042
- 'font-weight': 'bold'
3055
+ 'font-weight': 'bold',
3056
+ 'line-height': '1.25'
3043
3057
  }
3044
3058
  }, {
3045
3059
  value: 'header2',
3046
3060
  text: 'H2',
3047
3061
  styleForRenderMenuList: {
3048
3062
  'font-size': '24px',
3049
- 'font-weight': 'bold'
3063
+ 'font-weight': 'bold',
3064
+ 'line-height': '1.25'
3050
3065
  }
3051
3066
  }, {
3052
3067
  value: 'header3',
3053
3068
  text: 'H3',
3054
3069
  styleForRenderMenuList: {
3055
3070
  'font-size': '18px',
3056
- 'font-weight': 'bold'
3071
+ 'font-weight': 'bold',
3072
+ 'line-height': '1.25'
3057
3073
  }
3058
3074
  }, {
3059
3075
  value: 'header4',
3060
3076
  text: 'H4',
3061
3077
  styleForRenderMenuList: {
3062
3078
  'font-size': '16px',
3063
- 'font-weight': 'bold'
3079
+ 'font-weight': 'bold',
3080
+ 'line-height': '1.25'
3064
3081
  }
3065
3082
  }, {
3066
3083
  value: 'header5',
3067
3084
  text: 'H5',
3068
3085
  styleForRenderMenuList: {
3069
3086
  'font-size': '13px',
3070
- 'font-weight': 'bold'
3087
+ 'font-weight': 'bold',
3088
+ 'line-height': '1.25'
3071
3089
  }
3072
- }, {
3073
- value: 'paragraph',
3074
- text: t('header.text')
3075
3090
  }];
3076
3091
  var curValue = this.getValue(editor).toString();
3077
3092
  options.forEach(function (opt) {
@@ -3609,6 +3624,14 @@ var color = {
3609
3624
  menus: [colorMenuConf, bgColorMenuConf]
3610
3625
  };
3611
3626
 
3627
+ // `String.prototype.anchor` method
3628
+ // https://tc39.es/ecma262/#sec-string.prototype.anchor
3629
+ _export$1({ target: 'String', proto: true, forced: stringHtmlForced('anchor') }, {
3630
+ anchor: function anchor(name) {
3631
+ return createHtml(this, 'a', 'name', name);
3632
+ }
3633
+ });
3634
+
3612
3635
  /**
3613
3636
  * Expose `isUrl`.
3614
3637
  */
@@ -3810,46 +3833,13 @@ function insertLink(editor, text, url) {
3810
3833
  });
3811
3834
  });
3812
3835
  }
3813
- function updateLink(editor, text, url) {
3814
- return __awaiter(this, void 0, void 0, function () {
3815
- var checkRes, parsedUrl, props;
3816
- return __generator(this, function (_a) {
3817
- switch (_a.label) {
3818
- case 0:
3819
- if (!url) return [2
3820
- ];
3821
- return [4
3822
- , check$2('editLink', editor, text, url)];
3823
- case 1:
3824
- checkRes = _a.sent();
3825
- if (!checkRes) return [2
3826
- ];
3827
- return [4
3828
- , parse('editLink', editor, url)
3829
- ];
3830
- case 2:
3831
- parsedUrl = _a.sent();
3832
- props = {
3833
- url: replaceSymbols(parsedUrl)
3834
- };
3835
- Transforms.setNodes(editor, props, {
3836
- match: function match(n) {
3837
- return DomEditor.checkNodeType(n, 'link');
3838
- }
3839
- });
3840
- return [2
3841
- ];
3842
- }
3843
- });
3844
- });
3845
- }
3846
3836
 
3847
3837
  function withLink(editor) {
3848
3838
  var isInline = editor.isInline,
3849
3839
  insertData = editor.insertData,
3850
3840
  normalizeNode = editor.normalizeNode;
3851
3841
  editor.insertNode;
3852
- editor.insertText;
3842
+ var insertText = editor.insertText;
3853
3843
  var newEditor = editor;
3854
3844
  newEditor.isInline = function (elem) {
3855
3845
  var type = elem.type;
@@ -3858,6 +3848,41 @@ function withLink(editor) {
3858
3848
  }
3859
3849
  return isInline(elem);
3860
3850
  };
3851
+ newEditor.insertText = function (text) {
3852
+ var selection = newEditor.selection;
3853
+ if (text && selection && Range.isCollapsed(selection)) {
3854
+ var linkEntry = Editor.above(newEditor, {
3855
+ at: selection,
3856
+ match: function match(n) {
3857
+ return DomEditor.checkNodeType(n, 'link');
3858
+ }
3859
+ });
3860
+ if (linkEntry) {
3861
+ var _a = __read(linkEntry, 2),
3862
+ linkPath = _a[1];
3863
+ if (Editor.isEnd(newEditor, selection.anchor, linkPath)) {
3864
+ var after = Editor.after(newEditor, linkPath);
3865
+ if (after) {
3866
+ Transforms.select(newEditor, after);
3867
+ } else {
3868
+ var nextPath = Path.next(linkPath);
3869
+ Transforms.insertNodes(newEditor, {
3870
+ text: ''
3871
+ }, {
3872
+ at: nextPath
3873
+ });
3874
+ Transforms.select(newEditor, {
3875
+ path: nextPath,
3876
+ offset: 0
3877
+ });
3878
+ }
3879
+ insertText(text);
3880
+ return;
3881
+ }
3882
+ }
3883
+ }
3884
+ insertText(text);
3885
+ };
3861
3886
  newEditor.insertData = function (data) {
3862
3887
  var text = data.getData('text/plain');
3863
3888
  if (!isUrl_1(text)) {
@@ -3941,161 +3966,6 @@ var parseHtmlConf$4 = {
3941
3966
  parseElemHtml: parseHtml$4
3942
3967
  };
3943
3968
 
3944
- function genDomID$3() {
3945
- return genRandomStr('w-e-insert-link');
3946
- }
3947
- var InsertLinkMenu =
3948
- function () {
3949
- function InsertLinkMenu() {
3950
- this.title = t('link.insert');
3951
- this.iconSvg = LINK_SVG;
3952
- this.tag = 'button';
3953
- this.showModal = true;
3954
- this.modalWidth = 300;
3955
- this.$content = null;
3956
- this.textInputId = genDomID$3();
3957
- this.urlInputId = genDomID$3();
3958
- this.buttonId = genDomID$3();
3959
- }
3960
- InsertLinkMenu.prototype.getValue = function (editor) {
3961
- return '';
3962
- };
3963
- InsertLinkMenu.prototype.isActive = function (editor) {
3964
- return false;
3965
- };
3966
- InsertLinkMenu.prototype.exec = function (editor, value) {
3967
- };
3968
- InsertLinkMenu.prototype.isDisabled = function (editor) {
3969
- return isMenuDisabled(editor);
3970
- };
3971
- InsertLinkMenu.prototype.getModalPositionNode = function (editor) {
3972
- return null;
3973
- };
3974
- InsertLinkMenu.prototype.getModalContentElem = function (editor) {
3975
- var selection = editor.selection;
3976
- var _a = this,
3977
- textInputId = _a.textInputId,
3978
- urlInputId = _a.urlInputId,
3979
- buttonId = _a.buttonId;
3980
- var _b = __read(genModalInputElems(t('link.text'), textInputId), 2),
3981
- textContainerElem = _b[0],
3982
- inputTextElem = _b[1];
3983
- var $inputText = $(inputTextElem);
3984
- var _c = __read(genModalInputElems(t('link.url'), urlInputId), 2),
3985
- urlContainerElem = _c[0],
3986
- inputUrlElem = _c[1];
3987
- var $inputUrl = $(inputUrlElem);
3988
- var _d = __read(genModalButtonElems(buttonId, t('common.ok')), 1),
3989
- buttonContainerElem = _d[0];
3990
- if (this.$content == null) {
3991
- var $content_1 = $('<div></div>');
3992
- $content_1.on('click', "#" + buttonId, function (e) {
3993
- e.preventDefault();
3994
- var text = $content_1.find("#" + textInputId).val();
3995
- var url = $content_1.find("#" + urlInputId).val();
3996
- insertLink(editor, text, url);
3997
- editor.hidePanelOrModal();
3998
- });
3999
- this.$content = $content_1;
4000
- }
4001
- var $content = this.$content;
4002
- $content.empty();
4003
- $content.append(textContainerElem);
4004
- $content.append(urlContainerElem);
4005
- $content.append(buttonContainerElem);
4006
- if (selection == null || Range.isCollapsed(selection)) {
4007
- $inputText.val('');
4008
- } else {
4009
- var selectionText = Editor.string(editor, selection);
4010
- $inputText.val(selectionText);
4011
- }
4012
- $inputUrl.val('');
4013
- setTimeout(function () {
4014
- $inputText.focus();
4015
- });
4016
- return $content[0];
4017
- };
4018
- return InsertLinkMenu;
4019
- }();
4020
-
4021
- function genDomID$2() {
4022
- return genRandomStr('w-e-update-link');
4023
- }
4024
- var EditLinkMenu =
4025
- function () {
4026
- function EditLinkMenu() {
4027
- this.title = t('link.edit');
4028
- this.iconSvg = PENCIL_SVG;
4029
- this.tag = 'button';
4030
- this.showModal = true;
4031
- this.modalWidth = 300;
4032
- this.$content = null;
4033
- this.urlInputId = genDomID$2();
4034
- this.buttonId = genDomID$2();
4035
- }
4036
- EditLinkMenu.prototype.getSelectedLinkElem = function (editor) {
4037
- var node = DomEditor.getSelectedNodeByType(editor, 'link');
4038
- if (node == null) return null;
4039
- return node;
4040
- };
4041
- EditLinkMenu.prototype.getValue = function (editor) {
4042
- var linkElem = this.getSelectedLinkElem(editor);
4043
- if (linkElem) {
4044
- return linkElem.url || '';
4045
- }
4046
- return '';
4047
- };
4048
- EditLinkMenu.prototype.isActive = function (editor) {
4049
- return false;
4050
- };
4051
- EditLinkMenu.prototype.exec = function (editor, value) {
4052
- };
4053
- EditLinkMenu.prototype.isDisabled = function (editor) {
4054
- if (editor.selection == null) return true;
4055
- var linkElem = this.getSelectedLinkElem(editor);
4056
- if (linkElem == null) return true;
4057
- return false;
4058
- };
4059
- EditLinkMenu.prototype.getModalPositionNode = function (editor) {
4060
- return DomEditor.getSelectedNodeByType(editor, 'link');
4061
- };
4062
- EditLinkMenu.prototype.getModalContentElem = function (editor) {
4063
- var _a = this,
4064
- urlInputId = _a.urlInputId,
4065
- buttonId = _a.buttonId;
4066
- var _b = __read(genModalInputElems(t('link.url'), urlInputId), 2),
4067
- urlContainerElem = _b[0],
4068
- inputUrlElem = _b[1];
4069
- var $inputUrl = $(inputUrlElem);
4070
- var _c = __read(genModalButtonElems(buttonId, t('common.ok')), 1),
4071
- buttonContainerElem = _c[0];
4072
- if (this.$content == null) {
4073
- var $content_1 = $('<div></div>');
4074
- $content_1.on('click', 'button', function (e) {
4075
- e.preventDefault();
4076
- editor.restoreSelection();
4077
- var n = DomEditor.getSelectedNodeByType(editor, 'link');
4078
- var text = n ? Node.string(n) : '';
4079
- var url = $content_1.find("#" + urlInputId).val();
4080
- updateLink(editor, text, url);
4081
- editor.hidePanelOrModal();
4082
- });
4083
- this.$content = $content_1;
4084
- }
4085
- var $content = this.$content;
4086
- $content.empty();
4087
- $content.append(urlContainerElem);
4088
- $content.append(buttonContainerElem);
4089
- var url = this.getValue(editor);
4090
- $inputUrl.val(url);
4091
- setTimeout(function () {
4092
- $inputUrl.focus();
4093
- });
4094
- return $content[0];
4095
- };
4096
- return EditLinkMenu;
4097
- }();
4098
-
4099
3969
  var UnLink =
4100
3970
  function () {
4101
3971
  function UnLink() {
@@ -4207,14 +4077,6 @@ _export$1({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT$1 }, {
4207
4077
  }
4208
4078
  });
4209
4079
 
4210
- // `String.prototype.anchor` method
4211
- // https://tc39.es/ecma262/#sec-string.prototype.anchor
4212
- _export$1({ target: 'String', proto: true, forced: stringHtmlForced('anchor') }, {
4213
- anchor: function anchor(name) {
4214
- return createHtml(this, 'a', 'name', name);
4215
- }
4216
- });
4217
-
4218
4080
  var linkFormApplying = false;
4219
4081
  function syncApplyingFlag() {
4220
4082
  try {
@@ -4295,7 +4157,7 @@ function () {
4295
4157
  }
4296
4158
  this.tag = 'button';
4297
4159
  this.showModal = true;
4298
- this.modalWidth = 440;
4160
+ this.modalWidth = 300;
4299
4161
  this._root = null;
4300
4162
  this._editor = null;
4301
4163
  this._editLinkPath = null;
@@ -4579,7 +4441,7 @@ function () {
4579
4441
  });
4580
4442
  };
4581
4443
  LinkFormMenu.prototype._onRootClick = function (e) {
4582
- var _a, _b, _c;
4444
+ var _a, _b;
4583
4445
  var editor = this._editor;
4584
4446
  if (!editor || editor.isDestroyed) return;
4585
4447
  var el = e.target;
@@ -4592,13 +4454,6 @@ function () {
4592
4454
  setLinkFormModalOpen(false, editor);
4593
4455
  return;
4594
4456
  }
4595
- if (action === 'visit') {
4596
- var urlInput = (_c = this._root) === null || _c === void 0 ? void 0 : _c.querySelector("#" + this._urlInputId);
4597
- var href = normalizeLinkUrl(String((urlInput === null || urlInput === void 0 ? void 0 : urlInput.value) || '').trim());
4598
- if (!href) return;
4599
- window.open(href, '_blank', 'noopener,noreferrer');
4600
- return;
4601
- }
4602
4457
  if (action === 'ok') {
4603
4458
  void this._apply(editor);
4604
4459
  }
@@ -4664,7 +4519,7 @@ function () {
4664
4519
  }
4665
4520
  url = '';
4666
4521
  }
4667
- this._root.innerHTML = "\n <div class=\"mdgch-edit-link-row\">\n <span class=\"mdgch-edit-link-label\">\u6587\u672C</span>\n <input type=\"text\" class=\"mdgch-edit-link-input\" id=\"" + this._textInputId + "\" autocomplete=\"off\" />\n <span class=\"mdgch-edit-link-visit-spacer\" aria-hidden=\"true\">\u8BBF\u95EE</span>\n </div>\n <div class=\"mdgch-edit-link-row\">\n <span class=\"mdgch-edit-link-label\">\u94FE\u63A5</span>\n <input type=\"text\" class=\"mdgch-edit-link-input\" id=\"" + this._urlInputId + "\" autocomplete=\"off\" />\n <button type=\"button\" class=\"mdgch-edit-link-visit\" data-w-e-link-action=\"visit\">\u8BBF\u95EE</button>\n </div>\n <div class=\"mdgch-edit-link-actions\">\n <button type=\"button\" class=\"mdgch-edit-link-btn mdgch-edit-link-btn-cancel\" data-w-e-link-action=\"cancel\">\u53D6\u6D88</button>\n <button type=\"button\" class=\"mdgch-edit-link-btn mdgch-edit-link-btn-ok\" data-w-e-link-action=\"ok\">\u786E\u5B9A</button>\n </div>\n ";
4522
+ this._root.innerHTML = "\n <div class=\"mdgch-edit-link-row\">\n <span class=\"mdgch-edit-link-label\">\u6587\u672C</span>\n <input type=\"text\" class=\"mdgch-edit-link-input\" id=\"" + this._textInputId + "\" autocomplete=\"off\" />\n </div>\n <div class=\"mdgch-edit-link-row\">\n <span class=\"mdgch-edit-link-label\">\u94FE\u63A5</span>\n <input type=\"text\" class=\"mdgch-edit-link-input\" id=\"" + this._urlInputId + "\" autocomplete=\"off\" />\n </div>\n <div class=\"mdgch-edit-link-actions\">\n <button type=\"button\" class=\"mdgch-edit-link-btn mdgch-edit-link-btn-cancel\" data-w-e-link-action=\"cancel\"><span>\u53D6\u6D88</span></button>\n <button type=\"button\" class=\"mdgch-edit-link-btn mdgch-edit-link-btn-ok\" data-w-e-link-action=\"ok\"><span>\u786E\u5B9A</span></button>\n </div>\n ";
4668
4523
  var textInput = this._root.querySelector("#" + this._textInputId);
4669
4524
  var urlInput = this._root.querySelector("#" + this._urlInputId);
4670
4525
  if (textInput) textInput.value = text;
@@ -4731,14 +4586,14 @@ var config$1 = genLinkMenuConfig();
4731
4586
  var insertLinkMenuConf = {
4732
4587
  key: 'insertLink',
4733
4588
  factory: function factory() {
4734
- return new InsertLinkMenu();
4589
+ return new LinkFormMenu('insert');
4735
4590
  },
4736
4591
  config: config$1
4737
4592
  };
4738
4593
  var editLinkMenuConf = {
4739
4594
  key: 'editLink',
4740
4595
  factory: function factory() {
4741
- return new EditLinkMenu();
4596
+ return new LinkFormMenu('edit');
4742
4597
  },
4743
4598
  config: config$1
4744
4599
  };
@@ -5677,6 +5532,86 @@ function (_super) {
5677
5532
  return ImageWidth100;
5678
5533
  }(ImageWidthBaseClass);
5679
5534
 
5535
+ var ImageEnterAbove =
5536
+ function () {
5537
+ function ImageEnterAbove() {
5538
+ this.title = t('common.enterAbove');
5539
+ this.iconSvg = ENTER_SVG;
5540
+ this.tag = 'button';
5541
+ }
5542
+ ImageEnterAbove.prototype.getValue = function (_editor) {
5543
+ return '';
5544
+ };
5545
+ ImageEnterAbove.prototype.isActive = function (_editor) {
5546
+ return false;
5547
+ };
5548
+ ImageEnterAbove.prototype.isDisabled = function (editor) {
5549
+ if (editor.selection == null) return true;
5550
+ return DomEditor.getSelectedNodeByType(editor, 'image') == null;
5551
+ };
5552
+ ImageEnterAbove.prototype.exec = function (editor, _value) {
5553
+ if (this.isDisabled(editor)) return;
5554
+ var imageNode = DomEditor.getSelectedNodeByType(editor, 'image');
5555
+ if (imageNode == null) return;
5556
+ var path;
5557
+ try {
5558
+ path = DomEditor.findPath(editor, imageNode);
5559
+ } catch (_) {
5560
+ return;
5561
+ }
5562
+ if (!(path === null || path === void 0 ? void 0 : path.length)) return;
5563
+ var at = [path[0]];
5564
+ var emptyP = genEmptyParagraph(editor);
5565
+ pinEditorScrollDuring(editor, function () {
5566
+ Transforms.insertNodes(editor, emptyP, {
5567
+ at: at
5568
+ });
5569
+ try {
5570
+ Transforms.select(editor, Editor.start(editor, [at[0] + 1]));
5571
+ } catch (_) {
5572
+ }
5573
+ });
5574
+ };
5575
+ return ImageEnterAbove;
5576
+ }();
5577
+
5578
+ var ImageCancelEnter =
5579
+ function () {
5580
+ function ImageCancelEnter() {
5581
+ this.title = t('common.cancelEnter');
5582
+ this.iconSvg = CANCEL_ENTER_SVG;
5583
+ this.tag = 'button';
5584
+ }
5585
+ ImageCancelEnter.prototype.getValue = function (_editor) {
5586
+ return '';
5587
+ };
5588
+ ImageCancelEnter.prototype.isActive = function (_editor) {
5589
+ return false;
5590
+ };
5591
+ ImageCancelEnter.prototype.isDisabled = function (editor) {
5592
+ if (editor.selection == null) return true;
5593
+ var imageNode = DomEditor.getSelectedNodeByType(editor, 'image');
5594
+ if (imageNode == null) return true;
5595
+ try {
5596
+ var path = DomEditor.findPath(editor, imageNode);
5597
+ return !canRemoveEmptyLineAboveBlock(editor, path);
5598
+ } catch (_) {
5599
+ return true;
5600
+ }
5601
+ };
5602
+ ImageCancelEnter.prototype.exec = function (editor, _value) {
5603
+ if (this.isDisabled(editor)) return;
5604
+ var imageNode = DomEditor.getSelectedNodeByType(editor, 'image');
5605
+ if (imageNode == null) return;
5606
+ try {
5607
+ var path = DomEditor.findPath(editor, imageNode);
5608
+ removeEmptyLineAboveTopLevelBlock(editor, path);
5609
+ } catch (_) {
5610
+ }
5611
+ };
5612
+ return ImageCancelEnter;
5613
+ }();
5614
+
5680
5615
  function genImageMenuConfig() {
5681
5616
  return {
5682
5617
  onInsertedImage: function onInsertedImage(imageElem) {
@@ -5743,12 +5678,24 @@ var imageWidth100MenuConf = {
5743
5678
  return new ImageWidth100();
5744
5679
  }
5745
5680
  };
5681
+ var imageEnterMenuConf = {
5682
+ key: 'imageEnter',
5683
+ factory: function factory() {
5684
+ return new ImageEnterAbove();
5685
+ }
5686
+ };
5687
+ var imageCancelEnterMenuConf = {
5688
+ key: 'imageCancelEnter',
5689
+ factory: function factory() {
5690
+ return new ImageCancelEnter();
5691
+ }
5692
+ };
5746
5693
 
5747
5694
  var image$1 = {
5748
5695
  renderElems: [renderImageConf],
5749
5696
  elemsToHtml: [imageToHtmlConf],
5750
5697
  parseElemsHtml: [parseHtmlConf$3],
5751
- menus: [insertImageMenuConf, deleteImageMenuConf, editImageMenuConf, viewImageLinkMenuConf, imageWidth30MenuConf, imageWidth50MenuConf, imageWidth75MenuConf, imageWidth100MenuConf],
5698
+ menus: [insertImageMenuConf, deleteImageMenuConf, editImageMenuConf, viewImageLinkMenuConf, imageWidth30MenuConf, imageWidth50MenuConf, imageWidth75MenuConf, imageWidth100MenuConf, imageEnterMenuConf, imageCancelEnterMenuConf],
5752
5699
  editorPlugin: withImage
5753
5700
  };
5754
5701
 
@@ -6075,7 +6022,7 @@ function renderBlockQuote(elemNode, children, editor) {
6075
6022
  attrs: {
6076
6023
  class: 'mdg-bq-with-toolbar'
6077
6024
  }
6078
- }, __spreadArray([toolbar], __read(kids)));
6025
+ }, __spreadArray(__spreadArray([], __read(kids)), [toolbar]));
6079
6026
  }
6080
6027
  var renderBlockQuoteConf = {
6081
6028
  type: 'blockquote',
@@ -9513,7 +9460,8 @@ var blockquoteMergedMenuConf = {
9513
9460
 
9514
9461
  function withBlockquote(editor) {
9515
9462
  var insertBreak = editor.insertBreak,
9516
- insertText = editor.insertText;
9463
+ insertText = editor.insertText,
9464
+ insertData = editor.insertData;
9517
9465
  var newEditor = editor;
9518
9466
  newEditor.insertBreak = function () {
9519
9467
  var selection = newEditor.selection;
@@ -9547,6 +9495,30 @@ function withBlockquote(editor) {
9547
9495
  }
9548
9496
  insertText('\n');
9549
9497
  };
9498
+ newEditor.insertData = function (data) {
9499
+ var quoteNode = DomEditor.getSelectedNodeByType(newEditor, 'blockquote');
9500
+ if (quoteNode == null) {
9501
+ insertData(data);
9502
+ return;
9503
+ }
9504
+ var files = data.files;
9505
+ if (files && files.length > 0) {
9506
+ insertData(data);
9507
+ return;
9508
+ }
9509
+ var html = data.getData('text/html');
9510
+ if (html && /<img[^>]+>/i.test(html)) {
9511
+ insertData(data);
9512
+ return;
9513
+ }
9514
+ var text = data.getData('text/plain');
9515
+ if (!text) {
9516
+ insertData(data);
9517
+ return;
9518
+ }
9519
+ var normalized = text.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
9520
+ Editor.insertText(newEditor, normalized);
9521
+ };
9550
9522
  return newEditor;
9551
9523
  }
9552
9524
 
@@ -11038,11 +11010,55 @@ function getLastTextLineBeforeSelection(codeNode, editor) {
11038
11010
  if (length === 0) return '';
11039
11011
  return arr[length - 1];
11040
11012
  }
11013
+ function outdentCodeSelection(editor) {
11014
+ var selection = editor.selection;
11015
+ if (selection == null) return;
11016
+ if (!Path.equals(Range.start(selection).path, Range.end(selection).path)) return;
11017
+ var path = Range.start(selection).path;
11018
+ var textNode = Node.get(editor, path);
11019
+ if (!Text.isText(textNode)) return;
11020
+ var fullText = textNode.text;
11021
+ var rangeStart = Range.start(selection).offset;
11022
+ var rangeEnd = Range.isCollapsed(selection) ? rangeStart : Range.end(selection).offset;
11023
+ var lineStarts = [];
11024
+ var lineStart = 0;
11025
+ for (var i = 0; i <= fullText.length; i++) {
11026
+ if (i === fullText.length || fullText[i] === '\n') {
11027
+ var lineEnd = i;
11028
+ if (Range.isCollapsed(selection)) {
11029
+ if (lineStart <= rangeStart && rangeStart <= lineEnd) {
11030
+ lineStarts.push(lineStart);
11031
+ }
11032
+ } else if (lineEnd > rangeStart && lineStart <= rangeEnd) {
11033
+ lineStarts.push(lineStart);
11034
+ }
11035
+ lineStart = i + 1;
11036
+ }
11037
+ }
11038
+ for (var i = lineStarts.length - 1; i >= 0; i--) {
11039
+ var ls = lineStarts[i];
11040
+ var m = fullText.slice(ls).match(/^(?:\t| {1,4})/);
11041
+ if (!m) continue;
11042
+ var len = m[0].length;
11043
+ Transforms.delete(editor, {
11044
+ at: {
11045
+ anchor: {
11046
+ path: path,
11047
+ offset: ls
11048
+ },
11049
+ focus: {
11050
+ path: path,
11051
+ offset: ls + len
11052
+ }
11053
+ }
11054
+ });
11055
+ }
11056
+ }
11041
11057
  function withCodeBlock(editor) {
11042
11058
  var insertBreak = editor.insertBreak,
11043
11059
  normalizeNode = editor.normalizeNode,
11044
- insertData = editor.insertData;
11045
- editor.insertNode;
11060
+ insertData = editor.insertData,
11061
+ handleShiftTab = editor.handleShiftTab;
11046
11062
  var newEditor = editor;
11047
11063
  newEditor.insertBreak = function () {
11048
11064
  var codeNode = DomEditor.getSelectedNodeByType(newEditor, 'code');
@@ -11061,6 +11077,14 @@ function withCodeBlock(editor) {
11061
11077
  }
11062
11078
  newEditor.insertText('\n');
11063
11079
  };
11080
+ newEditor.handleShiftTab = function () {
11081
+ var codeNode = DomEditor.getSelectedNodeByType(newEditor, 'code');
11082
+ if (codeNode == null) {
11083
+ if (typeof handleShiftTab === 'function') handleShiftTab();
11084
+ return;
11085
+ }
11086
+ outdentCodeSelection(newEditor);
11087
+ };
11064
11088
  newEditor.normalizeNode = function (_a) {
11065
11089
  var _b = __read(_a, 2),
11066
11090
  node = _b[0],