spreed icon indicating copy to clipboard operation
spreed copied to clipboard

🗒️ Create text document within conversation

Open marcoambrosini opened this issue 3 years ago • 1 comments

Fix #5330

marcoambrosini avatar Jun 22 '22 11:06 marcoambrosini

@marcoambrosini can you add a checkbox list at the top with what's missing?

nickvergessen avatar Jul 28 '22 07:07 nickvergessen

I found the following API in the files app:

GET ocs/v2.php/apps/files/api/v1/templates

{
	"ocs": {
		"meta": {
			"status": "ok",
			"statuscode": 200,
			"message": "OK"
		},
		"data": [
			{
				"app": "text",
				"label": "New text file",
				"extension": ".md",
				"iconClass": "icon-filetype-text",
				"mimetypes": [
					"text/markdown",
					"text/plain"
				],
				"ratio": 1,
				"templates": [
					{
						"templateType": "user",
						"templateId": "/Templates/Meeting notes.md",
						"basename": "Meeting notes.md",
						"etag": "d798d4c181bf17cccc56fc14cdb1b432",
						"fileid": 6048522,
						"filename": "/Templates/Meeting notes.md",
						"lastmod": 1651761072,
						"mime": "text/markdown",
						"size": 326,
						"type": "file",
						"hasPreview": true,
						"previewUrl": null
					},
					{
						"templateType": "user",
						"templateId": "/Templates/Readme.md",
						"basename": "Readme.md",
						"etag": "62f1009ec0bef",
						"fileid": 6048520,
						"filename": "/Templates/Readme.md",
						"lastmod": 1651834695,
						"mime": "text/markdown",
						"size": 553,
						"type": "file",
						"hasPreview": true,
						"previewUrl": null
					},
					{
						"templateType": "user",
						"templateId": "/Templates/Retrospective.md",
						"basename": "Retrospective.md",
						"etag": "86b5c433c8a4487fc6b90188c08cfc3f",
						"fileid": 6051672,
						"filename": "/Templates/Retrospective.md",
						"lastmod": 1651834668,
						"mime": "text/markdown",
						"size": 340,
						"type": "file",
						"hasPreview": true,
						"previewUrl": null
					}
				]
			},
			{
				"app": "richdocuments",
				"label": "New document",
				"extension": ".odt",
				"iconClass": "icon-filetype-document",
				"mimetypes": [
					"application/vnd.oasis.opendocument.text",
					"application/vnd.oasis.opendocument.text-template"
				],
				"ratio": 0.7070707070707071,
				"templates": [
					{
						"templateType": "user",
						"templateId": "/Templates/Invoice.odt",
						"basename": "Invoice.odt",
						"etag": "6bf777d41b20c176a6fa5ac0f003365f",
						"fileid": 6048519,
						"filename": "/Templates/Invoice.odt",
						"lastmod": 1651761072,
						"mime": "application/vnd.oasis.opendocument.text",
						"size": 17276,
						"type": "file",
						"hasPreview": true,
						"previewUrl": null
					},
					{
						"templateType": "user",
						"templateId": "/Templates/Letter.odt",
						"basename": "Letter.odt",
						"etag": "cb8eef684bd5d5ff594a92c0d77918a9",
						"fileid": 6048526,
						"filename": "/Templates/Letter.odt",
						"lastmod": 1651761073,
						"mime": "application/vnd.oasis.opendocument.text",
						"size": 15961,
						"type": "file",
						"hasPreview": true,
						"previewUrl": null
					}
				]
			},
			{
				"app": "richdocuments",
				"label": "New spreadsheet",
				"extension": ".ods",
				"iconClass": "icon-filetype-spreadsheet",
				"mimetypes": [
					"application/vnd.oasis.opendocument.spreadsheet",
					"application/vnd.oasis.opendocument.spreadsheet-template"
				],
				"ratio": 1.7777777777777777,
				"templates": [
					{
						"templateType": "user",
						"templateId": "/Templates/Diagram & table.ods",
						"basename": "Diagram & table.ods",
						"etag": "4126004c40b518af7a56ea7434045ff4",
						"fileid": 6048527,
						"filename": "/Templates/Diagram & table.ods",
						"lastmod": 1651761073,
						"mime": "application/vnd.oasis.opendocument.spreadsheet",
						"size": 13378,
						"type": "file",
						"hasPreview": true,
						"previewUrl": null
					},
					{
						"templateType": "user",
						"templateId": "/Templates/Expense report.ods",
						"basename": "Expense report.ods",
						"etag": "a9b155fdacfea4665c6f3268a209d06a",
						"fileid": 6048523,
						"filename": "/Templates/Expense report.ods",
						"lastmod": 1651761072,
						"mime": "application/vnd.oasis.opendocument.spreadsheet",
						"size": 13441,
						"type": "file",
						"hasPreview": true,
						"previewUrl": null
					}
				]
			},
			{
				"app": "richdocuments",
				"label": "New presentation",
				"extension": ".odp",
				"iconClass": "icon-filetype-presentation",
				"mimetypes": [
					"application/vnd.oasis.opendocument.presentation",
					"application/vnd.oasis.opendocument.presentation-template"
				],
				"ratio": 1.7777777777777777,
				"templates": [
					{
						"templateType": "user",
						"templateId": "/Templates/Elegant.odp",
						"basename": "Elegant.odp",
						"etag": "3e6fb6dfc4e21f4b65972d5f28567759",
						"fileid": 6048517,
						"filename": "/Templates/Elegant.odp",
						"lastmod": 1651761071,
						"mime": "application/vnd.oasis.opendocument.presentation",
						"size": 14316,
						"type": "file",
						"hasPreview": true,
						"previewUrl": null
					},
					{
						"templateType": "user",
						"templateId": "/Templates/Simple.odp",
						"basename": "Simple.odp",
						"etag": "6ec58198694b8d1bc5503a3d6c4d55b8",
						"fileid": 6048524,
						"filename": "/Templates/Simple.odp",
						"lastmod": 1651761072,
						"mime": "application/vnd.oasis.opendocument.presentation",
						"size": 14810,
						"type": "file",
						"hasPreview": true,
						"previewUrl": null
					}
				]
			},
			{
				"app": "richdocuments",
				"label": "New diagram",
				"extension": ".odg",
				"iconClass": "icon-filetype-draw",
				"mimetypes": [
					"application/vnd.oasis.opendocument.graphics",
					"application/vnd.oasis.opendocument.graphics-template"
				],
				"ratio": 1,
				"templates": []
			}
		]
	}
}

We shall use this similarly to the files app to:

  • [ ] Populate the + menu with all icons and labels returned by this API
  • [ ] In a step 2 (like in the files app) allow to choose the template (Blank seems to not be on the API but should still be provided).

POST /ocs/v2.php/apps/files/api/v1/templates/create

{
	"filePath": "/New file name.md",
	"templatePath": "/Templates/Retrospective.md",
	"templateType": "user"
}

Will create the file with the selected template.

For blank you just skip the template* parameters:

{
	"filePath": "/empty.md"
}

nickvergessen avatar Aug 30 '22 06:08 nickvergessen

Menu Modal
Bildschirmfoto vom 2022-08-31 07-55-56 Bildschirmfoto vom 2022-08-31 07-53-47

I have to admit that I just copied over the TemplatePreview component from the files app and copied all dependencies (3 js methods from private files JS code) into the place of the import, but it works

nickvergessen avatar Aug 31 '22 06:08 nickvergessen

Had a quick chat with @marcoambrosini and fixed the missing top margin without templates. So merging now.

nickvergessen avatar Aug 31 '22 12:08 nickvergessen

No PHP change, so I canceled drone.

Merging

nickvergessen avatar Aug 31 '22 13:08 nickvergessen