Skip to content

Instantly share code, notes, and snippets.

@thomsbg
thomsbg / normalize.js
Last active April 10, 2020 21:51
normalize delta
function eachHardLine(delta, fn) {
let buffer = new Delta();
new Delta(delta).eachLine((line, attributes) => {
buffer = buffer.concat(line);
if (attributes.br) {
buffer.insert('\n', attributes);
} else {
fn(buffer, attributes);
buffer = new Delta();
}
query {
entryBody(uuid: "b4c7210f-0593-4ab2-85d9-abab343fcc09") {
components {
blockquote {
paragraphs {
ops
}
}
grouping {
layout
@thomsbg
thomsbg / schema.graphql
Last active May 7, 2020 21:53
No parent container
interface EntryRevision {
title: String
body: EntryBody
# etc
}
# A published unit of content
type Entry implements EntryRevision {
draft: EntryDraft
}
@thomsbg
thomsbg / fields.txt
Created May 7, 2020 22:36
Non-draftable fields from the content-api story schema
# applies to published revision only
"slug_prefix"
"comments_closed"
"comments_auto_closed_at"
# applies to draft revision only / story editor metadata
"hidden"
"embargoed"
"publish_scheduled_for"
"trashed_at"
@thomsbg
thomsbg / inline_input.graphql
Last active May 12, 2020 16:00
List + Association (Inline) Input patterns
input <%= association %>InlineInput {
connect: <%= association %>UniqueIdInput
create: <%= association %>CreateInput
createOrUpdate: <%= association %>CreateOrUpdateInlineInput
# Update-only. Should these be in a separate type?
update: <%= association %>UpdateInlineInput
disconnect: Boolean
}