pxx-vue-quill 1.0.162 → 1.0.164

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:54:53.887Z
10
+ * Date: 2025-09-15T03:58:17.460Z
11
11
  */
12
12
  (function (global, factory) {
13
13
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue')) :
@@ -20283,9 +20283,9 @@
20283
20283
  };
20284
20284
  }
20285
20285
 
20286
- function useCustomLinkClick(editor, initialHandleCustomLink) {
20286
+ function useCustomLink(editor) {
20287
20287
  const quillRef = vue.ref(null);
20288
- const handleCustomLinkRef = vue.ref(initialHandleCustomLink || null);
20288
+ const handleCustomLinkRef = vue.ref(null);
20289
20289
  const handleLinkClick = (event) => {
20290
20290
  if (!quillRef.value || !handleCustomLinkRef.value)
20291
20291
  return;
@@ -20332,12 +20332,43 @@
20332
20332
  const setHandleCustomLink = (fn) => {
20333
20333
  handleCustomLinkRef.value = fn;
20334
20334
  };
20335
+ const calculateSelectionPosition = (range) => {
20336
+ var _a;
20337
+ if (!quillRef.value)
20338
+ return { top: 0, left: 0 };
20339
+ const selectionRange = range || quillRef.value.getSelection();
20340
+ if (!selectionRange || selectionRange.length === 0)
20341
+ return { top: 0, left: 0 };
20342
+ try {
20343
+ const bounds = quillRef.value.getBounds(selectionRange.index, selectionRange.length);
20344
+ const editorElement = (_a = editor.value) === null || _a === void 0 ? void 0 : _a.querySelector('.ql-editor');
20345
+ const editorContainer = editorElement === null || editorElement === void 0 ? void 0 : editorElement.closest('.quill-editor-container');
20346
+ const editorWidth = editorContainer ? editorContainer.clientWidth : ((editorElement === null || editorElement === void 0 ? void 0 : editorElement.clientWidth) || 0);
20347
+ const customLinkWidth = 310;
20348
+ const maxLeft = editorWidth - customLinkWidth - 16;
20349
+ const left = Math.min(bounds.left, Math.max(0, maxLeft));
20350
+ const editorRect = editorElement === null || editorElement === void 0 ? void 0 : editorElement.getBoundingClientRect();
20351
+ const containerRect = editorContainer === null || editorContainer === void 0 ? void 0 : editorContainer.getBoundingClientRect();
20352
+ if (!editorRect || !containerRect) {
20353
+ return { top: bounds.top + bounds.height + 5, left: left };
20354
+ }
20355
+ const editorOffsetTop = editorRect.top - containerRect.top;
20356
+ const top = editorOffsetTop + bounds.top + bounds.height + 5;
20357
+ return {
20358
+ top: top,
20359
+ left: left
20360
+ };
20361
+ }
20362
+ catch (error) {
20363
+ console.warn('计算选中位置时出错:', error);
20364
+ return { top: 0, left: 0 };
20365
+ }
20366
+ };
20335
20367
  return {
20336
- quillRef,
20337
20368
  setQuill,
20338
20369
  setHandleCustomLink,
20339
- handleLinkClick,
20340
- addLinkClickListener
20370
+ addLinkClickListener,
20371
+ calculateSelectionPosition
20341
20372
  };
20342
20373
  }
20343
20374
 
@@ -20532,7 +20563,7 @@
20532
20563
  const { addClickHandler } = useGlobalClick(props.clickTargetSelector);
20533
20564
  const { isIPadBool, handleIPadNewline } = useIPadScene();
20534
20565
  const { setQuill, handleBlotFormatterClick, configureBlotFormatter, applyImageStyle, registerBlotFormatter, getBlotFormatterConfig } = useBlotFormatter(editor, props.enableImageResize);
20535
- const { setQuill: setLinkQuill, setHandleCustomLink, addLinkClickListener } = useCustomLinkClick(editor);
20566
+ const { setQuill: setLinkQuill, setHandleCustomLink, addLinkClickListener, calculateSelectionPosition } = useCustomLink(editor);
20536
20567
  vue.onMounted(() => {
20537
20568
  initialize();
20538
20569
  });
@@ -20872,8 +20903,8 @@
20872
20903
  vue.nextTick(() => {
20873
20904
  applyImageStyle();
20874
20905
  });
20875
- updateHistoryState();
20876
20906
  ctx.emit('textChange', { delta, oldContents, source });
20907
+ updateHistoryState();
20877
20908
  };
20878
20909
  const controlToolbarVisible = (visible) => {
20879
20910
  var _a;
@@ -20892,6 +20923,7 @@
20892
20923
  controlToolbarVisible(true);
20893
20924
  }
20894
20925
  ctx.emit('selectionChange', { range, oldRange, source });
20926
+ updateHistoryState();
20895
20927
  };
