pages_core 3.12.1 → 3.12.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/app/assets/builds/pages_core/admin-dist.js +135 -50
  4. data/app/assets/builds/pages_core/admin-dist.js.map +7 -0
  5. data/app/assets/builds/pages_core/admin.css +72 -20
  6. data/app/assets/stylesheets/pages_core/admin/components/attachments.css +1 -1
  7. data/app/assets/stylesheets/pages_core/admin/components/image_editor.css +2 -2
  8. data/app/assets/stylesheets/pages_core/admin/components/image_grid.css +8 -8
  9. data/app/assets/stylesheets/pages_core/admin/components/image_uploader.css +2 -2
  10. data/app/assets/stylesheets/pages_core/admin/components/layout.css +2 -2
  11. data/app/assets/stylesheets/pages_core/admin/components/modal.css +2 -2
  12. data/app/assets/stylesheets/pages_core/admin/components/search.css +27 -0
  13. data/app/assets/stylesheets/pages_core/admin/controllers/pages.css +6 -0
  14. data/app/controllers/admin/pages_controller.rb +12 -11
  15. data/app/controllers/concerns/pages_core/rss_controller.rb +17 -1
  16. data/app/controllers/pages_core/admin_controller.rb +6 -0
  17. data/app/controllers/pages_core/frontend/pages_controller.rb +9 -5
  18. data/app/controllers/pages_core/sitemaps_controller.rb +3 -5
  19. data/app/helpers/admin/pages_helper.rb +32 -0
  20. data/app/helpers/pages_core/images_helper.rb +28 -7
  21. data/app/javascript/admin-dist.ts +2 -0
  22. data/app/javascript/components/Attachments/{Attachment.jsx → Attachment.tsx} +42 -33
  23. data/app/javascript/components/Attachments/{AttachmentEditor.jsx → AttachmentEditor.tsx} +23 -23
  24. data/app/javascript/components/{EditableImage.jsx → EditableImage.tsx} +27 -24
  25. data/app/javascript/components/{FileUploadButton.jsx → FileUploadButton.tsx} +15 -16
  26. data/app/javascript/components/ImageCropper/FocalPoint.tsx +94 -0
  27. data/app/javascript/components/ImageCropper/{Image.jsx → Image.tsx} +13 -14
  28. data/app/javascript/components/ImageCropper/{Toolbar.jsx → Toolbar.tsx} +16 -12
  29. data/app/javascript/components/ImageCropper/{useCrop.js → useCrop.ts} +80 -37
  30. data/app/javascript/components/{ImageCropper.jsx → ImageCropper.tsx} +17 -15
  31. data/app/javascript/components/ImageEditor/{Form.jsx → Form.tsx} +24 -23
  32. data/app/javascript/components/{ImageEditor.jsx → ImageEditor.tsx} +17 -15
  33. data/app/javascript/components/ImageGrid/{DragElement.jsx → DragElement.tsx} +12 -10
  34. data/app/javascript/components/ImageGrid/{GridImage.jsx → GridImage.tsx} +40 -30
  35. data/app/javascript/components/ImageGrid/{Placeholder.jsx → Placeholder.tsx} +5 -6
  36. data/app/javascript/components/ImageGrid.jsx +3 -4
  37. data/app/javascript/components/{ImageUploader.jsx → ImageUploader.tsx} +46 -41
  38. data/app/javascript/components/Modal.tsx +48 -0
  39. data/app/javascript/components/PageImages.tsx +28 -0
  40. data/app/javascript/components/{PageTreeDraggable.jsx → PageTree/Draggable.tsx} +79 -57
  41. data/app/javascript/components/{PageTreeNode.jsx → PageTree/Node.tsx} +79 -70
  42. data/app/javascript/components/PageTree/types.ts +15 -0
  43. data/app/javascript/components/PageTree.tsx +206 -0
  44. data/app/javascript/components/RichTextToolbarButton.tsx +17 -0
  45. data/app/javascript/components/TagEditor/{AddTagForm.jsx → AddTagForm.tsx} +9 -10
  46. data/app/javascript/components/TagEditor/{Tag.jsx → Tag.tsx} +8 -9
  47. data/app/javascript/components/{TagEditor.jsx → TagEditor.tsx} +12 -13
  48. data/app/javascript/components/Toast.tsx +61 -0
  49. data/app/javascript/components/drag/{draggedOrder.js → draggedOrder.ts} +22 -12
  50. data/app/javascript/components/drag/types.ts +28 -0
  51. data/app/javascript/components/drag/{useDragCollection.js → useDragCollection.ts} +40 -22
  52. data/app/javascript/components/drag/{useDragUploader.js → useDragUploader.ts} +34 -25
  53. data/app/javascript/components/drag/useDraggable.ts +21 -0
  54. data/app/javascript/components/{drag.js → drag.ts} +1 -0
  55. data/app/javascript/controllers/{EditPageController.js → EditPageController.ts} +3 -1
  56. data/app/javascript/controllers/{LoginController.js → LoginController.ts} +7 -3
  57. data/app/javascript/controllers/{MainController.js → MainController.ts} +19 -14
  58. data/app/javascript/features/{RichText.jsx → RichText.tsx} +3 -3
  59. data/app/javascript/{index.js → index.ts} +8 -7
  60. data/app/javascript/lib/{Tree.js → Tree.ts} +106 -85
  61. data/app/javascript/lib/{copyToClipboard.js → copyToClipboard.ts} +1 -1
  62. data/app/javascript/lib/{readyHandler.js → readyHandler.ts} +4 -2
  63. data/app/javascript/lib/{request.js → request.ts} +11 -5
  64. data/app/javascript/stores/useModalStore.ts +15 -0
  65. data/app/javascript/stores/useToastStore.ts +26 -0
  66. data/app/javascript/stores.ts +2 -0
  67. data/app/javascript/types.ts +30 -0
  68. data/app/policies/page_policy.rb +4 -0
  69. data/app/views/admin/calendars/_sidebar.html.erb +3 -0
  70. data/app/views/admin/news/_sidebar.html.erb +3 -0
  71. data/app/views/admin/pages/_list_item.html.erb +4 -22
  72. data/app/views/admin/pages/_search_bar.html.erb +12 -0
  73. data/app/views/admin/pages/index.html.erb +3 -0
  74. data/app/views/admin/pages/search.html.erb +54 -0
  75. data/app/views/feeds/pages.rss.builder +3 -9
  76. data/config/routes.rb +1 -0
  77. data/lib/pages_core/configuration/pages.rb +0 -1
  78. data/lib/rails/generators/pages_core/frontend/frontend_generator.rb +33 -17
  79. data/lib/rails/generators/pages_core/frontend/templates/application.html.erb +0 -1
  80. data/lib/rails/generators/pages_core/frontend/templates/javascript/lib/gridOverlay.ts +40 -0
  81. data/lib/rails/generators/pages_core/frontend/templates/javascript/lib/responsiveEmbeds.ts +68 -0
  82. data/lib/rails/generators/pages_core/frontend/templates/postcss.config.js +17 -0
  83. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/application.postcss.css +4 -0
  84. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/components/base.css +24 -0
  85. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/components/layout.css +21 -0
  86. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/config.css +5 -0
  87. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/global/animation.css +5 -0
  88. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/global/colors.css +18 -0
  89. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/global/fonts.css +6 -0
  90. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/global/grid.css +65 -0
  91. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/global/typography.css +131 -0
  92. data/lib/rails/generators/pages_core/install/templates/pages_initializer.rb +0 -3
  93. metadata +69 -63
  94. data/app/javascript/admin-dist.js +0 -2
  95. data/app/javascript/components/ImageCropper/FocalPoint.jsx +0 -93
  96. data/app/javascript/components/Modal.jsx +0 -59
  97. data/app/javascript/components/PageImages.jsx +0 -25
  98. data/app/javascript/components/PageTree.jsx +0 -196
  99. data/app/javascript/components/RichTextToolbarButton.jsx +0 -20
  100. data/app/javascript/components/Toast.jsx +0 -72
  101. data/app/javascript/components/drag/useDraggable.js +0 -17
  102. data/app/javascript/stores/ModalStore.jsx +0 -12
  103. data/app/javascript/stores/ToastStore.jsx +0 -14
  104. data/app/javascript/stores.js +0 -2
  105. data/lib/rails/generators/pages_core/frontend/templates/javascript/lib/GridOverlay.js +0 -66
  106. data/lib/rails/generators/pages_core/frontend/templates/javascript/lib/ResponsiveEmbeds.js +0 -72
  107. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/application.sass.scss +0 -15
  108. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/components/base.scss +0 -12
  109. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/config.scss +0 -26
  110. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/framework/breakpoints.scss +0 -42
  111. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/framework/clearfix.scss +0 -7
  112. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/framework/fonts.scss +0 -32
  113. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/framework/grid.scss +0 -168
  114. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/framework/grid_overlay.scss +0 -44
  115. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/global/colors.scss +0 -8
  116. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/global/typography.scss +0 -90
  117. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/vendor/normalize.css +0 -349
  118. /data/app/javascript/components/Attachments/{Placeholder.jsx → Placeholder.tsx} +0 -0
  119. /data/app/javascript/components/ImageGrid/{FilePlaceholder.jsx → FilePlaceholder.tsx} +0 -0
  120. /data/app/javascript/{components.js → components.ts} +0 -0
  121. /data/app/javascript/{hooks.js → hooks.ts} +0 -0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pages_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.12.1
