@fiduswriter/editor 0.1.68 → 0.1.69
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 +16 -159
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -27,25 +27,8 @@ clipboard import/export.
|
|
|
27
27
|
- **E2EE** — End-to-end encryption with key management and passphrase support
|
|
28
28
|
- **Clipboard** — Paste from Word, LibreOffice, Google Docs with format
|
|
29
29
|
preservation
|
|
30
|
-
- **Tables** — Full
|
|
31
|
-
|
|
32
|
-
- **Code blocks** — Syntax-highlighted code block editing
|
|
33
|
-
|
|
34
|
-
## Exports
|
|
35
|
-
|
|
36
|
-
| Export | Description |
|
|
37
|
-
|--------|-------------|
|
|
38
|
-
| `Editor` | Main editor class — orchestrates ProseMirror, collaboration, and all subsystems |
|
|
39
|
-
| `createStaticEditor` | High-level helper that creates and initializes an editor without a backend server |
|
|
40
|
-
| `createStaticApp` | Lower-level helper that builds an in-memory `EditorApp` for static deployments |
|
|
41
|
-
|
|
42
|
-
Additional modules are exported under subpaths:
|
|
43
|
-
- `./state_plugins` — ProseMirror state plugins
|
|
44
|
-
- `./state_plugins/*` — Individual plugins (inline math, references, links, etc.)
|
|
45
|
-
- `./menus` — Editor menus and toolbar
|
|
46
|
-
- `./dialogs` — Editor dialogs (figure, citation, link, table, etc.)
|
|
47
|
-
- `./keymap` — Keyboard shortcut bindings
|
|
48
|
-
- `./exporter/native/file` — Download the current document as a `.fidus` file
|
|
30
|
+
- **Tables, figures & equations** — Full editing support for tables, images,
|
|
31
|
+
math formulas, and code blocks
|
|
49
32
|
|
|
50
33
|
## Installation
|
|
51
34
|
|
|
@@ -58,163 +41,36 @@ npm install @fiduswriter/editor
|
|
|
58
41
|
The library can be used in two modes: **static** (no backend server, like the
|
|
59
42
|
standalone demo) or **server-backed** (the classic Fidus Writer Django setup).
|
|
60
43
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
For a statically served editor, use `createStaticEditor`. It sets up the runtime
|
|
64
|
-
globals, loads locale strings, creates the in-memory app shell, and initializes
|
|
65
|
-
the editor.
|
|
44
|
+
For a quick start without a backend, import `createStaticEditor` from the
|
|
45
|
+
`@fiduswriter/editor/static_editor` subpath:
|
|
66
46
|
|
|
67
47
|
```ts
|
|
68
48
|
import {createStaticEditor} from "@fiduswriter/editor/static_editor"
|
|
69
|
-
import {ExportFidusFile} from "@fiduswriter/editor/exporter/native/file"
|
|
70
49
|
|
|
71
50
|
const editor = await createStaticEditor({
|
|
72
51
|
locale: "en",
|
|
73
52
|
username: "Demo User",
|
|
74
|
-
documentData: async () => ({
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
comments: {},
|
|
79
|
-
bibliography: {},
|
|
80
|
-
images: {}
|
|
81
|
-
},
|
|
82
|
-
doc_info: {
|
|
83
|
-
id: 1,
|
|
84
|
-
rights: "write",
|
|
85
|
-
is_owner: true,
|
|
86
|
-
path: "",
|
|
87
|
-
updated: new Date(),
|
|
88
|
-
dir: "ltr",
|
|
89
|
-
access_rights: "write",
|
|
90
|
-
e2ee: false,
|
|
91
|
-
owner: {id: 1, name: "Demo User", type: "user", contacts: []}
|
|
92
|
-
},
|
|
93
|
-
time: Date.now()
|
|
94
|
-
}),
|
|
95
|
-
documentStyles: [
|
|
96
|
-
{
|
|
97
|
-
title: "Standard article",
|
|
98
|
-
slug: "standard-article",
|
|
99
|
-
contents: "",
|
|
100
|
-
documentstylefile_set: []
|
|
101
|
-
}
|
|
102
|
-
],
|
|
103
|
-
exportTemplates: [
|
|
104
|
-
{
|
|
105
|
-
title: "Fidus Writer",
|
|
106
|
-
file_type: "fidus",
|
|
107
|
-
template_file: "/static/export-templates/template.fidus"
|
|
108
|
-
}
|
|
109
|
-
],
|
|
110
|
-
documentTemplates: {
|
|
111
|
-
"1": {title: "Standard article"}
|
|
112
|
-
}
|
|
53
|
+
documentData: async () => ({doc, doc_info, time: Date.now()}),
|
|
54
|
+
documentStyles: [ /* style fixtures */ ],
|
|
55
|
+
exportTemplates: [ /* export template fixtures */ ],
|
|
56
|
+
documentTemplates: { /* document template fixtures */ }
|
|
113
57
|
})
|
|
114
|
-
|
|
115
|
-
// Download the document as a .fidus file.
|
|
116
|
-
const doc = editor.getDoc({use_current_view: true})
|
|
117
|
-
new ExportFidusFile(
|
|
118
|
-
editor.app,
|
|
119
|
-
doc,
|
|
120
|
-
editor.mod.db.bibDB,
|
|
121
|
-
editor.mod.db.imageDB,
|
|
122
|
-
false
|
|
123
|
-
)
|
|
124
58
|
```
|
|
125
59
|
|
|
126
|
-
|
|
127
|
-
are:
|
|
128
|
-
|
|
129
|
-
- `locale` — locale code, e.g. `"en"`.
|
|
130
|
-
- `username` / `user` — either a display name or a complete `EditorUser` object.
|
|
131
|
-
- `documentData` — async function returning `{doc, doc_info, time}`.
|
|
132
|
-
- `documentStyles`, `exportTemplates`, `documentTemplates` — template/style
|
|
133
|
-
fixtures used by the document template and export dialogs.
|
|
134
|
-
- `initialImages` — optional map of image entries to prime the image database.
|
|
135
|
-
- `getDocContent` — optional callback returning the current document content;
|
|
136
|
-
used to derive the correct document template for downloads.
|
|
137
|
-
- `onSaveDocument` — optional callback invoked when the editor tries to save.
|
|
138
|
-
- `staticBasePath` — base URL for resolving CSS and static assets.
|
|
139
|
-
- `plugins` — extra editor plugins, e.g. `[["demo", {MyPlugin}]]`.
|
|
140
|
-
|
|
141
|
-
> **Note:** Import `createStaticEditor` from `@fiduswriter/editor/static_editor`
|
|
142
|
-
> rather than the main package entry. This keeps the `Editor` class out of the
|
|
143
|
-
> initial bundle and ensures the runtime globals (`gettext`, `interpolate`,
|
|
144
|
-
> `staticUrl`) are set before any editor module is evaluated.
|
|
145
|
-
>
|
|
146
|
-
> If you bundle a static page with esbuild, configure a loader for `.gz` assets
|
|
147
|
-
> — `citeproc-plus` loads compressed style and locale files:
|
|
148
|
-
>
|
|
149
|
-
> ```js
|
|
150
|
-
> loader: { ".gz": "file" }
|
|
151
|
-
> ```
|
|
152
|
-
|
|
153
|
-
For more control, build the app shell manually with `createStaticApp` and then
|
|
154
|
-
instantiate the `Editor` class yourself:
|
|
155
|
-
|
|
156
|
-
```ts
|
|
157
|
-
import {Editor, createStaticApp} from "@fiduswriter/editor"
|
|
158
|
-
|
|
159
|
-
const app = await createStaticApp({
|
|
160
|
-
locale: "en",
|
|
161
|
-
gettext: msgid => msgid,
|
|
162
|
-
csl,
|
|
163
|
-
documentData: async () => ({doc, doc_info, time: Date.now()})
|
|
164
|
-
})
|
|
165
|
-
|
|
166
|
-
const editor = new Editor({app, user}, "", "1", [])
|
|
167
|
-
await editor.init()
|
|
168
|
-
```
|
|
60
|
+
Full API documentation, configuration options, and a complete server-backed
|
|
61
|
+
usage example are available on the project site:
|
|
169
62
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
When a backend server is available, construct `Editor` directly with an
|
|
173
|
-
`EditorApp` object that provides API connectors, settings, and the CSL engine.
|
|
174
|
-
This is how the main Fidus Writer Django application uses the library.
|
|
175
|
-
|
|
176
|
-
```ts
|
|
177
|
-
import {Editor} from "@fiduswriter/editor"
|
|
178
|
-
|
|
179
|
-
const editor = new Editor(
|
|
180
|
-
{app, user},
|
|
181
|
-
"/documents/123",
|
|
182
|
-
"123",
|
|
183
|
-
[["my-plugin", {MyPlugin}]]
|
|
184
|
-
)
|
|
185
|
-
await editor.init()
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
The `app` object must satisfy the `EditorApp` interface:
|
|
189
|
-
|
|
190
|
-
- `name` — application name.
|
|
191
|
-
- `routes` — route table used by the editor router.
|
|
192
|
-
- `goTo(url)` — navigate to a different route.
|
|
193
|
-
- `isOffline()` — return whether the browser is offline.
|
|
194
|
-
- `settings` — editor settings such as `EDITOR_SAVE_MODE`, `LANGUAGE`,
|
|
195
|
-
`E2EE_MODE`, and `APPS`.
|
|
196
|
-
- `csl` — a CSL engine instance.
|
|
197
|
-
- `apiConnectors` — connectors for `document`, `documentImport`, `image`,
|
|
198
|
-
`bibliography`, and `contacts` APIs.
|
|
199
|
-
- `bibDB` and `imageDB` — database instances for bibliography and images.
|
|
63
|
+
**<https://fiduswriter.codeberg.page/fiduswriter-editor-js/>**
|
|
200
64
|
|
|
201
65
|
## Demo
|
|
202
66
|
|
|
203
67
|
A standalone browser demo is published on Codeberg Pages:
|
|
204
68
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
The demo loads the editor without a Django backend. On startup it shows a
|
|
208
|
-
dialog where you can:
|
|
209
|
-
|
|
210
|
-
- Choose a language from the bundled `locale/*/messages.json` catalogs
|
|
211
|
-
(defaults to English).
|
|
212
|
-
- Import an existing document in `.fidus`, `.docx`, `.odt`, or Pandoc `.json`
|
|
213
|
-
format, with drag-and-drop support.
|
|
214
|
-
- Start a new document from a built-in default template.
|
|
215
|
-
- Optionally apply a `.fidustemplate` document template to a new document.
|
|
69
|
+
**<https://fiduswriter.codeberg.page/fiduswriter-editor-js/editor/>**
|
|
216
70
|
|
|
217
|
-
|
|
71
|
+
The demo loads the editor without a Django backend. On startup it lets you
|
|
72
|
+
choose a language, import an existing document, or start from a default
|
|
73
|
+
template. Changes are saved locally and can be downloaded as a `.fidus` file.
|
|
218
74
|
|
|
219
75
|
## Development
|
|
220
76
|
|
|
@@ -224,6 +80,7 @@ npm run build # Compile TypeScript to dist/
|
|
|
224
80
|
npm run typecheck # Check types without emitting
|
|
225
81
|
npm run lint # Lint with ESLint
|
|
226
82
|
npm run format:check # Check formatting with Prettier
|
|
83
|
+
npm test # Run the test suite
|
|
227
84
|
```
|
|
228
85
|
|
|
229
86
|
## License
|