Skip to content

📦️(monorepo) create Docs package #1285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ COPY ./src/frontend/package.json ./package.json
COPY ./src/frontend/yarn.lock ./yarn.lock
COPY ./src/frontend/apps/impress/package.json ./apps/impress/package.json
COPY ./src/frontend/packages/eslint-config-impress/package.json ./packages/eslint-config-impress/package.json
COPY ./src/frontend/packages/common/package.json ./packages/common/package.json

RUN yarn install --frozen-lockfile

COPY .dockerignore ./.dockerignore
COPY ./src/frontend/.prettierrc.js ./.prettierrc.js
COPY ./src/frontend/packages/eslint-config-impress ./packages/eslint-config-impress
COPY ./src/frontend/packages/common ./packages/common
COPY ./src/frontend/apps/impress ./apps/impress

### ---- Front-end builder image ----
Expand Down
1 change: 1 addition & 0 deletions src/frontend/apps/impress/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const buildId = crypto.randomBytes(256).toString('hex').slice(0, 8);
const nextConfig = {
output: 'export',
trailingSlash: true,
transpilePackages: ['package-docs'],
images: {
unoptimized: true,
},
Expand Down
1 change: 1 addition & 0 deletions src/frontend/apps/impress/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"lodash": "4.17.21",
"luxon": "3.7.1",
"next": "15.4.6",
"package-docs": "*",
"posthog-js": "1.258.6",
"react": "*",
"react-aria-components": "1.11.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { BlockNoteView } from '@blocknote/mantine';
import '@blocknote/mantine/style.css';
import { useCreateBlockNote } from '@blocknote/react';
import { HocuspocusProvider } from '@hocuspocus/provider';
import { createDividerBlock } from 'package-docs';
import { useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import * as Y from 'yjs';
Expand All @@ -33,7 +34,7 @@ import { randomColor } from '../utils';

import { BlockNoteSuggestionMenu } from './BlockNoteSuggestionMenu';
import { BlockNoteToolbar } from './BlockNoteToolBar/BlockNoteToolbar';
import { CalloutBlock, DividerBlock } from './custom-blocks';
import { CalloutBlock } from './custom-blocks';
import {
InterlinkingLinkInlineContent,
InterlinkingSearchInlineContent,
Expand All @@ -49,7 +50,9 @@ const baseBlockNoteSchema = withPageBreak(
blockSpecs: {
...defaultBlockSpecs,
callout: CalloutBlock,
divider: DividerBlock,
divider: createDividerBlock({
color: 'var(--c--theme--colors--greyscale-300)',
}),
},
inlineContentSpecs: {
...defaultInlineContentSpecs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ import {
useBlockNoteEditor,
useDictionary,
} from '@blocknote/react';
import { getDividerReactSlashMenuItems } from 'package-docs';
import React, { useMemo } from 'react';
import { useTranslation } from 'react-i18next';

import { Icon } from '@/components';

import {
DocsBlockSchema,
DocsInlineContentSchema,
DocsStyleSchema,
} from '../types';

import {
getCalloutReactSlashMenuItems,
getDividerReactSlashMenuItems,
} from './custom-blocks';
import { getCalloutReactSlashMenuItems } from './custom-blocks';
import { useGetInterlinkingMenuItems } from './custom-inline-content';
import XLMultiColumn from './xl-multi-column';

Expand Down Expand Up @@ -55,7 +55,12 @@ export const BlockNoteSuggestionMenu = () => {
getCalloutReactSlashMenuItems(editor, t, basicBlocksName),
getMultiColumnSlashMenuItems?.(editor) || [],
getPageBreakReactSlashMenuItems(editor),
getDividerReactSlashMenuItems(editor, t, basicBlocksName),
getDividerReactSlashMenuItems(
editor,
t,
basicBlocksName,
<Icon iconName="remove" $size="18px" />,
),
),
query,
),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './CalloutBlock';
export * from './DividerBlock';
3 changes: 2 additions & 1 deletion src/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
"APP_IMPRESS": "yarn workspace app-impress",
"APP_E2E": "yarn workspace app-e2e",
"I18N": "yarn workspace packages-i18n",
"COMMON": "yarn workspace package-docs",
"COLLABORATION_SERVER": "yarn workspace server-y-provider",
"app:dev": "yarn APP_IMPRESS run dev",
"app:start": "yarn APP_IMPRESS run start",
"app:build": "yarn APP_IMPRESS run build",
"app:test": "yarn APP_IMPRESS run test",
"ci:build": "yarn APP_IMPRESS run build:ci",
"e2e:test": "yarn APP_E2E run test",
"lint": "yarn APP_IMPRESS run lint && yarn APP_E2E run lint && yarn workspace eslint-config-impress run lint && yarn I18N run lint && yarn COLLABORATION_SERVER run lint",
"lint": "yarn APP_IMPRESS run lint && yarn APP_E2E run lint && yarn workspace eslint-config-impress run lint && yarn I18N run lint && yarn COMMON run lint && yarn COLLABORATION_SERVER run lint",
"i18n:extract": "yarn I18N run extract-translation",
"i18n:deploy": "yarn I18N run format-deploy && yarn APP_IMPRESS prettier",
"i18n:test": "yarn I18N run test",
Expand Down
14 changes: 14 additions & 0 deletions src/frontend/packages/common/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
root: true,
extends: ['impress/next'],
parserOptions: {
sourceType: 'module',
ecmaVersion: 'latest',
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
},
rules: {
'@next/next/no-html-link-for-pages': 'off',
},
ignorePatterns: ['node_modules'],
};
20 changes: 20 additions & 0 deletions src/frontend/packages/common/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "package-docs",
"version": "3.5.0",
"license": "MIT",
"main": "src/index.ts",
"types": "src/index.ts",
"scripts": {
"lint": "eslint --ext .ts,.tsx src/"
},
"peerDependencies": {
"@blocknote/core": "0.35.0",
"@blocknote/react": "0.35.0",
"react": "19.1.0",
"react-dom": "19.1.0"
},
"devDependencies": {
"eslint-config-impress": "*",
"typescript": "*"
}
}
52 changes: 52 additions & 0 deletions src/frontend/packages/common/src/custom-blocks/DividerBlock.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { BlockNoteEditor, insertOrUpdateBlock } from '@blocknote/core';
import { createReactBlockSpec } from '@blocknote/react';
import { TFunction } from 'i18next';

interface DividerBlockProps {
color?: string;
}

export const createDividerBlock = ({ color }: DividerBlockProps) => {
return createReactBlockSpec(
{
type: 'divider',
propSchema: {},
content: 'none',
},
{
render: () => {
return (
<hr
style={{
width: '100%',
background: color,
margin: '1rem 0',
border: `1px solid ${color}`,
}}
/>
);
},
},
);
};

export const getDividerReactSlashMenuItems = (
// eslint-disable-next-line @typescript-eslint/no-explicit-any
editor: BlockNoteEditor<any, any, any>,
t: TFunction<'translation', undefined>,
group: string,
icon: React.ReactNode,
) => [
{
title: t('Divider'),
onItemClick: () => {
insertOrUpdateBlock(editor, {
type: 'divider',
});
},
aliases: ['divider', 'hr', 'horizontal rule', 'line', 'separator'],
group,
icon,
subtext: t('Add a horizontal line'),
},
];
1 change: 1 addition & 0 deletions src/frontend/packages/common/src/custom-blocks/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './DividerBlock';
1 change: 1 addition & 0 deletions src/frontend/packages/common/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './custom-blocks/';
28 changes: 28 additions & 0 deletions src/frontend/packages/common/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules",
"dist"
]
}
2 changes: 2 additions & 0 deletions src/frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15113,3 +15113,5 @@ zwitch@^2.0.0, zwitch@^2.0.4:
version "2.0.4"
resolved "https://registry.yarnpkg.com/zwitch/-/zwitch-2.0.4.tgz#c827d4b0acb76fc3e685a4c6ec2902d51070e9d7"
integrity sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==

# Force cache refresh for packages/common-package workspace linking
Loading