Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(float-image): support paste image from external #3617

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/drawing/src/services/drawing-manager-impl.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* limitations under the License.
*/

import { type Observable, Subject } from 'rxjs';
import type { Nullable } from '@univerjs/core';
import { sortRules, sortRulesByDesc } from '@univerjs/core';
import type { JSONOp, JSONOpList } from 'ot-json1';
import * as json1 from 'ot-json1';
import type { IDrawingGroupUpdateParam, IDrawingMap, IDrawingMapItemData, IDrawingOrderMapParam, IDrawingOrderUpdateParam, IDrawingParam, IDrawingSearch, IDrawingSubunitMap, IDrawingVisibleParam, IUnitDrawingService } from './drawing-manager.service';
import { sortRules, sortRulesByDesc } from '@univerjs/core';
import * as json1 from 'ot-json1';
import { type Observable, Subject } from 'rxjs';

export interface IDrawingJsonUndo1 {
undo: JSONOp;
Expand Down Expand Up @@ -237,7 +237,7 @@ export class UnitDrawingService<T extends IDrawingParam> implements IUnitDrawing
* ops: [[unit, sheetUnit, order, 0, { r: true }], [unit, sheetUnit, order, 1, { r: true }]]
* We expected them to composed as [unit, sheetUnit, order, [0, { r: true }], [1, { r: true }]]
* But extremely confusing to get [unit, sheetUnit, order, 0, { r: true }, 2, { r: true }]
* And We apply this composed op to data, it's not a 2-index item for us to remove.
* And We apply this composed op to data, it's no item with index 2 can be removed.
* So use unshift api instead of push here.
*/
ops.unshift(op);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,22 @@ export interface IInsertImageCommandParams {
export const InsertFloatImageCommand: ICommand<IInsertImageCommandParams> = {
id: 'sheet.command.insert-float-image',
type: CommandType.COMMAND,
handler: (accessor) => {
handler: async (accessor, params) => {
const renderManagerService = accessor.get(IRenderManagerService);
return renderManagerService.getCurrentTypeOfRenderer(UniverInstanceType.UNIVER_SHEET)
?.with(SheetDrawingUpdateController).insertFloatImage() ?? false;
const sheetDrawingUpdateController = renderManagerService.getCurrentTypeOfRenderer(UniverInstanceType.UNIVER_SHEET)
?.with(SheetDrawingUpdateController);

if (!sheetDrawingUpdateController) {
return false;
}
const files = params?.files;

if (files) {
const awaitFiles = files.map((file) => sheetDrawingUpdateController.insertFloatImageByFile(file));

return (await Promise.all(awaitFiles)).every((result) => result);
} else {
return sheetDrawingUpdateController.insertFloatImage();
}
},
};
Loading
Loading