@fiduswriter/editor 0.1.70 → 0.1.72
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/css/colors.css +1 -0
- package/css/editor.css +23 -5
- package/css/footnotes.css +14 -0
- package/css/margin_boxes.css +1 -6
- package/css/tracking.css +10 -0
- package/dist/comments/interactions.js +3 -1
- package/dist/comments/interactions.js.map +1 -1
- package/dist/marginboxes/index.d.ts +3 -1
- package/dist/marginboxes/index.d.ts.map +1 -1
- package/dist/marginboxes/index.js +62 -21
- package/dist/marginboxes/index.js.map +1 -1
- package/dist/marginboxes/templates.d.ts.map +1 -1
- package/dist/marginboxes/templates.js +42 -18
- package/dist/marginboxes/templates.js.map +1 -1
- package/dist/state_plugins/track/find_selected_changes.js +1 -1
- package/dist/state_plugins/track/find_selected_changes.js.map +1 -1
- package/dist/state_plugins/track/plugin.js +2 -2
- package/dist/state_plugins/track/plugin.js.map +1 -1
- package/dist/static_app.d.ts +5 -0
- package/dist/static_app.d.ts.map +1 -1
- package/dist/static_app.js +5 -0
- package/dist/static_app.js.map +1 -1
- package/dist/static_editor.d.ts +5 -0
- package/dist/static_editor.d.ts.map +1 -1
- package/dist/static_editor.js.map +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/src/comments/interactions.ts +3 -3
- package/src/marginboxes/index.ts +76 -24
- package/src/marginboxes/templates.ts +44 -10
- package/src/state_plugins/track/find_selected_changes.ts +1 -1
- package/src/state_plugins/track/plugin.ts +2 -2
- package/src/static_app.ts +10 -0
- package/src/static_editor.ts +5 -0
- package/src/types.ts +5 -0
|
@@ -108,6 +108,26 @@ interface MarginBoxOptionComment {
|
|
|
108
108
|
resolved?: boolean
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
/** A template for an answer to a comment */
|
|
112
|
+
const COMMENT_SHOW_MORE_THRESHOLD = 120
|
|
113
|
+
const COMMENT_TRUNCATE_LENGTH = 110
|
|
114
|
+
|
|
115
|
+
function commentContentTemplate({
|
|
116
|
+
serialized,
|
|
117
|
+
isGlobal
|
|
118
|
+
}: {
|
|
119
|
+
serialized: {html: string; text: string}
|
|
120
|
+
isGlobal: boolean
|
|
121
|
+
}): string {
|
|
122
|
+
if (isGlobal || serialized.text.length <= COMMENT_SHOW_MORE_THRESHOLD) {
|
|
123
|
+
return `<p class="comment-p">${serialized.html}</p>`
|
|
124
|
+
}
|
|
125
|
+
const truncatedText = `${escapeText(
|
|
126
|
+
serialized.text.slice(0, COMMENT_TRUNCATE_LENGTH - 1)
|
|
127
|
+
)}…`
|
|
128
|
+
return `<div class="comment-truncated"><p class="comment-p">${truncatedText}</p></div><div class="comment-full" style="display:none"><p class="comment-p">${serialized.html}</p></div>`
|
|
129
|
+
}
|
|
130
|
+
|
|
111
131
|
/** A template for an answer to a comment */
|
|
112
132
|
const answerCommentTemplate = ({
|
|
113
133
|
answer,
|
|
@@ -115,7 +135,8 @@ const answerCommentTemplate = ({
|
|
|
115
135
|
commentId,
|
|
116
136
|
activeCommentAnswerId,
|
|
117
137
|
active,
|
|
118
|
-
user
|
|
138
|
+
user,
|
|
139
|
+
isGlobal
|
|
119
140
|
}: {
|
|
120
141
|
answer: CommentAnswer
|
|
121
142
|
author: ContactPerson | undefined
|
|
@@ -123,8 +144,10 @@ const answerCommentTemplate = ({
|
|
|
123
144
|
activeCommentAnswerId: number | string | undefined
|
|
124
145
|
active: boolean
|
|
125
146
|
user: EditorUser
|
|
126
|
-
|
|
127
|
-
|
|
147
|
+
isGlobal: boolean
|
|
148
|
+
}) => {
|
|
149
|
+
const serialized = serializeComment(answer.answer)
|
|
150
|
+
return `<div class="comment-item comment-answer collapse ${active ? "show" : ""}" id="comment-answer-${answer.id}">
|
|
128
151
|
<div class="comment-user">
|
|
129
152
|
${author ? avatarTemplate({user: author}) : '<span class="fw-string-avatar"></span>'}
|
|
130
153
|
<h5 class="comment-user-name">${escapeText(author?.name || answer.username)}</h5>
|
|
@@ -138,11 +161,13 @@ const answerCommentTemplate = ({
|
|
|
138
161
|
</div>
|
|
139
162
|
</div>`
|
|
140
163
|
: `<div class="comment-text-wrapper">
|
|
141
|
-
|
|
164
|
+
${commentContentTemplate({serialized, isGlobal})}
|
|
142
165
|
</div>
|
|
143
166
|
<div class="comment-collapsible-buttons">
|
|
144
167
|
${
|
|
145
|
-
|
|
168
|
+
!isGlobal &&
|
|
169
|
+
serialized.text.length >
|
|
170
|
+
COMMENT_SHOW_MORE_THRESHOLD
|
|
146
171
|
? `<a type="button" class="comment-expand-compress show-more-less">${gettext("show more")}</a>`
|
|
147
172
|
: ""
|
|
148
173
|
}
|
|
@@ -154,6 +179,7 @@ const answerCommentTemplate = ({
|
|
|
154
179
|
}`
|
|
155
180
|
}
|
|
156
181
|
</div>`
|
|
182
|
+
}
|
|
157
183
|
|
|
158
184
|
interface SingleCommentTemplateProps {
|
|
159
185
|
comment: Comment
|
|
@@ -168,8 +194,9 @@ const singleCommentTemplate = ({
|
|
|
168
194
|
author,
|
|
169
195
|
active,
|
|
170
196
|
editComment
|
|
171
|
-
}: SingleCommentTemplateProps) =>
|
|
172
|
-
|
|
197
|
+
}: SingleCommentTemplateProps) => {
|
|
198
|
+
const serialized = serializeComment(comment.comment)
|
|
199
|
+
return `<div class="comment-item">
|
|
173
200
|
<div class="comment-user">
|
|
174
201
|
${author ? avatarTemplate({user: author}) : '<span class="fw-string-avatar"></span>'}
|
|
175
202
|
<h5 class="comment-user-name">${escapeText(author?.name || comment.username)}</h5>
|
|
@@ -179,13 +206,18 @@ const singleCommentTemplate = ({
|
|
|
179
206
|
${
|
|
180
207
|
active && editComment
|
|
181
208
|
? '<div id="comment-editor"></div>'
|
|
182
|
-
:
|
|
209
|
+
: `${commentContentTemplate({
|
|
210
|
+
serialized,
|
|
211
|
+
isGlobal: !!comment.isGlobal
|
|
212
|
+
})}`
|
|
183
213
|
}
|
|
184
214
|
</div>
|
|
185
215
|
<div class="comment-collapsible-buttons">
|
|
186
216
|
${
|
|
187
217
|
!editComment &&
|
|
188
|
-
|
|
218
|
+
!comment.isGlobal &&
|
|
219
|
+
serialized.text.length >
|
|
220
|
+
COMMENT_SHOW_MORE_THRESHOLD
|
|
189
221
|
? `<a type="button" class="comment-expand-compress show-more-less">${gettext("show more")}</a>`
|
|
190
222
|
: ""
|
|
191
223
|
}
|
|
@@ -196,6 +228,7 @@ const singleCommentTemplate = ({
|
|
|
196
228
|
}
|
|
197
229
|
</div>
|
|
198
230
|
</div>`
|
|
231
|
+
}
|
|
199
232
|
|
|
200
233
|
/** A template for the editor of a first comment before it has been saved (not an answer to a comment). */
|
|
201
234
|
const firstCommentTemplate = ({
|
|
@@ -330,7 +363,8 @@ ${
|
|
|
330
363
|
commentId: comment.id,
|
|
331
364
|
active,
|
|
332
365
|
activeCommentAnswerId,
|
|
333
|
-
user
|
|
366
|
+
user,
|
|
367
|
+
isGlobal: !!comment.isGlobal
|
|
334
368
|
})
|
|
335
369
|
)
|
|
336
370
|
.join("")
|
|
@@ -84,7 +84,7 @@ export function trackPlugin(options: {editor: Editor}) {
|
|
|
84
84
|
decos: DecorationSet.empty
|
|
85
85
|
}
|
|
86
86
|
},
|
|
87
|
-
apply(tr, _prev,
|
|
87
|
+
apply(tr, _prev, oldState, state) {
|
|
88
88
|
const meta = tr.getMeta(key)
|
|
89
89
|
if (meta) {
|
|
90
90
|
// There has been an update, return values from meta instead
|
|
@@ -92,7 +92,7 @@ export function trackPlugin(options: {editor: Editor}) {
|
|
|
92
92
|
return meta
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
const oldPluginState = key.getState(
|
|
95
|
+
const oldPluginState = key.getState(oldState) as {decos: DecorationSet} | undefined
|
|
96
96
|
if (!oldPluginState) {
|
|
97
97
|
return {decos: DecorationSet.empty}
|
|
98
98
|
}
|
package/src/static_app.ts
CHANGED
|
@@ -77,6 +77,11 @@ export interface StaticAppConfig {
|
|
|
77
77
|
json: Record<string, unknown>
|
|
78
78
|
status: number
|
|
79
79
|
}>
|
|
80
|
+
/**
|
|
81
|
+
* Optional user preferences that control inline editing helpers.
|
|
82
|
+
* Recognized keys include `inline_references` and `inline_math`.
|
|
83
|
+
*/
|
|
84
|
+
userPreferences?: Record<string, boolean>
|
|
80
85
|
}
|
|
81
86
|
|
|
82
87
|
interface StoredImage {
|
|
@@ -340,6 +345,11 @@ export async function createStaticApp(
|
|
|
340
345
|
LANGUAGE: config.locale
|
|
341
346
|
},
|
|
342
347
|
csl: config.csl,
|
|
348
|
+
config: {
|
|
349
|
+
user: {
|
|
350
|
+
preferences: config.userPreferences ?? {}
|
|
351
|
+
}
|
|
352
|
+
},
|
|
343
353
|
apiConnectors: {
|
|
344
354
|
document: documentApi,
|
|
345
355
|
documentImport: documentImportApi,
|
package/src/static_editor.ts
CHANGED
|
@@ -36,6 +36,11 @@ export interface StaticEditorConfig
|
|
|
36
36
|
}>
|
|
37
37
|
/** Optional extra editor plugins. */
|
|
38
38
|
plugins?: Array<[string, Record<string, unknown>]>
|
|
39
|
+
/**
|
|
40
|
+
* Optional user preferences that control inline editing helpers.
|
|
41
|
+
* Recognized keys include `inline_references` and `inline_math`.
|
|
42
|
+
*/
|
|
43
|
+
userPreferences?: Record<string, boolean>
|
|
39
44
|
}
|
|
40
45
|
|
|
41
46
|
async function loadLocaleCatalog(
|
package/src/types.ts
CHANGED
|
@@ -122,6 +122,11 @@ export interface EditorApp {
|
|
|
122
122
|
csl: CSL
|
|
123
123
|
bibDB?: EditorBibDB
|
|
124
124
|
imageDB: EditorImageDB
|
|
125
|
+
config?: {
|
|
126
|
+
user?: {
|
|
127
|
+
preferences?: Record<string, boolean>
|
|
128
|
+
}
|
|
129
|
+
}
|
|
125
130
|
apiConnectors: {
|
|
126
131
|
document: EditorDocumentApi
|
|
127
132
|
documentImport: EditorDocumentImportApi
|