toggle-components-library 1.37.0-beta.2 → 1.37.0-beta.4
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 +135 -84
- 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 +135 -84
- 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 +52 -7
- 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,17 +57,60 @@ 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
|
+
},
|
|
86
|
+
|
|
87
|
+
handleEnterKey(event) {
|
|
88
|
+
event.preventDefault();
|
|
89
|
+
event.target.blur();
|
|
90
|
+
},
|
|
58
91
|
|
|
92
|
+
|
|
59
93
|
updateContent(event) {
|
|
60
|
-
|
|
61
|
-
|
|
94
|
+
const newText = event.target.innerText;
|
|
95
|
+
|
|
96
|
+
// If text exceeds maxChars, prevent the change
|
|
97
|
+
if (newText.length > this.maxChars) {
|
|
98
|
+
// Save current selection
|
|
99
|
+
const selection = window.getSelection();
|
|
100
|
+
const range = selection.getRangeAt(0);
|
|
101
|
+
const cursorOffset = range.startOffset;
|
|
102
|
+
|
|
103
|
+
// Restore previous content
|
|
62
104
|
event.target.innerText = this.content;
|
|
63
|
-
|
|
64
|
-
//
|
|
65
|
-
document.
|
|
66
|
-
|
|
105
|
+
|
|
106
|
+
// Restore cursor position
|
|
107
|
+
const newRange = document.createRange();
|
|
108
|
+
newRange.setStart(event.target.firstChild || event.target, Math.min(cursorOffset, this.content.length));
|
|
109
|
+
newRange.collapse(true);
|
|
110
|
+
selection.removeAllRanges();
|
|
111
|
+
selection.addRange(newRange);
|
|
67
112
|
} else {
|
|
68
|
-
this.content =
|
|
113
|
+
this.content = newText;
|
|
69
114
|
this.$emit('update:lastCrumb', this.content);
|
|
70
115
|
}
|
|
71
116
|
}
|