rotion 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/exporter/blocks.js +4 -1
  2. package/dist/exporter/blocks.js.map +1 -1
  3. package/dist/exporter/breadcrumbs.d.ts +2 -7
  4. package/dist/exporter/breadcrumbs.js +91 -82
  5. package/dist/exporter/breadcrumbs.js.map +1 -1
  6. package/dist/exporter/types.d.ts +9 -1
  7. package/dist/ui/cjs/index.js +42 -12
  8. package/dist/ui/cjs/index.js.map +1 -1
  9. package/dist/ui/cjs/types/exporter/breadcrumbs.d.ts +2 -7
  10. package/dist/ui/cjs/types/exporter/types.d.ts +9 -1
  11. package/dist/ui/cjs/types/ui/components/Page/BreadcrumbBlock/BreadcrumbBlock.d.ts +1 -1
  12. package/dist/ui/cjs/types/ui/components/Page/BreadcrumbBlock/BreadcrumbBlock.types.d.ts +16 -2
  13. package/dist/ui/cjs/types/ui/components/Page/Page.d.ts +1 -1
  14. package/dist/ui/cjs/types/ui/components/Page/Page.types.d.ts +1 -0
  15. package/dist/ui/cjs/types/ui/components/Page/PageHandler.d.ts +1 -1
  16. package/dist/ui/cjs/types/ui/components/Page/PageHandler.types.d.ts +1 -0
  17. package/dist/ui/esm/index.js +42 -12
  18. package/dist/ui/esm/index.js.map +1 -1
  19. package/dist/ui/esm/types/exporter/breadcrumbs.d.ts +2 -7
  20. package/dist/ui/esm/types/exporter/types.d.ts +9 -1
  21. package/dist/ui/esm/types/ui/components/Page/BreadcrumbBlock/BreadcrumbBlock.d.ts +1 -1
  22. package/dist/ui/esm/types/ui/components/Page/BreadcrumbBlock/BreadcrumbBlock.types.d.ts +16 -2
  23. package/dist/ui/esm/types/ui/components/Page/Page.d.ts +1 -1
  24. package/dist/ui/esm/types/ui/components/Page/Page.types.d.ts +1 -0
  25. package/dist/ui/esm/types/ui/components/Page/PageHandler.d.ts +1 -1
  26. package/dist/ui/esm/types/ui/components/Page/PageHandler.types.d.ts +1 -0
  27. package/dist/ui/styles/page.css +27 -0
  28. package/dist/ui/types.d.ts +17 -5
  29. package/dist/ui/umd/index.js +42 -12
  30. package/dist/ui/umd/index.js.map +1 -1
  31. package/dist/ui/umd/types/exporter/breadcrumbs.d.ts +2 -7
  32. package/dist/ui/umd/types/exporter/types.d.ts +9 -1
  33. package/dist/ui/umd/types/ui/components/Page/BreadcrumbBlock/BreadcrumbBlock.d.ts +1 -1
  34. package/dist/ui/umd/types/ui/components/Page/BreadcrumbBlock/BreadcrumbBlock.types.d.ts +16 -2
  35. package/dist/ui/umd/types/ui/components/Page/Page.d.ts +1 -1
  36. package/dist/ui/umd/types/ui/components/Page/Page.types.d.ts +1 -0
  37. package/dist/ui/umd/types/ui/components/Page/PageHandler.d.ts +1 -1
  38. package/dist/ui/umd/types/ui/components/Page/PageHandler.types.d.ts +1 -0
  39. package/package.json +1 -1
@@ -1,12 +1,7 @@
1
- import type { MentionIcon } from './types.js';
1
+ import type { Breadcrumb } from './types.js';
2
2
  export interface FetchBreadcrumbsProps {
3
3
  type: 'page_id' | 'database_id' | 'block_id' | 'workspace';
4
4
  id: string;
5
5
  limit?: number;
6
6
  }
