element
+ if (!textAreaEl || !preEl) return;
+
+ const hasHorizontalScrollbar =
+ textAreaEl.scrollWidth > textAreaEl.clientWidth;
+ const additionalHeight = hasHorizontalScrollbar ? 30 : 0;
+
+ textAreaEl.style.height = "auto";
+ textAreaEl.style.height = `${textAreaEl.scrollHeight + additionalHeight}px`;
+ preEl.style.height = `${textAreaEl.scrollHeight + additionalHeight}px`;
+ }, [textAreaRef, highlightedElementRef]);
+
+ useEffect(() => {
+ const resizeListener = () => {
+ syncHeight();
+ };
+
+ window.addEventListener("resize", resizeListener);
+
+ return () => window.removeEventListener("resize", resizeListener);
+ });
+
+ useEffect(() => {
+ syncHeight();
+ syncScroll();
+ }, [content, syncScroll, syncHeight]);
+
+ const handleChange = (evt: ChangeEvent) => {
+ setContent(evt.target.value);
+ };
+
+ const handleKeyDown = (evt: KeyboardEvent) => {
+ if (!textAreaRef.current) return;
+
+ if (evt.key === "Tab") {
+ evt.preventDefault();
+ const { selectionStart } = evt.currentTarget;
+ let newCursorPos;
+ let newContent;
+
+ if (evt.shiftKey) {
+ // The previous character has to be a tab
+ if (content.substring(selectionStart - 1, selectionStart) !== "\t") {
+ return;
+ }
+
+ newContent = `${content.substring(
+ 0,
+ selectionStart - 1,
+ )}${content.substring(selectionStart)}`;
+
+ newCursorPos = selectionStart - 1;
+ } else {
+ newContent = `${content.substring(
+ 0,
+ selectionStart,
+ )}\t${content.substring(selectionStart)}`;
+ newCursorPos = selectionStart + 1;
+ }
+
+ setContent(newContent);
+
+ // Once state is updated, the cursor is pushed to the end of the string, which isn't ideal
+ // if the indentation is made before the end of the string.
+ // Doing this helps to preserve the cursor location.
+ textAreaRef.current.value = newContent;
+ textAreaRef.current.selectionStart = newCursorPos;
+ textAreaRef.current.selectionEnd = newCursorPos;
+ }
+ };
+
+ return (
+
+
+
+
+ {content}
+
+
+ );
+};
diff --git a/blocks/code/src/icons.tsx b/blocks/code/src/icons.tsx
new file mode 100644
index 0000000..95c754d
--- /dev/null
+++ b/blocks/code/src/icons.tsx
@@ -0,0 +1,32 @@
+export const CopyIcon = ({ size = 14 }) => {
+ return (
+
+ );
+};
diff --git a/blocks/code/src/index.ts b/blocks/code/src/index.ts
new file mode 100644
index 0000000..6eb172a
--- /dev/null
+++ b/blocks/code/src/index.ts
@@ -0,0 +1,8 @@
+/* eslint-disable canonical/filename-no-index -- @todo rename file */
+
+/**
+ * Entrypoint of the Block Component.
+ */
+import { App } from "./app";
+
+export default App;
diff --git a/blocks/code/src/property-ids.ts b/blocks/code/src/property-ids.ts
new file mode 100644
index 0000000..014ae16
--- /dev/null
+++ b/blocks/code/src/property-ids.ts
@@ -0,0 +1,8 @@
+export const propertyIds = {
+ caption:
+ "https://blockprotocol.org/@blockprotocol/types/property-type/caption/" as const,
+ content:
+ "https://blockprotocol.org/@blockprotocol/types/property-type/textual-content/" as const,
+ language:
+ "https://blockprotocol.org/@hash/types/property-type/code-block-language/" as const,
+};
diff --git a/blocks/code/src/types/generated/block-entity.ts b/blocks/code/src/types/generated/block-entity.ts
new file mode 100644
index 0000000..9c678dc
--- /dev/null
+++ b/blocks/code/src/types/generated/block-entity.ts
@@ -0,0 +1,55 @@
+/**
+ * This file was automatically generated – do not edit it.
+ */
+
+import { Entity } from "@blockprotocol/graph";
+
+export type BlockEntity = CodeBlock;
+
+export type BlockEntityOutgoingLinkAndTarget = CodeBlockOutgoingLinkAndTarget;
+
+/**
+ * A brief explanation or accompanying message.
+ */
+export type CaptionPropertyValue = TextDataType;
+
+export type CodeBlock = Entity;
+
+/**
+ * A description of the language the code is written in.
+ *
+ * This should conform to one of the languages supported by Prism, for example "javascript".
+ *
+ * See: https://prismjs.com/#supported-languages
+ */
+export type CodeBlockLanguagePropertyValue = TextDataType;
+
+export type CodeBlockOutgoingLinkAndTarget = never;
+
+export type CodeBlockOutgoingLinksByLinkEntityTypeId = {};
+
+/**
+ * The block entity of the “Code” block.
+ *
+ * See: https://blockprotocol.org/@hash/blocks/code
+ */
+export type CodeBlockProperties = {
+ "https://blockprotocol.org/@blockprotocol/types/property-type/caption/"?: CaptionPropertyValue;
+ "https://blockprotocol.org/@blockprotocol/types/property-type/textual-content/"?: TextualContentPropertyValue;
+ "https://blockprotocol.org/@hash/types/property-type/code-block-language/"?: CodeBlockLanguagePropertyValue;
+};
+
+/**
+ * An opaque, untyped JSON object
+ */
+export type ObjectDataType = {};
+
+/**
+ * An ordered sequence of characters
+ */
+export type TextDataType = string;
+
+/**
+ * The text material, information, or body, that makes up the content of this thing.
+ */
+export type TextualContentPropertyValue = TextDataType | ObjectDataType[];
diff --git a/blocks/code/src/utils.ts b/blocks/code/src/utils.ts
new file mode 100644
index 0000000..63366ca
--- /dev/null
+++ b/blocks/code/src/utils.ts
@@ -0,0 +1,1073 @@
+export const PrismLanguages = {
+ meta: {
+ code: "meta",
+ title: "NO_TITLE",
+ },
+ markup: {
+ code: "markup",
+ title: "Markup",
+ },
+ css: {
+ code: "css",
+ title: "CSS",
+ },
+ clike: {
+ code: "clike",
+ title: "C-like",
+ },
+ javascript: {
+ code: "javascript",
+ title: "JavaScript",
+ },
+ abap: {
+ code: "abap",
+ title: "ABAP",
+ },
+ abnf: {
+ code: "abnf",
+ title: "ABNF",
+ },
+ actionscript: {
+ code: "actionscript",
+ title: "ActionScript",
+ },
+ ada: {
+ code: "ada",
+ title: "Ada",
+ },
+ agda: {
+ code: "agda",
+ title: "Agda",
+ },
+ al: {
+ code: "al",
+ title: "AL",
+ },
+ antlr4: {
+ code: "antlr4",
+ title: "ANTLR4",
+ },
+ apacheconf: {
+ code: "apacheconf",
+ title: "Apache Configuration",
+ },
+ apex: {
+ code: "apex",
+ title: "Apex",
+ },
+ apl: {
+ code: "apl",
+ title: "APL",
+ },
+ applescript: {
+ code: "applescript",
+ title: "AppleScript",
+ },
+ aql: {
+ code: "aql",
+ title: "AQL",
+ },
+ arduino: {
+ code: "arduino",
+ title: "Arduino",
+ },
+ arff: {
+ code: "arff",
+ title: "ARFF",
+ },
+ asciidoc: {
+ code: "asciidoc",
+ title: "AsciiDoc",
+ },
+ aspnet: {
+ code: "aspnet",
+ title: "ASP.NET (C#)",
+ },
+ asm6502: {
+ code: "asm6502",
+ title: "6502 Assembly",
+ },
+ autohotkey: {
+ code: "autohotkey",
+ title: "AutoHotkey",
+ },
+ autoit: {
+ code: "autoit",
+ title: "AutoIt",
+ },
+ bash: {
+ code: "bash",
+ title: "Bash",
+ },
+ basic: {
+ code: "basic",
+ title: "BASIC",
+ },
+ batch: {
+ code: "batch",
+ title: "Batch",
+ },
+ bbcode: {
+ code: "bbcode",
+ title: "BBcode",
+ },
+ bicep: {
+ code: "bicep",
+ title: "Bicep",
+ },
+ birb: {
+ code: "birb",
+ title: "Birb",
+ },
+ bison: {
+ code: "bison",
+ title: "Bison",
+ },
+ bnf: {
+ code: "bnf",
+ title: "BNF",
+ },
+ brainfuck: {
+ code: "brainfuck",
+ title: "Brainfuck",
+ },
+ brightscript: {
+ code: "brightscript",
+ title: "BrightScript",
+ },
+ bro: {
+ code: "bro",
+ title: "Bro",
+ },
+ bsl: {
+ code: "bsl",
+ title: "BSL (1C:Enterprise)",
+ },
+ c: {
+ code: "c",
+ title: "C",
+ },
+ csharp: {
+ code: "csharp",
+ title: "C#",
+ },
+ cpp: {
+ code: "cpp",
+ title: "C++",
+ },
+ cfscript: {
+ code: "cfscript",
+ title: "CFScript",
+ },
+ chaiscript: {
+ code: "chaiscript",
+ title: "ChaiScript",
+ },
+ cil: {
+ code: "cil",
+ title: "CIL",
+ },
+ clojure: {
+ code: "clojure",
+ title: "Clojure",
+ },
+ cmake: {
+ code: "cmake",
+ title: "CMake",
+ },
+ cobol: {
+ code: "cobol",
+ title: "COBOL",
+ },
+ coffeescript: {
+ code: "coffeescript",
+ title: "CoffeeScript",
+ },
+ concurnas: {
+ code: "concurnas",
+ title: "Concurnas",
+ },
+ csp: {
+ code: "csp",
+ title: "Content-Security-Policy",
+ },
+ coq: {
+ code: "coq",
+ title: "Coq",
+ },
+ crystal: {
+ code: "crystal",
+ title: "Crystal",
+ },
+ "css-extras": {
+ code: "css-extras",
+ title: "CSS Extras",
+ },
+ csv: {
+ code: "csv",
+ title: "CSV",
+ },
+ cypher: {
+ code: "cypher",
+ title: "Cypher",
+ },
+ d: {
+ code: "d",
+ title: "D",
+ },
+ dart: {
+ code: "dart",
+ title: "Dart",
+ },
+ dataweave: {
+ code: "dataweave",
+ title: "DataWeave",
+ },
+ dax: {
+ code: "dax",
+ title: "DAX",
+ },
+ dhall: {
+ code: "dhall",
+ title: "Dhall",
+ },
+ diff: {
+ code: "diff",
+ title: "Diff",
+ },
+ django: {
+ code: "django",
+ title: "Django/Jinja2",
+ },
+ "dns-zone-file": {
+ code: "dns-zone-file",
+ title: "DNS zone file",
+ },
+ docker: {
+ code: "docker",
+ title: "Docker",
+ },
+ dot: {
+ code: "dot",
+ title: "DOT (Graphviz)",
+ },
+ ebnf: {
+ code: "ebnf",
+ title: "EBNF",
+ },
+ editorconfig: {
+ code: "editorconfig",
+ title: "EditorConfig",
+ },
+ eiffel: {
+ code: "eiffel",
+ title: "Eiffel",
+ },
+ ejs: {
+ code: "ejs",
+ title: "EJS",
+ },
+ elixir: {
+ code: "elixir",
+ title: "Elixir",
+ },
+ elm: {
+ code: "elm",
+ title: "Elm",
+ },
+ etlua: {
+ code: "etlua",
+ title: "Embedded Lua templating",
+ },
+ erb: {
+ code: "erb",
+ title: "ERB",
+ },
+ erlang: {
+ code: "erlang",
+ title: "Erlang",
+ },
+ "excel-formula": {
+ code: "excel-formula",
+ title: "Excel Formula",
+ },
+ fsharp: {
+ code: "fsharp",
+ title: "F#",
+ },
+ factor: {
+ code: "factor",
+ title: "Factor",
+ },
+ false: {
+ code: "false",
+ title: "False",
+ },
+ "firestore-security-rules": {
+ code: "firestore-security-rules",
+ title: "Firestore security rules",
+ },
+ flow: {
+ code: "flow",
+ title: "Flow",
+ },
+ fortran: {
+ code: "fortran",
+ title: "Fortran",
+ },
+ ftl: {
+ code: "ftl",
+ title: "FreeMarker Template Language",
+ },
+ gml: {
+ code: "gml",
+ title: "GameMaker Language",
+ },
+ gcode: {
+ code: "gcode",
+ title: "G-code",
+ },
+ gdscript: {
+ code: "gdscript",
+ title: "GDScript",
+ },
+ gedcom: {
+ code: "gedcom",
+ title: "GEDCOM",
+ },
+ gherkin: {
+ code: "gherkin",
+ title: "Gherkin",
+ },
+ git: {
+ code: "git",
+ title: "Git",
+ },
+ glsl: {
+ code: "glsl",
+ title: "GLSL",
+ },
+ go: {
+ code: "go",
+ title: "Go",
+ },
+ graphql: {
+ code: "graphql",
+ title: "GraphQL",
+ },
+ groovy: {
+ code: "groovy",
+ title: "Groovy",
+ },
+ haml: {
+ code: "haml",
+ title: "Haml",
+ },
+ handlebars: {
+ code: "handlebars",
+ title: "Handlebars",
+ },
+ haskell: {
+ code: "haskell",
+ title: "Haskell",
+ },
+ haxe: {
+ code: "haxe",
+ title: "Haxe",
+ },
+ hcl: {
+ code: "hcl",
+ title: "HCL",
+ },
+ hlsl: {
+ code: "hlsl",
+ title: "HLSL",
+ },
+ hoon: {
+ code: "hoon",
+ title: "Hoon",
+ },
+ http: {
+ code: "http",
+ title: "HTTP",
+ },
+ hpkp: {
+ code: "hpkp",
+ title: "HTTP Public-Key-Pins",
+ },
+ hsts: {
+ code: "hsts",
+ title: "HTTP Strict-Transport-Security",
+ },
+ ichigojam: {
+ code: "ichigojam",
+ title: "IchigoJam",
+ },
+ icon: {
+ code: "icon",
+ title: "Icon",
+ },
+ "icu-message-format": {
+ code: "icu-message-format",
+ title: "ICU Message Format",
+ },
+ idris: {
+ code: "idris",
+ title: "Idris",
+ },
+ ignore: {
+ code: "ignore",
+ title: ".ignore",
+ },
+ inform7: {
+ code: "inform7",
+ title: "Inform 7",
+ },
+ ini: {
+ code: "ini",
+ title: "Ini",
+ },
+ io: {
+ code: "io",
+ title: "Io",
+ },
+ j: {
+ code: "j",
+ title: "J",
+ },
+ java: {
+ code: "java",
+ title: "Java",
+ },
+ javadoc: {
+ code: "javadoc",
+ title: "JavaDoc",
+ },
+ javadoclike: {
+ code: "javadoclike",
+ title: "JavaDoc-like",
+ },
+ javastacktrace: {
+ code: "javastacktrace",
+ title: "Java stack trace",
+ },
+ jexl: {
+ code: "jexl",
+ title: "Jexl",
+ },
+ jolie: {
+ code: "jolie",
+ title: "Jolie",
+ },
+ jq: {
+ code: "jq",
+ title: "JQ",
+ },
+ jsdoc: {
+ code: "jsdoc",
+ title: "JSDoc",
+ },
+ "js-extras": {
+ code: "js-extras",
+ title: "JS Extras",
+ },
+ json: {
+ code: "json",
+ title: "JSON",
+ },
+ json5: {
+ code: "json5",
+ title: "JSON5",
+ },
+ jsonp: {
+ code: "jsonp",
+ title: "JSONP",
+ },
+ jsstacktrace: {
+ code: "jsstacktrace",
+ title: "JS stack trace",
+ },
+ "js-templates": {
+ code: "js-templates",
+ title: "JS Templates",
+ },
+ julia: {
+ code: "julia",
+ title: "Julia",
+ },
+ keyman: {
+ code: "keyman",
+ title: "Keyman",
+ },
+ kotlin: {
+ code: "kotlin",
+ title: "Kotlin",
+ },
+ kumir: {
+ code: "kumir",
+ title: "KuMir (КуМир)",
+ },
+ latex: {
+ code: "latex",
+ title: "LaTeX",
+ },
+ latte: {
+ code: "latte",
+ title: "Latte",
+ },
+ less: {
+ code: "less",
+ title: "Less",
+ },
+ lilypond: {
+ code: "lilypond",
+ title: "LilyPond",
+ },
+ liquid: {
+ code: "liquid",
+ title: "Liquid",
+ },
+ lisp: {
+ code: "lisp",
+ title: "Lisp",
+ },
+ livescript: {
+ code: "livescript",
+ title: "LiveScript",
+ },
+ llvm: {
+ code: "llvm",
+ title: "LLVM IR",
+ },
+ log: {
+ code: "log",
+ title: "Log file",
+ },
+ lolcode: {
+ code: "lolcode",
+ title: "LOLCODE",
+ },
+ lua: {
+ code: "lua",
+ title: "Lua",
+ },
+ makefile: {
+ code: "makefile",
+ title: "Makefile",
+ },
+ markdown: {
+ code: "markdown",
+ title: "Markdown",
+ },
+ "markup-templating": {
+ code: "markup-templating",
+ title: "Markup templating",
+ },
+ matlab: {
+ code: "matlab",
+ title: "MATLAB",
+ },
+ mel: {
+ code: "mel",
+ title: "MEL",
+ },
+ mizar: {
+ code: "mizar",
+ title: "Mizar",
+ },
+ mongodb: {
+ code: "mongodb",
+ title: "MongoDB",
+ },
+ monkey: {
+ code: "monkey",
+ title: "Monkey",
+ },
+ moonscript: {
+ code: "moonscript",
+ title: "MoonScript",
+ },
+ n1ql: {
+ code: "n1ql",
+ title: "N1QL",
+ },
+ n4js: {
+ code: "n4js",
+ title: "N4JS",
+ },
+ "nand2tetris-hdl": {
+ code: "nand2tetris-hdl",
+ title: "Nand To Tetris HDL",
+ },
+ naniscript: {
+ code: "naniscript",
+ title: "Naninovel Script",
+ },
+ nasm: {
+ code: "nasm",
+ title: "NASM",
+ },
+ neon: {
+ code: "neon",
+ title: "NEON",
+ },
+ nevod: {
+ code: "nevod",
+ title: "Nevod",
+ },
+ nginx: {
+ code: "nginx",
+ title: "nginx",
+ },
+ nim: {
+ code: "nim",
+ title: "Nim",
+ },
+ nix: {
+ code: "nix",
+ title: "Nix",
+ },
+ nsis: {
+ code: "nsis",
+ title: "NSIS",
+ },
+ objectivec: {
+ code: "objectivec",
+ title: "Objective-C",
+ },
+ ocaml: {
+ code: "ocaml",
+ title: "OCaml",
+ },
+ opencl: {
+ code: "opencl",
+ title: "OpenCL",
+ },
+ openqasm: {
+ code: "openqasm",
+ title: "OpenQasm",
+ },
+ oz: {
+ code: "oz",
+ title: "Oz",
+ },
+ parigp: {
+ code: "parigp",
+ title: "PARI/GP",
+ },
+ parser: {
+ code: "parser",
+ title: "Parser",
+ },
+ pascal: {
+ code: "pascal",
+ title: "Pascal",
+ },
+ pascaligo: {
+ code: "pascaligo",
+ title: "Pascaligo",
+ },
+ psl: {
+ code: "psl",
+ title: "PATROL Scripting Language",
+ },
+ pcaxis: {
+ code: "pcaxis",
+ title: "PC-Axis",
+ },
+ peoplecode: {
+ code: "peoplecode",
+ title: "PeopleCode",
+ },
+ perl: {
+ code: "perl",
+ title: "Perl",
+ },
+ php: {
+ code: "php",
+ title: "PHP",
+ },
+ phpdoc: {
+ code: "phpdoc",
+ title: "PHPDoc",
+ },
+ "php-extras": {
+ code: "php-extras",
+ title: "PHP Extras",
+ },
+ plsql: {
+ code: "plsql",
+ title: "PL/SQL",
+ },
+ powerquery: {
+ code: "powerquery",
+ title: "PowerQuery",
+ },
+ powershell: {
+ code: "powershell",
+ title: "PowerShell",
+ },
+ processing: {
+ code: "processing",
+ title: "Processing",
+ },
+ prolog: {
+ code: "prolog",
+ title: "Prolog",
+ },
+ promql: {
+ code: "promql",
+ title: "PromQL",
+ },
+ properties: {
+ code: "properties",
+ title: ".properties",
+ },
+ protobuf: {
+ code: "protobuf",
+ title: "Protocol Buffers",
+ },
+ pug: {
+ code: "pug",
+ title: "Pug",
+ },
+ puppet: {
+ code: "puppet",
+ title: "Puppet",
+ },
+ pure: {
+ code: "pure",
+ title: "Pure",
+ },
+ purebasic: {
+ code: "purebasic",
+ title: "PureBasic",
+ },
+ purescript: {
+ code: "purescript",
+ title: "PureScript",
+ },
+ python: {
+ code: "python",
+ title: "Python",
+ },
+ qsharp: {
+ code: "qsharp",
+ title: "Q#",
+ },
+ q: {
+ code: "q",
+ title: "Q (kdb+ database)",
+ },
+ qml: {
+ code: "qml",
+ title: "QML",
+ },
+ qore: {
+ code: "qore",
+ title: "Qore",
+ },
+ r: {
+ code: "r",
+ title: "R",
+ },
+ racket: {
+ code: "racket",
+ title: "Racket",
+ },
+ jsx: {
+ code: "jsx",
+ title: "React JSX",
+ },
+ tsx: {
+ code: "tsx",
+ title: "React TSX",
+ },
+ reason: {
+ code: "reason",
+ title: "Reason",
+ },
+ regex: {
+ code: "regex",
+ title: "Regex",
+ },
+ rego: {
+ code: "rego",
+ title: "Rego",
+ },
+ renpy: {
+ code: "renpy",
+ title: "Ren'py",
+ },
+ rest: {
+ code: "rest",
+ title: "reST (reStructuredText)",
+ },
+ rip: {
+ code: "rip",
+ title: "Rip",
+ },
+ roboconf: {
+ code: "roboconf",
+ title: "Roboconf",
+ },
+ robotframework: {
+ code: "robotframework",
+ title: "Robot Framework",
+ },
+ ruby: {
+ code: "ruby",
+ title: "Ruby",
+ },
+ rust: {
+ code: "rust",
+ title: "Rust",
+ },
+ sas: {
+ code: "sas",
+ title: "SAS",
+ },
+ sass: {
+ code: "sass",
+ title: "Sass (Sass)",
+ },
+ scss: {
+ code: "scss",
+ title: "Sass (Scss)",
+ },
+ scala: {
+ code: "scala",
+ title: "Scala",
+ },
+ scheme: {
+ code: "scheme",
+ title: "Scheme",
+ },
+ "shell-session": {
+ code: "shell-session",
+ title: "Shell session",
+ },
+ smali: {
+ code: "smali",
+ title: "Smali",
+ },
+ smalltalk: {
+ code: "smalltalk",
+ title: "Smalltalk",
+ },
+ smarty: {
+ code: "smarty",
+ title: "Smarty",
+ },
+ sml: {
+ code: "sml",
+ title: "SML",
+ },
+ solidity: {
+ code: "solidity",
+ title: "Solidity (Ethereum)",
+ },
+ "solution-file": {
+ code: "solution-file",
+ title: "Solution file",
+ },
+ soy: {
+ code: "soy",
+ title: "Soy (Closure Template)",
+ },
+ sparql: {
+ code: "sparql",
+ title: "SPARQL",
+ },
+ "splunk-spl": {
+ code: "splunk-spl",
+ title: "Splunk SPL",
+ },
+ sqf: {
+ code: "sqf",
+ title: "SQF: Status Quo Function (Arma 3)",
+ },
+ sql: {
+ code: "sql",
+ title: "SQL",
+ },
+ squirrel: {
+ code: "squirrel",
+ title: "Squirrel",
+ },
+ stan: {
+ code: "stan",
+ title: "Stan",
+ },
+ iecst: {
+ code: "iecst",
+ title: "Structured Text (IEC 61131-3)",
+ },
+ stylus: {
+ code: "stylus",
+ title: "Stylus",
+ },
+ swift: {
+ code: "swift",
+ title: "Swift",
+ },
+ "t4-templating": {
+ code: "t4-templating",
+ title: "T4 templating",
+ },
+ "t4-cs": {
+ code: "t4-cs",
+ title: "T4 Text Templates (C#)",
+ },
+ "t4-vb": {
+ code: "t4-vb",
+ title: "T4 Text Templates (VB)",
+ },
+ tap: {
+ code: "tap",
+ title: "TAP",
+ },
+ tcl: {
+ code: "tcl",
+ title: "Tcl",
+ },
+ tt2: {
+ code: "tt2",
+ title: "Template Toolkit 2",
+ },
+ textile: {
+ code: "textile",
+ title: "Textile",
+ },
+ toml: {
+ code: "toml",
+ title: "TOML",
+ },
+ turtle: {
+ code: "turtle",
+ title: "Turtle",
+ },
+ twig: {
+ code: "twig",
+ title: "Twig",
+ },
+ typescript: {
+ code: "typescript",
+ title: "TypeScript",
+ },
+ typoscript: {
+ code: "typoscript",
+ title: "TypoScript",
+ },
+ unrealscript: {
+ code: "unrealscript",
+ title: "UnrealScript",
+ },
+ uri: {
+ code: "uri",
+ title: "URI",
+ },
+ v: {
+ code: "v",
+ title: "V",
+ },
+ vala: {
+ code: "vala",
+ title: "Vala",
+ },
+ vbnet: {
+ code: "vbnet",
+ title: "VB.Net",
+ },
+ velocity: {
+ code: "velocity",
+ title: "Velocity",
+ },
+ verilog: {
+ code: "verilog",
+ title: "Verilog",
+ },
+ vhdl: {
+ code: "vhdl",
+ title: "VHDL",
+ },
+ vim: {
+ code: "vim",
+ title: "vim",
+ },
+ "visual-basic": {
+ code: "visual-basic",
+ title: "Visual Basic",
+ },
+ warpscript: {
+ code: "warpscript",
+ title: "WarpScript",
+ },
+ wasm: {
+ code: "wasm",
+ title: "WebAssembly",
+ },
+ wiki: {
+ code: "wiki",
+ title: "Wiki markup",
+ },
+ wolfram: {
+ code: "wolfram",
+ title: "Wolfram language",
+ },
+ xeora: {
+ code: "xeora",
+ title: "Xeora",
+ },
+ "xml-doc": {
+ code: "xml-doc",
+ title: "XML doc (.net)",
+ },
+ xojo: {
+ code: "xojo",
+ title: "Xojo (REALbasic)",
+ },
+ xquery: {
+ code: "xquery",
+ title: "XQuery",
+ },
+ yaml: {
+ code: "yaml",
+ title: "YAML",
+ },
+ yang: {
+ code: "yang",
+ title: "YANG",
+ },
+ zig: {
+ code: "zig",
+ title: "Zig",
+ },
+} as const;
+
+export const languageOptions = [
+ "css",
+ "csharp",
+ "dart",
+ "erlang",
+ "go",
+ "java",
+ "javascript",
+ "json",
+ "jsx",
+ "markup",
+ "python",
+ "haml",
+ "rust",
+ "ruby",
+ "typescript",
+] as const;
+
+export type LanguageType = (typeof languageOptions)[number];
+
+export const getLanguages = (languages: readonly LanguageType[]) => {
+ return languages.map((language) => PrismLanguages[language]);
+};
+
+// can comment this if we want to display all languages
+export const languages = getLanguages(languageOptions);
diff --git a/blocks/code/tsconfig.json b/blocks/code/tsconfig.json
new file mode 100644
index 0000000..20bf5d2
--- /dev/null
+++ b/blocks/code/tsconfig.json
@@ -0,0 +1,5 @@
+{
+ "extends": "@local/tsconfig/block.json",
+ "include": ["declarations.d.ts", "src"],
+ "exclude": ["node_modules"]
+}
diff --git a/blocks/code/turbo.json b/blocks/code/turbo.json
new file mode 100644
index 0000000..9d80ee7
--- /dev/null
+++ b/blocks/code/turbo.json
@@ -0,0 +1,28 @@
+{
+ "extends": ["//"],
+ "tasks": {
+ "codegen": {
+ "inputs": ["./package.json"],
+ "outputs": ["./src/types/generated/**"]
+ },
+ "build": {
+ "dependsOn": ["^build", "codegen", "format"],
+ "outputs": ["./dist/**"]
+ },
+ "lint:tsc": {
+ "dependsOn": ["codegen"]
+ },
+ "format": {
+ "cache": false,
+ "dependsOn": ["codegen"]
+ },
+ "dev": {
+ "persistent": true,
+ "dependsOn": ["^build", "codegen"]
+ },
+ "serve": {
+ "persistent": true,
+ "dependsOn": ["build"]
+ }
+ }
+}
diff --git a/blocks/countdown/LICENSE-APACHE.md b/blocks/countdown/LICENSE-APACHE.md
new file mode 100644
index 0000000..1d1b6f8
--- /dev/null
+++ b/blocks/countdown/LICENSE-APACHE.md
@@ -0,0 +1,189 @@
+# Apache License
+
+_Version 2.0, January 2004_
+_< >_
+
+### Terms and Conditions for use, reproduction, and distribution
+
+#### 1. Definitions
+
+“License” shall mean the terms and conditions for use, reproduction, and
+distribution as defined by Sections 1 through 9 of this document.
+
+“Licensor” shall mean the copyright owner or entity authorized by the copyright
+owner that is granting the License.
+
+“Legal Entity” shall mean the union of the acting entity and all other entities
+that control, are controlled by, or are under common control with that entity.
+For the purposes of this definition, “control” means **(i)** the power, direct or
+indirect, to cause the direction or management of such entity, whether by
+contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the
+outstanding shares, or **(iii)** beneficial ownership of such entity.
+
+“You” (or “Your”) shall mean an individual or Legal Entity exercising
+permissions granted by this License.
+
+“Source” form shall mean the preferred form for making modifications, including
+but not limited to software source code, documentation source, and configuration
+files.
+
+“Object” form shall mean any form resulting from mechanical transformation or
+translation of a Source form, including but not limited to compiled object code,
+generated documentation, and conversions to other media types.
+
+“Work” shall mean the work of authorship, whether in Source or Object form, made
+available under the License, as indicated by a copyright notice that is included
+in or attached to the work (an example is provided in the Appendix below).
+
+“Derivative Works” shall mean any work, whether in Source or Object form, that
+is based on (or derived from) the Work and for which the editorial revisions,
+annotations, elaborations, or other modifications represent, as a whole, an
+original work of authorship. For the purposes of this License, Derivative Works
+shall not include works that remain separable from, or merely link (or bind by
+name) to the interfaces of, the Work and Derivative Works thereof.
+
+“Contribution” shall mean any work of authorship, including the original version
+of the Work and any modifications or additions to that Work or Derivative Works
+thereof, that is intentionally submitted to Licensor for inclusion in the Work
+by the copyright owner or by an individual or Legal Entity authorized to submit
+on behalf of the copyright owner. For the purposes of this definition,
+“submitted” means any form of electronic, verbal, or written communication sent
+to the Licensor or its representatives, including but not limited to
+communication on electronic mailing lists, source code control systems, and
+issue tracking systems that are managed by, or on behalf of, the Licensor for
+the purpose of discussing and improving the Work, but excluding communication
+that is conspicuously marked or otherwise designated in writing by the copyright
+owner as “Not a Contribution.”
+
+“Contributor” shall mean Licensor and any individual or Legal Entity on behalf
+of whom a Contribution has been received by Licensor and subsequently
+incorporated within the Work.
+
+#### 2. Grant of Copyright License
+
+Subject to the terms and conditions of this License, each Contributor hereby
+grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
+irrevocable copyright license to reproduce, prepare Derivative Works of,
+publicly display, publicly perform, sublicense, and distribute the Work and such
+Derivative Works in Source or Object form.
+
+#### 3. Grant of Patent License
+
+Subject to the terms and conditions of this License, each Contributor hereby
+grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
+irrevocable (except as stated in this section) patent license to make, have
+made, use, offer to sell, sell, import, and otherwise transfer the Work, where
+such license applies only to those patent claims licensable by such Contributor
+that are necessarily infringed by their Contribution(s) alone or by combination
+of their Contribution(s) with the Work to which such Contribution(s) was
+submitted. If You institute patent litigation against any entity (including a
+cross-claim or counterclaim in a lawsuit) alleging that the Work or a
+Contribution incorporated within the Work constitutes direct or contributory
+patent infringement, then any patent licenses granted to You under this License
+for that Work shall terminate as of the date such litigation is filed.
+
+#### 4. Redistribution
+
+You may reproduce and distribute copies of the Work or Derivative Works thereof
+in any medium, with or without modifications, and in Source or Object form,
+provided that You meet the following conditions:
+
+- **(a)** You must give any other recipients of the Work or Derivative Works a copy of
+ this License; and
+- **(b)** You must cause any modified files to carry prominent notices stating that You
+ changed the files; and
+- **(c)** You must retain, in the Source form of any Derivative Works that You distribute,
+ all copyright, patent, trademark, and attribution notices from the Source form
+ of the Work, excluding those notices that do not pertain to any part of the
+ Derivative Works; and
+- **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any
+ Derivative Works that You distribute must include a readable copy of the
+ attribution notices contained within such NOTICE file, excluding those notices
+ that do not pertain to any part of the Derivative Works, in at least one of the
+ following places: within a NOTICE text file distributed as part of the
+ Derivative Works; within the Source form or documentation, if provided along
+ with the Derivative Works; or, within a display generated by the Derivative
+ Works, if and wherever such third-party notices normally appear. The contents of
+ the NOTICE file are for informational purposes only and do not modify the
+ License. You may add Your own attribution notices within Derivative Works that
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
+ provided that such additional attribution notices cannot be construed as
+ modifying the License.
+
+You may add Your own copyright statement to Your modifications and may provide
+additional or different license terms and conditions for use, reproduction, or
+distribution of Your modifications, or for any such Derivative Works as a whole,
+provided Your use, reproduction, and distribution of the Work otherwise complies
+with the conditions stated in this License.
+
+#### 5. Submission of Contributions
+
+Unless You explicitly state otherwise, any Contribution intentionally submitted
+for inclusion in the Work by You to the Licensor shall be under the terms and
+conditions of this License, without any additional terms or conditions.
+Notwithstanding the above, nothing herein shall supersede or modify the terms of
+any separate license agreement you may have executed with Licensor regarding
+such Contributions.
+
+#### 6. Trademarks
+
+This License does not grant permission to use the trade names, trademarks,
+service marks, or product names of the Licensor, except as required for
+reasonable and customary use in describing the origin of the Work and
+reproducing the content of the NOTICE file.
+
+#### 7. Disclaimer of Warranty
+
+Unless required by applicable law or agreed to in writing, Licensor provides the
+Work (and each Contributor provides its Contributions) on an “AS IS” BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
+including, without limitation, any warranties or conditions of TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
+solely responsible for determining the appropriateness of using or
+redistributing the Work and assume any risks associated with Your exercise of
+permissions under this License.
+
+#### 8. Limitation of Liability
+
+In no event and under no legal theory, whether in tort (including negligence),
+contract, or otherwise, unless required by applicable law (such as deliberate
+and grossly negligent acts) or agreed to in writing, shall any Contributor be
+liable to You for damages, including any direct, indirect, special, incidental,
+or consequential damages of any character arising as a result of this License or
+out of the use or inability to use the Work (including but not limited to
+damages for loss of goodwill, work stoppage, computer failure or malfunction, or
+any and all other commercial damages or losses), even if such Contributor has
+been advised of the possibility of such damages.
+
+#### 9. Accepting Warranty or Additional Liability
+
+While redistributing the Work or Derivative Works thereof, You may choose to
+offer, and charge a fee for, acceptance of support, warranty, indemnity, or
+other liability obligations and/or rights consistent with this License. However,
+in accepting such obligations, You may act only on Your own behalf and on Your
+sole responsibility, not on behalf of any other Contributor, and only if You
+agree to indemnify, defend, and hold each Contributor harmless for any liability
+incurred by, or claims asserted against, such Contributor by reason of your
+accepting any such warranty or additional liability.
+
+_END OF TERMS AND CONDITIONS_
+
+### APPENDIX: Apply the Apache License to a specific file
+
+To apply the Apache License to an individual file, attach the following notice.
+The text should be enclosed in the appropriate comment syntax for the file
+format.
+
+ Copyright © 2022–, HASH
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/blocks/countdown/LICENSE-MIT.md b/blocks/countdown/LICENSE-MIT.md
new file mode 100644
index 0000000..e33c1d3
--- /dev/null
+++ b/blocks/countdown/LICENSE-MIT.md
@@ -0,0 +1,21 @@
+# MIT License
+
+Copyright © 2022–, HASH
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/blocks/countdown/LICENSE.md b/blocks/countdown/LICENSE.md
new file mode 100644
index 0000000..8686df9
--- /dev/null
+++ b/blocks/countdown/LICENSE.md
@@ -0,0 +1,5 @@
+# License
+
+Licensed under either of the [Apache License, Version 2.0](LICENSE-APACHE.md) or [MIT license](LICENSE-MIT.md) at your option.
+
+For more information about contributing to this block, see our top-level [CONTRIBUTING](https://github.com/hashintel/hash/blob/main/.github/CONTRIBUTING.md) policy.
diff --git a/blocks/countdown/README.md b/blocks/countdown/README.md
new file mode 100644
index 0000000..7d3837b
--- /dev/null
+++ b/blocks/countdown/README.md
@@ -0,0 +1,11 @@
+The Countdown block displays the number of days, months, and years until a particular target date. The date is selected with an intuitive date picker and a title can be added above the countdown to provide additional context. Optionally, the number of minutes and hours can also be shown.
+
+## Programmatic Usage
+
+The block accepts the following properties ([view the Countdown Block entity type](https://blockprotocol.org/@hash/types/entity-type/countdown-block/v/2) to see these in context):
+
+- [`Title`](https://blockprotocol.org/@blockprotocol/types/property-type/title/)
+- [`Target Date and Time`](https://blockprotocol.org/@hash/types/property-type/target-date-and-time/)
+- [`Countdown Block should Display Time`](https://blockprotocol.org/@hash/types/property-type/countdown-block-should-display-time/)
+
+It uses the Graph Module's `updateEntity` method to persist these in the embedding application's storage.
diff --git a/blocks/countdown/eslint.config.js b/blocks/countdown/eslint.config.js
new file mode 100644
index 0000000..5b6bb9d
--- /dev/null
+++ b/blocks/countdown/eslint.config.js
@@ -0,0 +1,3 @@
+import { createBlock } from "@local/eslint/deprecated";
+
+export default createBlock(import.meta.dirname);
diff --git a/blocks/countdown/package.json b/blocks/countdown/package.json
new file mode 100644
index 0000000..ab8879a
--- /dev/null
+++ b/blocks/countdown/package.json
@@ -0,0 +1,83 @@
+{
+ "name": "@blocks/countdown",
+ "version": "0.2.1",
+ "private": true,
+ "description": "Countdown to a time and date",
+ "keywords": [
+ "blockprotocol",
+ "blocks",
+ "block"
+ ],
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/hashintel/blocks.git",
+ "directory": "blocks/countdown"
+ },
+ "license": "(MIT OR Apache-2.0)",
+ "author": "HASH",
+ "type": "module",
+ "scripts": {
+ "build": "block-scripts build",
+ "codegen": "block-scripts codegen && yarn format",
+ "dev": "block-scripts dev",
+ "fix:eslint": "eslint --fix .",
+ "format": "prettier --write --ignore-unknown src/types/generated/*.ts",
+ "lint:eslint": "eslint --report-unused-disable-directives .",
+ "lint:tsc": "tsc --noEmit",
+ "serve": "block-scripts serve"
+ },
+ "dependencies": {
+ "@blockprotocol/graph": "0.3.4",
+ "date-fns": "4.1.0",
+ "react-datepicker": "4.25.0"
+ },
+ "devDependencies": {
+ "@local/eslint": "0.0.0-private",
+ "@local/tsconfig": "0.0.0-private",
+ "@types/react-datepicker": "4.19.6",
+ "@types/react-dom": "19.1.7",
+ "block-scripts": "0.3.4",
+ "eslint": "10.0.3",
+ "mock-block-dock": "0.1.9",
+ "prettier": "3.8.1",
+ "react": "19.1.1",
+ "react-dom": "19.1.1",
+ "typescript": "5.9.3"
+ },
+ "peerDependencies": {
+ "react": "^19.0.0",
+ "react-dom": "^19.0.0"
+ },
+ "block-scripts": {
+ "devPort": 9090,
+ "servePort": 63215
+ },
+ "blockprotocol": {
+ "blockType": {
+ "entryPoint": "react"
+ },
+ "name": "@hash/countdown",
+ "displayName": "Countdown",
+ "examples": [
+ {
+ "https://blockprotocol.org/@blockprotocol/types/property-type/title/": "The Beta Launch",
+ "https://blockprotocol.org/@hash/types/property-type/target-date-and-time/": null,
+ "https://blockprotocol.org/@hash/types/property-type/countdown-block-should-display-time/": false
+ }
+ ],
+ "icon": "public/icon.svg",
+ "image": "public/preview.svg",
+ "protocol": "0.3",
+ "blockEntityType": "https://blockprotocol.org/@hash/types/entity-type/countdown-block/v/2",
+ "codegen": {
+ "outputFolder": "src/types/generated",
+ "targets": {
+ "block-entity.ts": [
+ {
+ "blockEntityType": true
+ }
+ ]
+ }
+ }
+ }
+}
diff --git a/blocks/countdown/public/icon.svg b/blocks/countdown/public/icon.svg
new file mode 100644
index 0000000..20be2d7
--- /dev/null
+++ b/blocks/countdown/public/icon.svg
@@ -0,0 +1,57 @@
+
+
diff --git a/blocks/countdown/public/preview.svg b/blocks/countdown/public/preview.svg
new file mode 100644
index 0000000..5a24095
--- /dev/null
+++ b/blocks/countdown/public/preview.svg
@@ -0,0 +1,35 @@
+
diff --git a/blocks/countdown/src/app.tsx b/blocks/countdown/src/app.tsx
new file mode 100644
index 0000000..5bb008c
--- /dev/null
+++ b/blocks/countdown/src/app.tsx
@@ -0,0 +1,129 @@
+import "react-datepicker/dist/react-datepicker.css";
+import "./datepicker-override.scss";
+import "./styles.scss";
+
+import type { BlockComponent } from "@blockprotocol/graph/react";
+import {
+ useEntitySubgraph,
+ useGraphBlockModule,
+} from "@blockprotocol/graph/react";
+import { useCallback, useEffect, useRef, useState } from "react";
+
+import { CountdownTitle } from "./countdown-title";
+import { DatePickerInput } from "./date-picker-input";
+import { Display } from "./display";
+import { propertyIds } from "./property-ids";
+import type { BlockEntity } from "./types/generated/block-entity";
+
+export const App: BlockComponent = ({
+ graph: { blockEntitySubgraph, readonly },
+}) => {
+ const { rootEntity: blockEntity } = useEntitySubgraph(blockEntitySubgraph);
+ const {
+ metadata: {
+ recordId: { entityId },
+ entityTypeId,
+ },
+ properties: {
+ [propertyIds.targetDateTime]: targetDate,
+ [propertyIds.title]: title,
+ [propertyIds.displayTime]: displayTime,
+ },
+ } = blockEntity;
+ const blockRef = useRef(null);
+ /* @ts-expect-error –– @todo H-3839 packages in BP repo needs updating, or this package updating to use graph in this repo */
+ const { graphModule } = useGraphBlockModule(blockRef);
+ const [localTargetDate, setLocalTargetDate] = useState(
+ !targetDate ? null : new Date(targetDate),
+ );
+ const [localTitle, setLocalTitle] = useState(title);
+ const [localDisplayTime, setLocalDisplayTime] = useState(false);
+
+ useEffect(() => {
+ setLocalTargetDate(!targetDate ? null : new Date(targetDate));
+ }, [targetDate]);
+
+ useEffect(() => {
+ setLocalTitle(title);
+ }, [title]);
+
+ useEffect(() => {
+ setLocalDisplayTime(!!displayTime);
+ }, [displayTime]);
+
+ const updateRemoteData = useCallback(
+ (data?: {
+ title?: string;
+ targetDate?: Date | null;
+ displayTime?: boolean;
+ }) => {
+ if (readonly) {
+ return;
+ }
+ const nextTargetDateTime = data?.targetDate ?? localTargetDate;
+ const nextTitle = data?.title ?? localTitle;
+
+ void graphModule.updateEntity({
+ data: {
+ entityId,
+ entityTypeId,
+ properties: {
+ [propertyIds.displayTime]: data?.displayTime ?? localDisplayTime,
+ ...(nextTargetDateTime
+ ? {
+ [propertyIds.targetDateTime]:
+ nextTargetDateTime.toISOString(),
+ }
+ : {}),
+ ...(nextTitle ? { [propertyIds.title]: nextTitle } : {}),
+ },
+ },
+ });
+ },
+ [
+ readonly,
+ localTargetDate,
+ localTitle,
+ graphModule,
+ entityId,
+ entityTypeId,
+ localDisplayTime,
+ ],
+ );
+
+ const handleDateChange = useCallback(
+ (changes: Date | [Date | null, Date | null] | null) => {
+ const newTargetDate = Array.isArray(changes) ? changes[0] : changes;
+ setLocalTargetDate(newTargetDate);
+ updateRemoteData({ targetDate: newTargetDate });
+ },
+ [updateRemoteData],
+ );
+
+ const handleDisplayTimeChange = useCallback(
+ (newDisplayTime: boolean) => {
+ setLocalDisplayTime(newDisplayTime);
+ updateRemoteData({ displayTime: newDisplayTime });
+ },
+ [updateRemoteData],
+ );
+
+ return (
+
+
+
+
+
+ );
+};
diff --git a/blocks/countdown/src/countdown-title.tsx b/blocks/countdown/src/countdown-title.tsx
new file mode 100644
index 0000000..bcc2a6a
--- /dev/null
+++ b/blocks/countdown/src/countdown-title.tsx
@@ -0,0 +1,73 @@
+import type { ChangeEvent, FunctionComponent } from "react";
+import { useEffect, useRef } from "react";
+
+type CountdownTitleProps = {
+ value: string | undefined;
+ onChangeText: (val: string) => void;
+ onBlur: () => void;
+ readonly: boolean;
+};
+
+export const CountdownTitle: FunctionComponent = ({
+ value,
+ onChangeText,
+ onBlur,
+ readonly,
+}) => {
+ const textareaEl = useRef(null);
+
+ useEffect(() => {
+ const textarea = textareaEl.current;
+ if (!textarea) return;
+
+ // We only want to set textContent when the value changes externally because
+ // by setting it we lose the cursor position in some browsers (firefox, safari)
+ if (value !== textarea.textContent) {
+ textarea.textContent = value ?? "";
+ }
+ }, [value]);
+
+ const handleChange = (evt: ChangeEvent) => {
+ if (!textareaEl.current) return;
+
+ onChangeText(evt.currentTarget.textContent ?? "");
+ };
+
+ return (
+
+ {
+ if (key === "Enter" || key === "Escape") {
+ textareaEl.current?.blur();
+ }
+ },
+ })}
+ />
+ {!readonly && (
+
+ )}
+
+ );
+};
diff --git a/blocks/countdown/src/date-picker-input.tsx b/blocks/countdown/src/date-picker-input.tsx
new file mode 100644
index 0000000..d019443
--- /dev/null
+++ b/blocks/countdown/src/date-picker-input.tsx
@@ -0,0 +1,137 @@
+import type {
+ FunctionComponent,
+ HTMLAttributes,
+ MutableRefObject,
+} from "react";
+import { forwardRef, useRef } from "react";
+import type { ReactDatePickerProps } from "react-datepicker";
+import DatePicker from "react-datepicker";
+
+const CalenderIcon: FunctionComponent<{ onClick: () => void }> = ({
+ onClick,
+}) => {
+ return (
+
+ );
+};
+
+const CustomInput = forwardRef<
+ HTMLInputElement,
+ HTMLAttributes & { displayTime: boolean }
+>(({ displayTime, ...props }, ref) => {
+ const inputRef = useRef(null);
+
+ return (
+ <>
+ {
+ if (!ref) return;
+
+ (inputRef as MutableRefObject).current =
+ element;
+ if (typeof ref === "function") {
+ ref(element);
+ } else {
+ // eslint-disable-next-line no-param-reassign
+ ref.current = element;
+ }
+ }}
+ {...props}
+ />
+ inputRef.current?.focus()} />
+ >
+ );
+});
+
+type CustomTimeInputProps = {
+ onChange?: (val: string) => void;
+ displayTime: boolean;
+ setDisplayTime: (val: boolean) => void;
+} & Omit, "onChange">;
+
+const CustomTimeInput = forwardRef(
+ ({ displayTime, setDisplayTime, ...props }, ref) => {
+ if (!displayTime) {
+ return (
+
+ );
+ }
+
+ return (
+ <>
+ {
+ props.onChange?.(evt.target.value || "00:00");
+ }}
+ />
+
+ >
+ );
+ },
+);
+
+type DatePickerInputProps = {
+ displayTime: boolean;
+ setDisplayTime: (val: boolean) => void;
+ readonly: boolean;
+} & ReactDatePickerProps;
+
+export const DatePickerInput = forwardRef(
+ ({ displayTime, setDisplayTime, readonly, ...props }, ref) => {
+ return (
+
+ }
+ customTimeInput={
+
+ }
+ showTimeInput
+ />
+
+ );
+ },
+);
diff --git a/blocks/countdown/src/datepicker-override.scss b/blocks/countdown/src/datepicker-override.scss
new file mode 100644
index 0000000..663b51c
--- /dev/null
+++ b/blocks/countdown/src/datepicker-override.scss
@@ -0,0 +1,233 @@
+.countdown-block {
+ .react-datepicker-popper {
+ border-radius: 6px;
+ inset: none;
+ box-shadow:
+ 0px 0.20370370149612427px 0.6296296119689941px 0px
+ hsla(226, 37%, 38%, 0.07),
+ 0px 4.237037181854248px 8.100000381469727px 0px hsla(226, 37%, 38%, 0.06),
+ 0px 7.129629611968994px 18.3700008392334px 0px hsla(226, 37%, 38%, 0.05),
+ 0px 11px 30px 0px hsla(226, 37%, 38%, 0.04);
+
+ &[data-placement^="bottom"] {
+ margin-top: 10px;
+ padding-top: 0;
+
+ .react-datepicker__triangle::before {
+ border-bottom-color: hsla(208, 39%, 90%, 1);
+ }
+
+ .react-datepicker__triangle::after {
+ border-bottom-color: hsla(204, 45%, 98%, 1);
+ }
+ }
+ }
+
+ .react-datepicker {
+ border: 1px solid hsla(208, 39%, 90%, 1);
+ font-family: "Inter", system-ui, sans-serif;
+
+ &__header {
+ padding: 0.75rem;
+ background: hsla(204, 45%, 98%, 1);
+ border-bottom: 1px solid hsla(208, 39%, 90%, 1);
+ }
+
+ &__current-month {
+ color: hsla(210, 18%, 26%, 1);
+ font-size: 1rem;
+ padding: 0.25rem;
+ font-weight: 600;
+ }
+
+ &__day-name {
+ font-size: 0.875rem;
+ margin: 0.5rem 0.55rem 0.2rem;
+ color: hsla(212, 17%, 47%, 0.75);
+ }
+
+ &__month {
+ margin: 0.5rem;
+ }
+
+ &__day {
+ font-size: 0.875rem;
+ line-height: 1;
+ padding: 0;
+ height: 40px;
+ width: 40px;
+ display: inline-flex;
+ justify-content: center;
+ align-items: center;
+ color: hsla(212, 17%, 40%, 0.9);
+ border: 2px solid hsla(204, 87%, 52%, 0);
+ transition: all 200ms ease-in;
+
+ &:hover {
+ background-color: hsla(204, 87%, 52%, 0.1);
+ border: 2px solid hsla(204, 87%, 52%, 0.3);
+ color: hsla(212, 17%, 20%, 1);
+ border-radius: 5rem;
+ }
+
+ &--selected {
+ background: hsla(210, 94%, 46%, 1);
+ color: #ffffff;
+ border-radius: 5rem;
+ border: 2px solid hsla(204, 87%, 52%, 0);
+ }
+
+ &--keyboard-selected {
+ border-radius: 5rem;
+ background: none;
+ border: 2px solid hsla(204, 87%, 52%, 1);
+ }
+ }
+
+ &__navigation {
+ top: 10px;
+
+ &--next {
+ right: 16px;
+ }
+
+ &--previous {
+ left: 16px;
+ }
+
+ &-icon::before {
+ border-color: hsla(212, 17%, 47%, 0.5);
+ border-width: 2px 2px 0 0;
+ top: 6px;
+ }
+
+ &-icon:hover::before {
+ border-color: rgb(76, 93, 113);
+ }
+ }
+
+ &__input-container {
+ box-shadow: 0px 1px 2px 0px hsla(220, 43%, 11%, 0.05);
+ padding: 0 16px;
+ border: 1px solid var(--border-color-light);
+ border-radius: 6px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: min-content;
+ transition: 0.3s all ease-in-out;
+
+ &:hover {
+ background-color: #f7fafc;
+ cursor: pointer;
+ }
+
+ &:focus-within {
+ border: 1px solid #0775e3;
+ }
+
+ input {
+ font-family: "Inter", system-ui, sans-serif;
+ padding: 12px 0;
+ font-size: 0.875rem;
+ background-color: transparent;
+ color: var(--tertiary-text-base);
+ outline: none;
+ border: none;
+ flex: 1;
+ transition: 0.3s all ease-in-out;
+ width: 100px;
+
+ &:placeholder-shown {
+ width: 100px;
+ }
+
+ &:not(:placeholder-shown) {
+ opacity: 0.6;
+
+ & + svg {
+ opacity: 0.6;
+ }
+ }
+
+ &::placeholder {
+ color: var(--primary-text-base);
+ font-size: 0.875rem;
+ font-weight: 500;
+ }
+
+ &[data-expanded="true"] {
+ width: 160px;
+ }
+ }
+
+ svg {
+ color: var(--tertiary-text-base);
+ transition: 0.3s all ease-in-out;
+ }
+ }
+
+ &__input-time-container {
+ margin: 0;
+ padding: 0.5rem 1.5rem;
+ background: hsla(204, 45%, 98%, 1);
+ border-top: 1px solid hsla(208, 39%, 90%, 1);
+ display: flex;
+ align-items: center;
+ }
+
+ &-time__caption {
+ font-family: inherit;
+ font-size: 0.875rem;
+ color: hsla(212, 17%, 40%, 1);
+ }
+
+ &__input-time-container
+ .react-datepicker-time__input-container
+ .react-datepicker-time__input {
+ margin-left: 0.5rem;
+ }
+
+ &__time-list-item {
+ font-family: inherit;
+ font-size: 0.875rem;
+ line-height: 1;
+ padding: 0;
+ color: var(--secondary-text-base);
+ border: 2px solid var(--border-color-dark);
+ transition: 0.3s all ease-in-out;
+ }
+
+ &-time__input input {
+ font-family: inherit;
+ font-size: 0.875rem;
+ padding: 6px 12px;
+ color: var(--secondary-text-base);
+ border-radius: 6px;
+ border: 1px solid hsla(210, 30%, 81%, 1);
+ box-shadow: 0px 1px 2px 0px hsla(220, 43%, 11%, 0.05);
+ }
+
+ &-time__btn {
+ color: var(--secondary-text-base);
+ padding: 8px 12px;
+ border: 1px solid var(--border-color-light);
+ background: transparent;
+ border-radius: 6px;
+ font-size: 0.875rem;
+ transition: 0.3s all ease-in-out;
+ }
+
+ &-time__btn:hover {
+ background-color: var(--border-color-light);
+ cursor: pointer;
+ color: var(--primary-text-base);
+ }
+
+ &-time__btn--remove {
+ margin-left: 0.25rem;
+ padding: 8px 12px;
+ transition: 0.3s all ease-in-out;
+ }
+ }
+}
diff --git a/blocks/countdown/src/dev.tsx b/blocks/countdown/src/dev.tsx
new file mode 100644
index 0000000..0c89bfb
--- /dev/null
+++ b/blocks/countdown/src/dev.tsx
@@ -0,0 +1,43 @@
+/**
+ * This is the entry point for developing and debugging.
+ * This file is not bundled with the block during the build process.
+ */
+import type { VersionedUrl } from "@blockprotocol/graph";
+import { MockBlockDock } from "mock-block-dock";
+import { createRoot } from "react-dom/client";
+
+import packageJSON from "../package.json";
+import Component from "./index";
+import type { BlockEntity } from "./types/generated/block-entity";
+
+const node = document.getElementById("app");
+
+const initialData: BlockEntity = {
+ metadata: {
+ recordId: {
+ entityId: "entity-countdown",
+ editionId: "1",
+ },
+ entityTypeId: packageJSON.blockprotocol.blockEntityType as VersionedUrl,
+ },
+ properties: {},
+};
+
+const App = () => {
+ return (
+
+ );
+};
+
+createRoot(node!).render( );
diff --git a/blocks/countdown/src/display.tsx b/blocks/countdown/src/display.tsx
new file mode 100644
index 0000000..d69539a
--- /dev/null
+++ b/blocks/countdown/src/display.tsx
@@ -0,0 +1,82 @@
+import type { Duration } from "date-fns";
+import { intervalToDuration, isPast } from "date-fns";
+import type { FunctionComponent } from "react";
+import { useEffect, useState } from "react";
+
+type DisplayProps = {
+ targetDate: Date | null;
+ displayTime: boolean;
+};
+
+const intervals: (keyof Duration)[] = [
+ "years",
+ "months",
+ "days",
+ "hours",
+ "minutes",
+];
+
+export const defaultDuration = {
+ years: 0,
+ months: 0,
+ days: 0,
+ hours: 0,
+ minutes: 0,
+} as Duration;
+
+export const Display: FunctionComponent = ({
+ targetDate,
+ displayTime,
+}) => {
+ const [_, setClock] = useState(new Date());
+
+ useEffect(() => {
+ const tick = () => setClock(new Date());
+ // Tick at most once per second
+ // It might take slightly longer than a second depending on how long it takes to get through other events
+ const tickInterval = setInterval(tick, 1000);
+
+ tick();
+
+ return () => clearInterval(tickInterval);
+ }, []);
+
+ const duration = targetDate
+ ? intervalToDuration({
+ start: new Date(),
+ end: targetDate,
+ })
+ : defaultDuration;
+
+ const filteredIntervals = intervals.reduce<(keyof Duration)[]>((acc, val) => {
+ if (!displayTime && ["hours", "minutes"].includes(val)) {
+ return acc;
+ }
+ if (duration[val] ?? acc.length > 0) {
+ return [...acc, val];
+ }
+ return acc;
+ }, []);
+
+ const intervalsToDisplay =
+ filteredIntervals.length > 0
+ ? filteredIntervals
+ : (["days"] as (keyof Duration)[]);
+
+ return (
+
+ {intervalsToDisplay.map((item) => {
+ return (
+
+
+ {["minutes"].includes(item)
+ ? (duration[item]?.toString().padStart(2, "0") ?? "00")
+ : (duration[item] ?? "0")}
+
+ {`${item} ${targetDate && isPast(targetDate) ? "ago" : ""}`}
+
+ );
+ })}
+
+ );
+};
diff --git a/blocks/countdown/src/index.ts b/blocks/countdown/src/index.ts
new file mode 100644
index 0000000..6eb172a
--- /dev/null
+++ b/blocks/countdown/src/index.ts
@@ -0,0 +1,8 @@
+/* eslint-disable canonical/filename-no-index -- @todo rename file */
+
+/**
+ * Entrypoint of the Block Component.
+ */
+import { App } from "./app";
+
+export default App;
diff --git a/blocks/countdown/src/property-ids.ts b/blocks/countdown/src/property-ids.ts
new file mode 100644
index 0000000..0eba2b3
--- /dev/null
+++ b/blocks/countdown/src/property-ids.ts
@@ -0,0 +1,8 @@
+export const propertyIds = {
+ title:
+ "https://blockprotocol.org/@blockprotocol/types/property-type/title/" as const,
+ targetDateTime:
+ "https://blockprotocol.org/@hash/types/property-type/target-date-and-time/" as const,
+ displayTime:
+ "https://blockprotocol.org/@hash/types/property-type/countdown-block-should-display-time/" as const,
+};
diff --git a/blocks/countdown/src/styles.scss b/blocks/countdown/src/styles.scss
new file mode 100644
index 0000000..9e7cda4
--- /dev/null
+++ b/blocks/countdown/src/styles.scss
@@ -0,0 +1,181 @@
+/* Countdown Block Styles */
+
+@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap");
+
+.countdown-block {
+ --font-family: system-ui, "Inter", "Open Sans", "Helvetica Neue", "Arial",
+ sans-serif;
+
+ --font-size-xs: clamp(0.8rem, 0.17vw + 0.76rem, 0.89rem);
+ --font-size-sm: clamp(0.85rem, 0.22vw + 0.83rem, 0.95rem);
+ --font-size-base: clamp(1rem, 0.34vw + 0.91rem, 1.12rem);
+ --font-size-md: clamp(1.25rem, 0.61vw + 1.1rem, 1.58rem);
+ --font-size-lg: clamp(1.56rem, 1vw + 1.31rem, 2.11rem);
+ --font-size-xl: clamp(1.95rem, 1.56vw + 1.56rem, 2.81rem);
+ --font-size-xxl: clamp(2.44rem, 2.38vw + 1.85rem, 3.75rem);
+ --font-size-xxxl: clamp(3.05rem, 3.54vw + 2.17rem, 5rem);
+
+ --neutral-0: #ffffff;
+
+ --brand-primary-base: #0775e3;
+ --brand-primary-hover: #006dc3;
+
+ --primary-text-base: #37434f;
+ --secondary-text-base: #64778c;
+ --tertiary-text-base: #91a5ba;
+
+ --border-color-light: #dde7f0;
+ --border-color-dark: #c1cfde;
+ --border-color-focused: #0775e3;
+
+ --border-radius-1: 0.25rem;
+ --border-radius-1-5: 0.375rem;
+
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ padding: 2rem 0;
+ font-family: var(--font-family);
+ width: 100%;
+
+ * {
+ box-sizing: border-box;
+ margin: 0;
+ padding: 0;
+ }
+
+ h1,
+ h2,
+ h3,
+ h4,
+ p,
+ li,
+ ol {
+ max-width: 60ch;
+ }
+
+ .countdown-title {
+ display: flex;
+ border: 1px solid transparent;
+ margin-bottom: 0.25rem;
+ position: relative;
+ transition: 0.3s all ease-in-out;
+ text-align: center;
+
+ .title-input {
+ position: relative;
+ cursor: text;
+ flex: 1;
+ border: 2px solid transparent;
+ max-width: 22.5rem;
+ font-size: 1.5rem;
+ line-height: 120%;
+ border-radius: var(--border-radius-1-5);
+ padding: 0.625rem 0.875rem;
+ color: var(--primary-text-base);
+ text-align: center;
+ outline: none;
+ resize: none;
+ display: flex;
+ justify-content: center;
+ word-break: break-word;
+ transition:
+ 0.3s text-align ease-in-out,
+ 0.3s border-color ease-in-out;
+
+ &:focus {
+ width: 100%;
+ border: 2px solid var(--border-color-focused);
+ text-align: left;
+ padding-right: 4rem;
+ }
+
+ &:hover {
+ border-color: var(--border-color-light);
+ }
+
+ &:empty:after {
+ color: var(--tertiary-text-base);
+ content: attr(placeholder);
+ white-space: nowrap;
+ width: 100%;
+ text-align: center;
+ }
+
+ &:focus + button {
+ pointer-events: auto;
+ visibility: visible;
+ }
+ }
+
+ button {
+ border: none;
+ transition: 0.3s all ease-in-out;
+ border-radius: var(--border-radius-1);
+ position: absolute;
+ top: 0.45rem;
+ right: 0.45rem;
+ bottom: 0.45rem;
+ background-color: var(--brand-primary-base);
+ color: var(--neutral-0);
+ height: 2.4rem;
+ width: 2.4rem;
+ visibility: hidden;
+ pointer-events: none;
+ transition: none;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+
+ &:hover {
+ cursor: pointer;
+ background-color: var(--brand-primary-hover);
+ }
+ }
+ }
+
+ &__display-grid {
+ background: var(--neutral-0);
+ border: 1px solid var(--border-color-light);
+ filter: drop-shadow(0px 4px 11px rgba(39, 50, 86, 0.03))
+ drop-shadow(0px 2.59259px 6.44213px rgba(39, 50, 86, 0.05))
+ drop-shadow(0px 0.5px 1px rgba(39, 50, 86, 0.12));
+ margin-bottom: 12px;
+ border-radius: var(--border-radius-1-5);
+ display: flex;
+ transition: 0.3s all ease-in-out;
+
+ &__item {
+ min-height: 10rem;
+ min-width: 10rem;
+ padding-top: 1.35rem;
+ padding-bottom: 1.35rem;
+ padding-left: 1.25rem;
+ padding-right: 1.25rem;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ border-right: 1px solid var(--border-color-light);
+
+ &:last-of-type {
+ border-right: none;
+ }
+
+ p:first-of-type {
+ font-size: 4.5rem;
+ font-weight: 700;
+ line-height: var(--line-height-none);
+ letter-spacing: -4%;
+ color: var(--primary-text-base);
+ margin-bottom: 0.25rem;
+ }
+
+ p:last-of-type {
+ color: var(--secondary-text-base);
+ text-transform: uppercase;
+ font-size: var(--font-size-xs);
+ font-weight: 500;
+ }
+ }
+ }
+}
diff --git a/blocks/countdown/src/types/generated/block-entity.ts b/blocks/countdown/src/types/generated/block-entity.ts
new file mode 100644
index 0000000..0ff9b56
--- /dev/null
+++ b/blocks/countdown/src/types/generated/block-entity.ts
@@ -0,0 +1,56 @@
+/**
+ * This file was automatically generated – do not edit it.
+ */
+
+import { Entity } from "@blockprotocol/graph";
+
+export type BlockEntity = CountdownBlock;
+
+export type BlockEntityOutgoingLinkAndTarget =
+ CountdownBlockOutgoingLinkAndTarget;
+
+/**
+ * A True or False value
+ */
+export type BooleanDataType = boolean;
+
+export type CountdownBlock = Entity;
+
+export type CountdownBlockOutgoingLinkAndTarget = never;
+
+export type CountdownBlockOutgoingLinksByLinkEntityTypeId = {};
+
+/**
+ * The block entity for the “Countdown” block.
+ *
+ * See: https://blockprotocol.org/@hash/blocks/countdown
+ */
+export type CountdownBlockProperties = {
+ "https://blockprotocol.org/@blockprotocol/types/property-type/title/"?: TitlePropertyValue;
+ "https://blockprotocol.org/@hash/types/property-type/target-date-and-time/"?: TargetDateAndTimePropertyValue;
+ "https://blockprotocol.org/@hash/types/property-type/countdown-block-should-display-time/"?: CountdownBlockShouldDisplayTimePropertyValue;
+};
+
+/**
+ * Whether or not the Countdown block should display granular time-related information, or just date information.
+ *
+ * See: https://blockprotocol.org/@hash/blocks/countdown
+ */
+export type CountdownBlockShouldDisplayTimePropertyValue = BooleanDataType;
+
+/**
+ * An ISO-8601 formatted date and time that acts as the target for something.
+ *
+ * For example: “2233-03-22T13:30:23Z”
+ */
+export type TargetDateAndTimePropertyValue = TextDataType;
+
+/**
+ * An ordered sequence of characters
+ */
+export type TextDataType = string;
+
+/**
+ * The name given to something to identify it, generally associated with objects or inanimate things such as books, websites, songs, etc.
+ */
+export type TitlePropertyValue = TextDataType;
diff --git a/blocks/countdown/tsconfig.json b/blocks/countdown/tsconfig.json
new file mode 100644
index 0000000..03676c9
--- /dev/null
+++ b/blocks/countdown/tsconfig.json
@@ -0,0 +1,5 @@
+{
+ "extends": "@local/tsconfig/block.json",
+ "include": ["src"],
+ "exclude": ["node_modules"]
+}
diff --git a/blocks/countdown/turbo.json b/blocks/countdown/turbo.json
new file mode 100644
index 0000000..9d80ee7
--- /dev/null
+++ b/blocks/countdown/turbo.json
@@ -0,0 +1,28 @@
+{
+ "extends": ["//"],
+ "tasks": {
+ "codegen": {
+ "inputs": ["./package.json"],
+ "outputs": ["./src/types/generated/**"]
+ },
+ "build": {
+ "dependsOn": ["^build", "codegen", "format"],
+ "outputs": ["./dist/**"]
+ },
+ "lint:tsc": {
+ "dependsOn": ["codegen"]
+ },
+ "format": {
+ "cache": false,
+ "dependsOn": ["codegen"]
+ },
+ "dev": {
+ "persistent": true,
+ "dependsOn": ["^build", "codegen"]
+ },
+ "serve": {
+ "persistent": true,
+ "dependsOn": ["build"]
+ }
+ }
+}
diff --git a/blocks/countdown/variants.json b/blocks/countdown/variants.json
new file mode 100644
index 0000000..fe51488
--- /dev/null
+++ b/blocks/countdown/variants.json
@@ -0,0 +1 @@
+[]
diff --git a/blocks/divider/LICENSE-APACHE.md b/blocks/divider/LICENSE-APACHE.md
new file mode 100644
index 0000000..1d1b6f8
--- /dev/null
+++ b/blocks/divider/LICENSE-APACHE.md
@@ -0,0 +1,189 @@
+# Apache License
+
+_Version 2.0, January 2004_
+_< >_
+
+### Terms and Conditions for use, reproduction, and distribution
+
+#### 1. Definitions
+
+“License” shall mean the terms and conditions for use, reproduction, and
+distribution as defined by Sections 1 through 9 of this document.
+
+“Licensor” shall mean the copyright owner or entity authorized by the copyright
+owner that is granting the License.
+
+“Legal Entity” shall mean the union of the acting entity and all other entities
+that control, are controlled by, or are under common control with that entity.
+For the purposes of this definition, “control” means **(i)** the power, direct or
+indirect, to cause the direction or management of such entity, whether by
+contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the
+outstanding shares, or **(iii)** beneficial ownership of such entity.
+
+“You” (or “Your”) shall mean an individual or Legal Entity exercising
+permissions granted by this License.
+
+“Source” form shall mean the preferred form for making modifications, including
+but not limited to software source code, documentation source, and configuration
+files.
+
+“Object” form shall mean any form resulting from mechanical transformation or
+translation of a Source form, including but not limited to compiled object code,
+generated documentation, and conversions to other media types.
+
+“Work” shall mean the work of authorship, whether in Source or Object form, made
+available under the License, as indicated by a copyright notice that is included
+in or attached to the work (an example is provided in the Appendix below).
+
+“Derivative Works” shall mean any work, whether in Source or Object form, that
+is based on (or derived from) the Work and for which the editorial revisions,
+annotations, elaborations, or other modifications represent, as a whole, an
+original work of authorship. For the purposes of this License, Derivative Works
+shall not include works that remain separable from, or merely link (or bind by
+name) to the interfaces of, the Work and Derivative Works thereof.
+
+“Contribution” shall mean any work of authorship, including the original version
+of the Work and any modifications or additions to that Work or Derivative Works
+thereof, that is intentionally submitted to Licensor for inclusion in the Work
+by the copyright owner or by an individual or Legal Entity authorized to submit
+on behalf of the copyright owner. For the purposes of this definition,
+“submitted” means any form of electronic, verbal, or written communication sent
+to the Licensor or its representatives, including but not limited to
+communication on electronic mailing lists, source code control systems, and
+issue tracking systems that are managed by, or on behalf of, the Licensor for
+the purpose of discussing and improving the Work, but excluding communication
+that is conspicuously marked or otherwise designated in writing by the copyright
+owner as “Not a Contribution.”
+
+“Contributor” shall mean Licensor and any individual or Legal Entity on behalf
+of whom a Contribution has been received by Licensor and subsequently
+incorporated within the Work.
+
+#### 2. Grant of Copyright License
+
+Subject to the terms and conditions of this License, each Contributor hereby
+grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
+irrevocable copyright license to reproduce, prepare Derivative Works of,
+publicly display, publicly perform, sublicense, and distribute the Work and such
+Derivative Works in Source or Object form.
+
+#### 3. Grant of Patent License
+
+Subject to the terms and conditions of this License, each Contributor hereby
+grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
+irrevocable (except as stated in this section) patent license to make, have
+made, use, offer to sell, sell, import, and otherwise transfer the Work, where
+such license applies only to those patent claims licensable by such Contributor
+that are necessarily infringed by their Contribution(s) alone or by combination
+of their Contribution(s) with the Work to which such Contribution(s) was
+submitted. If You institute patent litigation against any entity (including a
+cross-claim or counterclaim in a lawsuit) alleging that the Work or a
+Contribution incorporated within the Work constitutes direct or contributory
+patent infringement, then any patent licenses granted to You under this License
+for that Work shall terminate as of the date such litigation is filed.
+
+#### 4. Redistribution
+
+You may reproduce and distribute copies of the Work or Derivative Works thereof
+in any medium, with or without modifications, and in Source or Object form,
+provided that You meet the following conditions:
+
+- **(a)** You must give any other recipients of the Work or Derivative Works a copy of
+ this License; and
+- **(b)** You must cause any modified files to carry prominent notices stating that You
+ changed the files; and
+- **(c)** You must retain, in the Source form of any Derivative Works that You distribute,
+ all copyright, patent, trademark, and attribution notices from the Source form
+ of the Work, excluding those notices that do not pertain to any part of the
+ Derivative Works; and
+- **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any
+ Derivative Works that You distribute must include a readable copy of the
+ attribution notices contained within such NOTICE file, excluding those notices
+ that do not pertain to any part of the Derivative Works, in at least one of the
+ following places: within a NOTICE text file distributed as part of the
+ Derivative Works; within the Source form or documentation, if provided along
+ with the Derivative Works; or, within a display generated by the Derivative
+ Works, if and wherever such third-party notices normally appear. The contents of
+ the NOTICE file are for informational purposes only and do not modify the
+ License. You may add Your own attribution notices within Derivative Works that
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
+ provided that such additional attribution notices cannot be construed as
+ modifying the License.
+
+You may add Your own copyright statement to Your modifications and may provide
+additional or different license terms and conditions for use, reproduction, or
+distribution of Your modifications, or for any such Derivative Works as a whole,
+provided Your use, reproduction, and distribution of the Work otherwise complies
+with the conditions stated in this License.
+
+#### 5. Submission of Contributions
+
+Unless You explicitly state otherwise, any Contribution intentionally submitted
+for inclusion in the Work by You to the Licensor shall be under the terms and
+conditions of this License, without any additional terms or conditions.
+Notwithstanding the above, nothing herein shall supersede or modify the terms of
+any separate license agreement you may have executed with Licensor regarding
+such Contributions.
+
+#### 6. Trademarks
+
+This License does not grant permission to use the trade names, trademarks,
+service marks, or product names of the Licensor, except as required for
+reasonable and customary use in describing the origin of the Work and
+reproducing the content of the NOTICE file.
+
+#### 7. Disclaimer of Warranty
+
+Unless required by applicable law or agreed to in writing, Licensor provides the
+Work (and each Contributor provides its Contributions) on an “AS IS” BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
+including, without limitation, any warranties or conditions of TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
+solely responsible for determining the appropriateness of using or
+redistributing the Work and assume any risks associated with Your exercise of
+permissions under this License.
+
+#### 8. Limitation of Liability
+
+In no event and under no legal theory, whether in tort (including negligence),
+contract, or otherwise, unless required by applicable law (such as deliberate
+and grossly negligent acts) or agreed to in writing, shall any Contributor be
+liable to You for damages, including any direct, indirect, special, incidental,
+or consequential damages of any character arising as a result of this License or
+out of the use or inability to use the Work (including but not limited to
+damages for loss of goodwill, work stoppage, computer failure or malfunction, or
+any and all other commercial damages or losses), even if such Contributor has
+been advised of the possibility of such damages.
+
+#### 9. Accepting Warranty or Additional Liability
+
+While redistributing the Work or Derivative Works thereof, You may choose to
+offer, and charge a fee for, acceptance of support, warranty, indemnity, or
+other liability obligations and/or rights consistent with this License. However,
+in accepting such obligations, You may act only on Your own behalf and on Your
+sole responsibility, not on behalf of any other Contributor, and only if You
+agree to indemnify, defend, and hold each Contributor harmless for any liability
+incurred by, or claims asserted against, such Contributor by reason of your
+accepting any such warranty or additional liability.
+
+_END OF TERMS AND CONDITIONS_
+
+### APPENDIX: Apply the Apache License to a specific file
+
+To apply the Apache License to an individual file, attach the following notice.
+The text should be enclosed in the appropriate comment syntax for the file
+format.
+
+ Copyright © 2022–, HASH
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/blocks/divider/LICENSE-MIT.md b/blocks/divider/LICENSE-MIT.md
new file mode 100644
index 0000000..e33c1d3
--- /dev/null
+++ b/blocks/divider/LICENSE-MIT.md
@@ -0,0 +1,21 @@
+# MIT License
+
+Copyright © 2022–, HASH
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/blocks/divider/LICENSE.md b/blocks/divider/LICENSE.md
new file mode 100644
index 0000000..8686df9
--- /dev/null
+++ b/blocks/divider/LICENSE.md
@@ -0,0 +1,5 @@
+# License
+
+Licensed under either of the [Apache License, Version 2.0](LICENSE-APACHE.md) or [MIT license](LICENSE-MIT.md) at your option.
+
+For more information about contributing to this block, see our top-level [CONTRIBUTING](https://github.com/hashintel/hash/blob/main/.github/CONTRIBUTING.md) policy.
diff --git a/blocks/divider/README.md b/blocks/divider/README.md
new file mode 100644
index 0000000..da4a3c1
--- /dev/null
+++ b/blocks/divider/README.md
@@ -0,0 +1,12 @@
+The Divider block is a customizable wrapper around an `
` element.
+
+## Programmatic Usage
+
+The divider can be customized with the following properties ([view the Divider Block entity type](https://blockprotocol.org/@hash/types/entity-type/divider-block/v/2) to see these in context):
+
+- [`Height In Pixels`](https://blockprotocol.org/@blockprotocol/types/property-type/height-in-pixels/)
+- [`CSS Background Color`](https://blockprotocol.org/@blockprotocol/types/property-type/css-background-color/)
+
+Its width is set to 100% and its border to "none", allowing the `Height In Pixels` property to control the line's thickness. The `CSS Background Color` property sets the element's background color.
+
+By default, the line will be 1px thick and black.
diff --git a/blocks/divider/eslint.config.js b/blocks/divider/eslint.config.js
new file mode 100644
index 0000000..5b6bb9d
--- /dev/null
+++ b/blocks/divider/eslint.config.js
@@ -0,0 +1,3 @@
+import { createBlock } from "@local/eslint/deprecated";
+
+export default createBlock(import.meta.dirname);
diff --git a/blocks/divider/package.json b/blocks/divider/package.json
new file mode 100644
index 0000000..5c9a96c
--- /dev/null
+++ b/blocks/divider/package.json
@@ -0,0 +1,80 @@
+{
+ "name": "@blocks/divider",
+ "version": "0.1.2",
+ "private": true,
+ "description": "Break up content on a page with horizontal dividing lines",
+ "keywords": [
+ "blockprotocol",
+ "blocks",
+ "block"
+ ],
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/hashintel/blocks.git#main",
+ "directory": "blocks/divider"
+ },
+ "license": "(MIT OR Apache-2.0)",
+ "author": "HASH",
+ "type": "module",
+ "scripts": {
+ "build": "block-scripts build",
+ "codegen": "block-scripts codegen && yarn format",
+ "dev": "block-scripts dev",
+ "fix:eslint": "eslint --fix .",
+ "format": "prettier --write --ignore-unknown src/types/generated/*.ts",
+ "lint:eslint": "eslint --report-unused-disable-directives .",
+ "lint:tsc": "tsc --noEmit",
+ "serve": "block-scripts serve"
+ },
+ "dependencies": {
+ "@blockprotocol/core": "0.1.4",
+ "@blockprotocol/graph": "0.3.4"
+ },
+ "devDependencies": {
+ "@local/eslint": "0.0.0-private",
+ "@local/tsconfig": "0.0.0-private",
+ "@types/react-dom": "19.1.7",
+ "block-scripts": "0.3.4",
+ "eslint": "10.0.3",
+ "mock-block-dock": "0.1.9",
+ "prettier": "3.8.1",
+ "react": "19.1.1",
+ "react-dom": "19.1.1",
+ "typescript": "5.9.3"
+ },
+ "peerDependencies": {
+ "react": "^19.0.0",
+ "react-dom": "^19.0.0"
+ },
+ "block-scripts": {
+ "devPort": 9090,
+ "servePort": 62679
+ },
+ "blockprotocol": {
+ "blockType": {
+ "entryPoint": "react"
+ },
+ "name": "@hash/divider",
+ "displayName": "Divider",
+ "icon": "public/divider.svg",
+ "image": "public/preview.svg",
+ "examples": [
+ {
+ "https://blockprotocol.org/@blockprotocol/types/property-type/css-background-color/": "black",
+ "https://blockprotocol.org/@blockprotocol/types/property-type/height-in-pixels/": "2px"
+ }
+ ],
+ "protocol": "0.3",
+ "blockEntityType": "https://blockprotocol.org/@hash/types/entity-type/divider-block/v/2",
+ "codegen": {
+ "outputFolder": "src/types/generated",
+ "targets": {
+ "block-entity.ts": [
+ {
+ "blockEntityType": true
+ }
+ ]
+ }
+ }
+ }
+}
diff --git a/blocks/divider/public/divider.svg b/blocks/divider/public/divider.svg
new file mode 100644
index 0000000..f805eb3
--- /dev/null
+++ b/blocks/divider/public/divider.svg
@@ -0,0 +1,7 @@
+
diff --git a/blocks/divider/public/preview.svg b/blocks/divider/public/preview.svg
new file mode 100644
index 0000000..4bc6ea7
--- /dev/null
+++ b/blocks/divider/public/preview.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/blocks/divider/src/app.tsx b/blocks/divider/src/app.tsx
new file mode 100644
index 0000000..0563299
--- /dev/null
+++ b/blocks/divider/src/app.tsx
@@ -0,0 +1,24 @@
+import type { BlockComponent } from "@blockprotocol/graph/react";
+import { useEntitySubgraph } from "@blockprotocol/graph/react";
+
+import { propertyIds } from "./property-ids";
+import type { BlockEntity } from "./types/generated/block-entity";
+
+export const App: BlockComponent = ({
+ graph: { blockEntitySubgraph },
+}) => {
+ const { rootEntity } = useEntitySubgraph(blockEntitySubgraph);
+ const { [propertyIds.color]: color, [propertyIds.height]: height } =
+ rootEntity.properties;
+
+ return (
+
+ );
+};
diff --git a/blocks/divider/src/dev.tsx b/blocks/divider/src/dev.tsx
new file mode 100644
index 0000000..c305fc5
--- /dev/null
+++ b/blocks/divider/src/dev.tsx
@@ -0,0 +1,45 @@
+/**
+ * This is the entry point for developing and debugging.
+ * This file is not bundled with the block during the build process.
+ */
+import type { VersionedUrl } from "@blockprotocol/graph";
+import { MockBlockDock } from "mock-block-dock";
+import { createRoot } from "react-dom/client";
+
+import packageJSON from "../package.json";
+import Component from "./index";
+import { propertyIds } from "./property-ids";
+import type { BlockEntity } from "./types/generated/block-entity";
+
+const node = document.getElementById("app");
+
+const initialData: BlockEntity = {
+ metadata: {
+ entityTypeId: packageJSON.blockprotocol.blockEntityType as VersionedUrl,
+ recordId: {
+ entityId: "entity-divider",
+ editionId: "1",
+ },
+ },
+ properties: {
+ [propertyIds.color]: "red",
+ [propertyIds.height]: 2,
+ },
+};
+
+const App = () => (
+
+);
+
+createRoot(node!).render( );
diff --git a/blocks/divider/src/index.ts b/blocks/divider/src/index.ts
new file mode 100644
index 0000000..6eb172a
--- /dev/null
+++ b/blocks/divider/src/index.ts
@@ -0,0 +1,8 @@
+/* eslint-disable canonical/filename-no-index -- @todo rename file */
+
+/**
+ * Entrypoint of the Block Component.
+ */
+import { App } from "./app";
+
+export default App;
diff --git a/blocks/divider/src/property-ids.ts b/blocks/divider/src/property-ids.ts
new file mode 100644
index 0000000..dbeba6d
--- /dev/null
+++ b/blocks/divider/src/property-ids.ts
@@ -0,0 +1,6 @@
+export const propertyIds = {
+ color:
+ "https://blockprotocol.org/@blockprotocol/types/property-type/css-background-color/" as const,
+ height:
+ "https://blockprotocol.org/@blockprotocol/types/property-type/height-in-pixels/" as const,
+};
diff --git a/blocks/divider/src/types/generated/block-entity.ts b/blocks/divider/src/types/generated/block-entity.ts
new file mode 100644
index 0000000..44ac213
--- /dev/null
+++ b/blocks/divider/src/types/generated/block-entity.ts
@@ -0,0 +1,58 @@
+/**
+ * This file was automatically generated – do not edit it.
+ */
+
+import { Entity } from "@blockprotocol/graph";
+
+export type BlockEntity = DividerBlock;
+
+export type BlockEntityOutgoingLinkAndTarget =
+ DividerBlockOutgoingLinkAndTarget;
+
+/**
+ * The text color represented as a CSS-compatible color property expressed as a string.
+ *
+ * This is any ‘legal’ color value in CSS, for example (but not limited to)
+ *
+ * - a hexadecimal string: “#FFFFFF”
+ *
+ * - a named color: “skyblue”
+ *
+ * - an RGB value in functional notation: “rgb(255, 0, 255)”
+ *
+ * - an HSLA value in functional notation: “hsla(120, 100%, 50%)”
+ *
+ * See: https://www.w3schools.com/cssref/css_colors_legal.php
+ */
+export type CSSBackgroundColorPropertyValue = TextDataType;
+
+export type DividerBlock = Entity;
+
+export type DividerBlockOutgoingLinkAndTarget = never;
+
+export type DividerBlockOutgoingLinksByLinkEntityTypeId = {};
+
+/**
+ * The block entity for the “Divider” block.
+ *
+ * See: https://blockprotocol.org/@hash/blocks/divider
+ */
+export type DividerBlockProperties = {
+ "https://blockprotocol.org/@blockprotocol/types/property-type/height-in-pixels/"?: HeightInPixelsPropertyValue;
+ "https://blockprotocol.org/@blockprotocol/types/property-type/css-background-color/"?: CSSBackgroundColorPropertyValue;
+};
+
+/**
+ * The height of a UI element in pixels.
+ */
+export type HeightInPixelsPropertyValue = NumberDataType;
+
+/**
+ * An arithmetical value (in the Real number system)
+ */
+export type NumberDataType = number;
+
+/**
+ * An ordered sequence of characters
+ */
+export type TextDataType = string;
diff --git a/blocks/divider/tsconfig.json b/blocks/divider/tsconfig.json
new file mode 100644
index 0000000..03676c9
--- /dev/null
+++ b/blocks/divider/tsconfig.json
@@ -0,0 +1,5 @@
+{
+ "extends": "@local/tsconfig/block.json",
+ "include": ["src"],
+ "exclude": ["node_modules"]
+}
diff --git a/blocks/divider/turbo.json b/blocks/divider/turbo.json
new file mode 100644
index 0000000..9d80ee7
--- /dev/null
+++ b/blocks/divider/turbo.json
@@ -0,0 +1,28 @@
+{
+ "extends": ["//"],
+ "tasks": {
+ "codegen": {
+ "inputs": ["./package.json"],
+ "outputs": ["./src/types/generated/**"]
+ },
+ "build": {
+ "dependsOn": ["^build", "codegen", "format"],
+ "outputs": ["./dist/**"]
+ },
+ "lint:tsc": {
+ "dependsOn": ["codegen"]
+ },
+ "format": {
+ "cache": false,
+ "dependsOn": ["codegen"]
+ },
+ "dev": {
+ "persistent": true,
+ "dependsOn": ["^build", "codegen"]
+ },
+ "serve": {
+ "persistent": true,
+ "dependsOn": ["build"]
+ }
+ }
+}
diff --git a/blocks/embed/LICENSE-APACHE.md b/blocks/embed/LICENSE-APACHE.md
new file mode 100644
index 0000000..1d1b6f8
--- /dev/null
+++ b/blocks/embed/LICENSE-APACHE.md
@@ -0,0 +1,189 @@
+# Apache License
+
+_Version 2.0, January 2004_
+_< >_
+
+### Terms and Conditions for use, reproduction, and distribution
+
+#### 1. Definitions
+
+“License” shall mean the terms and conditions for use, reproduction, and
+distribution as defined by Sections 1 through 9 of this document.
+
+“Licensor” shall mean the copyright owner or entity authorized by the copyright
+owner that is granting the License.
+
+“Legal Entity” shall mean the union of the acting entity and all other entities
+that control, are controlled by, or are under common control with that entity.
+For the purposes of this definition, “control” means **(i)** the power, direct or
+indirect, to cause the direction or management of such entity, whether by
+contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the
+outstanding shares, or **(iii)** beneficial ownership of such entity.
+
+“You” (or “Your”) shall mean an individual or Legal Entity exercising
+permissions granted by this License.
+
+“Source” form shall mean the preferred form for making modifications, including
+but not limited to software source code, documentation source, and configuration
+files.
+
+“Object” form shall mean any form resulting from mechanical transformation or
+translation of a Source form, including but not limited to compiled object code,
+generated documentation, and conversions to other media types.
+
+“Work” shall mean the work of authorship, whether in Source or Object form, made
+available under the License, as indicated by a copyright notice that is included
+in or attached to the work (an example is provided in the Appendix below).
+
+“Derivative Works” shall mean any work, whether in Source or Object form, that
+is based on (or derived from) the Work and for which the editorial revisions,
+annotations, elaborations, or other modifications represent, as a whole, an
+original work of authorship. For the purposes of this License, Derivative Works
+shall not include works that remain separable from, or merely link (or bind by
+name) to the interfaces of, the Work and Derivative Works thereof.
+
+“Contribution” shall mean any work of authorship, including the original version
+of the Work and any modifications or additions to that Work or Derivative Works
+thereof, that is intentionally submitted to Licensor for inclusion in the Work
+by the copyright owner or by an individual or Legal Entity authorized to submit
+on behalf of the copyright owner. For the purposes of this definition,
+“submitted” means any form of electronic, verbal, or written communication sent
+to the Licensor or its representatives, including but not limited to
+communication on electronic mailing lists, source code control systems, and
+issue tracking systems that are managed by, or on behalf of, the Licensor for
+the purpose of discussing and improving the Work, but excluding communication
+that is conspicuously marked or otherwise designated in writing by the copyright
+owner as “Not a Contribution.”
+
+“Contributor” shall mean Licensor and any individual or Legal Entity on behalf
+of whom a Contribution has been received by Licensor and subsequently
+incorporated within the Work.
+
+#### 2. Grant of Copyright License
+
+Subject to the terms and conditions of this License, each Contributor hereby
+grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
+irrevocable copyright license to reproduce, prepare Derivative Works of,
+publicly display, publicly perform, sublicense, and distribute the Work and such
+Derivative Works in Source or Object form.
+
+#### 3. Grant of Patent License
+
+Subject to the terms and conditions of this License, each Contributor hereby
+grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
+irrevocable (except as stated in this section) patent license to make, have
+made, use, offer to sell, sell, import, and otherwise transfer the Work, where
+such license applies only to those patent claims licensable by such Contributor
+that are necessarily infringed by their Contribution(s) alone or by combination
+of their Contribution(s) with the Work to which such Contribution(s) was
+submitted. If You institute patent litigation against any entity (including a
+cross-claim or counterclaim in a lawsuit) alleging that the Work or a
+Contribution incorporated within the Work constitutes direct or contributory
+patent infringement, then any patent licenses granted to You under this License
+for that Work shall terminate as of the date such litigation is filed.
+
+#### 4. Redistribution
+
+You may reproduce and distribute copies of the Work or Derivative Works thereof
+in any medium, with or without modifications, and in Source or Object form,
+provided that You meet the following conditions:
+
+- **(a)** You must give any other recipients of the Work or Derivative Works a copy of
+ this License; and
+- **(b)** You must cause any modified files to carry prominent notices stating that You
+ changed the files; and
+- **(c)** You must retain, in the Source form of any Derivative Works that You distribute,
+ all copyright, patent, trademark, and attribution notices from the Source form
+ of the Work, excluding those notices that do not pertain to any part of the
+ Derivative Works; and
+- **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any
+ Derivative Works that You distribute must include a readable copy of the
+ attribution notices contained within such NOTICE file, excluding those notices
+ that do not pertain to any part of the Derivative Works, in at least one of the
+ following places: within a NOTICE text file distributed as part of the
+ Derivative Works; within the Source form or documentation, if provided along
+ with the Derivative Works; or, within a display generated by the Derivative
+ Works, if and wherever such third-party notices normally appear. The contents of
+ the NOTICE file are for informational purposes only and do not modify the
+ License. You may add Your own attribution notices within Derivative Works that
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
+ provided that such additional attribution notices cannot be construed as
+ modifying the License.
+
+You may add Your own copyright statement to Your modifications and may provide
+additional or different license terms and conditions for use, reproduction, or
+distribution of Your modifications, or for any such Derivative Works as a whole,
+provided Your use, reproduction, and distribution of the Work otherwise complies
+with the conditions stated in this License.
+
+#### 5. Submission of Contributions
+
+Unless You explicitly state otherwise, any Contribution intentionally submitted
+for inclusion in the Work by You to the Licensor shall be under the terms and
+conditions of this License, without any additional terms or conditions.
+Notwithstanding the above, nothing herein shall supersede or modify the terms of
+any separate license agreement you may have executed with Licensor regarding
+such Contributions.
+
+#### 6. Trademarks
+
+This License does not grant permission to use the trade names, trademarks,
+service marks, or product names of the Licensor, except as required for
+reasonable and customary use in describing the origin of the Work and
+reproducing the content of the NOTICE file.
+
+#### 7. Disclaimer of Warranty
+
+Unless required by applicable law or agreed to in writing, Licensor provides the
+Work (and each Contributor provides its Contributions) on an “AS IS” BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
+including, without limitation, any warranties or conditions of TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
+solely responsible for determining the appropriateness of using or
+redistributing the Work and assume any risks associated with Your exercise of
+permissions under this License.
+
+#### 8. Limitation of Liability
+
+In no event and under no legal theory, whether in tort (including negligence),
+contract, or otherwise, unless required by applicable law (such as deliberate
+and grossly negligent acts) or agreed to in writing, shall any Contributor be
+liable to You for damages, including any direct, indirect, special, incidental,
+or consequential damages of any character arising as a result of this License or
+out of the use or inability to use the Work (including but not limited to
+damages for loss of goodwill, work stoppage, computer failure or malfunction, or
+any and all other commercial damages or losses), even if such Contributor has
+been advised of the possibility of such damages.
+
+#### 9. Accepting Warranty or Additional Liability
+
+While redistributing the Work or Derivative Works thereof, You may choose to
+offer, and charge a fee for, acceptance of support, warranty, indemnity, or
+other liability obligations and/or rights consistent with this License. However,
+in accepting such obligations, You may act only on Your own behalf and on Your
+sole responsibility, not on behalf of any other Contributor, and only if You
+agree to indemnify, defend, and hold each Contributor harmless for any liability
+incurred by, or claims asserted against, such Contributor by reason of your
+accepting any such warranty or additional liability.
+
+_END OF TERMS AND CONDITIONS_
+
+### APPENDIX: Apply the Apache License to a specific file
+
+To apply the Apache License to an individual file, attach the following notice.
+The text should be enclosed in the appropriate comment syntax for the file
+format.
+
+ Copyright © 2022–, HASH
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/blocks/embed/LICENSE-MIT.md b/blocks/embed/LICENSE-MIT.md
new file mode 100644
index 0000000..e33c1d3
--- /dev/null
+++ b/blocks/embed/LICENSE-MIT.md
@@ -0,0 +1,21 @@
+# MIT License
+
+Copyright © 2022–, HASH
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/blocks/embed/LICENSE.md b/blocks/embed/LICENSE.md
new file mode 100644
index 0000000..8686df9
--- /dev/null
+++ b/blocks/embed/LICENSE.md
@@ -0,0 +1,5 @@
+# License
+
+Licensed under either of the [Apache License, Version 2.0](LICENSE-APACHE.md) or [MIT license](LICENSE-MIT.md) at your option.
+
+For more information about contributing to this block, see our top-level [CONTRIBUTING](https://github.com/hashintel/hash/blob/main/.github/CONTRIBUTING.md) policy.
diff --git a/blocks/embed/README.md b/blocks/embed/README.md
new file mode 100644
index 0000000..fb51c2d
--- /dev/null
+++ b/blocks/embed/README.md
@@ -0,0 +1,3 @@
+# Embed block
+
+A block to embed content from third-party sites.
diff --git a/blocks/embed/eslint.config.js b/blocks/embed/eslint.config.js
new file mode 100644
index 0000000..5b6bb9d
--- /dev/null
+++ b/blocks/embed/eslint.config.js
@@ -0,0 +1,3 @@
+import { createBlock } from "@local/eslint/deprecated";
+
+export default createBlock(import.meta.dirname);
diff --git a/blocks/embed/package.json b/blocks/embed/package.json
new file mode 100644
index 0000000..367bf0d
--- /dev/null
+++ b/blocks/embed/package.json
@@ -0,0 +1,70 @@
+{
+ "name": "@blocks/embed",
+ "version": "0.1.1",
+ "private": true,
+ "description": "Embed external content",
+ "keywords": [
+ "blockprotocol",
+ "blocks",
+ "block"
+ ],
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/hashintel/blocks.git#main",
+ "directory": "blocks/embed"
+ },
+ "license": "(MIT OR Apache-2.0)",
+ "author": "HASH",
+ "type": "module",
+ "scripts": {
+ "build": "block-scripts build",
+ "dev": "block-scripts dev",
+ "fix:eslint": "eslint --fix .",
+ "lint:eslint": "eslint --report-unused-disable-directives .",
+ "lint:tsc": "tsc --noEmit",
+ "serve": "block-scripts serve"
+ },
+ "dependencies": {
+ "blockprotocol": "patch:blockprotocol@npm%3A0.0.12#~/.yarn/patches/blockprotocol-npm-0.0.12-2558a31f0a.patch",
+ "lodash": "4.18.1",
+ "twind": "0.16.19"
+ },
+ "devDependencies": {
+ "@local/eslint": "0.0.0-private",
+ "@local/tsconfig": "0.0.0-private",
+ "@types/lodash": "4.17.20",
+ "@types/react-dom": "19.1.7",
+ "block-scripts": "0.0.14",
+ "eslint": "10.0.3",
+ "mock-block-dock": "0.0.10",
+ "react": "19.1.1",
+ "react-dom": "19.1.1",
+ "typescript": "5.9.3"
+ },
+ "peerDependencies": {
+ "lodash": "4.18.1",
+ "react": "^19.0.0",
+ "react-dom": "^19.0.0"
+ },
+ "block-scripts": {
+ "devPort": 9090,
+ "servePort": 62680
+ },
+ "blockprotocol": {
+ "blockType": {
+ "entryPoint": "react"
+ },
+ "name": "@hash/embed",
+ "displayName": "Embed",
+ "icon": "public/embed.svg",
+ "image": "public/preview.svg",
+ "examples": [
+ {
+ "initialHtml": "",
+ "initialWidth": 600,
+ "initialHeight": 340
+ }
+ ],
+ "protocol": "0.1"
+ }
+}
diff --git a/blocks/embed/public/embed.svg b/blocks/embed/public/embed.svg
new file mode 100644
index 0000000..809ffb6
--- /dev/null
+++ b/blocks/embed/public/embed.svg
@@ -0,0 +1,3 @@
+
diff --git a/blocks/embed/public/hash.svg b/blocks/embed/public/hash.svg
new file mode 100644
index 0000000..2ab1bfb
--- /dev/null
+++ b/blocks/embed/public/hash.svg
@@ -0,0 +1,3 @@
+
diff --git a/blocks/embed/public/preview.svg b/blocks/embed/public/preview.svg
new file mode 100644
index 0000000..6970b9c
--- /dev/null
+++ b/blocks/embed/public/preview.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/blocks/embed/public/spotify.svg b/blocks/embed/public/spotify.svg
new file mode 100644
index 0000000..f8fcfc2
--- /dev/null
+++ b/blocks/embed/public/spotify.svg
@@ -0,0 +1,3 @@
+
diff --git a/blocks/embed/public/twitter.svg b/blocks/embed/public/twitter.svg
new file mode 100644
index 0000000..5d37d13
--- /dev/null
+++ b/blocks/embed/public/twitter.svg
@@ -0,0 +1,3 @@
+
diff --git a/blocks/embed/public/youtube.svg b/blocks/embed/public/youtube.svg
new file mode 100644
index 0000000..017b04c
--- /dev/null
+++ b/blocks/embed/public/youtube.svg
@@ -0,0 +1,3 @@
+
diff --git a/blocks/embed/src/app.tsx b/blocks/embed/src/app.tsx
new file mode 100644
index 0000000..2d070cc
--- /dev/null
+++ b/blocks/embed/src/app.tsx
@@ -0,0 +1,360 @@
+/* @todo This package needs updating to use the latest @blockprotocol/graph package in this repo */
+// eslint-disable-next-line @typescript-eslint/ban-ts-comment
+// @ts-nocheck
+/* eslint-disable */
+
+import type { BlockProtocolUpdateEntitiesAction } from "blockprotocol";
+import type { BlockComponent } from "blockprotocol/react";
+import type { Reducer } from "react";
+import {
+ useCallback,
+ useEffect,
+ useLayoutEffect,
+ useReducer,
+ useRef,
+} from "react";
+import { setup, tw } from "twind";
+
+import { EditView } from "./components/edit-view";
+import { ResizeBlock } from "./components/resize-block";
+import {
+ BASE_HEIGHT,
+ BASE_WIDTH,
+ MAX_WIDTH,
+ PROVIDER_NAMES_THAT_CANT_BE_RESIZED,
+ PROVIDER_NAMES_TO_RESPECT_ASPECT_RATIO,
+} from "./constants";
+import { HtmlBlock } from "./html-block";
+import Pencil from "./svgs/pencil";
+import type { Actions, AppState, ProviderName } from "./types";
+import { getFormCopy } from "./utils";
+
+type BlockEntityProperties = {
+ // @todo temporarily using application-provided getEmbedCode - implement fallbacks for CORS-blocked oembed endpoints and remove
+ getEmbedBlock: (
+ url: string,
+ type?: ProviderName,
+ ) => Promise<{
+ html: string;
+ error?: string;
+ height?: number;
+ width?: number;
+ providerName?: string;
+ }>;
+ embedType?: ProviderName;
+ initialHtml?: string;
+ initialWidth?: number;
+ initialHeight?: number;
+};
+
+const getInitialState = ({
+ html,
+ width,
+ height,
+ embedType,
+}: Partial = {}) => ({
+ embedUrl: "",
+ embedType,
+ html,
+ width,
+ height,
+ maxWidth: MAX_WIDTH,
+ loading: false,
+ errorString: "",
+});
+
+const reducer = (state: AppState, action: Actions): AppState => {
+ switch (action.type) {
+ case "UPDATE_STATE":
+ return {
+ ...state,
+ ...action.payload,
+ };
+
+ case "RESET_STATE":
+ return {
+ ...getInitialState(),
+ embedType: state.embedType,
+ embedUrl: state.embedUrl,
+ };
+
+ default:
+ return state;
+ }
+};
+
+setup({ preflight: false });
+
+export const App: BlockComponent = ({
+ accountId,
+ embedType: initialEmbedType,
+ getEmbedBlock,
+ initialHtml,
+ initialHeight,
+ initialWidth,
+ entityId,
+ entityTypeId,
+ entityTypeVersionId,
+ updateEntities,
+}) => {
+ const [
+ {
+ embedUrl,
+ html,
+ width,
+ height,
+ embedType,
+ maxWidth,
+ loading,
+ errorString,
+ },
+ dispatch,
+ ] = useReducer>(
+ reducer,
+ getInitialState({
+ html: initialHtml,
+ width: initialWidth,
+ height: initialHeight,
+ embedType: initialEmbedType,
+ }),
+ );
+
+ const containerRef = useRef(null);
+ // The default width the block takes up. Ideally it should be provided by the EA
+ const blockWidthRef = useRef(null);
+
+ const getBlockDefaultSize = useCallback(
+ ({
+ embedType: providerName,
+ embedWidth,
+ embedHeight,
+ }: {
+ embedType: ProviderName | undefined;
+ embedWidth: number | undefined;
+ embedHeight: number | undefined;
+ }) => {
+ const blockShouldNotBeResized =
+ providerName && PROVIDER_NAMES_THAT_CANT_BE_RESIZED.has(providerName);
+
+ const blockShouldRespectAspectRatio =
+ providerName &&
+ PROVIDER_NAMES_TO_RESPECT_ASPECT_RATIO.has(providerName);
+
+ let defaultWidth: number = BASE_WIDTH;
+ let defaultHeight: number = BASE_HEIGHT;
+
+ if (blockShouldNotBeResized) {
+ defaultWidth = embedWidth as number;
+ defaultHeight = embedHeight as number;
+ } else {
+ defaultWidth = Math.min(
+ Math.max(blockWidthRef.current ?? 0, defaultWidth),
+ maxWidth,
+ );
+
+ if (blockShouldRespectAspectRatio && embedHeight && embedWidth) {
+ const embedAspectRatio =
+ Math.round((embedWidth / embedHeight) * 100) / 100;
+ if (embedAspectRatio) {
+ defaultHeight = Math.ceil(defaultWidth / embedAspectRatio);
+ }
+ }
+ }
+
+ return {
+ defaultWidth,
+ defaultHeight,
+ };
+ },
+ [maxWidth],
+ );
+
+ useEffect(() => {
+ const { defaultHeight, defaultWidth } = getBlockDefaultSize({
+ embedHeight: initialHeight,
+ embedWidth: initialWidth,
+ embedType: initialEmbedType,
+ });
+
+ dispatch({
+ type: "UPDATE_STATE",
+ payload: {
+ html: initialHtml,
+ width: defaultWidth,
+ height: defaultHeight,
+ embedType: initialEmbedType,
+ },
+ });
+ }, [
+ getBlockDefaultSize,
+ initialHtml,
+ initialHeight,
+ initialWidth,
+ initialEmbedType,
+ ]);
+
+ const setErrorString = (error: string) =>
+ dispatch({ type: "UPDATE_STATE", payload: { errorString: error } });
+
+ useLayoutEffect(() => {
+ if (!containerRef.current) return;
+ const blockWidth = containerRef.current.getBoundingClientRect().width;
+
+ if (!blockWidthRef.current) {
+ blockWidthRef.current = blockWidth;
+ }
+
+ if (html && !width && !initialWidth) {
+ dispatch({ type: "UPDATE_STATE", payload: { width: blockWidth } });
+ }
+ }, [html, width, initialWidth]);
+
+ const updateRemoteData = useCallback(
+ (
+ properties: Partial<
+ Pick & {
+ embedType: string;
+ }
+ >,
+ ) => {
+ const data = {
+ initialHtml: properties.html,
+ initialHeight: properties.height,
+ initialWidth: properties.width,
+ embedType: properties.embedType,
+ };
+
+ const updateAction: BlockProtocolUpdateEntitiesAction = {
+ accountId,
+ data,
+ entityId,
+ entityTypeId,
+ entityTypeVersionId,
+ };
+
+ if (updateEntities) {
+ void updateEntities([updateAction]);
+ }
+ },
+ [accountId, entityId, entityTypeId, entityTypeVersionId, updateEntities],
+ );
+
+ const handleGetEmbed = async () => {
+ if (!embedUrl) {
+ return;
+ }
+
+ dispatch({ type: "UPDATE_STATE", payload: { loading: true } });
+
+ const responseData = await getEmbedBlock(embedUrl, embedType);
+ const {
+ html: embedHtml,
+ height: embedHeight,
+ width: embedWidth,
+ providerName,
+ error,
+ } = responseData;
+
+ if (error) {
+ return dispatch({
+ type: "UPDATE_STATE",
+ payload: { errorString: error, loading: false },
+ });
+ }
+
+ const { defaultHeight, defaultWidth } = getBlockDefaultSize({
+ embedHeight,
+ embedType: providerName as ProviderName,
+ embedWidth,
+ });
+
+ const payload = {
+ html: embedHtml,
+ width: defaultWidth,
+ height: defaultHeight,
+ embedType: providerName as ProviderName,
+ };
+
+ dispatch({ type: "UPDATE_STATE", payload: { ...payload, loading: false } });
+
+ updateRemoteData(payload);
+ };
+
+ const resetData = () => {
+ dispatch({ type: "RESET_STATE" });
+
+ updateRemoteData({});
+ };
+
+ const updateDimensions = useCallback(
+ (newWidth: number, newHeight: number) => {
+ updateRemoteData({ html, width: newWidth, height: newHeight });
+ },
+ [html, updateRemoteData],
+ );
+
+ const renderContent = () => {
+ if (!html) {
+ const { bottomText, buttonText, placeholderText } =
+ getFormCopy(embedType);
+ return (
+
+ dispatch({ type: "UPDATE_STATE", payload: { embedUrl: url } })
+ }
+ />
+ );
+ }
+
+ const shouldRespectAspectRatio =
+ !!embedType && PROVIDER_NAMES_TO_RESPECT_ASPECT_RATIO.has(embedType);
+
+ const shouldNotBeResized =
+ !!embedType && PROVIDER_NAMES_THAT_CANT_BE_RESIZED.has(embedType);
+
+ return (
+
+
+ {shouldNotBeResized ? (
+
+ ) : (
+
+
+
+ )}
+
+
+
+ );
+ };
+
+ return (
+
+ {renderContent()}
+
+ );
+};
diff --git a/blocks/embed/src/components/edit-view.tsx b/blocks/embed/src/components/edit-view.tsx
new file mode 100644
index 0000000..9faae5a
--- /dev/null
+++ b/blocks/embed/src/components/edit-view.tsx
@@ -0,0 +1,86 @@
+import type { FormEvent, FunctionComponent } from "react";
+import { tw } from "twind";
+
+import Cross from "../svgs/cross";
+import Loader from "../svgs/loader";
+
+type EditViewProps = {
+ errorString: string;
+ setErrorString: (x: string) => void;
+ loading: boolean;
+ buttonText: string;
+ bottomText: string;
+ placeholderText: string;
+ onChangeEmbedUrl: (url: string) => void;
+ embedUrl: string;
+ onSubmit: () => Promise;
+};
+
+export const EditView: FunctionComponent = ({
+ errorString,
+ setErrorString,
+ loading,
+ buttonText,
+ bottomText,
+ placeholderText,
+ onChangeEmbedUrl,
+ embedUrl,
+ onSubmit,
+}) => {
+ const handleSubmit = (event: FormEvent) => {
+ event.preventDefault();
+ void onSubmit();
+ };
+
+ return (
+ <>
+ {errorString && (
+
+
+ Error
+ {errorString}
+
+
+
+ )}
+
+
+
+
+ >
+ );
+};
diff --git a/blocks/embed/src/components/resize-block.tsx b/blocks/embed/src/components/resize-block.tsx
new file mode 100644
index 0000000..ab1243f
--- /dev/null
+++ b/blocks/embed/src/components/resize-block.tsx
@@ -0,0 +1,242 @@
+import { throttle } from "lodash";
+import type { FunctionComponent, MouseEvent, ReactNode } from "react";
+import { useCallback, useLayoutEffect, useMemo, useRef } from "react";
+import { tw } from "twind";
+
+import { MIN_HEIGHT, MIN_WIDTH } from "../constants";
+import { CornerResize } from "../svgs/corner-resize";
+import { isInRange, toCSSObject, toCSSText } from "../utils";
+
+type ResizeBlockProps = {
+ width: number | undefined;
+ height: number | undefined;
+ maxWidth: number;
+ updateDimensions: (width: number, height: number) => void;
+ shouldRespectAspectRatio: boolean;
+ children?: ReactNode;
+};
+
+const BLOCK_RESIZER_POSITIONS = [
+ {
+ position: "left",
+ className: "left-1 top-1/2 -translate-y-1/2 h-12 w-1.5 cursor-col-resize",
+ },
+ {
+ position: "right",
+ className: "right-1 top-1/2 -translate-y-1/2 h-12 w-1.5 cursor-col-resize",
+ },
+ {
+ position: "bottom",
+ className:
+ "bottom-1 left-1/2 -translate-x-1/2 w-12 h-1.5 cursor-row-resize",
+ },
+ {
+ position: "bottom-right",
+ className: "bottom-1 right-1 cursor-nwse-resize",
+ },
+ {
+ position: "bottom-left",
+ className: "bottom-1 left-1 cursor-nesw-resize",
+ },
+] as const;
+
+/**
+ * @todo this component is a candidate for the hash-ui package
+ * and should be imported from there
+ */
+
+export const ResizeBlock: FunctionComponent = ({
+ children,
+ width,
+ height,
+ maxWidth,
+ shouldRespectAspectRatio,
+ updateDimensions,
+}) => {
+ const divRef = useRef(null);
+ const childrenWrapperRef = useRef(null);
+
+ const aspectRatio = useMemo(() => {
+ if (width && height && shouldRespectAspectRatio) {
+ return Math.round((width / height) * 100) / 100;
+ }
+ }, [height, width, shouldRespectAspectRatio]);
+
+ const maxHeight = useMemo(
+ () => (aspectRatio ? Math.ceil(maxWidth / aspectRatio) : undefined),
+ [aspectRatio, maxWidth],
+ );
+
+ const updateLocalDimensions = useCallback(
+ (dimensions: { width?: number; height?: number }) => {
+ if (!divRef.current) return;
+
+ const styles = {
+ ...toCSSObject(divRef.current.style.cssText),
+ ...(dimensions.width && isInRange(dimensions.width, MIN_WIDTH, maxWidth)
+ ? { width: `${dimensions.width}px` }
+ : {}),
+ ...(dimensions.height &&
+ isInRange(dimensions.height, MIN_HEIGHT, maxHeight)
+ ? { height: `${dimensions.height}px` }
+ : {}),
+ } as CSSStyleDeclaration;
+
+ divRef.current.style.cssText = toCSSText(styles);
+ },
+ [maxHeight, maxWidth],
+ );
+
+ const throttledUpdateLocalDimensions = useMemo(
+ () => throttle(updateLocalDimensions, 16),
+ [updateLocalDimensions],
+ );
+
+ useLayoutEffect(() => {
+ if (!divRef.current) return;
+ const { width: localWidth, height: localHeight } =
+ divRef.current.getBoundingClientRect();
+
+ if (localWidth !== width || localHeight !== height) {
+ updateLocalDimensions({ width, height });
+ }
+ }, [width, height, updateLocalDimensions]);
+
+ const handleResize = (
+ _evt: MouseEvent,
+ direction: (typeof BLOCK_RESIZER_POSITIONS)[number]["position"],
+ ) => {
+ if (!childrenWrapperRef.current) return;
+ let isResizing = false;
+
+ function onMouseMove(mouseMoveEvt: globalThis.MouseEvent) {
+ if (!divRef.current) return;
+ if (!childrenWrapperRef.current) return;
+ /**
+ * Fixes issue with iframes affecting mouseover event. https://stackoverflow.com/q/32885485/6789071
+ * logic is to put off pointer events on embed iframe while resizing
+ */
+ childrenWrapperRef.current.style.pointerEvents = "none";
+
+ let newWidth;
+ let newHeight;
+ const { left, right, top } = divRef.current.getBoundingClientRect();
+ isResizing = true;
+
+ switch (direction) {
+ case "right":
+ newWidth = Math.ceil(mouseMoveEvt.clientX - left);
+ break;
+ case "left":
+ newWidth = Math.ceil(right - mouseMoveEvt.clientX);
+ break;
+ case "bottom":
+ newHeight = Math.ceil(mouseMoveEvt.clientY - top);
+ break;
+ case "bottom-right":
+ newHeight = Math.ceil(mouseMoveEvt.clientY - top);
+ newWidth = Math.ceil(mouseMoveEvt.clientX - left);
+ break;
+ case "bottom-left":
+ newHeight = Math.ceil(mouseMoveEvt.clientY - top);
+ newWidth = Math.ceil(right - mouseMoveEvt.clientX);
+ break;
+ default:
+ break;
+ }
+
+ let newDimensions = {};
+
+ if (newWidth && newHeight) {
+ newDimensions = {
+ width: newWidth,
+ height: newHeight,
+ };
+ } else {
+ if (newWidth) {
+ newDimensions = {
+ width: newWidth,
+ ...(aspectRatio && { height: Math.ceil(newWidth / aspectRatio) }),
+ };
+ }
+
+ if (newHeight) {
+ newDimensions = {
+ height: newHeight,
+ ...(aspectRatio && { height: Math.ceil(newHeight * aspectRatio) }),
+ };
+ }
+ }
+
+ throttledUpdateLocalDimensions(newDimensions);
+
+ // @todo scroll Embedding Application to the bottom when vertical resizing close
+ // to the bottom of the page
+ }
+
+ function onMouseUp() {
+ if (!childrenWrapperRef.current) return;
+ childrenWrapperRef.current.style.pointerEvents = "auto";
+ isResizing = false;
+ document.removeEventListener("mousemove", onMouseMove);
+
+ setTimeout(() => {
+ if (!divRef.current) return;
+ const { width: newWidth, height: newHeight } =
+ divRef.current.getBoundingClientRect();
+
+ if (!isResizing) {
+ updateDimensions(newWidth, newHeight);
+ }
+ }, 500);
+ }
+
+ document.addEventListener("mousemove", onMouseMove);
+ document.addEventListener("mouseup", onMouseUp);
+ };
+
+ const resizerPositions = useMemo(
+ () =>
+ BLOCK_RESIZER_POSITIONS.filter(({ position }) =>
+ aspectRatio ? !position.includes("bottom") : true,
+ ),
+ [aspectRatio],
+ );
+
+ return (
+
+
+ {children}
+
+ {resizerPositions.map(({ position, className }) => {
+ if (["bottom-left", "bottom-right"].includes(position)) {
+ return (
+
+ );
+ }
+
+ return (
+
+ );
+};
diff --git a/blocks/embed/src/constants.ts b/blocks/embed/src/constants.ts
new file mode 100644
index 0000000..591022d
--- /dev/null
+++ b/blocks/embed/src/constants.ts
@@ -0,0 +1,52 @@
+// These are arbitary values. Ideally the Embedding Application should provide
+// some of them to the block
+
+import type { ProviderName } from "./types";
+
+/**
+ * This helps ensure there's space for the edit button
+ * when resizing.
+ */
+const EDIT_BTN_ALLOWANCE = 40;
+
+/**
+ * max width of block
+ */
+export const MAX_WIDTH = 900 - EDIT_BTN_ALLOWANCE;
+
+/**
+ * When embeds are loaded, they should take up the default block width. This value acts as a fallback
+ */
+export const BASE_WIDTH = 600;
+
+/**
+ * useful for embeds that don't come with height/width or aspect ratio
+ */
+export const BASE_HEIGHT = 340;
+
+/**
+ * min width of the block
+ */
+export const MIN_WIDTH = 100;
+
+/**
+ * min height of the block
+ */
+export const MIN_HEIGHT = 200;
+
+/**
+ * List of provider names where the aspect ratio should be respected
+ * when resizing
+ */
+export const PROVIDER_NAMES_TO_RESPECT_ASPECT_RATIO = new Set([
+ "YouTube",
+ "GIPHY",
+]);
+
+/**
+ * List of provider names that should not be resized
+ * The height and width used are gotten from the fetchEmbed api call
+ */
+export const PROVIDER_NAMES_THAT_CANT_BE_RESIZED = new Set([
+ "Twitter",
+]);
diff --git a/blocks/embed/src/dev.tsx b/blocks/embed/src/dev.tsx
new file mode 100644
index 0000000..f72265a
--- /dev/null
+++ b/blocks/embed/src/dev.tsx
@@ -0,0 +1,104 @@
+/**
+ * This is the entry point for developing and debugging.
+ * This file is not bundled with the library during the build process.
+ */
+import { MockBlockDock } from "mock-block-dock";
+import type { FunctionComponent } from "react";
+import { useState } from "react";
+import { createRoot } from "react-dom/client";
+import { tw } from "twind";
+
+import variants from "../variants.json";
+import Component from "./index";
+import type { ProviderName } from "./types";
+
+const node = document.getElementById("app");
+
+/** Temporarily leaving this here, till we fix importing it from hash-isomorphic-utils */
+const apiGraphQLEndpoint = "http://localhost:5001/graphql";
+
+const getEmbedBlock = async (
+ url?: string,
+ type?: ProviderName,
+): Promise<{
+ html: string;
+ error?: string;
+ height?: number;
+ width?: number;
+ providerName?: string;
+}> => {
+ const response = await fetch(apiGraphQLEndpoint, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ operationName: "getEmbedCode",
+ variables: { url, type },
+ query:
+ "query getEmbedCode($url: String!, $type: String) {\n embedCode(url: $url, type: $type) {\n html\n providerName\n height\n width\n __typename\n }\n}\n",
+ }),
+ });
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-return,@typescript-eslint/no-unsafe-member-access -- @todo validate JSON or add types */
+ const responseData = await response.json();
+
+ return {
+ ...responseData.data?.embedCode,
+ error: responseData?.errors?.[0]?.message,
+ };
+ /* eslint-enable @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-return,@typescript-eslint/no-unsafe-member-access */
+};
+
+// @todo replace typeof variants[number] with type BlockVariant when available
+const getVariantProperties = (variant: (typeof variants)[number]) => {
+ return {
+ ...variant.properties,
+ embedType: variant.properties?.embedType as ProviderName | undefined,
+ ...variant.examples[0],
+ };
+};
+
+const initialVariantIndex = 0;
+
+const initialState = getVariantProperties(variants[initialVariantIndex]!);
+
+const AppComponent: FunctionComponent = () => {
+ const [selectedVariantIndex, setSelectedVariantIndex] =
+ useState(initialVariantIndex);
+
+ return (
+
+
+
+
+
+
+
+
+ );
+};
+
+const App = () => {
+ return ;
+};
+
+createRoot(node!).render( );
diff --git a/blocks/embed/src/html-block.tsx b/blocks/embed/src/html-block.tsx
new file mode 100644
index 0000000..d62bcab
--- /dev/null
+++ b/blocks/embed/src/html-block.tsx
@@ -0,0 +1,53 @@
+import type { FunctionComponent } from "react";
+import { useEffect, useRef } from "react";
+import { tw } from "twind";
+
+import { toCSSText } from "./utils";
+
+type HtmlBlockProps = {
+ html: string;
+ dimensions?: { height: number; width: number };
+ [key: string]: unknown;
+};
+
+export const HtmlBlock: FunctionComponent = ({
+ html,
+ dimensions,
+ ...props
+}) => {
+ const divRef = useRef(null);
+
+ useEffect(() => {
+ if (!divRef.current) {
+ return;
+ }
+
+ const docFragment = document.createRange().createContextualFragment(html);
+
+ divRef.current.innerHTML = "";
+ divRef.current.appendChild(docFragment);
+ const el = divRef.current.children[0] as HTMLIFrameElement | undefined;
+ if (el) {
+ el.style.cssText = toCSSText({
+ position: "absolute",
+ left: "0px",
+ top: "0px",
+ height: "100%",
+ width: "100%",
+ } as CSSStyleDeclaration);
+ }
+ }, [html]);
+
+ return (
+
+ );
+};
diff --git a/blocks/embed/src/index.ts b/blocks/embed/src/index.ts
new file mode 100644
index 0000000..6eb172a
--- /dev/null
+++ b/blocks/embed/src/index.ts
@@ -0,0 +1,8 @@
+/* eslint-disable canonical/filename-no-index -- @todo rename file */
+
+/**
+ * Entrypoint of the Block Component.
+ */
+import { App } from "./app";
+
+export default App;
diff --git a/blocks/embed/src/mock-data/mock-data.ts b/blocks/embed/src/mock-data/mock-data.ts
new file mode 100644
index 0000000..0420919
--- /dev/null
+++ b/blocks/embed/src/mock-data/mock-data.ts
@@ -0,0 +1,8 @@
+import type { ProviderName } from "../types";
+
+export type EmbedDataType = {
+ initialHtml?: string;
+ initialWidth?: number;
+ initialHeight?: number;
+ embedType?: ProviderName;
+};
diff --git a/blocks/embed/src/svgs/corner-resize.tsx b/blocks/embed/src/svgs/corner-resize.tsx
new file mode 100644
index 0000000..38ca760
--- /dev/null
+++ b/blocks/embed/src/svgs/corner-resize.tsx
@@ -0,0 +1,26 @@
+import type { FunctionComponent } from "react";
+import { tw } from "twind";
+
+type CornerResizeProps = {
+ position: string;
+};
+
+export const CornerResize: FunctionComponent = ({
+ position,
+}) => {
+ return (
+
+ );
+};
diff --git a/blocks/embed/src/svgs/cross.tsx b/blocks/embed/src/svgs/cross.tsx
new file mode 100644
index 0000000..76aa81b
--- /dev/null
+++ b/blocks/embed/src/svgs/cross.tsx
@@ -0,0 +1,18 @@
+import type { FunctionComponent } from "react";
+import { tw } from "twind";
+
+const Cross: FunctionComponent = () => {
+ return (
+
+ );
+};
+
+export default Cross;
diff --git a/blocks/embed/src/svgs/loader.tsx b/blocks/embed/src/svgs/loader.tsx
new file mode 100644
index 0000000..6279cce
--- /dev/null
+++ b/blocks/embed/src/svgs/loader.tsx
@@ -0,0 +1,29 @@
+import type { FunctionComponent } from "react";
+import { tw } from "twind";
+
+const Loader: FunctionComponent = () => {
+ return (
+
+ );
+};
+
+export default Loader;
diff --git a/blocks/embed/src/svgs/pencil.tsx b/blocks/embed/src/svgs/pencil.tsx
new file mode 100644
index 0000000..8581619
--- /dev/null
+++ b/blocks/embed/src/svgs/pencil.tsx
@@ -0,0 +1,22 @@
+import type { FunctionComponent } from "react";
+
+const Pencil: FunctionComponent = () => {
+ return (
+
+ );
+};
+
+export default Pencil;
diff --git a/blocks/embed/src/types.ts b/blocks/embed/src/types.ts
new file mode 100644
index 0000000..ba53e46
--- /dev/null
+++ b/blocks/embed/src/types.ts
@@ -0,0 +1,302 @@
+export type AppState = {
+ embedUrl: string;
+ embedType: ProviderName | undefined;
+ html?: string;
+ height?: number;
+ width?: number;
+ maxWidth: number;
+ loading: boolean;
+ errorString: string;
+};
+
+export type Actions =
+ | { type: "UPDATE_STATE"; payload: Partial }
+ | { type: "RESET_STATE" };
+
+export type ProviderName =
+ | "23HQ"
+ | "Bopp"
+ | "GIPHY"
+ | "Infoveave"
+ | "Injurymap"
+ | "TikTok"
+ | "Abraia"
+ | "ActBlue"
+ | "Adways"
+ | "Alpha App Net"
+ | "Altium LLC"
+ | "Altru"
+ | "amCharts Live Editor"
+ | "Animatron"
+ | "Animoto"
+ | "AnnieMusic"
+ | "Apester"
+ | "Archivos"
+ | "Audioboom"
+ | "AudioClip"
+ | "Audiomack"
+ | "Avocode"
+ | "AxiomNinja"
+ | "Backtracks"
+ | "Beautiful.AI"
+ | "Blackfire.io"
+ | "Blogcast"
+ | "Box Office Buz"
+ | "BrioVR"
+ | "Buttondown"
+ | "Byzart Project"
+ | "Cacoo"
+ | "Carbon Health"
+ | "CatBoat"
+ | "Ceros"
+ | "Chainflix"
+ | "ChartBlocks"
+ | "chirbit.com"
+ | "CircuitLab"
+ | "Clipland"
+ | "Clyp"
+ | "CoCo Corp"
+ | "CodeHS"
+ | "CodePen"
+ | "Codepoints"
+ | "CodeSandbox"
+ | "CollegeHumor"
+ | "Commaful"
+ | "Coub"
+ | "Crowd Ranking"
+ | "Cueup DJ Booking"
+ | "Curated"
+ | "CustomerDB"
+ | "Cyrano Systems"
+ | "Dailymotion"
+ | "Datawrapper"
+ | "Deseret News"
+ | "Deviantart.com"
+ | "Didacte"
+ | "Digiteka"
+ | "Dipity"
+ | "DocDroid"
+ | "Dotsub"
+ | "DTube"
+ | "edocr"
+ | "eduMedia"
+ | "EgliseInfo"
+ | "Embed Articles"
+ | "Embedery"
+ | "Embedly"
+ | "Enystre Music"
+ | "Ethfiddle"
+ | "Ex.Co"
+ | "Eyrie"
+ | "Facebook"
+ | "Fader"
+ | "Faithlife TV"
+ | "Firework"
+ | "FITE"
+ | "Flat"
+ | "Flickr"
+ | "Flourish"
+ | "FOX SPORTS Australia"
+ | "FrameBuzz"
+ | "Framer"
+ | "FunnyOrDie"
+ | "Geograph Britain and Ireland"
+ | "Geograph Channel Islands"
+ | "Geograph Germany"
+ | "Show by Animaker"
+ | "Getty Images"
+ | "Gfycat"
+ | "Gifnote"
+ | "GloriaTV"
+ | "Gong"
+ | "Grain"
+ | "GT Channel"
+ | "Gyazo"
+ | "HASH"
+ | "hearthis.at"
+ | "hihaho"
+ | "HippoVideo"
+ | "Homey"
+ | "Hosted by You"
+ | "HuffDuffer"
+ | "Hulu"
+ | "Idomoo"
+ | "iFixit"
+ | "IFTTT"
+ | "iHeartRadio"
+ | "Indaco"
+ | "Infogram"
+ | "Inoreader"
+ | "inphood"
+ | "Instagram"
+ | "Insticator Inc"
+ | "Issuu"
+ | "ivlismusic"
+ | "Jovian"
+ | "KakaoTv"
+ | "Kickstarter"
+ | "Kidoju"
+ | "Kirim.Email"
+ | "Kit"
+ | "Kitchenbowl"
+ | "kmdr"
+ | "Knacki"
+ | "Knowledge Pad"
+ | "LearningApps.org"
+ | "Livestream"
+ | "LottieFiles"
+ | "Ludus"
+ | "Lumiere"
+ | "MathEmbed"
+ | "Matterport"
+ | "MediaLab"
+ | "Medienarchiv der Künste - Zürcher Hochschule der Künste"
+ | "Meetup"
+ | "me.me"
+ | "Mermaid Ink"
+ | "Microlink"
+ | "Microsoft Stream"
+ | "Minerva"
+ | "MixCloud"
+ | "Moby Picture"
+ | "Modelo"
+ | "MorphCast"
+ | "Music Box Maniacs"
+ | "myBeweeg"
+ | "Namchey"
+ | "nanoo.tv"
+ | "Nasjonalbiblioteket"
+ | "Natural Atlas"
+ | "nfb.ca"
+ | "NoPaste"
+ | "Observable"
+ | "Odds.com.au"
+ | "Official FM"
+ | "Omniscope"
+ | "Omny Studio"
+ | "On Aol"
+ | "Opsomai"
+ | "Ora TV"
+ | "Orbitvu"
+ | "Oumy"
+ | "Outplayed.tv"
+ | "Overflow"
+ | "OZ"
+ | "Padlet"
+ | "Pastery"
+ | "PingVP"
+ | "Pinpoll"
+ | "Pinterest"
+ | "Pixdor"
+ | "LeMans.Pod"
+ | "Lille.Pod"
+ | "Upec.Pod"
+ | "UnivParis1.Pod"
+ | "Podbean"
+ | "Polaris Share"
+ | "Poll Daddy"
+ | "Port"
+ | "Portfolium"
+ | "posiXion"
+ | "Prezi Video"
+ | "Qualifio"
+ | "Quiz.biz"
+ | "Quizz.biz"
+ | "RadioPublic"
+ | "rcvis"
+ | "Reddit"
+ | "ReleaseWire"
+ | "Replit"
+ | "RepubHub"
+ | "ReverbNation"
+ | "RiffReporter"
+ | "Roomshare"
+ | "RoosterTeeth"
+ | "Rumble"
+ | "Runkit"
+ | "Saooti"
+ | "Sapo Videos"
+ | "Screen9"
+ | "Screencast.com"
+ | "Screenr"
+ | "ScribbleMaps"
+ | "Scribd"
+ | "SendtoNews"
+ | "ShortNote"
+ | "Shoudio"
+ | "Show the Way, actionable location info"
+ | "Simplecast"
+ | "Sizzle"
+ | "Sketchfab"
+ | "SlideShare"
+ | "SmashNotes"
+ | "SmugMug"
+ | "SocialExplorer"
+ | "Odesli (formerly Songlink)"
+ | "SoundCloud"
+ | "SpeakerDeck"
+ | "Spotful"
+ | "Spotify"
+ | "Spreaker"
+ | "SproutVideo"
+ | "Stanford Digital Repository"
+ | "ArcGIS StoryMaps"
+ | "Streamable"
+ | "StreamOneCloud"
+ | "Subscribi"
+ | "Sudomemo"
+ | "Sutori"
+ | "Sway"
+ | "TED"
+ | "The New York Times"
+ | "They Said So"
+ | "TickCounter"
+ | "Toornament"
+ | "Topy"
+ | "TourHero"
+ | "Tumblr"
+ | "Tuxx"
+ | "tvcf"
+ | "Twitter"
+ | "TypeCast"
+ | "Typlog"
+ | "Ubideo"
+ | "University of Cambridge Map"
+ | "UOL"
+ | "uppy"
+ | "Ustream"
+ | "uStudio, Inc."
+ | "Utposts"
+ | "Uttles"
+ | "VeeR VR"
+ | "Verse"
+ | "VEVO"
+ | "VideoJug"
+ | "Vidlit"
+ | "Vidmizer"
+ | "Vidyard"
+ | "Vimeo"
+ | "Viously"
+ | "Viziosphere"
+ | "Vizydrop"
+ | "Vlipsy"
+ | "VLIVE"
+ | "Vlurb"
+ | "VoxSnap"
+ | "Wave.video"
+ | "wecandeo"
+ | "Wiredrive"
+ | "Wistia, Inc."
+ | "wizer.me"
+ | "Wokwi"
+ | "Wolfram Cloud"
+ | "Wootled"
+ | "WordPress.com"
+ | "Xpression"
+ | "Yes, I Know IT!"
+ | "YFrog"
+ | "YouTube"
+ | "Zeplin"
+ | "ZingSoft"
+ | "ZnipeTV"
+ | "Zoomable";
diff --git a/blocks/embed/src/utils.ts b/blocks/embed/src/utils.ts
new file mode 100644
index 0000000..ebaaa5e
--- /dev/null
+++ b/blocks/embed/src/utils.ts
@@ -0,0 +1,70 @@
+import kebabCase from "lodash/kebabCase";
+
+import type { ProviderName } from "./types";
+
+export function getFormCopy(entityType?: ProviderName): {
+ placeholderText: string;
+ buttonText: string;
+ bottomText: string;
+} {
+ if (entityType === "Twitter") {
+ return {
+ placeholderText: "Enter Tweet URL",
+ buttonText: "Embed Tweet",
+ bottomText: "Works with links to Tweets",
+ };
+ }
+
+ if (entityType === "YouTube") {
+ return {
+ placeholderText: "Enter Video URL",
+ buttonText: "Embed Video",
+ bottomText: "Works with links to videos or playlists",
+ };
+ }
+
+ if (entityType === "Spotify") {
+ return {
+ placeholderText: "Enter Song URL",
+ buttonText: "Embed Song",
+ bottomText: "Works with links to songs or playlists",
+ };
+ }
+
+ if (entityType === "HASH") {
+ return {
+ placeholderText: "Enter Simulation URL",
+ buttonText: "Embed Simulation",
+ bottomText: "Works with links to simulations",
+ };
+ }
+
+ return {
+ placeholderText: "Enter URL",
+ buttonText: "Embed Link",
+ bottomText: "Paste in a link to your embeddable content",
+ };
+}
+
+export const toCSSText = (styles: CSSStyleDeclaration): string =>
+ Object.entries(styles)
+ .map(([prop, value]) => `${kebabCase(prop)}:${value}`)
+ .join(";");
+
+export const toCSSObject = (cssText: string) =>
+ Object.fromEntries(
+ cssText
+ .split(";")
+ .filter(Boolean)
+ .map((rule) => {
+ return rule.split(":").map((item) => item.trim());
+ }),
+ ) as CSSStyleDeclaration;
+
+export const isInRange = (
+ value: number,
+ minValue: number = -Infinity,
+ maxValue: number = +Infinity,
+) => {
+ return value >= minValue && value <= maxValue;
+};
diff --git a/blocks/embed/tsconfig.json b/blocks/embed/tsconfig.json
new file mode 100644
index 0000000..03676c9
--- /dev/null
+++ b/blocks/embed/tsconfig.json
@@ -0,0 +1,5 @@
+{
+ "extends": "@local/tsconfig/block.json",
+ "include": ["src"],
+ "exclude": ["node_modules"]
+}
diff --git a/blocks/embed/turbo.json b/blocks/embed/turbo.json
new file mode 100644
index 0000000..2815ced
--- /dev/null
+++ b/blocks/embed/turbo.json
@@ -0,0 +1,32 @@
+{
+ "extends": ["//"],
+ "tasks": {
+ "schema": {
+ "inputs": ["./package.json"],
+ "outputs": ["./src/types.gen.ts"]
+ },
+ "build": {
+ "dependsOn": ["^build", "schema"],
+ "outputs": ["./dist/**"]
+ },
+ "lint:tsc": {
+ "dependsOn": ["schema"]
+ },
+ "lint:eslint": {
+ "env": ["CHECK_TEMPORARILY_DISABLED_RULES"],
+ "dependsOn": ["schema", "@local/eslint#build"]
+ },
+ "fix:eslint": {
+ "cache": false,
+ "dependsOn": ["^build", "schema"]
+ },
+ "dev": {
+ "persistent": true,
+ "dependsOn": ["^build", "schema"]
+ },
+ "serve": {
+ "persistent": true,
+ "dependsOn": ["build"]
+ }
+ }
+}
diff --git a/blocks/embed/variants.json b/blocks/embed/variants.json
new file mode 100644
index 0000000..24a0b39
--- /dev/null
+++ b/blocks/embed/variants.json
@@ -0,0 +1,73 @@
+[
+ {
+ "name": "Embed",
+ "description": "Embed Content",
+ "icon": "public/embed.svg",
+ "examples": [
+ {
+ "initialHtml": "",
+ "initialWidth": 600,
+ "initialHeight": 340
+ }
+ ]
+ },
+ {
+ "name": "Twitter",
+ "description": "Embed Tweet",
+ "icon": "public/twitter.svg",
+ "properties": {
+ "embedType": "Twitter"
+ },
+ "examples": [
+ {
+ "initialHtml": "1/ We've been working a new protocol at @hashai
It's called the block protocol (but NOT about blockchain or NFTs!)
It allows you to build reusable blocks (aka. components) that are interchangeable across website/apps
It takes a minute to explain, but I’ve drawn pictures… pic.x.com/9uhsPdAPSh
— Maggie Appleton 🧭 (@Mappletons) January 31, 2022
\n\n",
+ "initialHeight": 340
+ }
+ ]
+ },
+ {
+ "name": "YouTube",
+ "description": "Embed YouTube Video",
+ "icon": "public/youtube.svg",
+ "properties": {
+ "embedType": "YouTube"
+ },
+ "examples": [
+ {
+ "initialHtml": "",
+ "initialWidth": 600,
+ "initialHeight": 340
+ }
+ ]
+ },
+ {
+ "name": "Spotify",
+ "description": "Embed Spotify Song",
+ "icon": "public/spotify.svg",
+ "properties": {
+ "embedType": "Spotify"
+ },
+ "examples": [
+ {
+ "initialHtml": "",
+ "initialWidth": 600,
+ "initialHeight": 340
+ }
+ ]
+ },
+ {
+ "name": "HASH",
+ "description": "Embed Simulation",
+ "icon": "public/hash.svg",
+ "properties": {
+ "embedType": "HASH"
+ },
+ "examples": [
+ {
+ "initialHtml": "",
+ "initialWidth": 600,
+ "initialHeight": 340
+ }
+ ]
+ }
+]
diff --git a/blocks/faq/.npmignore b/blocks/faq/.npmignore
new file mode 100644
index 0000000..72c3280
--- /dev/null
+++ b/blocks/faq/.npmignore
@@ -0,0 +1,4 @@
+/dist
+/.turbo
+.blockprotocolrc
+CHANGELOG.md
diff --git a/blocks/faq/LICENSE-APACHE.md b/blocks/faq/LICENSE-APACHE.md
new file mode 100644
index 0000000..1d1b6f8
--- /dev/null
+++ b/blocks/faq/LICENSE-APACHE.md
@@ -0,0 +1,189 @@
+# Apache License
+
+_Version 2.0, January 2004_
+_< >_
+
+### Terms and Conditions for use, reproduction, and distribution
+
+#### 1. Definitions
+
+“License” shall mean the terms and conditions for use, reproduction, and
+distribution as defined by Sections 1 through 9 of this document.
+
+“Licensor” shall mean the copyright owner or entity authorized by the copyright
+owner that is granting the License.
+
+“Legal Entity” shall mean the union of the acting entity and all other entities
+that control, are controlled by, or are under common control with that entity.
+For the purposes of this definition, “control” means **(i)** the power, direct or
+indirect, to cause the direction or management of such entity, whether by
+contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the
+outstanding shares, or **(iii)** beneficial ownership of such entity.
+
+“You” (or “Your”) shall mean an individual or Legal Entity exercising
+permissions granted by this License.
+
+“Source” form shall mean the preferred form for making modifications, including
+but not limited to software source code, documentation source, and configuration
+files.
+
+“Object” form shall mean any form resulting from mechanical transformation or
+translation of a Source form, including but not limited to compiled object code,
+generated documentation, and conversions to other media types.
+
+“Work” shall mean the work of authorship, whether in Source or Object form, made
+available under the License, as indicated by a copyright notice that is included
+in or attached to the work (an example is provided in the Appendix below).
+
+“Derivative Works” shall mean any work, whether in Source or Object form, that
+is based on (or derived from) the Work and for which the editorial revisions,
+annotations, elaborations, or other modifications represent, as a whole, an
+original work of authorship. For the purposes of this License, Derivative Works
+shall not include works that remain separable from, or merely link (or bind by
+name) to the interfaces of, the Work and Derivative Works thereof.
+
+“Contribution” shall mean any work of authorship, including the original version
+of the Work and any modifications or additions to that Work or Derivative Works
+thereof, that is intentionally submitted to Licensor for inclusion in the Work
+by the copyright owner or by an individual or Legal Entity authorized to submit
+on behalf of the copyright owner. For the purposes of this definition,
+“submitted” means any form of electronic, verbal, or written communication sent
+to the Licensor or its representatives, including but not limited to
+communication on electronic mailing lists, source code control systems, and
+issue tracking systems that are managed by, or on behalf of, the Licensor for
+the purpose of discussing and improving the Work, but excluding communication
+that is conspicuously marked or otherwise designated in writing by the copyright
+owner as “Not a Contribution.”
+
+“Contributor” shall mean Licensor and any individual or Legal Entity on behalf
+of whom a Contribution has been received by Licensor and subsequently
+incorporated within the Work.
+
+#### 2. Grant of Copyright License
+
+Subject to the terms and conditions of this License, each Contributor hereby
+grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
+irrevocable copyright license to reproduce, prepare Derivative Works of,
+publicly display, publicly perform, sublicense, and distribute the Work and such
+Derivative Works in Source or Object form.
+
+#### 3. Grant of Patent License
+
+Subject to the terms and conditions of this License, each Contributor hereby
+grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
+irrevocable (except as stated in this section) patent license to make, have
+made, use, offer to sell, sell, import, and otherwise transfer the Work, where
+such license applies only to those patent claims licensable by such Contributor
+that are necessarily infringed by their Contribution(s) alone or by combination
+of their Contribution(s) with the Work to which such Contribution(s) was
+submitted. If You institute patent litigation against any entity (including a
+cross-claim or counterclaim in a lawsuit) alleging that the Work or a
+Contribution incorporated within the Work constitutes direct or contributory
+patent infringement, then any patent licenses granted to You under this License
+for that Work shall terminate as of the date such litigation is filed.
+
+#### 4. Redistribution
+
+You may reproduce and distribute copies of the Work or Derivative Works thereof
+in any medium, with or without modifications, and in Source or Object form,
+provided that You meet the following conditions:
+
+- **(a)** You must give any other recipients of the Work or Derivative Works a copy of
+ this License; and
+- **(b)** You must cause any modified files to carry prominent notices stating that You
+ changed the files; and
+- **(c)** You must retain, in the Source form of any Derivative Works that You distribute,
+ all copyright, patent, trademark, and attribution notices from the Source form
+ of the Work, excluding those notices that do not pertain to any part of the
+ Derivative Works; and
+- **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any
+ Derivative Works that You distribute must include a readable copy of the
+ attribution notices contained within such NOTICE file, excluding those notices
+ that do not pertain to any part of the Derivative Works, in at least one of the
+ following places: within a NOTICE text file distributed as part of the
+ Derivative Works; within the Source form or documentation, if provided along
+ with the Derivative Works; or, within a display generated by the Derivative
+ Works, if and wherever such third-party notices normally appear. The contents of
+ the NOTICE file are for informational purposes only and do not modify the
+ License. You may add Your own attribution notices within Derivative Works that
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
+ provided that such additional attribution notices cannot be construed as
+ modifying the License.
+
+You may add Your own copyright statement to Your modifications and may provide
+additional or different license terms and conditions for use, reproduction, or
+distribution of Your modifications, or for any such Derivative Works as a whole,
+provided Your use, reproduction, and distribution of the Work otherwise complies
+with the conditions stated in this License.
+
+#### 5. Submission of Contributions
+
+Unless You explicitly state otherwise, any Contribution intentionally submitted
+for inclusion in the Work by You to the Licensor shall be under the terms and
+conditions of this License, without any additional terms or conditions.
+Notwithstanding the above, nothing herein shall supersede or modify the terms of
+any separate license agreement you may have executed with Licensor regarding
+such Contributions.
+
+#### 6. Trademarks
+
+This License does not grant permission to use the trade names, trademarks,
+service marks, or product names of the Licensor, except as required for
+reasonable and customary use in describing the origin of the Work and
+reproducing the content of the NOTICE file.
+
+#### 7. Disclaimer of Warranty
+
+Unless required by applicable law or agreed to in writing, Licensor provides the
+Work (and each Contributor provides its Contributions) on an “AS IS” BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
+including, without limitation, any warranties or conditions of TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
+solely responsible for determining the appropriateness of using or
+redistributing the Work and assume any risks associated with Your exercise of
+permissions under this License.
+
+#### 8. Limitation of Liability
+
+In no event and under no legal theory, whether in tort (including negligence),
+contract, or otherwise, unless required by applicable law (such as deliberate
+and grossly negligent acts) or agreed to in writing, shall any Contributor be
+liable to You for damages, including any direct, indirect, special, incidental,
+or consequential damages of any character arising as a result of this License or
+out of the use or inability to use the Work (including but not limited to
+damages for loss of goodwill, work stoppage, computer failure or malfunction, or
+any and all other commercial damages or losses), even if such Contributor has
+been advised of the possibility of such damages.
+
+#### 9. Accepting Warranty or Additional Liability
+
+While redistributing the Work or Derivative Works thereof, You may choose to
+offer, and charge a fee for, acceptance of support, warranty, indemnity, or
+other liability obligations and/or rights consistent with this License. However,
+in accepting such obligations, You may act only on Your own behalf and on Your
+sole responsibility, not on behalf of any other Contributor, and only if You
+agree to indemnify, defend, and hold each Contributor harmless for any liability
+incurred by, or claims asserted against, such Contributor by reason of your
+accepting any such warranty or additional liability.
+
+_END OF TERMS AND CONDITIONS_
+
+### APPENDIX: Apply the Apache License to a specific file
+
+To apply the Apache License to an individual file, attach the following notice.
+The text should be enclosed in the appropriate comment syntax for the file
+format.
+
+ Copyright © 2022–, HASH
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/blocks/faq/LICENSE-MIT.md b/blocks/faq/LICENSE-MIT.md
new file mode 100644
index 0000000..e33c1d3
--- /dev/null
+++ b/blocks/faq/LICENSE-MIT.md
@@ -0,0 +1,21 @@
+# MIT License
+
+Copyright © 2022–, HASH
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/blocks/faq/LICENSE.md b/blocks/faq/LICENSE.md
new file mode 100644
index 0000000..8686df9
--- /dev/null
+++ b/blocks/faq/LICENSE.md
@@ -0,0 +1,5 @@
+# License
+
+Licensed under either of the [Apache License, Version 2.0](LICENSE-APACHE.md) or [MIT license](LICENSE-MIT.md) at your option.
+
+For more information about contributing to this block, see our top-level [CONTRIBUTING](https://github.com/hashintel/hash/blob/main/.github/CONTRIBUTING.md) policy.
diff --git a/blocks/faq/README.md b/blocks/faq/README.md
new file mode 100644
index 0000000..cf11529
--- /dev/null
+++ b/blocks/faq/README.md
@@ -0,0 +1,3 @@
+This block typically allows the user to create a frequently asked questions section.
+
+Each section consists of a `question` and `answer` that is saved on a `FAQ section` entity that is linked to the block entity.
diff --git a/blocks/faq/eslint.config.js b/blocks/faq/eslint.config.js
new file mode 100644
index 0000000..5b6bb9d
--- /dev/null
+++ b/blocks/faq/eslint.config.js
@@ -0,0 +1,3 @@
+import { createBlock } from "@local/eslint/deprecated";
+
+export default createBlock(import.meta.dirname);
diff --git a/blocks/faq/package.json b/blocks/faq/package.json
new file mode 100644
index 0000000..218b3fc
--- /dev/null
+++ b/blocks/faq/package.json
@@ -0,0 +1,80 @@
+{
+ "name": "@blocks/faq",
+ "version": "0.1.3",
+ "private": true,
+ "description": "Create a frequently asked questions section",
+ "keywords": [
+ "blockprotocol",
+ "blocks",
+ "block"
+ ],
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/hashintel/blocks.git#main",
+ "directory": "blocks/faq"
+ },
+ "license": "(MIT OR Apache-2.0)",
+ "author": "HASH",
+ "type": "module",
+ "scripts": {
+ "build": "block-scripts build",
+ "codegen": "block-scripts codegen && yarn format",
+ "dev": "block-scripts dev",
+ "fix:eslint": "eslint --fix .",
+ "format": "prettier --write --ignore-unknown src/types/generated/*.ts",
+ "lint:eslint": "eslint --report-unused-disable-directives .",
+ "lint:tsc": "tsc --noEmit",
+ "serve": "block-scripts serve"
+ },
+ "prettier": {
+ "printWidth": 80,
+ "trailingComma": "all"
+ },
+ "dependencies": {
+ "@blockprotocol/graph": "0.3.4",
+ "@hashintel/block-design-system": "0.0.5",
+ "@hashintel/design-system": "0.0.9-canary.2",
+ "@mui/material": "5.18.0",
+ "uuid": "13.0.1"
+ },
+ "devDependencies": {
+ "@local/eslint": "0.0.0-private",
+ "@types/react-dom": "19.1.7",
+ "block-scripts": "0.3.4",
+ "eslint": "10.0.3",
+ "mock-block-dock": "0.1.9",
+ "prettier": "3.8.1",
+ "react": "19.1.1",
+ "react-dom": "19.1.1",
+ "typescript": "5.9.3"
+ },
+ "peerDependencies": {
+ "react": "^19.0.0",
+ "react-dom": "^19.0.0"
+ },
+ "block-scripts": {
+ "port": 63212
+ },
+ "blockprotocol": {
+ "blockType": {
+ "entryPoint": "react"
+ },
+ "displayName": "FAQ",
+ "examples": [],
+ "icon": "public/faq-icon.svg",
+ "image": "public/block-preview.png",
+ "name": "@hash/faq",
+ "protocol": "0.3",
+ "blockEntityType": "https://blockprotocol.org/@hash/types/entity-type/faq-block/v/1",
+ "codegen": {
+ "outputFolder": "src/types/generated",
+ "targets": {
+ "block-entity.ts": [
+ {
+ "blockEntityType": true
+ }
+ ]
+ }
+ }
+ }
+}
diff --git a/blocks/faq/public/block-preview.png b/blocks/faq/public/block-preview.png
new file mode 100644
index 0000000..73e7c81
Binary files /dev/null and b/blocks/faq/public/block-preview.png differ
diff --git a/blocks/faq/public/faq-icon.svg b/blocks/faq/public/faq-icon.svg
new file mode 100644
index 0000000..c601a6b
--- /dev/null
+++ b/blocks/faq/public/faq-icon.svg
@@ -0,0 +1,3 @@
+
diff --git a/blocks/faq/src/app.tsx b/blocks/faq/src/app.tsx
new file mode 100644
index 0000000..9aa2769
--- /dev/null
+++ b/blocks/faq/src/app.tsx
@@ -0,0 +1,454 @@
+import type { LinkEntityAndRightEntity } from "@blockprotocol/graph";
+import {
+ type BlockComponent,
+ useEntitySubgraph,
+ useGraphBlockModule,
+} from "@blockprotocol/graph/react";
+import { EditableField, GetHelpLink } from "@hashintel/block-design-system";
+import { Button, faPlus, FontAwesomeIcon } from "@hashintel/design-system";
+import { theme } from "@hashintel/design-system/theme";
+import {
+ Card,
+ Collapse,
+ Fade,
+ Stack,
+ Switch,
+ ThemeProvider,
+ Typography,
+} from "@mui/material";
+import Box from "@mui/material/Box";
+import { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import { v4 as uuid } from "uuid";
+
+import { Question } from "./question";
+import type {
+ BlockEntity,
+ FAQBlockOutgoingLinksByLinkEntityTypeId,
+ FrequentlyAskedQuestion,
+ FrequentlyAskedQuestionProperties,
+} from "./types/generated/block-entity";
+
+type RootEntityKey = keyof BlockEntity["properties"];
+type QuestionEntityKey = keyof FrequentlyAskedQuestionProperties;
+
+type LinkType = keyof FAQBlockOutgoingLinksByLinkEntityTypeId;
+
+// Property types
+export const titleKey: RootEntityKey =
+ "https://blockprotocol.org/@blockprotocol/types/property-type/title/";
+export const descriptionKey: RootEntityKey =
+ "https://blockprotocol.org/@blockprotocol/types/property-type/description/";
+export const sectionsShouldBeNumberedKey: RootEntityKey =
+ "https://blockprotocol.org/@hash/types/property-type/sections-should-be-numbered/";
+export const answerVisibilityIsConfigurableKey: RootEntityKey =
+ "https://blockprotocol.org/@hash/types/property-type/answer-visibility-is-configurable/";
+export const questionKey: QuestionEntityKey =
+ "https://blockprotocol.org/@blockprotocol/types/property-type/question/";
+export const answerKey: QuestionEntityKey =
+ "https://blockprotocol.org/@blockprotocol/types/property-type/answer/";
+
+// Relevant Entity Types
+const frequentlyAskedQuestionType =
+ "https://blockprotocol.org/@hash/types/entity-type/frequently-asked-question/v/1";
+
+// Link Entity Types
+const hasFrequentlyAskedQuestion: LinkType =
+ "https://blockprotocol.org/@hash/types/entity-type/has-frequently-asked-question/v/1";
+
+export type QuestionOrAnswer = typeof questionKey | typeof answerKey;
+export type EntityType = typeof frequentlyAskedQuestionType;
+
+export const App: BlockComponent = ({
+ graph: { blockEntitySubgraph, readonly },
+}) => {
+ const blockRootRef = useRef(null);
+ /* @ts-expect-error –– @todo H-3839 packages in BP repo needs updating, or this package updating to use graph in this repo */
+ const { graphModule } = useGraphBlockModule(blockRootRef);
+ const { rootEntity: blockEntity, linkedEntities } =
+ useEntitySubgraph(blockEntitySubgraph);
+
+ const {
+ metadata: {
+ recordId: { entityId },
+ entityTypeId,
+ },
+ properties,
+ } = blockEntity;
+
+ const {
+ [titleKey]: title,
+ [descriptionKey]: description,
+ [sectionsShouldBeNumberedKey]: shouldDisplayQuestionNumbers,
+ [answerVisibilityIsConfigurableKey]: shouldDisplayQuestionToggles,
+ } = properties;
+
+ const questionLinkedEntities: LinkEntityAndRightEntity[] = useMemo(
+ () =>
+ linkedEntities.filter(
+ ({ linkEntity }) =>
+ linkEntity.metadata.entityTypeId === hasFrequentlyAskedQuestion,
+ ),
+ [linkedEntities],
+ );
+
+ const questionEntities: FrequentlyAskedQuestion[] | undefined =
+ questionLinkedEntities.map((linkEntity) => linkEntity.rightEntity);
+
+ const [hovered, setHovered] = useState(false);
+ const [titleValue, setTitleValue] = useState(title);
+ const [descriptionValue, setDescriptionValue] = useState(description);
+ const [displayNumbers, setDisplayNumbers] = useState(
+ shouldDisplayQuestionNumbers ?? true,
+ );
+ const [displayToggles, setDisplayToggles] = useState(
+ shouldDisplayQuestionToggles ?? true,
+ );
+ const [questions, setQuestions] = useState<
+ {
+ id: string;
+ properties: FrequentlyAskedQuestionProperties;
+ animatingOut?: boolean;
+ }[]
+ >(
+ questionEntities.map((questionEntity) => ({
+ id: questionEntity.metadata.recordId.entityId,
+ properties: questionEntity.properties,
+ })),
+ );
+
+ const updateField = async (value: string | boolean, field: RootEntityKey) => {
+ await graphModule.updateEntity({
+ data: {
+ entityId,
+ entityTypeId,
+ properties: {
+ ...properties,
+ [field]: value,
+ },
+ },
+ });
+ };
+
+ const createFrequentlyAskedQuestionEntity = useCallback(async () => {
+ if (readonly) {
+ return;
+ }
+
+ const createEntityResponse = await graphModule.createEntity({
+ data: {
+ entityTypeId: frequentlyAskedQuestionType,
+ properties: {},
+ },
+ });
+
+ const createdEntityId =
+ createEntityResponse.data?.metadata.recordId.entityId;
+
+ if (createdEntityId) {
+ await graphModule.createEntity({
+ data: {
+ entityTypeId: hasFrequentlyAskedQuestion,
+ properties: {},
+ linkData: {
+ leftEntityId: entityId,
+ rightEntityId: createdEntityId,
+ },
+ },
+ });
+ }
+ }, [graphModule, entityId, readonly]);
+
+ const addQuestion = useCallback(async () => {
+ setQuestions([...questions, { id: uuid(), properties: {} }]);
+ await createFrequentlyAskedQuestionEntity();
+ }, [questions, createFrequentlyAskedQuestionEntity]);
+
+ const updateQuestionField = async (
+ index: number,
+ value: string,
+ field: QuestionOrAnswer,
+ ) => {
+ const questionEntity = questionEntities[index];
+
+ if (!questionEntity) {
+ return;
+ }
+
+ await graphModule.updateEntity({
+ data: {
+ entityId: questionEntity.metadata.recordId.entityId,
+ entityTypeId: frequentlyAskedQuestionType,
+ properties: {
+ ...questionEntity.properties,
+ [field]: value,
+ },
+ },
+ });
+ };
+
+ const removeQuestion = (index: number) => {
+ setQuestions(
+ questions.map((question, questionIndex) => {
+ if (index === questionIndex) {
+ return { ...question, animatingOut: true };
+ }
+ return question;
+ }),
+ );
+ };
+
+ useEffect(() => {
+ if (!readonly && !questionEntities.length) {
+ void addQuestion();
+ }
+ // We only want to run this once when the block is initiated
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
+
+ const schema = useMemo(() => {
+ const questionsWithTitle = questionEntities.filter(
+ ({ properties: { [questionKey]: schemaQuestion } }) => !!schemaQuestion,
+ );
+
+ return JSON.stringify({
+ "@context": "http://schema.org",
+ "@type": "FAQPage",
+ mainEntity: questionsWithTitle.map(
+ ({
+ properties: {
+ [questionKey]: schemaQuestion,
+ [answerKey]: schemaAnswer,
+ },
+ }) => ({
+ "@type": "Question",
+ name: schemaQuestion,
+ acceptedAnswer: {
+ "@type": "Answer",
+ text: schemaAnswer ?? schemaQuestion,
+ },
+ }),
+ ),
+ });
+ }, [questionEntities]);
+
+ const shouldDisplayIntro = !!title || !!description || !readonly;
+
+ return (
+ <>
+
+
+ setHovered(true)}
+ onMouseLeave={() => setHovered(false)}
+ >
+ {!readonly ? (
+
+
+
+
+
+
+ palette.gray[50],
+ }}
+ >
+ Show numbers?
+
+ {
+ setDisplayNumbers(event.target.checked);
+ void updateField(
+ event.target.checked,
+ sectionsShouldBeNumberedKey,
+ );
+ }}
+ />
+
+
+
+ palette.gray[50],
+ }}
+ >
+ Show toggles?
+
+ {
+ setDisplayToggles(event.target.checked);
+ void updateField(
+ event.target.checked,
+ answerVisibilityIsConfigurableKey,
+ );
+ }}
+ />
+
+
+
+
+ ) : null}
+
+ `1px solid ${palette.gray[20]}`,
+ borderRadius: 2.5,
+ boxShadow: "none",
+ paddingY: 3,
+ paddingX: 3.75,
+ }
+ : {
+ background: "none",
+ boxShadow: "none",
+ }),
+ }}
+ >
+ {shouldDisplayIntro ? (
+
+ {
+ setTitleValue(event.target.value);
+ }}
+ onBlur={(event) => updateField(event.target.value, titleKey)}
+ sx={{
+ fontWeight: 700,
+ fontSize: 21,
+ lineHeight: 1,
+ letterSpacing: "-0.02em",
+ color: theme.palette.common.black,
+ }}
+ placeholder="Enter an optional FAQ section title"
+ readonly={readonly}
+ />
+
+ {
+ setDescriptionValue(event.target.value);
+ }}
+ onBlur={(event) => {
+ void updateField(event.target.value, descriptionKey);
+ }}
+ sx={{
+ fontWeight: 500,
+ fontSize: 14,
+ lineHeight: 1.3,
+ letterSpacing: "-0.02em",
+ color: theme.palette.gray[90],
+ }}
+ placeholder="Enter an optional description/introduction"
+ placeholderSx={{
+ fontStyle: "italic",
+ }}
+ readonly={readonly}
+ />
+
+ ) : null}
+
+
+ {questions.map((question, index) => (
+ {
+ const newQuestions = [...questions];
+ newQuestions.splice(index, 1);
+ setQuestions(newQuestions);
+
+ const questionLink =
+ questionLinkedEntities[index]?.linkEntity;
+
+ if (!questionLink) {
+ return;
+ }
+
+ await graphModule.deleteEntity({
+ data: {
+ entityId: questionLink.metadata.recordId.entityId,
+ },
+ });
+ }}
+ appear
+ >
+
+ transitions.create("margin-bottom"),
+ }}
+ >
+
+ updateQuestionField(index, value, field)
+ }
+ onRemove={() => removeQuestion(index)}
+ readonly={readonly}
+ deletable={questionEntities.length > 1}
+ displayNumber={displayNumbers}
+ displayToggle={displayToggles}
+ />
+
+
+ ))}
+
+
+ {!readonly ? (
+
+
+
+ ) : null}
+
+
+
+ >
+ );
+};
diff --git a/blocks/faq/src/assets.d.ts b/blocks/faq/src/assets.d.ts
new file mode 100644
index 0000000..62db9da
--- /dev/null
+++ b/blocks/faq/src/assets.d.ts
@@ -0,0 +1,3 @@
+declare module "*.css";
+declare module "*.sass";
+declare module "*.scss";
diff --git a/blocks/faq/src/dev.tsx b/blocks/faq/src/dev.tsx
new file mode 100644
index 0000000..9b3b5c0
--- /dev/null
+++ b/blocks/faq/src/dev.tsx
@@ -0,0 +1,45 @@
+import type { VersionedUrl } from "@blockprotocol/type-system";
+import { MockBlockDock } from "mock-block-dock";
+import { createRoot } from "react-dom/client";
+
+import packageJson from "../package.json";
+import Component from "./index";
+import type { BlockEntity } from "./types/generated/block-entity";
+
+const node = document.getElementById("app");
+
+const testEntity: BlockEntity = {
+ metadata: {
+ recordId: {
+ entityId: "test-entity",
+ editionId: new Date().toISOString(),
+ },
+ entityTypeId: packageJson.blockprotocol.blockEntityType as VersionedUrl,
+ },
+ properties: {},
+} as const;
+
+const DevApp = () => {
+ return (
+
+ );
+};
+
+if (node) {
+ createRoot(node).render( );
+} else {
+ throw new Error("Unable to find DOM element with id 'app'");
+}
diff --git a/blocks/faq/src/icons/caret-down.tsx b/blocks/faq/src/icons/caret-down.tsx
new file mode 100644
index 0000000..41fc7c5
--- /dev/null
+++ b/blocks/faq/src/icons/caret-down.tsx
@@ -0,0 +1,17 @@
+import type { SvgIconProps } from "@mui/material";
+import { SvgIcon } from "@mui/material";
+import type { FunctionComponent } from "react";
+
+export const CaretDownIcon: FunctionComponent = (props) => {
+ return (
+
+
+
+ );
+};
diff --git a/blocks/faq/src/index.ts b/blocks/faq/src/index.ts
new file mode 100644
index 0000000..4a0d45f
--- /dev/null
+++ b/blocks/faq/src/index.ts
@@ -0,0 +1,7 @@
+/**
+ * Entrypoint of the Block Component.
+ */
+// eslint-disable-next-line canonical/filename-no-index
+import { App } from "./app";
+
+export default App;
diff --git a/blocks/faq/src/question.tsx b/blocks/faq/src/question.tsx
new file mode 100644
index 0000000..66b8126
--- /dev/null
+++ b/blocks/faq/src/question.tsx
@@ -0,0 +1,192 @@
+import { EditableField } from "@hashintel/block-design-system";
+import { Button, faTrash, FontAwesomeIcon } from "@hashintel/design-system";
+import { Box, Collapse, Fade } from "@mui/material";
+import type { FunctionComponent } from "react";
+import { useState } from "react";
+
+import type { QuestionOrAnswer } from "./app";
+import { answerKey, questionKey } from "./app";
+import { CaretDownIcon } from "./icons/caret-down";
+
+interface QuestionProps {
+ index: number;
+ question?: string;
+ answer?: string;
+ deletable?: boolean;
+ readonly?: boolean;
+ displayNumber?: boolean;
+ displayToggle?: boolean;
+ updateField: (value: string, field: QuestionOrAnswer) => void;
+ onRemove: () => void;
+}
+
+export const Question: FunctionComponent = ({
+ index,
+ question,
+ answer,
+ deletable = true,
+ readonly,
+ displayNumber = true,
+ displayToggle = true,
+ updateField,
+ onRemove,
+}) => {
+ const [questionValue, setQuestionValue] = useState(question ?? "");
+ const [answerValue, setAnswerValue] = useState(answer ?? "");
+ const [expanded, setExpanded] = useState(true);
+
+ return (
+
+
+
+
+
+ `1px solid ${palette.gray[20]}`,
+ borderRadius: 2.5,
+ overflow: "hidden",
+ }
+ : {}),
+ }}
+ >
+
+ {
+ setQuestionValue(event.target.value);
+ }}
+ onBlur={(event) => updateField(event.target.value, questionKey)}
+ sx={{
+ fontWeight: 700,
+ fontSize: 15,
+ lineHeight: 1,
+ flexGrow: 1,
+ color: ({ palette }) => palette.gray[90],
+ }}
+ placeholder="Your frequently asked question goes here"
+ readonly={readonly}
+ />
+
+ {!readonly ? (
+
+
+
+ ) : null}
+
+
+
+ palette.gray[20],
+ }
+ : {}),
+ }}
+ >
+ {
+ setAnswerValue(event.target.value);
+ }}
+ onBlur={(event) => updateField(event.target.value, answerKey)}
+ sx={{
+ fontWeight: 400,
+ fontSize: 14,
+ lineHeight: 1.3,
+ color: ({ palette }) => palette.gray[90],
+ ...(readonly ? { paddingY: 0.5 } : {}),
+ }}
+ placeholder="Provide your answer here"
+ readonly={readonly}
+ />
+
+
+
+
+ );
+};
diff --git a/blocks/faq/src/types/generated/block-entity.ts b/blocks/faq/src/types/generated/block-entity.ts
new file mode 100644
index 0000000..ec0b5bf
--- /dev/null
+++ b/blocks/faq/src/types/generated/block-entity.ts
@@ -0,0 +1,111 @@
+/**
+ * This file was automatically generated – do not edit it.
+ */
+
+import { Entity, LinkData } from "@blockprotocol/graph";
+
+/**
+ * A response to a question that provides information, clarification, or confirmation.
+ */
+export type AnswerPropertyValue = TextDataType;
+
+/**
+ * Defines whether or not toggles should be displayed on questions to show/hide their respective answer.
+ */
+export type AnswerVisibilityIsConfigurablePropertyValue = BooleanDataType;
+
+export type BlockEntity = FAQBlock;
+
+export type BlockEntityOutgoingLinkAndTarget = FAQBlockOutgoingLinkAndTarget;
+
+/**
+ * A True or False value
+ */
+export type BooleanDataType = boolean;
+
+/**
+ * A piece of text that tells you about something or someone. This can include explaining what they look like, what its purpose is for, what they’re like, etc.
+ */
+export type DescriptionPropertyValue = TextDataType;
+
+export type FAQBlock = Entity;
+
+export type FAQBlockHasFrequentlyAskedQuestionLink = {
+ linkEntity: HasFrequentlyAskedQuestion;
+ rightEntity: FrequentlyAskedQuestion;
+};
+
+export type FAQBlockOutgoingLinkAndTarget =
+ FAQBlockHasFrequentlyAskedQuestionLink;
+
+export type FAQBlockOutgoingLinksByLinkEntityTypeId = {
+ "https://blockprotocol.org/@hash/types/entity-type/has-frequently-asked-question/v/1": FAQBlockHasFrequentlyAskedQuestionLink;
+};
+
+/**
+ * A block to display Frequently Asked Questions (FAQ).
+ */
+export type FAQBlockProperties = {
+ "https://blockprotocol.org/@blockprotocol/types/property-type/description/"?: DescriptionPropertyValue;
+ "https://blockprotocol.org/@blockprotocol/types/property-type/title/"?: TitlePropertyValue;
+ "https://blockprotocol.org/@hash/types/property-type/sections-should-be-numbered/"?: SectionsShouldBeNumberedPropertyValue;
+ "https://blockprotocol.org/@hash/types/property-type/answer-visibility-is-configurable/"?: AnswerVisibilityIsConfigurablePropertyValue;
+};
+
+export type FrequentlyAskedQuestion = Entity;
+
+export type FrequentlyAskedQuestionOutgoingLinkAndTarget = never;
+
+export type FrequentlyAskedQuestionOutgoingLinksByLinkEntityTypeId = {};
+
+/**
+ * A question frequently asked about something – or, often, a question that someone anticipates will be asked about something.
+ */
+export type FrequentlyAskedQuestionProperties = {
+ "https://blockprotocol.org/@blockprotocol/types/property-type/question/"?: QuestionPropertyValue;
+ "https://blockprotocol.org/@blockprotocol/types/property-type/answer/"?: AnswerPropertyValue;
+};
+
+export type HasFrequentlyAskedQuestion =
+ Entity & { linkData: LinkData };
+
+export type HasFrequentlyAskedQuestionOutgoingLinkAndTarget = never;
+
+export type HasFrequentlyAskedQuestionOutgoingLinksByLinkEntityTypeId = {};
+
+/**
+ * Contains a frequently asked question defined by a [Frequently Asked Question] entity.
+ */
+export type HasFrequentlyAskedQuestionProperties =
+ HasFrequentlyAskedQuestionProperties1 & HasFrequentlyAskedQuestionProperties2;
+export type HasFrequentlyAskedQuestionProperties1 = LinkProperties;
+
+export type HasFrequentlyAskedQuestionProperties2 = {};
+
+export type Link = Entity;
+
+export type LinkOutgoingLinkAndTarget = never;
+
+export type LinkOutgoingLinksByLinkEntityTypeId = {};
+
+export type LinkProperties = {};
+
+/**
+ * A sentence that is used to request information, clarification, or confirmation about something.
+ */
+export type QuestionPropertyValue = TextDataType;
+
+/**
+ * Defines whether or not sections should be numbered.
+ */
+export type SectionsShouldBeNumberedPropertyValue = BooleanDataType;
+
+/**
+ * An ordered sequence of characters
+ */
+export type TextDataType = string;
+
+/**
+ * The name given to something to identify it, generally associated with objects or inanimate things such as books, websites, songs, etc.
+ */
+export type TitlePropertyValue = TextDataType;
diff --git a/blocks/faq/theme-override.d.ts b/blocks/faq/theme-override.d.ts
new file mode 100644
index 0000000..85625e2
--- /dev/null
+++ b/blocks/faq/theme-override.d.ts
@@ -0,0 +1,2 @@
+// eslint-disable-next-line no-restricted-imports
+import "@hashintel/design-system/theme-override";
diff --git a/blocks/faq/tsconfig.json b/blocks/faq/tsconfig.json
new file mode 100644
index 0000000..12904d6
--- /dev/null
+++ b/blocks/faq/tsconfig.json
@@ -0,0 +1,5 @@
+{
+ "extends": "@local/tsconfig/block.json",
+ "include": ["src", "theme-override.d.ts"],
+ "exclude": ["node_modules"]
+}
diff --git a/blocks/faq/turbo.json b/blocks/faq/turbo.json
new file mode 100644
index 0000000..9d80ee7
--- /dev/null
+++ b/blocks/faq/turbo.json
@@ -0,0 +1,28 @@
+{
+ "extends": ["//"],
+ "tasks": {
+ "codegen": {
+ "inputs": ["./package.json"],
+ "outputs": ["./src/types/generated/**"]
+ },
+ "build": {
+ "dependsOn": ["^build", "codegen", "format"],
+ "outputs": ["./dist/**"]
+ },
+ "lint:tsc": {
+ "dependsOn": ["codegen"]
+ },
+ "format": {
+ "cache": false,
+ "dependsOn": ["codegen"]
+ },
+ "dev": {
+ "persistent": true,
+ "dependsOn": ["^build", "codegen"]
+ },
+ "serve": {
+ "persistent": true,
+ "dependsOn": ["build"]
+ }
+ }
+}
diff --git a/blocks/faq/variants.json b/blocks/faq/variants.json
new file mode 100644
index 0000000..fe51488
--- /dev/null
+++ b/blocks/faq/variants.json
@@ -0,0 +1 @@
+[]
diff --git a/blocks/heading/LICENSE-APACHE.md b/blocks/heading/LICENSE-APACHE.md
new file mode 100644
index 0000000..1d1b6f8
--- /dev/null
+++ b/blocks/heading/LICENSE-APACHE.md
@@ -0,0 +1,189 @@
+# Apache License
+
+_Version 2.0, January 2004_
+_< >_
+
+### Terms and Conditions for use, reproduction, and distribution
+
+#### 1. Definitions
+
+“License” shall mean the terms and conditions for use, reproduction, and
+distribution as defined by Sections 1 through 9 of this document.
+
+“Licensor” shall mean the copyright owner or entity authorized by the copyright
+owner that is granting the License.
+
+“Legal Entity” shall mean the union of the acting entity and all other entities
+that control, are controlled by, or are under common control with that entity.
+For the purposes of this definition, “control” means **(i)** the power, direct or
+indirect, to cause the direction or management of such entity, whether by
+contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the
+outstanding shares, or **(iii)** beneficial ownership of such entity.
+
+“You” (or “Your”) shall mean an individual or Legal Entity exercising
+permissions granted by this License.
+
+“Source” form shall mean the preferred form for making modifications, including
+but not limited to software source code, documentation source, and configuration
+files.
+
+“Object” form shall mean any form resulting from mechanical transformation or
+translation of a Source form, including but not limited to compiled object code,
+generated documentation, and conversions to other media types.
+
+“Work” shall mean the work of authorship, whether in Source or Object form, made
+available under the License, as indicated by a copyright notice that is included
+in or attached to the work (an example is provided in the Appendix below).
+
+“Derivative Works” shall mean any work, whether in Source or Object form, that
+is based on (or derived from) the Work and for which the editorial revisions,
+annotations, elaborations, or other modifications represent, as a whole, an
+original work of authorship. For the purposes of this License, Derivative Works
+shall not include works that remain separable from, or merely link (or bind by
+name) to the interfaces of, the Work and Derivative Works thereof.
+
+“Contribution” shall mean any work of authorship, including the original version
+of the Work and any modifications or additions to that Work or Derivative Works
+thereof, that is intentionally submitted to Licensor for inclusion in the Work
+by the copyright owner or by an individual or Legal Entity authorized to submit
+on behalf of the copyright owner. For the purposes of this definition,
+“submitted” means any form of electronic, verbal, or written communication sent
+to the Licensor or its representatives, including but not limited to
+communication on electronic mailing lists, source code control systems, and
+issue tracking systems that are managed by, or on behalf of, the Licensor for
+the purpose of discussing and improving the Work, but excluding communication
+that is conspicuously marked or otherwise designated in writing by the copyright
+owner as “Not a Contribution.”
+
+“Contributor” shall mean Licensor and any individual or Legal Entity on behalf
+of whom a Contribution has been received by Licensor and subsequently
+incorporated within the Work.
+
+#### 2. Grant of Copyright License
+
+Subject to the terms and conditions of this License, each Contributor hereby
+grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
+irrevocable copyright license to reproduce, prepare Derivative Works of,
+publicly display, publicly perform, sublicense, and distribute the Work and such
+Derivative Works in Source or Object form.
+
+#### 3. Grant of Patent License
+
+Subject to the terms and conditions of this License, each Contributor hereby
+grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
+irrevocable (except as stated in this section) patent license to make, have
+made, use, offer to sell, sell, import, and otherwise transfer the Work, where
+such license applies only to those patent claims licensable by such Contributor
+that are necessarily infringed by their Contribution(s) alone or by combination
+of their Contribution(s) with the Work to which such Contribution(s) was
+submitted. If You institute patent litigation against any entity (including a
+cross-claim or counterclaim in a lawsuit) alleging that the Work or a
+Contribution incorporated within the Work constitutes direct or contributory
+patent infringement, then any patent licenses granted to You under this License
+for that Work shall terminate as of the date such litigation is filed.
+
+#### 4. Redistribution
+
+You may reproduce and distribute copies of the Work or Derivative Works thereof
+in any medium, with or without modifications, and in Source or Object form,
+provided that You meet the following conditions:
+
+- **(a)** You must give any other recipients of the Work or Derivative Works a copy of
+ this License; and
+- **(b)** You must cause any modified files to carry prominent notices stating that You
+ changed the files; and
+- **(c)** You must retain, in the Source form of any Derivative Works that You distribute,
+ all copyright, patent, trademark, and attribution notices from the Source form
+ of the Work, excluding those notices that do not pertain to any part of the
+ Derivative Works; and
+- **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any
+ Derivative Works that You distribute must include a readable copy of the
+ attribution notices contained within such NOTICE file, excluding those notices
+ that do not pertain to any part of the Derivative Works, in at least one of the
+ following places: within a NOTICE text file distributed as part of the
+ Derivative Works; within the Source form or documentation, if provided along
+ with the Derivative Works; or, within a display generated by the Derivative
+ Works, if and wherever such third-party notices normally appear. The contents of
+ the NOTICE file are for informational purposes only and do not modify the
+ License. You may add Your own attribution notices within Derivative Works that
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
+ provided that such additional attribution notices cannot be construed as
+ modifying the License.
+
+You may add Your own copyright statement to Your modifications and may provide
+additional or different license terms and conditions for use, reproduction, or
+distribution of Your modifications, or for any such Derivative Works as a whole,
+provided Your use, reproduction, and distribution of the Work otherwise complies
+with the conditions stated in this License.
+
+#### 5. Submission of Contributions
+
+Unless You explicitly state otherwise, any Contribution intentionally submitted
+for inclusion in the Work by You to the Licensor shall be under the terms and
+conditions of this License, without any additional terms or conditions.
+Notwithstanding the above, nothing herein shall supersede or modify the terms of
+any separate license agreement you may have executed with Licensor regarding
+such Contributions.
+
+#### 6. Trademarks
+
+This License does not grant permission to use the trade names, trademarks,
+service marks, or product names of the Licensor, except as required for
+reasonable and customary use in describing the origin of the Work and
+reproducing the content of the NOTICE file.
+
+#### 7. Disclaimer of Warranty
+
+Unless required by applicable law or agreed to in writing, Licensor provides the
+Work (and each Contributor provides its Contributions) on an “AS IS” BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
+including, without limitation, any warranties or conditions of TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
+solely responsible for determining the appropriateness of using or
+redistributing the Work and assume any risks associated with Your exercise of
+permissions under this License.
+
+#### 8. Limitation of Liability
+
+In no event and under no legal theory, whether in tort (including negligence),
+contract, or otherwise, unless required by applicable law (such as deliberate
+and grossly negligent acts) or agreed to in writing, shall any Contributor be
+liable to You for damages, including any direct, indirect, special, incidental,
+or consequential damages of any character arising as a result of this License or
+out of the use or inability to use the Work (including but not limited to
+damages for loss of goodwill, work stoppage, computer failure or malfunction, or
+any and all other commercial damages or losses), even if such Contributor has
+been advised of the possibility of such damages.
+
+#### 9. Accepting Warranty or Additional Liability
+
+While redistributing the Work or Derivative Works thereof, You may choose to
+offer, and charge a fee for, acceptance of support, warranty, indemnity, or
+other liability obligations and/or rights consistent with this License. However,
+in accepting such obligations, You may act only on Your own behalf and on Your
+sole responsibility, not on behalf of any other Contributor, and only if You
+agree to indemnify, defend, and hold each Contributor harmless for any liability
+incurred by, or claims asserted against, such Contributor by reason of your
+accepting any such warranty or additional liability.
+
+_END OF TERMS AND CONDITIONS_
+
+### APPENDIX: Apply the Apache License to a specific file
+
+To apply the Apache License to an individual file, attach the following notice.
+The text should be enclosed in the appropriate comment syntax for the file
+format.
+
+ Copyright © 2022–, HASH
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/blocks/heading/LICENSE-MIT.md b/blocks/heading/LICENSE-MIT.md
new file mode 100644
index 0000000..e33c1d3
--- /dev/null
+++ b/blocks/heading/LICENSE-MIT.md
@@ -0,0 +1,21 @@
+# MIT License
+
+Copyright © 2022–, HASH
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/blocks/heading/LICENSE.md b/blocks/heading/LICENSE.md
new file mode 100644
index 0000000..8686df9
--- /dev/null
+++ b/blocks/heading/LICENSE.md
@@ -0,0 +1,5 @@
+# License
+
+Licensed under either of the [Apache License, Version 2.0](LICENSE-APACHE.md) or [MIT license](LICENSE-MIT.md) at your option.
+
+For more information about contributing to this block, see our top-level [CONTRIBUTING](https://github.com/hashintel/hash/blob/main/.github/CONTRIBUTING.md) policy.
diff --git a/blocks/heading/README.md b/blocks/heading/README.md
new file mode 100644
index 0000000..dabec38
--- /dev/null
+++ b/blocks/heading/README.md
@@ -0,0 +1,3 @@
+# Header block
+
+A block to display heading text.
diff --git a/blocks/heading/eslint.config.js b/blocks/heading/eslint.config.js
new file mode 100644
index 0000000..5b6bb9d
--- /dev/null
+++ b/blocks/heading/eslint.config.js
@@ -0,0 +1,3 @@
+import { createBlock } from "@local/eslint/deprecated";
+
+export default createBlock(import.meta.dirname);
diff --git a/blocks/heading/package.json b/blocks/heading/package.json
new file mode 100644
index 0000000..f826943
--- /dev/null
+++ b/blocks/heading/package.json
@@ -0,0 +1,81 @@
+{
+ "name": "@blocks/heading",
+ "version": "0.2.3",
+ "private": true,
+ "description": "Write titles, sub-titles, and section headings in four different sizes",
+ "keywords": [
+ "blockprotocol",
+ "blocks",
+ "block"
+ ],
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/hashintel/blocks.git#main",
+ "directory": "blocks/heading"
+ },
+ "license": "(MIT OR Apache-2.0)",
+ "author": "HASH",
+ "type": "module",
+ "scripts": {
+ "build": "block-scripts build",
+ "codegen": "block-scripts codegen && yarn format",
+ "dev": "block-scripts dev",
+ "fix:eslint": "eslint --fix .",
+ "format": "prettier --write --ignore-unknown src/types/generated/*.ts",
+ "lint:eslint": "eslint --report-unused-disable-directives .",
+ "lint:tsc": "tsc --noEmit",
+ "serve": "block-scripts serve"
+ },
+ "dependencies": {
+ "@blockprotocol/graph": "0.3.4",
+ "@blockprotocol/hook": "0.1.3"
+ },
+ "devDependencies": {
+ "@local/eslint": "0.0.0-private",
+ "@local/tsconfig": "0.0.0-private",
+ "@types/react-dom": "19.1.7",
+ "block-scripts": "0.3.4",
+ "eslint": "10.0.3",
+ "mock-block-dock": "0.1.9",
+ "prettier": "3.8.1",
+ "react": "19.1.1",
+ "react-dom": "19.1.1",
+ "typescript": "5.9.3"
+ },
+ "peerDependencies": {
+ "react": "^19.0.0",
+ "react-dom": "^19.0.0"
+ },
+ "block-scripts": {
+ "devPort": 9090,
+ "servePort": 63282
+ },
+ "blockprotocol": {
+ "blockType": {
+ "entryPoint": "react"
+ },
+ "name": "@hash/heading",
+ "displayName": "Heading",
+ "icon": "public/h1.svg",
+ "image": "public/preview.svg",
+ "examples": [
+ {
+ "https://blockprotocol.org/@blockprotocol/types/property-type/textual-content/": "Hello World!",
+ "https://blockprotocol.org/@blockprotocol/types/property-type/html-heading-level/": 2,
+ "https://blockprotocol.org/@blockprotocol/types/property-type/css-text-color/": "black"
+ }
+ ],
+ "protocol": "0.3",
+ "blockEntityType": "https://blockprotocol.org/@hash/types/entity-type/heading-block/v/3",
+ "codegen": {
+ "outputFolder": "src/types/generated",
+ "targets": {
+ "block-entity.ts": [
+ {
+ "blockEntityType": true
+ }
+ ]
+ }
+ }
+ }
+}
diff --git a/blocks/heading/public/h1.svg b/blocks/heading/public/h1.svg
new file mode 100644
index 0000000..a17272b
--- /dev/null
+++ b/blocks/heading/public/h1.svg
@@ -0,0 +1,3 @@
+
diff --git a/blocks/heading/public/h2.svg b/blocks/heading/public/h2.svg
new file mode 100644
index 0000000..4a36ff4
--- /dev/null
+++ b/blocks/heading/public/h2.svg
@@ -0,0 +1,3 @@
+
diff --git a/blocks/heading/public/h3.svg b/blocks/heading/public/h3.svg
new file mode 100644
index 0000000..b4d68a2
--- /dev/null
+++ b/blocks/heading/public/h3.svg
@@ -0,0 +1,3 @@
+
diff --git a/blocks/heading/public/h4.svg b/blocks/heading/public/h4.svg
new file mode 100644
index 0000000..4b73c7a
--- /dev/null
+++ b/blocks/heading/public/h4.svg
@@ -0,0 +1,3 @@
+
diff --git a/blocks/heading/public/h5.svg b/blocks/heading/public/h5.svg
new file mode 100644
index 0000000..903a34f
--- /dev/null
+++ b/blocks/heading/public/h5.svg
@@ -0,0 +1,3 @@
+
diff --git a/blocks/heading/public/h6.svg b/blocks/heading/public/h6.svg
new file mode 100644
index 0000000..83aff31
--- /dev/null
+++ b/blocks/heading/public/h6.svg
@@ -0,0 +1,3 @@
+
diff --git a/blocks/heading/public/preview.svg b/blocks/heading/public/preview.svg
new file mode 100644
index 0000000..40b83b4
--- /dev/null
+++ b/blocks/heading/public/preview.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/blocks/heading/src/app.tsx b/blocks/heading/src/app.tsx
new file mode 100644
index 0000000..150986d
--- /dev/null
+++ b/blocks/heading/src/app.tsx
@@ -0,0 +1,58 @@
+import type { BlockComponent } from "@blockprotocol/graph/react";
+import { useEntitySubgraph } from "@blockprotocol/graph/react";
+import { useHook, useHookBlockModule } from "@blockprotocol/hook/react";
+import { useRef } from "react";
+
+import { propertyIds } from "./property-ids";
+import type { BlockEntity } from "./types/generated/block-entity";
+
+export const App: BlockComponent = ({
+ graph: { blockEntitySubgraph },
+}) => {
+ const { rootEntity } = useEntitySubgraph(blockEntitySubgraph);
+ const containerRef = useRef(null);
+ const headerRef = useRef(null);
+ /* @ts-expect-error -- @todo H-3839 hook package in BP repo needs updating for new ref type */
+ const { hookModule } = useHookBlockModule(containerRef);
+
+ const {
+ [propertyIds.color]: color,
+ [propertyIds.level]: level = 1,
+ [propertyIds.textualContent]: textualContent,
+ } = rootEntity.properties;
+
+ useHook(
+ hookModule,
+ headerRef,
+ "text",
+ rootEntity.metadata.recordId.entityId,
+ [propertyIds.textualContent],
+ (node) => {
+ // eslint-disable-next-line no-param-reassign
+ node.innerText = typeof textualContent === "string" ? textualContent : "";
+
+ return () => {
+ // eslint-disable-next-line no-param-reassign
+ node.innerText = "";
+ };
+ },
+ );
+
+ if (![1, 2, 3, 4, 5, 6].includes(level)) {
+ throw new Error(`Unexpected level ${level} (expected 1 - 6)`);
+ }
+ const Header = `h${level}` as "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
+
+ return (
+
+
+
+ );
+};
diff --git a/blocks/heading/src/dev.tsx b/blocks/heading/src/dev.tsx
new file mode 100644
index 0000000..f9541c6
--- /dev/null
+++ b/blocks/heading/src/dev.tsx
@@ -0,0 +1,46 @@
+/**
+ * This is the entry point for developing and debugging.
+ * This file is not bundled with the block during the build process.
+ */
+import type { VersionedUrl } from "@blockprotocol/graph";
+import { MockBlockDock } from "mock-block-dock";
+import { createRoot } from "react-dom/client";
+
+import packageJSON from "../package.json";
+import Component from "./index";
+import { propertyIds } from "./property-ids";
+import type { BlockEntity } from "./types/generated/block-entity";
+
+const node = document.getElementById("app");
+
+const initialData: BlockEntity = {
+ metadata: {
+ entityTypeId: packageJSON.blockprotocol.blockEntityType as VersionedUrl,
+ recordId: {
+ entityId: "entity-heading",
+ editionId: "1",
+ },
+ },
+ properties: {
+ [propertyIds.textualContent]: "Hello, World",
+ [propertyIds.level]: 2,
+ [propertyIds.color]: "red",
+ },
+};
+
+const App = () => (
+
+);
+
+createRoot(node!).render( );
diff --git a/blocks/heading/src/index.ts b/blocks/heading/src/index.ts
new file mode 100644
index 0000000..6eb172a
--- /dev/null
+++ b/blocks/heading/src/index.ts
@@ -0,0 +1,8 @@
+/* eslint-disable canonical/filename-no-index -- @todo rename file */
+
+/**
+ * Entrypoint of the Block Component.
+ */
+import { App } from "./app";
+
+export default App;
diff --git a/blocks/heading/src/property-ids.ts b/blocks/heading/src/property-ids.ts
new file mode 100644
index 0000000..36ecf8c
--- /dev/null
+++ b/blocks/heading/src/property-ids.ts
@@ -0,0 +1,8 @@
+export const propertyIds = {
+ level:
+ "https://blockprotocol.org/@blockprotocol/types/property-type/html-heading-level/" as const,
+ color:
+ "https://blockprotocol.org/@blockprotocol/types/property-type/css-text-color/" as const,
+ textualContent:
+ "https://blockprotocol.org/@blockprotocol/types/property-type/textual-content/" as const,
+};
diff --git a/blocks/heading/src/types/generated/block-entity.ts b/blocks/heading/src/types/generated/block-entity.ts
new file mode 100644
index 0000000..11040c8
--- /dev/null
+++ b/blocks/heading/src/types/generated/block-entity.ts
@@ -0,0 +1,71 @@
+/**
+ * This file was automatically generated – do not edit it.
+ */
+
+import { Entity } from "@blockprotocol/graph";
+
+export type BlockEntity = HeadingBlock;
+
+export type BlockEntityOutgoingLinkAndTarget =
+ HeadingBlockOutgoingLinkAndTarget;
+
+/**
+ * The text color, represented as a CSS-compatible color property expressed as a string.
+ *
+ * This is any ‘legal’ color value in CSS, for example (but not limited to)
+ *
+ * - a hexadecimal string: “#FFFFFF”
+ *
+ * - a named color: “skyblue”
+ *
+ * - an RGB value in functional notation: “rgb(255, 0, 255)”
+ *
+ * - an HSLA value in functional notation: “hsla(120, 100%, 50%)”
+ *
+ * See: https://www.w3schools.com/cssref/css_colors_legal.php
+ */
+export type CSSTextColorPropertyValue = TextDataType;
+
+/**
+ * The “level” or size of the heading, this can be an integer between 1 to 6 (inclusive).
+ *
+ * This corresponds to the equivalent HTML tags (h1, h2, etc.)
+ */
+export type HTMLHeadingLevelPropertyValue = NumberDataType;
+
+export type HeadingBlock = Entity;
+
+export type HeadingBlockOutgoingLinkAndTarget = never;
+
+export type HeadingBlockOutgoingLinksByLinkEntityTypeId = {};
+
+/**
+ * The block entity for the “Heading” block.
+ *
+ * See: https://blockprotocol.org/@hash/blocks/heading
+ */
+export type HeadingBlockProperties = {
+ "https://blockprotocol.org/@blockprotocol/types/property-type/html-heading-level/"?: HTMLHeadingLevelPropertyValue;
+ "https://blockprotocol.org/@blockprotocol/types/property-type/css-text-color/"?: CSSTextColorPropertyValue;
+ "https://blockprotocol.org/@blockprotocol/types/property-type/textual-content/"?: TextualContentPropertyValue;
+};
+
+/**
+ * An arithmetical value (in the Real number system)
+ */
+export type NumberDataType = number;
+
+/**
+ * An opaque, untyped JSON object
+ */
+export type ObjectDataType = {};
+
+/**
+ * An ordered sequence of characters
+ */
+export type TextDataType = string;
+
+/**
+ * The text material, information, or body, that makes up the content of this thing.
+ */
+export type TextualContentPropertyValue = TextDataType | ObjectDataType[];
diff --git a/blocks/heading/tsconfig.json b/blocks/heading/tsconfig.json
new file mode 100644
index 0000000..03676c9
--- /dev/null
+++ b/blocks/heading/tsconfig.json
@@ -0,0 +1,5 @@
+{
+ "extends": "@local/tsconfig/block.json",
+ "include": ["src"],
+ "exclude": ["node_modules"]
+}
diff --git a/blocks/heading/turbo.json b/blocks/heading/turbo.json
new file mode 100644
index 0000000..9d80ee7
--- /dev/null
+++ b/blocks/heading/turbo.json
@@ -0,0 +1,28 @@
+{
+ "extends": ["//"],
+ "tasks": {
+ "codegen": {
+ "inputs": ["./package.json"],
+ "outputs": ["./src/types/generated/**"]
+ },
+ "build": {
+ "dependsOn": ["^build", "codegen", "format"],
+ "outputs": ["./dist/**"]
+ },
+ "lint:tsc": {
+ "dependsOn": ["codegen"]
+ },
+ "format": {
+ "cache": false,
+ "dependsOn": ["codegen"]
+ },
+ "dev": {
+ "persistent": true,
+ "dependsOn": ["^build", "codegen"]
+ },
+ "serve": {
+ "persistent": true,
+ "dependsOn": ["build"]
+ }
+ }
+}
diff --git a/blocks/heading/variants.json b/blocks/heading/variants.json
new file mode 100644
index 0000000..4ade9a2
--- /dev/null
+++ b/blocks/heading/variants.json
@@ -0,0 +1,58 @@
+[
+ {
+ "name": "Heading 1",
+ "description": "For the largest (top-level) section headings",
+ "icon": "public/h1.svg",
+ "properties": {
+ "https://blockprotocol.org/@blockprotocol/types/property-type/html-heading-level/": 1
+ },
+ "examples": [
+ {
+ "https://blockprotocol.org/@blockprotocol/types/property-type/html-heading-level/": 1,
+ "https://blockprotocol.org/@blockprotocol/types/property-type/textual-content/": "I'm a top-level heading!"
+ }
+ ]
+ },
+ {
+ "name": "Heading 2",
+ "description": "For large section headings",
+ "icon": "public/h2.svg",
+ "properties": {
+ "https://blockprotocol.org/@blockprotocol/types/property-type/html-heading-level/": 2
+ },
+ "examples": [
+ {
+ "https://blockprotocol.org/@blockprotocol/types/property-type/html-heading-level/": 2,
+ "https://blockprotocol.org/@blockprotocol/types/property-type/textual-content/": "I'm a large heading!"
+ }
+ ]
+ },
+ {
+ "name": "Heading 3",
+ "description": "For medium section headings",
+ "icon": "public/h3.svg",
+ "properties": {
+ "https://blockprotocol.org/@blockprotocol/types/property-type/html-heading-level/": 3
+ },
+ "examples": [
+ {
+ "https://blockprotocol.org/@blockprotocol/types/property-type/html-heading-level/": 3,
+ "https://blockprotocol.org/@blockprotocol/types/property-type/textual-content/": "I'm a medium heading!"
+ }
+ ]
+ },
+ {
+ "name": "Heading 4",
+ "description": "For small section headings",
+ "icon": "public/h4.svg",
+ "properties": {
+ "https://blockprotocol.org/@blockprotocol/types/property-type/html-heading-level/": 4
+ },
+ "examples": [
+ {
+ "https://blockprotocol.org/@blockprotocol/types/property-type/html-heading-level/": 4,
+ "https://blockprotocol.org/@blockprotocol/types/property-type/textual-content/": "I'm a small heading!"
+ }
+ ]
+ }
+]
diff --git a/blocks/how-to/LICENSE-APACHE.md b/blocks/how-to/LICENSE-APACHE.md
new file mode 100644
index 0000000..1d1b6f8
--- /dev/null
+++ b/blocks/how-to/LICENSE-APACHE.md
@@ -0,0 +1,189 @@
+# Apache License
+
+_Version 2.0, January 2004_
+_< >_
+
+### Terms and Conditions for use, reproduction, and distribution
+
+#### 1. Definitions
+
+“License” shall mean the terms and conditions for use, reproduction, and
+distribution as defined by Sections 1 through 9 of this document.
+
+“Licensor” shall mean the copyright owner or entity authorized by the copyright
+owner that is granting the License.
+
+“Legal Entity” shall mean the union of the acting entity and all other entities
+that control, are controlled by, or are under common control with that entity.
+For the purposes of this definition, “control” means **(i)** the power, direct or
+indirect, to cause the direction or management of such entity, whether by
+contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the
+outstanding shares, or **(iii)** beneficial ownership of such entity.
+
+“You” (or “Your”) shall mean an individual or Legal Entity exercising
+permissions granted by this License.
+
+“Source” form shall mean the preferred form for making modifications, including
+but not limited to software source code, documentation source, and configuration
+files.
+
+“Object” form shall mean any form resulting from mechanical transformation or
+translation of a Source form, including but not limited to compiled object code,
+generated documentation, and conversions to other media types.
+
+“Work” shall mean the work of authorship, whether in Source or Object form, made
+available under the License, as indicated by a copyright notice that is included
+in or attached to the work (an example is provided in the Appendix below).
+
+“Derivative Works” shall mean any work, whether in Source or Object form, that
+is based on (or derived from) the Work and for which the editorial revisions,
+annotations, elaborations, or other modifications represent, as a whole, an
+original work of authorship. For the purposes of this License, Derivative Works
+shall not include works that remain separable from, or merely link (or bind by
+name) to the interfaces of, the Work and Derivative Works thereof.
+
+“Contribution” shall mean any work of authorship, including the original version
+of the Work and any modifications or additions to that Work or Derivative Works
+thereof, that is intentionally submitted to Licensor for inclusion in the Work
+by the copyright owner or by an individual or Legal Entity authorized to submit
+on behalf of the copyright owner. For the purposes of this definition,
+“submitted” means any form of electronic, verbal, or written communication sent
+to the Licensor or its representatives, including but not limited to
+communication on electronic mailing lists, source code control systems, and
+issue tracking systems that are managed by, or on behalf of, the Licensor for
+the purpose of discussing and improving the Work, but excluding communication
+that is conspicuously marked or otherwise designated in writing by the copyright
+owner as “Not a Contribution.”
+
+“Contributor” shall mean Licensor and any individual or Legal Entity on behalf
+of whom a Contribution has been received by Licensor and subsequently
+incorporated within the Work.
+
+#### 2. Grant of Copyright License
+
+Subject to the terms and conditions of this License, each Contributor hereby
+grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
+irrevocable copyright license to reproduce, prepare Derivative Works of,
+publicly display, publicly perform, sublicense, and distribute the Work and such
+Derivative Works in Source or Object form.
+
+#### 3. Grant of Patent License
+
+Subject to the terms and conditions of this License, each Contributor hereby
+grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
+irrevocable (except as stated in this section) patent license to make, have
+made, use, offer to sell, sell, import, and otherwise transfer the Work, where
+such license applies only to those patent claims licensable by such Contributor
+that are necessarily infringed by their Contribution(s) alone or by combination
+of their Contribution(s) with the Work to which such Contribution(s) was
+submitted. If You institute patent litigation against any entity (including a
+cross-claim or counterclaim in a lawsuit) alleging that the Work or a
+Contribution incorporated within the Work constitutes direct or contributory
+patent infringement, then any patent licenses granted to You under this License
+for that Work shall terminate as of the date such litigation is filed.
+
+#### 4. Redistribution
+
+You may reproduce and distribute copies of the Work or Derivative Works thereof
+in any medium, with or without modifications, and in Source or Object form,
+provided that You meet the following conditions:
+
+- **(a)** You must give any other recipients of the Work or Derivative Works a copy of
+ this License; and
+- **(b)** You must cause any modified files to carry prominent notices stating that You
+ changed the files; and
+- **(c)** You must retain, in the Source form of any Derivative Works that You distribute,
+ all copyright, patent, trademark, and attribution notices from the Source form
+ of the Work, excluding those notices that do not pertain to any part of the
+ Derivative Works; and
+- **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any
+ Derivative Works that You distribute must include a readable copy of the
+ attribution notices contained within such NOTICE file, excluding those notices
+ that do not pertain to any part of the Derivative Works, in at least one of the
+ following places: within a NOTICE text file distributed as part of the
+ Derivative Works; within the Source form or documentation, if provided along
+ with the Derivative Works; or, within a display generated by the Derivative
+ Works, if and wherever such third-party notices normally appear. The contents of
+ the NOTICE file are for informational purposes only and do not modify the
+ License. You may add Your own attribution notices within Derivative Works that
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
+ provided that such additional attribution notices cannot be construed as
+ modifying the License.
+
+You may add Your own copyright statement to Your modifications and may provide
+additional or different license terms and conditions for use, reproduction, or
+distribution of Your modifications, or for any such Derivative Works as a whole,
+provided Your use, reproduction, and distribution of the Work otherwise complies
+with the conditions stated in this License.
+
+#### 5. Submission of Contributions
+
+Unless You explicitly state otherwise, any Contribution intentionally submitted
+for inclusion in the Work by You to the Licensor shall be under the terms and
+conditions of this License, without any additional terms or conditions.
+Notwithstanding the above, nothing herein shall supersede or modify the terms of
+any separate license agreement you may have executed with Licensor regarding
+such Contributions.
+
+#### 6. Trademarks
+
+This License does not grant permission to use the trade names, trademarks,
+service marks, or product names of the Licensor, except as required for
+reasonable and customary use in describing the origin of the Work and
+reproducing the content of the NOTICE file.
+
+#### 7. Disclaimer of Warranty
+
+Unless required by applicable law or agreed to in writing, Licensor provides the
+Work (and each Contributor provides its Contributions) on an “AS IS” BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
+including, without limitation, any warranties or conditions of TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
+solely responsible for determining the appropriateness of using or
+redistributing the Work and assume any risks associated with Your exercise of
+permissions under this License.
+
+#### 8. Limitation of Liability
+
+In no event and under no legal theory, whether in tort (including negligence),
+contract, or otherwise, unless required by applicable law (such as deliberate
+and grossly negligent acts) or agreed to in writing, shall any Contributor be
+liable to You for damages, including any direct, indirect, special, incidental,
+or consequential damages of any character arising as a result of this License or
+out of the use or inability to use the Work (including but not limited to
+damages for loss of goodwill, work stoppage, computer failure or malfunction, or
+any and all other commercial damages or losses), even if such Contributor has
+been advised of the possibility of such damages.
+
+#### 9. Accepting Warranty or Additional Liability
+
+While redistributing the Work or Derivative Works thereof, You may choose to
+offer, and charge a fee for, acceptance of support, warranty, indemnity, or
+other liability obligations and/or rights consistent with this License. However,
+in accepting such obligations, You may act only on Your own behalf and on Your
+sole responsibility, not on behalf of any other Contributor, and only if You
+agree to indemnify, defend, and hold each Contributor harmless for any liability
+incurred by, or claims asserted against, such Contributor by reason of your
+accepting any such warranty or additional liability.
+
+_END OF TERMS AND CONDITIONS_
+
+### APPENDIX: Apply the Apache License to a specific file
+
+To apply the Apache License to an individual file, attach the following notice.
+The text should be enclosed in the appropriate comment syntax for the file
+format.
+
+ Copyright © 2022–, HASH
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/blocks/how-to/LICENSE-MIT.md b/blocks/how-to/LICENSE-MIT.md
new file mode 100644
index 0000000..e33c1d3
--- /dev/null
+++ b/blocks/how-to/LICENSE-MIT.md
@@ -0,0 +1,21 @@
+# MIT License
+
+Copyright © 2022–, HASH
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/blocks/how-to/LICENSE.md b/blocks/how-to/LICENSE.md
new file mode 100644
index 0000000..8686df9
--- /dev/null
+++ b/blocks/how-to/LICENSE.md
@@ -0,0 +1,5 @@
+# License
+
+Licensed under either of the [Apache License, Version 2.0](LICENSE-APACHE.md) or [MIT license](LICENSE-MIT.md) at your option.
+
+For more information about contributing to this block, see our top-level [CONTRIBUTING](https://github.com/hashintel/hash/blob/main/.github/CONTRIBUTING.md) policy.
diff --git a/blocks/how-to/README.md b/blocks/how-to/README.md
new file mode 100644
index 0000000..c77f64b
--- /dev/null
+++ b/blocks/how-to/README.md
@@ -0,0 +1,5 @@
+This block typically allows the user to create a step-by-step tutorials that are easy to follow and understand.
+
+Each step consists of a `title`, `description`, and an optional `image` that is saved on a `How-to Step` entity that is linked to the block entity. The introduction is also stored in a `How-to Step` entity.
+
+The block also stores its state locally in `title` and `description` properties.
diff --git a/blocks/how-to/eslint.config.js b/blocks/how-to/eslint.config.js
new file mode 100644
index 0000000..5b6bb9d
--- /dev/null
+++ b/blocks/how-to/eslint.config.js
@@ -0,0 +1,3 @@
+import { createBlock } from "@local/eslint/deprecated";
+
+export default createBlock(import.meta.dirname);
diff --git a/blocks/how-to/package.json b/blocks/how-to/package.json
new file mode 100644
index 0000000..9d0b265
--- /dev/null
+++ b/blocks/how-to/package.json
@@ -0,0 +1,86 @@
+{
+ "name": "@blocks/how-to",
+ "version": "0.1.3",
+ "private": true,
+ "description": "Describe a task or process via a list of steps",
+ "keywords": [
+ "blockprotocol",
+ "blocks",
+ "block"
+ ],
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/hashintel/blocks.git#main",
+ "directory": "blocks/how-to"
+ },
+ "license": "(MIT OR Apache-2.0)",
+ "author": "HASH",
+ "type": "module",
+ "scripts": {
+ "build": "block-scripts build",
+ "codegen": "block-scripts codegen && yarn format",
+ "dev": "block-scripts dev",
+ "fix:eslint": "eslint --fix .",
+ "format": "prettier --write --ignore-unknown src/types/generated/*.ts",
+ "lint:eslint": "eslint --report-unused-disable-directives .",
+ "lint:tsc": "tsc --noEmit",
+ "serve": "block-scripts serve"
+ },
+ "prettier": {
+ "printWidth": 80,
+ "trailingComma": "all"
+ },
+ "dependencies": {
+ "@blockprotocol/graph": "0.3.4",
+ "@hashintel/block-design-system": "0.0.5",
+ "@hashintel/design-system": "0.0.9-canary.2",
+ "@mui/material": "5.18.0",
+ "react-sizeme": "3.0.2",
+ "uuid": "13.0.1"
+ },
+ "devDependencies": {
+ "@local/eslint": "0.0.0-private",
+ "@types/react-dom": "19.1.7",
+ "block-scripts": "0.3.4",
+ "eslint": "10.0.3",
+ "mock-block-dock": "0.1.9",
+ "prettier": "3.8.1",
+ "react": "19.1.1",
+ "react-dom": "19.1.1",
+ "typescript": "5.9.3"
+ },
+ "peerDependencies": {
+ "react": "^19.0.0",
+ "react-dom": "^19.0.0"
+ },
+ "block-scripts": {
+ "port": 63212
+ },
+ "blockprotocol": {
+ "blockType": {
+ "entryPoint": "react"
+ },
+ "displayName": "How To",
+ "examples": [
+ {
+ "https://blockprotocol.org/@blockprotocol/types/property-type/title/": "Boil water",
+ "https://blockprotocol.org/@blockprotocol/types/property-type/description/": "Bring the clear water to a rolling boil for 1 minute"
+ }
+ ],
+ "icon": "public/book-arrow-right.svg",
+ "image": "public/block-preview.png",
+ "name": "@hash/how-to",
+ "protocol": "0.3",
+ "blockEntityType": "https://blockprotocol.org/@hash/types/entity-type/how-to-block/v/2",
+ "codegen": {
+ "outputFolder": "src/types/generated",
+ "targets": {
+ "block-entity.ts": [
+ {
+ "blockEntityType": true
+ }
+ ]
+ }
+ }
+ }
+}
diff --git a/blocks/how-to/public/block-preview.png b/blocks/how-to/public/block-preview.png
new file mode 100644
index 0000000..c50eafe
Binary files /dev/null and b/blocks/how-to/public/block-preview.png differ
diff --git a/blocks/how-to/public/book-arrow-right.svg b/blocks/how-to/public/book-arrow-right.svg
new file mode 100644
index 0000000..3b78954
--- /dev/null
+++ b/blocks/how-to/public/book-arrow-right.svg
@@ -0,0 +1,3 @@
+
diff --git a/blocks/how-to/src/app.tsx b/blocks/how-to/src/app.tsx
new file mode 100644
index 0000000..91fb8ee
--- /dev/null
+++ b/blocks/how-to/src/app.tsx
@@ -0,0 +1,514 @@
+import type { LinkEntityAndRightEntity } from "@blockprotocol/graph";
+import {
+ type BlockComponent,
+ useEntitySubgraph,
+ useGraphBlockModule,
+} from "@blockprotocol/graph/react";
+import { EditableField, GetHelpLink } from "@hashintel/block-design-system";
+import { Button, faPlus, FontAwesomeIcon } from "@hashintel/design-system";
+import { theme } from "@hashintel/design-system/theme";
+import { Card, Collapse, Fade, Stack, ThemeProvider } from "@mui/material";
+import Box from "@mui/material/Box";
+import { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import { SizeMe } from "react-sizeme";
+import { v4 as uuid } from "uuid";
+
+import { Step } from "./step";
+import type {
+ BlockEntity,
+ HasHowToBlockIntroduction,
+ HowToBlockIntroduction,
+ HowToBlockOutgoingLinkAndTarget,
+ HowToBlockOutgoingLinksByLinkEntityTypeId,
+ HowToBlockStep,
+ HowToBlockStepProperties,
+} from "./types/generated/block-entity";
+
+type BlockEntityKey = keyof BlockEntity["properties"];
+type LinkType = keyof HowToBlockOutgoingLinksByLinkEntityTypeId;
+
+// Property types
+export const titleKey: BlockEntityKey =
+ "https://blockprotocol.org/@blockprotocol/types/property-type/title/";
+export const descriptionKey: BlockEntityKey =
+ "https://blockprotocol.org/@blockprotocol/types/property-type/description/";
+
+// Relevant Entity Types
+const howToBlockStepType =
+ "https://blockprotocol.org/@hash/types/entity-type/how-to-block-step/v/2";
+const howToBlockIntroductionType =
+ "https://blockprotocol.org/@hash/types/entity-type/how-to-block-introduction/v/2";
+
+// Link Entity Types
+const hasHowToBlockStep: LinkType =
+ "https://blockprotocol.org/@hash/types/entity-type/has-how-to-block-step/v/1";
+const hasHowToBlockIntroduction: LinkType =
+ "https://blockprotocol.org/@hash/types/entity-type/has-how-to-block-introduction/v/1";
+
+export type TitleOrDescription = typeof titleKey | typeof descriptionKey;
+export type EntityType =
+ | typeof howToBlockIntroductionType
+ | typeof howToBlockStepType;
+
+export const App: BlockComponent = ({
+ graph: { blockEntitySubgraph, readonly },
+}) => {
+ const blockRootRef = useRef(null);
+ /* @ts-expect-error –– @todo H-3839 packages in BP repo needs updating, or this package updating to use graph in this repo */
+ const { graphModule } = useGraphBlockModule(blockRootRef);
+ const { rootEntity: blockEntity, linkedEntities } = useEntitySubgraph<
+ BlockEntity,
+ HowToBlockOutgoingLinkAndTarget[]
+ >(blockEntitySubgraph);
+
+ const {
+ metadata: {
+ recordId: { entityId },
+ entityTypeId,
+ },
+ properties,
+ } = blockEntity;
+
+ const { [titleKey]: title, [descriptionKey]: description } = properties;
+
+ const introLinkedEntity:
+ | HowToBlockOutgoingLinksByLinkEntityTypeId["https://blockprotocol.org/@hash/types/entity-type/has-how-to-block-introduction/v/1"]
+ | undefined = useMemo(
+ () =>
+ linkedEntities.find(
+ ({ linkEntity }) =>
+ linkEntity.metadata.entityTypeId === hasHowToBlockIntroduction,
+ ),
+ [linkedEntities],
+ );
+
+ const introEntity: HowToBlockIntroduction | undefined =
+ introLinkedEntity?.rightEntity;
+ const introLinkEntity: HasHowToBlockIntroduction | undefined =
+ introLinkedEntity?.linkEntity;
+
+ const stepLinkedEntities: LinkEntityAndRightEntity[] = useMemo(
+ () =>
+ linkedEntities.filter(
+ ({ linkEntity }) =>
+ linkEntity.metadata.entityTypeId === hasHowToBlockStep,
+ ),
+ [linkedEntities],
+ );
+
+ const stepEntities: HowToBlockStep[] | undefined = stepLinkedEntities.map(
+ (linkEntity) => linkEntity.rightEntity,
+ );
+
+ const [hovered, setHovered] = useState(false);
+ const [titleValue, setTitleValue] = useState(title);
+ const [descriptionValue, setDescriptionValue] = useState(description);
+ const [steps, setSteps] = useState<
+ {
+ id: string;
+ properties: HowToBlockStepProperties;
+ animatingOut?: boolean;
+ }[]
+ >(
+ stepEntities.map((stepEntity) => ({
+ id: stepEntity.metadata.recordId.entityId,
+ properties: stepEntity.properties,
+ })),
+ );
+ const [introButtonAnimatingOut, setIntroButtonAnimatingOut] = useState(false);
+ const [introAnimatingOut, setIntroAnimatingOut] = useState(false);
+
+ const updateField = async (value: string, field: TitleOrDescription) => {
+ await graphModule.updateEntity({
+ data: {
+ entityId,
+ entityTypeId,
+ properties: {
+ ...properties,
+ [field]: value,
+ },
+ },
+ });
+ };
+
+ const createHowToEntity = useCallback(
+ async (entityType: EntityType, linkType: LinkType) => {
+ if (readonly) {
+ return;
+ }
+
+ const createEntityResponse = await graphModule.createEntity({
+ data: {
+ entityTypeId: entityType,
+ properties: {},
+ },
+ });
+
+ const createdEntityId =
+ createEntityResponse.data?.metadata.recordId.entityId;
+
+ if (createdEntityId) {
+ await graphModule.createEntity({
+ data: {
+ entityTypeId: linkType,
+ properties: {},
+ linkData: {
+ leftEntityId: entityId,
+ rightEntityId: createdEntityId,
+ },
+ },
+ });
+ }
+ },
+ [graphModule, entityId, readonly],
+ );
+
+ const createIntroduction = async () => {
+ setIntroButtonAnimatingOut(true);
+ await createHowToEntity(
+ howToBlockIntroductionType,
+ hasHowToBlockIntroduction,
+ );
+ };
+
+ const updateIntroductionField = async (
+ value: string | boolean,
+ field: TitleOrDescription,
+ ) => {
+ if (introEntity) {
+ await graphModule.updateEntity({
+ data: {
+ entityId: introEntity.metadata.recordId.entityId,
+ entityTypeId: howToBlockIntroductionType,
+ properties: {
+ ...introEntity.properties,
+ [field]: value,
+ },
+ },
+ });
+ }
+ };
+
+ const removeIntroduction = async () => {
+ setIntroAnimatingOut(true);
+
+ if (introLinkEntity) {
+ await graphModule.deleteEntity({
+ data: {
+ entityId: introLinkEntity.metadata.recordId.entityId,
+ },
+ });
+ }
+ };
+
+ const addStep = useCallback(async () => {
+ setSteps([...steps, { id: uuid(), properties: {} }]);
+ await createHowToEntity(howToBlockStepType, hasHowToBlockStep);
+ }, [steps, createHowToEntity]);
+
+ const updateStepField = async (
+ index: number,
+ value: string,
+ field: TitleOrDescription,
+ ) => {
+ const stepEntity = stepEntities[index];
+
+ if (!stepEntity) {
+ return;
+ }
+
+ await graphModule.updateEntity({
+ data: {
+ entityId: stepEntity.metadata.recordId.entityId,
+ entityTypeId: howToBlockStepType,
+ properties: {
+ ...stepEntity.properties,
+ [field]: value,
+ },
+ },
+ });
+ };
+
+ const removeStep = (index: number) => {
+ setSteps(
+ steps.map((step, stepIndex) => {
+ if (index === stepIndex) {
+ return { ...step, animatingOut: true };
+ }
+ return step;
+ }),
+ );
+ };
+
+ useEffect(() => {
+ if (!stepEntities.length) {
+ void addStep();
+ }
+ // We only want to run this once when the block is initiated
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
+
+ const schema = useMemo(() => {
+ const stepsWithTitle = stepEntities.filter(
+ ({ properties: { [titleKey]: schemaTitle } }) => !!schemaTitle,
+ );
+
+ return JSON.stringify({
+ "@context": "http://schema.org",
+ "@type": "HowTo",
+ name: title,
+ // Must have at least 2 steps for it to be valid
+ ...(stepsWithTitle.length > 1
+ ? {
+ step: stepsWithTitle.map(
+ ({
+ properties: {
+ [titleKey]: schemaTitle,
+ [descriptionKey]: schemaDescription,
+ },
+ }) => ({
+ "@type": "HowToStep",
+ name: schemaTitle,
+ text: schemaDescription ?? schemaTitle,
+ }),
+ ),
+ }
+ : {}),
+ });
+ }, [title, stepEntities]);
+
+ return (
+ <>
+
+
+
+ {({ size }) => {
+ const isMobile = (size.width ?? 0) < 800;
+
+ return (
+ setHovered(true)}
+ onMouseLeave={() => setHovered(false)}
+ >
+ {!readonly ? (
+
+
+
+
+
+ ) : null}
+
+
+ `1px solid ${palette.gray[20]}`,
+ borderRadius: 2.5,
+ boxShadow: "none",
+ paddingY: 3,
+ paddingX: 3.75,
+ }
+ : {
+ background: "none",
+ boxShadow: "none",
+ }),
+ }}
+ >
+ {title || description || !readonly ? (
+
+ {
+ if (!readonly) {
+ setTitleValue(event.target.value);
+ }
+ }}
+ onBlur={(event) =>
+ updateField(event.target.value, titleKey)
+ }
+ sx={{
+ fontWeight: 700,
+ fontSize: 21,
+ lineHeight: 1,
+ letterSpacing: "-0.02em",
+ color: theme.palette.common.black,
+ }}
+ placeholder="Enter a how-to guide name"
+ readonly={readonly}
+ />
+
+ {
+ if (!readonly) {
+ setDescriptionValue(event.target.value);
+ }
+ }}
+ onBlur={(event) => {
+ void updateField(event.target.value, descriptionKey);
+ }}
+ sx={{
+ fontWeight: 500,
+ fontSize: 14,
+ lineHeight: 1.3,
+ letterSpacing: "-0.02em",
+ color: theme.palette.gray[90],
+ }}
+ placeholder="Click here to add a description of the how-to process"
+ placeholderSx={{
+ fontStyle: "italic",
+ }}
+ readonly={readonly}
+ />
+
+ ) : null}
+
+ {(introEntity ?? !readonly) ? (
+
+ setIntroButtonAnimatingOut(false)}
+ >
+
+
+
+ setIntroAnimatingOut(false)}
+ appear
+ >
+ removeIntroduction()}
+ readonly={readonly}
+ deleteButtonText="Remove intro"
+ />
+
+
+ ) : null}
+
+
+ {steps.map((step, index) => (
+ {
+ const newSteps = [...steps];
+ newSteps.splice(index, 1);
+ setSteps(newSteps);
+
+ const stepLink =
+ stepLinkedEntities[index]?.linkEntity;
+
+ if (!stepLink) {
+ return;
+ }
+
+ await graphModule.deleteEntity({
+ data: {
+ entityId: stepLink.metadata.recordId.entityId,
+ },
+ });
+ }}
+ appear
+ >
+
+ transitions.create("margin-bottom"),
+ }}
+ >
+
+ updateStepField(index, value, field)
+ }
+ onRemove={() => removeStep(index)}
+ readonly={readonly}
+ deletable={stepEntities.length > 1}
+ deleteButtonText="Remove step"
+ />
+
+
+ ))}
+
+
+ {!readonly ? (
+
+
+
+ ) : null}
+
+
+ );
+ }}
+
+
+ >
+ );
+};
diff --git a/blocks/how-to/src/assets.d.ts b/blocks/how-to/src/assets.d.ts
new file mode 100644
index 0000000..62db9da
--- /dev/null
+++ b/blocks/how-to/src/assets.d.ts
@@ -0,0 +1,3 @@
+declare module "*.css";
+declare module "*.sass";
+declare module "*.scss";
diff --git a/blocks/how-to/src/dev.tsx b/blocks/how-to/src/dev.tsx
new file mode 100644
index 0000000..3215618
--- /dev/null
+++ b/blocks/how-to/src/dev.tsx
@@ -0,0 +1,45 @@
+import type { VersionedUrl } from "@blockprotocol/type-system";
+import { MockBlockDock } from "mock-block-dock";
+import { createRoot } from "react-dom/client";
+
+import packageJSON from "../package.json";
+import Component from "./index";
+import type { BlockEntity } from "./types/generated/block-entity";
+
+const node = document.getElementById("app");
+
+const testEntity: BlockEntity = {
+ metadata: {
+ recordId: {
+ entityId: "test-entity",
+ editionId: new Date().toISOString(),
+ },
+ entityTypeId: packageJSON.blockprotocol.blockEntityType as VersionedUrl,
+ },
+ properties: {},
+} as const;
+
+const DevApp = () => {
+ return (
+
+ );
+};
+
+if (node) {
+ createRoot(node).render( );
+} else {
+ throw new Error("Unable to find DOM element with id 'app'");
+}
diff --git a/blocks/how-to/src/index.ts b/blocks/how-to/src/index.ts
new file mode 100644
index 0000000..4a0d45f
--- /dev/null
+++ b/blocks/how-to/src/index.ts
@@ -0,0 +1,7 @@
+/**
+ * Entrypoint of the Block Component.
+ */
+// eslint-disable-next-line canonical/filename-no-index
+import { App } from "./app";
+
+export default App;
diff --git a/blocks/how-to/src/step.tsx b/blocks/how-to/src/step.tsx
new file mode 100644
index 0000000..c3ba154
--- /dev/null
+++ b/blocks/how-to/src/step.tsx
@@ -0,0 +1,162 @@
+import { EditableField } from "@hashintel/block-design-system";
+import { Button, faTrash, FontAwesomeIcon } from "@hashintel/design-system";
+import type { SxProps, Theme } from "@mui/material";
+import { Box, Fade, Typography } from "@mui/material";
+import type { FunctionComponent } from "react";
+import { useState } from "react";
+
+import type { TitleOrDescription } from "./app";
+import { descriptionKey, titleKey } from "./app";
+
+interface StepProps {
+ header: string;
+ headerSx?: SxProps;
+ title?: string;
+ titlePlaceholder?: string;
+ description?: string;
+ descriptionPlaceholder?: string;
+ deletable?: boolean;
+ readonly?: boolean;
+ updateField: (value: string, field: TitleOrDescription) => void;
+ onRemove: () => void;
+ deleteButtonText: string;
+}
+
+export const Step: FunctionComponent = ({
+ header,
+ headerSx = {},
+ title,
+ titlePlaceholder,
+ description,
+ descriptionPlaceholder,
+ deletable = true,
+ readonly,
+ updateField,
+ onRemove,
+ deleteButtonText,
+}) => {
+ const [titleValue, setTitleValue] = useState(title ?? "");
+ const [descriptionValue, setDescriptionValue] = useState(description ?? "");
+
+ return (
+
+
+ palette.black,
+ paddingY: 0.75,
+ ...headerSx,
+ }}
+ >
+ {header}
+
+
+ {!readonly ? (
+
+
+
+ ) : null}
+
+
+ palette.gray[20],
+ borderTopLeftRadius: 10,
+ borderTopRightRadius: 10,
+ }
+ : {}),
+ }}
+ >
+ {
+ if (!readonly) {
+ setTitleValue(event.target.value);
+ }
+ }}
+ onBlur={(event) => updateField(event.target.value, titleKey)}
+ sx={{
+ fontWeight: 700,
+ fontSize: 15,
+ lineHeight: 1,
+ color: ({ palette }) => palette.gray[90],
+ ...(readonly ? { paddingY: 0.5 } : {}),
+ }}
+ placeholder={titlePlaceholder}
+ readonly={readonly}
+ />
+
+
+ palette.gray[20],
+ borderBottomLeftRadius: 10,
+ borderBottomRightRadius: 10,
+ }
+ : {}),
+ }}
+ >
+ {
+ if (!readonly) {
+ setDescriptionValue(event.target.value);
+ }
+ }}
+ onBlur={(event) => updateField(event.target.value, descriptionKey)}
+ sx={{
+ fontWeight: 400,
+ fontSize: 14,
+ lineHeight: 1.3,
+ color: ({ palette }) => palette.gray[90],
+ ...(readonly ? { paddingY: 0.5 } : {}),
+ }}
+ placeholder={descriptionPlaceholder}
+ readonly={readonly}
+ />
+
+
+ );
+};
diff --git a/blocks/how-to/src/types/generated/block-entity.ts b/blocks/how-to/src/types/generated/block-entity.ts
new file mode 100644
index 0000000..6ada714
--- /dev/null
+++ b/blocks/how-to/src/types/generated/block-entity.ts
@@ -0,0 +1,134 @@
+/**
+ * This file was automatically generated – do not edit it.
+ */
+
+import { Entity, LinkData } from "@blockprotocol/graph";
+
+export type BlockEntity = HowToBlock;
+
+export type BlockEntityOutgoingLinkAndTarget = HowToBlockOutgoingLinkAndTarget;
+
+/**
+ * A piece of text that tells you about something or someone. This can include explaining what they look like, what its purpose is for, what they’re like, etc.
+ */
+export type DescriptionPropertyValue = TextDataType;
+
+export type HasHowToBlockIntroduction =
+ Entity & { linkData: LinkData };
+
+export type HasHowToBlockIntroductionOutgoingLinkAndTarget = never;
+
+export type HasHowToBlockIntroductionOutgoingLinksByLinkEntityTypeId = {};
+
+/**
+ * Contains a How-To Block Introduction
+ *
+ * See: https://blockprotocol.org/@hash/types/entity-type/how-to-block-introduction
+ */
+export type HasHowToBlockIntroductionProperties =
+ HasHowToBlockIntroductionProperties1 & HasHowToBlockIntroductionProperties2;
+export type HasHowToBlockIntroductionProperties1 = LinkProperties;
+
+export type HasHowToBlockIntroductionProperties2 = {};
+
+export type HasHowToBlockStep = Entity & {
+ linkData: LinkData;
+};
+
+export type HasHowToBlockStepOutgoingLinkAndTarget = never;
+
+export type HasHowToBlockStepOutgoingLinksByLinkEntityTypeId = {};
+
+/**
+ * Contains a How-To Block step.
+ *
+ * See: https://blockprotocol.org/@hash/types/entity-type/how-to-block-step
+ */
+export type HasHowToBlockStepProperties = HasHowToBlockStepProperties1 &
+ HasHowToBlockStepProperties2;
+export type HasHowToBlockStepProperties1 = LinkProperties;
+
+export type HasHowToBlockStepProperties2 = {};
+
+export type HowToBlock = Entity;
+
+export type HowToBlockHasHowToBlockIntroductionLink = {
+ linkEntity: HasHowToBlockIntroduction;
+ rightEntity: HowToBlockIntroduction;
+};
+
+export type HowToBlockHasHowToBlockStepLink = {
+ linkEntity: HasHowToBlockStep;
+ rightEntity: HowToBlockStep;
+};
+
+export type HowToBlockIntroduction = Entity;
+
+export type HowToBlockIntroductionOutgoingLinkAndTarget = never;
+
+export type HowToBlockIntroductionOutgoingLinksByLinkEntityTypeId = {};
+
+/**
+ * A short description or precursor that explains the process that’s defined within the How-To block, or defines any preliminary context.
+ *
+ * It also often describes any pre-requisites necessary for completing the subsequent set of “How-To Block Step”s.
+ *
+ * See: https://blockprotocol.org/@hash/types/entity-type/how-to-block-step
+ */
+export type HowToBlockIntroductionProperties = {
+ "https://blockprotocol.org/@blockprotocol/types/property-type/title/"?: TitlePropertyValue;
+ "https://blockprotocol.org/@blockprotocol/types/property-type/description/"?: DescriptionPropertyValue;
+};
+
+export type HowToBlockOutgoingLinkAndTarget =
+ | HowToBlockHasHowToBlockStepLink
+ | HowToBlockHasHowToBlockIntroductionLink;
+
+export type HowToBlockOutgoingLinksByLinkEntityTypeId = {
+ "https://blockprotocol.org/@hash/types/entity-type/has-how-to-block-step/v/1": HowToBlockHasHowToBlockStepLink;
+ "https://blockprotocol.org/@hash/types/entity-type/has-how-to-block-introduction/v/1": HowToBlockHasHowToBlockIntroductionLink;
+};
+
+/**
+ * The block entity for the "How-To" block.
+ *
+ * See: https://blockprotocol.org/@hash/blocks/how-to
+ */
+export type HowToBlockProperties = {
+ "https://blockprotocol.org/@blockprotocol/types/property-type/title/"?: TitlePropertyValue;
+ "https://blockprotocol.org/@blockprotocol/types/property-type/description/"?: DescriptionPropertyValue;
+};
+
+export type HowToBlockStep = Entity;
+
+export type HowToBlockStepOutgoingLinkAndTarget = never;
+
+export type HowToBlockStepOutgoingLinksByLinkEntityTypeId = {};
+
+/**
+ * Defines a single step within a How-To Block.
+ *
+ * See: https://blockprotocol.org/@hash/types/entity-type/how-to-block
+ */
+export type HowToBlockStepProperties = {
+ "https://blockprotocol.org/@blockprotocol/types/property-type/title/"?: TitlePropertyValue;
+ "https://blockprotocol.org/@blockprotocol/types/property-type/description/"?: DescriptionPropertyValue;
+};
+
+export type Link = Entity;
+
+export type LinkOutgoingLinkAndTarget = never;
+
+export type LinkOutgoingLinksByLinkEntityTypeId = {};
+
+export type LinkProperties = {};
+
+/**
+ * An ordered sequence of characters
+ */
+export type TextDataType = string;
+
+/**
+ * The name given to something to identify it, generally associated with objects or inanimate things such as books, websites, songs, etc.
+ */
+export type TitlePropertyValue = TextDataType;
diff --git a/blocks/how-to/theme-override.d.ts b/blocks/how-to/theme-override.d.ts
new file mode 100644
index 0000000..85625e2
--- /dev/null
+++ b/blocks/how-to/theme-override.d.ts
@@ -0,0 +1,2 @@
+// eslint-disable-next-line no-restricted-imports
+import "@hashintel/design-system/theme-override";
diff --git a/blocks/how-to/tsconfig.json b/blocks/how-to/tsconfig.json
new file mode 100644
index 0000000..12904d6
--- /dev/null
+++ b/blocks/how-to/tsconfig.json
@@ -0,0 +1,5 @@
+{
+ "extends": "@local/tsconfig/block.json",
+ "include": ["src", "theme-override.d.ts"],
+ "exclude": ["node_modules"]
+}
diff --git a/blocks/how-to/turbo.json b/blocks/how-to/turbo.json
new file mode 100644
index 0000000..9d80ee7
--- /dev/null
+++ b/blocks/how-to/turbo.json
@@ -0,0 +1,28 @@
+{
+ "extends": ["//"],
+ "tasks": {
+ "codegen": {
+ "inputs": ["./package.json"],
+ "outputs": ["./src/types/generated/**"]
+ },
+ "build": {
+ "dependsOn": ["^build", "codegen", "format"],
+ "outputs": ["./dist/**"]
+ },
+ "lint:tsc": {
+ "dependsOn": ["codegen"]
+ },
+ "format": {
+ "cache": false,
+ "dependsOn": ["codegen"]
+ },
+ "dev": {
+ "persistent": true,
+ "dependsOn": ["^build", "codegen"]
+ },
+ "serve": {
+ "persistent": true,
+ "dependsOn": ["build"]
+ }
+ }
+}
diff --git a/blocks/how-to/variants.json b/blocks/how-to/variants.json
new file mode 100644
index 0000000..fe51488
--- /dev/null
+++ b/blocks/how-to/variants.json
@@ -0,0 +1 @@
+[]
diff --git a/blocks/image/LICENSE-APACHE.md b/blocks/image/LICENSE-APACHE.md
new file mode 100644
index 0000000..1d1b6f8
--- /dev/null
+++ b/blocks/image/LICENSE-APACHE.md
@@ -0,0 +1,189 @@
+# Apache License
+
+_Version 2.0, January 2004_
+_< >_
+
+### Terms and Conditions for use, reproduction, and distribution
+
+#### 1. Definitions
+
+“License” shall mean the terms and conditions for use, reproduction, and
+distribution as defined by Sections 1 through 9 of this document.
+
+“Licensor” shall mean the copyright owner or entity authorized by the copyright
+owner that is granting the License.
+
+“Legal Entity” shall mean the union of the acting entity and all other entities
+that control, are controlled by, or are under common control with that entity.
+For the purposes of this definition, “control” means **(i)** the power, direct or
+indirect, to cause the direction or management of such entity, whether by
+contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the
+outstanding shares, or **(iii)** beneficial ownership of such entity.
+
+“You” (or “Your”) shall mean an individual or Legal Entity exercising
+permissions granted by this License.
+
+“Source” form shall mean the preferred form for making modifications, including
+but not limited to software source code, documentation source, and configuration
+files.
+
+“Object” form shall mean any form resulting from mechanical transformation or
+translation of a Source form, including but not limited to compiled object code,
+generated documentation, and conversions to other media types.
+
+“Work” shall mean the work of authorship, whether in Source or Object form, made
+available under the License, as indicated by a copyright notice that is included
+in or attached to the work (an example is provided in the Appendix below).
+
+“Derivative Works” shall mean any work, whether in Source or Object form, that
+is based on (or derived from) the Work and for which the editorial revisions,
+annotations, elaborations, or other modifications represent, as a whole, an
+original work of authorship. For the purposes of this License, Derivative Works
+shall not include works that remain separable from, or merely link (or bind by
+name) to the interfaces of, the Work and Derivative Works thereof.
+
+“Contribution” shall mean any work of authorship, including the original version
+of the Work and any modifications or additions to that Work or Derivative Works
+thereof, that is intentionally submitted to Licensor for inclusion in the Work
+by the copyright owner or by an individual or Legal Entity authorized to submit
+on behalf of the copyright owner. For the purposes of this definition,
+“submitted” means any form of electronic, verbal, or written communication sent
+to the Licensor or its representatives, including but not limited to
+communication on electronic mailing lists, source code control systems, and
+issue tracking systems that are managed by, or on behalf of, the Licensor for
+the purpose of discussing and improving the Work, but excluding communication
+that is conspicuously marked or otherwise designated in writing by the copyright
+owner as “Not a Contribution.”
+
+“Contributor” shall mean Licensor and any individual or Legal Entity on behalf
+of whom a Contribution has been received by Licensor and subsequently
+incorporated within the Work.
+
+#### 2. Grant of Copyright License
+
+Subject to the terms and conditions of this License, each Contributor hereby
+grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
+irrevocable copyright license to reproduce, prepare Derivative Works of,
+publicly display, publicly perform, sublicense, and distribute the Work and such
+Derivative Works in Source or Object form.
+
+#### 3. Grant of Patent License
+
+Subject to the terms and conditions of this License, each Contributor hereby
+grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
+irrevocable (except as stated in this section) patent license to make, have
+made, use, offer to sell, sell, import, and otherwise transfer the Work, where
+such license applies only to those patent claims licensable by such Contributor
+that are necessarily infringed by their Contribution(s) alone or by combination
+of their Contribution(s) with the Work to which such Contribution(s) was
+submitted. If You institute patent litigation against any entity (including a
+cross-claim or counterclaim in a lawsuit) alleging that the Work or a
+Contribution incorporated within the Work constitutes direct or contributory
+patent infringement, then any patent licenses granted to You under this License
+for that Work shall terminate as of the date such litigation is filed.
+
+#### 4. Redistribution
+
+You may reproduce and distribute copies of the Work or Derivative Works thereof
+in any medium, with or without modifications, and in Source or Object form,
+provided that You meet the following conditions:
+
+- **(a)** You must give any other recipients of the Work or Derivative Works a copy of
+ this License; and
+- **(b)** You must cause any modified files to carry prominent notices stating that You
+ changed the files; and
+- **(c)** You must retain, in the Source form of any Derivative Works that You distribute,
+ all copyright, patent, trademark, and attribution notices from the Source form
+ of the Work, excluding those notices that do not pertain to any part of the
+ Derivative Works; and
+- **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any
+ Derivative Works that You distribute must include a readable copy of the
+ attribution notices contained within such NOTICE file, excluding those notices
+ that do not pertain to any part of the Derivative Works, in at least one of the
+ following places: within a NOTICE text file distributed as part of the
+ Derivative Works; within the Source form or documentation, if provided along
+ with the Derivative Works; or, within a display generated by the Derivative
+ Works, if and wherever such third-party notices normally appear. The contents of
+ the NOTICE file are for informational purposes only and do not modify the
+ License. You may add Your own attribution notices within Derivative Works that
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
+ provided that such additional attribution notices cannot be construed as
+ modifying the License.
+
+You may add Your own copyright statement to Your modifications and may provide
+additional or different license terms and conditions for use, reproduction, or
+distribution of Your modifications, or for any such Derivative Works as a whole,
+provided Your use, reproduction, and distribution of the Work otherwise complies
+with the conditions stated in this License.
+
+#### 5. Submission of Contributions
+
+Unless You explicitly state otherwise, any Contribution intentionally submitted
+for inclusion in the Work by You to the Licensor shall be under the terms and
+conditions of this License, without any additional terms or conditions.
+Notwithstanding the above, nothing herein shall supersede or modify the terms of
+any separate license agreement you may have executed with Licensor regarding
+such Contributions.
+
+#### 6. Trademarks
+
+This License does not grant permission to use the trade names, trademarks,
+service marks, or product names of the Licensor, except as required for
+reasonable and customary use in describing the origin of the Work and
+reproducing the content of the NOTICE file.
+
+#### 7. Disclaimer of Warranty
+
+Unless required by applicable law or agreed to in writing, Licensor provides the
+Work (and each Contributor provides its Contributions) on an “AS IS” BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
+including, without limitation, any warranties or conditions of TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
+solely responsible for determining the appropriateness of using or
+redistributing the Work and assume any risks associated with Your exercise of
+permissions under this License.
+
+#### 8. Limitation of Liability
+
+In no event and under no legal theory, whether in tort (including negligence),
+contract, or otherwise, unless required by applicable law (such as deliberate
+and grossly negligent acts) or agreed to in writing, shall any Contributor be
+liable to You for damages, including any direct, indirect, special, incidental,
+or consequential damages of any character arising as a result of this License or
+out of the use or inability to use the Work (including but not limited to
+damages for loss of goodwill, work stoppage, computer failure or malfunction, or
+any and all other commercial damages or losses), even if such Contributor has
+been advised of the possibility of such damages.
+
+#### 9. Accepting Warranty or Additional Liability
+
+While redistributing the Work or Derivative Works thereof, You may choose to
+offer, and charge a fee for, acceptance of support, warranty, indemnity, or
+other liability obligations and/or rights consistent with this License. However,
+in accepting such obligations, You may act only on Your own behalf and on Your
+sole responsibility, not on behalf of any other Contributor, and only if You
+agree to indemnify, defend, and hold each Contributor harmless for any liability
+incurred by, or claims asserted against, such Contributor by reason of your
+accepting any such warranty or additional liability.
+
+_END OF TERMS AND CONDITIONS_
+
+### APPENDIX: Apply the Apache License to a specific file
+
+To apply the Apache License to an individual file, attach the following notice.
+The text should be enclosed in the appropriate comment syntax for the file
+format.
+
+ Copyright © 2022–, HASH
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/blocks/image/LICENSE-MIT.md b/blocks/image/LICENSE-MIT.md
new file mode 100644
index 0000000..e33c1d3
--- /dev/null
+++ b/blocks/image/LICENSE-MIT.md
@@ -0,0 +1,21 @@
+# MIT License
+
+Copyright © 2022–, HASH
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/blocks/image/LICENSE.md b/blocks/image/LICENSE.md
new file mode 100644
index 0000000..8686df9
--- /dev/null
+++ b/blocks/image/LICENSE.md
@@ -0,0 +1,5 @@
+# License
+
+Licensed under either of the [Apache License, Version 2.0](LICENSE-APACHE.md) or [MIT license](LICENSE-MIT.md) at your option.
+
+For more information about contributing to this block, see our top-level [CONTRIBUTING](https://github.com/hashintel/hash/blob/main/.github/CONTRIBUTING.md) policy.
diff --git a/blocks/image/README.md b/blocks/image/README.md
new file mode 100644
index 0000000..d59ef6b
--- /dev/null
+++ b/blocks/image/README.md
@@ -0,0 +1,18 @@
+The Image block allows JPG, GIF, and PNG images to be displayed with an optional caption and adjustable width. Images can be uploaded directly or provided via URL.
+
+The image's display width can be changed by dragging handles which appear on hover at the sides of the image. The caption below the image can also be edited directly.
+
+## Programmatic Usage
+
+On initialization, the embedding application may provide the following properties ([view the Image Block entity type](https://blockprotocol.org/@hash/types/entity-type/image-block/v/2) to see these in context):
+
+- [`Caption`](https://blockprotocol.org/@blockprotocol/types/property-type/caption/)
+- [`Width in Pixels`](https://blockprotocol.org/@blockprotocol/types/property-type/width-in-pixels/).
+
+The Image URL is provided by linking to an entity of the [`Remote File` entity type](https://blockprotocol.org/@blockprotocol/types/entity-type/remote-file/)
+
+This should be linked to by a link entity of entity type [`Displays Media File`](https://blockprotocol.org/@hash/types/entity-type/displays-media-file/v/1)
+
+If no image link is provided, the block displays an interface for entering an image URL or uploading an image file.
+
+Once the user has provided a URL or file, the block uses the Graph Module `uploadFile` method to store the image in the embedding application as a separate entity to the block's entity. The block then uses the Graph Module `createEntity` and `updateEntity` methods to create a link between the block's entity and the image file entity. If an existing link to an image file entity is found, the block deletes it before creating the new one. The block then uses the file URL returned from the embedding application to render the image.
diff --git a/blocks/image/eslint.config.js b/blocks/image/eslint.config.js
new file mode 100644
index 0000000..5b6bb9d
--- /dev/null
+++ b/blocks/image/eslint.config.js
@@ -0,0 +1,3 @@
+import { createBlock } from "@local/eslint/deprecated";
+
+export default createBlock(import.meta.dirname);
diff --git a/blocks/image/package.json b/blocks/image/package.json
new file mode 100644
index 0000000..7dd6dab
--- /dev/null
+++ b/blocks/image/package.json
@@ -0,0 +1,78 @@
+{
+ "name": "@blocks/image",
+ "version": "0.2.1",
+ "private": true,
+ "description": "Embed JPG, GIF, and PNG images by URL or file upload and add an optional caption",
+ "keywords": [
+ "blockprotocol",
+ "blocks",
+ "block"
+ ],
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/hashintel/blocks.git#main",
+ "directory": "blocks/image"
+ },
+ "license": "(MIT OR Apache-2.0)",
+ "author": "HASH",
+ "type": "module",
+ "scripts": {
+ "build": "block-scripts build",
+ "codegen": "block-scripts codegen && yarn format",
+ "dev": "block-scripts dev",
+ "fix:eslint": "eslint --fix .",
+ "format": "prettier --write --ignore-unknown src/types/generated/*.ts",
+ "lint:eslint": "eslint --report-unused-disable-directives .",
+ "lint:tsc": "tsc --noEmit",
+ "serve": "block-scripts serve"
+ },
+ "dependencies": {
+ "@blockprotocol/graph": "0.3.4",
+ "@blockprotocol/hook": "0.1.3",
+ "twind": "0.16.19"
+ },
+ "devDependencies": {
+ "@local/eslint": "0.0.0-private",
+ "@local/tsconfig": "0.0.0-private",
+ "@types/react-dom": "19.1.7",
+ "block-scripts": "0.3.4",
+ "eslint": "10.0.3",
+ "mock-block-dock": "0.1.9",
+ "prettier": "3.8.1",
+ "react": "19.1.1",
+ "react-dom": "19.1.1",
+ "typescript": "5.9.3"
+ },
+ "peerDependencies": {
+ "react": "^19.0.0",
+ "react-dom": "^19.0.0"
+ },
+ "block-scripts": {
+ "devPort": 9090,
+ "servePort": 62677
+ },
+ "blockprotocol": {
+ "blockType": {
+ "entryPoint": "react"
+ },
+ "name": "@hash/image",
+ "displayName": "Image",
+ "icon": "public/image.svg",
+ "image": "public/preview.svg",
+ "examples": [
+ {}
+ ],
+ "protocol": "0.3",
+ "blockEntityType": "https://blockprotocol.org/@hash/types/entity-type/image-block/v/3",
+ "codegen": {
+ "outputFolder": "src/types/generated",
+ "targets": {
+ "block-entity.ts": [
+ {
+ "blockEntityType": true
+ }
+ ]
+ }
+ }
+ }
+}
diff --git a/blocks/image/public/image.svg b/blocks/image/public/image.svg
new file mode 100644
index 0000000..36a75bf
--- /dev/null
+++ b/blocks/image/public/image.svg
@@ -0,0 +1,3 @@
+
diff --git a/blocks/image/public/preview.svg b/blocks/image/public/preview.svg
new file mode 100644
index 0000000..6d302cb
--- /dev/null
+++ b/blocks/image/public/preview.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/blocks/image/src/components/error-alert.tsx b/blocks/image/src/components/error-alert.tsx
new file mode 100644
index 0000000..9c14ffd
--- /dev/null
+++ b/blocks/image/src/components/error-alert.tsx
@@ -0,0 +1,30 @@
+import type { FunctionComponent } from "react";
+import { tw } from "twind";
+
+import Cross from "../svgs/cross";
+
+type ImageErrorAlertProps = { error: string | null; onClearError: () => void };
+
+export const ErrorAlert: FunctionComponent = ({
+ error,
+ onClearError,
+}) => (
+
+
+ Error
+ {error}
+
+
+
+
+);
diff --git a/blocks/image/src/components/media-with-caption.tsx b/blocks/image/src/components/media-with-caption.tsx
new file mode 100644
index 0000000..383a7bd
--- /dev/null
+++ b/blocks/image/src/components/media-with-caption.tsx
@@ -0,0 +1,84 @@
+import type { FunctionComponent } from "react";
+import { tw } from "twind";
+
+import Pencil from "../svgs/pencil";
+import { ResizeImageBlock } from "./resize-image-block";
+
+type MediaWithCaptionProps = {
+ src: string;
+ caption: string;
+ onCaptionChange: (caption: string) => void;
+ onCaptionConfirm: () => void;
+ onReset: () => void;
+ readonly?: boolean;
+ type: "image" | "video";
+} & (
+ | {
+ type: "image";
+ width: number | undefined;
+ onWidthChange: (width: number) => void;
+ }
+ | {
+ type: "video";
+ }
+);
+
+export const MediaWithCaption: FunctionComponent = ({
+ caption,
+ src,
+ onCaptionChange,
+ onCaptionConfirm,
+ onReset,
+ readonly,
+ ...props
+}) => {
+ const captionNode = (
+ onCaptionChange(event.target.value)}
+ onBlur={onCaptionConfirm}
+ />
+ );
+ return (
+
+ {props.type === "image" ? (
+
+
+
+ {captionNode}
+
+ ) : (
+
+ {/* eslint-disable-next-line jsx-a11y/media-has-caption */}
+
+ {captionNode}
+
+ )}
+ {!readonly && (
+
+ )}
+
+ );
+};
diff --git a/blocks/image/src/components/media.tsx b/blocks/image/src/components/media.tsx
new file mode 100644
index 0000000..a6f7344
--- /dev/null
+++ b/blocks/image/src/components/media.tsx
@@ -0,0 +1,324 @@
+/**
+ * This is currently duplicated line-for-line between Image and Video blocks.
+ * We intend to find a way to share these between blocks using components, or
+ * make these blocks variants.
+ *
+ * @todo Deduplicate this file
+ * @see https://linear.app/hash/issue/H-3022
+ */
+import type {
+ BlockGraphProperties,
+ UpdateEntityData,
+} from "@blockprotocol/graph";
+import {
+ useEntitySubgraph,
+ useGraphBlockModule,
+} from "@blockprotocol/graph/react";
+import {
+ getOutgoingLinksForEntity,
+ getRightEntityForLinkEntity,
+} from "@blockprotocol/graph/stdlib";
+import type {
+ Dispatch,
+ FunctionComponent,
+ RefObject,
+ SetStateAction,
+} from "react";
+import {
+ useCallback,
+ useEffect,
+ useLayoutEffect,
+ useRef,
+ useState,
+} from "react";
+import { unstable_batchedUpdates } from "react-dom";
+
+import { linkIds, propertyIds } from "../property-ids";
+import type { BlockEntity } from "../types/generated/block-entity";
+import { ErrorAlert } from "./error-alert";
+import { MediaWithCaption } from "./media-with-caption";
+import { UploadMediaForm } from "./upload-media-form";
+
+const useDefaultState = <
+ T extends number | string | boolean | null | undefined,
+>(
+ defaultValue: T,
+): [T, Dispatch>] => {
+ const defaultStateValue = {
+ prevDefault: defaultValue,
+ currentValue: defaultValue,
+ };
+ const [{ prevDefault, currentValue }, setNextValue] =
+ useState(defaultStateValue);
+
+ if (prevDefault !== defaultValue) {
+ setNextValue(defaultStateValue);
+ }
+
+ const setState = useCallback((value: SetStateAction) => {
+ setNextValue((prevValue) => {
+ const nextValue =
+ typeof value === "function" ? value(prevValue.currentValue) : value;
+
+ return {
+ ...prevValue,
+ currentValue: nextValue,
+ };
+ });
+ }, []);
+
+ return [currentValue, setState];
+};
+
+/**
+ * @todo Rewrite the state here to use a reducer, instead of batched updates
+ */
+export const Media: FunctionComponent<
+ BlockGraphProperties & {
+ blockRef: RefObject;
+ }
+> = ({ blockRef, graph: { blockEntitySubgraph, readonly } }) => {
+ const { rootEntity } = useEntitySubgraph(blockEntitySubgraph);
+ const outgoingLinks = getOutgoingLinksForEntity(
+ blockEntitySubgraph,
+ rootEntity.metadata.recordId.entityId,
+ );
+ const fileLink = outgoingLinks.find(
+ (potentialLink) => potentialLink.metadata.entityTypeId === linkIds.file,
+ );
+ const fileEntity = fileLink
+ ? getRightEntityForLinkEntity(
+ blockEntitySubgraph,
+ fileLink.metadata.recordId.entityId,
+ )
+ : null;
+
+ const { metadata, properties } = rootEntity;
+ const {
+ [propertyIds.caption]: initialCaption,
+ [propertyIds.width]: initialWidth,
+ } = properties;
+
+ /* @ts-expect-error –– @todo H-3839 packages in BP repo needs updating, or this package updating to use graph in this repo */
+ const { graphModule } = useGraphBlockModule(blockRef);
+
+ const [draftSrc, setDraftSrc] = useDefaultState(
+ fileEntity?.properties[propertyIds.bpUrl]?.toString() ?? "",
+ );
+
+ const [loading, setLoading] = useState(false);
+ const [errorString, setErrorString] = useState(null);
+
+ const [draftCaption, setDraftCaption] = useDefaultState(initialCaption ?? "");
+ const [draftWidth, setDraftWidth] = useDefaultState(initialWidth);
+
+ /**
+ * Default for this input field is blank, not the URL passed
+ */
+ const [draftUrl, setDraftUrl] = useState("");
+
+ const isMounted = useRef(false);
+
+ useEffect(() => {
+ isMounted.current = true;
+
+ return () => {
+ isMounted.current = false;
+ };
+ }, []);
+
+ const propertiesRef = useRef(properties);
+
+ useLayoutEffect(() => {
+ propertiesRef.current = properties;
+ });
+
+ const updateData = useCallback(
+ ({ width, src }: { src: string | undefined; width?: number }) => {
+ if (src?.trim()) {
+ const updateEntityData: UpdateEntityData = {
+ properties: {
+ ...propertiesRef.current,
+ [propertyIds.caption]: draftCaption,
+ },
+ entityId: metadata.recordId.entityId,
+ entityTypeId: metadata.entityTypeId,
+ };
+
+ if (width) {
+ updateEntityData.properties[propertyIds.width] = width;
+ }
+
+ void graphModule.updateEntity({ data: updateEntityData });
+
+ unstable_batchedUpdates(() => {
+ setErrorString(null);
+ if (width) {
+ setDraftWidth(width);
+ }
+ setDraftSrc(src);
+ });
+ }
+ },
+ [
+ draftCaption,
+ graphModule,
+ metadata.entityTypeId,
+ metadata.recordId.entityId,
+ setDraftSrc,
+ setDraftWidth,
+ ],
+ );
+
+ const updateWidth = useCallback(
+ (width: number) => {
+ updateData({ src: draftSrc, width });
+ },
+ [draftSrc, updateData],
+ );
+
+ const handleImageUpload = useCallback(
+ (imageProp: { url: string } | { file: FileList[number] }) => {
+ if (readonly) {
+ return;
+ }
+ if (!loading) {
+ unstable_batchedUpdates(() => {
+ setErrorString(null);
+ setLoading(true);
+ });
+
+ graphModule
+ .uploadFile({
+ data: imageProp,
+ })
+ .then(async ({ data: file }) => {
+ if (!file) {
+ return;
+ }
+
+ const linkId = fileLink?.metadata.recordId.entityId;
+
+ if (linkId) {
+ await graphModule.deleteEntity({
+ data: { entityId: linkId },
+ });
+ }
+
+ await graphModule.createEntity({
+ data: {
+ linkData: {
+ leftEntityId: metadata.recordId.entityId,
+ rightEntityId: file.metadata.recordId.entityId,
+ },
+ entityTypeId: linkIds.file,
+ properties: {},
+ },
+ });
+
+ if (isMounted.current) {
+ unstable_batchedUpdates(() => {
+ updateData({ src: file.properties[propertyIds.bpUrl] });
+ setLoading(false);
+ });
+ }
+ })
+ .catch((error: Error) =>
+ unstable_batchedUpdates(() => {
+ setErrorString(error.message);
+ setLoading(false);
+ }),
+ );
+ }
+ },
+ [
+ readonly,
+ loading,
+ graphModule,
+ fileLink?.metadata.recordId.entityId,
+ metadata.recordId.entityId,
+ updateData,
+ ],
+ );
+
+ const onUrlConfirm = () => {
+ if (loading) {
+ return;
+ }
+
+ if (draftUrl.trim()) {
+ handleImageUpload({ url: draftUrl });
+ } else {
+ setErrorString("Please enter a valid image URL or select a file below");
+ }
+ };
+
+ const resetComponent = () => {
+ if (readonly) {
+ return;
+ }
+ unstable_batchedUpdates(() => {
+ setLoading(false);
+ setErrorString(null);
+ setDraftWidth(undefined);
+ setDraftUrl("");
+ setDraftCaption("");
+ setDraftSrc("");
+ });
+ };
+
+ return (
+ <>
+
+ {draftSrc ? (
+ setDraftCaption(caption)}
+ onCaptionConfirm={() => updateData({ src: draftSrc })}
+ onReset={resetComponent}
+ width={draftWidth}
+ type="image"
+ readonly={readonly}
+ />
+ ) : (
+ <>
+ {errorString && (
+ setErrorString(null)}
+ />
+ )}
+ handleImageUpload({ file })}
+ onUrlChange={(nextDraftUrl) => setDraftUrl(nextDraftUrl)}
+ loading={loading}
+ type="image"
+ readonly={readonly}
+ />
+ >
+ )}
+
+ {draftSrc ? (
+ // @note This does not yet contain all required properties – these will be added in a follow up
+
+ ) : null}
+ >
+ );
+};
diff --git a/blocks/image/src/components/resize-image-block.tsx b/blocks/image/src/components/resize-image-block.tsx
new file mode 100644
index 0000000..b3676f2
--- /dev/null
+++ b/blocks/image/src/components/resize-image-block.tsx
@@ -0,0 +1,105 @@
+import type { FunctionComponent, MouseEvent } from "react";
+import { useLayoutEffect, useRef } from "react";
+import { tw } from "twind";
+
+type ResizeBlockProps = {
+ imageSrc: string;
+ width: number | undefined;
+ updateWidth: (width: number) => void;
+ readonly?: boolean;
+};
+
+const BLOCK_RESIZER_POSITIONS = ["left", "right"] as const;
+
+const MIN_WIDTH = 96;
+
+// @todo set a max-width
+
+export const ResizeImageBlock: FunctionComponent = ({
+ imageSrc,
+ width,
+ updateWidth,
+ readonly,
+}) => {
+ const imageRef = useRef(null);
+
+ const updateWidthRef = useRef(updateWidth);
+
+ useLayoutEffect(() => {
+ updateWidthRef.current = updateWidth;
+ });
+
+ useLayoutEffect(() => {
+ if (!imageRef.current) return;
+ if (!imageSrc) return;
+
+ const imageWidth = imageRef.current.getBoundingClientRect().width;
+
+ if (!width) {
+ updateWidth(imageWidth);
+ return;
+ }
+
+ if (imageWidth !== width) {
+ imageRef.current.style.width = `${width}px`;
+ }
+ }, [width, imageSrc, updateWidth]);
+
+ const handleResize = (_evt: MouseEvent, direction: "left" | "right") => {
+ function onMouseMove(mouseMoveEvt: globalThis.MouseEvent) {
+ if (!imageRef.current) return;
+ let newWidth;
+ const { left, right } = imageRef.current.getBoundingClientRect();
+
+ if (direction === "right") {
+ newWidth = mouseMoveEvt.pageX - left;
+ }
+
+ if (direction === "left") {
+ newWidth = right - mouseMoveEvt.pageX;
+ }
+
+ if (newWidth && newWidth > MIN_WIDTH) {
+ imageRef.current.style.width = `${newWidth}px`;
+ }
+ }
+
+ function onMouseUp() {
+ document.removeEventListener("mousemove", onMouseMove);
+ document.removeEventListener("mouseup", onMouseUp);
+ setTimeout(() => {
+ if (!imageRef.current) return;
+ const { width: newWidth } = imageRef.current.getBoundingClientRect();
+ updateWidthRef.current(newWidth);
+ }, 1000);
+ }
+
+ document.addEventListener("mousemove", onMouseMove);
+ document.addEventListener("mouseup", onMouseUp);
+ };
+
+ return (
+
+ {/* eslint-disable-next-line jsx-a11y/img-redundant-alt */}
+
+ {readonly
+ ? null
+ : BLOCK_RESIZER_POSITIONS.map((position) => (
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
+ handleResize(evt, position)}
+ />
+ ))}
+
+ );
+};
diff --git a/blocks/image/src/components/upload-media-form.tsx b/blocks/image/src/components/upload-media-form.tsx
new file mode 100644
index 0000000..1b058d7
--- /dev/null
+++ b/blocks/image/src/components/upload-media-form.tsx
@@ -0,0 +1,104 @@
+import type { ChangeEvent, FunctionComponent } from "react";
+import { tw } from "twind";
+
+import Loader from "../svgs/loader";
+
+type UploadMediaFormProps = {
+ onFileChoose: (file: File) => void;
+ onUrlChange: (url: string) => void;
+ onUrlConfirm: () => void;
+ loading: boolean;
+ type: "image" | "video";
+ readonly?: boolean;
+};
+
+export const UploadMediaForm: FunctionComponent = ({
+ loading,
+ onFileChoose,
+ onUrlChange,
+ onUrlConfirm,
+ type,
+ readonly,
+}) => {
+ /**
+ * @todo This should throw some kind of error if an invalid media is passed
+ */
+ const onFilesChoose = (files: FileList | null) => {
+ if (files?.[0] && files[0].type.search(type) > -1) {
+ onFileChoose(files[0]);
+ }
+ };
+
+ const capitalisedType = type === "image" ? "Image" : "Video";
+
+ return (
+ {
+ event.stopPropagation();
+ event.preventDefault();
+ }}
+ onDrop={(event) => {
+ event.preventDefault();
+ event.stopPropagation();
+
+ onFilesChoose(event.dataTransfer.files);
+ }}
+ >
+
+
+ );
+};
diff --git a/blocks/image/src/dev.tsx b/blocks/image/src/dev.tsx
new file mode 100644
index 0000000..8514521
--- /dev/null
+++ b/blocks/image/src/dev.tsx
@@ -0,0 +1,86 @@
+/**
+ * webpack-dev-server entry point for debugging.
+ * This file is not bundled with the library during the build process.
+ */
+
+import type {
+ Entity,
+ RemoteFileEntityProperties,
+ VersionedUrl,
+} from "@blockprotocol/graph";
+import { MockBlockDock } from "mock-block-dock";
+import { createRoot } from "react-dom/client";
+
+import packageJSON from "../package.json";
+import Component from "./index";
+import { linkIds, propertyIds } from "./property-ids";
+import type {
+ BlockEntity,
+ DisplaysMediaFile,
+} from "./types/generated/block-entity";
+
+const node = document.getElementById("app");
+
+const initialData: BlockEntity = {
+ properties: {
+ [propertyIds.caption]: "Placeholder image",
+ },
+ metadata: {
+ recordId: {
+ entityId: "entity-image",
+ editionId: "1",
+ },
+ entityTypeId: packageJSON.blockprotocol.blockEntityType as VersionedUrl,
+ },
+};
+
+const fileEntity: Entity = {
+ properties: {
+ [propertyIds.bpUrl]: "https://picsum.photos/450/300",
+ [propertyIds.filename]: "300.jpg",
+ [propertyIds.mimeType]: "image/jpg",
+ },
+ metadata: {
+ recordId: {
+ entityId: "entity-file",
+ editionId: "1",
+ },
+ entityTypeId: linkIds.file,
+ },
+};
+
+const fileEntityLink: DisplaysMediaFile = {
+ linkData: {
+ leftEntityId: initialData.metadata.recordId.entityId,
+ rightEntityId: fileEntity.metadata.recordId.entityId,
+ },
+ metadata: {
+ recordId: {
+ entityId: "entity-link",
+ editionId: "1",
+ },
+ entityTypeId: linkIds.file,
+ },
+ properties: {},
+};
+
+const App = () => {
+ return (
+
+ );
+};
+
+createRoot(node!).render( );
diff --git a/blocks/image/src/image.tsx b/blocks/image/src/image.tsx
new file mode 100644
index 0000000..762ce0e
--- /dev/null
+++ b/blocks/image/src/image.tsx
@@ -0,0 +1,40 @@
+import type { BlockComponent } from "@blockprotocol/graph/react";
+import { useEntitySubgraph } from "@blockprotocol/graph/react";
+import { useHook, useHookBlockModule } from "@blockprotocol/hook/react";
+import { useRef, useState } from "react";
+import { setup, tw } from "twind";
+
+import { Media } from "./components/media";
+import { linkIds } from "./property-ids";
+import type { BlockEntity } from "./types/generated/block-entity";
+
+setup({ preflight: false });
+
+export const Image: BlockComponent = (props) => {
+ const { graph } = props;
+ const { blockEntitySubgraph } = graph;
+ const { rootEntity } = useEntitySubgraph(blockEntitySubgraph);
+ const [showFallback, setShowFallback] = useState(false);
+
+ const blockRef = useRef(null);
+
+ /* @ts-expect-error -- @todo H-3839 hook package in BP repo needs updating for new ref type */
+ const { hookModule } = useHookBlockModule(blockRef);
+
+ useHook(
+ hookModule,
+ blockRef,
+ "image",
+ rootEntity.metadata.recordId.entityId,
+ [linkIds.file],
+ () => {
+ setShowFallback(true);
+ },
+ );
+
+ return (
+
+ {showFallback && }
+
+ );
+};
diff --git a/blocks/image/src/index.ts b/blocks/image/src/index.ts
new file mode 100644
index 0000000..c3e5cdd
--- /dev/null
+++ b/blocks/image/src/index.ts
@@ -0,0 +1,8 @@
+/* eslint-disable canonical/filename-no-index -- @todo rename file */
+
+/**
+ * Entrypoint of the Block Component.
+ */
+import { Image } from "./image";
+
+export default Image;
diff --git a/blocks/image/src/property-ids.ts b/blocks/image/src/property-ids.ts
new file mode 100644
index 0000000..e008550
--- /dev/null
+++ b/blocks/image/src/property-ids.ts
@@ -0,0 +1,17 @@
+export const propertyIds = {
+ caption:
+ "https://blockprotocol.org/@blockprotocol/types/property-type/caption/" as const,
+ width:
+ "https://blockprotocol.org/@blockprotocol/types/property-type/width-in-pixels/" as const,
+
+ bpUrl:
+ "https://blockprotocol.org/@blockprotocol/types/property-type/file-url/" as const,
+ filename:
+ "https://blockprotocol.org/@blockprotocol/types/property-type/file-name/" as const,
+ mimeType:
+ "https://blockprotocol.org/@blockprotocol/types/property-type/mime-type/" as const,
+};
+
+export const linkIds = {
+ file: "https://blockprotocol.org/@hash/types/entity-type/displays-media-file/v/1" as const,
+};
diff --git a/blocks/image/src/svgs/cross.tsx b/blocks/image/src/svgs/cross.tsx
new file mode 100644
index 0000000..76aa81b
--- /dev/null
+++ b/blocks/image/src/svgs/cross.tsx
@@ -0,0 +1,18 @@
+import type { FunctionComponent } from "react";
+import { tw } from "twind";
+
+const Cross: FunctionComponent = () => {
+ return (
+
+ );
+};
+
+export default Cross;
diff --git a/blocks/image/src/svgs/loader.tsx b/blocks/image/src/svgs/loader.tsx
new file mode 100644
index 0000000..6279cce
--- /dev/null
+++ b/blocks/image/src/svgs/loader.tsx
@@ -0,0 +1,29 @@
+import type { FunctionComponent } from "react";
+import { tw } from "twind";
+
+const Loader: FunctionComponent = () => {
+ return (
+
+ );
+};
+
+export default Loader;
diff --git a/blocks/image/src/svgs/pencil.tsx b/blocks/image/src/svgs/pencil.tsx
new file mode 100644
index 0000000..8581619
--- /dev/null
+++ b/blocks/image/src/svgs/pencil.tsx
@@ -0,0 +1,22 @@
+import type { FunctionComponent } from "react";
+
+const Pencil: FunctionComponent = () => {
+ return (
+
+ );
+};
+
+export default Pencil;
diff --git a/blocks/image/tsconfig.json b/blocks/image/tsconfig.json
new file mode 100644
index 0000000..03676c9
--- /dev/null
+++ b/blocks/image/tsconfig.json
@@ -0,0 +1,5 @@
+{
+ "extends": "@local/tsconfig/block.json",
+ "include": ["src"],
+ "exclude": ["node_modules"]
+}
diff --git a/blocks/image/turbo.json b/blocks/image/turbo.json
new file mode 100644
index 0000000..9d80ee7
--- /dev/null
+++ b/blocks/image/turbo.json
@@ -0,0 +1,28 @@
+{
+ "extends": ["//"],
+ "tasks": {
+ "codegen": {
+ "inputs": ["./package.json"],
+ "outputs": ["./src/types/generated/**"]
+ },
+ "build": {
+ "dependsOn": ["^build", "codegen", "format"],
+ "outputs": ["./dist/**"]
+ },
+ "lint:tsc": {
+ "dependsOn": ["codegen"]
+ },
+ "format": {
+ "cache": false,
+ "dependsOn": ["codegen"]
+ },
+ "dev": {
+ "persistent": true,
+ "dependsOn": ["^build", "codegen"]
+ },
+ "serve": {
+ "persistent": true,
+ "dependsOn": ["build"]
+ }
+ }
+}
diff --git a/blocks/kanban-board/LICENSE-APACHE.md b/blocks/kanban-board/LICENSE-APACHE.md
new file mode 100644
index 0000000..1d1b6f8
--- /dev/null
+++ b/blocks/kanban-board/LICENSE-APACHE.md
@@ -0,0 +1,189 @@
+# Apache License
+
+_Version 2.0, January 2004_
+_< >_
+
+### Terms and Conditions for use, reproduction, and distribution
+
+#### 1. Definitions
+
+“License” shall mean the terms and conditions for use, reproduction, and
+distribution as defined by Sections 1 through 9 of this document.
+
+“Licensor” shall mean the copyright owner or entity authorized by the copyright
+owner that is granting the License.
+
+“Legal Entity” shall mean the union of the acting entity and all other entities
+that control, are controlled by, or are under common control with that entity.
+For the purposes of this definition, “control” means **(i)** the power, direct or
+indirect, to cause the direction or management of such entity, whether by
+contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the
+outstanding shares, or **(iii)** beneficial ownership of such entity.
+
+“You” (or “Your”) shall mean an individual or Legal Entity exercising
+permissions granted by this License.
+
+“Source” form shall mean the preferred form for making modifications, including
+but not limited to software source code, documentation source, and configuration
+files.
+
+“Object” form shall mean any form resulting from mechanical transformation or
+translation of a Source form, including but not limited to compiled object code,
+generated documentation, and conversions to other media types.
+
+“Work” shall mean the work of authorship, whether in Source or Object form, made
+available under the License, as indicated by a copyright notice that is included
+in or attached to the work (an example is provided in the Appendix below).
+
+“Derivative Works” shall mean any work, whether in Source or Object form, that
+is based on (or derived from) the Work and for which the editorial revisions,
+annotations, elaborations, or other modifications represent, as a whole, an
+original work of authorship. For the purposes of this License, Derivative Works
+shall not include works that remain separable from, or merely link (or bind by
+name) to the interfaces of, the Work and Derivative Works thereof.
+
+“Contribution” shall mean any work of authorship, including the original version
+of the Work and any modifications or additions to that Work or Derivative Works
+thereof, that is intentionally submitted to Licensor for inclusion in the Work
+by the copyright owner or by an individual or Legal Entity authorized to submit
+on behalf of the copyright owner. For the purposes of this definition,
+“submitted” means any form of electronic, verbal, or written communication sent
+to the Licensor or its representatives, including but not limited to
+communication on electronic mailing lists, source code control systems, and
+issue tracking systems that are managed by, or on behalf of, the Licensor for
+the purpose of discussing and improving the Work, but excluding communication
+that is conspicuously marked or otherwise designated in writing by the copyright
+owner as “Not a Contribution.”
+
+“Contributor” shall mean Licensor and any individual or Legal Entity on behalf
+of whom a Contribution has been received by Licensor and subsequently
+incorporated within the Work.
+
+#### 2. Grant of Copyright License
+
+Subject to the terms and conditions of this License, each Contributor hereby
+grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
+irrevocable copyright license to reproduce, prepare Derivative Works of,
+publicly display, publicly perform, sublicense, and distribute the Work and such
+Derivative Works in Source or Object form.
+
+#### 3. Grant of Patent License
+
+Subject to the terms and conditions of this License, each Contributor hereby
+grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
+irrevocable (except as stated in this section) patent license to make, have
+made, use, offer to sell, sell, import, and otherwise transfer the Work, where
+such license applies only to those patent claims licensable by such Contributor
+that are necessarily infringed by their Contribution(s) alone or by combination
+of their Contribution(s) with the Work to which such Contribution(s) was
+submitted. If You institute patent litigation against any entity (including a
+cross-claim or counterclaim in a lawsuit) alleging that the Work or a
+Contribution incorporated within the Work constitutes direct or contributory
+patent infringement, then any patent licenses granted to You under this License
+for that Work shall terminate as of the date such litigation is filed.
+
+#### 4. Redistribution
+
+You may reproduce and distribute copies of the Work or Derivative Works thereof
+in any medium, with or without modifications, and in Source or Object form,
+provided that You meet the following conditions:
+
+- **(a)** You must give any other recipients of the Work or Derivative Works a copy of
+ this License; and
+- **(b)** You must cause any modified files to carry prominent notices stating that You
+ changed the files; and
+- **(c)** You must retain, in the Source form of any Derivative Works that You distribute,
+ all copyright, patent, trademark, and attribution notices from the Source form
+ of the Work, excluding those notices that do not pertain to any part of the
+ Derivative Works; and
+- **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any
+ Derivative Works that You distribute must include a readable copy of the
+ attribution notices contained within such NOTICE file, excluding those notices
+ that do not pertain to any part of the Derivative Works, in at least one of the
+ following places: within a NOTICE text file distributed as part of the
+ Derivative Works; within the Source form or documentation, if provided along
+ with the Derivative Works; or, within a display generated by the Derivative
+ Works, if and wherever such third-party notices normally appear. The contents of
+ the NOTICE file are for informational purposes only and do not modify the
+ License. You may add Your own attribution notices within Derivative Works that
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
+ provided that such additional attribution notices cannot be construed as
+ modifying the License.
+
+You may add Your own copyright statement to Your modifications and may provide
+additional or different license terms and conditions for use, reproduction, or
+distribution of Your modifications, or for any such Derivative Works as a whole,
+provided Your use, reproduction, and distribution of the Work otherwise complies
+with the conditions stated in this License.
+
+#### 5. Submission of Contributions
+
+Unless You explicitly state otherwise, any Contribution intentionally submitted
+for inclusion in the Work by You to the Licensor shall be under the terms and
+conditions of this License, without any additional terms or conditions.
+Notwithstanding the above, nothing herein shall supersede or modify the terms of
+any separate license agreement you may have executed with Licensor regarding
+such Contributions.
+
+#### 6. Trademarks
+
+This License does not grant permission to use the trade names, trademarks,
+service marks, or product names of the Licensor, except as required for
+reasonable and customary use in describing the origin of the Work and
+reproducing the content of the NOTICE file.
+
+#### 7. Disclaimer of Warranty
+
+Unless required by applicable law or agreed to in writing, Licensor provides the
+Work (and each Contributor provides its Contributions) on an “AS IS” BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
+including, without limitation, any warranties or conditions of TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
+solely responsible for determining the appropriateness of using or
+redistributing the Work and assume any risks associated with Your exercise of
+permissions under this License.
+
+#### 8. Limitation of Liability
+
+In no event and under no legal theory, whether in tort (including negligence),
+contract, or otherwise, unless required by applicable law (such as deliberate
+and grossly negligent acts) or agreed to in writing, shall any Contributor be
+liable to You for damages, including any direct, indirect, special, incidental,
+or consequential damages of any character arising as a result of this License or
+out of the use or inability to use the Work (including but not limited to
+damages for loss of goodwill, work stoppage, computer failure or malfunction, or
+any and all other commercial damages or losses), even if such Contributor has
+been advised of the possibility of such damages.
+
+#### 9. Accepting Warranty or Additional Liability
+
+While redistributing the Work or Derivative Works thereof, You may choose to
+offer, and charge a fee for, acceptance of support, warranty, indemnity, or
+other liability obligations and/or rights consistent with this License. However,
+in accepting such obligations, You may act only on Your own behalf and on Your
+sole responsibility, not on behalf of any other Contributor, and only if You
+agree to indemnify, defend, and hold each Contributor harmless for any liability
+incurred by, or claims asserted against, such Contributor by reason of your
+accepting any such warranty or additional liability.
+
+_END OF TERMS AND CONDITIONS_
+
+### APPENDIX: Apply the Apache License to a specific file
+
+To apply the Apache License to an individual file, attach the following notice.
+The text should be enclosed in the appropriate comment syntax for the file
+format.
+
+ Copyright © 2022–, HASH
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/blocks/kanban-board/LICENSE-MIT.md b/blocks/kanban-board/LICENSE-MIT.md
new file mode 100644
index 0000000..e33c1d3
--- /dev/null
+++ b/blocks/kanban-board/LICENSE-MIT.md
@@ -0,0 +1,21 @@
+# MIT License
+
+Copyright © 2022–, HASH
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/blocks/kanban-board/LICENSE.md b/blocks/kanban-board/LICENSE.md
new file mode 100644
index 0000000..8686df9
--- /dev/null
+++ b/blocks/kanban-board/LICENSE.md
@@ -0,0 +1,5 @@
+# License
+
+Licensed under either of the [Apache License, Version 2.0](LICENSE-APACHE.md) or [MIT license](LICENSE-MIT.md) at your option.
+
+For more information about contributing to this block, see our top-level [CONTRIBUTING](https://github.com/hashintel/hash/blob/main/.github/CONTRIBUTING.md) policy.
diff --git a/blocks/kanban-board/README.md b/blocks/kanban-board/README.md
new file mode 100644
index 0000000..271f004
--- /dev/null
+++ b/blocks/kanban-board/README.md
@@ -0,0 +1,12 @@
+## Overview
+
+The **kanban board** allows the user to capture information in cards, then organize these cards by dragging them between columns. Columns are customizable & sortable.
+
+Coming soon:
+
+
+- The ability to query and load entities into the board, in addition to or instead of manually inputted data
+
+## Technical Information
+
+This block uses [`@dnd-kit`](https://docs.dndkit.com/) for drag-and-drop behavior of columns & cards.
diff --git a/blocks/kanban-board/declarations.d.ts b/blocks/kanban-board/declarations.d.ts
new file mode 100644
index 0000000..ff3d73f
--- /dev/null
+++ b/blocks/kanban-board/declarations.d.ts
@@ -0,0 +1,4 @@
+declare module "*.module.scss" {
+ const classes: { readonly [key: string]: string };
+ export default classes;
+}
diff --git a/blocks/kanban-board/eslint.config.js b/blocks/kanban-board/eslint.config.js
new file mode 100644
index 0000000..5b6bb9d
--- /dev/null
+++ b/blocks/kanban-board/eslint.config.js
@@ -0,0 +1,3 @@
+import { createBlock } from "@local/eslint/deprecated";
+
+export default createBlock(import.meta.dirname);
diff --git a/blocks/kanban-board/package.json b/blocks/kanban-board/package.json
new file mode 100644
index 0000000..a3d81b1
--- /dev/null
+++ b/blocks/kanban-board/package.json
@@ -0,0 +1,133 @@
+{
+ "name": "@blocks/kanban-board",
+ "version": "0.0.2",
+ "private": true,
+ "description": "Capture information in cards, and drag cards flexibly between customizable columns",
+ "keywords": [
+ "blockprotocol",
+ "blocks",
+ "block"
+ ],
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/hashintel/blocks.git#main",
+ "directory": "blocks/kanban-board"
+ },
+ "license": "(MIT OR Apache-2.0)",
+ "author": "HASH",
+ "type": "module",
+ "scripts": {
+ "build": "block-scripts build",
+ "codegen": "block-scripts codegen && yarn format",
+ "dev": "block-scripts dev",
+ "fix:eslint": "eslint --fix .",
+ "format": "prettier --write --ignore-unknown src/types/generated/*.ts",
+ "lint:eslint": "eslint --report-unused-disable-directives .",
+ "lint:tsc": "tsc --noEmit",
+ "serve": "block-scripts serve"
+ },
+ "prettier": {
+ "printWidth": 80,
+ "trailingComma": "all"
+ },
+ "dependencies": {
+ "@blockprotocol/graph": "0.3.4",
+ "@dnd-kit/core": "6.3.1",
+ "@dnd-kit/sortable": "7.0.2",
+ "@dnd-kit/utilities": "3.2.2",
+ "@hashintel/block-design-system": "0.0.5",
+ "@hashintel/design-system": "0.0.9-canary.2",
+ "@mui/material": "5.18.0",
+ "clsx": "1.2.1",
+ "lodash.clonedeep": "4.5.0",
+ "lodash.debounce": "4.0.8",
+ "lodash.isequal": "4.5.0",
+ "react-textarea-autosize": "8.5.9"
+ },
+ "devDependencies": {
+ "@local/eslint": "0.0.0-private",
+ "@local/tsconfig": "0.0.0-private",
+ "@types/lodash.clonedeep": "4.5.9",
+ "@types/lodash.debounce": "4.0.9",
+ "@types/lodash.isequal": "4.5.8",
+ "@types/react-dom": "19.1.7",
+ "block-scripts": "0.3.4",
+ "eslint": "10.0.3",
+ "mock-block-dock": "0.1.9",
+ "prettier": "3.8.1",
+ "react": "19.1.1",
+ "react-dom": "19.1.1",
+ "typescript": "5.9.3"
+ },
+ "peerDependencies": {
+ "react": "^19.0.0",
+ "react-dom": "^19.0.0"
+ },
+ "block-scripts": {
+ "port": 63212
+ },
+ "blockprotocol": {
+ "blockType": {
+ "entryPoint": "react"
+ },
+ "displayName": "Kanban Board",
+ "examples": [
+ {
+ "https://blockprotocol.org/@hash/types/property-type/kanban-board-column/": [
+ {
+ "https://blockprotocol.org/@hash/types/property-type/kanban-board-column-id/": "col-todo",
+ "https://blockprotocol.org/@blockprotocol/types/property-type/title/": "Todo",
+ "https://blockprotocol.org/@hash/types/property-type/kanban-board-card/": [
+ {
+ "https://blockprotocol.org/@hash/types/property-type/kanban-board-card-id/": "task-1",
+ "https://blockprotocol.org/@blockprotocol/types/property-type/textual-content/": "First task"
+ },
+ {
+ "https://blockprotocol.org/@hash/types/property-type/kanban-board-card-id/": "task-2",
+ "https://blockprotocol.org/@blockprotocol/types/property-type/textual-content/": "Second task with a very long description"
+ },
+ {
+ "https://blockprotocol.org/@hash/types/property-type/kanban-board-card-id/": "task-3",
+ "https://blockprotocol.org/@blockprotocol/types/property-type/textual-content/": "Third task"
+ }
+ ]
+ },
+ {
+ "https://blockprotocol.org/@hash/types/property-type/kanban-board-column-id/": "col-in-progress",
+ "https://blockprotocol.org/@blockprotocol/types/property-type/title/": "In Progress",
+ "https://blockprotocol.org/@hash/types/property-type/kanban-board-card/": [
+ {
+ "https://blockprotocol.org/@hash/types/property-type/kanban-board-card-id/": "task-4",
+ "https://blockprotocol.org/@blockprotocol/types/property-type/textual-content/": "Fourth task"
+ },
+ {
+ "https://blockprotocol.org/@hash/types/property-type/kanban-board-card-id/": "task-5",
+ "https://blockprotocol.org/@blockprotocol/types/property-type/textual-content/": "Fifth task"
+ }
+ ]
+ },
+ {
+ "https://blockprotocol.org/@hash/types/property-type/kanban-board-column-id/": "col-done",
+ "https://blockprotocol.org/@blockprotocol/types/property-type/title/": "Done",
+ "https://blockprotocol.org/@hash/types/property-type/kanban-board-card/": []
+ }
+ ]
+ }
+ ],
+ "icon": "public/kanban-board.svg",
+ "image": "public/block-preview.png",
+ "name": "@hash/kanban-board",
+ "protocol": "0.3",
+ "blockEntityType": "https://blockprotocol.org/@hash/types/entity-type/kanban-board-block/v/2",
+ "codegen": {
+ "outputFolder": "src/types/generated",
+ "targets": {
+ "block-entity.ts": [
+ {
+ "blockEntityType": true
+ }
+ ]
+ }
+ }
+ }
+}
diff --git a/blocks/kanban-board/public/block-preview.png b/blocks/kanban-board/public/block-preview.png
new file mode 100644
index 0000000..a860cac
Binary files /dev/null and b/blocks/kanban-board/public/block-preview.png differ
diff --git a/blocks/kanban-board/public/kanban-board.svg b/blocks/kanban-board/public/kanban-board.svg
new file mode 100644
index 0000000..6786235
--- /dev/null
+++ b/blocks/kanban-board/public/kanban-board.svg
@@ -0,0 +1,3 @@
+
diff --git a/blocks/kanban-board/src/additional-types.ts b/blocks/kanban-board/src/additional-types.ts
new file mode 100644
index 0000000..1d8627b
--- /dev/null
+++ b/blocks/kanban-board/src/additional-types.ts
@@ -0,0 +1,9 @@
+import type {
+ BlockEntity,
+ KanbanBoardCardPropertyValue,
+ KanbanBoardColumnPropertyValue,
+} from "./types/generated/block-entity";
+
+export type BlockEntityKey = keyof BlockEntity["properties"];
+export type BoardColumnKey = keyof KanbanBoardColumnPropertyValue;
+export type BoardCardKey = keyof KanbanBoardCardPropertyValue;
diff --git a/blocks/kanban-board/src/app.tsx b/blocks/kanban-board/src/app.tsx
new file mode 100644
index 0000000..56ef624
--- /dev/null
+++ b/blocks/kanban-board/src/app.tsx
@@ -0,0 +1,82 @@
+import {
+ type BlockComponent,
+ useEntitySubgraph,
+ useGraphBlockModule,
+} from "@blockprotocol/graph/react";
+import { EditableField, theme } from "@hashintel/block-design-system";
+import { ThemeProvider } from "@mui/material";
+import { useMemo, useRef, useState } from "react";
+
+import type { BlockEntityKey } from "./additional-types";
+import styles from "./base.module.scss";
+import { Board } from "./components/board/board";
+import type {
+ BlockEntity,
+ KanbanBoardBlockOutgoingLinkAndTarget,
+} from "./types/generated/block-entity";
+
+const titleKey: BlockEntityKey =
+ "https://blockprotocol.org/@blockprotocol/types/property-type/title/";
+
+export const App: BlockComponent = ({
+ graph: { blockEntitySubgraph, readonly },
+}) => {
+ const blockRootRef = useRef(null);
+ /* @ts-expect-error –– @todo H-3839 packages in BP repo needs updating, or this package updating to use graph in this repo */
+ const { graphModule } = useGraphBlockModule(blockRootRef);
+
+ const { rootEntity: blockEntity } = useEntitySubgraph<
+ BlockEntity,
+ KanbanBoardBlockOutgoingLinkAndTarget[]
+ >(blockEntitySubgraph);
+
+ const {
+ metadata: {
+ recordId: { entityId: blockEntityId },
+ entityTypeId: blockEntityTypeId,
+ },
+ properties: { [titleKey]: title = "" },
+ } = blockEntity;
+
+ const updateEntity = useMemo(
+ () => async (newProperties: BlockEntity["properties"]) => {
+ await graphModule.updateEntity({
+ data: {
+ entityId: blockEntityId,
+ entityTypeId: blockEntityTypeId,
+ properties: { ...blockEntity.properties, ...newProperties },
+ },
+ });
+ },
+ [blockEntityId, blockEntityTypeId, blockEntity.properties, graphModule],
+ );
+
+ const [titleValue, setTitleValue] = useState(title);
+
+ return (
+
+
+ setTitleValue(event.target.value)}
+ onBlur={(event) => updateEntity({ [titleKey]: event.target.value })}
+ readonly={readonly}
+ sx={{
+ fontWeight: 700,
+ fontSize: "21px !important",
+ lineHeight: "1.2 !important",
+ color: "black",
+ }}
+ wrapperSx={{ mb: 1.5 }}
+ />
+
+
+
+
+ );
+};
diff --git a/blocks/kanban-board/src/base.module.scss b/blocks/kanban-board/src/base.module.scss
new file mode 100644
index 0000000..825a6c5
--- /dev/null
+++ b/blocks/kanban-board/src/base.module.scss
@@ -0,0 +1,247 @@
+@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap");
+
+.block {
+ position: relative;
+ /* –––––––––– Root variables –––––––––– */
+ /* palette */
+ /* neutral grays */
+ --neutral-0: #ffffff;
+ --neutral-50: #f8fafc;
+ --neutral-100: #f1f5f9;
+ --neutral-200: #e2e8f0;
+ --neutral-300: #cbd5e1;
+ --neutral-400: #94a3b8;
+ --neutral-500: #64748b;
+ --neutral-600: #475569;
+ --neutral-700: #334155;
+ --neutral-800: #1e293b;
+ --neutral-900: #0f172a;
+
+ /* primary colors */
+ --primary-50: #f0f9ff;
+ --primary-100: #e0f2fe;
+ --primary-200: #bae6fd;
+ --primary-300: #7dd3fc;
+ --primary-400: #38bdf8;
+ --primary-500: #0ea5e9;
+ --primary-600: #0284c7;
+ --primary-700: #0369a1;
+ --primary-800: #075985;
+ --primary-900: #0c4a6e;
+
+ /* secondary colors */
+ --secondary-50: #f5f3ff;
+ --secondary-100: #ede9fe;
+ --secondary-200: #ddd6fe;
+ --secondary-300: #c4b5fd;
+ --secondary-400: #a78bfa;
+ --secondary-500: #8b5cf6;
+ --secondary-600: #7c3aed;
+ --secondary-700: #6d28d9;
+ --secondary-800: #5b21b6;
+ --secondary-900: #4c1d95;
+
+ /* tertiary colors */
+ --tertiary-50: #fffbeb;
+ --tertiary-100: #fef3c7;
+ --tertiary-200: #fde68a;
+ --tertiary-300: #fcd34d;
+ --tertiary-400: #fbbf24;
+ --tertiary-500: #f59e0b;
+ --tertiary-600: #d97706;
+ --tertiary-700: #b45309;
+ --tertiary-800: #92400e;
+ --tertiary-900: #78350f;
+
+ /* warning colors */
+ --warning-50: #fff7ed;
+ --warning-100: #ffedd5;
+ --warning-200: #fed7aa;
+ --warning-300: #fdba74;
+ --warning-400: #fb923c;
+ --warning-500: #f97316;
+ --warning-600: #ea580c;
+ --warning-700: #c2410c;
+ --warning-800: #9a3412;
+ --warning-900: #7c2d12;
+
+ /* danger colors */
+ --danger-50: #fff1f2;
+ --danger-100: #ffe4e6;
+ --danger-200: #fecdd3;
+ --danger-300: #fda4af;
+ --danger-400: #fb7185;
+ --danger-500: #f43f5e;
+ --danger-600: #e11d48;
+ --danger-700: #be123c;
+ --danger-800: #9f1239;
+ --danger-900: #881337;
+
+ /* background colours */
+ --primary-background-base: var(--neutral-0);
+ --primary-background-hover: var(--neutral-50);
+ --secondary-background-base: var(--neutral-50);
+ --secondary-background-hover: var(--neutral-100);
+ --tertiary-background-base: var(--neutral-100);
+ --tertiary-background-hover: var(--neutral-200);
+
+ /* brand colours */
+ --brand-primary-base: var(--primary-600);
+ --brand-primary-hover: var(--primary-700);
+ --brand-secondary-base: var(--secondary-600);
+ --brand-secondary-hover: var(--secondary-700);
+ --brand-tertiary-base: var(--tertiary-600);
+ --brand-tertiary-hover: var(--tertiary-700);
+
+ /* text colours */
+ --primary-text-base: var(--neutral-800);
+ --primary-text-hover: var(--neutral-900);
+ --secondary-text-base: var(--neutral-600);
+ --secondary-text-hover: var(--neutral-700);
+
+ /* border colours */
+ --border-color-light: var(--neutral-200);
+ --border-color-dark: var(--neutral-400);
+
+ /* spacing */
+ --spacing-base: 1rem;
+ --space-1: calc(var(--spacing-base) * 0.25);
+ --space-2: calc(var(--spacing-base) * 0.5);
+ --space-3: calc(var(--spacing-base) * 0.75);
+ --space-4: var(--spacing-base);
+ --space-5: calc(var(--spacing-base) * 1.5);
+ --space-6: calc(var(--spacing-base) * 2);
+ --space-7: calc(var(--spacing-base) * 3);
+ --space-8: calc(var(--spacing-base) * 4.5);
+
+ /* font sizes */
+ --font-size-xs: clamp(0.8rem, 0.17vw + 0.76rem, 0.89rem);
+ --font-size-sm: clamp(0.85rem, 0.22vw + 0.83rem, 0.95rem);
+ --font-size-base: clamp(1rem, 0.34vw + 0.91rem, 1.12rem);
+ --font-size-md: clamp(1.25rem, 0.61vw + 1.1rem, 1.58rem);
+ --font-size-lg: clamp(1.56rem, 1vw + 1.31rem, 2.11rem);
+ --font-size-xl: clamp(1.95rem, 1.56vw + 1.56rem, 2.81rem);
+ --font-size-2xl: clamp(2.44rem, 2.38vw + 1.85rem, 3.75rem);
+ --font-size-3xl: clamp(3.05rem, 3.54vw + 2.17rem, 5rem);
+
+ /* line heights */
+ --line-height-tight: 1.25;
+ --line-height-base: 1.5;
+ --line-height-loose: 1.75;
+
+ /* font family */
+ --font-family: Inter, Helvetica, Arial, sans-serif;
+
+ /* border radius */
+ --border-radius-1: 0.25rem;
+ --border-radius-2: 0.5rem;
+ --border-radius-3: 1rem;
+
+ /* box shadow */
+ --shadow-1: 0px 1px 5px rgba(27, 33, 40, 0.07);
+ --shadow-2: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
+ --shadow-3: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
+ --shadow-4: 0 25px 50px -12px rgb(0 0 0 / 0.25);
+
+ /* border weight */
+ --border-weight-thin: 1px;
+ --border-weight-light: 2px;
+ --border-weight-base: 4px;
+
+ /* icon size */
+ --icon-size-base: 1rem;
+ --icon-size-large: 1.5rem;
+
+ /* –––––––––– Helper styles –––––––––– */
+
+ font-family: var(--font-family);
+ color: var(--primary-text-base);
+
+ /* Typography */
+
+ h1,
+ h2,
+ h3,
+ h4,
+ p,
+ li,
+ ol {
+ max-width: 60ch;
+ }
+
+ h1 {
+ font-size: var(--font-size-3xl);
+ margin: var(--space-4) 0 var(--space-2);
+ font-weight: 700;
+ color: var(--neutral-900);
+ }
+
+ h2 {
+ font-size: var(--font-size-xl);
+ margin: var(--space-4) 0 var(--space-2);
+ font-weight: 600;
+ color: var(--neutral-800);
+ }
+
+ h3 {
+ font-size: var(--font-size-lg);
+ margin: var(--space-4) 0 var(--space-2);
+ font-weight: 400;
+ color: var(--neutral-700);
+ }
+
+ h4 {
+ font-size: var(--font-size-md);
+ margin: var(--space-2) 0;
+ font-weight: 400;
+ color: var(--neutral-600);
+ }
+
+ h5 {
+ font-size: var(--font-size-base);
+ margin: var(--space-2) 0;
+ font-weight: 500;
+ }
+
+ p,
+ ol,
+ ul {
+ margin-bottom: var(--space-4);
+ }
+
+ p,
+ li {
+ font-size: var(--font-size-base);
+ line-height: var(--line-height-base);
+ }
+
+ p:global(.small-text) {
+ font-size: var(--font-size-xs);
+ color: var(--neutral-500);
+ }
+
+ hr {
+ border: 1px solid var(--border-color-light);
+ }
+
+ /* Buttons */
+
+ button {
+ border: none;
+ transition: 250ms ease-in-out;
+ font-family: var(--font-family);
+ font-size: inherit;
+ font-weight: 500;
+ padding: unset;
+ cursor: pointer;
+ }
+
+ /* Box element for containers and sections */
+ :global(.box) {
+ background: var(--secondary-background-base);
+ padding: var(--space-2) var(--space-6);
+ border: var(--border-color-light) solid var(--border-weight-thin);
+ border-radius: var(--border-radius-2);
+ box-shadow: var(--shadow-1);
+ }
+}
diff --git a/blocks/kanban-board/src/components/board/board.tsx b/blocks/kanban-board/src/components/board/board.tsx
new file mode 100644
index 0000000..4e6ac99
--- /dev/null
+++ b/blocks/kanban-board/src/components/board/board.tsx
@@ -0,0 +1,535 @@
+import type {
+ DragOverEvent,
+ DragStartEvent,
+ UniqueIdentifier,
+} from "@dnd-kit/core";
+import {
+ closestCenter,
+ defaultDropAnimationSideEffects,
+ DndContext,
+ DragOverlay,
+ KeyboardSensor,
+ PointerSensor,
+ useSensor,
+ useSensors,
+} from "@dnd-kit/core";
+import {
+ arrayMove,
+ SortableContext,
+ sortableKeyboardCoordinates,
+} from "@dnd-kit/sortable";
+import { PlusIcon } from "@hashintel/design-system";
+import cloneDeep from "lodash.clonedeep";
+import debounce from "lodash.debounce";
+import isEqual from "lodash.isequal";
+import { useMemo, useRef, useState } from "react";
+
+import type {
+ BlockEntityKey,
+ BoardCardKey,
+ BoardColumnKey,
+} from "../../additional-types";
+import type {
+ BlockEntity,
+ KanbanBoardColumnPropertyValue,
+} from "../../types/generated/block-entity";
+import { StaticCard } from "./card/static-card";
+import { Column } from "./column/column";
+import { SortableColumn } from "./column/sortable-column";
+import styles from "./styles.module.scss";
+import type {
+ ActiveItem,
+ CardData,
+ ColumnsState,
+ CreateCardCallback,
+ DataBeforeDrag,
+ DeleteCardCallback,
+ DeleteColumnCallback,
+ UpdateCardContentCallback,
+ UpdateColumnTitleCallback,
+} from "./types";
+
+const generateId = () => Date.now().toString();
+
+export const columnsKey: BlockEntityKey =
+ "https://blockprotocol.org/@hash/types/property-type/kanban-board-column/";
+
+export const columnIdKey: BoardColumnKey =
+ "https://blockprotocol.org/@hash/types/property-type/kanban-board-column-id/";
+export const columnTitleKey: BoardColumnKey =
+ "https://blockprotocol.org/@blockprotocol/types/property-type/title/";
+export const columnCardsKey: BoardColumnKey =
+ "https://blockprotocol.org/@hash/types/property-type/kanban-board-card/";
+
+export const cardIdKey: BoardCardKey =
+ "https://blockprotocol.org/@hash/types/property-type/kanban-board-card-id/";
+export const cardContentKey: BoardCardKey =
+ "https://blockprotocol.org/@blockprotocol/types/property-type/textual-content/";
+
+const transformEntityColumnsToColumnsState = (
+ columns: KanbanBoardColumnPropertyValue[],
+): ColumnsState => {
+ const cols: ColumnsState = {};
+
+ for (const column of columns) {
+ const {
+ [columnIdKey]: id,
+ [columnTitleKey]: title = "",
+ [columnCardsKey]: cards = [],
+ } = column;
+
+ cols[id] = {
+ id,
+ title,
+ cards: cards.map((card) => ({
+ id: card[cardIdKey],
+ content: card[cardContentKey] ?? "",
+ })),
+ };
+ }
+
+ return cols;
+};
+
+const transformColumnsStateToEntityColumns = (
+ columns: ColumnsState,
+ columnOrder: string[],
+): KanbanBoardColumnPropertyValue[] => {
+ return columnOrder.map((columnId) => {
+ const column = columns[columnId]!;
+ return {
+ [columnIdKey]: column.id,
+ [columnTitleKey]: column.title,
+ [columnCardsKey]: column.cards.map((card) => ({
+ [cardIdKey]: card.id,
+ [cardContentKey]: card.content,
+ })),
+ };
+ });
+};
+
+interface BoardProps {
+ blockEntity: BlockEntity;
+ updateEntity: (newProperties: BlockEntity["properties"]) => Promise;
+ readonly?: boolean;
+}
+
+export const Board = ({ blockEntity, updateEntity, readonly }: BoardProps) => {
+ const updateEntityQueue = useRef([]);
+ const isDebounceQueued = useRef(false);
+ const {
+ properties: { [columnsKey]: entityColumns = [] },
+ } = blockEntity;
+
+ const [prevBlockEntity, setPrevBlockEntity] = useState(blockEntity);
+
+ const [activeItem, setActiveItem] = useState(null);
+ const [columns, setColumns] = useState(
+ transformEntityColumnsToColumnsState(entityColumns),
+ );
+ const [columnOrder, setColumnOrder] = useState(
+ entityColumns.map((col) => col[columnIdKey]),
+ );
+ const [dataBeforeDrag, setDataBeforeDrag] = useState(null);
+
+ const debouncedUpdateEntity = useMemo(
+ () =>
+ debounce(async (newProperties: BlockEntity["properties"]) => {
+ isDebounceQueued.current = false;
+
+ const updateId = Date.now();
+ updateEntityQueue.current.push(updateId);
+ await updateEntity(newProperties);
+ updateEntityQueue.current = updateEntityQueue.current.filter(
+ (id) => id !== updateId,
+ );
+ }, 1000),
+ [updateEntity],
+ );
+
+ const updateStateAndEntity = ({
+ newColumnOrder,
+ newColumns,
+ skipUpdatingEntity,
+ }: {
+ newColumns?: ColumnsState;
+ newColumnOrder?: string[];
+ skipUpdatingEntity?: boolean;
+ }) => {
+ if (newColumns) setColumns(newColumns);
+ if (newColumnOrder) setColumnOrder(newColumnOrder);
+
+ if (skipUpdatingEntity) return;
+
+ isDebounceQueued.current = true;
+ void debouncedUpdateEntity({
+ [columnsKey]: transformColumnsStateToEntityColumns(
+ newColumns ?? columns,
+ newColumnOrder ?? columnOrder,
+ ),
+ });
+ };
+
+ const isCardOrColumn = (id: UniqueIdentifier) => {
+ if (id in columns) return "column";
+
+ return "card";
+ };
+
+ const findColumnOfCard = (cardId: UniqueIdentifier) => {
+ return Object.values(columns).find(
+ (col) => !!col.cards.find((card) => card.id === cardId),
+ );
+ };
+
+ const createColumn = () => {
+ const newColId = generateId();
+
+ const newColumns = {
+ ...columns,
+ [newColId]: {
+ id: newColId,
+ title: `Column ${Object.keys(columns).length + 1}`,
+ cards: [],
+ },
+ };
+
+ updateStateAndEntity({
+ newColumns,
+ newColumnOrder: [...columnOrder, newColId],
+ });
+ };
+
+ const deleteColumn: DeleteColumnCallback = (columnId) => {
+ const newColumns = { ...columns };
+ delete newColumns[columnId];
+
+ updateStateAndEntity({
+ newColumns,
+ newColumnOrder: columnOrder.filter((id) => id !== columnId),
+ });
+ };
+
+ const updateColumnTitle: UpdateColumnTitleCallback = (columnId, newTitle) => {
+ const targetCol = columns[columnId];
+ if (!targetCol) return;
+
+ updateStateAndEntity({
+ newColumns: {
+ ...columns,
+ [columnId]: { ...targetCol, title: newTitle },
+ },
+ });
+ };
+
+ const createCard: CreateCardCallback = (columnId, content) => {
+ const targetCol = columns[columnId];
+ if (!targetCol) return;
+
+ const cloneCol = { ...targetCol };
+ cloneCol.cards.push({ id: generateId(), content });
+
+ updateStateAndEntity({
+ newColumns: {
+ ...columns,
+ [columnId]: cloneCol,
+ },
+ });
+ };
+
+ const deleteCard: DeleteCardCallback = (columnId, cardId) => {
+ const targetCol = columns[columnId];
+ if (!targetCol) return;
+
+ const cloneCol = { ...targetCol };
+ cloneCol.cards = cloneCol.cards.filter((card) => card.id !== cardId);
+
+ updateStateAndEntity({
+ newColumns: {
+ ...columns,
+ [columnId]: cloneCol,
+ },
+ });
+ };
+
+ const updateCardContent: UpdateCardContentCallback = (cardId, newContent) => {
+ const columnId = findColumnOfCard(cardId)?.id;
+
+ if (!columnId) {
+ throw new Error("column of card not found");
+ }
+
+ const targetCol = columns[columnId];
+ if (!targetCol) return;
+
+ const cloneCol = { ...targetCol };
+
+ cloneCol.cards = cloneCol.cards.map((card) =>
+ card.id === cardId ? { ...card, content: newContent } : card,
+ );
+
+ updateStateAndEntity({
+ newColumns: {
+ ...columns,
+ [columnId]: cloneCol,
+ },
+ });
+ };
+
+ const handleDragStart = ({ active }: DragStartEvent) => {
+ if (isCardOrColumn(active.id) === "column") {
+ setDataBeforeDrag({ type: "columnOrder", data: [...columnOrder] });
+ return setActiveItem({ type: "column", id: active.id });
+ }
+
+ const foundCard = findColumnOfCard(active.id)?.cards.find(
+ (card) => card.id === active.id,
+ );
+
+ if (!foundCard) {
+ throw new Error("no card found");
+ }
+
+ setDataBeforeDrag({ type: "columns", data: cloneDeep(columns) });
+ setActiveItem({ type: "card", data: foundCard, id: active.id });
+ };
+
+ const handleDragOver = (event: DragOverEvent) => {
+ const { active, over } = event;
+
+ if (active.id === over?.id || !over) {
+ return;
+ }
+
+ const isDraggingColumn = isCardOrColumn(active.id) === "column";
+ const isOverColumn = isCardOrColumn(over.id) === "column";
+
+ if (isDraggingColumn) {
+ const overColumnId = isOverColumn
+ ? over.id
+ : findColumnOfCard(over.id)?.id;
+
+ const oldIndex = columnOrder.findIndex((id) => id === active.id);
+ const newIndex = columnOrder.findIndex((id) => id === overColumnId);
+
+ updateStateAndEntity({
+ skipUpdatingEntity: true,
+ newColumnOrder: arrayMove(columnOrder, oldIndex, newIndex),
+ });
+
+ return;
+ }
+
+ const activeColumn = findColumnOfCard(active.id);
+
+ if (!activeColumn) {
+ throw Error("activeColumn not found");
+ }
+
+ // dropping card into a column
+ if (isOverColumn) {
+ let movedCard: CardData | undefined;
+
+ // remove card from old column
+ activeColumn.cards = activeColumn.cards.filter((card) => {
+ if (card.id === active.id) {
+ movedCard = card;
+ return false;
+ }
+
+ return true;
+ });
+
+ // insert the card into the new column
+ if (!movedCard) {
+ throw new Error("moved card not foundƒ");
+ }
+
+ const overColumn = columns[over.id];
+
+ if (!overColumn) {
+ throw new Error("overColumn not found");
+ }
+
+ updateStateAndEntity({
+ skipUpdatingEntity: true,
+ newColumns: {
+ ...columns,
+ [activeColumn.id]: activeColumn,
+ [overColumn.id]: {
+ ...overColumn,
+ cards: [...overColumn.cards, movedCard],
+ },
+ },
+ });
+
+ return;
+ }
+
+ const overColumn = findColumnOfCard(over.id);
+
+ if (!overColumn) {
+ throw new Error("overColumn not found");
+ }
+
+ const droppedToSameColumn = activeColumn.id === overColumn.id;
+
+ // card moved in the same column
+ if (droppedToSameColumn) {
+ const oldIndex = overColumn.cards.findIndex(
+ (card) => card.id === active.id,
+ );
+ const newIndex = overColumn.cards.findIndex(
+ (card) => card.id === over.id,
+ );
+ const newCards = arrayMove(overColumn.cards, oldIndex, newIndex);
+
+ overColumn.cards = newCards;
+
+ updateStateAndEntity({
+ skipUpdatingEntity: true,
+ newColumns: { ...columns, [overColumn.id]: overColumn },
+ });
+
+ return;
+ }
+
+ let movedCard: CardData | undefined;
+
+ // remove card from old column
+ activeColumn.cards = activeColumn.cards.filter((card) => {
+ if (card.id === active.id) {
+ movedCard = card;
+ return false;
+ }
+
+ return true;
+ });
+
+ if (!movedCard) {
+ throw new Error("moved card not foundƒ");
+ }
+
+ // insert the card into the new column
+ const newIndex = overColumn.cards.findIndex((card) => card.id === over.id);
+ const newCards = [...overColumn.cards];
+ newCards.splice(newIndex, 0, movedCard);
+ overColumn.cards = newCards;
+
+ updateStateAndEntity({
+ skipUpdatingEntity: true,
+ newColumns: {
+ ...columns,
+ [activeColumn.id]: activeColumn,
+ [overColumn.id]: overColumn,
+ },
+ });
+ };
+
+ const handleDragEnd = () => {
+ /** we call `updateStateAndEntity` to update the entity with the current state after drag ends */
+ updateStateAndEntity({});
+ setDataBeforeDrag(null);
+ setActiveItem(null);
+ };
+
+ const handleDragCancel = () => {
+ setActiveItem(null);
+
+ if (!dataBeforeDrag) return;
+
+ const { data, type } = dataBeforeDrag;
+
+ if (type === "columnOrder") {
+ return setColumnOrder(data);
+ }
+
+ setColumns(data);
+ };
+
+ const sensors = useSensors(
+ useSensor(PointerSensor, {
+ activationConstraint: { distance: 10 },
+ }),
+ useSensor(KeyboardSensor, {
+ coordinateGetter: sortableKeyboardCoordinates,
+ }),
+ );
+
+ const isUpdatingEntity = updateEntityQueue.current.length > 0;
+ const shouldOverrideLocalState =
+ !isDebounceQueued.current && !isUpdatingEntity;
+
+ if (
+ blockEntity !== prevBlockEntity &&
+ shouldOverrideLocalState &&
+ /** do not update the state while user is dragging an item to prevent flickering */
+ !activeItem
+ ) {
+ setPrevBlockEntity(blockEntity);
+
+ const columnsChanged = !isEqual(entityColumns, columns);
+ if (columnsChanged) {
+ setColumns(transformEntityColumnsToColumnsState(entityColumns));
+ setColumnOrder(entityColumns.map((col) => col[columnIdKey]));
+ }
+ }
+
+ return (
+
+
+
+ {columnOrder.map((columnId) => (
+
+ ))}
+
+ {!readonly && (
+
+ )}
+
+
+
+ {activeItem ? (
+ activeItem.type === "column" ? (
+
+ ) : (
+
+ )
+ ) : null}
+
+
+ );
+};
diff --git a/blocks/kanban-board/src/components/board/card/card-content/card-content.tsx b/blocks/kanban-board/src/components/board/card/card-content/card-content.tsx
new file mode 100644
index 0000000..abc1f3c
--- /dev/null
+++ b/blocks/kanban-board/src/components/board/card/card-content/card-content.tsx
@@ -0,0 +1,74 @@
+/* eslint-disable jsx-a11y/click-events-have-key-events */
+import { useRef, useState } from "react";
+import TextareaAutosize from "react-textarea-autosize";
+
+import { IconButton } from "../../../icon-button/icon-button";
+import { DiscardIcon } from "../../../icons/discard-icon";
+import styles from "./styles.module.scss";
+
+export const CardContent = ({
+ onChange,
+ content,
+ readonly,
+ onDelete,
+}: {
+ content: string;
+ onChange?: (val: string) => void;
+ readonly?: boolean;
+ onDelete?: () => void;
+}) => {
+ const [prevContent, setPrevContent] = useState(content);
+ const [inputVal, setInputVal] = useState(content);
+ const inputRef = useRef(null);
+ const [editing, setEditing] = useState(false);
+
+ if (prevContent !== content) {
+ setPrevContent(content);
+ setInputVal(content);
+ }
+
+ if (!!readonly || !editing) {
+ return (
+ <>
+ setEditing(true)}
+ className={styles.wrapper}
+ >
+ {content}
+
+ {!readonly && (
+
+
+
+ )}
+ >
+ );
+ }
+
+ return (
+ {
+ event.stopPropagation();
+ event.preventDefault();
+ }}
+ onBlur={() => setEditing(false)}
+ onKeyDown={(event) => {
+ event.stopPropagation();
+
+ if (event.key === "Enter" || event.key === "Escape") {
+ inputRef.current?.blur();
+ }
+ }}
+ onChange={(event) => {
+ setInputVal(event.target.value);
+ onChange?.(event.target.value);
+ }}
+ />
+ );
+};
diff --git a/blocks/kanban-board/src/components/board/card/card-content/styles.module.scss b/blocks/kanban-board/src/components/board/card/card-content/styles.module.scss
new file mode 100644
index 0000000..6795aa9
--- /dev/null
+++ b/blocks/kanban-board/src/components/board/card/card-content/styles.module.scss
@@ -0,0 +1,19 @@
+.wrapper {
+ border: none;
+ background: none;
+ font-size: 13px;
+ font-weight: 500;
+ line-height: 1.5;
+ font-family: var(--font-family);
+ width: 100%;
+ resize: none;
+ padding: 2px;
+ min-height: 19.5px;
+}
+
+.deleteButton {
+ font-size: 13px !important;
+ position: absolute;
+ right: 4px;
+ top: 4px;
+}
diff --git a/blocks/kanban-board/src/components/board/card/card.tsx b/blocks/kanban-board/src/components/board/card/card.tsx
new file mode 100644
index 0000000..b672ade
--- /dev/null
+++ b/blocks/kanban-board/src/components/board/card/card.tsx
@@ -0,0 +1,55 @@
+import { useSortable } from "@dnd-kit/sortable";
+import { CSS } from "@dnd-kit/utilities";
+import clsx from "clsx";
+
+import type { CardData, UpdateCardContentCallback } from "../types";
+import { CardContent } from "./card-content/card-content";
+import styles from "./styles.module.scss";
+
+export const Card = ({
+ data,
+ onDelete,
+ updateCardContent,
+ readonly,
+}: {
+ data: CardData;
+ onDelete: () => void;
+ updateCardContent?: UpdateCardContentCallback;
+ readonly?: boolean;
+}) => {
+ const {
+ attributes,
+ listeners,
+ setNodeRef,
+ transform,
+ transition,
+ isDragging,
+ isSorting,
+ } = useSortable({ id: data.id });
+
+ const style = {
+ transform: CSS.Transform.toString(transform),
+ transition,
+ opacity: isDragging ? 0.5 : 1,
+ };
+
+ return (
+
+ updateCardContent?.(data.id, val)}
+ readonly={readonly}
+ onDelete={() => onDelete()}
+ />
+
+ );
+};
diff --git a/blocks/kanban-board/src/components/board/card/static-card.tsx b/blocks/kanban-board/src/components/board/card/static-card.tsx
new file mode 100644
index 0000000..675f2fc
--- /dev/null
+++ b/blocks/kanban-board/src/components/board/card/static-card.tsx
@@ -0,0 +1,20 @@
+import type { CardData } from "../types";
+import { CardContent } from "./card-content/card-content";
+import styles from "./styles.module.scss";
+
+export const StaticCard = ({
+ data,
+ shadow,
+}: {
+ data: CardData;
+ shadow?: boolean;
+}) => {
+ return (
+
+
+
+ );
+};
diff --git a/blocks/kanban-board/src/components/board/card/styles.module.scss b/blocks/kanban-board/src/components/board/card/styles.module.scss
new file mode 100644
index 0000000..4279482
--- /dev/null
+++ b/blocks/kanban-board/src/components/board/card/styles.module.scss
@@ -0,0 +1,33 @@
+.wrapper {
+ cursor: pointer;
+ padding: 10px;
+ gap: 10px;
+
+ background: white;
+
+ border: 1px solid #dde7f0;
+
+ box-shadow: var(--shadow-1);
+ border-radius: 6px;
+ position: relative;
+ overflow: hidden;
+
+ user-select: none;
+ -webkit-user-select: none;
+
+ &.showHandCursor {
+ cursor: grabbing;
+ }
+}
+
+@media screen and (min-width: 768px) {
+ .wrapper {
+ &:hover button {
+ display: block;
+ }
+
+ button {
+ display: none;
+ }
+ }
+}
diff --git a/blocks/kanban-board/src/components/board/column/column.tsx b/blocks/kanban-board/src/components/board/column/column.tsx
new file mode 100644
index 0000000..7c4730d
--- /dev/null
+++ b/blocks/kanban-board/src/components/board/column/column.tsx
@@ -0,0 +1,67 @@
+import { SortableContext } from "@dnd-kit/sortable";
+import { PlusIcon } from "@hashintel/design-system";
+import { useMemo } from "react";
+
+import { IconButton } from "../../icon-button/icon-button";
+import { DiscardIcon } from "../../icons/discard-icon";
+import { Card } from "../card/card";
+import { EditableColumnTitle } from "./editable-column-title/editable-column-title";
+import styles from "./styles.module.scss";
+import type { ColumnProps } from "./types";
+
+export const Column = ({
+ data,
+ deleteColumn,
+ createCard,
+ deleteCard,
+ updateCardContent,
+ updateColumnTitle,
+ readonly,
+ wrapperProps,
+ titleWrapperProps,
+}: ColumnProps) => {
+ const sortableItems = useMemo(
+ () => data.cards.map((card) => card.id),
+ [data.cards],
+ );
+
+ return (
+
+
+ updateColumnTitle?.(data.id, val)}
+ readonly={readonly}
+ />
+ {!readonly && (
+ deleteColumn?.(data.id)}>
+
+
+ )}
+
+
+
+ {data.cards.map((card) => (
+ deleteCard?.(data.id, card.id)}
+ updateCardContent={updateCardContent}
+ readonly={readonly}
+ />
+ ))}
+
+ {!readonly && (
+
+ )}
+
+
+ );
+};
diff --git a/blocks/kanban-board/src/components/board/column/editable-column-title/editable-column-title.tsx b/blocks/kanban-board/src/components/board/column/editable-column-title/editable-column-title.tsx
new file mode 100644
index 0000000..142105e
--- /dev/null
+++ b/blocks/kanban-board/src/components/board/column/editable-column-title/editable-column-title.tsx
@@ -0,0 +1,62 @@
+/* eslint-disable jsx-a11y/click-events-have-key-events */
+import { useRef, useState } from "react";
+
+import styles from "./styles.module.scss";
+
+export const EditableColumnTitle = ({
+ onChange,
+ title,
+ readonly,
+}: {
+ title: string;
+ onChange?: (val: string) => void;
+ readonly?: boolean;
+}) => {
+ const [prevTitle, setPrevTitle] = useState(title);
+ const [inputVal, setInputVal] = useState(title);
+ const inputRef = useRef(null);
+ const [editing, setEditing] = useState(false);
+
+ if (prevTitle !== title) {
+ setPrevTitle(title);
+ setInputVal(title);
+ }
+
+ if (!!readonly || !editing) {
+ return (
+ setEditing(true)}
+ className={styles.wrapper}
+ >
+ {title}
+
+ );
+ }
+
+ return (
+ {
+ event.stopPropagation();
+ event.preventDefault();
+ }}
+ onBlur={() => setEditing(false)}
+ onKeyDown={(event) => {
+ event.stopPropagation();
+
+ if (event.key === "Enter" || event.key === "Escape") {
+ inputRef.current?.blur();
+ }
+ }}
+ onChange={(event) => {
+ setInputVal(event.target.value);
+ onChange?.(event.target.value);
+ }}
+ />
+ );
+};
diff --git a/blocks/kanban-board/src/components/board/column/editable-column-title/styles.module.scss b/blocks/kanban-board/src/components/board/column/editable-column-title/styles.module.scss
new file mode 100644
index 0000000..df29201
--- /dev/null
+++ b/blocks/kanban-board/src/components/board/column/editable-column-title/styles.module.scss
@@ -0,0 +1,16 @@
+.wrapper {
+ flex: 1;
+ font-weight: 600;
+ border: none;
+ background: none;
+ font-size: 13px;
+ font-family: var(--font-family);
+ padding: 0;
+ line-height: 1.5;
+
+ text-align: start;
+
+ overflow-x: hidden;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+}
diff --git a/blocks/kanban-board/src/components/board/column/sortable-column.tsx b/blocks/kanban-board/src/components/board/column/sortable-column.tsx
new file mode 100644
index 0000000..636f0d6
--- /dev/null
+++ b/blocks/kanban-board/src/components/board/column/sortable-column.tsx
@@ -0,0 +1,44 @@
+import { useSortable } from "@dnd-kit/sortable";
+import { CSS } from "@dnd-kit/utilities";
+import clsx from "clsx";
+
+import { Column } from "./column";
+import styles from "./styles.module.scss";
+import type { SortableColumnProps } from "./types";
+
+export const SortableColumn = (props: SortableColumnProps) => {
+ const { data } = props;
+ const {
+ attributes,
+ listeners,
+ setNodeRef,
+ transform,
+ transition,
+ isDragging,
+ isSorting,
+ } = useSortable({ id: data.id });
+
+ const style = {
+ transform: CSS.Transform.toString(transform),
+ transition,
+ opacity: isDragging ? 0.5 : 1,
+ };
+
+ return (
+
+ );
+};
diff --git a/blocks/kanban-board/src/components/board/column/styles.module.scss b/blocks/kanban-board/src/components/board/column/styles.module.scss
new file mode 100644
index 0000000..8995ebf
--- /dev/null
+++ b/blocks/kanban-board/src/components/board/column/styles.module.scss
@@ -0,0 +1,54 @@
+.wrapper {
+ min-width: var(--columm-width);
+ width: var(--columm-width);
+ background: #fafbfc;
+ border-radius: 8px;
+ font-size: 13px;
+ min-height: 100%;
+ box-shadow: var(--shadow-1);
+
+ .titleRow {
+ padding: 12px 20px;
+ display: flex;
+ align-items: flex-start;
+ gap: 8px;
+
+ cursor: pointer;
+
+ &.showHandCursor {
+ cursor: grabbing;
+ }
+ }
+
+ .body {
+ display: flex;
+ flex-direction: column;
+ gap: 10px;
+ padding: 10px;
+ }
+
+ .addCardButton {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ padding: 10px;
+ gap: 8px;
+
+ height: 40px;
+ background: #f7fafc;
+ border: 1px solid #ebf2f7;
+ border-radius: 6px;
+
+ text-align: center;
+ color: #758aa1;
+
+ svg {
+ width: 13px;
+ }
+
+ &:hover,
+ &:focus {
+ background: #eff2f4;
+ }
+ }
+}
diff --git a/blocks/kanban-board/src/components/board/column/types.ts b/blocks/kanban-board/src/components/board/column/types.ts
new file mode 100644
index 0000000..977265c
--- /dev/null
+++ b/blocks/kanban-board/src/components/board/column/types.ts
@@ -0,0 +1,25 @@
+import type { HTMLProps } from "react";
+
+import type {
+ ColumnData,
+ CreateCardCallback,
+ DeleteCardCallback,
+ DeleteColumnCallback,
+ UpdateCardContentCallback,
+ UpdateColumnTitleCallback,
+} from "../types";
+
+export interface SortableColumnProps {
+ data: ColumnData;
+ readonly?: boolean;
+ deleteColumn?: DeleteColumnCallback;
+ createCard?: CreateCardCallback;
+ deleteCard?: DeleteCardCallback;
+ updateColumnTitle?: UpdateColumnTitleCallback;
+ updateCardContent?: UpdateCardContentCallback;
+}
+
+export interface ColumnProps extends SortableColumnProps {
+ wrapperProps?: HTMLProps;
+ titleWrapperProps?: HTMLProps;
+}
diff --git a/blocks/kanban-board/src/components/board/styles.module.scss b/blocks/kanban-board/src/components/board/styles.module.scss
new file mode 100644
index 0000000..bbe4791
--- /dev/null
+++ b/blocks/kanban-board/src/components/board/styles.module.scss
@@ -0,0 +1,37 @@
+.board {
+ --columm-width: 245px;
+
+ display: flex;
+ align-items: stretch;
+ min-height: 500px;
+ padding: 20px;
+ gap: 18px;
+ background: #4d0d8d;
+ border-radius: 8px;
+ font-size: 13px;
+ overflow-x: scroll;
+
+ .addColumnButton {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ gap: 8px;
+
+ min-width: var(--columm-width);
+ width: var(--columm-width);
+ height: 40px;
+ align-self: flex-start;
+ color: white;
+ background: rgba(255, 255, 255, 0.15);
+ border-radius: 6px;
+
+ svg {
+ width: 13px;
+ }
+
+ &:hover,
+ &:focus {
+ background: rgba(255, 255, 255, 0.1);
+ }
+ }
+}
diff --git a/blocks/kanban-board/src/components/board/types.ts b/blocks/kanban-board/src/components/board/types.ts
new file mode 100644
index 0000000..f10d71e
--- /dev/null
+++ b/blocks/kanban-board/src/components/board/types.ts
@@ -0,0 +1,39 @@
+import type { UniqueIdentifier } from "@dnd-kit/core";
+
+export type CardData = {
+ id: string;
+ content: string;
+};
+
+export type ColumnData = {
+ id: string;
+ title: string;
+ cards: CardData[];
+};
+
+export type ColumnsState = Record;
+
+export type ActiveItem =
+ | { type: "column"; id: UniqueIdentifier }
+ | { type: "card"; id: UniqueIdentifier; data: CardData }
+ | null;
+
+export type DataBeforeDrag =
+ | {
+ type: "columns";
+ data: ColumnsState;
+ }
+ | { type: "columnOrder"; data: string[] }
+ | null;
+
+export type DeleteColumnCallback = (columnId: string) => void;
+export type CreateCardCallback = (columnId: string, content: string) => void;
+export type DeleteCardCallback = (columnId: string, cardId: string) => void;
+export type UpdateColumnTitleCallback = (
+ columnId: string,
+ newTitle: string,
+) => void;
+export type UpdateCardContentCallback = (
+ cardId: string,
+ newContent: string,
+) => void;
diff --git a/blocks/kanban-board/src/components/icon-button/icon-button.tsx b/blocks/kanban-board/src/components/icon-button/icon-button.tsx
new file mode 100644
index 0000000..f9d1602
--- /dev/null
+++ b/blocks/kanban-board/src/components/icon-button/icon-button.tsx
@@ -0,0 +1,22 @@
+import clsx from "clsx";
+import type { ButtonHTMLAttributes } from "react";
+import { forwardRef } from "react";
+
+import styles from "./styles.module.scss";
+
+type ButtonProps = ButtonHTMLAttributes;
+
+export const IconButton = forwardRef(
+ ({ children, className, ...rest }, ref) => {
+ return (
+
+ );
+ },
+);
diff --git a/blocks/kanban-board/src/components/icon-button/styles.module.scss b/blocks/kanban-board/src/components/icon-button/styles.module.scss
new file mode 100644
index 0000000..64cce2f
--- /dev/null
+++ b/blocks/kanban-board/src/components/icon-button/styles.module.scss
@@ -0,0 +1,17 @@
+.wrapper {
+ background: none;
+ border-radius: 0.3em;
+ padding: 0.2em !important;
+
+ color: #c1cfde;
+
+ &:hover,
+ &:focus {
+ color: black;
+ }
+
+ svg {
+ width: 1em;
+ height: 1em;
+ }
+}
diff --git a/blocks/kanban-board/src/components/icons/discard-icon.tsx b/blocks/kanban-board/src/components/icons/discard-icon.tsx
new file mode 100644
index 0000000..d06c837
--- /dev/null
+++ b/blocks/kanban-board/src/components/icons/discard-icon.tsx
@@ -0,0 +1,9 @@
+export const DiscardIcon = () => (
+
+);
diff --git a/blocks/kanban-board/src/dev.tsx b/blocks/kanban-board/src/dev.tsx
new file mode 100644
index 0000000..da64a3a
--- /dev/null
+++ b/blocks/kanban-board/src/dev.tsx
@@ -0,0 +1,84 @@
+import type { VersionedUrl } from "@blockprotocol/graph";
+import { MockBlockDock } from "mock-block-dock";
+import { createRoot } from "react-dom/client";
+
+import packageJson from "../package.json";
+import {
+ cardContentKey,
+ cardIdKey,
+ columnCardsKey,
+ columnIdKey,
+ columnsKey,
+ columnTitleKey,
+} from "./components/board/board";
+import Component from "./index";
+import type { BlockEntity } from "./types/generated/block-entity";
+
+const node = document.getElementById("app");
+
+const testEntity: BlockEntity = {
+ metadata: {
+ recordId: {
+ entityId: "test-entity",
+ editionId: new Date().toISOString(),
+ },
+ entityTypeId: packageJson.blockprotocol.blockEntityType as VersionedUrl,
+ },
+ properties: {
+ [columnsKey]: [
+ {
+ [columnIdKey]: "col-todo",
+ [columnTitleKey]: "Todo",
+ [columnCardsKey]: [
+ { [cardIdKey]: "task-1", [cardContentKey]: "First task" },
+ {
+ [cardIdKey]: "task-2",
+ [cardContentKey]: "Second task with a very long description",
+ },
+ {
+ [cardIdKey]: "task-3",
+ [cardContentKey]: "Third task",
+ },
+ ],
+ },
+ {
+ [columnIdKey]: "col-in-progress",
+ [columnTitleKey]: "In Progress",
+ [columnCardsKey]: [
+ { [cardIdKey]: "task-4", [cardContentKey]: "Fourth task" },
+ { [cardIdKey]: "task-5", [cardContentKey]: "Fifth task" },
+ ],
+ },
+ {
+ [columnIdKey]: "col-done",
+ [columnTitleKey]: "Done",
+ [columnCardsKey]: [],
+ },
+ ],
+ },
+};
+
+const DevApp = () => {
+ return (
+
+ );
+};
+
+if (node) {
+ createRoot(node).render( );
+} else {
+ throw new Error("Unable to find DOM element with id 'app'");
+}
diff --git a/blocks/kanban-board/src/index.ts b/blocks/kanban-board/src/index.ts
new file mode 100644
index 0000000..6eb172a
--- /dev/null
+++ b/blocks/kanban-board/src/index.ts
@@ -0,0 +1,8 @@
+/* eslint-disable canonical/filename-no-index -- @todo rename file */
+
+/**
+ * Entrypoint of the Block Component.
+ */
+import { App } from "./app";
+
+export default App;
diff --git a/blocks/kanban-board/src/types/generated/block-entity.ts b/blocks/kanban-board/src/types/generated/block-entity.ts
new file mode 100644
index 0000000..1e9a970
--- /dev/null
+++ b/blocks/kanban-board/src/types/generated/block-entity.ts
@@ -0,0 +1,75 @@
+/**
+ * This file was automatically generated – do not edit it.
+ */
+
+import { Entity } from "@blockprotocol/graph";
+
+export type BlockEntity = KanbanBoardBlock;
+
+export type BlockEntityOutgoingLinkAndTarget =
+ KanbanBoardBlockOutgoingLinkAndTarget;
+
+export type KanbanBoardBlock = Entity;
+
+export type KanbanBoardBlockOutgoingLinkAndTarget = never;
+
+export type KanbanBoardBlockOutgoingLinksByLinkEntityTypeId = {};
+
+/**
+ * The block entity of the “Kanban Board” block.
+ *
+ * See: https://blockprotocol.org/@hash/blocks/kanban-board
+ */
+export type KanbanBoardBlockProperties = {
+ "https://blockprotocol.org/@blockprotocol/types/property-type/title/"?: TitlePropertyValue;
+ /**
+ * @minItems 0
+ */
+ "https://blockprotocol.org/@hash/types/property-type/kanban-board-column/"?: KanbanBoardColumnPropertyValue[];
+};
+
+/**
+ * An identifier for a card stored on a column on the “Kanban Board” block.
+ *
+ * Each card ID should be unique across all cards within a given board.
+ */
+export type KanbanBoardCardIDPropertyValue = TextDataType;
+
+/**
+ * The definition of a specific card within a column on the “Kanban Board” block.
+ */
+export type KanbanBoardCardPropertyValue = {
+ "https://blockprotocol.org/@hash/types/property-type/kanban-board-card-id/": KanbanBoardCardIDPropertyValue;
+ "https://blockprotocol.org/@blockprotocol/types/property-type/textual-content/"?: TextualContentPropertyValue;
+};
+
+/**
+ * An identifier for a column stored on the “Kanban Board” block.
+ *
+ * Each column ID should be unique across all columns within a given board.
+ */
+export type KanbanBoardColumnIDPropertyValue = TextDataType;
+
+/**
+ * The definition of a specific column within the “Kanban Board” block.
+ */
+export type KanbanBoardColumnPropertyValue = {
+ "https://blockprotocol.org/@hash/types/property-type/kanban-board-column-id/": KanbanBoardColumnIDPropertyValue;
+ "https://blockprotocol.org/@blockprotocol/types/property-type/title/"?: TitlePropertyValue;
+ "https://blockprotocol.org/@hash/types/property-type/kanban-board-card/"?: KanbanBoardCardPropertyValue[];
+};
+
+/**
+ * An ordered sequence of characters
+ */
+export type TextDataType = string;
+
+/**
+ * The text material, information, or body, that makes up the content of this thing.
+ */
+export type TextualContentPropertyValue = TextDataType;
+
+/**
+ * The name given to something to identify it, generally associated with objects or inanimate things such as books, websites, songs, etc.
+ */
+export type TitlePropertyValue = TextDataType;
diff --git a/blocks/kanban-board/theme-override.d.ts b/blocks/kanban-board/theme-override.d.ts
new file mode 100644
index 0000000..85625e2
--- /dev/null
+++ b/blocks/kanban-board/theme-override.d.ts
@@ -0,0 +1,2 @@
+// eslint-disable-next-line no-restricted-imports
+import "@hashintel/design-system/theme-override";
diff --git a/blocks/kanban-board/tsconfig.json b/blocks/kanban-board/tsconfig.json
new file mode 100644
index 0000000..70fa73d
--- /dev/null
+++ b/blocks/kanban-board/tsconfig.json
@@ -0,0 +1,5 @@
+{
+ "extends": "@local/tsconfig/block.json",
+ "include": ["declarations.d.ts", "src", "theme-override.d.ts"],
+ "exclude": ["node_modules"]
+}
diff --git a/blocks/kanban-board/turbo.json b/blocks/kanban-board/turbo.json
new file mode 100644
index 0000000..9d80ee7
--- /dev/null
+++ b/blocks/kanban-board/turbo.json
@@ -0,0 +1,28 @@
+{
+ "extends": ["//"],
+ "tasks": {
+ "codegen": {
+ "inputs": ["./package.json"],
+ "outputs": ["./src/types/generated/**"]
+ },
+ "build": {
+ "dependsOn": ["^build", "codegen", "format"],
+ "outputs": ["./dist/**"]
+ },
+ "lint:tsc": {
+ "dependsOn": ["codegen"]
+ },
+ "format": {
+ "cache": false,
+ "dependsOn": ["codegen"]
+ },
+ "dev": {
+ "persistent": true,
+ "dependsOn": ["^build", "codegen"]
+ },
+ "serve": {
+ "persistent": true,
+ "dependsOn": ["build"]
+ }
+ }
+}
diff --git a/blocks/kanban-board/variants.json b/blocks/kanban-board/variants.json
new file mode 100644
index 0000000..fe51488
--- /dev/null
+++ b/blocks/kanban-board/variants.json
@@ -0,0 +1 @@
+[]
diff --git a/blocks/minesweeper/LICENSE-APACHE.md b/blocks/minesweeper/LICENSE-APACHE.md
new file mode 100644
index 0000000..1d1b6f8
--- /dev/null
+++ b/blocks/minesweeper/LICENSE-APACHE.md
@@ -0,0 +1,189 @@
+# Apache License
+
+_Version 2.0, January 2004_
+_< >_
+
+### Terms and Conditions for use, reproduction, and distribution
+
+#### 1. Definitions
+
+“License” shall mean the terms and conditions for use, reproduction, and
+distribution as defined by Sections 1 through 9 of this document.
+
+“Licensor” shall mean the copyright owner or entity authorized by the copyright
+owner that is granting the License.
+
+“Legal Entity” shall mean the union of the acting entity and all other entities
+that control, are controlled by, or are under common control with that entity.
+For the purposes of this definition, “control” means **(i)** the power, direct or
+indirect, to cause the direction or management of such entity, whether by
+contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the
+outstanding shares, or **(iii)** beneficial ownership of such entity.
+
+“You” (or “Your”) shall mean an individual or Legal Entity exercising
+permissions granted by this License.
+
+“Source” form shall mean the preferred form for making modifications, including
+but not limited to software source code, documentation source, and configuration
+files.
+
+“Object” form shall mean any form resulting from mechanical transformation or
+translation of a Source form, including but not limited to compiled object code,
+generated documentation, and conversions to other media types.
+
+“Work” shall mean the work of authorship, whether in Source or Object form, made
+available under the License, as indicated by a copyright notice that is included
+in or attached to the work (an example is provided in the Appendix below).
+
+“Derivative Works” shall mean any work, whether in Source or Object form, that
+is based on (or derived from) the Work and for which the editorial revisions,
+annotations, elaborations, or other modifications represent, as a whole, an
+original work of authorship. For the purposes of this License, Derivative Works
+shall not include works that remain separable from, or merely link (or bind by
+name) to the interfaces of, the Work and Derivative Works thereof.
+
+“Contribution” shall mean any work of authorship, including the original version
+of the Work and any modifications or additions to that Work or Derivative Works
+thereof, that is intentionally submitted to Licensor for inclusion in the Work
+by the copyright owner or by an individual or Legal Entity authorized to submit
+on behalf of the copyright owner. For the purposes of this definition,
+“submitted” means any form of electronic, verbal, or written communication sent
+to the Licensor or its representatives, including but not limited to
+communication on electronic mailing lists, source code control systems, and
+issue tracking systems that are managed by, or on behalf of, the Licensor for
+the purpose of discussing and improving the Work, but excluding communication
+that is conspicuously marked or otherwise designated in writing by the copyright
+owner as “Not a Contribution.”
+
+“Contributor” shall mean Licensor and any individual or Legal Entity on behalf
+of whom a Contribution has been received by Licensor and subsequently
+incorporated within the Work.
+
+#### 2. Grant of Copyright License
+
+Subject to the terms and conditions of this License, each Contributor hereby
+grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
+irrevocable copyright license to reproduce, prepare Derivative Works of,
+publicly display, publicly perform, sublicense, and distribute the Work and such
+Derivative Works in Source or Object form.
+
+#### 3. Grant of Patent License
+
+Subject to the terms and conditions of this License, each Contributor hereby
+grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
+irrevocable (except as stated in this section) patent license to make, have
+made, use, offer to sell, sell, import, and otherwise transfer the Work, where
+such license applies only to those patent claims licensable by such Contributor
+that are necessarily infringed by their Contribution(s) alone or by combination
+of their Contribution(s) with the Work to which such Contribution(s) was
+submitted. If You institute patent litigation against any entity (including a
+cross-claim or counterclaim in a lawsuit) alleging that the Work or a
+Contribution incorporated within the Work constitutes direct or contributory
+patent infringement, then any patent licenses granted to You under this License
+for that Work shall terminate as of the date such litigation is filed.
+
+#### 4. Redistribution
+
+You may reproduce and distribute copies of the Work or Derivative Works thereof
+in any medium, with or without modifications, and in Source or Object form,
+provided that You meet the following conditions:
+
+- **(a)** You must give any other recipients of the Work or Derivative Works a copy of
+ this License; and
+- **(b)** You must cause any modified files to carry prominent notices stating that You
+ changed the files; and
+- **(c)** You must retain, in the Source form of any Derivative Works that You distribute,
+ all copyright, patent, trademark, and attribution notices from the Source form
+ of the Work, excluding those notices that do not pertain to any part of the
+ Derivative Works; and
+- **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any
+ Derivative Works that You distribute must include a readable copy of the
+ attribution notices contained within such NOTICE file, excluding those notices
+ that do not pertain to any part of the Derivative Works, in at least one of the
+ following places: within a NOTICE text file distributed as part of the
+ Derivative Works; within the Source form or documentation, if provided along
+ with the Derivative Works; or, within a display generated by the Derivative
+ Works, if and wherever such third-party notices normally appear. The contents of
+ the NOTICE file are for informational purposes only and do not modify the
+ License. You may add Your own attribution notices within Derivative Works that
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
+ provided that such additional attribution notices cannot be construed as
+ modifying the License.
+
+You may add Your own copyright statement to Your modifications and may provide
+additional or different license terms and conditions for use, reproduction, or
+distribution of Your modifications, or for any such Derivative Works as a whole,
+provided Your use, reproduction, and distribution of the Work otherwise complies
+with the conditions stated in this License.
+
+#### 5. Submission of Contributions
+
+Unless You explicitly state otherwise, any Contribution intentionally submitted
+for inclusion in the Work by You to the Licensor shall be under the terms and
+conditions of this License, without any additional terms or conditions.
+Notwithstanding the above, nothing herein shall supersede or modify the terms of
+any separate license agreement you may have executed with Licensor regarding
+such Contributions.
+
+#### 6. Trademarks
+
+This License does not grant permission to use the trade names, trademarks,
+service marks, or product names of the Licensor, except as required for
+reasonable and customary use in describing the origin of the Work and
+reproducing the content of the NOTICE file.
+
+#### 7. Disclaimer of Warranty
+
+Unless required by applicable law or agreed to in writing, Licensor provides the
+Work (and each Contributor provides its Contributions) on an “AS IS” BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
+including, without limitation, any warranties or conditions of TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
+solely responsible for determining the appropriateness of using or
+redistributing the Work and assume any risks associated with Your exercise of
+permissions under this License.
+
+#### 8. Limitation of Liability
+
+In no event and under no legal theory, whether in tort (including negligence),
+contract, or otherwise, unless required by applicable law (such as deliberate
+and grossly negligent acts) or agreed to in writing, shall any Contributor be
+liable to You for damages, including any direct, indirect, special, incidental,
+or consequential damages of any character arising as a result of this License or
+out of the use or inability to use the Work (including but not limited to
+damages for loss of goodwill, work stoppage, computer failure or malfunction, or
+any and all other commercial damages or losses), even if such Contributor has
+been advised of the possibility of such damages.
+
+#### 9. Accepting Warranty or Additional Liability
+
+While redistributing the Work or Derivative Works thereof, You may choose to
+offer, and charge a fee for, acceptance of support, warranty, indemnity, or
+other liability obligations and/or rights consistent with this License. However,
+in accepting such obligations, You may act only on Your own behalf and on Your
+sole responsibility, not on behalf of any other Contributor, and only if You
+agree to indemnify, defend, and hold each Contributor harmless for any liability
+incurred by, or claims asserted against, such Contributor by reason of your
+accepting any such warranty or additional liability.
+
+_END OF TERMS AND CONDITIONS_
+
+### APPENDIX: Apply the Apache License to a specific file
+
+To apply the Apache License to an individual file, attach the following notice.
+The text should be enclosed in the appropriate comment syntax for the file
+format.
+
+ Copyright © 2022–, HASH
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/blocks/minesweeper/LICENSE-MIT.md b/blocks/minesweeper/LICENSE-MIT.md
new file mode 100644
index 0000000..e33c1d3
--- /dev/null
+++ b/blocks/minesweeper/LICENSE-MIT.md
@@ -0,0 +1,21 @@
+# MIT License
+
+Copyright © 2022–, HASH
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/blocks/minesweeper/LICENSE.md b/blocks/minesweeper/LICENSE.md
new file mode 100644
index 0000000..8686df9
--- /dev/null
+++ b/blocks/minesweeper/LICENSE.md
@@ -0,0 +1,5 @@
+# License
+
+Licensed under either of the [Apache License, Version 2.0](LICENSE-APACHE.md) or [MIT license](LICENSE-MIT.md) at your option.
+
+For more information about contributing to this block, see our top-level [CONTRIBUTING](https://github.com/hashintel/hash/blob/main/.github/CONTRIBUTING.md) policy.
diff --git a/blocks/minesweeper/README.md b/blocks/minesweeper/README.md
new file mode 100644
index 0000000..4e5bdbc
--- /dev/null
+++ b/blocks/minesweeper/README.md
@@ -0,0 +1,13 @@
+# Minesweeper
+
+**Play Minesweeper in your browser!**
+
+Read more about Minesweeper, including rules, strategy, and world rankings, at [https://minesweepergame.com](https://minesweepergame.com/).
+
+## Usage instructions
+
+The grid size (square only) and number of mines can be set via the block's properties. The default is a `16 x 16` grid with `40` mines, representing "Intermediate" difficulty.
+
+## Credits
+
+Credit to [kurehajime](https://github.com/kurehajime) for the custom element – you can [find the code here](https://github.com/kurehajime/minesweeper_tag).
diff --git a/blocks/minesweeper/eslint.config.js b/blocks/minesweeper/eslint.config.js
new file mode 100644
index 0000000..5b6bb9d
--- /dev/null
+++ b/blocks/minesweeper/eslint.config.js
@@ -0,0 +1,3 @@
+import { createBlock } from "@local/eslint/deprecated";
+
+export default createBlock(import.meta.dirname);
diff --git a/blocks/minesweeper/mine-sweeper-tag.d.ts b/blocks/minesweeper/mine-sweeper-tag.d.ts
new file mode 100644
index 0000000..5111e21
--- /dev/null
+++ b/blocks/minesweeper/mine-sweeper-tag.d.ts
@@ -0,0 +1,7 @@
+declare module "mine-sweeper-tag" {
+ export class mine_sweeper extends HTMLElement {
+ cols: number;
+ bomb: number;
+ beep?: boolean;
+ }
+}
diff --git a/blocks/minesweeper/package.json b/blocks/minesweeper/package.json
new file mode 100644
index 0000000..03a282f
--- /dev/null
+++ b/blocks/minesweeper/package.json
@@ -0,0 +1,71 @@
+{
+ "name": "@blocks/minesweeper",
+ "version": "0.0.1",
+ "private": true,
+ "description": "Play Minesweeper in your browser!",
+ "keywords": [
+ "blockprotocol",
+ "blocks"
+ ],
+ "license": "(MIT OR Apache-2.0)",
+ "author": "HASH",
+ "type": "module",
+ "scripts": {
+ "build": "block-scripts build",
+ "codegen": "block-scripts codegen && yarn format",
+ "dev": "block-scripts dev",
+ "fix:eslint": "eslint --fix .",
+ "format": "prettier --write --ignore-unknown src/types/generated/*.ts",
+ "lint:eslint": "eslint --report-unused-disable-directives .",
+ "lint:tsc": "tsc --noEmit",
+ "serve": "block-scripts serve"
+ },
+ "dependencies": {
+ "@blockprotocol/graph": "0.3.4",
+ "lit": "2.8.0",
+ "mine-sweeper-tag": "1.0.6"
+ },
+ "devDependencies": {
+ "@local/eslint": "0.0.0-private",
+ "@local/tsconfig": "0.0.0-private",
+ "@types/react-dom": "19.1.7",
+ "block-scripts": "0.3.4",
+ "eslint": "10.0.3",
+ "mock-block-dock": "0.1.9",
+ "prettier": "3.8.1",
+ "react": "19.1.1",
+ "react-dom": "19.1.1",
+ "typescript": "5.9.3"
+ },
+ "block-scripts": {
+ "port": 63212
+ },
+ "blockprotocol": {
+ "blockType": {
+ "entryPoint": "custom-element",
+ "tagName": "minesweeper-block"
+ },
+ "displayName": "Minesweeper",
+ "examples": [
+ {
+ "https://blockprotocol.org/@hash/types/property-type/number-of-columns/": 12,
+ "https://blockprotocol.org/@hash/types/property-type/number-of-mines/": 30
+ }
+ ],
+ "icon": "public/minesweeper-icon.svg",
+ "image": "public/block-preview.png",
+ "name": "@hash/minesweeper",
+ "protocol": "0.3",
+ "blockEntityType": "https://blockprotocol.org/@hash/types/entity-type/minesweeper-block/v/1",
+ "codegen": {
+ "outputFolder": "src/types/generated",
+ "targets": {
+ "block-entity.ts": [
+ {
+ "blockEntityType": true
+ }
+ ]
+ }
+ }
+ }
+}
diff --git a/blocks/minesweeper/public/block-preview.png b/blocks/minesweeper/public/block-preview.png
new file mode 100644
index 0000000..b21ee99
Binary files /dev/null and b/blocks/minesweeper/public/block-preview.png differ
diff --git a/blocks/minesweeper/public/minesweeper-icon.svg b/blocks/minesweeper/public/minesweeper-icon.svg
new file mode 100644
index 0000000..556dab6
--- /dev/null
+++ b/blocks/minesweeper/public/minesweeper-icon.svg
@@ -0,0 +1,3 @@
+
diff --git a/blocks/minesweeper/src/app.ts b/blocks/minesweeper/src/app.ts
new file mode 100644
index 0000000..cfb6c8e
--- /dev/null
+++ b/blocks/minesweeper/src/app.ts
@@ -0,0 +1,64 @@
+import { BlockElementBase } from "@blockprotocol/graph/custom-element";
+import { getRoots } from "@blockprotocol/graph/stdlib";
+import type { PropertyValues } from "lit";
+import { unsafeHTML } from "lit/directives/unsafe-html.js";
+import { mine_sweeper } from "mine-sweeper-tag";
+
+import type { BlockEntity } from "./types/generated/block-entity";
+
+const colsKey: keyof BlockEntity["properties"] =
+ "https://blockprotocol.org/@hash/types/property-type/number-of-columns/";
+const minesKey: keyof BlockEntity["properties"] =
+ "https://blockprotocol.org/@hash/types/property-type/number-of-mines/";
+
+const takeNumberOrDefault = (value: unknown, defaultValue: number) => {
+ if (
+ typeof value === "number" ||
+ (typeof value === "string" && !Number.isNaN(parseInt(value, 10)))
+ ) {
+ return value;
+ }
+ return defaultValue;
+};
+
+export class MinesweeperBlock extends BlockElementBase {
+ connectedCallback() {
+ super.connectedCallback();
+ customElements.define("mine-sweeper", mine_sweeper);
+ }
+
+ protected shouldUpdate(_changedProperties: PropertyValues): boolean {
+ const graph = _changedProperties.get("graph");
+
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
+ if (!graph) {
+ // this is the first render – the value was previously undefined
+ return true;
+ }
+
+ const newBlockEntity = getRoots(graph.blockEntitySubgraph)[0];
+ if (!newBlockEntity) {
+ throw new Error("No root in updated blockEntitySubgraph");
+ }
+ return (
+ newBlockEntity.properties[colsKey]?.toString() !==
+ this.getBlockEntity().properties[colsKey]?.toString() ||
+ newBlockEntity.properties[minesKey]?.toString() !==
+ this.getBlockEntity().properties[minesKey]?.toString()
+ );
+ }
+
+ render() {
+ const { [colsKey]: colsFromProperties, [minesKey]: minesFromProperties } =
+ this.getBlockEntity().properties;
+
+ const cols = takeNumberOrDefault(colsFromProperties, 16);
+ const mines = takeNumberOrDefault(minesFromProperties, 40);
+
+ // the element breaks if its attributes change after it has been rendered,
+ // so we force it to be recreated by doing this
+ const minesweeperHtml = ` `;
+
+ return unsafeHTML(minesweeperHtml);
+ }
+}
diff --git a/blocks/minesweeper/src/dev.tsx b/blocks/minesweeper/src/dev.tsx
new file mode 100644
index 0000000..b911b0a
--- /dev/null
+++ b/blocks/minesweeper/src/dev.tsx
@@ -0,0 +1,71 @@
+import type { VersionedUrl } from "@blockprotocol/graph";
+import { MockBlockDock } from "mock-block-dock";
+import { createRoot } from "react-dom/client";
+
+import packageJson from "../package.json";
+import ElementClass from "./index";
+import type { BlockEntity } from "./types/generated/block-entity";
+
+const node = document.getElementById("app");
+
+const testEntity: BlockEntity = {
+ metadata: {
+ recordId: {
+ entityId: "minesweeper-block-1",
+ editionId: new Date().toISOString(),
+ },
+ entityTypeId: packageJson.blockprotocol.blockEntityType as VersionedUrl,
+ },
+ properties: {
+ "https://blockprotocol.org/@hash/types/property-type/number-of-columns/": 12,
+ "https://blockprotocol.org/@hash/types/property-type/number-of-mines/": 30,
+ },
+} as const;
+
+/**
+ * This is an embedding application for local development and debugging.
+ * It is the application loaded into the browser when you run 'yarn dev' (or 'npm run dev')
+ * No data from it will be published with your block or included as part of a production build.
+ *
+ * The component used here, 'MockBlockDock', does the following:
+ * 1. It renders your block on the page and provides the initial properties specified below
+ * 2. It holds an in-memory datastore of entities and links
+ * 3. It listens for messages from your blocks and updates its datastore appropriately (e.g. to create a new entity)
+ * 4. It displays a debug UI allowing you to see the contents of its datastore, and messages sent back and forth
+ */
+const DevApp = () => {
+ const tagName = packageJson.blockprotocol.blockType.tagName;
+ if (!tagName) {
+ throw new Error(
+ "Please set a name for your custom element in package.json, under blockprotocol.blockType.tagName",
+ );
+ }
+
+ return (
+
+ );
+};
+
+if (node) {
+ createRoot(node).render( );
+} else {
+ throw new Error("Unable to find DOM element with id 'app'");
+}
diff --git a/blocks/minesweeper/src/index.ts b/blocks/minesweeper/src/index.ts
new file mode 100644
index 0000000..c1777f6
--- /dev/null
+++ b/blocks/minesweeper/src/index.ts
@@ -0,0 +1,7 @@
+/**
+ * Entrypoint of the Block Component.
+ */
+// eslint-disable-next-line canonical/filename-no-index
+import { MinesweeperBlock } from "./app";
+
+export default MinesweeperBlock;
diff --git a/blocks/minesweeper/src/types/generated/block-entity.ts b/blocks/minesweeper/src/types/generated/block-entity.ts
new file mode 100644
index 0000000..6f9593f
--- /dev/null
+++ b/blocks/minesweeper/src/types/generated/block-entity.ts
@@ -0,0 +1,41 @@
+/**
+ * This file was automatically generated – do not edit it.
+ */
+
+import { Entity } from "@blockprotocol/graph";
+
+export type BlockEntity = MinesweeperBlock;
+
+export type BlockEntityOutgoingLinkAndTarget =
+ MinesweeperBlockOutgoingLinkAndTarget;
+
+export type MinesweeperBlock = Entity;
+
+export type MinesweeperBlockOutgoingLinkAndTarget = never;
+
+export type MinesweeperBlockOutgoingLinksByLinkEntityTypeId = {};
+
+/**
+ * The block entity of the "Minesweeper" block.
+ *
+ * See: https://blockprotocol.org/@hash/blocks/minesweeper
+ */
+export type MinesweeperBlockProperties = {
+ "https://blockprotocol.org/@hash/types/property-type/number-of-mines/"?: NumberOfMinesPropertyValue;
+ "https://blockprotocol.org/@hash/types/property-type/number-of-columns/"?: NumberOfColumnsPropertyValue;
+};
+
+/**
+ * An arithmetical value (in the Real number system)
+ */
+export type NumberDataType = number;
+
+/**
+ * How many columns there are or should be
+ */
+export type NumberOfColumnsPropertyValue = NumberDataType;
+
+/**
+ * How many mines there are or should be
+ */
+export type NumberOfMinesPropertyValue = NumberDataType;
diff --git a/blocks/minesweeper/tsconfig.json b/blocks/minesweeper/tsconfig.json
new file mode 100644
index 0000000..2bcd660
--- /dev/null
+++ b/blocks/minesweeper/tsconfig.json
@@ -0,0 +1,5 @@
+{
+ "extends": "@local/tsconfig/block.json",
+ "include": ["src", "mine-sweeper-tag.d.ts"],
+ "exclude": ["node_modules"]
+}
diff --git a/blocks/minesweeper/turbo.json b/blocks/minesweeper/turbo.json
new file mode 100644
index 0000000..9d80ee7
--- /dev/null
+++ b/blocks/minesweeper/turbo.json
@@ -0,0 +1,28 @@
+{
+ "extends": ["//"],
+ "tasks": {
+ "codegen": {
+ "inputs": ["./package.json"],
+ "outputs": ["./src/types/generated/**"]
+ },
+ "build": {
+ "dependsOn": ["^build", "codegen", "format"],
+ "outputs": ["./dist/**"]
+ },
+ "lint:tsc": {
+ "dependsOn": ["codegen"]
+ },
+ "format": {
+ "cache": false,
+ "dependsOn": ["codegen"]
+ },
+ "dev": {
+ "persistent": true,
+ "dependsOn": ["^build", "codegen"]
+ },
+ "serve": {
+ "persistent": true,
+ "dependsOn": ["build"]
+ }
+ }
+}
diff --git a/blocks/paragraph/LICENSE-APACHE.md b/blocks/paragraph/LICENSE-APACHE.md
new file mode 100644
index 0000000..1d1b6f8
--- /dev/null
+++ b/blocks/paragraph/LICENSE-APACHE.md
@@ -0,0 +1,189 @@
+# Apache License
+
+_Version 2.0, January 2004_
+_< >_
+
+### Terms and Conditions for use, reproduction, and distribution
+
+#### 1. Definitions
+
+“License” shall mean the terms and conditions for use, reproduction, and
+distribution as defined by Sections 1 through 9 of this document.
+
+“Licensor” shall mean the copyright owner or entity authorized by the copyright
+owner that is granting the License.
+
+“Legal Entity” shall mean the union of the acting entity and all other entities
+that control, are controlled by, or are under common control with that entity.
+For the purposes of this definition, “control” means **(i)** the power, direct or
+indirect, to cause the direction or management of such entity, whether by
+contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the
+outstanding shares, or **(iii)** beneficial ownership of such entity.
+
+“You” (or “Your”) shall mean an individual or Legal Entity exercising
+permissions granted by this License.
+
+“Source” form shall mean the preferred form for making modifications, including
+but not limited to software source code, documentation source, and configuration
+files.
+
+“Object” form shall mean any form resulting from mechanical transformation or
+translation of a Source form, including but not limited to compiled object code,
+generated documentation, and conversions to other media types.
+
+“Work” shall mean the work of authorship, whether in Source or Object form, made
+available under the License, as indicated by a copyright notice that is included
+in or attached to the work (an example is provided in the Appendix below).
+
+“Derivative Works” shall mean any work, whether in Source or Object form, that
+is based on (or derived from) the Work and for which the editorial revisions,
+annotations, elaborations, or other modifications represent, as a whole, an
+original work of authorship. For the purposes of this License, Derivative Works
+shall not include works that remain separable from, or merely link (or bind by
+name) to the interfaces of, the Work and Derivative Works thereof.
+
+“Contribution” shall mean any work of authorship, including the original version
+of the Work and any modifications or additions to that Work or Derivative Works
+thereof, that is intentionally submitted to Licensor for inclusion in the Work
+by the copyright owner or by an individual or Legal Entity authorized to submit
+on behalf of the copyright owner. For the purposes of this definition,
+“submitted” means any form of electronic, verbal, or written communication sent
+to the Licensor or its representatives, including but not limited to
+communication on electronic mailing lists, source code control systems, and
+issue tracking systems that are managed by, or on behalf of, the Licensor for
+the purpose of discussing and improving the Work, but excluding communication
+that is conspicuously marked or otherwise designated in writing by the copyright
+owner as “Not a Contribution.”
+
+“Contributor” shall mean Licensor and any individual or Legal Entity on behalf
+of whom a Contribution has been received by Licensor and subsequently
+incorporated within the Work.
+
+#### 2. Grant of Copyright License
+
+Subject to the terms and conditions of this License, each Contributor hereby
+grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
+irrevocable copyright license to reproduce, prepare Derivative Works of,
+publicly display, publicly perform, sublicense, and distribute the Work and such
+Derivative Works in Source or Object form.
+
+#### 3. Grant of Patent License
+
+Subject to the terms and conditions of this License, each Contributor hereby
+grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
+irrevocable (except as stated in this section) patent license to make, have
+made, use, offer to sell, sell, import, and otherwise transfer the Work, where
+such license applies only to those patent claims licensable by such Contributor
+that are necessarily infringed by their Contribution(s) alone or by combination
+of their Contribution(s) with the Work to which such Contribution(s) was
+submitted. If You institute patent litigation against any entity (including a
+cross-claim or counterclaim in a lawsuit) alleging that the Work or a
+Contribution incorporated within the Work constitutes direct or contributory
+patent infringement, then any patent licenses granted to You under this License
+for that Work shall terminate as of the date such litigation is filed.
+
+#### 4. Redistribution
+
+You may reproduce and distribute copies of the Work or Derivative Works thereof
+in any medium, with or without modifications, and in Source or Object form,
+provided that You meet the following conditions:
+
+- **(a)** You must give any other recipients of the Work or Derivative Works a copy of
+ this License; and
+- **(b)** You must cause any modified files to carry prominent notices stating that You
+ changed the files; and
+- **(c)** You must retain, in the Source form of any Derivative Works that You distribute,
+ all copyright, patent, trademark, and attribution notices from the Source form
+ of the Work, excluding those notices that do not pertain to any part of the
+ Derivative Works; and
+- **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any
+ Derivative Works that You distribute must include a readable copy of the
+ attribution notices contained within such NOTICE file, excluding those notices
+ that do not pertain to any part of the Derivative Works, in at least one of the
+ following places: within a NOTICE text file distributed as part of the
+ Derivative Works; within the Source form or documentation, if provided along
+ with the Derivative Works; or, within a display generated by the Derivative
+ Works, if and wherever such third-party notices normally appear. The contents of
+ the NOTICE file are for informational purposes only and do not modify the
+ License. You may add Your own attribution notices within Derivative Works that
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
+ provided that such additional attribution notices cannot be construed as
+ modifying the License.
+
+You may add Your own copyright statement to Your modifications and may provide
+additional or different license terms and conditions for use, reproduction, or
+distribution of Your modifications, or for any such Derivative Works as a whole,
+provided Your use, reproduction, and distribution of the Work otherwise complies
+with the conditions stated in this License.
+
+#### 5. Submission of Contributions
+
+Unless You explicitly state otherwise, any Contribution intentionally submitted
+for inclusion in the Work by You to the Licensor shall be under the terms and
+conditions of this License, without any additional terms or conditions.
+Notwithstanding the above, nothing herein shall supersede or modify the terms of
+any separate license agreement you may have executed with Licensor regarding
+such Contributions.
+
+#### 6. Trademarks
+
+This License does not grant permission to use the trade names, trademarks,
+service marks, or product names of the Licensor, except as required for
+reasonable and customary use in describing the origin of the Work and
+reproducing the content of the NOTICE file.
+
+#### 7. Disclaimer of Warranty
+
+Unless required by applicable law or agreed to in writing, Licensor provides the
+Work (and each Contributor provides its Contributions) on an “AS IS” BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
+including, without limitation, any warranties or conditions of TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
+solely responsible for determining the appropriateness of using or
+redistributing the Work and assume any risks associated with Your exercise of
+permissions under this License.
+
+#### 8. Limitation of Liability
+
+In no event and under no legal theory, whether in tort (including negligence),
+contract, or otherwise, unless required by applicable law (such as deliberate
+and grossly negligent acts) or agreed to in writing, shall any Contributor be
+liable to You for damages, including any direct, indirect, special, incidental,
+or consequential damages of any character arising as a result of this License or
+out of the use or inability to use the Work (including but not limited to
+damages for loss of goodwill, work stoppage, computer failure or malfunction, or
+any and all other commercial damages or losses), even if such Contributor has
+been advised of the possibility of such damages.
+
+#### 9. Accepting Warranty or Additional Liability
+
+While redistributing the Work or Derivative Works thereof, You may choose to
+offer, and charge a fee for, acceptance of support, warranty, indemnity, or
+other liability obligations and/or rights consistent with this License. However,
+in accepting such obligations, You may act only on Your own behalf and on Your
+sole responsibility, not on behalf of any other Contributor, and only if You
+agree to indemnify, defend, and hold each Contributor harmless for any liability
+incurred by, or claims asserted against, such Contributor by reason of your
+accepting any such warranty or additional liability.
+
+_END OF TERMS AND CONDITIONS_
+
+### APPENDIX: Apply the Apache License to a specific file
+
+To apply the Apache License to an individual file, attach the following notice.
+The text should be enclosed in the appropriate comment syntax for the file
+format.
+
+ Copyright © 2022–, HASH
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/blocks/paragraph/LICENSE-MIT.md b/blocks/paragraph/LICENSE-MIT.md
new file mode 100644
index 0000000..e33c1d3
--- /dev/null
+++ b/blocks/paragraph/LICENSE-MIT.md
@@ -0,0 +1,21 @@
+# MIT License
+
+Copyright © 2022–, HASH
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/blocks/paragraph/LICENSE.md b/blocks/paragraph/LICENSE.md
new file mode 100644
index 0000000..8686df9
--- /dev/null
+++ b/blocks/paragraph/LICENSE.md
@@ -0,0 +1,5 @@
+# License
+
+Licensed under either of the [Apache License, Version 2.0](LICENSE-APACHE.md) or [MIT license](LICENSE-MIT.md) at your option.
+
+For more information about contributing to this block, see our top-level [CONTRIBUTING](https://github.com/hashintel/hash/blob/main/.github/CONTRIBUTING.md) policy.
diff --git a/blocks/paragraph/README.md b/blocks/paragraph/README.md
new file mode 100644
index 0000000..a6bdc00
--- /dev/null
+++ b/blocks/paragraph/README.md
@@ -0,0 +1,3 @@
+# Paragraph block
+
+A block to display a paragraph of text.
diff --git a/blocks/paragraph/eslint.config.js b/blocks/paragraph/eslint.config.js
new file mode 100644
index 0000000..5b6bb9d
--- /dev/null
+++ b/blocks/paragraph/eslint.config.js
@@ -0,0 +1,3 @@
+import { createBlock } from "@local/eslint/deprecated";
+
+export default createBlock(import.meta.dirname);
diff --git a/blocks/paragraph/package.json b/blocks/paragraph/package.json
new file mode 100644
index 0000000..87221c6
--- /dev/null
+++ b/blocks/paragraph/package.json
@@ -0,0 +1,79 @@
+{
+ "name": "@blocks/paragraph",
+ "version": "0.1.2",
+ "private": true,
+ "description": "Write a block of text to express an idea, make a point, or record a thought",
+ "keywords": [
+ "blockprotocol",
+ "blocks",
+ "block"
+ ],
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/hashintel/blocks.git#main",
+ "directory": "blocks/paragraph"
+ },
+ "license": "(MIT OR Apache-2.0)",
+ "author": "HASH",
+ "type": "module",
+ "scripts": {
+ "build": "block-scripts build",
+ "codegen": "block-scripts codegen && yarn format",
+ "dev": "block-scripts dev",
+ "fix:eslint": "eslint --fix .",
+ "format": "prettier --write --ignore-unknown src/types/generated/*.ts",
+ "lint:eslint": "eslint --report-unused-disable-directives .",
+ "lint:tsc": "tsc --noEmit",
+ "serve": "block-scripts serve"
+ },
+ "dependencies": {
+ "@blockprotocol/graph": "0.3.4",
+ "@blockprotocol/hook": "0.1.3"
+ },
+ "devDependencies": {
+ "@local/eslint": "0.0.0-private",
+ "@local/tsconfig": "0.0.0-private",
+ "@types/react-dom": "19.1.7",
+ "block-scripts": "0.3.4",
+ "eslint": "10.0.3",
+ "mock-block-dock": "0.1.9",
+ "prettier": "3.8.1",
+ "react": "19.1.1",
+ "react-dom": "19.1.1",
+ "typescript": "5.9.3"
+ },
+ "peerDependencies": {
+ "react": "^19.0.0",
+ "react-dom": "^19.0.0"
+ },
+ "block-scripts": {
+ "devPort": 9090,
+ "servePort": 62682
+ },
+ "blockprotocol": {
+ "blockType": {
+ "entryPoint": "react"
+ },
+ "name": "@hash/paragraph",
+ "displayName": "Paragraph",
+ "icon": "public/paragraph.svg",
+ "image": "public/preview.svg",
+ "examples": [
+ {
+ "https://blockprotocol.org/@blockprotocol/types/property-type/textual-content/": "William Shakespeare was an English playwright, poet and actor, widely regarded as the greatest writer in the English language and the world's greatest dramatist. He is often called England's national poet and the \"Bard of Avon\"."
+ }
+ ],
+ "protocol": "0.3",
+ "blockEntityType": "https://blockprotocol.org/@hash/types/entity-type/paragraph-block/v/3",
+ "codegen": {
+ "outputFolder": "src/types/generated",
+ "targets": {
+ "block-entity.ts": [
+ {
+ "blockEntityType": true
+ }
+ ]
+ }
+ }
+ }
+}
diff --git a/blocks/paragraph/public/paragraph.svg b/blocks/paragraph/public/paragraph.svg
new file mode 100644
index 0000000..ca81c07
--- /dev/null
+++ b/blocks/paragraph/public/paragraph.svg
@@ -0,0 +1,3 @@
+
diff --git a/blocks/paragraph/public/preview.svg b/blocks/paragraph/public/preview.svg
new file mode 100644
index 0000000..c41354f
--- /dev/null
+++ b/blocks/paragraph/public/preview.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/blocks/paragraph/src/app.tsx b/blocks/paragraph/src/app.tsx
new file mode 100644
index 0000000..aa31fbf
--- /dev/null
+++ b/blocks/paragraph/src/app.tsx
@@ -0,0 +1,36 @@
+import type { BlockComponent } from "@blockprotocol/graph/react";
+import { useEntitySubgraph } from "@blockprotocol/graph/react";
+import { useHook, useHookBlockModule } from "@blockprotocol/hook/react";
+import { useRef } from "react";
+
+import { propertyIds } from "./property-ids";
+import type { BlockEntity } from "./types/generated/block-entity";
+
+export const App: BlockComponent = ({
+ graph: { blockEntitySubgraph },
+}) => {
+ const { rootEntity } = useEntitySubgraph(blockEntitySubgraph);
+ const ref = useRef(null);
+ /* @ts-expect-error -- @todo H-3839 hook package in BP repo needs updating for new ref type */
+ const { hookModule } = useHookBlockModule(ref);
+
+ useHook(
+ hookModule,
+ ref,
+ "text",
+ rootEntity.metadata.recordId.entityId,
+ [propertyIds.text],
+ (node) => {
+ const textualContent = rootEntity.properties[propertyIds.text];
+ // eslint-disable-next-line no-param-reassign
+ node.innerText = typeof textualContent === "string" ? textualContent : "";
+
+ return () => {
+ // eslint-disable-next-line no-param-reassign
+ node.innerText = "";
+ };
+ },
+ );
+
+ return ;
+};
diff --git a/blocks/paragraph/src/dev.tsx b/blocks/paragraph/src/dev.tsx
new file mode 100644
index 0000000..f189b9a
--- /dev/null
+++ b/blocks/paragraph/src/dev.tsx
@@ -0,0 +1,44 @@
+/**
+ * This is the entry point for developing and debugging.
+ * This file is not bundled with the block during the build process.
+ */
+import type { VersionedUrl } from "@blockprotocol/graph";
+import { MockBlockDock } from "mock-block-dock";
+import { createRoot } from "react-dom/client";
+
+import packageJSON from "../package.json";
+import Component from "./index";
+import { propertyIds } from "./property-ids";
+import type { BlockEntity } from "./types/generated/block-entity";
+
+const node = document.getElementById("app");
+
+const initialData: BlockEntity = {
+ metadata: {
+ entityTypeId: packageJSON.blockprotocol.blockEntityType as VersionedUrl,
+ recordId: {
+ entityId: "entity-paragraph",
+ editionId: "1",
+ },
+ },
+ properties: {
+ [propertyIds.text]: "Hello World!",
+ },
+};
+
+const App = () => (
+
+);
+
+createRoot(node!).render( );
diff --git a/blocks/paragraph/src/index.ts b/blocks/paragraph/src/index.ts
new file mode 100644
index 0000000..6eb172a
--- /dev/null
+++ b/blocks/paragraph/src/index.ts
@@ -0,0 +1,8 @@
+/* eslint-disable canonical/filename-no-index -- @todo rename file */
+
+/**
+ * Entrypoint of the Block Component.
+ */
+import { App } from "./app";
+
+export default App;
diff --git a/blocks/paragraph/src/property-ids.ts b/blocks/paragraph/src/property-ids.ts
new file mode 100644
index 0000000..d0cf3f7
--- /dev/null
+++ b/blocks/paragraph/src/property-ids.ts
@@ -0,0 +1,3 @@
+export const propertyIds = {
+ text: "https://blockprotocol.org/@blockprotocol/types/property-type/textual-content/" as const,
+};
diff --git a/blocks/paragraph/src/types/generated/block-entity.ts b/blocks/paragraph/src/types/generated/block-entity.ts
new file mode 100644
index 0000000..690a9cb
--- /dev/null
+++ b/blocks/paragraph/src/types/generated/block-entity.ts
@@ -0,0 +1,40 @@
+/**
+ * This file was automatically generated – do not edit it.
+ */
+
+import { Entity } from "@blockprotocol/graph";
+
+export type BlockEntity = ParagraphBlock;
+
+export type BlockEntityOutgoingLinkAndTarget =
+ ParagraphBlockOutgoingLinkAndTarget;
+
+/**
+ * An opaque, untyped JSON object
+ */
+export type ObjectDataType = {};
+
+export type ParagraphBlock = Entity;
+
+export type ParagraphBlockOutgoingLinkAndTarget = never;
+
+export type ParagraphBlockOutgoingLinksByLinkEntityTypeId = {};
+
+/**
+ * The block entity for the “Paragraph” block.
+ *
+ * See: https://blockprotocol.org/@hash/blocks/paragraph
+ */
+export type ParagraphBlockProperties = {
+ "https://blockprotocol.org/@blockprotocol/types/property-type/textual-content/"?: TextualContentPropertyValue;
+};
+
+/**
+ * An ordered sequence of characters
+ */
+export type TextDataType = string;
+
+/**
+ * The text material, information, or body, that makes up the content of this thing.
+ */
+export type TextualContentPropertyValue = TextDataType | ObjectDataType[];
diff --git a/blocks/paragraph/tsconfig.json b/blocks/paragraph/tsconfig.json
new file mode 100644
index 0000000..03676c9
--- /dev/null
+++ b/blocks/paragraph/tsconfig.json
@@ -0,0 +1,5 @@
+{
+ "extends": "@local/tsconfig/block.json",
+ "include": ["src"],
+ "exclude": ["node_modules"]
+}
diff --git a/blocks/paragraph/turbo.json b/blocks/paragraph/turbo.json
new file mode 100644
index 0000000..9d80ee7
--- /dev/null
+++ b/blocks/paragraph/turbo.json
@@ -0,0 +1,28 @@
+{
+ "extends": ["//"],
+ "tasks": {
+ "codegen": {
+ "inputs": ["./package.json"],
+ "outputs": ["./src/types/generated/**"]
+ },
+ "build": {
+ "dependsOn": ["^build", "codegen", "format"],
+ "outputs": ["./dist/**"]
+ },
+ "lint:tsc": {
+ "dependsOn": ["codegen"]
+ },
+ "format": {
+ "cache": false,
+ "dependsOn": ["codegen"]
+ },
+ "dev": {
+ "persistent": true,
+ "dependsOn": ["^build", "codegen"]
+ },
+ "serve": {
+ "persistent": true,
+ "dependsOn": ["build"]
+ }
+ }
+}
diff --git a/blocks/person/LICENSE-APACHE.md b/blocks/person/LICENSE-APACHE.md
new file mode 100644
index 0000000..1d1b6f8
--- /dev/null
+++ b/blocks/person/LICENSE-APACHE.md
@@ -0,0 +1,189 @@
+# Apache License
+
+_Version 2.0, January 2004_
+_< >_
+
+### Terms and Conditions for use, reproduction, and distribution
+
+#### 1. Definitions
+
+“License” shall mean the terms and conditions for use, reproduction, and
+distribution as defined by Sections 1 through 9 of this document.
+
+“Licensor” shall mean the copyright owner or entity authorized by the copyright
+owner that is granting the License.
+
+“Legal Entity” shall mean the union of the acting entity and all other entities
+that control, are controlled by, or are under common control with that entity.
+For the purposes of this definition, “control” means **(i)** the power, direct or
+indirect, to cause the direction or management of such entity, whether by
+contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the
+outstanding shares, or **(iii)** beneficial ownership of such entity.
+
+“You” (or “Your”) shall mean an individual or Legal Entity exercising
+permissions granted by this License.
+
+“Source” form shall mean the preferred form for making modifications, including
+but not limited to software source code, documentation source, and configuration
+files.
+
+“Object” form shall mean any form resulting from mechanical transformation or
+translation of a Source form, including but not limited to compiled object code,
+generated documentation, and conversions to other media types.
+
+“Work” shall mean the work of authorship, whether in Source or Object form, made
+available under the License, as indicated by a copyright notice that is included
+in or attached to the work (an example is provided in the Appendix below).
+
+“Derivative Works” shall mean any work, whether in Source or Object form, that
+is based on (or derived from) the Work and for which the editorial revisions,
+annotations, elaborations, or other modifications represent, as a whole, an
+original work of authorship. For the purposes of this License, Derivative Works
+shall not include works that remain separable from, or merely link (or bind by
+name) to the interfaces of, the Work and Derivative Works thereof.
+
+“Contribution” shall mean any work of authorship, including the original version
+of the Work and any modifications or additions to that Work or Derivative Works
+thereof, that is intentionally submitted to Licensor for inclusion in the Work
+by the copyright owner or by an individual or Legal Entity authorized to submit
+on behalf of the copyright owner. For the purposes of this definition,
+“submitted” means any form of electronic, verbal, or written communication sent
+to the Licensor or its representatives, including but not limited to
+communication on electronic mailing lists, source code control systems, and
+issue tracking systems that are managed by, or on behalf of, the Licensor for
+the purpose of discussing and improving the Work, but excluding communication
+that is conspicuously marked or otherwise designated in writing by the copyright
+owner as “Not a Contribution.”
+
+“Contributor” shall mean Licensor and any individual or Legal Entity on behalf
+of whom a Contribution has been received by Licensor and subsequently
+incorporated within the Work.
+
+#### 2. Grant of Copyright License
+
+Subject to the terms and conditions of this License, each Contributor hereby
+grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
+irrevocable copyright license to reproduce, prepare Derivative Works of,
+publicly display, publicly perform, sublicense, and distribute the Work and such
+Derivative Works in Source or Object form.
+
+#### 3. Grant of Patent License
+
+Subject to the terms and conditions of this License, each Contributor hereby
+grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
+irrevocable (except as stated in this section) patent license to make, have
+made, use, offer to sell, sell, import, and otherwise transfer the Work, where
+such license applies only to those patent claims licensable by such Contributor
+that are necessarily infringed by their Contribution(s) alone or by combination
+of their Contribution(s) with the Work to which such Contribution(s) was
+submitted. If You institute patent litigation against any entity (including a
+cross-claim or counterclaim in a lawsuit) alleging that the Work or a
+Contribution incorporated within the Work constitutes direct or contributory
+patent infringement, then any patent licenses granted to You under this License
+for that Work shall terminate as of the date such litigation is filed.
+
+#### 4. Redistribution
+
+You may reproduce and distribute copies of the Work or Derivative Works thereof
+in any medium, with or without modifications, and in Source or Object form,
+provided that You meet the following conditions:
+
+- **(a)** You must give any other recipients of the Work or Derivative Works a copy of
+ this License; and
+- **(b)** You must cause any modified files to carry prominent notices stating that You
+ changed the files; and
+- **(c)** You must retain, in the Source form of any Derivative Works that You distribute,
+ all copyright, patent, trademark, and attribution notices from the Source form
+ of the Work, excluding those notices that do not pertain to any part of the
+ Derivative Works; and
+- **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any
+ Derivative Works that You distribute must include a readable copy of the
+ attribution notices contained within such NOTICE file, excluding those notices
+ that do not pertain to any part of the Derivative Works, in at least one of the
+ following places: within a NOTICE text file distributed as part of the
+ Derivative Works; within the Source form or documentation, if provided along
+ with the Derivative Works; or, within a display generated by the Derivative
+ Works, if and wherever such third-party notices normally appear. The contents of
+ the NOTICE file are for informational purposes only and do not modify the
+ License. You may add Your own attribution notices within Derivative Works that
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
+ provided that such additional attribution notices cannot be construed as
+ modifying the License.
+
+You may add Your own copyright statement to Your modifications and may provide
+additional or different license terms and conditions for use, reproduction, or
+distribution of Your modifications, or for any such Derivative Works as a whole,
+provided Your use, reproduction, and distribution of the Work otherwise complies
+with the conditions stated in this License.
+
+#### 5. Submission of Contributions
+
+Unless You explicitly state otherwise, any Contribution intentionally submitted
+for inclusion in the Work by You to the Licensor shall be under the terms and
+conditions of this License, without any additional terms or conditions.
+Notwithstanding the above, nothing herein shall supersede or modify the terms of
+any separate license agreement you may have executed with Licensor regarding
+such Contributions.
+
+#### 6. Trademarks
+
+This License does not grant permission to use the trade names, trademarks,
+service marks, or product names of the Licensor, except as required for
+reasonable and customary use in describing the origin of the Work and
+reproducing the content of the NOTICE file.
+
+#### 7. Disclaimer of Warranty
+
+Unless required by applicable law or agreed to in writing, Licensor provides the
+Work (and each Contributor provides its Contributions) on an “AS IS” BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
+including, without limitation, any warranties or conditions of TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
+solely responsible for determining the appropriateness of using or
+redistributing the Work and assume any risks associated with Your exercise of
+permissions under this License.
+
+#### 8. Limitation of Liability
+
+In no event and under no legal theory, whether in tort (including negligence),
+contract, or otherwise, unless required by applicable law (such as deliberate
+and grossly negligent acts) or agreed to in writing, shall any Contributor be
+liable to You for damages, including any direct, indirect, special, incidental,
+or consequential damages of any character arising as a result of this License or
+out of the use or inability to use the Work (including but not limited to
+damages for loss of goodwill, work stoppage, computer failure or malfunction, or
+any and all other commercial damages or losses), even if such Contributor has
+been advised of the possibility of such damages.
+
+#### 9. Accepting Warranty or Additional Liability
+
+While redistributing the Work or Derivative Works thereof, You may choose to
+offer, and charge a fee for, acceptance of support, warranty, indemnity, or
+other liability obligations and/or rights consistent with this License. However,
+in accepting such obligations, You may act only on Your own behalf and on Your
+sole responsibility, not on behalf of any other Contributor, and only if You
+agree to indemnify, defend, and hold each Contributor harmless for any liability
+incurred by, or claims asserted against, such Contributor by reason of your
+accepting any such warranty or additional liability.
+
+_END OF TERMS AND CONDITIONS_
+
+### APPENDIX: Apply the Apache License to a specific file
+
+To apply the Apache License to an individual file, attach the following notice.
+The text should be enclosed in the appropriate comment syntax for the file
+format.
+
+ Copyright © 2022–, HASH
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/blocks/person/LICENSE-MIT.md b/blocks/person/LICENSE-MIT.md
new file mode 100644
index 0000000..e33c1d3
--- /dev/null
+++ b/blocks/person/LICENSE-MIT.md
@@ -0,0 +1,21 @@
+# MIT License
+
+Copyright © 2022–, HASH
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/blocks/person/LICENSE.md b/blocks/person/LICENSE.md
new file mode 100644
index 0000000..8686df9
--- /dev/null
+++ b/blocks/person/LICENSE.md
@@ -0,0 +1,5 @@
+# License
+
+Licensed under either of the [Apache License, Version 2.0](LICENSE-APACHE.md) or [MIT license](LICENSE-MIT.md) at your option.
+
+For more information about contributing to this block, see our top-level [CONTRIBUTING](https://github.com/hashintel/hash/blob/main/.github/CONTRIBUTING.md) policy.
diff --git a/blocks/person/README.md b/blocks/person/README.md
new file mode 100644
index 0000000..27dd039
--- /dev/null
+++ b/blocks/person/README.md
@@ -0,0 +1,12 @@
+The Person block displays useful information about a person.
+
+It accepts the following properties:
+
+- `name`
+- `avatar` (an image URL)
+- `email`
+- `employer`, with `name` and `position` sub-properties
+- `link` (a website URL)
+- `maxWidth`
+
+All of these properties are optional and the block's layout will adjust depending on which are provided.
diff --git a/blocks/person/eslint.config.js b/blocks/person/eslint.config.js
new file mode 100644
index 0000000..5b6bb9d
--- /dev/null
+++ b/blocks/person/eslint.config.js
@@ -0,0 +1,3 @@
+import { createBlock } from "@local/eslint/deprecated";
+
+export default createBlock(import.meta.dirname);
diff --git a/blocks/person/package.json b/blocks/person/package.json
new file mode 100644
index 0000000..1d32f68
--- /dev/null
+++ b/blocks/person/package.json
@@ -0,0 +1,72 @@
+{
+ "name": "@blocks/person",
+ "version": "0.2.1",
+ "private": true,
+ "description": "Display information about a person, including their name, job title, email, website address, and an avatar",
+ "keywords": [
+ "blockprotocol",
+ "blocks",
+ "block"
+ ],
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/hashintel/blocks.git#main",
+ "directory": "blocks/person"
+ },
+ "license": "(MIT OR Apache-2.0)",
+ "author": "HASH",
+ "type": "module",
+ "scripts": {
+ "build": "block-scripts build",
+ "dev": "block-scripts dev",
+ "fix:eslint": "eslint --fix .",
+ "lint:eslint": "eslint --report-unused-disable-directives .",
+ "lint:tsc": "tsc --noEmit",
+ "serve": "block-scripts serve"
+ },
+ "dependencies": {
+ "@blockprotocol/graph": "0.0.18",
+ "dompurify": "3.4.17"
+ },
+ "devDependencies": {
+ "@local/eslint": "0.0.0-private",
+ "@local/tsconfig": "0.0.0-private",
+ "@types/react-dom": "19.1.7",
+ "block-scripts": "0.0.14",
+ "eslint": "10.0.3",
+ "mock-block-dock": "0.0.38",
+ "react": "19.1.1",
+ "react-dom": "19.1.1",
+ "typescript": "5.9.3"
+ },
+ "peerDependencies": {
+ "react": "^19.0.0",
+ "react-dom": "^19.0.0"
+ },
+ "block-scripts": {
+ "devPort": 9090,
+ "servePort": 62692
+ },
+ "blockprotocol": {
+ "blockType": {
+ "entryPoint": "react"
+ },
+ "name": "@hash/person",
+ "displayName": "Person",
+ "icon": "public/account-circle.svg",
+ "image": "public/preview.svg",
+ "examples": [
+ {
+ "avatar": "https://i.pravatar.cc/300",
+ "employer": {
+ "name": "Bain & Co.",
+ "position": "General Manager of Insurance Claims"
+ },
+ "name": "Archibald Adams-Montgomery",
+ "email": "archie@example.com",
+ "link": "https://example.com/archie"
+ }
+ ],
+ "protocol": "0.2"
+ }
+}
diff --git a/blocks/person/public/account-circle.svg b/blocks/person/public/account-circle.svg
new file mode 100644
index 0000000..103d2f1
--- /dev/null
+++ b/blocks/person/public/account-circle.svg
@@ -0,0 +1,3 @@
+
diff --git a/blocks/person/public/preview.svg b/blocks/person/public/preview.svg
new file mode 100644
index 0000000..25438d3
--- /dev/null
+++ b/blocks/person/public/preview.svg
@@ -0,0 +1,13 @@
+