@innovastudio/contentbuilder 1.4.150 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. package/package.json +4 -1
  2. package/public/contentbuilder/contentbuilder.css +651 -33
  3. package/public/contentbuilder/contentbuilder.esm.js +18451 -11081
  4. package/public/contentbuilder/contentbuilder.min.js +11 -11
  5. package/public/contentbuilder/lang/en.js +9 -1
  6. package/public/contentbuilder/lang/fr.js +9 -1
  7. package/public/contentbuilder/themes/colored-blue.css +64 -53
  8. package/public/contentbuilder/themes/colored-blue2.css +64 -53
  9. package/public/contentbuilder/themes/colored-blue3.css +64 -53
  10. package/public/contentbuilder/themes/colored-blue4.css +64 -53
  11. package/public/contentbuilder/themes/colored-blue5.css +64 -53
  12. package/public/contentbuilder/themes/colored-blue6.css +64 -53
  13. package/public/contentbuilder/themes/colored-blue7.css +64 -53
  14. package/public/contentbuilder/themes/colored-blue8.css +64 -53
  15. package/public/contentbuilder/themes/colored-dark.css +60 -53
  16. package/public/contentbuilder/themes/colored-darkblue.css +64 -53
  17. package/public/contentbuilder/themes/colored-gray.css +64 -53
  18. package/public/contentbuilder/themes/colored-green.css +64 -53
  19. package/public/contentbuilder/themes/colored-green2.css +64 -53
  20. package/public/contentbuilder/themes/colored-green3.css +64 -53
  21. package/public/contentbuilder/themes/colored-green4.css +64 -53
  22. package/public/contentbuilder/themes/colored-green5.css +64 -53
  23. package/public/contentbuilder/themes/colored-magenta.css +64 -53
  24. package/public/contentbuilder/themes/colored-orange.css +64 -53
  25. package/public/contentbuilder/themes/colored-orange2.css +64 -53
  26. package/public/contentbuilder/themes/colored-orange3.css +64 -53
  27. package/public/contentbuilder/themes/colored-pink.css +64 -53
  28. package/public/contentbuilder/themes/colored-pink2.css +64 -53
  29. package/public/contentbuilder/themes/colored-pink3.css +64 -53
  30. package/public/contentbuilder/themes/colored-pink4.css +64 -53
  31. package/public/contentbuilder/themes/colored-purple.css +64 -53
  32. package/public/contentbuilder/themes/colored-purple2.css +64 -53
  33. package/public/contentbuilder/themes/colored-red.css +64 -53
  34. package/public/contentbuilder/themes/colored-red2.css +64 -53
  35. package/public/contentbuilder/themes/colored-red3.css +64 -53
  36. package/public/contentbuilder/themes/colored-red4.css +64 -53
  37. package/public/contentbuilder/themes/colored-red5.css +64 -53
  38. package/public/contentbuilder/themes/colored-yellow.css +64 -53
  39. package/public/contentbuilder/themes/colored-yellow2.css +64 -53
  40. package/public/contentbuilder/themes/dark-blue.css +78 -57
  41. package/public/contentbuilder/themes/dark-blue2.css +78 -57
  42. package/public/contentbuilder/themes/dark-blue3.css +78 -57
  43. package/public/contentbuilder/themes/dark-gray.css +78 -57
  44. package/public/contentbuilder/themes/dark-pink.css +78 -57
  45. package/public/contentbuilder/themes/dark-purple.css +78 -57
  46. package/public/contentbuilder/themes/dark-red.css +78 -57
  47. package/public/contentbuilder/themes/dark.css +74 -55
  48. package/public/contentbuilder/themes/light-blue.css +64 -53
  49. package/public/contentbuilder/themes/light-blue2.css +64 -53
  50. package/public/contentbuilder/themes/light-blue3.css +64 -53
  51. package/public/contentbuilder/themes/light-cyan.css +64 -53
  52. package/public/contentbuilder/themes/light-gray.css +64 -53
  53. package/public/contentbuilder/themes/light-gray2.css +64 -53
  54. package/public/contentbuilder/themes/light-gray3.css +64 -53
  55. package/public/contentbuilder/themes/light-green.css +64 -53
  56. package/public/contentbuilder/themes/light-pink.css +64 -53
  57. package/public/contentbuilder/themes/light-pink2.css +64 -53
  58. package/public/contentbuilder/themes/light-purple.css +64 -53
  59. package/public/contentbuilder/themes/light-purple2.css +64 -53
  60. package/public/contentbuilder/themes/light-red.css +64 -53
  61. package/public/contentbuilder/themes/light-yellow.css +64 -53
  62. package/public/contentbuilder/themes/light-yellow2.css +64 -53
  63. package/readme.txt +95 -10
  64. package/README.md +0 -2252