7
- export type BreadcrumbsIcon = MentionIcon;
8
- export interface Breadcrumbs {
9
- name: string;
10
- icon: BreadcrumbsIcon;
11
- }
12
- export declare const FetchBreadcrumbs: ({ type, id, limit }: FetchBreadcrumbsProps) => Promise<Breadcrumbs[]>;
7
+ export declare const FetchBreadcrumbs: ({ type, id, limit }: FetchBreadcrumbsProps) => Promise<Breadcrumb[]>;
@@ -208,7 +208,15 @@ export type ParagraphBlockObjectResponseEx = ParagraphBlockObjectResponse & {
208
208
  color: SelectColor;
209
209
  };
210
210
  };
211
- export type BlockObjectResponse = ParagraphBlockObjectResponseEx | Heading1BlockObjectResponse | Heading2BlockObjectResponse | Heading3BlockObjectResponse | BulletedListItemBlockObjectResponseEx | NumberedListItemBlockObjectResponseEx | QuoteBlockObjectResponse | ToDoBlockObjectResponse | ToggleBlockObjectResponseEx | TemplateBlockObjectResponse | SyncedBlockBlockObjectResponse | ChildPageBlockObjectResponseEx | ChildDatabaseBlockObjectResponseEx | EquationBlockObjectResponse | CodeBlockObjectResponse | CalloutBlockObjectResponseEx | DividerBlockObjectResponse | BreadcrumbBlockObjectResponse | TableOfContentsBlockObjectResponse | ColumnListBlockObjectResponseEx | ColumnBlockObjectResponse | LinkToPageBlockObjectResponse | TableBlockObjectResponseEx | TableRowBlockObjectResponse | EmbedBlockObjectResponseEx | BookmarkBlockObjectResponseEx | ImageBlockObjectResponseEx | VideoBlockObjectResponseEx | PdfBlockObjectResponse | FileBlockObjectResponse | AudioBlockObjectResponse | LinkPreviewBlockObjectResponse | UnsupportedBlockObjectResponse;
211
+ export type Breadcrumb = {
212
+ id: string;
213
+ name: string;
214
+ icon: MentionIcon;
215
+ };
216
+ export type BreadcrumbBlockObjectResponseEx = BreadcrumbBlockObjectResponse & {
217
+ list: Breadcrumb[];
218
+ };
219
+ export type BlockObjectResponse = ParagraphBlockObjectResponseEx | Heading1BlockObjectResponse | Heading2BlockObjectResponse | Heading3BlockObjectResponse | BulletedListItemBlockObjectResponseEx | NumberedListItemBlockObjectResponseEx | QuoteBlockObjectResponse | ToDoBlockObjectResponse | ToggleBlockObjectResponseEx | TemplateBlockObjectResponse | SyncedBlockBlockObjectResponse | ChildPageBlockObjectResponseEx | ChildDatabaseBlockObjectResponseEx | EquationBlockObjectResponse | CodeBlockObjectResponse | CalloutBlockObjectResponseEx | DividerBlockObjectResponse | BreadcrumbBlockObjectResponseEx | TableOfContentsBlockObjectResponse | ColumnListBlockObjectResponseEx | ColumnBlockObjectResponse | LinkToPageBlockObjectResponse | TableBlockObjectResponseEx | TableRowBlockObjectResponse | EmbedBlockObjectResponseEx | BookmarkBlockObjectResponseEx | ImageBlockObjectResponseEx | VideoBlockObjectResponseEx | PdfBlockObjectResponse | FileBlockObjectResponse | AudioBlockObjectResponse | LinkPreviewBlockObjectResponse | UnsupportedBlockObjectResponse;
212
220
  export type ListBlockChildrenResponseEx = ListBlockChildrenResponse & {
213
221
  results: Array<BlockObjectResponse>;
214
222
  children?: ListBlockChildrenResponse;
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import type { BreadcrumbBlockProps } from './BreadcrumbBlock.types';
3
- declare const BreadcrumbBlock: ({ block }: BreadcrumbBlockProps) => React.JSX.Element;
3
+ declare const BreadcrumbBlock: ({ block, link, hrefs, query }: BreadcrumbBlockProps) => React.JSX.Element;
4
4
  export default BreadcrumbBlock;
@@ -1,4 +1,18 @@
1
- import type { BreadcrumbBlockObjectResponse } from '../../../../exporter';
1
+ /// <reference types="node" />
2
+ import type { ReactNode } from 'react';
3
+ import type { ParsedUrlQueryInput } from 'node:querystring';
4
+ import type { Link } from '../../types';
5
+ import type { Breadcrumb, BreadcrumbBlockObjectResponseEx } from '../../../../exporter';
6
+ export interface BreadcrumbLinkProps {
7
+ breadcrumb: Breadcrumb;
8
+ link?: Link;
9
+ href?: string;
10
+ query?: ParsedUrlQueryInput;
11
+ children?: ReactNode;
12
+ }
2
13
  export interface BreadcrumbBlockProps {
3
- block: BreadcrumbBlockObjectResponse;
14
+ block: BreadcrumbBlockObjectResponseEx;
15
+ link?: Link;
16
+ hrefs?: string[];
17
+ query?: ParsedUrlQueryInput;
4
18
  }
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import type { PageProps } from './Page.types';
3
- export declare const Page: ({ blocks, href, link, query, modules }: PageProps) => React.JSX.Element;
3
+ export declare const Page: ({ blocks, href, link, query, modules, breadcrumb_hrefs }: PageProps) => React.JSX.Element;
4
4
  export default Page;
@@ -8,6 +8,7 @@ export interface PageProps {
8
8
  link?: Link;
9
9
  query?: ParsedUrlQueryInput;
10
10
  modules?: ExternalModules;
11
+ breadcrumb_hrefs?: string[];
11
12
  }
12
13
  export interface ListType {
13
14
  [key: string]: string;
@@ -11,5 +11,5 @@ export declare const blockType: {
11
11
  code: string;
12
12
  quote: string;
13
13
  };
14
- export declare const PageHandler: ({ block, href, link, query, modules }: HandlerProps) => React.JSX.Element;
14
+ export declare const PageHandler: ({ block, href, link, query, modules, breadcrumb_hrefs }: HandlerProps) => React.JSX.Element;
15
15
  export default PageHandler;
@@ -8,4 +8,5 @@ export interface HandlerProps {
8
8
  link?: Link;
9
9
  query?: ParsedUrlQueryInput;
10
10
  modules?: ExternalModules;
11
+ breadcrumb_hrefs?: string[];
11
12
  }
@@ -19313,11 +19313,42 @@ var BookmarkBlock = function (_a) {
19313
19313
  React.createElement(TextBlock, { tag: "span", block: block.bookmark.caption }))));
