Explorar o código

Merge pull request #7228 from weseek/fix/112798-insert-h1-when-page-create

fix: refactor pageEditor initValue
Yuki Takei %!s(int64=3) %!d(string=hai) anos
pai
achega
5c68d8ea08
Modificáronse 1 ficheiros con 4 adicións e 2 borrados
  1. 4 2
      packages/app/src/components/PageEditor.tsx

+ 4 - 2
packages/app/src/components/PageEditor.tsx

@@ -2,8 +2,9 @@ import React, {
   useCallback, useEffect, useMemo, useRef, useState,
   useCallback, useEffect, useMemo, useRef, useState,
 } from 'react';
 } from 'react';
 
 
-
 import EventEmitter from 'events';
 import EventEmitter from 'events';
+import nodePath from 'path';
+
 
 
 import {
 import {
   IPageHasId, PageGrant, pathUtils,
   IPageHasId, PageGrant, pathUtils,
@@ -106,7 +107,8 @@ const PageEditor = React.memo((): JSX.Element => {
 
 
     let initialValue = '';
     let initialValue = '';
     if (isEnabledAttachTitleHeader && currentPathname != null) {
     if (isEnabledAttachTitleHeader && currentPathname != null) {
-      initialValue += `${pathUtils.attachTitleHeader(currentPathname)}\n`;
+      const pageTitle = nodePath.basename(currentPathname);
+      initialValue += `${pathUtils.attachTitleHeader(pageTitle)}\n`;
     }
     }
     if (templateBodyData != null) {
     if (templateBodyData != null) {
       initialValue += `${templateBodyData}\n`;
       initialValue += `${templateBodyData}\n`;