Skip to content

Commit 2e0d618

Browse files
committed
code v1.2.4: Add invalid format error to secureview
* Added screenshot files. * Added invalid format error to secureview.
1 parent 86088b4 commit 2e0d618

19 files changed

+191
-13
lines changed

api/JoplinClipboard.d.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ClipboardContent } from './types';
12
export default class JoplinClipboard {
23
private electronClipboard_;
34
private electronNativeImage_;
@@ -26,4 +27,19 @@ export default class JoplinClipboard {
2627
* For example [ 'text/plain', 'text/html' ]
2728
*/
2829
availableFormats(): Promise<string[]>;
30+
/**
31+
* Writes multiple formats to the clipboard simultaneously.
32+
* This allows setting both text/plain and text/html at the same time.
33+
*
34+
* <span class="platform-desktop">desktop</span>
35+
*
36+
* @example
37+
* ```typescript
38+
* await joplin.clipboard.write({
39+
* text: 'Plain text version',
40+
* html: '<strong>HTML version</strong>'
41+
* });
42+
* ```
43+
*/
44+
write(content: ClipboardContent): Promise<void>;
2945
}

api/JoplinCommands.d.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Plugin from '../Plugin';
1414
* now, are not well documented. You can find the list directly on GitHub
1515
* though at the following locations:
1616
*
17-
* * [Main screen commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/MainScreen/commands)
17+
* * [Main screen commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/WindowCommandsAndDialogs/commands)
1818
* * [Global commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/commands)
1919
* * [Editor commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/NoteEditor/editorCommandDeclarations.ts)
2020
*
@@ -25,8 +25,13 @@ import Plugin from '../Plugin';
2525
* commands can be found in these places:
2626
*
2727
* * [Global commands](https://github.com/laurent22/joplin/tree/dev/packages/app-mobile/commands)
28+
* * [Note screen commands](https://github.com/laurent22/joplin/tree/dev/packages/app-mobile/components/screens/Note/commands)
2829
* * [Editor commands](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/components/NoteEditor/commandDeclarations.ts)
2930
*
31+
* Additionally, certain global commands have the same implementation on both platforms:
32+
*
33+
* * [Shared global commands](https://github.com/laurent22/joplin/tree/dev/packages/lib/commands)
34+
*
3035
* ## Executing editor commands
3136
*
3237
* There might be a situation where you want to invoke editor commands

api/JoplinSettings.d.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ export default class JoplinSettings {
4242
*/
4343
values(keys: string[] | string): Promise<Record<string, unknown>>;
4444
/**
45-
* @deprecated Use joplin.settings.values()
45+
* Gets a setting value (only applies to setting you registered from your plugin).
4646
*
47-
* Gets a setting value (only applies to setting you registered from your plugin)
47+
* Note: If you want to retrieve all your plugin settings, for example when the plugin starts,
48+
* it is recommended to use the `values()` function instead - it will be much faster than
49+
* calling `value()` multiple times.
4850
*/
4951
value(key: string): Promise<any>;
5052
/**

api/JoplinViews.d.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,17 @@ import JoplinViewsEditors from './JoplinViewsEditor';
99
/**
1010
* This namespace provides access to view-related services.
1111
*
12-
* All view services provide a `create()` method which you would use to create the view object, whether it's a dialog, a toolbar button or a menu item.
13-
* In some cases, the `create()` method will return a [[ViewHandle]], which you would use to act on the view, for example to set certain properties or call some methods.
12+
* ## Creating a view
13+
*
14+
* All view services provide a `create()` method which you would use to create the view object,
15+
* whether it's a dialog, a toolbar button or a menu item. In some cases, the `create()` method will
16+
* return a [[ViewHandle]], which you would use to act on the view, for example to set certain
17+
* properties or call some methods.
18+
*
19+
* ## The `webviewApi` object
20+
*
21+
* Within a view, you can use the global object `webviewApi` for various utility functions, such as
22+
* sending messages or displaying context menu. Refer to [[WebviewApi]] for the full documentation.
1423
*/
1524
export default class JoplinViews {
1625
private store;

api/JoplinViewsEditor.d.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
import Plugin from '../Plugin';
2-
import { ActivationCheckCallback, ViewHandle, UpdateCallback } from './types';
2+
import { ActivationCheckCallback, ViewHandle, UpdateCallback, EditorPluginCallbacks } from './types';
3+
interface SaveNoteOptions {
4+
/**
5+
* The ID of the note to save. This should match either:
6+
* - The ID of the note currently being edited
7+
* - The ID of a note that was very recently open in the editor.
8+
*
9+
* This property is present to ensure that the note editor doesn't write
10+
* to the wrong note just after switching notes.
11+
*/
12+
noteId: string;
13+
/** The note's new content. */
14+
body: string;
15+
}
316
/**
417
* Allows creating alternative note editors. You can create a view to handle loading and saving the
518
* note, and do your own rendering.
@@ -41,10 +54,18 @@ export default class JoplinViewsEditors {
4154
private store;
4255
private plugin;
4356
private activationCheckHandlers_;
57+
private unhandledActivationCheck_;
4458
constructor(plugin: Plugin, store: any);
4559
private controller;
60+
/**
61+
* Registers a new editor plugin. Joplin will call the provided callback to create new editor views
62+
* associated with the plugin as necessary (e.g. when a new editor is created in a new window).
63+
*/
64+
register(viewId: string, callbacks: EditorPluginCallbacks): Promise<void>;
4665
/**
4766
* Creates a new editor view
67+
*
68+
* @deprecated
4869
*/
4970
create(id: string): Promise<ViewHandle>;
5071
/**
@@ -59,11 +80,18 @@ export default class JoplinViewsEditors {
5980
* See [[JoplinViewPanels]]
6081
*/
6182
onMessage(handle: ViewHandle, callback: Function): Promise<void>;
83+
/**
84+
* Saves the content of the editor, without calling `onUpdate` for editors in the same window.
85+
*/
86+
saveNote(handle: ViewHandle, props: SaveNoteOptions): Promise<void>;
6287
/**
6388
* Emitted when the editor can potentially be activated - this is for example when the current
6489
* note is changed, or when the application is opened. At that point you should check the
6590
* current note and decide whether your editor should be activated or not. If it should, return
6691
* `true`, otherwise return `false`.
92+
*
93+
* @deprecated - `onActivationCheck` should be provided when the editor is first created with
94+
* `editor.register`.
6795
*/
6896
onActivationCheck(handle: ViewHandle, callback: ActivationCheckCallback): Promise<void>;
6997
/**
@@ -86,3 +114,4 @@ export default class JoplinViewsEditors {
86114
*/
87115
isVisible(handle: ViewHandle): Promise<boolean>;
88116
}
117+
export {};

api/JoplinViewsPanels.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,9 @@ export default class JoplinViewsPanels {
8080
* Tells whether the panel is visible or not
8181
*/
8282
visible(handle: ViewHandle): Promise<boolean>;
83+
/**
84+
* Assuming that the current panel is an editor plugin view, returns
85+
* whether the editor plugin view supports editing the current note.
86+
*/
8387
isActive(handle: ViewHandle): Promise<boolean>;
8488
}

api/JoplinWorkspace.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ export default class JoplinWorkspace {
8080
filterEditorContextMenu(handler: FilterHandler<EditContextMenuFilterObject>): void;
8181
/**
8282
* Gets the currently selected note. Will be `null` if no note is selected.
83+
*
84+
* On desktop, this returns the selected note in the focused window.
8385
*/
8486
selectedNote(): Promise<any>;
8587
/**
@@ -93,5 +95,12 @@ export default class JoplinWorkspace {
9395
* Gets the IDs of the selected notes (can be zero, one, or many). Use the data API to retrieve information about these notes.
9496
*/
9597
selectedNoteIds(): Promise<string[]>;
98+
/**
99+
* Gets the last hash (note section ID) from cross-note link targeting specific section.
100+
* New hash is available after `onNoteSelectionChange()` is triggered.
101+
* Example of cross-note link where `hello-world` is a hash: [Other Note Title](:/9bc9a5cb83f04554bf3fd3e41b4bb415#hello-world).
102+
* Method returns empty value when a note was navigated with method other than cross-note link containing valid hash.
103+
*/
104+
selectedNoteHash(): Promise<string>;
96105
}
97106
export {};

api/types.ts

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,9 +397,40 @@ export interface Rectangle {
397397
height?: number;
398398
}
399399

400-
export type ActivationCheckCallback = ()=> Promise<boolean>;
400+
export interface EditorUpdateEvent {
401+
newBody: string;
402+
noteId: string;
403+
}
404+
export type UpdateCallback = (event: EditorUpdateEvent)=> Promise<void>;
405+
401406

402-
export type UpdateCallback = ()=> Promise<void>;
407+
export interface ActivationCheckEvent {
408+
handle: ViewHandle;
409+
noteId: string;
410+
}
411+
export type ActivationCheckCallback = (event: ActivationCheckEvent)=> Promise<boolean>;
412+
413+
/**
414+
* Required callbacks for creating an editor plugin.
415+
*/
416+
export interface EditorPluginCallbacks {
417+
/**
418+
* Emitted when the editor can potentially be activated - this is for example when the current
419+
* note is changed, or when the application is opened. At that point you should check the
420+
* current note and decide whether your editor should be activated or not. If it should, return
421+
* `true`, otherwise return `false`.
422+
*/
423+
onActivationCheck: ActivationCheckCallback;
424+
425+
/**
426+
* Emitted when an editor view is created. This happens, for example, when a new window containing
427+
* a new editor is created.
428+
*
429+
* This callback should set the editor plugin's HTML using `editors.setHtml`, add scripts to the editor
430+
* with `editors.addScript`, and optionally listen for external changes using `editors.onUpdate`.
431+
*/
432+
onSetup: (handle: ViewHandle)=> Promise<void>;
433+
}
403434

404435
export type VisibleHandler = ()=> Promise<void>;
405436

@@ -408,6 +439,8 @@ export interface EditContextMenuFilterObject {
408439
}
409440

410441
export interface EditorActivationCheckFilterObject {
442+
effectiveNoteId: string;
443+
windowId: string;
411444
activatedEditors: {
412445
pluginId: string;
413446
viewId: string;
@@ -417,6 +450,20 @@ export interface EditorActivationCheckFilterObject {
417450

418451
export type FilterHandler<T> = (object: T)=> Promise<T>;
419452

453+
export type CommandArgument = string|number|object|boolean|null;
454+
455+
export interface MenuTemplateItem {
456+
label?: string;
457+
command?: string;
458+
commandArgs?: CommandArgument[];
459+
}
460+
461+
export interface WebviewApi {
462+
postMessage: (message: object)=> unknown;
463+
onMessage: (message: object)=> void;
464+
menuPopupFromTemplate: (template: MenuTemplateItem[])=> void;
465+
}
466+
420467
// =================================================================
421468
// Settings types
422469
// =================================================================
@@ -541,6 +588,30 @@ export interface SettingSection {
541588
*/
542589
export type Path = string[];
543590

591+
// =================================================================
592+
// Clipboard API types
593+
// =================================================================
594+
595+
/**
596+
* Represents content that can be written to the clipboard in multiple formats.
597+
*/
598+
export interface ClipboardContent {
599+
/**
600+
* Plain text representation of the content
601+
*/
602+
text?: string;
603+
604+
/**
605+
* HTML representation of the content
606+
*/
607+
html?: string;
608+
609+
/**
610+
* Image in [data URL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) format
611+
*/
612+
image?: string;
613+
}
614+
544615
// =================================================================
545616
// Content Script types
546617
// =================================================================

docs/assets/sn-decryption.png

87.1 KB
Loading

docs/assets/sn-encryption.png

126 KB
Loading

0 commit comments

Comments
 (0)