@knime/kds-rich-text-editor 14.3.0 → 15.0.0
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/CHANGELOG.md +26 -0
- package/README.md +4 -0
- package/dist/index.css +17 -215
- package/dist/index.js +79 -24
- package/dist/index.js.map +1 -1
- package/dist/src/KdsRichTextEditor.vue.d.ts.map +1 -1
- package/dist/src/utils/character-limit.d.ts +15 -0
- package/dist/src/utils/character-limit.d.ts.map +1 -0
- package/dist/src/utils/custom-link.d.ts.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @knime/kds-rich-text-editor
|
|
2
2
|
|
|
3
|
+
## 15.0.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8f818fe: `KdsRichTextEditor`:
|
|
8
|
+
|
|
9
|
+
- apply the character limit when the editor switches from read-only to editable. Previously, the editor applied it only when it was created.
|
|
10
|
+
- stop emitting `update:modelValue` when the editor switches between read-only and editable. The content doesn't change, so a parent no longer sees a change the user never made.
|
|
11
|
+
- let long links wrap with the text, so they stay inside the editor.
|
|
12
|
+
- keep initial content that is longer than the character limit instead of trimming it. The counter then shows more characters than the limit, and the content can only shrink until it fits.
|
|
13
|
+
- render links with `target="_blank"` and `rel="ugc noopener noreferrer nofollow"`. The editor ignores the `target` and `rel` saved in the content, so links always open in a new tab without access to the opener. The ctrl/cmd-click that opens a link while editing also opens it without the opener.
|
|
14
|
+
- show the "ctrl/cmd click to follow link" tooltip only while editing, and stop saving it into the content as the link's `title`. The editor drops a `title` that is already in the content when it loads the content.
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [8f818fe, ca52c71]
|
|
17
|
+
- @knime/kds-components@15.0.0
|
|
18
|
+
- @knime/kds-styles@15.0.0
|
|
19
|
+
- @knime/utils@4.1.0
|
|
20
|
+
|
|
21
|
+
## 14.4.0
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [2f327c4, 38d1679]
|
|
26
|
+
- @knime/kds-components@14.4.0
|
|
27
|
+
- @knime/kds-styles@14.4.0
|
|
28
|
+
|
|
3
29
|
## 14.3.0
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -101,6 +101,10 @@ Public symbols follow the KDS `Kds` prefix convention, except `EditorTools`:
|
|
|
101
101
|
| `KdsCharacterCountDisplay` | type | Union of the character counter display values |
|
|
102
102
|
| `EditorTools` | type | Toolbar tool definitions (not `Kds`-prefixed) |
|
|
103
103
|
|
|
104
|
+
To show saved editor content without the editor, use `KdsRichTextView` from
|
|
105
|
+
`@knime/kds-components`. It has the same styles as the editor, sanitizes the
|
|
106
|
+
HTML and doesn't load Tiptap.
|
|
107
|
+
|
|
104
108
|
### Using with Vitest, Nuxt, or Vite SSR
|
|
105
109
|
|
|
106
110
|
The published JavaScript imports its CSS as a side effect (e.g.
|
package/dist/index.css
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
.editor-wrapper {
|
|
30
|
-
&[data-v-
|
|
30
|
+
&[data-v-f486df47] {
|
|
31
31
|
/* Fixed 44px toolbar height per the design (28px content + 8px padding on
|
|
32
32
|
* each side); the small toolbar buttons (24px) center within the content
|
|
33
33
|
* area. */
|
|
@@ -40,258 +40,60 @@
|
|
|
40
40
|
height: 100%;
|
|
41
41
|
isolation: isolate;
|
|
42
42
|
}
|
|
43
|
-
&.disabled[data-v-
|
|
43
|
+
&.disabled[data-v-f486df47] {
|
|
44
44
|
color: var(--kds-color-text-and-icon-disabled);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
/* stylelint-disable selector-class-pattern */
|
|
49
49
|
.rich-text-editor {
|
|
50
|
-
&[data-v-
|
|
50
|
+
&[data-v-f486df47] {
|
|
51
51
|
height: 100%;
|
|
52
|
-
max-height: var(--
|
|
52
|
+
max-height: var(--ba8c99e6);
|
|
53
53
|
overflow-y: auto;
|
|
54
|
-
|
|
55
|
-
/* stylelint-disable knime/no-deep-nesting */
|
|
56
54
|
/* stylelint-enable selector-class-pattern */
|
|
57
55
|
}
|
|
58
56
|
&.editable {
|
|
59
|
-
&[data-v-
|
|
57
|
+
&[data-v-f486df47] {
|
|
60
58
|
padding: var(--kds-spacing-container-0-5x);
|
|
61
59
|
cursor: text;
|
|
62
60
|
background: var(--kds-color-background-input-initial);
|
|
63
61
|
}
|
|
64
|
-
&[data-v-
|
|
65
|
-
min-height: var(--
|
|
62
|
+
&[data-v-f486df47] .ProseMirror {
|
|
63
|
+
min-height: var(--v6c3d1d42);
|
|
66
64
|
}
|
|
67
65
|
}
|
|
68
|
-
&[data-v-
|
|
66
|
+
&[data-v-f486df47] .ProseMirror {
|
|
69
67
|
height: 100%;
|
|
70
|
-
font: var(--kds-font-base-body-small);
|
|
71
|
-
|
|
72
|
-
/* The following rich text styles are kept in sync with KdsDescription. */
|
|
73
|
-
p {
|
|
74
|
-
& {
|
|
75
|
-
padding: 0;
|
|
76
|
-
margin: 0 0 var(--kds-spacing-container-0-37x);
|
|
77
|
-
font: var(--kds-font-base-body-small);
|
|
78
|
-
}
|
|
79
|
-
&:last-child {
|
|
80
|
-
margin-bottom: 0;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
p.small-text {
|
|
84
|
-
font: var(--kds-font-base-subtext-xsmall);
|
|
85
|
-
}
|
|
86
|
-
strong,
|
|
87
|
-
b {
|
|
88
|
-
font-weight: var(--kds-core-font-weight-strong);
|
|
89
|
-
}
|
|
90
|
-
i,
|
|
91
|
-
em {
|
|
92
|
-
font-style: italic;
|
|
93
|
-
}
|
|
94
|
-
h1 {
|
|
95
|
-
margin: 0;
|
|
96
|
-
font: var(--kds-font-base-display-small);
|
|
97
|
-
color: var(--kds-color-text-and-icon-neutral);
|
|
98
|
-
}
|
|
99
|
-
h2 {
|
|
100
|
-
margin: 0;
|
|
101
|
-
font: var(--kds-font-base-display-xsmall);
|
|
102
|
-
color: var(--kds-color-text-and-icon-neutral);
|
|
103
|
-
}
|
|
104
|
-
h3 {
|
|
105
|
-
margin: 0;
|
|
106
|
-
font: var(--kds-font-base-body-medium-strong);
|
|
107
|
-
}
|
|
108
|
-
h4 {
|
|
109
|
-
margin: 0;
|
|
110
|
-
font: var(--kds-font-base-body-small-strong);
|
|
111
|
-
}
|
|
112
|
-
h5 {
|
|
113
|
-
margin: 0;
|
|
114
|
-
font: var(--kds-font-base-title-small-strong);
|
|
115
|
-
color: var(--kds-color-text-and-icon-neutral);
|
|
116
|
-
}
|
|
117
|
-
h6 {
|
|
118
|
-
margin: 0;
|
|
119
|
-
font: var(--kds-font-base-title-small);
|
|
120
|
-
color: var(--kds-color-text-and-icon-neutral);
|
|
121
|
-
}
|
|
122
|
-
blockquote {
|
|
123
|
-
& {
|
|
124
|
-
position: relative;
|
|
125
|
-
padding-left: var(--kds-spacing-container-1x);
|
|
126
|
-
margin-left: var(--kds-spacing-container-1x);
|
|
127
|
-
}
|
|
128
|
-
&::before {
|
|
129
|
-
position: absolute;
|
|
130
|
-
left: 0;
|
|
131
|
-
width: var(--kds-dimension-component-width-0-25x);
|
|
132
|
-
height: 100%;
|
|
133
|
-
content: "";
|
|
134
|
-
background-color: var(--kds-color-border-subtle);
|
|
135
|
-
border-radius: var(--kds-border-radius-container-pill);
|
|
136
|
-
}
|
|
137
|
-
& p:last-child {
|
|
138
|
-
margin-bottom: 0;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
pre {
|
|
142
|
-
& {
|
|
143
|
-
width: fit-content;
|
|
144
|
-
padding: var(--kds-spacing-container-0-75x);
|
|
145
|
-
font: var(--kds-font-base-code-xsmall);
|
|
146
|
-
background: var(--kds-color-surface-subtle);
|
|
147
|
-
border-radius: var(--kds-border-radius-container-0-25x);
|
|
148
|
-
}
|
|
149
|
-
& > code {
|
|
150
|
-
padding: 0;
|
|
151
|
-
background: none;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
& :not(pre) > code {
|
|
155
|
-
padding: var(--kds-spacing-container-0-12x)
|
|
156
|
-
var(--kds-spacing-container-0-25x);
|
|
157
|
-
font: var(--kds-font-base-code-xsmall);
|
|
158
|
-
background: var(--kds-color-surface-subtle);
|
|
159
|
-
box-decoration-break: clone;
|
|
160
|
-
border-radius: var(--kds-border-radius-container-0-12x);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/** keep in sync with KdsLink */
|
|
164
|
-
a {
|
|
165
|
-
& {
|
|
166
|
-
display: inline-flex;
|
|
167
|
-
align-items: center;
|
|
168
|
-
justify-content: center;
|
|
169
|
-
width: fit-content;
|
|
170
|
-
max-width: 100%;
|
|
171
|
-
padding: var(--kds-spacing-container-none)
|
|
172
|
-
var(--kds-spacing-container-0-10x);
|
|
173
|
-
font: var(--kds-font-base-body-small);
|
|
174
|
-
color: var(--kds-color-text-and-icon-neutral);
|
|
175
|
-
white-space: nowrap;
|
|
176
|
-
text-decoration-line: underline;
|
|
177
|
-
cursor: pointer;
|
|
178
|
-
border-radius: var(--kds-border-radius-container-0-12x);
|
|
179
|
-
|
|
180
|
-
/** internal links */
|
|
181
|
-
|
|
182
|
-
/** external links */
|
|
183
|
-
}
|
|
184
|
-
&:focus-visible {
|
|
185
|
-
outline: var(--kds-border-action-focused);
|
|
186
|
-
outline-offset: var(--kds-spacing-container-none);
|
|
187
|
-
}
|
|
188
|
-
&[href^="http"] {
|
|
189
|
-
& {
|
|
190
|
-
--link-color: var(--kds-color-text-and-icon-selected);
|
|
191
|
-
|
|
192
|
-
color: var(--link-color);
|
|
193
|
-
}
|
|
194
|
-
&:visited {
|
|
195
|
-
--link-color: var(--kds-color-text-and-icon-info);
|
|
196
|
-
|
|
197
|
-
color: var(--link-color);
|
|
198
|
-
}
|
|
199
|
-
&:hover {
|
|
200
|
-
--link-color: var(--kds-color-text-and-icon-primary-inverted);
|
|
201
|
-
|
|
202
|
-
color: var(--link-color);
|
|
203
|
-
background-color: var(--kds-color-background-primary-bold-hover);
|
|
204
|
-
}
|
|
205
|
-
&:active {
|
|
206
|
-
--link-color: var(--kds-color-text-and-icon-selected-inverted);
|
|
207
|
-
|
|
208
|
-
color: var(--link-color);
|
|
209
|
-
background-color: var(--kds-color-background-primary-bold-active);
|
|
210
|
-
}
|
|
211
|
-
&::after {
|
|
212
|
-
display: block;
|
|
213
|
-
width: var(--kds-dimension-icon-0-5x);
|
|
214
|
-
height: var(--kds-dimension-icon-0-5x);
|
|
215
|
-
margin-left: var(--kds-spacing-container-0-12x);
|
|
216
|
-
content: "";
|
|
217
|
-
background-color: var(--link-color);
|
|
218
|
-
mask-image: var(--v0bc2bfc0);
|
|
219
|
-
mask-repeat: no-repeat;
|
|
220
|
-
mask-size: contain;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
&:not([href^="http"]) {
|
|
224
|
-
& {
|
|
225
|
-
color: var(--kds-color-text-and-icon-neutral);
|
|
226
|
-
}
|
|
227
|
-
&:visited {
|
|
228
|
-
color: var(--kds-color-text-and-icon-info);
|
|
229
|
-
}
|
|
230
|
-
&:hover {
|
|
231
|
-
background-color: var(--kds-color-background-neutral-hover);
|
|
232
|
-
}
|
|
233
|
-
&:active {
|
|
234
|
-
background-color: var(--kds-color-background-neutral-active);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
ol,
|
|
239
|
-
ul {
|
|
240
|
-
padding-left: var(--kds-spacing-container-2x);
|
|
241
|
-
}
|
|
242
|
-
dd {
|
|
243
|
-
margin-left: var(--kds-spacing-container-1x);
|
|
244
|
-
}
|
|
245
|
-
table {
|
|
246
|
-
& {
|
|
247
|
-
border-spacing: var(--kds-spacing-container-0-25x) 0;
|
|
248
|
-
border-collapse: separate;
|
|
249
|
-
}
|
|
250
|
-
td,
|
|
251
|
-
th {
|
|
252
|
-
padding: var(--kds-spacing-container-0-25x);
|
|
253
|
-
}
|
|
254
|
-
th {
|
|
255
|
-
font: var(--kds-font-base-body-small-strong);
|
|
256
|
-
text-align: left;
|
|
257
|
-
border-bottom: var(--kds-border-width-icon-stroke-l) solid
|
|
258
|
-
var(--kds-color-border-neutral);
|
|
259
|
-
}
|
|
260
|
-
td {
|
|
261
|
-
font: var(--kds-font-base-body-small);
|
|
262
|
-
border-bottom: var(--kds-border-width-icon-stroke-s) solid
|
|
263
|
-
var(--kds-color-border-neutral);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
68
|
}
|
|
267
|
-
&[data-v-
|
|
268
|
-
&[data-v-
|
|
69
|
+
&[data-v-f486df47] .ProseMirror:focus-visible,
|
|
70
|
+
&[data-v-f486df47] .ProseMirror:focus {
|
|
269
71
|
outline: transparent;
|
|
270
72
|
}
|
|
271
73
|
}
|
|
272
74
|
.editor-wrapper.with-border {
|
|
273
|
-
&[data-v-
|
|
75
|
+
&[data-v-f486df47] {
|
|
274
76
|
border: var(--kds-border-action-input);
|
|
275
77
|
border-radius: var(--kds-border-radius-container-0-37x);
|
|
276
78
|
}
|
|
277
|
-
&.disabled[data-v-
|
|
79
|
+
&.disabled[data-v-f486df47] {
|
|
278
80
|
border: var(--kds-border-action-disabled);
|
|
279
81
|
}
|
|
280
|
-
& .toolbar-wrapper[data-v-
|
|
82
|
+
& .toolbar-wrapper[data-v-f486df47] {
|
|
281
83
|
border-top-left-radius: var(--kds-border-radius-container-0-37x);
|
|
282
84
|
border-top-right-radius: var(--kds-border-radius-container-0-37x);
|
|
283
85
|
}
|
|
284
|
-
& .rich-text-editor[data-v-
|
|
86
|
+
& .rich-text-editor[data-v-f486df47] {
|
|
285
87
|
border-bottom-right-radius: var(--kds-border-radius-container-0-37x);
|
|
286
88
|
border-bottom-left-radius: var(--kds-border-radius-container-0-37x);
|
|
287
89
|
}
|
|
288
90
|
}
|
|
289
|
-
.editor-wrapper.show-focus-ring[data-v-
|
|
91
|
+
.editor-wrapper.show-focus-ring[data-v-f486df47] {
|
|
290
92
|
outline: var(--kds-border-action-focused);
|
|
291
93
|
outline-offset: var(--kds-spacing-offset-focus);
|
|
292
94
|
}
|
|
293
95
|
.embedded-toolbar {
|
|
294
|
-
&[data-v-
|
|
96
|
+
&[data-v-f486df47] {
|
|
295
97
|
height: var(--toolbar-height);
|
|
296
98
|
padding: var(--kds-spacing-container-0-5x);
|
|
297
99
|
overflow-x: auto;
|
|
@@ -302,7 +104,7 @@ td {
|
|
|
302
104
|
border-bottom: var(--kds-border-base-muted);
|
|
303
105
|
-ms-overflow-style: none; /* needed to hide scroll bar in edge */
|
|
304
106
|
}
|
|
305
|
-
&[data-v-
|
|
107
|
+
&[data-v-f486df47]::-webkit-scrollbar {
|
|
306
108
|
display: none;
|
|
307
109
|
}
|
|
308
110
|
}
|
package/dist/index.js
CHANGED
|
@@ -3,10 +3,12 @@ import CharacterCount from "@tiptap/extension-character-count";
|
|
|
3
3
|
import StarterKit from "@tiptap/starter-kit";
|
|
4
4
|
import { EditorContent, Extension, useEditor } from "@tiptap/vue-3";
|
|
5
5
|
import { KdsButton, KdsLabel, KdsMenuButton, KdsModal, KdsSubText, KdsTextInput, KdsToggleButton } from "@knime/kds-components";
|
|
6
|
+
import "@knime/kds-styles/rich-text-content.css";
|
|
7
|
+
import { Extension as Extension$1 } from "@tiptap/core";
|
|
8
|
+
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
|
6
9
|
import HardBreak from "@tiptap/extension-hard-break";
|
|
7
|
-
import { getAttributes } from "@tiptap/core";
|
|
8
10
|
import Link from "@tiptap/extension-link";
|
|
9
|
-
import {
|
|
11
|
+
import { Decoration, DecorationSet } from "@tiptap/pm/view";
|
|
10
12
|
import TextAlign from "@tiptap/extension-text-align";
|
|
11
13
|
import Paragraph from "@tiptap/extension-paragraph";
|
|
12
14
|
import './index.css';//#region ../../node_modules/.pnpm/dompurify@3.4.17/node_modules/dompurify/dist/purify.es.mjs
|
|
@@ -2750,9 +2752,6 @@ var hotkeys = {
|
|
|
2750
2752
|
match
|
|
2751
2753
|
};
|
|
2752
2754
|
//#endregion
|
|
2753
|
-
//#region ../styles/dist/img/icons/external-link.svg?url
|
|
2754
|
-
var external_link_default = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20fill='none'%20stroke='currentColor'%20stroke-linecap='round'%20stroke-linejoin='round'%20viewBox='0%200%2012%2012'%3e%3cpath%20d='M5.5%201.5h-3a1%201%200%200%200-1%201v7a1%201%200%200%200%201%201h7a1%201%200%200%200%201-1v-3m0-5L6%205.892M10.5%201.5v2.75m0-2.75H7.75'%20vector-effect='non-scaling-stroke'/%3e%3c/svg%3e";
|
|
2755
|
-
//#endregion
|
|
2756
2755
|
//#region src/enums.ts
|
|
2757
2756
|
var kdsCharacterCountDisplay = {
|
|
2758
2757
|
NEVER: "never",
|
|
@@ -3312,6 +3311,40 @@ var RichTextEditorToolbar_default = /*#__PURE__*/ _plugin_vue_export_helper_defa
|
|
|
3312
3311
|
}
|
|
3313
3312
|
}), [["__scopeId", "data-v-7519cb37"]]);
|
|
3314
3313
|
//#endregion
|
|
3314
|
+
//#region src/utils/character-limit.ts
|
|
3315
|
+
/**
|
|
3316
|
+
* Limits the content to a number of characters, as CharacterCount's `limit`
|
|
3317
|
+
* does, but reads the limit on every change. CharacterCount fixes its limit
|
|
3318
|
+
* when the editor is created, so it can't follow an editor that switches
|
|
3319
|
+
* between read-only and editing. Counts with CharacterCount, which must be
|
|
3320
|
+
* registered too.
|
|
3321
|
+
*/
|
|
3322
|
+
var CharacterLimit = Extension$1.create({
|
|
3323
|
+
name: "characterLimit",
|
|
3324
|
+
addOptions() {
|
|
3325
|
+
return { getLimit: () => Infinity };
|
|
3326
|
+
},
|
|
3327
|
+
addProseMirrorPlugins() {
|
|
3328
|
+
const { getLimit } = this.options;
|
|
3329
|
+
const { editor } = this;
|
|
3330
|
+
const characters = (node) => editor.storage.characterCount.characters({ node });
|
|
3331
|
+
return [new Plugin({
|
|
3332
|
+
key: new PluginKey("characterLimit"),
|
|
3333
|
+
filterTransaction: (transaction, state) => {
|
|
3334
|
+
const limit = getLimit();
|
|
3335
|
+
if (!transaction.docChanged || !Number.isFinite(limit)) return true;
|
|
3336
|
+
const oldSize = characters(state.doc);
|
|
3337
|
+
const newSize = characters(transaction.doc);
|
|
3338
|
+
if (newSize <= limit || newSize <= oldSize) return true;
|
|
3339
|
+
if (oldSize > limit || !transaction.getMeta("paste")) return false;
|
|
3340
|
+
const pos = transaction.selection.$head.pos;
|
|
3341
|
+
transaction.deleteRange(pos - (newSize - limit), pos);
|
|
3342
|
+
return characters(transaction.doc) <= limit;
|
|
3343
|
+
}
|
|
3344
|
+
})];
|
|
3345
|
+
}
|
|
3346
|
+
});
|
|
3347
|
+
//#endregion
|
|
3315
3348
|
//#region src/utils/custom-escape.ts
|
|
3316
3349
|
var CustomEscape = Extension.create({
|
|
3317
3350
|
name: "OverrideEscape",
|
|
@@ -3342,26 +3375,47 @@ var kdsDefaultLinkToolOptions = {
|
|
|
3342
3375
|
};
|
|
3343
3376
|
var CustomLink = Link.extend({
|
|
3344
3377
|
addAttributes() {
|
|
3345
|
-
const modifier = navigator_exports.isMac() ? "⌘" : "Ctrl +";
|
|
3346
3378
|
return {
|
|
3347
3379
|
...this.parent?.(),
|
|
3348
3380
|
draggable: { default: "false" },
|
|
3349
|
-
title: {
|
|
3350
|
-
|
|
3381
|
+
title: {
|
|
3382
|
+
default: null,
|
|
3383
|
+
parseHTML: () => null
|
|
3384
|
+
},
|
|
3385
|
+
target: {
|
|
3386
|
+
default: "_blank",
|
|
3387
|
+
parseHTML: () => null
|
|
3388
|
+
},
|
|
3389
|
+
rel: {
|
|
3390
|
+
default: "ugc noopener noreferrer nofollow",
|
|
3391
|
+
parseHTML: () => null
|
|
3392
|
+
}
|
|
3351
3393
|
};
|
|
3352
3394
|
},
|
|
3353
3395
|
addProseMirrorPlugins() {
|
|
3354
3396
|
const plugins = this.parent?.() || [];
|
|
3355
|
-
const
|
|
3356
|
-
key: new PluginKey("
|
|
3397
|
+
const linkClickHandler = new Plugin({
|
|
3398
|
+
key: new PluginKey("handleLinkClick"),
|
|
3357
3399
|
props: { handleClick(view, _pos, event) {
|
|
3358
|
-
const
|
|
3359
|
-
|
|
3360
|
-
if (event[getMetaOrCtrlKey()] && link && attrs.href) window.open(attrs.href, attrs.target);
|
|
3400
|
+
const href = event.target?.closest("a")?.href;
|
|
3401
|
+
if (view.editable && href && event[getMetaOrCtrlKey()]) window.open(href, "_blank", "noopener,noreferrer");
|
|
3361
3402
|
return true;
|
|
3362
3403
|
} }
|
|
3363
3404
|
});
|
|
3364
|
-
|
|
3405
|
+
const modifier = navigator_exports.isMac() ? "⌘" : "Ctrl +";
|
|
3406
|
+
const { editor, type: linkType } = this;
|
|
3407
|
+
const editingHint = new Plugin({
|
|
3408
|
+
key: new PluginKey("linkEditingHint"),
|
|
3409
|
+
props: { decorations: (state) => {
|
|
3410
|
+
if (!editor.isEditable) return null;
|
|
3411
|
+
const decorations = [];
|
|
3412
|
+
state.doc.descendants((node, pos) => {
|
|
3413
|
+
if (node.isText && linkType.isInSet(node.marks)) decorations.push(Decoration.inline(pos, pos + node.nodeSize, { title: `Use "${modifier} click" to follow link` }));
|
|
3414
|
+
});
|
|
3415
|
+
return DecorationSet.create(state.doc, decorations);
|
|
3416
|
+
} }
|
|
3417
|
+
});
|
|
3418
|
+
plugins.push(linkClickHandler, editingHint);
|
|
3365
3419
|
return plugins;
|
|
3366
3420
|
}
|
|
3367
3421
|
});
|
|
@@ -3476,14 +3530,13 @@ var KdsRichTextEditor_default = /*#__PURE__*/ _plugin_vue_export_helper_default(
|
|
|
3476
3530
|
emits: /*@__PURE__*/ mergeModels(["blur"], ["update:modelValue"]),
|
|
3477
3531
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
3478
3532
|
useCssVars((_ctx) => ({
|
|
3479
|
-
"
|
|
3480
|
-
"
|
|
3481
|
-
"v0bc2bfc0": externalIcon
|
|
3533
|
+
"ba8c99e6": maxHeightStyle.value,
|
|
3534
|
+
"v6c3d1d42": minHeightStyle.value
|
|
3482
3535
|
}));
|
|
3483
|
-
const
|
|
3536
|
+
const editableCharacterLimit = Math.max(__props.characterLimit.maxCharacters ?? 1e3, MIN_CHARACTER_LIMIT);
|
|
3537
|
+
const hardCharacterLimit = computed(() => __props.editable ? editableCharacterLimit : Infinity);
|
|
3484
3538
|
const characterCountDisplay = __props.characterLimit.display ?? kdsCharacterCountDisplay.NEVER;
|
|
3485
3539
|
const slots = useSlots();
|
|
3486
|
-
const externalIcon = `url("${external_link_default}")`;
|
|
3487
3540
|
/** The current rich text value. */
|
|
3488
3541
|
const modelValue = useModel(__props, "modelValue");
|
|
3489
3542
|
const emit = __emit;
|
|
@@ -3525,7 +3578,8 @@ var KdsRichTextEditor_default = /*#__PURE__*/ _plugin_vue_export_helper_default(
|
|
|
3525
3578
|
openOnClick: false
|
|
3526
3579
|
})] : [],
|
|
3527
3580
|
CustomHardBreak,
|
|
3528
|
-
CharacterCount
|
|
3581
|
+
CharacterCount,
|
|
3582
|
+
CharacterLimit.configure({ getLimit: () => hardCharacterLimit.value }),
|
|
3529
3583
|
...__props.customEscapeHandler ? [CustomEscape.configure({ handler: __props.customEscapeHandler })] : [],
|
|
3530
3584
|
...__props.customExtensions
|
|
3531
3585
|
];
|
|
@@ -3537,6 +3591,7 @@ var KdsRichTextEditor_default = /*#__PURE__*/ _plugin_vue_export_helper_default(
|
|
|
3537
3591
|
autofocus: __props.autofocus,
|
|
3538
3592
|
extensions,
|
|
3539
3593
|
editorProps: { attributes: {
|
|
3594
|
+
class: "kds-rich-text-content",
|
|
3540
3595
|
...__props.ariaLabel ? { "aria-label": __props.ariaLabel } : {},
|
|
3541
3596
|
...__props.ariaLabelledby ? { "aria-labelledby": __props.ariaLabelledby } : {},
|
|
3542
3597
|
"aria-describedby": subTextId
|
|
@@ -3568,7 +3623,7 @@ var KdsRichTextEditor_default = /*#__PURE__*/ _plugin_vue_export_helper_default(
|
|
|
3568
3623
|
const oldValue = oldEditable && !oldDisabled;
|
|
3569
3624
|
const newValue = newEditable && !newDisabled;
|
|
3570
3625
|
if (oldValue === newValue) return;
|
|
3571
|
-
editor.value.setEditable(newValue);
|
|
3626
|
+
editor.value.setEditable(newValue, false);
|
|
3572
3627
|
if (__props.autofocus) focus();
|
|
3573
3628
|
});
|
|
3574
3629
|
onMounted(async () => {
|
|
@@ -3584,14 +3639,14 @@ var KdsRichTextEditor_default = /*#__PURE__*/ _plugin_vue_export_helper_default(
|
|
|
3584
3639
|
if (!editor.value || !__props.editable) return false;
|
|
3585
3640
|
switch (characterCountDisplay) {
|
|
3586
3641
|
case kdsCharacterCountDisplay.ALWAYS: return true;
|
|
3587
|
-
case kdsCharacterCountDisplay.AT_LIMIT: return hardCharacterLimit - characterCount.value <= AT_LIMIT_THRESHOLD;
|
|
3642
|
+
case kdsCharacterCountDisplay.AT_LIMIT: return hardCharacterLimit.value - characterCount.value <= AT_LIMIT_THRESHOLD;
|
|
3588
3643
|
default: return false;
|
|
3589
3644
|
}
|
|
3590
3645
|
});
|
|
3591
3646
|
const hasSubTextOverride = computed(() => Boolean(__props.subText));
|
|
3592
3647
|
const subTextValue = computed(() => {
|
|
3593
3648
|
if (hasSubTextOverride.value) return __props.subText;
|
|
3594
|
-
return showCharacterCount.value ? `${characterCount.value} / ${hardCharacterLimit} characters` : void 0;
|
|
3649
|
+
return showCharacterCount.value ? `${characterCount.value} / ${hardCharacterLimit.value} characters` : void 0;
|
|
3595
3650
|
});
|
|
3596
3651
|
return (_ctx, _cache) => {
|
|
3597
3652
|
return openBlock(), createElementBlock("div", null, [createElementVNode("div", { class: normalizeClass(["editor-wrapper", {
|
|
@@ -3648,7 +3703,7 @@ var KdsRichTextEditor_default = /*#__PURE__*/ _plugin_vue_export_helper_default(
|
|
|
3648
3703
|
])]);
|
|
3649
3704
|
};
|
|
3650
3705
|
}
|
|
3651
|
-
}), [["__scopeId", "data-v-
|
|
3706
|
+
}), [["__scopeId", "data-v-f486df47"]]);
|
|
3652
3707
|
//#endregion
|
|
3653
3708
|
//#region src/KdsRichTextInput.vue
|
|
3654
3709
|
var KdsRichTextInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
|