polotno-project / polotno-board

Roadmap and bug-tracker for the Polotno project.
https://polotno.dev/
9 stars 1 forks source link

Readonly Page Elements #39

Closed koolamusic closed 2 years ago

koolamusic commented 2 years ago

Currently we have the locked API that enables locking an element, however this only supports locking both the position and attributes of an element.

We need a way to prevent modifications to the element types Example a type TEXT can be readonly if modifications to the text are not allowed

{  type: 'text',  x: 50,  y: 50,  fill: 'black',  text: 'hello',}

In the above type TEXT, text will not be editable when readonly is set

{
  type: 'image',
  x: 0,
  y: 0,
  rotation: 0,
  locked: false,
  blurEnabled: false,
  src: 'https://example.com/image.png',
  clipSrc: '',
  showInExport: true,
});

In the above element type for IMAGE, we can ensure that clipSrc and src are not editable.

lavrton commented 2 years ago

For the reference, here is an example how to do that for text element with the current API

https://codesandbox.io/s/blissful-ardinghelli-42zs6?file=/src/index.js

koolamusic commented 2 years ago

Thanks a lot, this works well and I am going to close this issue.