stefnotch / quantum-sheet

QuantumSheet - A user friendly mathematics worksheet and solver
https://stefnotch.github.io/quantum-sheet/
GNU General Public License v3.0
55 stars 5 forks source link

Document Serialization #25

Closed phcreery closed 3 years ago

phcreery commented 3 years ago

This is a draft pull request for serialization. I am sure I have not covered everything but I wanted to open this up to bring up any potential discussion or questions.

https://github.com/stefnotch/quantum-sheet/projects/1#card-42110934

stefnotch commented 3 years ago

Woah, sweet, thank you very much for this! I'll take a look at it now

phcreery commented 3 years ago

Now it looks more like this:

      const serializedDocument = {
        elements: [
          {
            id: '9581a4b6-8f14-416c-a761-43c7459ffe33',
            typeName: 'scope-element',
            name: '',
            position: {
              x: 0,
              y: 0,
            },
            size: {
              x: 0,
              y: 0,
            },
            resizable: false,
            closed: false,
          },
          {
            id: '0e6f0520-0a52-4214-a12a-2d154325f198',
            typeName: 'expression-element',
            position: {
              x: 7,
              y: 5,
            },
            size: {
              x: 5,
              y: 2,
            },
            resizable: false,
            expression: [
              'Assign',
              'a',
              {
                num: '3',
              },
            ],
          },
        ],
      }
stefnotch commented 3 years ago

Cool, glad to see that you got the IDs to work. And woah, I've been using the uuid library for who knows how long, but I didn't know about the validate function. Makes me happy to also learn something new

stefnotch commented 3 years ago

This looks good, I'd be happy to merge it. Would you like to implement the deserializeElement functions or should I take care of that?

I'll probably also tweak small a thing or two and then tell you about it :)