oasis-editor 0.0.216 → 0.0.217
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/dist/{OasisEditorApp-z4XAN0Fg.js → OasisEditorApp-CN7pN1Mc.js} +1 -1
- package/dist/assets/{importDocxWorker-CttqoLlH.js → importDocxWorker-BIjCzhM3.js} +37 -24
- package/dist/core/commands/builtinCommands.d.ts +1 -1
- package/dist/core/commands/fieldDate.d.ts +13 -0
- package/dist/core/commands/publicCommandTypes.d.ts +1 -0
- package/dist/core/format/dateFormat.d.ts +17 -0
- package/dist/core/model/types/primitives.d.ts +5 -1
- package/dist/defaultToolbar-B7lLZb5m.js +1 -0
- package/dist/export/docx/text/fieldRunXml.d.ts +2 -2
- package/dist/i18n/locales/en.d.ts +1 -0
- package/dist/i18n/locales/pt-BR.d.ts +1 -0
- package/dist/import/docx/runs/types.d.ts +4 -0
- package/dist/oasis-editor.js +1 -1
- package/dist/oasis-editor.umd.cjs +1 -1
- package/dist/plugins/internal/createEssentialsPlugin.d.ts +1 -1
- package/dist/plugins/internal/essentialsCapabilities.d.ts +5 -0
- package/dist/plugins/internal/essentialsCommandGroups/fields.d.ts +9 -0
- package/dist/ui/app/essentials/fields.d.ts +9 -0
- package/package.json +1 -1
- package/dist/defaultToolbar-CKYcsSYD.js +0 -1
|
@@ -9854,18 +9854,23 @@ while (n === s[++o] && n === s[++o] && n === s[++o] && n === s[++o] && n === s[+
|
|
|
9854
9854
|
});
|
|
9855
9855
|
const e = c.pop();
|
|
9856
9856
|
e && ((e) => {
|
|
9857
|
-
const t = /\bNUMPAGES\b/i.test(e.instruction) ? "NUMPAGES" : /\bPAGE\b/i.test(e.instruction) ? "PAGE" : null;
|
|
9857
|
+
const t = /\bNUMPAGES\b/i.test(e.instruction) ? "NUMPAGES" : /\bPAGE\b/i.test(e.instruction) ? "PAGE" : /\bDATE\b/i.test(e.instruction) ? "DATE" : null;
|
|
9858
9858
|
if (!t) return;
|
|
9859
|
-
const r = Kt(/\*\s*([A-Za-z]+)/.exec(e.instruction)?.[1]), n = l.slice(e.beginIndex);
|
|
9860
|
-
if (
|
|
9861
|
-
const
|
|
9862
|
-
l.length = e.beginIndex
|
|
9863
|
-
|
|
9864
|
-
|
|
9865
|
-
|
|
9866
|
-
|
|
9867
|
-
|
|
9868
|
-
|
|
9859
|
+
const r = Kt(/\*\s*([A-Za-z]+)/.exec(e.instruction)?.[1]), n = "DATE" === t ? /@\s*"([^"]*)"/.exec(e.instruction)?.[1] : void 0, o = l.slice(e.beginIndex);
|
|
9860
|
+
if (o.some((e) => e.bookmark)) return;
|
|
9861
|
+
const i = o.filter((e) => !e.fieldChar && void 0 === e.fieldInstruction), a = i.map((e) => e.text).join("") || "1", s = i.find((e) => e.styles)?.styles ?? e.beginStyles;
|
|
9862
|
+
l.length = e.beginIndex;
|
|
9863
|
+
const c = "DATE" === t ? n ? {
|
|
9864
|
+
type: "DATE",
|
|
9865
|
+
dateFormat: n
|
|
9866
|
+
} : { type: "DATE" } : r ? {
|
|
9867
|
+
type: t,
|
|
9868
|
+
format: r
|
|
9869
|
+
} : { type: t };
|
|
9870
|
+
l.push({
|
|
9871
|
+
text: a,
|
|
9872
|
+
...s ? { styles: s } : {},
|
|
9873
|
+
field: c
|
|
9869
9874
|
});
|
|
9870
9875
|
})(e);
|
|
9871
9876
|
}
|
|
@@ -10030,16 +10035,19 @@ while (n === s[++o] && n === s[++o] && n === s[++o] && n === s[++o] && n === s[+
|
|
|
10030
10035
|
continue;
|
|
10031
10036
|
}
|
|
10032
10037
|
if ("fldSimple" === f.localName) {
|
|
10033
|
-
const e = f.getAttribute("w:instr") ?? f.getAttributeNS("http://schemas.openxmlformats.org/wordprocessingml/2006/main", "instr") ?? f.getAttribute("instr") ?? "", c = /\bNUMPAGES\b/i.test(e) ? "NUMPAGES" : /\bPAGE\b/i.test(e) ? "PAGE" : null, u = /\*\s*([A-Za-z]+)/.exec(e)?.[1], d = Kt(u), p = await Pr(f, t, r, n, o, i, a, s);
|
|
10038
|
+
const e = f.getAttribute("w:instr") ?? f.getAttributeNS("http://schemas.openxmlformats.org/wordprocessingml/2006/main", "instr") ?? f.getAttribute("instr") ?? "", c = /\bNUMPAGES\b/i.test(e) ? "NUMPAGES" : /\bPAGE\b/i.test(e) ? "PAGE" : /\bDATE\b/i.test(e) ? "DATE" : null, u = /\*\s*([A-Za-z]+)/.exec(e)?.[1], d = Kt(u), p = "DATE" === c ? /@\s*"([^"]*)"/.exec(e)?.[1] : void 0, h = await Pr(f, t, r, n, o, i, a, s);
|
|
10034
10039
|
if (c) {
|
|
10035
|
-
const e =
|
|
10040
|
+
const e = h.map((e) => e.text).join("") || "1", t = h.find((e) => e.styles)?.styles, r = "DATE" === c ? p ? {
|
|
10041
|
+
type: "DATE",
|
|
10042
|
+
dateFormat: p
|
|
10043
|
+
} : { type: "DATE" } : d ? {
|
|
10044
|
+
type: c,
|
|
10045
|
+
format: d
|
|
10046
|
+
} : { type: c };
|
|
10036
10047
|
l.push({
|
|
10037
10048
|
text: e,
|
|
10038
10049
|
styles: t,
|
|
10039
|
-
field:
|
|
10040
|
-
type: c,
|
|
10041
|
-
format: d
|
|
10042
|
-
} : { type: c }
|
|
10050
|
+
field: r
|
|
10043
10051
|
});
|
|
10044
10052
|
} else l.push({
|
|
10045
10053
|
text: "",
|
|
@@ -10050,7 +10058,7 @@ while (n === s[++o] && n === s[++o] && n === s[++o] && n === s[++o] && n === s[+
|
|
|
10050
10058
|
}), l.push({
|
|
10051
10059
|
text: "",
|
|
10052
10060
|
fieldChar: { kind: "separate" }
|
|
10053
|
-
}), l.push(...
|
|
10061
|
+
}), l.push(...h), l.push({
|
|
10054
10062
|
text: "",
|
|
10055
10063
|
fieldChar: { kind: "end" }
|
|
10056
10064
|
});
|
|
@@ -13046,12 +13054,17 @@ while (n === s[++o] && n === s[++o] && n === s[++o] && n === s[++o] && n === s[+
|
|
|
13046
13054
|
return t = e.fieldInstruction, `<w:r>${s()}<w:instrText xml:space="preserve">${to(t)}</w:instrText></w:r>`;
|
|
13047
13055
|
var t;
|
|
13048
13056
|
},
|
|
13049
|
-
field: (e) => function(e, t, r) {
|
|
13050
|
-
|
|
13051
|
-
|
|
13052
|
-
|
|
13053
|
-
|
|
13054
|
-
|
|
13057
|
+
field: (e) => function(e, t, r = "1") {
|
|
13058
|
+
let n;
|
|
13059
|
+
if ("DATE" === e.type) n = ` DATE \\@ "${e.dateFormat ?? "M/d/yyyy"}" `;
|
|
13060
|
+
else {
|
|
13061
|
+
const t = "PAGE" === e.type ? " PAGE " : " NUMPAGES ", r = function(e) {
|
|
13062
|
+
if (e && "decimal" !== e) return e;
|
|
13063
|
+
}(e.format);
|
|
13064
|
+
n = r ? ` ${t.trim()} \\* ${r} ` : t;
|
|
13065
|
+
}
|
|
13066
|
+
return `<w:fldSimple w:instr="${to(n)}"><w:r>${t}<w:t xml:space="preserve">${to(r)}</w:t></w:r></w:fldSimple>`;
|
|
13067
|
+
}(e.field, s(), "DATE" === e.field.type ? e.text : void 0),
|
|
13055
13068
|
textBox: (e) => zi(e, e.textBox, t, n, s(), o),
|
|
13056
13069
|
image: (e) => {
|
|
13057
13070
|
const r = t.imageMap.get(e.id);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const OASIS_BUILTIN_COMMANDS: readonly ["selectAll", "insertFootnote", "insertText", "insertEquation", "updateEquation", "insertTableOfContents", "updateTableOfContents", "pastePlainText", "paste", "pasteAsPlainText", "pasteMergeFormatting", "formatPainter", "formatPainterContinuous", "cancelFormatPainter", "bold", "italic", "underline", "strike", "superscript", "subscript", "link", "unlink", "alignLeft", "alignCenter", "alignRight", "alignJustify", "orderedList", "bulletList", "find", "replace", "toggleTrackChanges", "acceptRevisions", "rejectRevisions", "nextRevision", "previousRevision", "nextComment", "previousComment", "newComment", "replyComment", "editComment", "toggleCommentsPanel", "resolveComment", "reopenComment", "deleteComment", "toggleShowMargins", "toggleShowParagraphMarks", "togglePreciseFonts", "undo", "redo", "pageBreak", "lineBreak", "splitBlock", "setFontFamily", "setFontSize", "increaseFontSize", "decreaseFontSize", "changeTextCase", "clearFormatting", "setColor", "setHighlight", "setTextShading", "setStyleId", "setCharacterStyleId", "setUnderlineStyle", "documentStyles", "print", "copy", "cut", "newDocument", "exportDocx", "exportPdf", "importDocument", "insertHtml", "insertImage", "editImageAlt", "insertImageCaption", "imageContext", "imageWidthCm", "imageHeightCm", "imageCrop", "imageCropAspect", "imageCropShape", "imageCropFill", "imageCropFit", "imageCropReset", "imageBorder", "outdent", "indent", "togglePageBreakBefore", "toggleKeepWithNext", "setSpacingAfter", "setSpacingBefore", "setIndentLeft", "setIndentRight", "setIndentFirstLine", "setIndentHanging", "setSpecialIndent", "setParagraphShading", "applyParagraphBorders", "setLineHeight", "setListFormat", "setListStartAt", "toggleOrientation", "setOrientation", "sectionBreakNextPage", "sectionBreakContinuous", "setPageMargins", "setSectionPageNumbering", "editHeader", "editFooter", "insertPageNumber", "insertPageNumberXOfY", "placePageNumberTop", "placePageNumberBottom", "insertBookmark", "removeBookmark", "exitHeaderFooter", "applyDocumentTheme", "setDocumentColorScheme", "setDocumentFontScheme", "setDocumentParagraphSpacing", "setDocumentEffects", "setDocumentPageColor", "setDocumentWatermark", "setDocumentPageBorder", "setDocumentDesignDefault", "tableContext", "tableMerge", "tableSplit", "tableInsertColumnBefore", "tableInsertColumnAfter", "tableDeleteColumn", "tableInsertRowBefore", "tableInsertRowAfter", "tableDeleteRow", "tableCellShading", "tableCellBorders", "tableCellNoBorders", "tableApplyBorderPreset", "toggleTableDrawBorders", "toggleTableGridlines", "tableWidth100", "tableAlignLeft", "tableAlignCenter", "tableAlignRight", "tableSetCellWidth", "tableToggleHeaderRow", "tableToggleTotalRow", "tableToggleBandedRows", "tableToggleFirstColumn", "tableToggleLastColumn", "tableToggleBandedColumns", "setTableStyle", "tableToggleAutoFit", "tableDistributeColumns", "tableDistributeRows", "insertTable", "insertShape", "openSymbolDialog", "openEquationDialog"];
|
|
1
|
+
export declare const OASIS_BUILTIN_COMMANDS: readonly ["selectAll", "insertFootnote", "insertText", "insertEquation", "updateEquation", "insertTableOfContents", "updateTableOfContents", "pastePlainText", "paste", "pasteAsPlainText", "pasteMergeFormatting", "formatPainter", "formatPainterContinuous", "cancelFormatPainter", "bold", "italic", "underline", "strike", "superscript", "subscript", "link", "unlink", "alignLeft", "alignCenter", "alignRight", "alignJustify", "orderedList", "bulletList", "find", "replace", "toggleTrackChanges", "acceptRevisions", "rejectRevisions", "nextRevision", "previousRevision", "nextComment", "previousComment", "newComment", "replyComment", "editComment", "toggleCommentsPanel", "resolveComment", "reopenComment", "deleteComment", "toggleShowMargins", "toggleShowParagraphMarks", "togglePreciseFonts", "undo", "redo", "pageBreak", "lineBreak", "splitBlock", "setFontFamily", "setFontSize", "increaseFontSize", "decreaseFontSize", "changeTextCase", "clearFormatting", "setColor", "setHighlight", "setTextShading", "setStyleId", "setCharacterStyleId", "setUnderlineStyle", "documentStyles", "print", "copy", "cut", "newDocument", "exportDocx", "exportPdf", "importDocument", "insertHtml", "insertImage", "editImageAlt", "insertImageCaption", "imageContext", "imageWidthCm", "imageHeightCm", "imageCrop", "imageCropAspect", "imageCropShape", "imageCropFill", "imageCropFit", "imageCropReset", "imageBorder", "outdent", "indent", "togglePageBreakBefore", "toggleKeepWithNext", "setSpacingAfter", "setSpacingBefore", "setIndentLeft", "setIndentRight", "setIndentFirstLine", "setIndentHanging", "setSpecialIndent", "setParagraphShading", "applyParagraphBorders", "setLineHeight", "setListFormat", "setListStartAt", "toggleOrientation", "setOrientation", "sectionBreakNextPage", "sectionBreakContinuous", "setPageMargins", "setSectionPageNumbering", "editHeader", "editFooter", "insertPageNumber", "insertPageNumberXOfY", "placePageNumberTop", "placePageNumberBottom", "insertBookmark", "removeBookmark", "insertDateField", "exitHeaderFooter", "applyDocumentTheme", "setDocumentColorScheme", "setDocumentFontScheme", "setDocumentParagraphSpacing", "setDocumentEffects", "setDocumentPageColor", "setDocumentWatermark", "setDocumentPageBorder", "setDocumentDesignDefault", "tableContext", "tableMerge", "tableSplit", "tableInsertColumnBefore", "tableInsertColumnAfter", "tableDeleteColumn", "tableInsertRowBefore", "tableInsertRowAfter", "tableDeleteRow", "tableCellShading", "tableCellBorders", "tableCellNoBorders", "tableApplyBorderPreset", "toggleTableDrawBorders", "toggleTableGridlines", "tableWidth100", "tableAlignLeft", "tableAlignCenter", "tableAlignRight", "tableSetCellWidth", "tableToggleHeaderRow", "tableToggleTotalRow", "tableToggleBandedRows", "tableToggleFirstColumn", "tableToggleLastColumn", "tableToggleBandedColumns", "setTableStyle", "tableToggleAutoFit", "tableDistributeColumns", "tableDistributeRows", "insertTable", "insertShape", "openSymbolDialog", "openEquationDialog"];
|
|
2
2
|
export type OasisBuiltinCommand = (typeof OASIS_BUILTIN_COMMANDS)[number];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EditorState, EditorTextRun } from '../model.js';
|
|
2
|
+
export declare const DEFAULT_DATE_PICTURE = "M/d/yyyy";
|
|
3
|
+
export interface InsertDateFieldOptions {
|
|
4
|
+
/** `\@` picture controlling the result. Default `M/d/yyyy`. */
|
|
5
|
+
dateFormat?: string;
|
|
6
|
+
/** Value to resolve, for deterministic tests. Default now. */
|
|
7
|
+
value?: Date;
|
|
8
|
+
}
|
|
9
|
+
/** Insert a DATE field at the caret with a resolved, cached result. */
|
|
10
|
+
export declare function insertDateField(state: EditorState, options?: InsertDateFieldOptions): EditorState;
|
|
11
|
+
export declare function isDateFieldRun(run: EditorTextRun): boolean;
|
|
12
|
+
/** Whether the active zone is a header or footer (recall DATE fields in them). */
|
|
13
|
+
export declare function isInHeaderOrFooter(state: EditorState): boolean;
|
|
@@ -152,6 +152,7 @@ export interface OasisCommandPayloads {
|
|
|
152
152
|
placePageNumberBottom: undefined;
|
|
153
153
|
insertBookmark: string | undefined;
|
|
154
154
|
removeBookmark: string;
|
|
155
|
+
insertDateField: undefined;
|
|
155
156
|
exitHeaderFooter: undefined;
|
|
156
157
|
applyDocumentTheme: DesignThemeId;
|
|
157
158
|
setDocumentColorScheme: string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Date/time field formatting.
|
|
3
|
+
*
|
|
4
|
+
* DATE/TIME fields in Word carry a `\@` picture (e.g. `"M/d/yyyy"`) that
|
|
5
|
+
* controls the displayed result. This module mirrors WordCraft's `DATE_FORMATS`
|
|
6
|
+
* vocabulary and formats a JavaScript Date according to the common picture
|
|
7
|
+
* tokens Word understands, so an authored date field renders deterministically
|
|
8
|
+
* and round-trips through DOCX.
|
|
9
|
+
*/
|
|
10
|
+
export declare const DATE_FORMATS: ReadonlyArray<string>;
|
|
11
|
+
/**
|
|
12
|
+
* Format a Date according to a Word `\@` picture. Unrecognized tokens are
|
|
13
|
+
* passed through literally; `am/pm` renders "am"/"pm". Supports the common
|
|
14
|
+
* tokens: d/dd/ddd/dddd (day), M/MM/MMM/MMMM (month), yy/yyyy (year),
|
|
15
|
+
* h/hh (12h), H (24h), m/mm (minute), s/ss (second), and literal text.
|
|
16
|
+
*/
|
|
17
|
+
export declare function formatDate(value: Date, picture: string): string;
|
|
@@ -190,10 +190,14 @@ export interface EditorImageRunData {
|
|
|
190
190
|
}
|
|
191
191
|
/** `\*` number-format switch for PAGE/NUMPAGES fields (WordCraft NUMBER_FORMATS). */
|
|
192
192
|
export type PageNumberFormat = "decimal" | "roman" | "ROMAN" | "alphabetic" | "ALPHABETIC" | "Ordinal";
|
|
193
|
+
/** Field types the editor can author/evaluate for display. */
|
|
194
|
+
export type EditorFieldType = "PAGE" | "NUMPAGES" | "DATE";
|
|
193
195
|
export interface EditorFieldData {
|
|
194
|
-
type:
|
|
196
|
+
type: EditorFieldType;
|
|
195
197
|
/** Page-number `\*` format switch. Absent ⇒ decimal. */
|
|
196
198
|
format?: PageNumberFormat;
|
|
199
|
+
/** `\@` picture for DATE fields (e.g. "M/d/yyyy"). Absent ⇒ default. */
|
|
200
|
+
dateFormat?: string;
|
|
197
201
|
}
|
|
198
202
|
/**
|
|
199
203
|
* A preserved complex-field control character (`w:fldChar`). Carried on a
|