Skip to content

Commit

Permalink
Attempt to fix block drag-and-drop by only allowing it on top-level b…
Browse files Browse the repository at this point in the history
…locks (children of `div[@id = 'content-body']`)
  • Loading branch information
namedgraph committed Jan 11, 2025
1 parent 9463256 commit f3411b5
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ exclude-result-prefixes="#all"

<!-- start dragging content (or its descendants) -->

<xsl:template match="div[ixsl:query-params()?mode = '&ldh;ContentMode'][@about][contains-token(@class, 'block')]/descendant-or-self::*" mode="ixsl:ondragstart">
<xsl:template match="div[@id = 'content-body']/div[ixsl:query-params()?mode = '&ldh;ContentMode'][@about][contains-token(@class, 'block')]/descendant-or-self::*" mode="ixsl:ondragstart">
<xsl:message>ixsl:ondragstart</xsl:message>
<xsl:message>exists(key('elements-by-class', 'map-canvas')): <xsl:value-of select="exists(key('elements-by-class', 'map-canvas'))"/></xsl:message>

Expand All @@ -289,18 +289,18 @@ exclude-result-prefixes="#all"

<!-- dragging content over other content -->

<xsl:template match="div[ixsl:query-params()?mode = '&ldh;ContentMode'][@about][contains-token(@class, 'block')][acl:mode() = '&acl;Write']" mode="ixsl:ondragover">
<xsl:template match="div[@id = 'content-body']/div[ixsl:query-params()?mode = '&ldh;ContentMode'][@about][contains-token(@class, 'block')][acl:mode() = '&acl;Write']" mode="ixsl:ondragover">
<xsl:sequence select="ixsl:call(ixsl:event(), 'preventDefault', [])"/>
<ixsl:set-property name="dataTransfer.dropEffect" select="'move'" object="ixsl:event()"/>
</xsl:template>

<!-- change the style of elements when content is dragged over them -->

<xsl:template match="div[ixsl:query-params()?mode = '&ldh;ContentMode'][@about][contains-token(@class, 'block')][acl:mode() = '&acl;Write']" mode="ixsl:ondragenter">
<xsl:template match="div[@id = 'content-body']/div[ixsl:query-params()?mode = '&ldh;ContentMode'][@about][contains-token(@class, 'block')][acl:mode() = '&acl;Write']" mode="ixsl:ondragenter">
<xsl:sequence select="ixsl:call(ixsl:get(., 'classList'), 'toggle', [ 'drag-over', true() ])[current-date() lt xs:date('2000-01-01')]"/>
</xsl:template>

<xsl:template match="div[ixsl:query-params()?mode = '&ldh;ContentMode'][@about][contains-token(@class, 'block')][acl:mode() = '&acl;Write']" mode="ixsl:ondragleave">
<xsl:template match="div[@id = 'content-body']/div[ixsl:query-params()?mode = '&ldh;ContentMode'][@about][contains-token(@class, 'block')][acl:mode() = '&acl;Write']" mode="ixsl:ondragleave">
<xsl:variable name="related-target" select="ixsl:get(ixsl:event(), 'relatedTarget')" as="element()?"/> <!-- the element drag entered (optional) -->

<!-- only remove class if the related target does not have this div as ancestor (is not its child) -->
Expand All @@ -311,7 +311,7 @@ exclude-result-prefixes="#all"

<!-- dropping content over other content -->

<xsl:template match="div[ixsl:query-params()?mode = '&ldh;ContentMode'][@about][contains-token(@class, 'block')][acl:mode() = '&acl;Write']" mode="ixsl:ondrop">
<xsl:template match="div[@id = 'content-body']/div[ixsl:query-params()?mode = '&ldh;ContentMode'][@about][contains-token(@class, 'block')][acl:mode() = '&acl;Write']" mode="ixsl:ondrop">
<xsl:sequence select="ixsl:call(ixsl:event(), 'preventDefault', [])"/>
<xsl:variable name="block-uri" select="@about" as="xs:anyURI?"/>
<xsl:variable name="drop-block-uri" select="ixsl:call(ixsl:get(ixsl:event(), 'dataTransfer'), 'getData', [ 'text/uri-list' ])" as="xs:anyURI"/>
Expand Down

0 comments on commit f3411b5

Please sign in to comment.