Ver Fonte

compdfkit(rn) - 新增RN层CPDFConfiguration配置,新增代码注释

liuxiaolong há 10 meses atrás
pai
commit
8bae18fa2e

+ 0 - 0
API.md


+ 0 - 0
CHANGELOG.md


+ 0 - 133
CODE_OF_CONDUCT.md

@@ -1,133 +0,0 @@
-
-# Contributor Covenant Code of Conduct
-
-## Our Pledge
-
-We as members, contributors, and leaders pledge to make participation in our
-community a harassment-free experience for everyone, regardless of age, body
-size, visible or invisible disability, ethnicity, sex characteristics, gender
-identity and expression, level of experience, education, socio-economic status,
-nationality, personal appearance, race, caste, color, religion, or sexual
-identity and orientation.
-
-We pledge to act and interact in ways that contribute to an open, welcoming,
-diverse, inclusive, and healthy community.
-
-## Our Standards
-
-Examples of behavior that contributes to a positive environment for our
-community include:
-
-* Demonstrating empathy and kindness toward other people
-* Being respectful of differing opinions, viewpoints, and experiences
-* Giving and gracefully accepting constructive feedback
-* Accepting responsibility and apologizing to those affected by our mistakes,
-  and learning from the experience
-* Focusing on what is best not just for us as individuals, but for the overall
-  community
-
-Examples of unacceptable behavior include:
-
-* The use of sexualized language or imagery, and sexual attention or advances of
-  any kind
-* Trolling, insulting or derogatory comments, and personal or political attacks
-* Public or private harassment
-* Publishing others' private information, such as a physical or email address,
-  without their explicit permission
-* Other conduct which could reasonably be considered inappropriate in a
-  professional setting
-
-## Enforcement Responsibilities
-
-Community leaders are responsible for clarifying and enforcing our standards of
-acceptable behavior and will take appropriate and fair corrective action in
-response to any behavior that they deem inappropriate, threatening, offensive,
-or harmful.
-
-Community leaders have the right and responsibility to remove, edit, or reject
-comments, commits, code, wiki edits, issues, and other contributions that are
-not aligned to this Code of Conduct, and will communicate reasons for moderation
-decisions when appropriate.
-
-## Scope
-
-This Code of Conduct applies within all community spaces, and also applies when
-an individual is officially representing the community in public spaces.
-Examples of representing our community include using an official e-mail address,
-posting via an official social media account, or acting as an appointed
-representative at an online or offline event.
-
-## Enforcement
-
-Instances of abusive, harassing, or otherwise unacceptable behavior may be
-reported to the community leaders responsible for enforcement at
-[INSERT CONTACT METHOD].
-All complaints will be reviewed and investigated promptly and fairly.
-
-All community leaders are obligated to respect the privacy and security of the
-reporter of any incident.
-
-## Enforcement Guidelines
-
-Community leaders will follow these Community Impact Guidelines in determining
-the consequences for any action they deem in violation of this Code of Conduct:
-
-### 1. Correction
-
-**Community Impact**: Use of inappropriate language or other behavior deemed
-unprofessional or unwelcome in the community.
-
-**Consequence**: A private, written warning from community leaders, providing
-clarity around the nature of the violation and an explanation of why the
-behavior was inappropriate. A public apology may be requested.
-
-### 2. Warning
-
-**Community Impact**: A violation through a single incident or series of
-actions.
-
-**Consequence**: A warning with consequences for continued behavior. No
-interaction with the people involved, including unsolicited interaction with
-those enforcing the Code of Conduct, for a specified period of time. This
-includes avoiding interactions in community spaces as well as external channels
-like social media. Violating these terms may lead to a temporary or permanent
-ban.
-
-### 3. Temporary Ban
-
-**Community Impact**: A serious violation of community standards, including
-sustained inappropriate behavior.
-
-**Consequence**: A temporary ban from any sort of interaction or public
-communication with the community for a specified period of time. No public or
-private interaction with the people involved, including unsolicited interaction
-with those enforcing the Code of Conduct, is allowed during this period.
-Violating these terms may lead to a permanent ban.
-
-### 4. Permanent Ban
-
-**Community Impact**: Demonstrating a pattern of violation of community
-standards, including sustained inappropriate behavior, harassment of an
-individual, or aggression toward or disparagement of classes of individuals.
-
-**Consequence**: A permanent ban from any sort of public interaction within the
-community.
-
-## Attribution
-
-This Code of Conduct is adapted from the [Contributor Covenant][homepage],
-version 2.1, available at
-[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
-
-Community Impact Guidelines were inspired by
-[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
-
-For answers to common questions about this code of conduct, see the FAQ at
-[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
-[https://www.contributor-covenant.org/translations][translations].
-
-[homepage]: https://www.contributor-covenant.org
-[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
-[Mozilla CoC]: https://github.com/mozilla/diversity
-[FAQ]: https://www.contributor-covenant.org/faq
-[translations]: https://www.contributor-covenant.org/translations

+ 0 - 122
CONTRIBUTING.md

@@ -1,122 +0,0 @@
-# Contributing
-
-Contributions are always welcome, no matter how large or small!
-
-We want this community to be friendly and respectful to each other. Please follow it in all your interactions with the project. Before contributing, please read the [code of conduct](./CODE_OF_CONDUCT.md).
-
-## Development workflow
-
-This project is a monorepo managed using [Yarn workspaces](https://yarnpkg.com/features/workspaces). It contains the following packages:
-
-- The library package in the root directory.
-- An example app in the `example/` directory.
-
-To get started with the project, run `yarn` in the root directory to install the required dependencies for each package:
-
-```sh
-yarn
-```
-
-> Since the project relies on Yarn workspaces, you cannot use [`npm`](https://github.com/npm/cli) for development.
-
-The [example app](/example/) demonstrates usage of the library. You need to run it to test any changes you make.
-
-It is configured to use the local version of the library, so any changes you make to the library's source code will be reflected in the example app. Changes to the library's JavaScript code will be reflected in the example app without a rebuild, but native code changes will require a rebuild of the example app.
-
-If you want to use Android Studio or XCode to edit the native code, you can open the `example/android` or `example/ios` directories respectively in those editors. To edit the Objective-C or Swift files, open `example/ios/CompdfkitPdfExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > react-native-compdfkit-pdf`.
-
-To edit the Java or Kotlin files, open `example/android` in Android studio and find the source files at `react-native-compdfkit-pdf` under `Android`.
-
-You can use various commands from the root directory to work with the project.
-
-To start the packager:
-
-```sh
-yarn example start
-```
-
-To run the example app on Android:
-
-```sh
-yarn example android
-```
-
-To run the example app on iOS:
-
-```sh
-yarn example ios
-```
-
-Make sure your code passes TypeScript and ESLint. Run the following to verify:
-
-```sh
-yarn typecheck
-yarn lint
-```
-
-To fix formatting errors, run the following:
-
-```sh
-yarn lint --fix
-```
-
-Remember to add tests for your change if possible. Run the unit tests by:
-
-```sh
-yarn test
-```
-
-### Commit message convention
-
-We follow the [conventional commits specification](https://www.conventionalcommits.org/en) for our commit messages:
-
-- `fix`: bug fixes, e.g. fix crash due to deprecated method.
-- `feat`: new features, e.g. add new method to the module.
-- `refactor`: code refactor, e.g. migrate from class components to hooks.
-- `docs`: changes into documentation, e.g. add usage example for the module..
-- `test`: adding or updating tests, e.g. add integration tests using detox.
-- `chore`: tooling changes, e.g. change CI config.
-
-Our pre-commit hooks verify that your commit message matches this format when committing.
-
-### Linting and tests
-
-[ESLint](https://eslint.org/), [Prettier](https://prettier.io/), [TypeScript](https://www.typescriptlang.org/)
-
-We use [TypeScript](https://www.typescriptlang.org/) for type checking, [ESLint](https://eslint.org/) with [Prettier](https://prettier.io/) for linting and formatting the code, and [Jest](https://jestjs.io/) for testing.
-
-Our pre-commit hooks verify that the linter and tests pass when committing.
-
-### Publishing to npm
-
-We use [release-it](https://github.com/release-it/release-it) to make it easier to publish new versions. It handles common tasks like bumping version based on semver, creating tags and releases etc.
-
-To publish new versions, run the following:
-
-```sh
-yarn release
-```
-
-### Scripts
-
-The `package.json` file contains various scripts for common tasks:
-
-- `yarn`: setup project by installing dependencies.
-- `yarn typecheck`: type-check files with TypeScript.
-- `yarn lint`: lint files with ESLint.
-- `yarn test`: run unit tests with Jest.
-- `yarn example start`: start the Metro server for the example app.
-- `yarn example android`: run the example app on Android.
-- `yarn example ios`: run the example app on iOS.
-
-### Sending a pull request
-
-> **Working on your first pull request?** You can learn how from this _free_ series: [How to Contribute to an Open Source Project on GitHub](https://app.egghead.io/playlists/how-to-contribute-to-an-open-source-project-on-github).
-
-When you're sending a pull request:
-
-- Prefer small pull requests focused on one change.
-- Verify that linters and tests are passing.
-- Review the documentation to make sure it looks good.
-- Follow the pull request template when opening a pull request.
-- For pull requests that change the API or implementation, discuss with maintainers first by opening an issue.

+ 3 - 4
android/build.gradle

@@ -78,13 +78,12 @@ repositories {
 
 
 dependencies {
-
   // For < 0.71, this will be from the local maven repo
   // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
   //noinspection GradleDynamicVersion
   implementation "com.facebook.react:react-native:+"
-  api "com.compdf:compdfkit:2.0.0"
-  api "com.compdf:compdfkit-ui:2.0.0"
-  api "com.compdf:compdfkit-tools:2.0.0"
+  api "com.compdf:compdfkit:2.0.1"
+  api "com.compdf:compdfkit-ui:2.0.1"
+  api "com.compdf:compdfkit-tools:2.0.1"
 }
 

+ 0 - 8
android/src/main/java/com/compdfkitpdf/reactnative/CompdfkitPdfModule.java

@@ -25,8 +25,6 @@ import com.facebook.react.bridge.ReactApplicationContext;
 import com.facebook.react.bridge.ReactContext;
 import com.facebook.react.bridge.ReactContextBaseJavaModule;
 import com.facebook.react.bridge.ReactMethod;
-import com.facebook.react.bridge.ReadableMap;
-import com.facebook.react.bridge.ReadableMapKeySetIterator;
 
 /**
  * RN and Android native ComPDFKit SDK interaction class
@@ -90,12 +88,6 @@ public class CompdfkitPdfModule extends ReactContextBaseJavaModule {
     promise.resolve(CPDFSdk.getSDKBuildTag());
   }
 
-
-  @ReactMethod
-  public void testConfig(String json){
-    Log.e(TAG,  json);
-  }
-
   /**
    * Initialize the ComPDFKit PDF SDK using offline authentication.<br/>
    * <p></p>

+ 3 - 21
example/App.tsx

@@ -8,7 +8,6 @@
  */
 
 import React, { Component } from 'react';
-import configuration from './assets/configuration.json';
 import DocumentPicker from 'react-native-document-picker'
 import {
   StyleSheet,
@@ -17,7 +16,6 @@ import {
   TouchableOpacity
 } from 'react-native';
 import { ComPDFKit } from 'react-native-compdfkit-pdf';
-import { CPDFConfiguration, CPDFModeConfig } from '../src/configuration/CPDFConfiguration';
 
 
 type Props = {
@@ -38,7 +36,6 @@ export default class App extends Component<Props> {
 
   async getVersionCode() {
     var version = await ComPDFKit.getVersionCode()
-    console.log(version)
     this.setState({
       versionCode: version
     })
@@ -55,23 +52,8 @@ export default class App extends Component<Props> {
         </View>
         <View style={styles.container}>
           <TouchableOpacity onPress={() => {
-            // var ve  : string = 'file:///android_asset/pdf_document.pdf'
-            // ComPDFKit.openDocument(ve, '', JSON.stringify(configuration))
-
-            const configuration : CPDFConfiguration = {
-              modeConfig: {
-                initialViewMode: CPDFModeConfig.ViewMode.VIEWER,
-                availableViewModes: [
-                  CPDFModeConfig.ViewMode.VIEWER,
-                  CPDFModeConfig.ViewMode.ANNOTATIONS,
-                  CPDFModeConfig.ViewMode.CONTENT_EDITOR,
-                  CPDFModeConfig.ViewMode.FORMS,
-                  CPDFModeConfig.ViewMode.SIGNATURES
-                ]
-              }
-            }
-            var json = JSON.stringify(configuration)
-            ComPDFKit.testConfig(json)
+            var samplePDF  : string = 'file:///android_asset/pdf_document.pdf'
+            ComPDFKit.openDocument(samplePDF, '', ComPDFKit.getDefaultConfig({}))
           }}>
             <View style={styles.funItem}>
               <Text style={{ fontWeight: 'bold' }}>{'Open Sample'}</Text>
@@ -86,7 +68,7 @@ export default class App extends Component<Props> {
                 type: [DocumentPicker.types.pdf]
               });
               pickerResult.then(res => {
-                ComPDFKit.openDocument(res[0]?.uri as string, '', JSON.stringify(configuration))
+                ComPDFKit.openDocument(res[0]?.uri as string, '', ComPDFKit.getDefaultConfig({}))
               })
             } catch (err) {
             }

+ 1 - 1
example/package.json

@@ -1,6 +1,6 @@
 {
   "name": "react-native-compdfkit-pdf-example",
-  "version": "2.0.0-beta.1",
+  "version": "2.0.1-beta.1",
   "versionCode": "6",
   "private": true,
   "scripts": {

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "react-native-compdfkit-pdf",
-  "version": "2.0.0-beta.1",
+  "version": "2.0.1-beta.1",
   "description": "ComPDFKit for React Native is a comprehensive SDK that allows you to quickly add PDF functionality to Android and iOS React Native applications.",
   "main": "./src/index.tsx",
   "source": "src/index",

+ 419 - 0
src/configuration/CPDFConfiguration.ts

@@ -0,0 +1,419 @@
+import { BorderWidth, ColorAlpha, CPDFAlignment, CPDFAnnotationType, CPDFBorderStyle, CPDFCheckStyle, CPDFConfigTool, CPDFContentEditorType, CPDFDisplayMode, CPDFFormType, CPDFLineType, CPDFThemes, CPDFToolbarAction, CPDFToolbarMenuAction, CPDFTypeface, CPDFViewMode, DashGap, FontSize, HexColor } from "./CPDFOptions";
+
+/**
+ * Configuration information for displaying PDF using the ComPDFKit.openDocument method. 
+ * Used to configure UI elements, PDF properties, etc.
+ * 
+ * @example
+ * const configuration : CPDFConfiguration = {
+ *    modeConfig: {
+ *       initialViewMode: CPDFModeConfig.ViewMode.VIEWER,
+ *       availableViewModes: [
+ *         CPDFModeConfig.ViewMode.VIEWER,
+ *         CPDFModeConfig.ViewMode.ANNOTATIONS,
+ *         CPDFModeConfig.ViewMode.CONTENT_EDITOR,
+ *         CPDFModeConfig.ViewMode.FORMS,
+ *         CPDFModeConfig.ViewMode.SIGNATURES
+ *       ]
+ *     }
+ * }
+ * 
+ * ComPDFKit.openDocument(document, 'password', JSON.stringify(configuration))
+ */
+export class CPDFConfiguration {
+
+    /**
+     * PDF mode configuration
+     */
+    modeConfig?: {
+        /**
+         * Default mode to display when opening the PDF View, default is [CPDFToolbarAction.VIEWER]
+         */
+        initialViewMode?: CPDFViewMode,
+        /**
+         * Configure supported modes
+         */
+        availableViewModes?: CPDFViewMode[]
+    }
+
+    /**
+     * Configuration for top toolbar functionality
+     */
+    toolbarConfig?: {
+        /**
+         * Top toolbar actions for Android platform
+         * 
+         * Default: thumbnail, search, bota, menu.
+         * 
+         * {@link CPDFToolbarAction.BACK} button will be shown only on the far left
+         */
+        androidAvailableActions?: CPDFToolbarAction[],
+        /**
+          * Left toolbar actions for iOS platform
+          * 
+          * Default: back, thumbnail
+          */
+        iosLeftBarAvailableActions?: CPDFToolbarAction[],
+        /**
+         * Right toolbar actions for iOS platform
+         * 
+         * Default: search, bota, menu
+         */
+        iosRightBarAvailableActions?: CPDFToolbarAction[],
+
+        /**
+         * Configure the menu options opened in the top toolbar {@link CPDFToolbarAction.MENU}
+         */
+        availableMenus?: CPDFToolbarMenuAction[]
+    }
+
+    /**
+     * annotation config
+     */
+    annotationsConfig?: {
+        /**
+         * {@link CPDFViewMode.ANNOTATIONS} mode, list of annotation functions shown at the bottom of the view.
+         */
+        availableType?: CPDFAnnotationType[],
+        /**
+         * {@link CPDFViewMode.ANNOTATIONS} mode, annotation tools shown at the bottom of the view.
+         */
+        availableTools?: CPDFConfigTool[],
+        /**
+         * When adding an annotation, the annotation’s default attributes.
+         */
+        initAttribute?: {
+            /**
+             * Note annotation attribute configuration.
+             * @param { HexColor } [color] HEX color: #1460F3
+             * @param { ColorAlpha } [alpha] Color opacity, value range: 0~255
+             */
+            note?: {
+                color?: HexColor,
+                alpha?: ColorAlpha
+            },
+            /**
+             * Highlight annotation attribute configuration.
+             * @param { HexColor } [color] HEX color: #1460F3.
+             * @param { ColorAlpha } [alpha] Color opacity, value range: 0~255.
+             */
+            highlight?: {
+                color?: HexColor,
+                alpha?: ColorAlpha
+            },
+            /**
+             * Underline annotation attribute configuration.
+             * @param { HexColor } [color] HEX color: #1460F3
+             * @param { number } [alpha] Color opacity, value range: 0~255
+             */
+            underline?: {
+                color?: HexColor,
+                alpha?: ColorAlpha
+            },
+            /**
+             * Squiggly annotation attribute configuration.
+             * @param { HexColor } [color] HEX color: #1460F3
+             * @param { ColorAlpha } [alpha] Color opacity, value range: 0~255
+             */
+            squiggly?: {
+                color?: HexColor,
+                alpha?: ColorAlpha
+            },
+            /**
+             * Strikeout annotation attribute configuration.
+             * @param { HexColor } [color] HEX color: #1460F3
+             * @param { ColorAlpha } [alpha] Color opacity, value range: 0~255
+             */
+            strikeout?: {
+                color?: HexColor,
+                alpha?: ColorAlpha
+            },
+            /**
+             * Ink annotation attribute configuration.
+             * @param {HexColor} [color] HEX color: #1460F3
+             * @param {ColorAlpha} [alpha] Color opacity, value range: 0~255
+             * @param { BorderWidth } [borderWidth] Brush thickness, value range: 1~10
+             */
+            ink?: {
+                color?: HexColor,
+                alpha?: ColorAlpha,
+                borderWidth?: BorderWidth
+            },
+            /**
+             * square annotation attribute configuration.
+             * @param { HexColor } [fillColor] HEX color: #1460F3
+             * @param { HexColor } [borderColor] HEX color: #1460F3
+             * @param { ColorAlpha } [colorAlpha] fill color and border color opacity. value range:0~255
+             * @param { BorderWidth } [borderWidth] border thickness, value range:1~10
+             * @param { object } [borderStyle] Set the border style to dashed or solid.
+             */
+            square?: {
+                fillColor?: HexColor,
+                borderColor?: HexColor,
+                colorAlpha?: ColorAlpha,
+                borderWidth?: BorderWidth,
+                borderStyle?: {
+                    /**
+                     * default: {@link CPDFBorderStyle.SOLID}
+                     */
+                    style?: CPDFBorderStyle,
+                    /**
+                     * Dashed gap, only style={@link CPDFBorderStyle.DASHED} is valid.
+                     */
+                    dashGap?: DashGap
+                }
+            },
+            /**
+             * Circle annotation attribute configuration.
+             * @param { HexColor } [fillColor] HEX color: #1460F3
+             * @param { HexColor } [borderColor] HEX color: #1460F3
+             * @param { ColorAlpha } [colorAlpha] fill color and border color opacity. value range:0~255
+             * @param { BorderWidth } [borderWidth] border thickness, value range:1~10
+             * @param { object } [borderStyle] Set the border style to dashed or solid.
+             */
+            circle?: {
+                fillColor?: HexColor,
+                borderColor?: HexColor,
+                colorAlpha?: ColorAlpha,
+                borderWidth?: BorderWidth,
+                borderStyle?: {
+                     /**
+                     * default: {@link CPDFBorderStyle.SOLID}
+                     */
+                      style?: CPDFBorderStyle,
+                      /**
+                       * Dashed gap, only style={@link CPDFBorderStyle.DASHED} is valid.
+                       */
+                      dashGap?: DashGap
+                }
+            },
+            /**
+             * Line annotation attribute configuration.
+             * @param { HexColor } [borderColor] HEX color: #1460F3
+             * @param { ColorAlpha } [borderAlpha] line color opacity. value range:0~255
+             * @param { BorderWidth } [borderWidth] border thickness, value range:1~10
+             * @param { object } [borderStyle] Set the border style to dashed or solid.
+             */
+            line?: {
+                borderColor?: HexColor,
+                borderAlpha?: ColorAlpha,
+                borderWidth?: BorderWidth,
+                borderStyle?: {
+                    /**
+                     * default: {@link CPDFBorderStyle.SOLID}
+                     */
+                     style?: CPDFBorderStyle,
+                     /**
+                      * Dashed gap, only style={@link CPDFBorderStyle.DASHED} is valid.
+                      */
+                     dashGap?: DashGap
+                }
+            },
+            /**
+             * Arrow annotation attribute configuration.
+             * @param { HexColor } [borderColor] HEX color: #1460F3
+             * @param { ColorAlpha } [borderAlpha] line color opacity. value range:0~255
+             * @param { BorderWidth } [borderWidth] border thickness, value range:0~10
+             * @param { object } [borderStyle] Set the border style to dashed or solid.
+             * @param { CPDFLineType } [startLineType] Arrow starting position shape.
+             * @param { CPDFLineType } [tailLineType] Arrow tail position shape.
+             */
+            arrow?: {
+                borderColor?: HexColor,
+                borderAlpha?: ColorAlpha,
+                borderWidth?: BorderWidth,
+                borderStyle?: {
+                    /**
+                     * default: {@link CPDFBorderStyle.SOLID}
+                     */
+                     style?: CPDFBorderStyle,
+                     /**
+                      * Dashed gap, only style={@link CPDFBorderStyle.DASHED} is valid.
+                      */
+                     dashGap?: DashGap
+                },
+                startLineType?: CPDFLineType
+                tailLineType?: CPDFLineType
+            },
+            /**
+             * Freetext annotation attribute configuration.
+             * @param { HexColor } [fontColor] HEX color: #1460F3
+             * @param { ColorAlpha } [fontColorAlpha] text color opacity. value range:0~255
+             * @param { FontSize } [fontSize] font size, value range:1~100
+             * @param { boolean } [isBold] Whether the font is bold.
+             * @param { boolean } [isItalic] Is the font italicized.
+             * @param { CPDFAlignment } [alignment] Text alignment, {@link CPDFAlignment.LEFT} aligned by default.
+             * @param { CPDFTypeface } [typeface] The font used by default for text. The default is:{@link CPDFTypeface.HELVETICA}.
+             */
+            freeText?: {
+                fontColor?: HexColor,
+                fontColorAlpha?: ColorAlpha,
+                fontSize?: FontSize,
+                isBold?: boolean,
+                isItalic?: boolean,
+                alignment?: CPDFAlignment,
+                typeface?: CPDFTypeface
+            }
+        }
+    }
+
+    contentEditorConfig?: {
+        /**
+         * Content editing mode, the editing mode displayed at the bottom of the view
+         * Default order: editorText, editorImage
+         */
+        availableTypes?: CPDFContentEditorType[],
+        /**
+         * Available tools, including: Setting, Undo, Redo
+         */
+        availableTools?: CPDFConfigTool[]
+        
+        initAttribute?: {
+            /**
+             * When adding text, the text default properties
+             * @param { HexColor } [fontColor] HEX color: #1460F3
+             * @param { ColorAlpha } [fontColorAlpha] text color opacity. value range:0~255
+             * @param { FontSize } [fontSize] font size, value range:1~100
+             * @param { boolean } [isBold] Whether the font is bold.
+             * @param { boolean } [isItalic] Is the font italicized.
+             * @param { CPDFAlignment } [alignment] Text alignment, {@link CPDFAlignment.LEFT} aligned by default.
+             * @param { CPDFTypeface } [typeface] The font used by default for text. The default is:{@link CPDFTypeface.HELVETICA}.
+             */
+            text?: {
+                fontColor?: HexColor,
+                fontColorAlpha?: ColorAlpha,
+                fontSize?: FontSize,
+                isBold?: boolean,
+                isItalic?: boolean,
+                alignment?: CPDFAlignment,
+                typeface?: CPDFTypeface
+            }
+        }
+    }
+
+    formsConfig?: {
+        /**
+         * In {@link CPDFViewMode.Forms} mode, the list of form types at the bottom of the view.
+         */
+        availableTypes?: CPDFFormType[]
+        
+        /**
+         * Only supports {@link CPDFConfigTool.UNDO} and  {@link CPDFConfigTool.UNDO} .
+         */
+        availableTools?: CPDFConfigTool[]
+        
+        /**
+         * Form default attribute configuration
+         */
+        initAttribute?: {
+            /**
+             * Text field default properties, such as fill color, border color, text style, etc.
+             */
+            textField?: {
+                fillColor?: HexColor,
+                borderColor?: HexColor,
+                borderWidth?: BorderWidth,
+                fontColor?: HexColor,
+                fontSize?: FontSize,
+                isBold?: boolean,
+                isItalic?: boolean,
+                alignment?: CPDFAlignment,
+                multiline?: boolean,
+                typeface?: CPDFTypeface
+            },
+            checkBox?: CheckBoxAttr,
+            radioButton?: RadioButtonAttr,
+            listBox?: ListBoxAttr,
+            comboBox?: ComboBoxAttr,
+            pushButton?: {
+                fillColor?: HexColor,
+                borderColor?: HexColor,
+                borderWidth?: BorderWidth,
+                fontColor?: HexColor,
+                fontSize?: FontSize,
+                title?: string,
+                typeface?: CPDFTypeface,
+                isBold?: boolean,
+                isItalic?: boolean,
+            },
+            signaturesFields?: {
+                fillColor?: HexColor,
+                borderColor?: HexColor,
+                borderWidth?: number
+            }
+        }
+    }
+    /**
+     * PDF View configuration.
+     */
+    readerViewConfig?: {
+        linkHighlight?: boolean,
+        formFieldHighlight?: boolean,
+        displayMode?: CPDFDisplayMode,
+        /**
+         * PDF翻页是否为连续滚动
+         */
+        continueMode?: boolean,
+        /**
+         * 是否为垂直方向滚动
+         * true: 垂直滚动, false: 水平滚动
+         * 默认: true
+         */
+        verticalMode?: boolean,
+        /**
+         * 裁剪模式
+         * 是否裁剪PDF页面空白区域
+         * 默认:false
+         */
+        cropMode?: boolean,
+        themes?: CPDFThemes,
+        enableSliderBar?: boolean,
+        enablePageIndicator?: boolean,
+        /**
+         * 每页PDF的间距, 默认10px
+         */
+        pageSpacing?: number,
+        /**
+         * 页面缩放值, 默认1.0
+         */
+        pageScale?: number,
+        /**
+         * only android platform.
+         */
+        pageSameWidth?: boolean
+    }
+};
+
+/**
+ * @param { HexColor } [fillColor] HEX color: #1460F3
+ * @param { HexColor } [borderColor] HEX color: #1460F3
+ * @param { BorderWidth } [borderWidth] border thickness, value range:0~10
+ * @param { HexColor } [checkedColor] 
+ * @param { boolean } [isChecked]
+ * @param { CPDFCheckStyle } [checkedStyle] 
+ */
+export class CheckBoxAttr {
+    fillColor?: HexColor
+    borderColor?: HexColor
+    borderWidth?: BorderWidth
+    checkedColor?: HexColor
+    isChecked?: boolean
+    checkedStyle?: CPDFCheckStyle
+}
+
+export class RadioButtonAttr extends CheckBoxAttr{}
+
+export class ListBoxAttr {
+    fillColor?: string
+    borderColor?: string
+    borderWidth?: number
+    fontColor?: string
+    fontSize?: number
+    typeface?: CPDFTypeface
+    isBold?: boolean
+    isItalic?: boolean
+}
+
+export class ComboBoxAttr extends ListBoxAttr{}
+
+

+ 350 - 0
src/configuration/CPDFOptions.ts

@@ -0,0 +1,350 @@
+
+
+export const CPDFViewMode = {
+
+    /**
+     * Viewer mode, allows viewing PDF only, cannot edit annotations, forms, etc.
+     */
+    VIEWER: 'viewer',
+    /**
+     * Annotations mode, allows annotation editing
+     */
+    ANNOTATIONS: 'annotations',
+    /**
+     * Content editor mode, allows editing text, images of PDF document
+     */
+    CONTENT_EDITOR: 'contentEditor',
+    /**
+     * Forms mode, allows adding text fields, signature fields, list boxes, etc.
+     */
+    FORMS: 'forms',
+    /**
+     * Signatures mode, allows adding signature fields for electronic signing, digital signing, verifying digital signatures
+     */
+    SIGNATURES: 'signatures'
+
+} as const
+export type CPDFViewMode = ValueOf<typeof CPDFViewMode>;
+
+/**
+ * Toolbar actions supported in the displayed PDF view
+ */
+export const CPDFToolbarAction = {
+
+/**
+     * Back button, exits the displayed PDF interface when clicked.  
+     * for Android platform, it will be shown only on the far left of the toolbar.  
+     * for iOS platform, it will be displayed according to the configuration position.
+     */
+    BACK: 'back',
+
+    /**
+     * Thumbnail list
+     */
+    THUMBNAIL: 'thumbnail',
+    /**
+     * PDF text search functionality
+     */
+    SEARCH: 'search',
+    /**
+     * Display related content in the PDF document
+     * 
+     * b: Bookmark list  
+     * o: Outline list  
+     * t: Thumbnail list  
+     * a: Annotation list  
+     */
+    BOTA: 'bota',
+    /**
+     * Menu button
+     */
+    MENU: 'menu'
+
+} as const
+export type CPDFToolbarAction = ValueOf<typeof CPDFToolbarAction>;
+
+/**
+ * Configure the menu options opened in the top toolbar {@link CPDFToolbarAction.MENU}
+ * 
+ */
+export const CPDFToolbarMenuAction = {
+
+    /**
+     * Open the settings view and set the scrolling direction,
+     * display mode, theme color and other related settings for reading PDF.
+     */
+    VIEW_SETTINGS: 'viewSettings',
+
+    /**
+     * Open the document thumbnail list, and you can delete, rotate, and add document pages in the view.
+     */
+    DOCUMENT_EDITOR: 'documentEditor',
+
+    /**
+     * Open the document information view to display basic document information and permission information.
+     */
+    DOCUMENT_INFO: 'documentInfo',
+    /**
+     * Open the watermark editing view to add text and image watermarks and save them as a new document.
+     */
+    WATERMARK: 'watermark',
+    /**
+     * Open the security settings view, set the document opening password and set the permission password
+     */
+    SECURITY: 'security',
+    /**
+     * Flatten the annotations in the document, and the annotations will not be editable.
+     */
+    FLATTENED: 'flattened',
+    /**
+     * save pdf document.
+     */
+    SAVE: 'save',
+    /**
+     * Turn on system sharing function.
+     */
+    SHARE: 'share',
+    /**
+     * Open the system file selector and open a new pdf document.
+     */
+    OPEN_DOCUMENT: 'openDocument'
+
+} as const
+export type CPDFToolbarMenuAction = ValueOf<typeof CPDFToolbarMenuAction>;
+
+
+/**
+ * annotations type.
+ * Please note that {@link PENCIL} is only available on ios platform.
+ */
+export const CPDFAnnotationType = {
+
+    NOTE: 'note',
+
+    HIGHLIGHT: 'highlight',
+
+    UNDERLINE: 'underline',
+
+    SQUIGGLY: 'squiggly',
+
+    STRIKEOUT: 'strikeout',
+
+    INK: 'ink',
+
+    /**
+     * only ios platform.
+     */
+    PENCIL: "pencil",
+
+    CIRCLE: 'circle',
+
+    SQUARE: 'square',
+
+    ARROW: 'arrow',
+
+    LINE: 'line',
+
+    FREETEXT: 'freetext',
+
+    SIGNATURE: 'signature',
+
+    STAMP: 'stamp',
+
+    PICTURES: 'pictures',
+
+    LINK: 'link',
+
+    SOUND: 'sound'
+
+} as const
+export type CPDFAnnotationType = ValueOf<typeof CPDFAnnotationType>;
+
+/**
+  * {@link CPDFViewMode.ANNOTATIONS}, {@link CPDFViewMode.CONTENT_EDITOR},{@link CPDFViewMode.FORMS} function tools.
+  * {@link CPDFConfigTool.SETTING} is not available in form functionality.
+  *
+  */
+export const CPDFConfigTool = {
+    /**
+     * Set button, corresponding to open the selected annotation, text or picture property panel.
+     */
+    SETTING: 'setting',
+    /**
+     * Undo annotation, content editing, form operations
+     */
+    UNDO: 'undo',
+    /**
+     * Redo an undone action
+     */
+    REDO: 'redo'
+} as const
+export type CPDFConfigTool = ValueOf<typeof CPDFConfigTool>;
+
+
+/**
+ * Shape annotation border style, default {@link CPDFBorderStyle.SOLID}.  
+ * shape:
+ * * {@link CPDFAnnotationType.SQUARE}
+ * * {@link CPDFAnnotationType.CIRCLE}
+ * * {@link CPDFAnnotationType.ARROW}
+ * * {@link CPDFAnnotationType.LINE}
+ */
+export const CPDFBorderStyle = {
+
+    SOLID: 'solid',
+
+    DASHED: 'dashed'
+
+} as const
+export type CPDFBorderStyle = ValueOf<typeof CPDFBorderStyle>;
+
+/**
+ * Arrow annotation, start and tail shapes
+ */
+export const CPDFLineType = {
+    NONE: 'none',
+    OPEN_ARROW: 'openArrow', 
+    CLOSE_ARROW: 'closedArrow',
+    SQUARE: 'square',
+    CIRCLE: 'circle', 
+    DIAMOND: 'diamond' 
+}
+export type CPDFLineType = ValueOf<typeof CPDFLineType>;
+
+
+/**
+ * text alignment
+ */
+export const CPDFAlignment = {
+    LEFT: 'left',
+
+    CENTER: 'center',
+
+    RIGHT: 'right'
+} as const
+export type CPDFAlignment =  ValueOf<typeof CPDFAlignment>;
+
+
+export const CPDFTypeface  = {
+    COURIER: 'Courier',
+    HELVETICA: 'Helvetica',
+    TIMES_ROMAN: 'Times-Roman'
+} as const 
+export type CPDFTypeface =  ValueOf<typeof CPDFTypeface>;
+
+
+export const CPDFContentEditorType = {
+    EDITOR_TEXT: 'editorText',
+    EDITOR_IMAGE: 'editorImage'
+}
+export type CPDFContentEditorType =  ValueOf<typeof CPDFContentEditorType>;
+
+
+/**
+ * form types
+ */
+export const CPDFFormType = {
+
+    TEXT_FIELD: 'textField',
+
+    CHECKBOX: 'checkBox',
+
+    RADIO_BUTTON: 'radioButton',
+
+    LISTBOX: 'listBox',
+
+    COMBOBOX: 'comboBox',
+
+    SIGNATURES_FIELDS: 'signaturesFields',
+
+    PUSH_BUTTON: 'pushButton'
+    
+} as const
+export type CPDFFormType = ValueOf<typeof CPDFFormType>;
+
+export const CPDFCheckStyle = {
+    CHECK: 'check',
+    CIRCLE: 'circle',
+    CROSS:  'cross',
+    DIAMOND: 'diamond',
+    SQUARE: 'square',
+    STAR: 'star'
+}
+export type CPDFCheckStyle = ValueOf<typeof CPDFCheckStyle>;
+
+export const CPDFDisplayMode = {
+
+    SINGLE_PAGE: 'singlePage',
+
+    DOUBLE_PAGE: 'doublePage',
+
+    COVER_PAGE: 'coverPage'
+}
+export type CPDFDisplayMode = ValueOf<typeof CPDFDisplayMode>;
+
+export const CPDFThemes = {
+
+  /**
+   * Bright mode, readerview background is white
+   */
+  LIGHT: 'light',
+
+  /**
+   * dark mode, readerview background is black
+   */
+  DARK: 'dark',
+
+  /**
+   * brown paper color
+   */
+  SEPIA: 'sepia',
+
+  /**
+   * Light green, eye protection mode
+   */
+  RESEDA: 'reseda'
+
+}
+export type CPDFThemes = ValueOf<typeof CPDFThemes>;
+
+export type AnyCase<T extends string> =
+    string extends T ? string :
+    T extends `${infer F1}${infer F2}${infer R}` ? (
+        `${Uppercase<F1> | Lowercase<F1>}${Uppercase<F2> | Lowercase<F2>}${AnyCase<R>}`
+    ) :
+    T extends `${infer F}${infer R}` ? `${Uppercase<F> | Lowercase<F>}${AnyCase<R>}` :
+    "";
+
+type ValueOf<T> = T[keyof T];
+
+
+type BuildPowersOf2LengthArrays<N extends number, R extends never[][]> =
+  R[0][N] extends never ? R : BuildPowersOf2LengthArrays<N, [[...R[0], ...R[0]], ...R]>;
+
+type ConcatLargestUntilDone<N extends number, R extends never[][], B extends never[]> =
+  B["length"] extends N ? B : [...R[0], ...B][N] extends never
+    ? ConcatLargestUntilDone<N, R extends [R[0], ...infer U] ? U extends never[][] ? U : never : never, B>
+    : ConcatLargestUntilDone<N, R extends [R[0], ...infer U] ? U extends never[][] ? U : never : never, [...R[0], ...B]>;
+
+type Replace<R extends any[], T> = { [K in keyof R]: T }
+
+type TupleOf<T, N extends number> = number extends N ? T[] : {
+  [K in N]: 
+  BuildPowersOf2LengthArrays<K, [[never]]> extends infer U ? U extends never[][]
+  ? Replace<ConcatLargestUntilDone<K, U, []>, T> : never : never;
+}[N]
+
+type RangeOf<N extends number> = Partial<TupleOf<unknown, N>>["length"];
+
+type RangeOf2<From extends number, To extends number> = Exclude<RangeOf<To>, RangeOf<From>> | From;
+
+
+export type ColorAlpha = RangeOf2<0,255>
+
+export type BorderWidth = RangeOf2<1, 10>
+
+export type DashGap = RangeOf2<0.0, 8.0>
+
+export type HexColor = `#${string}`;
+
+export type FontSize = RangeOf2<0,100>

+ 288 - 3
src/index.tsx

@@ -1,9 +1,12 @@
 import { NativeModules } from 'react-native';
+import { CPDFConfiguration } from './configuration/CPDFConfiguration';
+import { CPDFAlignment, CPDFAnnotationType, CPDFBorderStyle, CPDFCheckStyle, CPDFConfigTool, CPDFContentEditorType, CPDFDisplayMode, CPDFFormType, CPDFLineType, CPDFThemes, CPDFToolbarAction, CPDFToolbarMenuAction, CPDFTypeface, CPDFViewMode } from './configuration/CPDFOptions';
 
 declare module 'react-native' {
   interface NativeModulesStatic {
     ComPDFKit: {
-      testConfig(configuration: string): () => void;
+      getDefaultConfig(overrides : Partial<CPDFConfiguration>) : string;
+      testConfig(configuration: string): () => Promise<string>;
       /**
        * Get the version number of the ComPDFKit SDK.
        * For example : '2.0.0'
@@ -113,7 +116,7 @@ declare module 'react-native' {
 }
 
 interface ComPDFKit {
-  testConfig(configuration: string): void;
+  testConfig(configuration: string): Promise<string>;
   getVersionCode(): Promise<string>;
   getSDKBuildTag(): Promise<string>;
   init_(license: string): Promise<boolean>;
@@ -123,4 +126,286 @@ interface ComPDFKit {
 
 const ComPDFKit = NativeModules.ComPDFKit
 
-export { ComPDFKit };
+export { ComPDFKit, CPDFViewMode };
+
+ComPDFKit.getDefaultConfig = getDefaultConfig
+
+
+function getDefaultConfig(overrides : Partial<CPDFConfiguration> = {}) : string {
+  const defaultConfig : CPDFConfiguration = {
+    modeConfig:{
+      initialViewMode: CPDFViewMode.VIEWER,
+      availableViewModes: [
+        CPDFViewMode.VIEWER,
+        CPDFViewMode.ANNOTATIONS,
+        CPDFViewMode.CONTENT_EDITOR,
+        CPDFViewMode.FORMS,
+        CPDFViewMode.SIGNATURES,
+      ]
+    },
+    toolbarConfig: {
+      androidAvailableActions: [
+        CPDFToolbarAction.THUMBNAIL,
+        CPDFToolbarAction.SEARCH,
+        CPDFToolbarAction.BOTA,
+        CPDFToolbarAction.MENU,
+      ],
+      iosLeftBarAvailableActions:[
+        CPDFToolbarAction.BACK,
+        CPDFToolbarAction.THUMBNAIL
+      ],
+      iosRightBarAvailableActions: [
+        CPDFToolbarAction.SEARCH,
+        CPDFToolbarAction.BOTA,
+        CPDFToolbarAction.MENU
+      ],
+      availableMenus: [
+        CPDFToolbarMenuAction.VIEW_SETTINGS,
+        CPDFToolbarMenuAction.DOCUMENT_EDITOR,
+        CPDFToolbarMenuAction.DOCUMENT_INFO,
+        CPDFToolbarMenuAction.WATERMARK,
+        CPDFToolbarMenuAction.SECURITY,
+        CPDFToolbarMenuAction.FLATTENED,
+        CPDFToolbarMenuAction.SAVE,
+        CPDFToolbarMenuAction.SHARE,
+        CPDFToolbarMenuAction.OPEN_DOCUMENT
+      ]
+    },
+    annotationsConfig: {
+      availableType: [
+        CPDFAnnotationType.NOTE,
+        CPDFAnnotationType.HIGHLIGHT,
+        CPDFAnnotationType.UNDERLINE,
+        CPDFAnnotationType.SQUIGGLY,
+        CPDFAnnotationType.STRIKEOUT,
+        CPDFAnnotationType.INK,
+        CPDFAnnotationType.CIRCLE,
+        CPDFAnnotationType.SQUARE,
+        CPDFAnnotationType.ARROW,
+        CPDFAnnotationType.LINE,
+        CPDFAnnotationType.FREETEXT,
+        CPDFAnnotationType.SIGNATURE,
+        CPDFAnnotationType.STAMP,
+        CPDFAnnotationType.PICTURES,
+        CPDFAnnotationType.LINK,
+        CPDFAnnotationType.SOUND,
+      ],
+      availableTools: [
+        CPDFConfigTool.SETTING,
+        CPDFConfigTool.UNDO,
+        CPDFConfigTool.REDO
+      ],
+      initAttribute: {
+        note: {
+          color: '#1460F3',
+          alpha: 255
+        },
+        highlight: {
+          color: '#1460F3',
+          alpha: 77
+        },
+        underline: {
+          color: '#1460F3',
+          alpha: 77
+        },
+        squiggly: {
+          color: '#1460F3',
+          alpha: 77
+        },
+        strikeout: {
+          color: '#1460F3',
+          alpha: 77
+        },
+        ink: {
+          color: '#1460F3',
+          alpha: 100,
+          borderWidth: 10
+        },
+        square: {
+          fillColor: '#1460F3',
+          borderColor: '#000000',
+          colorAlpha : 128,
+          borderWidth: 2,
+          borderStyle: {
+            style: CPDFBorderStyle.SOLID,
+            dashGap: 8.0
+          }
+        },
+        circle: {
+          fillColor: '#1460F3',
+          borderColor: '#000000',
+          colorAlpha : 128,
+          borderWidth: 2,
+          borderStyle: {
+            style: CPDFBorderStyle.SOLID,
+            dashGap: 8.0
+          }
+        },
+        line: {
+          borderColor: '#1460F3',
+          borderAlpha: 100,
+          borderWidth: 5,
+          borderStyle: {
+            style: CPDFBorderStyle.SOLID,
+            dashGap: 8.0
+          }
+        },
+        arrow: {
+          borderColor: '#1460F3',
+          borderAlpha: 100,
+          borderWidth: 5,
+          borderStyle: {
+            style: CPDFBorderStyle.SOLID,
+            dashGap: 8.0
+          },
+          startLineType: CPDFLineType.NONE,
+          tailLineType: CPDFLineType.OPEN_ARROW
+        },
+        freeText: {
+          fontColor: '#000000',
+          fontColorAlpha: 255,
+          fontSize: 30,
+          isBold: false,
+          isItalic: false,
+          alignment: CPDFAlignment.LEFT,
+          typeface: CPDFTypeface.HELVETICA
+        }
+      }
+    },
+    contentEditorConfig: {
+        availableTypes: [
+          CPDFContentEditorType.EDITOR_TEXT,
+          CPDFContentEditorType.EDITOR_IMAGE
+        ],
+        availableTools: [
+          CPDFConfigTool.SETTING,
+          CPDFConfigTool.UNDO,
+          CPDFConfigTool.REDO
+        ],
+        initAttribute: {
+          text: {
+            fontColor: '#000000',
+            fontColorAlpha: 100,
+            fontSize: 30,
+            isBold: false,
+            isItalic: false,
+            typeface: CPDFTypeface.TIMES_ROMAN,
+            alignment: CPDFAlignment.LEFT
+          }
+        }
+    },
+    formsConfig: {
+      availableTypes: [
+        CPDFFormType.TEXT_FIELD,
+        CPDFFormType.CHECKBOX,
+        CPDFFormType.RADIO_BUTTON,
+        CPDFFormType.LISTBOX,
+        CPDFFormType.COMBOBOX,
+        CPDFFormType.SIGNATURES_FIELDS,
+        CPDFFormType.PUSH_BUTTON,
+      ],
+      availableTools: [
+        CPDFConfigTool.UNDO,
+        CPDFConfigTool.REDO
+      ],
+      initAttribute: {
+        textField: {
+          fillColor: '#DDE9FF',
+          borderColor: '#1460F3',
+          borderWidth: 2,
+          fontColor: '#000000',
+          fontSize: 20,
+          isBold: false,
+          isItalic: false,
+          alignment: CPDFAlignment.LEFT,
+          multiline: true,
+          typeface: CPDFTypeface.HELVETICA
+        },
+        checkBox: {
+          fillColor: '#DDE9FF',
+          borderColor: '#1460F3',
+          borderWidth: 2,
+          checkedColor: '#43474D',
+          isChecked: false,
+          checkedStyle: CPDFCheckStyle.CHECK
+        },
+        radioButton: {
+          fillColor: '#DDE9FF',
+          borderColor: '#1460F3',
+          borderWidth: 2,
+          checkedColor: '#43474D',
+          isChecked: false,
+          checkedStyle: CPDFCheckStyle.CIRCLE
+        },
+        listBox: {
+          fillColor: '#DDE9FF',
+          borderColor: '#1460F3',
+          borderWidth: 2,
+          fontColor: '#000000',
+          fontSize: 20,
+          typeface: CPDFTypeface.HELVETICA,
+          isBold: false,
+          isItalic: false
+        },
+        comboBox: {
+          fillColor: '#DDE9FF',
+          borderColor: '#1460F3',
+          borderWidth: 2,
+          fontColor: '#000000',
+          fontSize: 20,
+          typeface: CPDFTypeface.HELVETICA,
+          isBold: false,
+          isItalic: false
+        },
+        pushButton: {
+          fillColor: '#DDE9FF',
+          borderColor: '#1460F3',
+          borderWidth: 2,
+          fontColor: '#000000',
+          fontSize: 20,
+          title: 'Button',
+          typeface: CPDFTypeface.HELVETICA,
+          isBold: false,
+          isItalic: false
+        },
+        signaturesFields: {
+          fillColor: '#DDE9FF',
+          borderColor: '#000000',
+          borderWidth: 2
+        }
+      }
+    },
+    readerViewConfig: {
+      linkHighlight: true,
+      formFieldHighlight: true,
+      displayMode: CPDFDisplayMode.SINGLE_PAGE,
+      continueMode: true,
+      verticalMode: true,
+      cropMode: false,
+      themes: CPDFThemes.LIGHT,
+      enableSliderBar: true,
+      enablePageIndicator: true,
+      pageScale: 1.0,
+      pageSpacing: 10,
+      pageSameWidth: true
+    }
+  }
+  return JSON.stringify(mergeDeep(defaultConfig, overrides), null, 2);
+}
+
+// 辅助函数:深度合并对象
+function mergeDeep(defaults: any, overrides: any): any {
+  const merged = { ...defaults };
+
+  for (const key in overrides) {
+      if (Array.isArray(overrides[key]) && Array.isArray(defaults[key])) {
+          merged[key] = [...overrides[key]]; // 使用新数组替换旧数组
+      } else if (overrides[key] instanceof Object && key in defaults) {
+          merged[key] = mergeDeep(defaults[key], overrides[key]);
+      } else {
+          merged[key] = overrides[key];
+      }
+  }
+
+  return merged;
+}

+ 1 - 2
tsconfig.json

@@ -22,7 +22,6 @@
     "resolveJsonModule": true,
     "skipLibCheck": true,
     "strict": true,
-    "target": "esnext",
-    "verbatimModuleSyntax": true
+    "target": "esnext"
   }
 }