pxx-vue-quill 1.0.97 → 1.0.99

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.
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * Copyright (c) 2025 Pxx-Team
9
9
  * Released under the MIT license
10
- * Date: 2025-09-09T02:34:04.777Z
10
+ * Date: 2025-09-10T01:59:09.315Z
11
11
  */
12
12
  (function (global, factory) {
13
13
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue')) :
@@ -18444,7 +18444,7 @@
18444
18444
  full: [
18445
18445
  ['bold', 'italic', 'underline'],
18446
18446
  [{ color: [] }],
18447
- ['link'],
18447
+ ['customLink'],
18448
18448
  [{ list: 'ordered' }, { list: 'bullet' }],
18449
18449
  ['image'],
18450
18450
  ['undo', 'redo'],
@@ -18517,8 +18517,9 @@
18517
18517
  ]),
18518
18518
  vue.h('span', { class: 'ql-formats' }, [
18519
18519
  vue.h('button', {
18520
- class: 'ql-link',
18521
- type: 'button'
18520
+ class: 'ql-customLink',
18521
+ type: 'button',
18522
+ onClick: () => emit('toolClick', 'customLink')
18522
18523
  }, '')
18523
18524
  ]),
18524
18525
  vue.h('span', { class: 'ql-formats' }, [
@@ -18590,6 +18591,80 @@
18590
18591
  }
18591
18592
  });
18592
18593
 
18594
+ const CustomLink = vue.defineComponent({
18595
+ name: 'CustomLink',
18596
+ props: {
18597
+ visible: {
18598
+ type: Boolean,
18599
+ default: false
18600
+ },
18601
+ position: {
18602
+ type: Object,
18603
+ default: () => ({ top: 0, left: 0 })
18604
+ },
18605
+ linkUrl: {
18606
+ type: String,
18607
+ default: ''
18608
+ },
18609
+ linkText: {
18610
+ type: String,
18611
+ default: ''
18612
+ }
18613
+ },
18614
+ emits: ['save', 'update:linkUrl', 'update:linkText'],
18615
+ setup(props, { emit }) {
18616
+ const localLinkUrl = vue.computed({
18617
+ get() {
18618
+ return props.linkUrl;
18619
+ },
18620
+ set(val) {
18621
+ emit('update:linkUrl', val);
18622
+ },
18623
+ });
18624
+ const localLinkText = vue.computed({
18625
+ get() {
18626
+ return props.linkText;
18627
+ },
18628
+ set(val) {
18629
+ emit('update:linkText', val);
18630
+ },
18631
+ });
18632
+ const handleSave = () => {
18633
+ emit('save', {
18634
+ url: localLinkUrl.value,
18635
+ text: localLinkText.value
18636
+ });
18637
+ };
18638
+ return () => {
18639
+ if (!props.visible)
18640
+ return null;
18641
+ return vue.h('div', {
18642
+ class: 'ql-custom-link',
18643
+ style: {
18644
+ top: `${props.position.top}px`,
18645
+ left: `${props.position.left}px`,
18646
+ },
18647
+ onClick: (event) => {
18648
+ event.stopPropagation();
18649
+ }
18650
+ }, [
18651
+ vue.h('input', {
18652
+ type: 'text',
18653
+ value: localLinkUrl.value,
18654
+ placeholder: '请输入链接',
18655
+ onInput: (e) => {
18656
+ localLinkUrl.value = e.target.value;
18657
+ }
18658
+ }),
18659
+ vue.h('button', {
18660
+ class: 'custom-link-btn',
18661
+ onClick: handleSave
18662
+ }, '确定'),
18663
+ ]);
18664
+ };
18665
+ }
18666
+ });
18667
+
18593
18668
  var dist = {};
18594
18669
 
18595
18670
  var Options = {};
@@ -18918,11 +18993,11 @@
18918
18993
  value: true
18919
18994
  });
18920
18995
 
18921
- 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; }; }();
18996
+ var _createClass$1 = 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; }; }();
18922
18997
 
18923
18998
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18924
18999
 
18925
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
19000
+ function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18926
19001
 
18927
19002
  var LEFT_ALIGN = 'left';
18928
19003
  var CENTER_ALIGN = 'center';
@@ -18933,7 +19008,7 @@
18933
19008
  var _this = this,
18934
19009
  _alignments;
18935
19010
 
18936
- _classCallCheck(this, DefaultAligner);
19011
+ _classCallCheck$1(this, DefaultAligner);
18937
19012
 
18938
19013
  this.applyStyle = options.aligner.applyStyle;
18939
19014
  this.alignAttribute = options.attribute;
@@ -18961,7 +19036,7 @@
18961
19036
  }), _alignments);
18962
19037
  }
18963
19038
 
18964
- _createClass(DefaultAligner, [{
19039
+ _createClass$1(DefaultAligner, [{
18965
19040
  key: 'getAlignments',
18966
19041
  value: function getAlignments() {
18967
19042
  var _this2 = this;
@@ -19264,190 +19339,182 @@
19264
19339
  return AlignAction;
19265
19340
  }
19266
19341
 
19267
- var ResizeAction = {};
19268
-
19269
- var hasRequiredResizeAction;
19342
+ var ResizeAction$1 = {};
19270
19343
 
19271
- function requireResizeAction () {
19272
- if (hasRequiredResizeAction) return ResizeAction;
19273
- hasRequiredResizeAction = 1;
19274
-
19275
- Object.defineProperty(ResizeAction, "__esModule", {
19276
- value: true
19277
- });
19344
+ Object.defineProperty(ResizeAction$1, "__esModule", {
19345
+ value: true
19346
+ });
19278
19347
 
19279
- 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; }; }();
19348
+ 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; }; }();
19280
19349
 
19281
- var _Action2 = requireAction();
19350
+ var _Action2 = requireAction();
19282
19351
 
19283
- var _Action3 = _interopRequireDefault(_Action2);
19352
+ var _Action3 = _interopRequireDefault(_Action2);
19284
19353
 
19285
- var _BlotFormatter = requireBlotFormatter();
19354
+ var _BlotFormatter = requireBlotFormatter();
19286
19355
 
19287
- _interopRequireDefault(_BlotFormatter);
19356
+ _interopRequireDefault(_BlotFormatter);
19288
19357
 
19289
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19358
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19290
19359
 
19291
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
19360
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
19292
19361
 
19293
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
19362
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
19294
19363
 
19295
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
19364
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
19296
19365
 
19297
- var ResizeAction$1 = function (_Action) {
19298
- _inherits(ResizeAction, _Action);
19366
+ var ResizeAction = function (_Action) {
19367
+ _inherits(ResizeAction, _Action);
19299
19368
 
19300
- function ResizeAction(formatter) {
19301
- _classCallCheck(this, ResizeAction);
19369
+ function ResizeAction(formatter) {
19370
+ _classCallCheck(this, ResizeAction);
19302
19371
 
19303
- var _this = _possibleConstructorReturn(this, (ResizeAction.__proto__ || Object.getPrototypeOf(ResizeAction)).call(this, formatter));
19372
+ var _this = _possibleConstructorReturn(this, (ResizeAction.__proto__ || Object.getPrototypeOf(ResizeAction)).call(this, formatter));
19304
19373
 
19305
- _this.onMouseDown = function (event) {
19306
- if (!(event.target instanceof HTMLElement)) {
19307
- return;
19308
- }
19309
- _this.dragHandle = event.target;
19310
- _this.setCursor(_this.dragHandle.style.cursor);
19374
+ _this.onMouseDown = function (event) {
19375
+ if (!(event.target instanceof HTMLElement)) {
19376
+ return;
19377
+ }
19378
+ _this.dragHandle = event.target;
19379
+ _this.setCursor(_this.dragHandle.style.cursor);
19311
19380
 
19312
- if (!_this.formatter.currentSpec) {
19313
- return;
19314
- }
19381
+ if (!_this.formatter.currentSpec) {
19382
+ return;
19383
+ }
19315
19384
 
19316
- var target = _this.formatter.currentSpec.getTargetElement();
19317
- if (!target) {
19318
- return;
19319
- }
19385
+ var target = _this.formatter.currentSpec.getTargetElement();
19386
+ if (!target) {
19387
+ return;
19388
+ }
19320
19389
 
19321
- var rect = target.getBoundingClientRect();
19390
+ var rect = target.getBoundingClientRect();
19322
19391
 
19323
- _this.dragStartX = event.clientX;
19324
- _this.preDragWidth = rect.width;
19325
- _this.targetRatio = rect.height / rect.width;
19392
+ _this.dragStartX = event.clientX;
19393
+ _this.preDragWidth = rect.width;
19394
+ _this.targetRatio = rect.height / rect.width;
19326
19395
 
19327
- document.addEventListener('mousemove', _this.onDrag);
19328
- document.addEventListener('mouseup', _this.onMouseUp);
19329
- };
19396
+ document.addEventListener('mousemove', _this.onDrag);
19397
+ document.addEventListener('mouseup', _this.onMouseUp);
19398
+ };
19330
19399
 
19331
- _this.onDrag = function (event) {
19332
- if (!_this.formatter.currentSpec) {
19333
- return;
19334
- }
19400
+ _this.onDrag = function (event) {
19401
+ if (!_this.formatter.currentSpec) {
19402
+ return;
19403
+ }
19335
19404
 
19336
- var target = _this.formatter.currentSpec.getTargetElement();
19337
- if (!target) {
19338
- return;
19339
- }
19405
+ var target = _this.formatter.currentSpec.getTargetElement();
19406
+ if (!target) {
19407
+ return;
19408
+ }
19340
19409
 
19341
- var deltaX = event.clientX - _this.dragStartX;
19342
- var newWidth = 0;
19410
+ var deltaX = event.clientX - _this.dragStartX;
19411
+ var newWidth = 0;
19343
19412
 
19344
- if (_this.dragHandle === _this.topLeftHandle || _this.dragHandle === _this.bottomLeftHandle) {
19345
- newWidth = Math.round(_this.preDragWidth - deltaX);
19346
- } else {
19347
- newWidth = Math.round(_this.preDragWidth + deltaX);
19348
- }
19413
+ if (_this.dragHandle === _this.topLeftHandle || _this.dragHandle === _this.bottomLeftHandle) {
19414
+ newWidth = Math.round(_this.preDragWidth - deltaX);
19415
+ } else {
19416
+ newWidth = Math.round(_this.preDragWidth + deltaX);
19417
+ }
19349
19418
 
19350
- var newHeight = _this.targetRatio * newWidth;
19419
+ var newHeight = _this.targetRatio * newWidth;
19351
19420
 
19352
- target.setAttribute('width', '' + newWidth);
19353
- target.setAttribute('height', '' + newHeight);
19421
+ target.setAttribute('width', '' + newWidth);
19422
+ target.setAttribute('height', '' + newHeight);
19354
19423
 
19355
- _this.formatter.update();
19356
- };
19424
+ _this.formatter.update();
19425
+ };
19357
19426
 
19358
- _this.onMouseUp = function () {
19359
- _this.setCursor('');
19360
- document.removeEventListener('mousemove', _this.onDrag);
19361
- document.removeEventListener('mouseup', _this.onMouseUp);
19362
- };
19427
+ _this.onMouseUp = function () {
19428
+ _this.setCursor('');
19429
+ document.removeEventListener('mousemove', _this.onDrag);
19430
+ document.removeEventListener('mouseup', _this.onMouseUp);
19431
+ };
19363
19432
 
19364
- _this.topLeftHandle = _this.createHandle('top-left', 'nwse-resize');
19365
- _this.topRightHandle = _this.createHandle('top-right', 'nesw-resize');
19366
- _this.bottomRightHandle = _this.createHandle('bottom-right', 'nwse-resize');
19367
- _this.bottomLeftHandle = _this.createHandle('bottom-left', 'nesw-resize');
19368
- _this.dragHandle = null;
19369
- _this.dragStartX = 0;
19370
- _this.preDragWidth = 0;
19371
- _this.targetRatio = 0;
19372
- return _this;
19373
- }
19433
+ _this.topLeftHandle = _this.createHandle('top-left', 'nwse-resize');
19434
+ _this.topRightHandle = _this.createHandle('top-right', 'nesw-resize');
19435
+ _this.bottomRightHandle = _this.createHandle('bottom-right', 'nwse-resize');
19436
+ _this.bottomLeftHandle = _this.createHandle('bottom-left', 'nesw-resize');
19437
+ _this.dragHandle = null;
19438
+ _this.dragStartX = 0;
19439
+ _this.preDragWidth = 0;
19440
+ _this.targetRatio = 0;
19441
+ return _this;
19442
+ }
19374
19443
 
19375
- _createClass(ResizeAction, [{
19376
- key: 'onCreate',
19377
- value: function onCreate() {
19378
- this.formatter.overlay.appendChild(this.topLeftHandle);
19379
- this.formatter.overlay.appendChild(this.topRightHandle);
19380
- this.formatter.overlay.appendChild(this.bottomRightHandle);
19381
- this.formatter.overlay.appendChild(this.bottomLeftHandle);
19444
+ _createClass(ResizeAction, [{
19445
+ key: 'onCreate',
19446
+ value: function onCreate() {
19447
+ this.formatter.overlay.appendChild(this.topLeftHandle);
19448
+ this.formatter.overlay.appendChild(this.topRightHandle);
19449
+ this.formatter.overlay.appendChild(this.bottomRightHandle);
19450
+ this.formatter.overlay.appendChild(this.bottomLeftHandle);
19382
19451
 
19383
- this.repositionHandles(this.formatter.options.resize.handleStyle);
19384
- }
19385
- }, {
19386
- key: 'onDestroy',
19387
- value: function onDestroy() {
19388
- this.setCursor('');
19389
- this.formatter.overlay.removeChild(this.topLeftHandle);
19390
- this.formatter.overlay.removeChild(this.topRightHandle);
19391
- this.formatter.overlay.removeChild(this.bottomRightHandle);
19392
- this.formatter.overlay.removeChild(this.bottomLeftHandle);
19393
- }
19394
- }, {
19395
- key: 'createHandle',
19396
- value: function createHandle(position, cursor) {
19397
- var box = document.createElement('div');
19398
- box.classList.add(this.formatter.options.resize.handleClassName);
19399
- box.setAttribute('data-position', position);
19400
- box.style.cursor = cursor;
19401
-
19402
- if (this.formatter.options.resize.handleStyle) {
19403
- Object.assign(box.style, this.formatter.options.resize.handleStyle);
19404
- }
19452
+ this.repositionHandles(this.formatter.options.resize.handleStyle);
19453
+ }
19454
+ }, {
19455
+ key: 'onDestroy',
19456
+ value: function onDestroy() {
19457
+ this.setCursor('');
19458
+ this.formatter.overlay.removeChild(this.topLeftHandle);
19459
+ this.formatter.overlay.removeChild(this.topRightHandle);
19460
+ this.formatter.overlay.removeChild(this.bottomRightHandle);
19461
+ this.formatter.overlay.removeChild(this.bottomLeftHandle);
19462
+ }
19463
+ }, {
19464
+ key: 'createHandle',
19465
+ value: function createHandle(position, cursor) {
19466
+ var box = document.createElement('div');
19467
+ box.classList.add(this.formatter.options.resize.handleClassName);
19468
+ box.setAttribute('data-position', position);
19469
+ box.style.cursor = cursor;
19470
+
19471
+ if (this.formatter.options.resize.handleStyle) {
19472
+ Object.assign(box.style, this.formatter.options.resize.handleStyle);
19473
+ }
19405
19474
 
19406
- box.addEventListener('mousedown', this.onMouseDown);
19475
+ box.addEventListener('mousedown', this.onMouseDown);
19407
19476
 
19408
- return box;
19409
- }
19410
- }, {
19411
- key: 'repositionHandles',
19412
- value: function repositionHandles(handleStyle) {
19413
- var handleXOffset = '0px';
19414
- var handleYOffset = '0px';
19415
- if (handleStyle) {
19416
- if (handleStyle.width) {
19417
- handleXOffset = -parseFloat(handleStyle.width) / 2 + 'px';
19418
- }
19419
- if (handleStyle.height) {
19420
- handleYOffset = -parseFloat(handleStyle.height) / 2 + 'px';
19421
- }
19422
- }
19477
+ return box;
19478
+ }
19479
+ }, {
19480
+ key: 'repositionHandles',
19481
+ value: function repositionHandles(handleStyle) {
19482
+ var handleXOffset = '0px';
19483
+ var handleYOffset = '0px';
19484
+ if (handleStyle) {
19485
+ if (handleStyle.width) {
19486
+ handleXOffset = -parseFloat(handleStyle.width) / 2 + 'px';
19487
+ }
19488
+ if (handleStyle.height) {
19489
+ handleYOffset = -parseFloat(handleStyle.height) / 2 + 'px';
19490
+ }
19491
+ }
19423
19492
 
19424
- Object.assign(this.topLeftHandle.style, { left: handleXOffset, top: handleYOffset });
19425
- Object.assign(this.topRightHandle.style, { right: handleXOffset, top: handleYOffset });
19426
- Object.assign(this.bottomRightHandle.style, { right: handleXOffset, bottom: handleYOffset });
19427
- Object.assign(this.bottomLeftHandle.style, { left: handleXOffset, bottom: handleYOffset });
19428
- }
19429
- }, {
19430
- key: 'setCursor',
19431
- value: function setCursor(value) {
19432
- if (document.body) {
19433
- document.body.style.cursor = value;
19434
- }
19493
+ Object.assign(this.topLeftHandle.style, { left: handleXOffset, top: handleYOffset });
19494
+ Object.assign(this.topRightHandle.style, { right: handleXOffset, top: handleYOffset });
19495
+ Object.assign(this.bottomRightHandle.style, { right: handleXOffset, bottom: handleYOffset });
19496
+ Object.assign(this.bottomLeftHandle.style, { left: handleXOffset, bottom: handleYOffset });
19497
+ }
19498
+ }, {
19499
+ key: 'setCursor',
19500
+ value: function setCursor(value) {
19501
+ if (document.body) {
19502
+ document.body.style.cursor = value;
19503
+ }
19435
19504
 
19436
- if (this.formatter.currentSpec) {
19437
- var target = this.formatter.currentSpec.getOverlayElement();
19438
- if (target) {
19439
- target.style.cursor = value;
19440
- }
19441
- }
19442
- }
19443
- }]);
19505
+ if (this.formatter.currentSpec) {
19506
+ var target = this.formatter.currentSpec.getOverlayElement();
19507
+ if (target) {
19508
+ target.style.cursor = value;
19509
+ }
19510
+ }
19511
+ }
19512
+ }]);
19444
19513
 
19445
- return ResizeAction;
19446
- }(_Action3.default);
19514
+ return ResizeAction;
19515
+ }(_Action3.default);
19447
19516
 
19448
- ResizeAction.default = ResizeAction$1;
19449
- return ResizeAction;
19450
- }
19517
+ ResizeAction$1.default = ResizeAction;
19451
19518
 
19452
19519
  var DeleteAction = {};
19453
19520
 
@@ -19554,7 +19621,7 @@
19554
19621
 
19555
19622
  var _AlignAction2 = _interopRequireDefault(_AlignAction);
19556
19623
 
19557
- var _ResizeAction = requireResizeAction();
19624
+ var _ResizeAction = ResizeAction$1;
19558
19625
 
19559
19626
  var _ResizeAction2 = _interopRequireDefault(_ResizeAction);
19560
19627
 
@@ -20047,7 +20114,7 @@
20047
20114
  }
20048
20115
  });
20049
20116
 
20050
- var _ResizeAction = requireResizeAction();
20117
+ var _ResizeAction = ResizeAction$1;
20051
20118
 
20052
20119
  Object.defineProperty(exports, 'ResizeAction', {
20053
20120
  enumerable: true,
@@ -20114,7 +20181,7 @@
20114
20181
  console.warn('移除blotFormatter overlay时出错:', error);
20115
20182
  }
20116
20183
  };
20117
- const handleGlobalClick = (event) => {
20184
+ const handleBlotFormatterClick = (event) => {
20118
20185
  var _a;
20119
20186
  if (!editor.value)
20120
20187
  return;
@@ -20126,32 +20193,6 @@
20126
20193
  removeQuillBlotFormatter();
20127
20194
  }
20128
20195
  };
20129
- const handleGlobalKeyup = (event) => {
20130
- var _a;
20131
- if (event.keyCode !== 46 && event.keyCode !== 8)
20132
- return;
20133
- const blotFormatter = (_a = quillRef.value) === null || _a === void 0 ? void 0 : _a.getModule('blotFormatter');
20134
- if (!blotFormatter || !blotFormatter.currentSpec)
20135
- return;
20136
- const target = event.target;
20137
- if (!editor.value || !editor.value.contains(target)) {
20138
- event.stopImmediatePropagation();
20139
- event.preventDefault();
20140
- return;
20141
- }
20142
- const allEditors = document.querySelectorAll('.quill-editor-container');
20143
- allEditors.forEach(editorElement => {
20144
- if (editorElement !== editor.value) {
20145
- const otherQuill = editorElement.__quill;
20146
- if (otherQuill && otherQuill !== quillRef.value) {
20147
- const otherBlotFormatter = otherQuill.getModule('blotFormatter');
20148
- if (otherBlotFormatter && otherBlotFormatter.currentSpec) {
20149
- otherBlotFormatter.hide();
20150
- }
20151
- }
20152
- }
20153
- });
20154
- };
20155
20196
  const configureBlotFormatter = () => {
20156
20197
  if (!quillRef.value)
20157
20198
  return;
@@ -20216,13 +20257,7 @@
20216
20257
  blotFormatter: {}
20217
20258
  };
20218
20259
  };
20219
- vue.onMounted(() => {
20220
- window.addEventListener('click', handleGlobalClick, true);
20221
- window.addEventListener('keyup', handleGlobalKeyup, true);
20222
- });
20223
20260
  vue.onBeforeUnmount(() => {
20224
- window.removeEventListener('click', handleGlobalClick, true);
20225
- window.removeEventListener('keyup', handleGlobalKeyup, true);
20226
20261
  removeQuillBlotFormatter();
20227
20262
  });
20228
20263
  const setQuill = (quillInstance) => {
@@ -20231,9 +20266,7 @@
20231
20266
  return {
20232
20267
  quillRef,
20233
20268
  setQuill,
20234
- removeQuillBlotFormatter,
20235
- handleGlobalClick,
20236
- handleGlobalKeyup,
20269
+ handleBlotFormatterClick,
20237
20270
  configureBlotFormatter,
20238
20271
  applyImageStyle,
20239
20272
  registerBlotFormatter,
@@ -20241,6 +20274,99 @@
20241
20274
  };
20242
20275
  }
20243
20276
 
20277
+ function useLinkClick(editor, initialHandleCustomLink) {
20278
+ const quillRef = vue.ref(null);
20279
+ const handleCustomLinkRef = vue.ref(initialHandleCustomLink || null);
20280
+ const handleLinkClick = (event) => {
20281
+ if (!quillRef.value || !handleCustomLinkRef.value)
20282
+ return;
20283
+ const target = event.target;
20284
+ if (target.tagName === 'A') {
20285
+ event.preventDefault();
20286
+ event.stopPropagation();
20287
+ try {
20288
+ const linkElement = target;
20289
+ const linkUrl = linkElement.getAttribute('href') || '';
20290
+ const linkText = linkElement.textContent || '';
20291
+ const range = quillRef.value.getSelection();
20292
+ if (range) {
20293
+ const [blot] = quillRef.value.getLeaf(range.index);
20294
+ if (blot && blot.parent && blot.parent.domNode.tagName === 'A') {
20295
+ const linkBlot = blot.parent;
20296
+ const linkIndex = quillRef.value.getIndex(linkBlot);
20297
+ const linkLength = linkBlot.length();
20298
+ quillRef.value.setSelection(linkIndex, linkLength);
20299
+ handleCustomLinkRef.value(true, { url: linkUrl, text: linkText });
20300
+ }
20301
+ }
20302
+ }
20303
+ catch (error) {
20304
+ console.warn('选中链接失败:', error);
20305
+ }
20306
+ }
20307
+ };
20308
+ const addLinkClickListener = () => {
20309
+ if (!quillRef.value)
20310
+ return;
20311
+ vue.nextTick(() => {
20312
+ var _a;
20313
+ const editorElement = (_a = editor.value) === null || _a === void 0 ? void 0 : _a.querySelector('.ql-editor');
20314
+ if (editorElement) {
20315
+ editorElement.removeEventListener('click', handleLinkClick);
20316
+ editorElement.addEventListener('click', handleLinkClick);
20317
+ }
20318
+ });
20319
+ };
20320
+ const setQuill = (quillInstance) => {
20321
+ quillRef.value = quillInstance;
20322
+ };
20323
+ const setHandleCustomLink = (fn) => {
20324
+ handleCustomLinkRef.value = fn;
20325
+ };
20326
+ return {
20327
+ quillRef,
20328
+ setQuill,
20329
+ setHandleCustomLink,
20330
+ handleLinkClick,
20331
+ addLinkClickListener
20332
+ };
20333
+ }
20334
+
20335
+ function useGlobalClick() {
20336
+ const clickHandlers = vue.ref([]);
20337
+ const handleGlobalClick = (event) => {
20338
+ clickHandlers.value.forEach(handler => {
20339
+ try {
20340
+ handler(event);
20341
+ }
20342
+ catch (error) {
20343
+ console.warn('全局点击事件处理函数执行出错:', error);
20344
+ }
20345
+ });
20346
+ };
20347
+ const addClickHandler = (handler) => {
20348
+ if (typeof handler === 'function' && !clickHandlers.value.includes(handler)) {
20349
+ clickHandlers.value.push(handler);
20350
+ }
20351
+ };
20352
+ const clearClickHandlers = () => {
20353
+ clickHandlers.value = [];
20354
+ };
20355
+ vue.onMounted(() => {
20356
+ window.addEventListener('click', handleGlobalClick);
20357
+ });
20358
+ vue.onBeforeUnmount(() => {
20359
+ window.removeEventListener('click', handleGlobalClick);
20360
+ clearClickHandlers();
20361
+ });
20362
+ return {
20363
+ clickHandlers: clickHandlers.value,
20364
+ addClickHandler,
20365
+ clearClickHandlers,
20366
+ handleGlobalClick
20367
+ };
20368
+ }
20369
+
20244
20370
  const boldSVG = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="18" height="18" viewBox="0 0 18 18"><g><g style="opacity:0;"><rect x="0" y="0" width="18" height="18" rx="0" fill="#FFFFFF" fill-opacity="1"/></g><g><path d="M6.794999938146972,7.7800002288818355L9.045000038146974,7.7800002288818355Q9.855000038146972,7.7800002288818355,10.230000038146972,7.442500128881836Q10.605000038146972,7.105000028881836,10.605000038146972,6.505000128881836Q10.605000038146972,6.114999728881836,10.440000038146973,5.860000628881836Q10.275000138146972,5.6050005288818365,9.929999838146973,5.470000228881836Q9.585000038146973,5.335000028881836,9.045000038146974,5.335000028881836L7.139999938146973,5.335000028881836L7.139999938146973,3.385000228881836L9.045000038146974,3.385000228881836Q10.034999838146973,3.385000228881836,10.852499938146973,3.797500608881836Q11.670000038146974,4.2100000388818355,12.142499938146972,4.922500628881836Q12.614999738146974,5.635000228881836,12.614999738146974,6.505000128881836Q12.614999738146974,7.375000028881836,12.142499938146972,8.042500028881836Q11.670000038146974,8.710000028881836,10.860000138146972,9.070000128881837Q10.050000238146973,9.430000328881835,9.045000038146974,9.430000328881835L6.794999938146972,9.430000328881835L6.794999938146972,7.7800002288818355ZM7.139999938146973,12.550000228881835L9.329999938146972,12.550000228881835Q9.900000138146972,12.550000228881835,10.327499838146974,12.354999528881836Q10.755000138146972,12.159999828881835,10.987500238146973,11.807499928881835Q11.219999838146972,11.454999928881836,11.219999838146972,11.020000428881836Q11.219999838146972,10.600000428881836,10.987500238146973,10.232500028881836Q10.755000138146972,9.864999728881836,10.327499838146974,9.647500028881836Q9.900000138146972,9.430000328881835,9.329999938146972,9.430000328881835L6.975000038146972,9.430000328881835L6.975000038146972,7.7800002288818355L9.329999938146972,7.7800002288818355Q10.349999938146972,7.7800002288818355,11.250000038146972,8.200000328881835Q12.149999638146973,8.620000328881837,12.690000538146972,9.362500228881835Q13.229999538146973,10.104999528881836,13.229999538146973,11.034999828881837Q13.229999538146973,11.949999828881836,12.690000538146972,12.752500528881836Q12.149999638146973,13.555000228881836,11.250000038146972,14.027500228881836Q10.349999938146972,14.500000228881836,9.329999938146972,14.500000228881836L7.139999938146973,14.500000228881836L7.139999938146973,12.550000228881835ZM7.064999938146973,14.500000228881836Q6.284999968146972,14.500000228881836,5.872500058146973,14.095000228881837Q5.460000038146973,13.689999228881836,5.460000038146973,12.895000428881836L5.460000038146973,4.989999728881836Q5.460000038146973,4.195000648881836,5.872500058146973,3.789999958881836Q6.284999968146972,3.385000228881836,7.064999938146973,3.385000228881836L7.469999838146973,3.385000228881836L7.469999838146973,14.500000228881836L7.064999938146973,14.500000228881836Z" fill="#555555" fill-opacity="1"/></g></g></svg>`;
20245
20371
  const italicSVG = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="18" height="18" viewBox="0 0 18 18"><g><g style="opacity:0;"><rect x="0" y="0" width="18" height="18" rx="0" fill="#FFFFFF" fill-opacity="1"/></g><g><path d="M8,3Q7.9015086,3,7.8049095,3.019214718Q7.7083106,3.038429435,7.6173165,3.076120459Q7.5263224,3.11381148,7.4444296,3.16853037Q7.3625371,3.2232492600000002,7.2928932,3.2928932Q7.2232492,3.36253715,7.1685302,3.4444297600000002Q7.1138113999999995,3.52632231,7.0761204,3.61731648Q7.0384293,3.70831072,7.0192146,3.80490965Q6.99999994,3.90150857,7,4Q6.99999994,4.0984913,7.0192146,4.1950902Q7.0384293,4.291689,7.0761204,4.3826833Q7.1138113999999995,4.4736774,7.1685302,4.5555699Q7.2232492,4.6374626,7.2928932,4.7071065999999995Q7.3625371,4.7767504,7.4444296,4.8314693Q7.5263224,4.8861883,7.6173165,4.9238794Q7.7083106,4.9615704,7.8049096,4.9807851Q7.9015086,4.9999999,8,5L9.137146,5L8,13L7,13Q6.90150857,13,6.80490965,13.019215Q6.70831072,13.038429,6.6173164799999995,13.07612Q6.52632231,13.113811,6.44442973,13.16853Q6.36253715,13.223249,6.2928932,13.292892Q6.22324926,13.362536,6.16853037,13.444429Q6.11381148,13.526321,6.076120459,13.617315Q6.038429435,13.708309,6.019214718,13.804909Q6,13.901508,6,14Q6,14.098491,6.019214718,14.195089Q6.038429435,14.291689,6.076120459,14.382683Q6.11381148,14.473677,6.16853037,14.555569Q6.22324926,14.637462,6.2928932,14.707106Q6.36253715,14.77675,6.44442976,14.831469Q6.52632231,14.886187,6.6173164799999995,14.923878Q6.70831072,14.961569,6.80490965,14.980784Q6.90150857,15,7,15L11,15Q11.0984912,15,11.1950898,14.980784Q11.2916889,14.961569,11.382682800000001,14.923878Q11.473677200000001,14.886187,11.5555696,14.831469Q11.6374626,14.77675,11.7071066,14.707106Q11.7767506,14.637462,11.8314691,14.555569Q11.8861876,14.473677,11.9238791,14.382683Q11.9615698,14.291689,11.9807849,14.195089Q12,14.098491,12,14Q12,13.901508,11.9807849,13.804909Q11.9615698,13.708309,11.9238791,13.617315Q11.8861876,13.526321,11.8314691,13.444428Q11.7767506,13.362536,11.7071066,13.292892Q11.6374626,13.223249,11.5555701,13.16853Q11.473677200000001,13.113811,11.382682800000001,13.07612Q11.2916889,13.038429,11.1950903,13.019215Q11.0984912,13,11,13L9.8626451,13L11,5L12,5Q12.0984907,4.9999999,12.1950893,4.9807851Q12.2916884,4.9615703,12.382682800000001,4.9238793Q12.4736767,4.8861883,12.5555696,4.8314693Q12.6374621,4.7767504,12.7071061,4.7071065999999995Q12.776750100000001,4.6374626,12.831468600000001,4.5555699Q12.8861876,4.4736774,12.9238787,4.3826833Q12.9615698,4.291689,12.9807849,4.1950902Q12.999999500000001,4.0984913,13,4Q12.999999500000001,3.90150857,12.980784400000001,3.80490965Q12.9615698,3.70831072,12.9238787,3.61731648Q12.8861876,3.52632231,12.8314691,3.44442973Q12.7767506,3.36253715,12.7071066,3.2928932Q12.6374626,3.2232492600000002,12.5555696,3.16853037Q12.4736767,3.11381148,12.382682800000001,3.076120459Q12.2916884,3.038429435,12.1950898,3.019214718Q12.0984907,3,12,3L8,3Z" fill-rule="evenodd" fill="#555555" fill-opacity="1"/></g></g></svg>`;
20246
20372
  const underlineSVG = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="18" height="18" viewBox="0 0 18 18"><g><g style="opacity:0;"><rect x="0" y="0" width="18" height="18" rx="0" fill="#FFFFFF" fill-opacity="1"/></g><g><path d="M5.000117301940918,14.500022450683593L5.000117301940918,14.500022450683593Q5.000117301940918,14.450777450683594,5.009724660740918,14.402477450683593Q5.019332019940918,14.354177450683594,5.038177530940918,14.308679450683593Q5.057023040940918,14.263182450683594,5.084382488940918,14.222236450683594Q5.111741931940918,14.181290450683594,5.146563901940918,14.146469450683593Q5.181385871940918,14.111646450683594,5.222332181940918,14.084286450683594Q5.263278451940918,14.056927450683594,5.308775541940918,14.038082450683595Q5.354272661940918,14.019237450683594,5.402572121940918,14.009630450683593Q5.450871581940918,14.000022450683593,5.500117301940918,14.000022450683593L12.500117301940918,14.000022450683593Q12.549362201940918,14.000022450683593,12.597661501940918,14.009629450683594Q12.645960801940918,14.019237450683594,12.691457701940918,14.038082450683595Q12.736954701940917,14.056926450683594,12.777901601940918,14.084285450683593Q12.818847701940918,14.111645450683593,12.853670101940917,14.146468450683594Q12.888492101940919,14.181289450683593,12.915851601940918,14.222235450683593Q12.943210601940919,14.263181450683593,12.962056201940918,14.308679450683593Q12.980901701940919,14.354177450683594,12.990509501940917,14.402477450683593Q13.00011680194092,14.450777450683594,13.000117301940918,14.500022450683593L13.000117301940918,14.500022450683593Q13.00011680194092,14.549268450683593,12.990509001940918,14.597566450683594Q12.980901701940919,14.645866450683593,12.962056201940918,14.691363450683594Q12.943210601940919,14.736860450683594,12.915851601940918,14.777807450683595Q12.888492101940919,14.818753450683595,12.853670101940917,14.853575450683593Q12.818847701940918,14.888397450683593,12.777901601940918,14.915756450683594Q12.736954701940917,14.943115450683594,12.691457701940918,14.961960450683593Q12.645960801940918,14.980806450683593,12.597661501940918,14.990413450683594Q12.549362201940918,15.000021450683594,12.500117301940918,15.000022450683593L5.500117301940918,15.000022450683593Q5.450871581940918,15.000021450683594,5.402572121940918,14.990414450683593Q5.354272661940918,14.980806450683593,5.308775541940918,14.961960450683593Q5.263278451940918,14.943115450683594,5.222332161940918,14.915756450683594Q5.181385871940918,14.888397450683593,5.146563901940918,14.853574450683594Q5.111741931940918,14.818752450683593,5.084382488940918,14.777806450683594Q5.057023040940918,14.736860450683594,5.038177530940918,14.691363450683594Q5.019332019940918,14.645866450683593,5.009724660740918,14.597567450683593Q5.000117301940918,14.549268450683593,5.000117301940918,14.500022450683593ZM5.045039176940918,3.548906330683594Q5.045039176940918,3.1015625006835936,5.283039211940918,2.8637809706835937Q5.521039131940918,2.6259994506835938,5.969039081940918,2.6259994506835938L5.997039201940918,2.6259994506835938Q6.445039201940918,2.6259994506835938,6.6830393019409176,2.8637809706835937Q6.921039201940918,3.1015625006835936,6.921039201940918,3.548906330683594L6.921039201940918,9.010000250683593Q6.921039201940918,9.737999950683594,7.180039401940919,10.255999550683594Q7.439039201940918,10.774000150683595,7.908039101940918,11.053999950683593Q8.377039001940918,11.333999650683594,8.993039101940917,11.333999650683594Q9.609039301940918,11.333999650683594,10.085039101940918,11.060999850683594Q10.561039401940917,10.788000150683594,10.820039301940918,10.263000450683593Q11.079039101940918,9.737999950683594,11.079039101940918,9.010000250683593L11.079039101940918,3.548906330683594Q11.079039101940918,3.1015625006835936,11.317039501940918,2.8637809706835937Q11.555039401940917,2.6259994506835938,12.003039401940917,2.6259994506835938L12.031039201940917,2.6259994506835938Q12.479039201940918,2.6259994506835938,12.717039101940918,2.8637809706835937Q12.955039001940918,3.1015625006835936,12.955039001940918,3.548906330683594L12.955039001940918,9.010000250683593Q12.955039001940918,10.144000050683594,12.416039501940919,11.095999750683594Q11.877039901940918,12.048000350683594,10.967039101940918,12.600999850683595Q10.057039301940918,13.154000450683593,8.993039101940917,13.154000450683593Q7.929039001940918,13.154000450683593,7.0190392019409185,12.600999850683595Q6.109039201940918,12.048000350683594,5.577039361940918,11.095999750683594Q5.045039176940918,10.144000050683594,5.045039176940918,9.010000250683593L5.045039176940918,3.548906330683594Z" fill="#555555" fill-opacity="1"/></g></g></svg>`;
@@ -20334,14 +20460,15 @@
20334
20460
  const showMoreToolbar = vue.ref(false);
20335
20461
  const canUndo = vue.ref(false);
20336
20462
  const canRedo = vue.ref(false);
20337
- const { setQuill, removeQuillBlotFormatter, configureBlotFormatter, applyImageStyle, registerBlotFormatter, getBlotFormatterConfig } = useBlotFormatter(editor, props.enableImageResize);
20338
- vue.onMounted(() => {
20339
- initialize();
20340
- });
20341
- vue.onBeforeUnmount(() => {
20342
- removeQuillBlotFormatter();
20343
- quill = null;
20344
- });
20463
+ const showLinkDialog = vue.ref(false);
20464
+ const linkUrl = vue.ref('');
20465
+ const linkText = vue.ref('');
20466
+ const canUseLink = vue.ref(false);
20467
+ const linkPosition = vue.ref({ top: 0, left: 0 });
20468
+ const savedRange = vue.ref(null);
20469
+ const { setQuill, handleBlotFormatterClick, configureBlotFormatter, applyImageStyle, registerBlotFormatter, getBlotFormatterConfig } = useBlotFormatter(editor, props.enableImageResize);
20470
+ const { setQuill: setLinkQuill, setHandleCustomLink, addLinkClickListener } = useLinkClick(editor);
20471
+ const { addClickHandler } = useGlobalClick();
20345
20472
  let quill;
20346
20473
  let options;
20347
20474
  const editorWrapClass = vue.computed(() => {
@@ -20379,6 +20506,7 @@
20379
20506
  icons['underline'] = underlineSVG;
20380
20507
  icons['more'] = moreSVG;
20381
20508
  icons['link'] = linkSVG;
20509
+ icons['customLink'] = linkSVG;
20382
20510
  icons['undo'] = undoSVG;
20383
20511
  icons['redo'] = redoSVG;
20384
20512
  icons['ocr'] = ocrSVG;
@@ -20408,6 +20536,7 @@
20408
20536
  if (toolbar) {
20409
20537
  const undoBtn = toolbar.querySelector('.ql-undo');
20410
20538
  const redoBtn = toolbar.querySelector('.ql-redo');
20539
+ const customLinkBtn = toolbar.querySelector('.ql-customLink');
20411
20540
  if (undoBtn) {
20412
20541
  if (canUndo.value) {
20413
20542
  undoBtn.classList.remove('ql-disabled');
@@ -20426,49 +20555,17 @@
20426
20555
  }
20427
20556
  redoBtn.disabled = !canRedo.value;
20428
20557
  }
20558
+ if (customLinkBtn) {
20559
+ if (canUseLink.value) {
20560
+ customLinkBtn.classList.remove('ql-disabled');
20561
+ }
20562
+ else {
20563
+ customLinkBtn.classList.add('ql-disabled');
20564
+ }
20565
+ customLinkBtn.disabled = !canUseLink.value;
20566
+ }
20429
20567
  }
20430
20568
  };
20431
- const initialize = () => {
20432
- var _a, _b;
20433
- if (!editor.value)
20434
- return;
20435
- if (props.enableImageResize) {
20436
- registerBlotFormatter();
20437
- }
20438
- options = composeOptions();
20439
- setIcons();
20440
- quill = new Quill(editor.value, options);
20441
- setQuill(quill);
20442
- const toolbar = (_a = quill === null || quill === void 0 ? void 0 : quill.getModule('toolbar')) === null || _a === void 0 ? void 0 : _a.container;
20443
- if (toolbar) {
20444
- toolbar.style.display = 'none';
20445
- }
20446
- setContents(props.content);
20447
- quill.on('text-change', handleTextChange);
20448
- quill.on('selection-change', handleSelectionChange);
20449
- quill.on('editor-change', handleEditorChange);
20450
- quill.on('text-change', updateHistoryState);
20451
- quill.on('selection-change', updateHistoryState);
20452
- updateHistoryState();
20453
- const toolbarDom = (_b = quill.getModule('toolbar')) === null || _b === void 0 ? void 0 : _b.container;
20454
- toolbarDom.addEventListener('mousedown', (e) => {
20455
- e.preventDefault();
20456
- });
20457
- const tooltipInput = toolbarDom.querySelector('.ql-tooltip input');
20458
- if (tooltipInput) {
20459
- vue.nextTick(() => {
20460
- tooltipInput.setAttribute('placeholder', props.placeholder);
20461
- });
20462
- }
20463
- if (!props.needCollapse && props.toolbarStyle) {
20464
- applyToolbarStyle();
20465
- }
20466
- applyEditorStyle();
20467
- if (props.enableImageResize) {
20468
- configureBlotFormatter();
20469
- }
20470
- ctx.emit('ready', quill);
20471
- };
20472
20569
  const composeOptions = () => {
20473
20570
  const clientOptions = {};
20474
20571
  clientOptions.theme = 'snow';
@@ -20488,6 +20585,11 @@
20488
20585
  ...toolbarOptions.full,
20489
20586
  ],
20490
20587
  handlers: {
20588
+ customLink: function () {
20589
+ if (canUseLink.value) {
20590
+ handleCustomLink(true);
20591
+ }
20592
+ },
20491
20593
  redo: function () {
20492
20594
  var _a;
20493
20595
  if (canRedo.value) {
@@ -20565,22 +20667,22 @@
20565
20667
  preview.setAttribute('href', 'javascript:void(0)');
20566
20668
  preview.setAttribute('target', '_self');
20567
20669
  };
20670
+ const controlToolbarVisible = (visible) => {
20671
+ var _a;
20672
+ const toolbar = (_a = quill === null || quill === void 0 ? void 0 : quill.getModule('toolbar')) === null || _a === void 0 ? void 0 : _a.container;
20673
+ if (toolbar) {
20674
+ toolbar.style.display = visible ? 'block' : 'none';
20675
+ props.needCollapse && (showMoreToolbar.value = false);
20676
+ ctx.emit('toolbarVisibleChange', visible);
20677
+ }
20678
+ };
20568
20679
  const isEditorFocus = vue.ref();
20569
20680
  const handleSelectionChange = (range, oldRange, source) => {
20570
- var _a;
20571
20681
  observeTooltip();
20572
20682
  isEditorFocus.value = !!(quill === null || quill === void 0 ? void 0 : quill.hasFocus());
20573
- const toolbar = (_a = quill === null || quill === void 0 ? void 0 : quill.getModule('toolbar')) === null || _a === void 0 ? void 0 : _a.container;
20574
- if (toolbar) {
20575
- if (isEditorFocus.value) {
20576
- toolbar.style.display = 'block';
20577
- ctx.emit('toolbarVisibleChange', true);
20578
- }
20579
- else {
20580
- toolbar.style.display = 'none';
20581
- showMoreToolbar.value = false;
20582
- ctx.emit('toolbarVisibleChange', true);
20583
- }
20683
+ canUseLink.value = !!(range && range.length > 0);
20684
+ if (isEditorFocus.value) {
20685
+ controlToolbarVisible(true);
20584
20686
  }
20585
20687
  ctx.emit('selectionChange', { range, oldRange, source });
20586
20688
  };
@@ -20679,14 +20781,6 @@
20679
20781
  const focus = () => {
20680
20782
  quill === null || quill === void 0 ? void 0 : quill.focus();
20681
20783
  };
20682
- const reinit = () => {
20683
- vue.nextTick(() => {
20684
- var _a;
20685
- if (!ctx.slots.toolbar && quill)
20686
- (_a = quill.getModule('toolbar')) === null || _a === void 0 ? void 0 : _a.container.remove();
20687
- initialize();
20688
- });
20689
- };
20690
20784
  const moreToolbarToolClick = (tool) => {
20691
20785
  var _a, _b;
20692
20786
  if (!quill)
@@ -20710,6 +20804,79 @@
20710
20804
  else if (tool === 'more') {
20711
20805
  showMoreToolbar.value = !showMoreToolbar.value;
20712
20806
  }
20807
+ else if (tool === 'customLink') {
20808
+ handleCustomLink(true);
20809
+ }
20810
+ };
20811
+ const calculateSelectionPosition = (range) => {
20812
+ if (!quill)
20813
+ return { top: 0, left: 0 };
20814
+ const selectionRange = range || quill.getSelection();
20815
+ if (!selectionRange || selectionRange.length === 0)
20816
+ return { top: 0, left: 0 };
20817
+ try {
20818
+ const bounds = quill.getBounds(selectionRange.index, selectionRange.length);
20819
+ return {
20820
+ top: bounds.top + bounds.height + 5,
20821
+ left: bounds.left
20822
+ };
20823
+ }
20824
+ catch (error) {
20825
+ console.warn('计算选中位置时出错:', error);
20826
+ return { top: 0, left: 0 };
20827
+ }
20828
+ };
20829
+ const handleCustomLink = (bool, linkInfo) => {
20830
+ if (!quill)
20831
+ return;
20832
+ if (bool) {
20833
+ controlToolbarVisible(false);
20834
+ if (linkInfo) {
20835
+ linkUrl.value = linkInfo.url;
20836
+ linkText.value = linkInfo.text;
20837
+ const range = quill.getSelection();
20838
+ savedRange.value = range ? { ...range } : null;
20839
+ }
20840
+ else {
20841
+ const range = quill.getSelection();
20842
+ if (range && range.length > 0) {
20843
+ savedRange.value = { ...range };
20844
+ const selectedText = quill.getText(range.index, range.length);
20845
+ linkText.value = selectedText;
20846
+ }
20847
+ else {
20848
+ savedRange.value = range ? { ...range } : null;
20849
+ linkText.value = '';
20850
+ }
20851
+ }
20852
+ const range = quill.getSelection();
20853
+ linkPosition.value = calculateSelectionPosition(range || undefined);
20854
+ }
20855
+ else {
20856
+ savedRange.value = null;
20857
+ }
20858
+ showLinkDialog.value = bool;
20859
+ };
20860
+ setHandleCustomLink(handleCustomLink);
20861
+ const saveLink = (data) => {
20862
+ console.log("data", data);
20863
+ if (!quill || !data.url.trim())
20864
+ return;
20865
+ const range = savedRange.value;
20866
+ if (!range)
20867
+ return;
20868
+ if (range.length > 0) {
20869
+ quill.formatText(range.index, range.length, 'link', data.url);
20870
+ }
20871
+ else {
20872
+ const text = data.text || data.url;
20873
+ quill.insertText(range.index, text, { link: data.url });
20874
+ quill.setSelection(range.index + text.length, 0);
20875
+ }
20876
+ showLinkDialog.value = false;
20877
+ linkUrl.value = '';
20878
+ linkText.value = '';
20879
+ savedRange.value = null;
20713
20880
  };
20714
20881
  vue.watch(() => props.content, (newContent) => {
20715
20882
  if (!quill || internalModelEquals(newContent))
@@ -20724,12 +20891,92 @@
20724
20891
  if (quill)
20725
20892
  quill.enable(newValue);
20726
20893
  });
20894
+ const initialize = () => {
20895
+ var _a;
20896
+ if (!editor.value)
20897
+ return;
20898
+ if (props.enableImageResize) {
20899
+ registerBlotFormatter();
20900
+ }
20901
+ options = composeOptions();
20902
+ setIcons();
20903
+ quill = new Quill(editor.value, options);
20904
+ setQuill(quill);
20905
+ setLinkQuill(quill);
20906
+ controlToolbarVisible(false);
20907
+ setContents(props.content);
20908
+ quill.on('text-change', handleTextChange);
20909
+ quill.on('selection-change', handleSelectionChange);
20910
+ quill.on('editor-change', handleEditorChange);
20911
+ quill.on('text-change', updateHistoryState);
20912
+ quill.on('selection-change', updateHistoryState);
20913
+ addLinkClickListener();
20914
+ const toolbarClickHandler = (event) => {
20915
+ const target = event.target;
20916
+ if (target.closest('.quill-editor-container')) {
20917
+ return;
20918
+ }
20919
+ controlToolbarVisible(false);
20920
+ };
20921
+ addClickHandler(toolbarClickHandler);
20922
+ addClickHandler(handleBlotFormatterClick);
20923
+ addClickHandler(() => {
20924
+ handleCustomLink(false);
20925
+ });
20926
+ updateHistoryState();
20927
+ const toolbarDom = (_a = quill.getModule('toolbar')) === null || _a === void 0 ? void 0 : _a.container;
20928
+ vue.nextTick(() => {
20929
+ const customLinkBtn = toolbarDom.querySelector('.ql-customLink');
20930
+ if (customLinkBtn) {
20931
+ customLinkBtn.addEventListener('click', (e) => {
20932
+ e.preventDefault();
20933
+ e.stopPropagation();
20934
+ if (canUseLink.value) {
20935
+ handleCustomLink(true);
20936
+ }
20937
+ });
20938
+ }
20939
+ });
20940
+ const tooltipInput = toolbarDom.querySelector('.ql-tooltip input');
20941
+ if (tooltipInput) {
20942
+ vue.nextTick(() => {
20943
+ tooltipInput.setAttribute('placeholder', props.placeholder);
20944
+ });
20945
+ }
20946
+ if (!props.needCollapse && props.toolbarStyle) {
20947
+ applyToolbarStyle();
20948
+ }
20949
+ applyEditorStyle();
20950
+ if (props.enableImageResize) {
20951
+ configureBlotFormatter();
20952
+ }
20953
+ ctx.emit('ready', quill);
20954
+ };
20955
+ const reinit = () => {
20956
+ vue.nextTick(() => {
20957
+ var _a;
20958
+ if (!ctx.slots.toolbar && quill)
20959
+ (_a = quill.getModule('toolbar')) === null || _a === void 0 ? void 0 : _a.container.remove();
20960
+ initialize();
20961
+ });
20962
+ };
20963
+ vue.onMounted(() => {
20964
+ initialize();
20965
+ });
20966
+ vue.onBeforeUnmount(() => {
20967
+ quill = null;
20968
+ });
20727
20969
  return {
20728
20970
  editor,
20729
20971
  editorWrapClass,
20730
20972
  showMoreToolbar,
20731
20973
  canUndo,
20732
20974
  canRedo,
20975
+ canUseLink,
20976
+ showLinkDialog,
20977
+ linkUrl,
20978
+ linkText,
20979
+ linkPosition,
20733
20980
  getEditor,
20734
20981
  getToolbar,
20735
20982
  getQuill,
@@ -20742,12 +20989,16 @@
20742
20989
  getText,
20743
20990
  setText,
20744
20991
  reinit,
20745
- moreToolbarToolClick
20992
+ moreToolbarToolClick,
20993
+ saveLink,
20994
+ handleCustomLink
20746
20995
  };
20747
20996
  },
20748
20997
  render() {
20749
20998
  return [
20750
- vue.h('div', { class: this.editorWrapClass }, [
20999
+ vue.h('div', {
21000
+ class: this.editorWrapClass
21001
+ }, [
20751
21002
  this.$props.needCollapse && this.$props.editorKey && vue.h(MoreToolbar, {
20752
21003
  editorKey: String(this.$props.editorKey),
20753
21004
  needCollapse: this.needCollapse,
@@ -20760,8 +21011,19 @@
20760
21011
  }
20761
21012
  }),
20762
21013
  vue.h('div', {
20763
- ref: 'editor', ...this.$attrs
21014
+ ref: 'editor',
21015
+ style: { position: 'relative' },
21016
+ ...this.$attrs
20764
21017
  }),
21018
+ vue.h(CustomLink, {
21019
+ visible: this.showLinkDialog,
21020
+ position: this.linkPosition,
21021
+ linkUrl: this.linkUrl,
21022
+ linkText: this.linkText,
21023
+ 'onUpdate:linkUrl': (value) => { this.linkUrl = value; },
21024
+ 'onUpdate:linkText': (value) => { this.linkText = value; },
21025
+ onSave: this.saveLink,
21026
+ })
20765
21027
  ]),
20766
21028
  ];
20767
21029
  },