Futa Arai 2 лет назад
Родитель
Сommit
d01d5fe924

+ 8 - 3
packages/remark-attachment-refs/src/client/components/Gallery.tsx

@@ -2,13 +2,18 @@ import React from 'react';
 
 import { RefsImgSubstance, Props } from './RefsImg';
 
+const gridDefault = 'col-4';
+const gridGapDefault = '1px';
+
 export const Gallery = React.memo((props: Props): JSX.Element => {
-  return <RefsImgSubstance {...props} />;
+  const grid = props.grid || gridDefault;
+  const gridGap = props.gridGap || gridGapDefault;
+  return <RefsImgSubstance grid={grid} gridGap={gridGap} {...props} />;
 });
 
 export const GalleryImmutable = React.memo((props: Omit<Props, 'isImmutable'>): JSX.Element => {
-  const grid = props.grid || 'col-4';
-  const gridGap = props.gridGap || '1px';
+  const grid = props.grid || gridDefault;
+  const gridGap = props.gridGap || gridGapDefault;
   return <RefsImgSubstance grid={grid} gridGap={gridGap} {...props} isImmutable />;
 });
 

+ 1 - 6
packages/remark-attachment-refs/src/client/services/renderer/refs.ts

@@ -1,10 +1,7 @@
-import * as url from 'url';
-
 import { pathUtils } from '@growi/core';
 import { remarkGrowiDirectivePluginType } from '@growi/remark-growi-directive';
 import { Schema as SanitizeOption } from 'hast-util-sanitize';
 import { selectAll, HastNode } from 'hast-util-select';
-import isAbsolute from 'is-absolute-url';
 import { Plugin } from 'unified';
 import { visit } from 'unist-util-visit';
 
@@ -18,8 +15,6 @@ const REFS_IMG_SUPPORTED_ATTRIBUTES = [
   'pagePath', 'prefix', 'depth', 'regexp', 'width', 'height', 'maxWidth', 'maxHeight', 'display', 'grid', 'gridGap', 'noCarousel',
 ];
 
-const { hasHeadingSlash } = pathUtils;
-
 type DirectiveAttributes = Record<string, string>
 
 export const remarkPlugin: Plugin = function() {
@@ -140,7 +135,7 @@ export const rehypePlugin: Plugin<[RefRehypePluginParams]> = (options = {}) => {
       }
 
       // return when page is already determined and aboslute path
-      if (hasHeadingSlash(pagePath)) {
+      if (pathUtils.hasHeadingSlash(pagePath)) {
         return;
       }