Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Eteri
erp5
Commits
36889ca4
Commit
36889ca4
authored
Feb 12, 2018
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_core] Display non editable SVG as an image
parent
122608e3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
3 deletions
+18
-3
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getEditorFieldPreferredTextEditor.py
...skins/erp5_core/Base_getEditorFieldPreferredTextEditor.py
+4
-0
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/gadget_editor.js.js
...inTemplateItem/portal_skins/erp5_core/gadget_editor.js.js
+14
-3
No files found.
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getEditorFieldPreferredTextEditor.py
View file @
36889ca4
...
@@ -19,5 +19,9 @@ if content_type == 'text/html':
...
@@ -19,5 +19,9 @@ if content_type == 'text/html':
if
content_type
==
'application/pdf'
:
if
content_type
==
'application/pdf'
:
return
'pdf'
return
'pdf'
# If this is a SVG, use the default SVG editor
if
content_type
==
'image/svg+xml'
:
return
'svg_editor'
# Else use preferred source code editor or fallback to Textarea
# Else use preferred source code editor or fallback to Textarea
return
context
.
portal_preferences
.
getPreferredSourceCodeEditor
()
or
'text_area'
return
context
.
portal_preferences
.
getPreferredSourceCodeEditor
()
or
'text_area'
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/gadget_editor.js.js
View file @
36889ca4
...
@@ -15,19 +15,17 @@ lockGadgetInQueue, unlockGadgetInQueue, unlockGadgetInFailedQueue*/
...
@@ -15,19 +15,17 @@ lockGadgetInQueue, unlockGadgetInQueue, unlockGadgetInFailedQueue*/
"
pdf
"
:
{
"
url
"
:
"
pdf_js/pdfjs.gadget.html
"
}
"
pdf
"
:
{
"
url
"
:
"
pdf_js/pdfjs.gadget.html
"
}
};
};
/*
function
readBlobAsDataURL
(
blob
)
{
function
readBlobAsDataURL
(
blob
)
{
var
fr
=
new
FileReader
();
var
fr
=
new
FileReader
();
return
new
RSVP
.
Promise
(
function
(
resolve
,
reject
,
notify
)
{
return
new
RSVP
.
Promise
(
function
(
resolve
,
reject
,
notify
)
{
fr
.
addEventListener
(
"
load
"
,
resolve
);
fr
.
addEventListener
(
"
load
"
,
resolve
);
fr
.
addEventListener
(
"
error
"
,
reject
);
fr
.
addEventListener
(
"
error
"
,
reject
);
fr.addEventListener("progress", notify);
fr
.
readAsDataURL
(
blob
);
fr
.
readAsDataURL
(
blob
);
},
function
()
{
},
function
()
{
fr
.
abort
();
fr
.
abort
();
});
});
}
}
*/
rJS
(
window
)
rJS
(
window
)
.
declareAcquiredMethod
(
'
triggerMaximize
'
,
'
triggerMaximize
'
)
.
declareAcquiredMethod
(
'
triggerMaximize
'
,
'
triggerMaximize
'
)
...
@@ -122,6 +120,9 @@ lockGadgetInQueue, unlockGadgetInQueue, unlockGadgetInFailedQueue*/
...
@@ -122,6 +120,9 @@ lockGadgetInQueue, unlockGadgetInQueue, unlockGadgetInFailedQueue*/
}
else
if
(
gadget
.
state
.
editable
&&
}
else
if
(
gadget
.
state
.
editable
&&
(
gadget
.
state
.
editor
===
'
text_area
'
))
{
(
gadget
.
state
.
editor
===
'
text_area
'
))
{
element
.
appendChild
(
document
.
createElement
(
'
textarea
'
));
element
.
appendChild
(
document
.
createElement
(
'
textarea
'
));
}
else
if
(
!
gadget
.
state
.
editable
&&
(
gadget
.
state
.
editor
===
'
svg_editor
'
))
{
element
.
appendChild
(
document
.
createElement
(
'
img
'
));
}
else
{
}
else
{
element
.
appendChild
(
document
.
createElement
(
'
pre
'
));
element
.
appendChild
(
document
.
createElement
(
'
pre
'
));
}
}
...
@@ -141,6 +142,16 @@ lockGadgetInQueue, unlockGadgetInQueue, unlockGadgetInFailedQueue*/
...
@@ -141,6 +142,16 @@ lockGadgetInQueue, unlockGadgetInQueue, unlockGadgetInFailedQueue*/
}
else
if
(
gadget
.
state
.
editable
&&
}
else
if
(
gadget
.
state
.
editable
&&
(
gadget
.
state
.
editor
===
'
text_area
'
))
{
(
gadget
.
state
.
editor
===
'
text_area
'
))
{
element
.
querySelector
(
'
textarea
'
).
value
=
gadget
.
state
.
value
;
element
.
querySelector
(
'
textarea
'
).
value
=
gadget
.
state
.
value
;
}
else
if
(
!
gadget
.
state
.
editable
&&
(
gadget
.
state
.
editor
===
'
svg_editor
'
))
{
queue
.
push
(
function
()
{
var
blob
=
new
Blob
([
gadget
.
state
.
value
],
{
type
:
'
image/svg+xml
'
});
return
readBlobAsDataURL
(
blob
);
})
.
push
(
function
(
evt
)
{
element
.
querySelector
(
'
img
'
).
src
=
evt
.
target
.
result
;
});
}
else
{
}
else
{
element
.
querySelector
(
'
pre
'
).
textContent
=
gadget
.
state
.
value
;
element
.
querySelector
(
'
pre
'
).
textContent
=
gadget
.
state
.
value
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment