Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySerfaty committed Feb 5, 2024
1 parent a4348fd commit c280552
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/bridges/HighlightSelection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/bridges/base.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Editor, type AnyExtension } from '@tiptap/core';

interface TenTapBridge<T, E, M> {
interface TenTapBridge<T = any, E = any, M = any> {
name: string;
tiptapExtension?: AnyExtension;
tiptapExtensionDeps?: AnyExtension[];
Expand All @@ -16,12 +16,12 @@ interface TenTapBridge<T, E, M> {
config?: string;
}

type CreateTenTapBridgeArgs<T, E, M> = Omit<
type CreateTenTapBridgeArgs<T = any, E = any, M = any> = Omit<
TenTapBridge<T, E, M> & { forceName?: string },
'name' | 'sendMessage' | 'configure' | 'configureTiptapExtensionsOnRunTime'
>;

class TenTapBridge<T, E, M> {
class TenTapBridge<T = any, E = any, M = any> {
constructor({
forceName,
tiptapExtension,
Expand Down
1 change: 1 addition & 0 deletions src/simpleWebEditor/Tiptap.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react';
import { EditorContent } from '@tiptap/react';
import { useTenTap } from '../webEditorUtils';
import { TenTapStartKit } from '../bridges/StarterKit';
Expand Down
3 changes: 3 additions & 0 deletions src/simpleWebEditor/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
export {};
declare global {
interface Window {
initialContent: string;
plugConfig: string;
whiteListPlugins: string[];
ReactNativeWebView: { postMessage: (message: string) => void };
}
}
22 changes: 22 additions & 0 deletions src/webEditorUtils/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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
}
}
11 changes: 10 additions & 1 deletion src/webEditorUtils/useTenTap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 || '';

Expand All @@ -17,7 +25,7 @@ export const sendMessage = (message: EditorMessage) => {

interface useTenTapArgs {
tiptapOptions?: any;
bridges?: TenTapBridge<unknown, unknown, unknown>[];
bridges?: TenTapBridge[];
}

const configs = JSON.parse(window.plugConfig || '{}');
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
1 change: 1 addition & 0 deletions website/src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react';
import { Redirect } from '@docusaurus/router';

export default function Home(): JSX.Element {
Expand Down

0 comments on commit c280552

Please sign in to comment.