diff options
author | Vinicius Reis <vinicius.reis@nextcloud.com> | 2022-03-04 17:21:16 +0300 |
---|---|---|
committer | Vinicius Reis <vinicius.reis@nextcloud.com> | 2022-03-14 17:38:28 +0300 |
commit | 54d6b790dc6b5da189541d99fd4cf2075d624212 (patch) | |
tree | 4da1d2a97f01fe505f615f6273d2c3a7bc77cb3f /src | |
parent | e174ede46f95e53ef79d56bc287ed9425f62e6e6 (diff) |
📄 (2184): add missing comments
Signed-off-by: Vinicius Reis <vinicius.reis@nextcloud.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/markdownit/containers.js | 28 | ||||
-rw-r--r-- | src/nodes/CustomContainer.js | 22 |
2 files changed, 49 insertions, 1 deletions
diff --git a/src/markdownit/containers.js b/src/markdownit/containers.js index 1196f9b8e..9cdc3dc7e 100644 --- a/src/markdownit/containers.js +++ b/src/markdownit/containers.js @@ -1,11 +1,33 @@ +/* + * @copyright Copyright (c) 2022 Vinicius Reis <vinicius@nextcloud.com> + * + * @author Vinicius Reis <vinicius@nextcloud.com> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + import container from 'markdown-it-container' export const typesAvailable = ['info', 'warn', 'error', 'success'] const buildRender = type => (tokens, idx, options, env, slf) => { - // add a class to the opening tag const tag = tokens[idx] + // add attributes to the opening tag if (tag.nesting === 1) { tag.attrSet('data-container', type) tag.attrJoin('class', `custom-container custom-container-${type}`) @@ -14,7 +36,11 @@ const buildRender = type => (tokens, idx, options, env, slf) => { return slf.renderToken(tokens, idx, options, env, slf) } +/** + * @param {object} md Markdown object + */ export default (md) => { + // create a custom container to each type typesAvailable.forEach(type => { md.use(container, type, { render: buildRender(type), diff --git a/src/nodes/CustomContainer.js b/src/nodes/CustomContainer.js index a1ebd391b..920c075e4 100644 --- a/src/nodes/CustomContainer.js +++ b/src/nodes/CustomContainer.js @@ -1,3 +1,25 @@ +/* + * @copyright Copyright (c) 2022 Vinicius Reis <vinicius@nextcloud.com> + * + * @author Vinicius Reis <vinicius@nextcloud.com> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + import { Node, mergeAttributes } from '@tiptap/core' import { typesAvailable } from '../markdownit/containers' |