Skip to content

Commit a77e763

Browse files
committed
fix(texteditor)[link]: edit link bug
1 parent 5038f33 commit a77e763

12 files changed

Lines changed: 157 additions & 44 deletions

File tree

contentcuration/contentcuration/frontend/shared/views/TipTapEditor/TipTapEditor/TipTapEditor.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
:style="linkHandler.editorStyle.value"
2121
>
2222
<LinkEditor
23+
:mode="linkHandler.editorMode.value"
2324
:initial-state="linkHandler.editorInitialState.value"
2425
@save="linkHandler.saveLink"
2526
@remove="linkHandler.removeLink"

contentcuration/contentcuration/frontend/shared/views/TipTapEditor/TipTapEditor/components/image/ImageDropZone.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@
8080
}
8181
8282
.drop-zone:focus {
83-
outline: 2px solid #3498db;
83+
background: #e6e6e6;
84+
border-radius: 4px;
85+
outline: 2px solid #0097f2;
8486
}
8587
8688
</style>

contentcuration/contentcuration/frontend/shared/views/TipTapEditor/TipTapEditor/components/image/ImageNodeView.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,4 +259,10 @@
259259
opacity: 1;
260260
}
261261
262+
button:focus-visible {
263+
background: #e6e6e6;
264+
border-radius: 4px;
265+
outline: 2px solid #0097f2;
266+
}
267+
262268
</style>

