IEditor.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\DirectEditing;
  8. use OCP\AppFramework\Http\Response;
  9. /**
  10. * @since 18.0.0
  11. */
  12. interface IEditor {
  13. /**
  14. * Return a unique identifier for the editor
  15. *
  16. * e.g. richdocuments
  17. *
  18. * @since 18.0.0
  19. * @return string
  20. */
  21. public function getId(): string;
  22. /**
  23. * Return a readable name for the editor
  24. *
  25. * e.g. Collabora Online
  26. *
  27. * @since 18.0.0
  28. * @return string
  29. */
  30. public function getName(): string;
  31. /**
  32. * A list of mimetypes that should open the editor by default
  33. *
  34. * @since 18.0.0
  35. * @return string[]
  36. */
  37. public function getMimetypes(): array;
  38. /**
  39. * A list of mimetypes that can be opened in the editor optionally
  40. *
  41. * @since 18.0.0
  42. * @return string[]
  43. */
  44. public function getMimetypesOptional(): array;
  45. /**
  46. * Return a list of file creation options to be presented to the user
  47. *
  48. * @since 18.0.0
  49. * @return ACreateFromTemplate[]|ACreateEmpty[]
  50. */
  51. public function getCreators(): array;
  52. /**
  53. * Return if the view is able to securely view a file without downloading it to the browser
  54. *
  55. * @since 18.0.0
  56. * @return bool
  57. */
  58. public function isSecure(): bool;
  59. /**
  60. * Return a template response for displaying the editor
  61. *
  62. * open can only be called once when the client requests the editor with a one-time-use token
  63. * For handling editing and later requests, editors need to implement their own token handling and take care of invalidation
  64. *
  65. * This behavior is similar to the current direct editing implementation in collabora where we generate a one-time token and switch over to the regular wopi token for the actual editing/saving process
  66. *
  67. * @since 18.0.0
  68. * @return Response
  69. */
  70. public function open(IToken $token): Response;
  71. }