Skip to content

Commit

Permalink
fix: sheet link popup should attach to cell editor
Browse files Browse the repository at this point in the history
  • Loading branch information
weird94 committed Nov 14, 2024
1 parent 820653c commit 18f312b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/docs-ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export * from './services';
export { IDocClipboardService } from './services/clipboard/clipboard.service';
export { DocEventManagerService } from './services/doc-event-manager.service';
export { DocIMEInputManagerService } from './services/doc-ime-input-manager.service';
export { DocCanvasPopManagerService } from './services/doc-popup-manager.service';
export { calcDocRangePositions, DocCanvasPopManagerService } from './services/doc-popup-manager.service';
export { DocStateChangeManagerService } from './services/doc-state-change-manager.service';
export { DocsRenderService } from './services/docs-render.service';
export { Editor } from './services/editor/editor';
Expand Down
25 changes: 17 additions & 8 deletions packages/sheets-hyper-link-ui/src/services/popup.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
*/

import type { DocumentDataModel, ICustomRange, IDisposable, INeedCheckDisposable, ITextRange, Nullable, Workbook } from '@univerjs/core';
import type { IBoundRectNoAngle } from '@univerjs/engine-render';
import type { ISheetLocationBase } from '@univerjs/sheets';
import type { ICanvasPopup } from '@univerjs/sheets-ui';
import { BuildTextUtils, CustomRangeType, Disposable, DOCS_ZEN_EDITOR_UNIT_ID_KEY, Inject, Injector, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
import { BuildTextUtils, CustomRangeType, Disposable, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DOCS_ZEN_EDITOR_UNIT_ID_KEY, Inject, Injector, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
import { DocSelectionManagerService } from '@univerjs/docs';
import { DocCanvasPopManagerService } from '@univerjs/docs-ui';
import { calcDocRangePositions, DocCanvasPopManagerService } from '@univerjs/docs-ui';
import { type IBoundRectNoAngle, IRenderManagerService } from '@univerjs/engine-render';
import { getCustomRangePosition, getEditingCustomRangePosition, IEditorBridgeService, SheetCanvasPopManagerService } from '@univerjs/sheets-ui';
import { IZenZoneService } from '@univerjs/ui';
import { BehaviorSubject, Subject } from 'rxjs';
Expand Down Expand Up @@ -287,17 +287,26 @@ export class SheetsHyperLinkPopupService extends Disposable {
} else if (type === HyperLinkEditSourceType.EDITING) {
const range = this._getEditingRange();

if (range) {
this._textSelectionManagerService.replaceTextRanges([{ ...range }]);
if (!range) {
return;
}

this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToCell(
link.row,
link.col,
this._textSelectionManagerService.replaceDocRanges([{ ...range }], { unitId: DOCS_NORMAL_EDITOR_UNIT_ID_KEY, subUnitId: DOCS_NORMAL_EDITOR_UNIT_ID_KEY });
const currentRender = this._injector.get(IRenderManagerService).getRenderById(DOCS_NORMAL_EDITOR_UNIT_ID_KEY);
if (!currentRender) {
return;
}
const rects = calcDocRangePositions(range, currentRender);
if (!rects?.length) {
return;
}
this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(
rects.pop()!,
this._editPopup,
unitId,
subUnitId
);

this._currentEditing$.next({
...link,
label: range?.label ?? '',
Expand Down

0 comments on commit 18f312b

Please sign in to comment.