@pretextbook/web-editor 0.0.13 → 0.0.14
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 +128 -128
- package/dist/App.d.ts +0 -0
- package/dist/components/BubbleMenu.d.ts +0 -0
- package/dist/components/CodeEditor.d.ts +0 -0
- package/dist/components/CodeEditorMenu.d.ts +0 -0
- package/dist/components/Editors.d.ts +0 -0
- package/dist/components/FloatingMenu.d.ts +0 -0
- package/dist/components/FullPreview.d.ts +0 -0
- package/dist/components/MenuBar.d.ts +0 -0
- package/dist/components/TheoremLike.d.ts +0 -0
- package/dist/components/TiptapMenuBar.d.ts +0 -0
- package/dist/components/VisualEditor.d.ts +0 -0
- package/dist/defaultContent.d.ts +0 -0
- package/dist/extensions/AxiomLike.d.ts +0 -0
- package/dist/extensions/Blocks.d.ts +0 -0
- package/dist/extensions/Definition.d.ts +0 -0
- package/dist/extensions/Divisions.d.ts +0 -0
- package/dist/extensions/Emph.d.ts +0 -0
- package/dist/extensions/ExampleLike.d.ts +0 -0
- package/dist/extensions/Inline.d.ts +0 -0
- package/dist/extensions/Keyboard.d.ts +0 -0
- package/dist/extensions/Math.d.ts +0 -0
- package/dist/extensions/RawPtx.d.ts +0 -0
- package/dist/extensions/RemarkLike.d.ts +0 -0
- package/dist/extensions/Statement.d.ts +0 -0
- package/dist/extensions/TheoremLike.d.ts +0 -0
- package/dist/extensions/Title.d.ts +0 -0
- package/dist/extensions/UnknownMark.d.ts +0 -0
- package/dist/extensions/Url.d.ts +0 -0
- package/dist/extensions/getCursorPos.d.ts +0 -0
- package/dist/index.d.ts +0 -0
- package/dist/index.es.js +27 -13
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/json2ptx.d.ts +0 -0
- package/dist/knownTags.d.ts +0 -0
- package/dist/main.d.ts +0 -0
- package/dist/ptxSourceSlice.d.ts +0 -0
- package/dist/utils.d.ts +0 -0
- package/dist/web-editor.css +1 -1
- package/package.json +89 -89
package/README.md
CHANGED
|
@@ -1,128 +1,128 @@
|
|
|
1
|
-
# PreTeXt Plus Editor
|
|
2
|
-
|
|
3
|
-
An in-browser editor for PreTeXt documents with visual and code editing modes.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @pretextbook/web-editor
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
### Basic Setup
|
|
14
|
-
|
|
15
|
-
```tsx
|
|
16
|
-
import React, { useState } from 'react';
|
|
17
|
-
import { Editors } from '@pretextbook/web-editor';
|
|
18
|
-
import '@pretextbook/web-editor/dist/web-editor.css';
|
|
19
|
-
|
|
20
|
-
function App() {
|
|
21
|
-
const [content, setContent] = useState('');
|
|
22
|
-
const [title, setTitle] = useState('My Document');
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<Editors
|
|
26
|
-
content={content}
|
|
27
|
-
onContentChange={setContent}
|
|
28
|
-
title={title}
|
|
29
|
-
onTitleChange={setTitle}
|
|
30
|
-
onSaveButton={() => console.log('Save clicked')}
|
|
31
|
-
saveButtonLabel="Save"
|
|
32
|
-
onCancelButton={() => console.log('Cancel clicked')}
|
|
33
|
-
cancelButtonLabel="Cancel"
|
|
34
|
-
/>
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export default App;
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### Styling
|
|
42
|
-
|
|
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:
|
|
46
|
-
|
|
47
|
-
```tsx
|
|
48
|
-
import '@pretextbook/web-editor/dist/web-editor.css';
|
|
49
|
-
```
|
|
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.
|
|
57
|
-
```css
|
|
58
|
-
@import '@pretextbook/web-editor/dist/web-editor.css';
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
## Props
|
|
62
|
-
|
|
63
|
-
The `Editors` component accepts the following props:
|
|
64
|
-
|
|
65
|
-
```tsx
|
|
66
|
-
interface editorProps {
|
|
67
|
-
content: string; // The current PreTeXt content
|
|
68
|
-
onContentChange: (value: string | undefined) => void; // Called when content changes
|
|
69
|
-
title?: string; // Document title
|
|
70
|
-
onTitleChange?: (value: string) => void; // Called when title changes
|
|
71
|
-
onSaveButton?: () => void; // Save button callback
|
|
72
|
-
saveButtonLabel?: string; // Custom save button text
|
|
73
|
-
onCancelButton?: () => void; // Cancel button callback
|
|
74
|
-
cancelButtonLabel?: string; // Custom cancel button text
|
|
75
|
-
}
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
## Features
|
|
79
|
-
|
|
80
|
-
- **Visual Editor**: Intuitive WYSIWYG editor for PreTeXt documents using Tiptap
|
|
81
|
-
- **Code Editor**: Monaco-powered code editor with syntax highlighting
|
|
82
|
-
- **Full Preview**: Full-page preview of your document
|
|
83
|
-
- **Synchronized Editing**: Changes in one editor instantly reflect in the other
|
|
84
|
-
- **Split View**: View code and visual editor side-by-side
|
|
85
|
-
- **Math Support**: KaTeX support for rendering mathematical expressions
|
|
86
|
-
- **Keyboard Shortcuts**: Intuitive keyboard navigation and commands
|
|
87
|
-
|
|
88
|
-
## Peer Dependencies
|
|
89
|
-
|
|
90
|
-
This package requires:
|
|
91
|
-
- `react` >= 16.8.0
|
|
92
|
-
- `react-dom` >= 16.8.0
|
|
93
|
-
|
|
94
|
-
These must be installed separately in your project.
|
|
95
|
-
|
|
96
|
-
## Browser Support
|
|
97
|
-
|
|
98
|
-
This package requires a modern browser with ES2020 support.
|
|
99
|
-
|
|
100
|
-
## Development
|
|
101
|
-
|
|
102
|
-
For development setup:
|
|
103
|
-
|
|
104
|
-
```bash
|
|
105
|
-
npm install
|
|
106
|
-
npm run dev
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
To build the library:
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
npm run build
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
To build the demo application:
|
|
116
|
-
|
|
117
|
-
```bash
|
|
118
|
-
npm run build:demo
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
## Publishing
|
|
122
|
-
|
|
123
|
-
See [PUBLISHING.md](./PUBLISHING.md) for instructions on publishing to npm.
|
|
124
|
-
|
|
125
|
-
## License
|
|
126
|
-
|
|
127
|
-
MIT
|
|
128
|
-
|
|
1
|
+
# PreTeXt Plus Editor
|
|
2
|
+
|
|
3
|
+
An in-browser editor for PreTeXt documents with visual and code editing modes.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @pretextbook/web-editor
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Basic Setup
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import React, { useState } from 'react';
|
|
17
|
+
import { Editors } from '@pretextbook/web-editor';
|
|
18
|
+
import '@pretextbook/web-editor/dist/web-editor.css';
|
|
19
|
+
|
|
20
|
+
function App() {
|
|
21
|
+
const [content, setContent] = useState('');
|
|
22
|
+
const [title, setTitle] = useState('My Document');
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<Editors
|
|
26
|
+
content={content}
|
|
27
|
+
onContentChange={setContent}
|
|
28
|
+
title={title}
|
|
29
|
+
onTitleChange={setTitle}
|
|
30
|
+
onSaveButton={() => console.log('Save clicked')}
|
|
31
|
+
saveButtonLabel="Save"
|
|
32
|
+
onCancelButton={() => console.log('Cancel clicked')}
|
|
33
|
+
cancelButtonLabel="Cancel"
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default App;
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Styling
|
|
42
|
+
|
|
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:
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
import '@pretextbook/web-editor/dist/web-editor.css';
|
|
49
|
+
```
|
|
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.
|
|
57
|
+
```css
|
|
58
|
+
@import '@pretextbook/web-editor/dist/web-editor.css';
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Props
|
|
62
|
+
|
|
63
|
+
The `Editors` component accepts the following props:
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
interface editorProps {
|
|
67
|
+
content: string; // The current PreTeXt content
|
|
68
|
+
onContentChange: (value: string | undefined) => void; // Called when content changes
|
|
69
|
+
title?: string; // Document title
|
|
70
|
+
onTitleChange?: (value: string) => void; // Called when title changes
|
|
71
|
+
onSaveButton?: () => void; // Save button callback
|
|
72
|
+
saveButtonLabel?: string; // Custom save button text
|
|
73
|
+
onCancelButton?: () => void; // Cancel button callback
|
|
74
|
+
cancelButtonLabel?: string; // Custom cancel button text
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Features
|
|
79
|
+
|
|
80
|
+
- **Visual Editor**: Intuitive WYSIWYG editor for PreTeXt documents using Tiptap
|
|
81
|
+
- **Code Editor**: Monaco-powered code editor with syntax highlighting
|
|
82
|
+
- **Full Preview**: Full-page preview of your document
|
|
83
|
+
- **Synchronized Editing**: Changes in one editor instantly reflect in the other
|
|
84
|
+
- **Split View**: View code and visual editor side-by-side
|
|
85
|
+
- **Math Support**: KaTeX support for rendering mathematical expressions
|
|
86
|
+
- **Keyboard Shortcuts**: Intuitive keyboard navigation and commands
|
|
87
|
+
|
|
88
|
+
## Peer Dependencies
|
|
89
|
+
|
|
90
|
+
This package requires:
|
|
91
|
+
- `react` >= 16.8.0
|
|
92
|
+
- `react-dom` >= 16.8.0
|
|
93
|
+
|
|
94
|
+
These must be installed separately in your project.
|
|
95
|
+
|
|
96
|
+
## Browser Support
|
|
97
|
+
|
|
98
|
+
This package requires a modern browser with ES2020 support.
|
|
99
|
+
|
|
100
|
+
## Development
|
|
101
|
+
|
|
102
|
+
For development setup:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
npm install
|
|
106
|
+
npm run dev
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
To build the library:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
npm run build
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
To build the demo application:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
npm run build:demo
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Publishing
|
|
122
|
+
|
|
123
|
+
See [PUBLISHING.md](./PUBLISHING.md) for instructions on publishing to npm.
|
|
124
|
+
|
|
125
|
+
## License
|
|
126
|
+
|
|
127
|
+
MIT
|
|
128
|
+
|
package/dist/App.d.ts
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/defaultContent.d.ts
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/extensions/Url.d.ts
CHANGED
|
File without changes
|
|
File without changes
|
package/dist/index.d.ts
CHANGED
|
File without changes
|
package/dist/index.es.js
CHANGED
|
@@ -32336,7 +32336,6 @@ const Cw = Oe.create({
|
|
|
32336
32336
|
content: "text*",
|
|
32337
32337
|
group: "inline math",
|
|
32338
32338
|
inline: !0,
|
|
32339
|
-
atom: !1,
|
|
32340
32339
|
parseHTML() {
|
|
32341
32340
|
return [{ tag: "m" }];
|
|
32342
32341
|
},
|
|
@@ -32346,15 +32345,20 @@ const Cw = Oe.create({
|
|
|
32346
32345
|
addNodeView() {
|
|
32347
32346
|
return ({ node: r, HTMLAttributes: e }) => {
|
|
32348
32347
|
const t = document.createElement("span");
|
|
32349
|
-
t.classList.add("node-view"), Object.entries(e).forEach(([a, l]) => {
|
|
32348
|
+
t.classList.add("node-view", "math"), Object.entries(e).forEach(([a, l]) => {
|
|
32350
32349
|
t.setAttribute(a, l);
|
|
32351
32350
|
});
|
|
32352
32351
|
const n = document.createElement("span"), i = document.createElement("span"), s = r.textContent.trim();
|
|
32353
|
-
return n.innerHTML = gi.renderToString(s, { throwOnError: !1 }), n.contentEditable = "
|
|
32354
|
-
|
|
32352
|
+
return n.classList.add("katex-rendered"), n.innerHTML = gi.renderToString(s, { throwOnError: !1 }), n.contentEditable = "false", n.style.pointerEvents = "none", i.classList.add("edit-math"), i.classList.add("is-editable"), i.innerHTML = "<m>" + r.textContent + "</m>", i.contentEditable = "true", i.draggable = !1, new MutationObserver(() => {
|
|
32353
|
+
const a = i.textContent || "";
|
|
32354
|
+
n.innerHTML = gi.renderToString(a, {
|
|
32355
32355
|
throwOnError: !1
|
|
32356
32356
|
});
|
|
32357
|
-
}).observe(i, { characterData: !0, subtree: !0 }),
|
|
32357
|
+
}).observe(i, { characterData: !0, subtree: !0 }), i.addEventListener("focus", () => {
|
|
32358
|
+
t.classList.add("has-focus");
|
|
32359
|
+
}), i.addEventListener("blur", () => {
|
|
32360
|
+
t.classList.remove("has-focus");
|
|
32361
|
+
}), t.appendChild(i), t.appendChild(n), {
|
|
32358
32362
|
dom: t,
|
|
32359
32363
|
contentDOM: i
|
|
32360
32364
|
};
|
|
@@ -32374,15 +32378,20 @@ const Cw = Oe.create({
|
|
|
32374
32378
|
addNodeView() {
|
|
32375
32379
|
return ({ node: r, HTMLAttributes: e }) => {
|
|
32376
32380
|
const t = document.createElement("div");
|
|
32377
|
-
t.classList.add("node-view"), t.classList.add("display"), Object.entries(e).forEach(([a, l]) => {
|
|
32381
|
+
t.classList.add("node-view", "math"), t.classList.add("display"), Object.entries(e).forEach(([a, l]) => {
|
|
32378
32382
|
t.setAttribute(a, l);
|
|
32379
32383
|
});
|
|
32380
32384
|
const n = document.createElement("span"), i = document.createElement("span"), s = r.textContent.trim();
|
|
32381
|
-
return n.innerHTML = gi.renderToString(s, { throwOnError: !1 }), n.contentEditable = "false", i.classList.add("edit-math"), i.classList.add("is-editable"), i.innerHTML = "<md>" + r.textContent + "</md>", new MutationObserver(() => {
|
|
32382
|
-
|
|
32385
|
+
return n.classList.add("katex-rendered"), n.innerHTML = gi.renderToString(s, { throwOnError: !1 }), n.contentEditable = "false", n.style.pointerEvents = "none", i.classList.add("edit-math"), i.classList.add("is-editable"), i.contentEditable = "true", i.innerHTML = "<md>" + r.textContent + "</md>", i.draggable = !1, new MutationObserver(() => {
|
|
32386
|
+
const a = i.textContent || "";
|
|
32387
|
+
n.innerHTML = gi.renderToString(a, {
|
|
32383
32388
|
throwOnError: !1
|
|
32384
32389
|
});
|
|
32385
|
-
}).observe(i, { characterData: !0, subtree: !0 }),
|
|
32390
|
+
}).observe(i, { characterData: !0, subtree: !0 }), i.addEventListener("focus", () => {
|
|
32391
|
+
t.classList.add("has-focus");
|
|
32392
|
+
}), i.addEventListener("blur", () => {
|
|
32393
|
+
t.classList.remove("has-focus");
|
|
32394
|
+
}), t.appendChild(i), t.appendChild(n), {
|
|
32386
32395
|
dom: t,
|
|
32387
32396
|
contentDOM: i
|
|
32388
32397
|
};
|
|
@@ -32402,15 +32411,20 @@ const Cw = Oe.create({
|
|
|
32402
32411
|
addNodeView() {
|
|
32403
32412
|
return ({ node: r, HTMLAttributes: e }) => {
|
|
32404
32413
|
const t = document.createElement("div");
|
|
32405
|
-
t.classList.add("node-view"), t.classList.add("display"), Object.entries(e).forEach(([a, l]) => {
|
|
32414
|
+
t.classList.add("node-view", "math"), t.classList.add("display"), Object.entries(e).forEach(([a, l]) => {
|
|
32406
32415
|
t.setAttribute(a, l);
|
|
32407
32416
|
});
|
|
32408
32417
|
const n = document.createElement("span"), i = document.createElement("span"), s = r.textContent.trim();
|
|
32409
|
-
return n.innerHTML = gi.renderToString(s, { throwOnError: !1 }), n.contentEditable = "false", i.classList.add("edit-math"), i.classList.add("is-editable"), i.innerHTML = "<md>" + r.textContent + "</md>", new MutationObserver(() => {
|
|
32410
|
-
|
|
32418
|
+
return n.classList.add("katex-rendered"), n.innerHTML = gi.renderToString(s, { throwOnError: !1 }), n.contentEditable = "false", n.style.pointerEvents = "none", i.classList.add("edit-math"), i.classList.add("is-editable"), i.innerHTML = "<md>" + r.textContent + "</md>", i.contentEditable = "true", i.draggable = !1, new MutationObserver(() => {
|
|
32419
|
+
const a = i.textContent || "";
|
|
32420
|
+
n.innerHTML = gi.renderToString(a, {
|
|
32411
32421
|
throwOnError: !1
|
|
32412
32422
|
});
|
|
32413
|
-
}).observe(i, { characterData: !0, subtree: !0 }),
|
|
32423
|
+
}).observe(i, { characterData: !0, subtree: !0 }), i.addEventListener("focus", () => {
|
|
32424
|
+
t.classList.add("has-focus");
|
|
32425
|
+
}), i.addEventListener("blur", () => {
|
|
32426
|
+
t.classList.remove("has-focus");
|
|
32427
|
+
}), t.appendChild(i), t.appendChild(n), {
|
|
32414
32428
|
dom: t,
|
|
32415
32429
|
contentDOM: i
|
|
32416
32430
|
};
|