20896
20928
  vue.watch(isEditorFocus, (focus) => {
20897
20929
  if (focus)
@@ -20900,7 +20932,6 @@
20900
20932
  ctx.emit('blur', editor);
20901
20933
  });
20902
20934
  const handleEditorChange = (...args) => {
20903
- updateHistoryState();
20904
20935
  if (args[0] === 'text-change')
20905
20936
  ctx.emit('editorChange', {
20906
20937
  name: args[0],
@@ -20916,19 +20947,6 @@
20916
20947
  source: args[3],
20917
20948
  });
20918
20949
  };
20919
- const getEditor = () => {
20920
- return editor.value;
20921
- };
20922
- const getToolbar = () => {
20923
- var _a;
20924
- return (_a = quill === null || quill === void 0 ? void 0 : quill.getModule('toolbar')) === null || _a === void 0 ? void 0 : _a.container;
20925
- };
20926
- const getQuill = () => {
20927
- if (quill)
20928
- return quill;
20929
- else
20930
- throw `The quill editor hasn't been instantiated`;
20931
- };
20932
20950
  const getContents = (index, length) => {
20933
20951
  if (props.contentType === 'html') {
20934
20952
  return getHTML();
@@ -20939,20 +20957,14 @@
20939
20957
  return quill === null || quill === void 0 ? void 0 : quill.getContents(index, length);
20940
20958
  };
20941
20959
  const setContents = (content, source = 'api') => {
20960
+ var _a;
20942
20961
  const normalizedContent = !content
20943
20962
  ? props.contentType === 'delta'
20944
20963
  ? new Delta$1()
20945
20964
  : ''
20946
20965
  : content;
20947
20966
  if (props.contentType === 'html') {
20948
- if (!normalizedContent || normalizedContent === '') {
20949
- if (quill) {
20950
- quill.root.innerHTML = '';
20951
- }
20952
- }
20953
- else {
20954
- setHTML(normalizedContent);
20955
- }
20967
+ setHTML((_a = normalizedContent) !== null && _a !== void 0 ? _a : '');
20956
20968
  }
20957
20969
  else if (props.contentType === 'text') {
20958
20970
  setText(normalizedContent, source);
@@ -21032,38 +21044,6 @@
21032
21044
  handleCustomLink(true);
21033
21045
  }
21034
21046
  };
21035
- const calculateSelectionPosition = (range) => {
21036
- var _a;
21037
- if (!quill)
21038
- return { top: 0, left: 0 };
21039
- const selectionRange = range || quill.getSelection();
21040
- if (!selectionRange || selectionRange.length === 0)
21041
- return { top: 0, left: 0 };
21042
- try {
21043
- const bounds = quill.getBounds(selectionRange.index, selectionRange.length);
21044
- const editorElement = (_a = editor.value) === null || _a === void 0 ? void 0 : _a.querySelector('.ql-editor');
21045
- const editorContainer = editorElement === null || editorElement === void 0 ? void 0 : editorElement.closest('.quill-editor-container');
21046
- const editorWidth = editorContainer ? editorContainer.clientWidth : ((editorElement === null || editorElement === void 0 ? void 0 : editorElement.clientWidth) || 0);
21047
- const customLinkWidth = 310;
21048
- const maxLeft = editorWidth - customLinkWidth - 16;
21049
- const left = Math.min(bounds.left, Math.max(0, maxLeft));
21050
- const editorRect = editorElement === null || editorElement === void 0 ? void 0 : editorElement.getBoundingClientRect();
21051
- const containerRect = editorContainer === null || editorContainer === void 0 ? void 0 : editorContainer.getBoundingClientRect();
21052
- if (!editorRect || !containerRect) {
21053
- return { top: bounds.top + bounds.height + 5, left: left };
21054
- }
21055
- const editorOffsetTop = editorRect.top - containerRect.top;
21056
- const top = editorOffsetTop + bounds.top + bounds.height + 5;
21057
- return {
21058
- top: top,
21059
- left: left
21060
- };
21061
- }
21062
- catch (error) {
21063
- console.warn('计算选中位置时出错:', error);
21064
- return { top: 0, left: 0 };
21065
- }
21066
- };
21067
21047
  const handleCustomLink = (bool, linkInfo) => {
21068
21048
  if (!quill)
21069
21049
  return;
@@ -21156,9 +21136,6 @@
21156
21136
  linkUrl,
21157
21137
  linkText,
21158
21138
  linkPosition,
21159
- getEditor,
21160
- getToolbar,
21161
- getQuill,
21162
21139
  getContents,
21163
21140
  setContents,
21164
21141
  getHTML,