mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
using whole note box to drag the box instead of special handle
This commit is contained in:
parent
2a14ea8d0c
commit
93d152eae5
@ -95,9 +95,9 @@ async function loadNotesAndRelations() {
|
|||||||
const title = data.noteTitles[note.id];
|
const title = data.noteTitles[note.id];
|
||||||
|
|
||||||
if (note.x && note.y) {
|
if (note.x && note.y) {
|
||||||
await newNode(note.id, title, note.x, note.y);
|
await createNoteBox(note.id, title, note.x, note.y);
|
||||||
} else {
|
} else {
|
||||||
await newNode(note.id, title, curX, curY);
|
await createNoteBox(note.id, title, curX, curY);
|
||||||
|
|
||||||
if (curX > 1000) {
|
if (curX > 1000) {
|
||||||
curX = 100;
|
curX = 100;
|
||||||
@ -114,14 +114,12 @@ async function loadNotesAndRelations() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const connection = instance.connect({
|
const connection = instance.connect({
|
||||||
id: relation.attributeIds,
|
|
||||||
source: relation.sourceNoteId,
|
source: relation.sourceNoteId,
|
||||||
target: relation.targetNoteId,
|
target: relation.targetNoteId,
|
||||||
type: relation.type
|
type: relation.type
|
||||||
});
|
});
|
||||||
|
|
||||||
relation.connectionId = connection.id;
|
connection.id = relation.attributeId;
|
||||||
|
|
||||||
connection.getOverlay("label").setLabel(relation.name);
|
connection.getOverlay("label").setLabel(relation.name);
|
||||||
connection.canvas.setAttribute("data-connection-id", connection.id);
|
connection.canvas.setAttribute("data-connection-id", connection.id);
|
||||||
}
|
}
|
||||||
@ -154,8 +152,9 @@ function initPanZoom() {
|
|||||||
async function initJsPlumb () {
|
async function initJsPlumb () {
|
||||||
instance = jsPlumb.getInstance({
|
instance = jsPlumb.getInstance({
|
||||||
Endpoint: ["Dot", {radius: 2}],
|
Endpoint: ["Dot", {radius: 2}],
|
||||||
Connector: "Straight",
|
Connector: "StateMachine",
|
||||||
HoverPaintStyle: {stroke: "#777", strokeWidth: 1 },
|
ConnectionOverlays: uniDirectionalOverlays,
|
||||||
|
HoverPaintStyle: { stroke: "#777", strokeWidth: 1 },
|
||||||
Container: "relation-map-canvas"
|
Container: "relation-map-canvas"
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -237,7 +236,7 @@ async function connectionCreatedHandler(info, originalEvent) {
|
|||||||
|
|
||||||
relations.push({ attributeId: attribute.attributeId , targetNoteId, sourceNoteId, name });
|
relations.push({ attributeId: attribute.attributeId , targetNoteId, sourceNoteId, name });
|
||||||
|
|
||||||
connection.setType("uniDirectional");
|
connection.id = attribute.attributeId;
|
||||||
connection.getOverlay("label").setLabel(name);
|
connection.getOverlay("label").setLabel(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,14 +295,20 @@ function saveData() {
|
|||||||
noteDetailService.noteChanged();
|
noteDetailService.noteChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
function initNode(el) {
|
async function createNoteBox(id, title, x, y) {
|
||||||
instance.draggable(el, {
|
const $noteBox = $("<div>")
|
||||||
handle: ".handle",
|
.addClass("note-box")
|
||||||
start:function(params) {
|
.prop("id", id)
|
||||||
},
|
.append($("<span>").addClass("title").html(await linkService.createNoteLink(id, title)))
|
||||||
drag:function(params) {
|
.append($("<div>").addClass("endpoint"))
|
||||||
|
.css("left", x + "px")
|
||||||
|
.css("top", y + "px");
|
||||||
|
|
||||||
},
|
instance.getContainer().appendChild($noteBox[0]);
|
||||||
|
|
||||||
|
instance.draggable($noteBox[0], {
|
||||||
|
start:function(params) {},
|
||||||
|
drag:function(params) {},
|
||||||
stop:function(params) {
|
stop:function(params) {
|
||||||
const note = mapData.notes.find(note => note.id === params.el.id);
|
const note = mapData.notes.find(note => note.id === params.el.id);
|
||||||
|
|
||||||
@ -318,7 +323,7 @@ function initNode(el) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
instance.makeSource(el, {
|
instance.makeSource($noteBox[0], {
|
||||||
filter: ".endpoint",
|
filter: ".endpoint",
|
||||||
anchor: "Continuous",
|
anchor: "Continuous",
|
||||||
connectorStyle: { stroke: "#000", strokeWidth: 1 },
|
connectorStyle: { stroke: "#000", strokeWidth: 1 },
|
||||||
@ -328,31 +333,11 @@ function initNode(el) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
instance.makeTarget(el, {
|
instance.makeTarget($noteBox[0], {
|
||||||
dropOptions: { hoverClass: "dragHover" },
|
dropOptions: { hoverClass: "dragHover" },
|
||||||
anchor: "Continuous",
|
anchor: "Continuous",
|
||||||
allowLoopback: true
|
allowLoopback: true
|
||||||
});
|
});
|
||||||
|
|
||||||
// this is not part of the core demo functionality; it is a means for the Toolkit edition's wrapped
|
|
||||||
// version of this demo to find out about new nodes being added.
|
|
||||||
//
|
|
||||||
instance.fire("jsPlumbDemoNodeAdded", el);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function newNode(id, title, x, y) {
|
|
||||||
const $noteBox = $("<div>")
|
|
||||||
.addClass("note-box")
|
|
||||||
.prop("id", id)
|
|
||||||
.append($("<div>").addClass("handle"))
|
|
||||||
.append($("<span>").addClass("title").html(await linkService.createNoteLink(id, title)))
|
|
||||||
.append($("<div>").addClass("endpoint"))
|
|
||||||
.css("left", x + "px")
|
|
||||||
.css("top", y + "px");
|
|
||||||
|
|
||||||
instance.getContainer().appendChild($noteBox[0]);
|
|
||||||
|
|
||||||
initNode($noteBox[0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$addChildNotesButton.click(async () => {
|
$addChildNotesButton.click(async () => {
|
||||||
@ -372,7 +357,7 @@ $addChildNotesButton.click(async () => {
|
|||||||
|
|
||||||
mapData.notes.push(note);
|
mapData.notes.push(note);
|
||||||
|
|
||||||
await newNode(note.id, note.title, curX, curY);
|
await createNoteBox(note.id, note.title, curX, curY);
|
||||||
|
|
||||||
if (curX > 1000) {
|
if (curX > 1000) {
|
||||||
curX = 100;
|
curX = 100;
|
||||||
@ -396,8 +381,6 @@ $addChildNotesButton.click(async () => {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
relation.connectionId = connection.id;
|
|
||||||
|
|
||||||
connection.getOverlay("label").setLabel(relation.name);
|
connection.getOverlay("label").setLabel(relation.name);
|
||||||
connection.canvas.setAttribute("data-connection-id", connection.id);
|
connection.canvas.setAttribute("data-connection-id", connection.id);
|
||||||
}
|
}
|
||||||
|
@ -77,18 +77,6 @@
|
|||||||
|
|
||||||
path, .jtk-endpoint { cursor:pointer; }
|
path, .jtk-endpoint { cursor:pointer; }
|
||||||
|
|
||||||
.handle {
|
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
top: 0;
|
|
||||||
width: 15px;
|
|
||||||
height: 100%;
|
|
||||||
background-color: #aaa;
|
|
||||||
float: left;
|
|
||||||
cursor: move;
|
|
||||||
border-radius: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ui-contextmenu {
|
.ui-contextmenu {
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
}
|
}
|
@ -134,20 +134,12 @@ async function deleteRelation(req) {
|
|||||||
|
|
||||||
let attribute = await repository.getEntity(`SELECT * FROM attributes WHERE isDeleted = 0 AND noteId = ? AND type = 'relation' AND name = ? AND value = ?`, [sourceNoteId, name, targetNoteId]);
|
let attribute = await repository.getEntity(`SELECT * FROM attributes WHERE isDeleted = 0 AND noteId = ? AND type = 'relation' AND name = ? AND value = ?`, [sourceNoteId, name, targetNoteId]);
|
||||||
|
|
||||||
if (!attribute) {
|
if (attribute) {
|
||||||
attribute = new Attribute();
|
attribute.isDeleted = true;
|
||||||
attribute.noteId = sourceNoteId;
|
|
||||||
attribute.name = name;
|
|
||||||
attribute.type = 'relation';
|
|
||||||
attribute.value = targetNoteId;
|
|
||||||
|
|
||||||
await attribute.save();
|
await attribute.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
return attribute;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
updateNoteAttributes,
|
updateNoteAttributes,
|
||||||
updateNoteAttribute,
|
updateNoteAttribute,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user