The Wayback Machine - https://web.archive.org/web/20230608002031/https://github.com/nextcloud/text
Skip to content

nextcloud/text

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
img
November 22, 2022 00:03
js
June 7, 2023 21:16
August 6, 2019 10:42
August 8, 2019 10:16
March 18, 2019 17:15
February 1, 2023 21:27
June 27, 2019 09:27

Nextcloud Text

GitHub Workflow Status Start contributing

πŸ“‘ Collaborative document editing!

Features

  • οΏ½? Simple focused writing: No distractions, only the formatting you need.
  • πŸ™‹ Work together: Share and collaborate with friends and colleagues, no matter if they use Nextcloud or not!
  • πŸ’Ύ Open format: Files are saved as Markdown, so you can edit them from any other text app too.
  • ✊ Strong foundation: We use οΏ½?οΏ½ tiptap which is based on πŸ¦‰ ProseMirror – huge thanks to them!

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.

Configuration

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

οΏ½?οΏ½ Development setup

Currently, this app requires the main branch of the Viewer app.

  1. οΏ½? Clone this app into the apps folder of your Nextcloud: git clone https://github.com/nextcloud/text.git
  2. πŸ‘©οΏ½?πŸ’» In the folder of the app, run the command make to install dependencies and build the Javascript.
  3. βœ… Enable the app through the app management of your Nextcloud
  4. πŸŽ‰ Partytime! Help fix some issues and review pull requests οΏ½?

πŸ§™ Advanced development stuff

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.

οΏ½?οΏ½ Testing the app

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.

Adding support for other mime types

  • The mime type needs to be known by Nextcloud server (see nextcloud/server#24488 for how this can be added)
  • Once that is there, please open a pull request to add them to

    text/src/helpers/mime.js

    Lines 35 to 61 in 12df66f

    const openMimetypesMarkdown = [
    'text/markdown',
    ]
    const openMimetypesPlainText = [
    'text/plain',
    'application/cmd',
    'application/x-empty',
    'application/x-msdos-program',
    'application/javascript',
    'application/json',
    'application/x-perl',
    'application/x-php',
    'application/x-tex',
    'application/xml',
    'application/yaml',
    'text/css',
    'text/html',
    'text/org',
    'text/x-c',
    'text/x-c++src',
    'text/x-h',
    'text/x-java-source',
    'text/x-ldif',
    'text/x-python',
    'text/x-shellscript',
    ]
  • You can test them like other mime types in cypress/e2e/files.spec.js

πŸ› οΏ½? Integrate text in your app

Load the editor

In order to load the editor in your app, you'll need to dispatch an event.

if (class_exists(LoadEditor::class)) {
	$this->eventDispatcher->dispatchTyped(new LoadEditor());
}

Integrate a file editor

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()
})

Markdown based content editor

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()
})