๐ Collaborative document editing!
Nextcloud Text is the default text editor since Nextcloud 17. To start editing just open an existing markdown or plaintext file or create a new one.
The rich workspaces in the file list can be disabled either by the users in the files app settings or globally by the admin with the following occ command:
occ config:app:set text workspace_available --value=0
This app requires the main branch of the Viewer app to be installed and enabled. Follow its development setup and then continue here.
apps
folder of your Nextcloud: git clone https://github.com/nextcloud/text.git
make
to install dependencies and build the Javascript.To build the Javascript whenever you make changes, instead of the full make
you can also run npm run build
. Or run npm run watch
to rebuild on every file save.
Currently, this app uses three different kinds of tests:
For testing the backend (PHP) Psalm and PHPUnit are used,
you can run the testcases (placed in tests/
) using the composer scripts psalm
and test:unit
.
For testing the frontend jest is used for unittests, whereas cypress is used for end2end testing.
The unittests are also placed in src/tests/
, the cypress tests are placed in cypress/
.
You can run the tests using the package scripts npm run test
(jest), and respective npm run test:cypress
(cypress).
Please note the cypress tests require a nextcloud server running, the if no running server is detected a docker container will be started,
this requires the current user to be in the docker
group.
Or you might set the CYPRESS_baseUrl
environment variable for a custom nextcloud server.
In order to load the editor in your app, you'll need to dispatch an event.
use OCA\Text\Event\LoadEditor;
// ...
if (class_exists(LoadEditor::class)) {
$this->eventDispatcher->dispatchTyped(new LoadEditor());
}
Make sure to check if OCA.Text is available as the Text app needs to be enabled. If you want your app to work without Text being installed, you will need to provide an editor fallback on your own.
window.OCA.Text.createEditor({
el: document.getElementById('my-editor-div'),
fileId: 12345,
filePath: '/Readme.md',
}).then((editor) => {
// Once ready you can access the editor instance and call methods like:
editor.setContent('new content') // Beware: this will overwrite the content read from the source file
editor.setReadOnly(true)
editor.insertAtCursor('<h1>Heading</h1>')
// Make sure to destory the editor instance once you remove the dom element
editor.destroy()
})
window.OCA.Text.createEditor({
el: document.getElementById('my-editor-div'),
content: 'initial content',
}).then((editor) => {
// Once ready you can access the editor instance and call methods like:
editor.setContent('new content')
editor.setReadOnly(true)
editor.insertAtCursor('<h1>Heading</h1>')
// Make sure to destory the editor instance once you remove the dom element
editor.destroy()
})