1/* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit BasicServicesKit 19 */ 20 21import { AsyncCallback } from './@ohos.base'; 22import Want from './@ohos.app.ability.Want'; 23import image from './@ohos.multimedia.image'; 24/*** if arkts 1.1 */ 25import unifiedDataChannel from './@ohos.data.unifiedDataChannel'; 26/*** endif */ 27 28/** 29 * systemPasteboard 30 * @namespace pasteboard 31 * @syscap SystemCapability.MiscServices.Pasteboard 32 * @since 6 33 */ 34/** 35 * systemPasteboard 36 * @namespace pasteboard 37 * @syscap SystemCapability.MiscServices.Pasteboard 38 * @atomicservice 39 * @since arkts {'1.1':'11', '1.2':'20'} 40 * @arkts 1.1&1.2 41 */ 42declare namespace pasteboard { 43 /** 44 * Indicates the maximum number of records allowed in a PasteData object. 45 * @constant 46 * @syscap SystemCapability.MiscServices.Pasteboard 47 * @since 7 48 */ 49 /** 50 * Indicates the maximum number of records allowed in a PasteData object. 51 * No limit the number of records in a PasteData object since API version 10. 52 * @constant 53 * @syscap SystemCapability.MiscServices.Pasteboard 54 * @since 10 55 */ 56 /** 57 * Indicates the maximum number of records allowed in a PasteData object. 58 * No limit the number of records in a PasteData object since API version 10. 59 * @constant 60 * @syscap SystemCapability.MiscServices.Pasteboard 61 * @atomicservice 62 * @since arkts {'1.1':'11', '1.2':'20'} 63 * @arkts 1.1&1.2 64 */ 65 const MAX_RECORD_NUM = 512; 66 /** 67 * Indicates MIME types of HTML text. 68 * @constant 69 * @syscap SystemCapability.MiscServices.Pasteboard 70 * @since 7 71 */ 72 /** 73 * Indicates MIME types of HTML text. 74 * @constant 75 * @syscap SystemCapability.MiscServices.Pasteboard 76 * @atomicservice 77 * @since arkts {'1.1':'11', '1.2':'20'} 78 * @arkts 1.1&1.2 79 */ 80 const MIMETYPE_TEXT_HTML = 'text/html'; 81 /** 82 * Indicates MIME types of wants. 83 * @constant 84 * @syscap SystemCapability.MiscServices.Pasteboard 85 * @since 7 86 */ 87 /** 88 * Indicates MIME types of wants. 89 * @constant 90 * @syscap SystemCapability.MiscServices.Pasteboard 91 * @atomicservice 92 * @since arkts {'1.1':'11', '1.2':'20'} 93 * @arkts 1.1&1.2 94 */ 95 const MIMETYPE_TEXT_WANT = 'text/want'; 96 /** 97 * Indicates MIME types of plain text. 98 * @constant 99 * @syscap SystemCapability.MiscServices.Pasteboard 100 * @since 7 101 */ 102 /** 103 * Indicates MIME types of plain text. 104 * @constant 105 * @syscap SystemCapability.MiscServices.Pasteboard 106 * @atomicservice 107 * @since arkts {'1.1':'11', '1.2':'20'} 108 * @arkts 1.1&1.2 109 */ 110 const MIMETYPE_TEXT_PLAIN = 'text/plain'; 111 /** 112 * Indicates MIME types of URIs. 113 * @constant 114 * @syscap SystemCapability.MiscServices.Pasteboard 115 * @since 7 116 */ 117 /** 118 * Indicates MIME types of URIs. 119 * @constant 120 * @syscap SystemCapability.MiscServices.Pasteboard 121 * @atomicservice 122 * @since arkts {'1.1':'11', '1.2':'20'} 123 * @arkts 1.1&1.2 124 */ 125 const MIMETYPE_TEXT_URI = 'text/uri'; 126 /** 127 * Indicates MIME type of PixelMap. 128 * @constant 129 * @syscap SystemCapability.MiscServices.Pasteboard 130 * @since 9 131 */ 132 /** 133 * Indicates MIME type of PixelMap. 134 * @constant 135 * @syscap SystemCapability.MiscServices.Pasteboard 136 * @atomicservice 137 * @since arkts {'1.1':'11', '1.2':'20'} 138 * @arkts 1.1&1.2 139 */ 140 const MIMETYPE_PIXELMAP = 'pixelMap'; 141 142 /** 143 * Indicates type of value. 144 * @type { string | image.PixelMap | Want | ArrayBuffer } 145 * @syscap SystemCapability.MiscServices.Pasteboard 146 * @since 9 147 */ 148 /** 149 * Indicates type of value. 150 * @typedef { string | image.PixelMap | Want | ArrayBuffer } 151 * @syscap SystemCapability.MiscServices.Pasteboard 152 * @atomicservice 153 * @since arkts {'1.1':'11', '1.2':'20'} 154 * @arkts 1.1&1.2 155 */ 156 type ValueType = string | image.PixelMap | Want | ArrayBuffer; 157 158 /** 159 * Creates a PasteData object for PasteData#MIMETYPE_TEXT_HTML. 160 * @param { string } htmlText - To save the Html text content. 161 * @returns { PasteData } Containing the contents of the clipboard content object. 162 * @syscap SystemCapability.MiscServices.Pasteboard 163 * @since 7 164 * @deprecated since 9 165 * @useinstead ohos.pasteboard.pasteboard#createData 166 */ 167 function createHtmlData(htmlText: string): PasteData; 168 169 /** 170 * Creates a PasteData object for PasteData#MIMETYPE_TEXT_WANT. 171 * @param { Want } want - To save the want of content. 172 * @returns { PasteData } Containing the contents of the clipboard content object. 173 * @syscap SystemCapability.MiscServices.Pasteboard 174 * @since 7 175 * @deprecated since 9 176 * @useinstead ohos.pasteboard.pasteboard#createData 177 */ 178 function createWantData(want: Want): PasteData; 179 180 /** 181 * Creates a PasteData object for PasteData#MIMETYPE_TEXT_PLAIN. 182 * @param { string } text - To save the text of content. 183 * @returns { PasteData } Containing the contents of the clipboard content object. 184 * @syscap SystemCapability.MiscServices.Pasteboard 185 * @since 6 186 * @deprecated since 9 187 * @useinstead ohos.pasteboard.pasteboard#createData 188 */ 189 function createPlainTextData(text: string): PasteData; 190 191 /** 192 * Creates a PasteData object for PasteData#MIMETYPE_TEXT_URI. 193 * @param { string } uri - To save the uri of content. 194 * @returns { PasteData } Containing the contents of the clipboard content object. 195 * @syscap SystemCapability.MiscServices.Pasteboard 196 * @since 7 197 * @deprecated since 9 198 * @useinstead ohos.pasteboard.pasteboard#createData 199 */ 200 function createUriData(uri: string): PasteData; 201 202 /** 203 * Creates a PasteData object with MIME type and value. 204 * @param { string } mimeType - indicates MIME type of value, its size cannot be greater than 1024 bytes. 205 * @param { ValueType } value - indicates the content that is set to PasteData. 206 * @returns { PasteData } a new PasteData object which contains mimeType and value. 207 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 208 * 2. Incorrect parameters types; 209 * 3. Parameter verification failed. 210 * @syscap SystemCapability.MiscServices.Pasteboard 211 * @since 9 212 */ 213 /** 214 * Creates a PasteData object of the specified type. 215 * @param { string } mimeType - indicates MIME type of value, its size cannot be greater than 1024 bytes. 216 * @param { ValueType } value - indicates the content that is set to PasteData. 217 * @returns { PasteData } a new PasteData object which contains mimeType and value. 218 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 219 * 2. Incorrect parameters types; 220 * 3. Parameter verification failed. 221 * @syscap SystemCapability.MiscServices.Pasteboard 222 * @atomicservice 223 * @since arkts {'1.1':'11', '1.2':'20'} 224 * @arkts 1.1&1.2 225 */ 226 function createData(mimeType: string, value: ValueType): PasteData; 227 228 /** 229 * Creates a PasteData object with the specified MIME types and values. 230 * @param { Record<string, ValueType> } data - indicates the MEME types and values of the PasteData object to create. 231 * @returns { PasteData } Returns the PasteData object created. 232 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 233 * 2. Incorrect parameters types; 234 * 3. Parameter verification failed. 235 * @syscap SystemCapability.MiscServices.Pasteboard 236 * @since arkts {'1.1':'14', '1.2':'20'} 237 * @arkts 1.1&1.2 238 */ 239 function createData(data: Record<string, ValueType>): PasteData; 240 241 /** 242 * Creates a Record object for PasteData#MIMETYPE_TEXT_HTML. 243 * @param { string } htmlText - To save the Html text content. 244 * @returns { PasteDataRecord } The content of a new record 245 * @syscap SystemCapability.MiscServices.Pasteboard 246 * @since 7 247 * @deprecated since 9 248 * @useinstead ohos.pasteboard.pasteboard#createRecord 249 */ 250 function createHtmlTextRecord(htmlText: string): PasteDataRecord; 251 252 /** 253 * Creates a Record object for PasteData#MIMETYPE_TEXT_WANT. 254 * @param { Want } want - To save the want of content. 255 * @returns { PasteDataRecord } The content of a new record 256 * @syscap SystemCapability.MiscServices.Pasteboard 257 * @since 7 258 * @deprecated since 9 259 * @useinstead ohos.pasteboard.pasteboard#createRecord 260 */ 261 function createWantRecord(want: Want): PasteDataRecord; 262 263 /** 264 * Creates a Record object for PasteData#MIMETYPE_TEXT_PLAIN. 265 * @param { string } text - To save the text of content. 266 * @returns { PasteDataRecord } The content of a new record 267 * @syscap SystemCapability.MiscServices.Pasteboard 268 * @since 7 269 * @deprecated since 9 270 * @useinstead ohos.pasteboard.pasteboard#createRecord 271 */ 272 function createPlainTextRecord(text: string): PasteDataRecord; 273 274 /** 275 * Creates a Record object for PasteData#MIMETYPE_TEXT_URI. 276 * @param { string } uri - To save the uri of content. 277 * @returns { PasteDataRecord } The content of a new record 278 * @syscap SystemCapability.MiscServices.Pasteboard 279 * @since 7 280 * @deprecated since 9 281 * @useinstead ohos.pasteboard.pasteboard#createRecord 282 */ 283 function createUriRecord(uri: string): PasteDataRecord; 284 285 /** 286 * Creates a record object with MIME type and value. 287 * @param { string } mimeType - indicates MIME type of value, its size cannot be greater than 1024 bytes. 288 * @param { ValueType } value - content to be saved. 289 * @returns { PasteDataRecord } a new PasteDataRecord object which contains mimeType and value. 290 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 291 * 2. Incorrect parameters types; 292 * 3. Parameter verification failed. 293 * @syscap SystemCapability.MiscServices.Pasteboard 294 * @since 9 295 */ 296 /** 297 * Creates a PasteDataRecord object of the specified type. 298 * @param { string } mimeType - indicates MIME type of value, its size cannot be greater than 1024 bytes. 299 * @param { ValueType } value - Data content of the specified type. 300 * @returns { PasteDataRecord } A new paste data record of a specified type. 301 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 302 * 2. Incorrect parameters types; 303 * 3. Parameter verification failed. 304 * @syscap SystemCapability.MiscServices.Pasteboard 305 * @atomicservice 306 * @since 11 307 */ 308 function createRecord(mimeType: string, value: ValueType): PasteDataRecord; 309 310 /** 311 * get SystemPasteboard 312 * @returns { SystemPasteboard } The system clipboard object 313 * @syscap SystemCapability.MiscServices.Pasteboard 314 * @since 6 315 */ 316 /** 317 * get SystemPasteboard 318 * @returns { SystemPasteboard } The system clipboard object 319 * @syscap SystemCapability.MiscServices.Pasteboard 320 * @atomicservice 321 * @since arkts {'1.1':'11', '1.2':'20'} 322 * @arkts 1.1&1.2 323 */ 324 function getSystemPasteboard(): SystemPasteboard; 325 326 /** 327 * Types of scope that PasteData can be pasted. 328 * @enum { number } 329 * @syscap SystemCapability.MiscServices.Pasteboard 330 * @since 9 331 */ 332 /** 333 * Types of scope that PasteData can be pasted. 334 * @enum { number } 335 * @syscap SystemCapability.MiscServices.Pasteboard 336 * @atomicservice 337 * @since arkts {'1.1':'11', '1.2':'20'} 338 * @arkts 1.1&1.2 339 */ 340 enum ShareOption { 341 /** 342 * INAPP indicates that only paste in the same app is allowed. 343 * @syscap SystemCapability.MiscServices.Pasteboard 344 * @since 9 345 */ 346 /** 347 * INAPP indicates that only intra-application pasting is allowed. 348 * @syscap SystemCapability.MiscServices.Pasteboard 349 * @atomicservice 350 * @since arkts {'1.1':'11', '1.2':'20'} 351 * @arkts 1.1&1.2 352 */ 353 INAPP, 354 /** 355 * LOCALDEVICE indicates that paste in any app in this device is allowed. 356 * @syscap SystemCapability.MiscServices.Pasteboard 357 * @since 9 358 */ 359 /** 360 * LOCALDEVICE indicates that paste is allowed in any application. 361 * @syscap SystemCapability.MiscServices.Pasteboard 362 * @atomicservice 363 * @since arkts {'1.1':'11', '1.2':'20'} 364 * @arkts 1.1&1.2 365 */ 366 LOCALDEVICE, 367 /** 368 * CROSSDEVICE indicates that paste in any app across devices is allowed. 369 * @syscap SystemCapability.MiscServices.Pasteboard 370 * @since 9 371 */ 372 /** 373 * CROSSDEVICE indicates that paste is allowed in any application across devices. 374 * @syscap SystemCapability.MiscServices.Pasteboard 375 * @atomicservice 376 * @since arkts {'1.1':'11', '1.2':'20'} 377 * @arkts 1.1&1.2 378 * @deprecated since 12 379 */ 380 CROSSDEVICE 381 } 382 383 /** 384 * Enumerates the patterns allowed in the system pasteboard. 385 * @enum { number } 386 * @syscap SystemCapability.MiscServices.Pasteboard 387 * @since 13 388 */ 389 enum Pattern { 390 /** 391 * URL pattern. 392 * @syscap SystemCapability.MiscServices.Pasteboard 393 * @since 13 394 */ 395 URL = 0, 396 /** 397 * Number pattern. 398 * @syscap SystemCapability.MiscServices.Pasteboard 399 * @since 13 400 */ 401 NUMBER = 1, 402 /** 403 * Email address pattern. 404 * @syscap SystemCapability.MiscServices.Pasteboard 405 * @since 13 406 */ 407 EMAIL_ADDRESS = 2, 408 } 409 410 411 /** 412 * Paste data property. 413 * @interface PasteDataProperty 414 * @syscap SystemCapability.MiscServices.Pasteboard 415 * @since 7 416 */ 417 /** 418 * Defines the properties of all data records on the pasteboard, including the timestamp, data type, pasteable range, 419 * and additional data. The defined properties can be applied to the pasteboard only with the setProperty method. 420 * @interface PasteDataProperty 421 * @syscap SystemCapability.MiscServices.Pasteboard 422 * @atomicservice 423 * @since arkts {'1.1':'11', '1.2':'20'} 424 * @arkts 1.1&1.2 425 */ 426 interface PasteDataProperty { 427 /** 428 * additional property data. key-value pairs. 429 * @type { object } 430 * @syscap SystemCapability.MiscServices.Pasteboard 431 * @since 7 432 */ 433 /** 434 * additional property data. key-value pairs. 435 * @type { object } 436 * @syscap SystemCapability.MiscServices.Pasteboard 437 * @atomicservice 438 * @since 11 439 */ 440 additions: { 441 [key: string]: object 442 } 443 /** 444 * non-repeating MIME types of all records in PasteData. 445 * @type { Array<string> } 446 * @readonly 447 * @syscap SystemCapability.MiscServices.Pasteboard 448 * @since 7 449 */ 450 /** 451 * non-repeating MIME types of all records in PasteData. 452 * @type { Array<string> } 453 * @readonly 454 * @syscap SystemCapability.MiscServices.Pasteboard 455 * @atomicservice 456 * @since 11 457 */ 458 readonly mimeTypes: Array<string>; 459 /** 460 * the user-defined tag of a PasteData object. 461 * @type { string } 462 * @syscap SystemCapability.MiscServices.Pasteboard 463 * @since 7 464 */ 465 /** 466 * the user-defined tag of a PasteData object. 467 * @type { string } 468 * @syscap SystemCapability.MiscServices.Pasteboard 469 * @atomicservice 470 * @since arkts {'1.1':'11', '1.2':'20'} 471 * @arkts 1.1&1.2 472 */ 473 tag: string; 474 /** 475 * a timestamp, which indicates when data is written to the system pasteboard. 476 * @type { number } 477 * @readonly 478 * @syscap SystemCapability.MiscServices.Pasteboard 479 * @since 7 480 */ 481 /** 482 * a timestamp, which indicates when data is written to the system pasteboard. 483 * @type { number } 484 * @readonly 485 * @syscap SystemCapability.MiscServices.Pasteboard 486 * @atomicservice 487 * @since arkts {'1.1':'11', '1.2':'20'} 488 * @arkts 1.1&1.2 489 */ 490 readonly timestamp: number; 491 /** 492 * Checks whether PasteData is set for local access only. 493 * @type { boolean } 494 * @syscap SystemCapability.MiscServices.Pasteboard 495 * @since 7 496 */ 497 /** 498 * Checks whether PasteData is set for local access only. 499 * @type { boolean } 500 * @syscap SystemCapability.MiscServices.Pasteboard 501 * @atomicservice 502 * @since 11 503 */ 504 localOnly: boolean; 505 /** 506 * Indicates the scope of clipboard data which can be pasted. 507 * If it is not set or is incorrectly set, The default value is CrossDevice. 508 * @type { ShareOption } 509 * @syscap SystemCapability.MiscServices.Pasteboard 510 * @since 9 511 */ 512 /** 513 * Indicates the scope of clipboard data which can be pasted. 514 * If it is not set or is incorrectly set, The default value is CrossDevice. 515 * @type { ShareOption } 516 * @syscap SystemCapability.MiscServices.Pasteboard 517 * @atomicservice 518 * @since arkts {'1.1':'11', '1.2':'20'} 519 * @arkts 1.1&1.2 520 */ 521 shareOption: ShareOption; 522 } 523 524 /** 525 * Paste data record. 526 * @interface PasteDataRecord 527 * @syscap SystemCapability.MiscServices.Pasteboard 528 * @since 7 529 */ 530 /** 531 * Paste data record. 532 * @interface PasteDataRecord 533 * @syscap SystemCapability.MiscServices.Pasteboard 534 * @atomicservice 535 * @since arkts {'1.1':'11', '1.2':'20'} 536 * @arkts 1.1&1.2 537 */ 538 interface PasteDataRecord { 539 /** 540 * HTML text in a record. 541 * @type { string } 542 * @syscap SystemCapability.MiscServices.Pasteboard 543 * @since 7 544 */ 545 /** 546 * HTML text in a record. 547 * @type { string } 548 * @syscap SystemCapability.MiscServices.Pasteboard 549 * @atomicservice 550 * @since 11 551 */ 552 htmlText: string; 553 /** 554 * an want in a record. 555 * @type { Want } 556 * @syscap SystemCapability.MiscServices.Pasteboard 557 * @since 7 558 */ 559 /** 560 * an want in a record. 561 * @type { Want } 562 * @syscap SystemCapability.MiscServices.Pasteboard 563 * @atomicservice 564 * @since 11 565 */ 566 want: Want; 567 /** 568 * MIME types of a record. 569 * @type { string } 570 * @syscap SystemCapability.MiscServices.Pasteboard 571 * @since 7 572 */ 573 /** 574 * MIME types of a record. 575 * @type { string } 576 * @syscap SystemCapability.MiscServices.Pasteboard 577 * @atomicservice 578 * @since arkts {'1.1':'11', '1.2':'20'} 579 * @arkts 1.1&1.2 580 */ 581 mimeType: string; 582 /** 583 * plain text in a record. 584 * @type { string } 585 * @syscap SystemCapability.MiscServices.Pasteboard 586 * @since 7 587 */ 588 /** 589 * plain text in a record. 590 * @type { string } 591 * @syscap SystemCapability.MiscServices.Pasteboard 592 * @atomicservice 593 * @since arkts {'1.1':'11', '1.2':'20'} 594 * @arkts 1.1&1.2 595 */ 596 plainText: string; 597 /** 598 * an URI in a record. 599 * @type { string } 600 * @syscap SystemCapability.MiscServices.Pasteboard 601 * @since 7 602 */ 603 /** 604 * an URI in a record. 605 * @type { string } 606 * @syscap SystemCapability.MiscServices.Pasteboard 607 * @atomicservice 608 * @since arkts {'1.1':'11', '1.2':'20'} 609 * @arkts 1.1&1.2 610 */ 611 uri: string; 612 /** 613 * PixelMap in a record. 614 * @type { image.PixelMap } 615 * @syscap SystemCapability.MiscServices.Pasteboard 616 * @since 9 617 */ 618 /** 619 * PixelMap in a record. 620 * @type { image.PixelMap } 621 * @syscap SystemCapability.MiscServices.Pasteboard 622 * @atomicservice 623 * @since 11 624 */ 625 pixelMap: image.PixelMap; 626 /** 627 * Custom data in a record, mimeType indicates the MIME type of custom data, ArrayBuffer indicates the value of custom data. 628 * @type { object } 629 * @syscap SystemCapability.MiscServices.Pasteboard 630 * @since 9 631 */ 632 /** 633 * Custom data in a record, mimeType indicates the MIME type of custom data, ArrayBuffer indicates the value of custom data. 634 * @type { object } 635 * @syscap SystemCapability.MiscServices.Pasteboard 636 * @atomicservice 637 * @since 11 638 */ 639 data: { 640 [mimeType: string]: ArrayBuffer 641 } 642 643 /** 644 * Converts data in PasteData to text format. 645 * @param { AsyncCallback<string> } callback - the callback of convertToText. 646 * @throws { BusinessError } 401 - Possible causes: Incorrect parameters types. 647 * @syscap SystemCapability.MiscServices.Pasteboard 648 * @since 7 649 * @deprecated since 9 650 * @useinstead ohos.pasteboard.pasteboard#toPlainText 651 */ 652 convertToText(callback: AsyncCallback<string>): void; 653 654 /** 655 * Converts data in PasteData to text format. 656 * @returns { Promise<string> } the promise returned by the function. 657 * @syscap SystemCapability.MiscServices.Pasteboard 658 * @since 7 659 * @deprecated since 9 660 * @useinstead ohos.pasteboard.pasteboard#toPlainText 661 */ 662 convertToText(): Promise<string>; 663 664 /** 665 * Converts data in PasteData to text format. 666 * @returns { string } the string returned by the function. 667 * @syscap SystemCapability.MiscServices.Pasteboard 668 * @since 9 669 */ 670 /** 671 * Converts data in PasteData to text format. 672 * @returns { string } the string returned by the function. 673 * @syscap SystemCapability.MiscServices.Pasteboard 674 * @atomicservice 675 * @since 11 676 */ 677 toPlainText(): string; 678 679 /** 680 * Adds data to the PasteDataRecord object. 681 * @param { string } type - indicates MIME type of the value to add. It cannot exceed 1024 bytes. 682 * @param { ValueType } value - indicates the value of the data to add. 683 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 684 * 2. Incorrect parameters types; 685 * 3. Parameter verification failed. 686 * @syscap SystemCapability.MiscServices.Pasteboard 687 * @since 14 688 */ 689 addEntry(type: string, value: ValueType): void; 690 691 /** 692 * Obtains the valid types in the PasteDataRecord object. 693 * @param { Array<string> } types - indicates an array of types from which the valid types are obtained. 694 * @returns { Array<string> } Returns the valid types obtained. 695 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 696 * 2. Incorrect parameters types; 697 * 3. Parameter verification failed. 698 * @syscap SystemCapability.MiscServices.Pasteboard 699 * @since 14 700 */ 701 getValidTypes(types: Array<string>): Array<string>; 702 703 /** 704 * Obtains data of the specified type. 705 * @param { string } type - indicates the type of the data to obtain. 706 * @returns { Promise<ValueType> } Promise used to return the data obtained. 707 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 708 * 2. Incorrect parameters types; 709 * 3. Parameter verification failed. 710 * @syscap SystemCapability.MiscServices.Pasteboard 711 * @since 14 712 */ 713 getData(type: string): Promise<ValueType>; 714 } 715 716 /** 717 * Classes for paste data. 718 * @interface PasteData 719 * @syscap SystemCapability.MiscServices.Pasteboard 720 * @since 6 721 */ 722 /** 723 * Classes for paste data. 724 * @interface PasteData 725 * @syscap SystemCapability.MiscServices.Pasteboard 726 * @atomicservice 727 * @since arkts {'1.1':'11', '1.2':'20'} 728 * @arkts 1.1&1.2 729 */ 730 interface PasteData { 731 /** 732 * Adds a Record for HTML text to a PasteData object, and updates the MIME type to PasteData#MIMETYPE_TEXT_HTML in DataProperty. 733 * @param { string } htmlText - To save the Html text content. 734 * @syscap SystemCapability.MiscServices.Pasteboard 735 * @since 7 736 * @deprecated since 9 737 * @useinstead ohos.pasteboard.pasteboard#addRecord 738 */ 739 addHtmlRecord(htmlText: string): void; 740 741 /** 742 * Adds an want Record to a PasteData object, and updates the MIME type to PasteData#MIMETYPE_TEXT_WANT in DataProperty. 743 * @param { Want } want - To save the want content. 744 * @syscap SystemCapability.MiscServices.Pasteboard 745 * @since 7 746 * @deprecated since 9 747 * @useinstead ohos.pasteboard.pasteboard#addRecord 748 */ 749 addWantRecord(want: Want): void; 750 751 /** 752 * Adds a PasteRecord to a PasteData object and updates MIME types in DataProperty. 753 * @param { PasteDataRecord } record - The content of a new record. 754 * @syscap SystemCapability.MiscServices.Pasteboard 755 * @since 7 756 */ 757 /** 758 * Adds a PasteRecord to a PasteData object and updates MIME types in DataProperty. 759 * @param { PasteDataRecord } record - The content of a new record. 760 * @syscap SystemCapability.MiscServices.Pasteboard 761 * @atomicservice 762 * @since arkts {'1.1':'11', '1.2':'20'} 763 * @arkts 1.1&1.2 764 */ 765 addRecord(record: PasteDataRecord): void; 766 767 /** 768 * Adds a Record for plain text to a PasteData object, and updates the MIME type to PasteData#MIMETYPE_TEXT_PLAIN in DataProperty. 769 * @param { string } text - To save the text of content. 770 * @syscap SystemCapability.MiscServices.Pasteboard 771 * @since 7 772 * @deprecated since 9 773 * @useinstead ohos.pasteboard.pasteboard#addRecord 774 */ 775 addTextRecord(text: string): void; 776 777 /** 778 * Adds a URI Record to a PasteData object, and updates the MIME type to PasteData#MIMETYPE_TEXT_URI in DataProperty. 779 * @param { string } uri - To save the uri of content. 780 * @syscap SystemCapability.MiscServices.Pasteboard 781 * @since 7 782 * @deprecated since 9 783 * @useinstead ohos.pasteboard.pasteboard#addRecord 784 */ 785 addUriRecord(uri: string): void; 786 787 /** 788 * Adds a record with mimeType and value to a PasteData object. 789 * @param { string } mimeType - indicates the MIME type of value, its size cannot be greater than 1024 bytes. 790 * @param { ValueType } value - content to be saved. 791 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 792 * 2. Incorrect parameters types; 793 * 3. Parameter verification failed. 794 * @throws { BusinessError } 12900002 - The number of records exceeds the upper limit. 795 * @syscap SystemCapability.MiscServices.Pasteboard 796 * @since 9 797 */ 798 /** 799 * Adds a record with mimeType and value to a PasteData object. 800 * @param { string } mimeType - indicates the MIME type of value, its size cannot be greater than 1024 bytes. 801 * @param { ValueType } value - content to be saved. 802 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 803 * 2. Incorrect parameters types; 804 * 3. Parameter verification failed. 805 * @syscap SystemCapability.MiscServices.Pasteboard 806 * @since 10 807 */ 808 /** 809 * Adds a record with mimeType and value to a PasteData object. 810 * @param { string } mimeType - indicates the MIME type of value, its size cannot be greater than 1024 bytes. 811 * @param { ValueType } value - content to be saved. 812 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 813 * 2. Incorrect parameters types; 814 * 3. Parameter verification failed. 815 * @syscap SystemCapability.MiscServices.Pasteboard 816 * @atomicservice 817 * @since arkts {'1.1':'11', '1.2':'20'} 818 * @arkts 1.1&1.2 819 */ 820 addRecord(mimeType: string, value: ValueType): void; 821 822 /** 823 * MIME types of all content on the pasteboard. 824 * @returns { Array<string> } type of array 825 * @syscap SystemCapability.MiscServices.Pasteboard 826 * @since 7 827 */ 828 /** 829 * MIME types of all content on the pasteboard. 830 * @returns { Array<string> } type of array 831 * @syscap SystemCapability.MiscServices.Pasteboard 832 * @atomicservice 833 * @since 11 834 */ 835 getMimeTypes(): Array<string>; 836 837 /** 838 * HTML text of the primary record in a PasteData object. 839 * @returns { string } type of htmltext 840 * @syscap SystemCapability.MiscServices.Pasteboard 841 * @since 7 842 */ 843 /** 844 * HTML text of the primary record in a PasteData object. 845 * @returns { string } type of htmltext 846 * @syscap SystemCapability.MiscServices.Pasteboard 847 * @atomicservice 848 * @since 11 849 */ 850 getPrimaryHtml(): string; 851 852 /** 853 * the want of the primary record in a PasteData object. 854 * @returns { Want } type of want 855 * @syscap SystemCapability.MiscServices.Pasteboard 856 * @since 7 857 */ 858 /** 859 * the want of the primary record in a PasteData object. 860 * @returns { Want } type of want 861 * @syscap SystemCapability.MiscServices.Pasteboard 862 * @atomicservice 863 * @since 11 864 */ 865 getPrimaryWant(): Want; 866 867 /** 868 * the MIME type of the primary record in a PasteData object. 869 * @returns { string } type of mimetype 870 * @syscap SystemCapability.MiscServices.Pasteboard 871 * @since 7 872 */ 873 /** 874 * the MIME type of the primary record in a PasteData object. 875 * @returns { string } type of mimetype 876 * @syscap SystemCapability.MiscServices.Pasteboard 877 * @atomicservice 878 * @since 11 879 */ 880 getPrimaryMimeType(): string; 881 882 /** 883 * the plain text of the primary record in a PasteData object. 884 * @returns { string } type of text 885 * @syscap SystemCapability.MiscServices.Pasteboard 886 * @since 6 887 */ 888 /** 889 * the plain text of the primary record in a PasteData object. 890 * @returns { string } type of text 891 * @syscap SystemCapability.MiscServices.Pasteboard 892 * @atomicservice 893 * @since 11 894 */ 895 getPrimaryText(): string; 896 897 /** 898 * the URI of the primary record in a PasteData object. 899 * @returns { string } type of uri 900 * @syscap SystemCapability.MiscServices.Pasteboard 901 * @since 7 902 */ 903 /** 904 * the URI of the primary record in a PasteData object. 905 * @returns { string } type of uri 906 * @syscap SystemCapability.MiscServices.Pasteboard 907 * @atomicservice 908 * @since 11 909 */ 910 getPrimaryUri(): string; 911 912 /** 913 * Gets the primary PixelMap record in a PasteData object. 914 * @returns { image.PixelMap } pixelMap 915 * @syscap SystemCapability.MiscServices.Pasteboard 916 * @since 9 917 */ 918 /** 919 * Gets the primary PixelMap record in a PasteData object. 920 * @returns { image.PixelMap } pixelMap 921 * @syscap SystemCapability.MiscServices.Pasteboard 922 * @atomicservice 923 * @since 11 924 */ 925 getPrimaryPixelMap(): image.PixelMap; 926 927 /** 928 * DataProperty of a PasteData object. 929 * @returns { PasteDataProperty } PasteDataProperty type of PasteDataProperty 930 * @syscap SystemCapability.MiscServices.Pasteboard 931 * @since 7 932 */ 933 /** 934 * DataProperty of a PasteData object. 935 * @returns { PasteDataProperty } PasteDataProperty type of PasteDataProperty 936 * @syscap SystemCapability.MiscServices.Pasteboard 937 * @atomicservice 938 * @since arkts {'1.1':'11', '1.2':'20'} 939 * @arkts 1.1&1.2 940 */ 941 getProperty(): PasteDataProperty; 942 943 /** 944 * Sets PasteDataProperty to a PasteData object, Modifying shareOption is supported only. 945 * @param { PasteDataProperty } property - save property to PasteData object. 946 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 947 * 2. Incorrect parameters types. 948 * @syscap SystemCapability.MiscServices.Pasteboard 949 * @since 9 950 */ 951 /** 952 * Sets PasteDataProperty to a PasteData object, Modifying shareOption is supported only. 953 * @param { PasteDataProperty } property - save property to PasteData object. 954 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 955 * 2. Incorrect parameters types. 956 * @syscap SystemCapability.MiscServices.Pasteboard 957 * @atomicservice 958 * @since arkts {'1.1':'11', '1.2':'20'} 959 * @arkts 1.1&1.2 960 */ 961 setProperty(property: PasteDataProperty): void; 962 963 /** 964 * Gets record by index in PasteData. 965 * @param { number } index - indicates the record index in PasteData. 966 * @returns { PasteDataRecord } the record in PasteData with index. 967 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 968 * 2. Incorrect parameters types. 969 * @syscap SystemCapability.MiscServices.Pasteboard 970 * @since 7 971 * @deprecated since 9 972 * @useinstead ohos.pasteboard.pasteboard#getRecord 973 */ 974 getRecordAt(index: number): PasteDataRecord; 975 976 /** 977 * Gets record by index in PasteData. 978 * @param { number } index - indicates the record index in PasteData. 979 * @returns { PasteDataRecord } the record in PasteData with index. 980 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 981 * 2. Incorrect parameters types. 982 * @throws { BusinessError } 12900001 - The index is out of the record. 983 * @syscap SystemCapability.MiscServices.Pasteboard 984 * @since 9 985 */ 986 /** 987 * Gets record by index in PasteData. 988 * @param { number } index - indicates the record index in PasteData. 989 * @returns { PasteDataRecord } the record in PasteData with index. 990 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 991 * 2. Incorrect parameters types. 992 * @throws { BusinessError } 12900001 - The index is out of the record. 993 * @syscap SystemCapability.MiscServices.Pasteboard 994 * @atomicservice 995 * @since arkts {'1.1':'11', '1.2':'20'} 996 * @arkts 1.1&1.2 997 */ 998 getRecord(index: number): PasteDataRecord; 999 1000 /** 1001 * the number of records in a PasteData object. 1002 * @returns { number } The number of the clipboard contents 1003 * @syscap SystemCapability.MiscServices.Pasteboard 1004 * @since 7 1005 */ 1006 /** 1007 * the number of records in a PasteData object. 1008 * @returns { number } The number of the clipboard contents 1009 * @syscap SystemCapability.MiscServices.Pasteboard 1010 * @atomicservice 1011 * @since arkts {'1.1':'11', '1.2':'20'} 1012 * @arkts 1.1&1.2 1013 */ 1014 getRecordCount(): number; 1015 1016 /** 1017 * the user-defined tag of a PasteData object. 1018 * @returns { string } type of tag 1019 * @syscap SystemCapability.MiscServices.Pasteboard 1020 * @since 7 1021 */ 1022 /** 1023 * the user-defined tag of a PasteData object. 1024 * @returns { string } type of tag 1025 * @syscap SystemCapability.MiscServices.Pasteboard 1026 * @atomicservice 1027 * @since 11 1028 */ 1029 getTag(): string; 1030 1031 /** 1032 * Checks whether there is a specified MIME type of data in DataProperty. 1033 * @param { string } mimeType - indicates to query data type. 1034 * @returns { boolean } if having mimeType in PasteData returns true, else returns false. 1035 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1036 * 2. Incorrect parameters types. 1037 * @syscap SystemCapability.MiscServices.Pasteboard 1038 * @since 7 1039 * @deprecated since 9 1040 * @useinstead ohos.pasteboard.pasteboard#hasType 1041 */ 1042 hasMimeType(mimeType: string): boolean; 1043 1044 /** 1045 * Checks whether there is a specified MIME type of data in DataProperty. 1046 * @param { string } mimeType - indicates to query data type. 1047 * @returns { boolean } if having mimeType in PasteData returns true, else returns false. 1048 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1049 * 2. Incorrect parameters types. 1050 * @syscap SystemCapability.MiscServices.Pasteboard 1051 * @since 9 1052 */ 1053 /** 1054 * Checks whether there is a specified MIME type of data in DataProperty. 1055 * @param { string } mimeType - indicates to query data type. 1056 * @returns { boolean } if having mimeType in PasteData returns true, else returns false. 1057 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1058 * 2. Incorrect parameters types. 1059 * @syscap SystemCapability.MiscServices.Pasteboard 1060 * @atomicservice 1061 * @since 11 1062 */ 1063 hasType(mimeType: string): boolean; 1064 1065 /** 1066 * Removes a Record based on a specified index. 1067 * @param { number } index - indicates the record index in PasteData. 1068 * @returns { boolean } The query returns True on success, or False on failure. 1069 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1070 * 2. Incorrect parameters types. 1071 * @syscap SystemCapability.MiscServices.Pasteboard 1072 * @since 7 1073 * @deprecated since 9 1074 * @useinstead ohos.pasteboard.pasteboard#removeRecord 1075 */ 1076 removeRecordAt(index: number): boolean; 1077 1078 /** 1079 * Removes a Record based on a specified index. 1080 * @param { number } index - indicates the record index in PasteData. 1081 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1082 * 2. Incorrect parameters types. 1083 * @throws { BusinessError } 12900001 - The index is out of the record. 1084 * @syscap SystemCapability.MiscServices.Pasteboard 1085 * @since 9 1086 */ 1087 /** 1088 * Removes a Record based on a specified index. 1089 * @param { number } index - indicates the record index in PasteData. 1090 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1091 * 2. Incorrect parameters types. 1092 * @throws { BusinessError } 12900001 - The index is out of the record. 1093 * @syscap SystemCapability.MiscServices.Pasteboard 1094 * @atomicservice 1095 * @since 11 1096 */ 1097 removeRecord(index: number): void; 1098 1099 /** 1100 * Replaces a specified record with a new one. 1101 * @param { number } index - indicates the record index in PasteData. 1102 * @param { PasteDataRecord } record - the content of the replaced record. 1103 * @returns { boolean } The query returns True on success, or False on failure. 1104 * @syscap SystemCapability.MiscServices.Pasteboard 1105 * @since 7 1106 * @deprecated since 9 1107 * @useinstead ohos.pasteboard.pasteboard#replaceRecord 1108 */ 1109 replaceRecordAt(index: number, record: PasteDataRecord): boolean; 1110 1111 /** 1112 * Replaces a specified record with a new one. 1113 * @param { number } index - indicates the record index in PasteData. 1114 * @param { PasteDataRecord } record - the content of a new record. 1115 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1116 * 2. Incorrect parameters types. 1117 * @throws { BusinessError } 12900001 - The index is out of the record. 1118 * @syscap SystemCapability.MiscServices.Pasteboard 1119 * @since 9 1120 */ 1121 /** 1122 * Replaces a specified record with a new one. 1123 * @param { number } index - indicates the record index in PasteData. 1124 * @param { PasteDataRecord } record - the content of the replaced record. 1125 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1126 * 2. Incorrect parameters types. 1127 * @throws { BusinessError } 12900001 - The index is out of the record. 1128 * @syscap SystemCapability.MiscServices.Pasteboard 1129 * @atomicservice 1130 * @since 11 1131 */ 1132 replaceRecord(index: number, record: PasteDataRecord): void; 1133 1134 /** 1135 * Utilized to notify pasteboard service while reading PasteData, in this case, the service will help to preserve the context and resources 1136 * @syscap SystemCapability.MiscServices.Pasteboard 1137 * @since 12 1138 */ 1139 pasteStart(): void; 1140 1141 /** 1142 * Invoked to notify pasteboard service the utilization of PasteData has completed and occupied resources can be released for further usage 1143 * @syscap SystemCapability.MiscServices.Pasteboard 1144 * @since 12 1145 */ 1146 pasteComplete(): void; 1147 } 1148 1149 /** 1150 * Enumerates the types of file conflict options when getting data from the Pastedboard. 1151 * @enum { number } 1152 * @syscap SystemCapability.MiscServices.Pasteboard 1153 * @atomicservice 1154 * @since 15 1155 */ 1156 enum FileConflictOptions { 1157 /** 1158 * OVERWRITE overwrite when destUri has file with same name. 1159 * @syscap SystemCapability.MiscServices.Pasteboard 1160 * @atomicservice 1161 * @since 15 1162 */ 1163 OVERWRITE, 1164 1165 /** 1166 * SKIP skip when destUri has file with same name. 1167 * @syscap SystemCapability.MiscServices.Pasteboard 1168 * @atomicservice 1169 * @since 15 1170 */ 1171 SKIP 1172 } 1173 1174 /** 1175 * Enumerates the types of progress indicator when getting data from the Pastedboard. 1176 * @enum { number } 1177 * @syscap SystemCapability.MiscServices.Pasteboard 1178 * @atomicservice 1179 * @since 15 1180 */ 1181 enum ProgressIndicator { 1182 /** 1183 * NONE getting data without system default progress indicator. 1184 * @syscap SystemCapability.MiscServices.Pasteboard 1185 * @atomicservice 1186 * @since 15 1187 */ 1188 NONE, 1189 1190 /** 1191 * DEFALUT getting data with system default progress indicator. 1192 * @syscap SystemCapability.MiscServices.Pasteboard 1193 * @atomicservice 1194 * @since 15 1195 */ 1196 DEFAULT 1197 } 1198 1199 /** 1200 * Notifies progress when getting PasteData. 1201 * @interface ProgressInfo 1202 * @syscap SystemCapability.MiscServices.Pasteboard 1203 * @atomicservice 1204 * @since 15 1205 */ 1206 interface ProgressInfo { 1207 /** 1208 * Progress when getting PasteData without using default system progress. 1209 * @type { number } 1210 * @syscap SystemCapability.MiscServices.Pasteboard 1211 * @atomicservice 1212 * @since 15 1213 */ 1214 progress: number; 1215 } 1216 1217 /** 1218 * Indicates progress of getting PasteData. 1219 * @typedef { function } ProgressListener 1220 * @syscap SystemCapability.MiscServices.Pasteboard 1221 * @atomicservice 1222 * @since 15 1223 */ 1224 type ProgressListener = (progress: ProgressInfo) => void; 1225 1226 /** 1227 * Indicates the signals to process default system progress task. 1228 * @class ProgressSignal 1229 * @syscap SystemCapability.MiscServices.Pasteboard 1230 * @atomicservice 1231 * @since 15 1232 */ 1233 export class ProgressSignal { 1234 /** 1235 * Cancel the paste in progress. 1236 * @syscap SystemCapability.MiscServices.Pasteboard 1237 * @atomicservice 1238 * @since 15 1239 */ 1240 cancel(): void; 1241 } 1242 1243 /** 1244 * Represents the get data parameters when getting PasteData from Pasteboard. 1245 * @interface GetDataParams 1246 * @syscap SystemCapability.MiscServices.Pasteboard 1247 * @atomicservice 1248 * @since 15 1249 */ 1250 interface GetDataParams { 1251 /** 1252 * DestUri indicates the uri of dest path where copy files will be copied to sandbox of Application. 1253 * @type { ?string } 1254 * @default - 1255 * @syscap SystemCapability.MiscServices.Pasteboard 1256 * @atomicservice 1257 * @since 15 1258 */ 1259 destUri?: string; 1260 1261 /** 1262 * FileConflictOptions indicates fileConflictOptions when dest path has file with same name. 1263 * @type { ?FileConflictOptions } 1264 * @default FileConflictOptions.OVERWRITE 1265 * @syscap SystemCapability.MiscServices.Pasteboard 1266 * @atomicservice 1267 * @since 15 1268 */ 1269 fileConflictOptions?: FileConflictOptions; 1270 1271 /** 1272 * ProgressIndicator indicates whether to use default system progress indicator. 1273 * @type { ProgressIndicator } 1274 * @syscap SystemCapability.MiscServices.Pasteboard 1275 * @atomicservice 1276 * @since 15 1277 */ 1278 progressIndicator: ProgressIndicator; 1279 1280 /** 1281 * ProgressListener indicates progress listener when getting PasteDate without using default system progress. 1282 * @type { ?ProgressListener } 1283 * @default - 1284 * @syscap SystemCapability.MiscServices.Pasteboard 1285 * @atomicservice 1286 * @since 15 1287 */ 1288 progressListener?: ProgressListener; 1289 1290 /** 1291 * Progress signal when getting PasteData with system progress indacator. 1292 * @type { ?ProgressSignal } 1293 * @default - 1294 * @syscap SystemCapability.MiscServices.Pasteboard 1295 * @atomicservice 1296 * @since 15 1297 */ 1298 progressSignal?: ProgressSignal; 1299 } 1300 1301 /** 1302 * Classes for system pasteboard. 1303 * @interface SystemPasteboard 1304 * @syscap SystemCapability.MiscServices.Pasteboard 1305 * @since 6 1306 */ 1307 /** 1308 * Classes for system pasteboard. 1309 * @interface SystemPasteboard 1310 * @syscap SystemCapability.MiscServices.Pasteboard 1311 * @atomicservice 1312 * @since arkts {'1.1':'11', '1.2':'20'} 1313 * @arkts 1.1&1.2 1314 */ 1315 interface SystemPasteboard { 1316 /** 1317 * Callback invoked when pasteboard content changes. 1318 * @param { 'update' } type - indicates pasteboard content changed. 1319 * @param { function } callback - the callback to add. 1320 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1321 * 2. Incorrect parameters types. 1322 * @syscap SystemCapability.MiscServices.Pasteboard 1323 * @since 7 1324 */ 1325 on(type: 'update', callback: () => void): void; 1326 1327 /** 1328 * Remove a callback invoked when pasteboard content changes. 1329 * @param { 'update' } type - indicates pasteboard content changed. 1330 * @param { function } [callback] - the callback to remove. If this parameter is not filled in, it indicates that all 1331 * callbacks for this application will be cleared. Otherwise, it indicates that the specified callback will be cleared. 1332 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1333 * 2. Incorrect parameters types. 1334 * @syscap SystemCapability.MiscServices.Pasteboard 1335 * @since 7 1336 */ 1337 off(type: 'update', callback?: () => void): void; 1338 1339 /** 1340 * Checks whether the data is remote. 1341 * @returns { boolean } True is remote data, else false. 1342 * @throws { BusinessError } 12900005 - Excessive processing time for internal data. 1343 * @syscap SystemCapability.MiscServices.Pasteboard 1344 * @atomicservice 1345 * @since 11 1346 */ 1347 isRemoteData(): boolean; 1348 1349 /** 1350 * Obtains the application bundle name of the data source. 1351 * @returns { string } Application bundle name of the data source. 1352 * @throws { BusinessError } 12900005 - Excessive processing time for internal data. 1353 * @syscap SystemCapability.MiscServices.Pasteboard 1354 * @atomicservice 1355 * @since arkts {'1.1':'11', '1.2':'20'} 1356 * @arkts 1.1&1.2 1357 */ 1358 getDataSource(): string; 1359 1360 /** 1361 * Checks whether there is a specified MIME type of data in Data. 1362 * @param { string } mimeType - indicates to query data type. 1363 * @returns { boolean } if having mimeType in PasteData returns true, else returns false. 1364 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1365 * 2. Incorrect parameters types. 1366 * @throws { BusinessError } 12900005 - Excessive processing time for internal data. 1367 * @syscap SystemCapability.MiscServices.Pasteboard 1368 * @atomicservice 1369 * @since arkts {'1.1':'11', '1.2':'20'} 1370 * @arkts 1.1&1.2 1371 */ 1372 hasDataType(mimeType: string): boolean; 1373 1374 /** 1375 * Clears the pasteboard. 1376 * @param { AsyncCallback<void> } callback - the callback of clearData. 1377 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1378 * 2. Incorrect parameters types. 1379 * @syscap SystemCapability.MiscServices.Pasteboard 1380 * @since 7 1381 * @deprecated since 9 1382 * @useinstead ohos.pasteboard.pasteboard#clearData 1383 */ 1384 clear(callback: AsyncCallback<void>): void; 1385 1386 /** 1387 * Clears the pasteboard. 1388 * @returns { Promise<void> } the promise returned by the clearData. 1389 * @syscap SystemCapability.MiscServices.Pasteboard 1390 * @since 7 1391 * @deprecated since 9 1392 * @useinstead ohos.pasteboard.pasteboard#clearData 1393 */ 1394 clear(): Promise<void>; 1395 1396 /** 1397 * Clears the pasteboard. 1398 * @param { AsyncCallback<void> } callback - the callback of clearData. 1399 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1400 * 2. Incorrect parameters types. 1401 * @syscap SystemCapability.MiscServices.Pasteboard 1402 * @since 9 1403 */ 1404 /** 1405 * Clears the pasteboard. 1406 * @param { AsyncCallback<void> } callback - the callback of clearData. 1407 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1408 * 2. Incorrect parameters types. 1409 * @syscap SystemCapability.MiscServices.Pasteboard 1410 * @atomicservice 1411 * @since arkts {'1.1':'11', '1.2':'20'} 1412 * @arkts 1.1&1.2 1413 */ 1414 clearData(callback: AsyncCallback<void>): void; 1415 1416 /** 1417 * Clears the pasteboard. 1418 * @returns { Promise<void> } the promise returned by the clearData. 1419 * @syscap SystemCapability.MiscServices.Pasteboard 1420 * @since 9 1421 */ 1422 /** 1423 * Clears the pasteboard. 1424 * @returns { Promise<void> } the promise returned by the clearData. 1425 * @syscap SystemCapability.MiscServices.Pasteboard 1426 * @atomicservice 1427 * @since arkts {'1.1':'11', '1.2':'20'} 1428 * @arkts 1.1&1.2 1429 */ 1430 clearData(): Promise<void>; 1431 1432 /** 1433 * Clears the pasteboard. 1434 * @throws { BusinessError } 12900005 - Excessive processing time for internal data. 1435 * @syscap SystemCapability.MiscServices.Pasteboard 1436 * @atomicservice 1437 * @since 11 1438 */ 1439 clearDataSync(): void; 1440 1441 /** 1442 * Gets pastedata from the system pasteboard. 1443 * @param { AsyncCallback<PasteData> } callback - the callback of getData. 1444 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1445 * 2. Incorrect parameters types. 1446 * @syscap SystemCapability.MiscServices.Pasteboard 1447 * @since 6 1448 * @deprecated since 9 1449 * @useinstead ohos.pasteboard.pasteboard#getData 1450 */ 1451 getPasteData(callback: AsyncCallback<PasteData>): void; 1452 1453 /** 1454 * Gets pastedata from the system pasteboard. 1455 * @returns { Promise<PasteData> } the promise returned by the getData. 1456 * @syscap SystemCapability.MiscServices.Pasteboard 1457 * @since 6 1458 * @deprecated since 9 1459 * @useinstead ohos.pasteboard.pasteboard#getData 1460 */ 1461 getPasteData(): Promise<PasteData>; 1462 1463 /** 1464 * Gets pastedata from the system pasteboard. 1465 * @param { AsyncCallback<PasteData> } callback - the callback of getData. 1466 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1467 * 2. Incorrect parameters types. 1468 * @throws { BusinessError } 27787277 - Another copy or paste operation is in progress. 1469 * @syscap SystemCapability.MiscServices.Pasteboard 1470 * @since 9 1471 */ 1472 /** 1473 * Gets pastedata from the system pasteboard. 1474 * @param { AsyncCallback<PasteData> } callback - the callback of getData. 1475 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1476 * 2. Incorrect parameters types. 1477 * @throws { BusinessError } 27787277 - Another copy or paste operation is in progress. 1478 * @syscap SystemCapability.MiscServices.Pasteboard 1479 * @atomicservice 1480 * @since 11 1481 */ 1482 /** 1483 * Gets pastedata from the system pasteboard. 1484 * @permission ohos.permission.READ_PASTEBOARD 1485 * @param { AsyncCallback<PasteData> } callback - the callback of getData. 1486 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the 1487 * permission required to call the API. 1488 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1489 * 2. Incorrect parameters types. 1490 * @throws { BusinessError } 27787277 - Another copy or paste operation is in progress. 1491 * @syscap SystemCapability.MiscServices.Pasteboard 1492 * @atomicservice 1493 * @since 12 1494 */ 1495 getData(callback: AsyncCallback<PasteData>): void; 1496 1497 /** 1498 * Gets pastedata from the system pasteboard. 1499 * @returns { Promise<PasteData> } the promise returned by the getData. 1500 * @throws { BusinessError } 27787277 - Another copy or paste operation is in progress. 1501 * @syscap SystemCapability.MiscServices.Pasteboard 1502 * @since 9 1503 */ 1504 /** 1505 * Gets pastedata from the system pasteboard. 1506 * @returns { Promise<PasteData> } the promise returned by the getData. 1507 * @throws { BusinessError } 27787277 - Another copy or paste operation is in progress. 1508 * @syscap SystemCapability.MiscServices.Pasteboard 1509 * @atomicservice 1510 * @since 11 1511 */ 1512 /** 1513 * Gets pastedata from the system pasteboard. 1514 * @permission ohos.permission.READ_PASTEBOARD 1515 * @returns { Promise<PasteData> } the promise returned by the getData. 1516 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the 1517 * permission required to call the API. 1518 * @throws { BusinessError } 27787277 - Another copy or paste operation is in progress. 1519 * @syscap SystemCapability.MiscServices.Pasteboard 1520 * @atomicservice 1521 * @since 12 1522 */ 1523 getData(): Promise<PasteData>; 1524 1525 /** 1526 * Gets pasteData from the system pasteboard. 1527 * @returns { PasteData } a new PasteData. 1528 * @throws { BusinessError } 12900005 - Excessive processing time for internal data. 1529 * @syscap SystemCapability.MiscServices.Pasteboard 1530 * @atomicservice 1531 * @since 11 1532 */ 1533 /** 1534 * Gets pasteData from the system pasteboard. 1535 * @permission ohos.permission.READ_PASTEBOARD 1536 * @returns { PasteData } a new PasteData. 1537 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the 1538 * permission required to call the API. 1539 * @throws { BusinessError } 12900005 - Excessive processing time for internal data. 1540 * @syscap SystemCapability.MiscServices.Pasteboard 1541 * @atomicservice 1542 * @since arkts {'1.1':'12', '1.2':'20'} 1543 * @arkts 1.1&1.2 1544 */ 1545 getDataSync(): PasteData; 1546 1547 /** 1548 * Checks whether there is content in the pasteboard. 1549 * @param { AsyncCallback<boolean> } callback - the callback of setPasteData. 1550 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1551 * 2. Incorrect parameters types. 1552 * @syscap SystemCapability.MiscServices.Pasteboard 1553 * @since 7 1554 * @deprecated since 9 1555 * @useinstead ohos.pasteboard.pasteboard#hasData 1556 */ 1557 hasPasteData(callback: AsyncCallback<boolean>): void; 1558 1559 /** 1560 * Checks whether there is content in the pasteboard. 1561 * @returns { Promise<boolean> } the promise returned by the function. 1562 * @syscap SystemCapability.MiscServices.Pasteboard 1563 * @since 7 1564 * @deprecated since 9 1565 * @useinstead ohos.pasteboard.pasteboard#hasData 1566 */ 1567 hasPasteData(): Promise<boolean>; 1568 1569 /** 1570 * Checks whether there is content in the system pasteboard. 1571 * @param { AsyncCallback<boolean> } callback - the callback of hasData. 1572 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1573 * 2. Incorrect parameters types. 1574 * @syscap SystemCapability.MiscServices.Pasteboard 1575 * @since 9 1576 */ 1577 /** 1578 * Checks whether there is content in the system pasteboard. 1579 * @param { AsyncCallback<boolean> } callback - the callback of hasData. 1580 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1581 * 2. Incorrect parameters types. 1582 * @syscap SystemCapability.MiscServices.Pasteboard 1583 * @atomicservice 1584 * @since 11 1585 */ 1586 hasData(callback: AsyncCallback<boolean>): void; 1587 1588 /** 1589 * Checks whether there is content in the system pasteboard. 1590 * @returns { Promise<boolean> } the promise returned by the function. 1591 * @syscap SystemCapability.MiscServices.Pasteboard 1592 * @since 9 1593 */ 1594 /** 1595 * Checks whether there is content in the system pasteboard. 1596 * @returns { Promise<boolean> } the promise returned by the function. 1597 * @syscap SystemCapability.MiscServices.Pasteboard 1598 * @atomicservice 1599 * @since 11 1600 */ 1601 hasData(): Promise<boolean>; 1602 1603 /** 1604 * Checks whether there is content in the system pasteboard. 1605 * @returns { boolean } True exists, false does not exist. 1606 * @throws { BusinessError } 12900005 - Excessive processing time for internal data. 1607 * @syscap SystemCapability.MiscServices.Pasteboard 1608 * @atomicservice 1609 * @since 11 1610 */ 1611 hasDataSync(): boolean; 1612 1613 /** 1614 * Writes PasteData to the pasteboard. 1615 * @param { PasteData } data - PasteData will be written to the clipboard 1616 * @param { AsyncCallback<void> } callback - the callback of setPasteData. 1617 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1618 * 2. Incorrect parameters types. 1619 * @syscap SystemCapability.MiscServices.Pasteboard 1620 * @since 6 1621 * @deprecated since 9 1622 * @useinstead ohos.pasteboard.pasteboard#setData 1623 */ 1624 setPasteData(data: PasteData, callback: AsyncCallback<void>): void; 1625 1626 /** 1627 * Writes PasteData to the pasteboard. 1628 * @param { PasteData } data - Containing the contents of the clipboard content object. 1629 * @returns { Promise<void> } the promise returned by the function. 1630 * @syscap SystemCapability.MiscServices.Pasteboard 1631 * @since 6 1632 * @deprecated since 9 1633 * @useinstead ohos.pasteboard.pasteboard#setData 1634 */ 1635 setPasteData(data: PasteData): Promise<void>; 1636 1637 /** 1638 * Writes PasteData to the system pasteboard. 1639 * @param { PasteData } data - PasteData will be written to the clipboard 1640 * @param { AsyncCallback<void> } callback - the callback of setData. 1641 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified. 1642 * 2. Incorrect parameters types. 1643 * @throws { BusinessError } 27787277 - Another copy or paste operation is in progress. 1644 * @throws { BusinessError } 27787278 - Replication is prohibited. 1645 * @syscap SystemCapability.MiscServices.Pasteboard 1646 * @since 9 1647 */ 1648 /** 1649 * Writes PasteData to the system pasteboard. 1650 * @param { PasteData } data - PasteData will be written to the clipboard 1651 * @param { AsyncCallback<void> } callback - the callback of setData. 1652 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1653 * 2. Incorrect parameters types. 1654 * @throws { BusinessError } 27787277 - Another copy or paste operation is in progress. 1655 * @throws { BusinessError } 27787278 - Replication is prohibited. 1656 * @syscap SystemCapability.MiscServices.Pasteboard 1657 * @atomicservice 1658 * @since arkts {'1.1':'11', '1.2':'20'} 1659 * @arkts 1.1&1.2 1660 */ 1661 setData(data: PasteData, callback: AsyncCallback<void>): void; 1662 1663 /** 1664 * Writes PasteData to the system pasteboard. 1665 * @param { PasteData } data - PasteData will be written to the clipboard. 1666 * @returns { Promise<void> } the promise returned by the function. 1667 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1668 * 2. Incorrect parameters types. 1669 * @throws { BusinessError } 27787277 - Another copy or paste operation is in progress. 1670 * @throws { BusinessError } 27787278 - Replication is prohibited. 1671 * @syscap SystemCapability.MiscServices.Pasteboard 1672 * @since 9 1673 */ 1674 /** 1675 * Writes PasteData to the system pasteboard. 1676 * @param { PasteData } data - PasteData will be written to the clipboard. 1677 * @returns { Promise<void> } the promise returned by the function. 1678 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1679 * 2. Incorrect parameters types. 1680 * @throws { BusinessError } 27787277 - Another copy or paste operation is in progress. 1681 * @throws { BusinessError } 27787278 - Replication is prohibited. 1682 * @syscap SystemCapability.MiscServices.Pasteboard 1683 * @atomicservice 1684 * @since arkts {'1.1':'11', '1.2':'20'} 1685 * @arkts 1.1&1.2 1686 */ 1687 setData(data: PasteData): Promise<void>; 1688 1689 /** 1690 * Writes PasteData to the system pasteboard. 1691 * @param { PasteData } data - PasteData will be written to the clipboard. 1692 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1693 * 2. Incorrect parameters types. 1694 * @throws { BusinessError } 12900005 - Excessive processing time for internal data. 1695 * @syscap SystemCapability.MiscServices.Pasteboard 1696 * @atomicservice 1697 * @since 11 1698 */ 1699 setDataSync(data: PasteData): void; 1700 1701 /** 1702 * Gets unified data from the system pasteboard. 1703 * @permission ohos.permission.READ_PASTEBOARD 1704 * @returns { Promise<unifiedDataChannel.UnifiedData> } the promise returned by the getData. 1705 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the 1706 * permission required to call the API. 1707 * @throws { BusinessError } 27787277 - Another copy or paste operation is in progress. 1708 * @syscap SystemCapability.MiscServices.Pasteboard 1709 * @atomicservice 1710 * @since 12 1711 */ 1712 getUnifiedData(): Promise<unifiedDataChannel.UnifiedData>; 1713 1714 /** 1715 * Gets unified data from the system pasteboard. 1716 * @permission ohos.permission.READ_PASTEBOARD 1717 * @returns { unifiedDataChannel.UnifiedData } a new UnifiedData. 1718 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the 1719 * permission required to call the API. 1720 * @throws { BusinessError } 12900005 - Excessive processing time for internal data. 1721 * @syscap SystemCapability.MiscServices.Pasteboard 1722 * @atomicservice 1723 * @since 12 1724 */ 1725 getUnifiedDataSync(): unifiedDataChannel.UnifiedData; 1726 1727 /** 1728 * Writes unified data to the system pasteboard. 1729 * @param { unifiedDataChannel.UnifiedData } data - Unified data will be written to the pasteboard. 1730 * @returns { Promise<void> } the promise returned by the function. 1731 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1732 * 2. Incorrect parameters types. 1733 * @throws { BusinessError } 27787277 - Another copy or paste operation is in progress. 1734 * @throws { BusinessError } 27787278 - Replication is prohibited. 1735 * @syscap SystemCapability.MiscServices.Pasteboard 1736 * @atomicservice 1737 * @since 12 1738 */ 1739 setUnifiedData(data: unifiedDataChannel.UnifiedData): Promise<void>; 1740 1741 /** 1742 * Writes unified data to the system pasteboard. 1743 * @param { unifiedDataChannel.UnifiedData } data - Unified data will be written to the pasteboard. 1744 * @throws { BusinessError } 401 - Possible causes: 1. Mandatory parameters are left unspecified; 1745 * 2. Incorrect parameters types. 1746 * @throws { BusinessError } 12900005 - Excessive processing time for internal data. 1747 * @syscap SystemCapability.MiscServices.Pasteboard 1748 * @atomicservice 1749 * @since 12 1750 */ 1751 setUnifiedDataSync(data: unifiedDataChannel.UnifiedData): void; 1752 1753 /** 1754 * Sets a unified ShareOptions for your application, so that the PasteData copied from your application is applicable to this ShareOptions. 1755 * 1756 * @param { ShareOption } shareOptions - Scope that PasteData can be pasted. 1757 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 1758 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1759 * 2. Incorrect parameter types; 1760 * 3. Parameter verification failed. 1761 * @throws { BusinessError } 12900006 - Settings already exist. 1762 * @syscap SystemCapability.MiscServices.Pasteboard 1763 * @systemapi 1764 * @since 12 1765 */ 1766 /** 1767 * Sets a unified ShareOptions for your application, so that the PasteData copied from your application is applicable to this ShareOptions. 1768 * 1769 * @permission ohos.permission.MANAGE_PASTEBOARD_APP_SHARE_OPTION 1770 * @param { ShareOption } shareOptions - Scope that PasteData can be pasted, The parameter can only be set InApp. 1771 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the 1772 * permission required to call the API. 1773 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1774 * 2. Incorrect parameter types; 1775 * 3. Parameter verification failed. 1776 * @throws { BusinessError } 12900006 - Settings already exist. 1777 * @syscap SystemCapability.MiscServices.Pasteboard 1778 * @since 14 1779 */ 1780 setAppShareOptions(shareOptions: ShareOption): void; 1781 1782 /** 1783 * Removes the unified ShareOptions of your application. 1784 * 1785 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 1786 * @syscap SystemCapability.MiscServices.Pasteboard 1787 * @systemapi 1788 * @since 12 1789 */ 1790 /** 1791 * Removes the unified ShareOptions of your application. 1792 * 1793 * @permission ohos.permission.MANAGE_PASTEBOARD_APP_SHARE_OPTION 1794 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the 1795 * permission required to call the API. 1796 * @syscap SystemCapability.MiscServices.Pasteboard 1797 * @since 14 1798 */ 1799 removeAppShareOptions(): void; 1800 1801 /** 1802 * Detects the patterns in the pasteboard. 1803 * 1804 * @param { Array<Pattern> } patterns - Patterns to detect. 1805 * @returns { Promise<Array<Pattern>> } Promise used to return the patterns detected. 1806 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1807 * 2. Incorrect parameter types; 1808 * 3. Parameter verification failed. 1809 * @syscap SystemCapability.MiscServices.Pasteboard 1810 * @since 13 1811 */ 1812 detectPatterns(patterns: Array<Pattern>): Promise<Array<Pattern>>; 1813 1814 /** 1815 * Get the MIME types in the pasteboard. 1816 * 1817 * @returns { Promise<Array<string>> } Promise used to return the MIME types. 1818 * @syscap SystemCapability.MiscServices.Pasteboard 1819 * @atomicservice 1820 * @since 14 1821 */ 1822 getMimeTypes(): Promise<Array<string>>; 1823 1824 /** 1825 * Gets the number of Pasteboard data changes. 1826 * 1827 * @returns { number } The number of Pasteboard data changes. 1828 * @syscap SystemCapability.MiscServices.Pasteboard 1829 * @atomicservice 1830 * @since 18 1831 */ 1832 getChangeCount(): number; 1833 1834 /** 1835 * Gets pastedata from the system pasteboard with system progress. 1836 * 1837 * @permission ohos.permission.READ_PASTEBOARD 1838 * @param { GetDataParams } params - Indicates the {@link GetDataParams}. 1839 * @returns { Promise<PasteData> } The promise returned by the getData. 1840 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the 1841 * permission required to call the API. 1842 * @throws { BusinessError } 401 - Parameter error. 1843 * @throws { BusinessError } 12900003 - Another copy or paste operation is in progress. 1844 * @throws { BusinessError } 12900007 - Invalid destUri or file system error. 1845 * @throws { BusinessError } 12900008 - Failed to start progress. 1846 * @throws { BusinessError } 12900009 - Progress exits abnormally. 1847 * @throws { BusinessError } 12900010 - System error occurred during paste execution. 1848 * @syscap SystemCapability.MiscServices.Pasteboard 1849 * @atomicservice 1850 * @since 15 1851 */ 1852 getDataWithProgress(params: GetDataParams): Promise<PasteData>; 1853 } 1854} 1855 1856export default pasteboard; 1857