@folijs/core 0.5.0 → 1.0.0
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/CHANGELOG.md +187 -0
- package/README.md +1 -1
- package/dist/document.d.ts +0 -7
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +5 -1
- package/dist/document.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -4
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +5 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +7 -0
- package/dist/internal.js.map +1 -0
- package/dist/model/attrs.d.ts +0 -10
- package/dist/model/attrs.d.ts.map +1 -1
- package/dist/model/attrs.js +10 -2
- package/dist/model/attrs.js.map +1 -1
- package/dist/model/content.d.ts +1 -1
- package/dist/model/content.d.ts.map +1 -1
- package/dist/model/content.js +1 -1
- package/dist/model/content.js.map +1 -1
- package/dist/model/errors.d.ts +0 -2
- package/dist/model/errors.d.ts.map +1 -1
- package/dist/model/errors.js +4 -1
- package/dist/model/errors.js.map +1 -1
- package/dist/model/fragment.d.ts +1 -1
- package/dist/model/fragment.d.ts.map +1 -1
- package/dist/model/fragment.js +3 -1
- package/dist/model/fragment.js.map +1 -1
- package/dist/model/mark.d.ts +1 -1
- package/dist/model/mark.d.ts.map +1 -1
- package/dist/model/mark.js +1 -1
- package/dist/model/mark.js.map +1 -1
- package/dist/model/node.d.ts +4 -4
- package/dist/model/node.d.ts.map +1 -1
- package/dist/model/node.js +8 -4
- package/dist/model/node.js.map +1 -1
- package/dist/model/schema.d.ts +8 -8
- package/dist/model/schema.d.ts.map +1 -1
- package/dist/model/schema.js +4 -3
- package/dist/model/schema.js.map +1 -1
- package/dist/schema.d.ts +0 -11
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +2 -0
- package/dist/schema.js.map +1 -1
- package/dist/state/attempt.d.ts +1 -3
- package/dist/state/attempt.d.ts.map +1 -1
- package/dist/state/commands.d.ts +2 -0
- package/dist/state/commands.d.ts.map +1 -1
- package/dist/state/commands.js +38 -6
- package/dist/state/commands.js.map +1 -1
- package/dist/state/comments.d.ts +1 -7
- package/dist/state/comments.d.ts.map +1 -1
- package/dist/state/comments.js +13 -3
- package/dist/state/comments.js.map +1 -1
- package/dist/state/controls.d.ts +110 -0
- package/dist/state/controls.d.ts.map +1 -0
- package/dist/state/controls.js +1473 -0
- package/dist/state/controls.js.map +1 -0
- package/dist/state/editor.d.ts +188 -68
- package/dist/state/editor.d.ts.map +1 -1
- package/dist/state/editor.js +265 -79
- package/dist/state/editor.js.map +1 -1
- package/dist/state/fields.d.ts +68 -0
- package/dist/state/fields.d.ts.map +1 -0
- package/dist/state/fields.js +410 -0
- package/dist/state/fields.js.map +1 -0
- package/dist/state/fieldupdate.d.ts +132 -0
- package/dist/state/fieldupdate.d.ts.map +1 -0
- package/dist/state/fieldupdate.js +1575 -0
- package/dist/state/fieldupdate.js.map +1 -0
- package/dist/state/find.d.ts +66 -0
- package/dist/state/find.d.ts.map +1 -0
- package/dist/state/find.js +405 -0
- package/dist/state/find.js.map +1 -0
- package/dist/state/history.d.ts +2 -0
- package/dist/state/history.d.ts.map +1 -1
- package/dist/state/history.js +44 -7
- package/dist/state/history.js.map +1 -1
- package/dist/state/index.d.ts +13 -6
- package/dist/state/index.d.ts.map +1 -1
- package/dist/state/index.js +12 -5
- package/dist/state/index.js.map +1 -1
- package/dist/state/lists.d.ts +3 -3
- package/dist/state/lists.d.ts.map +1 -1
- package/dist/state/lists.js.map +1 -1
- package/dist/state/mark.d.ts +1 -17
- package/dist/state/mark.d.ts.map +1 -1
- package/dist/state/mark.js +10 -1
- package/dist/state/mark.js.map +1 -1
- package/dist/state/navigation.d.ts +70 -0
- package/dist/state/navigation.d.ts.map +1 -0
- package/dist/state/navigation.js +226 -0
- package/dist/state/navigation.js.map +1 -0
- package/dist/state/notes.d.ts +84 -0
- package/dist/state/notes.d.ts.map +1 -0
- package/dist/state/notes.js +451 -0
- package/dist/state/notes.js.map +1 -0
- package/dist/state/review.d.ts +8 -4
- package/dist/state/review.d.ts.map +1 -1
- package/dist/state/review.js +134 -18
- package/dist/state/review.js.map +1 -1
- package/dist/state/sections.d.ts +91 -0
- package/dist/state/sections.d.ts.map +1 -0
- package/dist/state/sections.js +479 -0
- package/dist/state/sections.js.map +1 -0
- package/dist/state/state.d.ts +13 -7
- package/dist/state/state.d.ts.map +1 -1
- package/dist/state/state.js +9 -2
- package/dist/state/state.js.map +1 -1
- package/dist/state/stories.d.ts +2 -0
- package/dist/state/stories.d.ts.map +1 -0
- package/dist/state/stories.js +259 -0
- package/dist/state/stories.js.map +1 -0
- package/dist/state/tables.d.ts +1 -36
- package/dist/state/tables.d.ts.map +1 -1
- package/dist/state/tables.js +25 -6
- package/dist/state/tables.js.map +1 -1
- package/dist/state/track.d.ts +1 -6
- package/dist/state/track.d.ts.map +1 -1
- package/dist/state/track.js +65 -9
- package/dist/state/track.js.map +1 -1
- package/dist/state/word.d.ts +47 -55
- package/dist/state/word.d.ts.map +1 -1
- package/dist/state/word.js +306 -19
- package/dist/state/word.js.map +1 -1
- package/dist/state/wordclip.d.ts +17 -6
- package/dist/state/wordclip.d.ts.map +1 -1
- package/dist/state/wordclip.js +254 -17
- package/dist/state/wordclip.js.map +1 -1
- package/dist/state/wordformat.d.ts +1 -86
- package/dist/state/wordformat.d.ts.map +1 -1
- package/dist/state/wordformat.js +114 -12
- package/dist/state/wordformat.js.map +1 -1
- package/dist/transform/stepmap.d.ts +0 -2
- package/dist/transform/stepmap.d.ts.map +1 -1
- package/dist/v3/check.d.ts +0 -25
- package/dist/v3/check.d.ts.map +1 -1
- package/dist/v3/check.js +35 -7
- package/dist/v3/check.js.map +1 -1
- package/dist/v3/document.d.ts +135 -10
- package/dist/v3/document.d.ts.map +1 -1
- package/dist/v3/document.js +192 -38
- package/dist/v3/document.js.map +1 -1
- package/dist/v3/extensions.d.ts +43 -0
- package/dist/v3/extensions.d.ts.map +1 -0
- package/dist/v3/extensions.js +154 -0
- package/dist/v3/extensions.js.map +1 -0
- package/dist/v3/index.d.ts +3 -2
- package/dist/v3/index.d.ts.map +1 -1
- package/dist/v3/index.js +3 -2
- package/dist/v3/index.js.map +1 -1
- package/dist/v3/resolve.d.ts +9 -3
- package/dist/v3/resolve.d.ts.map +1 -1
- package/dist/v3/resolve.js +28 -4
- package/dist/v3/resolve.js.map +1 -1
- package/dist/v3/schema.d.ts +5 -16
- package/dist/v3/schema.d.ts.map +1 -1
- package/dist/v3/schema.js +167 -7
- package/dist/v3/schema.js.map +1 -1
- package/package.json +5 -1
- package/src/document.ts +5 -1
- package/src/index.ts +330 -4
- package/src/internal.ts +50 -0
- package/src/model/attrs.ts +10 -2
- package/src/model/content.ts +1 -1
- package/src/model/errors.ts +4 -1
- package/src/model/fragment.ts +2 -1
- package/src/model/mark.ts +1 -1
- package/src/model/node.ts +6 -4
- package/src/model/schema.ts +9 -3
- package/src/schema.ts +2 -0
- package/src/state/commands.ts +41 -4
- package/src/state/comments.ts +12 -3
- package/src/state/controls.ts +1612 -0
- package/src/state/editor.ts +508 -143
- package/src/state/fields.ts +444 -0
- package/src/state/fieldupdate.ts +1771 -0
- package/src/state/find.ts +518 -0
- package/src/state/history.ts +53 -7
- package/src/state/index.ts +125 -1
- package/src/state/lists.ts +2 -2
- package/src/state/mark.ts +10 -1
- package/src/state/navigation.ts +305 -0
- package/src/state/notes.ts +529 -0
- package/src/state/numeric-pictures.word.json +172 -0
- package/src/state/review.ts +172 -19
- package/src/state/sections.ts +578 -0
- package/src/state/state.ts +21 -3
- package/src/state/stories.ts +312 -0
- package/src/state/tables.ts +29 -7
- package/src/state/track.ts +72 -10
- package/src/state/word.ts +360 -24
- package/src/state/wordclip.ts +282 -32
- package/src/state/wordformat.ts +116 -12
- package/src/v3/check.ts +35 -7
- package/src/v3/document.ts +358 -50
- package/src/v3/extensions.ts +201 -0
- package/src/v3/index.ts +16 -0
- package/src/v3/resolve.ts +38 -9
- package/src/v3/schema.ts +174 -7
package/src/index.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// The public API of @folijs/core (ADR-0008), listed by name: what this file exports and
|
|
2
|
+
// docs/api.md lists is the 1.x promise. Names other packages need without a promise are on
|
|
3
|
+
// `@folijs/core/internal` (internal.ts); every other export is tagged internal and stripped from
|
|
4
|
+
// the published types.
|
|
1
5
|
export {
|
|
2
6
|
DEFAULT_SETTINGS,
|
|
3
7
|
type DocumentSettings,
|
|
@@ -7,7 +11,30 @@ export {
|
|
|
7
11
|
type PageSize,
|
|
8
12
|
parseContentV2,
|
|
9
13
|
} from "./document.js";
|
|
10
|
-
export
|
|
14
|
+
export {
|
|
15
|
+
type AttributeSpec,
|
|
16
|
+
type AttributeSpecs,
|
|
17
|
+
type Attrs,
|
|
18
|
+
ContentMatch,
|
|
19
|
+
FoliDocumentError,
|
|
20
|
+
Fragment,
|
|
21
|
+
Mark,
|
|
22
|
+
type MarkJSON,
|
|
23
|
+
type MarkSpec,
|
|
24
|
+
MarkType,
|
|
25
|
+
Node,
|
|
26
|
+
type NodeJSON,
|
|
27
|
+
NodeRange,
|
|
28
|
+
type NodeSpec,
|
|
29
|
+
NodeType,
|
|
30
|
+
ReplaceError,
|
|
31
|
+
ResolvedPos,
|
|
32
|
+
Schema,
|
|
33
|
+
type SchemaSpec,
|
|
34
|
+
Slice,
|
|
35
|
+
type SliceJSON,
|
|
36
|
+
TextNode,
|
|
37
|
+
} from "./model/index.js";
|
|
11
38
|
export {
|
|
12
39
|
ALIGNMENTS,
|
|
13
40
|
type Alignment,
|
|
@@ -37,6 +64,305 @@ export {
|
|
|
37
64
|
type SimpleMarkName,
|
|
38
65
|
type TextJSON,
|
|
39
66
|
} from "./schema.js";
|
|
40
|
-
export
|
|
41
|
-
|
|
42
|
-
|
|
67
|
+
export {
|
|
68
|
+
AllSelection,
|
|
69
|
+
acceptAllChanges,
|
|
70
|
+
acceptChange,
|
|
71
|
+
addComment,
|
|
72
|
+
addRepeatingItem,
|
|
73
|
+
alignAt,
|
|
74
|
+
arrowAcrossLeaf,
|
|
75
|
+
autolinkHref,
|
|
76
|
+
type BookmarkInfo,
|
|
77
|
+
type BookmarkResult,
|
|
78
|
+
type BuiltInCommands,
|
|
79
|
+
baseKeymap,
|
|
80
|
+
CellSelection,
|
|
81
|
+
type Change,
|
|
82
|
+
type ChangeFilter,
|
|
83
|
+
type ChangeKind,
|
|
84
|
+
type Command,
|
|
85
|
+
type CommentContent,
|
|
86
|
+
type CommentOptions,
|
|
87
|
+
type ControlInsertOptions,
|
|
88
|
+
type ControlPropertiesPatch,
|
|
89
|
+
type ControlRange,
|
|
90
|
+
type ControlValue,
|
|
91
|
+
type ControlValueInput,
|
|
92
|
+
type CrossReference,
|
|
93
|
+
type CrossReferenceTargets,
|
|
94
|
+
canOutdent,
|
|
95
|
+
cellsAsTable,
|
|
96
|
+
changeIndent,
|
|
97
|
+
closeHistory,
|
|
98
|
+
colorAt,
|
|
99
|
+
commentAnchors,
|
|
100
|
+
controlAt,
|
|
101
|
+
controlIsReadOnly,
|
|
102
|
+
controlProperties,
|
|
103
|
+
controlsIn,
|
|
104
|
+
controlValues,
|
|
105
|
+
convertNotes,
|
|
106
|
+
createEditor,
|
|
107
|
+
crossReferenceTargets,
|
|
108
|
+
type DeleteUnit,
|
|
109
|
+
type DocumentTarget,
|
|
110
|
+
deleteAllComments,
|
|
111
|
+
deleteBackward,
|
|
112
|
+
deleteBookmark,
|
|
113
|
+
deleteColumns,
|
|
114
|
+
deleteComment,
|
|
115
|
+
deleteForward,
|
|
116
|
+
deleteRows,
|
|
117
|
+
deleteSelection,
|
|
118
|
+
deleteTable,
|
|
119
|
+
documentOutline,
|
|
120
|
+
documentSections,
|
|
121
|
+
type Editor,
|
|
122
|
+
type EditorDocument,
|
|
123
|
+
type EditorListener,
|
|
124
|
+
type EditorOptions,
|
|
125
|
+
EditorState,
|
|
126
|
+
type EditorStateConfig,
|
|
127
|
+
editComment,
|
|
128
|
+
ensureStory,
|
|
129
|
+
extendCellSelection,
|
|
130
|
+
type Field,
|
|
131
|
+
type FieldDisplay,
|
|
132
|
+
type FieldInstruction,
|
|
133
|
+
type FieldLayout,
|
|
134
|
+
type FieldPage,
|
|
135
|
+
type FieldSkip,
|
|
136
|
+
type FieldSkipReason,
|
|
137
|
+
type FieldsReport,
|
|
138
|
+
type FindMatch,
|
|
139
|
+
type FindOptions,
|
|
140
|
+
type FoliCommands,
|
|
141
|
+
type FoundMatches,
|
|
142
|
+
fieldAround,
|
|
143
|
+
fieldCodesShown,
|
|
144
|
+
fieldDisplay,
|
|
145
|
+
fieldsIn,
|
|
146
|
+
findAll,
|
|
147
|
+
findInText,
|
|
148
|
+
fontFamilyAt,
|
|
149
|
+
fontSizeAt,
|
|
150
|
+
formatDatePicture,
|
|
151
|
+
formatNumericPicture,
|
|
152
|
+
goTo,
|
|
153
|
+
goToCell,
|
|
154
|
+
goToCellVertically,
|
|
155
|
+
HIGHLIGHT_HEX,
|
|
156
|
+
type HistoryOptions,
|
|
157
|
+
history,
|
|
158
|
+
type InsertFieldOptions,
|
|
159
|
+
type InsertNoteOptions,
|
|
160
|
+
insertBookmark,
|
|
161
|
+
insertColumn,
|
|
162
|
+
insertColumnBreak,
|
|
163
|
+
insertControl,
|
|
164
|
+
insertControlText,
|
|
165
|
+
insertCrossReference,
|
|
166
|
+
insertDate,
|
|
167
|
+
insertField,
|
|
168
|
+
insertHardBreak,
|
|
169
|
+
insertLink,
|
|
170
|
+
insertNote,
|
|
171
|
+
insertPageBreak,
|
|
172
|
+
insertPageNumber,
|
|
173
|
+
insertPicture,
|
|
174
|
+
insertRow,
|
|
175
|
+
insertSectionBreak,
|
|
176
|
+
insertTab,
|
|
177
|
+
insertTable,
|
|
178
|
+
insertTableOfContents,
|
|
179
|
+
insertText,
|
|
180
|
+
isBookmarkName,
|
|
181
|
+
isHeaderRow,
|
|
182
|
+
isMarkActive,
|
|
183
|
+
joinBackward,
|
|
184
|
+
joinForward,
|
|
185
|
+
joinHistory,
|
|
186
|
+
type ListKind,
|
|
187
|
+
liftListItem,
|
|
188
|
+
liftListItemAtStart,
|
|
189
|
+
lineSpacingAt,
|
|
190
|
+
linkAt,
|
|
191
|
+
linkEditorRequest,
|
|
192
|
+
listBookmarks,
|
|
193
|
+
listKeymap,
|
|
194
|
+
listKindAt,
|
|
195
|
+
marksAt,
|
|
196
|
+
mergeCells,
|
|
197
|
+
type NavigationRequest,
|
|
198
|
+
type NewPicture,
|
|
199
|
+
NodeSelection,
|
|
200
|
+
type NoteKind,
|
|
201
|
+
type NoteNumber,
|
|
202
|
+
type NoteNumberOptions,
|
|
203
|
+
nextChange,
|
|
204
|
+
nextMatch,
|
|
205
|
+
normalizeHref,
|
|
206
|
+
noteAtSelection,
|
|
207
|
+
noteNumbers,
|
|
208
|
+
noteProperties,
|
|
209
|
+
noteTexts,
|
|
210
|
+
type OpenStory,
|
|
211
|
+
type OutlineEntry,
|
|
212
|
+
openLinkEditor,
|
|
213
|
+
Plugin,
|
|
214
|
+
PluginKey,
|
|
215
|
+
type PluginSpec,
|
|
216
|
+
pageVariant,
|
|
217
|
+
paragraphStyleAt,
|
|
218
|
+
paragraphStyles,
|
|
219
|
+
parseFieldInstruction,
|
|
220
|
+
pasteCells,
|
|
221
|
+
previousChange,
|
|
222
|
+
type ReplaceRefusal,
|
|
223
|
+
type ReplaceReport,
|
|
224
|
+
type ReviewView,
|
|
225
|
+
redo,
|
|
226
|
+
redoDepth,
|
|
227
|
+
rejectAllChanges,
|
|
228
|
+
rejectChange,
|
|
229
|
+
removeLink,
|
|
230
|
+
removeSectionBreak,
|
|
231
|
+
renameBookmark,
|
|
232
|
+
replace,
|
|
233
|
+
replaceAll,
|
|
234
|
+
replyToComment,
|
|
235
|
+
requestsLinkEditor,
|
|
236
|
+
resolveComment,
|
|
237
|
+
type SectionAt,
|
|
238
|
+
type SectionBreakKind,
|
|
239
|
+
type SectionColumns,
|
|
240
|
+
type SectionSetup,
|
|
241
|
+
Selection,
|
|
242
|
+
type SelectionJSON,
|
|
243
|
+
type StorySide,
|
|
244
|
+
type StoryVariant,
|
|
245
|
+
type StoryView,
|
|
246
|
+
sectionAt,
|
|
247
|
+
sectionColumns,
|
|
248
|
+
sectionSettings,
|
|
249
|
+
selectAll,
|
|
250
|
+
selectedPicture,
|
|
251
|
+
setAlign,
|
|
252
|
+
setBlockType,
|
|
253
|
+
setCellShading,
|
|
254
|
+
setColumnWidth,
|
|
255
|
+
setControlProperties,
|
|
256
|
+
setControlValue,
|
|
257
|
+
setDifferentEvenPages,
|
|
258
|
+
setDifferentFirstPage,
|
|
259
|
+
setFontFamily,
|
|
260
|
+
setFontSize,
|
|
261
|
+
setHighlight,
|
|
262
|
+
setLineSpacing,
|
|
263
|
+
setLink,
|
|
264
|
+
setNoteProperties,
|
|
265
|
+
setParagraphSpacing,
|
|
266
|
+
setParagraphStyle,
|
|
267
|
+
setPictureAlt,
|
|
268
|
+
setPictureSize,
|
|
269
|
+
setReviewView,
|
|
270
|
+
setSectionSetup,
|
|
271
|
+
setStoryLinked,
|
|
272
|
+
setTableStyle,
|
|
273
|
+
setTextColor,
|
|
274
|
+
setTrackChanges,
|
|
275
|
+
sinkListItem,
|
|
276
|
+
splitBlock,
|
|
277
|
+
splitCell,
|
|
278
|
+
splitListItem,
|
|
279
|
+
storyOfSection,
|
|
280
|
+
type TableOfContentsOptions,
|
|
281
|
+
TextSelection,
|
|
282
|
+
type TrackState,
|
|
283
|
+
Transaction,
|
|
284
|
+
tableStyleAt,
|
|
285
|
+
tableStyles,
|
|
286
|
+
toggleFieldCodes,
|
|
287
|
+
toggleHeaderRow,
|
|
288
|
+
toggleList,
|
|
289
|
+
toggleMark,
|
|
290
|
+
trackedChanges,
|
|
291
|
+
trackState,
|
|
292
|
+
trackTransaction,
|
|
293
|
+
type UpdateFieldsOptions,
|
|
294
|
+
undo,
|
|
295
|
+
undoDepth,
|
|
296
|
+
untracked,
|
|
297
|
+
updateFields,
|
|
298
|
+
wrapInList,
|
|
299
|
+
} from "./state/index.js";
|
|
300
|
+
export {
|
|
301
|
+
AddMarkStep,
|
|
302
|
+
canJoin,
|
|
303
|
+
canSplit,
|
|
304
|
+
findWrapping,
|
|
305
|
+
liftTarget,
|
|
306
|
+
type Mappable,
|
|
307
|
+
Mapping,
|
|
308
|
+
type MapResult,
|
|
309
|
+
NodeMarkupBatchStep,
|
|
310
|
+
NodeMarkupStep,
|
|
311
|
+
type NodeTypeWithAttrs,
|
|
312
|
+
RemoveMarkStep,
|
|
313
|
+
ReplaceAroundStep,
|
|
314
|
+
ReplaceStep,
|
|
315
|
+
Step,
|
|
316
|
+
StepMap,
|
|
317
|
+
StepResult,
|
|
318
|
+
Transform,
|
|
319
|
+
TransformError,
|
|
320
|
+
} from "./transform/index.js";
|
|
321
|
+
export {
|
|
322
|
+
type AbstractNumberingJSON,
|
|
323
|
+
type BorderJSON,
|
|
324
|
+
type CellPropertiesJSON,
|
|
325
|
+
type CommentJSON,
|
|
326
|
+
type ContentOptions,
|
|
327
|
+
type ControlJSON,
|
|
328
|
+
createDocument,
|
|
329
|
+
type Extension,
|
|
330
|
+
type ExtensionNodeSpec,
|
|
331
|
+
type FoliDocument,
|
|
332
|
+
type FoliDocumentV3,
|
|
333
|
+
type FoliDocumentV4,
|
|
334
|
+
HIGHLIGHT_COLORS,
|
|
335
|
+
halfPointsToPt,
|
|
336
|
+
JUSTIFICATIONS,
|
|
337
|
+
type Justification,
|
|
338
|
+
type MeasureJSON,
|
|
339
|
+
migrateToV3,
|
|
340
|
+
migrateToV4,
|
|
341
|
+
migrateToV5,
|
|
342
|
+
mmToTwips,
|
|
343
|
+
type NotePropertiesJSON,
|
|
344
|
+
type NumberingInstanceJSON,
|
|
345
|
+
type NumberingLevelJSON,
|
|
346
|
+
type ParagraphPropertiesJSON,
|
|
347
|
+
type ParseOptions,
|
|
348
|
+
parseContent,
|
|
349
|
+
parseDocument,
|
|
350
|
+
ptToTwips,
|
|
351
|
+
type ResourceJSON,
|
|
352
|
+
type RowPropertiesJSON,
|
|
353
|
+
SCHEMA_VERSION,
|
|
354
|
+
type SectionJSON,
|
|
355
|
+
type StoryJSON,
|
|
356
|
+
type StyleJSON,
|
|
357
|
+
TABLE_CONDITIONS,
|
|
358
|
+
type TableCondition,
|
|
359
|
+
type TableConditionJSON,
|
|
360
|
+
type TablePropertiesJSON,
|
|
361
|
+
type ThemeJSON,
|
|
362
|
+
TWIPS_PER_INCH,
|
|
363
|
+
TWIPS_PER_POINT,
|
|
364
|
+
twipsToMm,
|
|
365
|
+
twipsToPt,
|
|
366
|
+
twipsToPx,
|
|
367
|
+
type WordSettingsJSON,
|
|
368
|
+
} from "./v3/index.js";
|
package/src/internal.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// `@folijs/core/internal` (ADR-0008): what the other Foli packages need from core that is not
|
|
2
|
+
// public (the Word context and envelope, the formatting resolver, clipboard fitting, layout
|
|
3
|
+
// helpers). No promise: any release may change it. The packages are installed at the same
|
|
4
|
+
// version (exact peer dependencies), so they always run with the core they were built with.
|
|
5
|
+
export {
|
|
6
|
+
CommentStep,
|
|
7
|
+
caretStop,
|
|
8
|
+
controlSpot,
|
|
9
|
+
copiedDefinitions,
|
|
10
|
+
deleteSelectionKeepingTables,
|
|
11
|
+
documentJSON,
|
|
12
|
+
EnvelopeStep,
|
|
13
|
+
editorCommand,
|
|
14
|
+
type FittedPaste,
|
|
15
|
+
fitPaste,
|
|
16
|
+
fitPastedV2,
|
|
17
|
+
keepTablesApart,
|
|
18
|
+
noteKindOf,
|
|
19
|
+
referencesIn,
|
|
20
|
+
StoryStep,
|
|
21
|
+
sameSpot,
|
|
22
|
+
setComments,
|
|
23
|
+
typedMarks,
|
|
24
|
+
viewKeys,
|
|
25
|
+
type WordContext,
|
|
26
|
+
type WordDefinitions,
|
|
27
|
+
type WordEnvelope,
|
|
28
|
+
withEnvelope,
|
|
29
|
+
wordContext,
|
|
30
|
+
} from "./state/index.js";
|
|
31
|
+
export type { EnvelopeKey, Story } from "./state/word.js";
|
|
32
|
+
export type { Check } from "./v3/check.js";
|
|
33
|
+
export {
|
|
34
|
+
type CellFormat,
|
|
35
|
+
type CellPlace,
|
|
36
|
+
CUSTOM_TYPE,
|
|
37
|
+
checkControl,
|
|
38
|
+
checkSection,
|
|
39
|
+
foreignTextOf,
|
|
40
|
+
formatNumber,
|
|
41
|
+
type ListMarker,
|
|
42
|
+
type ParagraphFormat,
|
|
43
|
+
Resolver,
|
|
44
|
+
RUN_PROPERTY_MARKS,
|
|
45
|
+
type RunFormat,
|
|
46
|
+
schema,
|
|
47
|
+
type TableFormat,
|
|
48
|
+
tableConditions,
|
|
49
|
+
withForeignText,
|
|
50
|
+
} from "./v3/index.js";
|
package/src/model/attrs.ts
CHANGED
|
@@ -11,9 +11,13 @@ export interface AttributeSpec {
|
|
|
11
11
|
|
|
12
12
|
export type AttributeSpecs = Readonly<Record<string, AttributeSpec>>;
|
|
13
13
|
|
|
14
|
+
/** @internal */
|
|
14
15
|
export const NO_ATTRS: Attrs = Object.freeze({});
|
|
15
16
|
|
|
16
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Fills defaults and validates. Unknown or missing required attributes are errors.
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
17
21
|
export function computeAttrs(
|
|
18
22
|
specs: AttributeSpecs | undefined,
|
|
19
23
|
given: Attrs | undefined,
|
|
@@ -40,6 +44,7 @@ export function computeAttrs(
|
|
|
40
44
|
/**
|
|
41
45
|
* The persisted form of `attrs`: only attributes that differ from their default (required ones
|
|
42
46
|
* always). Undefined when none remain, so a paragraph with default alignment has no `attrs`.
|
|
47
|
+
* @internal
|
|
43
48
|
*/
|
|
44
49
|
export function attrsToJSON(
|
|
45
50
|
specs: AttributeSpecs | undefined,
|
|
@@ -56,7 +61,10 @@ export function attrsToJSON(
|
|
|
56
61
|
return json;
|
|
57
62
|
}
|
|
58
63
|
|
|
59
|
-
/**
|
|
64
|
+
/**
|
|
65
|
+
* Structural equality for JSON-like attribute values.
|
|
66
|
+
* @internal
|
|
67
|
+
*/
|
|
60
68
|
export function deepEqual(a: unknown, b: unknown): boolean {
|
|
61
69
|
if (a === b) return true;
|
|
62
70
|
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return false;
|
package/src/model/content.ts
CHANGED
|
@@ -49,7 +49,7 @@ export class ContentMatch {
|
|
|
49
49
|
/** True when the content may end here. */
|
|
50
50
|
readonly validEnd: boolean;
|
|
51
51
|
|
|
52
|
-
/**
|
|
52
|
+
/** Use NodeType.contentMatch. */
|
|
53
53
|
constructor(
|
|
54
54
|
private readonly program: Program,
|
|
55
55
|
private readonly states: readonly number[],
|
package/src/model/errors.ts
CHANGED
|
@@ -8,7 +8,10 @@ export class ReplaceError extends Error {
|
|
|
8
8
|
override name = "ReplaceError";
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Throws a FoliDocumentError whose message starts with a JSON path.
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
12
15
|
export function fail(path: string, message: string): never {
|
|
13
16
|
throw new FoliDocumentError(`${path}: ${message}`);
|
|
14
17
|
}
|
package/src/model/fragment.ts
CHANGED
|
@@ -76,7 +76,8 @@ export class Fragment {
|
|
|
76
76
|
nodesBetween(
|
|
77
77
|
from: number,
|
|
78
78
|
to: number,
|
|
79
|
-
|
|
79
|
+
// biome-ignore lint/suspicious/noConfusingVoidType: a callback without a return (TypeScript 5 refuses one for `undefined`)
|
|
80
|
+
f: (node: Node, pos: number, parent: Node | null, index: number) => boolean | void,
|
|
80
81
|
nodeStart = 0,
|
|
81
82
|
parent: Node | null = null,
|
|
82
83
|
): void {
|
package/src/model/mark.ts
CHANGED
|
@@ -13,7 +13,7 @@ export interface MarkJSON {
|
|
|
13
13
|
export class Mark {
|
|
14
14
|
static readonly none: readonly Mark[] = Object.freeze([]);
|
|
15
15
|
|
|
16
|
-
/**
|
|
16
|
+
/** Use MarkType.create or Schema.mark. */
|
|
17
17
|
constructor(
|
|
18
18
|
readonly type: MarkType,
|
|
19
19
|
readonly attrs: Attrs,
|
package/src/model/node.ts
CHANGED
|
@@ -28,7 +28,7 @@ export class Node {
|
|
|
28
28
|
/** Set only on text nodes. */
|
|
29
29
|
declare readonly text?: string;
|
|
30
30
|
|
|
31
|
-
/**
|
|
31
|
+
/** Use NodeType.create, Schema.node/text or Schema.nodeFromJSON. */
|
|
32
32
|
constructor(
|
|
33
33
|
readonly type: NodeType,
|
|
34
34
|
readonly attrs: Attrs,
|
|
@@ -103,14 +103,16 @@ export class Node {
|
|
|
103
103
|
nodesBetween(
|
|
104
104
|
from: number,
|
|
105
105
|
to: number,
|
|
106
|
-
|
|
106
|
+
// biome-ignore lint/suspicious/noConfusingVoidType: a callback without a return (TypeScript 5 refuses one for `undefined`)
|
|
107
|
+
f: (node: Node, pos: number, parent: Node | null, index: number) => boolean | void,
|
|
107
108
|
): void {
|
|
108
109
|
this.content.nodesBetween(from, to, f, 0, this);
|
|
109
110
|
}
|
|
110
111
|
|
|
111
112
|
/** Calls `f` for every descendant. Return false to skip a node's children. */
|
|
112
113
|
descendants(
|
|
113
|
-
|
|
114
|
+
// biome-ignore lint/suspicious/noConfusingVoidType: a callback without a return (TypeScript 5 refuses one for `undefined`)
|
|
115
|
+
f: (node: Node, pos: number, parent: Node | null, index: number) => boolean | void,
|
|
114
116
|
): void {
|
|
115
117
|
this.nodesBetween(0, this.content.size, f);
|
|
116
118
|
}
|
|
@@ -254,7 +256,7 @@ export class Node {
|
|
|
254
256
|
}
|
|
255
257
|
|
|
256
258
|
export class TextNode extends Node {
|
|
257
|
-
/**
|
|
259
|
+
/** Use Schema.text. */
|
|
258
260
|
constructor(
|
|
259
261
|
type: NodeType,
|
|
260
262
|
override readonly text: string,
|
package/src/model/schema.ts
CHANGED
|
@@ -26,6 +26,11 @@ export interface NodeSpec {
|
|
|
26
26
|
atom?: boolean;
|
|
27
27
|
/** Whether a NodeSelection may select this node (default true; text is never selectable). */
|
|
28
28
|
selectable?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The text a leaf stands for in plain text, find, the clipboard and `.docx` (custom nodes,
|
|
31
|
+
* ADR-0008). Not saved: the attributes are.
|
|
32
|
+
*/
|
|
33
|
+
text?: (attrs: Attrs) => string;
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
export interface MarkSpec {
|
|
@@ -57,6 +62,7 @@ const NODE_KEYS = ["type", "attrs", "content", "text", "marks"];
|
|
|
57
62
|
/**
|
|
58
63
|
* How deep parsed JSON may nest: far beyond real documents (a table in a cell is three levels;
|
|
59
64
|
* Word nests tables a few dozen deep at most), well within the call stack.
|
|
65
|
+
* @internal
|
|
60
66
|
*/
|
|
61
67
|
export const MAX_NODE_DEPTH = 300;
|
|
62
68
|
const MARK_KEYS = ["type", "attrs"];
|
|
@@ -73,7 +79,7 @@ export class NodeType {
|
|
|
73
79
|
/** Allowed child marks; null means all. */
|
|
74
80
|
markSet!: readonly MarkType[] | null;
|
|
75
81
|
|
|
76
|
-
/**
|
|
82
|
+
/** Created by Schema. */
|
|
77
83
|
constructor(
|
|
78
84
|
readonly name: string,
|
|
79
85
|
readonly schema: Schema,
|
|
@@ -123,7 +129,7 @@ export class NodeType {
|
|
|
123
129
|
|
|
124
130
|
/**
|
|
125
131
|
* Creates a node without checking its content. Attributes are still validated.
|
|
126
|
-
*
|
|
132
|
+
* For transforms whose node ends up complete: a wrapper the wrapped blocks fill
|
|
127
133
|
* (validated when they are inserted) or the open half of a split (validated when the replace
|
|
128
134
|
* joins it). Steps do not validate closed nodes inside a slice: a node left incomplete here
|
|
129
135
|
* would make an invalid document.
|
|
@@ -185,7 +191,7 @@ export class MarkType {
|
|
|
185
191
|
readonly groups: readonly string[];
|
|
186
192
|
private readonly instance: Mark | null;
|
|
187
193
|
|
|
188
|
-
/**
|
|
194
|
+
/** Created by Schema. */
|
|
189
195
|
constructor(
|
|
190
196
|
readonly name: string,
|
|
191
197
|
readonly schema: Schema,
|
package/src/schema.ts
CHANGED
|
@@ -45,6 +45,7 @@ export function isSafeHref(href: unknown): href is string {
|
|
|
45
45
|
* Whether a link's attributes may come in from outside the document (a command, a paste from
|
|
46
46
|
* elsewhere): a safe `href`, or none with a bookmark (`anchor`, schema v3: Word's table of
|
|
47
47
|
* contents and cross-references).
|
|
48
|
+
* @internal
|
|
48
49
|
*/
|
|
49
50
|
export function isSafeLink(
|
|
50
51
|
attrs: { href?: unknown; anchor?: unknown } | null | undefined,
|
|
@@ -71,6 +72,7 @@ const color = {
|
|
|
71
72
|
isColor(value) ? undefined : "color must be a lowercase #rrggbb value",
|
|
72
73
|
};
|
|
73
74
|
|
|
75
|
+
/** @internal */
|
|
74
76
|
export const schemaV2 = new Schema({
|
|
75
77
|
nodes: {
|
|
76
78
|
doc: { content: "block+" },
|
package/src/state/commands.ts
CHANGED
|
@@ -11,10 +11,13 @@ import {
|
|
|
11
11
|
} from "../model/index.js";
|
|
12
12
|
import { isSafeLink } from "../schema.js";
|
|
13
13
|
import { TransformError } from "../transform/index.js";
|
|
14
|
+
import type { SectionJSON } from "../v3/document.js";
|
|
14
15
|
import { attempt } from "./attempt.js";
|
|
16
|
+
import { fieldOfPart, fieldSelection, isFieldPart } from "./fields.js";
|
|
15
17
|
import { redo, undo } from "./history.js";
|
|
16
18
|
import { openLinkEditor } from "./links.js";
|
|
17
19
|
import { keepLastMark, typedMarks } from "./mark.js";
|
|
20
|
+
import { absorbSection } from "./sections.js";
|
|
18
21
|
import { AllSelection, marksAt, NodeSelection, Selection, TextSelection } from "./selection.js";
|
|
19
22
|
import {
|
|
20
23
|
type Command,
|
|
@@ -176,6 +179,23 @@ function skipsDeleted(state: EditorState): boolean {
|
|
|
176
179
|
/** Content a tracked change deleted (still in the document until accepted). */
|
|
177
180
|
const isDeleted = (node: Node) => node.marks.some((m) => m.type.name === "deletion");
|
|
178
181
|
|
|
182
|
+
/**
|
|
183
|
+
* Backspace or Delete arriving at a field's marker (`node`, at `pos`) selects the field whole, as
|
|
184
|
+
* Word does: the next press deletes it. False for anything else, and a marker without a field.
|
|
185
|
+
*/
|
|
186
|
+
function selectFieldAt(
|
|
187
|
+
state: EditorState,
|
|
188
|
+
dispatch: ((tr: Transaction) => void) | undefined,
|
|
189
|
+
node: Node | null | undefined,
|
|
190
|
+
pos: number,
|
|
191
|
+
): boolean {
|
|
192
|
+
if (!isFieldPart(node)) return false;
|
|
193
|
+
const field = fieldOfPart(state.doc, pos);
|
|
194
|
+
if (!field || field.deleted) return false;
|
|
195
|
+
dispatch?.(state.tr.setSelection(fieldSelection(state.doc, field)));
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
|
|
179
199
|
/** Backspace: deletes the selection, else the previous character or word, else joins with the previous block. */
|
|
180
200
|
export function deleteBackward(unit: DeleteUnit = "char"): Command {
|
|
181
201
|
return (state, dispatch) => {
|
|
@@ -189,9 +209,10 @@ export function deleteBackward(unit: DeleteUnit = "char"): Command {
|
|
|
189
209
|
let $pos = found;
|
|
190
210
|
while ($pos.parentOffset > 0) {
|
|
191
211
|
const before = $pos.nodeBefore;
|
|
192
|
-
if (
|
|
193
|
-
else if (tracking && before && isDeleted(before))
|
|
212
|
+
if (tracking && before && isDeleted(before))
|
|
194
213
|
$pos = state.doc.resolve($pos.pos - before.nodeSize);
|
|
214
|
+
else if (selectFieldAt(state, dispatch, before, $pos.pos - 1)) return true;
|
|
215
|
+
else if (isMarker(word, before)) $pos = state.doc.resolve($pos.pos - 1);
|
|
195
216
|
else break;
|
|
196
217
|
}
|
|
197
218
|
if ($pos.parentOffset === 0) return joinBackward(at(state, $pos.pos), dispatch);
|
|
@@ -216,9 +237,10 @@ export function deleteForward(unit: DeleteUnit = "char"): Command {
|
|
|
216
237
|
let $pos = found;
|
|
217
238
|
while ($pos.parentOffset < $pos.parent.content.size) {
|
|
218
239
|
const after = $pos.nodeAfter;
|
|
219
|
-
if (
|
|
220
|
-
else if (tracking && after && isDeleted(after))
|
|
240
|
+
if (tracking && after && isDeleted(after))
|
|
221
241
|
$pos = state.doc.resolve($pos.pos + after.nodeSize);
|
|
242
|
+
else if (selectFieldAt(state, dispatch, after, $pos.pos)) return true;
|
|
243
|
+
else if (isMarker(word, after)) $pos = state.doc.resolve($pos.pos + 1);
|
|
222
244
|
else break;
|
|
223
245
|
}
|
|
224
246
|
if ($pos.parentOffset === $pos.parent.content.size)
|
|
@@ -232,6 +254,15 @@ export function deleteForward(unit: DeleteUnit = "char"): Command {
|
|
|
232
254
|
};
|
|
233
255
|
}
|
|
234
256
|
|
|
257
|
+
/**
|
|
258
|
+
* `first` was joined with the next paragraph at `pos`: if its mark ended a section, the next one
|
|
259
|
+
* takes over. While tracking the mark stays, recorded as deleted: accepting it does this.
|
|
260
|
+
*/
|
|
261
|
+
function sectionBreakGone(state: EditorState, tr: Transaction, first: Node, pos: number): void {
|
|
262
|
+
const section = first.attrs.section as SectionJSON | null | undefined;
|
|
263
|
+
if (section && !trackState(state)?.on) absorbSection(state, tr, section, pos);
|
|
264
|
+
}
|
|
265
|
+
|
|
235
266
|
/**
|
|
236
267
|
* At the start of a textblock: merges it into the previous textblock, or selects a previous
|
|
237
268
|
* opaque block (a table), as Word does. Does nothing at the start of the first block.
|
|
@@ -248,6 +279,7 @@ export const joinBackward: Command = (state, dispatch) => {
|
|
|
248
279
|
tr.join(boundary);
|
|
249
280
|
// The merged paragraph ends with this one's mark (schema v3: its section break).
|
|
250
281
|
keepLastMark(tr, boundary - before.nodeSize, $pos.parent);
|
|
282
|
+
sectionBreakGone(state, tr, before, boundary - before.nodeSize);
|
|
251
283
|
});
|
|
252
284
|
// A table: the caret goes to the end of its last cell, as Word moves into it.
|
|
253
285
|
if (before.type.name === "table") {
|
|
@@ -276,6 +308,7 @@ export const joinForward: Command = (state, dispatch) => {
|
|
|
276
308
|
return attempt(state, dispatch, (tr) => {
|
|
277
309
|
tr.join(boundary);
|
|
278
310
|
keepLastMark(tr, $pos.before(), after);
|
|
311
|
+
sectionBreakGone(state, tr, $pos.parent, $pos.before());
|
|
279
312
|
});
|
|
280
313
|
}
|
|
281
314
|
// A table: the caret goes to the start of its first cell.
|
|
@@ -421,6 +454,10 @@ export const insertHardBreak: Command = (state, dispatch) =>
|
|
|
421
454
|
export const insertPageBreak: Command = (state, dispatch) =>
|
|
422
455
|
insertLeaf("pageBreak", state, dispatch);
|
|
423
456
|
|
|
457
|
+
/** A column break at the selection: what follows it starts the next column. */
|
|
458
|
+
export const insertColumnBreak: Command = (state, dispatch) =>
|
|
459
|
+
insertLeaf("columnBreak", state, dispatch);
|
|
460
|
+
|
|
424
461
|
/** Replaces the selection with an inline leaf node of `name`, keeping the marks typing gets. */
|
|
425
462
|
function insertLeaf(name: string, ...[state, dispatch]: Parameters<Command>): boolean {
|
|
426
463
|
const type = state.schema.nodes[name];
|