From c2805520aeb1ec5db77f3a2e72299a2011456b94 Mon Sep 17 00:00:00 2001 From: GuySerfaty Date: Mon, 5 Feb 2024 12:44:50 +0200 Subject: [PATCH] fix lint --- src/bridges/HighlightSelection.ts | 2 +- src/bridges/base.ts | 6 +++--- src/simpleWebEditor/Tiptap.tsx | 1 + src/simpleWebEditor/index.d.ts | 3 +++ src/webEditorUtils/tsconfig.json | 22 ++++++++++++++++++++++ src/webEditorUtils/useTenTap.tsx | 11 ++++++++++- tsconfig.json | 2 +- website/src/pages/index.tsx | 1 + 8 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 src/webEditorUtils/tsconfig.json diff --git a/src/bridges/HighlightSelection.ts b/src/bridges/HighlightSelection.ts index 8f5b28d..df713d3 100644 --- a/src/bridges/HighlightSelection.ts +++ b/src/bridges/HighlightSelection.ts @@ -13,7 +13,7 @@ export const blueBackgroundPlugin = Extension.create({ init() { return DecorationSet.empty; }, - apply(tr, oldState, oldEditorState, newEditorState) { + apply(tr, _oldState, _oldEditorState, newEditorState) { if (tr.selection.empty) { // If there is no selection, return the old state return DecorationSet.empty; diff --git a/src/bridges/base.ts b/src/bridges/base.ts index 0f6b4b4..1daef01 100644 --- a/src/bridges/base.ts +++ b/src/bridges/base.ts @@ -1,6 +1,6 @@ import { Editor, type AnyExtension } from '@tiptap/core'; -interface TenTapBridge { +interface TenTapBridge { name: string; tiptapExtension?: AnyExtension; tiptapExtensionDeps?: AnyExtension[]; @@ -16,12 +16,12 @@ interface TenTapBridge { config?: string; } -type CreateTenTapBridgeArgs = Omit< +type CreateTenTapBridgeArgs = Omit< TenTapBridge & { forceName?: string }, 'name' | 'sendMessage' | 'configure' | 'configureTiptapExtensionsOnRunTime' >; -class TenTapBridge { +class TenTapBridge { constructor({ forceName, tiptapExtension, diff --git a/src/simpleWebEditor/Tiptap.tsx b/src/simpleWebEditor/Tiptap.tsx index e397a4a..2c5e018 100644 --- a/src/simpleWebEditor/Tiptap.tsx +++ b/src/simpleWebEditor/Tiptap.tsx @@ -1,3 +1,4 @@ +import React from 'react'; import { EditorContent } from '@tiptap/react'; import { useTenTap } from '../webEditorUtils'; import { TenTapStartKit } from '../bridges/StarterKit'; diff --git a/src/simpleWebEditor/index.d.ts b/src/simpleWebEditor/index.d.ts index b86dfd7..c815226 100644 --- a/src/simpleWebEditor/index.d.ts +++ b/src/simpleWebEditor/index.d.ts @@ -1,6 +1,9 @@ export {}; declare global { interface Window { + initialContent: string; + plugConfig: string; + whiteListPlugins: string[]; ReactNativeWebView: { postMessage: (message: string) => void }; } } diff --git a/src/webEditorUtils/tsconfig.json b/src/webEditorUtils/tsconfig.json new file mode 100644 index 0000000..783f07e --- /dev/null +++ b/src/webEditorUtils/tsconfig.json @@ -0,0 +1,22 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "_version": "2.0.0", + "compilerOptions": { + "lib": ["dom", "dom.iterable", "esnext"], + "module": "esnext", + "moduleResolution": "bundler", + "target": "es2015", + + "allowJs": true, + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "isolatedModules": true, + "jsx": "react-jsx", + "noEmit": true, + "noFallthroughCasesInSwitch": true, + "resolveJsonModule": true, + "skipLibCheck": true, + "strict": true + } +} \ No newline at end of file diff --git a/src/webEditorUtils/useTenTap.tsx b/src/webEditorUtils/useTenTap.tsx index 6d31716..73bd242 100644 --- a/src/webEditorUtils/useTenTap.tsx +++ b/src/webEditorUtils/useTenTap.tsx @@ -7,6 +7,14 @@ import { EditorUpdateSettings } from '../types/Actions'; import focusListener from '../simpleWebEditor/utils/focusListener'; import { type EditorNativeState } from '../types/EditorNativeState'; import type TenTapBridge from '../bridges/base'; +declare global { + interface Window { + initialContent: string; + plugConfig: string; + whiteListPlugins: string[]; + ReactNativeWebView: { postMessage: (message: string) => void }; + } +} const content = window.initialContent || ''; @@ -17,7 +25,7 @@ export const sendMessage = (message: EditorMessage) => { interface useTenTapArgs { tiptapOptions?: any; - bridges?: TenTapBridge[]; + bridges?: TenTapBridge[]; } const configs = JSON.parse(window.plugConfig || '{}'); @@ -50,6 +58,7 @@ export const useTenTap = (options?: useTenTapArgs) => { }; const state = bridges.reduce((acc, e) => { + if (!e.extendEditorState) return acc; return Object.assign(acc, e.extendEditorState(editor)); }, payload) as EditorNativeState; diff --git a/tsconfig.json b/tsconfig.json index d4cf248..1885646 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -25,5 +25,5 @@ "target": "esnext", "verbatimModuleSyntax": true, }, - "exclude": ["src/simpleWebEditor","./website", "./example/src/Examples/Advanced/Editor"] + "exclude": ["src/simpleWebEditor","./website", "./example/src/Examples/Advanced/Editor", "src/webEditorUtils"] } diff --git a/website/src/pages/index.tsx b/website/src/pages/index.tsx index 6a14177..aa5a5e8 100644 --- a/website/src/pages/index.tsx +++ b/website/src/pages/index.tsx @@ -1,3 +1,4 @@ +import React from 'react'; import { Redirect } from '@docusaurus/router'; export default function Home(): JSX.Element {