You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A plugin for [Strapi Headless CMS](https://github.com/strapi/strapi) that provides an integration with powerful
23
-
[mathjs](https://mathjs.org/) library.
22
+
A plugin for [Strapi Headless CMS](https://github.com/strapi/strapi) that provides an integration with powerful
23
+
[mathjs](https://mathjs.org/) library.
24
24
25
25
## Table of Contents
26
26
@@ -35,12 +35,13 @@ A plugin for [Strapi Headless CMS](https://github.com/strapi/strapi) that provid
35
35
-[💕Special Thanks](#-special-thanks)
36
36
37
37
## ✨ Features
38
+
38
39
-[Strapi Custom Field](https://docs.strapi.io/dev-docs/custom-fields) for calculating the provided formula.
39
40
-[mathjs](https://mathjs.org/) integration.
40
-
- Supports numbers, big numbers, complex numbers, fractions, units, strings, arrays, and matrices.
41
-
- Is compatible with JavaScript’s built-in Math library.
42
-
- Contains a flexible expression parser.
43
-
- Does symbolic computation.
41
+
- Supports numbers, big numbers, complex numbers, fractions, units, strings, arrays, and matrices.
42
+
- Is compatible with JavaScript’s built-in Math library.
43
+
- Contains a flexible expression parser.
44
+
- Does symbolic computation.
44
45
- Comes with a large set of built-in functions and constants.
45
46
- Calculating the `formula` with the provided `scope` using the powerful `mathjs.evaluate` method. [Read More.](https://mathjs.org/docs/expressions/parsing.html#evaluate)
46
47
@@ -52,63 +53,73 @@ Complete installation requirements are exact the same as for Strapi itself and c
> Before installing Strapi, the following requirements must be installed on your computer:
55
-
> - Node.js: Only Maintenance and LTS versions are supported (v16, v18, and v20).
56
+
>
57
+
> - Node.js: Only Maintenance and LTS versions are supported (v18, and v20).
56
58
> - Node v18.x is recommended for Strapi v4.3.9 and above
57
-
> - Node v16.x is recommended for Strapi v4.0.x to v4.3.8.
58
59
> - Your preferred Node.js package manager:
59
60
> - npm (v6 and above)
60
61
> - yarn
61
62
62
63
## 🦾 Installation
64
+
63
65
```shell
64
66
yarn add strapi-plugin-field-formula@latest
65
67
```
68
+
66
69
**OR**
70
+
67
71
```shell
68
72
npm install strapi-plugin-field-formula@latest
69
73
```
74
+
70
75
After successful installation you could re-build the Strapi instance. You could use the next commands (default) inside
71
76
your Strapi project:
77
+
72
78
```shell
73
79
yarn build
74
80
yarn develop
75
81
```
76
82
77
83
## ⚙️ Configuration
84
+
78
85
As a next step you must configure the plugin following the [official Strapi documentation](https://docs.strapi.io/dev-docs/plugins/documentation#configuration).
79
86
80
-
We need to enable the plugin by adding it to the Strapi plugin config file located in `./config/plugins.js` of your Strapi
87
+
We need to enable the plugin by adding it to the Strapi plugin config file located in `./config/plugins.js` of your Strapi
81
88
project. If this file does not exist yer, you have to create it manually.
82
89
83
90
Copy and paste the following config into you `./config/plugins.js` file:
91
+
84
92
```javascript
85
93
// ./config/plugins.js`
86
94
module.exports= {
87
95
// ...
88
-
'field-formula': {
89
-
enabled:true
96
+
"field-formula": {
97
+
enabled:true,
90
98
},
91
-
//...
92
-
}
99
+
//...
100
+
};
93
101
```
102
+
94
103
My congratulation 😄! You have successfully installed and configured the **Strapi Plugin Field Formula**.
95
104
96
105
## ♾️ Usage
97
-
> Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support
98
-
for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated
99
-
solution to work with different data types like numbers, big numbers, complex numbers, fractions, units, and matrices.
100
-
Powerful and easy to use.
101
106
102
-
Here is some examples, but to use this plugin on the full 100%, you have to read the official [Mathjs](https://mathjs.org/examples/index.html)
103
-
documentation, and especially the [expressions](https://mathjs.org/examples/expressions.js.html) part as `formula` is
107
+
> Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support
108
+
> for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated
109
+
> solution to work with different data types like numbers, big numbers, complex numbers, fractions, units, and matrices.
110
+
> Powerful and easy to use.
111
+
112
+
Here is some examples, but to use this plugin on the full 100%, you have to read the official [Mathjs](https://mathjs.org/examples/index.html)
113
+
documentation, and especially the [expressions](https://mathjs.org/examples/expressions.js.html) part as `formula` is
104
114
the same thing as `mathjs.evaluate` method 🤫
105
115
106
116
> Function `evaluate` accepts a single **(in our case)**`expression` or an array with expressions as the first argument
107
-
and has an optional second argument containing a `scope` with variables and functions. The scope can be a regular
108
-
JavaScript Object, or Map **(JSON in our case)**. The scope will be used to resolve symbols, and to write assigned
109
-
variables or function.
117
+
> and has an optional second argument containing a `scope` with variables and functions. The scope can be a regular
118
+
> JavaScript Object, or Map **(JSON in our case)**. The scope will be used to resolve symbols, and to write assigned
119
+
> variables or function.
110
120
111
121
### Example 1
122
+
112
123
```
113
124
formula: sqrt(x^y + r^k)
114
125
scope: {
@@ -121,26 +132,27 @@ result: 32.12475680841802
121
132
```
122
133
123
134
### Example 2
135
+
124
136
```
125
137
formula: cos(x deg)
126
138
scope: { "x": 45 }
127
139
result: 0.7071067811865476
128
140
```
129
141
130
142
## 🛠️ Contributing
131
-
See the [CONTRIBUTING.md](https://github.com/BorysShulyak/strapi-plugin-field-formula/blob/main/CONTRIBUTING.md)
143
+
144
+
See the [CONTRIBUTING.md](https://github.com/BorysShulyak/strapi-plugin-field-formula/blob/main/CONTRIBUTING.md)
132
145
document.
133
146
134
147
## 🗺️ Roadmap
148
+
135
149
- Object response to unleash more difficult expressions.
136
150
137
151
## ❤️ Support or Donate
138
-
If you are enjoying this plugin and feel extra appreciative, you could [buy me a book](https://bmc.link/borisshulyak)
152
+
153
+
If you are enjoying this plugin and feel extra appreciative, you could [buy me a book](https://bmc.link/borisshulyak)
139
154
📖 or 3 📖📖📖.
140
155
141
156
## 💕 Special Thanks
142
-
- I want to say thank you to **my wife Diana** for her love, daily support, motivation and inspiration.
143
-
144
-
145
-
146
157
158
+
- I want to say thank you to **my wife Diana** for her love, daily support, motivation and inspiration.
0 commit comments