@pretextbook/web-editor 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -3
- package/dist/App.d.ts +7 -0
- package/dist/components/BubbleMenu.d.ts +4 -0
- package/dist/components/CodeEditor.d.ts +6 -0
- package/dist/components/CodeEditorMenu.d.ts +12 -0
- package/dist/components/Editors.d.ts +12 -0
- package/dist/components/FloatingMenu.d.ts +4 -0
- package/dist/components/FullPreview.d.ts +5 -0
- package/dist/components/MenuBar.d.ts +12 -0
- package/dist/components/TheoremLike.d.ts +3 -0
- package/dist/components/TiptapMenuBar.d.ts +4 -0
- package/dist/components/VisualEditor.d.ts +12 -0
- package/dist/defaultContent.d.ts +3 -0
- package/dist/extensions/AxiomLike.d.ts +3 -0
- package/dist/extensions/Blocks.d.ts +3 -0
- package/dist/extensions/Definition.d.ts +3 -0
- package/dist/extensions/Divisions.d.ts +3 -0
- package/dist/extensions/Emph.d.ts +7 -0
- package/dist/extensions/ExampleLike.d.ts +3 -0
- package/dist/extensions/Inline.d.ts +3 -0
- package/dist/extensions/Keyboard.d.ts +3 -0
- package/dist/extensions/Math.d.ts +5 -0
- package/dist/extensions/RawPtx.d.ts +3 -0
- package/dist/extensions/RemarkLike.d.ts +3 -0
- package/dist/extensions/Statement.d.ts +3 -0
- package/dist/extensions/TheoremLike.d.ts +3 -0
- package/dist/extensions/Title.d.ts +3 -0
- package/dist/extensions/UnknownMark.d.ts +3 -0
- package/dist/extensions/getCursorPos.d.ts +42 -0
- package/dist/index.d.ts +6 -0
- package/dist/json2ptx.d.ts +2 -0
- package/dist/knownTags.d.ts +1 -0
- package/dist/main.d.ts +1 -0
- package/dist/ptxSourceSlice.d.ts +6 -0
- package/dist/utils.d.ts +14 -0
- package/dist/web-editor.css +1 -1
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -40,14 +40,20 @@ export default App;
|
|
|
40
40
|
|
|
41
41
|
### Styling
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
**Important:** This package uses Tailwind CSS internally, but **all styles are pre-compiled and bundled** in the CSS file. You don't need to install or configure Tailwind CSS in your project.
|
|
44
|
+
|
|
45
|
+
Simply import the CSS file:
|
|
44
46
|
|
|
45
|
-
**Option 1: Import the CSS file directly** (recommended)
|
|
46
47
|
```tsx
|
|
47
48
|
import '@pretextbook/web-editor/dist/web-editor.css';
|
|
48
49
|
```
|
|
49
50
|
|
|
50
|
-
|
|
51
|
+
Or in your CSS file:
|
|
52
|
+
```css
|
|
53
|
+
@import '@pretextbook/web-editor/dist/web-editor.css';
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
All button styles, layout, and MenuBar styling will work automatically without any additional setup.
|
|
51
57
|
```css
|
|
52
58
|
@import '@pretextbook/web-editor/dist/web-editor.css';
|
|
53
59
|
```
|
package/dist/App.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import 'primereact/resources/themes/lara-light-blue/theme.css';
|
|
2
|
+
import 'primereact/resources/primereact.min.css';
|
|
3
|
+
import 'primeicons/primeicons.css';
|
|
4
|
+
import 'primeflex/primeflex.css';
|
|
5
|
+
import './App.css';
|
|
6
|
+
declare function App(): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export default App;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './CodeEditorMenu.css';
|
|
3
|
+
interface CodeEditorMenuProps {
|
|
4
|
+
content: string;
|
|
5
|
+
onContentChange: (newContent: string) => void;
|
|
6
|
+
onUndo: () => void;
|
|
7
|
+
onRedo: () => void;
|
|
8
|
+
canUndo: boolean;
|
|
9
|
+
canRedo: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare const CodeEditorMenu: React.FC<CodeEditorMenuProps>;
|
|
12
|
+
export default CodeEditorMenu;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface editorProps {
|
|
2
|
+
content: string;
|
|
3
|
+
onContentChange: (value: string | undefined) => void;
|
|
4
|
+
title?: string;
|
|
5
|
+
onTitleChange?: (value: string) => void;
|
|
6
|
+
onSaveButton?: () => void;
|
|
7
|
+
saveButtonLabel?: string;
|
|
8
|
+
onCancelButton?: () => void;
|
|
9
|
+
cancelButtonLabel?: string;
|
|
10
|
+
}
|
|
11
|
+
declare const Editors: (props: editorProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export default Editors;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface MenuBarProps {
|
|
2
|
+
isChecked: boolean;
|
|
3
|
+
onChange: () => void;
|
|
4
|
+
title?: string;
|
|
5
|
+
onTitleChange?: (value: string) => void;
|
|
6
|
+
onSaveButton?: () => void;
|
|
7
|
+
saveButtonLabel?: string;
|
|
8
|
+
onCancelButton?: () => void;
|
|
9
|
+
cancelButtonLabel?: string;
|
|
10
|
+
}
|
|
11
|
+
declare const MenuBar: (props: MenuBarProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export default MenuBar;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import "katex/dist/katex.min.css";
|
|
2
|
+
import "../styles.scss";
|
|
3
|
+
interface VisualEditorProps {
|
|
4
|
+
content: string;
|
|
5
|
+
onChange: (html: string) => void;
|
|
6
|
+
}
|
|
7
|
+
interface VisualEditorProps {
|
|
8
|
+
content: string;
|
|
9
|
+
onChange: (html: string) => void;
|
|
10
|
+
}
|
|
11
|
+
declare const VisualEditor: ({ content, onChange }: VisualEditorProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export default VisualEditor;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Node } from "@tiptap/core";
|
|
2
|
+
export declare const inputPTXRegex: RegExp;
|
|
3
|
+
export declare const pastePTXRegex: RegExp;
|
|
4
|
+
export declare const inputMDRegex: RegExp;
|
|
5
|
+
export declare const inputRegex: RegExp;
|
|
6
|
+
declare const Emphasis: Node<any, any>;
|
|
7
|
+
export default Emphasis;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
interface CursorPosition {
|
|
2
|
+
pos: () => number;
|
|
3
|
+
depth: () => number;
|
|
4
|
+
inTextNode: () => boolean;
|
|
5
|
+
prevNodeIsText: () => boolean;
|
|
6
|
+
nextNodeIsText: () => boolean;
|
|
7
|
+
parentType: () => string;
|
|
8
|
+
anchor: () => any;
|
|
9
|
+
nextNodeSize: () => number;
|
|
10
|
+
prevNodeSize: () => number;
|
|
11
|
+
}
|
|
12
|
+
interface Editor {
|
|
13
|
+
$pos: (pos: number) => any;
|
|
14
|
+
state: {
|
|
15
|
+
selection: {
|
|
16
|
+
$anchor: {
|
|
17
|
+
pos: number;
|
|
18
|
+
depth: number;
|
|
19
|
+
parent: {
|
|
20
|
+
firstChild: {
|
|
21
|
+
isText: boolean;
|
|
22
|
+
} | null;
|
|
23
|
+
type: {
|
|
24
|
+
name: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
nodeBefore: {
|
|
28
|
+
isText: boolean;
|
|
29
|
+
nodeSize: number;
|
|
30
|
+
} | null;
|
|
31
|
+
nodeAfter: {
|
|
32
|
+
type: {
|
|
33
|
+
name: string;
|
|
34
|
+
};
|
|
35
|
+
nodeSize: number;
|
|
36
|
+
} | null;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export declare const getCursorPos: (editor: Editor) => CursorPosition;
|
|
42
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import './index.css';
|
|
2
|
+
export { default as Editors } from './components/Editors';
|
|
3
|
+
export type { editorProps } from './components/Editors';
|
|
4
|
+
export { default as CodeEditor } from './components/CodeEditor';
|
|
5
|
+
export { default as VisualEditor } from './components/VisualEditor';
|
|
6
|
+
export { default as FullPreview } from './components/FullPreview';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const KNOWN_TAGS: string[];
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './index.css';
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare function cleanPtx(origXml: string): string;
|
|
2
|
+
export declare function ptxToJson(xml: string): string;
|
|
3
|
+
export declare function blockAttributes(): {
|
|
4
|
+
label: {
|
|
5
|
+
parseHTML: (element: HTMLElement) => string | null;
|
|
6
|
+
};
|
|
7
|
+
"xml:id": {
|
|
8
|
+
parseHTML: (element: HTMLElement) => string | null;
|
|
9
|
+
};
|
|
10
|
+
component: {
|
|
11
|
+
parseHTML: (element: HTMLElement) => string | null;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export declare function generateInputRules(prefix: string, nodeType: any): import("@tiptap/core").InputRule[];
|