@blockprotocol/hook
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -33,3 +33,4 @@ import { RefObject } from "react"; | ||
* @param type The type of hook – i.e, "text" | ||
* @param path The path to the data associated with the hook | ||
* @param entityId The entityId of the entity on which to store data associated with the hook | ||
* @param path The path in the entity's properties to the data associated with the hook | ||
* @param fallback A fallback to be called if the embedding application doesn't | ||
@@ -40,2 +41,2 @@ * implement the hook service, or doesn't implement this | ||
*/ | ||
export declare const useHook: <T extends HTMLElement>(service: HookBlockHandler | null, ref: RefObject<void | T | null>, type: string, path: string, fallback: (node: T) => void | (() => void)) => void; | ||
export declare const useHook: <T extends HTMLElement>(service: HookBlockHandler | null, ref: RefObject<void | T | null>, type: string, entityId: string, path: string, fallback: (node: T) => void | (() => void)) => void; |
@@ -62,3 +62,4 @@ import { useEffect, useLayoutEffect, useRef, useState } from "react"; | ||
* @param type The type of hook – i.e, "text" | ||
* @param path The path to the data associated with the hook | ||
* @param entityId The entityId of the entity on which to store data associated with the hook | ||
* @param path The path in the entity's properties to the data associated with the hook | ||
* @param fallback A fallback to be called if the embedding application doesn't | ||
@@ -69,3 +70,3 @@ * implement the hook service, or doesn't implement this | ||
*/ | ||
export const useHook = (service, ref, type, path, fallback) => { | ||
export const useHook = (service, ref, type, entityId, path, fallback) => { | ||
/** | ||
@@ -118,2 +119,3 @@ * React can't catch async errors to handle them within ErrorBoundary's, etc, | ||
existingHook.node === node && | ||
existingHook.entityId === entityId && | ||
existingHook.path === path && | ||
@@ -133,2 +135,3 @@ existingHook.type === type) { | ||
existingHook.service === service && | ||
existingHook.entityId === entityId && | ||
existingHook.path === path && | ||
@@ -141,2 +144,3 @@ existingHook.type === type; | ||
type, | ||
entityId, | ||
path, | ||
@@ -161,2 +165,3 @@ node, | ||
hookId, | ||
entityId, | ||
path, | ||
@@ -187,2 +192,3 @@ type, | ||
hookId: hook.id, | ||
entityId, | ||
node, | ||
@@ -189,0 +195,0 @@ type, |
@@ -10,2 +10,3 @@ import { MessageCallback } from "@blockprotocol/core"; | ||
hookId: string | null; | ||
entityId: string; | ||
}; | ||
@@ -12,0 +13,0 @@ export declare type BlockHookMessageCallbacks = {}; |
{ | ||
"name": "@blockprotocol/hook", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Implementation of the Block Protocol Hook service specification for blocks and embedding applications", | ||
@@ -50,2 +50,4 @@ "keywords": [ | ||
"clean": "rimraf ./dist/", | ||
"fix:eslint": "eslint --fix .", | ||
"lint:eslint": "eslint .", | ||
"lint:tsc": "tsc --noEmit" | ||
@@ -57,3 +59,5 @@ }, | ||
"devDependencies": { | ||
"@local/eslint-config": "0.0.0-private", | ||
"@local/tsconfig": "0.0.0-private", | ||
"eslint": "8.24.0", | ||
"rimraf": "^3.0.2", | ||
@@ -60,0 +64,0 @@ "typescript": "4.8.2" |
## Block Protocol – Hook Service | ||
This package implements the Block Protocol Hraph service for blocks and embedding applications. | ||
This package implements the Block Protocol Hook service for blocks and embedding applications. | ||
@@ -23,6 +23,7 @@ To get started: | ||
data: { | ||
blockId: "hookId", | ||
node, | ||
type: "text", | ||
path: "$.text", | ||
hookId: null, // the embedding application will provide a hookId in response to use in future messages | ||
node, // a reference to the DOM node to render into | ||
type: "text", // the type of hook | ||
entityId: "entity1", // the id of the entity this hook will show/edit data for | ||
path: "$.text", // the path in the entity's properties data will be taken from/saved to | ||
}, | ||
@@ -29,0 +30,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
80615
19
436
122
5