@ones-editor/editor 2.0.6-beta.2 → 2.0.6-beta.3

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.
Files changed (53) hide show
  1. package/@ones-editor/callout-block/package.json +11 -0
  2. package/@ones-editor/callout-block/src/callout-block/callout-block-content.d.ts +3 -0
  3. package/@ones-editor/callout-block/src/callout-block/callout-block-doc.d.ts +2 -0
  4. package/@ones-editor/callout-block/src/callout-block/callout-block.d.ts +3 -0
  5. package/@ones-editor/callout-block/src/callout-block/callout-drop-target-finder.d.ts +10 -0
  6. package/@ones-editor/callout-block/src/callout-block/callout-input-handler.d.ts +9 -0
  7. package/@ones-editor/callout-block/src/callout-block/callout-last-callout-payload.d.ts +3 -0
  8. package/@ones-editor/callout-block/src/callout-block/callout-options.d.ts +2 -0
  9. package/@ones-editor/callout-block/src/callout-block/callout-properties.d.ts +2 -0
  10. package/@ones-editor/callout-block/src/callout-block/callout-quick-menu-item-filter.d.ts +8 -0
  11. package/@ones-editor/callout-block/src/callout-block/command-items/bg-color-item.d.ts +20 -0
  12. package/@ones-editor/callout-block/src/callout-block/command-items/delete-icon-item.d.ts +3 -0
  13. package/@ones-editor/callout-block/src/callout-block/command-items/preset-item.d.ts +10 -0
  14. package/@ones-editor/callout-block/src/callout-block/covert-to.d.ts +2 -0
  15. package/@ones-editor/callout-block/src/callout-block/helper.d.ts +2 -0
  16. package/@ones-editor/callout-block/src/callout-block/index.d.ts +1 -0
  17. package/@ones-editor/callout-block/src/callout-block/types.d.ts +9 -0
  18. package/@ones-editor/callout-block/src/index.d.ts +3 -0
  19. package/@ones-editor/callout-block/src/locale/en-us.d.ts +12 -0
  20. package/@ones-editor/callout-block/src/locale/index.d.ts +1 -0
  21. package/@ones-editor/callout-block/src/locale/ja-jp.d.ts +12 -0
  22. package/@ones-editor/callout-block/src/locale/zh-cn.d.ts +12 -0
  23. package/@ones-editor/core/src/core/composition/editor-input.d.ts +1 -1
  24. package/@ones-editor/core/src/core/containers/element.d.ts +1 -0
  25. package/@ones-editor/core/src/core/types.d.ts +2 -2
  26. package/@ones-editor/drop-target/src/drop-target.d.ts +6 -0
  27. package/@ones-editor/drop-target/src/index.d.ts +1 -0
  28. package/@ones-editor/misc/src/image.d.ts +2 -2
  29. package/@ones-editor/to-docx/src/doc2other/colors.d.ts +1 -1
  30. package/@ones-editor/tsconfig.tsbuildinfo +1 -1
  31. package/@ones-editor/ui/src/index.d.ts +2 -2
  32. package/@ones-editor/ui/src/quick-menu/index.d.ts +3 -1
  33. package/@ones-editor/ui/src/quick-menu/types.d.ts +4 -0
  34. package/@ones-editor/ui-base/src/color-palette/color-palette.d.ts +2 -1
  35. package/@ones-editor/ui-base/src/color-palette/create-palette.d.ts +6 -0
  36. package/@ones-editor/ui-base/src/color-palette/index.d.ts +2 -2
  37. package/@ones-editor/ui-base/src/command-bar/types.d.ts +1 -0
  38. package/@ones-editor/ui-base/src/emoji-item/emoji-item.d.ts +18 -0
  39. package/@ones-editor/ui-base/src/emoji-item/index.d.ts +2 -0
  40. package/@ones-editor/ui-base/src/emoji-palette/emoji-content.d.ts +20 -0
  41. package/@ones-editor/ui-base/src/emoji-palette/emoji-data.d.ts +34 -0
  42. package/@ones-editor/ui-base/src/emoji-palette/emoji-navigation.d.ts +15 -0
  43. package/@ones-editor/ui-base/src/emoji-palette/emoji-search.d.ts +11 -0
  44. package/@ones-editor/ui-base/src/emoji-palette/index.d.ts +25 -0
  45. package/@ones-editor/ui-base/src/emoji-palette/types.d.ts +0 -0
  46. package/@ones-editor/ui-base/src/icons/index.d.ts +7 -1
  47. package/@ones-editor/ui-base/src/index.d.ts +1 -0
  48. package/@ones-editor/ui-base/src/input/create-input.d.ts +1 -0
  49. package/@ones-editor/ui-base/src/locale/en-us.d.ts +16 -0
  50. package/@ones-editor/ui-base/src/locale/ja-jp.d.ts +16 -0
  51. package/@ones-editor/ui-base/src/locale/zh-cn.d.ts +16 -0
  52. package/dist/index.js +232 -207
  53. package/package.json +1 -1
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "@ones-editor/callout-block",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "private": true,
6
+ "main": "./src/index.ts",
7
+ "devDependencies": {
8
+ "@types/lodash.isequal": "^4.5.7"
9
+ },
10
+ "types": "src/index.d.ts"
11
+ }
@@ -0,0 +1,3 @@
1
+ import type { OnesEditor, BlockPath, BlockElement } from '../../../../@ones-editor/core';
2
+ import type { DocCalloutBlockData } from './types';
3
+ export declare function createCalloutBlockContent(editor: OnesEditor, path: BlockPath, blockElement: BlockElement, blockData: DocCalloutBlockData): import("@ones-editor/core").BlockContentElement;
@@ -0,0 +1,2 @@
1
+ import { DocCalloutBlockData } from './types';
2
+ export declare function isCalloutBlockData(v: unknown): v is DocCalloutBlockData;
@@ -0,0 +1,3 @@
1
+ import type { ComplexKindBlock } from '../../../../@ones-editor/core';
2
+ declare const CalloutBlock: ComplexKindBlock;
3
+ export { CalloutBlock, };
@@ -0,0 +1,10 @@
1
+ import { DropTargetFinder } from '../../../../@ones-editor/drop-target';
2
+ import { BlockElement, OnesEditor } from '../../../../@ones-editor/core';
3
+ export declare class CalloutDropTargetFinder implements DropTargetFinder {
4
+ private editor;
5
+ constructor(editor: OnesEditor);
6
+ private checkBlockAllowToDrop;
7
+ finder(editor: OnesEditor, source: BlockElement | null, x: number, y: number): BlockElement | null;
8
+ destroy(): void;
9
+ static init(editor: OnesEditor): CalloutDropTargetFinder;
10
+ }
@@ -0,0 +1,9 @@
1
+ import type { OnesEditorInputHandler, OnesEditor, OnesEditorCustom, DocObject } from '../../../../@ones-editor/core';
2
+ export declare class CalloutInputHandler implements OnesEditorInputHandler, OnesEditorCustom {
3
+ constructor(editor: OnesEditor);
4
+ private handleBackspaceEvent;
5
+ handleBeforeKeyDown(editor: OnesEditor, event: KeyboardEvent): boolean;
6
+ handleBeforePasteDoc(editor: OnesEditor, doc: DocObject): Promise<boolean>;
7
+ destroy(): void;
8
+ static init(editor: OnesEditor): void;
9
+ }
@@ -0,0 +1,3 @@
1
+ import { CalloutBlockPayload } from './types';
2
+ export declare function getLastCalloutData(): CalloutBlockPayload;
3
+ export declare function updateLastCalloutData(payload: Partial<CalloutBlockPayload>): void;
@@ -0,0 +1,2 @@
1
+ import { BlockOptions } from '../../../../@ones-editor/core';
2
+ export declare function getOptions(): BlockOptions;
@@ -0,0 +1,2 @@
1
+ import type { OnesEditor, BlockProperties } from '../../../../@ones-editor/core';
2
+ export declare function getBlockProperties(editor: OnesEditor): BlockProperties;
@@ -0,0 +1,8 @@
1
+ import { OnesEditor, OnesEditorCustom } from '../../../../@ones-editor/core';
2
+ import type { QuickMenuItem, QuickMenuItemFilter } from '../../../../@ones-editor/ui';
3
+ export declare class CalloutQuickMenuItemFilter implements QuickMenuItemFilter, OnesEditorCustom {
4
+ constructor(editor: OnesEditor);
5
+ filter(editor: OnesEditor, items: QuickMenuItem[], from: string): QuickMenuItem[];
6
+ destroy(): void;
7
+ static init(editor: OnesEditor): CalloutQuickMenuItemFilter;
8
+ }
@@ -0,0 +1,20 @@
1
+ import { BlockElement, CommandItem, OnesEditor, OnesEditorCustom } from '../../../../../@ones-editor/core';
2
+ import { ColorPaletteItem } from '../../../../../@ones-editor/ui-base';
3
+ export declare class BgColorItem implements CommandItem, OnesEditorCustom {
4
+ private editor;
5
+ id: string;
6
+ name: string;
7
+ manualShowChildren: boolean;
8
+ dropdown: boolean;
9
+ childrenPlacement: "bottom-start";
10
+ private bgColorButton;
11
+ bgColorPaletteItem: ColorPaletteItem;
12
+ element: HTMLButtonElement;
13
+ children: CommandItem[];
14
+ private constructor();
15
+ private createPaletteButton;
16
+ private getBgColorFromBlock;
17
+ updateItem(block: BlockElement): void;
18
+ destroy(): void;
19
+ static get(editor: OnesEditor): BgColorItem;
20
+ }
@@ -0,0 +1,3 @@
1
+ import { BlockElement, CommandItem, OnesEditor } from '../../../../../@ones-editor/core';
2
+ export declare const EMPTY_ICON = "";
3
+ export declare function createDeleteIconItem(editor: OnesEditor, block: BlockElement): CommandItem;
@@ -0,0 +1,10 @@
1
+ import { BlockElement, CommandItem, OnesEditor } from '../../../../../@ones-editor/core';
2
+ export type PresetId = `preset-${0 | 1}`;
3
+ export declare function isPresetId(id: string): id is PresetId;
4
+ export declare function getPresetId(id: PresetId): string;
5
+ export declare function getPresetIcon(id: string): string;
6
+ export declare function getPresetPayload(presetId: PresetId): {
7
+ backgroundColor: number;
8
+ icon: "preset-0" | "preset-1";
9
+ };
10
+ export declare function createPresetItem(presetId: PresetId, editor: OnesEditor, block: BlockElement): CommandItem;
@@ -0,0 +1,2 @@
1
+ import { OnesEditor, DocBlock, DocObject } from '../../../../@ones-editor/core';
2
+ export declare function toStandardDoc(editor: OnesEditor, blockData: DocBlock, doc: DocObject): Promise<DocObject>;
@@ -0,0 +1,2 @@
1
+ import { DocBlock } from '../../../../@ones-editor/core';
2
+ export declare function checkBlockAllowInCallout(block: DocBlock): boolean;
@@ -0,0 +1 @@
1
+ export { CalloutBlock } from './callout-block';
@@ -0,0 +1,9 @@
1
+ import { DocBlock } from '../../../../@ones-editor/core';
2
+ export type ColorId = number;
3
+ export interface DocCalloutBlockData extends DocBlock {
4
+ type: 'callout';
5
+ icon: string;
6
+ backgroundColor: ColorId;
7
+ children: string[];
8
+ }
9
+ export type CalloutBlockPayload = Pick<DocCalloutBlockData, 'icon' | 'backgroundColor'>;
@@ -0,0 +1,3 @@
1
+ import './index.scss';
2
+ import './locale';
3
+ export { CalloutBlock } from './callout-block';
@@ -0,0 +1,12 @@
1
+ declare const _default: {
2
+ callout: {
3
+ name: string;
4
+ command: {
5
+ presetInfo: string;
6
+ presetAlert: string;
7
+ clearEmoji: string;
8
+ background: string;
9
+ };
10
+ };
11
+ };
12
+ export default _default;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ declare const _default: {
2
+ callout: {
3
+ name: string;
4
+ command: {
5
+ presetInfo: string;
6
+ presetAlert: string;
7
+ clearEmoji: string;
8
+ background: string;
9
+ };
10
+ };
11
+ };
12
+ export default _default;
@@ -0,0 +1,12 @@
1
+ declare const _default: {
2
+ callout: {
3
+ name: string;
4
+ command: {
5
+ presetInfo: string;
6
+ presetAlert: string;
7
+ clearEmoji: string;
8
+ background: string;
9
+ };
10
+ };
11
+ };
12
+ export default _default;
@@ -27,7 +27,7 @@ export declare class EditorInput implements OnesEditorInput {
27
27
  callbacks: EditorInputCallbacks;
28
28
  inputElement: HTMLInputElement;
29
29
  constructor(editor: OnesEditor, callbacks: EditorInputCallbacks);
30
- private isInCommandbar;
30
+ private isInCommandBar;
31
31
  destroy(): void;
32
32
  getInput(): HTMLInputElement;
33
33
  focus(): void;
@@ -4,3 +4,4 @@ export declare function getContainerById(editor: OnesEditor, containerId: string
4
4
  export declare function getExistsContainerById(editor: OnesEditor, containerId: string): ContainerElement | null;
5
5
  export declare function getContainerBlocksElement(container: ContainerElement): ContainerBlocksElement;
6
6
  export declare function getContainerToolsElement(container: ContainerElement): ContainerToolsElement;
7
+ export declare function isContainerBlocksElement(element: Element): element is ContainerBlocksElement;
@@ -500,7 +500,7 @@ export declare class OnesEditorCustomDataWrapper<T> {
500
500
  getEditor(): OnesEditor;
501
501
  destroy(): void;
502
502
  }
503
- export type OnesEditorCustomCreator = (editor: OnesEditor) => OnesEditorCustom;
503
+ export type OnesEditorCustomCreator<T extends OnesEditorCustom = OnesEditorCustom> = (editor: OnesEditor) => T;
504
504
  export interface CloneBlockResultInfo {
505
505
  containerIdMap: Map<string, string>;
506
506
  blockIdMap: Map<string, string>;
@@ -541,7 +541,7 @@ export interface OnesEditor extends TypedEmitter<OnesEditorEvents> {
541
541
  readonly settingsProvider: OnesEditorSettingsProvider;
542
542
  version: string;
543
543
  readonly: boolean;
544
- addCustom: <T extends OnesEditorCustom>(name: string, creator: OnesEditorCustomCreator) => T;
544
+ addCustom: <T extends OnesEditorCustom>(name: string, creator: OnesEditorCustomCreator<T>) => T;
545
545
  getCustom: <T extends OnesEditorCustom>(name: string) => T;
546
546
  replaceCustom: <T extends OnesEditorCustom>(name: string, newCustom: T) => T;
547
547
  findCustom: <T extends OnesEditorCustom>(name: string) => T | null;
@@ -3,6 +3,10 @@ import DropIndicator from './drop-indicator';
3
3
  export interface DropHandler {
4
4
  handleDrop: (editor: OnesEditor, dragData: BlockElement | File[], targetContainer: ContainerElement, blockIndex: number) => boolean | undefined;
5
5
  }
6
+ export type DropTargetFinderId = keyof any;
7
+ export interface DropTargetFinder {
8
+ finder: (editor: OnesEditor, source: BlockElement | null, x: number, y: number) => BlockElement | null;
9
+ }
6
10
  export default class OnesEditorDropTarget {
7
11
  private editor;
8
12
  indicator: DropIndicator;
@@ -13,9 +17,11 @@ export default class OnesEditorDropTarget {
13
17
  } | undefined;
14
18
  handlers: DropHandler[];
15
19
  combineToCreate: CombineToCreateOptions[];
20
+ dropTargetFinders: Map<string | number | symbol, DropTargetFinder>;
16
21
  constructor(editor: OnesEditor);
17
22
  destroy(): void;
18
23
  addHandler(handler: DropHandler): void;
24
+ addFinder(id: DropTargetFinderId, finder: DropTargetFinder): void;
19
25
  static register(editor: OnesEditor): OnesEditorDropTarget;
20
26
  static get(editor: OnesEditor): OnesEditorDropTarget;
21
27
  static find(editor: OnesEditor): OnesEditorDropTarget | null;
@@ -2,5 +2,6 @@ import { INDICATOR_SIZE } from './drop-indicator';
2
2
  import OnesEditorDropTarget from './drop-target';
3
3
  import type { DropHandler } from './drop-target';
4
4
  import { patchInsertFile } from './handlers/patch-insert-file';
5
+ export type { DropTargetFinder, DropTargetFinderId } from './drop-target';
5
6
  export * from './drag-object';
6
7
  export { OnesEditorDropTarget, DropHandler, patchInsertFile, INDICATOR_SIZE };
@@ -1,3 +1,3 @@
1
- export declare function convertImageSrcToPng(src: string): Promise<Blob>;
1
+ export declare function convertImageSrcToPng(src: string, backgroundColor: string): Promise<Blob>;
2
2
  export declare function convertImageFileToPng(file: File): Promise<Blob>;
3
- export declare function downloadImageAsPng(downloadUrl: string, prefix?: string): Promise<void>;
3
+ export declare function downloadImageAsPng(downloadUrl: string, prefix?: string, backgroundColor?: string): Promise<void>;
@@ -6,7 +6,7 @@ export declare function styleColorToColor(color: string | undefined): "d83931" |
6
6
  * @param color
7
7
  * @returns
8
8
  */
9
- export declare function styleBackgroundColorToHighlight(color: string | undefined): "yellow" | "magenta" | "green" | "blue" | "lightGray" | "red" | "darkGreen" | "darkMagenta" | "darkGray" | undefined;
9
+ export declare function styleBackgroundColorToHighlight(color: string | undefined): "green" | "red" | "blue" | "yellow" | "magenta" | "lightGray" | "darkGreen" | "darkMagenta" | "darkGray" | undefined;
10
10
  export declare function styleBackgroundColorToHex(color: string | undefined): "fbbab6" | "ffdcb0" | "fff7a0" | "ceefc5" | "d1ddfb" | "d9cbf8" | "eaeaea" | "fe837c" | "ffbd6a" | "ffe662" | "a8f393" | "98b5ff" | "b394f8" | "b1b1b1" | undefined;
11
11
  /**
12
12
  * 将rgb(rrr,ggg,bbb)格式的颜色转为RRGGBB格式