4
+ version: 3.12.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Inge Jørgensen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-16 00:00:00.000000000 Z
11
+ date: 2023-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -361,6 +361,7 @@ files:
361
361
  - app/assets/builds/fonts/b2c7b78f.woff2
362
362
  - app/assets/builds/fonts/ceddc204.ttf
363
363
  - app/assets/builds/pages_core/admin-dist.js
364
+ - app/assets/builds/pages_core/admin-dist.js.map
364
365
  - app/assets/builds/pages_core/admin.css
365
366
  - app/assets/images/pages/admin/angle-down-solid.svg
366
367
  - app/assets/images/pages/admin/drag-icon.png
@@ -383,6 +384,7 @@ files:
383
384
  - app/assets/stylesheets/pages_core/admin/components/modal.css
384
385
  - app/assets/stylesheets/pages_core/admin/components/page_tree.css
385
386
  - app/assets/stylesheets/pages_core/admin/components/pagination.css
387
+ - app/assets/stylesheets/pages_core/admin/components/search.css
386
388
  - app/assets/stylesheets/pages_core/admin/components/sidebar.css
387
389
  - app/assets/stylesheets/pages_core/admin/components/tabs.css
388
390
  - app/assets/stylesheets/pages_core/admin/components/tag_editor.css
@@ -461,60 +463,63 @@ files:
461
463
  - app/helpers/pages_core/meta_tags_helper.rb
