This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/widgets/embedded-post.js.es6
Sam 4d71356e52 FIX: quoting a section inside expanded reply misattributed
1. expand "in reply to"
2. select text
3. quote reply

Was incorrectly attributed to parent post
2016-03-30 17:38:28 +11:00

45 lines
1.3 KiB
JavaScript

import RawHtml from 'discourse/widgets/raw-html';
import { createWidget } from 'discourse/widgets/widget';
import { h } from 'virtual-dom';
import { iconNode } from 'discourse/helpers/fa-icon';
import DiscourseURL from 'discourse/lib/url';
createWidget('post-link-arrow', {
html(attrs) {
if (attrs.above) {
return h('a.post-info.arrow', {
attributes: { title: I18n.t('topic.jump_reply_up') }
}, iconNode('arrow-up'));
} else {
return h('a.post-info.arrow', {
attributes: { title: I18n.t('topic.jump_reply_down') }
}, iconNode('arrow-down'));
}
},
click() {
DiscourseURL.routeTo(this.attrs.shareUrl);
}
});
export default createWidget('embedded-post', {
buildKey: attrs => `embedded-post-${attrs.id}`,
html(attrs, state) {
return [
h('div.reply', {attributes: {'data-post-id': attrs.id}}, [
h('div.row', [
this.attach('post-avatar', attrs),
h('div.topic-body', [
h('div.topic-meta-data', [
this.attach('poster-name', attrs),
this.attach('post-link-arrow', { above: state.above, shareUrl: attrs.shareUrl })
]),
new RawHtml({html: `<div class='cooked'>${attrs.cooked}</div>`})
])
])
])
];
}
});