contentcuration/contentcuration/frontend/shared/views/TipTapEditor/TipTapEditor/components/image/ImageUploadModal.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@
336336
337337
.close-button {
338338
font-size: 2rem;
339+
line-height: 1;
339340
color: black;
340341
cursor: pointer;
341342
background: none;
@@ -413,7 +414,6 @@
413414
.select-file-link {
414415
flex-shrink: 0;
415416
margin-left: 1rem;
416-
font-weight: 400;
417417
color: #4368f5;
418418
text-decoration: underline;
419419
cursor: pointer;
@@ -504,4 +504,11 @@
504504
font-size: 12px;
505505
}
506506
507+
button:focus-visible,
508+
input:focus {
509+
background: #e6e6e6;
510+
border-radius: 4px;
511+
outline: 2px solid #0097f2;
512+
}
513+
507514
</style>

contentcuration/contentcuration/frontend/shared/views/TipTapEditor/TipTapEditor/components/link/LinkBubbleMenu.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
8585
return {
8686
href,
87-
onEdit: openLinkEditor,
87+
onEdit: () => openLinkEditor('edit'),
8888
onRemove: removeLink,
8989
copyToClipboard,
9090
goToLink$,
@@ -149,7 +149,6 @@
149149
.bubble-menu-button:focus-visible {
150150
background: #e6e6e6;
151151
outline: 2px solid #0097f2;
152-
outline-offset: 2px;
153152
}
154153
155154
.bubble-menu-button img {

contentcuration/contentcuration/frontend/shared/views/TipTapEditor/TipTapEditor/components/link/LinkEditor.vue

Lines changed: 53 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
aria-modal="true"
99
>
1010
<div class="modal-header">
11-
<h3 :id="headingId">{{ addLink$() }}</h3>
11+
<h3 :id="headingId">{{ isEditMode ? editLink$() : addLink$() }}</h3>
1212
<button
1313
class="close-button"
1414
:title="close$()"
@@ -41,7 +41,23 @@
4141
</div>
4242
</div>
4343

44-
<div class="footer">
44+
<div
45+
class="footer"
46+
:class="{ 'edit-mode': isEditMode }"
47+
>
48+
<button
49+
v-if="isEditMode"
50+
class="remove-link-button"
51+
@click="$emit('remove')"
52+
>
53+
<img
54+
src="../../../assets/icon-linkOff.svg"
55+
aria-hidden="true"
56+
class="remove-link-icon"
57+
>
58+
<span> {{ removeLink$() }} </span>
59+
</button>
60+
4561
<button
4662
class="save-button"
4763
:disabled="!validateForm()"
@@ -57,18 +73,21 @@
5773

5874
<script>
5975
60-
import { defineComponent, ref, watch } from 'vue';
76+
import { defineComponent, ref, watch, computed } from 'vue';
6177
import { useFocusTrap } from '../../composables/useFocusTrap';
6278
import { getTipTapEditorStrings } from '../../TipTapEditorStrings';
6379
6480
export default defineComponent({
6581
name: 'LinkEditor',
6682
setup(props, { emit }) {
67-
const { addLink$, close$, text$, link$, save$, closeModal$ } = getTipTapEditorStrings();
83+
const { addLink$, close$, text$, link$, save$, closeModal$, editLink$, removeLink$ } =
84+
getTipTapEditorStrings();
6885
const rootEl = ref(null);
6986
const formData = ref({ text: '', href: '' });
7087
const headingId = `link-editor-heading-${Math.random().toString(36).substr(2, 9)}`;
7188
89+
const isEditMode = computed(() => props.mode === 'edit');
90+
7291
watch(
7392
() => props.initialState,
7493
newState => {
@@ -92,16 +111,20 @@
92111
formData,
93112
onSave,
94113
validateForm,
114+
isEditMode,
95115
headingId,
96116
addLink$,
97117
close$,
98118
text$,
99119
link$,
100120
save$,
101121
closeModal$,
122+
editLink$,
123+
removeLink$,
102124
};
103125
},
104126
props: {
127+
mode: { type: String, default: 'create' },
105128
initialState: { type: Object, required: true },
106129
},
107130
emits: ['save', 'remove', 'close'],
@@ -152,11 +175,6 @@
152175
border: 0;
153176
}
154177
155-
.close-button:focus-visible {
156-
outline: 2px solid #0097f2;
157-
outline-offset: 2px;
158-
}
159-
160178
.form-group {
161179
position: relative;
162180
display: flex;
@@ -183,15 +201,20 @@
183201
}
184202
185203
.form-group input:focus {
204+
border-bottom: 0;
186205
outline: 2px solid #0097f2;
187-
outline-offset: 2px;
206+
outline-offset: 1px;
188207
}
189208
190209
.footer {
191210
display: flex;
192211
justify-content: flex-end;
193212
}
194213
214+
.footer.edit-mode {
215+
justify-content: space-between;
216+
}
217+
195218
.save-button {
196219
padding: 8px 16px;
197220
font-weight: bold;
@@ -207,9 +230,27 @@
207230
cursor: not-allowed;
208231
}
209232
210-
.save-button:focus-visible {
233+
.remove-link-button {
234+
display: flex;
235+
gap: 8px;
236+
align-items: center;
237+
color: #4368f5;
238+
text-decoration: underline;
239+
cursor: pointer;
240+
background: none;
241+
border: 0;
242+
border-radius: 2px;
243+
}
244+
245+
.remove-link-icon {
246+
filter: brightness(0) saturate(100%) invert(32%) sepia(97%) saturate(2640%) hue-rotate(230deg)
247+
brightness(103%) contrast(94%);
248+
}
249+
250+
button:focus-visible {
251+
background: #e6e6e6;
252+
border-radius: 4px;
211253
outline: 2px solid #0097f2;
212-
outline-offset: 2px;
213254
}
214255
215256
</style>

contentcuration/contentcuration/frontend/shared/views/TipTapEditor/TipTapEditor/components/toolbar/FormatDropdown.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@
234234
background: #e6e6e6;
235235
border-radius: 4px;
236236
outline: 2px solid #0097f2;
237-
outline-offset: 2px;
238237
}
239238
240239
.dropdown-icon {
@@ -268,7 +267,6 @@
268267
'Segoe UI',
269268
sans-serif;
270269
font-size: 14px;
271-
font-weight: 400;
272270
line-height: 140%;
273271
color: #000000;
274272
cursor: pointer;

contentcuration/contentcuration/frontend/shared/views/TipTapEditor/TipTapEditor/components/toolbar/PasteDropdown.vue

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@
259259
background: #e6e6e6;
260260
border-radius: 4px;
261261
outline: 2px solid #0097f2;
262-
outline-offset: 2px;
263262
}
264263
265264
.toolbar-icon {
@@ -304,7 +303,6 @@
304303
background: #e6e6e6;
305304
border-radius: 4px;
306305
outline: 2px solid #0097f2;
307-
outline-offset: 2px;
308306
}
309307
310308
.dropdown-arrow {
@@ -343,7 +341,6 @@
343341
'Segoe UI',
344342
sans-serif;
345343
font-size: 14px;
346-
font-weight: 400;
347344
line-height: 140%;
348345
color: #000000;
349346
cursor: pointer;

contentcuration/contentcuration/frontend/shared/views/TipTapEditor/TipTapEditor/components/toolbar/ToolbarButton.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@
129129
background: #e6e6e6;
130130
border-radius: 4px;
131131
outline: 2px solid #0097f2;
132-
outline-offset: 2px;
133132
}
134133
135134
.toolbar-icon {

contentcuration/contentcuration/frontend/shared/views/TipTapEditor/TipTapEditor/composables/useImageHandling.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ref, onMounted, onUnmounted } from 'vue';
1+
import { ref, onMounted, onUnmounted, watch } from 'vue';
22

33
export function useImageHandling(editor) {
44
const modalMode = ref(null); // 'create' or 'edit'
@@ -84,6 +84,22 @@ export function useImageHandling(editor) {
8484
closeModal();
8585
};
8686

87+
watch(modalMode, mode => {
88+
const handler = event => {
89+
const popover = document.querySelector('.image-upload-modal');
90+
if (popover && !popover.contains(event.target)) {
91+
closeModal();
92+
}
93+
};
94+
if (mode) {
95+
setTimeout(() => {
96+
document.addEventListener('mousedown', handler, true);
97+
}, 0);
98+
} else {
99+
document.removeEventListener('mousedown', handler, true);
100+
}
101+
});
102+
87103
onMounted(() => {
88104
if (editor?.value) {
89105
editor.value.on('open-image-editor', openEditModal);

0 commit comments

Comments
 (0)