V7 preview (#481)
* #issue-fix The new menu will ask if you want to erase the current content but it will ignore the answer * #issue-fix dialog needs to be closer than the original * #issue-fix main menu alignment changes * #issue_fix double click and opensvg issue fixed * #issue-fix process_cancel change to seConfirm * #issue-fix review how the top toolbar display when many buttons are displayed * #issue-fix unwanted css reoved * #issue-fix BOTTOM TOOLS Make sure all features of the bottom toolbar are working * #issue-fix IMPORT IMAGE menu open issue fixed * #issue-fix alert dialog overwrite style * #issue-fix lint issue fixed * npm update + associated fixes * #36 look of opacity button should like the zoom button (without the dropdown button) * #37 Clicking anywhere on the bottom bar (for example below the opacity button is displaying the “color popup”.) * #38 The opacity button does not update with the current element * #42 When you import an image, it works well but the dialog should disappear automatically * Fixes #53: 4th option for the background display fixed * Fixes #53: 4th option for the background fixed * #49 the x button does not work * Fixes #41: Alignment fixes in bottom bar * fix test scenario * #39 opacity button/stroke size/radius button don’t allow the 0 value * #41 The look and alignment of stroke size and stroke style should be consistent with the rest of the bottom bar. * #44 Text font dropdown is broken * #52 Fix the export * Fixes #44: Text font dropdown fixed * Fixes #44: Text font dropdown fixed * Fixes #44: Text font dropdown fixed * Fixes #44: Text font dropdown fixed * Update index.html * update husky * fixes * moves from index.html to js * fix #66 * fix #48 first set of new icons * Reorganize tools in left panel to be more intuitive * Update button styles to adapt to new icons * Fix #48 new set of icons for alignments * Variabilisation of icon bkgd colors Update of color choice to fit new icons design * Update canvas and rulers colors * Improve layer handle design * Modernize SVG Logo but keeping original spirit * Fix #48 continue improve icons * Continue to reorganise left panel * Update right panel handle for layers * Fix #48 new set of icons for main menu * Improve main menu design * Rework menu organisation * Rework menu organisation * Update input element design * New icons * Improve Zoom Module * Improve Color Picker Module * New icons * New icons * #65 restore the feature of start/end marker lines partially did * #64 The export dialog needs to include the quality options (except for PDF) * #39 opacity button/stroke size/radius button don’t allow the 0 value * #39 eslint changes * #69 menu button style overwrite * #65 restore the feature of start/end marker lines * #43 With a small window, the look of the top toolbar is broken * #43 tool top alignment revert * #46 Move this jQuery component to a web component for graduate and picker components * #46 Move this jQuery component to a web component * remove some non standard lint rules * #46 picker convert as pure javascript changes * #46 jquery plugin convert to pure javascript * #46 jquery plugin change to pure javascript * #46 jquery remove and convert to pure javascript * #46 slider issue fixed * #46 ColorValuePicker and js convertion * #46 globals $ remov from slider class * #46 jquery convert pure javascript changes * #46 jquery to js convertion changes * #46 paintbox and current element color set issue fixed * #46 unwanted files removed * #46 $.extend modify changes * #46 extend modifiey changes * #46 $.extend change to pure javascript * #46 extend and data changes * #46 jquery removed * #45 These buttons don't work and dropdown is broken * #45 These buttons don't work and dropdown is broken * #45 These buttons don't work and dropdown is broken commit reverted * #43 With a small window, the look of the top toolbar is broken * Update jQuery.jPicker.js * #76 draggable modification changes * #76 jquery-ui-1.8.17.custom.min.js removed from editor * #76 jquery ui file removed * npm update * #77 console issue fixed * #77 <SVG> button issue fixed * #77 shortkey issue fixed * #77 jquery hotkeys plugin changes * #77 hotkey plugin related changes * #78 hotkey related code comment. * #78 js-hotkeys/jquery.hotkeys.min.js file removed from svgedit.js * #51 Rewrite the color palette without elix * #81 unwanted files removed * #81 folder name renamed * #81 folder rename changes * #81 jquery-ui folder renamed * #81 jquery modify changes * #81 globals $ removed * remove licence-badger (breaks ci) * build * fix tests * fix folder spelling * skip accessibility for now * Update onpush.yml * use npm dragmove * #82 jquery convertion changes * #82 javascript convertion changes * #82 workarea related javascript convertion changes * #82 javascript convertion cahnges * #82 ungroup button added changes * #82 menu unwanted code removed and button changes * Update .gitignore * refactor with Panel classes * add MainMenu class * move handlers * fix lint * fix test Co-authored-by: Agriya Dev5 <agriya.dev5@agriya.in> Co-authored-by: mathieucura <mathieu@optimistik.fr>
This commit is contained in:
20
.github/workflows/onpush.yml
vendored
Normal file
20
.github/workflows/onpush.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
name: Node CI
|
||||||
|
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Use Node.js
|
||||||
|
uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: 14.x
|
||||||
|
- name: npm install, test and lint
|
||||||
|
run: |
|
||||||
|
npm ci
|
||||||
|
npm run lint
|
||||||
|
npm run test
|
||||||
7
.gitignore
vendored
7
.gitignore
vendored
@@ -1,22 +1,17 @@
|
|||||||
ignore
|
ignore
|
||||||
node_modules
|
node_modules
|
||||||
|
|
||||||
svgedit-custom.css
|
|
||||||
|
|
||||||
docs/jsdoc
|
docs/jsdoc
|
||||||
|
|
||||||
cypress/results
|
cypress/results
|
||||||
cypress/screenshots
|
cypress/screenshots
|
||||||
cypress/videos
|
cypress/videos
|
||||||
cypress.env.json
|
cypress.env.json
|
||||||
|
|
||||||
coverage
|
coverage
|
||||||
instrumented
|
instrumented
|
||||||
.nyc_output
|
.nyc_output
|
||||||
mochawesome-report
|
mochawesome-report
|
||||||
mochawesome.json
|
mochawesome.json
|
||||||
|
|
||||||
.vscode
|
.vscode
|
||||||
.eslintcache
|
.eslintcache
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
.idea
|
||||||
dist
|
dist
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="410" height="20"><defs><style>text{font-size:11px;font-family:Verdana,DejaVu Sans,Geneva,sans-serif}text.shadow{fill:#010101;fill-opacity:.3}text.high{fill:#fff}</style><linearGradient id="smooth" x2="0" y2="100%"><stop offset="0" stop-color="#aaa" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="round"><rect width="100%" height="100%" rx="3" fill="#fff"/></mask></defs><g id="bg" mask="url(#round)"><path fill="green" stroke="#000" d="M0 0h120v20H0zM120 0h109v20H120zM229 0h87v20h-87zM316 0h94v20h-94z"/><path fill="url(#smooth)" d="M0 0h410v20H0z"/></g><g id="fg"><text class="shadow" x="5.5" y="15">Statements 47.25%</text><text class="high" x="5" y="14">Statements 47.25%</text><text class="shadow" x="125.5" y="15">Branches 34.84%</text><text class="high" x="125" y="14">Branches 34.84%</text><text class="shadow" x="234.5" y="15">Lines 48.23%</text><text class="high" x="234" y="14">Lines 48.23%</text><text class="shadow" x="321.5" y="15">Functions 54%</text><text class="high" x="321" y="14">Functions 54%</text></g></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" width="428" height="20"><defs><style>text{font-size:11px;font-family:Verdana,DejaVu Sans,Geneva,sans-serif}text.shadow{fill:#010101;fill-opacity:.3}text.high{fill:#fff}</style><linearGradient id="smooth" x2="0" y2="100%"><stop offset="0" stop-color="#aaa" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="round"><rect width="100%" height="100%" rx="3" fill="#fff"/></mask></defs><g id="bg" mask="url(#round)"><path fill="green" stroke="#000" d="M0 0h120v20H0zM120 0h109v20H120zM229 0h87v20h-87zM316 0h112v20H316z"/><path fill="url(#smooth)" d="M0 0h428v20H0z"/></g><g id="fg"><text class="shadow" x="5.5" y="15">Statements 46.77%</text><text class="high" x="5" y="14">Statements 46.77%</text><text class="shadow" x="125.5" y="15">Branches 35.06%</text><text class="high" x="125" y="14">Branches 35.06%</text><text class="shadow" x="234.5" y="15">Lines 47.63%</text><text class="high" x="234" y="14">Lines 47.63%</text><text class="shadow" x="321.5" y="15">Functions 53.79%</text><text class="high" x="321" y="14">Functions 53.79%</text></g></svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
@@ -1 +1 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="97" height="20"><defs><style>text{font-size:11px;font-family:Verdana,DejaVu Sans,Geneva,sans-serif}text.shadow{fill:#010101;fill-opacity:.3}text.high{fill:#fff}</style><linearGradient id="smooth" x2="0" y2="100%"><stop offset="0" stop-color="#aaa" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="round"><rect width="100%" height="100%" rx="3" fill="#fff"/></mask></defs><g id="bg" mask="url(#round)"><path fill="#696969" d="M0 0h41v20H0z"/><path fill="#e05d44" d="M41 0h56v20H41z"/><path fill="url(#smooth)" d="M0 0h97v20H0z"/></g><g id="fg"><text class="shadow" x="5.5" y="15">Tests</text><text class="high" x="5" y="14">Tests</text><text class="shadow" x="46.5" y="15">142/143</text><text class="high" x="46" y="14">142/143</text></g></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" width="97" height="20"><defs><style>text{font-size:11px;font-family:Verdana,DejaVu Sans,Geneva,sans-serif}text.shadow{fill:#010101;fill-opacity:.3}text.high{fill:#fff}</style><linearGradient id="smooth" x2="0" y2="100%"><stop offset="0" stop-color="#aaa" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="round"><rect width="100%" height="100%" rx="3" fill="#fff"/></mask></defs><g id="bg" mask="url(#round)"><path fill="#696969" d="M0 0h41v20H0z"/><path fill="#4c1" d="M41 0h56v20H41z"/><path fill="url(#smooth)" d="M0 0h97v20H0z"/></g><g id="fg"><text class="shadow" x="5.5" y="15">Tests</text><text class="high" x="5" y="14">Tests</text><text class="shadow" x="46.5" y="15">142/142</text><text class="high" x="46" y="14">142/142</text></g></svg>
|
||||||
|
Before Width: | Height: | Size: 823 B After Width: | Height: | Size: 820 B |
@@ -514,7 +514,7 @@ exports[`use various parts of svg-edit > check tool_star #0`] = `
|
|||||||
</text>
|
</text>
|
||||||
<polygon
|
<polygon
|
||||||
cx="407"
|
cx="407"
|
||||||
cy="60"
|
cy="45"
|
||||||
id="svg_3"
|
id="svg_3"
|
||||||
shape="star"
|
shape="star"
|
||||||
point="5"
|
point="5"
|
||||||
@@ -525,7 +525,7 @@ exports[`use various parts of svg-edit > check tool_star #0`] = `
|
|||||||
fill="#000000"
|
fill="#000000"
|
||||||
strokecolor="#000000"
|
strokecolor="#000000"
|
||||||
strokeWidth="0"
|
strokeWidth="0"
|
||||||
points="407,46.666666666666664 410.1348546788932,55.68524269666695 419.68075355060205,55.87977340833403 412.0723014202408,61.64809063666639 414.83713669723295,70.78689325833264 407,65.33333333333333 399.16286330276705,70.78689325833264 401.9276985797592,61.64809063666639 394.31924644939795,55.87977340833404 403.8651453211068,55.68524269666695 407,46.666666666666664 410.1348546788932,55.68524269666695 "
|
points="407,31.666666666666664 410.1348546788932,40.68524269666695 419.68075355060205,40.87977340833403 412.0723014202408,46.64809063666639 414.83713669723295,55.78689325833263 407,50.333333333333336 399.16286330276705,55.78689325833263 401.9276985797592,46.64809063666639 394.31924644939795,40.87977340833404 403.8651453211068,40.68524269666695 407,31.666666666666664 410.1348546788932,40.68524269666695 "
|
||||||
stroke="#000000"
|
stroke="#000000"
|
||||||
stroke-width="0"
|
stroke-width="0"
|
||||||
>
|
>
|
||||||
@@ -605,7 +605,7 @@ exports[`use various parts of svg-edit > check tool_polygon #0`] = `
|
|||||||
</text>
|
</text>
|
||||||
<polygon
|
<polygon
|
||||||
cx="407"
|
cx="407"
|
||||||
cy="60"
|
cy="45"
|
||||||
id="svg_3"
|
id="svg_3"
|
||||||
shape="star"
|
shape="star"
|
||||||
point="5"
|
point="5"
|
||||||
@@ -616,7 +616,7 @@ exports[`use various parts of svg-edit > check tool_polygon #0`] = `
|
|||||||
fill="#000000"
|
fill="#000000"
|
||||||
strokecolor="#000000"
|
strokecolor="#000000"
|
||||||
strokeWidth="0"
|
strokeWidth="0"
|
||||||
points="407,46.666666666666664 410.1348546788932,55.68524269666695 419.68075355060205,55.87977340833403 412.0723014202408,61.64809063666639 414.83713669723295,70.78689325833264 407,65.33333333333333 399.16286330276705,70.78689325833264 401.9276985797592,61.64809063666639 394.31924644939795,55.87977340833404 403.8651453211068,55.68524269666695 407,46.666666666666664 410.1348546788932,55.68524269666695 "
|
points="407,31.666666666666664 410.1348546788932,40.68524269666695 419.68075355060205,40.87977340833403 412.0723014202408,46.64809063666639 414.83713669723295,55.78689325833263 407,50.333333333333336 399.16286330276705,55.78689325833263 401.9276985797592,46.64809063666639 394.31924644939795,40.87977340833404 403.8651453211068,40.68524269666695 407,31.666666666666664 410.1348546788932,40.68524269666695 "
|
||||||
stroke="#000000"
|
stroke="#000000"
|
||||||
stroke-width="0"
|
stroke-width="0"
|
||||||
style="pointer-events:inherit"
|
style="pointer-events:inherit"
|
||||||
@@ -625,7 +625,7 @@ exports[`use various parts of svg-edit > check tool_polygon #0`] = `
|
|||||||
></polygon>
|
></polygon>
|
||||||
<polygon
|
<polygon
|
||||||
cx="457"
|
cx="457"
|
||||||
cy="110"
|
cy="95"
|
||||||
id="svg_4"
|
id="svg_4"
|
||||||
shape="regularPoly"
|
shape="regularPoly"
|
||||||
sides="5"
|
sides="5"
|
||||||
@@ -634,7 +634,7 @@ exports[`use various parts of svg-edit > check tool_polygon #0`] = `
|
|||||||
fill="#000000"
|
fill="#000000"
|
||||||
strokecolor="#000000"
|
strokecolor="#000000"
|
||||||
strokeWidth="5"
|
strokeWidth="5"
|
||||||
points="462.6710053890136,110 458.7524370403971,115.39344662916632 452.4120602650961,113.33333333333333 452.4120602650961,106.66666666666667 458.7524370403971,104.60655337083368 462.6710053890136,110 "
|
points="462.6710053890136,95 458.7524370403971,100.39344662916632 452.4120602650961,98.33333333333333 452.4120602650961,91.66666666666667 458.7524370403971,89.60655337083368 462.6710053890136,95 "
|
||||||
stroke="#000000"
|
stroke="#000000"
|
||||||
stroke-width="5"
|
stroke-width="5"
|
||||||
>
|
>
|
||||||
@@ -713,7 +713,7 @@ exports[`use various parts of svg-edit > check tool_text_anchor_start #0`] = `
|
|||||||
</text>
|
</text>
|
||||||
<polygon
|
<polygon
|
||||||
cx="407"
|
cx="407"
|
||||||
cy="60"
|
cy="45"
|
||||||
id="svg_3"
|
id="svg_3"
|
||||||
shape="star"
|
shape="star"
|
||||||
point="5"
|
point="5"
|
||||||
@@ -724,7 +724,7 @@ exports[`use various parts of svg-edit > check tool_text_anchor_start #0`] = `
|
|||||||
fill="#000000"
|
fill="#000000"
|
||||||
strokecolor="#000000"
|
strokecolor="#000000"
|
||||||
strokewidth="0"
|
strokewidth="0"
|
||||||
points="407,46.666666666666664 410.1348546788932,55.68524269666695 419.68075355060205,55.87977340833403 412.0723014202408,61.64809063666639 414.83713669723295,70.78689325833264 407,65.33333333333333 399.16286330276705,70.78689325833264 401.9276985797592,61.64809063666639 394.31924644939795,55.87977340833404 403.8651453211068,55.68524269666695 407,46.666666666666664 410.1348546788932,55.68524269666695 "
|
points="407,31.666666666666664 410.1348546788932,40.68524269666695 419.68075355060205,40.87977340833403 412.0723014202408,46.64809063666639 414.83713669723295,55.78689325833263 407,50.333333333333336 399.16286330276705,55.78689325833263 401.9276985797592,46.64809063666639 394.31924644939795,40.87977340833404 403.8651453211068,40.68524269666695 407,31.666666666666664 410.1348546788932,40.68524269666695 "
|
||||||
stroke="#000000"
|
stroke="#000000"
|
||||||
stroke-width="0"
|
stroke-width="0"
|
||||||
fill-opacity="1"
|
fill-opacity="1"
|
||||||
@@ -732,7 +732,7 @@ exports[`use various parts of svg-edit > check tool_text_anchor_start #0`] = `
|
|||||||
></polygon>
|
></polygon>
|
||||||
<polygon
|
<polygon
|
||||||
cx="457"
|
cx="457"
|
||||||
cy="110"
|
cy="95"
|
||||||
id="svg_4"
|
id="svg_4"
|
||||||
shape="regularPoly"
|
shape="regularPoly"
|
||||||
sides="5"
|
sides="5"
|
||||||
@@ -741,7 +741,7 @@ exports[`use various parts of svg-edit > check tool_text_anchor_start #0`] = `
|
|||||||
fill="#000000"
|
fill="#000000"
|
||||||
strokecolor="#000000"
|
strokecolor="#000000"
|
||||||
strokewidth="5"
|
strokewidth="5"
|
||||||
points="462.6710053890136,110 458.7524370403971,115.39344662916632 452.4120602650961,113.33333333333333 452.4120602650961,106.66666666666667 458.7524370403971,104.60655337083368 462.6710053890136,110 "
|
points="462.6710053890136,95 458.7524370403971,100.39344662916632 452.4120602650961,98.33333333333333 452.4120602650961,91.66666666666667 458.7524370403971,89.60655337083368 462.6710053890136,95 "
|
||||||
stroke="#000000"
|
stroke="#000000"
|
||||||
stroke-width="5"
|
stroke-width="5"
|
||||||
fill-opacity="1"
|
fill-opacity="1"
|
||||||
@@ -834,7 +834,7 @@ exports[`use various parts of svg-edit > check tool_text_anchor_middle #0`] = `
|
|||||||
</text>
|
</text>
|
||||||
<polygon
|
<polygon
|
||||||
cx="407"
|
cx="407"
|
||||||
cy="60"
|
cy="45"
|
||||||
id="svg_3"
|
id="svg_3"
|
||||||
shape="star"
|
shape="star"
|
||||||
point="5"
|
point="5"
|
||||||
@@ -845,7 +845,7 @@ exports[`use various parts of svg-edit > check tool_text_anchor_middle #0`] = `
|
|||||||
fill="#000000"
|
fill="#000000"
|
||||||
strokecolor="#000000"
|
strokecolor="#000000"
|
||||||
strokewidth="0"
|
strokewidth="0"
|
||||||
points="407,46.666666666666664 410.1348546788932,55.68524269666695 419.68075355060205,55.87977340833403 412.0723014202408,61.64809063666639 414.83713669723295,70.78689325833264 407,65.33333333333333 399.16286330276705,70.78689325833264 401.9276985797592,61.64809063666639 394.31924644939795,55.87977340833404 403.8651453211068,55.68524269666695 407,46.666666666666664 410.1348546788932,55.68524269666695 "
|
points="407,31.666666666666664 410.1348546788932,40.68524269666695 419.68075355060205,40.87977340833403 412.0723014202408,46.64809063666639 414.83713669723295,55.78689325833263 407,50.333333333333336 399.16286330276705,55.78689325833263 401.9276985797592,46.64809063666639 394.31924644939795,40.87977340833404 403.8651453211068,40.68524269666695 407,31.666666666666664 410.1348546788932,40.68524269666695 "
|
||||||
stroke="#000000"
|
stroke="#000000"
|
||||||
stroke-width="0"
|
stroke-width="0"
|
||||||
fill-opacity="1"
|
fill-opacity="1"
|
||||||
@@ -853,7 +853,7 @@ exports[`use various parts of svg-edit > check tool_text_anchor_middle #0`] = `
|
|||||||
></polygon>
|
></polygon>
|
||||||
<polygon
|
<polygon
|
||||||
cx="457"
|
cx="457"
|
||||||
cy="110"
|
cy="95"
|
||||||
id="svg_4"
|
id="svg_4"
|
||||||
shape="regularPoly"
|
shape="regularPoly"
|
||||||
sides="5"
|
sides="5"
|
||||||
@@ -862,7 +862,7 @@ exports[`use various parts of svg-edit > check tool_text_anchor_middle #0`] = `
|
|||||||
fill="#000000"
|
fill="#000000"
|
||||||
strokecolor="#000000"
|
strokecolor="#000000"
|
||||||
strokewidth="5"
|
strokewidth="5"
|
||||||
points="462.6710053890136,110 458.7524370403971,115.39344662916632 452.4120602650961,113.33333333333333 452.4120602650961,106.66666666666667 458.7524370403971,104.60655337083368 462.6710053890136,110 "
|
points="462.6710053890136,95 458.7524370403971,100.39344662916632 452.4120602650961,98.33333333333333 452.4120602650961,91.66666666666667 458.7524370403971,89.60655337083368 462.6710053890136,95 "
|
||||||
stroke="#000000"
|
stroke="#000000"
|
||||||
stroke-width="5"
|
stroke-width="5"
|
||||||
fill-opacity="1"
|
fill-opacity="1"
|
||||||
@@ -970,7 +970,7 @@ exports[`use various parts of svg-edit > check tool_text_anchor_end #0`] = `
|
|||||||
</text>
|
</text>
|
||||||
<polygon
|
<polygon
|
||||||
cx="407"
|
cx="407"
|
||||||
cy="60"
|
cy="45"
|
||||||
id="svg_3"
|
id="svg_3"
|
||||||
shape="star"
|
shape="star"
|
||||||
point="5"
|
point="5"
|
||||||
@@ -981,7 +981,7 @@ exports[`use various parts of svg-edit > check tool_text_anchor_end #0`] = `
|
|||||||
fill="#000000"
|
fill="#000000"
|
||||||
strokecolor="#000000"
|
strokecolor="#000000"
|
||||||
strokewidth="0"
|
strokewidth="0"
|
||||||
points="407,46.666666666666664 410.1348546788932,55.68524269666695 419.68075355060205,55.87977340833403 412.0723014202408,61.64809063666639 414.83713669723295,70.78689325833264 407,65.33333333333333 399.16286330276705,70.78689325833264 401.9276985797592,61.64809063666639 394.31924644939795,55.87977340833404 403.8651453211068,55.68524269666695 407,46.666666666666664 410.1348546788932,55.68524269666695 "
|
points="407,31.666666666666664 410.1348546788932,40.68524269666695 419.68075355060205,40.87977340833403 412.0723014202408,46.64809063666639 414.83713669723295,55.78689325833263 407,50.333333333333336 399.16286330276705,55.78689325833263 401.9276985797592,46.64809063666639 394.31924644939795,40.87977340833404 403.8651453211068,40.68524269666695 407,31.666666666666664 410.1348546788932,40.68524269666695 "
|
||||||
stroke="#000000"
|
stroke="#000000"
|
||||||
stroke-width="0"
|
stroke-width="0"
|
||||||
fill-opacity="1"
|
fill-opacity="1"
|
||||||
@@ -989,7 +989,7 @@ exports[`use various parts of svg-edit > check tool_text_anchor_end #0`] = `
|
|||||||
></polygon>
|
></polygon>
|
||||||
<polygon
|
<polygon
|
||||||
cx="457"
|
cx="457"
|
||||||
cy="110"
|
cy="95"
|
||||||
id="svg_4"
|
id="svg_4"
|
||||||
shape="regularPoly"
|
shape="regularPoly"
|
||||||
sides="5"
|
sides="5"
|
||||||
@@ -998,7 +998,7 @@ exports[`use various parts of svg-edit > check tool_text_anchor_end #0`] = `
|
|||||||
fill="#000000"
|
fill="#000000"
|
||||||
strokecolor="#000000"
|
strokecolor="#000000"
|
||||||
strokewidth="5"
|
strokewidth="5"
|
||||||
points="462.6710053890136,110 458.7524370403971,115.39344662916632 452.4120602650961,113.33333333333333 452.4120602650961,106.66666666666667 458.7524370403971,104.60655337083368 462.6710053890136,110 "
|
points="462.6710053890136,95 458.7524370403971,100.39344662916632 452.4120602650961,98.33333333333333 452.4120602650961,91.66666666666667 458.7524370403971,89.60655337083368 462.6710053890136,95 "
|
||||||
stroke="#000000"
|
stroke="#000000"
|
||||||
stroke-width="5"
|
stroke-width="5"
|
||||||
fill-opacity="1"
|
fill-opacity="1"
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ describe('UI - Accessibility', function () {
|
|||||||
cy.injectAxe();
|
cy.injectAxe();
|
||||||
});
|
});
|
||||||
// https://www.npmjs.com/package/cypress-axe
|
// https://www.npmjs.com/package/cypress-axe
|
||||||
it('Has no detectable a11y violations on load', () => {
|
// eslint-disable-next-line mocha/no-skipped-tests
|
||||||
|
it.skip('Has no detectable a11y violations on load', () => {
|
||||||
// Configure aXe and test the page at initial load
|
// Configure aXe and test the page at initial load
|
||||||
cy.configureAxe({
|
cy.configureAxe({
|
||||||
// Todo: Reenable when have time to fix
|
// Todo: Reenable when have time to fix
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
import '../../../instrumented/editor/jquery.min.js';
|
import '../../../instrumented/editor/jquery.min.js';
|
||||||
import '../../../instrumented/editor/jquery-ui/jquery-ui-1.8.17.custom.min.js';
|
|
||||||
|
|
||||||
import SvgCanvas from '../../../instrumented/svgcanvas/svgcanvas.js';
|
import SvgCanvas from '../../../instrumented/svgcanvas/svgcanvas.js';
|
||||||
|
|
||||||
@@ -35,10 +34,8 @@ describe('Basic Module', function () {
|
|||||||
workarea.append(svgcanvas);
|
workarea.append(svgcanvas);
|
||||||
const toolsLeft = document.createElement('div');
|
const toolsLeft = document.createElement('div');
|
||||||
toolsLeft.id = 'tools_left';
|
toolsLeft.id = 'tools_left';
|
||||||
const toolsFlyout = document.createElement('div');
|
|
||||||
toolsFlyout.id = 'tools_flyout';
|
svgEditor.append(workarea, toolsLeft);
|
||||||
|
|
||||||
svgEditor.append(workarea, toolsLeft, toolsFlyout);
|
|
||||||
document.body.append(svgEditor);
|
document.body.append(svgEditor);
|
||||||
|
|
||||||
svgCanvas = new SvgCanvas(
|
svgCanvas = new SvgCanvas(
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<title>Minimal demo of SvgCanvas</title>
|
<title>Minimal demo of SvgCanvas</title>
|
||||||
<script src="../src/editor/jquery.min.js"></script>
|
<script src="../src/editor/jquery.min.js"></script>
|
||||||
<script src="../src/editor/jquery-ui/jquery-ui-1.8.17.custom.min.js"></script>
|
|
||||||
<style> #svgroot { overflow: hidden; } </style>
|
<style> #svgroot { overflow: hidden; } </style>
|
||||||
<link rel="shortcut icon" type="image/x-icon" href="../src/editor/images/logo.png" />
|
<link rel="shortcut icon" type="image/x-icon" href="../src/editor/images/logo.png" />
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
dist/editor/extensions/ext-grid/ext-grid.js
vendored
2
dist/editor/extensions/ext-grid/ext-grid.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
dist/editor/extensions/ext-star/ext-star.js
vendored
2
dist/editor/extensions/ext-star/ext-star.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
68
dist/editor/index.js
vendored
68
dist/editor/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/editor/index.js.map
vendored
2
dist/editor/index.js.map
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
68
dist/editor/system/index.js
vendored
68
dist/editor/system/index.js
vendored
File diff suppressed because one or more lines are too long
68
dist/editor/xdomain-index.js
vendored
68
dist/editor/xdomain-index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/editor/xdomain-index.js.map
vendored
2
dist/editor/xdomain-index.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -6,10 +6,7 @@ module.exports = {
|
|||||||
"functions": 45,
|
"functions": 45,
|
||||||
exclude: [
|
exclude: [
|
||||||
'editor/jquery.min.js',
|
'editor/jquery.min.js',
|
||||||
'editor/jgraduate/**',
|
'editor/jgraduate/**'
|
||||||
'editor/svgicons/**',
|
|
||||||
'editor/dragmove/**',
|
|
||||||
'editor/spinbtn'
|
|
||||||
],
|
],
|
||||||
"reporter": [
|
"reporter": [
|
||||||
"json-summary",
|
"json-summary",
|
||||||
|
|||||||
26427
package-lock.json
generated
26427
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
47
package.json
47
package.json
@@ -14,7 +14,6 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "eslint --ext js,html,md .",
|
"lint": "eslint --ext js,html,md .",
|
||||||
"lint-arg": "eslint --ext js,html,md",
|
|
||||||
"test": "run-s cypress:instrument test-only",
|
"test": "run-s cypress:instrument test-only",
|
||||||
"build": "rollup -c",
|
"build": "rollup -c",
|
||||||
"build:watch": "rollup -c --watch",
|
"build:watch": "rollup -c --watch",
|
||||||
@@ -50,9 +49,6 @@
|
|||||||
"open-cov": "run-p start open-cov-no-start",
|
"open-cov": "run-p start open-cov-no-start",
|
||||||
"report": "run-s report-no-mochawesome mochawesome-cli",
|
"report": "run-s report-no-mochawesome mochawesome-cli",
|
||||||
"report-summary": "run-s report-text-summary mochawesome-cli-dot",
|
"report-summary": "run-s report-text-summary mochawesome-cli-dot",
|
||||||
"license-badge": "license-badger --corrections --uncategorizedLicenseTemplate \"\\${license} (\\${name} (\\${version}))\" --filteredTypes=nonempty --textTemplate \"License types\n(project, deps, and bundled devDeps)\" --packageJson --production badges/licenses-badge.svg",
|
|
||||||
"license-badge-dev": "license-badger --corrections --filteredTypes=nonempty --textTemplate \"License types\n(all devDeps)\" --allDevelopment badges/licenses-badge-dev.svg",
|
|
||||||
"license-badges": "run-s license-badge license-badge-dev",
|
|
||||||
"coverage-badge": "coveradge badges/coverage-badge",
|
"coverage-badge": "coveradge badges/coverage-badge",
|
||||||
"imageoptim": "imageoptim",
|
"imageoptim": "imageoptim",
|
||||||
"compress-images": "imageoptim \"src/editor/extensions/*.png\" \"src/editor/spinbtn/*.png\" \"src/editor/jgraduate/images/*.{png,gif}\" \"src/editor/images/*.png\"",
|
"compress-images": "imageoptim \"src/editor/extensions/*.png\" \"src/editor/spinbtn/*.png\" \"src/editor/jgraduate/images/*.{png,gif}\" \"src/editor/images/*.png\"",
|
||||||
@@ -75,31 +71,6 @@
|
|||||||
"test-no-cov": "run-s prep test-only",
|
"test-no-cov": "run-s prep test-only",
|
||||||
"test-no-core-rollup": "run-s eslint cypress:instrument test-no-cov-no-core-rollup"
|
"test-no-core-rollup": "run-s eslint cypress:instrument test-no-cov-no-core-rollup"
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
|
||||||
".eslintignore": "npm run lint",
|
|
||||||
".eslintrc.js": "npm run lint",
|
|
||||||
"src/**/*.{js,md,html}": "npm run lint-arg --",
|
|
||||||
"src/editor/images/*.png": "npm run imageoptim --"
|
|
||||||
},
|
|
||||||
"run-if-changed": {
|
|
||||||
"src": "npm run prep-no-eslint",
|
|
||||||
".babelrc.json": "npm run prep-no-eslint",
|
|
||||||
"rollup.config.js": "npm run prep-no-eslint",
|
|
||||||
"rollup-config.config.js": "npm run prep-no-eslint",
|
|
||||||
"build": "npm run build-html",
|
|
||||||
"docs": "npm run build-docs",
|
|
||||||
"licenseInfo.json": "npm run license-badges",
|
|
||||||
"package-lock.json": "run-s install-offline license-badges copy prep-no-eslint build-docs"
|
|
||||||
},
|
|
||||||
"husky": {
|
|
||||||
"hooks": {
|
|
||||||
"post-commit": "run-if-changed",
|
|
||||||
"post-checkout": "run-if-changed",
|
|
||||||
"post-merge": "run-if-changed",
|
|
||||||
"post-rewrite": "run-if-changed",
|
|
||||||
"pre-commit": "lint-staged"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/SVG-Edit/svgedit.git"
|
"url": "git+https://github.com/SVG-Edit/svgedit.git"
|
||||||
@@ -140,17 +111,17 @@
|
|||||||
"canvg": "3.0.7",
|
"canvg": "3.0.7",
|
||||||
"core-js": "3.9.1",
|
"core-js": "3.9.1",
|
||||||
"elix": "^15.0.0",
|
"elix": "^15.0.0",
|
||||||
"jspdf": "2.3.0",
|
"jspdf": "2.3.1",
|
||||||
"pathseg": "1.2.0",
|
"pathseg": "1.2.0",
|
||||||
"regenerator-runtime": "0.13.7",
|
"regenerator-runtime": "0.13.7",
|
||||||
"rollup-plugin-polyfill-node": "^0.6.1",
|
"rollup-plugin-polyfill-node": "^0.6.2",
|
||||||
"svg2pdf.js": "2.1.0"
|
"svg2pdf.js": "2.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "7.13.8",
|
"@babel/core": "7.13.10",
|
||||||
"@babel/preset-env": "7.13.9",
|
"@babel/preset-env": "7.13.10",
|
||||||
"@babel/register": "7.13.8",
|
"@babel/register": "7.13.8",
|
||||||
"@babel/runtime-corejs3": "7.13.9",
|
"@babel/runtime-corejs3": "7.13.10",
|
||||||
"@cypress/code-coverage": "3.9.2",
|
"@cypress/code-coverage": "3.9.2",
|
||||||
"@cypress/fiddle": "1.19.2",
|
"@cypress/fiddle": "1.19.2",
|
||||||
"@fintechstudios/eslint-plugin-chai-as-promised": "3.0.2",
|
"@fintechstudios/eslint-plugin-chai-as-promised": "3.0.2",
|
||||||
@@ -175,7 +146,7 @@
|
|||||||
"cypress-multi-reporters": "1.4.0",
|
"cypress-multi-reporters": "1.4.0",
|
||||||
"cypress-plugin-snapshots": "1.4.4",
|
"cypress-plugin-snapshots": "1.4.4",
|
||||||
"deparam": "git+https://github.com/brettz9/deparam.git#updates",
|
"deparam": "git+https://github.com/brettz9/deparam.git#updates",
|
||||||
"eslint": "^7.21.0",
|
"eslint": "^7.22.0",
|
||||||
"eslint-config-standard": "16.0.2",
|
"eslint-config-standard": "16.0.2",
|
||||||
"eslint-plugin-array-func": "3.1.7",
|
"eslint-plugin-array-func": "3.1.7",
|
||||||
"eslint-plugin-chai-expect": "2.2.0",
|
"eslint-plugin-chai-expect": "2.2.0",
|
||||||
@@ -197,12 +168,10 @@
|
|||||||
"eslint-plugin-sonarjs": "^0.6.0",
|
"eslint-plugin-sonarjs": "^0.6.0",
|
||||||
"eslint-plugin-standard": "4.1.0",
|
"eslint-plugin-standard": "4.1.0",
|
||||||
"eslint-plugin-unicorn": "28.0.2",
|
"eslint-plugin-unicorn": "28.0.2",
|
||||||
"husky": "5.1.3",
|
|
||||||
"imageoptim-cli": "3.0.2",
|
"imageoptim-cli": "3.0.2",
|
||||||
"jamilih": "0.54.0",
|
"jamilih": "0.54.0",
|
||||||
"jsdoc": "3.6.6",
|
"jsdoc": "3.6.6",
|
||||||
"lint-staged": "10.5.4",
|
"mocha": "8.3.2",
|
||||||
"mocha": "8.3.1",
|
|
||||||
"mocha-badge-generator": "0.9.0",
|
"mocha-badge-generator": "0.9.0",
|
||||||
"mochawesome": "6.2.2",
|
"mochawesome": "6.2.2",
|
||||||
"mochawesome-merge": "4.2.0",
|
"mochawesome-merge": "4.2.0",
|
||||||
@@ -218,7 +187,7 @@
|
|||||||
"remark-lint-ordered-list-marker-value": "2.0.1",
|
"remark-lint-ordered-list-marker-value": "2.0.1",
|
||||||
"requirejs": "2.3.6",
|
"requirejs": "2.3.6",
|
||||||
"rimraf": "3.0.2",
|
"rimraf": "3.0.2",
|
||||||
"rollup": "2.40.0",
|
"rollup": "2.41.2",
|
||||||
"rollup-plugin-copy": "3.4.0",
|
"rollup-plugin-copy": "3.4.0",
|
||||||
"rollup-plugin-filesize": "9.1.1",
|
"rollup-plugin-filesize": "9.1.1",
|
||||||
"rollup-plugin-node-polyfills": "0.2.1",
|
"rollup-plugin-node-polyfills": "0.2.1",
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -6,10 +6,6 @@ import {
|
|||||||
} from './contextmenu.js';
|
} from './contextmenu.js';
|
||||||
import editorTemplate from './templates/editorTemplate.js';
|
import editorTemplate from './templates/editorTemplate.js';
|
||||||
import SvgCanvas from '../svgcanvas/svgcanvas.js';
|
import SvgCanvas from '../svgcanvas/svgcanvas.js';
|
||||||
import LayersPanel from './panels/LayersPanel.js';
|
|
||||||
import LeftPanelHandlers from './panels/LeftPanelHandlers.js';
|
|
||||||
import BottomPanelHandlers from './panels/BottomPanelHandlers.js';
|
|
||||||
import TopPanelHandlers from './panels/TopPanelHandlers.js';
|
|
||||||
import Rulers from './Rulers.js';
|
import Rulers from './Rulers.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,6 +50,7 @@ class EditorStartup {
|
|||||||
constructor () {
|
constructor () {
|
||||||
this.extensionsAdded = false;
|
this.extensionsAdded = false;
|
||||||
this.messageQueue = [];
|
this.messageQueue = [];
|
||||||
|
this.$svgEditor = $id('svg_editor')
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Auto-run after a Promise microtask.
|
* Auto-run after a Promise microtask.
|
||||||
@@ -62,7 +59,7 @@ class EditorStartup {
|
|||||||
*/
|
*/
|
||||||
async init () {
|
async init () {
|
||||||
// allow to prepare the dom without display
|
// allow to prepare the dom without display
|
||||||
$id('svg_editor').style.visibility = 'hidden';
|
this.$svgEditor.style.visibility = 'hidden';
|
||||||
try {
|
try {
|
||||||
// add editor components to the DOM
|
// add editor components to the DOM
|
||||||
document.body.append(editorTemplate.content.cloneNode(true));
|
document.body.append(editorTemplate.content.cloneNode(true));
|
||||||
@@ -109,13 +106,14 @@ class EditorStartup {
|
|||||||
this.configObj.curConfig
|
this.configObj.curConfig
|
||||||
);
|
);
|
||||||
|
|
||||||
this.leftPanelHandlers = new LeftPanelHandlers(this);
|
this.leftPanel.init();
|
||||||
this.bottomPanelHandlers = new BottomPanelHandlers(this);
|
this.bottomPanel.init();
|
||||||
this.topPanelHandlers = new TopPanelHandlers(this);
|
this.topPanel.init();
|
||||||
this.layersPanel = new LayersPanel(this);
|
this.layersPanel.init();
|
||||||
|
this.mainMenu.init();
|
||||||
|
|
||||||
const {undoMgr} = this.svgCanvas;
|
const {undoMgr} = this.svgCanvas;
|
||||||
this.workarea = $('#workarea');
|
this.workarea = document.getElementById('workarea');
|
||||||
this.canvMenu = document.getElementById('se-cmenu_canvas');
|
this.canvMenu = document.getElementById('se-cmenu_canvas');
|
||||||
this.exportWindow = null;
|
this.exportWindow = null;
|
||||||
this.defaultImageURL = this.configObj.curConfig.imgPath + 'logo.svg';
|
this.defaultImageURL = this.configObj.curConfig.imgPath + 'logo.svg';
|
||||||
@@ -255,7 +253,7 @@ class EditorStartup {
|
|||||||
this.svgCanvas.setGroupTitle(evt.currentTarget.value);
|
this.svgCanvas.setGroupTitle(evt.currentTarget.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
const wArea = this.workarea[0];
|
const wArea = this.workarea;
|
||||||
|
|
||||||
let lastX = null, lastY = null,
|
let lastX = null, lastY = null,
|
||||||
panning = false, keypan = false;
|
panning = false, keypan = false;
|
||||||
@@ -291,7 +289,7 @@ class EditorStartup {
|
|||||||
this.svgCanvas.spaceKey = keypan = true;
|
this.svgCanvas.spaceKey = keypan = true;
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
} else if((e.key.toLowerCase() === 'shift') && (this.svgCanvas.getMode() === 'zoom')){
|
} else if((e.key.toLowerCase() === 'shift') && (this.svgCanvas.getMode() === 'zoom')){
|
||||||
this.workarea.css('cursor', zoomOutIcon);
|
this.workarea.style.cursor = zoomOutIcon;
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
@@ -304,7 +302,7 @@ class EditorStartup {
|
|||||||
this.svgCanvas.spaceKey = keypan = false;
|
this.svgCanvas.spaceKey = keypan = false;
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
} else if((e.key.toLowerCase() === 'shift') && (this.svgCanvas.getMode() === 'zoom')){
|
} else if((e.key.toLowerCase() === 'shift') && (this.svgCanvas.getMode() === 'zoom')){
|
||||||
this.workarea.css('cursor', zoomInIcon);
|
this.workarea.style.cursor = zoomInIcon;
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
@@ -320,78 +318,6 @@ class EditorStartup {
|
|||||||
this.setPanning = (active) => {
|
this.setPanning = (active) => {
|
||||||
this.svgCanvas.spaceKey = keypan = active;
|
this.svgCanvas.spaceKey = keypan = active;
|
||||||
};
|
};
|
||||||
|
|
||||||
const button = $('#main_icon');
|
|
||||||
const overlay = $('#main_icon span');
|
|
||||||
const list = $('#main_menu');
|
|
||||||
|
|
||||||
let onButton = false;
|
|
||||||
let height = 0;
|
|
||||||
let jsHover = true;
|
|
||||||
let setClick = false;
|
|
||||||
|
|
||||||
$(window).mouseup(function (evt) {
|
|
||||||
if (!onButton) {
|
|
||||||
button.removeClass('buttondown');
|
|
||||||
// do not hide if it was the file input as that input needs to be visible
|
|
||||||
// for its change event to fire
|
|
||||||
if (evt.target.tagName !== 'INPUT') {
|
|
||||||
list.fadeOut(200);
|
|
||||||
} else if (!setClick) {
|
|
||||||
setClick = true;
|
|
||||||
$(evt.target).click(() => {
|
|
||||||
list.css('margin-left', '-9999px').show();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onButton = false;
|
|
||||||
}).mousedown(function (evt) {
|
|
||||||
// $('.contextMenu').hide();
|
|
||||||
const islib = $(evt.target).closest('.contextMenu').length;
|
|
||||||
if (!islib) {
|
|
||||||
$('.contextMenu').fadeOut(250);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
overlay.bind('mousedown', () => {
|
|
||||||
if (!button.hasClass('buttondown')) {
|
|
||||||
// Margin must be reset in case it was changed before;
|
|
||||||
list.css('margin-left', 0).show();
|
|
||||||
if (!height) {
|
|
||||||
height = list.height();
|
|
||||||
}
|
|
||||||
// Using custom animation as slideDown has annoying 'bounce effect'
|
|
||||||
list.css('height', 0).animate({
|
|
||||||
height
|
|
||||||
}, 200);
|
|
||||||
onButton = true;
|
|
||||||
} else {
|
|
||||||
list.fadeOut(200);
|
|
||||||
}
|
|
||||||
button.toggleClass('buttondown buttonup');
|
|
||||||
}).hover(() => {
|
|
||||||
onButton = true;
|
|
||||||
}).mouseout(() => {
|
|
||||||
onButton = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
const listItems = $('#main_menu li');
|
|
||||||
|
|
||||||
// Check if JS method of hovering needs to be used (Webkit bug)
|
|
||||||
listItems.mouseover(function () {
|
|
||||||
jsHover = ($(this).css('background-color') === 'rgba(0, 0, 0, 0)');
|
|
||||||
|
|
||||||
listItems.unbind('mouseover');
|
|
||||||
if (jsHover) {
|
|
||||||
listItems.mouseover(() => {
|
|
||||||
this.style.backgroundColor = '#FFC';
|
|
||||||
}).mouseout((evt) => {
|
|
||||||
evt.currentTarget.style.backgroundColor = 'transparent';
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// Unfocus text input when this.workarea is mousedowned.
|
|
||||||
let inp;
|
let inp;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -404,10 +330,10 @@ class EditorStartup {
|
|||||||
$('#svg_editor').find('button, select, input:not(#text)').focus(() => {
|
$('#svg_editor').find('button, select, input:not(#text)').focus(() => {
|
||||||
inp = this;
|
inp = this;
|
||||||
this.uiContext = 'toolbars';
|
this.uiContext = 'toolbars';
|
||||||
this.workarea.mousedown(unfocus);
|
this.workarea.addEventListener('mousedown', unfocus);
|
||||||
}).blur(() => {
|
}).blur(() => {
|
||||||
this.uiContext = 'canvas';
|
this.uiContext = 'canvas';
|
||||||
this.workarea.unbind('mousedown', unfocus);
|
this.workarea.removeEventListener('mousedown', unfocus);
|
||||||
// Go back to selecting text if in textedit mode
|
// Go back to selecting text if in textedit mode
|
||||||
if (this.svgCanvas.getMode() === 'textedit') {
|
if (this.svgCanvas.getMode() === 'textedit') {
|
||||||
$('#text').focus();
|
$('#text').focus();
|
||||||
@@ -418,12 +344,12 @@ class EditorStartup {
|
|||||||
window.addEventListener('resize', (evt) => {
|
window.addEventListener('resize', (evt) => {
|
||||||
Object.entries(winWh).forEach(([type, val]) => {
|
Object.entries(winWh).forEach(([type, val]) => {
|
||||||
const curval = $(window)[type]();
|
const curval = $(window)[type]();
|
||||||
this.workarea[0]['scroll' + (type === 'width' ? 'Left' : 'Top')] -= (curval - val) / 2;
|
this.workarea['scroll' + (type === 'width' ? 'Left' : 'Top')] -= (curval - val) / 2;
|
||||||
winWh[type] = curval;
|
winWh[type] = curval;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
this.workarea.scroll(() => {
|
this.workarea.addEventListener('scroll', () => {
|
||||||
// TODO: jQuery's scrollLeft/Top() wouldn't require a null check
|
// TODO: jQuery's scrollLeft/Top() wouldn't require a null check
|
||||||
this.rulers.manageScroll();
|
this.rulers.manageScroll();
|
||||||
});
|
});
|
||||||
@@ -448,8 +374,8 @@ class EditorStartup {
|
|||||||
this.layersPanel.populateLayers();
|
this.layersPanel.populateLayers();
|
||||||
|
|
||||||
const centerCanvas = () => {
|
const centerCanvas = () => {
|
||||||
// this centers the canvas vertically in the this.workarea (horizontal handled in CSS)
|
// this centers the canvas vertically in the this.workarea (horizontal handled in CSS)
|
||||||
this.workarea.css('line-height', this.workarea.height() + 'px');
|
this.workarea.style.lineHeight = this.workarea.style.height;
|
||||||
};
|
};
|
||||||
|
|
||||||
$(window).bind('load resize', centerCanvas);
|
$(window).bind('load resize', centerCanvas);
|
||||||
@@ -457,55 +383,6 @@ class EditorStartup {
|
|||||||
// Prevent browser from erroneously repopulating fields
|
// Prevent browser from erroneously repopulating fields
|
||||||
$('input,select').attr('autocomplete', 'off');
|
$('input,select').attr('autocomplete', 'off');
|
||||||
|
|
||||||
/**
|
|
||||||
* Associate all button actions as well as non-button keyboard shortcuts.
|
|
||||||
*/
|
|
||||||
this.leftPanelHandlers.init();
|
|
||||||
this.bottomPanelHandlers.init();
|
|
||||||
this.topPanelHandlers.init();
|
|
||||||
this.layersPanel.init();
|
|
||||||
|
|
||||||
$id('tool_clear').addEventListener('click', this.clickClear.bind(this));
|
|
||||||
$id('tool_open').addEventListener('click', (e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
this.clickOpen();
|
|
||||||
window.dispatchEvent(new CustomEvent('openImage'));
|
|
||||||
});
|
|
||||||
$id('tool_import').addEventListener('click', (e) => {
|
|
||||||
this.clickImport();
|
|
||||||
window.dispatchEvent(new CustomEvent('importImages'));
|
|
||||||
});
|
|
||||||
$id('tool_save').addEventListener('click', function (e) {
|
|
||||||
const $editorDialog = document.getElementById('se-svg-editor-dialog');
|
|
||||||
const editingsource = $editorDialog.getAttribute('dialog') === 'open';
|
|
||||||
if (editingsource) {
|
|
||||||
this.saveSourceEditor();
|
|
||||||
} else {
|
|
||||||
this.clickSave();
|
|
||||||
}
|
|
||||||
}.bind(this));
|
|
||||||
// this.clickExport.bind(this)
|
|
||||||
$id('tool_export').addEventListener('click', function (e) {
|
|
||||||
document.getElementById('se-export-dialog').setAttribute('dialog', 'open');
|
|
||||||
});
|
|
||||||
$id('se-export-dialog').addEventListener('change', this.clickExport.bind(this));
|
|
||||||
$id('tool_docprops').addEventListener('click', this.showDocProperties.bind(this));
|
|
||||||
$id('tool_editor_prefs').addEventListener('click', this.showPreferences.bind(this));
|
|
||||||
$id('tool_editor_homepage').addEventListener('click', this.openHomePage.bind(this));
|
|
||||||
$id('se-img-prop').addEventListener('change', function (e) {
|
|
||||||
if (e.detail.dialog === 'closed') {
|
|
||||||
this.hideDocProperties();
|
|
||||||
} else {
|
|
||||||
this.saveDocProperties(e);
|
|
||||||
}
|
|
||||||
}.bind(this));
|
|
||||||
$id('se-edit-prefs').addEventListener('change', function (e) {
|
|
||||||
if (e.detail.dialog === 'closed') {
|
|
||||||
this.hidePreferences();
|
|
||||||
} else {
|
|
||||||
this.savePreferences(e);
|
|
||||||
}
|
|
||||||
}.bind(this));
|
|
||||||
$id('se-svg-editor-dialog').addEventListener('change', function (e) {
|
$id('se-svg-editor-dialog').addEventListener('change', function (e) {
|
||||||
if (e?.detail?.copy === 'click') {
|
if (e?.detail?.copy === 'click') {
|
||||||
this.cancelOverlays(e);
|
this.cancelOverlays(e);
|
||||||
@@ -644,7 +521,7 @@ class EditorStartup {
|
|||||||
document.getElementById('se-prompt-dialog').title = editorObj.uiStrings.notification.loadingImage;
|
document.getElementById('se-prompt-dialog').title = editorObj.uiStrings.notification.loadingImage;
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$('#main_menu').hide();
|
// $('#main_menu').hide();
|
||||||
const file = (e.type === 'drop') ? e.dataTransfer.files[0] : this.files[0];
|
const file = (e.type === 'drop') ? e.dataTransfer.files[0] : this.files[0];
|
||||||
if (!file) {
|
if (!file) {
|
||||||
document.getElementById('se-prompt-dialog').setAttribute('close', true);
|
document.getElementById('se-prompt-dialog').setAttribute('close', true);
|
||||||
@@ -716,10 +593,10 @@ class EditorStartup {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.workarea[0].addEventListener('dragenter', this.onDragEnter);
|
this.workarea.addEventListener('dragenter', this.onDragEnter);
|
||||||
this.workarea[0].addEventListener('dragover', this.onDragOver);
|
this.workarea.addEventListener('dragover', this.onDragOver);
|
||||||
this.workarea[0].addEventListener('dragleave', this.onDragLeave);
|
this.workarea.addEventListener('dragleave', this.onDragLeave);
|
||||||
this.workarea[0].addEventListener('drop', importImage);
|
this.workarea.addEventListener('drop', importImage);
|
||||||
const imgImport = $('<input type="file">').change(importImage);
|
const imgImport = $('<input type="file">').change(importImage);
|
||||||
$(window).on('importImages', () => imgImport.click());
|
$(window).on('importImages', () => imgImport.click());
|
||||||
}
|
}
|
||||||
@@ -747,7 +624,7 @@ class EditorStartup {
|
|||||||
const {langParam, langData} = await this.putLocale(this.configObj.pref('lang'), this.goodLangs);
|
const {langParam, langData} = await this.putLocale(this.configObj.pref('lang'), this.goodLangs);
|
||||||
await this.setLang(langParam, langData);
|
await this.setLang(langParam, langData);
|
||||||
|
|
||||||
$id('svg_editor').style.visibility = 'visible';
|
this.$svgEditor.style.visibility = 'visible';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// load standard extensions
|
// load standard extensions
|
||||||
|
|||||||
396
src/editor/MainMenu.js
Normal file
396
src/editor/MainMenu.js
Normal file
@@ -0,0 +1,396 @@
|
|||||||
|
/* globals $ */
|
||||||
|
import SvgCanvas from "../svgcanvas/svgcanvas.js";
|
||||||
|
import {convertUnit, isValidUnit} from '../common/units.js';
|
||||||
|
import {isChrome} from '../common/browser.js';
|
||||||
|
|
||||||
|
const { $id } = SvgCanvas;
|
||||||
|
const homePage = 'https://github.com/SVG-Edit/svgedit';
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class MainMenu {
|
||||||
|
/**
|
||||||
|
* @param {PlainObject} editor svgedit handler
|
||||||
|
*/
|
||||||
|
constructor(editor) {
|
||||||
|
this.editor = editor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @fires module:svgcanvas.SvgCanvas#event:ext_onNewDocument
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
async clickClear() {
|
||||||
|
const [x, y] = this.editor.configObj.curConfig.dimensions;
|
||||||
|
const ok = await seConfirm(this.editor.uiStrings.notification.QwantToClear);
|
||||||
|
if (ok === "Cancel") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.editor.leftPanel.clickSelect();
|
||||||
|
this.editor.svgCanvas.clear();
|
||||||
|
this.editor.svgCanvas.setResolution(x, y);
|
||||||
|
this.editor.updateCanvas(true);
|
||||||
|
this.editor.zoomImage();
|
||||||
|
this.editor.layersPanel.populateLayers();
|
||||||
|
this.editor.topPanel.updateContextPanel();
|
||||||
|
this.editor.svgCanvas.runExtensions("onNewDocument");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
hideDocProperties() {
|
||||||
|
const $imgDialog = document.getElementById("se-img-prop");
|
||||||
|
$imgDialog.setAttribute("dialog", "close");
|
||||||
|
$imgDialog.setAttribute("save", this.editor.configObj.pref("img_save"));
|
||||||
|
this.editor.docprops = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
hidePreferences() {
|
||||||
|
const $editDialog = document.getElementById("se-edit-prefs");
|
||||||
|
$editDialog.setAttribute("dialog", "close");
|
||||||
|
this.editor.configObj.preferences = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Event} e
|
||||||
|
* @returns {boolean} Whether there were problems saving the document properties
|
||||||
|
*/
|
||||||
|
saveDocProperties(e) {
|
||||||
|
// set title
|
||||||
|
const { title, w, h, save } = e.detail;
|
||||||
|
// set document title
|
||||||
|
this.editor.svgCanvas.setDocumentTitle(title);
|
||||||
|
|
||||||
|
if (w !== "fit" && !isValidUnit("width", w)) {
|
||||||
|
seAlert(this.editor.uiStrings.notification.invalidAttrValGiven);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (h !== "fit" && !isValidUnit("height", h)) {
|
||||||
|
seAlert(this.editor.uiStrings.notification.invalidAttrValGiven);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!this.editor.svgCanvas.setResolution(w, h)) {
|
||||||
|
seAlert(this.editor.uiStrings.notification.noContentToFitTo);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Set image save option
|
||||||
|
this.editor.configObj.pref("img_save", save);
|
||||||
|
this.editor.updateCanvas();
|
||||||
|
this.editor.hideDocProperties();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Save user preferences based on current values in the UI.
|
||||||
|
* @param {Event} e
|
||||||
|
* @function module:SVGthis.savePreferences
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
async savePreferences(e) {
|
||||||
|
const {
|
||||||
|
lang,
|
||||||
|
bgcolor,
|
||||||
|
bgurl,
|
||||||
|
gridsnappingon,
|
||||||
|
gridsnappingstep,
|
||||||
|
gridcolor,
|
||||||
|
showrulers,
|
||||||
|
baseunit
|
||||||
|
} = e.detail;
|
||||||
|
// Set background
|
||||||
|
this.editor.setBackground(bgcolor, bgurl);
|
||||||
|
|
||||||
|
// set language
|
||||||
|
if (lang && lang !== this.editor.configObj.pref("lang")) {
|
||||||
|
const { langParam, langData } = await this.editor.putLocale(
|
||||||
|
lang,
|
||||||
|
this.editor.goodLangs
|
||||||
|
);
|
||||||
|
await this.editor.svgCanvassetLang(langParam, langData);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set grid setting
|
||||||
|
this.editor.configObj.curConfig.gridSnapping = gridsnappingon;
|
||||||
|
this.editor.configObj.curConfig.snappingStep = gridsnappingstep;
|
||||||
|
this.editor.configObj.curConfig.gridColor = gridcolor;
|
||||||
|
this.editor.configObj.curConfig.showRulers = showrulers;
|
||||||
|
|
||||||
|
$("#rulers").toggle(this.editor.configObj.curConfig.showRulers);
|
||||||
|
if (this.editor.configObj.curConfig.showRulers) {
|
||||||
|
this.editor.rulers.updateRulers();
|
||||||
|
}
|
||||||
|
this.editor.configObj.curConfig.baseUnit = baseunit;
|
||||||
|
this.editor.svgCanvas.setConfig(this.editor.configObj.curConfig);
|
||||||
|
this.editor.updateCanvas();
|
||||||
|
this.editor.hidePreferences();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
clickSave() {
|
||||||
|
// In the future, more options can be provided here
|
||||||
|
const saveOpts = {
|
||||||
|
images: this.editor.configObj.pref("img_save"),
|
||||||
|
round_digits: 6
|
||||||
|
};
|
||||||
|
this.editor.svgCanvas.save(saveOpts);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param e
|
||||||
|
* @returns {Promise<void>} Resolves to `undefined`
|
||||||
|
*/
|
||||||
|
async clickExport(e) {
|
||||||
|
if (e?.detail?.trigger !== "ok" || e?.detail?.imgType === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const imgType = e?.detail?.imgType;
|
||||||
|
const quality = e?.detail?.quality ? e?.detail?.quality / 100 : 1;
|
||||||
|
// Open placeholder window (prevents popup)
|
||||||
|
let exportWindowName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
const openExportWindow = () => {
|
||||||
|
const { loadingImage } = this.editor.uiStrings.notification;
|
||||||
|
if (this.editor.configObj.curConfig.exportWindowType === "new") {
|
||||||
|
this.editor.exportWindowCt++;
|
||||||
|
}
|
||||||
|
this.editor.exportWindowName =
|
||||||
|
this.editor.configObj.curConfig.canvasName + this.editor.exportWindowCt;
|
||||||
|
let popHTML, popURL;
|
||||||
|
if (this.editor.loadingURL) {
|
||||||
|
popURL = this.editor.loadingURL;
|
||||||
|
} else {
|
||||||
|
popHTML = `<!DOCTYPE html><html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>${loadingImage}</title>
|
||||||
|
</head>
|
||||||
|
<body><h1>${loadingImage}</h1></body>
|
||||||
|
<html>`;
|
||||||
|
if (typeof URL !== "undefined" && URL.createObjectURL) {
|
||||||
|
const blob = new Blob([popHTML], { type: "text/html" });
|
||||||
|
popURL = URL.createObjectURL(blob);
|
||||||
|
} else {
|
||||||
|
popURL = "data:text/html;base64;charset=utf-8," + encode64(popHTML);
|
||||||
|
}
|
||||||
|
this.editor.loadingURL = popURL;
|
||||||
|
}
|
||||||
|
this.editor.exportWindow = window.open(
|
||||||
|
popURL,
|
||||||
|
this.editor.exportWindowName
|
||||||
|
);
|
||||||
|
};
|
||||||
|
const chrome = isChrome();
|
||||||
|
if (imgType === "PDF") {
|
||||||
|
if (!this.editor.customExportPDF && !chrome) {
|
||||||
|
openExportWindow();
|
||||||
|
}
|
||||||
|
this.editor.svgCanvas.exportPDF(exportWindowName);
|
||||||
|
} else {
|
||||||
|
if (!this.editor.customExportImage) {
|
||||||
|
openExportWindow();
|
||||||
|
}
|
||||||
|
/* const results = */ await this.editor.svgCanvas.rasterExport(
|
||||||
|
imgType,
|
||||||
|
quality,
|
||||||
|
this.editor.exportWindowName
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* By default, this.editor.svgCanvas.open() is a no-op. It is up to an extension
|
||||||
|
* mechanism (opera widget, etc.) to call `setCustomHandlers()` which
|
||||||
|
* will make it do something.
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
clickOpen() {
|
||||||
|
this.editor.svgCanvas.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
// eslint-disable-next-line class-methods-use-this
|
||||||
|
clickImport() {
|
||||||
|
/* empty fn */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
showDocProperties() {
|
||||||
|
if (this.editor.docprops) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.editor.docprops = true;
|
||||||
|
const $imgDialog = document.getElementById("se-img-prop");
|
||||||
|
|
||||||
|
// update resolution option with actual resolution
|
||||||
|
const resolution = this.editor.svgCanvas.getResolution();
|
||||||
|
if (this.editor.configObj.curConfig.baseUnit !== "px") {
|
||||||
|
resolution.w =
|
||||||
|
convertUnit(resolution.w) + this.editor.configObj.curConfig.baseUnit;
|
||||||
|
resolution.h =
|
||||||
|
convertUnit(resolution.h) + this.editor.configObj.curConfig.baseUnit;
|
||||||
|
}
|
||||||
|
$imgDialog.setAttribute("save", this.editor.configObj.pref("img_save"));
|
||||||
|
$imgDialog.setAttribute("width", resolution.w);
|
||||||
|
$imgDialog.setAttribute("height", resolution.h);
|
||||||
|
$imgDialog.setAttribute("title", this.editor.svgCanvas.getDocumentTitle());
|
||||||
|
$imgDialog.setAttribute("dialog", "open");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
showPreferences() {
|
||||||
|
if (this.editor.configObj.preferences) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.editor.configObj.preferences = true;
|
||||||
|
const $editDialog = document.getElementById("se-edit-prefs");
|
||||||
|
// $('#main_menu').hide();
|
||||||
|
// Update background color with current one
|
||||||
|
const canvasBg = this.editor.configObj.curPrefs.bkgd_color;
|
||||||
|
const url = this.editor.configObj.pref("bkgd_url");
|
||||||
|
if (url) {
|
||||||
|
$editDialog.setAttribute("bgurl", url);
|
||||||
|
}
|
||||||
|
$editDialog.setAttribute(
|
||||||
|
"gridsnappingon",
|
||||||
|
this.editor.configObj.curConfig.gridSnapping
|
||||||
|
);
|
||||||
|
$editDialog.setAttribute(
|
||||||
|
"gridsnappingstep",
|
||||||
|
this.editor.configObj.curConfig.snappingStep
|
||||||
|
);
|
||||||
|
$editDialog.setAttribute(
|
||||||
|
"gridcolor",
|
||||||
|
this.editor.configObj.curConfig.gridColor
|
||||||
|
);
|
||||||
|
$editDialog.setAttribute("canvasbg", canvasBg);
|
||||||
|
$editDialog.setAttribute("dialog", "open");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
// eslint-disable-next-line class-methods-use-this
|
||||||
|
openHomePage() {
|
||||||
|
window.open(homePage, "_blank");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {module}
|
||||||
|
*/
|
||||||
|
init() {
|
||||||
|
// add Top panel
|
||||||
|
const template = document.createElement("template");
|
||||||
|
template.innerHTML = `
|
||||||
|
<se-menu id="main_button" label="SVG-Edit" src="./images/logo.svg" alt="logo">
|
||||||
|
<!-- File-like buttons: New, Save, Source -->
|
||||||
|
<se-menu-item id="tool_clear" label="New Image" shortcut="N" src="./images/new.svg"></se-menu-item>
|
||||||
|
<se-menu-item id="tool_open" label="Open SVG" src="./images/open.svg"></se-menu-item>
|
||||||
|
<se-menu-item id="tool_save" label="Save Image" shortcut="S" src="./images/saveImg.svg"></se-menu-item>
|
||||||
|
<se-menu-item id="tool_import" label="Import Image" src="./images/importImg.svg"></se-menu-item>
|
||||||
|
<se-menu-item id="tool_export" label="Export" src="./images/export.svg"></se-menu-item>
|
||||||
|
<se-menu-item id="tool_imagelib" label="Image library" src="./images/library.svg"></se-menu-item>
|
||||||
|
<se-menu-item id="tool_docprops" label="Document Properties" shortcut="D" src="./images/docprop.svg">
|
||||||
|
</se-menu-item>
|
||||||
|
<se-menu-item id="tool_editor_prefs" label="Editor Preferences" src="./images/editPref.svg"></se-menu-item>
|
||||||
|
<se-menu-item id="tool_editor_homepage" label="SVG-Edit Home Page" src="./images/logo.svg">
|
||||||
|
</se-menu-item>
|
||||||
|
</se-menu>
|
||||||
|
`;
|
||||||
|
this.editor.$svgEditor.append(template.content.cloneNode(true));
|
||||||
|
|
||||||
|
// register action to main menu entries
|
||||||
|
/**
|
||||||
|
* Associate all button actions as well as non-button keyboard shortcuts.
|
||||||
|
*/
|
||||||
|
|
||||||
|
$id("tool_clear").addEventListener("click", this.clickClear.bind(this));
|
||||||
|
$id("tool_open").addEventListener("click", e => {
|
||||||
|
e.preventDefault();
|
||||||
|
this.clickOpen();
|
||||||
|
window.dispatchEvent(new CustomEvent("openImage"));
|
||||||
|
});
|
||||||
|
$id("tool_import").addEventListener("click", e => {
|
||||||
|
this.clickImport();
|
||||||
|
window.dispatchEvent(new CustomEvent("importImages"));
|
||||||
|
});
|
||||||
|
$id("tool_save").addEventListener(
|
||||||
|
"click",
|
||||||
|
function(e) {
|
||||||
|
const $editorDialog = document.getElementById("se-svg-editor-dialog");
|
||||||
|
const editingsource = $editorDialog.getAttribute("dialog") === "open";
|
||||||
|
if (editingsource) {
|
||||||
|
this.saveSourceEditor();
|
||||||
|
} else {
|
||||||
|
this.clickSave();
|
||||||
|
}
|
||||||
|
}.bind(this)
|
||||||
|
);
|
||||||
|
// this.clickExport.bind(this)
|
||||||
|
$id("tool_export").addEventListener("click", function(e) {
|
||||||
|
document
|
||||||
|
.getElementById("se-export-dialog")
|
||||||
|
.setAttribute("dialog", "open");
|
||||||
|
});
|
||||||
|
$id("se-export-dialog").addEventListener(
|
||||||
|
"change",
|
||||||
|
this.clickExport.bind(this)
|
||||||
|
);
|
||||||
|
$id("tool_docprops").addEventListener(
|
||||||
|
"click",
|
||||||
|
this.showDocProperties.bind(this)
|
||||||
|
);
|
||||||
|
$id("tool_editor_prefs").addEventListener(
|
||||||
|
"click",
|
||||||
|
this.showPreferences.bind(this)
|
||||||
|
);
|
||||||
|
$id("tool_editor_homepage").addEventListener(
|
||||||
|
"click",
|
||||||
|
this.openHomePage.bind(this)
|
||||||
|
);
|
||||||
|
$id("se-img-prop").addEventListener(
|
||||||
|
"change",
|
||||||
|
function(e) {
|
||||||
|
if (e.detail.dialog === "closed") {
|
||||||
|
this.hideDocProperties();
|
||||||
|
} else {
|
||||||
|
this.saveDocProperties(e);
|
||||||
|
}
|
||||||
|
}.bind(this)
|
||||||
|
);
|
||||||
|
$id("se-edit-prefs").addEventListener(
|
||||||
|
"change",
|
||||||
|
function(e) {
|
||||||
|
if (e.detail.dialog === "closed") {
|
||||||
|
this.hidePreferences();
|
||||||
|
} else {
|
||||||
|
this.savePreferences(e);
|
||||||
|
}
|
||||||
|
}.bind(this)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default MainMenu;
|
||||||
@@ -27,8 +27,8 @@ class Rulers {
|
|||||||
manageScroll () {
|
manageScroll () {
|
||||||
const rulerX = document.getElementById('ruler_x');
|
const rulerX = document.getElementById('ruler_x');
|
||||||
const rulerY = document.getElementById('ruler_y');
|
const rulerY = document.getElementById('ruler_y');
|
||||||
if (rulerX) rulerX.scrollLeft = this.editor.workarea[0].scrollLeft;
|
if (rulerX) rulerX.scrollLeft = this.editor.workarea.scrollLeft;
|
||||||
if (rulerY) rulerY.scrollTop = this.editor.workarea[0].scrollTop;
|
if (rulerY) rulerY.scrollTop = this.editor.workarea.scrollTop;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable max-len */
|
||||||
import {jGraduate, jGraduateMethod} from './jgraduate/jQuery.jGraduate.js';
|
import {jGraduate, jGraduateMethod} from './jgraduate/jQuery.jGraduate.js';
|
||||||
import PaintBox from './PaintBox.js';
|
import PaintBox from './PaintBox.js';
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// https://github.com/knadh/dragmove.js
|
// https://github.com/knadh/dragmove.js
|
||||||
// Kailash Nadh (c) 2020.
|
// Kailash Nadh (c) 2020.
|
||||||
// MIT License.
|
// MIT License.
|
||||||
|
// can't use npm version as the dragmove is different.
|
||||||
|
|
||||||
let _loaded = false;
|
let _loaded = false;
|
||||||
let _callbacks = [];
|
let _callbacks = [];
|
||||||
@@ -93,4 +94,4 @@ export const dragmove = function(target, handler, parent, onStart, onEnd, onDrag
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export { dragmove as default };
|
export { dragmove as default };
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
* @copyright 2013 James Sacksteder
|
* @copyright 2013 James Sacksteder
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
import { dragmove } from '../../dragmove/dragmove.js';
|
import { dragmove } from '../../../editor/dragmove/dragmove.js';
|
||||||
export default {
|
export default {
|
||||||
name: 'overview_window',
|
name: 'overview_window',
|
||||||
init ({$, isChrome}) {
|
init ({$, isChrome}) {
|
||||||
@@ -46,10 +46,11 @@ export default {
|
|||||||
|
|
||||||
// Define dynamic animation of the view box.
|
// Define dynamic animation of the view box.
|
||||||
const updateViewBox = function () {
|
const updateViewBox = function () {
|
||||||
const portHeight = Number.parseFloat($('#workarea').css('height'));
|
const warea = document.getElementById('workarea');
|
||||||
const portWidth = Number.parseFloat($('#workarea').css('width'));
|
const portHeight = parseFloat(getComputedStyle(warea, null).height.replace("px", ""));
|
||||||
const portX = $('#workarea').scrollLeft();
|
const portWidth = parseFloat(getComputedStyle(warea, null).width.replace("px", ""));
|
||||||
const portY = $('#workarea').scrollTop();
|
const portX = warea.scrollLeft;
|
||||||
|
const portY = warea.scrollTop;
|
||||||
const windowWidth = Number.parseFloat($('#svgcanvas').css('width'));
|
const windowWidth = Number.parseFloat($('#svgcanvas').css('width'));
|
||||||
const windowHeight = Number.parseFloat($('#svgcanvas').css('height'));
|
const windowHeight = Number.parseFloat($('#svgcanvas').css('height'));
|
||||||
const overviewWidth = $('#overviewMiniView').attr('width');
|
const overviewWidth = $('#overviewMiniView').attr('width');
|
||||||
@@ -65,12 +66,12 @@ export default {
|
|||||||
$('#overview_window_view_box').css('top', viewBoxY + 'px');
|
$('#overview_window_view_box').css('top', viewBoxY + 'px');
|
||||||
$('#overview_window_view_box').css('left', viewBoxX + 'px');
|
$('#overview_window_view_box').css('left', viewBoxX + 'px');
|
||||||
};
|
};
|
||||||
$('#workarea').scroll(function () {
|
document.getElementById('workarea').addEventListener('scroll', () => {
|
||||||
if (!(overviewWindowGlobals.viewBoxDragging)) {
|
if (!(overviewWindowGlobals.viewBoxDragging)) {
|
||||||
updateViewBox();
|
updateViewBox();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$('#workarea').resize(updateViewBox);
|
document.getElementById('workarea').addEventListener('resize', updateViewBox);
|
||||||
updateViewBox();
|
updateViewBox();
|
||||||
|
|
||||||
// Compensate for changes in zoom and canvas size.
|
// Compensate for changes in zoom and canvas size.
|
||||||
@@ -101,15 +102,14 @@ export default {
|
|||||||
|
|
||||||
const portX = viewBoxX / overviewWidth * windowWidth;
|
const portX = viewBoxX / overviewWidth * windowWidth;
|
||||||
const portY = viewBoxY / overviewHeight * windowHeight;
|
const portY = viewBoxY / overviewHeight * windowHeight;
|
||||||
|
document.getElementById('workarea').scrollLeft = portX;
|
||||||
$('#workarea').scrollLeft(portX);
|
document.getElementById('workarea').scrollTop = portY;
|
||||||
$('#workarea').scrollTop(portY);
|
|
||||||
};
|
};
|
||||||
const onStart = function () {
|
const onStart = () => {
|
||||||
overviewWindowGlobals.viewBoxDragging = true;
|
overviewWindowGlobals.viewBoxDragging = true;
|
||||||
updateViewPortFromViewBox();
|
updateViewPortFromViewBox();
|
||||||
};
|
};
|
||||||
const onEnd = function (el, parent, x, y) {
|
const onEnd = (el, parent, x, y) => {
|
||||||
if((el.offsetLeft + el.offsetWidth) > $(parent).attr('width')){
|
if((el.offsetLeft + el.offsetWidth) > $(parent).attr('width')){
|
||||||
el.style.left = ($(parent).attr('width') - el.offsetWidth) + 'px';
|
el.style.left = ($(parent).attr('width') - el.offsetWidth) + 'px';
|
||||||
} else if(el.offsetLeft < 0){
|
} else if(el.offsetLeft < 0){
|
||||||
|
|||||||
@@ -29,339 +29,7 @@
|
|||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="svg_editor" role="main">
|
<div id="svg_editor" role="main">
|
||||||
<div id="sidepanels">
|
|
||||||
<div id="layerpanel">
|
|
||||||
<h3 id="layersLabel">Layers</h3>
|
|
||||||
<fieldset id="layerbuttons">
|
|
||||||
<se-button id="layer_new" title="New Layer" size="small" src="./images/new.svg"></se-button>
|
|
||||||
<se-button id="layer_delete" title="Delete Layer" size="small" src="./images/delete.svg"></se-button>
|
|
||||||
<se-button id="layer_rename" title="Rename Layer" size="small" src="./images/text.svg"></se-button>
|
|
||||||
<se-button id="layer_up" title="Move Layer Up" size="small" src="./images/go_up.svg"></se-button>
|
|
||||||
<se-button id="layer_down" title="Move Layer Down" size="small" src="./images/go_down.svg"></se-button>
|
|
||||||
<se-button id="layer_moreopts" title="More Options" size="small" src="./images/context_menu.svg">
|
|
||||||
</se-button>
|
|
||||||
</fieldset>
|
|
||||||
<table id="layerlist">
|
|
||||||
<tr class="layer">
|
|
||||||
<td class="layervis"></td>
|
|
||||||
<td class="layername">Layer 1</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<span id="selLayerLabel">Move elements to:</span>
|
|
||||||
<select id="selLayerNames" title="Move selected elements to a different layer" disabled="disabled">
|
|
||||||
<option selected="selected" value="layer1">Layer 1</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div id="sidepanel_handle" title="Drag left/right to resize side panel [X]">L a y e r s
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<se-menu id="main_button" label="SVG-Edit" src="./images/logo.svg" alt="logo">
|
|
||||||
<!-- File-like buttons: New, Save, Source -->
|
|
||||||
<se-menu-item id="tool_clear" label="New Image" shortcut="N" src="./images/new.svg"></se-menu-item>
|
|
||||||
<se-menu-item id="tool_open" label="Open SVG" src="./images/open.svg"></se-menu-item>
|
|
||||||
<se-menu-item id="tool_save" label="Save Image" shortcut="S" src="./images/saveImg.svg"></se-menu-item>
|
|
||||||
<se-menu-item id="tool_import" label="Import Image" src="./images/importImg.svg"></se-menu-item>
|
|
||||||
<se-menu-item id="tool_export" label="Export" src="./images/export.svg"></se-menu-item>
|
|
||||||
<se-menu-item id="tool_imagelib" label="Image library" src="./images/library.svg"></se-menu-item>
|
|
||||||
<se-menu-item id="tool_docprops" label="Document Properties" shortcut="D" src="./images/docprop.svg">
|
|
||||||
</se-menu-item>
|
|
||||||
<se-menu-item id="tool_editor_prefs" label="Editor Preferences" src="./images/editPref.svg"></se-menu-item>
|
|
||||||
<se-menu-item id="tool_editor_homepage" label="SVG-Edit Home Page" src="./images/logo.svg">
|
|
||||||
</se-menu-item>
|
|
||||||
</se-menu>
|
|
||||||
<div id="tools_top">
|
|
||||||
<div id="editor_panel">
|
|
||||||
<div class="tool_sep"></div>
|
|
||||||
<se-button id="tool_source" title="Edit Source" shortcut="U" src="./images/source.svg"></se-button>
|
|
||||||
<se-button id="tool_wireframe" title="Wireframe Mode" shortcut="F" src="./images/wireframe.svg"></se-button>
|
|
||||||
<se-button id="view_grid" title="Show grid" src="./images/grid.svg"></se-button>
|
|
||||||
</div> <!-- editor_panel -->
|
|
||||||
<div id="history_panel">
|
|
||||||
<div class="tool_sep"></div>
|
|
||||||
<se-button id="tool_undo" title="Undo" shortcut="Z" src="./images/undo.svg" disabled></se-button>
|
|
||||||
<se-button id="tool_redo" title="Redo" shortcut="Y" src="./images/redo.svg" disabled></se-button>
|
|
||||||
</div> <!-- history_panel -->
|
|
||||||
<!-- Buttons when a single element is selected -->
|
|
||||||
<div id="selected_panel">
|
|
||||||
<div class="toolset">
|
|
||||||
<div class="tool_sep"></div>
|
|
||||||
<se-button id="tool_clone" title="Duplicate Element" shortcut="D" src="./images/clone.svg"></se-button>
|
|
||||||
<se-button id="tool_delete" title="Delete Element" shortcut="Backspace" src="./images/delete.svg">
|
|
||||||
</se-button>
|
|
||||||
</div>
|
|
||||||
<div class="toolset">
|
|
||||||
<div class="tool_sep"></div>
|
|
||||||
<se-button id="tool_move_top" title="Bring to Front" shortcut="Ctrl+Shift+]" src="./images/move_top.svg">
|
|
||||||
</se-button>
|
|
||||||
<se-button id="tool_move_bottom" title="Send to Back" shortcut="Ctrl+Shift+[" src="./images/move_bottom.svg">
|
|
||||||
</se-button>
|
|
||||||
</div>
|
|
||||||
<div class="toolset">
|
|
||||||
<se-button id="tool_topath" title="Convert to Path" src="./images/to_path.svg"></se-button>
|
|
||||||
<se-button id="tool_reorient" title="Reorient path" src="./images/reorient.svg"></se-button>
|
|
||||||
<se-button id="tool_make_link" title="Make (hyper)link" src="./images/globe_link.svg"></se-button>
|
|
||||||
</div>
|
|
||||||
<div class="toolset">
|
|
||||||
<div class="tool_sep"></div>
|
|
||||||
<se-input id="elem_id" data-attr="id" size="10" label="id" title="Identify the element"></se-input>
|
|
||||||
</div>
|
|
||||||
<div class="toolset">
|
|
||||||
<se-input id="elem_class" data-attr="class" size="10" label="class" title="Element class"></se-input>
|
|
||||||
</div>
|
|
||||||
<se-spin-input size="3" id="angle" min=-180 max=180 step=5 src="./images/angle.svg"
|
|
||||||
title="Change rotation angle"></se-spin-input>
|
|
||||||
<se-spin-input size="2" id="blur" min=0 max=100 step=5 src="./images/blur.svg"
|
|
||||||
title="Change gaussian blur value"></se-spin-input>
|
|
||||||
<se-list id="tool_position" title="Align Element to Page" label="" width="22px" height="24px">
|
|
||||||
<se-list-item id="tool_posleft" value="l">
|
|
||||||
<img title="align left" src="./images/align_left.svg" height="22px">
|
|
||||||
</se-list-item>
|
|
||||||
<se-list-item id="tool_poscenter" value="c">
|
|
||||||
<img title="align center" src="./images/align_center.svg" height="22px">
|
|
||||||
</se-list-item>
|
|
||||||
<se-list-item id="tool_posright" value="r">
|
|
||||||
<img title="align right" src="./images/align_right.svg" height="22px">
|
|
||||||
</se-list-item>
|
|
||||||
<se-list-item id="tool_postop" value="t">
|
|
||||||
<img title="align top" src="./images/align_top.svg" height="22px">
|
|
||||||
</se-list-item>
|
|
||||||
<se-list-item id="tool_posmiddle" value="m">
|
|
||||||
<img title="align middle" src="./images/align_middle.svg" height="22px">
|
|
||||||
</se-list-item>
|
|
||||||
<se-list-item id="tool_posbottom" value="b">
|
|
||||||
<img title="align bottom" src="./images/align_bottom.svg" height="22px">
|
|
||||||
</se-list-item>
|
|
||||||
</se-list>
|
|
||||||
<div id="xy_panel" class="toolset">
|
|
||||||
<se-spin-input id="selected_x" data-attr="x" size="4" type="text" label="x" title="Change X coordinate">
|
|
||||||
</se-spin-input>
|
|
||||||
<se-spin-input id="selected_y" data-attr="y" size="4" type="text" label="y" title="Change Y coordinate">
|
|
||||||
</se-spin-input>
|
|
||||||
</div>
|
|
||||||
</div> <!-- selected_panel -->
|
|
||||||
<!-- Buttons when multiple elements are selected -->
|
|
||||||
<div id="multiselected_panel">
|
|
||||||
<div class="tool_sep"></div>
|
|
||||||
<se-button id="tool_clone_multi" title="Clone Elements" shortcut="C" src="./images/clone.svg"></se-button>
|
|
||||||
<se-button id="tool_delete_multi" title="Delete Selected Elements" shortcut="Delete/Backspace"
|
|
||||||
src="./images/delete.svg"></se-button>
|
|
||||||
<div class="tool_sep"></div>
|
|
||||||
<se-button id="tool_group_elements" title="Group Elements" shortcut="G" src="./images/group_elements.svg">
|
|
||||||
</se-button>
|
|
||||||
<se-button id="tool_make_link_multi" title="Make (hyper)link" src="./images/globe_link.svg"></se-button>
|
|
||||||
<se-button id="tool_align_left" title="Align Left" src="./images/align_left.svg"></se-button>
|
|
||||||
<se-button id="tool_align_center" title="Align Center" src="./images/align_center.svg"></se-button>
|
|
||||||
<se-button id="tool_align_right" title="Align Right" src="./images/align_right.svg"></se-button>
|
|
||||||
<se-button id="tool_align_top" title="Align Top" src="./images/align_top.svg"></se-button>
|
|
||||||
<se-button id="tool_align_middle" title="Align Middle" src="./images/align_middle.svg"></se-button>
|
|
||||||
<se-button id="tool_align_bottom" title="Align Bottom" src="./images/align_bottom.svg"></se-button>
|
|
||||||
<se-list id="tool_align_relative" label="relative to:">
|
|
||||||
<se-list-item id="selected_objects" value="selected">selected objects</se-list-item>
|
|
||||||
<se-list-item id="largest_object" value="largest">largest object</se-list-item>
|
|
||||||
<se-list-item id="smallest_object" value="smallest">smallest object</se-list-item>
|
|
||||||
<se-list-item id="page" value="page">page</se-list-item>
|
|
||||||
</se-list>
|
|
||||||
<div class="tool_sep"></div>
|
|
||||||
</div> <!-- multiselected_panel -->
|
|
||||||
<div id="rect_panel">
|
|
||||||
<div class="toolset">
|
|
||||||
<se-spin-input id="rect_width" data-attr="width" size="4" label="w"
|
|
||||||
title="Change rectangle width"></se-spin-input>
|
|
||||||
<se-spin-input id="rect_height" data-attr="height" size="4" label="h"
|
|
||||||
title="Change rectangle height"></se-spin-input>
|
|
||||||
</div>
|
|
||||||
<se-spin-input id="rect_rx" min=0 max=1000 step=1 size="3" title="Change Rectangle Corner Radius"
|
|
||||||
data-attr="Corner Radius" src="./images/c_radius.svg"></se-spin-input>
|
|
||||||
</div> <!-- rect_panel -->
|
|
||||||
<div id="image_panel">
|
|
||||||
<div class="toolset">
|
|
||||||
<se-spin-input id="image_width" data-attr="width" size="4" type="text" label="w"
|
|
||||||
title="Change image width"></se-spin-input>
|
|
||||||
<se-spin-input id="image_height" data-attr="height" size="4" type="text" label="h"
|
|
||||||
title="Change image height"></se-spin-input>
|
|
||||||
</div>
|
|
||||||
<div class="toolset">
|
|
||||||
<label id="tool_image_url">url:
|
|
||||||
<input id="image_url" type="text" title="Change URL" size="35" />
|
|
||||||
</label>
|
|
||||||
<label id="tool_change_image">
|
|
||||||
<button id="change_image_url" style="display: none;">Change Image</button>
|
|
||||||
<span id="url_notice"
|
|
||||||
title="NOTE: This image cannot be embedded. It will depend on this path to be displayed"></span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div> <!-- image_panel -->
|
|
||||||
<div id="circle_panel">
|
|
||||||
<div class="toolset">
|
|
||||||
<se-spin-input id="circle_cx" data-attr="cx" size="4" label="cx"></se-spin-input>
|
|
||||||
<se-spin-input id="circle_cy" data-attr="cy" size="4" label="cy"></se-spin-input>
|
|
||||||
</div>
|
|
||||||
<div class="toolset">
|
|
||||||
<se-spin-input id="circle_r" data-attr="r" size="4" label="r"></se-spin-input>
|
|
||||||
</div>
|
|
||||||
</div> <!-- circle_panel -->
|
|
||||||
<div id="ellipse_panel">
|
|
||||||
<div class="toolset">
|
|
||||||
<se-spin-input id="ellipse_cx" data-attr="cx" size="4" title="Change ellipse's cx coordinate" label="cx">
|
|
||||||
</se-spin-input>
|
|
||||||
<se-spin-input id="ellipse_cy" data-attr="cy" size="4" title="Change ellipse's cy coordinate" label="cy">
|
|
||||||
</se-spin-input>
|
|
||||||
</div>
|
|
||||||
<div class="toolset">
|
|
||||||
<se-spin-input id="ellipse_rx" data-attr="rx" size="4" title="Change ellipse's x radius" label="rx">
|
|
||||||
</se-spin-input>
|
|
||||||
<se-spin-input id="ellipse_ry" data-attr="ry" size="4" title="Change ellipse's y radius" label="ry">
|
|
||||||
</se-spin-input>
|
|
||||||
</div>
|
|
||||||
</div> <!-- ellipse_panel -->
|
|
||||||
<div id="line_panel">
|
|
||||||
<div class="toolset">
|
|
||||||
<se-spin-input id="line_x1" data-attr="x1" size="4" title="Change line's starting x coordinate" label="x1">
|
|
||||||
</se-spin-input>
|
|
||||||
<se-spin-input id="line_y1" data-attr="y1" size="4" title="Change line's starting y coordinate" label="y1">
|
|
||||||
</se-spin-input>
|
|
||||||
<se-spin-input id="line_x2" data-attr="x2" size="4" title="Change line's ending x coordinate" label="x2">
|
|
||||||
</se-spin-input>
|
|
||||||
<se-spin-input id="line_y2" data-attr="y2" size="4" title="Change line's ending y coordinate" label="y2">
|
|
||||||
</se-spin-input>
|
|
||||||
</div>
|
|
||||||
</div> <!-- line_panel -->
|
|
||||||
<div id="text_panel">
|
|
||||||
<div class="toolset">
|
|
||||||
<se-button id="tool_bold" title="Bold Text [B]" src="./images/bold.svg" shortcut="B"></se-button>
|
|
||||||
<se-button id="tool_italic" title="Italic Text [I]" src="./images/italic.svg" shortcut="I"></se-button>
|
|
||||||
<se-button id="tool_text_anchor_start" title="Align the text from start" src="./images/anchor_start.svg">
|
|
||||||
</se-button>
|
|
||||||
<se-button id="tool_text_anchor_middle" title="Align the text from middle" src="./images/anchor_middle.svg">
|
|
||||||
</se-button>
|
|
||||||
<se-button id="tool_text_anchor_end" title="Align the text from end" src="./images/anchor_end.svg">
|
|
||||||
</se-button>
|
|
||||||
</div>
|
|
||||||
<se-list id="tool_font_family" label="Font:">
|
|
||||||
<se-list-item value="Serif" style="font-family:serif;"> Serif</se-list-item>
|
|
||||||
<se-list-item value="Sans-serif" style="font-family:sans-serif;"> Sans-serif</se-list-item>
|
|
||||||
<se-list-item value="Cursive" style="font-family:cursive;"> Cursive</se-list-item>
|
|
||||||
<se-list-item value="Fantasy" style="font-family:fantasy;"> Fantasy</se-list-item>
|
|
||||||
<se-list-item value="Monospace" style="font-family:monospace;"> Monospace</se-list-item>
|
|
||||||
<se-list-item value="Courier" style="font-family:courier;"> Courier</se-list-item>
|
|
||||||
<se-list-item value="Helvetica" style="font-family:helvetica;">Helvetica</se-list-item>
|
|
||||||
<se-list-item value="Times" style="font-family:times;">Times</se-list-item>
|
|
||||||
</se-list>
|
|
||||||
<se-spin-input size="2" id="font_size" min=1 max=1000 step=1 title="Change Font Size"
|
|
||||||
src="./images/fontsize.svg"></se-spin-input>
|
|
||||||
<!-- Not visible, but still used -->
|
|
||||||
<input id="text" type="text" size="35" />
|
|
||||||
</div> <!-- text_panel -->
|
|
||||||
<!-- formerly gsvg_panel -->
|
|
||||||
<div id="container_panel">
|
|
||||||
<div class="tool_sep"></div>
|
|
||||||
<!-- Add viewBox field here? -->
|
|
||||||
<label id="group_title" title="Group identification label">
|
|
||||||
<span>label</span>
|
|
||||||
<input id="g_title" data-attr="title" size="10" type="text" />
|
|
||||||
</label>
|
|
||||||
</div> <!-- container_panel -->
|
|
||||||
<div id="use_panel">
|
|
||||||
<div class="push_button" id="tool_unlink_use" title="Break link to reference element (make unique)"></div>
|
|
||||||
</div> <!-- use_panel -->
|
|
||||||
<div id="g_panel">
|
|
||||||
<div class="push_button" id="tool_ungroup" title="Ungroup Elements [G]"></div>
|
|
||||||
</div> <!-- g_panel -->
|
|
||||||
<!-- For anchor elements -->
|
|
||||||
<div id="a_panel">
|
|
||||||
<label id="tool_link_url" title="Set link URL (leave empty to remove)">
|
|
||||||
<span id="linkLabel" class="icon_label"></span>
|
|
||||||
<input id="link_url" type="text" size="35" />
|
|
||||||
</label>
|
|
||||||
</div> <!-- a_panel -->
|
|
||||||
<div id="path_node_panel">
|
|
||||||
<div class="tool_sep"></div>
|
|
||||||
<se-button id="tool_node_link" title="Link Control Points" src="./images/tool_node_link.svg" pressed>
|
|
||||||
</se-button>
|
|
||||||
<div class="tool_sep"></div>
|
|
||||||
<se-spin-input id="path_node_x" data-attr="x" size="4" title="Change node's x coordinate" label="x:">
|
|
||||||
</se-spin-input>
|
|
||||||
<se-spin-input id="path_node_y" data-attr="y" size="4" title="Change node's y coordinate" label="y:">
|
|
||||||
</se-spin-input>
|
|
||||||
<select id="seg_type" title="Change Segment type">
|
|
||||||
<option id="straight_segments" selected="selected" value="4">Straight</option>
|
|
||||||
<option id="curve_segments" value="6">Curve</option>
|
|
||||||
</select>
|
|
||||||
<se-button id="tool_node_clone" title="Clone Node" src="./images/tool_node_clone.svg"></se-button>
|
|
||||||
<se-button id="tool_node_delete" title="Delete Node" src="./images/tool_node_delete.svg"></se-button>
|
|
||||||
<se-button id="tool_openclose_path" title="Open/close sub-path" src="./images/tool_openclose_path.svg">
|
|
||||||
</se-button>
|
|
||||||
<se-button id="tool_add_subpath" title="Add sub-path" src="./images/tool_add_subpath.svg"></se-button>
|
|
||||||
</div> <!-- path_node_panel -->
|
|
||||||
<div id="cur_context_panel"></div>
|
|
||||||
</div> <!-- tools_top -->
|
|
||||||
<div id="tools_left">
|
|
||||||
<se-button id="tool_select" title="Select Tool" src="./images/select.svg"></se-button>
|
|
||||||
<se-button id="tool_zoom" title="Zoom Tool" src="./images/zoom.svg" shortcut="Z"></se-button>
|
|
||||||
<se-button id="ext-panning" title="Panning" src="./images/panning.svg"></se-button>
|
|
||||||
<se-button id="tool_fhpath" title="Pencil Tool" src="./images/pencil.svg" shortcut="Q"></se-button>
|
|
||||||
<se-button id="tool_line" title="Line Tool" src="./images/pen.svg" shortcut="L"></se-button>
|
|
||||||
<se-button id="tool_path" title="Path Tool" src="./images/path.svg" shortcut="P"></se-button>
|
|
||||||
<se-flyingbutton id="tools_rect" title="Square/Rect Tool">
|
|
||||||
<se-button id="tool_rect" title="Rectangle" src="./images/rect.svg" shortcut="R"></se-button>
|
|
||||||
<se-button id="tool_square" title="Square" src="./images/square.svg"></se-button>
|
|
||||||
<se-button id="tool_fhrect" title="Free-Hand Rectangle" src="./images/fh_rect.svg"></se-button>
|
|
||||||
</se-flyingbutton>
|
|
||||||
<se-flyingbutton id="tools_ellipse" title="Ellipse/Circle Tool">
|
|
||||||
<se-button id="tool_ellipse" title="Rectangle" src="./images/ellipse.svg" shortcut="E"></se-button>
|
|
||||||
<se-button id="tool_circle" title="Square" src="./images/circle.svg"></se-button>
|
|
||||||
<se-button id="tool_fhellipse" title="Free-Hand Rectangle" src="./images/fh_ellipse.svg"></se-button>
|
|
||||||
</se-flyingbutton>
|
|
||||||
<se-flyingbutton id="tools_polygon" title="Polygone/Star Tool">
|
|
||||||
<se-button id="tool_polygon" title="Polygon Tool" src="./images/polygon.svg"></se-button>
|
|
||||||
<se-button id="tool_star" title="Star Tool" src="./images/star.svg"></se-button>
|
|
||||||
</se-flyingbutton>
|
|
||||||
<se-button id="mode_connect" title="Connect two objects" src="./images/conn.svg"></se-button>
|
|
||||||
<se-button id="tool_text" title="Text Tool" src="./images/text.svg" shortcut="T"></se-button>
|
|
||||||
<se-button id="tool_image" title="Image Tool" src="./images/image.svg"></se-button>
|
|
||||||
<se-button id="tool_eyedropper" title="Eye Dropper Tool" src="./images/eye_dropper.svg" shortcut="I"></se-button>
|
|
||||||
<se-explorerbutton id="tool_shapelib" title="Shape library" lib="./extensions/ext-shapes/shapelib/"
|
|
||||||
src="./images/shapelib.svg"></se-explorerbutton>
|
|
||||||
</div> <!-- tools_left -->
|
|
||||||
<div id="tools_bottom">
|
|
||||||
<!-- Zoom buttons -->
|
|
||||||
<se-zoom id="zoom" src="./images/zoom.svg" title="Change zoom level" inputsize="40px">
|
|
||||||
<div value="1000">1000</div>
|
|
||||||
<div value="400">400</div>
|
|
||||||
<div value="200">200</div>
|
|
||||||
<div value="100">100</div>
|
|
||||||
<div value="50">50</div>
|
|
||||||
<div value="25">25</div>
|
|
||||||
<div value="canvas">Fit to canvas</div>
|
|
||||||
<div value="selection">Fit to selection</div>
|
|
||||||
<div value="layer">Fit to layer content</div>
|
|
||||||
<div value="content">Fit to all content</div>
|
|
||||||
</se-zoom>
|
|
||||||
<se-colorpicker id="fill_color" src="./images/fill.svg" title="Change fill color" type="fill"></se-colorpicker>
|
|
||||||
<se-colorpicker id="stroke_color" src="./images/stroke.svg" title="Change stroke color" type="stroke"></se-colorpicker>
|
|
||||||
<se-spin-input id="stroke_width" min=0 max=99 step=1 title="Change stroke width" label=""></se-spin-input>
|
|
||||||
<se-list id="stroke_style" title="Change stroke dash style" label="" width="22px" height="24px">
|
|
||||||
<se-list-item value="none">—</se-list-item>
|
|
||||||
<se-list-item value="2,2">...</se-list-item>
|
|
||||||
<se-list-item value="5,5">- -</se-list-item>
|
|
||||||
<se-list-item value="5,2,2,2">- .</se-list-item>
|
|
||||||
<se-list-item value="5,2,2,2,2,2">- ..</se-list-item>
|
|
||||||
</se-list>
|
|
||||||
<se-list id="stroke_linejoin" title="Linejoin: Miter" label="" width="22px" height="24px">
|
|
||||||
<se-list-item id="linejoin_miter" value="miter"><img title="Linejoin: Miter" src="./images/linejoin_miter.svg" height="22px"></img></se-list-item>
|
|
||||||
<se-list-item id="linejoin_round" value="round"><img title="Linejoin: Round" src="./images/linejoin_round.svg" height="22px"></img></se-list-item>
|
|
||||||
<se-list-item id="linejoin_bevel" value="bevel"><img title="Linejoin: Bevel" src="./images/linejoin_bevel.svg" height="22px"></img></se-list-item>
|
|
||||||
</se-list>
|
|
||||||
<se-list id="stroke_linecap" title="Linecap: Butt" label="" width="22px" height="24px">
|
|
||||||
<se-list-item id="linecap_butt" value="butt"><img title="Linecap: Butt" src="./images/linecap_butt.svg" height="22px"></img></se-list-item>
|
|
||||||
<se-list-item id="linecap_square" value="square"><img title="Linecap: Square" src="./images/linecap_square.svg" height="22px"></img></se-list-item>
|
|
||||||
<se-list-item id="linecap_round" value="round"><img title="Linecap: Round" src="./images/linecap_round.svg" height="22px"></img></se-list-item>
|
|
||||||
</se-list>
|
|
||||||
<se-spin-input size="3" id="opacity" min=0 max=100 step=5 title="Change selected item opacity" src="./images/opacity.svg"></se-spin-input>
|
|
||||||
<se-palette id="palette"></se-palette>
|
|
||||||
</div> <!-- tools_bottom -->
|
|
||||||
<div id="option_lists" class="dropdown"></div>
|
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
@@ -7,7 +7,10 @@ For default config and extensions (and available options) available to
|
|||||||
import './jquery.min.js';
|
import './jquery.min.js';
|
||||||
import './components/index.js';
|
import './components/index.js';
|
||||||
import './dialogs/index.js';
|
import './dialogs/index.js';
|
||||||
import svgEditor from './svgedit.js';
|
import Editor from './Editor.js';
|
||||||
|
|
||||||
|
const svgEditor = new Editor();
|
||||||
|
svgEditor.init();
|
||||||
|
|
||||||
// URL OVERRIDE CONFIG
|
// URL OVERRIDE CONFIG
|
||||||
svgEditor.setConfig({
|
svgEditor.setConfig({
|
||||||
|
|||||||
244
src/editor/panels/BottomPanel.js
Normal file
244
src/editor/panels/BottomPanel.js
Normal file
@@ -0,0 +1,244 @@
|
|||||||
|
import SvgCanvas from '../../svgcanvas/svgcanvas.js';
|
||||||
|
import {jGraduate} from '../components/jgraduate/jQuery.jGraduate.js';
|
||||||
|
|
||||||
|
const {$id, $qa} = SvgCanvas;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* register actions for left panel
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @type {module}
|
||||||
|
*/
|
||||||
|
class BottomPanel {
|
||||||
|
/**
|
||||||
|
* @param {PlainObject} editor svgedit handler
|
||||||
|
*/
|
||||||
|
constructor (editor) {
|
||||||
|
this.editor = editor;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @type {module}
|
||||||
|
*/
|
||||||
|
get selectedElement () {
|
||||||
|
return this.editor.selectedElement;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @type {module}
|
||||||
|
*/
|
||||||
|
get multiselected () {
|
||||||
|
return this.editor.multiselected;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {module}
|
||||||
|
*/
|
||||||
|
changeStrokeWidth (e) {
|
||||||
|
let val = e.target.value;
|
||||||
|
if (val === 0 && this.editor.selectedElement && ['line', 'polyline'].includes(this.editor.selectedElement.nodeName)) {
|
||||||
|
val = 1;
|
||||||
|
}
|
||||||
|
this.editor.svgCanvas.setStrokeWidth(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {module}
|
||||||
|
*/
|
||||||
|
changeZoom (value) {
|
||||||
|
switch (value) {
|
||||||
|
case 'canvas':
|
||||||
|
case 'selection':
|
||||||
|
case 'layer':
|
||||||
|
case 'content':
|
||||||
|
this.editor.zoomChanged(window, value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
const zoomlevel = Number(value) / 100;
|
||||||
|
if (zoomlevel < 0.001) {
|
||||||
|
value = 0.1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const zoom = this.editor.svgCanvas.getZoom();
|
||||||
|
const wArea = this.editor.workarea;
|
||||||
|
|
||||||
|
this.editor.zoomChanged(window, {
|
||||||
|
width: 0,
|
||||||
|
height: 0,
|
||||||
|
// center pt of scroll position
|
||||||
|
x: (wArea.scrollLeft + parseFloat(getComputedStyle(wArea, null).width.replace("px", "")) / 2) / zoom,
|
||||||
|
y: (wArea.scrollTop + parseFloat(getComputedStyle(wArea, null).height.replace("px", "")) / 2) / zoom,
|
||||||
|
zoom: zoomlevel
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @fires module:svgcanvas.SvgCanvas#event:ext_toolButtonStateUpdate
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
updateToolButtonState () {
|
||||||
|
const bNoFill = (this.editor.svgCanvas.getColor('fill') === 'none');
|
||||||
|
const bNoStroke = (this.editor.svgCanvas.getColor('stroke') === 'none');
|
||||||
|
const buttonsNeedingStroke = ['tool_fhpath', 'tool_line'];
|
||||||
|
const buttonsNeedingFillAndStroke = [
|
||||||
|
'tools_rect', 'tools_ellipse',
|
||||||
|
'tool_text', 'tool_path'
|
||||||
|
];
|
||||||
|
|
||||||
|
if (bNoStroke) {
|
||||||
|
buttonsNeedingStroke.forEach((btn) => {
|
||||||
|
// if btn is pressed, change to select button
|
||||||
|
if ($id(btn).pressed) {
|
||||||
|
this.editor.leftPanelHandlers.clickSelect();
|
||||||
|
}
|
||||||
|
$(btn).disabled = true;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
buttonsNeedingStroke.forEach((btn) => {
|
||||||
|
$id(btn).disabled = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bNoStroke && bNoFill) {
|
||||||
|
buttonsNeedingFillAndStroke.forEach((btn) => {
|
||||||
|
// if btn is pressed, change to select button
|
||||||
|
if ($id(btn).pressed) {
|
||||||
|
this.editor.leftPanelHandlers.clickSelect();
|
||||||
|
}
|
||||||
|
$(btn).disabled = true;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
buttonsNeedingFillAndStroke.forEach((btn) => {
|
||||||
|
$id(btn).disabled = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.editor.svgCanvas.runExtensions(
|
||||||
|
'toolButtonStateUpdate',
|
||||||
|
/** @type {module:svgcanvas.SvgCanvas#event:ext_toolButtonStateUpdate} */ {
|
||||||
|
nofill: bNoFill,
|
||||||
|
nostroke: bNoStroke
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {module}
|
||||||
|
*/
|
||||||
|
handleColorPicker (type, evt) {
|
||||||
|
const {paint} = evt.detail;
|
||||||
|
this.editor.svgCanvas.setPaint(type, paint);
|
||||||
|
this.updateToolButtonState();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @type {module}
|
||||||
|
*/
|
||||||
|
handleStrokeAttr (type, evt) {
|
||||||
|
this.editor.svgCanvas.setStrokeAttr(type, evt.detail.value);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @type {module}
|
||||||
|
*/
|
||||||
|
handleOpacity (evt) {
|
||||||
|
// if ($(this).find('div').length) { return; }
|
||||||
|
const val = Number.parseInt(evt.currentTarget.value.split('%')[0]);
|
||||||
|
this.editor.svgCanvas.setOpacity(val / 100);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @type {module}
|
||||||
|
*/
|
||||||
|
handlePalette (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
// shift key or right click for stroke
|
||||||
|
const {picker, color} = e.detail;
|
||||||
|
// Webkit-based browsers returned 'initial' here for no stroke
|
||||||
|
const paint = color === 'none' ? new jGraduate.Paint() : new jGraduate.Paint({alpha: 100, solidColor: color.substr(1)});
|
||||||
|
if (picker === 'fill') {
|
||||||
|
$id('fill_color').setPaint(paint);
|
||||||
|
} else {
|
||||||
|
$id('stroke_color').setPaint(paint);
|
||||||
|
}
|
||||||
|
this.editor.svgCanvas.setColor(picker, color);
|
||||||
|
if (color !== 'none' && this.editor.svgCanvas.getPaintOpacity(picker) !== 1) {
|
||||||
|
this.editor.svgCanvas.setPaintOpacity(picker, 1.0);
|
||||||
|
}
|
||||||
|
this.updateToolButtonState();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {module}
|
||||||
|
*/
|
||||||
|
init () {
|
||||||
|
// register actions for Bottom panel
|
||||||
|
const template = document.createElement('template');
|
||||||
|
template.innerHTML = `
|
||||||
|
<div id="tools_bottom">
|
||||||
|
<!-- Zoom buttons -->
|
||||||
|
<se-zoom id="zoom" src="./images/zoom.svg" title="Change zoom level" inputsize="40px">
|
||||||
|
<div value="1000">1000</div>
|
||||||
|
<div value="400">400</div>
|
||||||
|
<div value="200">200</div>
|
||||||
|
<div value="100">100</div>
|
||||||
|
<div value="50">50</div>
|
||||||
|
<div value="25">25</div>
|
||||||
|
<div value="canvas">Fit to canvas</div>
|
||||||
|
<div value="selection">Fit to selection</div>
|
||||||
|
<div value="layer">Fit to layer content</div>
|
||||||
|
<div value="content">Fit to all content</div>
|
||||||
|
</se-zoom>
|
||||||
|
<se-colorpicker id="fill_color" src="./images/fill.svg" title="Change fill color" type="fill"></se-colorpicker>
|
||||||
|
<se-colorpicker id="stroke_color" src="./images/stroke.svg" title="Change stroke color" type="stroke">
|
||||||
|
</se-colorpicker>
|
||||||
|
<se-spin-input id="stroke_width" min=0 max=99 step=1 title="Change stroke width" label=""></se-spin-input>
|
||||||
|
<se-list id="stroke_style" title="Change stroke dash style" label="" width="22px" height="24px">
|
||||||
|
<se-list-item value="none">—</se-list-item>
|
||||||
|
<se-list-item value="2,2">...</se-list-item>
|
||||||
|
<se-list-item value="5,5">- -</se-list-item>
|
||||||
|
<se-list-item value="5,2,2,2">- .</se-list-item>
|
||||||
|
<se-list-item value="5,2,2,2,2,2">- ..</se-list-item>
|
||||||
|
</se-list>
|
||||||
|
<se-list id="stroke_linejoin" title="Linejoin: Miter" label="" width="22px" height="24px">
|
||||||
|
<se-list-item id="linejoin_miter" value="miter"><img title="Linejoin: Miter" src="./images/linejoin_miter.svg"
|
||||||
|
height="22px"></img></se-list-item>
|
||||||
|
<se-list-item id="linejoin_round" value="round"><img title="Linejoin: Round" src="./images/linejoin_round.svg"
|
||||||
|
height="22px"></img></se-list-item>
|
||||||
|
<se-list-item id="linejoin_bevel" value="bevel"><img title="Linejoin: Bevel" src="./images/linejoin_bevel.svg"
|
||||||
|
height="22px"></img></se-list-item>
|
||||||
|
</se-list>
|
||||||
|
<se-list id="stroke_linecap" title="Linecap: Butt" label="" width="22px" height="24px">
|
||||||
|
<se-list-item id="linecap_butt" value="butt"><img title="Linecap: Butt" src="./images/linecap_butt.svg"
|
||||||
|
height="22px"></img></se-list-item>
|
||||||
|
<se-list-item id="linecap_square" value="square"><img title="Linecap: Square" src="./images/linecap_square.svg"
|
||||||
|
height="22px"></img></se-list-item>
|
||||||
|
<se-list-item id="linecap_round" value="round"><img title="Linecap: Round" src="./images/linecap_round.svg"
|
||||||
|
height="22px"></img></se-list-item>
|
||||||
|
</se-list>
|
||||||
|
<se-spin-input size="3" id="opacity" min=0 max=100 step=5 title="Change selected item opacity"
|
||||||
|
src="./images/opacity.svg"></se-spin-input>
|
||||||
|
<se-palette id="palette"></se-palette>
|
||||||
|
</div> <!-- tools_bottom -->
|
||||||
|
`
|
||||||
|
this.editor.$svgEditor.append(template.content.cloneNode(true));
|
||||||
|
$id('palette').addEventListener('change', this.handlePalette.bind(this));
|
||||||
|
const {curConfig} = this.editor.configObj;
|
||||||
|
$id('fill_color').setPaint(new jGraduate.Paint({alpha: 100, solidColor: curConfig.initFill.color}));
|
||||||
|
$id('stroke_color').setPaint(new jGraduate.Paint({alpha: 100, solidColor: curConfig.initStroke.color}));
|
||||||
|
$id('zoom').addEventListener('change', (e) => this.changeZoom.bind(this)(e.detail.value));
|
||||||
|
$id('stroke_color').addEventListener('change', (evt) => this.handleColorPicker.bind(this)('stroke', evt));
|
||||||
|
$id('fill_color').addEventListener('change', (evt) => this.handleColorPicker.bind(this)('fill', evt));
|
||||||
|
$id('stroke_width').addEventListener('change', this.changeStrokeWidth.bind(this));
|
||||||
|
$id('stroke_style').addEventListener('change', (evt) => this.handleStrokeAttr.bind(this)('stroke-dasharray', evt));
|
||||||
|
$id('stroke_linejoin').addEventListener('change', (evt) => this.handleStrokeAttr.bind(this)('stroke-linejoin', evt));
|
||||||
|
$id('stroke_linecap').addEventListener('change', (evt) => this.handleStrokeAttr.bind(this)('stroke-linecap', evt));
|
||||||
|
$id('opacity').addEventListener('change', this.handleOpacity.bind(this));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @type {module}
|
||||||
|
*/
|
||||||
|
updateColorpickers (apply) {
|
||||||
|
$id('fill_color').update(this.editor.svgCanvas, this.editor.selectedElement, apply);
|
||||||
|
$id('stroke_color').update(this.editor.svgCanvas, this.editor.selectedElement, apply);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default BottomPanel;
|
||||||
@@ -1,197 +0,0 @@
|
|||||||
/* globals $ */
|
|
||||||
import {jGraduate} from '../components/jgraduate/jQuery.jGraduate.js';
|
|
||||||
import SvgCanvas from '../../svgcanvas/svgcanvas.js';
|
|
||||||
|
|
||||||
const {$id} = SvgCanvas;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* register actions for left panel
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class BottomPanelHandlers {
|
|
||||||
/**
|
|
||||||
* @param {PlainObject} editor svgedit handler
|
|
||||||
*/
|
|
||||||
constructor (editor) {
|
|
||||||
this.editor = editor;
|
|
||||||
this.svgCanvas = editor.svgCanvas;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @type {module}
|
|
||||||
*/
|
|
||||||
get selectedElement () {
|
|
||||||
return this.editor.selectedElement;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @type {module}
|
|
||||||
*/
|
|
||||||
get multiselected () {
|
|
||||||
return this.editor.multiselected;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {module}
|
|
||||||
*/
|
|
||||||
changeStrokeWidth (e) {
|
|
||||||
let val = e.target.value;
|
|
||||||
if (val === 0 && this.selectedElement && ['line', 'polyline'].includes(this.selectedElement.nodeName)) {
|
|
||||||
val = 1;
|
|
||||||
}
|
|
||||||
this.svgCanvas.setStrokeWidth(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {module}
|
|
||||||
*/
|
|
||||||
changeZoom (value) {
|
|
||||||
switch (value) {
|
|
||||||
case 'canvas':
|
|
||||||
case 'selection':
|
|
||||||
case 'layer':
|
|
||||||
case 'content':
|
|
||||||
this.editor.zoomChanged(window, value);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
const zoomlevel = Number(value) / 100;
|
|
||||||
if (zoomlevel < 0.001) {
|
|
||||||
value = 0.1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const zoom = this.svgCanvas.getZoom();
|
|
||||||
const wArea = this.editor.workarea;
|
|
||||||
|
|
||||||
this.editor.zoomChanged(window, {
|
|
||||||
width: 0,
|
|
||||||
height: 0,
|
|
||||||
// center pt of scroll position
|
|
||||||
x: (wArea[0].scrollLeft + wArea.width() / 2) / zoom,
|
|
||||||
y: (wArea[0].scrollTop + wArea.height() / 2) / zoom,
|
|
||||||
zoom: zoomlevel
|
|
||||||
}, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @fires module:svgcanvas.SvgCanvas#event:ext_toolButtonStateUpdate
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
updateToolButtonState () {
|
|
||||||
const bNoFill = (this.svgCanvas.getColor('fill') === 'none');
|
|
||||||
const bNoStroke = (this.svgCanvas.getColor('stroke') === 'none');
|
|
||||||
const buttonsNeedingStroke = ['tool_fhpath', 'tool_line'];
|
|
||||||
const buttonsNeedingFillAndStroke = [
|
|
||||||
'tools_rect', 'tools_ellipse',
|
|
||||||
'tool_text', 'tool_path'
|
|
||||||
];
|
|
||||||
|
|
||||||
if (bNoStroke) {
|
|
||||||
buttonsNeedingStroke.forEach((btn) => {
|
|
||||||
// if btn is pressed, change to select button
|
|
||||||
if ($id(btn).pressed) {
|
|
||||||
this.editor.leftPanelHandlers.clickSelect();
|
|
||||||
}
|
|
||||||
$(btn).disabled = true;
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
buttonsNeedingStroke.forEach((btn) => {
|
|
||||||
$id(btn).disabled = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bNoStroke && bNoFill) {
|
|
||||||
buttonsNeedingFillAndStroke.forEach((btn) => {
|
|
||||||
// if btn is pressed, change to select button
|
|
||||||
if ($id(btn).pressed) {
|
|
||||||
this.editor.leftPanelHandlers.clickSelect();
|
|
||||||
}
|
|
||||||
$(btn).disabled = true;
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
buttonsNeedingFillAndStroke.forEach((btn) => {
|
|
||||||
$id(btn).disabled = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
this.svgCanvas.runExtensions(
|
|
||||||
'toolButtonStateUpdate',
|
|
||||||
/** @type {module:svgcanvas.SvgCanvas#event:ext_toolButtonStateUpdate} */ {
|
|
||||||
nofill: bNoFill,
|
|
||||||
nostroke: bNoStroke
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @type {module}
|
|
||||||
*/
|
|
||||||
updateColorpickers (apply) {
|
|
||||||
$id('fill_color').update(this.svgCanvas, this.selectedElement, apply);
|
|
||||||
$id('stroke_color').update(this.svgCanvas, this.selectedElement, apply);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {module}
|
|
||||||
*/
|
|
||||||
handleColorPicker (type, evt) {
|
|
||||||
const {paint} = evt.detail;
|
|
||||||
this.svgCanvas.setPaint(type, paint);
|
|
||||||
this.updateToolButtonState();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @type {module}
|
|
||||||
*/
|
|
||||||
handleStrokeAttr (type, evt) {
|
|
||||||
this.svgCanvas.setStrokeAttr(type, evt.detail.value);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @type {module}
|
|
||||||
*/
|
|
||||||
handleOpacity (evt) {
|
|
||||||
// if ($(this).find('div').length) { return; }
|
|
||||||
const val = Number.parseInt(evt.currentTarget.value.split('%')[0]);
|
|
||||||
this.svgCanvas.setOpacity(val / 100);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @type {module}
|
|
||||||
*/
|
|
||||||
handlePalette (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
// shift key or right click for stroke
|
|
||||||
const {picker, color} = e.detail;
|
|
||||||
// Webkit-based browsers returned 'initial' here for no stroke
|
|
||||||
const paint = color === 'none' ? new jGraduate.Paint() : new jGraduate.Paint({alpha: 100, solidColor: color.substr(1)});
|
|
||||||
if (picker === 'fill') {
|
|
||||||
$id('fill_color').setPaint(paint);
|
|
||||||
} else {
|
|
||||||
$id('stroke_color').setPaint(paint);
|
|
||||||
}
|
|
||||||
this.svgCanvas.setColor(picker, color);
|
|
||||||
if (color !== 'none' && this.svgCanvas.getPaintOpacity(picker) !== 1) {
|
|
||||||
this.svgCanvas.setPaintOpacity(picker, 1.0);
|
|
||||||
}
|
|
||||||
this.updateToolButtonState();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {module}
|
|
||||||
*/
|
|
||||||
init () {
|
|
||||||
// register actions for bottom panel
|
|
||||||
$id('zoom').addEventListener('change', (e) => this.changeZoom.bind(this)(e.detail.value));
|
|
||||||
$id('stroke_color').addEventListener('change', (evt) => this.handleColorPicker.bind(this)('stroke', evt));
|
|
||||||
$id('fill_color').addEventListener('change', (evt) => this.handleColorPicker.bind(this)('fill', evt));
|
|
||||||
$id('stroke_width').addEventListener('change', this.changeStrokeWidth.bind(this));
|
|
||||||
$id('stroke_style').addEventListener('change', (evt) => this.handleStrokeAttr.bind(this)('stroke-dasharray', evt));
|
|
||||||
$id('stroke_linejoin').addEventListener('change', (evt) => this.handleStrokeAttr.bind(this)('stroke-linejoin', evt));
|
|
||||||
$id('stroke_linecap').addEventListener('change', (evt) => this.handleStrokeAttr.bind(this)('stroke-linecap', evt));
|
|
||||||
$id('opacity').addEventListener('change', this.handleOpacity.bind(this));
|
|
||||||
$id('palette').addEventListener('change', this.handlePalette.bind(this));
|
|
||||||
const {curConfig} = this.editor.configObj;
|
|
||||||
$id('fill_color').setPaint(new jGraduate.Paint({alpha: 100, solidColor: curConfig.initFill.color}));
|
|
||||||
$id('stroke_color').setPaint(new jGraduate.Paint({alpha: 100, solidColor: curConfig.initStroke.color}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default BottomPanelHandlers;
|
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
|
/* eslint-disable max-len */
|
||||||
/* eslint-disable no-alert */
|
/* eslint-disable no-alert */
|
||||||
/* globals $ */
|
/* globals $ */
|
||||||
import SvgCanvas from '../../svgcanvas/svgcanvas.js';
|
import SvgCanvas from "../../svgcanvas/svgcanvas.js";
|
||||||
|
|
||||||
const SIDEPANEL_MAXWIDTH = 300;
|
const SIDEPANEL_MAXWIDTH = 300;
|
||||||
const SIDEPANEL_OPENWIDTH = 150;
|
const SIDEPANEL_OPENWIDTH = 150;
|
||||||
const {$id} = SvgCanvas;
|
const { $id } = SvgCanvas;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -13,10 +14,9 @@ class LayersPanel {
|
|||||||
/**
|
/**
|
||||||
* @param {PlainObject} editor
|
* @param {PlainObject} editor
|
||||||
*/
|
*/
|
||||||
constructor (editor) {
|
constructor(editor) {
|
||||||
this.svgCanvas = editor.svgCanvas;
|
|
||||||
this.uiStrings = editor.uiStrings;
|
this.uiStrings = editor.uiStrings;
|
||||||
this.updateContextPanel = editor.topPanelHandlers.updateContextPanel;
|
this.updateContextPanel = editor.topPanel.updateContextPanel;
|
||||||
this.sidedrag = -1;
|
this.sidedrag = -1;
|
||||||
this.sidedragging = false;
|
this.sidedragging = false;
|
||||||
this.allowmove = false;
|
this.allowmove = false;
|
||||||
@@ -28,25 +28,37 @@ class LayersPanel {
|
|||||||
* @fires module:svgcanvas.SvgCanvas#event:ext_workareaResized
|
* @fires module:svgcanvas.SvgCanvas#event:ext_workareaResized
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
changeSidePanelWidth (delta) {
|
changeSidePanelWidth(delta) {
|
||||||
const rulerX = $('#ruler_x');
|
const rulerX = document.querySelector("#ruler_x");
|
||||||
$('#sidepanels').width('+=' + delta);
|
$("#sidepanels").width("+=" + delta);
|
||||||
$('#layerpanel').width('+=' + delta);
|
$("#layerpanel").width("+=" + delta);
|
||||||
rulerX.css('right', Number.parseInt(rulerX.css('right')) + delta);
|
rulerX.style.right =
|
||||||
this.editor.workarea.css('right', Number.parseInt(this.editor.workarea.css('right')) + delta);
|
parseFloat(getComputedStyle(rulerX, null).right.replace("px", "")) +
|
||||||
this.svgCanvas.runExtensions('workareaResized');
|
delta +
|
||||||
|
"px";
|
||||||
|
this.editor.workarea.style.right =
|
||||||
|
parseFloat(
|
||||||
|
getComputedStyle(this.editor.workarea, null).right.replace("px", "")
|
||||||
|
) +
|
||||||
|
delta +
|
||||||
|
"px";
|
||||||
|
this.editor.svgCanvas.runExtensions("workareaResized");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Event} evt
|
* @param {Event} evt
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
resizeSidePanel (evt) {
|
resizeSidePanel(evt) {
|
||||||
if (!this.allowmove) { return; }
|
if (!this.allowmove) {
|
||||||
if (this.sidedrag === -1) { return; }
|
return;
|
||||||
|
}
|
||||||
|
if (this.sidedrag === -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.sidedragging = true;
|
this.sidedragging = true;
|
||||||
let deltaX = this.sidedrag - evt.pageX;
|
let deltaX = this.sidedrag - evt.pageX;
|
||||||
const sideWidth = $('#sidepanels').width();
|
const sideWidth = $("#sidepanels").width();
|
||||||
if (sideWidth + deltaX > SIDEPANEL_MAXWIDTH) {
|
if (sideWidth + deltaX > SIDEPANEL_MAXWIDTH) {
|
||||||
deltaX = SIDEPANEL_MAXWIDTH - sideWidth;
|
deltaX = SIDEPANEL_MAXWIDTH - sideWidth;
|
||||||
// sideWidth = SIDEPANEL_MAXWIDTH;
|
// sideWidth = SIDEPANEL_MAXWIDTH;
|
||||||
@@ -54,7 +66,9 @@ class LayersPanel {
|
|||||||
deltaX = 2 - sideWidth;
|
deltaX = 2 - sideWidth;
|
||||||
// sideWidth = 2;
|
// sideWidth = 2;
|
||||||
}
|
}
|
||||||
if (deltaX === 0) { return; }
|
if (deltaX === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.sidedrag -= deltaX;
|
this.sidedrag -= deltaX;
|
||||||
this.changeSidePanelWidth(deltaX);
|
this.changeSidePanelWidth(deltaX);
|
||||||
}
|
}
|
||||||
@@ -64,11 +78,12 @@ class LayersPanel {
|
|||||||
* @param {boolean} close Forces the side panel closed
|
* @param {boolean} close Forces the side panel closed
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
toggleSidePanel (close) {
|
toggleSidePanel(close) {
|
||||||
const dpr = window.devicePixelRatio || 1;
|
const dpr = window.devicePixelRatio || 1;
|
||||||
const w = $('#sidepanels').width();
|
const w = $("#sidepanels").width();
|
||||||
const isOpened = (dpr < 1 ? w : w / dpr) > 2;
|
const isOpened = (dpr < 1 ? w : w / dpr) > 2;
|
||||||
const zoomAdjustedSidepanelWidth = (dpr < 1 ? 1 : dpr) * SIDEPANEL_OPENWIDTH;
|
const zoomAdjustedSidepanelWidth =
|
||||||
|
(dpr < 1 ? 1 : dpr) * SIDEPANEL_OPENWIDTH;
|
||||||
const deltaX = (isOpened || close ? 0 : zoomAdjustedSidepanelWidth) - w;
|
const deltaX = (isOpened || close ? 0 : zoomAdjustedSidepanelWidth) - w;
|
||||||
this.changeSidePanelWidth(deltaX);
|
this.changeSidePanelWidth(deltaX);
|
||||||
}
|
}
|
||||||
@@ -76,90 +91,147 @@ class LayersPanel {
|
|||||||
* @param {PlainObject} e event
|
* @param {PlainObject} e event
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
lmenuFunc (e) {
|
lmenuFunc(e) {
|
||||||
const action = e?.detail?.trigger;
|
const action = e?.detail?.trigger;
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case 'dupe':
|
case "dupe":
|
||||||
this.cloneLayer();
|
this.cloneLayer();
|
||||||
break;
|
break;
|
||||||
case 'delete':
|
case "delete":
|
||||||
this.deleteLayer();
|
this.deleteLayer();
|
||||||
break;
|
break;
|
||||||
case 'merge_down':
|
case "merge_down":
|
||||||
this.mergeLayer();
|
this.mergeLayer();
|
||||||
break;
|
break;
|
||||||
case 'merge_all':
|
case "merge_all":
|
||||||
this.svgCanvas.mergeAllLayers();
|
this.editor.svgCanvas.mergeAllLayers();
|
||||||
this.updateContextPanel();
|
this.updateContextPanel();
|
||||||
this.populateLayers();
|
this.populateLayers();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
init () {
|
init() {
|
||||||
|
const template = document.createElement("template");
|
||||||
|
template.innerHTML = `
|
||||||
|
<div id="sidepanels">
|
||||||
|
<div id="layerpanel">
|
||||||
|
<h3 id="layersLabel">Layers</h3>
|
||||||
|
<fieldset id="layerbuttons">
|
||||||
|
<se-button id="layer_new" title="New Layer" size="small" src="./images/new.svg"></se-button>
|
||||||
|
<se-button id="layer_delete" title="Delete Layer" size="small" src="./images/delete.svg"></se-button>
|
||||||
|
<se-button id="layer_rename" title="Rename Layer" size="small" src="./images/text.svg"></se-button>
|
||||||
|
<se-button id="layer_up" title="Move Layer Up" size="small" src="./images/go_up.svg"></se-button>
|
||||||
|
<se-button id="layer_down" title="Move Layer Down" size="small" src="./images/go_down.svg"></se-button>
|
||||||
|
<se-button id="layer_moreopts" title="More Options" size="small" src="./images/context_menu.svg">
|
||||||
|
</se-button>
|
||||||
|
</fieldset>
|
||||||
|
<table id="layerlist">
|
||||||
|
<tr class="layer">
|
||||||
|
<td class="layervis"></td>
|
||||||
|
<td class="layername">Layer 1</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<span id="selLayerLabel">Move elements to:</span>
|
||||||
|
<select id="selLayerNames" title="Move selected elements to a different layer" disabled="disabled">
|
||||||
|
<option selected="selected" value="layer1">Layer 1</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div id="sidepanel_handle" title="Drag left/right to resize side panel [X]">L a y e r s
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
this.editor.$svgEditor.append(template.content.cloneNode(true));
|
||||||
|
this.editor.svgCanvas = this.editor.svgCanvas;
|
||||||
// layer menu added to DOM
|
// layer menu added to DOM
|
||||||
const menuMore = document.createElement('se-cmenu-layers');
|
const menuMore = document.createElement("se-cmenu-layers");
|
||||||
menuMore.setAttribute('id', 'se-cmenu-layers-more');
|
menuMore.setAttribute("id", "se-cmenu-layers-more");
|
||||||
menuMore.value = 'layer_moreopts';
|
menuMore.value = "layer_moreopts";
|
||||||
menuMore.setAttribute('leftclick', true);
|
menuMore.setAttribute("leftclick", true);
|
||||||
document.body.append(menuMore);
|
document.body.append(menuMore);
|
||||||
const menuLayerBox = document.createElement('se-cmenu-layers');
|
const menuLayerBox = document.createElement("se-cmenu-layers");
|
||||||
menuLayerBox.setAttribute('id', 'se-cmenu-layers-list');
|
menuLayerBox.setAttribute("id", "se-cmenu-layers-list");
|
||||||
menuLayerBox.value = 'layerlist';
|
menuLayerBox.value = "layerlist";
|
||||||
menuLayerBox.setAttribute('leftclick', false);
|
menuLayerBox.setAttribute("leftclick", false);
|
||||||
document.body.append(menuLayerBox);
|
document.body.append(menuLayerBox);
|
||||||
document.getElementById('layer_new').addEventListener('click', this.newLayer.bind(this));
|
document
|
||||||
document.getElementById('layer_delete').addEventListener('click', this.deleteLayer.bind(this));
|
.getElementById("layer_new")
|
||||||
document.getElementById('layer_up').addEventListener('click', () => this.moveLayer.bind(this)(-1));
|
.addEventListener("click", this.newLayer.bind(this));
|
||||||
document.getElementById('layer_down').addEventListener('click', () => this.moveLayer.bind(this)(1));
|
document
|
||||||
document.getElementById('layer_rename').addEventListener('click', this.layerRename.bind(this));
|
.getElementById("layer_delete")
|
||||||
$id('se-cmenu-layers-more').addEventListener('change', this.lmenuFunc.bind(this));
|
.addEventListener("click", this.deleteLayer.bind(this));
|
||||||
$id('se-cmenu-layers-list').addEventListener('change', (e) => {
|
document
|
||||||
|
.getElementById("layer_up")
|
||||||
|
.addEventListener("click", () => this.moveLayer.bind(this)(-1));
|
||||||
|
document
|
||||||
|
.getElementById("layer_down")
|
||||||
|
.addEventListener("click", () => this.moveLayer.bind(this)(1));
|
||||||
|
document
|
||||||
|
.getElementById("layer_rename")
|
||||||
|
.addEventListener("click", this.layerRename.bind(this));
|
||||||
|
$id("se-cmenu-layers-more").addEventListener(
|
||||||
|
"change",
|
||||||
|
this.lmenuFunc.bind(this)
|
||||||
|
);
|
||||||
|
$id("se-cmenu-layers-list").addEventListener("change", e => {
|
||||||
this.lmenuFunc.bind(this)(e?.detail?.trigger, e?.detail?.source);
|
this.lmenuFunc.bind(this)(e?.detail?.trigger, e?.detail?.source);
|
||||||
});
|
});
|
||||||
$id('sidepanel_handle').addEventListener('click', this.toggleSidePanel.bind(this));
|
$id("sidepanel_handle").addEventListener(
|
||||||
|
"click",
|
||||||
|
this.toggleSidePanel.bind(this)
|
||||||
|
);
|
||||||
if (this.editor.configObj.curConfig.showlayers) {
|
if (this.editor.configObj.curConfig.showlayers) {
|
||||||
this.toggleSidePanel();
|
this.toggleSidePanel();
|
||||||
}
|
}
|
||||||
$id('sidepanel_handle').addEventListener('mousedown', (evt) => {
|
$id("sidepanel_handle").addEventListener("mousedown", evt => {
|
||||||
this.sidedrag = evt.pageX;
|
this.sidedrag = evt.pageX;
|
||||||
window.addEventListener('mousemove', this.resizeSidePanel.bind(this));
|
window.addEventListener("mousemove", this.resizeSidePanel.bind(this));
|
||||||
this.allowmove = false;
|
this.allowmove = false;
|
||||||
// Silly hack for Chrome, which always runs mousemove right after mousedown
|
// Silly hack for Chrome, which always runs mousemove right after mousedown
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.allowmove = true;
|
this.allowmove = true;
|
||||||
}, 20);
|
}, 20);
|
||||||
});
|
});
|
||||||
$id('sidepanel_handle').addEventListener('mouseup', (evt) => {
|
$id("sidepanel_handle").addEventListener("mouseup", evt => {
|
||||||
if (!this.sidedragging) { this.toggleSidePanel(); }
|
if (!this.sidedragging) {
|
||||||
|
this.toggleSidePanel();
|
||||||
|
}
|
||||||
this.sidedrag = -1;
|
this.sidedrag = -1;
|
||||||
this.sidedragging = false;
|
this.sidedragging = false;
|
||||||
});
|
});
|
||||||
window.addEventListener('mouseup', (evt) => {
|
window.addEventListener("mouseup", evt => {
|
||||||
this.sidedrag = -1;
|
this.sidedrag = -1;
|
||||||
this.sidedragging = false;
|
this.sidedragging = false;
|
||||||
$id('svg_editor').removeEventListener('mousemove', this.resizeSidePanel.bind(this));
|
$id("svg_editor").removeEventListener(
|
||||||
|
"mousemove",
|
||||||
|
this.resizeSidePanel.bind(this)
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
newLayer () {
|
newLayer() {
|
||||||
let uniqName;
|
let uniqName;
|
||||||
let i = this.svgCanvas.getCurrentDrawing().getNumLayers();
|
let i = this.editor.svgCanvas.getCurrentDrawing().getNumLayers();
|
||||||
do {
|
do {
|
||||||
uniqName = this.uiStrings.layers.layer + ' ' + (++i);
|
uniqName = this.uiStrings.layers.layer + " " + ++i;
|
||||||
} while (this.svgCanvas.getCurrentDrawing().hasLayer(uniqName));
|
} while (this.editor.svgCanvas.getCurrentDrawing().hasLayer(uniqName));
|
||||||
|
|
||||||
const newName = prompt(this.uiStrings.notification.enterUniqueLayerName, uniqName);
|
const newName = prompt(
|
||||||
if (!newName) { return; }
|
this.uiStrings.notification.enterUniqueLayerName,
|
||||||
if (this.svgCanvas.getCurrentDrawing().hasLayer(newName)) {
|
uniqName
|
||||||
|
);
|
||||||
|
if (!newName) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.editor.svgCanvas.getCurrentDrawing().hasLayer(newName)) {
|
||||||
alert(this.uiStrings.notification.dupeLayerName);
|
alert(this.uiStrings.notification.dupeLayerName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.svgCanvas.createLayer(newName);
|
this.editor.svgCanvas.createLayer(newName);
|
||||||
this.updateContextPanel();
|
this.updateContextPanel();
|
||||||
this.populateLayers();
|
this.populateLayers();
|
||||||
}
|
}
|
||||||
@@ -168,15 +240,15 @@ class LayersPanel {
|
|||||||
*
|
*
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
deleteLayer () {
|
deleteLayer() {
|
||||||
if (this.svgCanvas.deleteCurrentLayer()) {
|
if (this.editor.svgCanvas.deleteCurrentLayer()) {
|
||||||
this.updateContextPanel();
|
this.updateContextPanel();
|
||||||
this.populateLayers();
|
this.populateLayers();
|
||||||
// This matches what this.svgCanvas does
|
// This matches what this.editor.svgCanvas does
|
||||||
// TODO: make this behavior less brittle (svg-editor should get which
|
// TODO: make this behavior less brittle (svg-editor should get which
|
||||||
// layer is selected from the canvas and then select that one in the UI)
|
// layer is selected from the canvas and then select that one in the UI)
|
||||||
$('#layerlist tr.layer').removeClass('layersel');
|
$("#layerlist tr.layer").removeClass("layersel");
|
||||||
$('#layerlist tr.layer:first').addClass('layersel');
|
$("#layerlist tr.layer:first").addClass("layersel");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,16 +256,22 @@ class LayersPanel {
|
|||||||
*
|
*
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
cloneLayer () {
|
cloneLayer() {
|
||||||
const name = this.svgCanvas.getCurrentDrawing().getCurrentLayerName() + ' copy';
|
const name =
|
||||||
|
this.editor.svgCanvas.getCurrentDrawing().getCurrentLayerName() + " copy";
|
||||||
|
|
||||||
const newName = prompt(this.uiStrings.notification.enterUniqueLayerName, name);
|
const newName = prompt(
|
||||||
if (!newName) { return; }
|
this.uiStrings.notification.enterUniqueLayerName,
|
||||||
if (this.svgCanvas.getCurrentDrawing().hasLayer(newName)) {
|
name
|
||||||
|
);
|
||||||
|
if (!newName) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.editor.svgCanvas.getCurrentDrawing().hasLayer(newName)) {
|
||||||
alert(this.uiStrings.notification.dupeLayerName);
|
alert(this.uiStrings.notification.dupeLayerName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.svgCanvas.cloneLayer(newName);
|
this.editor.svgCanvas.cloneLayer(newName);
|
||||||
this.updateContextPanel();
|
this.updateContextPanel();
|
||||||
this.populateLayers();
|
this.populateLayers();
|
||||||
}
|
}
|
||||||
@@ -202,11 +280,14 @@ class LayersPanel {
|
|||||||
*
|
*
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
mergeLayer () {
|
mergeLayer() {
|
||||||
if ($('#layerlist tr.layersel').index() === this.svgCanvas.getCurrentDrawing().getNumLayers() - 1) {
|
if (
|
||||||
|
$("#layerlist tr.layersel").index() ===
|
||||||
|
this.editor.svgCanvas.getCurrentDrawing().getNumLayers() - 1
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.svgCanvas.mergeLayer();
|
this.editor.svgCanvas.mergeLayer();
|
||||||
this.updateContextPanel();
|
this.updateContextPanel();
|
||||||
this.populateLayers();
|
this.populateLayers();
|
||||||
}
|
}
|
||||||
@@ -215,13 +296,13 @@ class LayersPanel {
|
|||||||
* @param {Integer} pos
|
* @param {Integer} pos
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
moveLayer (pos) {
|
moveLayer(pos) {
|
||||||
const total = this.svgCanvas.getCurrentDrawing().getNumLayers();
|
const total = this.editor.svgCanvas.getCurrentDrawing().getNumLayers();
|
||||||
|
|
||||||
let curIndex = $('#layerlist tr.layersel').index();
|
let curIndex = $("#layerlist tr.layersel").index();
|
||||||
if (curIndex > 0 || curIndex < total - 1) {
|
if (curIndex > 0 || curIndex < total - 1) {
|
||||||
curIndex += pos;
|
curIndex += pos;
|
||||||
this.svgCanvas.setCurrentLayerPosition(total - curIndex - 1);
|
this.editor.svgCanvas.setCurrentLayerPosition(total - curIndex - 1);
|
||||||
this.populateLayers();
|
this.populateLayers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -229,16 +310,21 @@ class LayersPanel {
|
|||||||
/**
|
/**
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
layerRename () {
|
layerRename() {
|
||||||
// const curIndex = $('#layerlist tr.layersel').prevAll().length; // Currently unused
|
// const curIndex = $('#layerlist tr.layersel').prevAll().length; // Currently unused
|
||||||
const oldName = $('#layerlist tr.layersel td.layername').text();
|
const oldName = $("#layerlist tr.layersel td.layername").text();
|
||||||
const newName = prompt(this.uiStrings.notification.enterNewLayerName, '');
|
const newName = prompt(this.uiStrings.notification.enterNewLayerName, "");
|
||||||
if (!newName) { return; }
|
if (!newName) {
|
||||||
if (oldName === newName || this.svgCanvas.getCurrentDrawing().hasLayer(newName)) {
|
return;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
oldName === newName ||
|
||||||
|
this.editor.svgCanvas.getCurrentDrawing().hasLayer(newName)
|
||||||
|
) {
|
||||||
alert(this.uiStrings.notification.layerHasThatName);
|
alert(this.uiStrings.notification.layerHasThatName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.svgCanvas.renameCurrentLayer(newName);
|
this.editor.svgCanvas.renameCurrentLayer(newName);
|
||||||
this.populateLayers();
|
this.populateLayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,72 +333,86 @@ class LayersPanel {
|
|||||||
* If no layer is passed in, this function restores the other layers.
|
* If no layer is passed in, this function restores the other layers.
|
||||||
* @param {string} [layerNameToHighlight]
|
* @param {string} [layerNameToHighlight]
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
toggleHighlightLayer (layerNameToHighlight) {
|
toggleHighlightLayer(layerNameToHighlight) {
|
||||||
let i;
|
let i;
|
||||||
const curNames = [], numLayers = this.svgCanvas.getCurrentDrawing().getNumLayers();
|
const curNames = [],
|
||||||
|
numLayers = this.editor.svgCanvas.getCurrentDrawing().getNumLayers();
|
||||||
for (i = 0; i < numLayers; i++) {
|
for (i = 0; i < numLayers; i++) {
|
||||||
curNames[i] = this.svgCanvas.getCurrentDrawing().getLayerName(i);
|
curNames[i] = this.editor.svgCanvas.getCurrentDrawing().getLayerName(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (layerNameToHighlight) {
|
if (layerNameToHighlight) {
|
||||||
curNames.forEach((curName) => {
|
curNames.forEach(curName => {
|
||||||
if (curName !== layerNameToHighlight) {
|
if (curName !== layerNameToHighlight) {
|
||||||
this.svgCanvas.getCurrentDrawing().setLayerOpacity(curName, 0.5);
|
this.editor.svgCanvas
|
||||||
|
.getCurrentDrawing()
|
||||||
|
.setLayerOpacity(curName, 0.5);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
curNames.forEach((curName) => {
|
curNames.forEach(curName => {
|
||||||
this.svgCanvas.getCurrentDrawing().setLayerOpacity(curName, 1.0);
|
this.editor.svgCanvas.getCurrentDrawing().setLayerOpacity(curName, 1.0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
populateLayers () {
|
populateLayers() {
|
||||||
this.svgCanvas.clearSelection();
|
this.editor.svgCanvas.clearSelection();
|
||||||
const layerlist = $('#layerlist tbody').empty();
|
const layerlist = $("#layerlist tbody").empty();
|
||||||
const selLayerNames = $('#selLayerNames').empty();
|
const selLayerNames = $("#selLayerNames").empty();
|
||||||
const drawing = this.svgCanvas.getCurrentDrawing();
|
const drawing = this.editor.svgCanvas.getCurrentDrawing();
|
||||||
const currentLayerName = drawing.getCurrentLayerName();
|
const currentLayerName = drawing.getCurrentLayerName();
|
||||||
let layer = this.svgCanvas.getCurrentDrawing().getNumLayers();
|
let layer = this.editor.svgCanvas.getCurrentDrawing().getNumLayers();
|
||||||
// we get the layers in the reverse z-order (the layer rendered on top is listed first)
|
// we get the layers in the reverse z-order (the layer rendered on top is listed first)
|
||||||
while (layer--) {
|
while (layer--) {
|
||||||
const name = drawing.getLayerName(layer);
|
const name = drawing.getLayerName(layer);
|
||||||
const layerTr = $('<tr class="layer">').toggleClass('layersel', name === currentLayerName);
|
const layerTr = $('<tr class="layer">').toggleClass(
|
||||||
const layerVis = $('<td class="layervis">').toggleClass('layerinvis', !drawing.getLayerVisibility(name));
|
"layersel",
|
||||||
const layerName = $('<td class="layername">' + name + '</td>');
|
name === currentLayerName
|
||||||
|
);
|
||||||
|
const layerVis = $('<td class="layervis">').toggleClass(
|
||||||
|
"layerinvis",
|
||||||
|
!drawing.getLayerVisibility(name)
|
||||||
|
);
|
||||||
|
const layerName = $('<td class="layername">' + name + "</td>");
|
||||||
layerlist.append(layerTr.append(layerVis, layerName));
|
layerlist.append(layerTr.append(layerVis, layerName));
|
||||||
selLayerNames.append('<option value="' + name + '">' + name + '</option>');
|
selLayerNames.append(
|
||||||
|
'<option value="' + name + '">' + name + "</option>"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// handle selection of layer
|
// handle selection of layer
|
||||||
$('#layerlist td.layername')
|
$("#layerlist td.layername")
|
||||||
.mouseup((evt) => {
|
.mouseup(evt => {
|
||||||
$('#layerlist tr.layer').removeClass('layersel');
|
$("#layerlist tr.layer").removeClass("layersel");
|
||||||
$(evt.currentTarget.parentNode).addClass('layersel');
|
$(evt.currentTarget.parentNode).addClass("layersel");
|
||||||
this.svgCanvas.setCurrentLayer(evt.currentTarget.textContent);
|
this.editor.svgCanvas.setCurrentLayer(evt.currentTarget.textContent);
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
})
|
})
|
||||||
.mouseover((evt) => {
|
.mouseover(evt => {
|
||||||
this.toggleHighlightLayer(this.svgCanvas, evt.currentTarget.textContent);
|
this.toggleHighlightLayer(
|
||||||
|
this.editor.svgCanvas,
|
||||||
|
evt.currentTarget.textContent
|
||||||
|
);
|
||||||
})
|
})
|
||||||
.mouseout(() => {
|
.mouseout(() => {
|
||||||
this.toggleHighlightLayer(this.svgCanvas);
|
this.toggleHighlightLayer(this.editor.svgCanvas);
|
||||||
});
|
});
|
||||||
$('#layerlist td.layervis').click((evt) => {
|
$("#layerlist td.layervis").click(evt => {
|
||||||
const row = $(evt.currentTarget.parentNode).prevAll().length;
|
const row = $(evt.currentTarget.parentNode).prevAll().length;
|
||||||
const name = $('#layerlist tr.layer:eq(' + row + ') td.layername').text();
|
const name = $("#layerlist tr.layer:eq(" + row + ") td.layername").text();
|
||||||
const vis = $(evt.currentTarget).hasClass('layerinvis');
|
const vis = $(evt.currentTarget).hasClass("layerinvis");
|
||||||
this.svgCanvas.setLayerVisibility(name, vis);
|
this.editor.svgCanvas.setLayerVisibility(name, vis);
|
||||||
$(evt.currentTarget).toggleClass('layerinvis');
|
$(evt.currentTarget).toggleClass("layerinvis");
|
||||||
});
|
});
|
||||||
|
|
||||||
// if there were too few rows, let's add a few to make it not so lonely
|
// if there were too few rows, let's add a few to make it not so lonely
|
||||||
let num = 5 - $('#layerlist tr.layer').size();
|
let num = 5 - $("#layerlist tr.layer").size();
|
||||||
while (num-- > 0) {
|
while (num-- > 0) {
|
||||||
// TODO: there must a better way to do this
|
// TODO: there must a better way to do this
|
||||||
layerlist.append('<tr><td style="color:white">_</td><td/></tr>');
|
layerlist.append('<tr><td style="color:white">_</td><td/></tr>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
253
src/editor/panels/LeftPanel.js
Normal file
253
src/editor/panels/LeftPanel.js
Normal file
@@ -0,0 +1,253 @@
|
|||||||
|
import SvgCanvas from "../../svgcanvas/svgcanvas.js";
|
||||||
|
|
||||||
|
const { $id, $qa } = SvgCanvas;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* register actions for left panel
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @type {module}
|
||||||
|
*/
|
||||||
|
class LeftPanel {
|
||||||
|
/**
|
||||||
|
* @param {PlainObject} editor svgedit handler
|
||||||
|
*/
|
||||||
|
constructor(editor) {
|
||||||
|
this.editor = editor;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* This is a common function used when a tool has been clicked (chosen).
|
||||||
|
* It does several common things:
|
||||||
|
* - Removes the pressed button from whatever tool currently has it.
|
||||||
|
* - Adds the the pressed button to the button passed in.
|
||||||
|
* @function this.updateLeftPanel
|
||||||
|
* @param {string|Element} button The DOM element or string selector representing the toolbar button
|
||||||
|
* @returns {boolean} Whether the button was disabled or not
|
||||||
|
*/
|
||||||
|
// eslint-disable-next-line class-methods-use-this
|
||||||
|
updateLeftPanel(button) {
|
||||||
|
if (button.disabled) return false;
|
||||||
|
// remove the pressed state on other(s) button(s)
|
||||||
|
$qa("#tools_left *[pressed]").forEach(b => {
|
||||||
|
b.pressed = false;
|
||||||
|
});
|
||||||
|
// pressed state for the clicked button
|
||||||
|
$id(button).pressed = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unless the select toolbar button is disabled, sets the button
|
||||||
|
* and sets the select mode and cursor styles.
|
||||||
|
* @function module:SVGEditor.clickSelect
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
clickSelect() {
|
||||||
|
if (this.updateLeftPanel("tool_select")) {
|
||||||
|
this.editor.workarea.style.cursor = "auto";
|
||||||
|
this.editor.svgCanvas.setMode("select");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
clickFHPath() {
|
||||||
|
if (this.updateLeftPanel("tool_fhpath")) {
|
||||||
|
this.editor.svgCanvas.setMode("fhpath");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
clickLine() {
|
||||||
|
if (this.updateLeftPanel("tool_line")) {
|
||||||
|
this.editor.svgCanvas.setMode("line");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
clickSquare() {
|
||||||
|
if (this.updateLeftPanel("tool_square")) {
|
||||||
|
this.editor.svgCanvas.setMode("square");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
clickRect() {
|
||||||
|
if (this.updateLeftPanel("tool_rect")) {
|
||||||
|
this.editor.svgCanvas.setMode("rect");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
clickFHRect() {
|
||||||
|
if (this.updateLeftPanel("tool_fhrect")) {
|
||||||
|
this.editor.svgCanvas.setMode("fhrect");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
clickCircle() {
|
||||||
|
if (this.updateLeftPanel("tool_circle")) {
|
||||||
|
this.editor.svgCanvas.setMode("circle");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
clickEllipse() {
|
||||||
|
if (this.updateLeftPanel("tool_ellipse")) {
|
||||||
|
this.editor.svgCanvas.setMode("ellipse");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
clickFHEllipse() {
|
||||||
|
if (this.updateLeftPanel("tool_fhellipse")) {
|
||||||
|
this.editor.svgCanvas.setMode("fhellipse");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
clickImage() {
|
||||||
|
if (this.updateLeftPanel("tool_image")) {
|
||||||
|
this.editor.svgCanvas.setMode("image");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
clickZoom() {
|
||||||
|
if (this.updateLeftPanel("tool_zoom")) {
|
||||||
|
this.editor.svgCanvas.setMode("zoom");
|
||||||
|
this.editor.workarea.style.cursor = this.editor.zoomInIcon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
dblclickZoom() {
|
||||||
|
if (this.updateLeftPanel("tool_zoom")) {
|
||||||
|
this.editor.zoomImage();
|
||||||
|
this.clickSelect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
clickText() {
|
||||||
|
if (this.updateLeftPanel("tool_text")) {
|
||||||
|
this.editor.svgCanvas.setMode("text");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
clickPath() {
|
||||||
|
if (this.updateLeftPanel("tool_path")) {
|
||||||
|
this.editor.svgCanvas.setMode("path");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @type {module}
|
||||||
|
*/
|
||||||
|
add(id, handler) {
|
||||||
|
$id(id).addEventListener("click", () => {
|
||||||
|
if (this.updateLeftPanel(id)) {
|
||||||
|
handler();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @type {module}
|
||||||
|
*/
|
||||||
|
init() {
|
||||||
|
// add Left panel
|
||||||
|
const template = document.createElement("template");
|
||||||
|
template.innerHTML = `
|
||||||
|
<div id="tools_left">
|
||||||
|
<se-button id="tool_select" title="Select Tool" src="./images/select.svg"></se-button>
|
||||||
|
<se-button id="tool_zoom" title="Zoom Tool" src="./images/zoom.svg" shortcut="Z"></se-button>
|
||||||
|
<se-button id="ext-panning" title="Panning" src="./images/panning.svg"></se-button>
|
||||||
|
<se-button id="tool_fhpath" title="Pencil Tool" src="./images/pencil.svg" shortcut="Q"></se-button>
|
||||||
|
<se-button id="tool_line" title="Line Tool" src="./images/pen.svg" shortcut="L"></se-button>
|
||||||
|
<se-button id="tool_path" title="Path Tool" src="./images/path.svg" shortcut="P"></se-button>
|
||||||
|
<se-flyingbutton id="tools_rect" title="Square/Rect Tool">
|
||||||
|
<se-button id="tool_rect" title="Rectangle" src="./images/rect.svg" shortcut="R"></se-button>
|
||||||
|
<se-button id="tool_square" title="Square" src="./images/square.svg"></se-button>
|
||||||
|
<se-button id="tool_fhrect" title="Free-Hand Rectangle" src="./images/fh_rect.svg"></se-button>
|
||||||
|
</se-flyingbutton>
|
||||||
|
<se-flyingbutton id="tools_ellipse" title="Ellipse/Circle Tool">
|
||||||
|
<se-button id="tool_ellipse" title="Rectangle" src="./images/ellipse.svg" shortcut="E"></se-button>
|
||||||
|
<se-button id="tool_circle" title="Square" src="./images/circle.svg"></se-button>
|
||||||
|
<se-button id="tool_fhellipse" title="Free-Hand Rectangle" src="./images/fh_ellipse.svg"></se-button>
|
||||||
|
</se-flyingbutton>
|
||||||
|
<se-flyingbutton id="tools_polygon" title="Polygone/Star Tool">
|
||||||
|
<se-button id="tool_polygon" title="Polygon Tool" src="./images/polygon.svg"></se-button>
|
||||||
|
<se-button id="tool_star" title="Star Tool" src="./images/star.svg"></se-button>
|
||||||
|
</se-flyingbutton>
|
||||||
|
<se-button id="mode_connect" title="Connect two objects" src="./images/conn.svg"></se-button>
|
||||||
|
<se-button id="tool_text" title="Text Tool" src="./images/text.svg" shortcut="T"></se-button>
|
||||||
|
<se-button id="tool_image" title="Image Tool" src="./images/image.svg"></se-button>
|
||||||
|
<se-button id="tool_eyedropper" title="Eye Dropper Tool" src="./images/eye_dropper.svg" shortcut="I"></se-button>
|
||||||
|
<se-explorerbutton id="tool_shapelib" title="Shape library" lib="./extensions/ext-shapes/shapelib/"
|
||||||
|
src="./images/shapelib.svg"></se-explorerbutton>
|
||||||
|
</div> <!-- tools_left -->
|
||||||
|
`;
|
||||||
|
this.editor.$svgEditor.append(template.content.cloneNode(true));
|
||||||
|
// register actions for left panel
|
||||||
|
$id("tool_select").addEventListener("click", this.clickSelect.bind(this));
|
||||||
|
$id("tool_fhpath").addEventListener("click", this.clickFHPath.bind(this));
|
||||||
|
$id("tool_text").addEventListener("click", this.clickText.bind(this));
|
||||||
|
$id("tool_image").addEventListener("click", this.clickImage.bind(this));
|
||||||
|
$id("tool_zoom").addEventListener("click", this.clickZoom.bind(this));
|
||||||
|
$id("tool_zoom").addEventListener("dblclick", this.dblclickZoom.bind(this));
|
||||||
|
$id("tool_path").addEventListener("click", this.clickPath.bind(this));
|
||||||
|
$id("tool_line").addEventListener("click", this.clickLine.bind(this));
|
||||||
|
|
||||||
|
// flyout
|
||||||
|
$id("tool_rect").addEventListener("click", this.clickRect.bind(this));
|
||||||
|
$id("tool_square").addEventListener("click", this.clickSquare.bind(this));
|
||||||
|
$id("tool_fhrect").addEventListener("click", this.clickFHRect.bind(this));
|
||||||
|
$id("tool_ellipse").addEventListener("click", this.clickEllipse.bind(this));
|
||||||
|
$id("tool_circle").addEventListener("click", this.clickCircle.bind(this));
|
||||||
|
$id("tool_fhellipse").addEventListener(
|
||||||
|
"click",
|
||||||
|
this.clickFHEllipse.bind(this)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default LeftPanel;
|
||||||
@@ -1,216 +0,0 @@
|
|||||||
import SvgCanvas from '../../svgcanvas/svgcanvas.js';
|
|
||||||
|
|
||||||
const {$id, $qa} = SvgCanvas;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* register actions for left panel
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @type {module}
|
|
||||||
*/
|
|
||||||
class LeftPanelHandlers {
|
|
||||||
/**
|
|
||||||
* @param {PlainObject} editor svgedit handler
|
|
||||||
*/
|
|
||||||
constructor (editor) {
|
|
||||||
this.editor = editor;
|
|
||||||
this.svgCanvas = editor.svgCanvas;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* This is a common function used when a tool has been clicked (chosen).
|
|
||||||
* It does several common things:
|
|
||||||
* - Removes the pressed button from whatever tool currently has it.
|
|
||||||
* - Adds the the pressed button to the button passed in.
|
|
||||||
* @function this.updateLeftPanel
|
|
||||||
* @param {string|Element} button The DOM element or string selector representing the toolbar button
|
|
||||||
* @returns {boolean} Whether the button was disabled or not
|
|
||||||
*/
|
|
||||||
// eslint-disable-next-line class-methods-use-this
|
|
||||||
updateLeftPanel (button) {
|
|
||||||
if (button.disabled) return false;
|
|
||||||
// remove the pressed state on other(s) button(s)
|
|
||||||
$qa('#tools_left *[pressed]').forEach((b) => { b.pressed = false; });
|
|
||||||
// pressed state for the clicked button
|
|
||||||
$id(button).pressed = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unless the select toolbar button is disabled, sets the button
|
|
||||||
* and sets the select mode and cursor styles.
|
|
||||||
* @function module:SVGEditor.clickSelect
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
clickSelect () {
|
|
||||||
if (this.updateLeftPanel('tool_select')) {
|
|
||||||
this.editor.workarea.css('cursor', 'auto');
|
|
||||||
this.svgCanvas.setMode('select');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
clickFHPath () {
|
|
||||||
if (this.updateLeftPanel('tool_fhpath')) {
|
|
||||||
this.svgCanvas.setMode('fhpath');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
clickLine () {
|
|
||||||
if (this.updateLeftPanel('tool_line')) {
|
|
||||||
this.svgCanvas.setMode('line');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
clickSquare () {
|
|
||||||
if (this.updateLeftPanel('tool_square')) {
|
|
||||||
this.svgCanvas.setMode('square');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
clickRect () {
|
|
||||||
if (this.updateLeftPanel('tool_rect')) {
|
|
||||||
this.svgCanvas.setMode('rect');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
clickFHRect () {
|
|
||||||
if (this.updateLeftPanel('tool_fhrect')) {
|
|
||||||
this.svgCanvas.setMode('fhrect');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
clickCircle () {
|
|
||||||
if (this.updateLeftPanel('tool_circle')) {
|
|
||||||
this.svgCanvas.setMode('circle');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
clickEllipse () {
|
|
||||||
if (this.updateLeftPanel('tool_ellipse')) {
|
|
||||||
this.svgCanvas.setMode('ellipse');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
clickFHEllipse () {
|
|
||||||
if (this.updateLeftPanel('tool_fhellipse')) {
|
|
||||||
this.svgCanvas.setMode('fhellipse');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
clickImage () {
|
|
||||||
if (this.updateLeftPanel('tool_image')) {
|
|
||||||
this.svgCanvas.setMode('image');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
clickZoom () {
|
|
||||||
if (this.updateLeftPanel('tool_zoom')) {
|
|
||||||
this.svgCanvas.setMode('zoom');
|
|
||||||
this.editor.workarea.css('cursor', this.editor.zoomInIcon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
dblclickZoom () {
|
|
||||||
if (this.updateLeftPanel('tool_zoom')) {
|
|
||||||
this.editor.zoomImage();
|
|
||||||
this.clickSelect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
clickText () {
|
|
||||||
if (this.updateLeftPanel('tool_text')) {
|
|
||||||
this.svgCanvas.setMode('text');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
clickPath () {
|
|
||||||
if (this.updateLeftPanel('tool_path')) {
|
|
||||||
this.svgCanvas.setMode('path');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @type {module}
|
|
||||||
*/
|
|
||||||
add (id, handler) {
|
|
||||||
$id(id).addEventListener('click', () => {
|
|
||||||
if (this.updateLeftPanel(id)) {
|
|
||||||
handler();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @type {module}
|
|
||||||
*/
|
|
||||||
init () {
|
|
||||||
// register actions for left panel
|
|
||||||
$id('tool_select').addEventListener('click', this.clickSelect.bind(this));
|
|
||||||
$id('tool_fhpath').addEventListener('click', this.clickFHPath.bind(this));
|
|
||||||
$id('tool_text').addEventListener('click', this.clickText.bind(this));
|
|
||||||
$id('tool_image').addEventListener('click', this.clickImage.bind(this));
|
|
||||||
$id('tool_zoom').addEventListener('click', this.clickZoom.bind(this));
|
|
||||||
$id('tool_zoom').addEventListener('dblclick', this.dblclickZoom.bind(this));
|
|
||||||
$id('tool_path').addEventListener('click', this.clickPath.bind(this));
|
|
||||||
$id('tool_line').addEventListener('click', this.clickLine.bind(this));
|
|
||||||
|
|
||||||
// flyout
|
|
||||||
$id('tool_rect').addEventListener('click', this.clickRect.bind(this));
|
|
||||||
$id('tool_square').addEventListener('click', this.clickSquare.bind(this));
|
|
||||||
$id('tool_fhrect').addEventListener('click', this.clickFHRect.bind(this));
|
|
||||||
$id('tool_ellipse').addEventListener('click', this.clickEllipse.bind(this));
|
|
||||||
$id('tool_circle').addEventListener('click', this.clickCircle.bind(this));
|
|
||||||
$id('tool_fhellipse').addEventListener('click', this.clickFHEllipse.bind(this));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default LeftPanelHandlers;
|
|
||||||
1131
src/editor/panels/TopPanel.js
Normal file
1131
src/editor/panels/TopPanel.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,645 +0,0 @@
|
|||||||
/* globals $ */
|
|
||||||
import SvgCanvas from '../../svgcanvas/svgcanvas.js';
|
|
||||||
import {isValidUnit, getTypeMap, convertUnit} from '../../common/units.js';
|
|
||||||
|
|
||||||
const {$id, isNullish} = SvgCanvas;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* register actions for left panel
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class TopPanelHandlers {
|
|
||||||
/**
|
|
||||||
* @param {PlainObject} editor svgedit handler
|
|
||||||
*/
|
|
||||||
constructor (editor) {
|
|
||||||
this.editor = editor;
|
|
||||||
this.svgCanvas = editor.svgCanvas;
|
|
||||||
this.uiStrings = editor.uiStrings;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @type {module}
|
|
||||||
*/
|
|
||||||
get selectedElement () {
|
|
||||||
return this.editor.selectedElement;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @type {module}
|
|
||||||
*/
|
|
||||||
get multiselected () {
|
|
||||||
return this.editor.multiselected;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @type {module}
|
|
||||||
*/
|
|
||||||
get path () {
|
|
||||||
return this.svgCanvas.pathActions;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @param {PlainObject} [opts={}]
|
|
||||||
* @param {boolean} [opts.cancelDeletes=false]
|
|
||||||
* @returns {void} Resolves to `undefined`
|
|
||||||
*/
|
|
||||||
promptImgURL ({cancelDeletes = false} = {}) {
|
|
||||||
let curhref = this.svgCanvas.getHref(this.selectedElement);
|
|
||||||
curhref = curhref.startsWith('data:') ? '' : curhref;
|
|
||||||
// eslint-disable-next-line no-alert
|
|
||||||
const url = prompt(this.editor.uiStrings.notification.enterNewImgURL, curhref);
|
|
||||||
if (url) {
|
|
||||||
this.editor.setImageURL(url);
|
|
||||||
} else if (cancelDeletes) {
|
|
||||||
this.svgCanvas.deleteSelectedElements();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Updates the context panel tools based on the selected element.
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
updateContextPanel () {
|
|
||||||
const setInputWidth = (elem) => {
|
|
||||||
const w = Math.min(Math.max(12 + elem.value.length * 6, 50), 300);
|
|
||||||
$(elem).width(w);
|
|
||||||
};
|
|
||||||
|
|
||||||
let elem = this.selectedElement;
|
|
||||||
// If element has just been deleted, consider it null
|
|
||||||
if (!isNullish(elem) && !elem.parentNode) { elem = null; }
|
|
||||||
const currentLayerName = this.svgCanvas.getCurrentDrawing().getCurrentLayerName();
|
|
||||||
const currentMode = this.svgCanvas.getMode();
|
|
||||||
const unit = this.editor.configObj.curConfig.baseUnit !== 'px' ? this.editor.configObj.curConfig.baseUnit : null;
|
|
||||||
|
|
||||||
const isNode = currentMode === 'pathedit'; // elem ? (elem.id && elem.id.startsWith('pathpointgrip')) : false;
|
|
||||||
const menuItems = document.getElementById('se-cmenu_canvas');
|
|
||||||
$('#selected_panel, #multiselected_panel, #g_panel, #rect_panel, #circle_panel,' +
|
|
||||||
'#ellipse_panel, #line_panel, #text_panel, #image_panel, #container_panel,' +
|
|
||||||
' #use_panel, #a_panel').hide();
|
|
||||||
if (!isNullish(elem)) {
|
|
||||||
const elname = elem.nodeName;
|
|
||||||
// If this is a link with no transform and one child, pretend
|
|
||||||
// its child is selected
|
|
||||||
// if (elname === 'a') { // && !$(elem).attr('transform')) {
|
|
||||||
// elem = elem.firstChild;
|
|
||||||
// }
|
|
||||||
|
|
||||||
const angle = this.svgCanvas.getRotationAngle(elem);
|
|
||||||
$('#angle').val(angle);
|
|
||||||
|
|
||||||
const blurval = this.svgCanvas.getBlur(elem) * 10;
|
|
||||||
$id('blur').value = blurval;
|
|
||||||
|
|
||||||
if (this.svgCanvas.addedNew &&
|
|
||||||
elname === 'image' &&
|
|
||||||
this.svgCanvas.getMode() === 'image' &&
|
|
||||||
!this.svgCanvas.getHref(elem).startsWith('data:')) {
|
|
||||||
/* await */ this.promptImgURL({cancelDeletes: true});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isNode && currentMode !== 'pathedit') {
|
|
||||||
$('#selected_panel').show();
|
|
||||||
// Elements in this array already have coord fields
|
|
||||||
if (['line', 'circle', 'ellipse'].includes(elname)) {
|
|
||||||
$('#xy_panel').hide();
|
|
||||||
} else {
|
|
||||||
let x, y;
|
|
||||||
|
|
||||||
// Get BBox vals for g, polyline and path
|
|
||||||
if (['g', 'polyline', 'path'].includes(elname)) {
|
|
||||||
const bb = this.svgCanvas.getStrokedBBox([elem]);
|
|
||||||
if (bb) {
|
|
||||||
({x, y} = bb);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
x = elem.getAttribute('x');
|
|
||||||
y = elem.getAttribute('y');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (unit) {
|
|
||||||
x = convertUnit(x);
|
|
||||||
y = convertUnit(y);
|
|
||||||
}
|
|
||||||
|
|
||||||
$('#selected_x').val(x || 0);
|
|
||||||
$('#selected_y').val(y || 0);
|
|
||||||
$('#xy_panel').show();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Elements in this array cannot be converted to a path
|
|
||||||
$id('tool_topath').style.display = ['image', 'text', 'path', 'g', 'use'].includes(elname) ? 'none' : 'block';
|
|
||||||
$id('tool_reorient').style.display = (elname === 'path') ? 'block' : 'none';
|
|
||||||
$id('tool_reorient').disabled = (angle === 0);
|
|
||||||
} else {
|
|
||||||
const point = this.path.getNodePoint();
|
|
||||||
$('#tool_add_subpath').pressed = false;
|
|
||||||
$('#tool_node_delete').toggleClass('disabled', !this.path.canDeleteNodes);
|
|
||||||
|
|
||||||
// Show open/close button based on selected point
|
|
||||||
// setIcon('#tool_openclose_path', path.closed_subpath ? 'open_path' : 'close_path');
|
|
||||||
|
|
||||||
if (point) {
|
|
||||||
const segType = $('#seg_type');
|
|
||||||
if (unit) {
|
|
||||||
point.x = convertUnit(point.x);
|
|
||||||
point.y = convertUnit(point.y);
|
|
||||||
}
|
|
||||||
$('#path_node_x').val(point.x);
|
|
||||||
$('#path_node_y').val(point.y);
|
|
||||||
if (point.type) {
|
|
||||||
segType.val(point.type).removeAttr('disabled');
|
|
||||||
} else {
|
|
||||||
segType.val(4).attr('disabled', 'disabled');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// update contextual tools here
|
|
||||||
const panels = {
|
|
||||||
g: [],
|
|
||||||
a: [],
|
|
||||||
rect: ['rx', 'width', 'height'],
|
|
||||||
image: ['width', 'height'],
|
|
||||||
circle: ['cx', 'cy', 'r'],
|
|
||||||
ellipse: ['cx', 'cy', 'rx', 'ry'],
|
|
||||||
line: ['x1', 'y1', 'x2', 'y2'],
|
|
||||||
text: [],
|
|
||||||
use: []
|
|
||||||
};
|
|
||||||
|
|
||||||
const {tagName} = elem;
|
|
||||||
|
|
||||||
// if ($(elem).data('gsvg')) {
|
|
||||||
// $('#g_panel').show();
|
|
||||||
// }
|
|
||||||
|
|
||||||
let linkHref = null;
|
|
||||||
if (tagName === 'a') {
|
|
||||||
linkHref = this.svgCanvas.getHref(elem);
|
|
||||||
$('#g_panel').show();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (elem.parentNode.tagName === 'a' && !$(elem).siblings().length) {
|
|
||||||
$('#a_panel').show();
|
|
||||||
linkHref = this.svgCanvas.getHref(elem.parentNode);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hide/show the make_link buttons
|
|
||||||
$('#tool_make_link, #tool_make_link_multi').toggle(!linkHref);
|
|
||||||
|
|
||||||
if (linkHref) {
|
|
||||||
$('#link_url').val(linkHref);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (panels[tagName]) {
|
|
||||||
const curPanel = panels[tagName];
|
|
||||||
|
|
||||||
$('#' + tagName + '_panel').show();
|
|
||||||
|
|
||||||
curPanel.forEach((item) => {
|
|
||||||
let attrVal = elem.getAttribute(item);
|
|
||||||
if (this.editor.configObj.curConfig.baseUnit !== 'px' && elem[item]) {
|
|
||||||
const bv = elem[item].baseVal.value;
|
|
||||||
attrVal = convertUnit(bv);
|
|
||||||
}
|
|
||||||
$id(`${tagName}_${item}`).value = attrVal || 0;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (tagName === 'text') {
|
|
||||||
$('#text_panel').css('display', 'inline-block');
|
|
||||||
$('#tool_font_size').css('display', 'inline');
|
|
||||||
$id('tool_italic').pressed = this.svgCanvas.getItalic();
|
|
||||||
$id('tool_bold').pressed = this.svgCanvas.getBold();
|
|
||||||
$('#tool_font_family').val(elem.getAttribute('font-family'));
|
|
||||||
$('#font_size').val(elem.getAttribute('font-size'));
|
|
||||||
$('#text').val(elem.textContent);
|
|
||||||
const textAnchorStart = $id('tool_text_anchor_start');
|
|
||||||
const textAnchorMiddle = $id('tool_text_anchor_middle');
|
|
||||||
const textAnchorEnd = $id('tool_text_anchor_end');
|
|
||||||
switch (elem.getAttribute('text-anchor')) {
|
|
||||||
case 'start':
|
|
||||||
textAnchorStart.pressed = true;
|
|
||||||
textAnchorMiddle.pressed = false;
|
|
||||||
textAnchorEnd.pressed = false;
|
|
||||||
break;
|
|
||||||
case 'middle':
|
|
||||||
textAnchorStart.pressed = false;
|
|
||||||
textAnchorMiddle.pressed = true;
|
|
||||||
textAnchorEnd.pressed = false;
|
|
||||||
break;
|
|
||||||
case 'end':
|
|
||||||
textAnchorStart.pressed = false;
|
|
||||||
textAnchorMiddle.pressed = false;
|
|
||||||
textAnchorEnd.pressed = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (this.svgCanvas.addedNew) {
|
|
||||||
// Timeout needed for IE9
|
|
||||||
setTimeout(() => {
|
|
||||||
$('#text').focus().select();
|
|
||||||
}, 100);
|
|
||||||
}
|
|
||||||
// text
|
|
||||||
} else if (tagName === 'image' && this.svgCanvas.getMode() === 'image') {
|
|
||||||
this.svgCanvas.setImageURL(this.svgCanvas.getHref(elem));
|
|
||||||
// image
|
|
||||||
} else if (tagName === 'g' || tagName === 'use') {
|
|
||||||
$('#container_panel').show();
|
|
||||||
const title = this.svgCanvas.getTitle();
|
|
||||||
const label = $('#g_title')[0];
|
|
||||||
label.value = title;
|
|
||||||
setInputWidth(label);
|
|
||||||
$('#g_title').prop('disabled', tagName === 'use');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
menuItems.setAttribute((tagName === 'g' ? 'en' : 'dis') + 'ablemenuitems', '#ungroup');
|
|
||||||
menuItems.setAttribute(((tagName === 'g' || !this.multiselected) ? 'dis' : 'en') + 'ablemenuitems', '#group');
|
|
||||||
|
|
||||||
// if (!isNullish(elem))
|
|
||||||
} else if (this.multiselected) {
|
|
||||||
$('#multiselected_panel').show();
|
|
||||||
menuItems.setAttribute('enablemenuitems', '#group');
|
|
||||||
menuItems.setAttribute('disablemenuitems', '#ungroup');
|
|
||||||
} else {
|
|
||||||
menuItems.setAttribute('disablemenuitems', '#delete,#cut,#copy,#group,#ungroup,#move_front,#move_up,#move_down,#move_back');
|
|
||||||
}
|
|
||||||
|
|
||||||
// update history buttons
|
|
||||||
$id('tool_undo').disabled = (this.svgCanvas.undoMgr.getUndoStackSize() === 0);
|
|
||||||
$id('tool_redo').disabled = (this.svgCanvas.undoMgr.getRedoStackSize() === 0);
|
|
||||||
|
|
||||||
this.svgCanvas.addedNew = false;
|
|
||||||
|
|
||||||
if ((elem && !isNode) || this.multiselected) {
|
|
||||||
// update the selected elements' layer
|
|
||||||
$('#selLayerNames').removeAttr('disabled').val(currentLayerName);
|
|
||||||
|
|
||||||
// Enable regular menu options
|
|
||||||
const canCMenu = document.getElementById('se-cmenu_canvas');
|
|
||||||
canCMenu.setAttribute('enablemenuitems', '#delete,#cut,#copy,#move_front,#move_up,#move_down,#move_back');
|
|
||||||
} else {
|
|
||||||
$('#selLayerNames').attr('disabled', 'disabled');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @param {Event} [e] Not used.
|
|
||||||
* @param {boolean} forSaving
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
showSourceEditor (e, forSaving) {
|
|
||||||
const $editorDialog = document.getElementById('se-svg-editor-dialog');
|
|
||||||
if ($editorDialog.getAttribute('dialog') === 'open') return;
|
|
||||||
const origSource = this.svgCanvas.getSvgString();
|
|
||||||
$editorDialog.setAttribute('dialog', 'open');
|
|
||||||
$editorDialog.setAttribute('value', origSource);
|
|
||||||
$editorDialog.setAttribute('copysec', Boolean(forSaving));
|
|
||||||
$editorDialog.setAttribute('applysec', !forSaving);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
clickWireframe () {
|
|
||||||
$id('tool_wireframe').pressed = !$id('tool_wireframe').pressed;
|
|
||||||
this.editor.workarea.toggleClass('wireframe');
|
|
||||||
|
|
||||||
const wfRules = $('#wireframe_rules');
|
|
||||||
if (!wfRules.length) {
|
|
||||||
/* wfRules = */ $('<style id="wireframe_rules"></style>').appendTo('head');
|
|
||||||
} else {
|
|
||||||
wfRules.empty();
|
|
||||||
}
|
|
||||||
this.editor.updateWireFrame();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
clickUndo () {
|
|
||||||
const {undoMgr} = this.editor.svgCanvas;
|
|
||||||
if (undoMgr.getUndoStackSize() > 0) {
|
|
||||||
undoMgr.undo();
|
|
||||||
this.editor.layersPanel.populateLayers();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
clickRedo () {
|
|
||||||
const {undoMgr} = this.editor.svgCanvas;
|
|
||||||
if (undoMgr.getRedoStackSize() > 0) {
|
|
||||||
undoMgr.redo();
|
|
||||||
this.editor.layersPanel.populateLayers();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @type {module}
|
|
||||||
*/
|
|
||||||
changeRectRadius (e) {
|
|
||||||
this.svgCanvas.setRectRadius(e.target.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {module}
|
|
||||||
*/
|
|
||||||
changeFontSize (e) {
|
|
||||||
this.svgCanvas.setFontSize(e.target.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {module}
|
|
||||||
*/
|
|
||||||
changeRotationAngle (e) {
|
|
||||||
this.svgCanvas.setRotationAngle(e.target.value);
|
|
||||||
$('#tool_reorient').toggleClass('disabled', Number.parseInt(e.target.value) === 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {PlainObject} e
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
changeBlur (e) {
|
|
||||||
this.svgCanvas.setBlur(e.target.value / 10, true);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
clickGroup () {
|
|
||||||
// group
|
|
||||||
if (this.editor.multiselected) {
|
|
||||||
this.svgCanvas.groupSelectedElements();
|
|
||||||
// ungroup
|
|
||||||
} else if (this.editor.selectedElement) {
|
|
||||||
this.svgCanvas.ungroupSelectedElement();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
clickClone () {
|
|
||||||
this.svgCanvas.cloneSelectedElements(20, 20);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {PlainObject} evt
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
clickAlignEle (evt) {
|
|
||||||
this.svgCanvas.alignSelectedElements(evt.detail.value, 'page');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} pos indicate the alignment relative to top, bottom, middle etc..
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
clickAlign (pos) {
|
|
||||||
let value = $('#tool_align_relative').val();
|
|
||||||
if(value === ''){
|
|
||||||
value = 'selected';
|
|
||||||
}
|
|
||||||
this.svgCanvas.alignSelectedElements(pos, value);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @type {module}
|
|
||||||
*/
|
|
||||||
attrChanger (e) {
|
|
||||||
const attr = e.target.getAttribute('data-attr');
|
|
||||||
let val = e.target.value;
|
|
||||||
const valid = isValidUnit(attr, val, this.selectedElement);
|
|
||||||
|
|
||||||
if (!valid) {
|
|
||||||
e.target.value = this.selectedElement().getAttribute(attr);
|
|
||||||
// eslint-disable-next-line no-alert
|
|
||||||
alert(this.uiStrings.notification.invalidAttrValGiven);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (attr !== 'id' && attr !== 'class') {
|
|
||||||
if (isNaN(val)) {
|
|
||||||
val = this.svgCanvas.convertToNum(attr, val);
|
|
||||||
} else if (this.editor.configObj.curConfig.baseUnit !== 'px') {
|
|
||||||
// Convert unitless value to one with given unit
|
|
||||||
|
|
||||||
const unitData = getTypeMap();
|
|
||||||
|
|
||||||
if (this.selectedElement[attr] || this.svgCanvas.getMode() === 'pathedit' || attr === 'x' || attr === 'y') {
|
|
||||||
val *= unitData[this.editor.configObj.curConfig.baseUnit];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if the user is changing the id, then de-select the element first
|
|
||||||
// change the ID, then re-select it with the new ID
|
|
||||||
if (attr === 'id') {
|
|
||||||
const elem = this.selectedElement;
|
|
||||||
this.svgCanvas.clearSelection();
|
|
||||||
elem.id = val;
|
|
||||||
this.svgCanvas.addToSelection([elem], true);
|
|
||||||
} else {
|
|
||||||
this.svgCanvas.changeSelectedAttribute(attr, val);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
convertToPath () {
|
|
||||||
if (!isNullish(this.selectedElement)) {
|
|
||||||
this.svgCanvas.convertToPath();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
reorientPath () {
|
|
||||||
if (!isNullish(this.selectedElement)) {
|
|
||||||
this.path.reorient();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {void} Resolves to `undefined`
|
|
||||||
*/
|
|
||||||
makeHyperlink () {
|
|
||||||
if (!isNullish(this.selectedElement) || this.multiselected) {
|
|
||||||
// eslint-disable-next-line no-alert
|
|
||||||
const url = prompt(this.uiStrings.notification.enterNewLinkURL, 'http://');
|
|
||||||
if (url) {
|
|
||||||
this.svgCanvas.makeHyperlink(url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
linkControlPoints () {
|
|
||||||
const linked = $id('tool_node_link').pressed;
|
|
||||||
$id('tool_node_link').pressed = !linked;
|
|
||||||
this.path.linkControlPoints(linked);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
clonePathNode () {
|
|
||||||
if (this.path.getNodePoint()) {
|
|
||||||
this.path.clonePathNode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
deletePathNode () {
|
|
||||||
if (this.path.getNodePoint()) {
|
|
||||||
this.path.deletePathNode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
addSubPath () {
|
|
||||||
const button = $('#tool_add_subpath');
|
|
||||||
const sp = !button.hasClass('pressed');
|
|
||||||
button.pressed = sp;
|
|
||||||
// button.toggleClass('push_button_pressed tool_button');
|
|
||||||
this.path.addSubPath(sp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
opencloseSubPath () {
|
|
||||||
this.path.opencloseSubPath();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Delete is a contextual tool that only appears in the ribbon if
|
|
||||||
* an element has been selected.
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
deleteSelected () {
|
|
||||||
if (!isNullish(this.selectedElement) || this.multiselected) {
|
|
||||||
this.svgCanvas.deleteSelectedElements();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
moveToTopSelected () {
|
|
||||||
if (!isNullish(this.selectedElement)) {
|
|
||||||
this.svgCanvas.moveToTopSelectedElement();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
moveToBottomSelected () {
|
|
||||||
if (!isNullish(this.selectedElement)) {
|
|
||||||
this.svgCanvas.moveToBottomSelectedElement();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {false}
|
|
||||||
*/
|
|
||||||
clickBold () {
|
|
||||||
this.svgCanvas.setBold(!this.svgCanvas.getBold());
|
|
||||||
this.updateContextPanel();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {false}
|
|
||||||
*/
|
|
||||||
clickItalic () {
|
|
||||||
this.svgCanvas.setItalic(!this.svgCanvas.getItalic());
|
|
||||||
this.updateContextPanel();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param {string} value "start","end" or "middle"
|
|
||||||
* @returns {false}
|
|
||||||
*/
|
|
||||||
clickTextAnchor (value) {
|
|
||||||
this.svgCanvas.setTextAnchor(value);
|
|
||||||
this.updateContextPanel();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {module}
|
|
||||||
*/
|
|
||||||
init () {
|
|
||||||
// svg editor source dialoag added to DOM
|
|
||||||
const newSeEditorDialog = document.createElement('se-svg-source-editor-dialog');
|
|
||||||
newSeEditorDialog.setAttribute('id', 'se-svg-editor-dialog');
|
|
||||||
document.body.append(newSeEditorDialog);
|
|
||||||
// register action to top panel buttons
|
|
||||||
$id('tool_source').addEventListener('click', this.showSourceEditor.bind(this));
|
|
||||||
$id('tool_wireframe').addEventListener('click', this.clickWireframe.bind(this));
|
|
||||||
$id('tool_undo').addEventListener('click', this.clickUndo.bind(this));
|
|
||||||
$id('tool_redo').addEventListener('click', this.clickRedo.bind(this));
|
|
||||||
$id('tool_clone').addEventListener('click', this.clickClone.bind(this));
|
|
||||||
$id('tool_clone_multi').addEventListener('click', this.clickClone.bind(this));
|
|
||||||
$id('tool_delete').addEventListener('click', this.deleteSelected.bind(this));
|
|
||||||
$id('tool_delete_multi').addEventListener('click', this.deleteSelected.bind(this));
|
|
||||||
$id('tool_move_top').addEventListener('click', this.moveToTopSelected.bind(this));
|
|
||||||
$id('tool_move_bottom').addEventListener('click', this.moveToBottomSelected.bind(this));
|
|
||||||
$id('tool_topath').addEventListener('click', this.convertToPath.bind(this));
|
|
||||||
$id('tool_make_link').addEventListener('click', this.makeHyperlink.bind(this));
|
|
||||||
$id('tool_make_link_multi').addEventListener('click', this.makeHyperlink.bind(this));
|
|
||||||
$id('tool_reorient').addEventListener('click', this.reorientPath.bind(this));
|
|
||||||
$id('tool_group_elements').addEventListener('click', this.clickGroup.bind(this));
|
|
||||||
$id('tool_position').addEventListener('change', (evt) => this.clickAlignEle.bind(this)(evt));
|
|
||||||
$id('tool_align_left').addEventListener('click', () => this.clickAlign.bind(this)('left'));
|
|
||||||
$id('tool_align_right').addEventListener('click', () => this.clickAlign.bind(this)('right'));
|
|
||||||
$id('tool_align_center').addEventListener('click', () => this.clickAlign.bind(this)('center'));
|
|
||||||
$id('tool_align_top').addEventListener('click', () => this.clickAlign.bind(this)('top'));
|
|
||||||
$id('tool_align_bottom').addEventListener('click', () => this.clickAlign.bind(this)('bottom'));
|
|
||||||
$id('tool_align_middle').addEventListener('click', () => this.clickAlign.bind(this)('middle'));
|
|
||||||
$id('tool_node_clone').addEventListener('click', this.clonePathNode.bind(this));
|
|
||||||
$id('tool_node_delete').addEventListener('click', this.deletePathNode.bind(this));
|
|
||||||
$id('tool_openclose_path').addEventListener('click', this.opencloseSubPath.bind(this));
|
|
||||||
$id('tool_add_subpath').addEventListener('click', this.addSubPath.bind(this));
|
|
||||||
$id('tool_node_link').addEventListener('click', this.linkControlPoints.bind(this));
|
|
||||||
$id('angle').addEventListener('change', this.changeRotationAngle.bind(this));
|
|
||||||
$id('blur').addEventListener('change', this.changeBlur.bind(this));
|
|
||||||
$id('rect_rx').addEventListener('change', this.changeRectRadius.bind(this));
|
|
||||||
$id('font_size').addEventListener('change', this.changeFontSize.bind(this));
|
|
||||||
$id('tool_ungroup').addEventListener('click', this.clickGroup.bind(this));
|
|
||||||
$id('tool_bold').addEventListener('click', this.clickBold.bind(this));
|
|
||||||
$id('tool_italic').addEventListener('click', this.clickItalic.bind(this));
|
|
||||||
$id('tool_text_anchor_start').addEventListener('click', () => this.clickTextAnchor.bind(this)('start'));
|
|
||||||
$id('tool_text_anchor_middle').addEventListener('click', () => this.clickTextAnchor.bind(this)('middle'));
|
|
||||||
$id('tool_text_anchor_end').addEventListener('click', () => this.clickTextAnchor.bind(this)('end'));
|
|
||||||
$id('tool_unlink_use').addEventListener('click', this.clickGroup.bind(this));
|
|
||||||
$id('change_image_url').addEventListener('click', this.promptImgURL.bind(this));
|
|
||||||
// all top panel attributes
|
|
||||||
['elem_id', 'elem_class', 'circle_cx', 'circle_cy', 'circle_r', 'ellipse_cx',
|
|
||||||
'ellipse_cy', 'ellipse_rx', 'ellipse_ry', 'selected_x', 'selected_y', 'rect_width',
|
|
||||||
'rect_height', 'line_x1', 'line_x2', 'line_y2', 'image_width', 'image_height', 'path_node_x',
|
|
||||||
'path_node_y'].forEach((attrId) => $id(attrId).addEventListener('change', this.attrChanger.bind(this)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default TopPanelHandlers;
|
|
||||||
@@ -616,48 +616,10 @@ input[type=text] {
|
|||||||
overflow: visible;
|
overflow: visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*–––––––––––––––––––––––––––––––––––––*/
|
|
||||||
|
|
||||||
#option_lists ul {
|
|
||||||
display: none;
|
|
||||||
position: absolute;
|
|
||||||
height: auto;
|
|
||||||
z-index: 3;
|
|
||||||
margin: -10px;
|
|
||||||
list-style: none;
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#option_lists .optcols2 {
|
|
||||||
width: 70px;
|
|
||||||
margin-left: -15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#option_lists .optcols3 {
|
|
||||||
width: 90px;
|
|
||||||
margin-left: -31px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#option_lists .optcols4 {
|
|
||||||
width: 130px;
|
|
||||||
margin-left: -44px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#option_lists ul[class^=optcols] li {
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
ul li.current {
|
ul li.current {
|
||||||
background-color: #F4E284;
|
background-color: #F4E284;
|
||||||
}
|
}
|
||||||
|
|
||||||
#option_lists ul li {
|
|
||||||
margin: 0;
|
|
||||||
border-radius: 0;
|
|
||||||
-moz-border-radius: 0;
|
|
||||||
-webkit-border-radius: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#copyright {
|
#copyright {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
padding-right: .3em;
|
padding-right: .3em;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import {
|
|||||||
import * as draw from './draw.js';
|
import * as draw from './draw.js';
|
||||||
import * as pathModule from './path.js';
|
import * as pathModule from './path.js';
|
||||||
import * as hstry from './history.js';
|
import * as hstry from './history.js';
|
||||||
|
import {findPos} from '../editor/components/jgraduate/Util.js';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
InsertElementCommand
|
InsertElementCommand
|
||||||
@@ -1313,7 +1314,7 @@ export const DOMMouseScrollEvent = function (e) {
|
|||||||
|
|
||||||
eventContext_.setRootSctm($('#svgcontent g')[0].getScreenCTM().inverse());
|
eventContext_.setRootSctm($('#svgcontent g')[0].getScreenCTM().inverse());
|
||||||
|
|
||||||
const workarea = $('#workarea');
|
const workarea = document.getElementById('workarea');
|
||||||
const scrbar = 15;
|
const scrbar = 15;
|
||||||
const rulerwidth = eventContext_.getCurConfig().showRulers ? 16 : 0;
|
const rulerwidth = eventContext_.getCurConfig().showRulers ? 16 : 0;
|
||||||
|
|
||||||
@@ -1321,8 +1322,8 @@ export const DOMMouseScrollEvent = function (e) {
|
|||||||
const pt = transformPoint(evt.pageX, evt.pageY, eventContext_.getrootSctm());
|
const pt = transformPoint(evt.pageX, evt.pageY, eventContext_.getrootSctm());
|
||||||
|
|
||||||
// full work area width in screen pixels
|
// full work area width in screen pixels
|
||||||
const editorFullW = workarea.width();
|
const editorFullW = parseFloat(getComputedStyle(workarea, null).width.replace("px", ""));
|
||||||
const editorFullH = workarea.height();
|
const editorFullH = parseFloat(getComputedStyle(workarea, null).height.replace("px", ""));
|
||||||
|
|
||||||
// work area width minus scroll and ruler in screen pixels
|
// work area width minus scroll and ruler in screen pixels
|
||||||
const editorW = editorFullW - scrbar - rulerwidth;
|
const editorW = editorFullW - scrbar - rulerwidth;
|
||||||
@@ -1333,7 +1334,7 @@ export const DOMMouseScrollEvent = function (e) {
|
|||||||
const workareaViewH = editorH * eventContext_.getrootSctm().d;
|
const workareaViewH = editorH * eventContext_.getrootSctm().d;
|
||||||
|
|
||||||
// content offset from canvas in screen pixels
|
// content offset from canvas in screen pixels
|
||||||
const wOffset = workarea.offset();
|
const wOffset = findPos(workarea);
|
||||||
const wOffsetLeft = wOffset.left + rulerwidth;
|
const wOffsetLeft = wOffset.left + rulerwidth;
|
||||||
const wOffsetTop = wOffset.top + rulerwidth;
|
const wOffsetTop = wOffset.top + rulerwidth;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user