| | @@ -906,19 +906,20 @@ |
| 906 | 906 | }; |
| 907 | 907 | enum fileedit_render_modes { |
| 908 | 908 | /* GUESS must be 0. All others have unspecified values. */ |
| 909 | 909 | FE_RENDER_GUESS = 0, |
| 910 | 910 | FE_RENDER_PLAIN_TEXT, |
| 911 | | -FE_RENDER_HTML, |
| 911 | +FE_RENDER_HTML_IFRAME, |
| 912 | +FE_RENDER_HTML_INLINE, |
| 912 | 913 | FE_RENDER_WIKI |
| 913 | 914 | }; |
| 914 | 915 | |
| 915 | 916 | static int fileedit_render_mode_for_mimetype(const char * zMimetype){ |
| 916 | 917 | int rc = FE_RENDER_PLAIN_TEXT; |
| 917 | 918 | if( zMimetype ){ |
| 918 | 919 | if( fossil_strcmp(zMimetype, "text/html")==0 ){ |
| 919 | | - rc = FE_RENDER_HTML; |
| 920 | + rc = FE_RENDER_HTML_IFRAME; |
| 920 | 921 | }else if( fossil_strcmp(zMimetype, "text/x-fossil-wiki")==0 |
| 921 | 922 | || fossil_strcmp(zMimetype, "text/x-markdown")==0 ){ |
| 922 | 923 | rc = FE_RENDER_WIKI; |
| 923 | 924 | } |
| 924 | 925 | } |
| | @@ -936,20 +937,24 @@ |
| 936 | 937 | zMime = mimetype_from_name(zFilename); |
| 937 | 938 | if(FE_RENDER_GUESS==renderMode){ |
| 938 | 939 | renderMode = fileedit_render_mode_for_mimetype(zMime); |
| 939 | 940 | } |
| 940 | 941 | switch(renderMode){ |
| 941 | | - case FE_RENDER_HTML:{ |
| 942 | + case FE_RENDER_HTML_IFRAME:{ |
| 942 | 943 | char * z64 = encode64(blob_str(pContent), blob_size(pContent)); |
| 943 | 944 | CX("<iframe width='100%%' frameborder='0' " |
| 944 | 945 | "marginwidth='0' style='height:%dem' " |
| 945 | 946 | "marginheight='0' sandbox='allow-same-origin' " |
| 946 | 947 | "id='ifm1' src='data:text/html;base64,%z'" |
| 947 | 948 | "></iframe>", |
| 948 | 949 | nIframeHeightEm ? nIframeHeightEm : 40, |
| 949 | 950 | z64); |
| 950 | 951 | break; |
| 952 | + } |
| 953 | + case FE_RENDER_HTML_INLINE:{ |
| 954 | + CX("%b",pContent); |
| 955 | + break; |
| 951 | 956 | } |
| 952 | 957 | case FE_RENDER_WIKI: |
| 953 | 958 | wiki_render_by_mimetype(pContent, zMime); |
| 954 | 959 | break; |
| 955 | 960 | default:{ |
| | @@ -1590,14 +1595,11 @@ |
| 1590 | 1595 | CX("<div id='fileedit-tab-preview' " |
| 1591 | 1596 | "data-tab-parent='fileedit-tabs' " |
| 1592 | 1597 | "data-tab-label='Preview'" |
| 1593 | 1598 | ">"); |
| 1594 | 1599 | |
| 1595 | | - CX("<fieldset class='fileedit-options'>" |
| 1596 | | - "<legend>Preview...</legend><div>"); |
| 1597 | | - |
| 1598 | | - CX("<div class='preview-controls'>"); |
| 1600 | + CX("<div class='fileedit-options flex-container row'>"); |
| 1599 | 1601 | CX("<button>Refresh</button>"); |
| 1600 | 1602 | /* Default preview rendering mode selection... */ |
| 1601 | 1603 | previewRenderMode = fileedit_render_mode_for_mimetype(zFileMime); |
| 1602 | 1604 | style_select_list_int("select-preview-mode", |
| 1603 | 1605 | "preview_render_mode", |
| | @@ -1604,24 +1606,28 @@ |
| 1604 | 1606 | "Preview Mode", |
| 1605 | 1607 | "Preview mode format.", |
| 1606 | 1608 | previewRenderMode, |
| 1607 | 1609 | "Guess", FE_RENDER_GUESS, |
| 1608 | 1610 | "Wiki/Markdown", FE_RENDER_WIKI, |
| 1609 | | - "HTML (iframe)", FE_RENDER_HTML, |
| 1611 | + "HTML (iframe)", FE_RENDER_HTML_IFRAME, |
| 1612 | + "HTML (inline)", FE_RENDER_HTML_INLINE, |
| 1610 | 1613 | "Plain Text", FE_RENDER_PLAIN_TEXT, |
| 1611 | 1614 | NULL); |
| 1612 | 1615 | /* |
| 1613 | | - ** Set up a JS-side mapping of the FE_RENDER_xyz values. This is |
| 1616 | + ** Set up a JS-side mapping of the FE_RENDER_xyz values. This is |
| 1614 | 1617 | ** used for dynamically toggling certain UI components on and off. |
| 1615 | 1618 | */ |
| 1616 | 1619 | blob_appendf(&endScript, "fossil.page.previewModes={" |
| 1617 | 1620 | "guess: %d, %d: 'guess', wiki: %d, %d: 'wiki'," |
| 1618 | | - "html: %d, %d: 'html', text: %d, %d: 'text'" |
| 1621 | + "htmlIframe: %d, %d: 'htmlIframe', " |
| 1622 | + "htmlInline: %d, %d: 'htmlInline', " |
| 1623 | + "text: %d, %d: 'text'" |
| 1619 | 1624 | "};\n", |
| 1620 | 1625 | FE_RENDER_GUESS, FE_RENDER_GUESS, |
| 1621 | 1626 | FE_RENDER_WIKI, FE_RENDER_WIKI, |
| 1622 | | - FE_RENDER_HTML, FE_RENDER_HTML, |
| 1627 | + FE_RENDER_HTML_IFRAME, FE_RENDER_HTML_IFRAME, |
| 1628 | + FE_RENDER_HTML_INLINE, FE_RENDER_HTML_INLINE, |
| 1623 | 1629 | FE_RENDER_PLAIN_TEXT, FE_RENDER_PLAIN_TEXT); |
| 1624 | 1630 | /* Allow selection of HTML preview iframe height */ |
| 1625 | 1631 | previewHtmlHeight = atoi(PD("preview_html_ems","0")); |
| 1626 | 1632 | if(!previewHtmlHeight){ |
| 1627 | 1633 | previewHtmlHeight = 40; |
| | @@ -1641,11 +1647,11 @@ |
| 1641 | 1647 | "Add line numbers to plain-text previews?", |
| 1642 | 1648 | "1", |
| 1643 | 1649 | "If on, plain-text files (only) will get " |
| 1644 | 1650 | "line numbers added to the preview.", |
| 1645 | 1651 | P("preview_ln")!=0); |
| 1646 | | - CX("</div></fieldset>"/*.fileedit-options*/); |
| 1652 | + CX("</div>"/*.fileedit-options*/); |
| 1647 | 1653 | CX("<div id='fileedit-tab-preview-wrapper'></div>"); |
| 1648 | 1654 | CX("</div>"/*#fileedit-tab-preview*/); |
| 1649 | 1655 | } |
| 1650 | 1656 | |
| 1651 | 1657 | /****** Diff tab ******/ |
| | @@ -1652,18 +1658,20 @@ |
| 1652 | 1658 | { |
| 1653 | 1659 | CX("<div id='fileedit-tab-diff' " |
| 1654 | 1660 | "data-tab-parent='fileedit-tabs' " |
| 1655 | 1661 | "data-tab-label='Diff'" |
| 1656 | 1662 | ">"); |
| 1657 | | - CX("<div id='fileedit-tab-diff-buttons'>" |
| 1663 | + |
| 1664 | + CX("<div class='fileedit-options flex-container row' " |
| 1665 | + "id='fileedit-tab-diff-buttons'>" |
| 1658 | 1666 | "<button class='sbs'>Side-by-side</button>" |
| 1659 | 1667 | "<button class='unified'>Unified</button>" |
| 1660 | 1668 | "</div>"); |
| 1661 | 1669 | CX("<div id='fileedit-tab-diff-wrapper'>" |
| 1662 | 1670 | "Diffs will be shown here." |
| 1663 | 1671 | "</div>"); |
| 1664 | | - CX("</div>"); |
| 1672 | + CX("</div>"/*#fileedit-tab-diff*/); |
| 1665 | 1673 | } |
| 1666 | 1674 | |
| 1667 | 1675 | |
| 1668 | 1676 | /****** Commit ******/ |
| 1669 | 1677 | CX("<div id='fileedit-tab-commit' " |
| | @@ -1671,15 +1679,11 @@ |
| 1671 | 1679 | "data-tab-label='Commit'" |
| 1672 | 1680 | ">"); |
| 1673 | 1681 | |
| 1674 | 1682 | { |
| 1675 | 1683 | /******* Flags/options *******/ |
| 1676 | | - CX("<fieldset class='fileedit-options'>" |
| 1677 | | - "<legend>Options</legend><div>" |
| 1678 | | - /* Chrome does not sanely lay out multiple |
| 1679 | | - ** fieldset children after the <legend>, so |
| 1680 | | - ** a containing div is necessary. */); |
| 1684 | + CX("<div class='fileedit-options flex-container row'>"); |
| 1681 | 1685 | style_labeled_checkbox("cb-dry-run", |
| 1682 | 1686 | "dry_run", "Dry-run?", "1", |
| 1683 | 1687 | "In dry-run mode, the Save button performs " |
| 1684 | 1688 | "all work needed for saving but then rolls " |
| 1685 | 1689 | "back the transaction, and thus does not " |
| | @@ -1731,11 +1735,11 @@ |
| 1731 | 1735 | 100, |
| 1732 | 1736 | "100%", 100, "125%", 125, |
| 1733 | 1737 | "150%", 150, "175%", 175, |
| 1734 | 1738 | "200%", 200, NULL); |
| 1735 | 1739 | #endif |
| 1736 | | - CX("</div></fieldset>"/*checkboxes*/); |
| 1740 | + CX("</div>"/*checkboxes*/); |
| 1737 | 1741 | } |
| 1738 | 1742 | |
| 1739 | 1743 | { /******* Comment *******/ |
| 1740 | 1744 | CX("<fieldset class='fileedit-options'>" |
| 1741 | 1745 | "<legend>Message (required)</legend><div>"); |
| | @@ -1750,11 +1754,11 @@ |
| 1750 | 1754 | } |
| 1751 | 1755 | CX("</input>\n"); |
| 1752 | 1756 | CX("<div class='fileedit-hint'>Comments use the Fossil wiki markup " |
| 1753 | 1757 | "syntax.</div>\n"/*TODO: select for fossil/md/plain text*/); |
| 1754 | 1758 | CX("</div></fieldset>\n"/*commit comment*/); |
| 1755 | | - CX("<div>" |
| 1759 | + CX("<div class='flex-container row'>" |
| 1756 | 1760 | "<button id='fileedit-btn-commit'>Commit</button>" |
| 1757 | 1761 | "</div>\n"); |
| 1758 | 1762 | CX("<div id='fileedit-manifest'></div>\n"); |
| 1759 | 1763 | } |
| 1760 | 1764 | |
| 1761 | 1765 | |