refactor(md-deck): pos string and yaml copy output
Replace per-axis x1/y1/x2/y2 layer fields with a single pos string (x1,y1-x2,y2) matching the compact layers format. When a deck is configured via a yaml/tag codeblock (data-config), the copy button now emits a yaml/tag block serialized from current store state so template layers round-trip.
This commit is contained in:
@@ -18,7 +18,7 @@ describe("layersToConfigs", () => {
|
||||
|
||||
test("parses structured list with prop layers", () => {
|
||||
const layers = layersToConfigs([
|
||||
{ prop: "name", x1: 1, y1: 1, x2: 5, y2: 2, font: 12 },
|
||||
{ prop: "name", pos: "1,1-5,2", font: 12 },
|
||||
]);
|
||||
expect(layers).toHaveLength(1);
|
||||
expect(layers[0]).toMatchObject({
|
||||
@@ -35,7 +35,7 @@ describe("layersToConfigs", () => {
|
||||
|
||||
test("parses structured list with template layers", () => {
|
||||
const layers = layersToConfigs([
|
||||
{ template: "**{{name}}**", x1: 1, y1: 3, x2: 5, y2: 8, align: "l" },
|
||||
{ template: "**{{name}}**", pos: "1,3-5,8", align: "l" },
|
||||
]);
|
||||
expect(layers).toHaveLength(1);
|
||||
expect(layers[0]).toMatchObject({
|
||||
@@ -50,6 +50,12 @@ describe("layersToConfigs", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("defaults placement when pos is missing or invalid", () => {
|
||||
const layers = layersToConfigs([{ prop: "x" }, { prop: "y", pos: "bogus" }]);
|
||||
expect(layers[0]).toMatchObject({ x1: 1, y1: 1, x2: 2, y2: 2 });
|
||||
expect(layers[1]).toMatchObject({ x1: 1, y1: 1, x2: 2, y2: 2 });
|
||||
});
|
||||
|
||||
test("returns [] for absent/empty input", () => {
|
||||
expect(layersToConfigs()).toEqual([]);
|
||||
expect(layersToConfigs("")).toEqual([]);
|
||||
@@ -81,8 +87,8 @@ describe("normalizeDeckConfig", () => {
|
||||
test("normalizes layers and back_layers", () => {
|
||||
const cfg = normalizeDeckConfig({
|
||||
layers: [
|
||||
{ prop: "name", x1: 1, y1: 1, x2: 5, y2: 1 },
|
||||
{ template: "{{body}}", x1: 1, y1: 2, x2: 5, y2: 8 },
|
||||
{ prop: "name", pos: "1,1-5,1" },
|
||||
{ template: "{{body}}", pos: "1,2-5,8" },
|
||||
],
|
||||
back_layers: "logo:1,1-2,2",
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user