I am using vis-timeline 7.4.7.
There is a feature, the website says:
When the Timeline is configured to be editable (both options selectable and editable are true), the user can: ... Create a new range item by dragging on an empty space with the ctrl key down...
I need to use the options.add=true, also the editable and the selectable, because of the other features I am using.
My question is: is there a way to disable the "add new item with ctrl/meta + click-and-drag" feature?
I found that it is handled by Input.domHandler ->... -> recognize ->... -> propagatedHandler -> _onDragStart -> _onDragStartAddItem, but I could not find a way to set an option to disable this.
Note: That would be a great workaround to hide the new blue element (with a build-in text says "new item"), but the new element does not have any special class or anything I could target with CSS. (The item will not stay alive, as I can catch it with the onAdd function, but it runs only AFTER the user released the mouse button)
My current workaround is that I add my own class to all the elements I create, so I can tartet the new element with:not(). Well... not the best solution:(
Note2: it is happening not only with ctrlKey, but also with metaKey
How i got around it is like this.
A bit hacky. On the onAdd
event listener I did the following.
function isUUID(uuid) {
var regex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
return regex.test(uuid);
}
onAdd: (item, callback) => {
if (item.content == 'new item' && isUUID(item.id) ) {
callback(null)
} else {
//emits('onAdd', item);
callback(item);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.