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 */ 15import { AsyncCallback } from './@ohos.base'; 16import Want from './@ohos.app.ability.Want'; 17import image from './@ohos.multimedia.image'; 18 19/** 20 * systemPasteboard 21 * @namespace pasteboard 22 * @syscap SystemCapability.MiscServices.Pasteboard 23 */ 24declare namespace pasteboard { 25 /** 26 * Indicates the maximum number of records allowed in a PasteData object. 27 * @constant 28 * @syscap SystemCapability.MiscServices.Pasteboard 29 * @since 7 30 */ 31 const MAX_RECORD_NUM: number; 32 /** 33 * Indicates MIME types of HTML text. 34 * @constant 35 * @syscap SystemCapability.MiscServices.Pasteboard 36 * @since 7 37 */ 38 const MIMETYPE_TEXT_HTML: string; 39 /** 40 * Indicates MIME types of wants. 41 * @constant 42 * @syscap SystemCapability.MiscServices.Pasteboard 43 * @since 7 44 */ 45 const MIMETYPE_TEXT_WANT: string; 46 /** 47 * Indicates MIME types of plain text. 48 * @constant 49 * @syscap SystemCapability.MiscServices.Pasteboard 50 * @since 7 51 */ 52 const MIMETYPE_TEXT_PLAIN: string; 53 /** 54 * Indicates MIME types of URIs. 55 * @constant 56 * @syscap SystemCapability.MiscServices.Pasteboard 57 * @since 7 58 */ 59 const MIMETYPE_TEXT_URI: string; 60 /** 61 * Indicates MIME type of PixelMap. 62 * @constant 63 * @syscap SystemCapability.MiscServices.Pasteboard 64 * @since 9 65 */ 66 const MIMETYPE_PIXELMAP: string; 67 68 /** 69 * Indicates type of value. 70 * @type { string | image.PixelMap | Want | ArrayBuffer } 71 * @syscap SystemCapability.MiscServices.Pasteboard 72 * @since 9 73 */ 74 type ValueType = string | image.PixelMap | Want | ArrayBuffer; 75 76 /** 77 * Creates a PasteData object for PasteData#MIMETYPE_TEXT_HTML. 78 * @param { string } htmlText - To save the Html text content. 79 * @returns { PasteData } Containing the contents of the clipboard content object. 80 * @syscap SystemCapability.MiscServices.Pasteboard 81 * @since 7 82 * @deprecated since 9 83 * @useinstead ohos.pasteboard.pasteboard#createData 84 */ 85 function createHtmlData(htmlText: string): PasteData; 86 87 /** 88 * Creates a PasteData object for PasteData#MIMETYPE_TEXT_WANT. 89 * @param { Want } want - To save the want of content. 90 * @returns { PasteData } Containing the contents of the clipboard content object. 91 * @syscap SystemCapability.MiscServices.Pasteboard 92 * @since 7 93 * @deprecated since 9 94 * @useinstead ohos.pasteboard.pasteboard#createData 95 */ 96 function createWantData(want: Want): PasteData; 97 98 /** 99 * Creates a PasteData object for PasteData#MIMETYPE_TEXT_PLAIN. 100 * @param { string } text - To save the text of content. 101 * @returns { PasteData } Containing the contents of the clipboard content object. 102 * @syscap SystemCapability.MiscServices.Pasteboard 103 * @since 6 104 * @deprecated since 9 105 * @useinstead ohos.pasteboard.pasteboard#createData 106 */ 107 function createPlainTextData(text: string): PasteData; 108 109 /** 110 * Creates a PasteData object for PasteData#MIMETYPE_TEXT_URI. 111 * @param { string } uri - To save the uri of content. 112 * @returns { PasteData } Containing the contents of the clipboard content object. 113 * @syscap SystemCapability.MiscServices.Pasteboard 114 * @since 7 115 * @deprecated since 9 116 * @useinstead ohos.pasteboard.pasteboard#createData 117 */ 118 function createUriData(uri: string): PasteData; 119 120 /** 121 * Creates a PasteData object with MIME type and value. 122 * @param { string } mimeType - indicates MIME type of value. 123 * @param { ValueType } value - indicates the content that is set to PasteData. 124 * @returns { PasteData } a new PasteData object which contains mimeType and value. 125 * @throws { BusinessError } 401 - if type of mimeType is not string, or the value can not match the mimeType correctly. 126 * @syscap SystemCapability.MiscServices.Pasteboard 127 * @since 9 128 */ 129 function createData(mimeType: string, value: ValueType): PasteData; 130 131 /** 132 * Creates a Record object for PasteData#MIMETYPE_TEXT_HTML. 133 * @param { string } htmlText - To save the Html text content. 134 * @returns { PasteDataRecord } The content of a new record 135 * @syscap SystemCapability.MiscServices.Pasteboard 136 * @since 7 137 * @deprecated since 9 138 * @useinstead ohos.pasteboard.pasteboard#createRecord 139 */ 140 function createHtmlTextRecord(htmlText: string): PasteDataRecord; 141 142 /** 143 * Creates a Record object for PasteData#MIMETYPE_TEXT_WANT. 144 * @param { Want } want - To save the want of content. 145 * @returns { PasteDataRecord } The content of a new record 146 * @syscap SystemCapability.MiscServices.Pasteboard 147 * @since 7 148 * @deprecated since 9 149 * @useinstead ohos.pasteboard.pasteboard#createRecord 150 */ 151 function createWantRecord(want: Want): PasteDataRecord; 152 153 /** 154 * Creates a Record object for PasteData#MIMETYPE_TEXT_PLAIN. 155 * @param { string } text - To save the text of content. 156 * @returns { PasteDataRecord } The content of a new record 157 * @syscap SystemCapability.MiscServices.Pasteboard 158 * @since 7 159 * @deprecated since 9 160 * @useinstead ohos.pasteboard.pasteboard#createRecord 161 */ 162 function createPlainTextRecord(text: string): PasteDataRecord; 163 164 /** 165 * Creates a Record object for PasteData#MIMETYPE_TEXT_URI. 166 * @param { string } uri - To save the uri of content. 167 * @returns { PasteDataRecord } The content of a new record 168 * @syscap SystemCapability.MiscServices.Pasteboard 169 * @since 7 170 * @deprecated since 9 171 * @useinstead ohos.pasteboard.pasteboard#createRecord 172 */ 173 function createUriRecord(uri: string): PasteDataRecord; 174 175 /** 176 * Creates a record object with MIME type and value. 177 * @param { string } mimeType - indicates MIME type of value. 178 * @param { ValueType } value - content to be saved. 179 * @returns { PasteDataRecord } a new PasteDataRecord object which contains mimeType and value. 180 * @throws { BusinessError } 401 - if type of mimeType is not string, or the value can not match the mimeType correctly. 181 * @syscap SystemCapability.MiscServices.Pasteboard 182 * @since 9 183 */ 184 function createRecord(mimeType: string, value: ValueType): PasteDataRecord; 185 186 /** 187 * get SystemPasteboard 188 * @returns { SystemPasteboard } The system clipboard object 189 * @syscap SystemCapability.MiscServices.Pasteboard 190 * @since 6 191 */ 192 function getSystemPasteboard(): SystemPasteboard; 193 194 /** 195 * Types of scope that PasteData can be pasted. 196 * @enum { number } 197 * @syscap SystemCapability.MiscServices.Pasteboard 198 * @since 9 199 */ 200 enum ShareOption { 201 /** 202 * INAPP indicates that only paste in the same app is allowed. 203 * @syscap SystemCapability.MiscServices.Pasteboard 204 * @since 9 205 */ 206 INAPP, 207 /** 208 * LOCALDEVICE indicates that paste in any app in this device is allowed. 209 * @syscap SystemCapability.MiscServices.Pasteboard 210 * @since 9 211 */ 212 LOCALDEVICE, 213 /** 214 * CROSSDEVICE indicates that paste in any app across devices is allowed. 215 * @syscap SystemCapability.MiscServices.Pasteboard 216 * @since 9 217 */ 218 CROSSDEVICE 219 } 220 221 /** 222 * Paste data property. 223 * @interface PasteDataProperty 224 * @syscap SystemCapability.MiscServices.Pasteboard 225 */ 226 interface PasteDataProperty { 227 /** 228 * additional property data. key-value pairs. 229 * @type { [key: string]: object } 230 * @syscap SystemCapability.MiscServices.Pasteboard 231 * @since 7 232 */ 233 additions: { 234 [key: string]: object 235 } 236 /** 237 * non-repeating MIME types of all records in PasteData. 238 * @type { Array<string> } 239 * @readonly 240 * @syscap SystemCapability.MiscServices.Pasteboard 241 * @since 7 242 */ 243 readonly mimeTypes: Array<string>; 244 /** 245 * the user-defined tag of a PasteData object. 246 * @type { string } 247 * @syscap SystemCapability.MiscServices.Pasteboard 248 * @since 7 249 */ 250 tag: string; 251 /** 252 * a timestamp, which indicates when data is written to the system pasteboard. 253 * @type { number } 254 * @readonly 255 * @syscap SystemCapability.MiscServices.Pasteboard 256 * @since 7 257 */ 258 readonly timestamp: number; 259 /** 260 * Checks whether PasteData is set for local access only. 261 * @type { boolean } 262 * @syscap SystemCapability.MiscServices.Pasteboard 263 * @since 7 264 */ 265 localOnly: boolean; 266 /** 267 * Indicates the scope of clipboard data which can be pasted. 268 * If it is not set or is incorrectly set, The default value is CrossDevice. 269 * @type { ShareOption } 270 * @syscap SystemCapability.MiscServices.Pasteboard 271 * @since 9 272 */ 273 shareOption: ShareOption; 274 } 275 276 /** 277 * Paste data record. 278 * @interface PasteDataRecord 279 * @syscap SystemCapability.MiscServices.Pasteboard 280 */ 281 interface PasteDataRecord { 282 /** 283 * HTML text in a record. 284 * @type { string } 285 * @syscap SystemCapability.MiscServices.Pasteboard 286 * @since 7 287 */ 288 htmlText: string; 289 /** 290 * an want in a record. 291 * @type { Want } 292 * @syscap SystemCapability.MiscServices.Pasteboard 293 * @since 7 294 */ 295 want: Want; 296 /** 297 * MIME types of a record. 298 * @type { string } 299 * @syscap SystemCapability.MiscServices.Pasteboard 300 * @since 7 301 */ 302 mimeType: string; 303 /** 304 * plain text in a record. 305 * @type { string } 306 * @syscap SystemCapability.MiscServices.Pasteboard 307 * @since 7 308 */ 309 plainText: string; 310 /** 311 * an URI in a record. 312 * @type { string } 313 * @syscap SystemCapability.MiscServices.Pasteboard 314 * @since 7 315 */ 316 uri: string; 317 /** 318 * PixelMap in a record. 319 * @type { image.PixelMap } 320 * @syscap SystemCapability.MiscServices.Pasteboard 321 * @since 9 322 */ 323 pixelMap: image.PixelMap; 324 /** 325 * Custom data in a record, mimeType indicates the MIME type of custom data, ArrayBuffer indicates the value of custom data. 326 * @type { object } 327 * @syscap SystemCapability.MiscServices.Pasteboard 328 * @since 9 329 */ 330 data: { 331 [mimeType: string]: ArrayBuffer 332 } 333 334 /** 335 * Converts data in PasteData to text format. 336 * @param { AsyncCallback<string> } callback - the callback of convertToText. 337 * @syscap SystemCapability.MiscServices.Pasteboard 338 * @since 7 339 * @deprecated since 9 340 * @useinstead ohos.pasteboard.pasteboard#convertToTextV9 341 */ 342 convertToText(callback: AsyncCallback<string>): void; 343 344 /** 345 * Converts data in PasteData to text format. 346 * @returns { Promise<string> } the promise returned by the function. 347 * @syscap SystemCapability.MiscServices.Pasteboard 348 * @since 7 349 * @deprecated since 9 350 * @useinstead ohos.pasteboard.pasteboard#convertToTextV9 351 */ 352 convertToText(): Promise<string>; 353 354 /** 355 * Converts data in PasteData to text format. 356 * @returns { string } the string returned by the function. 357 * @syscap SystemCapability.MiscServices.Pasteboard 358 * @since 9 359 */ 360 toPlainText(): string; 361 } 362 363 /** 364 * Classes for paste data. 365 * @interface PasteData 366 * @syscap SystemCapability.MiscServices.Pasteboard 367 */ 368 interface PasteData { 369 /** 370 * Adds a Record for HTML text to a PasteData object, and updates the MIME type to PasteData#MIMETYPE_TEXT_HTML in DataProperty. 371 * @param { string } htmlText - To save the Html text content. 372 * @syscap SystemCapability.MiscServices.Pasteboard 373 * @since 7 374 * @deprecated since 9 375 * @useinstead ohos.pasteboard.pasteboard#addRecord 376 */ 377 addHtmlRecord(htmlText: string): void; 378 379 /** 380 * Adds an want Record to a PasteData object, and updates the MIME type to PasteData#MIMETYPE_TEXT_WANT in DataProperty. 381 * @param { Want } want - To save the want content. 382 * @syscap SystemCapability.MiscServices.Pasteboard 383 * @since 7 384 * @deprecated since 9 385 * @useinstead ohos.pasteboard.pasteboard#addRecord 386 */ 387 addWantRecord(want: Want): void; 388 389 /** 390 * Adds a PasteRecord to a PasteData object and updates MIME types in DataProperty. 391 * @param { PasteDataRecord } record - The content of a new record. 392 * @syscap SystemCapability.MiscServices.Pasteboard 393 * @since 7 394 */ 395 addRecord(record: PasteDataRecord): void; 396 397 /** 398 * Adds a Record for plain text to a PasteData object, and updates the MIME type to PasteData#MIMETYPE_TEXT_PLAIN in DataProperty. 399 * @param { string } text - To save the text of content. 400 * @syscap SystemCapability.MiscServices.Pasteboard 401 * @since 7 402 * @deprecated since 9 403 * @useinstead ohos.pasteboard.pasteboard#addRecord 404 */ 405 addTextRecord(text: string): void; 406 407 /** 408 * Adds a URI Record to a PasteData object, and updates the MIME type to PasteData#MIMETYPE_TEXT_URI in DataProperty. 409 * @param { string } uri - To save the uri of content. 410 * @syscap SystemCapability.MiscServices.Pasteboard 411 * @since 7 412 * @deprecated since 9 413 * @useinstead ohos.pasteboard.pasteboard#addRecord 414 */ 415 addUriRecord(uri: string): void; 416 417 /** 418 * Adds a record with mimeType and value to a PasteData object. 419 * @param { string } mimeType - indicates the MIME type of value. 420 * @param { ValueType } value - content to be saved. 421 * @throws { BusinessError } 401 - if type of mimeType is not string, or the value can not match the mimeType correctly. 422 * @throws { BusinessError } 12900002 - The number of record exceeds the maximum limit. 423 * @syscap SystemCapability.MiscServices.Pasteboard 424 * @since 9 425 */ 426 /** 427 * Adds a record with mimeType and value to a PasteData object. 428 * @param { string } mimeType - indicates the MIME type of value. 429 * @param { ValueType } value - content to be saved. 430 * @throws { BusinessError } 401 - if type of mimeType is not string, or the value can not match the mimeType correctly. 431 * @syscap SystemCapability.MiscServices.Pasteboard 432 * @since 10 433 */ 434 addRecord(mimeType: string, value: ValueType): void; 435 436 /** 437 * MIME types of all content on the pasteboard. 438 * @returns { Array<string> } type of array 439 * @syscap SystemCapability.MiscServices.Pasteboard 440 * @since 7 441 */ 442 getMimeTypes(): Array<string>; 443 444 /** 445 * HTML text of the primary record in a PasteData object. 446 * @returns { string } type of htmltext 447 * @syscap SystemCapability.MiscServices.Pasteboard 448 * @since 7 449 */ 450 getPrimaryHtml(): string; 451 452 /** 453 * the want of the primary record in a PasteData object. 454 * @returns { want } type of want 455 * @syscap SystemCapability.MiscServices.Pasteboard 456 * @since 7 457 */ 458 getPrimaryWant(): Want; 459 460 /** 461 * the MIME type of the primary record in a PasteData object. 462 * @returns { string } type of mimetype 463 * @syscap SystemCapability.MiscServices.Pasteboard 464 * @since 7 465 */ 466 getPrimaryMimeType(): string; 467 468 /** 469 * the plain text of the primary record in a PasteData object. 470 * @returns { string } type of text 471 * @syscap SystemCapability.MiscServices.Pasteboard 472 * @since 6 473 */ 474 getPrimaryText(): string; 475 476 /** 477 * the URI of the primary record in a PasteData object. 478 * @returns { string } type of uri 479 * @syscap SystemCapability.MiscServices.Pasteboard 480 * @since 7 481 */ 482 getPrimaryUri(): string; 483 484 /** 485 * Gets the primary PixelMap record in a PasteData object. 486 * @returns { image.PixelMap } pixelMap 487 * @syscap SystemCapability.MiscServices.Pasteboard 488 * @since 9 489 */ 490 getPrimaryPixelMap(): image.PixelMap; 491 492 /** 493 * DataProperty of a PasteData object. 494 * @returns { PasteDataProperty } PasteDataProperty type of PasteDataProperty 495 * @syscap SystemCapability.MiscServices.Pasteboard 496 * @since 7 497 */ 498 getProperty(): PasteDataProperty; 499 500 /** 501 * Sets PasteDataProperty to a PasteData object, Modifying shareOption is supported only. 502 * @param { PasteDataProperty } property - save property to PasteData object. 503 * @throws { BusinessError } 401 - if type of property is not PasteDataProperty. 504 * @syscap SystemCapability.MiscServices.Pasteboard 505 * @since 9 506 */ 507 setProperty(property: PasteDataProperty): void; 508 509 /** 510 * Gets record by index in PasteData. 511 * @param { number } index - indicates the record index in PasteData. 512 * @returns { PasteDataRecord } the record in PasteData with index. 513 * @syscap SystemCapability.MiscServices.Pasteboard 514 * @since 7 515 * @deprecated since 9 516 * @useinstead ohos.pasteboard.pasteboard#getRecord 517 */ 518 getRecordAt(index: number): PasteDataRecord; 519 520 /** 521 * Gets record by index in PasteData. 522 * @param { number } index - indicates the record index in PasteData. 523 * @returns { PasteDataRecord } the record in PasteData with index. 524 * @throws { BusinessError } 401 - if type of index is not number. 525 * @throws { BusinessError } 12900001 - The index is out of the record. 526 * @syscap SystemCapability.MiscServices.Pasteboard 527 * @since 9 528 */ 529 getRecord(index: number): PasteDataRecord; 530 531 /** 532 * the number of records in a PasteData object. 533 * @returns { number } The number of the clipboard contents 534 * @syscap SystemCapability.MiscServices.Pasteboard 535 * @since 7 536 */ 537 getRecordCount(): number; 538 539 /** 540 * the user-defined tag of a PasteData object. 541 * @returns { string } type of tag 542 * @syscap SystemCapability.MiscServices.Pasteboard 543 * @since 7 544 */ 545 getTag(): string; 546 547 /** 548 * Checks whether there is a specified MIME type of data in DataProperty. 549 * @param { string } mimeType - indicates to query data type. 550 * @returns { boolean } if having mimeType in PasteData returns true, else returns false. 551 * @syscap SystemCapability.MiscServices.Pasteboard 552 * @since 7 553 * @deprecated since 9 554 * @useinstead ohos.pasteboard.pasteboard#hasType 555 */ 556 hasMimeType(mimeType: string): boolean; 557 558 /** 559 * Checks whether there is a specified MIME type of data in DataProperty. 560 * @param { string } mimeType - indicates to query data type. 561 * @returns { boolean } if having mimeType in PasteData returns true, else returns false. 562 * @throws { BusinessError } 401 - if type of path is not string. 563 * @syscap SystemCapability.MiscServices.Pasteboard 564 * @since 9 565 */ 566 hasType(mimeType: string): boolean; 567 568 /** 569 * Removes a Record based on a specified index. 570 * @param { number } index - indicates the record index in PasteData. 571 * @returns { boolean } The query returns True on success, or False on failure. 572 * @syscap SystemCapability.MiscServices.Pasteboard 573 * @since 7 574 * @deprecated since 9 575 * @useinstead ohos.pasteboard.pasteboard#removeRecord 576 */ 577 removeRecordAt(index: number): boolean; 578 579 /** 580 * Removes a Record based on a specified index. 581 * @param { number } index - indicates the record index in PasteData. 582 * @throws { BusinessError } 401 - if type of index is not number. 583 * @throws { BusinessError } 12900001 - The index is out of the record. 584 * @syscap SystemCapability.MiscServices.Pasteboard 585 * @since 9 586 */ 587 removeRecord(index: number): void; 588 589 /** 590 * Replaces a specified record with a new one. 591 * @param { number } index - indicates the record index in PasteData. 592 * @param { PasteDataRecord } record - the content of a new record. 593 * @returns { boolean } The query returns True on success, or False on failure. 594 * @syscap SystemCapability.MiscServices.Pasteboard 595 * @since 7 596 * @deprecated since 9 597 * @useinstead ohos.pasteboard.pasteboard#replaceRecord 598 */ 599 replaceRecordAt(index: number, record: PasteDataRecord): boolean; 600 601 /** 602 * Replaces a specified record with a new one. 603 * @param { number } index - indicates the record index in PasteData. 604 * @param { PasteDataRecord } record - the content of a new record. 605 * @throws { BusinessError } 401 - if type of index is not number or type of record is not PasteDataRecord. 606 * @throws { BusinessError } 12900001 - The index is out of the record. 607 * @syscap SystemCapability.MiscServices.Pasteboard 608 * @since 9 609 */ 610 replaceRecord(index: number, record: PasteDataRecord): void; 611 } 612 613 /** 614 * Classes for system pasteboard. 615 * @interface SystemPasteboard 616 * @syscap SystemCapability.MiscServices.Pasteboard 617 */ 618 interface SystemPasteboard { 619 /** 620 * Callback invoked when pasteboard content changes. 621 * @param { string } type - indicates pasteboard content changed. 622 * @param { () => void } callback - the callback to add. 623 * @throws { BusinessError } 401 - if type is not string or callback is not () => void. 624 * @syscap SystemCapability.MiscServices.Pasteboard 625 * @since 7 626 */ 627 on(type: 'update', callback: () => void): void; 628 629 /** 630 * Remove a callback invoked when pasteboard content changes. 631 * @param { string } type - indicates pasteboard content changed. 632 * @param { () => void } [callback] - the callback to remove. If this parameter is not filled in, it indicates that all 633 * callbacks for this application will be cleared. Otherwise, it indicates that the specified callback will be cleared. 634 * @throws { BusinessError } 401 - if type is not string or callback is not () => void. 635 * @syscap SystemCapability.MiscServices.Pasteboard 636 * @since 7 637 */ 638 off(type: 'update', callback?: () => void): void; 639 640 /** 641 * Clears the pasteboard. 642 * @param { AsyncCallback<void> } callback - the callback of clearData. 643 * @syscap SystemCapability.MiscServices.Pasteboard 644 * @since 7 645 * @deprecated since 9 646 * @useinstead ohos.pasteboard.pasteboard#clearData 647 */ 648 clear(callback: AsyncCallback<void>): void; 649 650 /** 651 * Clears the pasteboard. 652 * @returns { Promise<void> } the promise returned by the clearData. 653 * @syscap SystemCapability.MiscServices.Pasteboard 654 * @since 7 655 * @deprecated since 9 656 * @useinstead ohos.pasteboard.pasteboard#clearData 657 */ 658 clear(): Promise<void>; 659 660 /** 661 * Clears the pasteboard. 662 * @param { AsyncCallback<void> } callback - the callback of clearData. 663 * @throws { BusinessError } 401 - if callback is not AsyncCallback<void>. 664 * @syscap SystemCapability.MiscServices.Pasteboard 665 * @since 9 666 */ 667 clearData(callback: AsyncCallback<void>): void; 668 669 /** 670 * Clears the pasteboard. 671 * @returns { Promise<void> } the promise returned by the clearData. 672 * @syscap SystemCapability.MiscServices.Pasteboard 673 * @since 9 674 */ 675 clearData(): Promise<void>; 676 677 /** 678 * Gets pastedata from the system pasteboard. 679 * @param { AsyncCallback<PasteData> } callback - the callback of getData. 680 * @syscap SystemCapability.MiscServices.Pasteboard 681 * @since 6 682 * @deprecated since 9 683 * @useinstead ohos.pasteboard.pasteboard#getData 684 */ 685 getPasteData(callback: AsyncCallback<PasteData>): void; 686 687 /** 688 * Gets pastedata from the system pasteboard. 689 * @returns { Promise<PasteData> } the promise returned by the getData. 690 * @syscap SystemCapability.MiscServices.Pasteboard 691 * @since 6 692 * @deprecated since 9 693 * @useinstead ohos.pasteboard.pasteboard#getData 694 */ 695 getPasteData(): Promise<PasteData>; 696 697 /** 698 * Gets pastedata from the system pasteboard. 699 * @param { AsyncCallback<PasteData> } callback - the callback of getData. 700 * @throws { BusinessError } 401 - if type of callback is not AsyncCallback<PasteData>. 701 * @throws { BusinessError } 12900003 - Another copy or paste is in progress. 702 * @syscap SystemCapability.MiscServices.Pasteboard 703 * @since 9 704 */ 705 getData(callback: AsyncCallback<PasteData>): void; 706 707 /** 708 * Gets pastedata from the system pasteboard. 709 * @returns { Promise<PasteData> } the promise returned by the getData. 710 * @throws { BusinessError } 12900003 - Another copy or paste is in progress. 711 * @syscap SystemCapability.MiscServices.Pasteboard 712 * @since 9 713 */ 714 getData(): Promise<PasteData>; 715 716 /** 717 * Checks whether there is content in the pasteboard. 718 * @param { AsyncCallback<boolean> } callback - the callback of setPasteData. 719 * @syscap SystemCapability.MiscServices.Pasteboard 720 * @since 7 721 * @deprecated since 9 722 * @useinstead ohos.pasteboard.pasteboard#hasData 723 */ 724 hasPasteData(callback: AsyncCallback<boolean>): void; 725 726 /** 727 * Checks whether there is content in the pasteboard. 728 * @returns { Promise<boolean> } the promise returned by the function. 729 * @syscap SystemCapability.MiscServices.Pasteboard 730 * @since 7 731 * @deprecated since 9 732 * @useinstead ohos.pasteboard.pasteboard#hasData 733 */ 734 hasPasteData(): Promise<boolean>; 735 736 /** 737 * Checks whether there is content in the system pasteboard. 738 * @param { AsyncCallback<boolean> } callback - the callback of hasData. 739 * @throws { BusinessError } 401 - if type of callback is not AsyncCallback<boolean>. 740 * @syscap SystemCapability.MiscServices.Pasteboard 741 * @since 9 742 */ 743 hasData(callback: AsyncCallback<boolean>): void; 744 745 /** 746 * Checks whether there is content in the system pasteboard. 747 * @returns { Promise<boolean> } the promise returned by the function. 748 * @syscap SystemCapability.MiscServices.Pasteboard 749 * @since 9 750 */ 751 hasData(): Promise<boolean>; 752 753 /** 754 * Writes PasteData to the pasteboard. 755 * @param { PasteData } data - PasteData will be written to the clipboard 756 * @param { AsyncCallback<void> } callback - the callback of setPasteData. 757 * @syscap SystemCapability.MiscServices.Pasteboard 758 * @since 6 759 * @deprecated since 9 760 * @useinstead ohos.pasteboard.pasteboard#setData 761 */ 762 setPasteData(data: PasteData, callback: AsyncCallback<void>): void; 763 764 /** 765 * Writes PasteData to the pasteboard. 766 * @param { PasteData } data - Containing the contents of the clipboard content object. 767 * @returns { Promise<void> } the promise returned by the function. 768 * @syscap SystemCapability.MiscServices.Pasteboard 769 * @since 6 770 * @deprecated since 9 771 * @useinstead ohos.pasteboard.pasteboard#setData 772 */ 773 setPasteData(data: PasteData): Promise<void>; 774 775 /** 776 * Writes PasteData to the system pasteboard. 777 * @param { PasteData } data - PasteData will be written to the clipboard 778 * @param { AsyncCallback<void> } callback - the callback of setData. 779 * @throws { BusinessError } 401 - if type of data is not PasteData or type of callback is not AsyncCallback<void>. 780 * @throws { BusinessError } 12900003 - Another copy or paste is in progress. 781 * @throws { BusinessError } 12900004 - Replication is prohibited. 782 * @syscap SystemCapability.MiscServices.Pasteboard 783 * @since 9 784 */ 785 setData(data: PasteData, callback: AsyncCallback<void>): void; 786 787 /** 788 * Writes PasteData to the system pasteboard. 789 * @param { PasteData } data - PasteData will be written to the clipboard. 790 * @returns { Promise<void> } the promise returned by the function. 791 * @throws { BusinessError } 401 - if type of data is not PasteData. 792 * @throws { BusinessError } 12900003 - Another copy or paste is in progress. 793 * @throws { BusinessError } 12900004 - Replication is prohibited. 794 * @syscap SystemCapability.MiscServices.Pasteboard 795 * @since 9 796 */ 797 setData(data: PasteData): Promise<void>; 798 } 799} 800 801export default pasteboard;