462
464
  - app/helpers/pages_core/open_graph_tags_helper.rb
463
465
  - app/helpers/pages_core/page_path_helper.rb
464
- - app/javascript/admin-dist.js
465
- - app/javascript/components.js
466
+ - app/javascript/admin-dist.ts
467
+ - app/javascript/components.ts
466
468
  - app/javascript/components/Attachments.jsx
467
- - app/javascript/components/Attachments/Attachment.jsx
468
- - app/javascript/components/Attachments/AttachmentEditor.jsx
469
- - app/javascript/components/Attachments/Placeholder.jsx
469
+ - app/javascript/components/Attachments/Attachment.tsx
470
+ - app/javascript/components/Attachments/AttachmentEditor.tsx
471
+ - app/javascript/components/Attachments/Placeholder.tsx
470
472
  - app/javascript/components/DateRangeSelect.jsx
471
- - app/javascript/components/EditableImage.jsx
472
- - app/javascript/components/FileUploadButton.jsx
473
- - app/javascript/components/ImageCropper.jsx
474
- - app/javascript/components/ImageCropper/FocalPoint.jsx
475
- - app/javascript/components/ImageCropper/Image.jsx
476
- - app/javascript/components/ImageCropper/Toolbar.jsx
477
- - app/javascript/components/ImageCropper/useCrop.js
478
- - app/javascript/components/ImageEditor.jsx
479
- - app/javascript/components/ImageEditor/Form.jsx
473
+ - app/javascript/components/EditableImage.tsx
474
+ - app/javascript/components/FileUploadButton.tsx
475
+ - app/javascript/components/ImageCropper.tsx
476
+ - app/javascript/components/ImageCropper/FocalPoint.tsx
477
+ - app/javascript/components/ImageCropper/Image.tsx
478
+ - app/javascript/components/ImageCropper/Toolbar.tsx
479
+ - app/javascript/components/ImageCropper/useCrop.ts
480
+ - app/javascript/components/ImageEditor.tsx
481
+ - app/javascript/components/ImageEditor/Form.tsx
480
482
  - app/javascript/components/ImageGrid.jsx
481
- - app/javascript/components/ImageGrid/DragElement.jsx
482
- - app/javascript/components/ImageGrid/FilePlaceholder.jsx
483
- - app/javascript/components/ImageGrid/GridImage.jsx
484
- - app/javascript/components/ImageGrid/Placeholder.jsx
485
- - app/javascript/components/ImageUploader.jsx
486
- - app/javascript/components/Modal.jsx
483
+ - app/javascript/components/ImageGrid/DragElement.tsx
484
+ - app/javascript/components/ImageGrid/FilePlaceholder.tsx
485
+ - app/javascript/components/ImageGrid/GridImage.tsx
486
+ - app/javascript/components/ImageGrid/Placeholder.tsx
487
+ - app/javascript/components/ImageUploader.tsx
488
+ - app/javascript/components/Modal.tsx
487
489
  - app/javascript/components/PageDates.jsx
488
490
  - app/javascript/components/PageFiles.jsx
489
- - app/javascript/components/PageImages.jsx
490
- - app/javascript/components/PageTree.jsx
491
- - app/javascript/components/PageTreeDraggable.jsx
492
- - app/javascript/components/PageTreeNode.jsx
491
+ - app/javascript/components/PageImages.tsx
492
+ - app/javascript/components/PageTree.tsx
493
+ - app/javascript/components/PageTree/Draggable.tsx
494
+ - app/javascript/components/PageTree/Node.tsx
495
+ - app/javascript/components/PageTree/types.ts
493
496
  - app/javascript/components/RichTextArea.jsx
494
- - app/javascript/components/RichTextToolbarButton.jsx
495
- - app/javascript/components/TagEditor.jsx
496
- - app/javascript/components/TagEditor/AddTagForm.jsx
497
- - app/javascript/components/TagEditor/Tag.jsx
498
- - app/javascript/components/Toast.jsx
499
- - app/javascript/components/drag.js
500
- - app/javascript/components/drag/draggedOrder.js
501
- - app/javascript/components/drag/useDragCollection.js
502
- - app/javascript/components/drag/useDragUploader.js
503
- - app/javascript/components/drag/useDraggable.js
504
- - app/javascript/controllers/EditPageController.js
505
- - app/javascript/controllers/LoginController.js
506
- - app/javascript/controllers/MainController.js
497
+ - app/javascript/components/RichTextToolbarButton.tsx
498
+ - app/javascript/components/TagEditor.tsx
499
+ - app/javascript/components/TagEditor/AddTagForm.tsx
500
+ - app/javascript/components/TagEditor/Tag.tsx
501
+ - app/javascript/components/Toast.tsx
502
+ - app/javascript/components/drag.ts
503
+ - app/javascript/components/drag/draggedOrder.ts
504
+ - app/javascript/components/drag/types.ts
505
+ - app/javascript/components/drag/useDragCollection.ts
506
+ - app/javascript/components/drag/useDragUploader.ts
507
+ - app/javascript/components/drag/useDraggable.ts
508
+ - app/javascript/controllers/EditPageController.ts
509
+ - app/javascript/controllers/LoginController.ts
510
+ - app/javascript/controllers/MainController.ts
507
511
  - app/javascript/controllers/PageOptionsController.js
508
- - app/javascript/features/RichText.jsx
509
- - app/javascript/hooks.js
510
- - app/javascript/index.js
511
- - app/javascript/lib/Tree.js
512
- - app/javascript/lib/copyToClipboard.js
513
- - app/javascript/lib/readyHandler.js
514
- - app/javascript/lib/request.js
515
- - app/javascript/stores.js
516
- - app/javascript/stores/ModalStore.jsx
517
- - app/javascript/stores/ToastStore.jsx
512
+ - app/javascript/features/RichText.tsx
513
+ - app/javascript/hooks.ts
514
+ - app/javascript/index.ts
515
+ - app/javascript/lib/Tree.ts
516
+ - app/javascript/lib/copyToClipboard.ts
517
+ - app/javascript/lib/readyHandler.ts
518
+ - app/javascript/lib/request.ts
519
+ - app/javascript/stores.ts
520
+ - app/javascript/stores/useModalStore.ts
521
+ - app/javascript/stores/useToastStore.ts
522
+ - app/javascript/types.ts
518
523
  - app/jobs/pages_core/autopublish_job.rb
519
524
  - app/jobs/pages_core/sweep_cache_job.rb
520
525
  - app/mailers/admin_mailer.rb
@@ -586,10 +591,12 @@ files:
586
591
  - app/views/admin/pages/_edit_options.html.erb
587
592
  - app/views/admin/pages/_form.html.erb
588
593
  - app/views/admin/pages/_list_item.html.erb
594
+ - app/views/admin/pages/_search_bar.html.erb
589
595
  - app/views/admin/pages/deleted.html.erb
590
596
  - app/views/admin/pages/edit.html.erb
591
597
  - app/views/admin/pages/index.html.erb
592
598
  - app/views/admin/pages/new.html.erb
599
+ - app/views/admin/pages/search.html.erb
593
600
  - app/views/admin/password_resets/show.html.erb
594
601
  - app/views/admin/users/_access_control.html.erb
595
602
  - app/views/admin/users/_list.html.erb
@@ -653,19 +660,18 @@ files:
653
660
  - lib/pages_core/version.rb
654
661
  - lib/rails/generators/pages_core/frontend/frontend_generator.rb
655
662
  - lib/rails/generators/pages_core/frontend/templates/application.html.erb
656
- - lib/rails/generators/pages_core/frontend/templates/javascript/lib/GridOverlay.js
657
- - lib/rails/generators/pages_core/frontend/templates/javascript/lib/ResponsiveEmbeds.js
658
- - lib/rails/generators/pages_core/frontend/templates/stylesheets/application.sass.scss
659
- - lib/rails/generators/pages_core/frontend/templates/stylesheets/components/base.scss
660
- - lib/rails/generators/pages_core/frontend/templates/stylesheets/config.scss
661
- - lib/rails/generators/pages_core/frontend/templates/stylesheets/framework/breakpoints.scss
662
- - lib/rails/generators/pages_core/frontend/templates/stylesheets/framework/clearfix.scss
663
- - lib/rails/generators/pages_core/frontend/templates/stylesheets/framework/fonts.scss
664
- - lib/rails/generators/pages_core/frontend/templates/stylesheets/framework/grid.scss
665
- - lib/rails/generators/pages_core/frontend/templates/stylesheets/framework/grid_overlay.scss
666
- - lib/rails/generators/pages_core/frontend/templates/stylesheets/global/colors.scss
667
- - lib/rails/generators/pages_core/frontend/templates/stylesheets/global/typography.scss
668
- - lib/rails/generators/pages_core/frontend/templates/stylesheets/vendor/normalize.css
663
+ - lib/rails/generators/pages_core/frontend/templates/javascript/lib/gridOverlay.ts
664
+ - lib/rails/generators/pages_core/frontend/templates/javascript/lib/responsiveEmbeds.ts
665
+ - lib/rails/generators/pages_core/frontend/templates/postcss.config.js
666
+ - lib/rails/generators/pages_core/frontend/templates/stylesheets/application.postcss.css
667
+ - lib/rails/generators/pages_core/frontend/templates/stylesheets/components/base.css
668
+ - lib/rails/generators/pages_core/frontend/templates/stylesheets/components/layout.css
669
+ - lib/rails/generators/pages_core/frontend/templates/stylesheets/config.css
670
+ - lib/rails/generators/pages_core/frontend/templates/stylesheets/global/animation.css
671
+ - lib/rails/generators/pages_core/frontend/templates/stylesheets/global/colors.css
672
+ - lib/rails/generators/pages_core/frontend/templates/stylesheets/global/fonts.css
673
+ - lib/rails/generators/pages_core/frontend/templates/stylesheets/global/grid.css
674
+ - lib/rails/generators/pages_core/frontend/templates/stylesheets/global/typography.css
669
675
  - lib/rails/generators/pages_core/install/install_generator.rb
670
676
  - lib/rails/generators/pages_core/install/templates/active_job_initializer.rb
671
677
  - lib/rails/generators/pages_core/install/templates/application_controller.rb
@@ -709,7 +715,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
709
715
  - !ruby/object:Gem::Version
710
716
  version: '0'
711
717
  requirements: []
712
- rubygems_version: 3.4.6
718
+ rubygems_version: 3.4.10
713
719
  signing_key:
714
720
  specification_version: 4
715
721
  summary: Pages Core
