add animal emojis to rich text cursors' tooltips

pull/1/head
ansuz 3 years ago
parent 8a1f6d66cf
commit 840a16a563

@ -3,7 +3,9 @@ define([
'/common/common-ui-elements.js',
'/common/common-interface.js',
'/bower_components/chainpad/chainpad.dist.js',
], function ($, UIElements, UI, ChainPad) {
'/customize/messages.js',
'/common/inner/common-mediatag.js',
], function ($, UIElements, UI, ChainPad, Messages, MT) {
var Cursor = {};
Cursor.isCursor = function (el) {
@ -35,13 +37,20 @@ define([
$(el).remove();
};
Cursor.create = function (inner, hjsonToDom, cursorModule) {
Cursor.create = function (inner, hjsonToDom, cursorModule, uid) {
var exp = {};
var cursors = {};
// XXX despite the name of this function this doesn't actually render as a tippy tooltip
// that means that emojis will use the system font that shows up in native tooltips
// so this might be of limited value/aesthetic appeal compared to other apps' cursors
var makeTippy = function (cursor) {
return cursor.name;
//return cursor.name;
if (typeof(cursor.uid) === 'string' && (!cursor.name || cursor.name === Messages.anonymous)) {
return MT.getPseudorandomAnimal(cursor.uid) + ' ' + Messages.anonymous;
}
return cursor.name || Messages.anonymous;
};
var makeCursor = function (id, cursor) {
@ -138,6 +147,12 @@ define([
var cursorObj = data.cursor;
if (!cursorObj.selectionStart) { return; }
if (cursorObj.name === Messages.anonymous) {
// save a little bit of data from going over the wire...
// remote clients will interpret this as Messages.anonymous (in their UI language)
cursorObj.name = '';
cursorObj.uid = uid;
}
// 1. Transform the cursor to get the offset relative to our doc
// 2. Turn it into a range

@ -678,6 +678,7 @@ define([
var metadataMgr = framework._.sfCommon.getMetadataMgr();
var privateData = metadataMgr.getPrivateData();
var myData = metadataMgr.getUserData();
var common = framework._.sfCommon;
var APP = window.APP;
@ -704,7 +705,7 @@ define([
var cursor = module.cursor = Cursor(inner);
// Display other users cursor
var cursors = Cursors.create(inner, hjsonToDom, cursor);
var cursors = Cursors.create(inner, hjsonToDom, cursor, myData.uid);
var openLink = function(e) {
var el = e.currentTarget;

Loading…
Cancel
Save