Skip to content
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

feat: Revive attachment-refs with remark #7597

Merged
merged 24 commits into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
66fa348
refs 120355: enable plugin attachment refs
arafubeatbox Apr 17, 2023
6f261df
refs 120355: make plugin attachment reffs runnable
arafubeatbox Apr 18, 2023
4e3af3c
Merge branch 'master' into feat/112904-120355-enable-attachment-refs
arafubeatbox Apr 19, 2023
3662742
refs 120355: rename plugin-attachment-reefs to remark-attachment-refs
arafubeatbox Apr 19, 2023
8411984
refs 120355: enable attachment refs routes
arafubeatbox Apr 20, 2023
b54ae56
Merge branch 'master' into feat/112904-120355-enable-attachment-refs
arafubeatbox Apr 20, 2023
9dd7343
refs 120355: render Ref
arafubeatbox Apr 21, 2023
dd61fa4
refs 120355: fix Ref
arafubeatbox Apr 21, 2023
20dc791
refs 120355: RefImg
arafubeatbox Apr 21, 2023
5f67229
refs 120355: complete RefImg
arafubeatbox Apr 21, 2023
c529c44
refs 120355: Refs
arafubeatbox Apr 22, 2023
617c92f
refs 120355: RefsImg
arafubeatbox Apr 22, 2023
0a43425
refs 120355: fix prefix
arafubeatbox Apr 22, 2023
2256f2c
refs 120355: Gallery
arafubeatbox Apr 22, 2023
494f7e2
refs 120355: refactor
arafubeatbox Apr 22, 2023
ebdeaf0
refs 120355: remove unnecessary files
arafubeatbox Apr 22, 2023
be2e064
refs 120355: update version
arafubeatbox Apr 22, 2023
245206c
refs 120355: fix col bug
arafubeatbox Apr 23, 2023
0fcd38d
refs 120355: comment out image carousel code
arafubeatbox Apr 23, 2023
43a4bd4
refs 120355: fix path resolve logic
arafubeatbox Apr 23, 2023
d01d5fe
refs 120355: fix gallery
arafubeatbox Apr 23, 2023
4fb496e
refs 120355: refactor
arafubeatbox Apr 24, 2023
3be5001
refs 120355: remove unnecessary packages
arafubeatbox Apr 24, 2023
68ce6a3
refs 120355: apply FB
arafubeatbox Apr 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"@google-cloud/storage": "^5.8.5",
"@growi/core": "^6.1.0-RC.0",
"@growi/hackmd": "^6.1.0-RC.0",
"@growi/remark-attachment-refs": "^6.1.0-RC.0",
"@growi/preset-themes": "^6.1.0-RC.0",
"@growi/remark-drawio": "^6.1.0-RC.0",
"@growi/remark-growi-directive": "^6.1.0-RC.0",
Expand Down
25 changes: 25 additions & 0 deletions apps/app/src/client/services/renderer/renderer.tsx
yuki-takei marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import assert from 'assert';

import { isClient } from '@growi/core/dist/utils/browser-utils';
import * as refsGrowiPlugin from '@growi/remark-attachment-refs/dist/client/index.mjs';
import * as drawioPlugin from '@growi/remark-drawio';
// eslint-disable-next-line import/extensions
import * as lsxGrowiPlugin from '@growi/remark-lsx/dist/client/index.mjs';
Expand Down Expand Up @@ -58,6 +59,7 @@ export const generateViewOptions = (
drawioPlugin.remarkPlugin,
xsvToTable.remarkPlugin,
lsxGrowiPlugin.remarkPlugin,
refsGrowiPlugin.remarkPlugin,
);
if (config.isEnabledLinebreaks) {
remarkPlugins.push(breaks);
Expand All @@ -72,13 +74,15 @@ export const generateViewOptions = (
commonSanitizeOption,
drawioPlugin.sanitizeOption,
lsxGrowiPlugin.sanitizeOption,
refsGrowiPlugin.sanitizeOption,
)]
: () => {};

// add rehype plugins
rehypePlugins.push(
slug,
[lsxGrowiPlugin.rehypePlugin, { pagePath, isSharedPage: config.isSharedPage }],
[refsGrowiPlugin.rehypePlugin, { pagePath }],
rehypeSanitizePlugin,
katex,
[relocateToc.rehypePluginStore, { storeTocNode }],
Expand All @@ -93,6 +97,11 @@ export const generateViewOptions = (
components.h5 = Header;
components.h6 = Header;
components.lsx = lsxGrowiPlugin.Lsx;
components.ref = refsGrowiPlugin.Ref;
components.refs = refsGrowiPlugin.Refs;
components.refimg = refsGrowiPlugin.RefImg;
components.refsimg = refsGrowiPlugin.RefsImg;
components.gallery = refsGrowiPlugin.Gallery;
components.drawio = DrawioViewerWithEditButton;
components.table = TableWithEditButton;
}
Expand Down Expand Up @@ -153,6 +162,7 @@ export const generateSimpleViewOptions = (
drawioPlugin.remarkPlugin,
xsvToTable.remarkPlugin,
lsxGrowiPlugin.remarkPlugin,
refsGrowiPlugin.remarkPlugin,
);

const isEnabledLinebreaks = overrideIsEnabledLinebreaks ?? config.isEnabledLinebreaks;
Expand All @@ -171,12 +181,14 @@ export const generateSimpleViewOptions = (
commonSanitizeOption,
drawioPlugin.sanitizeOption,
lsxGrowiPlugin.sanitizeOption,
refsGrowiPlugin.sanitizeOption,
)]
: () => {};

