code rearrangement
This commit is contained in:
+39
-9
@@ -82,13 +82,17 @@ function handleImageData(el, data, attr) {
|
||||
// onFormButtonClick: this.handleFormButtonClick
|
||||
// onQuoteClick: this.handleQuoteClick (optional)
|
||||
export function fullFormatter(style, data, values, key) {
|
||||
if (style == 'EX') {
|
||||
// attachments are handled elsewhere.
|
||||
if (!style) {
|
||||
// Unformatted.
|
||||
return values;
|
||||
}
|
||||
|
||||
if (style == 'HD') {
|
||||
// Hidden.
|
||||
return null;
|
||||
}
|
||||
|
||||
let el = Drafty.tagName(style);
|
||||
if (el) {
|
||||
const attr = Drafty.attrValue(style, data) || {};
|
||||
attr.key = key;
|
||||
switch (style) {
|
||||
@@ -140,10 +144,10 @@ export function fullFormatter(style, data, values, key) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
return React.createElement(el, attr, values);
|
||||
} else {
|
||||
if (!el) {
|
||||
return values;
|
||||
}
|
||||
return React.createElement(el, attr, values);
|
||||
};
|
||||
|
||||
// Converts Drafty object into a one-line preview. 'this' is set by the caller.
|
||||
@@ -151,9 +155,18 @@ export function fullFormatter(style, data, values, key) {
|
||||
// formatMessage: this.props.intl.formatMessage
|
||||
// messages: formatjs messages defined with defineMessages.
|
||||
export function previewFormatter(style, data, values, key) {
|
||||
if (!style) {
|
||||
// Unformatted.
|
||||
return values;
|
||||
}
|
||||
|
||||
if (style == 'HD') {
|
||||
// Hidden.
|
||||
return null;
|
||||
}
|
||||
|
||||
let el = Drafty.tagName(style);
|
||||
const attr = { key: key };
|
||||
if (el) {
|
||||
switch (style) {
|
||||
case 'BR':
|
||||
// Replace new line with a space.
|
||||
@@ -205,10 +218,10 @@ export function previewFormatter(style, data, values, key) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
return React.createElement(el, attr, values);
|
||||
} else {
|
||||
if (!el) {
|
||||
return values;
|
||||
}
|
||||
return React.createElement(el, attr, values);
|
||||
};
|
||||
|
||||
// Converts Drafty object into a quoted reply. 'this' is set by the caller.
|
||||
@@ -218,7 +231,7 @@ export function previewFormatter(style, data, values, key) {
|
||||
// authorizeURL: this.props.tinode.authorizeURL
|
||||
// onQuoteClick: this.handleQuoteClick (optional)
|
||||
export function quoteFormatter(style, data, values, key) {
|
||||
if (['BR', 'IM', 'MN', 'QQ'].includes(style)) {
|
||||
if (['BR', 'EX', 'IM', 'MN', 'QQ'].includes(style)) {
|
||||
let el = Drafty.tagName(style);
|
||||
let attr = Drafty.attrValue(style, data) || {};
|
||||
attr.key = key;
|
||||
@@ -240,6 +253,23 @@ export function quoteFormatter(style, data, values, key) {
|
||||
attr.className = 'reply-quote';
|
||||
attr.onClick = this.onQuoteClick;
|
||||
break;
|
||||
case 'EX':
|
||||
let fname;
|
||||
if (data) {
|
||||
if (data.mime == 'application/json') {
|
||||
// Ignore JSON attachments: they are form response payloads.
|
||||
return null;
|
||||
}
|
||||
// Clear inband data.
|
||||
data.val = null;
|
||||
fname = data.name;
|
||||
}
|
||||
if (!fname)
|
||||
fname = this.formatMessage(messages.drafty_attachment);
|
||||
}
|
||||
el = React.Fragment;
|
||||
values = [<i key="ex" className="material-icons">attachment</i>, fname];
|
||||
break;
|
||||
}
|
||||
return React.createElement(el, attr, values);
|
||||
}
|
||||
|
||||
+33
-8
@@ -450,13 +450,15 @@ function handleImageData(el, data, attr) {
|
||||
}
|
||||
|
||||
function fullFormatter(style, data, values, key) {
|
||||
if (style == 'EX') {
|
||||
if (!style) {
|
||||
return values;
|
||||
}
|
||||
|
||||
if (style == 'HD') {
|
||||
return null;
|
||||
}
|
||||
|
||||
let el = tinode_sdk__WEBPACK_IMPORTED_MODULE_2__.Drafty.tagName(style);
|
||||
|
||||
if (el) {
|
||||
const attr = tinode_sdk__WEBPACK_IMPORTED_MODULE_2__.Drafty.attrValue(style, data) || {};
|
||||
attr.key = key;
|
||||
|
||||
@@ -513,19 +515,27 @@ function fullFormatter(style, data, values, key) {
|
||||
break;
|
||||
}
|
||||
|
||||
return react__WEBPACK_IMPORTED_MODULE_0___default().createElement(el, attr, values);
|
||||
} else {
|
||||
if (!el) {
|
||||
return values;
|
||||
}
|
||||
|
||||
return react__WEBPACK_IMPORTED_MODULE_0___default().createElement(el, attr, values);
|
||||
}
|
||||
;
|
||||
function previewFormatter(style, data, values, key) {
|
||||
if (!style) {
|
||||
return values;
|
||||
}
|
||||
|
||||
if (style == 'HD') {
|
||||
return null;
|
||||
}
|
||||
|
||||
let el = tinode_sdk__WEBPACK_IMPORTED_MODULE_2__.Drafty.tagName(style);
|
||||
const attr = {
|
||||
key: key
|
||||
};
|
||||
|
||||
if (el) {
|
||||
switch (style) {
|
||||
case 'BR':
|
||||
el = (react__WEBPACK_IMPORTED_MODULE_0___default().Fragment);
|
||||
@@ -594,14 +604,19 @@ function previewFormatter(style, data, values, key) {
|
||||
break;
|
||||
}
|
||||
|
||||
return react__WEBPACK_IMPORTED_MODULE_0___default().createElement(el, attr, values);
|
||||
} else {
|
||||
if (!el) {
|
||||
return values;
|
||||
}
|
||||
|
||||
return react__WEBPACK_IMPORTED_MODULE_0___default().createElement(el, attr, values);
|
||||
}
|
||||
;
|
||||
function quoteFormatter(style, data, values, key) {
|
||||
if (['BR', 'IM', 'MN', 'QQ'].includes(style)) {
|
||||
if (style == 'EX') {
|
||||
console.log("quoteFormatter EX 1", data);
|
||||
}
|
||||
|
||||
let el = tinode_sdk__WEBPACK_IMPORTED_MODULE_2__.Drafty.tagName(style);
|
||||
let attr = tinode_sdk__WEBPACK_IMPORTED_MODULE_2__.Drafty.attrValue(style, data) || {};
|
||||
attr.key = key;
|
||||
@@ -635,6 +650,10 @@ function quoteFormatter(style, data, values, key) {
|
||||
return react__WEBPACK_IMPORTED_MODULE_0___default().createElement(el, attr, values);
|
||||
}
|
||||
|
||||
if (style == 'EX') {
|
||||
console.log("quoteFormatter EX 2", data);
|
||||
}
|
||||
|
||||
return previewFormatter.call(this, style, data, values, key);
|
||||
}
|
||||
|
||||
@@ -11439,10 +11458,16 @@ class SendMessage extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureComp
|
||||
formatMessage
|
||||
} = this.props.intl;
|
||||
const prompt = this.props.disabled ? formatMessage(messages.messaging_disabled) : this.props.messagePrompt ? formatMessage(messages[this.props.messagePrompt]) : formatMessage(messages.type_new_message);
|
||||
|
||||
if (this.props.replyTo) {
|
||||
console.log("Reply:", this.props.replyTo.content);
|
||||
}
|
||||
|
||||
const quote = this.props.replyTo ? tinode_sdk__WEBPACK_IMPORTED_MODULE_2__.Drafty.format(this.props.replyTo.content, _lib_formatters_js__WEBPACK_IMPORTED_MODULE_5__.quoteFormatter, {
|
||||
formatMessage: formatMessage,
|
||||
authorizeURL: this.props.tinode.authorizeURL
|
||||
}) : null;
|
||||
console.log("Quoted:", quote);
|
||||
return react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
||||
id: "send-message-wrapper"
|
||||
}, quote ? react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
||||
|
||||
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+9
-12
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user