mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 15:36:16 -04:00
chat: Deprecate the chat
export from the client-side chat module
This commit is contained in:
parent
2e684476cb
commit
2d3418caf7
2 changed files with 23 additions and 14 deletions
|
@ -97,6 +97,7 @@
|
||||||
`src/node/handler/PadMessageHandler.js` is deprecated.
|
`src/node/handler/PadMessageHandler.js` is deprecated.
|
||||||
* Client-side:
|
* Client-side:
|
||||||
* The `chat` global variable is deprecated.
|
* The `chat` global variable is deprecated.
|
||||||
|
* The `chat` export in `src/static/js/chat.js` is deprecated.
|
||||||
* The `pad.determineChatVisibility()` method was removed.
|
* The `pad.determineChatVisibility()` method was removed.
|
||||||
* The `pad.determineChatAndUsersVisibility()` method was removed.
|
* The `pad.determineChatAndUsersVisibility()` method was removed.
|
||||||
* Returning `true` from a `handleMessageSecurity` hook function is deprecated;
|
* Returning `true` from a `handleMessageSecurity` hook function is deprecated;
|
||||||
|
|
|
@ -25,7 +25,7 @@ const padeditor = require('./pad_editor').padeditor;
|
||||||
// Removes diacritics and lower-cases letters. https://stackoverflow.com/a/37511463
|
// Removes diacritics and lower-cases letters. https://stackoverflow.com/a/37511463
|
||||||
const normalize = (s) => s.normalize('NFD').replace(/[\u0300-\u036f]/g, '').toLowerCase();
|
const normalize = (s) => s.normalize('NFD').replace(/[\u0300-\u036f]/g, '').toLowerCase();
|
||||||
|
|
||||||
exports.chat = (() => {
|
const chat = (() => {
|
||||||
let isStuck = false;
|
let isStuck = false;
|
||||||
let userAndChat = false;
|
let userAndChat = false;
|
||||||
let chatMentions = 0;
|
let chatMentions = 0;
|
||||||
|
@ -305,35 +305,43 @@ exports.chat = (() => {
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
Object.defineProperty(exports, 'chat', {
|
||||||
|
get: () => {
|
||||||
|
padutils.warnDeprecated(
|
||||||
|
'chat.chat is deprecated and will be removed in a future version of Etherpad');
|
||||||
|
return chat;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
exports.aceKeyEvent = (hookName, {evt}) => {
|
exports.aceKeyEvent = (hookName, {evt}) => {
|
||||||
const {altC} = window.clientVars.padShortcutEnabled;
|
const {altC} = window.clientVars.padShortcutEnabled;
|
||||||
if (evt.type !== 'keydown' || !evt.altKey || evt.keyCode !== 67 || !altC) return;
|
if (evt.type !== 'keydown' || !evt.altKey || evt.keyCode !== 67 || !altC) return;
|
||||||
evt.target.blur();
|
evt.target.blur();
|
||||||
exports.chat.show();
|
chat.show();
|
||||||
exports.chat.focus();
|
chat.focus();
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handleClientMessage_CHAT_MESSAGE = (hookName, {msg}) => {
|
exports.handleClientMessage_CHAT_MESSAGE = (hookName, {msg}) => {
|
||||||
exports.chat.addMessage(msg.message, true, false);
|
chat.addMessage(msg.message, true, false);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handleClientMessage_CHAT_MESSAGES = (hookName, {msg}) => {
|
exports.handleClientMessage_CHAT_MESSAGES = (hookName, {msg}) => {
|
||||||
for (let i = msg.messages.length - 1; i >= 0; i--) {
|
for (let i = msg.messages.length - 1; i >= 0; i--) {
|
||||||
exports.chat.addMessage(msg.messages[i], true, true);
|
chat.addMessage(msg.messages[i], true, true);
|
||||||
}
|
}
|
||||||
if (!exports.chat.gotInitalMessages) {
|
if (!chat.gotInitalMessages) {
|
||||||
exports.chat.scrollDown();
|
chat.scrollDown();
|
||||||
exports.chat.gotInitalMessages = true;
|
chat.gotInitalMessages = true;
|
||||||
exports.chat.historyPointer = clientVars.chatHead - msg.messages.length;
|
chat.historyPointer = clientVars.chatHead - msg.messages.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
// messages are loaded, so hide the loading-ball
|
// messages are loaded, so hide the loading-ball
|
||||||
$('#chatloadmessagesball').css('display', 'none');
|
$('#chatloadmessagesball').css('display', 'none');
|
||||||
|
|
||||||
// there are less than 100 messages or we reached the top
|
// there are less than 100 messages or we reached the top
|
||||||
if (exports.chat.historyPointer <= 0) {
|
if (chat.historyPointer <= 0) {
|
||||||
$('#chatloadmessagesbutton').css('display', 'none');
|
$('#chatloadmessagesbutton').css('display', 'none');
|
||||||
} else {
|
} else {
|
||||||
// there are still more messages, re-show the load-button
|
// there are still more messages, re-show the load-button
|
||||||
|
@ -342,14 +350,14 @@ exports.handleClientMessage_CHAT_MESSAGES = (hookName, {msg}) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.postAceInit = async (hookName, {clientVars, pad}) => {
|
exports.postAceInit = async (hookName, {clientVars, pad}) => {
|
||||||
exports.chat.init(pad);
|
chat.init(pad);
|
||||||
|
|
||||||
if (padcookie.getPref('chatAlwaysVisible')) {
|
if (padcookie.getPref('chatAlwaysVisible')) {
|
||||||
exports.chat.stickToScreen(true);
|
chat.stickToScreen(true);
|
||||||
$('#options-stickychat').prop('checked', true);
|
$('#options-stickychat').prop('checked', true);
|
||||||
}
|
}
|
||||||
if (padcookie.getPref('chatAndUsers')) {
|
if (padcookie.getPref('chatAndUsers')) {
|
||||||
exports.chat.chatAndUsers(true);
|
chat.chatAndUsers(true);
|
||||||
$('#options-chatandusers').prop('checked', true);
|
$('#options-chatandusers').prop('checked', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,7 +380,7 @@ exports.postAceInit = async (hookName, {clientVars, pad}) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clientVars.readonly) {
|
if (clientVars.readonly) {
|
||||||
exports.chat.hide();
|
chat.hide();
|
||||||
$('#chatinput').attr('disabled', true);
|
$('#chatinput').attr('disabled', true);
|
||||||
$('#options-chatandusers').parent().hide();
|
$('#options-chatandusers').parent().hide();
|
||||||
$('#options-stickychat').parent().hide();
|
$('#options-stickychat').parent().hide();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue