Skip to content

Commit daffd88

Browse files
author
JelteMX
committed
First setup 🔥
0 parents  commit daffd88

24 files changed

+12823
-0
lines changed

.eslintrc.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const base = require("./node_modules/@mendix/pluggable-widgets-tools/configs/eslint.ts.base.json");
2+
3+
base["rules"]["@typescript-eslint/ban-ts-ignore"] = "warn";
4+
base["rules"]["@typescript-eslint/no-var-requires"] = "off";
5+
6+
module.exports = {
7+
...base
8+
};

.gitattributes

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
* text=auto
2+
*.ts text eol=lf
3+
*.tsx text eol=lf
4+
*.js text eol=lf
5+
*.jsx text eol=lf
6+
*.css text eol=lf
7+
*.scss text eol=lf
8+
*.json text eol=lf
9+
*.xml text eol=lf
10+
*.md text eol=lf
11+
*.gitattributes eol=lf
12+
*.gitignore eol=lf
13+
*.png binary
14+
*.jpg binary
15+
*.gif binary

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
dist/
2+
node_modules/
3+
*.log
4+
.env
5+
.vscode
6+
package-lock.json

LICENSE

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
The Apache License v2.0
2+
3+
Copyright 2020 Mendix Technology BV
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.

README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
[![Apache License](https://img.shields.io/badge/license-Apache%202.0-orange.svg)](http://www.apache.org/licenses/LICENSE-2.0)
2+
[![Dependencies](https://david-dm.org/JelteMX/mendix-text-template.svg)]([https://david-dm.org/JelteMX/mendix-text-template](https://david-dm.org/JelteMX/mendix-text-template))
3+
[![DevDependencies](https://david-dm.org/JelteMX/mendix-text-template/dev-status.svg)]([https://david-dm.org/JelteMX/mendix-text-template?type=dev](https://david-dm.org/JelteMX/mendix-text-template?type=dev))
4+
[![Support](https://img.shields.io/badge/Support-Community%20(no%20active%20support)-orange.svg)](https://docs.mendix.com/developerportal/app-store/app-store-content-support)
5+
[![Studio](https://img.shields.io/badge/Studio%20version-8.6.4%2B-blue.svg)](https://appstore.home.mendix.com/link/modeler/)
6+
![GitHub release](https://img.shields.io/github/release/JelteMX/mendix-text-template)
7+
![GitHub issues](https://img.shields.io/github/issues/JelteMX/mendix-text-template)
8+
[![Available](https://img.shields.io/badge/Test%20Project-available-green.svg)](https://github.com/JelteMX/widget-test-projects)
9+
10+
# Mendix Text Template
11+
12+
Render Markdown/HTML from a Text template. As powerful as the HTMLSnippet/Formatstring widget, but with more flexibility.
13+
14+
This uses the [react-markdown](https://github.com/rexxars/react-markdown) library (MIT License) and [react-shortcodes](https://github.com/djm/remark-shortcodes) library (MIT License)
15+
16+
![logo](/assets/AppStoreIcon.png)
17+
18+
> See test-project (**_to be published_**) for a live demo!
19+
20+
![preview](/assets/template.png)
21+
22+
Tested in the following Browsers:
23+
24+
- IE11 / Edge
25+
- Chrome, Firefox, Safari
26+
- Should work on Mobile Web
27+
28+
> This widget is built in Mendix 8.6.4. It would probably work in 8.0.0, but there are no guarantees.
29+
30+
## Features
31+
32+
- Render Markdown (string) as HTML. Markdown is [Github Flavored Markdown](https://guides.github.com/features/mastering-markdown/)
33+
- Render HTML from a text template. It will try to parse it as proper React elements.
34+
- Use your standard text template in Mendix, where values from your Mendix objects are replaced by `{1}` etc
35+
- Want to use static/dynamic images? You can get the direct url in your template using the `$$[placeholder]$$` strings
36+
- Using a file? You can get a direct url to it with the `$$file$$` string
37+
38+
## TODO
39+
40+
- Currently the `[[ shortcode ]]` template (everything between `[[` and `]]`) is reserved for future shortcode support. You can think of something like `[[ youtube id="" ]]` for a YouTube embed. This is not there yet. Any shortcode that you will put in there will not be rendered.
41+
- There might be useful other strings (`$$key$$`) added later. Currently I am only using this for images and a file
42+
- File is only a single one, because of a bug in Mendix Studio 8.6.4 (cannot create a list of files like images)
43+
- It always renders a container with the class name. This could be made optional (although not ideal)
44+
- Mendix Studio support will be added later
45+
46+
## What is it __NOT__?
47+
48+
Although this is very powerful, this widget does __NOT__ support inline scripts like you can do with the HTMLSnippet/Javascript snippet. The reason for that is simple: It should not be done in the Mendix page itself. I might add a ``[[ script ]]`` shortcode later where you can load a script from an external source.
49+
50+
By default HTML is escaped and should not render. You can switch this off. If you happen to find an XSS vulnerability (e.g. you can somehow get `alert(1)` working), please contact me and I will see how we can prevent this!
51+
52+
## Usage
53+
54+
- Place the Text Template widget on your page (doesn't need a context like dataview)
55+
- Define your template. If you have a context, you can define Parameters. These parameters can then be used in your template with brackets (`{1}` etc). __Note: Because Mendix uses the brackets, you cannot use them for other purposes in your template!__
56+
- Want to use HTML? `HTML -> Escape HTML: No`. Use with caution. Also, for some elements (like in the Test-project with an SVG) you might want to surround them with a `<div>` element
57+
- Misc settings may or may not be usefull. They will add certain `data-` tags to all generated elements. Also, if there are certain elements prohibited, you can disable them (This is a list like `image,strong`). When disabling certain elements, you can choose whether or not to show them (if you want to, set **Unwrap disallowed** to Yes)
58+
- This element has Conditional Visibility built-in
59+
60+
## Test project
61+
62+
The Test-project can be downloaded here: __*To be published*__
63+
64+
## Issues, suggestions and feature requests
65+
66+
Please report your issues [here](https://github.com/JelteMX/mendix-text-template/issues)
67+
68+
## License
69+
70+
Apache 2

assets/AppStoreIcon.png

14.4 KB
Loading

assets/images.png

202 KB
Loading

assets/in_page.png

98.5 KB
Loading

assets/template.png

161 KB
Loading

package.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "texttemplateelement",
3+
"widgetName": "TextTemplateElement",
4+
"version": "1.0.0",
5+
"description": "My widget description",
6+
"copyright": "2020 Mendix Technology BV",
7+
"author": "Jelte Lagendijk <[email protected]>",
8+
"config": {
9+
"widgetPath": "./dist/MxTestProject/widgets",
10+
"projectPath": "./dist/MxTestProject/",
11+
"mendixHost": "http://windows:8080",
12+
"developmentPort": "3000"
13+
},
14+
"packagePath": "mendix",
15+
"scripts": {
16+
"start": "concurrently \"pluggable-widgets-tools start:server --open\" \"npm:dev\"",
17+
"dev": "pluggable-widgets-tools start:ts",
18+
"build": "pluggable-widgets-tools build:ts",
19+
"lint": "pluggable-widgets-tools lint",
20+
"lint:fix": "pluggable-widgets-tools lint:fix",
21+
"prerelease": "npm run lint",
22+
"release": "pluggable-widgets-tools release:ts"
23+
},
24+
"license": "Apache-2.0",
25+
"devDependencies": {
26+
"@mendix/pluggable-widgets-tools": "^8.9.2",
27+
"@types/big.js": "^4.0.5",
28+
"@types/classnames": "^2.2.10",
29+
"@types/jest": "^24.0.0",
30+
"@types/react": "~16.9.0",
31+
"@types/react-dom": "~16.9.0",
32+
"@types/react-test-renderer": "~16.9.0"
33+
},
34+
"dependencies": {
35+
"classnames": "^2.2.6",
36+
"react-markdown": "^4.3.1",
37+
"remark-shortcodes": "^0.3.1"
38+
}
39+
}

0 commit comments

Comments
 (0)