package/README.md DELETED
@@ -1,2252 +0,0 @@
1
- # ContentBuilder.js
2
-
3
- ContentBuilder.js is a drag & drop HTML editor javascript library. It is the first editor that allows you to build content layout in almost any css grid framework such as Bootstrap, Foundation and more.
4
-
5
- ![Screenshot](docs/preview.png)
6
-
7
- ## Getting Started
8
-
9
-
10
- Include the main css file:
11
-
12
- ```html
13
- <link href="contentbuilder/contentbuilder.css" rel="stylesheet" type="text/css" />
14
- ```
15
-
16
- and the css file for snippets:
17
-
18
- ```html
19
- <link href="assets/minimalist-blocks/content.css" rel="stylesheet" type="text/css" />
20
- ```
21
-
22
- #### Install as Web Library
23
-
24
- Include js file:
25
-
26
- ```html
27
- <script src="contentbuilder/contentbuilder.min.js" type="text/javascript"></script>
28
- ```
29
-
30
- #### Or Install with NPM
31
-
32
- ```
33
- npm install @innovastudio/contentbuilder
34
- ```
35
-
36
- Then import into your project:
37
-
38
- ```javascript
39
- import ContentBuilder from '@innovastudio/contentbuilder';
40
- ```
41
-
42
- ## Usage
43
-
44
- ```html
45
- <div class="container">
46
- </div>
47
- ```
48
-
49
- ```javascript
50
- const builder = new ContentBuilder({
51
- container: '.container'
52
- });
53
- ```
54
-
55
- To get the HTML:
56
-
57
- ```javascript
58
- let html = builder.html();
59
- ```
60
- Then you can do anything with the html, for example, posting it to the server for saving, etc.
61
-
62
- ### Examples (HTML, PHP, React, Vue)
63
-
64
- ContentBuilder.js is written in pure Javascript (ES6) so you can use it in most situations. Sample use in simple HTML, PHP, React and Vue projects are included.
65
-
66
- React and Vue project examples are provided in separate downloads in the user area.
67
-
68
- ## Folder Structure
69
-
70
- - public/
71
- - assets/
72
- - contentbuilder/
73
- - uploads/
74
- - example1.html (HTML example)
75
- - example2.php (PHP example)
76
- - example3.html (Multiple editable area example)
77
- - ...Other examples
78
- - src/
79
- - contentbuilder/ (Only provided in Source Code package)
80
- - scss/ (Only provided in Source Code package)
81
- - docs/
82
- - README.md (Documentation)
83
- - readme.txt (Readme file)
84
- - readme-sourcecode.txt (Readme file for Source Code package)
85
- - ...
86
-
87
- ## Snippets
88
-
89
- Snippets are predesigned blocks that you can add or drag & drop into your content.
90
-
91
- By default, snippets are enabled. When you add a content, please click the **MORE** button to open the snippets dialog.
92
-
93
- ![Add Snippet](docs/add-snippet1.png)
94
-
95
- Snippet dialog opened.
96
-
97
- ![Add Snippet](docs/add-snippet2.png)
98
-
99
- Snippet files are located in the folder:
100
-
101
- **assets/minimalist-blocks/**
102
-
103
- It contains:
104
- - content.js (snippets file)
105
- - content.css (snippet style)
106
- - images
107
-
108
- You can configure the snippets location by setting the **snippetUrl** and **snippetPath** parameters:
109
-
110
- ```javascript
111
- const builder = new ContentBuilder({
112
- container: '.container',
113
- snippetUrl: 'assets/minimalist-blocks/content.js', // Snippet file
114
- snippetPath: 'assets/minimalist-blocks/', // Location of snippets' assets
115
- });
116
- ```
117
- In case of a different location, path adjustment may be needed. Here you can use the **snippetPathReplace** parameter.
118
-
119
- Example:
120
-
121
- ```javascript
122
- const builder = new ContentBuilder({
123
- ...
124
- snippetPathReplace: ['assets/minimalist-blocks/', 'mycustomfolder/assets/minimalist-blocks/'],
125
- ...
126
- });
127
- ```
128
-
129
- In this example, the default location is changed to **mycustomfolder/assets/minimalist-blocks/**
130
-
131
- ## Snippet Side Panel
132
-
133
- Snippets can be displayed on a side panel. This allows you to drag & drop snippets into your content.
134
-
135
- ![Snippet Side Panel](docs/side-panel-on-right.png)
136
-
137
- By default, this feature is not enabled.
138
-
139
- To enable this feature, include the snippet file on the page:
140
-
141
- ```javascript
142
- <script src="assets/minimalist-blocks/content.js" type="text/javascript"></script>
143
- ```
144
-
145
- Or load it programmatically:
146
-
147
- ```javascript
148
- builder.loadSnippets('assets/minimalist-blocks/content.js');
149
- ```
150
-
151
- ### Configuration
152
-
153
- Here are some options to configure the snippet side panel:
154
-
155
- #### Placement
156
-
157
- ```javascript
158
- const builder = new ContentBuilder({
159
- container: '.container',
160
- sidePanel: 'left'
161
- });
162
- ```
163
- The default placement is 'right'. If set to 'left', the placement will be on the left as seen below.
164
-
165
- ![Side Panel on Left](docs/side-panel-on-left.png)
166
-
167
- #### Open on the first load
168
-
169
- By default, the snippet side panel is closed. To open it on the first load:
170
-
171
- ```javascript
172
- const builder = new ContentBuilder({
173
- container: '.container',
174
- snippetOpen: true
175
- });
176
- ```
177
-
178
- #### Display mode
179
-
180
- If the snippet side panel is not used (during editing), it will be automatically closed. To make it always visible:
181
-
182
- ```javascript
183
- const builder = new ContentBuilder({
184
- container: '.container',
185
- snippetDisplay: 'visible' // default: auto
186
- });
187
- ```
188
-
189
- #### Snippet Categories
190
-
191
- Snippets have multiple categories for different purposes. The built-in categories are defined in the **snippetCategories** parameter:
192
-
193
- ```javascript
194
- const builder = new ContentBuilder({
195
- container: '.container',
196
- snippetCategories: [
197
- [120,'Basic'],
198
- [118,'Article'],
199
- [101,'Headline'],
200
- [119,'Buttons'],
201
- [102,'Photos'],
202
- [103,'Profile'],
203
- [116,'Contact'],
204
- [104,'Products'],
205
- [105,'Features'],
206
- [106,'Process'],
207
- [107,'Pricing'],
208
- [108,'Skills'],
209
- [109,'Achievements'],
210
- [110,'Quotes'],
211
- [111,'Partners'],
212
- [112,'As Featured On'],
213
- [113,'Page Not Found'],
214
- [114,'Coming Soon'],
215
- [115,'Help, FAQ']
216
- ],
217
- defaultSnippetCategory: 120, // the default category is 'Basic'
218
- });
219
- ```
220
-
221
- The **defaultSnippetCategory** specifies the category to open on the first load.
222
-
223
-
224
- ## Snippet Button
225
-
226
- You can enable the Snippet button on the toolbar for quick access to the snippets.
227
-
228
- ![Add Snippet Button](docs/add-snippet-button.png)
229
-
230
- Here you can open the Snippet dialog from the toolbar by clicking the (+) button.
231
-
232
- To enable the button:
233
-
234
- ```javascript
235
- const builder = new ContentBuilder({
236
- container: '.container',
237
- toolbarAddSnippetButton: true
238
- });
239
- ```
240
-
241
- Please see the Toolbar section for more customization on the toolbar.
242
-
243
- #### Programmatically Open Snippet Dialog
244
-
245
- If needed, you can open the Snippet dialog programmatically by calling the **viewSnippets()** method:
246
-
247
- ```javascript
248
- builder.viewSnippets()
249
- ```
250
-
251
- ## Language File
252
-
253
- With the Language file, you can translate the ContentBuilder.js interface into another language.
254
-
255
- The provided language files:
256
-
257
- - contentbuilder/lang/en.js
258
- - contentbuilder/lang/en.js
259
-
260
- To enable the language file, you need to add the file before including ContentBuilder.js:
261
-
262
- ```javascript
263
- <script src="contentbuilder/lang/en.js" type="text/javascript"></script>
264
- ```
265
- or
266
- ```javascript
267
- <script src="contentbuilder/lang/fr.js" type="text/javascript"></script>
268
- ```
269
-
270
- Here is the language file content as seen on en.js:
271
- ```javascript
272
- var _txt = new Array();
273
- _txt['Bold'] = 'Bold';
274
- _txt['Italic'] = 'Italic';
275
- ```
276
-
277
- You can create your own language file by copying/modifying this file.
278
-
279
- ## Icon Support
280
-
281
- ContentBuilder.js allows you to insert icons. Some snippets are designed using icons as well.
282
- Icons are located in the assets folder:
283
-
284
- **assets/ionicons/**
285
-
286
- You can see the icons that are imported in the snippet css file (assets/minimalist-blocks/content.css):
287
-
288
- ```css
289
- @import url("../ionicons/css/ionicons.min.css");
290
- ```
291
-
292
- You can modify this if you want to change the location of the icons.
293
-
294
- Note that icons need to be located inside the assets folder. You can change the assets folder location by setting:
295
-
296
- ```javascript
297
- const builder = new ContentBuilder({
298
- container: '.container',
299
- assetPath: 'assets/',
300
- });
301
- ```
302
-
303
- ## Custom File/Media Browser or Asset Manager Support
304
-
305
- You can specify your own custom file/media browser (or Asset Manager) to work with ContentBuilder.js.
306
-
307
- As an example, a simple file/media browser is provided with some sample images or videos that you can select and insert into your content.
308
-
309
- To configure:
310
-
311
- ```javascript
312
- const builder = new ContentBuilder({
313
- container: '.container',
314
- imageSelect: 'assets.html',
315
- fileSelect: 'assets.html',
316
- videoSelect: 'assets.html'
317
- });
318
- ```
319
-
320
- To try, click the link icon (1) on a selected image to open the image dialog. On the image dialog, you see a browse button displayed (2).
321
-
322
- ![Image Dialog](docs/image-select.png)
323
-
324
- Click the browse button to open the file/media browser as specified (assets.html).
325
-
326
- ![Image Dialog](docs/image-browser.png)
327
-
328
- Then you can select an image.
329
-
330
- The file/media browser can also be opened from the link dialog and video settings dialog.
331
-
332
- ![Image Dialog](docs/file-select.png)
333
-
334
- Click the browse button to open the file/media browser as specified (the assets.html).
335
-
336
- ![Image Dialog](docs/file-browser.png)
337
-
338
- Please see assets.html if you want to create your own file/image browser. Use the **selectAsset()** function as shown in assets.html to work with ContentBuilder.js. So when you select a file or image, the url will be returned to ContentBuilder.js.
339
-
340
- #### Using Custom Function
341
-
342
- You can replace the **imageSelect**, **fileSelect** and **videoSelect** parameters with the **onImageSelectClick**, **onFileSelectClick** and **onVideoSelectClick** parameters that will run your own custom function.
343
-
344
- Example:
345
-
346
- ```javascript
347
- const builder = new ContentBuilder({
348
- container: '.container',
349
- onImageSelectClick: function () { ... },
350
- onFileSelectClick: function () { ... },
351
- onVideoSelectClick: function () { ... },
352
- });
353
- ```
354
-
355
- ## Saving Base64 Images
356
-
357
- When you insert an image or change an embedded image, you will be able to browse the local image file. The selected image will be embedded as a base64 format in your content, so you will see the result immediately without having to wait for the image upload process.
358
-
359
- ![Image Dialog](docs/insert-image.png)
360
-
361
- The embedded image will be:
362
-
363
- ```html
364
- <img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAA....">
365
- ```
366
-
367
- You can save all embedded base64 images to the server by calling the **saveImages()** method.
368
- Normally, you'd call the **saveImages()** method on your saving implementation. So before saving the HTML content, all embedded images will be saved first on the server (ex. as jpg, png) and all base64 image sources will be replaced (automatically) with the physical image url. Then the HTML content can be saved. This process is made simple by using the **saveImages()** method.
369
-
370
- There are 2 ways to use the **saveImages()** method:
371
-
372
- #### 1. Using Form Method
373
-
374
- Example (if you're using PHP):
375
-
376
- ```javascript
377
- builder.saveImages('saveimage.php', function(){
378
-
379
- // Image saving done. Then you can save the content
380
- let html = builder.html();
381
-
382
- // ...
383
-
384
- });
385
- ```
386
-
387
- Here you specify a server side handler (**saveimage.php**) that performs the file saving on the server.
388
-
389
- File saving on the server is not part of ContentBuilder.js and depends on your server environment.
390
- As examples, you can use the provided handler:
391
-
392
- - saveimage.php (for PHP)
393
- - saveimage.ashx (for ASP.NET)
394
-
395
- Please add your own security handling on these files.
396
-
397
- To try a working example, please open example2.php.
398
-
399
- #### 2. Using AJAX Post Method
400
-
401
- ```javascript
402
- builder.saveImages('', ()=>{
403
-
404
- // Image saving done. Then you can save the content
405
- let html = builder.html();
406
-
407
- // ...
408
-
409
- }, (img, base64, filename)=>{
410
-
411
- // Upload base64 images
412
- const reqBody = { image: base64, filename: filename };
413
- fetch('/uploadbase64', {
414
- method:'POST',
415
- body: JSON.stringify(reqBody),
416
- headers: {
417
- 'Content-Type': 'application/json',
418
- }
419
- })
420
- .then(response=>response.json())
421
- .then(response=>{
422
- if(!response.error) {
423
- const uploadedImageUrl = response.url;
424
- img.setAttribute('src', uploadedImageUrl); // Update image src
425
- }
426
- });
427
-
428
- });
429
- ```
430
-
431
- In this example, each image will be sent to an endpoint: /upload
432
-
433
- If you're using Node.js, you can implement the endpoint to save the images using:
434
-
435
- ```javascript
436
- const express = require('express');
437
- const fs = require('fs');
438
- const app = express();
439
- const path = require('path');
440
- const cors = require('cors');
441
- const serveStatic = require('serve-static');
442
- const formidable = require('formidable-serverless');
443
- const sharp = require('sharp');
444
-
445
- var $path = __dirname + '/public/uploads/'; // Physical path
446
- var $urlpath = 'uploads/'; // URL path
447
-
448
- app.use(cors());
449
- app.use(express.urlencoded({
450
- extended: true
451
- }));
452
- app.use(express.json({ limit: '50mb' }));
453
- app.use(serveStatic(path.join(__dirname, '/public')));
454
-
455
- app.post('/uploadbase64', async (req, res) => {
456
- const base64Data = req.body.image;
457
- const filename = req.body.filename;
458
-
459
- let extension = path.extname(filename).toLowerCase();
460
-
461
- let imageFile=base64Data;
462
- if(extension === '.jpeg' || extension === '.jpg') {
463
- let img = new Buffer.from(base64Data, 'base64');
464
- imageFile = await sharp(img).resize(1600, 1600, {
465
- fit: sharp.fit.inside,
466
- withoutEnlargement: true,
467
- })
468
- .jpeg({ quality: 70, progressive: true, force: false })
469
- .toBuffer();
470
- }
471
- fs.writeFile($path + filename, imageFile, 'base64', async (err)=>{
472
- if (err) {
473
- res.status(500).json({
474
- ok:true, status: 500,
475
- error: 'Something went wrong.'
476
- });
477
- return
478
- }
479
- res.status(200).json({
480
- ok:true, status: 200,
481
- url: $urlpath + filename
482
- });
483
- });
484
- });
485
-
486
- app.listen(8081, function() {
487
- console.log('App running on port 8081');
488
- });
489
- ```
490
-
491
- Example use of the AJAX post method can be seen on:
492
- - React Example (react-contentbuilder folder, please see src/components/contentbuilder/buildercontrol.jsx)
493
- - Vue Example (vue-contentbuilder folder, please see src/components/Editable.vue)
494
- - src/index.js (in Source Code package)
495
-
496
- ### Configuration
497
-
498
- Here are some options you can set to configure the image embed functionality:
499
-
500
- #### Image Quality
501
-
502
- ```javascript
503
- const builder = new ContentBuilder({
504
- container: '.container',
505
- imageQuality: 0.92,
506
- });
507
- ```
508
-
509
- #### Maximum Width
510
-
511
- ```javascript
512
- const builder = new ContentBuilder({
513
- container: '.container',
514
- maxEmbedImageWidth: 1600,
515
- });
516
- ```
517
- If maxEmbedImageWidth is set to -1, then no maximum width will be applied (will use original image width).
518
-
519
- #### Enable/Disable Embed Image Feature
520
-
521
- ```javascript
522
- const builder = new ContentBuilder({
523
- container: '.container',
524
- imageEmbed: false,
525
- });
526
- ```
527
- If imageEmbed is set to false, the browse image button will not be displayed as seen below.
528
-
529
- ![Image Embed Disabled](docs/no-image-embed.png)
530
-
531
- #### Using Custom Function on Browse Image Click
532
-
533
- ```javascript
534
- const builder = new ContentBuilder({
535
- container: '.container',
536
- onImageBrowseClick: function() { ... },
537
- });
538
- ```
539
-
540
- The function will be called when the browse image button is clicked.
541
-
542
- ![Image Browse Click](docs/on-image-browse-click.png)
543
-
544
- #### Using Custom Function on Image Link/Settings Click
545
-
546
- ```javascript
547
- const builder = new ContentBuilder({
548
- container: '.container',
549
- onImageSettingClick: function() { ... },
550
- });
551
- ```
552
-
553
- The function will be called when the image settings button is clicked.
554
-
555
- ![Image Settings Click](docs/on-image-settings-click.png)
556
-
557
-
558
- ## Image Upload from the Image Dialog
559
-
560
- A browse local image button can be enabled on the Image dialog. This can be used to select and upload image to the server.
561
-
562
- ![Image Dialog](docs/upload-image.png)
563
-
564
- ![Image Dialog](docs/upload-image2.png)
565
-
566
- There are 2 ways to enable the button:
567
-
568
- #### 1. Using Form Method
569
-
570
- Use the **mediaHandler** parameter. You can also use the **largerImageHandler** parameter (previous version) which is the same and still works.
571
-
572
- Example:
573
-
574
- ```javascript
575
- const builder = new ContentBuilder({
576
- container: '.container',
577
- mediaHandler: 'savemedia.php' // or savemedia.ashx if you're using ASP.NET
578
- });
579
- ```
580
-
581
- Here you specify a server side handler for uploading files.
582
-
583
- As examples, you can use the provided handler:
584
-
585
- - savemedia.php (for PHP)
586
- - savemedia.ashx (for ASP.NET)
587
-
588
- By default, images are saved in the **upload/** folder. You can change the upload folder by editing **savemedia.php** or **savemedia.aspx**.
589
-
590
- #### 2. Using AJAX Post Method
591
-
592
- Use the **onMediaUpload** parameter. You can also use the **onLargerImageUpload** parameter (previous version) which is the same and still works.
593
-
594
- Example:
595
-
596
- ```javascript
597
- const builder = new ContentBuilder({
598
- container: '.container',
599
- onMediaUpload: (e)=>{
600
- uploadFile(e, (response)=>{
601
- if(!response.error) {
602
- const uploadedImageUrl = response.url;
603
- if(uploadedImageUrl) obj.returnUrl(uploadedImageUrl);
604
- }
605
- });
606
- }
607
- });
608
-
609
- function uploadFile(e, callback) {
610
-
611
- const selectedFile = e.target.files[0];
612
-
613
- const formData = new FormData();
614
- formData.append('file', selectedFile);
615
- fetch('/upload', {
616
- method: 'POST',
617
- body: formData,
618
- })
619
- .then(response=>response.json())
620
- .then(response=>{
621
- console.log(response)
622
- if(callback) callback(response);
623
- });
624
- }
625
- ```
626
- The example above uses the **returnUrl(url)** method to apply the uploaded image url back to the image dialog. You can also use the **applyLargerImage** parameter (previous version) which is the same and still works.
627
- In the example, file will be sent to an endpoint: /upload
628
-
629
- Working examples can be seen on the React & Vue examples:
630
- - React Example (react-contentbuilder folder, please see src/components/contentbuilder/buildercontrol.jsx)
631
- - Vue Example (vue-contentbuilder folder, please see src/components/Editable.vue)
632
- - src/index.js (in Source Code package)
633
-
634
- ## Video Upload from the Video Dialog
635
-
636
- A browse local video button can be enabled on the video dialog. This can be used to select and upload video (mp4 file) to the server.
637
-
638
- ![Browse button](docs/upload-video.png)
639
-
640
- ![Select video](docs/upload-video2.png)
641
-
642
- There are 2 ways to enable the button:
643
-
644
-
645
- #### 1. Using Form Method
646
-
647
- Use the **videoHandler** parameter.
648
-
649
- Example:
650
-
651
- ```javascript
652
- const builder = new ContentBuilder({
653
- container: '.container',
654
- videoHandler: 'savemedia.php' // or savemedia.ashx if you're using ASP.NET
655
- });
656
- ```
657
-
658
- Here you specify a server side handler for uploading files.
659
-
660
- As examples, you can use the provided handler:
661
-
662
- - savemedia.php (for PHP)
663
- - savemedia.ashx (for ASP.NET)
664
-
665
- By default, videos are saved in the **upload/** folder. You can change the upload folder by editing **savemedia.php** or **savemedia.aspx**.
666
-
667
- #### 2. Using AJAX Post Method
668
-
669
- Use the **onVideoUpload** parameter.
670
-
671
- Example:
672
-
673
- ```javascript
674
- const builder = new ContentBuilder({
675
- container: '.container',
676
- ...
677
- onVideoUpload: (e)=>{
678
- uploadFile(e, (response)=>{
679
- if(!response.error) {
680
- const uploadedFileUrl = response.url;
681
- if(uploadedFileUrl) obj.returnUrl(uploadedFileUrl);
682
- }
683
- });
684
- },
685
- });
686
-
687
- function uploadFile(e, callback) {
688
-
689
- const selectedFile = e.target.files[0];
690
-
691
- const formData = new FormData();
692
- formData.append('file', selectedFile);
693
- fetch('/upload', {
694
- method: 'POST',
695
- body: formData,
696
- })
697
- .then(response=>response.json())
698
- .then(response=>{
699
- console.log(response)
700
- if(callback) callback(response);
701
- });
702
- }
703
- ```
704
-
705
- ## Plugins
706
-
707
- With plugins, you can extend the ContentBuilder.js features. A plugin can add an additional button into the ContentBuilder.js toolbar. For example, a 'wordcount' plugin adds a button in the toolbar and when clicked, a dialog showing the word count info will be diplayed.
708
-
709
- ![Word Count Plugin](docs/wordcount.png)
710
-
711
- Plugin scripts are located in the **plugins/** folder inside **contentbuilder/**.
712
-
713
- You will see the folder containing some prebuilt plugins:
714
- - contentbuilder/plugins/helloworld
715
- - contentbuilder/plugins/preview
716
- - contentbuilder/plugins/searchreplace
717
- - contentbuilder/plugins/showgrid
718
- - contentbuilder/plugins/symbols
719
- - contentbuilder/plugins/wordcount
720
-
721
- To load the plugins, you can configure:
722
-
723
- ```javascript
724
- const builder = new ContentBuilder({
725
- container: '.is-container',
726
- plugins: [
727
- { name: 'preview', showInMainToolbar: true, showInElementToolbar: true },
728
- { name: 'wordcount', showInMainToolbar: true, showInElementToolbar: true },
729
- { name: 'symbols', showInMainToolbar: true, showInElementToolbar: false },
730
- ],
731
- pluginPath: 'contentbuilder/',
732
- });
733
- ```
734
-
735
- Here we specify the **plugins** and **pluginPath** parameters.
736
-
737
- The **plugins** parameter accepts list of plugins with configurations:
738
- - name: name of the plugin (same as the folder name)
739
- - showInMainToolbar: the plugin will add a button on the main editing toolbar (when text element is selected).
740
- - showInElementToolbar: the plugin will add a button on the element editing toolbar (when non-text element is selected).
741
-
742
- The difference between the main editing toolbar and the element editing toolbar is that the main editing toolbar shows when a text element is selected (cursor is placed on text), whereas the element editing toolbar shows when a non-text element is clicked/selected (such as when selecting an image, spacer, etc).
743
-
744
- Main editing toolbar (text-based):
745
-
746
- ![Word Count Plugin](docs/rte-main.png)
747
-
748
- Element editing toolbar (non text):
749
-
750
- ![Word Count Plugin](docs/rte-alternate.png)
751
-
752
- As seen in the example configuration above:
753
- - The 'symbols' plugin should display its button only if a text element is selected/clicked. So the **showInMainToolbar** (main editing toolbar) is set to true and **showInElementToolbar** (element editing toolbar) is set to false. Here the Symbol button is displayed on the main editing toolbar:
754
- ![Button Editor Plugin](docs/plugin-symbols1.png)
755
- Here the Symbol button is not displayed on the element editing toolbar:
756
- ![Button Editor Plugin](docs/plugin-symbols2.png)
757
-
758
- In the previous version, there is a ‘buttoneditor’ plugin which shows an edit (pencil) icon when a link button is clicked. This plugin is now integrated with the builder, so no configuration is needed.
759
-
760
- ![Button Editor Plugin](docs/plugin-buttoneditor.png)
761
-
762
- An alternative way to load the plugins is by using a configuration file:
763
-
764
- **contentbuilder/config.js**
765
-
766
- If the plugins parameter is not set during initialization (as in the above example), ContentBuilder.js will automatically load this configuration file.
767
- Sample configuration in **config.js**:
768
-
769
- ```javascript
770
- _cb.settings.plugins = [
771
- { name: 'preview', showInMainToolbar: true, showInElementToolbar: true },
772
- { name: 'wordcount', showInMainToolbar: true, showInElementToolbar: true },
773
- { name: 'symbols', showInMainToolbar: true, showInElementToolbar: false },
774
- ];
775
- ```
776
-
777
- To disable loading this file, you can set disableConfig to false:
778
-
779
- ```javascript
780
- const builder = new ContentBuilder({
781
- container: '.is-container',
782
- disableConfig: false
783
- });
784
- ```
785
-
786
- Note that using an external configuration file is an approach that comes from the previous version of ContentBuilder.js.
787
- In the previous version, the plugins parameter is configured like this:
788
-
789
- ```javascript
790
- ['preview','wordcount']
791
- ```
792
- This still works, however we recommend using the new approach (explained above) for future flexibility.
793
-
794
- #### Plugin Development
795
-
796
- If you want to create your own plugin, please see this guide:
797
-
798
- https://innovastudio.com/content-builder/plugin-development.aspx
799
-
800
- ## Modules
801
-
802
- With modules, you can extend snippets.
803
-
804
- Normally, snippets are defined as static HTML. With a module snippet (snippet as a module), you can a create dynamic (non-static) snippets for ContentBuilder.js. You can add custom scripts to control the snippet content, create interactive elements and make it configurable via a custom dialog.
805
-
806
- To create your own module, please see this guide:
807
-
808
- https://innovastudio.com/content-builder/module-development.aspx
809
-
810
- Note that module files are located in:
811
-
812
- **assets/modules/**
813
-
814
- You will see there are some prebuilt modules in the folder (please see the above guide for details).
815
-
816
- ## Your Own Snippets
817
-
818
- You can create or add your own snippets by customizing the snippet file:
819
-
820
- **assets/minimalist-blocks/content.js**
821
-
822
- The snippet file is JSON formatted.
823
-
824
- Here is an example of a snippet definition in the snippet file:
825
-
826
- ```javascript
827
- {
828
- 'thumbnail': 'preview/basic-01.png',
829
- 'category': '120',
830
- 'html':
831
- '<div class="row">' +
832
- '<div class="column full">' +
833
- '<h1>My Heading Text</h1>' +
834
- '</div>' +
835
- '</div>'
836
- }
837
- ```
838
-
839
- A snippet needs to have a thumbnail, category number and HTML content.
840
-
841
- Thumbnails are created & stored in the **preview/** folder:
842
-
843
- **assets/minimalist-blocks/preview/**
844
-
845
- Snippet categories you can use:
846
-
847
- - 120: Basic
848
- - 118: Article
849
- - 101: Headline
850
- - 119: Buttons
851
- - 102: Photos
852
- - 103: Profile
853
- - 116: Contact
854
- - 104: Products
855
- - 105: Features
856
- - 106: Process
857
- - 107: Pricing
858
- - 108: Skills
859
- - 109: Achievements
860
- - 110: Quotes
861
- - 111: Partners
862
- - 112: As Featured On
863
- - 113: Page Not Found
864
- - 114: Coming Soon
865
- - 115: Help, FAQ
866
-
867
- The HTML content for the snippets needs to be formatted in a simple grid. Here are some examples:
868
-
869
- Single column:
870
-
871
- ```html
872
- <div class="row">
873
- <div class="column full">
874
- ...
875
- </div>
876
- </div>
877
- ```
878
-
879
- Two columns:
880
-
881
- ```html
882
- <div class="row">
883
- <div class="column half">
884
- ...
885
- </div>
886
- <div class="column half">
887
- ...
888
- </div>
889
- </div>
890
- ```
891
-
892
- Three columns:
893
-
894
- ```html
895
- <div class="row">
896
- <div class="column third">
897
- ...
898
- </div>
899
- <div class="column third">
900
- ...
901
- </div>
902
- <div class="column third">
903
- ...
904
- </div>
905
- </div>
906
- ```
907
-
908
- Four columns:
909
-
910
- ```html
911
- <div class="row">
912
- <div class="fourth third">
913
- ...
914
- </div>
915
- <div class="fourth third">
916
- ...
917
- </div>
918
- <div class="fourth third">
919
- ...
920
- </div>
921
- <div class="fourth third">
922
- ...
923
- </div>
924
- </div>
925
- ```
926
-
927
- Five columns:
928
-
929
- ```html
930
- <div class="row">
931
- <div class="column fifth">
932
- ...
933
- </div>
934
- <div class="column fifth">
935
- ...
936
- </div>
937
- <div class="column fifth">
938
- ...
939
- </div>
940
- <div class="column fifth">
941
- ...
942
- </div>
943
- <div class="column fifth">
944
- ...
945
- </div>
946
- </div>
947
- ```
948
-
949
- Six columns:
950
-
951
- ```html
952
- <div class="row">
953
- <div class="column sixth">
954
- ...
955
- </div>
956
- <div class="column sixth">
957
- ...
958
- </div>
959
- <div class="column sixth">
960
- ...
961
- </div>
962
- <div class="column sixth">
963
- ...
964
- </div>
965
- <div class="column sixth">
966
- ...
967
- </div>
968
- <div class="column sixth">
969
- ...
970
- </div>
971
- </div>
972
- ```
973
-
974
- If you are using a css framework, such as Bootstrap or Foundation, this simple grid will be automatically converted to the framework grid you’re using.
975
-
976
- ContentBuilder.js has default maximum number of columns is set to 4. You can increase this limit by setting:
977
-
978
- ```javascript
979
- const builder = new ContentBuilder({
980
- container: '.container',
981
- maxColumns: 5
982
- });
983
- ```
984
-
985
- Other layouts you can use to create your own your snippets:
986
-
987
- ```html
988
- <div class="row">
989
- <div class="column two-third">
990
- ...
991
- </div>
992
- <div class="column third">
993
- ...
994
- </div>
995
- </div>
996
- ```
997
-
998
- Result:
999
-
1000
- ![Layout example](docs/two-third.png)
1001
-
1002
- ```html
1003
- <div class="row">
1004
- <div class="column two-fourth">
1005
- ...
1006
- </div>
1007
- <div class="column fourth">
1008
- ...
1009
- </div>
1010
- </div>
1011
- ```
1012
-
1013
- Result:
1014
-
1015
- ![Layout example](docs/two-fourth.png)
1016
-
1017
- ```html
1018
- <div class="row">
1019
- <div class="column two-fifth">
1020
- ...
1021
- </div>
1022
- <div class="column fifth">
1023
- ...
1024
- </div>
1025
- </div>
1026
- ```
1027
-
1028
- Result:
1029
-
1030
- ![Layout example](docs/two-fifth.png)
1031
-
1032
- ```html
1033
- <div class="row">
1034
- <div class="column two-sixth">
1035
- ...
1036
- </div>
1037
- <div class="column sixth">
1038
- ...
1039
- </div>
1040
- </div>
1041
- ```
1042
-
1043
- Result:
1044
-
1045
- ![Layout example](docs/two-sixth.png)
1046
-
1047
- You can also add some behavior in your HTML snippets:
1048
-
1049
- - To make an image not replaceable, add the **data-fixed** attribute to the <img> element, for example:
1050
- ```html
1051
- <img src=".." data-fixed />
1052
- ```
1053
-
1054
- - To make a column not editable, add the **data-noedit** attribute to the column, for example:
1055
- ```html
1056
- <div class="row">
1057
- <div class="column full" data-noedit>
1058
- ...
1059
- </div>
1060
- </div>
1061
- ```
1062
-
1063
- - To make a column not editable and cannot be deleted, moved or duplicated, add the **data-protected** attribute to the column, for example:
1064
- ```html
1065
- <div class="row">
1066
- <div class="column full" data-protected>
1067
- ...
1068
- </div>
1069
- </div>
1070
- ```
1071
-
1072
- ## CSS Framework Support
1073
-
1074
- ContentBuilder.js can be used with popular css frameworks, such as Bootstrap, Foundation and more.
1075
- There are 2 types of configuration:
1076
-
1077
- #### 1. If the framework has 12 columns grid system
1078
-
1079
- Specify the framework classes using the **row** & **cols** parameters.
1080
-
1081
- Example:
1082
-
1083
- Bootstrap:
1084
-
1085
- ```javascript
1086
- const builder = new ContentBuilder({
1087
- container: '.container',
1088
- row: 'row',
1089
- cols: ['col-md-1', 'col-md-2', 'col-md-3', 'col-md-4', 'col-md-5', 'col-md-6', 'col-md-7', 'col-md-8', 'col-md-9', 'col-md-10', 'col-md-11', 'col-md-12']
1090
- });
1091
- ```
1092
-
1093
- Foundation:
1094
-
1095
- ```javascript
1096
- const builder = new ContentBuilder({
1097
- container: '.container',
1098
- row: 'row',
1099
- cols: ['large-1 columns', 'large-2 columns', 'large-3 columns', 'large-4 columns', 'large-5 columns', 'large-6 columns', 'large-7 columns', 'large-8 columns', 'large-9 columns', 'large-10 columns', 'large-11 columns', 'large-12 columns']
1100
- });
1101
- ```
1102
-
1103
- Tailwind:
1104
- ```javascript
1105
- const builder = new ContentBuilder({
1106
- container: '.container',
1107
- row: 'flex flex-col md:flex-row',
1108
- cols: [
1109
- 'w-full md:w-1/12 px-4',
1110
- 'w-full md:w-2/12 px-4',
1111
- 'w-full md:w-3/12 px-4',
1112
- 'w-full md:w-4/12 px-4',
1113
- 'w-full md:w-5/12 px-4',
1114
- 'w-full md:w-6/12 px-4',
1115
- 'w-full md:w-7/12 px-4',
1116
- 'w-full md:w-8/12 px-4',
1117
- 'w-full md:w-9/12 px-4',
1118
- 'w-full md:w-10/12 px-4',
1119
- 'w-full md:w-11/12 px-4',
1120
- 'w-full px-4'],
1121
- });
1122
- ```
1123
-
1124
- #### 2. If the framework has grid system in which the column size increment is not constant
1125
-
1126
- Specify two additional parameters: **colequal** & **colsizes**
1127
-
1128
- - **colequal**: list of all class combinations that have same width
1129
- - **colsizes**: list of all class combinations in increment order
1130
-
1131
- Example:
1132
-
1133
- UIKit Framework:
1134
-
1135
- ```javascript
1136
- const builder = new ContentBuilder({
1137
- container: '.container',
1138
- row: 'uk-grid',
1139
- cols: ['uk-width-1-6@m', 'uk-width-1-5@m', 'uk-width-1-4@m', 'uk-width-1-3@m', 'uk-width-2-5@m', 'uk-width-1-2@m', 'uk-width-3-5@m', 'uk-width-2-3@m', 'uk-width-3-4@m', 'uk-width-4-5@m', 'uk-width-5-6@m', 'uk-width-1-1@m'],
1140
-
1141
- //the following parameters are needed for grid system in which the column size increment is not constant.
1142
- colequal: [
1143
- ['uk-width-1-4@m', 'uk-width-1-4@m', 'uk-width-1-4@m', 'uk-width-1-4@m'],
1144
- ['uk-width-1-3@m', 'uk-width-1-3@m', 'uk-width-1-3@m'],
1145
- ['uk-width-1-2@m', 'uk-width-1-2@m']
1146
- ],
1147
- colsizes: [
1148
- [ //increment for 3 columns
1149
- ['uk-width-1-5@m', 'uk-width-2-5@m', 'uk-width-2-5@m'],
1150
- ['uk-width-1-3@m', 'uk-width-1-3@m', 'uk-width-1-3@m'],
1151
- ['uk-width-2-5@m', 'uk-width-2-5@m', 'uk-width-1-5@m'],
1152
- ['uk-width-1-2@m', 'uk-width-1-4@m', 'uk-width-1-4@m'],
1153
- ['uk-width-3-5@m', 'uk-width-1-5@m', 'uk-width-1-5@m']
1154
- ],
1155
- [ //increment for 2 columns
1156
- ['uk-width-1-6@m', 'uk-width-5-6@m'],
1157
- ['uk-width-1-5@m', 'uk-width-4-5@m'],
1158
- ['uk-width-1-4@m', 'uk-width-3-4@m'],
1159
- ['uk-width-1-3@m', 'uk-width-2-3@m'],
1160
- ['uk-width-2-5@m', 'uk-width-3-5@m'],
1161
- ['uk-width-1-2@m', 'uk-width-1-2@m'],
1162
- ['uk-width-3-5@m', 'uk-width-2-5@m'],
1163
- ['uk-width-2-3@m', 'uk-width-1-3@m'],
1164
- ['uk-width-3-4@m', 'uk-width-1-4@m'],
1165
- ['uk-width-4-5@m', 'uk-width-1-5@m'],
1166
- ['uk-width-5-6@m', 'uk-width-1-6@m']
1167
- ],
1168
- ]
1169
- });
1170
- ```
1171
-
1172
- Note:
1173
- - With the configuration explained above, all snippets/blocks are automatically converted into the framework's grid system. So there is no modification needed on the snippet file when used in various frameworks.
1174
- - ContentBuilder.js may not always work on certain frameworks.
1175
- - Here are some examples on using various css frameworks:
1176
- - example1.html (without framework / use built in basic css)
1177
- - example1-bootstrap.html (Bootstrap Example)
1178
- - example1-bulma.html (Bulma Example)
1179
- - example1-foundation.html (Foundation Example)
1180
- - example1-foundationxy.html (Foundation XY Grid Example)
1181
- - example1-material.html (Material Design Lite Example)
1182
- - example1-materializecss.html (Materialize Example)
1183
- - example1-milligram.html (Milligram Example)
1184
- - example1-minicss.html (Mini.css Example)
1185
- - example1-mustardui.html (Mustard UI Example)
1186
- - example1-primer.html (Primer Example)
1187
- - example1-purecss.html (Pure Css Example)
1188
- - example1-skeleton.html (Skeleton Example)
1189
- - example1-spectre.html (Spectre.css Example)
1190
- - example1-tailwind (Tailwind Example)
1191
- - example1-uikit.html (UIKit Example)
1192
- - example1-w3css.html (W3.CSS Example)
1193
-
1194
- ## Multiple Editable Area Support
1195
-
1196
- To implement multiple editable area, Use the same initialization.
1197
-
1198
- Example:
1199
-
1200
- ```html
1201
- <div class="section">
1202
- <div class="container area1">
1203
- ...
1204
- </div>
1205
- </div>
1206
- <div class="section">
1207
- <div class="container area2">
1208
- ...
1209
- </div>
1210
- </div>
1211
- ```
1212
-
1213
- ```javascript
1214
- const builder = new ContentBuilder({
1215
- container: '.container'
1216
- });
1217
- ```
1218
-
1219
- To get the HTML content:
1220
-
1221
- ```javascript
1222
- let html1 = builder.html(document.querySelector('.area1')); //Get 1st area content
1223
-
1224
- let html2 = builder.html(document.querySelector('.area2')); //Get 1st area contentarea
1225
- ```
1226
-
1227
- Please try: example3.html
1228
-
1229
- ## Programmatically Add Editable Area
1230
-
1231
- If your application dynamically adds an editable area/container, you don't need to re-init the ContentBuilder.js.
1232
-
1233
- Just run applyBehavior() method:
1234
- ```javascript
1235
- builder.applyBehavior();
1236
- ```
1237
-
1238
- This will make the new container editable.
1239
-
1240
-
1241
- ## Lightbox Support
1242
-
1243
- With Lightbox support, you can click a link or column to open an image, video (.mp4) or Youtube in an animated modal window (a lightbox).
1244
-
1245
- To enable this feature:
1246
-
1247
- ```javascript
1248
- const builder = new ContentBuilder({
1249
- container: '.container',
1250
- useLightbox: true // default: false
1251
- });
1252
- ```
1253
-
1254
- If lightbox support is enabled, a checkbox to open the image or video link in a lightbox will be displayed in the Image and link dialog.
1255
-
1256
- ![Open in a Lightbox](docs/lightbox1.png)
1257
-
1258
- Also in the Column Settings dialog, the 'On Click' tab will be visible.
1259
-
1260
- ![On Click Tab](docs/lightbox2.png)
1261
-
1262
- To try the On-Click action, you will need to lock the column.
1263
-
1264
- ![Column Lock](docs/lock.png)
1265
-
1266
- Then, when you click the link or column, the lightbox will be opened (a locked column will disable the editing).
1267
-
1268
- ![Lightbox](docs/lightbox3.png)
1269
-
1270
- #### In Production
1271
-
1272
- In production (for viewing content), you will need to include a Lightbox script as follow:
1273
-
1274
- The css:
1275
-
1276
- ```html
1277
- <link href="assets/scripts/lightbox/lightbox.css" rel="stylesheet" type="text/css" />
1278
- ```
1279
-
1280
- And the js:
1281
-
1282
- ```html
1283
- <script src="assets/scripts/lightbox/lightbox.js"></script>
1284
- <script>
1285
- lightbox.init();
1286
- </script>
1287
- ```
1288
-
1289
- ## Color Picker
1290
-
1291
- The color picker shows some default color list.
1292
-
1293
- ![Color Picker](docs/color-picker.png)
1294
-
1295
- To configure the colors:
1296
- ```javascript
1297
- const builder = new ContentBuilder({
1298
- container: '.container',
1299
- colors: ["#ff8f00", "#ef6c00", "#d84315", "#c62828", "#58362f", "#37474f", "#353535",
1300
- "#f9a825", "#9e9d24", "#558b2f", "#ad1457", "#6a1b9a", "#4527a0", "#616161",
1301
- "#00b8c9", "#009666", "#2e7d32", "#0277bd", "#1565c0", "#283593", "#9e9e9e"],
1302
- });
1303
- ```
1304
-
1305
- ## Custom Tags
1306
-
1307
- Custom tags are commonly used in a CMS for adding dynamic element within the content by replacing the tags in production (not during editing). Here is an example:
1308
-
1309
- ![Custom Tags](docs/customtags.png)
1310
-
1311
- To configure this feature:
1312
-
1313
- ```javascript
1314
- const builder = new ContentBuilder({
1315
- container: '.container',
1316
- customTags: [["Site Name", "{%SITENAME%}"],
1317
- ["Logo", "{%LOGO%}"],
1318
- ["My Plugin", "{%MY_PLUGIN%}"],
1319
- });
1320
- ```
1321
-
1322
- ## Modal Animation
1323
-
1324
- Some modals open with animation. For example, when deleting a row, a confirmation modal shows with zoom animation on the content. To enable or disable this feature:
1325
-
1326
- ```javascript
1327
- const builder = new ContentBuilder({
1328
- container: '.container',
1329
- animateModal: false, // default: true
1330
- });
1331
- ```
1332
-
1333
- ## Custom Value
1334
-
1335
- You can pass any custom value to the server. In a CMS application, you can pass, for example, a user id or session id, etc.
1336
-
1337
- The value will be passed when an image is submitted to the server using the Form method. Note that in the AJAX post method, you may not need this feature as you can post any data during the AJAX post. On the server, the image handler can use this value to decide where to save the image for each user. This is more towards customizing your application.
1338
-
1339
- To specify a custom value:
1340
-
1341
- ```javascript
1342
- const builder = new ContentBuilder({
1343
- container: '.container',
1344
- customval: 200 // or any value
1345
- });
1346
- ```
1347
-
1348
- ## Preferences
1349
-
1350
- The preferences dialog allows you to choose your editing preferences. You can hide unwanted tools, choose the toolbar placement or even make the interface clean to write without distraction.
1351
-
1352
- ![Preferences](docs/preferences.png)
1353
-
1354
- Preference options are explained below.
1355
-
1356
- ### Builder Mode
1357
-
1358
- You can choose: Default, Minimal or Clean.
1359
-
1360
- #### Default
1361
-
1362
- The default mode shows all available buttons on the row & column tool.
1363
-
1364
- ![Default](docs/builder-mode-default.png)
1365
-
1366
- #### Minimal
1367
-
1368
- The minimal mode simplifies the row & column tool.
1369
-
1370
- ![Minimal](docs/builder-mode-minimal.png)
1371
-
1372
- As seen in the row tool, a new 'Grid' button is shown. Clicking on the button will show a small grid tool.
1373
-
1374
- ![Grid Tool](docs/builder-mode-minimal2.png)
1375
-
1376
- #### Clean
1377
-
1378
- This option will further simplify the interface, by showing only the 'Grid' button.
1379
-
1380
- ![Clean](docs/builder-mode-clean.png)
1381
-
1382
- #### To set the Builder Mode in code
1383
-
1384
- ```javascript
1385
- const builder = new ContentBuilder({
1386
- container: '.container',
1387
- builderMode: 'clean'
1388
- });
1389
- ```
1390
- Values:
1391
- - not set or empty (default)
1392
- - minimal
1393
- - clean
1394
-
1395
- ### Outline Mode
1396
-
1397
- You can choose: Row & Column, Row Only
1398
-
1399
- #### Row & Column
1400
-
1401
- Shows an outline on active row and column.
1402
-
1403
- ![Row & Column Outline](docs/outline-full.png)
1404
-
1405
- #### Row Only
1406
-
1407
- Shows an outline on active row only.
1408
-
1409
- ![Row Only Outline](docs/outline-row.png)
1410
-
1411
- #### To set the Outline Mode in code
1412
-
1413
- ```javascript
1414
- const builder = new ContentBuilder({
1415
- container: '.container',
1416
- outlineMode: 'row'
1417
- });
1418
- ```
1419
- Values:
1420
- - not set or empty => Row & Column (default)
1421
- - row => Row Only
1422
-
1423
- ### Outline Style
1424
-
1425
- You can choose: Colored, Gray
1426
-
1427
- Here the outline is set to gray.
1428
-
1429
- ![Gray Ouline](docs/outline-gray.png)
1430
-
1431
- #### To set the Outline Style in code
1432
-
1433
- ```javascript
1434
- const builder = new ContentBuilder({
1435
- container: '.container',
1436
- outlineStyle: 'grayoutline'
1437
- });
1438
- ```
1439
-
1440
- Values:
1441
- - not set or empty => Colored (default)
1442
- - grayoutline => Gray
1443
-
1444
- ### Hide Outline
1445
-
1446
- If checked, there will be no outline on active row or column.
1447
-
1448
- ![Outline Hidden](docs/outline-hide.png)
1449
-
1450
- #### To hide the Outline in code
1451
-
1452
- ```javascript
1453
- const builder = new ContentBuilder({
1454
- container: '.container',
1455
- rowcolOutline: false // outline will be hidden
1456
- });
1457
- ```
1458
- Values:
1459
- - true => Visible (default)
1460
- - false => Hidden
1461
-
1462
- ### Hide Column Tool
1463
-
1464
- If checked, column tool will not be visible on active column.
1465
-
1466
- ![Column Tool Hidden](docs/column-tool-hide.png)
1467
-
1468
- #### To hide the Column Tool in code
1469
-
1470
- ```javascript
1471
- const builder = new ContentBuilder({
1472
- container: '.container',
1473
- columnTool: false // column tool will be hidden
1474
- });
1475
- ```
1476
- Values:
1477
- - true => Visible (default)
1478
- - false => Hidden
1479
-
1480
- ### Row Tool Position
1481
-
1482
- You can choose: Left, Right.
1483
-
1484
- Here the position is set Left.
1485
-
1486
- ![Row Tool on Left](docs/row-tool-left.png)
1487
-
1488
- #### To set the Row Tool Position in code
1489
-
1490
- ```javascript
1491
- const builder = new ContentBuilder({
1492
- container: '.container',
1493
- rowTool: 'left' // positioned on left
1494
- });
1495
- ```
1496
- Values:
1497
- - right (default)
1498
- - left
1499
-
1500
- ### Tool Style
1501
-
1502
- You can choose: Colored, Mono.
1503
-
1504
- Here the tool style is set to Mono.
1505
-
1506
- ![Mono](docs/tool-style-mono.png)
1507
-
1508
- #### To set the Tool Style in code
1509
-
1510
- ```javascript
1511
- const builder = new ContentBuilder({
1512
- container: '.container',
1513
- toolStyle: 'gray' // = Gray or Mono
1514
- });
1515
- ```
1516
- Values:
1517
- - not set or empty => Colored (default)
1518
- - gray => Gray or Mono
1519
-
1520
- ### Hide Snippet (+) Tool
1521
-
1522
- If checked, the Add (+) Snippet button will be hidden.
1523
-
1524
- Here the Add (+) Snippet button is visible.
1525
-
1526
- ![Add Snippet Visible](docs/add-snippet-visible.png)
1527
-
1528
- And here the Add (+) Snippet button is hidden.
1529
-
1530
- ![Add Snippet Hidden](docs/add-snippet-hidden.png)
1531
-
1532
- #### To hide the Snippet (+) Tool in code
1533
-
1534
- ```javascript
1535
- const builder = new ContentBuilder({
1536
- container: '.container',
1537
- snippetAddTool: false // Snippet (+) tool will be hidden
1538
- });
1539
- ```
1540
- Values:
1541
- - true => Visible (default)
1542
- - false => Hidden
1543
-
1544
- ### Hide Element Tool
1545
-
1546
- If checked, the element tool will be hidden.
1547
-
1548
- Here the element tool is visible.
1549
-
1550
- ![Element Tool Visible](docs/elm-tool-visible.png)
1551
-
1552
- And here the element tool is hidden.
1553
-
1554
- ![Element Tool Hidden](docs/elm-tool-hidden.png)
1555
-
1556
- #### To hide the Element Tool in code
1557
-
1558
- ```javascript
1559
- const builder = new ContentBuilder({
1560
- container: '.container',
1561
- elementTool: false // Element tool will be hidden
1562
- });
1563
- ```
1564
- Values:
1565
- - true => Visible (default)
1566
- - false => Hidden
1567
-
1568
- ### Hide Element Highlight
1569
-
1570
- If checked, there will be no active element highlight.
1571
-
1572
- Here the element highlight is visible.
1573
-
1574
- ![Element Highlight Visible](docs/element-highlight-visible.png)
1575
-
1576
- And here the element highlight is not visible.
1577
-
1578
- ![Element Highlight Hidden](docs/element-highlight-hidden.png)
1579
-
1580
- #### To hide the Element Highlight in code
1581
-
1582
- ```javascript
1583
- const builder = new ContentBuilder({
1584
- container: '.container',
1585
- elementHighlight: false // Element highlight will be hidden
1586
- });
1587
- ```
1588
- Values:
1589
- - true => Visible (default)
1590
- - false => Hidden
1591
-
1592
- ### Snippet Sidebar Visibility
1593
-
1594
- You can choose: Auto, Always Visible.
1595
-
1596
- Normally, the snippet sidebar will be automatically closed during editing. If set to 'Always Visible', the snippet sidebar will stay visible.
1597
-
1598
- #### To set the Snippet Sidebar Visibility in code
1599
-
1600
- ```javascript
1601
- const builder = new ContentBuilder({
1602
- container: '.container',
1603
- snippetDisplay: 'visible' // stay visible
1604
- });
1605
- ```
1606
-
1607
- Values:
1608
- - auto => Auto close (default)
1609
- - visible => Stay visible
1610
-
1611
-
1612
- ### Paste Result
1613
-
1614
- You can choose:
1615
- - Text Only
1616
- - HTML (Without Style)
1617
- - HTML (With Style)
1618
-
1619
- This is a behavior you can choose when you paste copied content from another source, for example, from a Word document.
1620
-
1621
- #### To set the Paste Result in code
1622
-
1623
- ```javascript
1624
- const builder = new ContentBuilder({
1625
- container: '.container',
1626
- paste: 'text'
1627
- });
1628
- ```
1629
- Values:
1630
- - text (default)
1631
- - html
1632
- - html-without-styles
1633
-
1634
- ### Toolbar Position
1635
-
1636
- You can choose: Top, Left, or Right
1637
-
1638
- Normally the toolbar is positioned on top.
1639
-
1640
- If the position is set to Left, the toolbar will be shown on the left.
1641
-
1642
- ![Toolbar on Left](docs/toolbar-left.png)
1643
-
1644
- If the position is set to Right, the toolbar will be shown on the right.
1645
-
1646
- ![Toolbar on Right](docs/toolbar-right.png)
1647
-
1648
- #### To set the Toolbar Position in code
1649
-
1650
- ```javascript
1651
- const builder = new ContentBuilder({
1652
- container: '.container',
1653
- toolbar: 'left'
1654
- });
1655
- ```
1656
- Values:
1657
- - top (default)
1658
- - left
1659
- - right
1660
-
1661
- ### Programmatically Open Preference Dialog
1662
-
1663
- ```javascript
1664
- builder.viewConfig()
1665
- ```
1666
- ### Clear Saved Preferences
1667
-
1668
- Normaly, when you click Ok on the Preferences dialog, your chosen settings will be automatically saved (on browser local storage). So the next time you open the builder, you can still work with your chosen preferences.
1669
-
1670
- To force the builder to not use the saved preferences, you can use:
1671
-
1672
- ```javascript
1673
- const builder = new ContentBuilder({
1674
- container: '.container',
1675
- clearPreferences: true,
1676
- });
1677
- ```
1678
-
1679
- ### Example: Making the builder interface clean
1680
-
1681
- As an example, here are the settings you can choose to make the builder clean.
1682
-
1683
- ![Example Settings](docs/example-pref.png)
1684
-
1685
- In this example, the **Builder Mode** is set to 'Clean' and the **Hide Outline** is checked.
1686
-
1687
- Here is the result.
1688
-
1689
- ![The Result](docs/clean-ui.png)
1690
-
1691
- ## Themes
1692
-
1693
- To enable theme selection:
1694
-
1695
- ```javascript
1696
- const builder = new ContentBuilder({
1697
- container: '.container',
1698
- themes: [
1699
- ['#ffffff','',''],
1700
- ['#282828','dark','contentbuilder/themes/dark.css'],
1701
- ['#0088dc','colored','contentbuilder/themes/colored-blue.css'],
1702
- ['#006add','colored','contentbuilder/themes/colored-blue6.css'],
1703
- ['#0a4d92','colored','contentbuilder/themes/colored-darkblue.css'],
1704
- ['#96af16','colored','contentbuilder/themes/colored-green.css'],
1705
- ['#f3522b','colored','contentbuilder/themes/colored-orange.css'],
1706
-
1707
- ['#b92ea6','colored','contentbuilder/themes/colored-magenta.css'],
1708
- ['#e73171','colored','contentbuilder/themes/colored-pink.css'],
1709
- ['#782ec5','colored','contentbuilder/themes/colored-purple.css'],
1710
- ['#ed2828','colored','contentbuilder/themes/colored-red.css'],
1711
- ['#f9930f','colored','contentbuilder/themes/colored-yellow.css'],
1712
- ['#13b34b','colored','contentbuilder/themes/colored-green4.css'],
1713
- ['#333333','colored-dark','contentbuilder/themes/colored-dark.css'],
1714
-
1715
- ['#dbe5f5','light','contentbuilder/themes/light-blue.css'],
1716
- ['#fbe6f2','light','contentbuilder/themes/light-pink.css'],
1717
- ['#dcdaf3','light','contentbuilder/themes/light-purple.css'],
1718
- ['#ffe9e0','light','contentbuilder/themes/light-red.css'],
1719
- ['#fffae5','light','contentbuilder/themes/light-yellow.css'],
1720
- ['#ddf3dc','light','contentbuilder/themes/light-green.css'],
1721
- ['#c7ebfd','light','contentbuilder/themes/light-blue2.css'],
1722
-
1723
- ['#ffd5f2','light','contentbuilder/themes/light-pink2.css'],
1724
- ['#eadafb','light','contentbuilder/themes/light-purple2.css'],
1725
- ['#c5d4ff','light','contentbuilder/themes/light-blue3.css'],
1726
- ['#ffefb1','light','contentbuilder/themes/light-yellow2.css'],
1727
- ['#fefefe','light','contentbuilder/themes/light-gray3.css'],
1728
- ['#e5e5e5','light','contentbuilder/themes/light-gray2.css'],
1729
- ['#dadada','light','contentbuilder/themes/light-gray.css'],
1730
-
1731
- ['#3f4ec9','colored','contentbuilder/themes/colored-blue2.css'],
1732
- ['#6779d9','colored','contentbuilder/themes/colored-blue4.css'],
1733
- ['#10b9d7','colored','contentbuilder/themes/colored-blue3.css'],
1734
- ['#006add','colored','contentbuilder/themes/colored-blue5.css'],
1735
- ['#e92f94','colored','contentbuilder/themes/colored-pink3.css'],
1736
- ['#a761d9','colored','contentbuilder/themes/colored-purple2.css'],
1737
- ['#f9930f','colored','contentbuilder/themes/colored-yellow2.css'],
1738
-
1739
- ['#f3522b','colored','contentbuilder/themes/colored-red3.css'],
1740
- ['#36b741','colored','contentbuilder/themes/colored-green2.css'],
1741
- ['#00c17c','colored','contentbuilder/themes/colored-green3.css'],
1742
- ['#fb3279','colored','contentbuilder/themes/colored-pink2.css'],
1743
- ['#ff6d13','colored','contentbuilder/themes/colored-orange2.css'],
1744
- ['#f13535','colored','contentbuilder/themes/colored-red2.css'],
1745
- ['#646464','colored','contentbuilder/themes/colored-gray.css'],
1746
-
1747
- ['#3f4ec9','dark','contentbuilder/themes/dark-blue.css'],
1748
- ['#0b4d92','dark','contentbuilder/themes/dark-blue2.css'],
1749
- ['#006add','dark','contentbuilder/themes/dark-blue3.css'],
1750
- ['#5f3ebf','dark','contentbuilder/themes/dark-purple.css'],
1751
- ['#e92f69','dark','contentbuilder/themes/dark-pink.css'],
1752
- ['#4c4c4c','dark','contentbuilder/themes/dark-gray.css'],
1753
- ['#ed2828','dark','contentbuilder/themes/dark-red.css'],
1754
-
1755
- ['#006add','colored','contentbuilder/themes/colored-blue8.css'],
1756
- ['#ff7723','colored','contentbuilder/themes/colored-orange3.css'],
1757
- ['#ff5722','colored','contentbuilder/themes/colored-red5.css'],
1758
- ['#f13535','colored','contentbuilder/themes/colored-red4.css'],
1759
- ['#00bd79','colored','contentbuilder/themes/colored-green5.css'],
1760
- ['#557ae9','colored','contentbuilder/themes/colored-blue7.css'],
1761
- ['#fb3279','colored','contentbuilder/themes/colored-pink4.css'],
1762
- ],
1763
- });
1764
- ```
1765
-
1766
- Each theme definition consists of:
1767
- - color preview (for the selection)
1768
- - class name (needed by the css)
1769
- - css file
1770
-
1771
- When enabled, the theme selection will be visible on the Preferences dialog.
1772
-
1773
- ![Themes](docs/themes.png)
1774
-
1775
- Example themes:
1776
-
1777
- ![Red](docs/theme-red.png)
1778
-
1779
- ![Green](docs/theme-green.png)
1780
-
1781
- To load a specific theme programmatically, you can use:
1782
-
1783
- ```javascript
1784
- builder.setUIColor('colored','contentbuilder/contentbuilder-red.css');
1785
- ```
1786
- For light theme:
1787
-
1788
- ```javascript
1789
- builder.setUIColor('');
1790
- ```
1791
- For dark theme:
1792
-
1793
- ```javascript
1794
- builder.setUIColor('dark','/dist/contentbuilder-dark.css');
1795
- ```
1796
-
1797
- ## HTML Code Editing Support
1798
-
1799
- You can edit the HTML code of your content with or without syntax highlighting.
1800
-
1801
- To configure:
1802
-
1803
- ```javascript
1804
- const builder = new ContentBuilder({
1805
- container: '.container',
1806
- htmlSyntaxHighlighting: true,
1807
- });
1808
- ```
1809
-
1810
- With syntax highlighting:
1811
-
1812
- ![Code Editor with Syntax Highlighting](docs/html-code-highlighted.png)
1813
-
1814
- Without syntax highlighting:
1815
-
1816
- ![Code Editor without Syntax Highlighting](docs/html-code.png)
1817
-
1818
- #### Programmatically open HTML code editor
1819
-
1820
- To open HTML code editor programmatically:
1821
-
1822
- ```javascript
1823
- builder.viewHtml();
1824
- ```
1825
-
1826
- #### Disable Column HTML code editor
1827
-
1828
- The column HTML editor button is shown on the column tool popup. If disabled, the button will not be visible.
1829
-
1830
- ![Column HTML Editor](docs/html-editor-column.png)
1831
-
1832
- To disable:
1833
-
1834
- ```javascript
1835
- const builder = new ContentBuilder({
1836
- container: '.container',
1837
- columnHtmlEditor: false,
1838
- });
1839
- ```
1840
-
1841
- #### Disable Row HTML code editor
1842
-
1843
- The row HTML editor button is shown on the row tool popup. If disabled, the button will not be visible.
1844
-
1845
- ![Row HTML Editor](docs/html-editor-row.png)
1846
-
1847
- To disable:
1848
-
1849
- ```javascript
1850
- const builder = new ContentBuilder({
1851
- container: '.container',
1852
- rowHtmlEditor: false,
1853
- });
1854
- ```
1855
-
1856
- ## Loading HTML Content Programmatically
1857
-
1858
- To load HTML content programmatically, you can pass your HTML content in the **loadHtml()** method:
1859
-
1860
- ```javascript
1861
- builder.loadHtml(html);
1862
- ```
1863
-
1864
- ## Paste HTML Content Programmatically
1865
-
1866
- To paste HTML content programmatically, you can pass your HTML content in the **pasteHtmlAtCaret()** method:
1867
-
1868
- ```javascript
1869
- builder.pasteHtmlAtCaret(html);
1870
- ```
1871
- You will need to place the cursor on the content where you want to paste the HTML.
1872
-
1873
- ## Insert Custom HTML Snippet Programmatically
1874
-
1875
- To insert custom HTML snippet programmatically, you can pass your HTML snippet in the **addSnippet()** method:
1876
-
1877
- ```javascript
1878
- builder.addSnippet(`
1879
- <div class="row">
1880
- <div class="column">
1881
- <h3>Hello World!</h3>
1882
- </div>
1883
- </div>
1884
- `);
1885
- ```
1886
-
1887
- ## Element Selection
1888
-
1889
- By default, when you press CMD-A or CTRL-A, you will select the current element where cursor is placed (not selecting all elements on the entire column).
1890
- This behavior is defined by the **elementSelection** parameter:
1891
-
1892
- ```javascript
1893
- const builder = new ContentBuilder({
1894
- container: '.container',
1895
- elementSelection: true,
1896
- });
1897
- ```
1898
- If **elementSelection** is set to false, then the selection will go to the entire column.
1899
-
1900
- ## Style Panel
1901
-
1902
- ContentBuilder.js provides you with a style panel to format the selected element. Click the **Settings** button on the element tool popup to open the Style panel.
1903
-
1904
- ![Style Panel](docs/style-panel.png)
1905
-
1906
- To disable the Style panel button:
1907
-
1908
- ```javascript
1909
- const builder = new ContentBuilder({
1910
- container: '.container',
1911
- elementEditor: false,
1912
- });
1913
- ```
1914
-
1915
- ## Zoom Support
1916
-
1917
- You can change the editable area zoom by clicking the zoom icon on the toolbar and use the zoom slider.
1918
-
1919
- ![Zoom](docs/zoom.png)
1920
-
1921
- To specify the default zoom, use:
1922
-
1923
- ```javascript
1924
- const builder = new ContentBuilder({
1925
- container: '.container',
1926
- zoom: 0.8, // value: 0.5 to 1
1927
- });
1928
- ```
1929
-
1930
- When you change the zoom size, the value is saved automatically (on browser's local storage). So next time you open the builder, the previously chosen zoom will be used (not the default zoom value).
1931
-
1932
- Some event callbacks you can use when the zoom is changed.
1933
-
1934
- ```javascript
1935
- const builder = new ContentBuilder({
1936
- container: '.container',
1937
- onZoomStart: function() { ... },
1938
- onZoom: function(scale) { ... },
1939
- onZoomEnd: function(scale) { ... },
1940
- });
1941
- ```
1942
-
1943
- ## Toolbar
1944
-
1945
- #### Main Toolbar
1946
-
1947
- The default main toolbar shows the buttons as seen below:
1948
-
1949
- ![Default Toolbar](docs/toolbar-main.png)
1950
-
1951
- The second toolbar is displayed when you click the ... (more) button:
1952
-
1953
- ![Second Toolbar](docs/toolbar-main-more.png)
1954
-
1955
- To configure the main toolbar, use the **buttons** parameter, and to configure the second toolbar, use the **buttonsMore** parameter:
1956
-
1957
- ```javascript
1958
- const builder = new ContentBuilder({
1959
- container: '.container',
1960
- buttons: ['bold', 'italic', 'underline', 'formatting', 'color', 'align', 'textsettings', 'createlink', 'tags', '|', 'undo', 'redo', 'zoom', 'more'],
1961
- buttonsMore: ['icon', 'image', '|', 'list', 'font', 'formatpara', '|', 'html', 'preferences'],
1962
- });
1963
- ```
1964
-
1965
- Note: Use '|' for separator.
1966
-
1967
- **Allowed buttons for the main toolbar**:
1968
- - addsnippet
1969
- - bold
1970
- - italic
1971
- - underline
1972
- - formatting
1973
- - color
1974
- - removeformat
1975
- - align
1976
- - textsettings
1977
- - createlink
1978
- - tags
1979
- - undo
1980
- - redo
1981
- - zoom
1982
- - icon
1983
- - image
1984
- - list
1985
- - font
1986
- - formatpara
1987
- - gridtool
1988
- - html
1989
- - preferences
1990
- - more (cannot be used in second row)
1991
- - plugin buttons (such as: preview, wordcount, searchreplace, symbols)
1992
-
1993
-
1994
- #### Element Toolbar
1995
-
1996
- Element toolbar is displayed when a non-text element is selected, for example, when you select an image.
1997
-
1998
- The default element toolbar shows the buttons as seen below:
1999
-
2000
- ![Element Toolbar](docs/toolbar-element.png)
2001
-
2002
- When you click the … (more) button, a second row of buttons will be displayed:
2003
-
2004
- ![Second Toolbar](docs/toolbar-element-more.png)
2005
-
2006
- To configure the element toolbar, use the **elementButtons** parameter, and to configure the second row buttons, use the **elementButtonsMore** parameter:
2007
-
2008
- ```javascript
2009
- const builder = new ContentBuilder({
2010
- container: '.container',
2011
- elementButtons: ['left', 'center', 'right', 'full' , 'undo', 'redo', 'zoom', 'more'],
2012
- elementButtonsMore: ['|', 'html', 'preferences'],
2013
- });
2014
- ```
2015
-
2016
- **Allowed buttons for elementButtons**:
2017
- - addsnippet
2018
- - left
2019
- - center
2020
- - right
2021
- - full
2022
- - gridtool
2023
- - html
2024
- - preferences
2025
- - undo
2026
- - redo
2027
- - zoom
2028
- - more (cannot be used in second row)
2029
- - plugin buttons (such as: preview, wordcount, searchreplace, symbols)
2030
-
2031
- #### Plugin Buttons
2032
-
2033
- As you can see on both the main toolbar and the element toolbar, there are some additional buttons that come from installed plugins (on the left side of the second toolbar).
2034
-
2035
- ![Main Toolbar Plugin Buttons](docs/toolbar-main-plugin-buttons.png)
2036
-
2037
- ![Element Toolbar Plugin Buttons](docs/toolbar-element-plugin-buttons.png)
2038
-
2039
- The default installed plugins are:
2040
- - preview (adds the **Preview** button to preview the content in various screen sizes)
2041
- - wordcount (adds the **Word Count** button to show word count info)
2042
- - symbols (adds the **Symbols** button to insert symbols)
2043
- - buttoneditor (this plugin doesn't add a button on the toolbar)
2044
-
2045
- If plugin buttons are defined in the toolbar (the plugin name found in **buttons**, **buttonsMore**, **elementButtons** or **elementButtonsMore**), then the plugin buttons will not be automatically added on the left side of the second toolbar.
2046
-
2047
- Please see Plugins section for more info on plugins.
2048
-
2049
- #### Example: if you don't want to use the "More" button
2050
-
2051
- ```javascript
2052
- const builder = new ContentBuilder({
2053
- container: '.container',
2054
- buttons: ['bold', 'italic', 'undo', 'redo', 'zoom', 'preview'],
2055
- buttonsMore: [],
2056
- elementButtons: ['undo', 'redo', 'zoom', 'preview'],
2057
- elementButtonsMore: [],
2058
- plugins: [
2059
- { name: 'preview', showInMainToolbar: true, showInElementToolbar: true },
2060
- ],
2061
- pluginPath: 'contentbuilder/',
2062
- });
2063
- ```
2064
- As seen on the code, we install only the 'preview' plugin. You will need to define all installed plugin buttons on the toolbar.
2065
- Then you set the second toolbars to empty:
2066
- - buttonsMore: []
2067
- - elementButtonsMore: []
2068
-
2069
- Here is the result.
2070
-
2071
- ![Example](docs/toolbar-example1.png)
2072
-
2073
- Or, if you are not using any plugins, use:
2074
-
2075
- ```javascript
2076
- const builder = new ContentBuilder({
2077
- container: '.container',
2078
- buttons: ['bold', 'italic', 'undo', 'redo', 'zoom'],
2079
- buttonsMore: [],
2080
- elementButtons: ['undo', 'redo', 'zoom'],
2081
- elementButtonsMore: [],
2082
- disableConfig: true
2083
- });
2084
- ```
2085
- Here is the result.
2086
-
2087
- ![Example](docs/toolbar-example2.png)
2088
-
2089
- #### Icon Toolbar
2090
-
2091
- Another toolbar that is used is the icon toolbar which is displayed when an icon is selected.
2092
-
2093
- The icon toolbar shows the buttons as seen below:
2094
-
2095
- ![Icon toolbar](docs/icon-toolbar.png)
2096
-
2097
- To configure the icon toolbar, use the **iconButtons** parameter, and to configure the second row buttons, use the **iconButtonsMore** parameter:
2098
-
2099
- ```javascript
2100
- const builder = new ContentBuilder({
2101
- container: '.container',
2102
- iconButtons: ['icon', 'color','textsettings', 'createLink','|', 'undo', 'redo', 'zoom', 'more'],
2103
- iconButtonsMore: ['|', 'html', 'preferences'],
2104
- });
2105
- ```
2106
-
2107
- ## Text Settings
2108
-
2109
- With Text Settings on the toolbar, you can adjust font size, font weight, line spacing (line height) and letter spacing.
2110
-
2111
- ![Text Settings](docs/text-settings.png)
2112
-
2113
- If the Bold button on the toolbar is sufficient for you, you can hide the font weight settings by setting the **simpleTextSettings** parameter to true.
2114
-
2115
- ```javascript
2116
- const builder = new ContentBuilder({
2117
- container: '.container',
2118
- simpleTextSettings: true,
2119
- });
2120
- ```
2121
-
2122
- ![Text Settings](docs/text-settings2.png)
2123
-
2124
- ## Undo & Redo
2125
-
2126
- You can programmatically perform an undo or redo action.
2127
-
2128
- To undo:
2129
-
2130
- ```javascript
2131
- builder.undo();
2132
- ```
2133
-
2134
- To redo:
2135
-
2136
- ```javascript
2137
- builder.redo();
2138
- ```
2139
-
2140
- ## Events
2141
-
2142
- Some useful parameters to define an event callback function:
2143
-
2144
- #### onRender
2145
- Triggered when content structure is changed, for example, when a new snippet is added.
2146
- If you monitor your content to apply a certain process or add a certain behavior, you can re-run your process here.
2147
-
2148
- ```javascript
2149
- const builder = new ContentBuilder({
2150
- container: '.container',
2151
- onRender: function() { ... }
2152
- });
2153
- ```
2154
-
2155
- #### onChange
2156
- Triggered when content is changed.
2157
-
2158
- ```javascript
2159
- const builder = new ContentBuilder({
2160
- container: '.container',
2161
- onChange: function() { ... }
2162
- });
2163
- ```
2164
-
2165
- #### onContentClick(event)
2166
- Triggered when content is clicked.
2167
-
2168
- ```javascript
2169
- const builder = new ContentBuilder({
2170
- container: '.container',
2171
- onContentClick: function(event) { ... }
2172
- });
2173
- ```
2174
-
2175
- ## Destroy
2176
-
2177
- To destroy the builder plugin:
2178
-
2179
- ```javascript
2180
- builder.destroy();
2181
- ```
2182
-
2183
- ## Flexible Path
2184
-
2185
- ContentBuilder.js requires some assets located in the **assets/** folder. For example, there are icons, optional scripts for module, etc.
2186
-
2187
- If you want to change the location of the assets/ folder, you can change the **assetPath** value:
2188
-
2189
- ```javascript
2190
- const builder = new ContentBuilder({
2191
- container: '.container',
2192
- assetPath: 'assets/'
2193
- });
2194
- ```
2195
- The **assetPath** value is required by the icons and optional scripts for module.
2196
-
2197
- There are some folders inside the **assets/** folder:
2198
-
2199
- #### assets/fonts/
2200
- This folder contains thumbnails for the font selection. You can change the location of this folder by changing the value of the **fontAssetPath** parameter:
2201
- ```javascript
2202
- const builder = new ContentBuilder({
2203
- container: '.container',
2204
- fontAssetPath: 'assets/fonts/'
2205
- });
2206
- ```
2207
-
2208
- #### assets/minimalist-blocks/
2209
- This is the location of the snippet file and its assets. To change the location:
2210
- ```javascript
2211
- const builder = new ContentBuilder({
2212
- container: '.container',
2213
- snippetUrl: 'assets/minimalist-blocks/content.js', // Snippet file
2214
- snippetPath: 'assets/minimalist-blocks/', // Location of snippets' assets
2215
- });
2216
- ```
2217
- You may also need to use the **snippetPathReplace** parameter. Please see the usage in the Snippets section in this documentation.
2218
-
2219
- #### assets/modules/
2220
- This is the location of the modules. To change the location:
2221
- ```javascript
2222
- const builder = new ContentBuilder({
2223
- container: '.container',
2224
- modulePath: 'assets/modules/'
2225
- });
2226
- ```
2227
-
2228
- Another location you may want to change is the **plugins/** folder location, which contains plugin-related files.
2229
-
2230
- #### contentbuilder/plugins/
2231
- Here you just need to specify the pluginPath parameter with the folder where the plugins/ folder is located. The default value is the contentbuilder/ folder.
2232
- To change the location:
2233
- ```javascript
2234
- const builder = new ContentBuilder({
2235
- container: '.container',
2236
- pluginPath: 'contentbuilder/',
2237
- });
2238
- ```
2239
-
2240
-
2241
- ## Credits
2242
-
2243
- #### Libraries
2244
-
2245
- - CodeMirror, Copyright (C) 2017 by Marijn Haverbeke <marijnh@gmail.com> and others (MIT license), https://github.com/codemirror/CodeMirror
2246
- - Cropper.js, Copyright 2015-present Chen Fengyuan (MIT license), https://fengyuanchen.github.io/cropperjs/
2247
- - Ionicons, Copyright (c) 2015-present Ionic (http://ionic.io/) (MIT license), https://ionic.io/ionicons/v1
2248
- - js-beautify, Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors (MIT license), https://github.com/beautify-web/js-beautify
2249
- - Moveable, Copyright (c) 2019 Daybrush (MIT license), https://github.com/daybrush/moveable
2250
- - Sortable, Copyright (c) 2019 All contributors to Sortable (MIT license), https://github.com/SortableJS/Sortable
2251
- - Tabler Icons, Copyright (c) 2020 Paweł Kuna (MIT license), https://github.com/tabler/tabler-icons
2252
-