Add notepad text import export
All checks were successful
Deploy Sokko G / deploy (push) Successful in 7s
All checks were successful
Deploy Sokko G / deploy (push) Successful in 7s
This commit is contained in:
parent
323e1b266d
commit
f76cddcc95
8 changed files with 165 additions and 19 deletions
|
|
@ -156,6 +156,17 @@ export function validateSiteContent(site) {
|
|||
"toolboxes.modules.notepad.permanentStatus",
|
||||
"toolboxes.modules.notepad.updatedAtPrefix",
|
||||
"toolboxes.modules.notepad.sessionStorageError",
|
||||
"toolboxes.modules.notepad.importPlaceholder",
|
||||
"toolboxes.modules.notepad.importOpenButton",
|
||||
"toolboxes.modules.notepad.exportOpenButton",
|
||||
"toolboxes.modules.notepad.importModalTitle",
|
||||
"toolboxes.modules.notepad.exportModalTitle",
|
||||
"toolboxes.modules.notepad.importButton",
|
||||
"toolboxes.modules.notepad.exportButton",
|
||||
"toolboxes.modules.notepad.importSuccess",
|
||||
"toolboxes.modules.notepad.exportSuccess",
|
||||
"toolboxes.modules.notepad.importError",
|
||||
"toolboxes.modules.notepad.exportInfo",
|
||||
"toolboxes.modules.checklist.itemPlaceholder",
|
||||
"toolboxes.modules.checklist.sectionPlaceholder",
|
||||
"toolboxes.modules.checklist.quantityLabel",
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ test("toolbox module registry and modules expose expected behavior", async () =>
|
|||
assert.match(moduleRegistry, /Planificateur d'équipements/);
|
||||
assert.match(moduleRegistry, /imageAnnotation:/);
|
||||
assert.match(moduleRegistry, /Annotation d'images/);
|
||||
assert.match(moduleRegistry, /editable: false/);
|
||||
assert.match(moduleRegistry, /notepad: \{ label: "Bloc notes", icon: "notepad", Component: NotepadModule, editable: true \}/);
|
||||
assert.match(moduleRegistry, /module-edit-button/);
|
||||
assert.match(moduleRegistry, /itemReorder\.startDrag/);
|
||||
assert.match(moduleRegistry, /onPointerDown/);
|
||||
|
|
@ -159,6 +159,8 @@ test("toolbox module registry and modules expose expected behavior", async () =>
|
|||
assert.match(moduleRegistry, /CompactDropdown/);
|
||||
assert.doesNotMatch(source, /<select value="" onChange=\{\(event\) => addModule/);
|
||||
assert.match(notepadModule, /export function NotepadModule/);
|
||||
assert.match(notepadModule, /TextExchangeActions/);
|
||||
assert.match(notepadModule, /type="notepad"/);
|
||||
assert.match(combosModule, /export function CombosModule/);
|
||||
assert.match(combosModule, /keyboardMouse/);
|
||||
assert.match(combosModule, /Nintendo 64/);
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ function createTextImportContext() {
|
|||
let index = 0;
|
||||
return {
|
||||
uid: (prefix) => `${prefix}-${index += 1}`,
|
||||
normalizeNotepadData,
|
||||
normalizeChecklistData,
|
||||
normalizeLinksData,
|
||||
normalizeCountersData,
|
||||
|
|
@ -40,6 +41,23 @@ test("colon text import accepts labels without value", () => {
|
|||
|
||||
test("text exchange round trips simple toolbox modules and resets checklist progress", () => {
|
||||
const context = createTextImportContext();
|
||||
const notepad = normalizeNotepadData({
|
||||
html: '<h3>Route</h3><p><strong style="color: #f6c453">Boss</strong></p>',
|
||||
drawingMode: "permanent",
|
||||
drawings: {
|
||||
strokes: [
|
||||
{ id: "old-stroke", color: "#22d3ee", width: 4, points: [{ x: 2, y: 3 }, { x: 8, y: 13 }] }
|
||||
]
|
||||
}
|
||||
});
|
||||
const notepadImport = importModuleText("notepad", exportModuleText("notepad", notepad), context);
|
||||
assert.equal(notepadImport.ok, true);
|
||||
assert.match(notepadImport.data.html, /<h3>Route<\/h3>/);
|
||||
assert.match(notepadImport.data.html, /<strong style="color: #f6c453">Boss<\/strong>/);
|
||||
assert.equal(notepadImport.data.drawingMode, "permanent");
|
||||
assert.equal(notepadImport.data.drawings.strokes.length, 1);
|
||||
assert.notEqual(notepadImport.data.drawings.strokes[0].id, "old-stroke");
|
||||
|
||||
const checklist = normalizeChecklistData({
|
||||
sections: [
|
||||
{
|
||||
|
|
@ -169,6 +187,8 @@ test("text exchange rejects invalid imports without data", () => {
|
|||
assert.match(invalidImage.error, /^Ligne 1:/);
|
||||
assert.equal(invalidMarker.ok, false);
|
||||
assert.match(invalidMarker.error, /^Ligne 2:/);
|
||||
assert.equal(importModuleText("notepad", "@notepad\n@html\n<p>Note</p>", context).ok, false);
|
||||
assert.equal(importModuleText("notepad", "@notepad\n@drawings: {bad}", context).ok, false);
|
||||
assert.equal(importModuleText("table", "\n", context).ok, false);
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue