执行过npm install命令的vue-element-admin源码
康凯
2022-05-20 aa4c235a8ca67ea8b731f90c951a465e92c0a865
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
/*!
 * tui-editor
 * @version 1.3.3
 * @author NHN Ent. FE Development Lab <dl_javascript@nhnent.com> (https://nhnent.github.io/tui.editor/)
 * @license MIT
 */
(function webpackUniversalModuleDefinition(root, factory) {
    if(typeof exports === 'object' && typeof module === 'object')
        module.exports = factory(require("jquery"), require("tui-code-snippet"), (function webpackLoadOptionalExternalModule() { try { return require("tui-editor"); } catch(e) {} }()), (function webpackLoadOptionalExternalModule() { try { return require("tui-editor/dist/tui-editor-Viewer"); } catch(e) {} }()));
    else if(typeof define === 'function' && define.amd)
        define(["jquery", "tui-code-snippet", "tui-editor", "tui-editor/dist/tui-editor-Viewer"], factory);
    else {
        var a = typeof exports === 'object' ? factory(require("jquery"), require("tui-code-snippet"), (function webpackLoadOptionalExternalModule() { try { return require("tui-editor"); } catch(e) {} }()), (function webpackLoadOptionalExternalModule() { try { return require("tui-editor/dist/tui-editor-Viewer"); } catch(e) {} }())) : factory(root["$"], (root["tui"] && root["tui"]["util"]), (root["tui"] && root["tui"]["Editor"]), (root["tui"] && root["tui"]["Editor"]));
        for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
    }
})(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_0__, __WEBPACK_EXTERNAL_MODULE_2__, __WEBPACK_EXTERNAL_MODULE_4__, __WEBPACK_EXTERNAL_MODULE_5__) {
return /******/ (function(modules) { // webpackBootstrap
/******/     // The module cache
/******/     var installedModules = {};
/******/
/******/     // The require function
/******/     function __webpack_require__(moduleId) {
/******/
/******/         // Check if module is in cache
/******/         if(installedModules[moduleId]) {
/******/             return installedModules[moduleId].exports;
/******/         }
/******/         // Create a new module (and put it into the cache)
/******/         var module = installedModules[moduleId] = {
/******/             i: moduleId,
/******/             l: false,
/******/             exports: {}
/******/         };
/******/
/******/         // Execute the module function
/******/         modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/         // Flag the module as loaded
/******/         module.l = true;
/******/
/******/         // Return the exports of the module
/******/         return module.exports;
/******/     }
/******/
/******/
/******/     // expose the modules object (__webpack_modules__)
/******/     __webpack_require__.m = modules;
/******/
/******/     // expose the module cache
/******/     __webpack_require__.c = installedModules;
/******/
/******/     // define getter function for harmony exports
/******/     __webpack_require__.d = function(exports, name, getter) {
/******/         if(!__webpack_require__.o(exports, name)) {
/******/             Object.defineProperty(exports, name, {
/******/                 configurable: false,
/******/                 enumerable: true,
/******/                 get: getter
/******/             });
/******/         }
/******/     };
/******/
/******/     // getDefaultExport function for compatibility with non-harmony modules
/******/     __webpack_require__.n = function(module) {
/******/         var getter = module && module.__esModule ?
/******/             function getDefault() { return module['default']; } :
/******/             function getModuleExports() { return module; };
/******/         __webpack_require__.d(getter, 'a', getter);
/******/         return getter;
/******/     };
/******/
/******/     // Object.prototype.hasOwnProperty.call
/******/     __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/     // __webpack_public_path__
/******/     __webpack_require__.p = "dist/";
/******/
/******/     // Load entry module and return exports
/******/     return __webpack_require__(__webpack_require__.s = 46);
/******/ })
/************************************************************************/
/******/ ({
 
/***/ 0:
/***/ (function(module, exports) {
 
module.exports = __WEBPACK_EXTERNAL_MODULE_0__;
 
/***/ }),
 
/***/ 1:
/***/ (function(module, exports, __webpack_require__) {
 
"use strict";
 
 
Object.defineProperty(exports, "__esModule", {
  value: true
});
/**
* @fileoverview Editor/Viewer proxy for extensions
* @author NHN Ent. FE Development Lab <dl_javascript@nhnent.com>
*/
/* eslint global-require: 0 no-empty: 0 */
 
var Editor = void 0;
try {
  Editor = __webpack_require__(4);
} catch (e) {}
if (!Editor) {
  try {
    Editor = __webpack_require__(5);
  } catch (e) {}
}
 
exports.default = Editor;
 
/***/ }),
 
/***/ 2:
/***/ (function(module, exports) {
 
module.exports = __WEBPACK_EXTERNAL_MODULE_2__;
 
/***/ }),
 
/***/ 4:
/***/ (function(module, exports) {
 
if(typeof __WEBPACK_EXTERNAL_MODULE_4__ === 'undefined') {var e = new Error("Cannot find module \"undefined\""); e.code = 'MODULE_NOT_FOUND'; throw e;}
module.exports = __WEBPACK_EXTERNAL_MODULE_4__;
 
/***/ }),
 
/***/ 46:
/***/ (function(module, exports, __webpack_require__) {
 
"use strict";
 
 
Object.defineProperty(exports, "__esModule", {
  value: true
});
 
var _jquery = __webpack_require__(0);
 
var _jquery2 = _interopRequireDefault(_jquery);
 
var _editorProxy = __webpack_require__(1);
 
var _editorProxy2 = _interopRequireDefault(_editorProxy);
 
var _scrollManager = __webpack_require__(47);
 
var _scrollManager2 = _interopRequireDefault(_scrollManager);
 
var _sectionManager = __webpack_require__(48);
 
var _sectionManager2 = _interopRequireDefault(_sectionManager);
 
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 
/**
 * scrollSync plugin
 * @param {Editor} editor - editor
 * @ignore
 */
/**
* @fileoverview Implements Scroll Sync Extension
* @author NHN Ent. FE Development Lab <dl_javascript@nhnent.com>
*/
function scrollSyncExtension(editor) {
  var className = 'tui-scrollsync';
  var i18n = editor.i18n;
  var TOOL_TIP = {
    active: i18n.get('Auto scroll enabled'),
    inactive: i18n.get('Auto scroll disabled')
  };
 
  if (editor.isViewer()) {
    return;
  }
 
  var cm = editor.getCodeMirror();
  var sectionManager = new _sectionManager2.default(cm, editor.preview);
  var scrollManager = new _scrollManager2.default(sectionManager, cm, editor.preview.$el);
 
  var isScrollable = false;
  var isActive = true;
  var button = void 0;
  var $divider = void 0;
 
  // UI
  if (editor.getUI().name === 'default') {
    var toolbar = editor.getUI().getToolbar();
 
    toolbar.addItem('divider');
    toolbar.addItem({
      type: 'button',
      options: {
        className: className,
        command: 'scrollSyncToggle',
        tooltip: TOOL_TIP.active,
        $el: (0, _jquery2.default)('<button class="active ' + className + '" type="button"></button>')
      }
    });
    var items = toolbar.getItems();
    $divider = items[items.length - 2].$el;
    button = items[items.length - 1];
 
    changeButtonVisiblityStateIfNeed();
    // hide scroll follow button in wysiwyg
    editor.on('changeMode', changeButtonVisiblityStateIfNeed);
    editor.on('changePreviewStyle', changeButtonVisiblityStateIfNeed);
 
    // Commands
    editor.addCommand('markdown', {
      name: 'scrollSyncToggle',
      exec: function exec() {
        isActive = !isActive;
        button._onOut();
        if (isActive) {
          button.$el.addClass('active');
          button.setTooltip(TOOL_TIP.active);
        } else {
          button.$el.removeClass('active');
          button.setTooltip(TOOL_TIP.inactive);
        }
        button._onOver();
      }
    });
  }
 
  // Events
  cm.on('change', function () {
    isScrollable = false;
    sectionManager.makeSectionList();
  });
 
  /**
   * change button visiblity state
   */
  function changeButtonVisiblityStateIfNeed() {
    if (editor.mdPreviewStyle === 'vertical' && editor.currentMode === 'markdown') {
      button.$el.show();
      $divider.show();
    } else {
      button.$el.hide();
      $divider.hide();
    }
  }
 
  editor.on('previewRenderAfter', function () {
    sectionManager.sectionMatch();
    if (isActive) {
      scrollManager.syncPreviewScrollTopToMarkdown();
    }
    isScrollable = true;
  });
 
  editor.eventManager.listen('scroll', function (event) {
    if (!isActive) {
      return;
    }
 
    if (isScrollable && editor.preview.isVisible()) {
      if (event.source === 'markdown' && !scrollManager.isMarkdownScrollEventBlocked) {
        scrollManager.syncPreviewScrollTopToMarkdown();
      } else if (event.source === 'preview' && !scrollManager.isPreviewScrollEventBlocked) {
        scrollManager.syncMarkdownScrollTopToPreview();
      }
    } else {
      scrollManager.saveScrollInfo();
    }
  });
}
 
_editorProxy2.default.defineExtension('scrollSync', scrollSyncExtension);
 
exports.default = scrollSyncExtension;
 
/***/ }),
 
/***/ 47:
/***/ (function(module, exports, __webpack_require__) {
 
"use strict";
 
 
Object.defineProperty(exports, "__esModule", {
  value: true
});
 
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /**
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     * @fileoverview Implements Scroll Sync Extension ScrollManager Module
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     * @author NHN Ent. FE Development Lab <dl_javascript@nhnent.com>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     */
 
 
var _tuiCodeSnippet = __webpack_require__(2);
 
var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet);
 
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
 
var PREVIEW_MARGIN_TOP = 57;
var SCROLL_TOP_PADDING = 20;
var SCROLL_BOCKING_RESET_DELAY = 15;
 
/**
 * Class ScrollManager
 * manage scroll sync between markdown editor and preview
 */
 
var ScrollManager = function () {
  /**
   * Creates an instance of ScrollManager.
   * @param {SectionManager} sectionManager - sectionManager
   * @param {CodeMirror} cm - CodeMirror
   * @param {jQuery} $previewContainerEl - preview container
   * @memberof ScrollManager
   */
  function ScrollManager(sectionManager, cm, $previewContainerEl) {
    _classCallCheck(this, ScrollManager);
 
    this.sectionManager = sectionManager;
    this.cm = cm;
    this.$previewContainerEl = $previewContainerEl;
    this.$contents = this.$previewContainerEl.find('.tui-editor-contents');
    this.releaseTimer = null;
    /**
     * current timeout id needs animation
     * @type {number}
     */
    this._currentTimeoutId = null;
 
    /**
     * Saved scrollInfo object of CodeMirror
     * @type {object}
     */
    this._savedScrollInfo = null;
  }
 
  /**
   * _getEditorSectionHeight
   * Return section height of editor
   * @param {object} section section be calculated height
   * @returns {number} height
   * @private
   */
 
 
  _createClass(ScrollManager, [{
    key: '_getEditorSectionHeight',
    value: function _getEditorSectionHeight(section) {
      var height = this.cm.heightAtLine(section.end, 'local');
      height -= this.cm.heightAtLine(section.start > 0 ? section.start - 1 : 0, 'local');
 
      return height;
    }
 
    /**
     * _getLineHeightGapInSection
     * Return height gap between passed line in passed section
     * @param {object} section section be calculated
     * @param {number} line line number
     * @returns {number} gap
     * @private
     */
 
  }, {
    key: '_getEditorLineHeightGapInSection',
    value: function _getEditorLineHeightGapInSection(section, line) {
      var gap = this.cm.heightAtLine(line, 'local');
      gap -= this.cm.heightAtLine(section.start > 0 ? section.start - 1 : 0, 'local');
 
      return Math.max(gap, 0);
    }
 
    /**
     * _getSectionScrollRatio
     * Return ratio of height between scrollTop line and scrollTop section
     * @param {object} section section be calculated
     * @param {number} line line number
     * @returns {number} ratio
     * @private
     */
 
  }, {
    key: '_getEditorSectionScrollRatio',
    value: function _getEditorSectionScrollRatio(section, line) {
      var isOneLine = section.end === section.start;
      var ratio = void 0;
 
      if (isOneLine) {
        ratio = 0;
      } else {
        ratio = this._getEditorLineHeightGapInSection(section, line) / this._getEditorSectionHeight(section);
      }
 
      return ratio;
    }
 
    /**
     * _getScrollFactorsOfEditor
     * Return Scroll Information of editor for preview scroll sync
     * @returns {object} scroll factors
     * @private
     */
 
  }, {
    key: '_getScrollFactorsOfEditor',
    value: function _getScrollFactorsOfEditor() {
      var cm = this.cm;
 
      var scrollInfo = cm.getScrollInfo();
      var topLine = void 0,
          topSection = void 0,
          ratio = void 0,
          factors = void 0;
 
      // if codemirror has not visible scrollInfo have incorrect value
      // so we use saved scroll info for alternative
      scrollInfo = this._fallbackScrollInfoIfIncorrect(scrollInfo);
 
      var isEditorBottom = scrollInfo.height - scrollInfo.top <= scrollInfo.clientHeight;
 
      if (isEditorBottom) {
        factors = {
          isEditorBottom: isEditorBottom
        };
      } else {
        topLine = cm.coordsChar({
          left: scrollInfo.left,
          top: scrollInfo.top
        }, 'local').line;
 
        topSection = this.sectionManager.sectionByLine(topLine);
 
        ratio = this._getEditorSectionScrollRatio(topSection, topLine);
 
        factors = {
          section: topSection,
          sectionRatio: ratio
        };
      }
 
      return factors;
    }
 
    /**
     * Return Scroll Information of editor for Markdown scroll sync
     * @returns {object} scroll factors
     * @private
     */
 
  }, {
    key: '_getScrollInfoForMarkdown',
    value: function _getScrollInfoForMarkdown() {
      var _this = this;
 
      var sectionList = this.sectionManager.getSectionList();
      var factors = void 0;
 
      _tuiCodeSnippet2.default.forEachArray(sectionList, function (section) {
        var $div = section.$previewSectionEl;
        var $preview = $div.parent().parent();
        var isPreviewBottom = $preview[0].clientHeight - $preview.scrollTop() <= $preview[0].height;
        var needNext = true;
 
        if (isPreviewBottom) {
          factors = {
            isPreviewBottom: isPreviewBottom
          };
          needNext = false;
        } else if (_this._isTopSection($preview, $div)) {
          factors = {
            section: section,
            sectionRatio: _this._getMarkdownEditorScrollRatio($preview, $div)
          };
          needNext = false;
        }
 
        return needNext;
      });
 
      return factors;
    }
 
    /**
     * Return ScrollRatio for Markdown scroll value
     * @param {jQuery} $preview jQuery wrapped preview container
     * @param {jQuery} $div jQuery wrapped section div element
     * @returns {number}
     * @private
     */
 
  }, {
    key: '_getMarkdownEditorScrollRatio',
    value: function _getMarkdownEditorScrollRatio($preview, $div) {
      return ($preview.scrollTop() - $div[0].offsetTop) / $div.height();
    }
 
    /**
     * _getScrollTopForPreview
     * Return scrollTop value for preview
     * @returns {number|undefined} scrollTop value, when something wrong then return undefined
     * @private
     */
 
  }, {
    key: '_getScrollTopForPreview',
    value: function _getScrollTopForPreview() {
      var scrollTop = void 0;
 
      var scrollFactors = this._getScrollFactorsOfEditor();
      var section = scrollFactors.section,
          sectionRatio = scrollFactors.sectionRatio;
 
 
      if (scrollFactors.isEditorBottom) {
        scrollTop = this.$contents.height();
      } else if (section.$previewSectionEl) {
        scrollTop = section.$previewSectionEl[0].offsetTop;
        scrollTop += section.$previewSectionEl.height() * sectionRatio - SCROLL_TOP_PADDING;
      }
 
      scrollTop = scrollTop && Math.max(scrollTop, 0);
 
      return scrollTop;
    }
 
    /**
     * Return scrollTop value for Markdown editor
     * @returns {number}
     * @private
     */
 
  }, {
    key: '_getScrollTopForMarkdown',
    value: function _getScrollTopForMarkdown() {
      var scrollTop = void 0;
      var scrollFactors = this._getScrollInfoForMarkdown();
      var ratio = scrollFactors.sectionRatio;
 
      if (scrollFactors.isPreviewBottom) {
        scrollTop = this.cm.getScrollInfo().height;
      } else if (scrollFactors.section) {
        var section = scrollFactors.section;
 
        var coordsAtStart = this.cm.charCoords({
          line: section.start,
          char: 0
        }, 'local');
        var coordsAtEnd = this.cm.charCoords({
          line: section.end,
          char: 0
        }, 'local');
 
        scrollTop = coordsAtStart.top;
        scrollTop += (coordsAtEnd.top - coordsAtStart.top) * ratio;
      }
 
      scrollTop = scrollTop && Math.max(scrollTop, 0);
 
      return scrollTop;
    }
 
    /**
     * syncPreviewScrollTopToMarkdown
     * sync preview scroll to markdown
     */
 
  }, {
    key: 'syncPreviewScrollTopToMarkdown',
    value: function syncPreviewScrollTopToMarkdown() {
      var _this2 = this;
 
      var $previewContainerEl = this.$previewContainerEl;
 
      var sourceScrollTop = $previewContainerEl.scrollTop();
      var targetScrollTop = this._getScrollTopForPreview();
 
      this.isPreviewScrollEventBlocked = true;
 
      this._animateRun(sourceScrollTop, targetScrollTop, function (deltaScrollTop) {
        clearTimeout(_this2.releaseTimer);
 
        $previewContainerEl.scrollTop(deltaScrollTop);
 
        _this2.releaseTimer = setTimeout(function () {
          _this2.isPreviewScrollEventBlocked = false;
        }, SCROLL_BOCKING_RESET_DELAY);
      });
    }
 
    /**
     * syncMarkdownScrollTopToPreview
     * sync markdown scroll to preview
     */
 
  }, {
    key: 'syncMarkdownScrollTopToPreview',
    value: function syncMarkdownScrollTopToPreview() {
      var _this3 = this;
 
      var codeMirror = this.cm;
      var codeMirrorScrollInfo = codeMirror.getScrollInfo();
      var sourceScrollTop = codeMirrorScrollInfo.top;
      var targetScrollTop = this._getScrollTopForMarkdown();
 
      this.isMarkdownScrollEventBlocked = true;
 
      this._animateRun(sourceScrollTop, targetScrollTop, function (deltaScrollTop) {
        clearTimeout(_this3.releaseTimer);
 
        codeMirror.scrollTo(0, deltaScrollTop);
 
        _this3.releaseTimer = setTimeout(function () {
          _this3.isMarkdownScrollEventBlocked = false;
        }, SCROLL_BOCKING_RESET_DELAY);
      });
    }
 
    /**
     * _animateRun
     * animate with passed Callback
     * @param {number} originValue original value
     * @param {number} targetValue target value
     * @param {function} stepCB callback function
     * @private
     */
 
  }, {
    key: '_animateRun',
    value: function _animateRun(originValue, targetValue, stepCB) {
      var valueDiff = targetValue - originValue,
          startTime = Date.now(),
          self = this;
 
      // if already doing animation
      if (this._currentTimeoutId) {
        clearTimeout(this._currentTimeoutId);
      }
 
      /**
       * Each animation step
       */
      function step() {
        var stepTime = Date.now();
        var progress = (stepTime - startTime) / 200; // 200 is animation time
        var deltaValue = void 0;
 
        if (progress < 1) {
          deltaValue = originValue + valueDiff * Math.cos((1 - progress) * Math.PI / 2);
          stepCB(Math.ceil(deltaValue));
          self._currentTimeoutId = setTimeout(step, 1);
        } else {
          stepCB(targetValue);
          self._currentTimeoutId = null;
        }
      }
 
      step();
    }
 
    /**
     * Fallback to saved scrolInfo if incorrect scrollInfo passed
     * this because incorrect CodeMirror returns scrollInfo if CodeMirror is invisible
     * @param {object} scrollInfo scrollInfo
     * @returns {object} scrollInfo
     * @private
     */
 
  }, {
    key: '_fallbackScrollInfoIfIncorrect',
    value: function _fallbackScrollInfoIfIncorrect(scrollInfo) {
      return scrollInfo.height < 0 && this._savedScrollInfo ? this._savedScrollInfo : scrollInfo;
    }
 
    /**
     * Save Codemirror's scrollInfo for alternative use
     * memberOf ScrollManager
     */
 
  }, {
    key: 'saveScrollInfo',
    value: function saveScrollInfo() {
      this._savedScrollInfo = this.cm.getScrollInfo();
    }
 
    /**
     * Return whether given range is top section of preview contents or not
     * @param {jQuery} $preview jQuery wrapped preview container
     * @param {jQuery} $div jQuery wrapped section div element
     * @returns {boolean}
     * @private
     */
 
  }, {
    key: '_isTopSection',
    value: function _isTopSection($preview, $div) {
      var previewScrollTop = $preview.scrollTop();
      var divOffsetTop = $div[0].offsetTop;
      var divHeight = $div.height();
      var isSectionBegin = previewScrollTop >= divOffsetTop - PREVIEW_MARGIN_TOP;
      var isSectionEnd = previewScrollTop > divOffsetTop + divHeight;
 
      return isSectionBegin && !isSectionEnd;
    }
  }]);
 
  return ScrollManager;
}();
 
exports.default = ScrollManager;
 
/***/ }),
 
/***/ 48:
/***/ (function(module, exports, __webpack_require__) {
 
"use strict";
 
 
Object.defineProperty(exports, "__esModule", {
  value: true
});
 
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /**
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     * @fileoverview Implements Scroll Sync Extension SectionManager Module
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     * @author NHN Ent. FE Development Lab <dl_javascript@nhnent.com>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     */
 
 
var _jquery = __webpack_require__(0);
 
var _jquery2 = _interopRequireDefault(_jquery);
 
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
 
var FIND_HEADER_RX = /^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/;
var FIND_LIST_RX = /^ *(\*|-|\d+\.|[*-] \[[ xX]])\s/;
var FIND_QUOTE_RX = /^ {0,3}(> ?)+\s/;
var FIND_IMAGE_RX = /^ {0,3}!\[([^[\]]*)]\(([^)]*)\)/;
var FIND_SETEXT_HEADER_RX = /^ *(?:={1,}|-{1,})\s*$/;
var FIND_CODEBLOCK_END_RX = /^ *(`{3,}|~{3,})[ ]*$/;
var FIND_CODEBLOCK_START_RX = /^ *(`{3,}|~{3,})[ .]*(\S+)? */;
var FIND_SPACE = /\s/g;
 
/**
 * Class SectionManager
 * manage logical markdown content sections
 */
 
var SectionManager = function () {
  /**
   * Creates an instance of SectionManager.
   * @param {CodeMirror} cm - codemirror
   * @param {Preview} preview - preview
   * @memberof SectionManager
   */
  function SectionManager(cm, preview) {
    _classCallCheck(this, SectionManager);
 
    this.cm = cm;
    this.preview = preview;
    this.$previewContent = preview.$el.find('.tui-editor-contents');
 
    /**
     *  section list
     * @type {object[]}
     */
    this._sectionList = null;
 
    /**
     * current working section needs making section list
     * @type {object}
     */
    this._currentSection = null;
  }
 
  /**
   * _addNewSection
   * add new section
   * @param {number} start initial start line number
   * @param {number} end initial end line number
   * @private
   */
 
 
  _createClass(SectionManager, [{
    key: '_addNewSection',
    value: function _addNewSection(start, end) {
      var newSection = this._makeSectionData(start, end);
      this._sectionList.push(newSection);
      this._currentSection = newSection;
    }
 
    /**
     * getSectionList
     * return section list
     * @returns {object[]} section object list
     */
 
  }, {
    key: 'getSectionList',
    value: function getSectionList() {
      if (!this._sectionList) {
        this.makeSectionList();
      }
 
      return this._sectionList;
    }
 
    /**
     * _makeSectionData
     * make default section object
     * @param {number} start initial start line number
     * @param {number} end initial end line number
     * @returns {object} section object
     * @private
     */
 
  }, {
    key: '_makeSectionData',
    value: function _makeSectionData(start, end) {
      return {
        start: start,
        end: end,
        $previewSectionEl: null
      };
    }
 
    /**
     * _updateCurrentSectionEnd
     * update current section's end line number
     * @param {number} end end value to update
     * @private
     */
 
  }, {
    key: '_updateCurrentSectionEnd',
    value: function _updateCurrentSectionEnd(end) {
      this._currentSection.end = end;
    }
 
    /**
     * _eachLineState
     * iterate codemiror lines, callback function parameter pass line type and line number
     * @param {function} iteratee callback function
     * @private
     */
 
  }, {
    key: '_eachLineState',
    value: function _eachLineState(iteratee) {
      var isSection = void 0,
          i = void 0,
          lineString = void 0,
          nextLineString = void 0,
          prevLineString = void 0,
          isTrimming = true,
          onTable = false,
          onCodeBlock = false,
          trimCapture = '';
      var isRightAfterImageSection = false;
      var isEnsuredSection = false;
      var codeblockStartLineIndex = void 0;
 
      var lineLength = this.cm.getDoc().lineCount();
 
      for (i = 0; i < lineLength; i += 1) {
        isSection = false;
        lineString = this.cm.getLine(i);
        nextLineString = this.cm.getLine(i + 1) || '';
        prevLineString = this.cm.getLine(i - 1) || '';
        var isCodeBlockEnded = this._isCodeBlockEnd(prevLineString) && codeblockStartLineIndex !== i - 1;
 
        if (onTable && (!lineString || !this._isTableCode(lineString))) {
          onTable = false;
        } else if (!onTable && this._isTable(lineString, nextLineString)) {
          onTable = true;
        }
 
        if (onCodeBlock && isCodeBlockEnded) {
          onCodeBlock = false;
        }
        if (!onCodeBlock && this._isCodeBlockStart(lineString)) {
          onCodeBlock = this._doFollowedLinesHaveCodeBlockEnd(i, lineLength);
          codeblockStartLineIndex = i;
        }
 
        if (isEnsuredSection && lineString.length !== 0) {
          if (this._isIndependentImage(onCodeBlock, onTable, lineString, prevLineString)) {
            isRightAfterImageSection = true;
            isEnsuredSection = true;
          } else {
            isRightAfterImageSection = false;
            isEnsuredSection = false;
          }
 
          isSection = true;
        } else if (this._isAtxHeader(lineString)) {
          isRightAfterImageSection = false;
          isSection = true;
          isEnsuredSection = false;
          // setext header
        } else if (!this._isCodeBlockEnd(lineString) && !onTable && this._isSeTextHeader(lineString, nextLineString)) {
          isRightAfterImageSection = false;
          isSection = true;
          isEnsuredSection = false;
        } else if (this._isIndependentImage(onCodeBlock, onTable, lineString, prevLineString)) {
          isRightAfterImageSection = true;
          isSection = true;
          isEnsuredSection = false;
        } else if (isRightAfterImageSection && lineString.length === 0) {
          isRightAfterImageSection = false;
          isEnsuredSection = true;
        }
 
        // resolve wrong number of sections mismatch compare to preview
        if (isTrimming) {
          trimCapture += lineString.trim();
 
          if (trimCapture) {
            isTrimming = false;
          } else {
            continue;
          }
        }
 
        iteratee(isSection, i);
      }
    }
 
    /**
     * Return whether is independent image line with padding lines top and bottom
     * @param {boolean} onCodeBlock Is on codeblock
     * @param {boolean} onTable Is on table
     * @param {string} lineString Current line string
     * @param {string} prevLineString Previous line string
     * @returns {boolean}
     * @private
     */
 
  }, {
    key: '_isIndependentImage',
    value: function _isIndependentImage(onCodeBlock, onTable, lineString, prevLineString) {
      return !onCodeBlock && !onTable && this._isImage(lineString) && !this._isList(lineString) && !this._isQuote(lineString) && prevLineString.length === 0;
    }
 
    /**
     * _doFollowedLinesHaveCodeBlockEnd
     * Check if follow lines have codeblock end
     * @param {number} lineIndex current index
     * @param {number} lineLength line length
     * @returns {boolean} result
     * @private
     */
 
  }, {
    key: '_doFollowedLinesHaveCodeBlockEnd',
    value: function _doFollowedLinesHaveCodeBlockEnd(lineIndex, lineLength) {
      var doLineHaveCodeBlockEnd = false;
 
      for (var i = lineIndex + 1; i < lineLength; i += 1) {
        if (this._isCodeBlockEnd(this.cm.getLine(i))) {
          doLineHaveCodeBlockEnd = true;
          break;
        }
      }
 
      return doLineHaveCodeBlockEnd;
    }
 
    /**
     * _isCodeBlockStart
     * Check if passed string have code block start
     * @param {string} string string to check
     * @returns {boolean} result
     * @private
     */
 
  }, {
    key: '_isCodeBlockStart',
    value: function _isCodeBlockStart(string) {
      return FIND_CODEBLOCK_START_RX.test(string);
    }
 
    /**
     * _isCodeBlockEnd
     * Check if passed string have code block end
     * @param {string} string string to check
     * @returns {boolean} result
     * @private
     */
 
  }, {
    key: '_isCodeBlockEnd',
    value: function _isCodeBlockEnd(string) {
      return FIND_CODEBLOCK_END_RX.test(string);
    }
 
    /**
     * _isTable
     * Check if passed string have table
     * @param {string} lineString current line string
     * @param {string} nextLineString next line string
     * @returns {boolean} result
     * @private
     */
 
  }, {
    key: '_isTable',
    value: function _isTable(lineString, nextLineString) {
      return this._isTableCode(lineString) && this._isTableAligner(nextLineString);
    }
 
    /**
     * _isTableCode
     * Check if passed string have table code
     * @param {string} string string to check
     * @returns {boolean} result
     * @private
     */
 
  }, {
    key: '_isTableCode',
    value: function _isTableCode(string) {
      return (/(^\S?.*\|.*)/.test(string)
      );
    }
 
    /**
     * _isTableAligner
     * Check if passed string have table align code
     * @param {string} string string to check
     * @returns {boolean} result
     * @private
     */
 
  }, {
    key: '_isTableAligner',
    value: function _isTableAligner(string) {
      return (/(\s*[-:]+\s*\|)+/.test(string)
      );
    }
 
    /**
     * _isAtxHeader
     * Check if passed string have atx header
     * @param {string} string string to check
     * @returns {boolean} result
     * @private
     */
 
  }, {
    key: '_isAtxHeader',
    value: function _isAtxHeader(string) {
      return FIND_HEADER_RX.test(string);
    }
 
    /**
     * _isSeTextHeader
     * @param {string} lineString current line string
     * @param {string} nextLineString next line string
     * @returns {boolean} result
     * @private
     */
 
  }, {
    key: '_isSeTextHeader',
    value: function _isSeTextHeader(lineString, nextLineString) {
      return lineString.replace(FIND_SPACE, '') !== '' && !this._isQuote(lineString) && nextLineString && FIND_SETEXT_HEADER_RX.test(nextLineString);
    }
  }, {
    key: '_isImage',
    value: function _isImage(lineString) {
      return FIND_IMAGE_RX.test(lineString);
    }
  }, {
    key: '_isList',
    value: function _isList(lineString) {
      return FIND_LIST_RX.test(lineString);
    }
  }, {
    key: '_isQuote',
    value: function _isQuote(lineString) {
      return FIND_QUOTE_RX.test(lineString);
    }
 
    /**
     * makeSectionList
     * make section list
     */
 
  }, {
    key: 'makeSectionList',
    value: function makeSectionList() {
      var _this = this;
 
      this._sectionList = [];
 
      this._eachLineState(function (isSection, lineNumber) {
        if (isSection || !_this._sectionList.length) {
          _this._addNewSection(lineNumber, lineNumber);
        } else {
          _this._updateCurrentSectionEnd(lineNumber);
        }
      });
    }
 
    /**
     * sectionMatch
     * make preview sections then match section list with preview section element
     */
 
  }, {
    key: 'sectionMatch',
    value: function sectionMatch() {
      if (this.getSectionList()) {
        var sections = this._getPreviewSections();
        this._matchPreviewSectionsWithSectionlist(sections);
      }
    }
 
    /**
     * _matchPreviewSectionsWithSectionlist
     * match section list with preview section element
     * @param {HTMLNode[]} sections section nodes
     * @private
     */
 
  }, {
    key: '_matchPreviewSectionsWithSectionlist',
    value: function _matchPreviewSectionsWithSectionlist(sections) {
      var sectionList = this.getSectionList();
      sections.forEach(function (childs, index) {
        var section = sectionList[index];
        if (section) {
          var $sectionDiv = (0, _jquery2.default)('<div class=\'content-id-' + index + '\'></div>');
          section.$previewSectionEl = (0, _jquery2.default)(childs).wrapAll($sectionDiv).parent();
        }
      });
    }
 
    /**
     * _getPreviewSections
     * get preview html section group to make section
     * @returns {array[]} element node array
     * @private
     */
 
  }, {
    key: '_getPreviewSections',
    value: function _getPreviewSections() {
      var sections = [];
      var lastSection = 0;
      var isRightAfterImageSection = false;
 
      sections[0] = [];
 
      this.$previewContent.contents().filter(findElementNodeFilter).each(function (index, el) {
        var isParagraph = el.tagName === 'P';
        var isHeading = el.tagName.match(/^(H1|H2|H3|H4|H5|H6)$/);
        var isImage = isParagraph && el.childNodes[0].nodeName === 'IMG';
 
        if ((isHeading || isImage || isRightAfterImageSection) && sections[lastSection].length) {
          sections.push([]);
          lastSection += 1;
          isRightAfterImageSection = false;
        }
 
        if (isImage) {
          isRightAfterImageSection = true;
        }
 
        sections[lastSection].push(el);
      });
 
      return sections;
    }
 
    /**
     * _sectionByLine
     * get section by markdown line
     * @param {number} line markdown editor line number
     * @returns {object} section
     */
 
  }, {
    key: 'sectionByLine',
    value: function sectionByLine(line) {
      var sectionIndex = void 0;
      var sectionList = this.getSectionList();
      var sectionLength = sectionList.length;
 
      for (sectionIndex = 0; sectionIndex < sectionLength; sectionIndex += 1) {
        if (line <= sectionList[sectionIndex].end) {
          break;
        }
      }
 
      if (sectionIndex === sectionLength) {
        sectionIndex = sectionLength - 1;
      }
 
      return sectionList[sectionIndex];
    }
  }]);
 
  return SectionManager;
}();
 
/**
 * findElementNodeFilter
 * @this Node
 * @returns {boolean} true or not
 * @ignore
 */
 
 
function findElementNodeFilter() {
  return this.nodeType === Node.ELEMENT_NODE;
}
 
exports.default = SectionManager;
 
/***/ }),
 
/***/ 5:
/***/ (function(module, exports) {
 
if(typeof __WEBPACK_EXTERNAL_MODULE_5__ === 'undefined') {var e = new Error("Cannot find module \"undefined\""); e.code = 'MODULE_NOT_FOUND'; throw e;}
module.exports = __WEBPACK_EXTERNAL_MODULE_5__;
 
/***/ })
 
/******/ });
});