Skip to content

Latest commit

 

History

History
132 lines (91 loc) · 5.73 KB

rich_text.md

File metadata and controls

132 lines (91 loc) · 5.73 KB

Rich text

Many resources, including messages, documents, and comments, represent their content as rich text in HTML. Rich text content may contain lists, block quotes, simple formatting, and inline attachments such as mentions, images, and files.

Working with rich text HTML

If your application reads Basecamp rich text content, it must be able to process HTML. Use a web view component to render rich text content unmodified. Or, if your application needs a plain-text representation of rich text content, first decode any HTML entities, then replace <br> tags with line breaks, and finally strip the remaining HTML tags.

Similarly, if your application writes rich text content, it must be able to generate well-formed HTML. At a minimum, this means properly encoding HTML entities and replacing line breaks with <br> tags.

Applications that modify existing rich text content should take special care not to discard any formatting or attachments during processing. Consider using a full HTML parser to manipulate rich text content. Libraries such as Nokogiri (Ruby) and Cheerio (Node.js) are good fits for this scenario.

Allowed HTML tags

You may use the following standard HTML tags in rich text content: div, h1, br, strong, em, strike, a (with an href attribute), pre, ol, ul, li, and blockquote. Any other tags will be removed automatically.

The special <bc-attachment> tag allows you to insert an inline attachment. Each <bc-attachment> has an sgid attribute which points to the attachable_sgid attribute of an attachable Basecamp resource. Your application will receive a rendered representation of the attachable resource inside the <bc-attachment> tag in API responses.

Inserting a mention

Mentions in rich text content are attachments that reference a Person on the current Project. When you submit rich text content with mentions, Basecamp delivers a special notification to each mentioned person.

Create a mention in Basecamp's rich text editor by typing "@" and selecting a person from the drop-down list. Create mentions with the API by inserting a <bc-attachment> tag with an sgid attribute pointing to the person's attachable_sgid.

For example, to mention this person:

  {
    "id": 1007299208,
    "name": "Victor Cooper",
    "attachable_sgid": "BAh7CEkiCG..."
  }

Submit this rich text content:

  <bc-attachment sgid="BAh7CEkiCG..."></bc-attachment>

The Basecamp API will return an expanded representation similar to the following:

  <bc-attachment sgid="BAh7CEkiCG..." content-type="application/vnd.basecamp.mention">
    <figure>
      <img srcset="..." src="..." class="avatar" ...