├── .babelrc ├── .github └── workflows │ ├── appstore-build-publish.yml │ ├── lint.yml │ ├── nodejs.yml │ └── static-analysis.yml ├── .gitignore ├── .nextcloudignore ├── .php_cs.dist ├── CHANGELOG.md ├── LICENCE ├── Makefile ├── README.md ├── appinfo └── info.xml ├── composer.json ├── composer.lock ├── css └── preview.css ├── js ├── CheckboxPlugin.ts ├── MermaidPlugin.ts ├── Nextcloud.d.ts ├── PasteImage.ts ├── PreviewPlugin.ts ├── PublicPreview.ts ├── Renderer.ts ├── SidebarPreview.ts ├── VideoPlugin.ts └── editor.ts ├── krankerl.toml ├── lib ├── AppInfo │ └── Application.php └── Listener │ ├── CSPListener.php │ └── ScriptListener.php ├── package-lock.json ├── package.json ├── psalm.xml ├── screenshots ├── checkboxes.png ├── editor.png ├── embed.png ├── graph.png ├── math.png ├── preview.png ├── syntax.png └── videos.png ├── tests └── stub.phpstub ├── tsconfig.json └── webpack.config.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "env", 5 | { 6 | "modules": false 7 | } 8 | ] 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /.github/workflows/appstore-build-publish.yml: -------------------------------------------------------------------------------- 1 | # This workflow is provided via the organization template repository 2 | # 3 | # https://github.com/nextcloud/.github 4 | # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization 5 | 6 | name: Build and publish app release 7 | 8 | on: 9 | release: 10 | types: [published] 11 | 12 | env: 13 | PHP_VERSION: 8.0 14 | 15 | jobs: 16 | build_and_publish: 17 | runs-on: ubuntu-latest 18 | 19 | if: ${{ github.repository_owner == 'icewind1991' }} 20 | 21 | steps: 22 | - name: Check actor permission 23 | uses: skjnldsv/check-actor-permission@e591dbfe838300c007028e1219ca82cc26e8d7c5 # v2.1 24 | with: 25 | require: write 26 | 27 | - name: Set app env 28 | run: | 29 | # Split and keep last 30 | echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV 31 | echo "APP_VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV 32 | 33 | - name: Checkout 34 | uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 35 | with: 36 | path: ${{ env.APP_NAME }} 37 | 38 | - name: Get appinfo data 39 | id: appinfo 40 | uses: skjnldsv/xpath-action@7e6a7c379d0e9abc8acaef43df403ab4fc4f770c # master 41 | with: 42 | filename: ${{ env.APP_NAME }}/appinfo/info.xml 43 | expression: "//info//dependencies//nextcloud/@min-version" 44 | 45 | - name: Read package.json node and npm engines version 46 | uses: skjnldsv/read-package-engines-version-actions@1bdcee71fa343c46b18dc6aceffb4cd1e35209c6 # v1.2 47 | id: versions 48 | # Continue if no package.json 49 | continue-on-error: true 50 | with: 51 | path: ${{ env.APP_NAME }} 52 | fallbackNode: "^16" 53 | fallbackNpm: "^7" 54 | 55 | - name: Set up node ${{ steps.versions.outputs.nodeVersion }} 56 | # Skip if no package.json 57 | if: ${{ steps.versions.outputs.nodeVersion }} 58 | uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3 59 | with: 60 | node-version: ${{ steps.versions.outputs.nodeVersion }} 61 | 62 | - name: Set up npm ${{ steps.versions.outputs.npmVersion }} 63 | # Skip if no package.json 64 | if: ${{ steps.versions.outputs.npmVersion }} 65 | run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}" 66 | 67 | - name: Set up php ${{ env.PHP_VERSION }} 68 | uses: shivammathur/setup-php@1a18b2267f80291a81ca1d33e7c851fe09e7dfc4 # v2 69 | with: 70 | php-version: ${{ env.PHP_VERSION }} 71 | coverage: none 72 | env: 73 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 74 | 75 | - name: Check composer.json 76 | id: check_composer 77 | uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2 78 | with: 79 | files: "${{ env.APP_NAME }}/composer.json" 80 | 81 | - name: Install composer dependencies 82 | if: steps.check_composer.outputs.files_exists == 'true' 83 | run: | 84 | cd ${{ env.APP_NAME }} 85 | composer install --no-dev 86 | 87 | - name: Build ${{ env.APP_NAME }} 88 | # Skip if no package.json 89 | if: ${{ steps.versions.outputs.nodeVersion }} 90 | run: | 91 | cd ${{ env.APP_NAME }} 92 | npm ci 93 | npm run build 94 | 95 | - name: Check Krankerl config 96 | id: krankerl 97 | uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2 98 | with: 99 | files: ${{ env.APP_NAME }}/krankerl.toml 100 | 101 | - name: Install Krankerl 102 | if: steps.krankerl.outputs.files_exists == 'true' 103 | run: | 104 | wget https://github.com/ChristophWurst/krankerl/releases/download/v0.14.0/krankerl_0.14.0_amd64.deb 105 | sudo dpkg -i krankerl_0.14.0_amd64.deb 106 | 107 | - name: Package ${{ env.APP_NAME }} ${{ env.APP_VERSION }} with krankerl 108 | if: steps.krankerl.outputs.files_exists == 'true' 109 | run: | 110 | cd ${{ env.APP_NAME }} 111 | krankerl package 112 | 113 | - name: Package ${{ env.APP_NAME }} ${{ env.APP_VERSION }} with makefile 114 | if: steps.krankerl.outputs.files_exists != 'true' 115 | run: | 116 | cd ${{ env.APP_NAME }} 117 | make appstore 118 | 119 | - name: Checkout server ${{ fromJSON(steps.appinfo.outputs.result).nextcloud.min-version }} 120 | continue-on-error: true 121 | id: server-checkout 122 | run: | 123 | NCVERSION=${{ fromJSON(steps.appinfo.outputs.result).nextcloud.min-version }} 124 | wget --quiet https://download.nextcloud.com/server/releases/latest-$NCVERSION.zip 125 | unzip latest-$NCVERSION.zip 126 | 127 | - name: Checkout server master fallback 128 | uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 129 | if: ${{ steps.server-checkout.outcome != 'success' }} 130 | with: 131 | repository: nextcloud/server 132 | path: nextcloud 133 | 134 | - name: Sign app 135 | run: | 136 | # Extracting release 137 | cd ${{ env.APP_NAME }}/build/artifacts 138 | tar -xvf ${{ env.APP_NAME }}.tar.gz 139 | cd ../../../ 140 | # Setting up keys 141 | echo "${{ secrets.APP_PRIVATE_KEY }}" > ${{ env.APP_NAME }}.key 142 | wget --quiet "https://github.com/nextcloud/app-certificate-requests/raw/master/${{ env.APP_NAME }}/${{ env.APP_NAME }}.crt" 143 | # Signing 144 | php nextcloud/occ integrity:sign-app --privateKey=../${{ env.APP_NAME }}.key --certificate=../${{ env.APP_NAME }}.crt --path=../${{ env.APP_NAME }}/build/artifacts/${{ env.APP_NAME }} 145 | # Rebuilding archive 146 | cd ${{ env.APP_NAME }}/build/artifacts 147 | tar -zcvf ${{ env.APP_NAME }}.tar.gz ${{ env.APP_NAME }} 148 | 149 | - name: Attach tarball to github release 150 | uses: svenstaro/upload-release-action@133984371c30d34e38222a64855679a414cb7575 # v2 151 | id: attach_to_release 152 | with: 153 | repo_token: ${{ secrets.GITHUB_TOKEN }} 154 | file: ${{ env.APP_NAME }}/build/artifacts/${{ env.APP_NAME }}.tar.gz 155 | asset_name: ${{ env.APP_NAME }}-${{ env.APP_VERSION }}.tar.gz 156 | tag: ${{ github.ref }} 157 | overwrite: true 158 | 159 | - name: Upload app to Nextcloud appstore 160 | uses: nextcloud-releases/nextcloud-appstore-push-action@a011fe619bcf6e77ddebc96f9908e1af4071b9c1 # v1 161 | with: 162 | app_name: ${{ env.APP_NAME }} 163 | appstore_token: ${{ secrets.APPSTORE_TOKEN }} 164 | download_url: ${{ steps.attach_to_release.outputs.browser_download_url }} 165 | app_private_key: ${{ secrets.APP_PRIVATE_KEY }} 166 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: Php Lint 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: 7 | - main 8 | - master 9 | - stable* 10 | 11 | jobs: 12 | php-linters: 13 | runs-on: ubuntu-latest 14 | strategy: 15 | matrix: 16 | php-versions: ['8.0', '8.1', '8.2'] 17 | name: php${{ matrix.php-versions }} lint 18 | steps: 19 | - name: Checkout 20 | uses: actions/checkout@master 21 | - name: Set up php${{ matrix.php-versions }} 22 | uses: shivammathur/setup-php@master 23 | with: 24 | php-version: ${{ matrix.php-versions }} 25 | coverage: none 26 | - name: Install dependencies 27 | run: composer i 28 | - name: Lint 29 | run: composer run lint 30 | 31 | php-cs-fixer: 32 | name: php-cs check 33 | runs-on: ubuntu-latest 34 | steps: 35 | - name: Checkout 36 | uses: actions/checkout@master 37 | - name: Set up php${{ matrix.php-versions }} 38 | uses: shivammathur/setup-php@master 39 | with: 40 | php-version: 8.0 41 | tools: composer:v1 42 | coverage: none 43 | - name: Install dependencies 44 | run: composer i 45 | - name: Run coding standards check 46 | run: composer run cs:check 47 | -------------------------------------------------------------------------------- /.github/workflows/nodejs.yml: -------------------------------------------------------------------------------- 1 | name: Node CI 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: 7 | - main 8 | - master 9 | - stable* 10 | 11 | jobs: 12 | build: 13 | 14 | runs-on: ubuntu-20.04 15 | 16 | strategy: 17 | matrix: 18 | node-version: [12.x, 15.x] 19 | 20 | steps: 21 | - uses: actions/checkout@v1 22 | - uses: c-hive/gha-npm-cache@v1 23 | - name: Use Node.js ${{ matrix.node-version }} 24 | uses: actions/setup-node@v1 25 | with: 26 | node-version: ${{ matrix.node-version }} 27 | - name: npm install 28 | run: npm ci 29 | - name: npm build 30 | run: npm run build 31 | -------------------------------------------------------------------------------- /.github/workflows/static-analysis.yml: -------------------------------------------------------------------------------- 1 | name: Php Static analysis 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: 7 | - main 8 | - master 9 | - stable* 10 | 11 | jobs: 12 | static-psalm-analysis: 13 | runs-on: ubuntu-latest 14 | strategy: 15 | matrix: 16 | ocp-version: [ 'dev-master' ] 17 | name: Nextcloud ${{ matrix.ocp-version }} 18 | steps: 19 | - name: Checkout 20 | uses: actions/checkout@master 21 | - name: Set up php 22 | uses: shivammathur/setup-php@master 23 | with: 24 | php-version: 8.0 25 | tools: composer:v1 26 | coverage: none 27 | extensions: redis 28 | - name: Install dependencies 29 | run: composer i 30 | - name: Install dependencies 31 | run: composer require --dev nextcloud/ocp:${{ matrix.ocp-version }} 32 | - name: Run coding standards check 33 | run: composer run psalm 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | node_modules 3 | vendor 4 | *.cache 5 | -------------------------------------------------------------------------------- /.nextcloudignore: -------------------------------------------------------------------------------- 1 | .drone 2 | .git 3 | .github 4 | .gitignore 5 | .scrutinizer.yml 6 | .travis.yml 7 | .tx 8 | krankerl.toml 9 | screenshots 10 | .nextcloudignore 11 | Makefile 12 | screenshots 13 | node_modules 14 | composer.* 15 | package* 16 | .php_cs* 17 | tests 18 | tsconfig.json 19 | webpack.* 20 | psalm.xml 21 | -------------------------------------------------------------------------------- /.php_cs.dist: -------------------------------------------------------------------------------- 1 | getFinder() 12 | ->ignoreVCSIgnored(true) 13 | ->notPath('build') 14 | ->notPath('l10n') 15 | ->notPath('lib/Vendor') 16 | ->notPath('src') 17 | ->notPath('tests/configs') 18 | ->notPath('vendor') 19 | ->in(__DIR__); 20 | return $config; 21 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/), 6 | and this project adheres to [Semantic Versioning](https://semver.org/). 7 | 8 | ## [Unreleased] 9 | ### Changed 10 | - Updated changelog style, added missing releases and release dates. 11 | [#211](https://github.com/icewind1991/files_markdown/pull/211) @SimJoSt 12 | 13 | ## [2.4.0] - 2023-04-20 14 | ### Added 15 | - Compatible with Nextcloud 25 and 26. 16 | 17 | ## [2.3.6] - 2022-04-14 18 | ### Added 19 | - Compatible with Nextcloud 24. 20 | ### Fixed 21 | - Fix latex rendering. 22 | 23 | ## [2.3.5] - 2021-12-01 24 | ### Added 25 | - Compatible with Nextcloud 23. 26 | 27 | ## [2.3.4] - 2021-06-05 28 | ### Added 29 | - Compatible with Nextcloud 22. 30 | 31 | ## [2.3.3] - 2021-03-09 32 | ### Removed 33 | - Remove usage of deprecated methods. 34 | 35 | ## [2.3.2] - 2021-02-26 36 | ### Added 37 | - Compatible with Nextcloud 21. 38 | 39 | ## [2.3.1] - 2020-09-23 40 | ### Added 41 | - Compatible with Nextcloud 20. 42 | 43 | ## [2.3.0] - 2020-06-05 44 | ### Added 45 | - Compatible with Nextcloud 19. 46 | 47 | ## [2.2.0] - 2020-01-14 48 | ### Added 49 | - Compatible with Nextcloud 18. 50 | 51 | ## [2.1.0] - 2019-09-15 52 | ### Added 53 | - Compatible with Nextcloud 17. 54 | 55 | ## [2.0.6] - 2019-04-02 56 | ### Added 57 | - Nextcloud 16 support. 58 | 59 | ## [2.0.5] - 2018-11-13 60 | ### Added 61 | - Nextcloud 15 support. 62 | 63 | ## [2.0.4] - 2018-02-27 64 | ### Fixed 65 | - Fix issue with rendering public preview in some cases. 66 | 67 | ## [2.0.3] - 2018-02-27 68 | ### Changed 69 | - Publicly shared markdown files are now rendered the same as when editing. 70 | 71 | ## [2.0.2] - 2018-02-26 72 | ### Fixed 73 | - Fix clicking checkboxes sometimes changing the text incorrectly. 74 | 75 | ## [2.0.1] - 2017-09-14 76 | ### Changed 77 | - Improve behaviour of synchronized scrolling. 78 | - Enable automatic linking of links. 79 | ### Fixed 80 | - Fix styling conflict with core. 81 | [#64](https://github.com/icewind1991/files_markdown/pull/64) @MorrisJobke 82 | - Fix load markdown renderer in some chrome versions. 83 | 84 | ## [2.0.0] - 2017-09-04 85 | ### Added 86 | - Add synchronized scrolling between source and preview. 87 | - Add support for checkbox lists. 88 | - Add support for table of contents. 89 | - Add support for embedding videos. 90 | - Add support for rendering mermaid.js graphs. 91 | ### Changed 92 | - Allow linking inside the document with anchors. 93 | - Allow copy-pasting images directly into documents. 94 | - Better on demand loading of large 3rdparty libraries. 95 | ### Fixed 96 | - Various minor rendering fixes. 97 | 98 | ## [1.0.1] - 2017-02-16 99 | ### Changed 100 | - open outbound links in a new tab. 101 | ### Fixed 102 | - Fix rending of the last item in a numbered list. 103 | - no longer breaks the mail app. 104 | 105 | ## [1.0.0] - 2016-11-30 106 | ### Added 107 | - Initial version for Nextcloud 10+. 108 | - Added rendered markdown previews in the files sidebar. 109 | ### Changed 110 | - Switched to usin KaTeX for math rendering. 111 | -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | app_name=files_markdown 2 | project_dir=$(CURDIR)/../$(app_name) 3 | build_dir=$(CURDIR)/build/artifacts 4 | sign_dir=$(build_dir)/sign 5 | cert_dir=$(HOME)/.nextcloud/certificates 6 | 7 | all: build/editor.js 8 | 9 | sources=$(wildcard js/*.ts) $(wildcard js/*/*.ts) tsconfig.json .babelrc webpack.config.js 10 | 11 | .PHONY: watch 12 | watch: node_modules 13 | node_modules/.bin/webpack --watch --mode development 14 | 15 | clean: 16 | rm -rf $(build_dir) node_modules 17 | 18 | node_modules: package.json 19 | npm install 20 | 21 | CHANGELOG.md: node_modules 22 | node_modules/.bin/changelog 23 | 24 | build/editor.js: $(sources) node_modules 25 | node_modules/.bin/webpack --mode production 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Nextcloud Markdown Editor 2 | ================= 3 | 4 | Extends Nextcloud text editing with a live preview for markdown files 5 | 6 | ![Markdown Editor](screenshots/editor.png) 7 | 8 | Usage 9 | --- 10 | 11 | Starting with Nextcloud 17, the **[Text](github.com/nextcloud/text/)** app replaced the **[Plain text editor](https://apps.nextcloud.com/apps/files_texteditor)** app. In order to use ***Markdown Editor***, you must install and enable both it and **[Plain text editor](https://apps.nextcloud.com/apps/files_texteditor)**. 12 | 13 | To use ***Markdown Editor***, simply open any file with an `.md` or `.markdown` extension. 14 | 15 | Behaviors 16 | --- 17 | 18 | ![dots](https://user-images.githubusercontent.com/37463152/109408156-52e2c200-794c-11eb-93e4-e99ff97f8ae9.png) 19 | 20 | 21 | ### SCENARIO ONE 22 | 23 | _WITH **MARKDOWN EDITOR**, **PLAIN TEXT EDITOR**, AND **TEXT** APPS ALL ENABLED:_ 24 | 25 | The **[Text](github.com/nextcloud/text/)** app will still, by default, open `.txt`, `.md`, and `.markdown` files. However, you can override that behavior by clicking the three-dot dropdown menu for any `.txt`, `.md`, or `.markdown` file and choosing “Edit in plain text editor.” Using this method, ***Markdown Editor*** will open `.md`, and `.markdown` files while ***Plain text editor*** will open `.txt` files. 26 | 27 | ### SCENARIO TWO 28 | 29 | _WITH **MARKDOWN EDITOR** AND **PLAIN TEXT EDITOR** ENABLED, BUT **TEXT** DISABLED:_ 30 | 31 | ***Markdown Editor*** will open `.md`, and `.markdown` files while ***Plain text editor*** will open `.txt` files. It’s unnecessary to use the three-dot dropdown menu to invoke either. 32 | 33 | >_Be aware: Disabling the **Text** app will also disable (but not delete) any **Rich Workspace** notes you may have created. These are the styled notes that appear above and before file lists. Re-enabling **Text** makes them visible again._ 34 | 35 | 36 | Features 37 | --- 38 | 39 | ### Embed images and videos stored on your Nextcloud 40 | 41 | ![Embed Images](screenshots/embed.png) 42 | 43 | ![Embed Videos](screenshots/videos.png) 44 | 45 | ### Use LaTeX to add math to your documents 46 | 47 | ![LaTeX math](screenshots/math.png) 48 | 49 | ### Keep track of tasks with checkbox lists 50 | 51 | ![Checkbox lists](screenshots/checkboxes.png) 52 | 53 | ### Syntax highlighting for your code 54 | 55 | ![Syntax highlighting](screenshots/syntax.png) 56 | 57 | ### Create graph using [mermaid.js](https://github.com/knsv/mermaid) 58 | 59 | ![Mermaid.js graphs](screenshots/graph.png) 60 | 61 | ### Fully rendered previews in the sidebar 62 | 63 | ![Sidebar previews](screenshots/preview.png) 64 | 65 | Requirements 66 | --- 67 | 68 | This app requires the [Plain text editor](https://apps.nextcloud.com/apps/files_texteditor) app to be installed on Nextcloud 10 or higher. 69 | 70 | Installation 71 | --- 72 | 73 | - Get ***Markdown Editor*** from the [Nextcloud app store](https://apps.nextcloud.com/apps/files_markdown) 74 | or download the latest release from [github](https://github.com/icewind1991/files_markdown/releases). 75 | 76 | - If you’re installing from git, build the project by running `make` in Nextcloud’s app directory. 77 | 78 | Development 79 | --- 80 | 81 | ***Markdown Editor*** is written in [typescript](https://www.typescriptlang.org/). It requires [nodejs](https://nodejs.org/en/) and [npm](https://www.npmjs.com/) to build. 82 | 83 | For development you can automatically build the project every time the source changes by running `make watch`. 84 | -------------------------------------------------------------------------------- /appinfo/info.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | files_markdown 5 | Markdown Editor 6 | A Markdown Editor with live preview 7 | 10 | 2.4.1 11 | agpl 12 | Robin Appelman 13 | 14 | FilesMarkdown 15 | 16 | office 17 | https://github.com/icewind1991/files_markdown 18 | https://github.com/icewind1991/files_markdown/issues 19 | https://github.com/icewind1991/files_markdown.git 20 | 21 | 22 | https://raw.githubusercontent.com/icewind1991/files_markdown/master/screenshots/editor.png 23 | 24 | 25 | https://raw.githubusercontent.com/icewind1991/files_markdown/master/screenshots/embed.png 26 | 27 | 28 | https://raw.githubusercontent.com/icewind1991/files_markdown/master/screenshots/videos.png 29 | 30 | 31 | https://raw.githubusercontent.com/icewind1991/files_markdown/master/screenshots/graph.png 32 | 33 | 34 | https://raw.githubusercontent.com/icewind1991/files_markdown/master/screenshots/syntax.png 35 | 36 | 37 | https://raw.githubusercontent.com/icewind1991/files_markdown/master/screenshots/checkboxes.png 38 | 39 | 40 | https://raw.githubusercontent.com/icewind1991/files_markdown/master/screenshots/math.png 41 | 42 | 43 | https://raw.githubusercontent.com/icewind1991/files_markdown/master/screenshots/preview.png 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require-dev": { 3 | "roave/security-advisories": "dev-master", 4 | "nextcloud/ocp": "dev-master", 5 | "php-parallel-lint/php-parallel-lint": "^1.0.0", 6 | "nextcloud/coding-standard": "^0.4.0", 7 | "psalm/phar": "^4.3" 8 | }, 9 | "license": "AGPLv3", 10 | "scripts": { 11 | "lint": "parallel-lint --exclude src --exclude vendor --exclude target --exclude build .", 12 | "cs:check": "php-cs-fixer fix --dry-run --diff", 13 | "cs:fix": "php-cs-fixer fix", 14 | "psalm": "psalm.phar" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /css/preview.css: -------------------------------------------------------------------------------- 1 | /** sidebar preview */ 2 | .thumbnail > #preview.text-markdown { 3 | zoom: 0.8; 4 | } 5 | 6 | .thumbnail > #preview.text-markdown .mermaid { 7 | zoom: 0.7; 8 | } 9 | 10 | #preview_wrap#preview_wrap { 11 | overflow: hidden; 12 | } 13 | 14 | #preview.text-markdown { 15 | font-size: 14px; 16 | } 17 | 18 | /*hide plain text preview*/ 19 | #preview.text-markdown #imgframe { 20 | display: none; 21 | } 22 | 23 | #preview.text-markdown .public-preview { 24 | height: 75%; 25 | width: 80%; 26 | margin: 0 auto; 27 | max-width: 1100px; 28 | padding: 0 20px !important; 29 | box-sizing: border-box; 30 | font-size: 18px; 31 | line-height: 1.6em; 32 | min-height: 440px; 33 | color: #333; 34 | text-align: left; 35 | margin-bottom: 170px !important; 36 | } 37 | 38 | #preview.text-markdown input[type="checkbox"].checkbox { 39 | display: none; 40 | } 41 | 42 | #preview.text-markdown > *:first-child { 43 | margin-top: 0 !important; 44 | } 45 | 46 | #preview.text-markdown > *:last-child { 47 | margin-bottom: 0 !important; 48 | } 49 | 50 | #preview.text-markdown a { 51 | color: #4183C4; 52 | } 53 | 54 | #preview.text-markdown a.button { 55 | color: #545454; 56 | } 57 | 58 | #preview.text-markdown a.absent { 59 | color: #cc0000; 60 | } 61 | 62 | #preview.text-markdown a.anchor { 63 | display: block; 64 | padding-left: 30px; 65 | margin-left: -30px; 66 | cursor: pointer; 67 | position: absolute; 68 | top: 0; 69 | left: 0; 70 | bottom: 0; 71 | } 72 | 73 | #preview.text-markdown h1, #preview.text-markdown h2, #preview.text-markdown h3, #preview.text-markdown h4, #preview.text-markdown h5, #preview.text-markdown h6 { 74 | margin: 30px 0 10px; 75 | padding: 0; 76 | -webkit-font-smoothing: antialiased; 77 | cursor: text; 78 | position: relative; 79 | } 80 | 81 | #preview.text-markdown h1:hover a.anchor, #preview.text-markdown h2:hover a.anchor, 82 | #preview.text-markdown h3:hover a.anchor, #preview.text-markdown h4:hover a.anchor, 83 | #preview.text-markdown h5:hover a.anchor, #preview.text-markdown h6:hover a.anchor { 84 | background: url("../../images/modules/styleguide/para.png") no-repeat 10px center; 85 | text-decoration: none; 86 | } 87 | 88 | #preview.text-markdown h1 tt, #preview.text-markdown h1 code { 89 | font-size: inherit; 90 | } 91 | 92 | #preview.text-markdown h2 tt, #preview.text-markdown h2 code { 93 | font-size: inherit; 94 | } 95 | 96 | #preview.text-markdown h3 tt, #preview.text-markdown h3 code { 97 | font-size: inherit; 98 | } 99 | 100 | #preview.text-markdown h4 tt, #preview.text-markdown h4 code { 101 | font-size: inherit; 102 | } 103 | 104 | #preview.text-markdown h5 tt, #preview.text-markdown h5 code { 105 | font-size: inherit; 106 | } 107 | 108 | #preview.text-markdown h6 tt, #preview.text-markdown h6 code { 109 | font-size: inherit; 110 | } 111 | 112 | #preview.text-markdown h1 { 113 | font-size: 34px; 114 | line-height: 40px; 115 | margin: 40px 0 20px; 116 | } 117 | 118 | #preview.text-markdown h2 { 119 | font-size: 28px; 120 | } 121 | 122 | #preview.text-markdown h3 { 123 | font-size: 24px; 124 | line-height: 30px; 125 | } 126 | 127 | #preview.text-markdown h4 { 128 | font-size: 20px; 129 | } 130 | 131 | #preview.text-markdown h5 { 132 | font-size: 18px; 133 | } 134 | 135 | #preview.text-markdown h6 { 136 | font-size: 14px; 137 | } 138 | 139 | #preview.text-markdown p, #preview.text-markdown blockquote, #preview.text-markdown ul, #preview.text-markdown ol, #preview.text-markdown dl, #preview.text-markdown table, #preview.text-markdown pre { 140 | margin: 15px 0; 141 | } 142 | 143 | #preview.text-markdown hr { 144 | background: transparent url("../../images/modules/pulls/dirty-shade.png") repeat-x 0 0; 145 | border: 0 none; 146 | color: #cccccc; 147 | height: 4px; 148 | padding: 0; 149 | } 150 | 151 | #preview.text-markdown > h2:first-child { 152 | margin-top: 0; 153 | padding-top: 0; 154 | } 155 | 156 | #preview.text-markdown > h1:first-child { 157 | margin-top: 0; 158 | padding-top: 0; 159 | } 160 | 161 | #preview.text-markdown > h1:first-child + h2 { 162 | margin-top: 0; 163 | padding-top: 0; 164 | } 165 | 166 | #preview.text-markdown > h3:first-child, #preview.text-markdown > h4:first-child, #preview.text-markdown > h5:first-child, #preview.text-markdown > h6:first-child { 167 | margin-top: 0; 168 | padding-top: 0; 169 | } 170 | 171 | #preview.text-markdown a:first-child h1, #preview.text-markdown a:first-child h2, #preview.text-markdown a:first-child h3, #preview.text-markdown a:first-child h4, #preview.text-markdown a:first-child h5, #preview.text-markdown a:first-child h6 { 172 | margin-top: 0; 173 | padding-top: 0; 174 | } 175 | 176 | #preview.text-markdown h1 p, #preview.text-markdown h2 p, #preview.text-markdown h3 p, #preview.text-markdown h4 p, #preview.text-markdown h5 p, #preview.text-markdown h6 p { 177 | margin-top: 0; 178 | } 179 | 180 | #preview.text-markdown li p.first { 181 | display: inline-block; 182 | } 183 | 184 | #preview.text-markdown ul, #preview.text-markdown ol { 185 | padding-left: 30px; 186 | margin: 0px; 187 | } 188 | 189 | #preview.text-markdown ul { 190 | list-style: disc; 191 | } 192 | 193 | #preview.text-markdown ol { 194 | list-style: decimal; 195 | } 196 | 197 | #preview.text-markdown ul :first-child, #preview.text-markdown ol :first-child { 198 | margin-top: 0; 199 | } 200 | 201 | #preview.text-markdown ul :last-child, #preview.text-markdown ol :last-child { 202 | margin-bottom: 15px; 203 | } 204 | 205 | #preview.text-markdown dl { 206 | padding: 0; 207 | } 208 | 209 | #preview.text-markdown dl dt { 210 | font-size: 14px; 211 | font-weight: bold; 212 | font-style: italic; 213 | padding: 0; 214 | margin: 15px 0 5px; 215 | } 216 | 217 | #preview.text-markdown dl dt:first-child { 218 | padding: 0; 219 | } 220 | 221 | #preview.text-markdown dl dt > :first-child { 222 | margin-top: 0; 223 | } 224 | 225 | #preview.text-markdown dl dt > :last-child { 226 | margin-bottom: 0; 227 | } 228 | 229 | #preview.text-markdown dl dd { 230 | margin: 0 0 15px; 231 | padding: 0 15px; 232 | } 233 | 234 | #preview.text-markdown dl dd > :first-child { 235 | margin-top: 0; 236 | } 237 | 238 | #preview.text-markdown dl dd > :last-child { 239 | margin-bottom: 0; 240 | } 241 | 242 | #preview.text-markdown hr { 243 | border: 1px inset; 244 | height: auto; 245 | } 246 | 247 | #preview.text-markdown blockquote { 248 | border-left: 4px solid #dddddd; 249 | padding: 0 15px; 250 | color: #777777; 251 | } 252 | 253 | #preview.text-markdown blockquote > :first-child { 254 | margin-top: 0; 255 | } 256 | 257 | #preview.text-markdown blockquote > :last-child { 258 | margin-bottom: 0; 259 | } 260 | 261 | #preview.text-markdown table { 262 | padding: 0; 263 | } 264 | 265 | #preview.text-markdown table tr { 266 | border-top: 1px solid #cccccc; 267 | background-color: white; 268 | margin: 0; 269 | padding: 0; 270 | } 271 | 272 | #preview.text-markdown table tr:nth-child(2n) { 273 | background-color: #f8f8f8; 274 | } 275 | 276 | #preview.text-markdown table tr th { 277 | color: #777; 278 | font-weight: bold; 279 | border-bottom: 1px solid #cccccc; 280 | text-align: left; 281 | margin: 0; 282 | padding: 6px 13px; 283 | } 284 | 285 | #preview.text-markdown table tr td { 286 | /*border: 1px solid #cccccc;*/ 287 | text-align: left; 288 | margin: 0; 289 | padding: 6px 13px; 290 | } 291 | 292 | #preview.text-markdown table tr td[align="right"] { 293 | text-align: right; 294 | } 295 | 296 | #preview.text-markdown table tr td[align="center"] { 297 | text-align: center; 298 | } 299 | 300 | #preview.text-markdown table tr th :first-child, #preview.text-markdown table tr td :first-child { 301 | margin-top: 0; 302 | } 303 | 304 | #preview.text-markdown table tr th :last-child, #preview.text-markdown table tr td :last-child { 305 | margin-bottom: 0; 306 | } 307 | 308 | #preview.text-markdown img { 309 | max-width: 100%; 310 | } 311 | 312 | #preview.text-markdown span.frame { 313 | display: block; 314 | overflow: hidden; 315 | } 316 | 317 | #preview.text-markdown span.frame > span { 318 | border: 1px solid #dddddd; 319 | display: block; 320 | float: left; 321 | overflow: hidden; 322 | margin: 13px 0 0; 323 | padding: 7px; 324 | width: auto; 325 | } 326 | 327 | #preview.text-markdown span.frame span img { 328 | display: block; 329 | float: left; 330 | } 331 | 332 | #preview.text-markdown span.frame span span { 333 | clear: both; 334 | color: #333333; 335 | display: block; 336 | padding: 5px 0 0; 337 | } 338 | 339 | #preview.text-markdown span.align-center { 340 | display: block; 341 | overflow: hidden; 342 | clear: both; 343 | } 344 | 345 | #preview.text-markdown span.align-center > span { 346 | display: block; 347 | overflow: hidden; 348 | margin: 13px auto 0; 349 | text-align: center; 350 | } 351 | 352 | #preview.text-markdown span.align-center span img { 353 | margin: 0 auto; 354 | text-align: center; 355 | } 356 | 357 | #preview.text-markdown span.align-right { 358 | display: block; 359 | overflow: hidden; 360 | clear: both; 361 | } 362 | 363 | #preview.text-markdown span.align-right > span { 364 | display: block; 365 | overflow: hidden; 366 | margin: 13px 0 0; 367 | text-align: right; 368 | } 369 | 370 | #preview.text-markdown span.align-right span img { 371 | margin: 0; 372 | text-align: right; 373 | } 374 | 375 | #preview.text-markdown span.float-left { 376 | display: block; 377 | margin-right: 13px; 378 | overflow: hidden; 379 | float: left; 380 | } 381 | 382 | #preview.text-markdown span.float-left span { 383 | margin: 13px 0 0; 384 | } 385 | 386 | #preview.text-markdown span.float-right { 387 | display: block; 388 | margin-left: 13px; 389 | overflow: hidden; 390 | float: right; 391 | } 392 | 393 | #preview.text-markdown span.float-right > span { 394 | display: block; 395 | overflow: hidden; 396 | margin: 13px auto 0; 397 | text-align: right; 398 | } 399 | 400 | #preview.text-markdown code, #preview.text-markdown tt { 401 | margin: 0 2px; 402 | padding: 0 5px; 403 | white-space: nowrap; 404 | border: 1px solid #eaeaea; 405 | background-color: #f8f8f8; 406 | border-radius: 3px; 407 | font-family: 'Lucida Console', 'Lucida Sans Typewriter', 'DejaVu Sans Mono', monospace; 408 | } 409 | 410 | #preview.text-markdown pre code { 411 | margin: 0; 412 | padding: 0; 413 | white-space: pre; 414 | border: none; 415 | background: transparent; 416 | } 417 | 418 | #preview.text-markdown .highlight pre { 419 | background-color: #f8f8f8; 420 | border: 1px solid #cccccc; 421 | font-size: 13px; 422 | line-height: 19px; 423 | overflow: auto; 424 | padding: 6px 10px; 425 | border-radius: 3px; 426 | } 427 | 428 | #preview.text-markdown pre { 429 | background-color: #f8f8f8; 430 | border: 1px solid #cccccc; 431 | font-size: 13px; 432 | line-height: 19px; 433 | overflow: auto; 434 | padding: 6px 10px; 435 | border-radius: 3px; 436 | } 437 | 438 | #preview.text-markdown pre code, #preview.text-markdown pre tt { 439 | background-color: transparent; 440 | border: none; 441 | } 442 | 443 | #preview.text-markdown strong { 444 | font-weight: bold; 445 | } 446 | 447 | #preview.text-markdown em { 448 | font-style: italic; 449 | } 450 | 451 | #preview.text-markdown .embed-responsive { 452 | position: relative; 453 | height: 0; 454 | padding-top: 56.25%; 455 | overflow: hidden; 456 | } 457 | 458 | #preview.text-markdown .embed-responsive > iframe, 459 | #preview.text-markdown .embed-responsive > video { 460 | position: absolute; 461 | top: 0; 462 | left: 0; 463 | max-width: 100%; 464 | max-height: 100%; 465 | } 466 | 467 | .oc-dialog-dim.oc-dialog-dim { 468 | z-index: 9999; 469 | } 470 | 471 | #preview.text-markdown { 472 | font-family: 'Open Sans', Frutiger, Calibri, 'Myriad Pro', Myriad, sans-serif; 473 | } 474 | 475 | /* fixes opacity of quota in navigation sidebar in the files app*/ 476 | .section { 477 | opacity: 1; 478 | } 479 | -------------------------------------------------------------------------------- /js/CheckboxPlugin.ts: -------------------------------------------------------------------------------- 1 | // based on https://github.com/mcecot/markdown-it-checkbox 2 | 3 | import MarkdownIt from "markdown-it"; 4 | import Token from 'markdown-it/lib/token'; 5 | import {RuleCore} from 'markdown-it/lib/parser_core'; 6 | import StateCore from "markdown-it/lib/rules_core/state_core"; 7 | 8 | export interface CheckboxPluginOptions { 9 | divWrap: boolean; 10 | divClass: string; 11 | idPrefix: string; 12 | readonly: boolean; 13 | checkboxClass: string; 14 | } 15 | 16 | interface TokenConstructor { 17 | new(name: string, tagName: string, someNumber: number): Token; 18 | } 19 | 20 | interface CheckboxReplacerState extends StateCore { 21 | Token: TokenConstructor; 22 | } 23 | 24 | export function CheckBoxReplacer(md: MarkdownIt, userOptions: Partial): RuleCore { 25 | let lastId = 0; 26 | const defaults: CheckboxPluginOptions = { 27 | divWrap: false, 28 | divClass: 'checkbox', 29 | idPrefix: 'checkbox', 30 | readonly: true, 31 | checkboxClass: '' 32 | }; 33 | const options = $.extend(defaults, userOptions); 34 | const pattern = /\[(X|\s|\_|\-)\]\s(.*)/i; 35 | const createTokens = function (checked: boolean, label: string, Token: TokenConstructor, line: number): Token[] { 36 | const nodes: Token[] = []; 37 | let token: Token; 38 | 39 | /** 40 | *
41 | */ 42 | if (options.divWrap) { 43 | token = new Token("checkbox_open", "div", 1); 44 | token.attrs = [["class", options.divClass]]; 45 | nodes.push(token); 46 | } 47 | 48 | /** 49 | * 50 | */ 51 | const id = options.idPrefix + lastId; 52 | lastId += 1; 53 | token = new Token("checkbox_input", "input", 0); 54 | token.attrs = [["type", "checkbox"], ["id", id]]; 55 | if (checked === true) { 56 | token.attrs.push(["checked", "true"]); 57 | } 58 | if (options.readonly) { 59 | token.attrs.push(["disabled", "disabled"]); 60 | } 61 | if (options.checkboxClass) { 62 | token.attrs.push(["class", options.checkboxClass]); 63 | } 64 | token.attrs.push(["data-line", String(line)]); 65 | nodes.push(token); 66 | 67 | /** 68 | *