@fiduswriter/editor 0.1.68 → 0.1.70

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 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 table editing with column/row operations
31
- - **Figures & equations** — Image and math formula editing with captions
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
- ### Static usage
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
- doc: {
76
- v: 0,
77
- content: { /* ProseMirror document JSON */ },
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
- `createStaticEditor` accepts a `StaticEditorConfig`. The most important options
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
- ### Server-backed usage
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
- **https://fiduswriter.codeberg.page/fiduswriter-editor-js/**
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
- Changes are saved locally and can be downloaded as a `.fidus` file.
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
@@ -1 +1 @@
1
- {"version":3,"file":"static_editor.d.ts","sourceRoot":"","sources":["../src/static_editor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,GAAG,EAAE,UAAU,EAAC,MAAM,YAAY,CAAA;AAC/C,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,iBAAiB,CAAA;AAEpD,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,YAAY,CAAA;AAEtC,YAAY,EAAC,eAAe,EAAC,MAAM,iBAAiB,CAAA;AAEpD,MAAM,WAAW,kBACb,SAAQ,IAAI,CAAC,eAAe,EAAE,SAAS,GAAG,KAAK,CAAC;IAChD,mGAAmG;IACnG,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,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AG,CAAC,EAAE,GAAG,CAAA;IACT,yFAAyF;IACzF,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,+DAA+D;IAC/D,IAAI,CAAC,EAAE,UAAU,CAAA;IACjB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACtC;;OAEG;IACH,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC;QACxD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QAC7B,MAAM,EAAE,MAAM,CAAA;KACjB,CAAC,CAAA;IACF,qCAAqC;IACrC,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;CACrD;AAuDD;;;;;;;;;GASG;AACH,wBAAsB,kBAAkB,CACpC,MAAM,EAAE,kBAAkB,GAC3B,OAAO,CAAC,MAAM,CAAC,CAoGjB"}
@@ -30,6 +30,17 @@ function defaultStaticUrl(basePath) {
30
30
  return `${basePath}static/${path}`;
31
31
  };
32
32
  }
33
+ function ensureResetCSS(basePath) {
34
+ const href = `${basePath}css/reset.css`;
35
+ if (document.querySelector(`link[rel="stylesheet"][href="${href}"]`) ||
36
+ document.querySelector('link[rel="stylesheet"][href$="css/reset.css"]')) {
37
+ return;
38
+ }
39
+ const link = document.createElement("link");
40
+ link.rel = "stylesheet";
41
+ link.href = href;
42
+ document.head.insertBefore(link, document.head.firstChild);
43
+ }
33
44
  /**
34
45
  * Create and initialize a statically served Fidus Writer editor.
35
46
  *
@@ -53,6 +64,7 @@ export async function createStaticEditor(config) {
53
64
  const localeGettext = config.gettext ?? createGettext(catalog);
54
65
  const basePath = config.staticBasePath ??
55
66
  window.location.pathname.replace(/\/(?:editor\/(?:index\.html)?|index\.html)$/, "/");
67
+ ensureResetCSS(basePath);
56
68
  initSettings({
57
69
  apiUrl: url => url,
58
70
  apiUrlMap: {},
@@ -1 +1 @@
1
- {"version":3,"file":"static_editor.js","sourceRoot":"","sources":["../src/static_editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAC,MAAM,WAAW,CAAA;AAwCvE,KAAK,UAAU,iBAAiB,CAC5B,MAAc;IAEd,IAAI,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,aAAa,MAAM,gBAAgB,CAAC,CAAA;QACjE,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACf,OAAO,EAAE,CAAA;QACb,CAAC;QACD,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAA2B,CAAA;IAC5D,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,EAAE,CAAA;IACb,CAAC;AACL,CAAC;AAED,SAAS,aAAa,CAAC,OAA+B;IAClD,OAAO,SAAS,WAAW,CAAC,KAAa;QACrC,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAA;IAClC,CAAC,CAAA;AACL,CAAC;AAED,SAAS,gBAAgB,CAAC,QAAgB;IACtC,OAAO,CAAC,IAAY,EAAE,EAAE;QACpB,IAAI,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;YACjC,OAAO,GAAG,QAAQ,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAA;QAC/D,CAAC;QACD,IAAI,IAAI,KAAK,mCAAmC,EAAE,CAAC;YAC/C,OAAO,GAAG,QAAQ,sBAAsB,CAAA;QAC5C,CAAC;QACD,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YAC1B,OAAO,GAAG,QAAQ,GAAG,IAAI,EAAE,CAAA;QAC/B,CAAC;QACD,OAAO,GAA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AC,eAAe,EAAC,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC,CAAA;IAEzD,MAAM,GAAG,GAAG,MAAM,eAAe,CAAC;QAC9B,GAAG,MAAM;QACT,MAAM;QACN,OAAO,EAAE,aAAa;QACtB,GAAG;QACH,cAAc,EAAE,MAAM,CAAC,cAAc;KACxC,CAAC,CAAA;IAEF,uEAAuE;IACvE,wCAAwC;IACxC,MAAM,OAAO,CAAC,GAAG,CAAC;QACb,GAAG,CAAC,KAAa,CAAC,KAAK,EAAE;QACzB,GAAG,CAAC,OAAe,CAAC,KAAK,EAAE;KAC/B,CAAC,CAAA;IAEF,MAAM,OAAO,GAAG,CAAC,MAAM,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC,QAAQ,CAAA;IACtD,MAAM,KAAK,GAAI,OAAO,EAAE,EAAsB,IAAI,CAAC,CAAA;IACnD,MAAM,OAAO,GAAI,OAAO,EAAE,IAAe,IAAI,EAAE,CAAA;IAE/C,MAAM,EAAC,MAAM,EAAC,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,CAAA;IAE3C,MAAM,MAAM,GAAG,IAAI,MAAM,CACrB,EAAC,GAAG,EAAE,IAAI,EAAC,EACX,OAAO,EACP,MAAM,CAAC,KAAK,CAAC,EACb,MAAM,CAAC,OAAO,IAAK,EAA+C,CACrE,CAAA;IAED,MAAM,MAAM,CAAC,IAAI,EAAE,CAAA;IACnB,OAAO,MAAM,CAAA;AACjB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiduswriter/editor",
3
- "version": "0.1.68",
3
+ "version": "0.1.70",
4
4
  "description": "Fidus Writer browser editor",
5
5
  "keywords": [
6
6
  "fiduswriter",
@@ -102,7 +102,7 @@
102
102
  "fast-xml-parser": "^4.5.0",
103
103
  "fastdom": "^1.0.11",
104
104
  "fix-utf8": "^2.0.1",
105
- "fwtoolkit": "^0.2.5",
105
+ "fwtoolkit": "^0.2.6",
106
106
  "jszip": "^3.10.1",
107
107
  "mathml-to-latex": "^1.4.3",
108
108
  "mathml2omml": "^0.5.0",
@@ -73,6 +73,24 @@ function defaultStaticUrl(basePath: string): (path: string) => string {
73
73
  }
74
74
  }
75
75
 
76
+ function ensureResetCSS(basePath: string): void {
77
+ const href = `${basePath}css/reset.css`
78
+ if (
79
+ document.querySelector(
80
+ `link[rel="stylesheet"][href="${href}"]`
81
+ ) ||
82
+ document.querySelector(
83
+ 'link[rel="stylesheet"][href$="css/reset.css"]'
84
+ )
85
+ ) {
86
+ return
87
+ }
88
+ const link = document.createElement("link")
89
+ link.rel = "stylesheet"
90
+ link.href = href
91
+ document.head.insertBefore(link, document.head.firstChild)
92
+ }
93
+
76
94
  /**
77
95
  * Create and initialize a statically served Fidus Writer editor.
78
96
  *
@@ -105,6 +123,8 @@ export async function createStaticEditor(
105
123
  "/"
106
124
  )
107
125
 
126
+ ensureResetCSS(basePath)
127
+
108
128
  initSettings({
109
129
  apiUrl: url => url,
110
130
  apiUrlMap: {},