@brandup/ui-textbox 1.0.40 → 1.0.42

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.
package/package.json CHANGED
@@ -24,15 +24,15 @@
24
24
  "email": "it@brandup.online"
25
25
  },
26
26
  "license": "Apache-2.0",
27
- "version": "1.0.40",
27
+ "version": "1.0.42",
28
28
  "main": "source/index.ts",
29
29
  "types": "source/index.ts",
30
30
  "dependencies": {
31
31
  "@brandup/ui": "^2.0.7",
32
32
  "@brandup/ui-helpers": "^2.0.7",
33
- "@brandup/ui-input": "^1.0.40",
34
- "@brandup/ui-kit": "^1.0.40",
35
- "@brandup/ui-richeditor": "^1.0.40"
33
+ "@brandup/ui-input": "^1.0.42",
34
+ "@brandup/ui-kit": "^1.0.42",
35
+ "@brandup/ui-richeditor": "^1.0.42"
36
36
  },
37
37
  "files": [
38
38
  "source",
package/source/index.ts CHANGED
@@ -7,10 +7,12 @@ export {
7
7
  ALL_FORMAT_TOOLS,
8
8
  EDITOR_ACTIONS,
9
9
  FORMAT_TOOLS,
10
+ parseBlockTypes,
10
11
  parseEditorActions,
11
12
  parseFormatTools,
12
13
  defaultFormatMarkers,
13
14
  normalizeWhitespace,
15
+ type BlockType,
14
16
  type EditorAction,
15
17
  type FormatTool,
16
18
  type FormatStorage,
@@ -49,26 +49,7 @@
49
49
  z-index: 2;
50
50
  margin-right: 5px;
51
51
  padding-right: calc(var(--input-padding-lr) - 5px);
52
- scrollbar-width: 6px;
53
- overflow-y: auto;
54
-
55
- &::-webkit-scrollbar {
56
- width: 6px;
57
- background: none;
58
- }
59
-
60
- &::-webkit-scrollbar-track {
61
- border-radius: 3px;
62
- background-color: transparent;
63
- margin: 6px 0;
64
- cursor: default;
65
- }
66
-
67
- &::-webkit-scrollbar-thumb {
68
- background-color: #8696a0;
69
- border-radius: 3px;
70
- cursor: default;
71
- }
52
+ overflow-y: auto; // полоса прокрутки — общая, от .ui-scrollable кита
72
53
  }
73
54
 
74
55
  // редактор (@brandup/ui-richeditor) — занимает доступное место; внутреннее оформление в richeditor.less
package/source/textbox.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  import "./textbox.less"; // стили компонента
2
2
 
3
3
  import { InputControl } from "@brandup/ui-input";
4
- import { IS_TOUCH_DEVICE } from "@brandup/ui-kit";
4
+ import { IS_TOUCH_DEVICE, SCROLLABLE_CLASS } from "@brandup/ui-kit";
5
5
  import { DOM } from "@brandup/ui";
6
6
  import { FuncHelper } from "@brandup/ui-helpers";
7
7
  import RichEditor, {
8
8
  defaultFormatMarkers,
9
+ parseBlockTypes,
9
10
  parseEditorActions,
10
11
  parseFormatTools,
11
12
  type FormatMarkers,
@@ -101,16 +102,18 @@ export default class TextBox extends InputControl<HTMLInputElement | HTMLTextAre
101
102
 
102
103
  // форматирование доступно только для обычного текстового ввода
103
104
  const format = type === "text" && valueElem.hasAttribute("data-format");
104
- const formatStorage: FormatStorage =
105
- valueElem.getAttribute("data-format-storage") === "markdown" ? "markdown" : "html";
106
- const formatTools = format ? parseFormatTools(valueElem.getAttribute("data-format-tools")) : [];
105
+ const formatStorage: FormatStorage = valueElem.dataset.formatStorage === "markdown" ? "markdown" : "html";
106
+ const formatTools = format ? parseFormatTools(valueElem.dataset.formatTools ?? null) : [];
107
107
  // кнопки действий панели (очистка формата, отмена, повтор) — подключаются явно
108
- const editorActions = format ? parseEditorActions(valueElem.getAttribute("data-editor-actions")) : [];
108
+ const editorActions = format ? parseEditorActions(valueElem.dataset.editorActions ?? null) : [];
109
+ // типы блоков (цитата, блок кода) — тоже явно и только в многострочном поле
110
+ const blocks = parseBlockTypes(multyline ? (valueElem.dataset.blocks ?? null) : null);
109
111
 
110
112
  // markdown-маркеры с дефолтами, переопределяются атрибутами data-format-md-<tool>
111
113
  const formatMarkers = defaultFormatMarkers();
112
114
  if (format) {
113
115
  for (const tool of Object.keys(formatMarkers) as FormatTool[]) {
116
+ // имя атрибута собирается на ходу: у dataset оно потребовало бы ручного camelCase
114
117
  const marker = valueElem.getAttribute(`data-format-md-${tool}`)?.trim();
115
118
  if (marker) formatMarkers[tool] = marker;
116
119
  }
@@ -122,7 +125,7 @@ export default class TextBox extends InputControl<HTMLInputElement | HTMLTextAre
122
125
 
123
126
  const container = DOM.tag("div", { class: ROOT_CLASS }, [
124
127
  DOM.tag("div", { class: "decorator" }),
125
- DOM.tag("div", { class: "editor" }, [inputElem, symbolsCountElem]),
128
+ DOM.tag("div", { class: ["editor", SCROLLABLE_CLASS] }, [inputElem, symbolsCountElem]),
126
129
  actionsElem,
127
130
  ]);
128
131
 
@@ -139,7 +142,7 @@ export default class TextBox extends InputControl<HTMLInputElement | HTMLTextAre
139
142
  // команда объявляется атрибутом data-command — по нему её ищет обработчик @brandup/ui
140
143
  const buttonElem = DOM.tag(
141
144
  "button",
142
- { "data-command": "copy-text", title: "Скопировать в буфер обмена" },
145
+ { command: "copy-text", title: "Скопировать в буфер обмена" },
143
146
  copyIcon
144
147
  );
145
148
  if (disabled) buttonElem.disabled = true;
@@ -184,6 +187,7 @@ export default class TextBox extends InputControl<HTMLInputElement | HTMLTextAre
184
187
  markers: formatMarkers,
185
188
  placeholder,
186
189
  multiline: multyline,
190
+ blocks,
187
191
  readonly,
188
192
  // тулбар позиционируется относительно контейнера TextBox (а не document.body)
189
193
  toolbarContainer: container,