19314
19314
  };
19315
19315
 
19316
- // TODO: Iimplement and design
19316
+ function buildPathname(id, name, href) {
19317
+ if (href === '/') {
19318
+ return href;
19319
+ }
19320
+ var _a = getLinkPathAndLinkKey(href || ''), path = _a[0], slugKey = _a[1];
19321
+ var file = '';
19322
+ if (slugKey === 'id') {
19323
+ file = id;
19324
+ }
19325
+ else {
19326
+ file = encodeURIComponent(name.toLowerCase()).replace(/%20/g, '-');
19327
+ }
19328
+ return "".concat(path).concat(file);
19329
+ }
19330
+ var BreadcrumbLink = function (_a) {
19331
+ var breadcrumb = _a.breadcrumb, link = _a.link, href = _a.href, query = _a.query, children = _a.children;
19332
+ var id = breadcrumb.id, name = breadcrumb.name;
19333
+ var pathname = buildPathname(id, name, href);
19334
+ if (link && href) {
19335
+ var Link = link;
19336
+ return (React.createElement(Link, { className: "notionate-blocks-breadcrumb-a", href: { pathname: pathname, query: query } }, children));
19337
+ }
19338
+ if (href) {
19339
+ return (React.createElement("a", { className: "notionate-blocks-breadcrumb-a", href: "".concat(pathname).concat(queryToString(query)) }, children));
19340
+ }
19341
+ return (React.createElement("span", { className: "notionate-blocks-breadcrumb-a" }, children));
19342
+ };
19317
19343
  var BreadcrumbBlock = function (_a) {
19318
- var block = _a.block;
19319
- var parent = block.parent;
19320
- return (React.createElement("div", { className: "notionate-blocks-breadcrumb" }, parent.type));
19344
+ var block = _a.block, link = _a.link, hrefs = _a.hrefs, query = _a.query;
19345
+ var max = block.list.length;
19346
+ return (React.createElement("div", { className: "notionate-blocks-breadcrumb" }, block.list.map(function (v, i) { return (React.createElement(React.Fragment, null,
19347
+ React.createElement(BreadcrumbLink, { key: "crumb-".concat(i), breadcrumb: v, href: hrefs === undefined ? undefined : hrefs[i], link: link, query: query },
19348
+ v.icon.type === 'emoji' && React.createElement("span", { className: "notionate-blocks-breadcrumb-emoji" }, v.icon.emoji),
19349
+ v.icon.type !== 'emoji' && React.createElement("img", { className: "notionate-blocks-breadcrumb-icon", src: v.icon.src, width: 20, height: 20, alt: v.name }),
19350
+ React.createElement("span", { className: "notionate-blocks-breadcrumb-title" }, v.name)),
19351
+ i + 1 < max && React.createElement("span", { className: "notionate-blocks-breadcrumb-slash" }, "/"))); })));
19321
19352
  };
