Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(javascript) add a read only mode #14

Closed
wants to merge 4 commits into from
Closed

feat(javascript) add a read only mode #14

wants to merge 4 commits into from

Conversation

tbo47
Copy link

@tbo47 tbo47 commented Apr 12, 2022

add a read only mode

I don't know how to use svg-shape-texteditor-decorator.js as I am not using it

you can close this PR if it doesn't make sense

@tbo47 tbo47 closed this Apr 12, 2022
@tbo47 tbo47 reopened this Apr 12, 2022
@AlexeyBoiko
Copy link
Owner

Hello.
If you don't need text editor and delete button -> don't use SvgShapeTextEditorDecorator.
Create diagram without shape decorators:

const diagram = svgDiagramCreate(document.getElementById('diagram'));

If you do not need text editor but need delete button: create your own DeleteButtonDecorator, and use it like this:

const diagram = svgDiagramCreate(
	svg,
	// ShapeDecoratorFuctory
	function(shape, param) {
		// the way to add custom logic inside shapes - decorators
		return new DeleteButtonDecorator(shape, param.createParams.props)
			.on('del', del);
	});

You can add different functionality fo different shapes:

const diagram = svgDiagramCreate(
	svg,
	function(shape, param) {

		switch(param.createParams.templateKey) {
			case 'circle':
				return new CircleDecorator(...);
			case 'oval':
				return new OvalDecorator(...);
		}
		...
	});

You can mix functionality:

const diagram = svgDiagramCreate(
	svg,
	function(shape, param) {
		return new Decorator2(
			new Decorator1(shape)
		);
	});

CLose PR if the solution suits you.

@tbo47
Copy link
Author

tbo47 commented Apr 14, 2022

Thanks for your answer. Yes, I don't use SvgShapeTextEditorDecorator. I just need a mode where I can drag and drop shapes and a mode where I can not.

@tbo47 tbo47 closed this Apr 14, 2022
@AlexeyBoiko
Copy link
Owner

I just need a mode where I can drag and drop shapes and a mode where I can not.

If you want to disable shape:

shape.update({ state: shape.stateGet().add('disabled') });

You can use CSS, to disable all shapes:

[data-templ] {
	pointer-events: none;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants