pxx-vue-quill 1.0.161 → 1.0.163

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-15T01:45:46.446Z
10
+ * Date: 2025-09-15T03:56:15.666Z
11
11
  */
12
12
  (function (global, factory) {
13
13
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue')) :
@@ -20275,9 +20275,9 @@
20275
20275
  };
20276
20276
  }
20277
20277
 
20278
- function useCustomLinkClick(editor, initialHandleCustomLink) {
20278
+ function useCustomLink(editor) {
20279
20279
  const quillRef = vue.ref(null);
20280
- const handleCustomLinkRef = vue.ref(initialHandleCustomLink || null);
20280
+ const handleCustomLinkRef = vue.ref(null);
20281
20281
  const handleLinkClick = (event) => {
20282
20282
  if (!quillRef.value || !handleCustomLinkRef.value)
20283
20283
  return;
@@ -20324,12 +20324,43 @@
20324
20324
  const setHandleCustomLink = (fn) => {
20325
20325
  handleCustomLinkRef.value = fn;
20326
20326
  };
20327
+ const calculateSelectionPosition = (range) => {
20328
+ var _a;
20329
+ if (!quillRef.value)
20330
+ return { top: 0, left: 0 };
20331
+ const selectionRange = range || quillRef.value.getSelection();
20332
+ if (!selectionRange || selectionRange.length === 0)
20333
+ return { top: 0, left: 0 };
20334
+ try {
20335
+ const bounds = quillRef.value.getBounds(selectionRange.index, selectionRange.length);
20336
+ const editorElement = (_a = editor.value) === null || _a === void 0 ? void 0 : _a.querySelector('.ql-editor');
20337
+ const editorContainer = editorElement === null || editorElement === void 0 ? void 0 : editorElement.closest('.quill-editor-container');
20338
+ const editorWidth = editorContainer ? editorContainer.clientWidth : ((editorElement === null || editorElement === void 0 ? void 0 : editorElement.clientWidth) || 0);
20339
+ const customLinkWidth = 310;
20340
+ const maxLeft = editorWidth - customLinkWidth - 16;
20341
+ const left = Math.min(bounds.left, Math.max(0, maxLeft));
20342
+ const editorRect = editorElement === null || editorElement === void 0 ? void 0 : editorElement.getBoundingClientRect();
20343
+ const containerRect = editorContainer === null || editorContainer === void 0 ? void 0 : editorContainer.getBoundingClientRect();
20344
+ if (!editorRect || !containerRect) {
20345
+ return { top: bounds.top + bounds.height + 5, left: left };
20346
+ }
20347
+ const editorOffsetTop = editorRect.top - containerRect.top;
20348
+ const top = editorOffsetTop + bounds.top + bounds.height + 5;
20349
+ return {
20350
+ top: top,
20351
+ left: left
20352
+ };
20353
+ }
20354
+ catch (error) {
20355
+ console.warn('计算选中位置时出错:', error);
20356
+ return { top: 0, left: 0 };
20357
+ }
20358
+ };
20327
20359
  return {
20328
- quillRef,
20329
20360
  setQuill,
20330
20361
  setHandleCustomLink,
20331
- handleLinkClick,
20332
- addLinkClickListener
20362
+ addLinkClickListener,
20363
+ calculateSelectionPosition
20333
20364
  };
20334
20365
  }
20335
20366
 
@@ -20524,7 +20555,7 @@
20524
20555
  const { addClickHandler } = useGlobalClick(props.clickTargetSelector);
20525
20556
  const { isIPadBool, handleIPadNewline } = useIPadScene();
20526
20557
  const { setQuill, handleBlotFormatterClick, configureBlotFormatter, applyImageStyle, registerBlotFormatter, getBlotFormatterConfig } = useBlotFormatter(editor, props.enableImageResize);
20527
- const { setQuill: setLinkQuill, setHandleCustomLink, addLinkClickListener } = useCustomLinkClick(editor);
20558
+ const { setQuill: setLinkQuill, setHandleCustomLink, addLinkClickListener, calculateSelectionPosition } = useCustomLink(editor);
20528
20559
  vue.onMounted(() => {
20529
20560
  initialize();
20530
20561
  });
@@ -20864,8 +20895,8 @@
20864
20895
  vue.nextTick(() => {
20865
20896
  applyImageStyle();
20866
20897
  });
20867
- updateHistoryState();
20868
20898
  ctx.emit('textChange', { delta, oldContents, source });
20899
+ updateHistoryState();
20869
20900
  };
20870
20901
  const controlToolbarVisible = (visible) => {
20871
20902
  var _a;
@@ -20884,6 +20915,7 @@
20884
20915
  controlToolbarVisible(true);
20885
20916
  }
20886
20917
  ctx.emit('selectionChange', { range, oldRange, source });
20918
+ updateHistoryState();
20887
20919
  };
20888
20920
  vue.watch(isEditorFocus, (focus) => {
20889
20921
  if (focus)
@@ -20892,7 +20924,6 @@
20892
20924
  ctx.emit('blur', editor);
20893
20925
  });
20894
20926
  const handleEditorChange = (...args) => {
20895
- updateHistoryState();
20896
20927
  if (args[0] === 'text-change')
20897
20928
  ctx.emit('editorChange', {
20898
20929
  name: args[0],
@@ -20908,19 +20939,6 @@
20908
20939
  source: args[3],
20909
20940
  });
20910
20941
  };
20911
- const getEditor = () => {
20912
- return editor.value;
20913
- };
20914
- const getToolbar = () => {
20915
- var _a;
20916
- return (_a = quill === null || quill === void 0 ? void 0 : quill.getModule('toolbar')) === null || _a === void 0 ? void 0 : _a.container;
20917
- };
20918
- const getQuill = () => {
20919
- if (quill)
20920
- return quill;
20921
- else
20922
- throw `The quill editor hasn't been instantiated`;
20923
- };
20924
20942
  const getContents = (index, length) => {
20925
20943
  if (props.contentType === 'html') {
20926
20944
  return getHTML();
@@ -20931,20 +20949,14 @@
20931
20949
  return quill === null || quill === void 0 ? void 0 : quill.getContents(index, length);
20932
20950
  };
20933
20951
  const setContents = (content, source = 'api') => {
20952
+ var _a;
20934
20953
  const normalizedContent = !content
20935
20954
  ? props.contentType === 'delta'
20936
20955
  ? new Delta$1()
20937
20956
  : ''
20938
20957
  : content;
20939
20958
  if (props.contentType === 'html') {
20940
- if (!normalizedContent || normalizedContent === '') {
20941
- if (quill) {
20942
- quill.root.innerHTML = '';
20943
- }
20944
- }
20945
- else {
20946
- setHTML(normalizedContent);
20947
- }
20959
+ setHTML((_a = normalizedContent) !== null && _a !== void 0 ? _a : '');
20948
20960
  }
20949
20961
  else if (props.contentType === 'text') {
20950
20962
  setText(normalizedContent, source);
@@ -21024,38 +21036,6 @@
21024
21036
  handleCustomLink(true);
21025
21037
  }
21026
21038
  };
21027
- const calculateSelectionPosition = (range) => {
21028
- var _a;
21029
- if (!quill)
21030
- return { top: 0, left: 0 };
21031
- const selectionRange = range || quill.getSelection();
21032
- if (!selectionRange || selectionRange.length === 0)
21033
- return { top: 0, left: 0 };
21034
- try {
21035
- const bounds = quill.getBounds(selectionRange.index, selectionRange.length);
21036
- const editorElement = (_a = editor.value) === null || _a === void 0 ? void 0 : _a.querySelector('.ql-editor');
21037
- const editorContainer = editorElement === null || editorElement === void 0 ? void 0 : editorElement.closest('.quill-editor-container');
21038
- const editorWidth = editorContainer ? editorContainer.clientWidth : ((editorElement === null || editorElement === void 0 ? void 0 : editorElement.clientWidth) || 0);
21039
- const customLinkWidth = 310;
21040
- const maxLeft = editorWidth - customLinkWidth - 16;
21041
- const left = Math.min(bounds.left, Math.max(0, maxLeft));
21042
- const editorRect = editorElement === null || editorElement === void 0 ? void 0 : editorElement.getBoundingClientRect();
21043
- const containerRect = editorContainer === null || editorContainer === void 0 ? void 0 : editorContainer.getBoundingClientRect();
21044
- if (!editorRect || !containerRect) {
21045
- return { top: bounds.top + bounds.height + 5, left: left };
21046
- }
21047
- const editorOffsetTop = editorRect.top - containerRect.top;
21048
- const top = editorOffsetTop + bounds.top + bounds.height + 5;
21049
- return {
21050
- top: top,
21051
- left: left
21052
- };
21053
- }
21054
- catch (error) {
21055
- console.warn('计算选中位置时出错:', error);
21056
- return { top: 0, left: 0 };
21057
- }
21058
- };
21059
21039
  const handleCustomLink = (bool, linkInfo) => {
21060
21040
  if (!quill)
21061
21041
  return;
@@ -21148,9 +21128,6 @@
21148
21128
  linkUrl,
21149
21129
  linkText,
21150
21130
  linkPosition,
21151
- getEditor,
21152
- getToolbar,
21153
- getQuill,
21154
21131
  getContents,
21155
21132
  setContents,
21156
21133
  getHTML,