19322
19353
 
19323
19354
  var BulletedListBlocks = function (_a) {
@@ -19814,9 +19845,9 @@ var VideoBlock = function (_a) {
19814
19845
  };
19815
19846
 
19816
19847
  var blockType = {
19817
- heading_1: 'h1',
19818
- heading_2: 'h2',
19819
- heading_3: 'h3',
19848
+ heading_1: 'h2',
19849
+ heading_2: 'h3',
19850
+ heading_3: 'h4',
19820
19851
  bulleted_list_item: 'li',
19821
19852
  numbered_list_item: 'li',
19822
19853
  divider: 'hr',
@@ -19826,13 +19857,12 @@ var blockType = {
19826
19857
  };
19827
19858
  var PageHandler = function (_a) {
19828
19859
  var _b;
19829
- var block = _a.block, href = _a.href, link = _a.link, query = _a.query, modules = _a.modules;
19860
+ var block = _a.block, href = _a.href, link = _a.link, query = _a.query, modules = _a.modules, breadcrumb_hrefs = _a.breadcrumb_hrefs;
19830
19861
  switch (block.type) {
19831
19862
  case 'bookmark':
19832
19863
  return React.createElement(BookmarkBlock, { block: block, key: block.id });
19833
19864
  case 'breadcrumb':
19834
- console.log("still a not supported component: ".concat(block.type));
19835
- return React.createElement(BreadcrumbBlock, { block: block, key: block.id });
19865
+ return React.createElement(BreadcrumbBlock, { block: block, hrefs: breadcrumb_hrefs, link: link, query: query, key: block.id });
19836
19866
  case 'bulleted_list_item':
19837
19867
  return React.createElement(BulletedListBlocks, { block: block, key: block.id });
19838
19868
  case 'callout':
@@ -19904,7 +19934,7 @@ var ListBlock = function (_a) {
19904
19934
  };
19905
19935
 
19906
19936
  var Page = function (_a) {
19907
- var blocks = _a.blocks, href = _a.href, link = _a.link, query = _a.query, modules = _a.modules;
19937
+ var blocks = _a.blocks, href = _a.href, link = _a.link, query = _a.query, modules = _a.modules, breadcrumb_hrefs = _a.breadcrumb_hrefs;
19908
19938
  var results = blocks.results;
19909
19939
  var listType = {
19910
19940
  bulleted_list_item: 'ul',
@@ -19939,7 +19969,7 @@ var Page = function (_a) {
19939
19969
  }
19940
19970
  }
19941
19971
  else {
19942
- var elem = PageHandler({ block: block, href: href, link: link, query: query, modules: modules });
19972
+ var elem = PageHandler({ block: block, href: href, link: link, query: query, modules: modules, breadcrumb_hrefs: breadcrumb_hrefs });
19943
19973
  if (elem !== undefined) {
19944
19974
  children.push(elem);
19945
19975
  }