2019-12-17 05:06:41 +08:00
|
|
|
import React, { Component } from 'react';
|
2018-12-13 04:10:27 +08:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { Session } from 'meteor/session';
|
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
|
|
|
import injectWbResizeEvent from '/imports/ui/components/presentation/resize-wrapper/component';
|
|
|
|
import Button from '/imports/ui/components/button/component';
|
2019-03-29 02:47:11 +08:00
|
|
|
import NoteService from './service';
|
2018-12-13 04:10:27 +08:00
|
|
|
import { styles } from './styles';
|
|
|
|
|
|
|
|
const intlMessages = defineMessages({
|
|
|
|
hideNoteLabel: {
|
|
|
|
id: 'app.note.hideNoteLabel',
|
|
|
|
description: 'Label for hiding note button',
|
|
|
|
},
|
2019-01-10 02:06:23 +08:00
|
|
|
title: {
|
|
|
|
id: 'app.note.title',
|
|
|
|
description: 'Title for the shared notes',
|
|
|
|
},
|
2019-02-24 06:38:58 +08:00
|
|
|
tipLabel: {
|
|
|
|
id: 'app.note.tipLabel',
|
|
|
|
description: 'Label for tip on how to escape iframe',
|
|
|
|
},
|
2018-12-13 04:10:27 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
const propTypes = {
|
2019-03-29 02:47:11 +08:00
|
|
|
isLocked: PropTypes.bool.isRequired,
|
2018-12-13 04:10:27 +08:00
|
|
|
intl: PropTypes.shape({
|
|
|
|
formatMessage: PropTypes.func.isRequired,
|
|
|
|
}).isRequired,
|
|
|
|
};
|
|
|
|
|
2019-12-17 05:06:41 +08:00
|
|
|
class Note extends Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
2018-12-13 04:10:27 +08:00
|
|
|
|
2019-12-17 05:06:41 +08:00
|
|
|
this.noteURL = NoteService.getNoteURL();
|
|
|
|
this.readOnlyURL = NoteService.getReadOnlyURL();
|
|
|
|
}
|
2018-12-13 04:10:27 +08:00
|
|
|
|
2019-12-17 05:06:41 +08:00
|
|
|
componentWillUnmount() {
|
|
|
|
const revs = NoteService.getRevs();
|
|
|
|
NoteService.setLastRevs(revs);
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
isLocked,
|
|
|
|
intl,
|
|
|
|
isRTL,
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
const url = isLocked ? this.readOnlyURL : this.noteURL;
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
data-test="note"
|
|
|
|
className={styles.note}
|
|
|
|
>
|
|
|
|
<header className={styles.header}>
|
|
|
|
<div
|
|
|
|
data-test="noteTitle"
|
|
|
|
className={styles.title}
|
|
|
|
>
|
|
|
|
<Button
|
|
|
|
onClick={() => {
|
|
|
|
Session.set('openPanel', 'userlist');
|
2021-04-27 07:04:34 +08:00
|
|
|
window.dispatchEvent(new Event('panelChanged'));
|
2019-12-17 05:06:41 +08:00
|
|
|
}}
|
2020-07-21 05:19:24 +08:00
|
|
|
data-test="hideNoteLabel"
|
2019-12-17 05:06:41 +08:00
|
|
|
aria-label={intl.formatMessage(intlMessages.hideNoteLabel)}
|
|
|
|
label={intl.formatMessage(intlMessages.title)}
|
2020-07-21 05:19:24 +08:00
|
|
|
icon={isRTL ? 'right_arrow' : 'left_arrow'}
|
2019-12-17 05:06:41 +08:00
|
|
|
className={styles.hideBtn}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</header>
|
|
|
|
<iframe
|
|
|
|
title="etherpad"
|
|
|
|
src={url}
|
|
|
|
aria-describedby="sharedNotesEscapeHint"
|
|
|
|
/>
|
|
|
|
<span id="sharedNotesEscapeHint" className={styles.hint} aria-hidden>
|
|
|
|
{intl.formatMessage(intlMessages.tipLabel)}
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2018-12-13 04:10:27 +08:00
|
|
|
|
|
|
|
Note.propTypes = propTypes;
|
|
|
|
|
|
|
|
export default injectWbResizeEvent(injectIntl(Note));
|