Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
5ddbc5e
wip
Geliogabalus Feb 19, 2025
724b1a8
wip
Geliogabalus Feb 21, 2025
044af30
layer models
Geliogabalus Feb 23, 2025
af043f2
wip
Geliogabalus Feb 23, 2025
60bbcd9
update
Geliogabalus Feb 25, 2025
5832a22
fix
Geliogabalus Feb 25, 2025
bb09418
up
Geliogabalus Feb 25, 2025
9a9aeac
up
Geliogabalus Feb 26, 2025
6249685
up
Geliogabalus Feb 28, 2025
1a208bc
up
Geliogabalus Mar 2, 2025
309edaa
wip
Geliogabalus Mar 4, 2025
099cf81
up
Geliogabalus Mar 9, 2025
2f2c482
up
Geliogabalus Mar 18, 2025
62ed851
wip
Geliogabalus Mar 18, 2025
903e922
wip
Geliogabalus Mar 18, 2025
b491ea8
fix
Geliogabalus Mar 18, 2025
1533570
up
Geliogabalus Mar 19, 2025
0752076
up
Geliogabalus May 16, 2025
163c221
wip
Geliogabalus May 16, 2025
c66280b
wip
Geliogabalus May 29, 2025
c2dc6ae
wip
Geliogabalus Jun 5, 2025
0a2f047
up
Geliogabalus Jun 5, 2025
8a03a89
up
Geliogabalus Jun 6, 2025
d058bac
reset fix
Geliogabalus Jun 6, 2025
468a6c6
wip
Geliogabalus Jun 9, 2025
5083b69
up
Geliogabalus Jun 9, 2025
dab0da8
update
Geliogabalus Jun 16, 2025
58be262
up
Geliogabalus Jun 16, 2025
15ec945
tests start
Geliogabalus Jun 17, 2025
e4786f2
fixes and tests
Geliogabalus Jun 18, 2025
1487770
update
Geliogabalus Jun 29, 2025
bf9a4c8
wip
Geliogabalus Jul 10, 2025
7864d01
update
Geliogabalus Jul 11, 2025
4d8ed05
up
Geliogabalus Jul 11, 2025
4152946
refactor
Geliogabalus Jul 14, 2025
2c6c5d9
up
Geliogabalus Jul 14, 2025
29ca501
revert
Geliogabalus Jul 14, 2025
ec9a33a
up
Geliogabalus Jul 14, 2025
505fc50
up
Geliogabalus Jul 15, 2025
6eb29f1
wip
Geliogabalus Jul 16, 2025
a94376e
async removing
Geliogabalus Jul 17, 2025
ed79f8e
wip (probably doesn't work)
Geliogabalus Jul 21, 2025
8358fa8
up
Geliogabalus Jul 23, 2025
5e4b02b
up
Geliogabalus Jul 23, 2025
8328efe
wip
Geliogabalus Jul 23, 2025
34812b6
up
Geliogabalus Jul 24, 2025
d861c35
fix
Geliogabalus Jul 24, 2025
3c6aa1d
fix
Geliogabalus Jul 25, 2025
a852825
final
Geliogabalus Jul 25, 2025
8782e66
typings
Geliogabalus Jul 26, 2025
b08e3ec
up
Geliogabalus Jul 28, 2025
49f8a85
up
Geliogabalus Jul 28, 2025
c32030d
wip
Geliogabalus Jul 29, 2025
57f18b0
update
Geliogabalus Jul 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 38 additions & 9 deletions packages/joint-core/src/dia/Cell.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,15 @@ export const Cell = Model.extend({
}
}

this.trigger('remove', this, graph.attributes.cells, opt);
this.trigger('remove', this, graph.cellCollection, opt);

graph.stopBatch('remove');

return this;
},

toFront: function(opt) {
var graph = this.graph;
const { graph } = this;
if (graph) {
opt = defaults(opt || {}, { foregroundEmbeds: true });

Expand All @@ -261,12 +261,14 @@ export const Cell = Model.extend({

const sortedCells = opt.foregroundEmbeds ? cells : sortBy(cells, cell => cell.z());

const maxZ = graph.maxZIndex();
const layerId = this.layer();

const maxZ = graph.maxZIndex(layerId);
let z = maxZ - cells.length + 1;

const collection = graph.get('cells');
const layerCells = graph.getCellLayerCells(layerId);

let shouldUpdate = (collection.toArray().indexOf(sortedCells[0]) !== (collection.length - cells.length));
let shouldUpdate = (layerCells.indexOf(sortedCells[0]) !== (layerCells.length - cells.length));
if (!shouldUpdate) {
shouldUpdate = sortedCells.some(function(cell, index) {
return cell.z() !== z + index;
Expand All @@ -290,7 +292,7 @@ export const Cell = Model.extend({
},

toBack: function(opt) {
var graph = this.graph;
const { graph } = this;
if (graph) {
opt = defaults(opt || {}, { foregroundEmbeds: true });

Expand All @@ -304,11 +306,13 @@ export const Cell = Model.extend({

const sortedCells = opt.foregroundEmbeds ? cells : sortBy(cells, cell => cell.z());

let z = graph.minZIndex();
const layerId = this.layer();

let z = graph.minZIndex(layerId);

var collection = graph.get('cells');
const layerCells = graph.getCellLayerCells(layerId);

let shouldUpdate = (collection.toArray().indexOf(sortedCells[0]) !== 0);
let shouldUpdate = (layerCells.indexOf(sortedCells[0]) !== 0);
if (!shouldUpdate) {
shouldUpdate = sortedCells.some(function(cell, index) {
return cell.z() !== z + index;
Expand Down Expand Up @@ -942,6 +946,31 @@ export const Cell = Model.extend({
.getPointRotatedAroundCenter(this.angle(), x, y)
// Transform the absolute position into relative
.difference(this.position());
},

layer: function(layerId, opt) {
// if strictly null unset the layer
if (layerId === null) {
return this.unset('layer', opt);
}

// if undefined return the current layer id
if (layerId === undefined) {
layerId = this.get('layer') || null;
// If the cell is part of a graph, use the graph's default cell layer.
if (layerId == null && this.graph) {
layerId = this.graph.getDefaultCellLayer().id;
}

return layerId;
}

// otherwise set the layer id
if (!isString(layerId)) {
throw new Error('Layer id must be a string.');
}

return this.set('layer', layerId, opt);
}

}, {
Expand Down
7 changes: 6 additions & 1 deletion packages/joint-core/src/dia/ElementView.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,12 @@ export const ElementView = CellView.extend({
element.startBatch('to-front');

// Bring the model to the front with all his embeds.
element.toFront({ deep: true, ui: true });
if (paper.options.useLayersForEmbedding) {
// don't use deep: true, because embedded cells are already on top of the container because of the layer
element.toFront({ ui: true });
} else {
element.toFront({ deep: true, ui: true });
}

// Note that at this point cells in the collection are not sorted by z index (it's running in the batch, see
// the dia.Graph._sortOnChangeZ), so we can't assume that the last cell in the collection has the highest z.
Expand Down
Loading
Loading