oasis-editor 0.0.231 → 0.0.233

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.
@@ -1,4 +1,5 @@
1
1
  import { EditorState } from '../../core/model.js';
2
+ export type ClipboardIssue = "access-denied" | "empty" | "unsupported" | "document-changed";
2
3
  export type ClipboardPasteMode = "rich" | "text" | "merge";
3
4
  export interface ClipboardPasteDeps {
4
5
  state: () => EditorState;
@@ -9,6 +10,7 @@ export interface ClipboardPasteDeps {
9
10
  resetTransactionGrouping: () => void;
10
11
  focusInput: () => void;
11
12
  onError?: (error: unknown) => void;
13
+ onIssue?: (issue: ClipboardIssue) => void;
12
14
  }
13
15
  /** A permissions prompt may still deny access at runtime. */
14
16
  export declare function canReadSystemClipboard(): boolean;
@@ -1,11 +1,11 @@
1
1
  import { EditorState } from '../../core/model.js';
2
- import { ClipboardPasteDeps } from './clipboardPaste.js';
2
+ import { ClipboardIssue, ClipboardPasteDeps } from './clipboardPaste.js';
3
3
  /** Clipboard writes must be initiated from the user's gesture. */
4
4
  export declare function canWriteSystemClipboard(): boolean;
5
5
  /**
6
6
  * A rejected write always returns false. In particular, Cut must not delete
7
7
  * text because an asynchronous Clipboard API call was merely attempted.
8
8
  */
9
- export declare function writeEditorSelectionToClipboard(snapshot: EditorState): Promise<boolean>;
9
+ export declare function writeEditorSelectionToClipboard(snapshot: EditorState, onIssue?: (issue: ClipboardIssue) => void): Promise<boolean>;
10
10
  /** Atomic undoable deletion, only after successful clipboard write. */
11
11
  export declare function cutEditorSelection(deps: ClipboardPasteDeps): Promise<boolean>;
@@ -1,3 +1,4 @@
1
+ import { EditorClipboardActions } from './createEditorClipboardActions.js';
1
2
  import { MergeKey } from '../../core/transactionMergeKeys.js';
2
3
  import { EditorSelection, EditorState } from '../../core/model.js';
3
4
  import { ToolbarStyleState } from '../toolbarStyleState.js';
@@ -18,6 +19,7 @@ interface ContextMenuState {
18
19
  y: number;
19
20
  }
20
21
  export interface EditorChromeDeps {
22
+ clipboardActions?: EditorClipboardActions;
21
23
  state: () => EditorState;
22
24
  selection: () => EditorSelection;
23
25
  toolbarStyleState: () => ToolbarStyleState;
@@ -0,0 +1,19 @@
1
+ import { ClipboardIssue, ClipboardPasteDeps, ClipboardPasteMode } from './clipboardPaste.js';
2
+ export interface ClipboardNotice {
3
+ action: "copy" | "cut" | "paste";
4
+ issue: ClipboardIssue;
5
+ mode?: ClipboardPasteMode;
6
+ }
7
+ /** One editor's actions, feedback and single-use native-paste fallback. */
8
+ export declare function createEditorClipboardActions(deps: ClipboardPasteDeps): ReturnType<typeof createClipboardActions>;
9
+ export type EditorClipboardActions = ReturnType<typeof createEditorClipboardActions>;
10
+ declare function createClipboardActions(deps: ClipboardPasteDeps): {
11
+ notice: import('solid-js').Accessor<ClipboardNotice | undefined>;
12
+ dismiss: () => void;
13
+ consumePasteMode: () => ClipboardPasteMode | undefined;
14
+ copy: () => Promise<boolean>;
15
+ cut: () => Promise<boolean>;
16
+ paste: (mode?: ClipboardPasteMode) => Promise<boolean>;
17
+ hasSelection: () => boolean;
18
+ };
19
+ export {};
@@ -1,3 +1,4 @@
1
+ import { EditorClipboardActions } from './createEditorClipboardActions.js';
1
2
  import { BooleanStyleKey } from '../toolbarStyleState.js';
2
3
  import { EditorState } from '../../core/model.js';
3
4
  import { EditorLogger } from '../../utils/logger.js';
@@ -17,6 +18,7 @@ interface LinkDialogSetter {
17
18
  }): void;
18
19
  }
