Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a section and remove latlng and leaflet usage from impress&draw c… #10921

Merged
merged 3 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
153 changes: 78 additions & 75 deletions browser/src/canvas/sections/CommentListSection.ts

Large diffs are not rendered by default.

100 changes: 50 additions & 50 deletions browser/src/canvas/sections/CommentSection.ts

Large diffs are not rendered by default.

25 changes: 6 additions & 19 deletions browser/src/control/Control.JSDialogBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -1832,26 +1832,13 @@ L.Control.JSDialogBuilder = L.Control.extend({
return false;
},

_createComment: function(container, data, isRoot) {
_createComment: function(container, data) {
// Create annotation copy and add it into the container.
container.appendChild(data.annotation.sectionProperties.container);

var annotation = new app.definitions.Comment(data.data, data.id === 'new' ? {noMenu: true} : {}, this);
annotation.context = data.annotation.containerObject.context;
annotation.documentTopLeft = data.annotation.containerObject.documentTopLeft;
annotation.containerObject = data.annotation.containerObject;
annotation.sectionProperties.section = annotation;
annotation.sectionProperties.commentListSection = data.annotation.sectionProperties.commentListSection;
annotation.onInitialize();

if (app.isCommentEditingAllowed())
annotation.sectionProperties.menu.isRoot = isRoot;

container.appendChild(annotation.sectionProperties.container);

annotation.show();
annotation.update();
annotation.setExpanded();
annotation.hideMarker();
data.annotation.show();
data.annotation.update();
data.annotation.setExpanded();
},

_rootCommentControl: function(parentContainer, data, builder) {
Expand All @@ -1873,7 +1860,7 @@ L.Control.JSDialogBuilder = L.Control.extend({

container.annotation = data.annotation;
container.id = data.id;
builder._createComment(container, data, true);
builder._createComment(container, data);
if (data.children.length > 1 && mainContainer.id !== 'comment-thread' + data.id)
{
var numberOfReplies = data.children.length - 1;
Expand Down
2 changes: 1 addition & 1 deletion browser/src/control/Parts.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ L.Map.include({
isTheSamePart =
app.calc.partHashes[docLayer._prevSelectedPart] === app.calc.partHashes[part];
} else if ((docType === 'presentation' || docType === 'drawing')) {
if (docLayer._prevSelectedPart !== undefined && part < app.impress.partList.length)
if (docLayer._prevSelectedPart !== undefined && part < app.impress.partList.length && app.impress.partList[docLayer._prevSelectedPart])
isTheSamePart = app.impress.partList[docLayer._prevSelectedPart].hash === app.impress.partList[part].hash;
} else if (docType !== 'text') {
console.error('Unknown docType: ' + docType);
Expand Down
13 changes: 8 additions & 5 deletions browser/src/layer/tile/ImpressTileLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Impress tile layer is used to display a presentation document
*/

/* global app $ L */
/* global app $ L cool */

L.ImpressTileLayer = L.CanvasTileLayer.extend({

Expand Down Expand Up @@ -108,14 +108,17 @@ L.ImpressTileLayer = L.CanvasTileLayer.extend({
}
},

newAnnotation: function (comment) {
newAnnotation: function (commentData) {
var ratio = this._tileWidthTwips / this._tileSize;
var docTopLeft = app.sectionContainer.getDocumentTopLeft();
docTopLeft = [docTopLeft[0] * ratio, docTopLeft[1] * ratio];
comment.anchorPos = [docTopLeft[0], docTopLeft[1]];
comment.rectangle = [docTopLeft[0], docTopLeft[1], 566, 566];
commentData.anchorPos = [docTopLeft[0], docTopLeft[1]];
commentData.rectangle = [docTopLeft[0], docTopLeft[1], 566, 566];

commentData.parthash = app.impress.partList[this._selectedPart].hash;

const comment = new cool.Comment(commentData, {}, app.sectionContainer.getSectionWithName(L.CSections.CommentList.name));

comment.parthash = app.impress.partList[this._selectedPart].hash;
var annotation = app.sectionContainer.getSectionWithName(L.CSections.CommentList.name).add(comment);
app.sectionContainer.getSectionWithName(L.CSections.CommentList.name).modify(annotation);
},
Expand Down
14 changes: 8 additions & 6 deletions browser/src/layer/tile/WriterTileLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,21 @@
* Writer tile layer is used to display a text document
*/

/* global app GraphicSelection */
/* global app GraphicSelection cool */
L.WriterTileLayer = L.CanvasTileLayer.extend({

newAnnotation: function (comment) {
newAnnotation: function (commentData) {
const comment = new cool.Comment(commentData, {}, app.sectionContainer.getSectionWithName(L.CSections.CommentList.name));

if (app.file.textCursor.visible) {
comment.anchorPos = [app.file.textCursor.rectangle.x2, app.file.textCursor.rectangle.y1];
comment.sectionProperties.data.anchorPos = [app.file.textCursor.rectangle.x2, app.file.textCursor.rectangle.y1];
} else if (GraphicSelection.hasActiveSelection()) {
// An image is selected, then guess the anchor based on the graphic selection.
comment.anchorPos = [GraphicSelection.rectangle.x1, GraphicSelection.rectangle.y2];
comment.sectionProperties.data.anchorPos = [GraphicSelection.rectangle.x1, GraphicSelection.rectangle.y2];
}

var annotation = app.sectionContainer.getSectionWithName(L.CSections.CommentList.name).add(comment);
app.sectionContainer.getSectionWithName(L.CSections.CommentList.name).modify(annotation);
app.sectionContainer.getSectionWithName(L.CSections.CommentList.name).add(comment);
app.sectionContainer.getSectionWithName(L.CSections.CommentList.name).modify(comment);
},

beforeAdd: function (map) {
Expand Down