@@ -1,2 +0,0 @@
1
- import startPages from "./index.js";
2
- startPages();
@@ -1,93 +0,0 @@
1
- import React from "react";
2
- import PropTypes from "prop-types";
3
-
4
- export default class FocalPoint extends React.Component {
5
- constructor(props) {
6
- super(props);
7
- this.state = {
8
- dragging: false,
9
- x: props.x,
10
- y: props.y
11
- };
12
- this.dragStart = this.dragStart.bind(this);
13
- this.dragEnd = this.dragEnd.bind(this);
14
- this.drag = this.drag.bind(this);
15
- this.container = React.createRef();
16
- this.point = React.createRef();
17
- }
18
-
19
- clamp(val, min, max) {
20
- if (val < min) {
21
- return min;
22
- } else if (val > max) {
23
- return max;
24
- } else {
25
- return val;
26
- }
27
- }
28
-
29
- dragStart(evt) {
30
- evt.preventDefault();
31
- evt.stopPropagation();
32
- if (evt.target == this.point.current) {
33
- this.setState({dragging: true});
34
- }
35
- }
36
-
37
- dragEnd() {
38
- if (this.state.dragging) {
39
- this.setState({dragging: false});
40
- this.props.onChange({x: this.state.x, y: this.state.y});
41
- }
42
- }
43
-
44
- drag(evt) {
45
- if (this.state.dragging) {
46
- let containerSize = this.container.current.getBoundingClientRect();
47
- var x , y;
48
- evt.preventDefault();
49
-
50
- if (evt.type == "touchmove") {
51
- x = evt.touches[0].clientX - (containerSize.x || containerSize.left);
52
- y = evt.touches[0].clientY - (containerSize.y || containerSize.top);
53
- } else {
54
- x = evt.clientX - (containerSize.x || containerSize.left);
55
- y = evt.clientY - (containerSize.y || containerSize.top);
56
- }
57
-
58
- x = this.clamp(x, 0, this.props.width);
59
- y = this.clamp(y, 0, this.props.height);
60
-
61
- this.setState({x: (x / this.props.width) * 100,
62
- y: (y / this.props.height) * 100});
63
- }
64
- }
65
-
66
- render() {
67
- let x = this.props.width * (this.state.x / 100);
68
- let y = this.props.height * (this.state.y / 100);
69
- let pointStyle = {
70
- transform: `translate3d(${x}px, ${y}px, 0)`
71
- };
72
- return (
73
- <div className="focal-editor"
74
- ref={this.container}
75
- onTouchStart={this.dragStart}
76
- onTouchEnd={this.dragEnd}
77
- onTouchMove={this.drag}
78
- onMouseDown={this.dragStart}
79
- onMouseUp={this.dragEnd}
80
- onMouseMove={this.drag}>
81
- <div className="focal-point" style={pointStyle} ref={this.point} />
82
- </div>
83
- );
84
- }
85
- }
86
-
87
- FocalPoint.propTypes = {
88
- x: PropTypes.number,
89
- y: PropTypes.number,
90
- onChange: PropTypes.func,
91
- width: PropTypes.number,
92
- height: PropTypes.number
93
- };
@@ -1,59 +0,0 @@
1
- import React from "react";
2
- import ModalStore from "../stores/ModalStore";
3
-
4
- export default class Modal extends React.Component {
5
- constructor(props) {
6
- super(props);
7
- this.state = { component: null };
8
- this.store = ModalStore;
9
- this.closeModal = this.closeModal.bind(this);
10
- this.handleChange = this.handleChange.bind(this);
11
- this.handleKeypress = this.handleKeypress.bind(this);
12
- }
13
-
14
- componentDidMount() {
15
- this.unsubscribe = this.store.subscribe(this.handleChange);
16
- window.addEventListener("keypress", this.handleKeypress);
17
- }
18
-
19
- componentWillUnmount() {
20
- this.unsubscribe();
21
- window.removeEventListener("keypress", this.handleKeypress);
22
- }
23
-
24
- closeModal(evt) {
25
- evt.stopPropagation();
26
- evt.preventDefault();
27
- ModalStore.dispatch({ type: "CLOSE" });
28
- }
29
-
30
- handleChange() {
31
- this.setState({ ...this.store.getState() });
32
- }
33
-
34
- handleKeypress(evt) {
35
- if (this.state.component && (evt.key == "Escape" || evt.keyCode === 27)) {
36
- this.closeModal(evt);
37
- }
38
- }
39
-
40
- render() {
41
- let component = this.state.component;
42
-
43
- if (component) {
44
- document.body.classList.add("modal");
45
- } else {
46
- document.body.classList.remove("modal");
47
- return (<div className="modal-wrapper"></div>);
48
- }
49
-
50
- return (
51
- <div className="modal-wrapper open">
52
- <div className="background" onClick={this.closeModal} />
53
- <div className="modal">
54
- {component}
55
- </div>
56
- </div>
57
- );
58
- }
59
- }
@@ -1,25 +0,0 @@
1
- import React from "react";
2
- import PropTypes from "prop-types";
3
- import ImageGrid from "./ImageGrid";
4
-
5
- export default class PageImages extends React.Component {
6
- render() {
7
- return (
8
- <div className="page-images">
9
- <ImageGrid attribute="page[page_images_attributes]"
10
- primaryAttribute="page[image_id]"
11
- enablePrimary={true}
12
- showEmbed={true}
13
- locale={this.props.locale}
14
- locales={this.props.locales}
15
- records={this.props.records} />
16
- </div>
17
- );
18
- }
19
- }
20
-
21
- PageImages.propTypes = {
22
- locale: PropTypes.string,
23
- locales: PropTypes.object,
24
- records: PropTypes.array
25
- };
@@ -1,196 +0,0 @@
1
- import React from "react";
2
- import PropTypes from "prop-types";
3
- import PageTreeDraggable from "./PageTreeDraggable";
4
- import Tree from "../lib/Tree";
5
- import { postJson, putJson } from "../lib/request";
6
-
7
- export default class PageTree extends React.Component {
8
- constructor(props) {
9
- super(props);
10
-
11
- this.state = { tree: this.buildTree(props.pages) };
12
-
13
- this.addChild = this.addChild.bind(this);
14
- this.movedPage = this.movedPage.bind(this);
15
- this.toggleCollapsed = this.toggleCollapsed.bind(this);
16
- this.updatePage = this.updatePage.bind(this);
17
- this.updateTree = this.updateTree.bind(this);
18
- }
19
-
20
- addChild(id, attributes) {
21
- let tree = this.state.tree;
22
- var index = tree.append(attributes, id);
23
- this.reorderChildren(id);
24
- this.setCollapsed(id, false);
25
- this.createPage(index, attributes);
26
- this.setState({tree: tree});
27
- }
28
-
29
- movedPage(id) {
30
- let tree = this.state.tree;
31
- let index = tree.getIndex(id);
32
- this.reorderChildren(index.parent);
33
-
34
- let parent = tree.getIndex(index.parent);
35
- let position = parent.children.indexOf(id) + 1;
36
-
37
- this.movePage(index, parent, position);
38
- this.setState({tree: tree});
39
- }
40
-
41
- toggleCollapsed(id) {
42
- let tree = this.state.tree;
43
- var node = tree.getIndex(id).node;
44
- this.setCollapsed(id, !node.collapsed);
45
- this.setState({tree: tree});
46
- }
47
-
48
- updatePage(id, attributes) {
49
- let tree = this.state.tree;
50
- let index = tree.getIndex(id);
51
- let url = `/admin/${index.node.locale}/pages/${index.node.id}.json`;
52
- this.updateNode(index, attributes);
53
- this.performUpdate(index, url, { page: attributes });
54
- }
55
-
56
- updateTree(tree) {
57
- this.setState({ tree: tree });
58
- }
59
-
60
- applyCollapsed(tree) {
61
- const depth = (t, index) => {
62
- var depth = 0;
63
- let pointer = t.getIndex(index.parent);
64
- while (pointer) {
65
- depth += 1;
66
- pointer = t.getIndex(pointer.parent);
67
- }
68
- return depth;
69
- };
70
-
71
- let collapsedState = this.collapsedState();
72
- let walk = function (id) {
73
- var index = tree.getIndex(id);
74
- var node = index.node;
75
- if (Object.prototype.hasOwnProperty.call(collapsedState, node.id)) {
76
- node.collapsed = collapsedState[node.id];
77
- } else if (node.news_page) {
78
- node.collapsed = true;
79
- } else if (depth(tree, index) > 1) {
80
- node.collapsed = true;
81
- }
82
- if (index.children && index.children.length) {
83
- index.children.forEach(c => walk(c));
84
- }
85
- };
86
- walk(1);
87
- }
88
-
89
- collapsedState() {
90
- if (window && window.localStorage &&
91
- typeof(window.localStorage.collapsedPages) != "undefined") {
92
- return JSON.parse(window.localStorage.collapsedPages);
93
- }
94
- return {};
95
- }
96
-
97
- createPage(index, attributes) {
98
- postJson(`/admin/${index.node.locale}/pages.json`, { page: attributes })
99
- .then(response => this.updateNode(index, response));
100
- }
101
-
102
- buildTree(pages) {
103
- // Build tree
104
- let parentMap = pages.reduce((m, page) => {
105
- let id = page.parent_page_id;
106
- m[id] = [...(m[id] || []), page];
107
- return m;
108
- }, {});
109
-
110
- pages.forEach((p) => p.children = parentMap[p.id] || []);
111
-
112
- let tree = new Tree({ name: "All Pages",
113
- locale: this.props.locale,
114
- permissions: this.props.permissions,
115
- root: true,
116
- children: parentMap[null] });
117
- this.applyCollapsed(tree);
118
- tree.updateNodesPosition();
119
- return tree;
120
- }
121
-
122
- movePage(index, parent, position) {
123
- let data = {
124
- parent_id: parent.node.id,
125
- position: position
126
- };
127
- let url = `/admin/${index.node.locale}/pages/${index.node.id}/move.json`;
128
- this.performUpdate(index, url, data);
129
- }
130
-
131
- performUpdate(index, url, data) {
132
- putJson(url, data).then(response => this.updateNode(index, response));
133
- }
134
-
135
- render() {
136
- return(
137
- <PageTreeDraggable tree={this.state.tree}
138
- addChild={this.addChild}
139
- movedPage={this.movedPage}
140
- toggleCollapsed={this.toggleCollapsed}
141
- updatePage={this.updatePage}
142
- updateTree={this.updateTree}
143
- locale={this.props.locale}
144
- dir={this.props.dir} />
145
- );
146
- }
147
-
148
- reorderChildren(id) {
149
- let tree = this.state.tree;
150
- var index = this.state.tree.getIndex(id);
151
- var node = index.node;
152
- if (!node.news_page) {
153
- return;
154
- }
155
- index.children = index.children.sort(function (a, b) {
156
- var aNode = tree.getIndex(a).node;
157
- var bNode = tree.getIndex(b).node;
158
- if (aNode.pinned == bNode.pinned) {
159
- return new Date(bNode.published_at) - new Date(aNode.published_at);
160
- } else {
161
- return aNode.pinned ? -1 : 1;
162
- }
163
- });
164
- tree.updateNodesPosition();
165
- }
166
-
167
- setCollapsed(id, value) {
168
- var node = this.state.tree.getIndex(id).node;
169
- node.collapsed = value;
170
- this.storeCollapsed(id, node.collapsed);
171
- this.state.tree.updateNodesPosition();
172
- }
173
-
174
- storeCollapsed(id, newState) {
175
- let node = this.state.tree.getIndex(id).node;
176
- var store = this.collapsedState();
177
- store[node.id] = newState;
178
- window.localStorage.collapsedPages = JSON.stringify(store);
179
- }
180
-
181
- updateNode(index, attributes) {
182
- for (var attr in attributes) {
183
- if (Object.prototype.hasOwnProperty.call(attributes, attr)) {
184
- index.node[attr] = attributes[attr];
185
- }
186
- }
187
- this.setState({ tree: this.state.tree });
188
- }
189
- }
190
-
191
- PageTree.propTypes = {
192
- pages: PropTypes.array,
193
- locale: PropTypes.string,
194
- dir: PropTypes.string,
195
- permissions: PropTypes.array
196
- };
@@ -1,20 +0,0 @@
1
- import React from "react";
2
- import PropTypes from "prop-types";
3
-
4
- export default class RichTextToolbarButton extends React.Component {
5
- render() {
6
- return (
7
- <a title={this.props.name}
8
- className={"button " + this.props.className}
9
- onClick={this.props.onClick}>
10
- <i className={"fa-solid fa-" + this.props.className} />
11
- </a>
12
- );
13
- }
14
- }
15
-
16
- RichTextToolbarButton.propTypes = {
17
- className: PropTypes.string,
18
- name: PropTypes.string,
19
- onClick: PropTypes.func
20
- };
@@ -1,72 +0,0 @@
1
- import React from "react";
2
- import PropTypes from "prop-types";
3
- import ToastStore from "../stores/ToastStore";
4
-
5
- export default class Toast extends React.Component {
6
- constructor(props) {
7
- super(props);
8
- this.state = { toast: undefined,
9
- fadeout: false };
10
- this.store = ToastStore;
11
- this.timer = undefined;
12
- this.handleChange = this.handleChange.bind(this);
13
- }
14
-
15
- componentDidMount() {
16
- this.unsubscribe = this.store.subscribe(this.handleChange);
17
- if (this.props.error) {
18
- this.store.dispatch({ type: "ERROR", message: this.props.error });
19
- }
20
- if (this.props.notice) {
21
- this.store.dispatch({ type: "NOTICE", message: this.props.notice });
22
- }
23
- }
24
-
25
- componentWillUnmount() {
26
- this.unsubscribe();
27
- if (this.timer) {
28
- clearTimeout(this.timer);
29
- }
30
- }
31
-
32
- handleChange() {
33
- this.setState({ toast: this.store.getState()[0], fadeout: false });
34
- if (!this.timer) {
35
- this.timer = setTimeout(() => {
36
- this.setState({ fadeout: true });
37
- this.timer = setTimeout(() => {
38
- this.timer = undefined;
39
- this.setState({ fadeout: false });
40
- this.store.dispatch({ type: "NEXT" });
41
- }, 500);
42
- }, 4000);
43
- }
44
- }
45
-
46
- render() {
47
- let toast = this.state.toast;
48
- let classNames = ["toast"];
49
-
50
- if (toast) {
51
- classNames.push(toast.type);
52
- if (this.state.fadeout) {
53
- classNames.push("fadeout");
54
- }
55
- }
56
-
57
- return (
58
- <div className="toast-wrapper" aria-live="polite">
59
- {toast && (
60
- <div className={classNames.join(" ")}>
61
- {toast.message}
62
- </div>
63
- )}
64
- </div>
65
- );
66
- }
67
- }
68
-
69
- Toast.propTypes = {
70
- notice: PropTypes.string,
71
- error: PropTypes.string
72
- };