Skip to content

Commit

Permalink
Fix initialization in Write
Browse files Browse the repository at this point in the history
  • Loading branch information
Lionel Laské committed May 14, 2024
1 parent f048a60 commit d34266d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 49 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Alignment issue in Abacus #1607
- Blank screen on iOS when opening a PDF #1618
- Journal instance pop up remain after launching a PDF or an external app #1619
- Welcome message not displayed in Write activity #1617

## [1.8.0] - 2024-04-10
### Added
Expand Down
97 changes: 48 additions & 49 deletions activities/Write.activity/js/activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,56 +79,55 @@ define([
document.getElementById(20).title = l10n.get("ExportToPdf");
document.getElementById(21).title = l10n.get("ExportToDoc");
document.getElementById(22).title = l10n.get("ExportToOdt");
});

if (!environment.objectId && !environment.sharedId) {
// New instance
// Intentionally added setTimeout to allow locale.ini file to be loaded
setTimeout(function(){
editor.setContents([
{insert: l10n.get('Welcome',{username: environment.user.name}) + '\n' , attributes: { size: "40px" , color : environment.user.colorvalue.stroke , bold: true }},
]);
var length = editor.getLength();
editor.clipboard.dangerouslyPasteHTML(length,l10n.get('Write'));
length = editor.getLength();
editor.clipboard.dangerouslyPasteHTML(length,l10n.get('Writefeatures'));
length = editor.getLength();
editor.clipboard.dangerouslyPasteHTML(length,l10n.get('Enjoy'));
length = editor.getLength();
editor.clipboard.dangerouslyPasteHTML(length,"<br></br>");
length = editor.getLength();
editor.updateContents(
new Delta()
.retain(editor.getSelection().index+1)
.insert({
image: window.initialImageDataUrl
})
);
},200);
} else {
// Existing instance
activity.getDatastoreObject().loadAsText(function(error, metadata, data) {
if (error==null && data!=null) {
var delta = JSON.parse(data);
console.log(delta);
editor.setContents(delta);
}
});
}
// Shared instances
if (environment.sharedId) {
console.log("Shared instance");

// Hide GUI of undo and redo for non host users
document.getElementById("edit-undo").style.display = "none";
document.getElementById("edit-redo").style.display = "none";
document.getElementById("shared-button").click();
presence = activity.getPresenceObject(function(error, network) {
network.onDataReceived(onNetworkDataReceived);
network.onSharedActivityUserChanged(onNetworkUserChanged);
});
}

if (!environment.objectId && !environment.sharedId) {
// New instance
// Intentionally added setTimeout to allow locale.ini file to be loaded
setTimeout(function(){
editor.setContents([
{insert: l10n.get('Welcome',{username: environment.user.name}) + '\n' , attributes: { size: "40px" , color : environment.user.colorvalue.stroke , bold: true }},
]);
var length = editor.getLength();
editor.clipboard.dangerouslyPasteHTML(length,l10n.get('Write'));
length = editor.getLength();
editor.clipboard.dangerouslyPasteHTML(length,l10n.get('Writefeatures'));
length = editor.getLength();
editor.clipboard.dangerouslyPasteHTML(length,l10n.get('Enjoy'));
length = editor.getLength();
editor.clipboard.dangerouslyPasteHTML(length,"<br></br>");
length = editor.getLength();
editor.updateContents(
new Delta()
.retain(editor.getSelection().index+1)
.insert({
image: window.initialImageDataUrl
})
);
},200);
} else {
// Existing instance
activity.getDatastoreObject().loadAsText(function(error, metadata, data) {
if (error==null && data!=null) {
var delta = JSON.parse(data);
console.log(delta);
editor.setContents(delta);
}
});
}
// Shared instances
if (environment.sharedId) {
console.log("Shared instance");

// Hide GUI of undo and redo for non host users
document.getElementById("edit-undo").style.display = "none";
document.getElementById("edit-redo").style.display = "none";
document.getElementById("shared-button").click();
presence = activity.getPresenceObject(function(error, network) {
network.onDataReceived(onNetworkDataReceived);
network.onSharedActivityUserChanged(onNetworkUserChanged);
});
}
});
});

// Save in Journal on Stop
Expand Down

0 comments on commit d34266d

Please sign in to comment.