@blinkk/editor
Version:
Structured content editor with live previews.
79 lines • 2.86 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.HistoryPart = void 0;
const section_1 = require("./section");
const selective_edit_1 = require("@blinkk/selective-edit");
const javascript_time_ago_1 = __importDefault(require("javascript-time-ago"));
class HistoryPart extends section_1.ContentSectionPart {
constructor(config) {
super(config);
this.timeAgo = new javascript_time_ago_1.default('en-US');
}
get canChangeSection() {
return true;
}
get label() {
return 'History';
}
get section() {
return 'history';
}
templateAction(editor) {
return selective_edit_1.html ``;
}
templateChanges(editor) {
if (!editor.state.file?.history) {
return selective_edit_1.html `<div class="le__part__content__history__title">
Change history
</div>
<div class="le__list">
<div class="le__list__item le__list__item--pad_small">
<div class="le__list__item__label">Change history unavailable.</div>
</div>
</div>`;
}
return selective_edit_1.html `<div class="le__part__content__history__title">
Change history
</div>
<div class="le__list">
${selective_edit_1.repeat(editor.state.file.history, change => change.hash, (change, index) => selective_edit_1.html `<div
class=${selective_edit_1.classMap({
le__list__item: true,
'le__list__item--pad': true,
'le__list__item--selected': index === 0,
le__change: true,
})}
>
<span class="material-icons">notes</span>
<div class="le__change__details">
<div class="le__change__meta">
<strong>${change.hash.slice(0, 5)}</strong>
by
<strong>${change.author?.name}</strong>
(${this.timeAgo.format(new Date(change.timestamp || new Date()))})
</div>
<div class="le__change__summary">${change.summary}</div>
</div>
</div>`)}
</div>`;
}
templateContent(editor) {
return selective_edit_1.html `<div class="le__part__content__history__title">
Current workspace
</div>
<div class="le__part__content__history__current le__list">
<div
class="le__list__item le__list__item--pad le__list__item--emphasis"
>
<span class="material-icons">dashboard</span>
${editor.state.workspace?.name}
</div>
</div>
${this.templateChanges(editor)}`;
}
}
exports.HistoryPart = HistoryPart;
//# sourceMappingURL=sectionHistory.js.map