documenting code
This commit is contained in:
parent
1f19883455
commit
4a0f3f65a6
12 changed files with 69 additions and 27 deletions
|
@ -369,29 +369,38 @@ export const generatePartTransform = (x, y, rotate, flipX, flipY, part) => {
|
||||||
let scaleX = 1
|
let scaleX = 1
|
||||||
let scaleY = 1
|
let scaleY = 1
|
||||||
|
|
||||||
|
// move the part an additional offset so it ends up in the correct spot after flipping.
|
||||||
|
// it will scale around the part's 0, 0, which isn't always the top left, so we need to move it over so that 0,0 lines up with topRight + topLeft
|
||||||
if (flipX) {
|
if (flipX) {
|
||||||
|
xTotal += part.topLeft.x
|
||||||
|
xTotal += part.bottomRight.x
|
||||||
|
// reverse the x scale
|
||||||
scaleX = -1
|
scaleX = -1
|
||||||
xTotal += part.topLeft.x * 2 + part.width
|
|
||||||
}
|
}
|
||||||
if (flipY) {
|
if (flipY) {
|
||||||
|
yTotal += part.topLeft.y
|
||||||
|
yTotal += part.bottomRight.y
|
||||||
scaleY = -1
|
scaleY = -1
|
||||||
yTotal += part.topLeft.y * 2 + part.height
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add the scaling to the transforms
|
||||||
if (scaleX + scaleY < 2) {
|
if (scaleX + scaleY < 2) {
|
||||||
transforms.push(`scale(${scaleX} ${scaleY})`)
|
transforms.push(`scale(${scaleX} ${scaleY})`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rotate) {
|
if (rotate) {
|
||||||
|
// we can put the center as the rotation origin, so get the center
|
||||||
const center = {
|
const center = {
|
||||||
x: part.topLeft.x + part.width/2,
|
x: part.topLeft.x + part.width/2,
|
||||||
y: part.topLeft.y + part.height/2,
|
y: part.topLeft.y + part.height/2,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add the rotation around the center to the transforms
|
||||||
transforms.push(`rotate(${rotate} ${center.x} ${center.y})`)
|
transforms.push(`rotate(${rotate} ${center.x} ${center.y})`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xTotal > 0 || yTotal > 0) transforms.unshift(
|
// put the translation before any other transforms to avoid having to make complex calculations once the matrix has been rotated or scaled
|
||||||
|
if (xTotal !== 0 || yTotal !== 0) transforms.unshift(
|
||||||
`translate(${xTotal} ${yTotal})`
|
`translate(${xTotal} ${yTotal})`
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -7,20 +7,17 @@ import enNamespaces from "./next/en/index.mjs"
|
||||||
import esNamespaces from "./next/es/index.mjs"
|
import esNamespaces from "./next/es/index.mjs"
|
||||||
import frNamespaces from "./next/fr/index.mjs"
|
import frNamespaces from "./next/fr/index.mjs"
|
||||||
import nlNamespaces from "./next/nl/index.mjs"
|
import nlNamespaces from "./next/nl/index.mjs"
|
||||||
import ukNamespaces from "./next/uk/index.mjs"
|
|
||||||
|
|
||||||
export const de = deNamespaces
|
export const de = deNamespaces
|
||||||
export const en = enNamespaces
|
export const en = enNamespaces
|
||||||
export const es = esNamespaces
|
export const es = esNamespaces
|
||||||
export const fr = frNamespaces
|
export const fr = frNamespaces
|
||||||
export const nl = nlNamespaces
|
export const nl = nlNamespaces
|
||||||
export const uk = ukNamespaces
|
|
||||||
|
|
||||||
export const languages = {
|
export const languages = {
|
||||||
de: "Deutsch",
|
de: "Deutsch",
|
||||||
en: "English",
|
en: "English",
|
||||||
es: "Español",
|
es: "Español",
|
||||||
fr: "Français",
|
fr: "Français",
|
||||||
nl: "Nederlands",
|
nl: "Nederlands"
|
||||||
uk: "undefined"
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@ const settings = {
|
||||||
"advanced.d": "Legt fest, ob erweiterte Einstellungen und Schnittmusteroptionen angezeigt werden sollen oder nicht",
|
"advanced.d": "Legt fest, ob erweiterte Einstellungen und Schnittmusteroptionen angezeigt werden sollen oder nicht",
|
||||||
"paperless.t": "Papierlos",
|
"paperless.t": "Papierlos",
|
||||||
"paperless.d": "Zeichnet ein Schnittmuster mit allen benötigten Dimensionen, sodass es direkt auf den Stoff oder ein anderes Medium übertragen werden kann, ohne es auszudrucken",
|
"paperless.d": "Zeichnet ein Schnittmuster mit allen benötigten Dimensionen, sodass es direkt auf den Stoff oder ein anderes Medium übertragen werden kann, ohne es auszudrucken",
|
||||||
|
"sabool.t": "Include seam allowance",
|
||||||
|
"sabool.d": "Controls whether or not to include seam allowance in your pattern",
|
||||||
"sa.t": "Nahtzugabe",
|
"sa.t": "Nahtzugabe",
|
||||||
"sa.d": "Steuert die Breite der Nahtzugabe, die in deinem Schnittmuster enthalten ist",
|
"sa.d": "Steuert die Breite der Nahtzugabe, die in deinem Schnittmuster enthalten ist",
|
||||||
"locale.t": "Sprache",
|
"locale.t": "Sprache",
|
||||||
|
|
|
@ -7,7 +7,9 @@ const settings = {
|
||||||
"advanced.d": "Controls whether or not to display advanced settings and pattern options",
|
"advanced.d": "Controls whether or not to display advanced settings and pattern options",
|
||||||
"paperless.t": "Paperless",
|
"paperless.t": "Paperless",
|
||||||
"paperless.d": "Drafts a pattern with all dimensions included so you can transfer it on fabric or another medium without the need to print",
|
"paperless.d": "Drafts a pattern with all dimensions included so you can transfer it on fabric or another medium without the need to print",
|
||||||
"sa.t": "Seam allowance",
|
"sabool.t": "Include seam allowance",
|
||||||
|
"sabool.d": "Controls whether or not to include seam allowance in your pattern",
|
||||||
|
"sa.t": "Seam allowance size",
|
||||||
"sa.d": "Controls the amount of seam allowance included in your pattern",
|
"sa.d": "Controls the amount of seam allowance included in your pattern",
|
||||||
"locale.t": "Language",
|
"locale.t": "Language",
|
||||||
"locale.d": "Determines the language used on your pattern",
|
"locale.d": "Determines the language used on your pattern",
|
||||||
|
|
|
@ -7,6 +7,8 @@ const settings = {
|
||||||
"advanced.d": "Controla si mostrar o no la configuración avanzada y las opciones de patrón",
|
"advanced.d": "Controla si mostrar o no la configuración avanzada y las opciones de patrón",
|
||||||
"paperless.t": "Sin papel",
|
"paperless.t": "Sin papel",
|
||||||
"paperless.d": "Dibuja un patrón con todas las dimensiones incluidas para que puedas transferirlo sobre tela u otro medio sin la necesidad de imprimir",
|
"paperless.d": "Dibuja un patrón con todas las dimensiones incluidas para que puedas transferirlo sobre tela u otro medio sin la necesidad de imprimir",
|
||||||
|
"sabool.t": "Include seam allowance",
|
||||||
|
"sabool.d": "Controls whether or not to include seam allowance in your pattern",
|
||||||
"sa.t": "Margen de costura",
|
"sa.t": "Margen de costura",
|
||||||
"sa.d": "Controla la cantidad de margen de costura incluido en tu patrón",
|
"sa.d": "Controla la cantidad de margen de costura incluido en tu patrón",
|
||||||
"locale.t": "Idioma",
|
"locale.t": "Idioma",
|
||||||
|
|
|
@ -7,6 +7,8 @@ const settings = {
|
||||||
"advanced.d": "Permet d'afficher ou non les paramètres avancés et les options de patron",
|
"advanced.d": "Permet d'afficher ou non les paramètres avancés et les options de patron",
|
||||||
"paperless.t": "Sans papier",
|
"paperless.t": "Sans papier",
|
||||||
"paperless.d": "Dessine un patron avec toutes les dimensions incluses afin que vous puissiez le transférer sur du tissu ou un autre support sans avoir à imprimer",
|
"paperless.d": "Dessine un patron avec toutes les dimensions incluses afin que vous puissiez le transférer sur du tissu ou un autre support sans avoir à imprimer",
|
||||||
|
"sabool.t": "Include seam allowance",
|
||||||
|
"sabool.d": "Controls whether or not to include seam allowance in your pattern",
|
||||||
"sa.t": "Marge de couture",
|
"sa.t": "Marge de couture",
|
||||||
"sa.d": "Contrôle la valeur de la marge de couture incluse dans votre patron",
|
"sa.d": "Contrôle la valeur de la marge de couture incluse dans votre patron",
|
||||||
"locale.t": "Langue",
|
"locale.t": "Langue",
|
||||||
|
|
|
@ -7,6 +7,8 @@ const settings = {
|
||||||
"advanced.d": "Bepaalt of de geavanceerde patroonopties wel of niet getoond worden",
|
"advanced.d": "Bepaalt of de geavanceerde patroonopties wel of niet getoond worden",
|
||||||
"paperless.t": "Papierloos",
|
"paperless.t": "Papierloos",
|
||||||
"paperless.d": "Hiermee tekent u een patroon met alle afmetingen zodat u het op stof of een ander medium kunt overbrengen zonder dat u het hoeft af te drukken",
|
"paperless.d": "Hiermee tekent u een patroon met alle afmetingen zodat u het op stof of een ander medium kunt overbrengen zonder dat u het hoeft af te drukken",
|
||||||
|
"sabool.t": "Include seam allowance",
|
||||||
|
"sabool.d": "Controls whether or not to include seam allowance in your pattern",
|
||||||
"sa.t": "Naadtoeslag",
|
"sa.t": "Naadtoeslag",
|
||||||
"sa.d": "Bepaalt de hoeveelheid naadtoeslag die is inbegrepen in uw patroon",
|
"sa.d": "Bepaalt de hoeveelheid naadtoeslag die is inbegrepen in uw patroon",
|
||||||
"locale.t": "Taal",
|
"locale.t": "Taal",
|
||||||
|
|
|
@ -5,9 +5,15 @@ import Part from './part'
|
||||||
import { TransformWrapper, TransformComponent } from "react-zoom-pan-pinch"
|
import { TransformWrapper, TransformComponent } from "react-zoom-pan-pinch"
|
||||||
|
|
||||||
const Draft = props => {
|
const Draft = props => {
|
||||||
const { patternProps, gist, updateGist, app, bgProps={}, fitLayoutPart = false, layoutType="printLayout"} = props
|
const { draft, patternProps, gist, updateGist, app, bgProps={}, fitLayoutPart = false, layoutType="printingLayout"} = props
|
||||||
|
|
||||||
|
// keep a fresh copy of the layout because we might manipulate it without saving to the gist
|
||||||
|
let layout = draft.settings.layout === true ? {
|
||||||
|
...patternProps.autoLayout,
|
||||||
|
width: patternProps.width,
|
||||||
|
height: patternProps.height
|
||||||
|
} : {...draft.settings.layout}
|
||||||
|
|
||||||
let layout = {...props.layout}
|
|
||||||
const svgRef = useRef(null);
|
const svgRef = useRef(null);
|
||||||
|
|
||||||
if (!patternProps) return null
|
if (!patternProps) return null
|
||||||
|
@ -43,7 +49,7 @@ const Draft = props => {
|
||||||
if (history) {
|
if (history) {
|
||||||
updateGist(['layouts', layoutType], newLayout, history)
|
updateGist(['layouts', layoutType], newLayout, history)
|
||||||
} else {
|
} else {
|
||||||
// we don't put it in the gist if it shouldn't contribute to history because we need some the data calculated here for rendering purposes on the initial layout, but we don't want to actually save a layout until the user manipulates it
|
// we don't put it in the gist if it shouldn't contribute to history because we need some of the data calculated here for rendering purposes on the initial layout, but we don't want to actually save a layout until the user manipulates it. This is what allows the layout to respond appropriately to settings changes. Once the user has starting playing with the layout, all bets are off
|
||||||
layout = newLayout
|
layout = newLayout
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,7 @@ const Part = props => {
|
||||||
|
|
||||||
// update the layout on mount
|
// update the layout on mount
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
// only update if there's a rendered part and it's not the pages or fabric part
|
||||||
if (partRef.current && !props.isLayoutPart) {
|
if (partRef.current && !props.isLayoutPart) {
|
||||||
updateLayout(false)
|
updateLayout(false)
|
||||||
}
|
}
|
||||||
|
@ -77,6 +78,7 @@ const Part = props => {
|
||||||
|
|
||||||
// Initialize drag handler
|
// Initialize drag handler
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
// don't drag the pages
|
||||||
if (props.isLayoutPart) return
|
if (props.isLayoutPart) return
|
||||||
handleDrag(select(partRef.current))
|
handleDrag(select(partRef.current))
|
||||||
}, [rotate, partRef, partLayout])
|
}, [rotate, partRef, partLayout])
|
||||||
|
@ -124,6 +126,7 @@ const Part = props => {
|
||||||
|
|
||||||
if (rotate) {
|
if (rotate) {
|
||||||
let newRotation = getRotation(event);
|
let newRotation = getRotation(event);
|
||||||
|
// shift key to snap the rotation
|
||||||
if (event.sourceEvent.shiftKey) {
|
if (event.sourceEvent.shiftKey) {
|
||||||
newRotation = Math.ceil(newRotation/15) * 15
|
newRotation = Math.ceil(newRotation/15) * 15
|
||||||
}
|
}
|
||||||
|
@ -138,41 +141,53 @@ const Part = props => {
|
||||||
translateY = event.y
|
translateY = event.y
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// a drag happened, so we should update the layout when we're done
|
||||||
didDrag = true;
|
didDrag = true;
|
||||||
setTransforms()
|
setTransforms()
|
||||||
})
|
})
|
||||||
.on('end', function(event) {
|
.on('end', function(event) {
|
||||||
// save to gist
|
// save to gist if anything actually changed
|
||||||
if (didDrag) updateLayout()
|
if (didDrag) updateLayout()
|
||||||
|
|
||||||
didDrag = false
|
didDrag = false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/** reset the part's transforms */
|
||||||
const resetPart = (event) => {
|
const resetPart = (event) => {
|
||||||
rotation = 0
|
rotation = 0
|
||||||
flipX = 0
|
flipX = 0
|
||||||
flipY = 0
|
flipY = 0
|
||||||
updateLayout()
|
updateLayout()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** toggle between dragging and rotating */
|
||||||
const toggleDragRotate = () => {
|
const toggleDragRotate = () => {
|
||||||
|
// only respond if the part should be able to drag/rotate
|
||||||
if (!partRef.current || props.isLayoutPart) {return}
|
if (!partRef.current || props.isLayoutPart) {return}
|
||||||
updateLayout()
|
|
||||||
setRotate(!rotate)
|
setRotate(!rotate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** update the layout either locally or in the gist */
|
||||||
const updateLayout = (history=true) => {
|
const updateLayout = (history=true) => {
|
||||||
|
/** don't mess with what we don't lay out */
|
||||||
if (!partRef.current || props.isLayoutPart) return
|
if (!partRef.current || props.isLayoutPart) return
|
||||||
|
|
||||||
|
// set the transforms on the part in order to calculate from the latest position
|
||||||
setTransforms()
|
setTransforms()
|
||||||
|
|
||||||
|
// get the bounding box and the svg's current transform matrix
|
||||||
const partRect = innerRef.current.getBoundingClientRect();
|
const partRect = innerRef.current.getBoundingClientRect();
|
||||||
const matrix = innerRef.current.ownerSVGElement.getScreenCTM().inverse();
|
const matrix = innerRef.current.ownerSVGElement.getScreenCTM().inverse();
|
||||||
|
|
||||||
|
// a function to convert dom space to svg space
|
||||||
const domToSvg = (point) => DOMPointReadOnly.fromPoint(point).matrixTransform(matrix)
|
const domToSvg = (point) => DOMPointReadOnly.fromPoint(point).matrixTransform(matrix)
|
||||||
|
|
||||||
// include the new top left and bottom right to ease calculating the pattern width and height
|
// include the new top left and bottom right to ease calculating the pattern width and height
|
||||||
const tl = domToSvg({x: partRect.left, y: partRect.top});
|
const tl = domToSvg({x: partRect.left, y: partRect.top});
|
||||||
const br = domToSvg({x: partRect.right, y: props.isLayoutPart ? 0 : partRect.bottom});
|
const br = domToSvg({x: partRect.right, y: props.isLayoutPart ? 0 : partRect.bottom});
|
||||||
|
|
||||||
|
// update it on the draft component
|
||||||
props.updateLayout(partName, {
|
props.updateLayout(partName, {
|
||||||
move: {
|
move: {
|
||||||
x: translateX,
|
x: translateX,
|
||||||
|
@ -186,13 +201,14 @@ const Part = props => {
|
||||||
}, history)
|
}, history)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method to flip (mirror) the part along the X or Y axis
|
/** Method to flip (mirror) the part along the X or Y axis */
|
||||||
const flip = axis => {
|
const flip = axis => {
|
||||||
if (axis === 'x') flipX = !flipX
|
if (axis === 'x') flipX = !flipX
|
||||||
else flipY = !flipY
|
else flipY = !flipY
|
||||||
updateLayout()
|
updateLayout()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** method to rotate 90 degrees */
|
||||||
const rotate90 = (direction = 1) => {
|
const rotate90 = (direction = 1) => {
|
||||||
if (flipX) direction *= -1
|
if (flipX) direction *= -1
|
||||||
if (flipY) direction *= -1
|
if (flipY) direction *= -1
|
||||||
|
@ -202,6 +218,7 @@ const Part = props => {
|
||||||
updateLayout()
|
updateLayout()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// don't render if the part is empty
|
||||||
if (Object.keys(part.snippets).length === 0 && Object.keys(part.paths).length === 0) return null;
|
if (Object.keys(part.snippets).length === 0 && Object.keys(part.paths).length === 0) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
import { useEffect, useRef } from 'react'
|
import { useEffect } from 'react'
|
||||||
import { useTranslation } from 'next-i18next'
|
import { useTranslation } from 'next-i18next'
|
||||||
import Settings from './settings'
|
import Settings from './settings'
|
||||||
import Draft from '../draft/index'
|
import Draft from '../draft/index'
|
||||||
import pluginBuilder from './plugin'
|
import pluginBuilder from './plugin'
|
||||||
|
|
||||||
const PrintLayout = props => {
|
const PrintLayout = props => {
|
||||||
|
// disable xray
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.gist?._state?.xray?.enabled) props.updateGist(
|
if (props.gist?._state?.xray?.enabled) props.updateGist(
|
||||||
['_state', 'xray', 'enabled'],
|
['_state', 'xray', 'enabled'],
|
||||||
|
@ -15,20 +16,18 @@ const PrintLayout = props => {
|
||||||
const { t } = useTranslation(['workbench'])
|
const { t } = useTranslation(['workbench'])
|
||||||
|
|
||||||
const draft = props.draft
|
const draft = props.draft
|
||||||
|
// add the pages plugin to the draft
|
||||||
draft.use(pluginBuilder(
|
draft.use(pluginBuilder(
|
||||||
props.gist?._state?.layout?.forPrinting?.page?.size,
|
props.gist?._state?.layout?.forPrinting?.page?.size,
|
||||||
props.gist?._state?.layout?.forPrinting?.page?.orientation,
|
props.gist?._state?.layout?.forPrinting?.page?.orientation,
|
||||||
))
|
))
|
||||||
|
|
||||||
let patternProps
|
let patternProps
|
||||||
let layout
|
let layout
|
||||||
try {
|
try {
|
||||||
|
// draft the pattern
|
||||||
draft.draft()
|
draft.draft()
|
||||||
patternProps = draft.getRenderProps()
|
patternProps = draft.getRenderProps()
|
||||||
layout = draft.settings.layout === true ? {
|
|
||||||
...patternProps.autoLayout,
|
|
||||||
width: patternProps.width,
|
|
||||||
height: patternProps.height
|
|
||||||
} : draft.settings.layout
|
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
console.log(err, props.gist)
|
console.log(err, props.gist)
|
||||||
}
|
}
|
||||||
|
@ -54,7 +53,6 @@ const PrintLayout = props => {
|
||||||
bgProps={bgProps}
|
bgProps={bgProps}
|
||||||
gistReady={props.gistReady}
|
gistReady={props.gistReady}
|
||||||
layoutPart="pages"
|
layoutPart="pages"
|
||||||
layout={layout}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
|
@ -26,7 +26,7 @@ const PrintLayoutSettings = props => {
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
key="reset"
|
key="reset"
|
||||||
onClick={() => props.unsetGist(['layouts', 'printLayout'])}
|
onClick={() => props.unsetGist(['layouts', 'printingLayout'])}
|
||||||
className="btn btn-primary btn-outline"
|
className="btn btn-primary btn-outline"
|
||||||
>
|
>
|
||||||
<ClearIcon className="h-6 w-6 mr-2"/>
|
<ClearIcon className="h-6 w-6 mr-2"/>
|
||||||
|
|
|
@ -16,7 +16,7 @@ import GistAsJson from 'shared/components/workbench/json.js'
|
||||||
import GistAsYaml from 'shared/components/workbench/yaml.js'
|
import GistAsYaml from 'shared/components/workbench/yaml.js'
|
||||||
import DraftEvents from 'shared/components/workbench/events.js'
|
import DraftEvents from 'shared/components/workbench/events.js'
|
||||||
import CutLayout from 'shared/components/workbench/layout/cut'
|
import CutLayout from 'shared/components/workbench/layout/cut'
|
||||||
import PrintLayout from 'shared/components/workbench/layout/print'
|
import PrintingLayout from 'shared/components/workbench/layout/print'
|
||||||
|
|
||||||
import ErrorBoundary from 'shared/components/error/error-boundary';
|
import ErrorBoundary from 'shared/components/error/error-boundary';
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ const views = {
|
||||||
measurements: Measurements,
|
measurements: Measurements,
|
||||||
draft: LabDraft,
|
draft: LabDraft,
|
||||||
test: LabSample,
|
test: LabSample,
|
||||||
printingLayout: PrintLayout,
|
printingLayout: PrintingLayout,
|
||||||
cuttingLayout: CutLayout,
|
cuttingLayout: CutLayout,
|
||||||
export: ExportDraft,
|
export: ExportDraft,
|
||||||
events: DraftEvents,
|
events: DraftEvents,
|
||||||
|
@ -90,7 +90,6 @@ const WorkbenchWrapper = ({ app, design, preload=false, from=false, layout=false
|
||||||
|
|
||||||
// Helper methods to manage the gist state
|
// Helper methods to manage the gist state
|
||||||
const updateWBGist = useMemo(() => (path, value, closeNav=false, addToHistory=true) => {
|
const updateWBGist = useMemo(() => (path, value, closeNav=false, addToHistory=true) => {
|
||||||
console.warn('updating gist')
|
|
||||||
updateGist(path, value, addToHistory)
|
updateGist(path, value, addToHistory)
|
||||||
// Force close of menu on mobile if it is open
|
// Force close of menu on mobile if it is open
|
||||||
if (closeNav && app.primaryMenu) app.setPrimaryMenu(false)
|
if (closeNav && app.primaryMenu) app.setPrimaryMenu(false)
|
||||||
|
@ -111,12 +110,18 @@ const WorkbenchWrapper = ({ app, design, preload=false, from=false, layout=false
|
||||||
// don't do anything until the gist is ready
|
// don't do anything until the gist is ready
|
||||||
if (!gistReady) {return null}
|
if (!gistReady) {return null}
|
||||||
|
|
||||||
// Generate the draft here so we can pass it down
|
// Generate the draft here so we can pass it down to both the view and the options menu
|
||||||
let draft = false
|
let draft = false
|
||||||
if (['draft', 'events', 'test', 'printingLayout'].indexOf(gist._state?.view) !== -1) {
|
if (['draft', 'events', 'test', 'printingLayout'].indexOf(gist._state?.view) !== -1) {
|
||||||
const layout = (gist._state.view === 'printingLayout' && gist.layouts?.printLayout) || gist.layout || true
|
// get the appropriate layout for the view
|
||||||
|
const layout = gist.layouts?.[gist._state.view] || gist.layout || true
|
||||||
|
// hand it separately to the design
|
||||||
draft = new design({...gist, layout})
|
draft = new design({...gist, layout})
|
||||||
|
|
||||||
|
// add theme to svg renderer
|
||||||
if (gist.renderer === 'svg') draft.use(theme)
|
if (gist.renderer === 'svg') draft.use(theme)
|
||||||
|
|
||||||
|
// draft it for draft and event views. Other views may add plugins, etc and we don't want to draft twice
|
||||||
try {
|
try {
|
||||||
if (['draft', 'events'].indexOf(gist._state.view) > -1) draft.draft()
|
if (['draft', 'events'].indexOf(gist._state.view) > -1) draft.draft()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue