Skip to main content
Version: 1.x.x

Adding Quip Comments

It's easy to support cross-platform Quip commenting in your app. To enable comments for a Record, you'll need to override two quip.apps.Record methods:

Then, add the CommentsTrigger React component and pass in the relevant record. This component renders a standard Quip comment bubble that automatically updates with the current number of comments.

Each Record can have its own Quip comment thread.

If you want to customize the appearance of the trigger, you can make your own custom trigger with these Record methods:

A full example of an app with comment records:

import React, { Component } from "react";
import quip from "quip-apps-api";

class RootRecord extends quip.apps.RootRecord {
static getProperties() {
return {
commentableRecord: CommentableRecord,
};
}

static getDefaultProperties(): {[property: string]: any} {
return {
commentableRecord: {},
};
}

commentableRecord(): CommentableRecord {
return this.get("commentableRecord") as CommentableRecord;
}
}

quip.apps.registerClass(RootRecord, "root-record");

class CommentableRecord extends quip.apps.Record {
static getProperties = () => ({})

node: Element | null = null;

getDom() {
if (!this.node) {
throw new Error("Attempt to call getDom before node was set");
}
return this.node;
}

setDom(node: Element | null) {
this.node = node;
}

supportsComments() {
return true;
}
}

quip.apps.registerClass(CommentableRecord, "commentable-record");

interface MainProps {
rootRecord: RootRecord;
}

class Main extends Component<MainProps> {
render() {
const {rootRecord} = this.props;
const commentableRecord = rootRecord.commentableRecord()
return (
<div ref={(c) => commentableRecord.setDom(c)}>
Comment
<quip.apps.ui.CommentsTrigger
record={commentableRecord}
showEmpty={true}
/>
</div>
);
}
}

quip.apps.initialize({
initializationCallback: (
rootNode: Element,
params: {
isCreation: boolean;
creationUrl?: string;
}
) => {
const rootRecord = quip.apps.getRootRecord() as RootEntity;
ReactDOM.render(
<Main rootRecord={rootRecord}/>,
rootNode);
},
});