toggle-components-library 1.37.0-beta.2 → 1.37.0-beta.3
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/dist/toggle-components-library.common.js +118 -79
- package/dist/toggle-components-library.common.js.map +1 -1
- package/dist/toggle-components-library.css +1 -1
- package/dist/toggle-components-library.umd.js +118 -79
- package/dist/toggle-components-library.umd.js.map +1 -1
- package/dist/toggle-components-library.umd.min.js +1 -1
- package/dist/toggle-components-library.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/components/breadcrumb/ToggleBreadCrumb.vue +36 -2
- package/src/sass/includes/_as_breadcrumb.scss +1 -0
package/package.json
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
contenteditable="true"
|
|
7
7
|
class="toggle-breadcrumb-editable-input"
|
|
8
8
|
@input="updateContent($event);"
|
|
9
|
+
@keydown.enter.prevent="handleEnterKey"
|
|
10
|
+
@paste.prevent="handlePaste"
|
|
9
11
|
>{{ crumb.name }}</span>
|
|
10
12
|
</template>
|
|
11
13
|
<template v-else>
|
|
@@ -55,15 +57,47 @@ export default {
|
|
|
55
57
|
},
|
|
56
58
|
|
|
57
59
|
methods: {
|
|
60
|
+
handlePaste(event) {
|
|
61
|
+
// Get plain text from clipboard and clean it
|
|
62
|
+
const text = (event.clipboardData || window.clipboardData).getData('text');
|
|
63
|
+
const cleanText = text.replace(/[\r\n\s]+/g, ' ').trim();
|
|
64
|
+
|
|
65
|
+
// Get current selection information
|
|
66
|
+
const selection = window.getSelection();
|
|
67
|
+
const selectionLength = selection.toString().length;
|
|
68
|
+
const currentLength = this.content.length;
|
|
69
|
+
|
|
70
|
+
// Check if adding the pasted text would exceed maxChars
|
|
71
|
+
if (currentLength - selectionLength + cleanText.length <= this.maxChars && selection.rangeCount) {
|
|
72
|
+
const range = selection.getRangeAt(0);
|
|
73
|
+
range.deleteContents();
|
|
74
|
+
range.insertNode(document.createTextNode(cleanText));
|
|
75
|
+
|
|
76
|
+
// Move cursor to end of inserted text
|
|
77
|
+
range.collapse(false);
|
|
78
|
+
selection.removeAllRanges();
|
|
79
|
+
selection.addRange(range);
|
|
80
|
+
|
|
81
|
+
// Update content
|
|
82
|
+
this.content = event.target.innerText;
|
|
83
|
+
this.$emit('update:lastCrumb', this.content);
|
|
84
|
+
}
|
|
85
|
+
},
|
|
58
86
|
|
|
87
|
+
handleEnterKey(event) {
|
|
88
|
+
event.preventDefault();
|
|
89
|
+
event.target.blur();
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
|
|
59
93
|
updateContent(event) {
|
|
60
94
|
// Limit the input to 50 characters
|
|
61
95
|
if (event.target.innerText.length >= this.maxChars) {
|
|
62
96
|
event.target.innerText = this.content;
|
|
63
|
-
|
|
97
|
+
|
|
64
98
|
// Move the cursor to the end of the input
|
|
65
99
|
document.getSelection().modify("move", "forward", "documentboundary");
|
|
66
|
-
|
|
100
|
+
|
|
67
101
|
} else {
|
|
68
102
|
this.content = event.target.innerText;
|
|
69
103
|
this.$emit('update:lastCrumb', this.content);
|