5htp-core 0.4.9-2 → 0.4.9-5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/package.json +4 -1
  2. package/src/client/assets/css/components/lists.less +3 -3
  3. package/src/client/components/Form.ts +1 -1
  4. package/src/client/components/Select/ChoiceElement.tsx +20 -27
  5. package/src/client/components/Select/index.tsx +24 -42
  6. package/src/client/components/inputv3/Rte/Editor.tsx +16 -8
  7. package/src/client/components/inputv3/Rte/ToolbarPlugin/index.tsx +6 -1
  8. package/src/client/components/inputv3/Rte/plugins/DraggableBlockPlugin/index.css +23 -23
  9. package/src/client/components/inputv3/Rte/plugins/DraggableBlockPlugin/index.tsx +26 -24
  10. package/src/client/components/inputv3/Rte/plugins/FloatingLinkEditorPlugin/index.css +10 -38
  11. package/src/client/components/inputv3/Rte/plugins/FloatingLinkEditorPlugin/index.tsx +349 -356
  12. package/src/client/components/inputv3/Rte/plugins/FloatingTextFormatToolbarPlugin/index.css +80 -84
  13. package/src/client/components/inputv3/Rte/plugins/FloatingTextFormatToolbarPlugin/index.tsx +308 -347
  14. package/src/client/components/inputv3/Rte/style.less +0 -2
  15. package/src/client/components/inputv3/Rte/themes/PlaygroundEditorTheme.ts +1 -1
  16. package/src/client/components/inputv3/base.less +0 -6
  17. package/src/client/components/inputv3/file/index.tsx +50 -48
  18. package/src/client/components/inputv3/index.tsx +1 -1
  19. package/src/client/services/router/request/api.ts +29 -13
  20. package/src/common/router/request/api.ts +6 -4
  21. package/src/server/services/disks/driver.ts +2 -0
  22. package/src/server/services/disks/drivers/s3/index.ts +30 -1
  23. package/src/server/utils/rte.ts +217 -59
  24. package/src/server/utils/slug.ts +67 -0
  25. package/src/server/services/schema/rte.ts +0 -110
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "5htp-core",
3
3
  "description": "Convenient TypeScript framework designed for Performance and Productivity.",
4
- "version": "0.4.9-2",
4
+ "version": "0.4.9-5",
5
5
  "author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
6
6
  "repository": "git://github.com/gaetanlegac/5htp-core.git",
7
7
  "license": "MIT",
@@ -34,6 +34,7 @@
34
34
  "dayjs": "^1.11.5",
35
35
  "deep-extend": "^0.6.0",
36
36
  "dottie": "^2.0.2",
37
+ "escape-regexp": "^0.0.1",
37
38
  "express": "^4.17.1",
38
39
  "express-csp-header": "^5.0.0",
39
40
  "express-fileupload": "^1.2.1",
@@ -74,7 +75,9 @@
74
75
  "regenerator-runtime": "^0.13.9",
75
76
  "request": "^2.88.2",
76
77
  "sharp": "^0.29.1",
78
+ "slugify": "^1.6.6",
77
79
  "sql-formatter": "^4.0.2",
80
+ "stopword": "^3.1.1",
78
81
  "tslog": "^4.9.1",
79
82
  "uuid": "^8.3.2",
80
83
  "uuid-by-string": "^3.0.4",
@@ -94,9 +94,9 @@ ol.steps {
94
94
  // Stepnumber = at the left
95
95
  &:not(.col) {
96
96
 
97
- padding-left: /*@sizeStep + */(@spacing);
97
+ padding-left: /*@sizeStep + */1.5em;
98
98
  padding-top: (@sizeStep - @itemLineHeight) / 2;
99
- line-height: @itemLineHeight;
99
+ //line-height: @itemLineHeight;
100
100
  margin: 5px 0;
101
101
 
102
102
  &:before {
@@ -124,7 +124,7 @@ strong.step {
124
124
  font-weight: bold;
125
125
 
126
126
  font-size: 1em;
127
- line-height: 1.8em;
127
+ line-height: 2.2em;
128
128
  }
129
129
 
130
130
  /*----------------------------------
@@ -17,7 +17,7 @@ export type { TValidationResult, TSchemaData } from '@common/validation/schema';
17
17
  /*----------------------------------
18
18
  - TYPES
19
19
  ----------------------------------*/
20
- type TFormOptions<TFormData extends {}> = {
20
+ export type TFormOptions<TFormData extends {}> = {
21
21
  data?: Partial<TFormData>,
22
22
  submit?: (data: TFormData) => Promise<void>,
23
23
  autoValidateOnly?: (keyof TFormData)[],
@@ -34,7 +34,7 @@ export default ({ choice, currentList, onChange, multiple, includeCurrent, forma
34
34
 
35
35
  return format === 'list' ? (
36
36
  <li>
37
- <Button icon={isCurrent ? 'check-circle' : undefined} onClick={() => onChange( current => multiple
37
+ <Button active={isCurrent} onClick={() => onChange( current => multiple
38
38
  ? (isCurrent
39
39
  ? currentList.filter(item => item.value !== choice.value)
40
40
  : [...(current || []), choice]
@@ -44,34 +44,27 @@ export default ({ choice, currentList, onChange, multiple, includeCurrent, forma
44
44
  {choice.label}
45
45
  </Button>
46
46
  </li>
47
- ) : isCurrent ? (
48
- <li class={"badge bg primary"+ (showRemoveButton ? ' pdr-05' : '')}>
49
- {choice.label}
50
-
51
- {showRemoveButton && (
52
- <span class="badge xs clickable" onClick={(e) => {
53
- e.stopPropagation();
54
- onChange( current => current.filter( c => c.value !== choice.value))
55
- return false;
56
- }}>
57
- x
58
- </span>
59
- )}
60
- </li>
61
47
  ) : (
62
- <li class={"badge clickable"} onClick={() => {
63
- onChange( current => multiple
64
- ? [...(current || []), choice]
65
- : choice
66
- );
67
- }}>
68
- {/*search.keywords ? (
69
- <span>
70
-
71
- <strong>{search.keywords}</strong>{choice.label.slice( search.keywords.length )}
48
+ <li>
49
+ <Button type="secondary" active={isCurrent} onClick={() => onChange(current => multiple
50
+ ? (isCurrent
51
+ ? currentList.filter(item => item.value !== choice.value)
52
+ : [...(current || []), choice]
53
+ )
54
+ : isCurrent ? undefined : choice
55
+ )}>
56
+ {choice.label}
72
57
 
73
- </span>
74
- ) : */choice.label}
58
+ {showRemoveButton && (
59
+ <span class="badge xs clickable" onClick={(e) => {
60
+ e.stopPropagation();
61
+ onChange( current => current.filter( c => c.value !== choice.value))
62
+ return false;
63
+ }}>
64
+ x
65
+ </span>
66
+ )}
67
+ </Button>
75
68
  </li>
76
69
  )
77
70
  }
@@ -250,51 +250,33 @@ export default (props: Props) => {
250
250
  ) : (
251
251
  <div class="col sp-05">
252
252
  <div class={className} onMouseDown={() => refInputSearch.current?.focus()}>
253
-
254
- <div class="row al-left wrap pd-1">
255
-
256
- {icon !== undefined && (
257
- <i src={icon} />
258
- )}
259
-
260
- <div class="col al-left sp-05">
261
-
262
- <label>{title}{isRequired && (
263
- <span class="fg error">&nbsp;*</span>
264
- )}</label>
265
-
266
- <div class="row al-left wrap sp-05">
267
-
268
- {selectedItems.map( choice => (
269
- <ChoiceElement format='badge' choice={choice}
270
- currentList={currentList}
271
- onChange={onChange}
272
- multiple={multiple}
273
- includeCurrent
274
- />
275
- ))}
276
-
277
- {Search}
278
- </div>
279
- </div>
280
253
 
281
- </div>
254
+ <div class="row al-left wrap sp-05">
282
255
 
283
- <div class="pd-1">
284
- <ul class="row al-left wrap sp-05" style={{
285
- maxHeight: '30vh',
286
- overflowY: 'auto'
287
- }}>
288
- {choices.map( choice => (
289
- <ChoiceElement format='badge' choice={choice}
290
- currentList={currentList}
291
- onChange={onChange}
292
- multiple={multiple}
293
- includeCurrent
294
- />
295
- ))}
296
- </ul>
256
+ {selectedItems.map( choice => (
257
+ <ChoiceElement format='badge' choice={choice}
258
+ currentList={currentList}
259
+ onChange={onChange}
260
+ multiple={multiple}
261
+ includeCurrent
262
+ />
263
+ ))}
264
+
265
+ {Search}
297
266
  </div>
267
+
268
+ <ul class="row al-left wrap sp-05" style={{
269
+ maxHeight: '30vh',
270
+ }}>
271
+ {choices.map( choice => (
272
+ <ChoiceElement format='badge' choice={choice}
273
+ currentList={currentList}
274
+ onChange={onChange}
275
+ multiple={multiple}
276
+ includeCurrent
277
+ />
278
+ ))}
279
+ </ul>
298
280
 
299
281
  </div>
300
282
  {errors?.length && (
@@ -119,6 +119,12 @@ export default ({ value, setValue, props }: {
119
119
  // Trigger onchange oly when finished typing
120
120
  const refCommit = React.useRef<NodeJS.Timeout | null>(null);
121
121
 
122
+ const onRef = (_floatingAnchorElem: HTMLDivElement) => {
123
+ if (_floatingAnchorElem !== null) {
124
+ setFloatingAnchorElem(_floatingAnchorElem);
125
+ }
126
+ };
127
+
122
128
  const { historyState } = useSharedHistoryContext();
123
129
  const {
124
130
  settings: {
@@ -176,16 +182,18 @@ export default ({ value, setValue, props }: {
176
182
  }}>
177
183
  <div className="editor-container">
178
184
  <ToolbarPlugin setIsLinkEditMode={setIsLinkEditMode} />
179
- <div className="editor-inner reading">
185
+ <div className="editor-inner">
180
186
  <RichTextPlugin
181
187
  contentEditable={
182
- <ContentEditable
183
- className="editor-input"
184
- aria-placeholder={"Type text here ..."}
185
- placeholder={
186
- <div className="editor-placeholder">Type text here ...</div>
187
- }
188
- />
188
+ <div className="editor pdh-2" ref={onRef}>
189
+ <ContentEditable
190
+ className="editor-input reading col"
191
+ aria-placeholder={"Type text here ..."}
192
+ placeholder={
193
+ <div className="editor-placeholder">Type text here ...</div>
194
+ }
195
+ />
196
+ </div>
189
197
  }
190
198
  ErrorBoundary={LexicalErrorBoundary}
191
199
  />
@@ -482,7 +482,12 @@ export default function ToolbarPlugin({
482
482
  const canViewerSeeInsertCodeButton = !isImageCaption;
483
483
 
484
484
  return (
485
- <div className="row menu al-left">
485
+ <div className="row menu al-left" style={{
486
+ position: 'sticky',
487
+ top: 0,
488
+ background: 'white',
489
+ 'zIndex': 5
490
+ }}>
486
491
 
487
492
  {/* <Button icon="undo" size="s"
488
493
  disabled={!canUndo || !isEditable}
@@ -1,36 +1,36 @@
1
1
  .draggable-block-menu {
2
- border-radius: 4px;
3
- padding: 2px 1px;
4
- cursor: grab;
5
- opacity: 0;
6
- position: absolute;
7
- left: 0;
8
- top: 0;
9
- will-change: transform;
2
+ border-radius: 4px;
3
+ padding: 2px 1px;
4
+ cursor: grab;
5
+ opacity: 0;
6
+ position: absolute;
7
+ left: 0;
8
+ top: 0;
9
+ will-change: transform;
10
10
  }
11
11
 
12
12
  .draggable-block-menu .icon {
13
- width: 16px;
14
- height: 16px;
15
- opacity: 0.3;
16
- background-image: url(../../images/icons/draggable-block-menu.svg);
13
+ width: 16px;
14
+ height: 16px;
15
+ opacity: 0.3;
16
+ background-image: url(../../images/icons/draggable-block-menu.svg);
17
17
  }
18
18
 
19
19
  .draggable-block-menu:active {
20
- cursor: grabbing;
20
+ cursor: grabbing;
21
21
  }
22
22
 
23
23
  .draggable-block-menu:hover {
24
- background-color: #efefef;
24
+ background-color: #efefef;
25
25
  }
26
26
 
27
27
  .draggable-block-target-line {
28
- pointer-events: none;
29
- background: deepskyblue;
30
- height: 4px;
31
- position: absolute;
32
- left: 0;
33
- top: 0;
34
- opacity: 0;
35
- will-change: transform;
36
- }
28
+ pointer-events: none;
29
+ background: deepskyblue;
30
+ height: 4px;
31
+ position: absolute;
32
+ left: 0;
33
+ top: 0;
34
+ opacity: 0;
35
+ will-change: transform;
36
+ }
@@ -7,37 +7,39 @@
7
7
  */
8
8
  import './index.css';
9
9
 
10
- import {DraggableBlockPlugin_EXPERIMENTAL} from '@lexical/react/LexicalDraggableBlockPlugin';
11
- import {useRef} from 'react';
10
+ import React from 'react';
11
+
12
+ import { DraggableBlockPlugin_EXPERIMENTAL } from '@lexical/react/LexicalDraggableBlockPlugin';
13
+ import { useRef } from 'react';
12
14
 
13
15
  const DRAGGABLE_BLOCK_MENU_CLASSNAME = 'draggable-block-menu';
14
16
 
15
17
  function isOnMenu(element: HTMLElement): boolean {
16
- return !!element.closest(`.${DRAGGABLE_BLOCK_MENU_CLASSNAME}`);
18
+ return !!element.closest(`.${DRAGGABLE_BLOCK_MENU_CLASSNAME}`);
17
19
  }
18
20
 
19
21
  export default function DraggableBlockPlugin({
20
- anchorElem = document.body,
22
+ anchorElem = document.body,
21
23
  }: {
22
- anchorElem?: HTMLElement;
23
- }): JSX.Element {
24
- const menuRef = useRef<HTMLDivElement>(null);
25
- const targetLineRef = useRef<HTMLDivElement>(null);
24
+ anchorElem?: HTMLElement;
25
+ }): React.JSX.Element {
26
+ const menuRef = useRef<HTMLDivElement>(null);
27
+ const targetLineRef = useRef<HTMLDivElement>(null);
26
28
 
27
- return (
28
- <DraggableBlockPlugin_EXPERIMENTAL
29
- anchorElem={anchorElem}
30
- menuRef={menuRef}
31
- targetLineRef={targetLineRef}
32
- menuComponent={
33
- <div ref={menuRef} className="icon draggable-block-menu">
34
- <div className="icon" />
35
- </div>
36
- }
37
- targetLineComponent={
38
- <div ref={targetLineRef} className="draggable-block-target-line" />
39
- }
40
- isOnMenu={isOnMenu}
41
- />
42
- );
29
+ return (
30
+ <DraggableBlockPlugin_EXPERIMENTAL
31
+ anchorElem={anchorElem}
32
+ menuRef={menuRef}
33
+ targetLineRef={targetLineRef}
34
+ menuComponent={
35
+ <div ref={menuRef} className="icon draggable-block-menu">
36
+ <div className="icon" />
37
+ </div>
38
+ }
39
+ targetLineComponent={
40
+ <div ref={targetLineRef} className="draggable-block-target-line" />
41
+ }
42
+ isOnMenu={isOnMenu}
43
+ />
44
+ );
43
45
  }
@@ -1,41 +1,13 @@
1
1
  .link-editor {
2
- display: flex;
3
- position: absolute;
4
- top: 0;
5
- left: 0;
6
- z-index: 10;
7
- max-width: 400px;
8
- width: 100%;
9
- opacity: 0;
10
- background-color: #fff;
11
- box-shadow: 0 5px 10px rgba(0, 0, 0, 0.3);
12
- border-radius: 0 0 8px 8px;
13
- transition: opacity 0.5s;
14
- will-change: transform;
15
- }
16
2
 
17
- .link-editor .button {
18
- width: 20px;
19
- height: 20px;
20
- display: inline-block;
21
- padding: 6px;
22
- border-radius: 8px;
23
- cursor: pointer;
24
- margin: 0 2px;
25
- }
3
+ position: absolute;
4
+ top: 0;
5
+ left: 0;
6
+ z-index: 10;
7
+ max-width: 400px;
8
+ width: 100%;
26
9
 
27
- .link-editor .button.hovered {
28
- width: 20px;
29
- height: 20px;
30
- display: inline-block;
31
- background-color: #eee;
32
- }
33
-
34
- .link-editor .button i,
35
- .actions i {
36
- background-size: contain;
37
- display: inline-block;
38
- height: 20px;
39
- width: 20px;
40
- vertical-align: -0.25em;
41
- }
10
+ opacity: 0;
11
+ transition: opacity 0.5s;
12
+ will-change: transform;
13
+ }