// add rehype plugins
rehypePlugins.push(
[lsxGrowiPlugin.rehypePlugin, { pagePath, isSharedPage: config.isSharedPage }],
[refsGrowiPlugin.rehypePlugin, { pagePath }],
[keywordHighlighter.rehypePlugin, { keywords: highlightKeywords }],
rehypeSanitizePlugin,
katex,
Expand All @@ -185,6 +197,11 @@ export const generateSimpleViewOptions = (
// add components
if (components != null) {
components.lsx = lsxGrowiPlugin.LsxImmutable;
components.ref = refsGrowiPlugin.RefImmutable;
components.refs = refsGrowiPlugin.RefsImmutable;
components.refimg = refsGrowiPlugin.RefImgImmutable;
components.refsimg = refsGrowiPlugin.RefsImgImmutable;
components.gallery = refsGrowiPlugin.GalleryImmutable;
components.drawio = drawioPlugin.DrawioViewer;
}

Expand Down Expand Up @@ -219,6 +236,7 @@ export const generatePreviewOptions = (config: RendererConfig, pagePath: string)
drawioPlugin.remarkPlugin,
xsvToTable.remarkPlugin,
lsxGrowiPlugin.remarkPlugin,
refsGrowiPlugin.remarkPlugin,
);
if (config.isEnabledLinebreaks) {
remarkPlugins.push(breaks);
Expand All @@ -232,6 +250,7 @@ export const generatePreviewOptions = (config: RendererConfig, pagePath: string)
? [sanitize, deepmerge(
commonSanitizeOption,
lsxGrowiPlugin.sanitizeOption,
refsGrowiPlugin.sanitizeOption,
drawioPlugin.sanitizeOption,
addLineNumberAttribute.sanitizeOption,
)]
Expand All @@ -240,6 +259,7 @@ export const generatePreviewOptions = (config: RendererConfig, pagePath: string)
// add rehype plugins
rehypePlugins.push(
[lsxGrowiPlugin.rehypePlugin, { pagePath, isSharedPage: config.isSharedPage }],
[refsGrowiPlugin.rehypePlugin, { pagePath }],
addLineNumberAttribute.rehypePlugin,
rehypeSanitizePlugin,
katex,
Expand All @@ -248,6 +268,11 @@ export const generatePreviewOptions = (config: RendererConfig, pagePath: string)
// add components
if (components != null) {
components.lsx = lsxGrowiPlugin.LsxImmutable;
components.ref = refsGrowiPlugin.RefImmutable;
components.refs = refsGrowiPlugin.RefsImmutable;
components.refimg = refsGrowiPlugin.RefImgImmutable;
components.refsimg = refsGrowiPlugin.RefsImgImmutable;
components.gallery = refsGrowiPlugin.GalleryImmutable;
components.drawio = drawioPlugin.DrawioViewer;
}

Expand Down
2 changes: 2 additions & 0 deletions apps/app/src/server/crowi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import http from 'http';
import path from 'path';

import { createTerminus } from '@godaddy/terminus';
import attachmentRoutes from '@growi/remark-attachment-refs/dist/server';
import lsxRoutes from '@growi/remark-lsx/dist/server';
import mongoose from 'mongoose';
import next from 'next';
Expand Down Expand Up @@ -531,6 +532,7 @@ Crowi.prototype.setupTerminus = function(server) {

Crowi.prototype.setupRoutesForPlugins = function() {
lsxRoutes(this, this.express);
attachmentRoutes(this, this.express);
};

/**
Expand Down
2 changes: 1 addition & 1 deletion apps/app/src/server/models/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ schema.statics.findByIdsAndViewer = async function(
};

/*
* Find a page by path and viewer. Pass false to useFindOne to use findOne method.
* Find a page by path and viewer. Pass true to useFindOne to use findOne method.
*/
schema.statics.findByPathAndViewer = async function(
path: string | null, user, userGroups = null, useFindOne = false, includeEmpty = false,
Expand Down
10 changes: 0 additions & 10 deletions packages-obsolete/plugin-attachment-refs/src/client-entry.js

This file was deleted.

28 changes: 0 additions & 28 deletions packages-obsolete/plugin-attachment-refs/src/client/css/index.css

This file was deleted.

This file was deleted.