19
20
  export interface EditorCommandRuntimeDeps {
21
+ clipboardActions?: EditorClipboardActions;
20
22
  document: DocumentRuntime;
21
23
  interaction: InteractionRuntime;
22
24
  commentComposer: EditorCommentComposer;
@@ -1,5 +1,14 @@
1
+ import { Accessor } from 'solid-js';
1
2
  import { EditorState } from '../../core/model.js';
2
3
  export type FormatPainterMode = "once" | "continuous" | null;
4
+ export interface EditorFormatPainter {
5
+ mode: Accessor<FormatPainterMode>;
6
+ canCapture: () => boolean;
7
+ armOnce: () => boolean;
8
+ armContinuous: () => boolean;
9
+ cancel: () => void;
10
+ applyToSelection: (origin: "pointer" | "keyboard") => boolean;
11
+ }
3
12
  export interface EditorFormatPainterDeps {
4
13
  state: () => EditorState;
5
14
  isReadOnly: () => boolean;
@@ -14,12 +23,4 @@ export interface EditorFormatPainterDeps {
14
23
  * Pointer selection is committed only after pointerup (never during drag),
15
24
  * and keyboard selection only on keyup.
16
25
  */
17
- export declare function createEditorFormatPainter(deps: EditorFormatPainterDeps): {
18
- mode: import('solid-js').Accessor<FormatPainterMode>;
19
- canCapture: () => boolean;
20
- armOnce: () => boolean;
21
- armContinuous: () => boolean;
22
- cancel: () => void;
23
- applyToSelection: (origin: "pointer" | "keyboard") => boolean;
24
- };
25
- export type EditorFormatPainter = ReturnType<typeof createEditorFormatPainter>;
26
+ export declare function createEditorFormatPainter(deps: EditorFormatPainterDeps): EditorFormatPainter;
@@ -1,3 +1,4 @@
1
+ import { EditorClipboardActions } from './createEditorClipboardActions.js';
1
2
  import { EditorPosition, EditorState } from '../../core/model.js';
2
3
  import { EditorLogger } from '../../utils/logger.js';
3
4
  import { createEditorCommandsController } from '../../app/controllers/EditorCommandsController.js';
@@ -6,6 +7,7 @@ import { SelectedObjectRun } from '../../core/commands/selectedObjectRun.js';
6
7
  type DocRuntime = ReturnType<typeof createEditorDocumentRuntime>;
7
8
  type CommandsController = ReturnType<typeof createEditorCommandsController>;
8
9
  export interface EditorInteractionRuntimeDeps {
10
+ clipboardActions?: EditorClipboardActions;
9
11
  state: EditorState;
10
12
  logger: EditorLogger;
11
13
  isReadOnly: () => boolean;
@@ -147,14 +149,7 @@ declare function createEditorInteractionRuntimeImpl(deps: EditorInteractionRunti
147
149
  applyToolbarUnderlineStyleCommand: (style: import('../../core/model.js').EditorUnderlineStyle | null) => void;
148
150
  applyToolbarBooleanStyleCommand: (key: import('../toolbarStyleState.js').BooleanStyleKey) => void;
149
151
  };
150
- formatPainter: {
151
- mode: import('solid-js').Accessor<import('./createEditorFormatPainter.js').FormatPainterMode>;
152
- canCapture: () => boolean;
153
- armOnce: () => boolean;
154
- armContinuous: () => boolean;
155
- cancel: () => void;
156
- applyToSelection: (origin: "pointer" | "keyboard") => boolean;
157
- };
152
+ formatPainter: import('./createEditorFormatPainter.js').EditorFormatPainter;
158
153
  onEditorPointerDown: (event: PointerEvent) => void;
159
154
  tableResize: import('../../app/controllers/useEditorTableResize.js').TableResizeOps;
160
155
  tableCornerResize: import('../../app/controllers/useEditorTableCornerResize.js').TableCornerResizeOps;
@@ -1,8 +1,4 @@
1
1
  import { EssentialsBrowserCapability } from '../../../plugins/internal/essentialsCapabilities.js';
2
2
  import { CreateEditorEssentialsPluginOptions } from './types.js';
3
- /**
4
- * Copies the editor's *model selection*, not the DOM selection of the button
5
- * that currently holds focus. Keyboard copy through the editor input continues
6
- * to use useEditorClipboard, preserving its existing rich-clipboard behavior.
7
- */
8
- export declare function buildEssentialsBrowser(options: Pick<CreateEditorEssentialsPluginOptions, "state" | "isReadOnly" | "applyTransactionalState" | "tableOps" | "clearPreferredColumn" | "resetTransactionGrouping" | "focusInput">): EssentialsBrowserCapability;
3
+ /** Ribbon and context-menu actions share this editor's clipboard feedback. */
4
+ export declare function buildEssentialsBrowser(options: Pick<CreateEditorEssentialsPluginOptions, "state" | "isReadOnly" | "applyTransactionalState" | "tableOps" | "clearPreferredColumn" | "resetTransactionGrouping" | "focusInput" | "clipboardActions">): EssentialsBrowserCapability;
@@ -1,3 +1,4 @@
1
+ import { EditorClipboardActions } from '../createEditorClipboardActions.js';
1
2
  import { MergeKey } from '../../../core/transactionMergeKeys.js';
2
3
  import { EditorState } from '../../../core/model.js';
3
4
  import { SelectedImageRun } from '../../../core/commands/image.js';
@@ -9,6 +10,7 @@ import { EditorCommentComposer } from '../createEditorCommentComposer.js';
9
10
  import { createEditorTableOperations } from '../../../app/controllers/useEditorTableOperations.js';
10
11
  import { EssentialsDesignCapability } from '../../../plugins/internal/essentialsCapabilities.js';
11
12
  export interface CreateEditorEssentialsPluginOptions {
13
+ clipboardActions?: EditorClipboardActions;
12
14
  design?: EssentialsDesignCapability;
13
15
  state: () => EditorState;
14
16
  isReadOnly: () => boolean;
@@ -1,3 +1,4 @@
1
+ import { EditorClipboardActions } from './createEditorClipboardActions.js';
1
2
  import { MergeKey } from '../../core/transactionMergeKeys.js';
2
3
  import { EditorState } from '../../core/model.js';
3
4
  import { TranslateFn } from '../../i18n/index.js';
@@ -9,6 +10,7 @@ interface ContextMenuState {
9
10
  y: number;
10
11
  }
11
12
  export interface EditorContextMenuClipboardDeps {
13
+ clipboardActions?: EditorClipboardActions;
12
14
  state: () => EditorState;
13
15
  isReadOnly: () => boolean;
14
16
  t: TranslateFn;
@@ -53,8 +55,8 @@ declare function createEditorContextMenuClipboardImpl(deps: EditorContextMenuCli
53
55
  buildContextMenuItems: () => ContextMenuItem[];
54
56
  closeContextMenu: () => void;
55
57
  handleEditorContextMenu: (event: MouseEvent) => void;
56
- programmaticCopy: () => Promise<void>;
57
- programmaticCut: () => Promise<void>;
58
- programmaticPaste: () => Promise<void>;
58
+ programmaticCopy: () => Promise<boolean>;
59
+ programmaticCut: () => Promise<boolean>;
60
+ programmaticPaste: () => Promise<boolean>;
59
61
  };
60
62
  export {};
@@ -1,3 +1,4 @@
1
+ import { EditorClipboardActions } from './createEditorClipboardActions.js';
1
2
  import { EditorState } from '../../core/model.js';
2
3
  import { EditorLogger } from '../../utils/logger.js';
3
4
  import { createEditorClipboardController } from '../../app/controllers/useEditorClipboard.js';
@@ -25,6 +26,7 @@ type ClipboardParams = Parameters<typeof createEditorClipboardController>[0];
25
26
  * the pointer/keyboard interaction controllers on top of them.
26
27
  */
27
28
  export interface EditorInteractionWiringContext {
29
+ clipboardActions?: EditorClipboardActions;
28
30
  state: EditorState;
29
31
  applyState: NavigationParams["applyState"];
30
32
  applyTransactionalState: TextDragParams["applyTransactionalState"];
@@ -0,0 +1,6 @@
1
+ import { JSX } from 'solid-js';
2
+ import { ClipboardNotice } from '../app/createEditorClipboardActions.js';
3
+ export declare function ClipboardFeedback(props: {
4
+ notice: () => ClipboardNotice | undefined;
5
+ onDismiss: () => void;
6
+ }): JSX.Element;
@@ -3,5 +3,7 @@ export interface PopoverBranch {
3
3
  open: () => boolean;
4
4
  contains: (target: Node) => boolean;
5
5
  children: Set<PopoverBranch>;
6
+ /** A chosen action ends this menu path; opening a child does not. */
7
+ closeAll: () => void;
6
8
  }
7
9
  export declare const PopoverBranchContext: import('solid-js').Context<PopoverBranch | undefined>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oasis-editor",
3
- "version": "0.0.231",
3
+ "version": "0.0.233",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {
@@ -77,7 +77,9 @@
77
77
  "test:ribbon:ci": "node scripts/verify-ribbon-ci.mjs",
78
78
  "test:ribbon:contexts": "node scripts/verify-ribbon-contexts.mjs",
79
79
  "test:ribbon:icons": "node scripts/verify-ribbon-icons.mjs",
80
- "test:ribbon:editing": "node scripts/verify-ribbon-editing.mjs"
80
+ "test:ribbon:editing": "node scripts/verify-ribbon-editing.mjs",
81
+ "test:ribbon:clipboard": "node scripts/verify-ribbon-clipboard.mjs",
82
+ "test:ribbon:painter": "node scripts/verify-ribbon-painter.mjs"
81
83
  },
82
84
  "devDependencies": {
83
85
  "@eslint/js": "^10.0.1",